2012-05-04 21:53:50 +00:00
|
|
|
#ifndef MWGUI_LIST_HPP
|
|
|
|
#define MWGUI_LIST_HPP
|
|
|
|
|
|
|
|
#include <MyGUI.h>
|
|
|
|
|
|
|
|
namespace MWGui
|
|
|
|
{
|
|
|
|
namespace Widgets
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* \brief a very simple list widget that supports word-wrapping entries
|
2012-05-10 09:19:22 +00:00
|
|
|
* \note if the width or height of the list changes, you must call adjustSize() method
|
2012-05-04 21:53:50 +00:00
|
|
|
*/
|
|
|
|
class MWList : public MyGUI::Widget
|
|
|
|
{
|
|
|
|
MYGUI_RTTI_DERIVED(MWList)
|
|
|
|
public:
|
|
|
|
MWList();
|
|
|
|
|
|
|
|
typedef MyGUI::delegates::CMultiDelegate1<std::string> EventHandle_String;
|
2012-09-24 06:09:16 +00:00
|
|
|
typedef MyGUI::delegates::CMultiDelegate1<MyGUI::Widget*> EventHandle_Widget;
|
2012-05-04 21:53:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Event: Item selected with the mouse.
|
|
|
|
* signature: void method(std::string itemName)
|
|
|
|
*/
|
|
|
|
EventHandle_String eventItemSelected;
|
|
|
|
|
2012-09-24 06:09:16 +00:00
|
|
|
/**
|
|
|
|
* Event: Item selected with the mouse.
|
|
|
|
* signature: void method(MyGUI::Widget* sender)
|
|
|
|
*/
|
|
|
|
EventHandle_Widget eventWidgetSelected;
|
|
|
|
|
|
|
|
|
2012-05-10 09:19:22 +00:00
|
|
|
/**
|
2012-05-17 11:12:38 +00:00
|
|
|
* Call after the size of the list changed, or items were inserted/removed
|
2012-05-10 09:19:22 +00:00
|
|
|
*/
|
|
|
|
void adjustSize();
|
|
|
|
|
2012-05-04 21:53:50 +00:00
|
|
|
void addItem(const std::string& name);
|
2012-05-17 12:54:03 +00:00
|
|
|
void addSeparator(); ///< add a seperator between the current and the next item.
|
2012-05-04 21:53:50 +00:00
|
|
|
void removeItem(const std::string& name);
|
|
|
|
bool hasItem(const std::string& name);
|
|
|
|
unsigned int getItemCount();
|
2012-05-17 12:54:03 +00:00
|
|
|
std::string getItemNameAt(unsigned int at); ///< \attention if there are separators, this method will return "" at the place where the separator is
|
2012-05-04 21:53:50 +00:00
|
|
|
void clear();
|
|
|
|
|
2012-09-22 22:36:20 +00:00
|
|
|
MyGUI::Widget* getItemWidget(const std::string& name);
|
|
|
|
///< get widget for an item name, useful to set up tooltip
|
|
|
|
|
2012-05-04 21:53:50 +00:00
|
|
|
protected:
|
|
|
|
void initialiseOverride();
|
|
|
|
|
|
|
|
void redraw(bool scrollbarShown = false);
|
|
|
|
|
|
|
|
void onMouseWheel(MyGUI::Widget* _sender, int _rel);
|
|
|
|
void onItemSelected(MyGUI::Widget* _sender);
|
|
|
|
|
|
|
|
private:
|
|
|
|
MyGUI::ScrollView* mScrollView;
|
|
|
|
MyGUI::Widget* mClient;
|
|
|
|
|
|
|
|
std::vector<std::string> mItems;
|
|
|
|
|
|
|
|
int mItemHeight; // height of all items
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|