_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

dropdown.h
Go to the documentation of this file.
1 /* _______ __ __ __ ______ __ __ _______ __ __
2  * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
3  * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
4  * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
5  * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
6  * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
7  * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
8  *
9  * Copyright (c) 2004, 2005 darkbits Js_./
10  * Per Larsson a.k.a finalman _RqZ{a<^_aa
11  * Olof Naess�n a.k.a jansem/yakslem _asww7!uY`> )\a//
12  * _Qhm`] _f "'c 1!5m
13  * Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[
14  * .)j(] .d_/ '-( P . S
15  * License: (BSD) <Td/Z <fP"5(\"??"\a. .L
16  * Redistribution and use in source and _dV>ws?a-?' ._/L #'
17  * binary forms, with or without )4d[#7r, . ' )d`)[
18  * modification, are permitted provided _Q-5'5W..j/?' -?!\)cam'
19  * that the following conditions are met: j<<WP+k/);. _W=j f
20  * 1. Redistributions of source code must .$%w\/]Q . ."' . mj$
21  * retain the above copyright notice, ]E.pYY(Q]>. a J@\
22  * this list of conditions and the j(]1u<sE"L,. . ./^ ]{a
23  * following disclaimer. 4'_uomm\. )L);-4 (3=
24  * 2. Redistributions in binary form must )_]X{Z('a_"a7'<a"a, ]"[
25  * reproduce the above copyright notice, #}<]m7`Za??4,P-"'7. ).m
26  * this list of conditions and the ]d2e)Q(<Q( ?94 b- LQ/
27  * following disclaimer in the <B!</]C)d_, '(<' .f. =C+m
28  * documentation and/or other materials .Z!=J ]e []('-4f _ ) -.)m]'
29  * provided with the distribution. .w[5]' _[ /.)_-"+? _/ <W"
30  * 3. Neither the name of Guichan nor the :$we` _! + _/ . j?
31  * names of its contributors may be used =3)= _f (_yQmWW$#( "
32  * to endorse or promote products derived - W, sQQQQmZQ#Wwa]..
33  * from this software without specific (js, \[QQW$QWW#?!V"".
34  * prior written permission. ]y:.<\.. .
35  * -]n w/ ' [.
36  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT )/ )/ !
37  * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY < (; sac , '
38  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, ]^ .- %
39  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF c < r
40  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR aga< <La
41  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 5% )P'-3L
42  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR _bQf` y`..)a
43  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ,J?4P'.P"_(\?d'.,
44  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES _Pa,)!f/<[]/ ?"
45  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT _2-..:. .r+_,.. .
46  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ?a.<%"' " -'.a_ _,
47  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ^
48  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
49  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
50  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
51  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
52  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53  */
54 
55 #ifndef GCN_DROPDOWN_HPP
56 #define GCN_DROPDOWN_HPP
57 
58 #include "guichan/basiccontainer.h"
59 #include "guichan/focushandler.h"
60 #include "guichan/keylistener.h"
61 #include "guichan/listmodel.h"
62 #include "guichan/mouselistener.h"
63 #include "guichan/platform.h"
66 
67 namespace gcn
68 {
79  public BasicContainer,
80  public MouseListener,
81  public KeyListener,
82  public ActionListener
83  {
84  public:
88  DropDown();
89 
96  DropDown(ListModel *listModel);
97 
106  DropDown(ListModel *listModel,
107  ScrollArea *scrollArea,
108  ListBox *listBox);
109 
113  virtual ~DropDown();
114 
120  virtual int getSelected();
121 
127  virtual void setSelected(int selected);
128 
134  virtual void setListModel(ListModel *listModel);
135 
141  virtual ListModel *getListModel();
142 
148  virtual void setScrollArea(ScrollArea* scrollArea);
149 
155  virtual ScrollArea *getScrollArea();
156 
162  virtual void setListBox(ListBox* listBox);
163 
169  virtual ListBox *getListBox();
170 
174  virtual void adjustHeight();
175 
176 
177  // Inherited from Widget
178 
179  virtual void draw(Graphics* graphics);
180 
181  virtual void drawBorder(Graphics* graphics);
182 
183  virtual bool _keyInputMessage(const KeyInput& keyInput);
184 
185  virtual void logic();
186 
187  virtual void _mouseInputMessage(const MouseInput &mouseInput);
188 
189  virtual void lostFocus();
190 
191  virtual void setBaseColor(const Color& color);
192 
193  virtual void setBackgroundColor(const Color& color);
194 
195  virtual void setForegroundColor(const Color& color);
196 
197 
198  // Inherited from BasicContainer
199 
200  virtual void moveToTop(Widget* widget);
201 
202  virtual void moveToBottom(Widget* widget);
203 
204  virtual void _announceDeath(Widget* widget);
205 
206  virtual void getDrawSize(int& width, int& height, Widget* widget);
207 
208 
209  // Inherited from ActionListener
210 
211  virtual void action(const std::string& eventId);
212 
213 
214  // Inherited from KeyListener
215 
216  virtual bool keyPress(const Key& key);
217 
218 
219  // Inherited from MouseListener
220 
221  virtual void mousePress(int x, int y, int button);
222 
223  virtual void mouseRelease(int x, int y, int button);
224 
225  virtual void setFont(Font *font);
226 
227  virtual bool getDirty() const;
228 
229  protected:
235  virtual void drawButton(Graphics *graphics);
236 
240  virtual void dropDown();
241 
245  virtual void foldUp();
246 
248  bool mPushed;
249  int mOldH;
255  };
256 }
257 
258 #endif // end GCN_DROPDOWN_HPP
gcn::KeyListener
Definition: keylistener.h:74
mouselistener.h
GCN_CORE_DECLSPEC
#define GCN_CORE_DECLSPEC
Definition: platform.h:59
gcn::Graphics
Definition: graphics.h:97
gcn::DropDown::mDefaultScrollArea
ScrollArea * mDefaultScrollArea
Definition: dropdown.h:252
gcn::DropDown::mDroppedDown
bool mDroppedDown
Definition: dropdown.h:247
keylistener.h
gcn::MouseListener
Definition: mouselistener.h:72
listmodel.h
gcn::ActionListener
Definition: actionlistener.h:71
gcn::DropDown
Definition: dropdown.h:78
gcn::FocusHandler
Definition: focushandler.h:80
gcn::KeyInput
Definition: keyinput.h:67
gcn::DropDown::mPushed
bool mPushed
Definition: dropdown.h:248
gcn::ListBox
Definition: listbox.h:72
gcn::DropDown::mFocusHandler
FocusHandler mFocusHandler
Definition: dropdown.h:254
gcn::BasicContainer
Definition: basiccontainer.h:73
gcn
Definition: cliprectangle.cpp:61
gcn::DropDown::mOldH
int mOldH
Definition: dropdown.h:249
listbox.h
focushandler.h
gcn::ListModel
Definition: listmodel.h:70
basiccontainer.h
platform.h
gcn::Color
Definition: color.h:65
gcn::Font
Definition: font.h:69
gcn::DropDown::mScrollArea
ScrollArea * mScrollArea
Definition: dropdown.h:250
gcn::DropDown::mDefaultListBox
ListBox * mDefaultListBox
Definition: dropdown.h:253
gcn::Key
Definition: key.h:67
scrollarea.h
gcn::DropDown::mListBox
ListBox * mListBox
Definition: dropdown.h:251
gcn::MouseInput
Definition: mouseinput.h:67
gcn::Widget
Definition: widget.h:93
gcn::ScrollArea
Definition: scrollarea.h:75
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.