Page 1 of 1

ListIconGadget color-matching grid lines

Posted: Tue Mar 26, 2024 5:11 am
by BarryG
When I use gridlines with a colored ListIconGadget, the lines look horrible unless you color them to match. Here's how I do it:

Code: Select all

Procedure SetBackColorAndLines(gad,color)
  r=Red(color)-20 : If r<0 : r=0 : EndIf
  g=Green(color)-20 : If g<0 : g=0 : EndIf
  b=Blue(color)-20 : If b<0 : b=0 : EndIf
  SetGadgetColor(gad,#PB_Gadget_LineColor,RGB(r,g,b))
  SetGadgetColor(gad,#PB_Gadget_BackColor,color)
EndProcedure

If OpenWindow(0, 100, 100, 400, 100, "ListIcon Example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ListIconGadget(0, 5, 5, 390, 90, "Name", 100, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect)
  AddGadgetColumn(0, 1, "Address", 250)
  AddGadgetItem(0, -1, "Harry Rannit"+Chr(10)+"12 Parliament Way, Battle Street, By the Bay")
  AddGadgetItem(0, -1, "Ginger Brokeit"+Chr(10)+"130 PureBasic Road, BigTown, CodeCity")
  
  ;SetGadgetColor(0,#PB_Gadget_BackColor,RGB(255,225,170)) ; The usual ugly way. :(
  
  SetBackColorAndLines(0,RGB(255,225,170)) ; The nice color-matching way. :)
  
  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf
Comparison of yucky on the left, and color-matching on the right:

Image

Re: ListIconGadget color-matching grid lines

Posted: Tue Mar 26, 2024 10:45 am
by Caronte3D
Looks better :D
Thanks! :wink:

Re: ListIconGadget color-matching grid lines

Posted: Tue Mar 26, 2024 1:56 pm
by jacdelad
Very nice, never thought about the grid lines, but I will definitely look closer at them from now on.

Re: ListIconGadget color-matching grid lines

Posted: Mon May 13, 2024 6:57 pm
by Kwai chang caine
Nice thanks for sharing 8)