My Project
GUIListBox.h
1 #pragma once
2 
3 #include "GUIContainer.h"
4 #include "GUIScript.h"
5 
6 namespace ParaEngine
7 {
8  struct GUIListItem {
9  u16string text;
10  bool selected;
11  GUI_SCRIPT onclick;
12  CGUIBase *advObj;
13  };
14 
22  {
23  public:
24  CGUIListBox();
25  virtual ~CGUIListBox();
26 
31  void SetMultiSelect(bool multiselect){m_bMultiSelect=multiselect;};
36  bool GetMultiSelect(){return m_bMultiSelect;};
37 
43  void SetItemHeight(int height);
48  int GetItemHeight(){return m_ItemHeight;}
49 
55  int GetSelected(){return m_nSelected;};
61  bool GetSelected(int index);
62 
69  virtual int GetTextA(std::string& out);
70  int GetTextA(int index, std::string& out);
76  virtual const char16_t* GetText();;
77  const char16_t* GetText(int index);
78 
84  void AddItem(const GUIListItem& listitem);
85 
90  void AddTextItemA(const char* szText);
91 
98  void InsertItem(int index,const GUIListItem* listitem);
103  void DeleteItem(int index);
104 
108  void RemoveAll();
114  GUIListItem* GetItem(int index);
115 
123  void SetWordBreak(bool wordbreak);
128  bool GetWordBreak(){return m_bWordBreak;};
129 
134  void SelectItem(int index);
138  bool GetItemCanDrag(){return m_bItemCanDrag;}
139  void SetItemCanDrag(bool candrag){m_bItemCanDrag=candrag;}
140 
144  int Size(){return (int)m_items.size();}
145 
146  virtual void UpdateScroll(int nXDelta,int nYDelta);
147  virtual HRESULT Render(GUIState* pGUIState ,float fElapsedTime);
148 
149  virtual void InitObject(const char * strObjectName, const char * alignment, int x, int y, int width, int height);
150  //virtual bool MsgProc(CGUIEvent *event=NULL);
151  virtual bool MsgProc(MSG *event);
152  virtual void UpdateRects();
153 
154  virtual IObject* Clone()const;
155  virtual void Clone(IObject *pobj)const;
156  virtual const IType* GetType()const{return m_type;}
157 
158  static void StaticInit();
160  protected:
161  static const IType* m_type;
162  //if allow select multiple items
163  bool m_bMultiSelect;
164  //the index of the selected item, it is the first selected item if m_bMultiSelect is true; if nothing selected, it is -1;
165  int m_nSelected;
166  int m_ItemHeight;
167  mutable list<GUIListItem> m_items;
168  map<int,GUIListItem*> m_itemmap;
169  int m_deltaX,m_deltaY;
170  bool m_bItemCanDrag;
171  bool m_bAllowAdvObject;
172  bool m_bDrag; // Whether the user is dragging the mouse to select
173  bool m_bWordBreak;
174  Color m_SelBkColor; // Selected background color
175  int m_nSelStart;
176  };
177 }
IType is for type information and validating It contains type information of an object.
Definition: Type.h:75
int GetItemHeight()
Get the height of each item.
Definition: GUIListBox.h:48
Definition: EventBinding.h:22
different physics engine has different winding order.
Definition: EventBinding.h:32
int Size()
Get number of items in the CGUIListBox.
Definition: GUIListBox.h:144
int GetSelected()
Get the selected item.
Definition: GUIListBox.h:55
base object for all 2D GUI objects (1) 2D GUI object are not tested against view frustum, instead it is controlled by visibility tag automatically or through user input.
Definition: GUIBase.h:54
base class for object, such as CBaseObject, IAttributeObject, GUI object.
Definition: PERef.h:287
m_objResource->m_objArtwork->DrawingRects[0]: client rectangle; m_objResource->m_objArtwork->DrawingR...
Definition: GUIListBox.h:21
bool GetMultiSelect()
Get multiselect state of the listbox.
Definition: GUIListBox.h:36
Definition: GUIListBox.h:8
void SetMultiSelect(bool multiselect)
Enable or disable multiselect of the listbox.
Definition: GUIListBox.h:31
m_objResource->m_objArtwork->DrawingRects[0]: client rectangle; m_objResource->m_objArtwork->DrawingR...
Definition: GUIContainer.h:19
It&#39;s used as parameter to Render method of each GUI object.
Definition: GUIState.h:16
bool GetItemCanDrag()
decide if the items can be dragged inside the listbox
Definition: GUIListBox.h:138
Definition: ParaColor.h:275
bool GetWordBreak()
Get Workbreak of the list item.
Definition: GUIListBox.h:128
static const IType * m_type
events
Definition: GUIListBox.h:161