GlistEngine
Loading...
Searching...
No Matches
gGUIListbox.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: Noyan Culum, Sevval Bulburu, Aynur Dogan 2022-08-18 *
31 ****************************************************************************/
32
33/*
34 * gGUIListbox.h
35 *
36 * Created on: Feb 5, 2022
37 * Author: noyan
38 */
39
40#ifndef UI_GGUILISTBOX_H_
41#define UI_GGUILISTBOX_H_
42
43#include "gGUIScrollable.h"
44#include <deque>
45#include "gImage.h"
46
47
48/*
49 * This class creates list boxes. List boxes can use when developer wants to listed
50 * any kind of data. There isn't an edge for number of the datas.
51 *
52 * Listbox uses a vector for storing the datas. This vector stores the given
53 * title's. Developer can make basic operations about this vector such as adding
54 * a data to a vector, removing data from the vector or renamed the spesific line's
55 * title.
56 *
57 * Also developers can use icons with the datas. SetIconType() function uses for
58 * activeted the default icons. When the function activated, then deleloper can
59 * change icons with images from outside or using gGUIResources class'es icons.
60 * Icon's color can be change with setIconColor() function.
61 *
62 * Developer can click to a line. When the line clicked it's color will be orange.
63 * This color can be changed with the setChosenColor() function.
64 */
65
67public:
69 virtual ~gGUIListbox();
70
71 void set(gBaseApp* root, gBaseGUIObject* topParentGUIObject, gBaseGUIObject* parentGUIObject, int parentSlotLineNo, int parentSlotColumnNo, int x, int y, int w, int h);
72
73 /*
74 * Used for add an element to da data list with given title.
75 *
76 * @param lineData is the string value that stored in the data list.
77 */
78 void addData(std::string lineData);
79
80 /*
81 * Changes the data of the given line no.
82 *
83 * @param lineData is the string value that stored in the data list.
84 */
85 void setData(int lineNo, std::string lineData);
86
87 /*
88 * Renamed title of the given line number with the given text.
89 *
90 * @lineNo is the line number that changed the title.
91 * @lineData is the new title for the given line number.
92 */
93 void insertData(int lineNo, std::string lineData);
94
95 /*
96 * Used for erase the given line number from the data list.
97 *
98 * @param lineNo is the line number that developer wants to erase from the
99 * list.
100 */
101 void removeData(int lineNo);
102
103 /*
104 * Used for erase the click and selected line from the list.
105 */
107
108 /*
109 * Used for clean all the datas in the class.
110 */
111 void clear();
112
114
115 /*
116 * Sets the click and selected line with the given line number.
117 *
118 * @param lineNo is the number of line that selected.
119 */
120 void setSelected(int lineNo);
121
122 /*
123 * Returns selected line's number.
124 */
126
127 /*
128 * Returns the title of the selected line.
129 */
130 std::string getSelectedData();
131
132 /*
133 * Returns the title of the given line number.
134 *
135 * @lineNo is the number of line that the title's given.
136 */
137 std::string getData(int lineNo);
138
139 /*
140 * Returns all the titles in a vector.
141 *
142 */
143 std::vector<std::string> getData();
144
145 /*
146 * Returns the size of data list.
147 */
149
150 void mousePressed(int x, int y, int button);
151 void mouseReleased(int x, int y, int button);
152
153 /*
154 * Sets the color of the row which developer click and select, with the
155 * given color. Colors consist of RGB values float between 0.0f-1.0f.
156 *
157 * @param color The given color consist of (r, g, b) float values.
158 */
159 void setChosenColor(float r, float g, float b);
160
161
162 /*
163 * Sets the number of the lines that visible on the tree list. This function
164 * should be use before Treelist added to the panel with setControl function.
165 *
166 * @param linenumber is an integer value which define the number of minimum
167 * lines. Developer should give a number bigger than 0.
168 */
169 void setVisibleLineNumber(int linenumber);
170
171 /*
172 * Sets the icon type at the top of the titles. If developer wants to use new
173 * icons, should sets the isicon attribute. If the attribute is not setted,
174 * default list will be drawn.
175 *
176 * @param isicon is the boolean value that sets the icon types. For using new
177 * icons, it should be 'true'.
178 */
179 void setIconType(bool isicon);
180
181 /*
182 * Sets the icons with default 'File icon' for the all elements of the data
183 * list.
184 */
185 void setIcons();
186
187 /*
188 * Sets the color of the icons with the given color. Colors consist of RGB
189 * values float between 0.0f-1.0f.
190 *
191 * @param color The given color consist of (r, g, b) float values.
192 */
193 void setIconsColor(float r, float g, float b);
194
195 /*
196 * Sets the given icon to the given title. Developer can give any
197 * image from outside. The image must be loaded before using as a parameter
198 * for the function. Image's width and height will be arrange automatically.
199 *
200 * @param icon is the image that developer wants to use.
201 *
202 * @param title is the string data value which the icon will be changed.
203 */
204 void setIcon(gImage* icon, std::string title);
205
206
207 /*
208 * Sets the given icon to the given object of the struct. Uses the icons in
209 * the gGUIResources class. This icons are storing in the base64. Icon's
210 * width and height will be arrange automatically.
211 *
212 * @param iconid is the icon number of the images in the gGUIResources class.
213 * This numbers are defined with enumeration method.
214 *
215 * @param title is the string data value which the icon will be changed.
216 */
217 void setIcon(int iconid, std::string title);
218
219 /*
220 * Returns the isicon value of the given data list.
221 */
223
224 /*
225 * Returns the pointer of the image that uses for icons to the given data
226 * list
227 *
228 * @param title is the string data value which returned icon image on the
229 * list.
230 */
231 gTexture* getIcon(std::string title);
232
233 /*
234 * Returns the color that when an data is chosen.
235 */
237
238 /*
239 * Returns the icons color.
240 */
242
243 /*
244 * Returns the number of the lines which is visible in the box.
245 */
247
249
252
253private:
254 int listboxh;
255 int lineh;
256 int visibilelinenum, minboxh;
257 std::vector<std::string> data;
258 std::deque<gTexture*> icons;
259 float textoffset;
260 int firstlineno, flno, fldy;
261 int selectedno;
262 bool mousepressedonlist;
263 bool isicon;
264 gColor chosencolor, iconcolor;
265 bool isdisabled;
266
267private:
268 void updateTotalHeight();
269};
270
271#endif /* UI_GGUILISTBOX_H_ */
Definition gBaseApp.h:16
Definition gBaseGUIObject.h:18
gBaseApp * root
Definition gBaseGUIObject.h:147
std::string title
Definition gBaseGUIObject.h:145
Definition gColor.h:17
Definition gGUIListbox.h:66
void setIconType(bool isicon)
int getTotalHeight()
void setDisabled(bool isDisabled)
int getSelected()
bool getIconType()
void insertData(int lineNo, std::string lineData)
std::string getSelectedData()
void mouseReleased(int x, int y, int button)
void setSelected(int lineNo)
gTexture * getIcon(std::string title)
int getVisibleLineNumber()
void mousePressed(int x, int y, int button)
void setIcon(int iconid, std::string title)
void removeSelected()
gColor getIconsColor()
void removeData(int lineNo)
void setIcons()
void setIcon(gImage *icon, std::string title)
virtual ~gGUIListbox()
void set(gBaseApp *root, gBaseGUIObject *topParentGUIObject, gBaseGUIObject *parentGUIObject, int parentSlotLineNo, int parentSlotColumnNo, int x, int y, int w, int h)
bool isDisabled()
void clear()
void drawContent()
void setData(int lineNo, std::string lineData)
void setVisibleLineNumber(int linenumber)
std::vector< std::string > getData()
void addData(std::string lineData)
int getDataNum()
gColor getChosenColor()
std::string getData(int lineNo)
void setIconsColor(float r, float g, float b)
void setChosenColor(float r, float g, float b)
Definition gGUIScrollable.h:68
Definition gImage.h:34
Definition gTexture.h:17
float r
Definition gColor.h:22
float b
Definition gColor.h:22
float g
Definition gColor.h:22