Correct some Xbrowse Bugs

Correct some Xbrowse Bugs

Postby Silvio » Fri Apr 24, 2009 9:12 am

There was bugs on savestate and restore state because if you used Multiheader not saved it on state string
now I correct it !!!
sample :
1:80:Codice:S:1;2:250:Descrizione voce:S:1;3:50:Fila:S:1;
the last parameter is the nheadertype parameter
I sent this modifies to Antonio
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: Correct some Xbrowse Bugs

Postby Silvio » Tue Apr 28, 2009 10:42 am

I FORGET to insert the source code


Code: Select all  Expand view
//----------------------------------------------------------------------------//

METHOD SaveState() CLASS TXBrowse

   local oCol
   local cState
   local nFor, nLen

   nLen   := Len( ::aCols )
   cState := Ltrim( Str( ::nRowHeight ) ) + ";"

   for nFor := 1 to nLen
      oCol   := ::aCols[ nFor ]
      cState += Ltrim( Str( oCol:nCreationOrder ) ) + ":" +;
                Ltrim( str( oCol:nWidth ) ) + ":" +;
                oCol:cHeader + ":" +;
                iif(oCol:lHide, "H", "S") + ":" +;
                Ltrim( str( oCol:nHeaderType ) )   // salvo il tipo di header
      if nFor < nLen
         cState += ";"
      endif
   next

return cState

//----------------------------------------------------------------------------//

METHOD RestoreState( cState ) CLASS TXBrowse

   local oCol
   local aMoved, aNaturalOrder
   local cCol
   local nLen, nOrder, nWidth, nFor, nAt, nHeight
   local lHide,cHeader,j

   if Empty( cState )
      return nil
   endif

   aMoved := {}
   aNaturalOrder := {}
   nLen   := Len( ::aCols )

   nHeight := Val(StrToken( cState, 1, ";" ) )

   if Empty( ::nRowHeight )
      return nil
   endif

   // Check integrity

   for nFor := 1 to nLen
      cCol := StrToken( cState, nFor + 1, ";" )
      if Empty( cCol )
         return nil
      endif
      aadd( aNaturalOrder, nFor )
   next

   ::nRowHeight := nHeight

   for nFor := 1 to nLen
      cCol   := StrToken( cState, nFor + 1, ";" )
      nOrder := Val( StrToken( cCol, 1, ":" ) )
      nWidth := Val( StrToken( cCol, 2, ":" ) )
      cHeader :=  StrToken( cCol, 3, ":" )
      lHide  := ( AllTrim( StrToken( cCol, 4, ":" ) ) == "H" )
      nHeaderType  :=  StrToken( cCol, 5, ":" )
      nAt := Ascan( ::aCols, {|v| v:nCreationOrder == nOrder } )
      if nAt > 0
         oCol := ::aCols[ nAt ]
         oCol:lHide  := lHide
         oCol:nWidth := nWidth
         oCol:cHeader := cHeader
         oCol: nHeaderType :=nHeaderType   // restore tipo di header
      endif
      if nOrder != nFor
         if nOrder != aNaturalOrder[ nFor ] .and. ( nAt := Ascan( aNaturalOrder, nOrder ) ) != 0
         ::SwapCols( nFor, nAt, .f. )
         aNaturalOrder[ nFor ]:= nOrder
         aNaturalOrder[ nAt ]:= nFor
        endif
      endif
   next

   ::GetDisplayCols()
   ::Super:Refresh()

return nil

//----------------------------------------------------------------------------//
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: nageswaragunupudi and 37 guests