Scrollbar width/height

Linux specific forum
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Scrollbar width/height

Post by Polo »

Hi,

On Ubuntu (latest one, basic install) the scrollbars are some thin lines whatever size you create them.
How can I retrieve the width (or height if it's an horizontal scrollbar) of a basic scrollbar so I know what correct size to use? If possible something that would work on any Linux distribution :)

Thanks in advance!
Gaetan
User avatar
idle
Always Here
Always Here
Posts: 6026
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Scrollbar width/height

Post by idle »

The height is ignored on ubuntu but PB will return the height you set
if there's a difference between distro's scrollbars then you may need to use the "size-allocate" signal
to get the gadgets dimensions

Code: Select all

Structure GtkRectangle 
  x.l
  y.l
  width.l
  height.l
EndStructure   

ProcedureC CBSizeRequest(*wid.GtkWidget,*rect.Gtkrectangle,*usedata)
  Debug "x " + Str(*rect\x)
  Debug  "y " + Str(*rect\y)  
  Debug  "width " + Str(*rect\width)
  Debug "height " + Str(*rect\height)  
EndProcedure 
 

If OpenWindow(0, 0, 0, 305, 140, "ScrollBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    TextGadget       (2,  10, 25, 250,  30, "ScrollBar Standard  (start=50, page=30/100)",#PB_Text_Center)
    ScrollBarGadget  (0,  10, 42, 250,  20, 0, 100, 30)
    g_signal_connect_(GadgetID(0),"size-allocate",@CBSizeRequest(),0)
          
    SetGadgetState   (0,  50)   ; set 1st scrollbar (ID = 0) to 50 of 100
    TextGadget       (3,  10,115, 250,  20, "ScrollBar Vertical  (start=100, page=50/300)",#PB_Text_Right)
    ScrollBarGadget  (1, 270, 10,  25, 120 ,0, 300, 50, #PB_ScrollBar_Vertical)
    SetGadgetState   (1, 100)   ; set 2nd scrollbar (ID = 1) to 100 of 300
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf

Windows 11, Manjaro, Raspberry Pi OS
Image
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: Scrollbar width/height

Post by Polo »

Thanks, I'll try that! ;)
User avatar
idle
Always Here
Always Here
Posts: 6026
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Scrollbar width/height

Post by idle »

this is probably better

Code: Select all

If OpenWindow(0, 0, 0, 305, 140, "ScrollBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    TextGadget       (2,  10, 25, 250,  30, "ScrollBar Standard  (start=50, page=30/100)",#PB_Text_Center)
    ScrollBarGadget(0,  10, 42, 250,  20, 0, 100, 30)
      
    *wid.GtkWidget = GadgetID(0) 
    Debug "x " + Str(*wid\allocation\x) 
    Debug "y " + Str(*wid\allocation\y) 
    Debug "width " + Str(*wid\allocation\width)
    Debug "height " + Str(*wid\allocation\height) 
          
    SetGadgetState  (0,  50)   ; set 1st scrollbar (ID = 0) to 50 of 100
    TextGadget       (3,  10,115, 250,  20, "ScrollBar Vertical  (start=100, page=50/300)",#PB_Text_Right)
    ScrollBarGadget  (1, 270, 10,  25, 120 ,0, 300, 50, #PB_ScrollBar_Vertical)
        
    *wid.GtkWidget = GadgetID(1) 
    Debug "x " + Str(*wid\allocation\x) 
    Debug "y " + Str(*wid\allocation\y) 
    Debug "width " + Str(*wid\allocation\width)
    Debug "height " + Str(*wid\allocation\height) 
    
    
   SetGadgetState   (1, 100)   ; set 2nd scrollbar (ID = 1) to 100 of 300
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf

Windows 11, Manjaro, Raspberry Pi OS
Image
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Re: Scrollbar width/height

Post by Polo »

Works perfectly thanks!
Post Reply