Gadget demonstration

Everything else that doesn't fall into one of the other categories.
AZJIO
Posts: 54
Joined: Wed Dec 14, 2022 1:13 pm

Gadget demonstration

Post by AZJIO »

When changing the theme, I want to see what all the gadgets look like. Here is an example of a demonstration of all the gadgets.

Code: Select all

EnableExplicit

#Window = 0
#Menu = 0

Enumeration
	#btn
	#Str
	#Ch
	#Combo
	#Date
	#Calendar
	#Editor
	#Frame
	#Link
	#Image
	#LIG
	#LV
	#Spin
	#Txt
	#Track
	#Tree
	#Panel
	#Op1
	#Op2
	#Op3
	#Progress
EndEnumeration

Global ww, hh, i


; ExamineDesktops()
; ww = DesktopWidth(0)
; hh = DesktopHeight(0)
; If ww < 400 Or hh < 400
; 	End
; EndIf

Procedure Handler()
	;     MessageRequester("Button click event on gadget #" + EventGadget())
	DisplayPopupMenu(#Menu, WindowID(#Window))
EndProcedure

Procedure EventsMenu()
	Select EventMenu()
		Case 0 To 3
			MessageRequester("Menu")
	EndSelect
EndProcedure


If OpenWindow(#Window, 0, 0, ww, hh, "", #PB_Window_Background)
; If OpenWindow(#Window, 0, 0, 500, 770, "GUI", #PB_Window_ScreenCentered | #PB_Window_TitleBar)
	ButtonGadget(#btn, 5, 5, 30, 30, Chr($2630)))
; 	GadgetToolTip(#btn, "Button")
	
	If CreatePopupMenu(#Menu)
		MenuItem(0, "Item 1")
		MenuItem(1, "Item 2")
		MenuItem(2, "Item 3")
		MenuItem(3, "Item 4")
	EndIf

	StringGadget(#Str, 40, 5, 120, 25, "Search", #PB_String_PlaceHolder)
	CheckBoxGadget(#Ch, 6,  40, 150, 20, "CheckBox") : SetGadgetState(#Ch, #PB_Checkbox_Checked)
	FrameGadget(#Frame, 6,  70, 160, 50, "Frame", #PB_Frame_Single)
	EditorGadget(#Editor, 6, 130, 160, 100) : SetGadgetText(#Editor, "Editor")

	CreateImage(0, 80, 80, 32, #PB_Image_Transparent)
	If StartDrawing(ImageOutput(0))
		For i = 35 To 5 Step -5
			Circle(35, 35, i, RGB(Random(155, 50), Random(155, 50), Random(155, 50)))
		Next
		DrawingMode(#PB_2DDrawing_Transparent)
		DrawText(8, 18, "Image", $00FFFF)
		StopDrawing()
	EndIf
	ImageGadget(#Image, 175, 5, 80, 80, ImageID(0))

	OptionGadget(#Op1, 260, 5, 100, 20, "Option 1")
	OptionGadget(#Op2, 260, 30, 100, 20, "Option 2") : SetGadgetState(#Op2, 1)
	OptionGadget(#Op3, 260, 55, 100, 20, "Option 3")

	ProgressBarGadget(#Progress, 200, 85, 150, 20, 0, 100)
	SetGadgetState(#Progress, 50)
	
	ComboBoxGadget(#Combo, 200, 115, 150, 25)
	For i = 0 To 5
		AddGadgetItem(#Combo, -1, "item " + i)
	Next
	
	DateGadget(#Date, 200, 150, 150, 25, "%mm/%dd/%yyyy")
	
	HyperLinkGadget(#Link, 200, 180, 90,20,"HyperLink", RGB(255,0,0))
	SetGadgetColor(#Link, #PB_Gadget_FrontColor, $aaaaaa)

	SpinGadget(#Spin, 290, 180, 60, 25, 0, 1000)
	SetGadgetState(#Spin, 5) : SetGadgetText(#Spin, "5")

	TextGadget(#Txt, 200, 210, 150, 30, "TextGadget+Border", #PB_Text_Border)

	TrackBarGadget(#Track, 6, 250, 250, 20, 0, 1000)
	SetGadgetState(#Track, 500)

	ListIconGadget(#LIG, 6, 280, 230, 120, "Col1", 70, #PB_ListIcon_CheckBoxes)
	For i = 2 To 3
		AddGadgetColumn(#LIG, i, "Col" + Str(i), 50)
	Next
	For i = 0 To 6
		AddGadgetItem(#LIG, i, "Item 1"+Chr(10)+"Item 2"+Chr(10)+"Item 3")
	Next
	SetGadgetItemState(#LIG, 1, #PB_ListIcon_Checked)
	;     SetGadgetItemState(#LIG, 2, #PB_ListIcon_Selected)
	;     SetActiveGadget(#LIG)

	ListViewGadget(#LV, 250, 280, 120, 120)
	For i = 1 To 12
		AddGadgetItem (#LV, -1, "Item " + Str(i))
	Next
	SetGadgetState(#LV, 4)

	PanelGadget(#Panel, 6, 410, 160, 120)
	AddGadgetItem (#Panel, -1, "Tab1")
	;     ButtonGadget(2, 6, 15, 80, 24,"Button 1")
	;     ButtonGadget(3, 95, 15, 80, 24,"Button 2")
	AddGadgetItem (#Panel, -1,"Tab2")
	CloseGadgetList()

	TreeGadget(#Tree, 6, 540, 160, 140)
	For i = 0 To 10
		AddGadgetItem(#Tree, -1, "Normal Item "+Str(i), 0, 0) ; if you want to add an image, use
		AddGadgetItem(#Tree, -1, "Node "+Str(i), 0, 0)		  ; Imagei(x) as 4th parameter
		AddGadgetItem(#Tree, -1, "Sub-Item 1", 0, 1)		  ; These are on the 1st sublevel
		AddGadgetItem(#Tree, -1, "Sub-Item 2", 0, 1)
		AddGadgetItem(#Tree, -1, "Sub-Item 3", 0, 1)
		AddGadgetItem(#Tree, -1, "Sub-Item 4", 0, 1)
		AddGadgetItem(#Tree, -1, "File "+Str(i), 0, 0) ; sublevel 0 again
	Next

	CalendarGadget(#Calendar, 175, 410, 210, 270)
	
	BindGadgetEvent(#btn, @Handler())
	BindEvent(#PB_Event_Menu, @EventsMenu())
EndIf