It's only possible to change the height of the ToolBar indirectly. One possibility is to use
Code: Select all
gtk_toolbar_set_style_(*Toolbar.GtkToolbar, Style)
to display only an icon, an icon together with a label below the icon or only the label without an icon. Another possibility is to change the icon size to fixed predefined resolutions. For demonstration purposes you may try the following code example.
You may wonder why I used API tool buttons and not PB's ToolBarStandardButton(). Of course it also works with PB's ToolBarStandardButtons but I would have to define a label for each button. By using predefined stock icons the labels are already predefined and are also automatically displayed in your local language (in my case in German).
You may also wonder why not every selected predefined icon size results in the correct resolution. This is caused by the fact that the predefined stock icons don't provide all listed possible resolutions. If you would provide an icon in all resolutions, the icon would be switched to the correct size!
Code: Select all
Procedure ChangeToolBarIconSize(ToolBarIconSize.I)
; ----- Change icon size of ToolBar
gtk_toolbar_set_icon_size_(ToolBarID(0), ToolBarIconSize)
; ----- Redisplay window to show modified ToolBar
gtk_widget_show_all_(WindowID(0))
EndProcedure
OpenWindow(0, 200, 100, 300, 250, "ToolBar")
; ----- Create toolbar and 3 API tool buttons
CreateToolBar(0, WindowID(0))
ToolButton = gtk_tool_button_new_from_stock_( #GTK_STOCK_DIALOG_INFO)
gtk_toolbar_insert_(ToolBarID(0), ToolButton, -1)
ToolButton = gtk_tool_button_new_from_stock_(#GTK_STOCK_DIALOG_WARNING)
gtk_toolbar_insert_(ToolBarID(0), ToolButton, -1)
ToolButton = gtk_tool_button_new_from_stock_(#GTK_STOCK_DIALOG_ERROR)
gtk_toolbar_insert_(ToolBarID(0), ToolButton, -1)
; ----- Define FrameGadget with 5 OptionGadgets for the different icon sizes
FrameGadget(0, 10, 5, 130, 150, "ToolBar icon size:")
OptionGadget(1, 10, 20, 110, 25, "16x16")
OptionGadget(2, 10, 45, 110, 25, "18x18")
OptionGadget(3, 10, 70, 110, 25, "20x20")
OptionGadget(4, 10, 95, 110, 25, "24x24")
OptionGadget(5, 10, 120, 110, 25, "32x32")
OptionGadget(6, 10, 145, 110, 25, "48x48")
SetGadgetState(4, #True)
; ----- Define FrameGadget with 3 display styles
FrameGadget(7, 150, 5, 130, 90, "ToolBar style:")
OptionGadget( 8, 160, 20, 110, 25, "Icon only")
OptionGadget( 9, 160, 45, 110, 25, "Label only")
OptionGadget(10, 160, 70, 110, 25, "Icon plus label")
SetGadgetState(8, #True)
; ----- Redisplay window to show modified ToolBar
gtk_widget_show_all_(WindowID(0))
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
Select EventGadget()
Case 1 ; 16x16
ChangeToolBarIconSize(#GTK_ICON_SIZE_MENU)
Case 2 ; 18x18
ChangeToolBarIconSize(#GTK_ICON_SIZE_SMALL_TOOLBAR)
Case 3 ; 20x20
ChangeToolBarIconSize(#GTK_ICON_SIZE_BUTTON)
Case 4 ; 24x24
ChangeToolBarIconSize(#GTK_ICON_SIZE_LARGE_TOOLBAR)
Case 5 ; 32x32
ChangeToolBarIconSize(#GTK_ICON_SIZE_DND)
Case 6 ; 48x48
ChangeToolBarIconSize(#GTK_ICON_SIZE_DIALOG)
Case 8
gtk_toolbar_set_style_(ToolBarID(0), #GTK_TOOLBAR_ICONS)
Case 9
gtk_toolbar_set_style_(ToolBarID(0), #GTK_TOOLBAR_TEXT)
Case 10
gtk_toolbar_set_style_(ToolBarID(0), #GTK_TOOLBAR_BOTH)
EndSelect
EndSelect
ForEver