jassing wrote:It seems status bar doesn't use constants; it uses 0, so multiple windows get fubar'd
Similarly for toolbars & menus...
Shouldn't you be able to add a toolbar to a container?
From generated code:
Code: Select all
CreateToolBar(0, WindowID(#Window_0))
CreateStatusBar(0, WindowID(#Window_0))
StatusBarText(0, 0, "Label")
CreateMenu(0, WindowID(#Window_0))
Should be able to name each with a constant like any other gadget.. no?
You can already do each of the things you requested. The constants for menu# are generally the same for each place that menu option occurs across different menus and toolbars. This is so that the event loop can handle each of them the same. If you want to handle them differently then give them different values.
Here is some code demonstrating toolbars and statusbars:
Code: Select all
Enumeration windows
#window_0
#window_1
EndEnumeration
Enumeration gadgets
#container_0
EndEnumeration
Enumeration statusBars
#statusBar_window_0
#statusBar_window_1
#statusBar_container_0
EndEnumeration
Enumeration toolBars
#toolBar_container_0
#toolBar_window_0
#toolBar_window_1
EndEnumeration
If OpenWindow(#window_0, 0, 0, 600, 500, "StatusBar", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget) And
OpenWindow(#window_1, 0, 0, 600, 50, "StatusBar", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget)
UseGadgetList(WindowID(#window_0))
If ContainerGadget(#container_0, 0, 100, 550, 150,#PB_Container_Single)
If CreateStatusBar(2, GadgetID(#container_0))
AddStatusBarField(100)
AddStatusBarField(#PB_Ignore) ; automatically resize this field
AddStatusBarField(200)
StatusBarText(#statusBar_container_0, 0, "con_0 Area norm")
StatusBarText(#statusBar_container_0, 2, "con_0 Area right & raised", #PB_StatusBar_Right | #PB_StatusBar_Raised)
StatusBarText(#statusBar_container_0, 1, "con_0 Area centered", #PB_StatusBar_Center)
EndIf
If CreateToolBar(#toolBar_container_0, GadgetID(#container_0))
ToolBarStandardButton(2, #PB_ToolBarIcon_Save)
ToolBarStandardButton(0, #PB_ToolBarIcon_New)
ToolBarStandardButton(1, #PB_ToolBarIcon_Open)
EndIf
EndIf
;window statusbars
If CreateStatusBar(#statusBar_window_0, WindowID(#window_0))
AddStatusBarField(100)
AddStatusBarField(#PB_Ignore) ; automatically resize this field
AddStatusBarField(200)
StatusBarText(#statusBar_window_0, 0, "win_0 Area norm")
StatusBarText(#statusBar_window_0, 2, "win_0 Area right & raised", #PB_StatusBar_Right | #PB_StatusBar_Raised)
StatusBarText(#statusBar_window_0, 1, "win_0 Area centered", #PB_StatusBar_Center)
EndIf
If CreateStatusBar(#statusBar_window_1, WindowID(#window_1))
AddStatusBarField(100)
AddStatusBarField(#PB_Ignore) ; automatically resize this field
AddStatusBarField(200)
StatusBarText(#statusBar_window_1, 0, "win_1 Area norm")
StatusBarText(#statusBar_window_1, 2, "win_1 Area right & raised", #PB_StatusBar_Right | #PB_StatusBar_Raised)
StatusBarText(#statusBar_window_1, 1, "win_1 Area centered", #PB_StatusBar_Center)
EndIf
;window toolbars
If CreateToolBar(#toolBar_window_1, WindowID(#window_1))
ToolBarStandardButton(1, #PB_ToolBarIcon_Open)
ToolBarStandardButton(2, #PB_ToolBarIcon_Save)
ToolBarStandardButton(0, #PB_ToolBarIcon_New)
EndIf
If CreateToolBar(#toolBar_window_0, WindowID(#window_0))
ToolBarStandardButton(0, #PB_ToolBarIcon_New)
ToolBarStandardButton(1, #PB_ToolBarIcon_Open)
ToolBarStandardButton(2, #PB_ToolBarIcon_Save)
EndIf
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
You'll notice that the trick is to use GadgetID() instead of WidowID() when using a gadget as the target instead of a window.