How do I get a horizontal scrollbar to show up on a ListIcon

Linux specific forum
dougmo52usr
User
User
Posts: 55
Joined: Mon Jul 18, 2016 6:43 pm

How do I get a horizontal scrollbar to show up on a ListIcon

Post by dougmo52usr »

I get a vertical scrollbar automatically when there are more rows than fit in the ListIconGadget.
I don't seem to get a horizontal scrollbar when I have more columns than fit in the ListIconGadget.
What am I lacking?

Code: Select all

Window_0 = OpenWindow(#PB_Any, 0,0,600,400, "Test", #PB_Window_ScreenCentered)
If Window_0
  ListIcon_0 = ListIconGadget(#PB_Any, 20, 20, 560, 100, "Column 1", 100, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
  If ListIcon_0
    For Column=1 To 10
      AddGadgetColumn(ListIcon_0,Column,"Column " + Str(Column+1),100)
    Next
    Row$ = ""
    For Row = 1 To 10
      For Column = 0 To 10
        Row$ = Row$ + "Col"+Str(Column)+"R"+Str(Row) + Chr(10)
      Next     
      AddGadgetItem(ListIcon_0,-1,Row$)
      Row$ = ""
    Next   
    Repeat
      Event = WaitWindowEvent()
      Select Event
        Case #PB_Event_Gadget
      EndSelect      
    Until Event = #PB_Event_CloseWindow
  EndIf
EndIf
dougmo52usr
User
User
Posts: 55
Joined: Mon Jul 18, 2016 6:43 pm

Re: How do I get a horizontal scrollbar to show up on a List

Post by dougmo52usr »

Ran the above code in Windows 7 Pro 32 bit and it works perfectly. Both scrollbars present and working.

Not so in Linux 64 bit at least. There is a vertical scrollbar, but no horizontal. Also on my machine in the Linux 64 bit version just left of the ListIcon vertical scrollbar there is a small vertical band that generates a Gtk exception if I click it with the mouse.
User avatar
Keya
Addict
Addict
Posts: 1891
Joined: Thu Jun 04, 2015 7:10 am

Re: How do I get a horizontal scrollbar to show up on a List

Post by Keya »

It doesn't seem like it's actually a supported capability in GTK!
https://www.gtk.org/tutorial1.2/gtk_tut-11.html
Note: The CList widget does not have its own scrollbars and should be placed within a ScrolledWindow widget if your require this functionality. This is a change from the GTK 1.0 implementation.
by ScrolledWindow im not sure if they mean ScrollAreaGadget or not. The only problem with that however is that it still doesn't respond with a scrollbar appearing if you slide the rightmost column off-screen, like it does in Windows. It just lets you scroll the whole gadget, based on the width of the entire list gadget (ignoring column sizes). You can detect an Event=4 (#PB_Paint) at that stage, but I don't know how to get the column width via PB commands so i think youd have to use a "gdk_get_column_width" or whatever its called api call
Oma
Enthusiast
Enthusiast
Posts: 312
Joined: Thu Jun 26, 2014 9:17 am
Location: Germany

Re: How do I get a horizontal scrollbar to show up on a List

Post by Oma »

Hi,
the problem only exists on some window managers.
The missing horizontal scrollbar is just hidden by the PB-preset mode.
This API could fix this to a permanent appearance...

Code: Select all

gtk_scrolled_window_set_policy_(gtk_widget_get_parent_(GadgetID(ListIcon_0)), #GTK_POLICY_ALWAYS, #GTK_POLICY_ALWAYS)
But the real problem is, that the right column widths are reduced to 1 or 0 :?: until the TreeView fits in the ScrolledWindow in Gtk3, so the horizontal scrollbar isn't needed any more.
But i don't know what happens here exactly.

Setting a min. column width (for example '80') ...

Code: Select all

gtk_tree_view_column_set_min_width(gtk_tree_view_get_column(GadgetID(ListIcon_0), Column), 80)
can override but not fix this.

Regards, Charly
PureBasic 5.4-5.7, Linux: (X/L/K)Ubuntus+Mint - Windows XP (32Bit)
PureBasic Linux-API-Library & Viewer: http://www.chabba.de
dougmo52usr
User
User
Posts: 55
Joined: Mon Jul 18, 2016 6:43 pm

Re: How do I get a horizontal scrollbar to show up on a List

Post by dougmo52usr »

Thanks for the assistance. gtk_scrolled_window_set_policy_ and gtk_tree_view_column_set_min_width gave me enough info to get something working as expected. It would be nice if I could resize the columns but at least I can scroll them into view.

Code: Select all

Global Window_0, ListIcon_0

Procedure GetTextWidth(Gadget,Text$)
  Protected TextWidth
  If StartDrawing(WindowOutput(Window_0))
    DrawingFont(GetGadgetFont(Gadget))
    TextWidth = TextWidth(Text$)
    StopDrawing()
  EndIf 
  ProcedureReturn TextWidth
EndProcedure 

Procedure WinMain()
  Window_0 = OpenWindow(#PB_Any, 0,0,600,400, "Test", #PB_Window_ScreenCentered)
  If Window_0 And IsWindow(Window_0)
    ListIcon_0 = ListIconGadget(#PB_Any, 20, 20, 560, 100, "Column 1", 100, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect | #PB_ListIcon_AlwaysShowSelection)
    If ListIcon_0 And IsGadget(ListIcon_0)
      gtk_scrolled_window_set_policy_(gtk_widget_get_parent_(GadgetID(ListIcon_0)), #GTK_POLICY_ALWAYS, #GTK_POLICY_ALWAYS)
      For Column=1 To 10
        Col$ = "Column " + Str(Column+1)
        ColW = GetTextWidth(ListIcon_0,Col$) + 20
        AddGadgetColumn(ListIcon_0,Column,Col$,ColW)
        gtk_tree_view_column_set_min_width_(gtk_tree_view_get_column_(GadgetID(ListIcon_0), Column), ColW)
      Next
      Row$ = ""
      For Row = 1 To 10
        For Column = 0 To 10
          Row$ = Row$ + "Col"+Str(Column)+"R"+Str(Row) + Chr(10)
        Next     
        AddGadgetItem(ListIcon_0,-1,Row$)
        Row$ = ""
      Next   
      While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend
    EndIf
  EndIf
EndProcedure

WinMain()
dougmo52usr
User
User
Posts: 55
Joined: Mon Jul 18, 2016 6:43 pm

Re: How do I get a horizontal scrollbar to show up on a List

Post by dougmo52usr »

I'm pretty sure gtk_tree_view_column_get_resizable returned #True. I checked the column resize mode with gtk_tree_view_column_get_sizing and it was set to GTK_TREE_VIEW_COLUMN_FIXED, so I changed it to GTK_TREE_VIEW_COLUMN_GROW_ONLY with gtk_tree_view_column_set_sizing. Still couldn't resize columns by dragging the cell grid even though the resize cursor showed up but So set it to GTK_TREE_VIEW_COLUMN_AUTOSIZE. Now the resize arrow doesn't show up but the column sizes are great since I can put the important columns to the left and scroll to others as desired, and it is smart enough to resize based not only on the grid column title but also the column item contents. There did not seem to be a need to call gtk_tree_view_column_set_min_width if using GTK_TREE_VIEW_COLUMN_AUTOSIZE.
Post Reply