ListboxItem or ListboxTextItem?

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

leonardoalt
Just popping in
Just popping in
Posts: 15
Joined: Thu Nov 06, 2008 18:44

ListboxItem or ListboxTextItem?

Postby leonardoalt » Fri Nov 07, 2008 01:27

Hello.
I saw an example of how to use a Combobox and ListboxTextItem.
A piece of the code:
CEGUI::ListboxTextItem *item = new CEGUI::ListboxTextItem( "Disabled", 1 );
combobox->addItem( item );
item = new CEGUI::ListboxTextItem( "Bottom", 2 );
combobox->addItem( item );
item = new CEGUI::ListboxTextItem( "All", 3 );
combobox->addItem( item );

But when I do this, I get this error:
no matching function for call to ‘CEGUI::Combobox::addItem(CEGUI::ListboxTextItem*&)’
/usr/include/CEGUI/elements/CEGUICombobox.h:573: nota: os candidatos são: void CEGUI::Combobox::addItem(CEGUI::ListboxItem*)
(I used the same code)

What can be wrong?

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Fri Nov 07, 2008 09:54

Hi,

You're likely going to have to post much more of your actual code.

The code posted looks ok, the error could be a number of things. Are you correctly including the required headers (especially "elements/CEGUIListboxTextItem.h")? If it's not that, you'll definitely have to post a minimal - but complete - example of code that exhibits the issue (since it's a programmer error, not a CEGUI issue - but we're willing to help where possible).

CE.

leonardoalt
Just popping in
Just popping in
Posts: 15
Joined: Thu Nov 06, 2008 18:44

Postby leonardoalt » Fri Nov 07, 2008 10:35

Ok, thanks, I'll post later, I do not have the code here.
One doubt for now:
Can combobox->addItem receive a ListboxTextItem? Or only ListboxItem?

Thank you.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Fri Nov 07, 2008 13:05

The addItem member function takes a pointer to a ListboxItem, but the key thing is that ListboxTextItem subclasses ListboxItem ("is-a" relationship) and so passing a pointer to the subclass to a function that takes a pointer to the superclass is valid C++.

CE.

leonardoalt
Just popping in
Just popping in
Posts: 15
Joined: Thu Nov 06, 2008 18:44

Postby leonardoalt » Fri Nov 07, 2008 19:48

Yes, I read the API reference, and that's why I can not understand the error

"no matching function for call to ‘CEGUI::Combobox::addItem(CEGUI::ListboxTextItem*&)’"

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Sat Nov 08, 2008 10:31

This is why I asked if the correct header was included, and if so, to see a full (but as small as possible) example of some code that demonstrates the issue.

Currently you have basically just repeated the error that you are receiving, and this is not enough information to diagnose the problem. You must provide as much information as possible.

Please re-read the announcement post Forum Usage Guidelines: Ensure you have read this!; so far you seen to have done the exact opposite to most of these guidelines ;)

CE.

leonardoalt
Just popping in
Just popping in
Posts: 15
Joined: Thu Nov 06, 2008 18:44

Postby leonardoalt » Sat Nov 08, 2008 16:13

Ok, I'll post the code here later (do not have it here now).

I used these includes:

#include <CEGUI/CEGUI.h>
#include <CEGUI/elements/CEGUIListboxItem.h>
#include <CEGUI/elements/CEGUIListboxTextItem.h>
#include <CEGUI/elements/CEGUICombobox.h>

Need something more?

Thanks for all.

leonardoalt
Just popping in
Just popping in
Posts: 15
Joined: Thu Nov 06, 2008 18:44

Postby leonardoalt » Mon Nov 17, 2008 17:08

The code:

bool
MenuInput::ConfigurationsButton(const EventArgs& rEvent)
{
try
{
CEGUI::WindowManager* WMngr = CEGUI::WindowManager::getSingletonPtr();
CEGUI::Window* WRoot = CEGUI::System::getSingleton().getGUISheet();
FrameWindow* WFrame = (FrameWindow*)WRoot->getChild("MainMenu");
WFrame->setEnabled(false);

/* Configuration Frame */
CEGUI::FrameWindow* WConfigs = (FrameWindow*)WMngr->createWindow("AquaLook/FrameWindow", "ConfigurationsMenu");
WRoot->addChildWindow(WConfigs);
WConfigs->setPosition(CEGUI::UVector2(CEGUI::UDim(0.25f, 0), CEGUI::UDim(0.27f, 0)));
WConfigs->setSize(CEGUI::UVector2(CEGUI::UDim(0.55f, 0), CEGUI::UDim(0.55f, 0)));
WConfigs->setText("Configurations Menu");
WConfigs->setSizingEnabled(false);

/* Era pra ser Label. "Video Mode" */
CEGUI::ButtonBase* VMButton = (CEGUI::ButtonBase*)WMngr->createWindow("AquaLook/Button", "VMButton");
WConfigs->addChildWindow(VMButton);
VMButton->setPosition(CEGUI::UVector2(CEGUI::UDim(0.125f, 0), CEGUI::UDim(0.2f, 0)));
VMButton->setSize(CEGUI::UVector2(CEGUI::UDim(0.275f, 0), CEGUI::UDim(0.2f, 0)));
VMButton->setText("Video Mode");

string current;

/* Combobox Video Mode */
Combobox* vmCombo = (Combobox*)WMngr->createWindow("AquaLook/Combobox", "VMCombobox");
WConfigs->addChildWindow(vmCombo);
vmCombo->setPosition(CEGUI::UVector2(CEGUI::UDim(0.6f, 0), CEGUI::UDim(0.2f, 0)));
vmCombo->setSize(CEGUI::UVector2(CEGUI::UDim(0.25f, 0), CEGUI::UDim(0.2f, 0)));

current = Configuration::getSingleton().Get("VideoMode");
vmCombo->setText(current);

string Resolutions[4] = {"640 x 480", "800 x 600", "1024 x 768", "1280 x 1024"};
for(int i = 0; i < 4; ++i)
vmCombo->addItem(new ListboxTextItem(Resolutions[i]));
}
catch(CEGUI::Exception e)
{
throw std::string('\n' + e.getMessage().c_str() + '\n');
}
return true;

leonardoalt
Just popping in
Just popping in
Posts: 15
Joined: Thu Nov 06, 2008 18:44

Postby leonardoalt » Mon Nov 17, 2008 17:18

And when I do this:

ListboxItem* item;
item = new ListboxTextItem("640 x 480");
item->setTextColours(colour(0.f, 0.f, 0.f));
vmCombo->addItem(item);

I get these errors:
./Source/Definitions/MenuInput.cpp:120: erro: cannot convert ‘CEGUI::ListboxTextItem*’ to ‘CEGUI::ListboxItem*’ in assignment
../Source/Definitions/MenuInput.cpp:121: erro: ‘class CEGUI::ListboxItem’ has no member named ‘setTextColours’
make: ** [Source/Definitions/MenuInput.o] Erro 1

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Mon Nov 17, 2008 20:28

Hi,

Thanks for posting the code. I'll deal with the easy bit first.
./Source/Definitions/MenuInput.cpp:121: erro: ‘class CEGUI::ListboxItem’ has no member named ‘setTextColours’

This is because that member function only exists in CEGUI::ListboxTextItem, to get that to work, you'd need this instead (ignoring the other issues you have):

Code: Select all

ListboxTextItem* item;
item = new ListboxTextItem("640 x 480");
item->setTextColours(colour(0.f, 0.f, 0.f));
vmCombo->addItem(item);


With regards to this (and the other similar related you were/are getting):
./Source/Definitions/MenuInput.cpp:120: erro: cannot convert ‘CEGUI::ListboxTextItem*’ to ‘CEGUI::ListboxItem*’ in assignment

I can't explain this. I took your code and it compiles fine here (I had to remove the 'Configuration singleton' bit obviously, but aside from that). This leaves us with possibilities that are not code related, but related to your system, tools and configuration. So...

- What system are you running (OS / platform / etc)?
- (Assuming gcc) Which version of GCC is in use?
- What, if any, options are you using with configure and also in the vars CFLAGS / CXXFLAGS / etc?

For info, I compiled it on a Intel based Apple Mac using gcc 4.0 within Xcode. No other special settings.

CE.

lvella
Just popping in
Just popping in
Posts: 1
Joined: Mon Nov 17, 2008 22:32

Postby lvella » Mon Nov 17, 2008 22:44

Hi there. I work at the same project as leonardoalt and found out what was causing the problem. Probably there is a bug in gcc while dealing with precompiled headers.

There are some dependencies that make compilation very slow while including it's headers, so we are using a precompiled header to speed up building, including those dependencies there.

The header CEGUI/CEGUI.h was being included via this precompiled header, too. Just taking it out of the precompiled header was enougth get rid of the error.

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Postby CrazyEddie » Tue Nov 18, 2008 09:26

Hi,

Thanks for posting the resolution to this; it's actually very interesting (and also odd, as you say, it would seem like a gcc bug).

In any case, I'm glad you have things compiling correctly now :)

CE.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 5 guests