how to set the height of row of a listicon?

Just starting out? Need help? Post your questions and find answers here.
gabriel
Enthusiast
Enthusiast
Posts: 137
Joined: Sat Aug 01, 2009 4:49 pm
Location: Beirut, Lebanon

how to set the height of row of a listicon?

Post by gabriel »

hello:

I got this code from this forum and changed it a little, it uses Gnozal PureColor to color a listicon and change the font.
my problem is that with big characters size, the standard height of row become too small, so how to increase/change it?

thanks

Code: Select all

    Global FontID1 = LoadFont(0, "Arial", 15)
    Global FontID2 = LoadFont(1, "Arial", 15, #PB_Font_Bold)
    ;
    Procedure MyCellColorCallback(GadgetNumber.l, CellRow.l, CellColumn.l, *TextColor.LONG, *BackColor.LONG, *FontID.LONG)
      If GadgetNumber = 1
        Select CellRow    ; first=0
          Case 3
            *TextColor\l = #Red
            *BackColor\l = $82E287
            *FontID\l = FontID2
          Default
            *TextColor\l = #Blue
            *BackColor\l = RGB(247, 242, 170)
            *FontID\l = FontID1
        EndSelect
      EndIf
    EndProcedure
    ; Create Window
    OpenWindow(0, 100, 300, 400, 200, "PureCOLOR test : cell callback demo", #PB_Window_SystemMenu)

    ListIconGadget(1, 1, 1, 350, 190, "0", 100, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect)
    ;
    AddGadgetColumn(1, 1, "1", 100)
    AddGadgetColumn(1, 2, "2", 100)
    AddGadgetItem(1, -1, "0:0" + Chr(10) + "0:1" + Chr(10) + "Red")
    AddGadgetItem(1, -1, "1:0" + Chr(10) + "1:1" + Chr(10) + "1:2")
    AddGadgetItem(1, -1, "Blue" + Chr(10) + "Green" + Chr(10) + "2:2")
    AddGadgetItem(1, -1, "3:0" + Chr(10) + "Red" + Chr(10) + "3:2")
    AddGadgetItem(1, -1, "Red" + Chr(10) + "4:1" + Chr(10) + "Red")
    AddGadgetItem(1, -1, "Green" + Chr(10) + "Blue" + Chr(10) + "5:2")
    AddGadgetItem(1, -1, "6:0" + Chr(10) + "6:1" + Chr(10) + "6:2")
    AddGadgetItem(1, -1, "Red" + Chr(10) + "Blue" + Chr(10) + "7:2")
    AddGadgetItem(1, -1, "Strike" + Chr(10) + "Strike" + Chr(10) + "Strike")
    PureCOLOR_SetCellColorCallback(0, @MyCellColorCallback())
    Repeat
      EventID.l = WaitWindowEvent()
      If EventID = #PB_Event_CloseWindow
        Break
      EndIf
    ForEver
    ;
    End
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4955
Joined: Sun Apr 12, 2009 6:27 am

Re: how to set the height of row of a listicon?

Post by RASHAD »

Hi gabriel

Change Header height
Change Row height

Code: Select all

Global oldproc, header_h

Procedure Hheight(hwnd, msg, wParam, lParam)
   Select msg
      Case #HDM_LAYOUT      
        ;SetGadgetItemAttribute(GetDlgCtrlID_(hWnd), 0, #PB_ListIcon_ColumnWidth , 0,0)
        result = CallWindowProc_(oldproc, hwnd, msg, wParam, lParam)
        *hdlayout.HD_LAYOUT = lParam
        If *hdlayout\prc <> 0
            *rect.RECT = *hdlayout\prc
            *rect\top = header_h
        EndIf
        If *hdlayout\pwpos <> 0
            *windowpos.WINDOWPOS = *hdlayout\pwpos
            *windowpos\cy = header_h
        EndIf
      
      Default
        result = CallWindowProc_(oldproc, hWnd, Msg, wParam, lParam)
    
    EndSelect
    ProcedureReturn result
EndProcedure


If OpenWindow(0, 0, 0, 640, 300, "ListIconGadgets", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ListIconGadget(0, 10,  25, 600, 200, "Column 1", 120, #PB_ListIcon_GridLines| #PB_ListIcon_FullRowSelect)

      For b = 2 To 4          ; add 3 more columns to each listicon
        AddGadgetColumn(0, b, "Column " + Str(b), 120)
      Next
      For b = 0 To 2          ; add 4 items to each line of the listicons
        AddGadgetItem(0, b, "Item 1"+Chr(10)+"Item 2"+Chr(10)+"Item 3"+Chr(10)+"Item 4")
      Next
      
      
    header_h = 60                                                 ;Set Header Height
    Header = SendMessage_(GadgetID(0), #LVM_GETHEADER, 0, 0)
    oldproc = SetWindowLong_(Header, #GWL_WNDPROC, @Hheight())
    SendMessage_(GadgetID(0), #LVM_SCROLL, 0, 0)
      
    hImg = ImageList_Create_(1, 40, #ILC_COLORDDB, 0, 0)          ;Set Row Height
    SendMessage_(GadgetID(0), #LVM_SETIMAGELIST, #LVSIL_SMALL,hImg)
    ImageList_Destroy_(hImg)
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf

Egypt my love
USCode
Addict
Addict
Posts: 924
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Re: how to set the height of row of a listicon?

Post by USCode »

Try using SetGadgetFont() for the ListIcon gadget instead, then then rowsize will be adjusted accordingly automatically.
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: how to set the height of row of a listicon?

Post by gnozal »

Change the ListIconGadget font to FondID2. It should change the header and row height.

Code: Select all

Global FontID1 = LoadFont(0, "Arial", 15)
Global FontID2 = LoadFont(1, "Arial", 15, #PB_Font_Bold)
    ;
Procedure MyCellColorCallback(GadgetNumber.l, CellRow.l, CellColumn.l, *TextColor.Long, *BackColor.Long, *FontID.Long)
  If GadgetNumber = 1
    Select CellRow    ; first=0
      Case 3
        *TextColor\l = #Red
        *BackColor\l = $82E287
        *FontID\l = FontID2
      Default
        *TextColor\l = #Blue
        *BackColor\l = RGB(247, 242, 170)
        *FontID\l = FontID1
    EndSelect
  EndIf
EndProcedure
    ; Create Window
OpenWindow(0, 100, 300, 400, 200, "PureCOLOR test : cell callback demo", #PB_Window_SystemMenu)
    
ListIconGadget(1, 1, 1, 350, 190, "0", 100, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect)
SetGadgetFont(1, FontID2) ;<--------------------------------------------
  ;
AddGadgetColumn(1, 1, "1", 100)
AddGadgetColumn(1, 2, "2", 100)
AddGadgetItem(1, -1, "0:0" + Chr(10) + "0:1" + Chr(10) + "Red")
AddGadgetItem(1, -1, "1:0" + Chr(10) + "1:1" + Chr(10) + "1:2")
AddGadgetItem(1, -1, "Blue" + Chr(10) + "Green" + Chr(10) + "2:2")
AddGadgetItem(1, -1, "3:0" + Chr(10) + "Red" + Chr(10) + "3:2")
AddGadgetItem(1, -1, "Red" + Chr(10) + "4:1" + Chr(10) + "Red")
AddGadgetItem(1, -1, "Green" + Chr(10) + "Blue" + Chr(10) + "5:2")
AddGadgetItem(1, -1, "6:0" + Chr(10) + "6:1" + Chr(10) + "6:2")
AddGadgetItem(1, -1, "Red" + Chr(10) + "Blue" + Chr(10) + "7:2")
AddGadgetItem(1, -1, "Strike" + Chr(10) + "Strike" + Chr(10) + "Strike")
PureCOLOR_SetCellColorCallback(0, @MyCellColorCallback())
Repeat
  EventID.l = WaitWindowEvent()
  If EventID = #PB_Event_CloseWindow
    Break
  EndIf
ForEver
  ;
End
I will update the help file for the PB4.6x version.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
gabriel
Enthusiast
Enthusiast
Posts: 137
Joined: Sat Aug 01, 2009 4:49 pm
Location: Beirut, Lebanon

Re: how to set the height of row of a listicon?

Post by gabriel »

Fantastic!!
Thank you all :D
Post Reply