Neo  0.5.0
Developer Documentation
List.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014 (C) Yannick Pflanzer <neo-engine.de>
3  *
4  * This file is part of Neo2D.
5  *
6  * Neo2D is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Neo2D is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with Neo2D. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * Diese Datei ist Teil von Neo2D.
20  *
21  * Neo2D ist Freie Software: Sie können es unter den Bedingungen
22  * der GNU Lesser General Public License, wie von der Free Software Foundation,
23  * Version 3 der Lizenz oder (nach Ihrer Wahl) jeder späteren
24  * veröffentlichten Version, weiterverbreiten und/oder modifizieren.
25  *
26  * Neo2D wird in der Hoffnung, dass es nützlich sein wird, aber
27  * OHNE JEDE GEWÄHRLEISTUNG, bereitgestellt; sogar ohne die implizite
28  * Gewährleistung der MARKTFÄHIGKEIT oder EIGNUNG FÜR EINEN BESTIMMTEN ZWECK.
29  * Siehe die GNU Lesser General Public License für weitere Details.
30  *
31  * Sie sollten eine Kopie der GNU Lesser General Public License zusammen mit
32  *diesem
33  * Programm erhalten haben. Wenn nicht, siehe <http://www.gnu.org/licenses/>.
34  */
35 
36 #ifndef __LIST_H__
37 #define __LIST_H__
38 
39 #include <string>
40 #include <NeoEngine.h>
41 #include <Widget.h>
42 #include <Button.h>
43 
44 namespace Neo2D
45 {
46 namespace Gui
47 {
48 
49 using namespace Neo;
50 
56 class NEO2D_EXPORT List : public Widget
57 {
58 protected:
59 
61  std::vector<Button*> m_entries;
63 
64  static void listCallback(Widget* w, long int data);
65 
66  struct CallbackData
67  {
68  int idx;
70  };
71 
72 public:
73  List(unsigned int x, unsigned int y, unsigned int width,
74  unsigned int height, const char* label)
75  : Widget(x, y, width, height, label), m_font("assets/default.ttf"),
76  m_selectedEntry(-1)
77  {}
78 
79  void show() { m_visible = true; }
80  Button* getEntry(unsigned int idx) { return m_entries[idx]; }
81  void addEntry(Button* l);
82  void addEntry(const char* label);
83 
84  void setSelectedEntry(int idx) { m_selectedEntry = idx; }
85  int getSelectedEntry() { return m_selectedEntry; }
86 
87  void draw(Vector2 offset);
88  void update();
89 };
90 }
91 }
92 #endif
Button * getEntry(unsigned int idx)
Definition: List.h:80
Implements a framework for string manipulation that operates directly on C strings.
Definition: NeoString.h:35
The Widget class contains all information that is common to all GUI widgets.
Definition: Widget.h:72
Definition: List.h:66
void show()
Definition: List.h:79
Implements a simple pushable button that calls the specified callback.
Definition: Button.h:67
int idx
Definition: List.h:68
List * list
Definition: List.h:69
int getSelectedEntry()
Definition: List.h:85
List(unsigned int x, unsigned int y, unsigned int width, unsigned int height, const char *label)
Definition: List.h:73
Definition: Vector2.h:31
String m_font
Definition: List.h:62
Definition: Button.h:42
Definition: List.h:56
Definition: Color.h:29
std::vector< Button * > m_entries
Definition: List.h:61
int m_selectedEntry
Definition: List.h:60
void setSelectedEntry(int idx)
Definition: List.h:84