Page 1 of 1

Help resizing a combobox button

Posted: Tue Feb 12, 2008 19:32
by willjm
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!

Posted: Wed Feb 13, 2008 08:15
by scriptkid
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.

Posted: Wed Feb 13, 2008 09:54
by CrazyEddie
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.