Page 1 of 1

how to set the height of row of a listicon?

Posted: Thu May 26, 2011 8:37 pm
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

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

Posted: Fri May 27, 2011 12:33 am
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


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

Posted: Fri May 27, 2011 1:10 am
by USCode
Try using SetGadgetFont() for the ListIcon gadget instead, then then rowsize will be adjusted accordingly automatically.

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

Posted: Fri May 27, 2011 7:54 am
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.

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

Posted: Fri May 27, 2011 10:34 am
by gabriel
Fantastic!!
Thank you all :D