QT-ListIconGadget (Autosize ?)

Linux specific forum
ccode
User
User
Posts: 99
Joined: Sat Jun 23, 2018 5:21 pm

QT-ListIconGadget (Autosize ?)

Post by ccode »

The icon size is not adjusted automatically. (As with GTK 2 or 3)

Does anyone have a code for a good icon customization?

Code: Select all

Procedure IconSize(gadget)
  CompilerIf Subsystem("qt")
    NewList ISize.i()
    For i = 0 To CountGadgetItems(gadget)
      AddElement(ISize())
      ISize() = Len(GetGadgetItemText(gadget, i-1))
    Next i
    SortList(ISize(),#PB_Sort_Descending)
    SelectElement(ISize(), 0)
    SetGadgetItemAttribute(1, -1, #PB_ListIcon_ColumnWidth, ISize()*8) ;?
    ;Debug GetGadgetItemAttribute(1, -1, #PB_ListIcon_ColumnWidth)
  CompilerEndIf
EndProcedure

OpenWindow(0, #PB_Ignore, #PB_Ignore, 200, 200, "test", #PB_Window_SystemMenu)

ListIconGadget(1, 0, 0, 200, 200, "test", 50) ;Not Autosize (Qt)

For i = 1 To 100
  AddGadgetItem(1, -1, "Item + " + Str(i))
Next i
IconSize(1)

SetGadgetColor(1, #PB_Gadget_FrontColor, RGB(255, 255, 255))
SetGadgetColor(1, #PB_Gadget_BackColor, RGB(0, 0, 0))

Repeat
  Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow