Adonthell  0.4
win_base.h
Go to the documentation of this file.
1 /*
2  (C) Copyright 2000, 2001 Joel Vennin
3  Part of the Adonthell Project <http://adonthell.nongnu.org>
4 
5  Adonthell is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  Adonthell is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with Adonthell. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 
20 /**
21  * @file win_base.h
22  * @author Vennin Jo�l <jol@linuxgames.com>
23  *
24  * brief Declares the win_bases class.
25  *
26  *
27  */
28 
29 
30 #ifndef _WIN_BASE_H_
31 #define _WIN_BASE_H_
32 
33 #include "win_event.h"
34 #include "win_border.h"
35 #include "win_background.h"
36 #include "win_keys.h"
37 
38 class win_container;
39 class win_scroll;
40 class win_select;
41 class win_manager;
42 
43 /**
44  * Common properties for each win_base's object
45  *
46  * @bug It's currently impossible to render a windowed object
47  * anywhere else than the screen. Windows should be capable
48  * of being assigned a target parameter, which is a pointer
49  * to the surface they should be drawn.
50  */
51 class win_base: public win_event, public win_border, public drawing_area, public win_background
52 {
53  public:
54 
55  /**
56  * Default constructor:
57  * - not visible
58  * - x,y equals to 0
59  * - not focus
60  * - not activate
61  * - not brightness
62  * - not transluency
63  * - can be selected
64  * - alignement is ALIGN_NONE
65  */
66  win_base();
67 
68  /**
69  * Return the relative horizontal position of the win_*.
70  * @return horizontal position of the win_*.
71  */
72  s_int16 x() const
73  {return x_;}
74 
75 
76  /**
77  * Return the relative vertical position of the win_*.
78  * @return vertical position of the win_*.
79  */
80  s_int16 y() const
81  {return y_;}
82 
83 
84  /**
85  * Return the pad horizontal position of the win_*.
86  * @return the pad horizontal position of the win_*.
87  */
89  {return pad_x_;}
90 
91 
92  /**
93  * Return the pad vertical position of the win_*.
94  * @return the pad vertical position of the win_*.
95  */
97  {return pad_y_;}
98 
99 
100  /**
101  * Return the horizontal position of the win_*.
102  * @return the horizontal position of the win_*.
103  */
104  s_int16 real_x() const
105  {return drawing_area::x();}
106 
107 
108  /**
109  * Return the vertical position of the win_*.
110  * @return the vertical position of the win_*.
111  */
112  s_int16 real_y() const
113  {return drawing_area::y();}
114 
115 
116  /** Move the win_*.
117  * @param tx new horizontal position.
118  * @param ty new vertical position.
119  */
120  virtual void move(s_int16 tx,s_int16 ty);
121 
122 
123  /** Rezise the win_*.
124  * @param tl new horizontal position.
125  * @param th new vertical position.
126  */
127  virtual void resize(u_int16 tl, u_int16 th);
128 
129 
130  /** Test if win_* is visible
131  * @return true if visible else false
132  */
133  bool is_visible() const
134  {return visible_;}
135 
136 
137  /** Set the visible parameter
138  * @param b true if the win_* should be visible, false otherwise
139  */
140  void set_visible(const bool b)
141  {visible_=b;}
142 
143 
144  /** Test if win_* is activated
145  * @return true if activate else false
146  */
147  bool is_activate() const
148  {return activate_;}
149 
150 
151  /** Set the activate parameter
152  * When a win_* is setup on, the keys queue is cleared
153  *
154  * @param b true if the win_* should be visible, false otherwise
155  */
156  void set_activate(const bool b)
157  {if((activate_=b)) {on_activate();input::clear_keys_queue();}else on_unactivate();}
158 
159 
160  /** Test if win_* has focus on
161  * @return true if focus on else false
162  */
163  bool is_focus()const
164  {return focus_;}
165 
166 
167  /** Set the focus parameter
168  * @param b true if the win_* should be focus on, false otherwise
169  */
170  void set_focus(const bool b)
171  {focus_=b;}
172 
173 
174  /** Test if win_* has focus on
175  * @return true if focus on else false
176  */
177  bool is_trans() const
178  {return trans_;}
179 
180 
181  /** Set the transluency parameter
182  * @param b true if the win_* should be ins transluency, false otherwise
183  */
184  virtual void set_trans(const bool b)
185  {set_trans_border(trans_ = b);set_trans_background(b);}
186 
187 
188  /** Test if win_* is in brightness
189  * @return true if in brightness else false
190  */
191  bool is_brightness() const
192  {return brightness_;}
193 
194 
195  /** Set the transluency parameter
196  * @param b true if the win_* should be in transluency, false otherwise
197  */
198  virtual void set_brightness(const bool b)
199  {set_brightness_border(brightness_ = b);set_brightness_background(b);}
200 
201 
202  /** Set alignement of win_*
203  * @param a can be, ALIGN_NONE, ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT
204  */
205  void set_align(const u_int8 a)
206  {align_=a;update_align();}
207 
208 
209  /** Return alignment of win_*
210  * @return align_ parameter
211  */
212  u_int8 align() const {return align_;}
213 
214 
215  /** Test if win_* can be selected
216  * @return true if it can be selected, false otherwise
217  */
218  bool is_can_be_selected() const
219  {return can_be_selected_;}
220 
221 
222  /** Set the object to be selected
223  * A win_obj can be selectable or not when it is inside a win_select
224  * @param b true if the object can be selected inside a win_select., false otherwise
225  */
226  void set_can_be_selected(const bool b)
227  {can_be_selected_ = b;}
228 
229 
230  /** Update process
231  * @return true if update is successful, false otherwise
232  */
233  virtual bool update();
234 
235 
236  /** Draw process
237  * @return true if draw is successful, false otherwise
238  */
239  virtual bool draw();
240 
241 
242  /** Input Update process
243  * @
244  */
245  virtual bool input_update();
246 
247  virtual ~win_base();
248 
249  void set_manager (win_manager*);
250 
251  static const u_int8 ALIGN_NONE = 0;
252  static const u_int8 ALIGN_LEFT = 1;
253  static const u_int8 ALIGN_CENTER = 2;
254  static const u_int8 ALIGN_RIGHT = 3;
255 
256  protected:
257 
258  friend class win_container;
259 
260  friend class win_scroll;
261 
262  friend class win_select;
263 
264  virtual void update_position();
265 
266  void update_align();
267 
268  void set_container(win_container * wc);
269 
270 
271 
272  s_int16 x_;
273 
274  s_int16 y_;
275 
276  s_int16 pad_x_;
277 
278  s_int16 pad_y_;
279 
280  u_int8 align_;
281 
282  bool visible_;
283 
284  bool focus_;
285 
286  bool activate_;
287 
288  bool brightness_;
289 
290  bool trans_;
291 
292  bool can_be_selected_;
293 
294  win_container * wb_father_;
295 
296  win_manager * manager_;
297 };
298 
299 
300 
301 #endif
302 
303 
304 
305 
306 
307 
308 
309 
310 
311 
312 
313 
314 
315 
316 
win_base::set_activate
void set_activate(const bool b)
Set the activate parameter When a win_* is setup on, the keys queue is cleared.
Definition: win_base.h:156
win_base::draw
virtual bool draw()
Draw process.
Definition: win_base.cc:111
win_base
Common properties for each win_base's object.
Definition: win_base.h:51
win_base::set_visible
void set_visible(const bool b)
Set the visible parameter.
Definition: win_base.h:140
win_base::is_trans
bool is_trans() const
Test if win_* has focus on.
Definition: win_base.h:177
win_base::align
u_int8 align() const
Return alignment of win_*.
Definition: win_base.h:212
win_base::is_can_be_selected
bool is_can_be_selected() const
Test if win_* can be selected.
Definition: win_base.h:218
win_base::input_update
virtual bool input_update()
Input Update process .
Definition: win_base.cc:106
win_background
Definition: win_background.h:28
win_base::pad_x
s_int16 & pad_x()
Return the pad horizontal position of the win_*.
Definition: win_base.h:88
win_base::set_focus
void set_focus(const bool b)
Set the focus parameter.
Definition: win_base.h:170
win_select
Definition: win_select.h:24
win_base::update
virtual bool update()
Update process.
Definition: win_base.cc:94
win_scroll
Definition: win_scroll.h:25
u_int8
#define u_int8
8 bits long unsigned integer
Definition: types.h:35
win_base::is_activate
bool is_activate() const
Test if win_* is activated.
Definition: win_base.h:147
s_int16
#define s_int16
16 bits long signed integer
Definition: types.h:47
win_base::resize
virtual void resize(u_int16 tl, u_int16 th)
Rezise the win_*.
Definition: win_base.cc:85
win_base::is_visible
bool is_visible() const
Test if win_* is visible.
Definition: win_base.h:133
win_base::move
virtual void move(s_int16 tx, s_int16 ty)
Move the win_*.
Definition: win_base.cc:75
win_base::x
s_int16 x() const
Return the relative horizontal position of the win_*.
Definition: win_base.h:72
win_manager
The window manager takes care of basic GUI functions, such as input focus, window state updates and d...
Definition: win_manager.h:65
win_base::real_y
s_int16 real_y() const
Return the vertical position of the win_*.
Definition: win_base.h:112
win_base::set_trans
virtual void set_trans(const bool b)
Set the transluency parameter.
Definition: win_base.h:184
win_base::set_brightness
virtual void set_brightness(const bool b)
Set the transluency parameter.
Definition: win_base.h:198
win_base::set_can_be_selected
void set_can_be_selected(const bool b)
Set the object to be selected A win_obj can be selectable or not when it is inside a win_select.
Definition: win_base.h:226
win_base::win_base
win_base()
Default constructor:
Definition: win_base.cc:24
win_base::real_x
s_int16 real_x() const
Return the horizontal position of the win_*.
Definition: win_base.h:104
drawing_area::x
s_int16 x() const
Returns the horizontal position of the drawing_area.
Definition: drawing_area.h:77
drawing_area
Implements "drawing zones" for drawing operations.
Definition: drawing_area.h:54
win_base::set_align
void set_align(const u_int8 a)
Set alignement of win_*.
Definition: win_base.h:205
u_int16
#define u_int16
16 bits long unsigned integer
Definition: types.h:38
win_event
Definition: win_event.h:35
input::clear_keys_queue
static void clear_keys_queue()
Totally clears the key queue.
Definition: input.cc:168
win_base::is_brightness
bool is_brightness() const
Test if win_* is in brightness.
Definition: win_base.h:191
win_base::pad_y
s_int16 & pad_y()
Return the pad vertical position of the win_*.
Definition: win_base.h:96
drawing_area::y
s_int16 y() const
Returns the vertical position of the drawing_area.
Definition: drawing_area.h:85
win_base::y
s_int16 y() const
Return the relative vertical position of the win_*.
Definition: win_base.h:80
win_base::is_focus
bool is_focus() const
Test if win_* has focus on.
Definition: win_base.h:163
win_border
Definition: win_border.h:31
win_container
Definition: win_container.h:29