TWBrowse GoLeft() [Solved]

Post Reply
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

TWBrowse GoLeft() [Solved]

Post by Enrico Maria Giordano »

This is the sample:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oWnd, oBrw

    USE TEST

    DEFINE WINDOW oWnd

    @ 0, 0 LISTBOX oBrw FIELDS

    oBrw:lCellStyle = .T.

    oWnd:oClient = oBrw

    ACTIVATE WINDOW oWnd;
             MAXIMIZED

    CLOSE

    RETURN NIL
Try to:

- move the hilight to a column near the right side of the browse

- restore the window (click the button near the right-top X)

- move the now invisible hilight to the left

You should get an error.

EMG
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Enrico,

I confirm it with Aug 2006 build. I'm surprized nobody has reported it sooner.

James
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

This seems as a possible fix:

Code: Select all

METHOD ReSize( nSizeType, nWidth, nHeight ) CLASS TWBrowse

   local nTotalSize := 0

   ::nRowPos = Min( ::nRowPos, Max( ::nRowCount(), 1 ) )
   ::nColAct = Min( ::nColAct, AScan( ::GetColSizes(),;
                                      { | nSize | nTotalSize += nSize,;
                                      nWidth < nTotalSize }, ::nColPos ) )

return Super:ReSize( nSizeType, nWidth, nHeight )
and in function wbrwline():

Code: Select all

   ...
   nColPos = Max( nColPos, 1 )  // new!

   for n := nColPos to Len( aValues )
      nLeft   = nColStart + 1
      nRight  = Min( nColStart := ( nLeft + aColSizes[ n ] - 1 ), nWidth )
      if nLeft > nWidth
         exit
      endif
      if n >= Len( aValues ) // changed!
         nRight = nWidth
      endif
      ...
though is this the desirable behavior ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Antonio Linares wrote:This seems as a possible fix:
Thank you.
Antonio Linares wrote:though is this the desirable behavior ?
Yes, it is similar to the vertical resize behavior. But there is one more problem: the horizontal scrollbar is not correctly updated. Can you fix that too?

EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Enrico,

Horizontal scrollbar updated:

Code: Select all

METHOD ReSize( nSizeType, nWidth, nHeight ) CLASS TWBrowse

   local nTotalSize := 0

   ::nRowPos = Min( ::nRowPos, Max( ::nRowCount(), 1 ) )
   ::nColAct = Min( ::nColAct, AScan( ::GetColSizes(),;
                                      { | nSize | nTotalSize += nSize,;
                                      nWidth < nTotalSize }, ::nColPos ) )
   if ::oHScroll != nil
      ::oHScroll:SetPos( ::nColAct )
   endif

return Super:ReSize( nSizeType, nWidth, nHeight )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Unfortunately there is still a bug:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oWnd, oBrw

    DBCREATE( "BUGTEST", { { "TEST1", "C", 10, 0 },;
                           { "TEST2", "C", 10, 0 } } )

    USE BUGTEST

    APPEND BLANK

    DEFINE WINDOW oWnd

    @ 0, 0 LISTBOX oBrw FIELDS

    oBrw:lCellStyle = .T.

    oWnd:oClient = oBrw

    ACTIVATE WINDOW oWnd;
             MAXIMIZED

    CLOSE

    RETURN NIL
No cell is selected.

EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Enrico,

It is a side effect of the latest change. This seems to fix it:

Code: Select all

METHOD ReSize( nSizeType, nWidth, nHeight ) CLASS TWBrowse

   local nTotalSize := 0

   ::nRowPos = Min( ::nRowPos, Max( ::nRowCount(), 1 ) )
   ::nColAct = Min( ::nColAct, AScan( ::GetColSizes(),;
                                      { | nSize | nTotalSize += nSize,;
                                      nWidth < nTotalSize }, ::nColPos ) )
   ::nColAct = Max( ::nColAct, 1 )
                                      
   if ::oHScroll != nil
      ::oHScroll:SetPos( ::nColAct )
   endif

return Super:ReSize( nSizeType, nWidth, nHeight )
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

Sorry, one more bug:

Code: Select all

#include "Fivewin.ch"


FUNCTION MAIN()

    LOCAL oWnd, oBrw

    DBCREATE( "BUGTEST", { { "TEST1", "C", 10, 0 },;
                           { "TEST2", "C", 10, 0 } } )

    USE BUGTEST

    APPEND BLANK

    DEFINE WINDOW oWnd

    @ 0, 0 LISTBOX oBrw FIELDS

    oBrw:lCellStyle = .T.

    oWnd:oClient = oBrw

    ACTIVATE WINDOW oWnd;
             MAXIMIZED

    CLOSE

    RETURN NIL
Select the second column and the resize the window: the first column will be selected back.

EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Enrico,

Fixed. This code seems the right one:

Code: Select all

METHOD ReSize( nSizeType, nWidth, nHeight ) CLASS TWBrowse

   local n, nTotalSize := 0, aSizes := ::GetColSizes()

   ::nRowPos = Min( ::nRowPos, Max( ::nRowCount(), 1 ) )
   
   n = Max( ::nColPos, 1 )
   while nTotalSize < nWidth .and. n <= Len( aSizes )
      nTotalSize += aSizes[ n++ ]
   end
   ::nColAct = Min( --n, ::nColAct )
                                      
   if ::oHScroll != nil
      ::oHScroll:SetPos( ::nColAct )
   endif

return Super:ReSize( nSizeType, nWidth, nHeight )
Please modify your example as follows and shrink the window and you will see how the selected cell is changed to the last visible one:

Code: Select all

#include "Fivewin.ch" 


FUNCTION MAIN() 

    LOCAL oWnd, oBrw 

    DBCREATE( "BUGTEST", { { "TEST1", "C", 10, 0 },; 
                           { "TEST2", "C", 10, 0 },;
                           { "TEST3", "C", 10, 0 },;
                           { "TEST4", "C", 10, 0 } } ) 

    USE BUGTEST 

    APPEND BLANK 

    DEFINE WINDOW oWnd 

    @ 0, 0 LISTBOX oBrw FIELDS 

    oBrw:lCellStyle = .T. 

    oWnd:oClient = oBrw 

    ACTIVATE WINDOW oWnd 
           

    CLOSE 

    RETURN NIL
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply