Page 1 of 1

ListBox and MultiListBox question

Posted: Tue Jul 19, 2005 15:01
by zander1976
Hello Everybody,

I have a few questions with regards to working with ListBoxes. Hopefully someone will have an idea of what I need to do. I have look threw the api docs and did some forum searching but I am still having problems.

1. MultiColumnList - if I understand correct gives me the ability to:
Name Score
whatever 10

It takes a ListboxTextItem so how do I add more elements (ie the score)?

2. Also how do i set the col that will actually be sorted? The sort option takes true of false.

3. Can I assign and ID to the row for example:
Player Name
whatever

Can I assign an id now ( I tried assigning id in ListboxTextItem ) but there is no method to that I could find that says findItemWithId?

4. ListBoxTitles. Ok I am completely lost with these :(
I used the gui editor to create listbox and a listboxtitle (it was in the list of windows I could create in the gui editor) but its not visible and not attached to the listbox at all. Is there a way to do this. Do I have to attach it in the code.

Sorry for so many questions I have tried to look them up myself and figure each out but man ce is big. I am amazed by how much it can do and for the most part is quite easy to use.

Thanks in advance for any help.
Ben

Re: ListBox and MultiListBox question

Posted: Wed Jul 20, 2005 08:33
by CrazyEddie
Hi,

1) Yes, this is correct. To set items in the grid, you specify the column id and row index, or use a MCLGridRef. Basically you add the columns you want, then add a row and set the items within the row with setItem

2) setSortColumnByID is one way.

3) Yes, this ability was added for 0.3.0. See setRowID

4) If you mean the ListHeader, these are automatically created when you add a column to your multi-column list. You do not need to create them manually, unless you're creating a new widget type. See addColumn

Hope this answers some of your questions :)

Re: ListBox and MultiListBox question

Posted: Thu Jul 21, 2005 12:22
by zander1976
Ahh sweet.. Thank you very much CE for your help and for CEGUI.. :)

Ben

Re: ListBox and MultiListBox question

Posted: Fri Sep 23, 2005 19:25
by Van
Am I to understand that EACH COLUMN[/u] must have its own [i]ListboxTextItem ??

Please correct me if I am wrong:

Code: Select all

 CEGUI::ListboxTextItem *mMyItems[3];
 ...
 mRowNum = mMyMCListBox->addRow();
 MyMCListBox->setItem(mMyItems[0], 0, mRowNum);
 MyMCListBox->setItem(mMyItems[1], 1, mRowNum);
 mMyMCListBox->setItem(mMyItems[2], 2, mRowNum);


Is that the jist of it it? Or do I have it all wrong?

And, what happens/what do you do in a drag and drop scenerio?

Re: ListBox and MultiListBox question

Posted: Sat Sep 24, 2005 15:22
by Van
OK, I have the MultiColumnListBox working - sort of... My problem is I can't select any of the row items. I am probably not setting something correcty...

Code: Select all

   // LIST BOX
   strcat( mStr, "/MultiColumnList" );
   mListBox = (CEGUI::MultiColumnList *)mWinMgr->createWindow(
      (CEGUI::utf8*)CEGUILOOK"/MultiColumnList", (CEGUI::utf8*)mStr);
   mListBox->addColumn("Serial No.",      0, 0.25f);
   mListBox->addColumn("Name",            1, 0.25f);
   mListBox->addColumn("Qty",            2, 0.25f);
   mListBox->addColumn("Category",         3, 0.25f);
   mListBox->setPosition( CEGUI::Point(0.05f, 0.1f) );
   mListBox->setSize( CEGUI::Size(0.90f, 0.80f) );
   mListBox->setSelectionMode(CEGUI::MultiColumnList::SelectionMode::RowMultiple);
   mListBox->setColumnHeaderWidth(0, 0.25f);
   mListBox->setColumnHeaderWidth(1, 0.25f);
   mListBox->setColumnHeaderWidth(2, 0.25f);
   mListBox->setColumnHeaderWidth(3, 0.25f);

   // TEST
   unsigned int mRow = mListBox->addRow();
   CEGUI::ListboxTextItem* item = new CEGUI::ListboxTextItem((CEGUI::utf8*)"12345", 0);
   mListBox->setItem(item, 0, mRow);
   item = new CEGUI::ListboxTextItem((CEGUI::utf8*)"Name1", 1);
   mListBox->setItem(item, 1, mRow);
   item = new CEGUI::ListboxTextItem((CEGUI::utf8*)"17", 2);
   mListBox->setItem(item, 2, mRow);
   item = new CEGUI::ListboxTextItem((CEGUI::utf8*)"Resource1", 3);
   mListBox->setItem(item, 3, mRow);
   //-
   mRow = mListBox->addRow();
   item = new CEGUI::ListboxTextItem((CEGUI::utf8*)"234", 4);
   mListBox->setItem(item, 0, mRow);
   item = new CEGUI::ListboxTextItem((CEGUI::utf8*)"name2", 5);
   mListBox->setItem(item, 1, mRow);
   item = new CEGUI::ListboxTextItem((CEGUI::utf8*)"45", 6);
   mListBox->setItem(item, 2, mRow);
   item = new CEGUI::ListboxTextItem((CEGUI::utf8*)"Resource2", 7);
   mListBox->setItem(item, 3, mRow);
   // TEST


Anyone see why I can't select a row?

Re: ListBox and MultiListBox question

Posted: Sat Sep 24, 2005 16:21
by Van
never mind. Stupid me forgot to set the setSelectionBrushImage for each item. :oops:

Re: ListBox and MultiListBox question

Posted: Sun Sep 25, 2005 09:07
by CrazyEddie
Van wrote:
Am I to understand that EACH COLUMN[/u] must have its own [i]ListboxTextItem ??

Each individual entry in the grid requires its own item.

Van wrote:
And, what happens/what do you do in a drag and drop scenerio?

In the current system, items are not based on the Window class, and do not natively support drag and drop.