Page 1 of 1

Copying window trees

Posted: Fri Oct 03, 2008 12:43
by cippyboy
Is there a way to copy a whole window tree ? Like, I have this window, with tons of widgets on it and I want to duplicate it and don't wanna copy-paste tons of XML with just a single position changed for each copy. Besides, I need a certain number of them so code is preferable.

I'm thinking I could recurs the whole tree and make copies of windows & properties, but that involves tons of renaming.

Posted: Sat Oct 04, 2008 09:55
by scriptkid
Hi,

you need a recursive copy, and you have to deal with naming issue ;)

The layout editor does the exact thing when it copies & pastes though. The code should be pretty straightforward and can be found in this file:
http://crayzedsgui.svn.sourceforge.net/ ... iew=markup

I think that -besides the pieces of wxWidgets code- the CopiedSelection class can be reused easily, so feel free to use it :)

There's one line which i didn't understand myself anymore: the check for "_TabPane_". I think that the if-statement is wrong, and should also have "!= npos" behind it. I'll look into this.

HTH.

Posted: Mon Oct 06, 2008 16:30
by cippyboy
Thanks, I thought it was built-in or something. As for the copied selection class, it looked pretty weird, like that map that I don't see why it's there, so i decided to write my own function today because I would have to intervene with a different naming scheme than it was presented there, but anyways, I managed to solve it, so thanks again :D

Posted: Mon Oct 06, 2008 18:08
by scriptkid
Hi,

not sure which map you mean, but glad that you have a working solution now :)

Maybe that one day, this copying should be part of Cegui itself...

Posted: Thu Oct 09, 2008 07:27
by CrazyEddie
scriptkid wrote:Maybe that one day, this copying should be part of Cegui itself...

I think this is a good thing to add to the TODO list :) We should also probably have a deep and a shallow 'mode' to copy either all the child content also, or just a given window.

CE.