Adonthell 0.4
|
00001 /* 00002 $Id: win_base.h,v 1.26 2008/04/22 17:35:03 ksterker Exp $ 00003 00004 (C) Copyright 2000, 2001 Joel Vennin 00005 Part of the Adonthell Project http://adonthell.linuxgames.com 00006 00007 This program is free software; you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License. 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY. 00011 00012 See the COPYING file for more details 00013 */ 00014 00015 00016 /** 00017 * @file win_base.h 00018 * @author Vennin Joël <jol@linuxgames.com> 00019 * 00020 * brief Declares the win_bases class. 00021 * 00022 * 00023 */ 00024 00025 00026 #ifndef _WIN_BASE_H_ 00027 #define _WIN_BASE_H_ 00028 00029 #include "win_event.h" 00030 #include "win_border.h" 00031 #include "win_background.h" 00032 #include "win_keys.h" 00033 00034 class win_container; 00035 class win_scroll; 00036 class win_select; 00037 class win_manager; 00038 00039 /** 00040 * Common properties for each win_base's object 00041 * 00042 * @bug It's currently impossible to render a windowed object 00043 * anywhere else than the screen. Windows should be capable 00044 * of being assigned a target parameter, which is a pointer 00045 * to the surface they should be drawn. 00046 */ 00047 class win_base: public win_event, public win_border, public drawing_area, public win_background 00048 { 00049 public: 00050 00051 /** 00052 * Default constructor: 00053 * - not visible 00054 * - x,y equals to 0 00055 * - not focus 00056 * - not activate 00057 * - not brightness 00058 * - not transluency 00059 * - can be selected 00060 * - alignement is ALIGN_NONE 00061 */ 00062 win_base(); 00063 00064 /** 00065 * Return the relative horizontal position of the win_*. 00066 * @return horizontal position of the win_*. 00067 */ 00068 s_int16 x() const 00069 {return x_;} 00070 00071 00072 /** 00073 * Return the relative vertical position of the win_*. 00074 * @return vertical position of the win_*. 00075 */ 00076 s_int16 y() const 00077 {return y_;} 00078 00079 00080 /** 00081 * Return the pad horizontal position of the win_*. 00082 * @return the pad horizontal position of the win_*. 00083 */ 00084 s_int16 & pad_x() 00085 {return pad_x_;} 00086 00087 00088 /** 00089 * Return the pad vertical position of the win_*. 00090 * @return the pad vertical position of the win_*. 00091 */ 00092 s_int16 & pad_y() 00093 {return pad_y_;} 00094 00095 00096 /** 00097 * Return the horizontal position of the win_*. 00098 * @return the horizontal position of the win_*. 00099 */ 00100 s_int16 real_x() const 00101 {return drawing_area::x();} 00102 00103 00104 /** 00105 * Return the vertical position of the win_*. 00106 * @return the vertical position of the win_*. 00107 */ 00108 s_int16 real_y() const 00109 {return drawing_area::y();} 00110 00111 00112 /** Move the win_*. 00113 * @param tx new horizontal position. 00114 * @param ty new vertical position. 00115 */ 00116 virtual void move(s_int16 tx,s_int16 ty); 00117 00118 00119 /** Rezise the win_*. 00120 * @param tl new horizontal position. 00121 * @param th new vertical position. 00122 */ 00123 virtual void resize(u_int16 tl, u_int16 th); 00124 00125 00126 /** Test if win_* is visible 00127 * @return true if visible else false 00128 */ 00129 bool is_visible() const 00130 {return visible_;} 00131 00132 00133 /** Set the visible parameter 00134 * @param b true if the win_* should be visible, false otherwise 00135 */ 00136 void set_visible(const bool b) 00137 {visible_=b;} 00138 00139 00140 /** Test if win_* is activated 00141 * @return true if activate else false 00142 */ 00143 bool is_activate() const 00144 {return activate_;} 00145 00146 00147 /** Set the activate parameter 00148 * When a win_* is setup on, the keys queue is cleared 00149 * 00150 * @param b true if the win_* should be visible, false otherwise 00151 */ 00152 void set_activate(const bool b) 00153 {if((activate_=b)) {on_activate();input::clear_keys_queue();}else on_unactivate();} 00154 00155 00156 /** Test if win_* has focus on 00157 * @return true if focus on else false 00158 */ 00159 bool is_focus()const 00160 {return focus_;} 00161 00162 00163 /** Set the focus parameter 00164 * @param b true if the win_* should be focus on, false otherwise 00165 */ 00166 void set_focus(const bool b) 00167 {focus_=b;} 00168 00169 00170 /** Test if win_* has focus on 00171 * @return true if focus on else false 00172 */ 00173 bool is_trans() const 00174 {return trans_;} 00175 00176 00177 /** Set the transluency parameter 00178 * @param b true if the win_* should be ins transluency, false otherwise 00179 */ 00180 virtual void set_trans(const bool b) 00181 {set_trans_border(trans_ = b);set_trans_background(b);} 00182 00183 00184 /** Test if win_* is in brightness 00185 * @return true if in brightness else false 00186 */ 00187 bool is_brightness() const 00188 {return brightness_;} 00189 00190 00191 /** Set the transluency parameter 00192 * @param b true if the win_* should be in transluency, false otherwise 00193 */ 00194 virtual void set_brightness(const bool b) 00195 {set_brightness_border(brightness_ = b);set_brightness_background(b);} 00196 00197 00198 /** Set alignement of win_* 00199 * @param a can be, ALIGN_NONE, ALIGN_LEFT, ALIGN_CENTER, ALIGN_RIGHT 00200 */ 00201 void set_align(const u_int8 a) 00202 {align_=a;update_align();} 00203 00204 00205 /** Return alignment of win_* 00206 * @return align_ parameter 00207 */ 00208 u_int8 align() const {return align_;} 00209 00210 00211 /** Test if win_* can be selected 00212 * @return true if it can be selected, false otherwise 00213 */ 00214 bool is_can_be_selected() const 00215 {return can_be_selected_;} 00216 00217 00218 /** Set the object to be selected 00219 * A win_obj can be selectable or not when it is inside a win_select 00220 * @param b true if the object can be selected inside a win_select., false otherwise 00221 */ 00222 void set_can_be_selected(const bool b) 00223 {can_be_selected_ = b;} 00224 00225 00226 /** Update process 00227 * @return true if update is successful, false otherwise 00228 */ 00229 virtual bool update(); 00230 00231 00232 /** Draw process 00233 * @return true if draw is successful, false otherwise 00234 */ 00235 virtual bool draw(); 00236 00237 00238 /** Input Update process 00239 * @ 00240 */ 00241 virtual bool input_update(); 00242 00243 virtual ~win_base(); 00244 00245 void set_manager (win_manager*); 00246 00247 static const u_int8 ALIGN_NONE = 0; 00248 static const u_int8 ALIGN_LEFT = 1; 00249 static const u_int8 ALIGN_CENTER = 2; 00250 static const u_int8 ALIGN_RIGHT = 3; 00251 00252 protected: 00253 00254 friend class win_container; 00255 00256 friend class win_scroll; 00257 00258 friend class win_select; 00259 00260 virtual void update_position(); 00261 00262 void update_align(); 00263 00264 void set_container(win_container * wc); 00265 00266 00267 00268 s_int16 x_; 00269 00270 s_int16 y_; 00271 00272 s_int16 pad_x_; 00273 00274 s_int16 pad_y_; 00275 00276 u_int8 align_; 00277 00278 bool visible_; 00279 00280 bool focus_; 00281 00282 bool activate_; 00283 00284 bool brightness_; 00285 00286 bool trans_; 00287 00288 bool can_be_selected_; 00289 00290 win_container * wb_father_; 00291 00292 win_manager * manager_; 00293 }; 00294 00295 00296 00297 #endif 00298 00299 00300 00301 00302 00303 00304 00305 00306 00307 00308 00309 00310 00311 00312