Re: Questions about the new XmlDialog
Posted: Tue Aug 20, 2013 9:39 pm
Good tip Little John, thanks.
Why does it take so long to compile 12 lines of code though?
Why does it take so long to compile 12 lines of code though?
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
<panel>
<tab />
</panel>
unfortunately not.hallodri wrote:@ kiffi
Have you had success with the panels?
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
Thanks! tabs inside of a panel are working now (since B13).Fred wrote:edit: fixed for next beta.
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
Fred, please add this functionality before releasing the final.Fred wrote:'columns' and 'items' are not supported for this version. Fixed the 'expand' issue.
Sure you can add the columns and the items after the dialog creation, it's not a problem (before your show it).Andre wrote:Fred, please add this functionality before releasing the final.Fred wrote:'columns' and 'items' are not supported for this version. Fixed the 'expand' issue.
I often use the ListIconGadget for displaying structured information tables. Without the column support I can't use the new Dialog library...![]()
Or is there any workaround in the meantime?
Thanks a lot!
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.cptdark wrote:What about ButtonImageGadget and ImageGadget?
How to add images using files or integrated in exe?
thanks
Andre wrote:Fred, please add this functionality before releasing the final.Fred wrote:'columns' and 'items' are not supported for this version. Fixed the 'expand' issue.
I often use the ListIconGadget for displaying structured information tables. Without the column support I can't use the new Dialog library...![]()
Or is there any workaround in the meantime?
Thanks a lot!
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()
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()