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