Page 1 of 1

PB5.20B15 Dialog with menu or toolbar layouting wrong

Posted: Sun Sep 01, 2013 12:12 pm
by uwekel
Hi,

if i create a dialog and add a menu or toolbar afterwards, the layout engine does not take menu height and toolbar height into account.

Here is an example:

Code: Select all

#Dialog = 0
#Xml = 0

XML$ +
"<window id='0' width='200' height='200' name='test' text='Test' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu'>" +
"  <button text='Click'/>" +
"</window>"

If CatchXML(#Xml, @XML$, StringByteLength(XML$)) And XMLStatus(#Xml) = #PB_XML_Success
  If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "test")
    
    CreateMenu(0, WindowID(0))
    MenuTitle("File")
    
    CreateToolBar(0, WindowID(0))
    ToolBarStandardButton(0, #PB_ToolBarIcon_New)
    
    Repeat
      Event = WaitWindowEvent()
    Until Event = #PB_Event_CloseWindow
  Else
    Debug "Dialog error: " + DialogError(#Dialog)
  EndIf
Else
  Debug "XML error: " + XMLError(#Xml) + " (Line: " + XMLErrorLine(#Xml) + ")"
EndIf
This makes it impossible to use the great layouting features in applications main window with menu and tool bar :-(

Best regards
Uwe

Re: PB5.20B15 Dialog with menu or toolbar layouting wrong

Posted: Mon Sep 02, 2013 7:56 pm
by uwekel
Maybe better if the Dialog would support menu and toolbar creation , e.g. like this:

Code: Select all

<menu>
<menutitle text='File' />
<menuitem text='Open...' onevent='OnFileOpen()' shortcut='Ctrl+O' icon='0' />
<menubar>
...
</menu>
Best regards
Uwe

Re: PB5.20B15 Dialog with menu or toolbar layouting wrong

Posted: Sat Sep 07, 2013 7:24 pm
by hallodri
The same under Windows, Beta 17

Re: PB5.20B15 Dialog with menu or toolbar layouting wrong

Posted: Wed Sep 11, 2013 11:04 am
by Fred
Menu are not supported on dialog for now.

Re: PB5.20B15 Dialog with menu or toolbar layouting wrong

Posted: Tue Jul 29, 2014 3:38 pm
by Olby
This a real show-stopper. Just tried to use status bar with an XML dialog. Shame they don't work with each other. :(

Re: PB5.20B15 Dialog with menu or toolbar layouting wrong

Posted: Sun Oct 18, 2015 11:27 am
by Xanos
Currently, I use an empty text element in a vbox, however this is only a workaround and may cause different problems depending on the menu height.
Of course it would be much better, if the internal layout calculation would take only the "inner size" into account, not depending on space that is occupied by menu or something else that messes up the layout.

My current workaround, that works at least with the menu-height in Windows 10 (all standard):

Code: Select all

CompilerIf #PB_Compiler_Unicode
    #XmlEncoding = #PB_UTF8
  CompilerElse 
    #XmlEncoding = #PB_Ascii
  CompilerEndIf

  #Dialog = 0
  #Xml = 0
  
  XML$ = ~"<window id='#PB_Any' name='main' text='Menubar Test' minwidth='400' minheight='200' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>\n" +
         "  <vbox expand='item:2'>\n" +
         "    <text text='Some Content'></text>\n"+
         "    <button text='Some Button'></button>\n" +
         "    <text text=' '></text>" + ; menu placeholder
         "  </vbox>\n" +
         "</window>"
  
  If CatchXML(#Xml, @XML$, StringByteLength(XML$), 0, #XmlEncoding) And XMLStatus(#Xml) = #PB_XML_Success
    
    If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "main")
      
      CreateMenu(0, WindowID(DialogWindow(#dialog)))
      MenuTitle("Test")
      MenuItem(1, "1")
      MenuItem(2, "2")
      
      Repeat
        Event = WaitWindowEvent()
      Until Event = #PB_Event_CloseWindow 
      
    Else  
      Debug "Dialog error: " + DialogError(#Dialog)
    EndIf
  Else
    Debug "XML error: " + XMLError(#Xml) + " (Line: " + XMLErrorLine(#Xml) + ")"
  EndIf