TDME2  1.9.200
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GUIGridController.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string>
4 #include <vector>
5 
6 #include <tdme/tdme.h>
12 
13 using std::string;
14 using std::vector;
15 
25 
26 /**
27  * Grid controller
28  * @author Andreas Drewke
29  */
31  : public GUIElementController
32 {
33  friend class GUIGrid;
34  friend class GUIGridItemController;
35 
36 private:
39  STATIC_DLL_IMPEXT static constexpr char VALUE_DELIMITER { '|' };
40  vector<GUIGridItemController*> gridItemControllers;
41  bool disabled;
46 
47  bool keyControl;
48 
49  bool onSubTreeChangeRun { false };
50  int horizontalItems { 1 };
51 
52  // forbid class copy
54 
55  /**
56  * Private constructor
57  * @param node node
58  */
60 
61  /**
62  * @return if multiple selection is enabled
63  */
64  bool isMultipleSelection();
65 
66  /**
67  * @return is control down
68  */
69  bool isKeyControlDown();
70 
71  /**
72  * Get focussed item idx
73  */
74  int getFocussedItemIdx();
75 
76  /**
77  * Get item idx
78  * @param gridItemElementNode grid item element node
79  */
80  int getItemIdx(GUIElementNode* gridItemElementNode);
81 
82  /**
83  * Unselect all items
84  */
85  void unselect();
86 
87  /**
88  * Select
89  * @param itemIdx item index
90  */
91  void select(int itemIdx);
92 
93  /**
94  * Select
95  * @param gridItemElementNode grid item element node
96  */
97  void select(GUIElementNode* gridItemElementNode);
98 
99  /**
100  * Unfocus all items
101  */
102  void unfocus();
103 
104  /**
105  * Focus
106  * @param itemIdx item index
107  */
108  void focus(int itemIdx);
109 
110  /**
111  * Focus
112  * @param gridItemElementNode grid item element node
113  */
114  void focus(GUIElementNode* gridItemElementNode);
115 
116  /**
117  * Select current item
118  */
119  void selectCurrent();
120 
121  /**
122  * Focus next item
123  */
124  void focusNext();
125 
126  /**
127  * Focus previous item
128  */
129  void focusPrevious();
130 
131  /**
132  * Toggle
133  * @param itemIdx item index
134  */
135  void toggle(int itemIdx);
136 
137  /**
138  * Toggle
139  * @param gridItemElementNode grid item element node
140  */
141  void toggle(GUIElementNode* gridItemElementNode);
142 
143  /**
144  * Select focussed node
145  */
146  void select();
147 
148  /**
149  * Determine items
150  */
151  void determineItems();
152 
153 public:
154 
155  // overridden methods
156  void initialize() override;
157  void dispose() override;
158  void postLayout() override;
159  void handleMouseEvent(GUINode* node, GUIMouseEvent* event) override;
160  void handleKeyboardEvent(GUIKeyboardEvent* event) override;
161  void tick() override;
162  void onFocusGained() override;
163  void onFocusLost() override;
164  bool hasValue() override;
165  const MutableString& getValue() override;
166  void setValue(const MutableString& value) override;
167  void onSubTreeChange() override;
168 
169 };
void selectCurrent()
Select current item.
vector< GUIGridItemController * > gridItemControllers
void onFocusGained() override
On focus gained.
void dispose() override
Dispose controller.
void postLayout() override
Post layout event.
void initialize() override
Initialize controller after element has been created.
void handleKeyboardEvent(GUIKeyboardEvent *event) override
Handle keyboard event.
GUIGridController(GUINode *node)
Private constructor.
void onFocusLost() override
On focus lost.
void setValue(const MutableString &value) override
Set value.
void handleMouseEvent(GUINode *node, GUIMouseEvent *event) override
Handle mouse event.
void tick() override
Tick method will be executed once per frame.
static constexpr STATIC_DLL_IMPEXT char VALUE_DELIMITER
static STATIC_DLL_IMPEXT string CONDITION_DISABLED
void focusPrevious()
Focus previous item.
static STATIC_DLL_IMPEXT string CONDITION_ENABLED
int getItemIdx(GUIElementNode *gridItemElementNode)
Get item idx.
const MutableString & getValue() override
void onSubTreeChange() override
On sub tree change.
int getFocussedItemIdx()
Get focussed item idx.
GUI grid element.
Definition: GUIGrid.h:28
GUI node controller base class.
GUI node base class.
Definition: GUINode.h:64
Mutable utf8 aware string class.
Definition: MutableString.h:23
#define STATIC_DLL_IMPEXT
Definition: tdme.h:15
#define FORBID_CLASS_COPY(CLASS)
Definition: tdme.h:6