Page 1 of 1

Problems populating a listbox

Posted: Sat Mar 25, 2006 18:32
by klad
Hi there!

Look at this pic: (ctrl++ to zoom the browser :wink: )

Image

As you can see, the listbox text looks strange. I don't know why.

This is the xml layout for the listbox:

Code: Select all

<?xml version="1.0" ?>
<GUILayout>
   <Window Type="DefaultWindow" Name="ReceiveChatWindow">
      <Property Name="Position" Value="x:0.0 y:0.00" />
      <Property Name="Size" Value="w:1.000000 h:0.900000" />
   
      <Window Type="WindowsLook/Listbox" Name="ChatWindow/ListBox">            
            <Property Name="Position" Value="x:0.05 y:0.03" />
            <Property Name="Size" Value="w:0.9 h:0.1" />            
      </Window>            
      
      <Window Type="WindowsLook/Editbox" Name="ChatWindow/EditBox2">            
            <Property Name="Position" Value="x:0.05 y:0.8" />
            <Property Name="Size" Value="w:0.9 h:0.05" />            
      </Window>         
   </Window>      
   
</GUILayout>


and this is the code i use to put text on the listbox:

Code: Select all

CEGUI::Listbox* win3= (CEGUI::Listbox*)CEGUI::WindowManager::getSingleton().getWindow("ChatWindow/ListBox");
   
   
   CEGUI::ListboxTextItem *listboxitem = new CEGUI::ListboxTextItem("MessageToDisplay");
   
   win3->addItem(listboxitem);
   win3->ensureItemIsVisible(win3->getItemCount());


I'm pretty sure that the text is displayed, because when I change the text, i can aprreciate the changes. But it si displayed strangely.

Maybe some font problems? But when i try to change the font using Setfont("Tahoma-14") the application freezes.


And this is the code i use to load the layout, and to hide the editbox (that will pop out when i press a key)

Code: Select all

   CEGUI::Window* sheet =
      CEGUI::WindowManager::getSingleton().loadWindowLayout(
      (CEGUI::utf8*)"ReceiveChat.layout");

   CEGUI::Window* win= CEGUI::WindowManager::getSingleton().getWindow("ReceiveChatWindow");
   win->show();
   State::gGUISystem->setGUISheet(win);
   CEGUI::Window* win2= CEGUI::WindowManager::getSingleton().getWindow("ChatWindow/EditBox2");   
   win2->hide();

It's an ogre application that will include a cegui chat.

Any idea of what might happen?
Thanks in advance

Posted: Sat Mar 25, 2006 21:19
by Scorch
Only thing I can see that might be different between your code and mine (Functionaly)
is I initialize in this order:

Code: Select all

mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, false, 3000, primaryView->GetSceneManager());
  mGUISystem = new CEGUI::System(mGUIRenderer);
  CEGUI::Logger::getSingleton().setLoggingLevel(CEGUI::Informative);
  CEGUI::SchemeManager::getSingleton().loadScheme((CEGUI::utf8*)"TaharezLook.scheme");
  mGUISystem->setDefaultMouseCursor((CEGUI::utf8*)"TaharezLook", (CEGUI::utf8*)"MouseArrow");
  mGUISystem->setDefaultFont((CEGUI::utf8*)"Tahoma-12");


Then later I load all my layouts (preloading them).
Then when I need them I set the root sheet to the layout I want.

Posted: Sat Aug 05, 2006 18:37
by kiolakin
I ran into this today. Apparently by default the text foreground and background are set to the same color. In order to see everything, you need to set the text color and selection brush as:

Code: Select all

ListboxTextItem *item=new ListboxTextItem((utf8*)szName.c_str());
item->setTextColours(colour(0,0,0,1));
item->setSelectionBrushImage("WindowsLook","Background");
_mLbxFiles->addItem(item);


Don't forget the colour() because I think this is where the main code is messed up, if you try to setTextColours(0,0,0,1) it will make the top transparent and bottom right opaque, which will result in what you get by default.

The same seems to hold true for combobox.

Posted: Sat Aug 05, 2006 19:11
by kiolakin
I am trying to track it down atm, to see if I can figure out how to fix it...

I really need to get a windows diff program...

Posted: Sat Aug 05, 2006 19:22
by kiolakin
Found it. It isn't really a bug like I thought it was, it turns out that the default text colour is white. So unless you are using a white background it won't be a problem, and then it is only a problem if you don't select your own text colour.