1 ////////////////////////////////////////////////////////////////////////////////
2 // Scorched3D (c) 2000-2009
4 // This file is part of Scorched3D.
6 // Scorched3D is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // Scorched3D 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 General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with Scorched3D; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ////////////////////////////////////////////////////////////////////////////////
21 #if !defined(__INCLUDE_GLWSelectorh_INCLUDE__)
22 #define __INCLUDE_GLWSelectorh_INCLUDE__
24 #include <GLW/GLWWindow.h>
25 #include <GLW/GLWToolTip.h>
26 #include <GLEXT/GLTexture.h>
27 #include <lang/LangString.h>
33 Defines the contents of one row of the selection dialog.
35 class GLWSelectorEntry
38 GLWSelectorEntry(const LangString
&text
= LangString(),
40 bool selected
= false,
43 const std::string
&dataText
= "");
45 LangString
&getText() { return text_
; }
46 const char *getDataText() { return dataText_
.c_str(); }
47 ToolTip
*getToolTip() { return tip_
; }
48 GLTexture
*getIcon() { return icon_
; }
49 bool getSelected() { return selected_
; }
50 bool getSeperator() { return seperator_
; }
51 void setSeperator() { seperator_
= true; }
52 void *getUserData() { return userData_
; }
53 Vector
&getColor() { return color_
; }
54 int &getTextureWidth() { return textureWidth_
; }
56 std::list
<GLWSelectorEntry
> &getPopups() { return popups_
; }
60 std::string dataText_
;
65 bool selected_
, seperator_
;
67 std::list
<GLWSelectorEntry
> popups_
;
71 The user interested in the chosen selection.
76 virtual void itemSelected(GLWSelectorEntry
*entry
, int position
) = 0;
77 virtual void noItemSelected() { };
81 A class that presents the user with an on screen menu and
82 allows them to select one item.
83 This class is used by other classes that throw up a selection
86 class GLWSelectorPart
;
87 class GLWSelector
: public GLWWindow
90 static GLWSelector
*instance();
92 // Show the selector as the specified position
96 std::list
<GLWSelectorEntry
> &entries
,
97 unsigned int showState
= 0,
98 bool transparent
= true);
102 // Add/remove a popup
103 GLWSelectorI
*getUser() { return user_
; }
104 void addPart(GLWSelectorPart
*part
);
105 void rmPart(GLWSelectorPart
*part
);
107 // Inherited from GLWWindow
109 virtual void mouseDown(int button
, float x
, float y
, bool &skipRest
);
110 virtual void mouseUp(int button
, float x
, float y
, bool &skipRest
);
111 virtual void mouseDrag(int button
, float mx
, float my
, float x
, float y
, bool &skipRest
);
112 virtual void keyDown(char *buffer
, unsigned int keyState
,
113 KeyboardHistory::HistoryElement
*history
, int hisCount
,
117 static GLWSelector
*instance_
;
118 std::list
<GLWSelectorPart
*> parts_
;
119 unsigned int showState_
;
124 virtual ~GLWSelector();