It is currently Wed Aug 22, 2018 6:40 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Center ScrollArea scroll bars
PostPosted: Fri Mar 30, 2018 3:56 am 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5779
Location: Wales, UK
From the Help:
Quote:
#PB_ScrollArea_Center : If the inner size is smaller than the outer one,
then the inner area is automatically centered.


That works perfectly, but in my case the inner size is larger than the outer size - how to Center?

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: Center ScrollArea scroll bars
PostPosted: Fri Mar 30, 2018 11:57 am 
Offline
Addict
Addict

Joined: Sun Apr 12, 2009 6:27 am
Posts: 3056
Code:
   SetGadgetAttribute(gadget,#PB_ScrollArea_Y,(inner_Y-outer_Y)/2)
   SetGadgetAttribute(gadget,#PB_ScrollArea_X,(inner_X-outer_X)/2)

_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: Center ScrollArea scroll bars
PostPosted: Fri Mar 30, 2018 5:17 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5779
Location: Wales, UK
Rashad!

I was playing with:
SendMessage_(GadgetID(#MyScrlArea), #WM_VSCROLL, #SB_THUMBTRACK, 0)

....and you have a PB solution. Thankyou!

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: Center ScrollArea scroll bars
PostPosted: Sun Apr 01, 2018 2:29 am 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5779
Location: Wales, UK
Hmm - turns out that a tweak is needed. I have applied a tweak that looks right.......
Code:
Enumeration
#Win
#Panel
#Scrl
#Canv
#Temp
EndEnumeration

If OpenWindow(#Win, 0, 0, 700, 650, "ScrollArea scrollbar positions", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

                      ScrollBarGadget(#Temp, 0, 0, 0, 0, 0, 100, 100, #PB_ScrollBar_Vertical)
              iScrlBarW = GadgetWidth(#Temp, #PB_Gadget_RequiredSize)
                           FreeGadget(#Temp)

           SetWindowColor(#Win, RGB(240,240,240))

              PanelGadget(#Panel, 1, 1, 698, 648)

            AddGadgetItem(#Panel, -1, "Tab 0")

         ScrollAreaGadget(#Scrl, 5,  40,  376,  570, 1000, 1000, 10, #PB_ScrollArea_BorderLess | #PB_ScrollArea_Center)
             CanvasGadget(#Canv, 0,   0, 1000, 1000, #PB_Canvas_Container)
          CloseGadgetList() ;#Canv
          CloseGadgetList() ;#Scrl

             StartDrawing(CanvasOutput(#Canv))
                      Box(0, 0, GadgetWidth(#Canv), GadgetHeight(#Canv), RGB(192,192,192))
                   LineXY(500,   0,  500, 1000, RGB(200,000,000))
                   LineXY(  0, 500, 1000,  500, RGB(200,000,000))
              DrawingMode(#PB_2DDrawing_Outlined)
                      Box(332, 235, 336, 530, RGB(000,000,200))

              StopDrawing()

              SetGadgetAttribute(#Scrl, #PB_ScrollArea_X, ((1000 - 376) / 2) + (iScrlBarW / 2))
              SetGadgetAttribute(#Scrl, #PB_ScrollArea_Y, ((1000 - 570) / 2) + (iScrlBarW / 2))

         Repeat
         Until WaitWindowEvent(1) = #PB_Event_CloseWindow
EndIf

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: Center ScrollArea scroll bars
PostPosted: Sun Apr 01, 2018 6:59 am 
Offline
Addict
Addict

Joined: Sun Apr 12, 2009 6:27 am
Posts: 3056
Right on
Suit all cases (Hal or Val scroll bar not exist)
Code:
Enumeration
#Win
#Panel
#Scrl
#Canv
#Temp
EndEnumeration

If OpenWindow(#Win, 0, 0, 700, 650, "ScrollArea scrollbar positions", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)

SetWindowColor(#Win, RGB(240,240,240))

PanelGadget(#Panel, 1, 1, 698, 648)

AddGadgetItem(#Panel, -1, "Tab 0")

ScrollAreaGadget(#Scrl, 5,  40,  376,  570, 1000, 1000, 10, #PB_ScrollArea_BorderLess | #PB_ScrollArea_Center)
   CanvasGadget(#Canv, 0,   0, 1000, 1000, #PB_Canvas_Container)
CloseGadgetList() ;#Canv
CloseGadgetList() ;#Scrl

   StartDrawing(CanvasOutput(#Canv))
            Box(0, 0, GadgetWidth(#Canv), GadgetHeight(#Canv), RGB(192,192,192))
         LineXY(500,   0,  500, 1000, RGB(200,000,000))
         LineXY(  0, 500, 1000,  500, RGB(200,000,000))
    DrawingMode(#PB_2DDrawing_Outlined)
            Box(332, 235, 336, 530, RGB(000,000,200))

    StopDrawing()
   
    SetGadgetAttribute(#Scrl, #PB_ScrollArea_X, 1000)
    hpos = GetGadgetAttribute(#Scrl, #PB_ScrollArea_X)
   
    SetGadgetAttribute(#Scrl, #PB_ScrollArea_Y, 1000)
    vpos = GetGadgetAttribute(#Scrl, #PB_ScrollArea_Y)             

    SetGadgetAttribute(#Scrl, #PB_ScrollArea_X, hpos/2)
    SetGadgetAttribute(#Scrl, #PB_ScrollArea_Y, vpos/2)

Repeat
Until WaitWindowEvent(1) = #PB_Event_CloseWindow
EndIf

_________________
Egypt my love


Top
 Profile  
Reply with quote  
 Post subject: Re: Center ScrollArea scroll bars
PostPosted: Sun Apr 01, 2018 12:36 pm 
Offline
Always Here
Always Here

Joined: Fri Oct 23, 2009 2:33 am
Posts: 5779
Location: Wales, UK
That's excellent Rashad - it really should be part of the built-in PB function.

_________________
IdeasVacuum
If it sounds simple, you have not grasped the complexity.


Top
 Profile  
Reply with quote  
 Post subject: Re: Center ScrollArea scroll bars
PostPosted: Mon Apr 02, 2018 1:53 am 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1481
IdeasVacuum wrote:
it really should be part of the built-in PB function.

+1 (if Fred sees this).


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 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