MultiColumnList
From CEGUI Wiki - Crazy Eddie's GUI System (Open Source)
Creating the MultiColumnList in code
Take a look at this code on how we create the MultiColumnList window:
// Get the CEGUI Window Manager CEGUI::WindowManager *mWinMgr = CEGUI::WindowManager::getSingletonPtr(); // Create the CEGUI MultiColumnList window CEGUI::MultiColumnList *mListBox = (CEGUI::MultiColumnList *)mWinMgr->createWindow( (CEGUI::utf8*)CEGUILOOK"/MultiColumnList", (CEGUI::utf8*)"MyListBox"); // Don't forget to add this window to another window and set its other properties // like position, size, etc. Use the methods you prefer. mListBox->setPosition( CEGUI::Point(0.05f, 0.1f) ); mListBox->setSize( CEGUI::Size(0.90f, 0.80f) ); // mSomeWindow->addChild(mListBox); // Set the users selection ability mListBox->setSelectionMode(CEGUI::MultiColumnList::SelectionMode::RowMultiple); // Add some column headers mListBox->addColumn("Column1", 0, 0.10f); mListBox->addColumn("Column2", 1, 0.25f); mListBox->addColumn("Column3", 2, 0.25f); mListBox->addColumn("Column4", 3, 0.45f); // I don't know why, but you have set the column header widths via this function. // The Column Header widths are not assumed from the "addColumn" function. Bug? mListBox->setColumnHeaderWidth(0, 0.10f); mListBox->setColumnHeaderWidth(1, 0.25f); mListBox->setColumnHeaderWidth(2, 0.25f); mListBox->setColumnHeaderWidth(3, 0.45f);
Note these lines in the code:
// I don't know why, but you have set the column header widths via this function. // The Column Header widths are not assumed from the "addColumn" function. Bug? mListBox->setColumnHeaderWidth(0, 0.10f); mListBox->setColumnHeaderWidth(1, 0.25f); mListBox->setColumnHeaderWidth(2, 0.25f); mListBox->setColumnHeaderWidth(3, 0.45f);
If you don't set the column header widths with the setColumnHeaderWidth() method then the columns will appear to be stacked on top of one another. This may be a bug in the library. The numbers I used for the widths are arbitrary. You can make them anything you like.
!! WARNING !! Take note that you should not follow each addColumn() with a setColumnHeaderWidth(). Create all the columns first and then set the column widths. Not following this will yield unreliable column size results.
In other words DO NOT DO THIS
// Add some column headers mListBox->addColumn("Column1", 0, 0.10f); mListBox->setColumnHeaderWidth(0, 0.10f); mListBox->addColumn("Column2", 1, 0.25f); mListBox->setColumnHeaderWidth(1, 0.25f); mListBox->addColumn("Column3", 2, 0.25f); mListBox->setColumnHeaderWidth(2, 0.25f); mListBox->addColumn("Column4", 3, 0.45f); mListBox->setColumnHeaderWidth(3, 0.45f);