PB5.20B15 Dialog with menu or toolbar layouting wrong

Just starting out? Need help? Post your questions and find answers here.
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

PB5.20B15 Dialog with menu or toolbar layouting wrong

Post 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
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
uwekel
Enthusiast
Enthusiast
Posts: 740
Joined: Sat Dec 03, 2011 5:54 pm
Location: Oldenburg (Germany)

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

Post 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
PB 5.70 LTS (x64) - Debian Testing, Gnome 3.30.2
User avatar
hallodri
Enthusiast
Enthusiast
Posts: 208
Joined: Tue Nov 08, 2005 7:59 am
Location: Germany
Contact:

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

Post by hallodri »

The same under Windows, Beta 17
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

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

Post by Fred »

Menu are not supported on dialog for now.
Olby
Enthusiast
Enthusiast
Posts: 461
Joined: Mon Jan 12, 2009 10:33 am
Contact:

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

Post 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. :(
Intel Core i7 Quad 2.3 Ghz, 8GB RAM, GeForce GT 630M 2GB, Windows 10 (x64)
User avatar
Xanos
User
User
Posts: 45
Joined: Sat Feb 28, 2015 1:20 pm

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

Post 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
Programming on Windows 10 Pro / Windows 7 Enterprise / Linux Mint 19 / Manjaro Linux with PB 5, Python 3 and Go
Post Reply