1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 10:49:57 +00:00
openmw-tes3mp/apps/openmw/mwgui/list.hpp

84 lines
2.6 KiB
C++
Raw Normal View History

#ifndef MWGUI_LIST_HPP
#define MWGUI_LIST_HPP
2013-03-09 19:40:59 +00:00
#include <MyGUI_ScrollView.h>
namespace MWGui
{
namespace Widgets
{
2013-03-09 19:40:59 +00:00
/**
* \brief a custom ScrollView which has access to scrollbar properties
*/
class MWScrollView : public MyGUI::ScrollView
{
MYGUI_RTTI_DERIVED(MWScrollView)
public:
size_t getScrollPosition();
void setScrollPosition(size_t);
size_t getScrollRange();
};
/**
* \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
*/
class MWList : public MyGUI::Widget
{
MYGUI_RTTI_DERIVED(MWList)
public:
MWList();
typedef MyGUI::delegates::CMultiDelegate2<const std::string&, int> EventHandle_StringInt;
2012-09-24 06:09:16 +00:00
typedef MyGUI::delegates::CMultiDelegate1<MyGUI::Widget*> EventHandle_Widget;
/**
* Event: Item selected with the mouse.
* signature: void method(std::string itemName)
*/
EventHandle_StringInt 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
/**
* Call after the size of the list changed, or items were inserted/removed
2012-05-10 09:19:22 +00:00
*/
void adjustSize();
void addItem(const std::string& name);
void addSeparator(); ///< add a seperator between the current and the next item.
void removeItem(const std::string& name);
bool hasItem(const std::string& name);
unsigned int getItemCount();
std::string getItemNameAt(unsigned int at); ///< \attention if there are separators, this method will return "" at the place where the separator is
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
protected:
void initialiseOverride();
void redraw(bool scrollbarShown = false);
void onMouseWheel(MyGUI::Widget* _sender, int _rel);
void onItemSelected(MyGUI::Widget* _sender);
private:
2013-03-09 19:40:59 +00:00
MWGui::Widgets::MWScrollView* mScrollView;
MyGUI::Widget* mClient;
std::vector<std::string> mItems;
int mItemHeight; // height of all items
};
}
}
#endif