ClientWidth help from other OS's

BlitzMax Forums/BlitzMax GUI Programming/ClientWidth help from other OS's

No, I mean the arrows on the scrollbar.


Ah, ok. Those arrows don't produce an own event, so you can't act directly on it. But you can check the slider value and set it to whatever you like when you recognize a 1 pixel shift...

Your code also doesn't stop scrolling, so you can scroll as far as you want.


That's right. It just shows an idea how you could catch some events and move the panel as you had problems setting the range of the scrollbar. I leave it up to you to create a working type :)

SuperStrict
Import MaxGui.Drivers


Global PanelAsWindow:TGadget
Global PanelToScroll:TGadget
Global SB1:TGadget
Global Offset:Int


Local Window1:TGadget = CreateWindow:TGadget("Window1",87,108,335,262,Null,WINDOW_TITLEBAR|WINDOW_RESIZABLE |WINDOW_STATUS )
	' a panel used as window we look through to to see a part of the bigger scroll-area
	PanelAsWindow:TGadget = CreatePanel:TGadget(0,0,299,167,Window1:TGadget,Null,"Panel1")
		SetGadgetLayout( PanelAsWindow:TGadget,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED )

	'the panel we want to scroll
	PanelToScroll:TGadget = CreatePanel:TGadget(0,0,299,278,PanelAsWindow:TGadget,PANEL_ACTIVE,"Panel2")
		SetGadgetLayout( PanelToScroll:TGadget,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED,EDGE_ALIGNED )
		ActivateGadget(PanelToScroll)
	'some gagdets on top to scroll, not important
	Local TextField1:TGadget = CreateTextField:TGadget(93,36,80,18,PanelToScroll:TGadget,Null)
		SetGadgetText( TextField1:TGadget,"TextField1")
	Local TextArea1:TGadget = CreateTextArea:TGadget(12,173,275,95,PanelToScroll:TGadget,Null)
		SetTextAreaText( TextArea1:TGadget , "TextArea1" )
	Local Label1:TGadget = CreateLabel:TGadget("Label1",12,95,80,16,PanelToScroll:TGadget,LABEL_SUNKENFRAME)
	Local ProgBar1:TGadget = CreateProgBar:TGadget(207,88,80,23,PanelToScroll:TGadget,Null)
		UpdateProgBar( ProgBar1:TGadget,0.200000003 )
	'a button outside the scrollarea		
	Local Ok1:TGadget = CreateButton:TGadget("Ok1",224,178,75,23,Window1:TGadget,BUTTON_OK)
	


	'set the scrollbar
	SB1:TGadget = CreateSlider:TGadget(303,0,23,167,Window1:TGadget,SLIDER_VERTICAL | SLIDER_SCROLLBAR )
				SetSliderRange( SB1:TGadget,1 ,100 )
				SetSliderRange( SB1:TGadget,GadgetHeight(PanelAsWindow),GadgetHeight(PanelToScroll))


Repeat
	WaitEvent()
	Select EventID()
		Case EVENT_WINDOWCLOSE
			Select EventSource()
				Case Window1	Window1_WC( Window1:TGadget )
			End Select

		Case EVENT_GADGETACTION
			Select EventSource()
				Case SB1	SB1_GA( SB1:TGadget , EventData() )
				Case Ok1	Ok1_GA( Ok1:TGadget )
			End Select

		Case EVENT_MOUSEWHEEL
			Select EventSource()
				Case PanelToScroll	PanelToScroll_MW( PanelToScroll:TGadget , EventData() )
			End Select

		Case EVENT_KEYDOWN
			Select EventSource()
				Case PanelToScroll	PanelToScroll_KD( PanelToScroll:TGadget , EventData() )
			End Select

	End Select
Forever

Function Window1_WC( Window:TGadget )
	DebugLog "Window Window1 wants to be closed"
'	HideGadget( Window:TGadget )

	End
End Function

Function SB1_GA( Slider:TGadget , Number:Int )
	DebugLog "Slider SB1 changed to " + Number
	Global LastNumber:Int
	Local Offset:Int
	If Abs(LastNumber-Number)=1 Then
		Offset=Number-(Sgn(LastNumber-Number)*20 )
		SetSliderValue(Slider,Offset)
		Number = Offset
	EndIf
	SetGadgetShape( PanelToScroll:TGadget,GadgetX(PanelToScroll),GadgetY(PanelAsWindow)-Number,GadgetWidth(PanelToScroll),GadgetHeight(PanelToScroll) )
	LastNumber=Number
End Function

Function Ok1_GA( Button:TGadget )
	DebugLog "Button Ok1 was pressed"
	
End Function


Function PanelToScroll_MW( Panel:TGadget , MouseWheel:Int )
	DebugLog "Panel PanelToScroll detected "+ MouseWheel +" Mouse Wheel clicks"
	Offset:+Mousewheel*10
		SetGadgetShape( PanelToScroll:TGadget,GadgetX(PanelToScroll),GadgetY(PanelAsWindow)+Offset,GadgetWidth(PanelToScroll),GadgetHeight(PanelToScroll) )
End Function

Function PanelToScroll_KD( Panel:TGadget , Key:Int )
	DebugLog "Panel PanelToScroll detected Key "+ Key +" pressed"
	Select Key
		Case KEY_DOWN	Offset:+10
		Case KEY_UP	Offset:-10
	End Select
	
		SetGadgetShape( PanelToScroll:TGadget,GadgetX(PanelToScroll),GadgetY(PanelAsWindow)+Offset,GadgetWidth(PanelToScroll),GadgetHeight(PanelToScroll) )
End Function