You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
1.7 KiB

#ifndef UITEXTLIST_H
#define UITEXTLIST_H
#include "uiwidget.h"
class UIListItem;
typedef std::shared_ptr<UIListItem> UIListItemPtr;
typedef std::list<UIListItemPtr> UIListItemList;
class UIListItem
{
public:
void setText(const std::string& text) { m_text = text; }
void setData(const boost::any& data) { m_data = data; }
boost::any getData() { return m_data; }
std::string getText() { return m_text; }
private:
std::string m_text;
boost::any m_data;
};
class UIList : public UIWidget
{
public:
UIList();
virtual void render();
void insertItem(int row, const UIListItemPtr& item);
//void insertItems(int row, const UIListItemList& items);
int addItem(const UIListItemPtr& item);
//int addItems(const UIListItemList& items);
void removeItem(const UIListItemPtr& item);
void removeRow(int row);
UIListItemPtr takeRow(int row);
void setCurrentItem(const UIListItemPtr& item);
void setCurrentRow(int row);
UIListItemPtr getItem(int row);
UIListItemPtr getItemAt(const Point& point);
UIListItemList getItems();
int getItemRow(const UIListItemPtr& item);
int getItemsCount();
UIListItemPtr getCurrentItem();
int getCurrentRow();
protected:
virtual void onStyleApply(const OTMLNodePtr& styleNode);
virtual bool onKeyPress(uchar keyCode, char keyChar, int keyboardModifiers);
virtual bool onMousePress(const Point& mousePos, UI::MouseButton button);
virtual bool onMouseMove(const Point& mousePos, const Point& mouseMoved);
// possible signals
//onItemActivated
//onItemChanged
//onCurrentItemChange
//onCurrenteRowChange
//onCurrentTextChange
//onItemClicked
std::list<UIListItem> m_items;
};
#endif