aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/irrlicht-1.8/source/Irrlicht/CGUIContextMenu.h
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/CGUIContextMenu.h')
-rw-r--r--libraries/irrlicht-1.8/source/Irrlicht/CGUIContextMenu.h348
1 files changed, 174 insertions, 174 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CGUIContextMenu.h b/libraries/irrlicht-1.8/source/Irrlicht/CGUIContextMenu.h
index 843b2b7..4966684 100644
--- a/libraries/irrlicht-1.8/source/Irrlicht/CGUIContextMenu.h
+++ b/libraries/irrlicht-1.8/source/Irrlicht/CGUIContextMenu.h
@@ -1,174 +1,174 @@
1// Copyright (C) 2002-2012 Nikolaus Gebhardt 1// Copyright (C) 2002-2012 Nikolaus Gebhardt
2// This file is part of the "Irrlicht Engine". 2// This file is part of the "Irrlicht Engine".
3// For conditions of distribution and use, see copyright notice in irrlicht.h 3// For conditions of distribution and use, see copyright notice in irrlicht.h
4 4
5#ifndef __C_GUI_CONTEXT_MENU_H_INCLUDED__ 5#ifndef __C_GUI_CONTEXT_MENU_H_INCLUDED__
6#define __C_GUI_CONTEXT_MENU_H_INCLUDED__ 6#define __C_GUI_CONTEXT_MENU_H_INCLUDED__
7 7
8#include "IrrCompileConfig.h" 8#include "IrrCompileConfig.h"
9#ifdef _IRR_COMPILE_WITH_GUI_ 9#ifdef _IRR_COMPILE_WITH_GUI_
10 10
11#include "IGUIContextMenu.h" 11#include "IGUIContextMenu.h"
12#include "irrString.h" 12#include "irrString.h"
13#include "irrArray.h" 13#include "irrArray.h"
14#include "IGUIFont.h" 14#include "IGUIFont.h"
15 15
16namespace irr 16namespace irr
17{ 17{
18namespace gui 18namespace gui
19{ 19{
20 20
21 //! GUI Context menu interface. 21 //! GUI Context menu interface.
22 class CGUIContextMenu : public IGUIContextMenu 22 class CGUIContextMenu : public IGUIContextMenu
23 { 23 {
24 public: 24 public:
25 25
26 //! constructor 26 //! constructor
27 CGUIContextMenu(IGUIEnvironment* environment, 27 CGUIContextMenu(IGUIEnvironment* environment,
28 IGUIElement* parent, s32 id, core::rect<s32> rectangle, 28 IGUIElement* parent, s32 id, core::rect<s32> rectangle,
29 bool getFocus = true, bool allowFocus = true); 29 bool getFocus = true, bool allowFocus = true);
30 30
31 //! destructor 31 //! destructor
32 virtual ~CGUIContextMenu(); 32 virtual ~CGUIContextMenu();
33 33
34 //! set behavior when menus are closed 34 //! set behavior when menus are closed
35 virtual void setCloseHandling(ECONTEXT_MENU_CLOSE onClose); 35 virtual void setCloseHandling(ECONTEXT_MENU_CLOSE onClose);
36 36
37 //! get current behavior when the menue will be closed 37 //! get current behavior when the menue will be closed
38 virtual ECONTEXT_MENU_CLOSE getCloseHandling() const; 38 virtual ECONTEXT_MENU_CLOSE getCloseHandling() const;
39 39
40 //! Returns amount of menu items 40 //! Returns amount of menu items
41 virtual u32 getItemCount() const; 41 virtual u32 getItemCount() const;
42 42
43 //! Adds a menu item. 43 //! Adds a menu item.
44 virtual u32 addItem(const wchar_t* text, s32 commandid, 44 virtual u32 addItem(const wchar_t* text, s32 commandid,
45 bool enabled, bool hasSubMenu, bool checked, bool autoChecking); 45 bool enabled, bool hasSubMenu, bool checked, bool autoChecking);
46 46
47 //! Insert a menu item at specified position. 47 //! Insert a menu item at specified position.
48 virtual u32 insertItem(u32 idx, const wchar_t* text, s32 commandId, bool enabled, 48 virtual u32 insertItem(u32 idx, const wchar_t* text, s32 commandId, bool enabled,
49 bool hasSubMenu, bool checked, bool autoChecking); 49 bool hasSubMenu, bool checked, bool autoChecking);
50 50
51 //! Find a item which has the given CommandId starting from given index 51 //! Find a item which has the given CommandId starting from given index
52 virtual s32 findItemWithCommandId(s32 commandId, u32 idxStartSearch) const; 52 virtual s32 findItemWithCommandId(s32 commandId, u32 idxStartSearch) const;
53 53
54 //! Adds a separator item to the menu 54 //! Adds a separator item to the menu
55 virtual void addSeparator(); 55 virtual void addSeparator();
56 56
57 //! Returns text of the menu item. 57 //! Returns text of the menu item.
58 virtual const wchar_t* getItemText(u32 idx) const; 58 virtual const wchar_t* getItemText(u32 idx) const;
59 59
60 //! Sets text of the menu item. 60 //! Sets text of the menu item.
61 virtual void setItemText(u32 idx, const wchar_t* text); 61 virtual void setItemText(u32 idx, const wchar_t* text);
62 62
63 //! Returns if a menu item is enabled 63 //! Returns if a menu item is enabled
64 virtual bool isItemEnabled(u32 idx) const; 64 virtual bool isItemEnabled(u32 idx) const;
65 65
66 //! Sets if the menu item should be enabled. 66 //! Sets if the menu item should be enabled.
67 virtual void setItemEnabled(u32 idx, bool enabled); 67 virtual void setItemEnabled(u32 idx, bool enabled);
68 68
69 //! Returns if a menu item is checked 69 //! Returns if a menu item is checked
70 virtual bool isItemChecked(u32 idx) const; 70 virtual bool isItemChecked(u32 idx) const;
71 71
72 //! Sets if the menu item should be checked. 72 //! Sets if the menu item should be checked.
73 virtual void setItemChecked(u32 idx, bool enabled); 73 virtual void setItemChecked(u32 idx, bool enabled);
74 74
75 //! Removes a menu item 75 //! Removes a menu item
76 virtual void removeItem(u32 idx); 76 virtual void removeItem(u32 idx);
77 77
78 //! Removes all menu items 78 //! Removes all menu items
79 virtual void removeAllItems(); 79 virtual void removeAllItems();
80 80
81 //! called if an event happened. 81 //! called if an event happened.
82 virtual bool OnEvent(const SEvent& event); 82 virtual bool OnEvent(const SEvent& event);
83 83
84 //! draws the element and its children 84 //! draws the element and its children
85 virtual void draw(); 85 virtual void draw();
86 86
87 //! Returns the selected item in the menu 87 //! Returns the selected item in the menu
88 virtual s32 getSelectedItem() const; 88 virtual s32 getSelectedItem() const;
89 89
90 //! Returns a pointer to the submenu of an item. 90 //! Returns a pointer to the submenu of an item.
91 //! \return Pointer to the submenu of an item. 91 //! \return Pointer to the submenu of an item.
92 virtual IGUIContextMenu* getSubMenu(u32 idx) const; 92 virtual IGUIContextMenu* getSubMenu(u32 idx) const;
93 93
94 //! Sets the visible state of this element. 94 //! Sets the visible state of this element.
95 virtual void setVisible(bool visible); 95 virtual void setVisible(bool visible);
96 96
97 //! should the element change the checked status on clicking 97 //! should the element change the checked status on clicking
98 virtual void setItemAutoChecking(u32 idx, bool autoChecking); 98 virtual void setItemAutoChecking(u32 idx, bool autoChecking);
99 99
100 //! does the element change the checked status on clicking 100 //! does the element change the checked status on clicking
101 virtual bool getItemAutoChecking(u32 idx) const; 101 virtual bool getItemAutoChecking(u32 idx) const;
102 102
103 //! Returns command id of a menu item 103 //! Returns command id of a menu item
104 virtual s32 getItemCommandId(u32 idx) const; 104 virtual s32 getItemCommandId(u32 idx) const;
105 105
106 //! Sets the command id of a menu item 106 //! Sets the command id of a menu item
107 virtual void setItemCommandId(u32 idx, s32 id); 107 virtual void setItemCommandId(u32 idx, s32 id);
108 108
109 //! Adds a sub menu from an element that already exists. 109 //! Adds a sub menu from an element that already exists.
110 virtual void setSubMenu(u32 index, CGUIContextMenu* menu); 110 virtual void setSubMenu(u32 index, CGUIContextMenu* menu);
111 111
112 //! When an eventparent is set it receives events instead of the usual parent element 112 //! When an eventparent is set it receives events instead of the usual parent element
113 virtual void setEventParent(IGUIElement *parent); 113 virtual void setEventParent(IGUIElement *parent);
114 114
115 //! Writes attributes of the element. 115 //! Writes attributes of the element.
116 virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const; 116 virtual void serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const;
117 117
118 //! Reads attributes of the element 118 //! Reads attributes of the element
119 virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options); 119 virtual void deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options);
120 120
121 protected: 121 protected:
122 122
123 void closeAllSubMenus(); 123 void closeAllSubMenus();
124 bool hasOpenSubMenu() const; 124 bool hasOpenSubMenu() const;
125 125
126 struct SItem 126 struct SItem
127 { 127 {
128 core::stringw Text; 128 core::stringw Text;
129 bool IsSeparator; 129 bool IsSeparator;
130 bool Enabled; 130 bool Enabled;
131 bool Checked; 131 bool Checked;
132 bool AutoChecking; 132 bool AutoChecking;
133 core::dimension2d<u32> Dim; 133 core::dimension2d<u32> Dim;
134 s32 PosY; 134 s32 PosY;
135 CGUIContextMenu* SubMenu; 135 CGUIContextMenu* SubMenu;
136 s32 CommandId; 136 s32 CommandId;
137 }; 137 };
138 138
139 virtual void recalculateSize(); 139 virtual void recalculateSize();
140 140
141 //! returns true, if an element was highlighted 141 //! returns true, if an element was highlighted
142 virtual bool highlight(const core::position2d<s32>& p, bool canOpenSubMenu); 142 virtual bool highlight(const core::position2d<s32>& p, bool canOpenSubMenu);
143 143
144 //! sends a click Returns: 144 //! sends a click Returns:
145 //! 0 if click went outside of the element, 145 //! 0 if click went outside of the element,
146 //! 1 if a valid button was clicked, 146 //! 1 if a valid button was clicked,
147 //! 2 if a nonclickable element was clicked 147 //! 2 if a nonclickable element was clicked
148 virtual u32 sendClick(const core::position2d<s32>& p); 148 virtual u32 sendClick(const core::position2d<s32>& p);
149 149
150 //! returns the item highlight-area 150 //! returns the item highlight-area
151 virtual core::rect<s32> getHRect(const SItem& i, const core::rect<s32>& absolute) const; 151 virtual core::rect<s32> getHRect(const SItem& i, const core::rect<s32>& absolute) const;
152 152
153 //! Gets drawing rect of Item 153 //! Gets drawing rect of Item
154 virtual core::rect<s32> getRect(const SItem& i, const core::rect<s32>& absolute) const; 154 virtual core::rect<s32> getRect(const SItem& i, const core::rect<s32>& absolute) const;
155 155
156 156
157 core::array<SItem> Items; 157 core::array<SItem> Items;
158 core::position2d<s32> Pos; 158 core::position2d<s32> Pos;
159 IGUIElement* EventParent; 159 IGUIElement* EventParent;
160 IGUIFont *LastFont; 160 IGUIFont *LastFont;
161 ECONTEXT_MENU_CLOSE CloseHandling; 161 ECONTEXT_MENU_CLOSE CloseHandling;
162 s32 HighLighted; 162 s32 HighLighted;
163 u32 ChangeTime; 163 u32 ChangeTime;
164 bool AllowFocus; 164 bool AllowFocus;
165 }; 165 };
166 166
167 167
168} // end namespace gui 168} // end namespace gui
169} // end namespace irr 169} // end namespace irr
170 170
171#endif // _IRR_COMPILE_WITH_GUI_ 171#endif // _IRR_COMPILE_WITH_GUI_
172 172
173#endif // __C_GUI_CONTEXT_MENU_H_INCLUDED__ 173#endif // __C_GUI_CONTEXT_MENU_H_INCLUDED__
174 174