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
87
class
gGUIContextMenuItem
:
public
gGUIControl
{
88
public
:
89
90
gGUIContextMenuItem
(std::string text,
gImage
* menuIcon,
bool
seperatorAdded);
91
~gGUIContextMenuItem
();
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
104
int
getItemId
();
105
111
void
setParentItemId
(
int
itemId);
112
118
int
getParentItemId
();
119
127
gGUIContextMenuItem
*
getItem
(
int
itemNo);
128
134
int
getContextMenuLeftMargin
();
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
*/
148
int
getContextMenuSize
();
149
155
bool
getContextMenuShown
();
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
190
int
contextmenux
,
contextmenuy
,
contextmenudefaultw
,
contextmenuh
;
191
192
private
:
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
215
class
gGUIContextMenu
:
public
gGUIContextMenuItem
{
216
public
:
217
218
gGUIContextMenu
();
219
virtual
~gGUIContextMenu
();
220
221
void
draw
();
222
223
private
:
224
std::vector<gGUIContextMenuItem> items;
225
};
226
227
#endif
/* UI_GGUICONTEXTMENU_H_ */
gGUIContextMenuItem
Definition
gGUIContextMenu.h:87
gGUIContextMenuItem::getContextMenuShown
bool getContextMenuShown()
gGUIContextMenuItem::contextmenux
int contextmenux
Definition
gGUIContextMenu.h:190
gGUIContextMenuItem::isPressed
bool isPressed()
gGUIContextMenuItem::~gGUIContextMenuItem
~gGUIContextMenuItem()
gGUIContextMenuItem::setContextMenuLeftMargin
void setContextMenuLeftMargin(int leftMargin)
gGUIContextMenuItem::mouseMoved
void mouseMoved(int x, int y)
gGUIContextMenuItem::gGUIContextMenuItem
gGUIContextMenuItem(std::string text, gImage *menuIcon, bool seperatorAdded)
gGUIContextMenuItem::contextmenuy
int contextmenuy
Definition
gGUIContextMenu.h:190
gGUIContextMenuItem::getParentItemId
int getParentItemId()
gGUIContextMenuItem::mouseReleased
void mouseReleased(int x, int y, int button)
gGUIContextMenuItem::getContextMenuSize
int getContextMenuSize()
gGUIContextMenuItem::contextmenudefaultw
int contextmenudefaultw
Definition
gGUIContextMenu.h:190
gGUIContextMenuItem::drawMenuItem
virtual void drawMenuItem()
gGUIContextMenuItem::getItemTitle
std::string getItemTitle(int itemNo)
gGUIContextMenuItem::contextmenuh
int contextmenuh
Definition
gGUIContextMenu.h:190
gGUIContextMenuItem::getItem
gGUIContextMenuItem * getItem(int itemNo)
gGUIContextMenuItem::mousePressed
void mousePressed(int x, int y, int button)
gGUIContextMenuItem::addItem
void addItem(std::string text, gImage *menuIcon, bool seperatorAdded)
gGUIContextMenuItem::setParentItemId
void setParentItemId(int itemId)
gGUIContextMenuItem::getItemId
int getItemId()
gGUIContextMenuItem::getContextMenuLeftMargin
int getContextMenuLeftMargin()
gGUIContextMenu
Definition
gGUIContextMenu.h:215
gGUIContextMenu::~gGUIContextMenu
virtual ~gGUIContextMenu()
gGUIContextMenu::gGUIContextMenu
gGUIContextMenu()
gGUIContextMenu::draw
void draw()
gGUIControl
Definition
gGUIControl.h:29
gImage
Definition
gImage.h:34
gGUIControl.h
gImage.h
engine
ui
gGUIContextMenu.h
Generated by
1.9.8