GUISAN
checkbox.hpp
1 /* _______ __ __ __ ______ __ __ _______ __ __
2  * / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
3  * / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
4  * / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
5  * / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
6  * /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
7  * \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
8  *
9  * Copyright (c) 2004, 2005, 2006, 2007 Olof Naessén and Per Larsson
10  *
11  * Js_./
12  * Per Larsson a.k.a finalman _RqZ{a<^_aa
13  * Olof Naessén a.k.a jansem/yakslem _asww7!uY`> )\a//
14  * _Qhm`] _f "'c 1!5m
15  * Visit: http://guichan.darkbits.org )Qk<P ` _: :+' .' "{[
16  * .)j(] .d_/ '-( P . S
17  * License: (BSD) <Td/Z <fP"5(\"??"\a. .L
18  * Redistribution and use in source and _dV>ws?a-?' ._/L #'
19  * binary forms, with or without )4d[#7r, . ' )d`)[
20  * modification, are permitted provided _Q-5'5W..j/?' -?!\)cam'
21  * that the following conditions are met: j<<WP+k/);. _W=j f
22  * 1. Redistributions of source code must .$%w\/]Q . ."' . mj$
23  * retain the above copyright notice, ]E.pYY(Q]>. a J@\
24  * this list of conditions and the j(]1u<sE"L,. . ./^ ]{a
25  * following disclaimer. 4'_uomm\. )L);-4 (3=
26  * 2. Redistributions in binary form must )_]X{Z('a_"a7'<a"a, ]"[
27  * reproduce the above copyright notice, #}<]m7`Za??4,P-"'7. ).m
28  * this list of conditions and the ]d2e)Q(<Q( ?94 b- LQ/
29  * following disclaimer in the <B!</]C)d_, '(<' .f. =C+m
30  * documentation and/or other materials .Z!=J ]e []('-4f _ ) -.)m]'
31  * provided with the distribution. .w[5]' _[ /.)_-"+? _/ <W"
32  * 3. Neither the name of Guichan nor the :$we` _! + _/ . j?
33  * names of its contributors may be used =3)= _f (_yQmWW$#( "
34  * to endorse or promote products derived - W, sQQQQmZQ#Wwa]..
35  * from this software without specific (js, \[QQW$QWW#?!V"".
36  * prior written permission. ]y:.<\.. .
37  * -]n w/ ' [.
38  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT )/ )/ !
39  * HOLDERS AND CONTRIBUTORS "AS IS" AND ANY < (; sac , '
40  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, ]^ .- %
41  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF c < r
42  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR aga< <La
43  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 5% )P'-3L
44  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR _bQf` y`..)a
45  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, ,J?4P'.P"_(\?d'.,
46  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES _Pa,)!f/<[]/ ?"
47  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT _2-..:. .r+_,.. .
48  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, ?a.<%"' " -'.a_ _,
49  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ^
50  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
51  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
52  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
53  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
54  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
55  */
56 
57 #ifndef GCN_CHECKBOX_HPP
58 #define GCN_CHECKBOX_HPP
59 
60 #include <string>
61 
62 #include "guisan/keylistener.hpp"
63 #include "guisan/mouselistener.hpp"
64 #include "guisan/platform.hpp"
65 #include "guisan/widget.hpp"
66 
67 namespace gcn
68 {
77  class GCN_CORE_DECLSPEC CheckBox :
78  public Widget,
79  public MouseListener,
80  public KeyListener
81  {
82  public:
83 
87  CheckBox();
88 
96  CheckBox(const std::string &caption, bool selected = false);
97 
101  virtual ~CheckBox() { }
102 
109  bool isSelected() const;
110 
117  void setSelected(bool selected);
118 
125  const std::string &getCaption() const;
126 
135  void setCaption(const std::string& caption);
136 
140  void adjustSize();
141 
142 
143  // Inherited from Widget
144 
145  virtual void draw(Graphics* graphics);
146 
147  virtual void drawBorder(Graphics* graphics);
148 
149 
150  // Inherited from KeyListener
151 
152  virtual void keyPressed(KeyEvent& keyEvent);
153 
154 
155  // Inherited from MouseListener
156 
157  virtual void mouseClicked(MouseEvent& mouseEvent);
158 
159  virtual void mouseDragged(MouseEvent& mouseEvent);
160 
161 
162  protected:
168  virtual void drawBox(Graphics *graphics);
169 
174  virtual void toggleSelected();
175 
179  bool mSelected;
180 
184  std::string mCaption;
185  };
186 }
187 
188 #endif // end GCN_CHECKBOX_HPP
Definition: keylistener.hpp:76
virtual ~CheckBox()
Definition: checkbox.hpp:101
Definition: graphics.hpp:100
Definition: widget.hpp:93
Definition: keyevent.hpp:71
std::string mCaption
Definition: checkbox.hpp:184
Definition: actionevent.hpp:65
Definition: checkbox.hpp:77
bool mSelected
Definition: checkbox.hpp:179
Definition: mouselistener.hpp:73
Definition: mouseevent.hpp:74