Page 1 of 1

Enhancement: ScrollAreaGadget

Posted: Sun Apr 01, 2018 12:50 pm
by IdeasVacuum
From the Help:
#PB_ScrollArea_Center : If the inner size is smaller than the outer one,
then the inner area is automatically centered.
-Works perfectly but does not cater for when the inner size is larger than the outer size.

It can be done - should be part of the PB #PB_ScrollArea_Center function.

Rashad's solution:

Code: Select all

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