GlistEngine
Loading...
Searching...
No Matches
gGUIContextMenu.h
Go to the documentation of this file.
1/****************************************************************************
2 * Copyright (c) 2014 Nitra Games Ltd., Istanbul, Turkey *
3 * *
4 * Permission is hereby granted, free of charge, to any person obtaining a *
5 * copy of this software and associated documentation files (the *
6 * "Software"), to deal in the Software without restriction, including *
7 * without limitation the rights to use, copy, modify, merge, publish, *
8 * distribute, distribute with modifications, sublicense, and/or sell *
9 * copies of the Software, and to permit persons to whom the Software is *
10 * furnished to do so, subject to the following conditions: *
11 * *
12 * The above copyright notice and this permission notice should not be *
13 * deleted from the source form of the Software. *
14 * *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
22 * *
23 * Except as contained in this notice, the name(s) of the above copyright *
24 * holders shall not be used in advertising or otherwise to promote the *
25 * sale, use or other dealings in this Software without prior written *
26 * authorization. *
27 ****************************************************************************/
28
29/****************************************************************************
30 * Author: Ipek Senturk, 2022 Jul 29 *
31 ****************************************************************************/
32/*
33 * gGUIContextMenu.h
34 *
35 * Created on: 29 Jul 2022
36 * Author: Ipek Senturk
37 */
38
39#ifndef UI_GGUICONTEXTMENU_H_
40#define UI_GGUICONTEXTMENU_H_
41
42#include "gGUIControl.h"
43#include "gImage.h"
44
88public:
89
90 gGUIContextMenuItem(std::string text, gImage* menuIcon, bool seperatorAdded);
92
93 virtual void drawMenuItem();
94
95 void mouseMoved(int x, int y);
96 void mousePressed(int x, int y, int button);
97 void mouseReleased(int x, int y, int button);
98
105
111 void setParentItemId(int itemId);
112
119
128
135
141 void setContextMenuLeftMargin(int leftMargin);
142
143 /*
144 * Returns the total number of context menu items.
145 *
146 * @return the current size of items vector.
147 */
149
156
157 /*
158 * Returns the information for whether an item is
159 * selected or not.
160 *
161 * @return whether a menu item was clicked or not.
162 */
163 bool isPressed();
164
165 /*
166 * Returns the title of a context menu item.
167 *
168 * @param itemNo is the number of context menu item whose
169 * title will be returned
170 *
171 * @return a menu items title as a string.
172 */
173 std::string getItemTitle(int itemNo);
174
187 void addItem(std::string text, gImage* menuIcon, bool seperatorAdded);
188
189
191
192private:
193 static int lastitemid;
194 static int lastparentitemid;
195 static std::vector<int> parentitems;
196 int itemid, parentitemid;
197 std::string text;
198 std::vector<gGUIContextMenuItem> items;
199 int contextmenuw;
200 int contextmenuleftmargin;
201 int contextmenulineh;
202 int datady;
203 bool contextmenushown;
204 bool hovered;
205 bool seperatoradded;
206 bool ispressed;
207 bool isparent;
208 gImage* menuicon;
209 int menuiconx, menuicony, menuiconw, menuiconh;
210 int itemno;
211 int counter;
212 int i;
213};
214
216public:
217
220
221 void draw();
222
223private:
224 std::vector<gGUIContextMenuItem> items;
225};
226
227#endif /* UI_GGUICONTEXTMENU_H_ */
Definition gGUIContextMenu.h:87
int contextmenux
Definition gGUIContextMenu.h:190
void setContextMenuLeftMargin(int leftMargin)
void mouseMoved(int x, int y)
gGUIContextMenuItem(std::string text, gImage *menuIcon, bool seperatorAdded)
int contextmenuy
Definition gGUIContextMenu.h:190
void mouseReleased(int x, int y, int button)
int contextmenudefaultw
Definition gGUIContextMenu.h:190
virtual void drawMenuItem()
std::string getItemTitle(int itemNo)
int contextmenuh
Definition gGUIContextMenu.h:190
gGUIContextMenuItem * getItem(int itemNo)
void mousePressed(int x, int y, int button)
void addItem(std::string text, gImage *menuIcon, bool seperatorAdded)
void setParentItemId(int itemId)
int getContextMenuLeftMargin()
Definition gGUIContextMenu.h:215
virtual ~gGUIContextMenu()
Definition gGUIControl.h:29
Definition gImage.h:34