Hi,
I'm trying to upgrade my program from CEGUI 0.4.x to 0.5.0..
I think lots of members(classes) have disappeared.
I found somewhere in this forum that I can replace StaticText or StaticImage to DefaultWindow, but then, how can I replace many members of Static*?
There're no such members in DefaultWindow.
For example,
StaticText had setHorizontalFormatting, setVerticalFormatting member function, but it isn't in DefaultWindow.
I think I can use setProperty function to set these values, but I can't find references that I can use in setProperty.
Where can I find them?
Please help~
Thanks in advance,
Todd.
0.4.x => 0.5.0 upgrade questions..
Moderators: CEGUI MVP, CEGUI Team
WidgetGalore has the answer you are looking for, or you can go through the source code to find the available properties.
Thanks, Rackle.
I have some more questions..(Please excuse if the question doesn't make sense
I'm a novice in game programming )
According to the WidgetGalore,
to make the same effect with StaticText in 0.4.X,
I need to use DefaultWindow.
And from the code [http://www.cegui.org.uk/wiki/index.php/WidgetGalore#WidgetGalore.h widgetgalore.h] in that page,
it seems that "StaticText" has property named "TextColours".
What I am trying to do is to create a widget type called "BubbleStaticText" which inherits from DefaultWindow(originally from StaticText in 0.4.x)
I tried to set property values "FrameEnabled", "BackgroundEnabled", "FrameEnabled" in the constructor of BubbleStaticText, but what I get is "Exception: There is no Property named 'FrameEnabled' available in the set.".
However, these worked in 0.4.x version because there were methods setFrameEnabled, setBackgroundEnabled, setTextColours in StaticText class.
Many articles in the forum show example codes like the one above but the only difference that I can find is they're using WindowManager::getWindow instead of WindowManager::createWindow (which means they're using layout xml file and I'm not..)
Can you or anybody help me, please?
I have some more questions..(Please excuse if the question doesn't make sense

According to the WidgetGalore,
to make the same effect with StaticText in 0.4.X,
I need to use DefaultWindow.
And from the code [http://www.cegui.org.uk/wiki/index.php/WidgetGalore#WidgetGalore.h widgetgalore.h] in that page,
it seems that "StaticText" has property named "TextColours".
Code: Select all
/* StaticText */
DefaultWindow* staticText = static_cast<DefaultWindow*>(winMgr.getWindow("StaticText"));
staticText->setText("Red Static Text");
staticText->setProperty("TextColours", "tl:FFFF0000 tr:FFFF0000 bl:FFFF0000 br:FFFF0000"); // aarrggbb in Hexadecimal
// tl: top left, tr: top right, bl: bottom left, br: bottom right
staticText->setProperty("VertFormatting", "VertCentred"); // TopAligned, BottomAligned, VertCentred
staticText->setProperty("HorzFormatting", "HorzCentred"); // LeftAligned, RightAligned, HorzCentred
// HorzJustified, WordWrapLeftAligned, WordWrapRightAligned, WordWrapCentred, WordWrapJustified
staticText->setTooltipText("This is a StaticText widget");
What I am trying to do is to create a widget type called "BubbleStaticText" which inherits from DefaultWindow(originally from StaticText in 0.4.x)
I tried to set property values "FrameEnabled", "BackgroundEnabled", "FrameEnabled" in the constructor of BubbleStaticText, but what I get is "Exception: There is no Property named 'FrameEnabled' available in the set.".
However, these worked in 0.4.x version because there were methods setFrameEnabled, setBackgroundEnabled, setTextColours in StaticText class.
Many articles in the forum show example codes like the one above but the only difference that I can find is they're using WindowManager::getWindow instead of WindowManager::createWindow (which means they're using layout xml file and I'm not..)
Can you or anybody help me, please?
Correcting my question..
I tried in various ways.. and found out something.
Since I wanted to have custom class that inherited from DefaultWindow, I needed a factory.
To make cegui WindowManager to use that factory, I need a custom window type (which I named "BubbleStaticText").
When I give "BubbleStaticText" to WindowManager::createWindow, it calls my own factory and in turn, it tries to create an instance of BubbleStaticText.
In the constructor of BubbleStaticText, it tries to set properties such as "FrameEnabled", "BackgroundEnabled", ... which fails.
So, I tried some other things.
I gave "DefaultWindow" to WindowManager::createWindow ==> Exception occurred when i tried to set properties.
I gave "WindowsLook/StaticText" to WindowManager::createWindow ==> Passed without exception!
So, what I want to know is..
How can I make my own class/factory that inherits(?) WindowsLook/StaticText.
Please, help~
I tried in various ways.. and found out something.
Since I wanted to have custom class that inherited from DefaultWindow, I needed a factory.
To make cegui WindowManager to use that factory, I need a custom window type (which I named "BubbleStaticText").
When I give "BubbleStaticText" to WindowManager::createWindow, it calls my own factory and in turn, it tries to create an instance of BubbleStaticText.
In the constructor of BubbleStaticText, it tries to set properties such as "FrameEnabled", "BackgroundEnabled", ... which fails.
So, I tried some other things.
I gave "DefaultWindow" to WindowManager::createWindow ==> Exception occurred when i tried to set properties.
I gave "WindowsLook/StaticText" to WindowManager::createWindow ==> Passed without exception!
So, what I want to know is..
How can I make my own class/factory that inherits(?) WindowsLook/StaticText.
Please, help~
Use this bit of code with the main.cpp from WidgetGalore:
I looked through my WidgetGalore.layout to figure out how the static text widget was created and noticed "TaharezLook/StaticText" as the type, which I then used in the createWindow() function. Then I looked in the TaharezLook.looknfeel and saw that both the FrameEnabled and the BackgroundEnabled properties are set to true by default, so changed them to false in code to see what would happen.
All in all I prefer the .layout approach to the programming approach; I prefer to click options to create a layout than to code it all and then try to figure out the coordinates to position the widgets as well as figuring out their width and height. But hey, that's just me.
Hope this helps.
Code: Select all
#include "CEGuiSample.h"
#include "CEGUI.h"
class DemoSample : public CEGuiSample
{
public:
bool initialiseSample()
{
using namespace CEGUI;
// Retrieve the window manager
WindowManager& winMgr = WindowManager::getSingleton();
// Load the TaharezLook scheme and set up the default mouse cursor and font
SchemeManager::getSingleton().loadScheme("TaharezLook.scheme");
System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");
FontManager::getSingleton().createFont("Commonwealth-10.font");
// Set the GUI Sheet
Window* sheet = winMgr.createWindow("DefaultWindow", "root_wnd");
System::getSingleton().setGUISheet(sheet);
DefaultWindow* BubbleStaticText = static_cast<DefaultWindow*>(winMgr.createWindow("TaharezLook/StaticText", "BubbleStaticText"));
sheet->addChildWindow(BubbleStaticText);
BubbleStaticText->setPosition(UVector2(cegui_reldim(0.0f), cegui_reldim(0.0f))); // Top-left corner
BubbleStaticText->setSize(UVector2(cegui_reldim(0.4f), cegui_reldim(0.2f))); // Some width and height
BubbleStaticText->setText("My BubbleStatic text"); // Displayed text
BubbleStaticText->setProperty("FrameEnabled", "false"); // Display border or not
BubbleStaticText->setProperty("BackgroundEnabled", "false"); // Background clips other widgets or not
return true;
}
void cleanupSample(void)
{
}
};
I looked through my WidgetGalore.layout to figure out how the static text widget was created and noticed "TaharezLook/StaticText" as the type, which I then used in the createWindow() function. Then I looked in the TaharezLook.looknfeel and saw that both the FrameEnabled and the BackgroundEnabled properties are set to true by default, so changed them to false in code to see what would happen.
All in all I prefer the .layout approach to the programming approach; I prefer to click options to create a layout than to code it all and then try to figure out the coordinates to position the widgets as well as figuring out their width and height. But hey, that's just me.
Hope this helps.
Thanks, Rackle.
I think I've got the solution (I'm not sure it's correct, though)
I added a custom type to the scheme file (currently, I tested it by adding to the windowslook.scheme)
When I called the windowmanager's createwindow with "MyGui/BubbleStaticText" custom type, it called my factory! and it's based on the Falagard/StaticText which has "FrameEnabled", "BackgroundEnabled" and so on.
So it works as my intention.
Thanks for your help.
I think I've got the solution (I'm not sure it's correct, though)
I added a custom type to the scheme file (currently, I tested it by adding to the windowslook.scheme)
Code: Select all
<FalagardMapping WindowType="MyGui/BubbleStaticText" TargetType="DefaultWindow" Renderer="Falagard/StaticText" LookNFeel="WindowsLook/StaticText" />
When I called the windowmanager's createwindow with "MyGui/BubbleStaticText" custom type, it called my factory! and it's based on the Falagard/StaticText which has "FrameEnabled", "BackgroundEnabled" and so on.
So it works as my intention.
Thanks for your help.
Could you post an entire working example of what you did?
I pursued creating my own widgets for a time, but found documentation on doing so to be lacking, and help here to be non-forthcoming. Due to time constraints, I took a different approach to solve my problems, but am still quite curious to figure out what piece I was missing, since I did also have a factory, entries in the scheme, etc.
I pursued creating my own widgets for a time, but found documentation on doing so to be lacking, and help here to be non-forthcoming. Due to time constraints, I took a different approach to solve my problems, but am still quite curious to figure out what piece I was missing, since I did also have a factory, entries in the scheme, etc.
Who is online
Users browsing this forum: No registered users and 15 guests