[SOLVED]multicolumnlist help

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

maori
Just can't stay away
Just can't stay away
Posts: 161
Joined: Tue Sep 23, 2008 13:05
Location: Plumstead , UK

[SOLVED]multicolumnlist help

Postby maori » Sun Jul 19, 2009 14:41

hi guys

how can i add items to a multicolumnlist my problem is i want to display a keymap file

and i can do this with a normal ItemListbox like so

Code: Select all

ItemListbox* Key_Map = static_cast<ItemListbox*>(winMgr.getWindow( "KEY"));
   ItemEntry* key_item = static_cast<ItemEntry*>( WindowManager::getSingleton().createWindow( "MySkin/ListboxItem" ));

// code that opens the file here

Key_Map->addItem( key_item );
keymap_item->setText( total );


but what i really want is for a multicolumnlist that will display this in one colum and the keys assigned to it in another colum but on varies times of trying it will only display one item so am a bit lost :oops:
had a look on the wiki and couldnt really find an answer to what i'am trying to do so any help much appricated

TIA
Last edited by maori on Tue Jul 21, 2009 17:35, edited 1 time in total.
trying to upgrade to 0.8.2 from 0.7.9 :D

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: multicolumnlist help

Postby CrazyEddie » Mon Jul 20, 2009 08:38

One thing to note, before getting into other stuff is that the MultiColumnList differs from the ItemListBox in that the items added are not ItemEntry based, rather the older style ListboxItem based - which may or may not have implications for you.

The basic mode of operation is to create the MCL and add the required columns (like 'action' and 'key' or whatever). For each pair, you then would use addRow to add a new empty row, then setItem twice per row; the first time with an item for the first column, and the second time with an item for the second column.

I think the main missing bits of information are what format is the file in, how are you parsing it, what info do you get back from the parse and how have you tried using this so far? Knowing this would give a better idea of how you should be doing it.

CE

maori
Just can't stay away
Just can't stay away
Posts: 161
Joined: Tue Sep 23, 2008 13:05
Location: Plumstead , UK

Re: multicolumnlist help

Postby maori » Mon Jul 20, 2009 15:45

Heya CE

okidoki

the file is parsed though a sscanf function and i read out two items from this the 1st one would be keycode and the 2nd the function assotiated with it

i have tried but the only info i got was the first row :oops: so i treid the itemlistbox way and got all lines to show for the keycode and added another itemlistbox to get the function name hehe long way round i know but i wanted to test that i was doing things correct but for the life of me i couldnt get the multicolumlist to work hence the post :oops:

i looked at the wiki and thogh the forums but all i could find was rows/colums that had been added manually so not sure of how to get it all wrapped up


TIA
trying to upgrade to 0.8.2 from 0.7.9 :D

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: multicolumnlist help

Postby CrazyEddie » Mon Jul 20, 2009 20:11

I'm going to assume that the data fields you sscanf into are strings, or that you can get that data into string form. What follows is a basic example of how you might add the content to a MCL.

First of all I'm going to use a custom ListboxTextItem, this makes everything much easier since we do not then have to manually set up every item, this is basically taken from the CEGUI samples. Note that the default text colour is white, this means that if your list has a white or light coloured background, you will have to set the text colour also in the constructor here.

Code: Select all

class MyListItem : public CEGUI::ListboxTextItem
{
public:
    MyListItem(const CEGUI::String& text) : ListboxTextItem(text)
    {
        setSelectionBrushImage("TaharezLook", "MultiListSelectionBrush");
    }
};


Next we have a little helper function, it takes a pointer to the MCL widget and a couple of C strings, it does the work to add the row to the list using the MyListItem class defined above.

Code: Select all

void addMCLEntry(CEGUI::MultiColumnList* list, const char* func_text, const char* key_text)
{
    uint row_idx = list->addRow();
    list->setItem(new MyListItem(func_text), 0, row_idx);
    list->setItem(new MyListItem(key_text), 1, row_idx);
}


Don't forget to add the columns to the list, if you have not done this in XML or code anywhere, you might do it like this (here the MCL window is named KEY_MAP:

Code: Select all

    MultiColumnList* key_map =
        static_cast<MultiColumnList*>(WindowManager::getSingleton().getWindow("KEY_MAP"));

    // add columns if we did not do that already!
    if (key_map->getColumnCount() == 0)
    {
        key_map->addColumn("Function", 0, UDim(0.75f, 0));
        key_map->addColumn("Key", 1, UDim(0.25f, 0));
    }


Then you call the function addMCLEntry each time you parse a line out of the file:

Code: Select all

    // func_str and key_str are c-style strings
    addMCLEntry(key_map, func_str, key_str);


HTH

CE.

maori
Just can't stay away
Just can't stay away
Posts: 161
Joined: Tue Sep 23, 2008 13:05
Location: Plumstead , UK

Re: multicolumnlist help

Postby maori » Tue Jul 21, 2009 15:06

Hi CE

wow thanks bud that does the trick perfect hehe pretty easy when you know how :hammer:

thanks a lot sir
trying to upgrade to 0.8.2 from 0.7.9 :D


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 3 guests