Page 2 of 3

Re: Questions about the new XmlDialog

Posted: Tue Aug 20, 2013 9:39 pm
by IdeasVacuum
Good tip Little John, thanks.

Why does it take so long to compile 12 lines of code though?

Re: Questions about the new XmlDialog

Posted: Tue Aug 20, 2013 9:56 pm
by Little John
Compiling that code takes, say, half a second here on my old PC.

Very probably it is a special problem on your system. My first guess is your anti-virus program running in the background.

Re: Questions about the new XmlDialog

Posted: Wed Aug 21, 2013 9:30 am
by akj
@Kiffi:
Many thanks for your reply. I did exactly as you suggested, replacing my extra code by yours, but there is still a major problem.
The widths specified are honoured, but not the heights.

According to the incredibly useful WinDowse program (http://www.greatis.com/delphicb/windowse) the size of my displayed objects are:
Main window
--- Window W = 506 Window H = 1092
--- Client W = 500 Client H = 1061
Date gadget
--- Window W = 200 Window H = 32767
--- Client W =196 Client H = 32763

Why on earth does the date gadget have a height of 32767??
In case it is relevant I have dual monitors of size 1920x1080 and 1440x900 and am using PB 5.20 beta 12 under Windows 7 Ultimate service pack 1

Postscript:
If I use <singlebox> rather than <vbox> and <hbox> then the heights are honoured, but not the widths (the reverse of above). How strange.

Re: Questions about the new XmlDialog

Posted: Thu Aug 22, 2013 9:31 am
by Kiffi
@Fred (or @All): do you have an example to show how to use <panel>?

Code: Select all

<panel>
<tab />
</panel>
... shows a PanelGadget but without a Tab. I have tried several attributes (name, label, id, text) but with no effect.

Thanks in advance & Greetings ... Kiffi

P.S.: Same with listicon & column.

Re: Questions about the new XmlDialog

Posted: Sat Aug 24, 2013 7:27 am
by hallodri
@ kiffi
Have you had success with the panels?

Re: Questions about the new XmlDialog

Posted: Sat Aug 24, 2013 10:14 am
by Kiffi
hallodri wrote:@ kiffi
Have you had success with the panels?
unfortunately not.

Code: Select all

#Dialog = 0
#Xml = 0

Define XML.s

XML = "<window id='#PB_Any' width='300' height='300' name='test' text='test' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu'>"
XML + " <panel>"
XML + "  <tab>123</tab>"
XML + "  <tab text='123'></tab>"
XML + "  <tab id='123'></tab>"
XML + " </panel>"
XML + "</window>"

CatchXML(#Xml, @XML, StringByteLength(XML))
CreateDialog(#Dialog)
OpenXMLDialog(#Dialog, #Xml, "test")

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
Anyone else?

Greetings ... Kiffi

Re: Questions about the new XmlDialog

Posted: Sat Aug 24, 2013 10:22 am
by Fred
Looks like a bug, i'm on it.

edit: fixed for next beta.

Re: Questions about the new XmlDialog

Posted: Sat Aug 24, 2013 5:00 pm
by Kiffi
Fred wrote:edit: fixed for next beta.
Thanks! tabs inside of a panel are working now (since B13). :D

But columns inside a listicon are not displayed:

Code: Select all

#Dialog = 0
#Xml = 0

Define XML.s

XML = "<window id='#PB_Any' width='300' height='300' name='test' text='test' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu'>"
XML + " <panel>"

XML + "  <tab text='Tab 1 (Panel)' expand='yes'>"
XML + "   <panel>"
XML + "    <tab text='Tab 1'></tab>"
XML + "    <tab text='Tab 2'></tab>"
XML + "    <tab text='Tab 3'></tab>"
XML + "   </panel>"
XML + "  </tab>"

XML + "  <tab text='Tab 2 (Listicon)' expand='yes'>"
XML + "   <listicon>"
XML + "    <column text='Col 1' width='100'></column>"
XML + "    <column text='Col 2' width='100'></column>"
XML + "    <column text='Col 3' width='100'></column>"
XML + "   </listicon>"
XML + "  </tab>"

XML + "  <tab text='Tab 3'></tab>"
XML + " </panel>"
XML + "</window>"

CatchXML(#Xml, @XML, StringByteLength(XML))
CreateDialog(#Dialog)
OpenXMLDialog(#Dialog, #Xml, "test")

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
And: PB_Window_ScreenCentered still not working as expected.

Another question: in the documentation i read that the attribute expand="yes" is default. Currently is it not default (try to remove the attribute in my sample above).

Thanks in advance & Greetings ... Kiffi

Re: Questions about the new XmlDialog

Posted: Sat Aug 24, 2013 7:49 pm
by Fred
'columns' and 'items' are not supported for this version. Fixed the 'expand' issue.

Re: Questions about the new XmlDialog

Posted: Sat Aug 24, 2013 10:54 pm
by Andre
Fred wrote:'columns' and 'items' are not supported for this version. Fixed the 'expand' issue.
Fred, please add this functionality before releasing the final.

I often use the ListIconGadget for displaying structured information tables. Without the column support I can't use the new Dialog library... :cry:
Or is there any workaround in the meantime?

Thanks a lot! :D

Re: Questions about the new XmlDialog

Posted: Sat Aug 24, 2013 11:07 pm
by cptdark
What about ButtonImageGadget and ImageGadget?

How to add images using files or integrated in exe?

thanks

Re: Questions about the new XmlDialog

Posted: Sun Aug 25, 2013 12:47 am
by Fred
Andre wrote:
Fred wrote:'columns' and 'items' are not supported for this version. Fixed the 'expand' issue.
Fred, please add this functionality before releasing the final.

I often use the ListIconGadget for displaying structured information tables. Without the column support I can't use the new Dialog library... :cry:
Or is there any workaround in the meantime?

Thanks a lot! :D
Sure you can add the columns and the items after the dialog creation, it's not a problem (before your show it).

Re: Questions about the new XmlDialog

Posted: Sun Aug 25, 2013 12:48 am
by Fred
cptdark wrote:What about ButtonImageGadget and ImageGadget?

How to add images using files or integrated in exe?

thanks
The same way you would do with creating the window with regular PB command. Just use DialogGadget() to get the gadget number and you're done.

Re: Questions about the new XmlDialog

Posted: Sun Aug 25, 2013 5:19 am
by hallodri
Andre wrote:
Fred wrote:'columns' and 'items' are not supported for this version. Fixed the 'expand' issue.
Fred, please add this functionality before releasing the final.

I often use the ListIconGadget for displaying structured information tables. Without the column support I can't use the new Dialog library... :cry:
Or is there any workaround in the meantime?

Thanks a lot! :D

a small workaround

Code: Select all

;######################################################################
Procedure SearchListIcon(node, id=-1)
  Protected index.i
  Protected item.s
  
  While node And id = -1
    
    If LCase(GetXMLNodeName(node)) = "listicon"
      SearchListIcon(ChildXMLNode(node), Val(GetXMLAttribute(node, "id")))
    EndIf    
    
    If ChildXMLNode(node)           
      SearchListIcon(ChildXMLNode(node))
    EndIf        
    
    node = NextXMLNode(node)
  Wend
  
  index = 0
  
  While node And id > -1
    
    If index = 0
      RemoveGadgetColumn(id, 0)
    EndIf    
    
    If LCase(GetXMLNodeName(node)) = "column"      
      
      AddGadgetColumn(id, index, 
                      GetXMLAttribute(node, "text"), 
                      Val(GetXMLAttribute(node, "width")))
      index + 1
      
    Else
      Break
    EndIf    
    
    node = NextXMLNode(node)
    
  Wend
  
  index = 0
  
  While node And id > -1
    If LCase(GetXMLNodeName(node)) = "item"      
      
      item = ReplaceString(GetXMLNodeText(node), "\n", #LF$)
      
      AddGadgetItem(id, index, item)
      
      index + 1
    EndIf        
    
    node = NextXMLNode(node)
  Wend  
  
  
EndProcedure

;######################################################################
Procedure OpenXMLDialog2(Dialog, xml, Name.s, x, y, w, h, parent)
  
  Protected result
  
  result = OpenXMLDialog(Dialog, xml, Name.s, x, y, w, h, parent)  
  
  If result
    SearchListIcon(MainXMLNode(xml))
  EndIf  
  
  ProcedureReturn result
EndProcedure

;######################################################################
Macro OpenXMLDialog(Dialog, xml, Name, x=0, y=0, w=0, h=0, parent=0)
  OpenXMLDialog2(Dialog, xml, Name, x, y, w, h, parent)
EndMacro

;######################################################################
Procedure Main()
  
  Protected dialog 
  Protected xml 
  Protected xmlstring.s
  
  xmlstring = "<window id='#PB_Any' width='300' height='300' name='test' text='test' flags='#PB_Window_SizeGadget| #PB_Window_ScreenCentered | #PB_Window_SystemMenu'>"+
  xmlstring + "<panel>"+
  xmlstring + "	<tab text='First tab'>"+
  xmlstring + "		<vbox expand='item:1'>"+
  xmlstring + "			<listicon id='0' flags='#PB_ListIcon_FullRowSelect'>"+
  xmlstring + "				<column text='col0' width='150'/>"+
  xmlstring + "				<column text='col1' width='50'/>"+
  xmlstring + "				<column text='col2' width='50'/>"+
  xmlstring + "				<item>Item0\nItem1\nItem2</item>"+
  xmlstring + "				<item>Item0\nItem1\nItem2</item>"+
  xmlstring + "				<item>Item0\nItem1\nItem2</item>"+
  xmlstring + "				<item>Item0\nItem1\nItem2</item>"+
  xmlstring + "				<item>Item0\nItem1\nItem2</item>"+
  xmlstring + "			</listicon>"+
  xmlstring + "		</vbox>"+
  xmlstring + "		</tab>"+
  xmlstring + "</panel>"+
  xmlstring + "</window>"

  
  dialog = CreateDialog(#PB_Any)
  
  If dialog
    
    xml = CatchXML(#PB_Any, @xmlstring, StringByteLength(xmlstring));LoadXML(#PB_Any, "ui.xml")
    
    If xml
      
      If OpenXMLDialog(dialog, xml, "", #PB_Ignore, #PB_Ignore)
        
        While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend      
        
      EndIf    
      
      FreeXML(xml)      
    EndIf    
    
    FreeDialog(dialog)
  EndIf
  
EndProcedure:End Main()
@Fred
Please publish no half measures.

Re: Questions about the new XmlDialog

Posted: Sun Aug 25, 2013 9:29 am
by Fred
Here we go:

Code: Select all

Procedure Main()
 
  Protected dialog
  Protected xml
  Protected xmlstring.s
 
  xmlstring = "<window id='#PB_Any' width='300' height='300' name='test' text='test' flags='#PB_Window_SizeGadget| #PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_Invisible'>"+
              "<panel>"+
              "   <tab text='First tab'>"+
              "         <listicon id='0' flags='#PB_ListIcon_FullRowSelect'>"+
              "         </listicon>"+
              "   </tab>"+
              "</panel>"+
              "</window>"

 
  dialog = CreateDialog(#PB_Any)
 
  If dialog
   
    xml = CatchXML(#PB_Any, @xmlstring, StringByteLength(xmlstring));LoadXML(#PB_Any, "ui.xml")
   
    If xml
     
      If OpenXMLDialog(dialog, xml, "", #PB_Ignore, #PB_Ignore)
        AddGadgetColumn(0, 1, "Column 1", 50)
        AddGadgetColumn(0, 2, "Column 2", 50)
        AddGadgetColumn(0, 3, "Column 3", 50)
        AddGadgetColumn(0, 4, "Column 4", 50)
        
        For k = 0 To 10
          AddGadgetItem(0, -1, "Item "+k)
        Next
        
        HideWindow(DialogWindow(dialog), #False)
       
        While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend     
       
      EndIf   
     
      FreeXML(xml)     
    EndIf   
   
    FreeDialog(dialog)
  EndIf
 
EndProcedure:End Main()