Problems populating a listbox

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

klad
Just popping in
Just popping in
Posts: 1
Joined: Sat Mar 25, 2006 18:09

Problems populating a listbox

Postby klad » Sat Mar 25, 2006 18:32

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
Last edited by klad on Sat Mar 25, 2006 22:22, edited 1 time in total.

Scorch
Not too shy to talk
Not too shy to talk
Posts: 21
Joined: Mon Feb 13, 2006 07:05
Location: Las Vegas, NV

Postby Scorch » Sat Mar 25, 2006 21:19

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.

kiolakin
Not too shy to talk
Not too shy to talk
Posts: 22
Joined: Mon Jul 31, 2006 01:06

Postby kiolakin » Sat Aug 05, 2006 18:37

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.

kiolakin
Not too shy to talk
Not too shy to talk
Posts: 22
Joined: Mon Jul 31, 2006 01:06

Postby kiolakin » Sat Aug 05, 2006 19:11

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...

kiolakin
Not too shy to talk
Not too shy to talk
Posts: 22
Joined: Mon Jul 31, 2006 01:06

Postby kiolakin » Sat Aug 05, 2006 19:22

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.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 6 guests