Hi Frank,
In Harbour we already support basic mouse functionality from CL53
TBROWSE class. Look at :mRowPos(), :mColPos() and :hitTest() method
and TBMouse() function.
If it's not enough then we can extend it.
best regards,
Przemek
> fyi, my project needed extra TBrowse functions too to
>
> * determine in which TBrowse cell the mouse was clicked
> tb:: mouRow2u() and tb:: mouCol2u() but not screen coord based, rather in
> which (visible) TBColumn and which TBrowse row
>
> * how many rows the header and footer occupy (these are also mentioned by Hannes)
> tb:: hrCount_u9T() [Header Row Count]
> tb:: frCount_u9T() [Footer Row Count]
>
> the code below is also based on Hannes' outline (note the diff offsets 5.2/5.3)
>
> afaik, however, tb:: mouRow2u() and tb:: mouCol2u() are not (yet) totally
> correct (when the TBrowse first column doesn't start at TBrowse:nLeft + 1, due
> to not fitting exactly)
>
> .oO i hope not to confuse with these oceans names:
> tb:: t_u9 -> TBrowse:nTop
> tb:: l_u9 -> TBrowse:nLeft
> tb:: b_u9 -> TBrowse:nBottom
> tb:: r_u9 -> TBrowse:nRight
> tb:: ccCount_u9T -> TBrowse:colCount
> tb:: crCount_u9T -> TBrowse:rowCount
>
> main reason for mentioning is the different offsets under 5.2 and 5.3 (i think
> this was not in Hannes' writings afair)
>
> /// *************************************************************************
> /// clipper 5.2(e) TBrowse internals
> /// *************************************************************************
> #define MAGICSTRINGNO 14
>
> #define OFFSET4TCINFO 85
> #define LENGTH4TCINFO 12
>
> #define BLOCKNO4HEADSEP 29
> #define BLOCKNO4FOOTSEP 31
> #define BLOCKNO4DATAROW 33
> #define BLOCKNO4FOOTROW 45
> /// *************************************************************************
> /// clipper 5.3(b) TBrowse internals
> /// *************************************************************************
> #define MAGICSTRINGNO 14
>
> #define OFFSET4TCINFO 85 + 6
> #define LENGTH4TCINFO 12 + 6
>
> #define BLOCKNO4HEADSEP 29
> #define BLOCKNO4FOOTSEP 31
> #define BLOCKNO4DATAROW 33
> #define BLOCKNO4FOOTROW 45
> /// *************************************************************************
> /// common oceans source (clipper 5.2/5.3)
> /// *************************************************************************
>
> __9 o ::u6T (tb):: hrCount_u9T () { ;
>
> ___r ( headRows2u( self ))
>
> } __p( (tb):: hrCount_u9T )
>
> /// *************************************************************************
>
> __9 o ::u6T (tb):: frCount_u9T () { ;
>
> ___r ( footRows2u( self ))
>
> } __p( (tb):: frCount_u9T )
>
> /// *************************************************************************
>
> __2 o ::u6T :: mouRow2u ( ;// STATIC FUNC
> ;
> tb ::O6T self ;
> , o ::u6T mouRow_u7 ;
> ;
> ) {
>
> __7 o ::c6T info_c7T ;
> := self[ MAGICSTRINGNO ] ;
>
> __7 o ::u6T headSepRow_u7 ;
> := BIN2I(( info_c7T ) . c:: sub9c( BLOCKNO4HEADSEP )) ;
>
> __7 o ::u6T footSepRow_u7 ;
> := BIN2I(( info_c7T ) . c:: sub9c( BLOCKNO4FOOTSEP )) ;
>
> mouRow_u7 -= headRows2u( self )
>
> __8i( headSepRow_u7 < 0 ) {
> mouRow_u7 -= 1
> }
>
> ___r ( _7j( mouRow_u7 >= 1 ;
> , mouRow_u7 < self . tb:: b_u9 - self . tb:: t_u9 + 1 - footRows2u( self ) - ;
> _9j( footSepRow_u7 < 0 )( 0, 1 )) ;
> ( mouRow_u7, 0 ))
>
> } __p( :: mouRow2u )
>
> /// *************************************************************************
>
> __2 o ::u6T :: mouCol2u ( ;// STATIC FUNC
> ;
> tb ::O6T self ;
> , o ::u6T mouCol_u7T ;
> ;
> ) {
>
> __7 o ::c6T info_c7T ;
> := self[ MAGICSTRINGNO ] ;
>
> __7 o ::u6T colCount_u7T ;
> := self . tb:: ccCount_u9T ;
> ;
> , tcMin_u7 ;// Table Column Minimum
> := 1 ;
> , tcMax_u7 ;// Table Column Maximum
> := 1 ;
> ;
> , vsLen_u7T ;// Virtual Screen Length
> := BIN2I(( info_c7T ) . c:: sub9c( 13 )) ;
>
> __0f( u7, 1, colCount_u7T ) {
>
> tcMax_u7 += ( BIN2I(( info_c7T ) . c:: sub9c( OFFSET4TCINFO + vsLen_u7T + ( u7 - 1 ) * ( LENGTH4TCINFO ))) + 1 )
>
> __7i( mouCol_u7T >= tcMin_u7 ;
> , mouCol_u7T < tcMax_u7 ) {
> ___8
> }
>
> tcMin_u7 += ( BIN2I(( info_c7T ) . c:: sub9c( OFFSET4TCINFO + vsLen_u7T + ( u7 - 1 ) * ( LENGTH4TCINFO ))) + 1 )
>
> }
>
> ___r ( _9j( u7 > colCount_u7T )( 0, u7 ))
>
> } __p( :: mouCol2u )
>
> /// *************************************************************************
> /// number of rows used for heading region excluding TBrowse/TBColumn:headSep
> /// *************************************************************************
>
> __2 o ::u6T :: headRows2u ( ;// STATIC FUNC
> ;
> tb ::O6T self ;
> ;
> ) {
>
> __7 o ::c6T info_c7T ;
> := self[ MAGICSTRINGNO ] ;
>
> __7 o ::u6T headSepRow_u7 ;
> := BIN2I(( info_c7T ) . c:: sub9c( BLOCKNO4HEADSEP )) ;
>
> __9i( headSepRow_u7 < 0 ) {
> headSepRow_u7 := BIN2I(( info_c7T ) . c:: sub9c( BLOCKNO4DATAROW ))
> }
>
> ___r ( headSepRow_u7 )
>
> } __p( :: headRows2u )
>
> /// *************************************************************************
> /// number of rows used for footing region excluding TBrowse/TBColumn:footSep
> /// *************************************************************************
>
> __2 o ::u6T :: footRows2u ( ;// STATIC FUNC
> ;
> tb ::O6T self ;
> ;
> ) {
>
> __7 o ::c6T info_c7T ;
> := self[ MAGICSTRINGNO ] ;
>
> __7 o ::u6T hFootRow_u7T ;// first Foot Row
> := BIN2I(( info_c7T ) . c:: sub9c( BLOCKNO4FOOTROW )) ;
>
> ___r ( self . tb:: b_u9 - self . tb:: t_u9 + 1 - hFootRow_u7T )
>
> } __p( :: footRows2u )
>
> /// *************************************************************************
> /// clipper 5.2(e) TBrowse internals (transpile output)
> /// *************************************************************************
>
> STATIC FUNCTION u2mouRow (self,t7u_mouRow) ; local _ := (NIL,NIL )
>
> local T7c_info:=self[ 14 ]
>
>
> local t7u_headSepRow:=BIN2I((SUBSTR (T7c_info ,29 )))
>
>
> local t7u_footSepRow:=BIN2I((SUBSTR (T7c_info ,31 )))
> t7u_mouRow -= u2headRows(self )
>
> if((!(t7u_headSepRow < 0 )) )
> t7u_mouRow -= 1
> end
>
>
>
>
> return iif(t7u_mouRow >= 1 .AND.t7u_mouRow < self : t9u_b - self : t9u_t + 1 - u2footRows(self ) - iif(t7u_footSepRow < 0,0,1),t7u_mouRow,0)
>
> return NIL
>
>
>
>
>
>
>
>
> STATIC FUNCTION u2mouCol (self,T7u_mouCol) ; local _ := (NIL,NIL )
>
>
>
> local T7c_info:=self[ 14 ]
>
>
>
>
>
>
>
>
>
>
> local T7u_colCount:=self : T9u_ccCount,t7u_tcMin:=1,t7u_tcMax:=1,T7u_vsLen:=BIN2I((SUBSTR (T7c_info ,13 )))
> for t7u := 1 to T7u_colCount step 1
>
> t7u_tcMax += (BIN2I((SUBSTR (T7c_info ,85 + T7u_vsLen + (t7u - 1 ) * (12 ) ))) + 1 )
>
>
> if(((T7u_mouCol >= t7u_tcMin) .AND.(T7u_mouCol < t7u_tcMax ) ) )
> exit
> end
>
> t7u_tcMin += (BIN2I((SUBSTR (T7c_info ,85 + T7u_vsLen + (t7u - 1 ) * (12 ) ))) + 1 )
>
> end
>
> return iif(t7u > T7u_colCount,0,t7u)
>
> return NIL
>
>
>
>
>
>
>
>
>
> STATIC FUNCTION u2headRows (self) ; local _ := (NIL,NIL )
>
>
>
> local T7c_info:=self[ 14 ]
>
>
> local t7u_headSepRow:=BIN2I((SUBSTR (T7c_info ,29 )))
> if(t7u_headSepRow < 0 )
> t7u_headSepRow := BIN2I((SUBSTR (T7c_info ,33 )))
> end
>
> return t7u_headSepRow
>
> return NIL
>
>
>
>
>
>
>
>
>
> STATIC FUNCTION u2footRows (self) ; local _ := (NIL,NIL )
>
>
>
> local T7c_info:=self[ 14 ]
>
>
> local T7u_hFootRow:=BIN2I((SUBSTR (T7c_info ,45 )))
> return self : t9u_b - self : t9u_t + 1 - T7u_hFootRow
>
> return NIL
>
>
> /// *************************************************************************
> /// clipper 5.3(b) TBrowse internals (transpile output)
> /// *************************************************************************
>
> STATIC FUNCTION T9u_hrCount() ; local self := qself() ; local _ := (NIL,NIL )
> return u2headRows(self )
>
> return NIL
>
>
>
>
> STATIC FUNCTION T9u_frCount() ; local self := qself() ; local _ := (NIL,NIL )
> return u2footRows(self )
>
> return NIL
>
>
>
>
>
>
>
>
> STATIC FUNCTION u2mouRow (self,t7u_mouRow) ; local _ := (NIL,NIL )
>
>
>
> local T7c_info:=self[ 14 ]
>
>
> local t7u_headSepRow:=BIN2I((SUBSTR (T7c_info ,29 )))
>
>
> local t7u_footSepRow:=BIN2I((SUBSTR (T7c_info ,31 )))
> t7u_mouRow -= u2headRows(self )
>
> if((!(t7u_headSepRow < 0 )) )
> t7u_mouRow -= 1
> end
>
>
>
>
> return iif(t7u_mouRow >= 1 .AND.t7u_mouRow < self : t9u_b - self : t9u_t + 1 - u2footRows(self ) - iif(t7u_footSepRow < 0,0,1),t7u_mouRow,0)
>
> return NIL
>
>
>
>
>
>
>
>
> STATIC FUNCTION u2mouCol (self,T7u_mouCol) ; local _ := (NIL,NIL )
>
>
>
> local T7c_info:=self[ 14 ]
>
>
>
>
>
>
>
>
>
>
> local T7u_colCount:=self : T9u_ccCount,t7u_tcMin:=1,t7u_tcMax:=1,T7u_vsLen:=BIN2I((SUBSTR (T7c_info ,13 )))
> for t7u := 1 to T7u_colCount step 1
>
> t7u_tcMax += (BIN2I((SUBSTR (T7c_info ,85 + 6 + T7u_vsLen + (t7u - 1 ) * (12 + 6 ) ))) + 1 )
>
>
> if(((T7u_mouCol >= t7u_tcMin) .AND.(T7u_mouCol < t7u_tcMax ) ) )
> exit
> end
>
> t7u_tcMin += (BIN2I((SUBSTR (T7c_info ,85 + 6 + T7u_vsLen + (t7u - 1 ) * (12 + 6 ) ))) + 1 )
>
> end
>
> return iif(t7u > T7u_colCount,0,t7u)
>
> return NIL
>
>
>
>
>
>
>
>
>
> STATIC FUNCTION u2headRows (self) ; local _ := (NIL,NIL )
>
>
>
> local T7c_info:=self[ 14 ]
>
>
> local t7u_headSepRow:=BIN2I((SUBSTR (T7c_info ,29 )))
> if(t7u_headSepRow < 0 )
> t7u_headSepRow := BIN2I((SUBSTR (T7c_info ,33 )))
> end
>
> return t7u_headSepRow
>
> return NIL
>
>
>
>
>
>
>
>
>
> STATIC FUNCTION u2footRows (self) ; local _ := (NIL,NIL )
>
>
>
> local T7c_info:=self[ 14 ]
>
>
> local T7u_hFootRow:=BIN2I((SUBSTR (T7c_info ,45 )))
> return self : t9u_b - self : t9u_t + 1 - T7u_hFootRow
>
> return NIL
>
> /// *************************************************************************
>