When using a derived window public from CEGUI::Window, how to create it.
Window *wnd = winMgr.createWindow("TaharezLook/FrameWindow", "Demo Window"); //It works
root->addChildWindow(wnd);
Window *wnd = new CTitleWindow("TaharezLook/FrameWindow", "Demo Window"); //Nothing showed up
root->addChildWindow(wnd);
CTitleWindow is a class public from CEGUI::Window, and did nothing.
How to create my own window?
Moderators: CEGUI MVP, CEGUI Team
Thank you, I found that I need a WindowFactory, so I do that, but...
this is TitleWindow.h
#pragma once
#include <CEGUI/CEGUIWindow.h>
#include <CEGUI/CEGUIWindowFactory.h>
class CTitleWindow : public CEGUI::Window
{
public:
static const CEGUI::String WidgetTypeName; //!< Window factory name
CTitleWindow(const CEGUI::String& type, const CEGUI::String& name);
virtual ~CTitleWindow();
};
namespace CEGUI
{
CEGUI_DECLARE_WINDOW_FACTORY(CTitleWindow)
}
This is TitleWindow.cpp
#include "TitleWindow.h"
using namespace CEGUI;
const String CTitleWindow::WidgetTypeName("TitleWindow");
namespace CEGUI
{
CEGUI_DEFINE_WINDOW_FACTORY(CTitleWindow)
}
CTitleWindow::CTitleWindow(const String& type, const String& name)
:Window(type, name)
{
}
CTitleWindow::~CTitleWindow()
{
}
And the code to create window.
WindowFactoryManager& wfMgr = WindowFactoryManager::getSingleton();
wfMgr.addFactory(&CEGUI_WINDOW_FACTORY(CTitleWindow));
//Window *wnd = new CTitleWindow("TaharezLook/FrameWindow", "Demo Window");
Window *wnd = winMgr.createWindow("TitleWindow", "Title Window");
root->addChildWindow(wnd);
It does'n work. What's wrong?
this is TitleWindow.h
#pragma once
#include <CEGUI/CEGUIWindow.h>
#include <CEGUI/CEGUIWindowFactory.h>
class CTitleWindow : public CEGUI::Window
{
public:
static const CEGUI::String WidgetTypeName; //!< Window factory name
CTitleWindow(const CEGUI::String& type, const CEGUI::String& name);
virtual ~CTitleWindow();
};
namespace CEGUI
{
CEGUI_DECLARE_WINDOW_FACTORY(CTitleWindow)
}
This is TitleWindow.cpp
#include "TitleWindow.h"
using namespace CEGUI;
const String CTitleWindow::WidgetTypeName("TitleWindow");
namespace CEGUI
{
CEGUI_DEFINE_WINDOW_FACTORY(CTitleWindow)
}
CTitleWindow::CTitleWindow(const String& type, const String& name)
:Window(type, name)
{
}
CTitleWindow::~CTitleWindow()
{
}
And the code to create window.
WindowFactoryManager& wfMgr = WindowFactoryManager::getSingleton();
wfMgr.addFactory(&CEGUI_WINDOW_FACTORY(CTitleWindow));
//Window *wnd = new CTitleWindow("TaharezLook/FrameWindow", "Demo Window");
Window *wnd = winMgr.createWindow("TitleWindow", "Title Window");
root->addChildWindow(wnd);
It does'n work. What's wrong?
I found a sample in Sample_MineSweeper, and solve the problem.
The code I post can compile and run, but didn't show my TitleWindow.
Then I found the reason. I didn't assign any skin to TitleWindow, so it can't be seen. I add a "TaharezLook/FrameWindow" child window to Title window, and the window showed up.
But I still have some question, how could I assign skins to my window? The regular way is createWindow("TaharezLook/FrameWindow");
But I createWindow("MyWindowType").
Can I assign a skin to my window, instead of add a childWindow, to let my window be visible?
The code I post can compile and run, but didn't show my TitleWindow.
Then I found the reason. I didn't assign any skin to TitleWindow, so it can't be seen. I add a "TaharezLook/FrameWindow" child window to Title window, and the window showed up.
But I still have some question, how could I assign skins to my window? The regular way is createWindow("TaharezLook/FrameWindow");
But I createWindow("MyWindowType").
Can I assign a skin to my window, instead of add a childWindow, to let my window be visible?
- lindquist
- CEGUI Team (Retired)
- Posts: 770
- Joined: Mon Jan 24, 2005 21:20
- Location: Copenhagen, Denmark
First. There is a lot more to using a skin made for FrameWindow than just assigning it to a random widget derived from Window.
The easiest to map skins to widgets is by using falagard mappings. All the default skin do this in the .scheme files.
you can also do it explicitly by doing:
wnd->setWindowRenderer("Falagard/Default");
wnd->setLookNFeel("MyLookNFeel");
HTH
The easiest to map skins to widgets is by using falagard mappings. All the default skin do this in the .scheme files.
you can also do it explicitly by doing:
wnd->setWindowRenderer("Falagard/Default");
wnd->setLookNFeel("MyLookNFeel");
HTH
Who is online
Users browsing this forum: No registered users and 24 guests