Hello,
there are, at least, two ways to do this.
The first one - using the HColumn():aBitmaps array of pairs { bCondition, oBmp } - if a result of bCondition is .t., the appropriate bitmap is drawn. See the example in samples/a.prg, Openabout() function.
The second - using of HPaintCB class, see the tutorial, "Advanced using of controls"/Browse:
oBrw:aColumns[1]:oPaintCB := HPaintCB():New()
oBrw:aColumns[1]:oPaintCB:Set( PAINT_LINE_ALL, bCol1 )
In that sample the bCol1 codeblock draws a gradient background only, but you can draw there all what you need, including the bitmap.
Regards, Alexander.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi!
First option not work with mouse click, only with "space bar". keyboard and array browse, I use DBF browse.
And the second option I don't understand how I'm going to use it.
Both options are intended to display the checkbox. To change it you may use few other ways. One of them, via the oBrw:bKeyDown, is in a.prg. If you want to change the field by mouse doubleclick or enter, you need to use the bEnter block, something like this:
Local bEnter := {|o,nc|
IF nc == 1 // nc is a column number
o:aArray[ o:nCurrent,1 ] := !o:aArray[ o:nCurrent,1 ]
// Or, for a dbf browse:
// ( o:alias ) -> (rlock()) // if in shared mode
// ( o:alias ) -> SomeField := !( o:alias ) -> SomeField
// ( o:alias ) -> (dbUnlock())
o:RefreshLine()
ENDIF
RETURN .T.
}
...
oBrw:bEnter := bEnter
What about displaying checkbox, using the HPaintCB, see the tutorial, "Advanced using of controls", "Browse of bitmaps", bCol2 codeblock. To change it, you may use the same trick with bEnter.
Regards, Alexander
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
#include"hwgui.ch"FUNCTIONMain()localoDlg,oBrwaStructure:={{"idcontact","+",04,0},;//Auto increment{"mark","l",01,0},;{"name","c",60,0}}If!hb_vfexists("contacts.dbf")Ifdbcreate("contacts.dbf",aStructure,,.t.,"ctc")//Create and open with shared modeindexonfield->nametagtgNamectc->(dbappend())ctc->name:="JOSÉ DE ASSUMPÇÃO"ctc->(dbappend())ctc->name:="MARIA ANTONIETA"ctc->(dbappend())ctc->name:="SNOOPY"ctc->(dbappend())ctc->name:="POPEYE"ctc->(DbDelete())ctc->(dbCloseArea())Elsehwg_MsgStop("Error Creating DBF")cancelEndIfEndIfUsecontactsnewsharedalias"ctc"INITDIALOGoDlgTITLE"TEST"AT0,0SIZE800,600@10,10BROWSEoBrwDATABASEofoDlgSIZE200,200oBrw:Alias:="ctc"AddColumnFieldBlock("mark")tooBrwHeader"mark"Length20AddColumnFieldBlock("idcontact")tooBrwHeader"Cont_ID"Length10AddColumnFieldBlock("name")tooBrwHeader"Name"length100oBmp:=HBitmap():AddStandard("gtk_apply")//"gtk_ok"oBrw:aColumns[1]:aBitmaps:={{{|l|l},oBmp}}oDlg:Activate()closeallhb_vferase("contacts.dbf")Returnnil
Hi!
Because i use for show and edit a logical column of browse checkbox picture.
But this version SVN show F or T into field logical.
Best regards,
Itamar M. Lins Jr.
Hello,
there are, at least, two ways to do this.
The first one - using the HColumn():aBitmaps array of pairs { bCondition, oBmp } - if a result of bCondition is .t., the appropriate bitmap is drawn. See the example in samples/a.prg, Openabout() function.
The second - using of HPaintCB class, see the tutorial, "Advanced using of controls"/Browse:
oBrw:aColumns[1]:oPaintCB := HPaintCB():New()
oBrw:aColumns[1]:oPaintCB:Set( PAINT_LINE_ALL, bCol1 )
In that sample the bCol1 codeblock draws a gradient background only, but you can draw there all what you need, including the bitmap.
Regards, Alexander.
Hi!
First option not work with mouse click, only with "space bar". keyboard and array browse, I use DBF browse.
And the second option I don't understand how I'm going to use it.
Is correct this syntaxe ? (return nil)
How to put checkbox control in get line of browse ?
Best regards,
Itamar M. Lins Jr.
Both options are intended to display the checkbox. To change it you may use few other ways. One of them, via the oBrw:bKeyDown, is in a.prg. If you want to change the field by mouse doubleclick or enter, you need to use the bEnter block, something like this:
Local bEnter := {|o,nc|
IF nc == 1 // nc is a column number
o:aArray[ o:nCurrent,1 ] := !o:aArray[ o:nCurrent,1 ]
// Or, for a dbf browse:
// ( o:alias ) -> (rlock()) // if in shared mode
// ( o:alias ) -> SomeField := !( o:alias ) -> SomeField
// ( o:alias ) -> (dbUnlock())
o:RefreshLine()
ENDIF
RETURN .T.
}
...
oBrw:bEnter := bEnter
What about displaying checkbox, using the HPaintCB, see the tutorial, "Advanced using of controls", "Browse of bitmaps", bCol2 codeblock. To change it, you may use the same trick with bEnter.
Regards, Alexander
Hi!
First option not show column on Linux GTK.
Best regards,
Itamar M. Lins Jr.
1) No "gtk_apply", but "gtk-apply"
2) There are no records with a mark = .t. in your dbf
Regards, Alexander.
Hi!
I saw(found) your example in the tutor program -> DRAWN BROWSE.(oBrw2)
But it doesn't work in traditional browse.
A get error HANDLE.
Probably along these lines -> hwg_Fillrect( h, x1, y1, x2, y2, ob:handle )
And DRAWN BROWSE I not found method ON POSTCHANGE.
Best regards,
Itamar M. Lins Jr.
Hi!
More info about use in Linux OS.
Note that the check mark only appears when the browse line receives cursor focus
Best regards,
Itaamr M. Lins Jr.
Hmm... It appears normally here, on my Linux computer.
I've added new sample module to the tutorial, "Array of browse" with displaying/editing logical fields.
Regards, Alexander