Swapping Window Parents

BlitzMax Forums/MaxGUI Module/Swapping Window Parents

USNavyFish(Posted 2008) [#1]
At one point in my program, I free a window and rebuild a new one.

That window has several children, and I would like to be able to transfer the children to the new instance of the window, without having to completely re-create the child windows.

Is this possible? Essentially I'm asking if it's possible to 're-parent' windows.

Perhaps one could initially group the child windows to a window pointer, and then simply redirect that pointer once it comes time to free the main window? I do not know how this would be done.

Any advice would be greatly appreciated.


CS_TBL(Posted 2008) [#2]
Mmm dunno exactly, I think not btw. However, creating a new window with child objects shouldn't be rocket science.

Function MakeMyWindow:tgadget()
  Local Window:tgadget=CreateWindow(yadayadayada)
  ..
  CreateButton(yadayadayada,..,..,..,Window)
  ..
  Return Window
End Function


Et Voila, a new window with all your gadgets has been created.

Alternatively:
Function MakeMyWindow(parent:tgadget)
  ..
  CreateButton(yadayadayada,..,..,..,parent)
  ..
End Function


Alternatively:
Type WindowContent
  field window:tgadget
  field button:tgadget
  field slider:tgadget
  field editfield:tgadget
End Type

function FillWindow(w:WindowContent)
  w.window=CreateWindow(yadayada)
  w.button=CreateButton(whoopiedoo)
  w.slider=CreateSlider(bidibidi)
  w.editfield=CreateEditfield(mimimimi)
end function

local myWindowContent:WindowContent=new WindowContent

FillWindow



Brucey(Posted 2008) [#3]
but the whole point of re-parenting is the fact that all you need to do is point the child at a new parent, rather than having to completely rebuild everything, including states, list positions, etc.

You want to be able to do something like :
  myPanel.Reparent(newParentWindow)

One line of code...

MaxGUI isn't really designed for doing anything as complicated as this though... :-p



However, here's an example of BlitzMax doing just that : reparent_example.zip (1.3meg)

:-)


USNavyFish(Posted 2008) [#4]
CS_TBL: My current implementation is function-based as demonstrated in your third example.

Unfortunately, it's kind of slow. I have to free then recreate about 20 TGadgets.


Brucey:

I'm currently having fun building my own 'framework' but am quite impressed by your wxMax module. I may run through a few of the tutorials after this project and learn your system. Looks far more functional than I could ever expect to produce anytime soon!

I assume you do your reparenting through C-code and Win32 interfacing. I don't plan on delving that deep, so unless someone's made a maxgui module for reparenting, it looks like I'll have to accept the speed hit.



Of course, there could be a much simpler solution, and perhaps someone has that answer. The reason I want to reparent is because I am creating a new window everytime I switch my MaxGUI-canvas-based OpenGL context between fullscreen mode and windowed mode.

For some reason, using SetGadgetShape does NOT give me a full-screen window (It leaves the taskbar). Creating a new window with the fullscreen resolution does, however. Any ideas?


jsp(Posted 2008) [#5]
Is this what you are looking for:
http://jsp.logiczone.de/downloads/SwitchParent.zip