Help resizing a combobox button

Forum for general chit-chat or off-topic discussion.

Moderators: CEGUI MVP, CEGUI Team

willjm
Just popping in
Just popping in
Posts: 1
Joined: Tue Feb 12, 2008 14:48

Help resizing a combobox button

Postby willjm » Tue Feb 12, 2008 19:32

Hi all,

I'm attempting to resize the width and height of a combobox button with no success.

Code: Select all

/*
**       tagFontType
*/
CEGUI::URect tagTestRect(CEGUI::UDim(0.0, 10), CEGUI::UDim(0.0, 10), CEGUI::UDim(0.0, 10), CEGUI::UDim(0.0, 10));

CEGUI::Combobox *tagFontType = (CEGUI::Combobox*)
CEGUI::WindowManager::getSingleton().createWindow("SVTLook/Combobox", at+strTagFontType);
assert(tagFontType && "ActorTypeEditor::showEditor: failed to create tagFontType");

SystemFontMgr *tSystemFontMgr = SystemFontMgr::getSingletonPtr();
assert(tSystemFontMgr && "ActorTypeEditor::showEditor: failed to get a pointer to the system font manager");
SystemFontMgr::SystemFontTypeMapIterator sftItr = tSystemFontMgr->getSystemFontTypeMapIterator();
      
while(sftItr.hasMoreElements())
{
   SystemFontType sft = sftItr.getNext();
   int count = 0;
   CEGUI::colour listboxTextColor(1.0, 0.0, 1.0, 1.0);
   std::string font = sft.name;
   if(tagFontType->getItemCount() <= 0 ||
      tagFontType->findItemWithText(font, tagFontType->getListboxItemFromIndex(0)) == NULL)
   {
      CEGUI::ListboxTextItem* listboxItem = new CEGUI::ListboxTextItem(font.c_str(), count++);
      assert(listboxItem && "ActorTypeEditor::showEditor: failed to create listboxtext item");

      listboxItem->setTextColours(listboxTextColor, listboxTextColor, listboxTextColor, listboxTextColor);
      listboxItem->setSelectionBrushImage("SVTLook", "Background");
      // We lose the pointer here, but the memory will be cleaned up when we delete the fontCombo
      tagFontType->addItem(listboxItem);
   }
}

tagFontType->setText(dbc.tagFontType);

tabWindow->addChildWindow(tagFontType);
tagFontType->setPosition(CEGUI::UVector2(CEGUI::UDim(0.0, 20), tagLabelRect.d_min.d_y));
tagFontType->getEditbox()->setHeight(CEGUI::UDim(0.0, 10));
tagFontType->getEditbox()->setWidth(CEGUI::UDim(0.0, 10));
tagFontType->getPushButton()->setArea(tagTestRect);
tagFontType->setArea(tagColorRect);
tagFontType->setInheritsAlpha(false);
tagFontType->subscribeEvent(CEGUI::Combobox::EventTextSelectionChanged, CEGUI::Event::Subscriber(&ActorTypeEditor::handleFontChange, this));
std::string fontNameStr = CEGUI::System::getSingleton().getDefaultFont()->getProperty("Name").c_str();


As one can see, I created a test URect and tried to set the area of the PushButton to that. I have also tried to use the following with no success...

tagFontType->getPushButton()->setWidth(CEGUI::UDim(0.0, 10.0));
tagFontType->getPushButton()->setHeight(CEGUI::UDim(0.0, 10.0));

Any help would be much appreciated!

User avatar
scriptkid
Home away from home
Home away from home
Posts: 1178
Joined: Wed Jan 12, 2005 12:06
Location: The Hague, The Netherlands
Contact:

Postby scriptkid » Wed Feb 13, 2008 08:15

Hi and welcome,

i'm affraight that you can't -someone correct me if i'm wrong- modify the editbox or push button, because they are child components of the main combobox, and have therefore a relative size.

If it is your intention to make both the editbox and the surrounding combobox the same width, then you should call the sizing on your tagFontType widget.

Something off topic: i notice some unneeded asserts. Cegui throws when it can't create a widget. And the getSingletonPrt() can't really fail either cause it means invalid initialisation which would have lead to an earlier crash.

HTH.
Check out my released snake game using Cegui!

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

Postby CrazyEddie » Wed Feb 13, 2008 09:54

Hi :D

scriptkid wrote:someone correct me if i'm wrong

I'll rise to the challenge :P

You can modify the size and position of the button (or anything else) by changing the way it is laid out in the looknfeel skin.

If you want to be able to programatically change the size and/or position of such a component, you need to define some appropriate properties within the skin and use those in "PropertyDim"s for the area that lays out the component child widget (in this case, the push button of the Combobox).

If you say exactly what you want to achieve, I might be able to muster an example xml snippet.


Return to “Offtopic Discussion”

Who is online

Users browsing this forum: No registered users and 3 guests