Questions about the new XmlDialog

Everything else that doesn't fall into one of the other PB categories.
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Questions about the new XmlDialog

Post by IdeasVacuum »

Good tip Little John, thanks.

Why does it take so long to compile 12 lines of code though?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Little John
Addict
Addict
Posts: 4779
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Questions about the new XmlDialog

Post 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.
akj
Enthusiast
Enthusiast
Posts: 668
Joined: Mon Jun 09, 2003 10:08 pm
Location: Nottingham

Re: Questions about the new XmlDialog

Post 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.
Anthony Jordan
User avatar
Kiffi
Addict
Addict
Posts: 1486
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Questions about the new XmlDialog

Post 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.
Hygge
User avatar
hallodri
Enthusiast
Enthusiast
Posts: 208
Joined: Tue Nov 08, 2005 7:59 am
Location: Germany
Contact:

Re: Questions about the new XmlDialog

Post by hallodri »

@ kiffi
Have you had success with the panels?
User avatar
Kiffi
Addict
Addict
Posts: 1486
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Questions about the new XmlDialog

Post 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
Hygge
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Questions about the new XmlDialog

Post by Fred »

Looks like a bug, i'm on it.

edit: fixed for next beta.
User avatar
Kiffi
Addict
Addict
Posts: 1486
Joined: Tue Mar 02, 2004 1:20 pm
Location: Amphibios 9

Re: Questions about the new XmlDialog

Post 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
Hygge
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Questions about the new XmlDialog

Post by Fred »

'columns' and 'items' are not supported for this version. Fixed the 'expand' issue.
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2137
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Re: Questions about the new XmlDialog

Post 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
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
cptdark

Re: Questions about the new XmlDialog

Post by cptdark »

What about ButtonImageGadget and ImageGadget?

How to add images using files or integrated in exe?

thanks
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Questions about the new XmlDialog

Post 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).
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Questions about the new XmlDialog

Post 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.
User avatar
hallodri
Enthusiast
Enthusiast
Posts: 208
Joined: Tue Nov 08, 2005 7:59 am
Location: Germany
Contact:

Re: Questions about the new XmlDialog

Post 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.
Last edited by hallodri on Wed Aug 28, 2013 6:18 pm, edited 1 time in total.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: Questions about the new XmlDialog

Post 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()
Post Reply