
ListIconGadget - Multiline Entry
Howdy!
I have a similar question to Christian's original question. Except, I don't need all the fancy multi-line stuff. I just want to be able to change the text color of individual lines based on the value in one of the columns. So if I have an 11 column listicon, I want a line to be red if the value in column 2 is non-zero. Normal and black otherwise. And that's all I need. Nothing else fancy. Is it possible? I'm trying to make this as lightweight and optimized as possible since the bulk of my program relies on multiple listicons and the speed of switching between them and selecting lines.
Thanks! ^_^
[Edit] Scratch that! I think I have it going now
I have a similar question to Christian's original question. Except, I don't need all the fancy multi-line stuff. I just want to be able to change the text color of individual lines based on the value in one of the columns. So if I have an 11 column listicon, I want a line to be red if the value in column 2 is non-zero. Normal and black otherwise. And that's all I need. Nothing else fancy. Is it possible? I'm trying to make this as lightweight and optimized as possible since the bulk of my program relies on multiple listicons and the speed of switching between them and selecting lines.
Thanks! ^_^
[Edit] Scratch that! I think I have it going now

Actually, I'm still having problems. If I make a change to the logic in the callback that controls which listicon line gets what color, the lines do not update with the color. They have to be redrawn somehow. For example, minimizing and then maximizing the window or selecting the lines, etc...
So, how can I force a repaint of the lines in a listicon control to show the new colors?
So, how can I force a repaint of the lines in a listicon control to show the new colors?
Hi Xombie,
to colorize a single line it is easier to use this little callback:
Hope that is what you wanted to do!
Regards,
Christian
to colorize a single line it is easier to use this little callback:
Code: Select all
;-- SetLIGadgetItemColor
#NM_CUSTOMDRAW = -12 ; $FFFFFFF4
#CDRF_DODEFAULT = $0
#CDDS_PREPAINT = 1 ; $00000001
#CDRF_NOTIFYITEMDRAW = 32 ; $00000020
#CDRF_NEWFONT = 2 ; $00000002
#CDDS_ITEM = 65536 ; $00010000
#CDDS_ITEMPREPAINT = #CDDS_ITEM | #CDDS_PREPAINT
;- Constants
#Window_Main_ID = 0
#Window_Main_Width = 500
#Window_Main_Height = 500
#Gadget_ListIcon_ID = 0
;- Variables
Global WMID.l ; - Handle of the main window
;- Procedures
Procedure SetLIGadgetItemColor(GadgetID.l, lParam.l)
*nml.NMLVCUSTOMDRAW = lParam
; - Copy CustomDraw Structure
Select *nml\nmcd\dwDrawStage
Case #CDDS_PREPAINT ; - tell Windows that every line has to be painted seperatly
Result = #CDRF_NOTIFYITEMDRAW
Case #CDDS_ITEMPREPAINT ; - colorize lines
If *nml\nmcd\hdr\idFrom = GadgetID
For a = 0 To CountGadgetItems(GadgetID)
If *nml\nmcd\dwItemSpec = a
; - paint text red if column 2 is non-zero
If GetGadgetItemText(GadgetID, a, 1) <> "0"
*nml\clrTextBk = RGB(200, 0, 0) ; Background Color
*nml\clrText = RGB(255, 255, 255) ; Text Color
Else
*nml\clrTextBk = RGB(255, 255, 255) ; Background Color
*nml\clrText = RGB( 0, 0, 0) ; Text Color
EndIf
Result = #CDRF_NEWFONT
EndIf
Next a
EndIf
EndSelect
ProcedureReturn Result
EndProcedure
Procedure ColorCallback(WindowID, Message, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
Select Message
Case #WM_NOTIFY
*hdr.NMHDR = lParam
Select wParam
Case #Gadget_ListIcon_ID ; - Your ListIconGadget
If *hdr\code = #NM_CUSTOMDRAW
Result = SetLIGadgetItemColor(#Gadget_ListIcon_ID, lParam)
EndIf
EndSelect
EndSelect
ProcedureReturn Result
EndProcedure
;- Program
WMID = OpenWindow(#Window_Main_ID, 0, 0, #Window_Main_Width, #Window_Main_Height, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "ListIcon with Colored Lines")
If WMID
If CreateGadgetList(WMID)
ListIconGadget(#Gadget_ListIcon_ID, 0, 0, WindowWidth(), WindowHeight(), "Column 1", 150, #PB_ListIcon_FullRowSelect)
AddGadgetColumn(#Gadget_ListIcon_ID, 1, "Column 2", WindowWidth()-155)
For a = 0 To 50
AddGadgetItem(#Gadget_ListIcon_ID, -1, "Line "+Str(a)+Chr(10)+"0")
AddGadgetItem(#Gadget_ListIcon_ID, -1, "Line "+Str(a)+Chr(10)+"Non-Zero")
Next a
EndIf
SetWindowCallback(@ColorCallback())
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
quit = #TRUE
EndSelect
Until quit = #TRUE
EndIf
Regards,
Christian
No way of doing that with a ListIcon I'm afraid. The closest you would probably get (without a custom window class) would be to use an owner-drawn PB ListView gadget (Windows ListBox) and set the #LBS_OWNERDRAWVARIABLE style etc. A lot of work if you then try to use one of these to mimick a ListIcon.
I may look like a mule, but I'm not a complete ass.
Ah, a long long time ago, in a galaxy far far away...Ollivier wrote:Thank you Srod. I remember you had a code using editorgagdet for each cell (Perhaps my memory is wrong! )


In short, no! The overhead would be horrendous, the flicker would send your monitor into orbit...... It just wouldn't be worth the hassle. You will need some kind of custom solution; either a 3rd party grid control allowing for variable row-heights (have a look at xgrid or csgrid) or proceed with an owner-drawn PB ListView gadget etc.Do you think it's possible creating one little editorgadget per cell which the size is managed by splittergadgets ?
I may look like a mule, but I'm not a complete ass.
- Fluid Byte
- Addict
- Posts: 2336
- Joined: Fri Jul 21, 2006 4:41 am
- Location: Berlin, Germany
Hello,
has someone which for the 4,31 version ?
Donald
..
has someone which for the 4,31 version ?
Donald
..
DONALD
http://www.PureBasic-Donald.de
PureBasic - jaPBe - PureFORM - PureVisonXP - TailBite
GFABasic 16Bit 4.38 - GB32 2.30 B1160 - GFABasic DOS 4.51

PureBasic - jaPBe - PureFORM - PureVisonXP - TailBite
GFABasic 16Bit 4.38 - GB32 2.30 B1160 - GFABasic DOS 4.51
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada