Custom window class

Apostate

20-08-2012 14:28:53

This feels like it's going to be another dumb question, but I'll ask anyways. I made a console window in the layout editor and exported a class cpp/h for it. I'm using

MyGUI::LayoutManager::getInstance().loadLayout("console.layout");

to make an instance of it. I can use

MyGUI::WindowPtr console = m_GUI->findWidget<MyGUI::Window>("consoleWindow");

to find it as a WindowPtr, but how do I go from there to the ConsoleWindow class I made for it so i can actually use the functions I added to it? Apparently I can just do

ConsoleWindow* console = new ConsoleWindow()

instead of loadLayout and hold onto the ConsoleWindow*, but I'd rather not have to track all my windows myself if I don't have to, although I will if that's what I'm supposed to be doing. It doesn't like trying to cast from MyGUI::WindowPtr to my ConsoleWindow* (I guess this class is more a container of widgets than an actual widget or something?). I haven't been able to find anything in the docs about this, so I'm just kind of making it up as I go along. How is this supposed to work? :oops:

Apostate

24-08-2012 23:02:30

So is there a way to do this or do I have to track the windows myself?

my.name

27-08-2012 07:10:53

look at demos
BaseLayout class

Apostate

03-09-2012 20:39:50

The demos looks like they're just doing ConsoleWindow* = new ConsoleWindow(), which is a little annoying, but I can live with that. I was also getting an assert complaining about not finding a "_Main" or "Root" widget until I noticed that that was what was being used as the name for the console window in the console demo. Then I found it checking specifically for those names in BaseLayout.h. I guess the root window in a custom widget always has to be named "_Main" or "Root"? Would it not be possible for the Layout Editor to auto-name the root window for you, or make a sort of invisible dummy node that encapsulates everything in the layout as the root/main node? It looks like it's doing basically that after the log/assert message anyway, and it still seems to work, so I just kind of wonder why it doesn't just do that by default.

Anyway, I think I have it working now. Thanks for the pointer in the right direction :)