TWBrowse refiniment

TWBrowse refiniment

Postby Enrico Maria Giordano » Thu Feb 23, 2006 10:53 am

In the following sample, try to click below the last record. It will be selected while it shouldn't:

Code: Select all  Expand view
#include "Fivewin.ch"


REQUEST DBFCDX


FUNCTION MAIN()

    LOCAL oDlg, oBrw

    RDDSETDEFAULT( "DBFCDX" )

    USE TEST

    INDEX ON FIELD -> last + FIELD -> first TO "TEMP__" FOR FIELD -> last = "A"

    DEFINE DIALOG oDlg;
           SIZE 400, 400

    @ 1, 1 LISTBOX oBrw FIELDS TEST -> last,;
                               TEST -> first;
           SIZE 200, 200 PIXEL

    oBrw:bLogicLen = { || ( oBrw:cAlias ) -> ( OrdKeyCount() ) }

    ACTIVATE DIALOG oDlg;
             CENTER

    CLOSE

    FERASE( "TEMP__.CDX" )

    RETURN NIL


It is not a very important issue but anyway this is a possible fix:

Code: Select all  Expand view
METHOD LButtonDown( nRow, nCol, nKeyFlags ) CLASS TWBrowse

   local nClickRow, nSkipped
   local nColPos := 0, nColInit := ::nColPos - 1
   local nAtCol

   if ::lDrag
      return Super:LButtonDown( nRow, nCol, nKeyFlags )
   endif

   nClickRow = nWRow( ::hWnd, ::hDC, nRow,;
                      If( ::oFont != nil, ::oFont:hFont, 0 ) )

   if ::nLen < 1 .and. nClickRow != 0
      return nil
   endif

   if ::lMChange .and. AScan( ::GetColSizes(),;
             { | nColumn | nColPos += nColumn,;
                           nColInit++,;
                           nCol >= nColPos - 1 .and. ;
                           nCol <= nColPos + 1 }, ::nColPos ) != 0
      if ! ::lCaptured
         ::lCaptured = .t.
         ::Capture()
         ::VertLine( nColPos, nColInit )
      endif
      return nil
   endif

   ::SetFocus()

   if nClickRow == 0 .and. Valtype(nKeyFlags) == "N"
      if ::aActions != nil .and. ;
         ( nAtCol := ::nAtCol( nCol ) ) <= Len( ::aActions )
            if ::aActions[ nAtCol ] != nil
               wBrwLine( ::hWnd, ::GetDC(), 0, ::aHeaders, ::GetColSizes(),;
                         ::nColPos, ::nClrForeHead, ::nClrBackHead,;
                         If( ::oFont != nil, ::oFont:hFont, 0 ),.f.,;
                         ::aJustify, nAtCol, ::nLineStyle,,, ::oVScroll, ::bLogicLen )
               ::ReleaseDC()
               Eval( ::aActions[ nAtCol ], Self, nRow, nCol )
               wBrwLine( ::hWnd, ::GetDC(), 0, ::aHeaders, ::GetColSizes(),;
                         ::nColPos, ::nClrForeHead, ::nClrBackHead,;
                         If( ::oFont != nil, ::oFont:hFont, 0 ),.f.,;
                         ::aJustify,, ::nLineStyle,,, ::oVScroll, ::bLogicLen )
               ::ReleaseDC()
            else
               MsgBeep()
            endif
      else
         MsgBeep()
      endif
   endif

   if nClickRow > ::nLen //EMG
      return 0 //EMG
   endif //EMG

   if nClickRow > 0 .and. nClickRow != ::nRowPos .and. ;
      nClickRow < ::nRowCount() + 1
      ::DrawLine()
      nSkipped  = ::Skip( nClickRow - ::nRowPos )
      ::nRowPos += nSkipped
      if ::oVScroll != nil
         ::VSetPos( ::VGetPos() + nSkipped )
      endif
      if ::lCellStyle
           ::nColAct := ::nAtCol( nCol )
           if ::oHScroll != nil
              ::oHScroll:SetPos(::nColAct)
           endif
      endif
      ::DrawSelect()
      ::lHitTop = .f.
      ::lHitBottom = .f.
      if ::bChange != nil
         Eval( ::bChange, Self )
      endif
   else
      if ::lCellStyle
           ::nColAct := ::nAtCol( nCol )
           if ::oHScroll != nil
              ::oHScroll:SetPos(::nColAct)
           endif
           ::Refresh(.f.)
      endif
   endif

   Super:LButtonDown( nRow, nCol, nKeyFlags )

return 0


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby James Bott » Thu Feb 23, 2006 2:30 pm

Enrico,

What version of FWH are you using?

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

Postby Enrico Maria Giordano » Thu Feb 23, 2006 2:36 pm

The latest.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby James Bott » Thu Feb 23, 2006 2:49 pm

Enrico,

Actually, I do think that the scrollbar is an imortant issue, as does Dale and others, I'm sure. I have been working on it myself. There are a number of bugs still. For the last couple of days I have been trying to fix the tumbbar size problem (currently it is always the same size). Perhaps together we can get the scrollbar working properly.

One thing I think I have solved is defaulting bLogicLen to ordkeyCount() if the driver supports it, otherwise to reccount(). Often I forget to set bLogicLen.

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

Postby Enrico Maria Giordano » Thu Feb 23, 2006 3:02 pm

James Bott wrote:Enrico,

Actually, I do think that the scrollbar is an imortant issue, as does Dale and others, I'm sure. I have been working on it myself. There are a number of bugs still. For the last couple of days I have been trying to fix the tumbbar size problem (currently it is always the same size). Perhaps together we can get the scrollbar working properly.


I fix that problem years ago but Antonio thinks that a fixed-size thumb is a better choice (and I respect its decision). Anyway, if you are interested I can explain how.

James Bott wrote:One thing I think I have solved is defaulting bLogicLen to ordkeyCount() if the driver supports it, otherwise to reccount(). Often I forget to set bLogicLen.


I have it in my customized TWBrowse from the FW 1.9.1 days. :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby James Bott » Thu Feb 23, 2006 3:12 pm

Enrico,

I fix that problem years ago but Antonio thinks that a fixed-size thumb is a better choice (and I respect its decision).


Since the code to handle it was commented out, I figured it was just because it isn't working. Did he say why he thought it was better? Still it could be made a configurable option, then everyone could be happy.

Anyway, if you are interested I can explain how.


Please. I have already spent hours on this. I finally found one very strange thing. If I have 30 records and the setPage() method is activated, when you scroll past the 23th record, oVScrollbar:getPos() continues to return 23 always. I don't know if this is a bug in the C code or what.

I'm all ears.

James
Last edited by James Bott on Thu Feb 23, 2006 3:36 pm, edited 1 time in total.
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Postby Enrico Maria Giordano » Thu Feb 23, 2006 3:29 pm

James Bott wrote:Since the code to handle it was commented out, I figured it was just because it isn't working. Did he say why he thought it was better?


If I remember correctly, because a too little thumb is difficult to click.

James Bott wrote:Still it could be made a configurable option, then everyone could be happy.


Yes, it seems the best choice, as usual.

James Bott wrote:Please. I have already spent hours on this. I finally found one very strange thing. If I have 30 records and the setPage() method is activated, when you scroll past the 23th record, oVScrollbar:getPos() continues to return 23 always. I don't know if this is a bug in the C code or what.

I'm all ears.


Let me collect all the necessary changes. Now I'm about to going to pick up my daughter at shool. I report all here as soon as possible.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Enrico Maria Giordano » Thu Feb 23, 2006 3:49 pm

This is what I rapidly found. Let me know if there are pending issues and I will search for other fixes:

Code: Select all  Expand view
METHOD SetPage( nSize, lRedraw )

METHOD SetRange( nMin, nMax ) INLINE ;
                               ::nMin := nMin, ::nMax := nMax, ;
        SetScrollRange( if( ::lIsChild, ::oWnd:hWnd, ::hWnd ), ;
            if( ::lIsChild, If( ::lVertical, SB_VERT, SB_HORZ ), SB_CTL ), ;
                 nMin, nMax, .f. ), ::SetPage( 1, .t. )

METHOD SetPage( nSize, lReDraw ) CLASS TScrollBar

   local nFlags

   DEFAULT lRedraw := .f.

   if ! Empty( ::hWnd )
      nFlags = SB_CTL
   else
      if ::lVertical
         nFlags = SB_VERT
      else
         nFlags = SB_HORZ
      endif
   endif

   if ::nMin > 0 .or. ::nMax > 0
      SetScrollInfo( If( ! Empty( ::hWnd ), ::hWnd, ::oWnd:hWnd ),;
                     nFlags, nSize, lReDraw )
   endif

return nil


EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Antonio Linares » Sun Feb 26, 2006 7:18 am

> If I remember correctly, because a too little thumb is difficult to click.

Yes :)

Thanks for the fix!
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42071
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Rick Lipkin » Sun Feb 26, 2006 3:43 pm

Gentleman ..

My 2 cents worth here .. would very much like to have ( wish list ) a freeze column method and an index optimized for dbfcdx and ads.

The current version in FWH only has optimization for the 16 bit versions of ads and no freeze method :cry:

And yes I know there are other replacement browse classes out there .. but FWH Twbrowse is part of the FW library and I prefer to use that one because it can be compiled with Borland and Microsoft.

Any luck if either of you ( james or enrico ) can make a contibution to the current FWH Twbrowse :D

Thanks
Rick Lipkin
SC Dept of Health, USA
User avatar
Rick Lipkin
 
Posts: 2664
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Postby Enrico Maria Giordano » Sun Feb 26, 2006 3:47 pm

Rick Lipkin wrote:would very much like to have ( wish list ) a freeze column method


You already have it in TCBrowse class.

Rick Lipkin wrote:and an index optimized for dbfcdx and ads.


Whan do you exactly mean with "index optimized"?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Rick Lipkin » Sun Feb 26, 2006 9:19 pm

Enrico

I have never used tcbrowse .. so used to the standard listbox and the syntax of twbrowse.

I looked at the examples ( for tcbrowse ) and it looks like a major re-write .. not what I had in mind.

As far as the ADS optimization .. in the twbrowse setfilter method one could optimize reccount with testing for the default rdd and use ADSKeyCount, ADSKeyNO, AdsGetRelKeyPos, OrdKeyCount, OrdKeyNo,OrdKeyGoTo

Perhaps a column freeze and a goto col method would be nice as well.

Rick
User avatar
Rick Lipkin
 
Posts: 2664
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Postby Enrico Maria Giordano » Sun Feb 26, 2006 9:28 pm

Rick Lipkin wrote:As far as the ADS optimization .. in the twbrowse setfilter method one could optimize reccount with testing for the default rdd and use ADSKeyCount, ADSKeyNO, AdsGetRelKeyPos, OrdKeyCount, OrdKeyNo,OrdKeyGoTo


Why not using index scopes (OrdScope()) instead?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby dpaterso » Mon Feb 27, 2006 6:21 am

Good Morning All!

And all this time I thought it was just me that had issues with TWBROWSE :) :) :)

Regards,

Dale.
dpaterso
 
Posts: 142
Joined: Tue Jan 24, 2006 9:45 am
Location: South Africa

Postby James Bott » Mon Feb 27, 2006 11:31 am

Rick,

It is really not easy to freeze colums in TWBrowse because it does not contain column objects--the entire line is contained in one codeblock and drawn by one Eval().

TCBrowse was written to use column objects. This is what makes it easy to manipulate each column's properties; color, freezing, etc.

So, if you need more sophistication in a browse you are going to have to use one of the more advanced browses, TCBrowse, TSBrowse, or other.

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

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 45 guests