It is currently Tue Mar 31, 2020 8:33 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: How do I get a horizontal scrollbar to show up on a ListIcon
PostPosted: Sat Feb 25, 2017 11:59 pm 
Offline
User
User

Joined: Mon Jul 18, 2016 6:43 pm
Posts: 38
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:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: How do I get a horizontal scrollbar to show up on a List
PostPosted: Sun Feb 26, 2017 4:37 am 
Offline
User
User

Joined: Mon Jul 18, 2016 6:43 pm
Posts: 38
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: How do I get a horizontal scrollbar to show up on a List
PostPosted: Sun Feb 26, 2017 8:45 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 04, 2015 7:10 am
Posts: 1672
It doesn't seem like it's actually a supported capability in GTK!
https://www.gtk.org/tutorial1.2/gtk_tut-11.html
Quote:
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

_________________
Thankyou to all the coders who generously helped & encouraged me in the nearly 2yrs when i was welcome here,
it was a tremendous privilege. I learned a lot. I wish you and your families all the best and success for the future.


Top
 Profile  
Reply with quote  
 Post subject: Re: How do I get a horizontal scrollbar to show up on a List
PostPosted: Sun Feb 26, 2017 4:19 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Jun 26, 2014 9:17 am
Posts: 308
Location: Germany
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:
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:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: How do I get a horizontal scrollbar to show up on a List
PostPosted: Sun Feb 26, 2017 5:01 pm 
Offline
User
User

Joined: Mon Jul 18, 2016 6:43 pm
Posts: 38
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:
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()


Top
 Profile  
Reply with quote  
 Post subject: Re: How do I get a horizontal scrollbar to show up on a List
PostPosted: Sun Feb 26, 2017 6:01 pm 
Offline
User
User

Joined: Mon Jul 18, 2016 6:43 pm
Posts: 38
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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye