Page 1 of 1

Edit a dialog vbox/hbox at runtime

Posted: Mon Mar 09, 2015 4:08 pm
by atomo
Hi,

Is it possible to add gadgets inside a dialog vbox/hbox after OpenXMLDialog has been called ?

Re: Edit a dialog vbox/hbox at runtime

Posted: Mon Mar 09, 2015 10:09 pm
by Andre
Unfortunately I think not.

It would be a dream, if you could easily do an 'update' to a dialog window, after it's content (more or less gadgets, the content of multi-line gadgets like listicons, textgadgets etc.) or it's font size has changed.

Several similar requests have been made, see here: http://www.purebasic.fr/english/search. ... mit=Search

Re: Edit a dialog vbox/hbox at runtime

Posted: Tue Mar 10, 2015 3:17 am
by RASHAD
Hi
I am not sure if the next snippet do the job or not
- Click OK to add a new Gadget
- Click Cancel to get the response from the new one

Code: Select all

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

XML$ = "<?xml version='1.0' ?>"+
       " <window id='0' name='test' text='Gridbox' minwidth='auto' minheight='auto' maxheight='auto' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>"+
       "  <hbox expand='item:3'>" +
       "    <button text='OK' height='40' width='80' id='10'/>"+
       "    <button text='Cancel' height='40' width='80' id='11'/>"+
       "    <empty/>"+
       "    <image name='fixedImage' height='40' width='40' />"+
       "  </hbox>"+
       " </window>"

Define XML.i
Define Dialog.i

XML.i = CatchXML(#PB_Any, @XML$, StringByteLength(XML$), 0, #XmlEncoding)
Dialog.i = CreateDialog(#PB_Any)
OpenXMLDialog(Dialog.i, XML.i, "test")

Define Image.i = CreateImage(#PB_Any, 40, 40)
StartDrawing(ImageOutput(Image.i))
Box(0,0,40,40, RGB(255,255,255))
Circle(20,20,17, RGB(255,0,0))
StopDrawing()
SetGadgetState(DialogGadget(Dialog.i, "fixedImage"), ImageID(Image.i))

Repeat
  Select WaitWindowEvent()
       Case #PB_Event_CloseWindow
              Quit =1
       Case #PB_Event_Gadget
              Select EventGadget()
                    Case 10
                           ;*************** Simple Add ****************************************
                           ;ResizeWindow(0,#PB_Ignore ,#PB_Ignore ,WindowWidth(0)+60,#PB_Ignore )
                           ;ButtonGadget(12,GadgetX(10)+170,GadgetY(10),60,40,"Button 12")
                           
                           ;***************  Keeping The Dialogue Properties **********************
                           FreeDialog(Dialog.i)
                           XML2$ = "<?xml version='1.0' ?>"+
                           " <window id='0' name='test' text='Gridbox' minwidth='auto' minheight='auto' maxheight='auto' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>"+
                           "  <hbox expand='item:4'>" +
                           "    <button text='OK' height='40' width='80' id='10'/>"+
                           "    <button text='NO' height='40' width='80' id='11'/>"+
                           "    <button text='Cancel' height='40' width='80' id='12'/>"+
                           "    <empty/>"+
                           "    <image name='fixedImage' height='40' width='40' />"+
                           "  </hbox>"+
                           " </window>"
                           XML.i = CatchXML(#PB_Any, @XML2$, StringByteLength(XML2$), 0, #XmlEncoding)                           
                           Dialog.i = CreateDialog(#PB_Any)
                           OpenXMLDialog(Dialog.i, XML.i, "test")
                           SetGadgetState(DialogGadget(Dialog.i, "fixedImage"), ImageID(Image.i))
                           
                    Case 12
                            Debug "Cancel"
              EndSelect
  EndSelect                  
Until Quit =1 
CloseWindow(DialogWindow(Dialog.i))

End