Another simple way to add the getbar feature:
1. txbrowse class
+ data lgetbar
txbrwcolumn class
+ data cf1 // firstline
+ data cf2 //second line
+ data cfieldname // for sql where / search
2. method headerheight() class txbrowse
headerheight + 2*::nRowheight // to place the 2 gets bar lines
3. METHOD MouseRowPos( nRow ) CLASS TXBrowse
if ::lgetbar.and.nrow<::HeaderHeight().and.nrow>=::HeaderHeight()-::nrowheight
nrowpos:=-1
elseif ::lgetbar.and.nrow<=::HeaderHeight()-::nrowheight.and.nrow>=::HeaderHeight()-::nrowheight*2
nrowpos:=-2
else
nRowPos := Int( nTmp / ::nRowHeight ) + 1
end
4. method paint() class txbrowse
if ::lgetbar
for nFor := 1 to nLast
if aCols[ nFor ] > nBrwWidth
exit
endif
oCol := ::ColAtPos( nFor )
oCol:PaintData( nRow-::nrowheight*2, aCols[ nFor ], nHeight, lHighLite, .t., nFor, -1 )
oCol:PaintData( nRow-::nrowheight, aCols[ nFor ], nHeight, lHighLite, .t., nFor, 0 )
next
//the right+1 column
oCol:PaintData( nRow-::nrowheight*2, aCols[ nLast+1 ], nHeight, lHighLite, .t., nFor, -1 )
oCol:PaintData( nRow-::nrowheight, aCols[ nLast+1], nHeight, lHighLite, .t., nFor, 0 )
endif
5.
method paintdata() class txbrwcolumn
if ::bStrData != nil.and. !EVAL(::obrw:bBookMark)==EVAL(::obrw:bkeyCount)+1,.t.);
.or.::obrw:lgetbar.and.nPaintRow<=0
if ::obrw:lgetbar.and.nPaintRow==-1
cdata:=::cf1
elseif ::obrw:lgetbar.and.nPaintRow==0
cdata:=::cf2
else
cData := Eval( ::bStrData )
end
6. method edit() class txbrwcolumn
if ::obrw:nrowsel==-1
uvalue:=::cf1
elseif ::obrw:nrowsel==0
uvalue:=::cf2
else
uValue := IfNil( ::Value, ::BlankValue() )
end
if ::obrw:lgetbar
if ::obrw:nrowsel==-1
::bOnPostEdit:={|o,v,n| if(n != VK_ESCAPE ,::cf1:=v,)}
::nEdittype:={||if(::beditblock<>nil,EDIT_GET_BUTTON,1)}
if ::beditblock<>nil.and.GetCursorPos()[2]>::nwidth+ ::nDisplayCol-10
::RunBtnAction()
end
elseif ::obrw:nrowsel==0
::bOnPostEdit:={|o,v,n| if(n != VK_ESCAPE ,::cf2:=v,)}
::nEdittype:={||if(::beditblock<>nil,EDIT_GET_BUTTON,1)}
if ::beditblock<>nil.and.GetCursorPos()[2]>::nwidth+ ::nDisplayCol-10
::RunBtnAction()
end
else
::bOnPostEdit:=if(::bOnPostEditST == nil,{|o,v,n|v:=v},::bOnPostEditST)
::nEdittype:=::nEdittypeSt
endif
end
[img:1rmsuswr]http://d2.freep.cn/3tb_1609051740356hcb573125.jpg[/img:1rmsuswr]
The problem left is nedittype , can't enable bar gets always enable if nedittype<1
Shuming Wang
↧