Code: Select all
OpenWindow(0, 270, 100, 300, 200, "Change ToolBar properties")
FrameGadget(0, 10, 10, WindowWidth(0) - 20, 50, "Toolbar height:")
OptionGadget(1, 20, GadgetY(0) + 20, 120, 20, "Regular: 24x24")
OptionGadget(2, 160, GadgetY(0) + 20, 120, 20, "Small: 16x16")
SetGadgetState(2, #True)
FrameGadget(3, 10, GadgetY(0) + 60, WindowWidth(0) - 20, 50, "Display:")
OptionGadget(4, 20, GadgetY(3) + 20, 120, 20, "Icon+Label")
OptionGadget(5, 115, GadgetY(3) + 20, 120, 20, "Icon only")
OptionGadget(6, 200, GadgetY(3) + 20, 120, 20, "Label only")
SetGadgetState(5, #True)
CheckBoxGadget(7, 18, GadgetY(3) + 65, WindowWidth(0) - 20, 20,
"Separator between toolbar and window")
SetGadgetState(7, #True)
CheckBoxGadget(8, 18, GadgetY(7) + 25, WindowWidth(0) - 20, 20,
"Hide toolbar")
CreateImage(0, 16, 16)
StartDrawing(ImageOutput(0))
Box(0, 0, 16, 16, $FF0000)
Box(4, 4, 8, 8, $FFFF)
StopDrawing()
CreateToolBar(0, WindowID(0))
ToolBarImageButton(0, ImageID(0))
; ----- Get item object of ToolBar button and set label to "Demo"
ItemArray = CocoaMessage(0, ToolBarID(0), "items")
Item = CocoaMessage(0, ItemArray, "objectAtIndex:", 0)
CocoaMessage(0, Item, "setLabel:$", @"Demo")
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
EventGadget = EventGadget()
Select EventGadget
Case 1 To 2
CocoaMessage(0, ToolBarID(0), "setSizeMode:", EventGadget)
Case 4 To 6
CocoaMessage(0, ToolBarID(0), "setDisplayMode:", EventGadget - 3)
Case 7
CocoaMessage(0, ToolBarID(0), "setShowsBaselineSeparator:",
GetGadgetState(7))
Case 8
CocoaMessage(0, ToolBarID(0), "setVisible:", GetGadgetState(8) ! 1)
EndSelect
EndSelect
ForEver