Page 1 of 1

Multiple questions about new Dialog feature

Posted: Thu Oct 31, 2013 3:21 pm
by Kukulkan
Hi,

this is to show my questions:

Code: Select all

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

#Dialog = 0
#Xml = 0

XML$ = "<?xml version='1.0' ?>"+
       " <window id='#PB_Any' name='test' text='Gridbox' minwidth='auto' minheight='auto' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>"+
       "   <gridbox columns='2'>"+
       "     <option name='cboProxy1' colspan='2' text='Keinen Proxy verwenden'/>"+
       "     <option name='cboProxy2' colspan='2' text='Proxy Server verwenden (server:port):'/>"+
       "     <empty /><string name='strProxyURL' minwidth='450' />"+
       "     <option name='cboProxy3' colspan='2' text='Proxy Autoconfiguration File (PAC) verwenden:'/>"+
       "     <empty /><string name='strProxyPACURL' minwidth='450' />"+
       "     <empty /><hbox>"+
       "                 <button name='btnOK' text='OK' />"+
       "                 <button name='btnCancel' text='Abbruch'/>"+
       "              </hbox>"+
       "   </gridbox>"+
       " </window>"

If CatchXML(#Xml, @XML$, StringByteLength(XML$), 0, #XmlEncoding) And XMLStatus(#Xml) = #PB_XML_Success
  
  If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "test")
    
    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
Question 1: No matter to what I set the minwidth of strProxyURL and strProxyPACURL, it seems ignored.

Question 2: How to make the option boxes (cboProxy) being grouped to each other (only one allowed to be set at any time). Is there something I've missed? Maybe some group identifier?

Question 3: How to make the first column having a fixed size or at least a minimum size? It simply takes to much space. How to limit the size of a column?

Can somebody please help me? I like to use this new feature but it seems a little tricky...

Kukulkan

Re: Multiple questions about new Dialog feature

Posted: Thu Oct 31, 2013 3:51 pm
by Fred
Q1: there is no 'minwidth' for gadget, only 'width' (which actually act as minwidth).

Q2: for now, you can't. Should be doable by code if you really need that.

Q3: I don't see why you need a column, but you can use 'width' to set one

Here is a slightly modified version:

Code: Select all

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

#Dialog = 0
#Xml = 0

XML$ = "<?xml version='1.0' ?>"+
       " <window id='#PB_Any' name='test' text='Gridbox' minwidth='auto' minheight='auto' maxheight='auto' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>"+
       "   <gridbox columns='1'>"+
       "     <option name='cboProxy1' colspan='2' text='Keinen Proxy verwenden'/>"+
       "     <option name='cboProxy2' colspan='2' text='Proxy Server verwenden (server:port):'/>"+
       "     <string name='strProxyURL' width='450' />"+
       "     <option name='cboProxy3' colspan='2' text='Proxy Autoconfiguration File (PAC) verwenden:'/>"+
       "     <string name='strProxyPACURL' width='450' />"+
       "     <hbox>"+
       "                 <button name='btnOK' text='OK' />"+
       "                 <button name='btnCancel' text='Abbruch'/>"+
       "              </hbox>"+
       "   </gridbox>"+
       " </window>"

If CatchXML(#Xml, @XML$, StringByteLength(XML$), 0, #XmlEncoding) And XMLStatus(#Xml) = #PB_XML_Success
 
  If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "test")
   
    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

Re: Multiple questions about new Dialog feature

Posted: Thu Oct 31, 2013 4:34 pm
by Kukulkan
Hi Fred,

thanks for the quick reply.

For 1) this helps.

For 2) I think this is mandatory. Otherwise <option> is more or less useless...

For 3) It is because the string fields need to be aligned below the text beginning of the option above. It looks more grouped and clearly arranged.
I don't see why you need a column, but you can use 'width' to set one
Can you please give me an example? How can the 'width' be used to define a column width?

Kukulkan

Re: Multiple questions about new Dialog feature

Posted: Thu Oct 31, 2013 5:55 pm
by Fred
Q2: it's like in PB code, they have to be grouped in XML for now to act as group.

Q3: you can set 'width' to one empty element, and use colexpand="item:2" to specify which column needs to grow

Code: Select all

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

#Dialog = 0
#Xml = 0

XML$ = "<?xml version='1.0' ?>"+
       " <window id='#PB_Any' name='test' text='Gridbox' minwidth='auto' minheight='auto' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>"+
       "   <gridbox columns='2' colexpand='item:2'>"+
       "     <option name='cboProxy1' colspan='2' text='Keinen Proxy verwenden'/>"+
       "     <option name='cboProxy2' colspan='2' text='Proxy Server verwenden (server:port):'/>"+
       "     <empty width='10'/><string name='strProxyURL' minwidth='450' />"+
       "     <option name='cboProxy3' colspan='2' text='Proxy Autoconfiguration File (PAC) verwenden:'/>"+
       "     <empty/><string name='strProxyPACURL' width='450' />"+
       "     <hbox  colspan='2'>"+
       "                 <button name='btnOK' text='OK' />"+
       "                 <button name='btnCancel' text='Abbruch'/>"+
       "              </hbox>"+
       "   </gridbox>"+
       " </window>"

If CatchXML(#Xml, @XML$, StringByteLength(XML$), 0, #XmlEncoding) And XMLStatus(#Xml) = #PB_XML_Success
 
  If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "test")
   
    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

Re: Multiple questions about new Dialog feature

Posted: Thu Oct 31, 2013 5:59 pm
by Kukulkan
Fred wrote:Q2: it's like in PB code, they have to be grouped in XML for now to act as group.
But in PB it is ok to be on the same container (like frame gadget). And in PB it does not matter if there is another gadget between. In XML it seems out of group even if there is another gadget between.

I do not use the event binding for the dialog. Any idea about how to handle this easily in PB event loop?
Fred wrote:Q3: you can set 'width' to one empty element, and use colexpand="item:2" to specify which column needs to grow
This works, fine! Thank you!

Kukulkan

Re: Multiple questions about new Dialog feature

Posted: Thu Oct 31, 2013 6:01 pm
by Fred
I don't know how to make it generic, but for a case by case basis, it's just SetGadgetState() on the other options when clicking on one. You can use DialogGadget() to get the gadget. But you are right, it should have an option to create easily groups in XML.

Re: Multiple questions about new Dialog feature

Posted: Thu Oct 31, 2013 6:23 pm
by Danilo
Kukulkan wrote:And in PB it does not matter if there is another gadget between.
Other gadget type ends the group. PB help for OptionGadget():
The first time this function is called, a group is created and all following calls of OptionGadget() will add a gadget to this group. To finish the group, just create a gadget of another type.

Re: Multiple questions about new Dialog feature

Posted: Sat Nov 02, 2013 11:56 am
by Kukulkan
Danilo, you are right. But I can handle the order of gadget creation and therefore it is easy to solve:

Code: Select all

If OpenWindow(0, 0, 0, 160, 140, "OptionGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
  FrameGadget(#PB_Any, 20, 5, 120, 120, "FrameGadget")
  OptionGadget(#PB_Any, 30, 20, 60, 20, "Option 1")
  OptionGadget(#PB_Any, 30, 70, 60, 20, "Option 2")
  OptionGadget(#PB_Any, 30, 95, 60, 20, "Option 3")
  StringGadget(#PB_Any, 30, 45, 60, 20, "String")
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
But I cant for the XML version... Or did I miss something?

Kukulkan

Re: Multiple questions about new Dialog feature

Posted: Tue Sep 01, 2015 7:56 pm
by Shardik
Fred in announcement of PB 5.40 Beta 1 wrote:- Added "group" XML attribute for 'option' dialog gadget, to specify explicitly a group
Now with the new 'group' attribute for the 'option' dialog Kukulkan's code example from his first posting (or Fred's modified example) is working fine cross-platform (tested with PB 5.40 Beta 1 on Windows XP SP3, Kubuntu 14.04 x86 and MacOS X Yosemite x86):

Code: Select all

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

#Dialog = 0
#Xml = 0

XML$ = "<?xml version='1.0' ?>"+
       " <window id='#PB_Any' name='test' text='Gridbox' minwidth='auto' minheight='auto' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>"+
       "   <gridbox columns='2'>"+
       "     <option group='1' name='cboProxy1' colspan='2' text='Keinen Proxy verwenden'/>"+
       "     <option group='1' name='cboProxy2' colspan='2' text='Proxy Server verwenden (server:port):'/>"+
       "     <empty /><string name='strProxyURL' minwidth='450' />"+
       "     <option group='1' name='cboProxy3' colspan='2' text='Proxy Autoconfiguration File (PAC) verwenden:'/>"+
       "     <empty /><string name='strProxyPACURL' minwidth='450' />"+
       "     <empty /><hbox>"+
       "                 <button name='btnOK' text='OK' />"+
       "                 <button name='btnCancel' text='Abbruch'/>"+
       "              </hbox>"+
       "   </gridbox>"+
       " </window>"

If CatchXML(#Xml, @XML$, StringByteLength(XML$), 0, #XmlEncoding) And XMLStatus(#Xml) = #PB_XML_Success
 
  If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "test")
    SetGadgetState(DialogGadget(0, "cboProxy1"), #True)

    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
Thank you PB team!

Re: Multiple questions about new Dialog feature

Posted: Wed Sep 02, 2015 7:27 am
by Kukulkan
Yes, this is nice and it was absolutely needed and necessary. Only pity that it took almost two years...

Re: Multiple questions about new Dialog feature

Posted: Wed Sep 02, 2015 5:04 pm
by blueb
Kukulkan wrote:Yes, this is nice and it was absolutely needed and necessary. Only pity that it took almost two years...
"Patience is bitter; but the fruit is sweet" :mrgreen: