Form designer & status bars

Post bugs related to the IDE here
jassing
Addict
Addict
Posts: 1768
Joined: Wed Feb 17, 2010 12:00 am

Form designer & status bars

Post by jassing »

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?
Last edited by jassing on Sun Dec 14, 2014 12:33 am, edited 1 time in total.
User avatar
Demivec
Addict
Addict
Posts: 4089
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: For designer & status bars

Post by Demivec »

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.
jassing
Addict
Addict
Posts: 1768
Joined: Wed Feb 17, 2010 12:00 am

Re: For designer & status bars

Post by jassing »

Hm. I created a new form, added a status bar -- I can't see where to specify it's constant for enumeration...
In fact, there's no setting for the status bar, just for the individual statusbar field. And for the field there is no 'variable' setting for a constant/enumeration.
The menu is always '0' (I can change the menu item)
Toolbar is same as menu, the toolbar itself is '0'.
If I create a form; then add a menu, toolbar, and status bar, and look at the windows "Objects" nothing is listed.
No matter how hard I try, I can't add or cut/copy a toolbar to a container...

I know the form designer is new... but you should be able set simple parameters (like a statusbar field constant) Gadgets also lack all the constants/flags available (and no way to add them)...

I guess if this was all by design, then it's not a bug.. thanks for your time.
User avatar
Demivec
Addict
Addict
Posts: 4089
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: For designer & status bars

Post by Demivec »

jassing wrote:I guess if this was all by design, then it's not a bug.. thanks for your time.
That may be but I can't confirm that because I haven't used the Form Designer yet.

It seems that I mistook your original question. You titled the thread 'For designer & status bars'. I see now it was probably a typo and you meant something like 'Form designer & status bars' but also didn't mention the Form Designer in your first post either. :oops:
jassing
Addict
Addict
Posts: 1768
Joined: Wed Feb 17, 2010 12:00 am

Re: Form designer & status bars

Post by jassing »

Demivec wrote:
jassing wrote:That may be but I can't confirm that because I haven't used the Form Designer yet.

It seems that I mistook your original question. You titled the thread 'For designer & status bars'. I see now it was probably a typo and you meant something like 'Form designer & status bars' but also didn't mention the Form Designer in your first post either. :oops:
Indeed -- sorry about that.
Post Reply