00001 /* 00002 File : gadget_b.h 00003 Date : 19-Sep-02 00004 Description : Base class to represent a generic toolbox gadget. 00005 00006 Copyright © 1995-2002 Alexander Thoukydides 00007 00008 This program is free software; you can redistribute it and/or 00009 modify it under the terms of the GNU General Public License 00010 as published by the Free Software Foundation; either version 2 00011 of the License, or (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 00021 */ 00022 00023 // Only include header file once 00024 #ifndef gadget_b_h 00025 #define gadget_b_h 00026 00027 // Include cpplib header files 00028 #include "string.h" 00029 00030 // Include oslib header files 00031 #include "oslib/gadget.h" 00032 #include "oslib/macros.h" 00033 00034 // A class to represent a generic gadget 00035 class gadget_b 00036 { 00037 public: 00038 00039 /* 00040 Parameters : void 00041 Returns : - 00042 Description : Destructor function. 00043 */ 00044 virtual ~gadget_b(); 00045 00046 /* 00047 Parameters : flags - The new flag settings. 00048 Returns : void 00049 Description : Set the flags for this gadget. 00050 */ 00051 void set_flags(bits flags = 0); 00052 00053 /* 00054 Parameters : void 00055 Returns : gadget_flags - The flag settings for this gadget. 00056 Description : Return the flag word for this gadget. 00057 */ 00058 gadget_flags get_flags() const; 00059 00060 /* 00061 Parameters : faded - The new faded state. 00062 Returns : void 00063 Description : Set the faded state for this gadget. 00064 */ 00065 void set_faded(bool faded = TRUE); 00066 00067 /* 00068 Parameters : void 00069 Returns : bool - The faded state. 00070 Description : Get the faded state for this gadget. 00071 */ 00072 bool get_faded() const; 00073 00074 /* 00075 Parameters : back - The at back state. 00076 Returns : void 00077 Description : Set the at back state for this gadget. 00078 */ 00079 void set_at_back(bool back = TRUE); 00080 00081 /* 00082 Parameters : void 00083 Returns : bool - The at back state. 00084 Description : Get the at back state for this gadget. 00085 */ 00086 bool get_at_back() const; 00087 00088 /* 00089 Parameters : help - The help message text. 00090 Returns : void 00091 Description : Set the help message text for this gadget. 00092 */ 00093 void set_help_message(const char *help); 00094 00095 /* 00096 Parameters : help - The help message text. 00097 Returns : void 00098 Description : Set the help message text for this gadget. 00099 */ 00100 void set_help_message(const string &help); 00101 00102 /* 00103 Parameters : void 00104 Returns : size_t - The size of buffer required to hold the help 00105 message. 00106 Description : Get the size of buffer required to read the help message. 00107 */ 00108 size_t get_help_message_size() const; 00109 00110 /* 00111 Parameters : help - Pointer to buffer to hold the help text. 00112 size - The size of the buffer. 00113 Returns : size_t - Number of bytes written to the buffer. 00114 Description : Get the help message that is associated with this gadget. 00115 */ 00116 size_t get_help_message(char *help, size_t size) const; 00117 00118 /* 00119 Parameters : void 00120 Returns : string - The help message. 00121 Description : Get the help message that is associated with this gadget. 00122 */ 00123 string get_help_message() const; 00124 00125 /* 00126 Parameters : void 00127 Returns : int - The type of this gadget. 00128 Description : Get the type of this gadget. 00129 */ 00130 int get_type() const; 00131 00132 /* 00133 Parameters : bbox - The new bounding box for this gadget. 00134 Returns : void 00135 Description : Set the bounding box of this gadget. 00136 */ 00137 void set_bbox(const os_box &bbox); 00138 00139 /* 00140 Parameters : void 00141 Returns : os_box - The bounding box of this gadget. 00142 Description : Get the bounding box of this gadget. 00143 */ 00144 os_box get_bbox() const; 00145 00146 protected: 00147 00148 /* 00149 Parameters : void 00150 Returns : - 00151 Description : Protected constructor to prevent creation of abstract 00152 base class. 00153 */ 00154 gadget_b(); 00155 00156 /* 00157 Parameters : flags - The new flag settings. 00158 Returns : void 00159 Description : Representation specific function to set the flags for 00160 this gadget. 00161 */ 00162 virtual void _set_flags(bits flags); 00163 00164 /* 00165 Parameters : void 00166 Returns : gadget_flags - The flag settings for this gadget. 00167 Description : Representation specific function to get the flags for 00168 this gadget. 00169 */ 00170 virtual gadget_flags _get_flags() const; 00171 00172 /* 00173 Parameters : help - The help text. 00174 Returns : void 00175 Description : Representation specific function to set the help text. 00176 */ 00177 virtual void _set_help_message(const char *help); 00178 00179 /* 00180 Parameters : help - Pointer to buffer to hold the help text, or 00181 NULL to read the size of buffer required. 00182 size - The size of the buffer. 00183 Returns : size_t - Number of bytes written to the buffer, or 00184 the buffer size required if NULL passed. 00185 Description : Representation specific function to get the help text or 00186 the buffer size required. 00187 */ 00188 virtual size_t _get_help_message(char *help, size_t size) const; 00189 00190 /* 00191 Parameters : void 00192 Returns : int - The type of this gadget. 00193 Description : Representation specific function to get the type of this 00194 gadget. 00195 */ 00196 virtual int _get_type() const; 00197 00198 /* 00199 Parameters : bbox - The new bounding box for this gadget. 00200 Returns : void 00201 Description : Representation specific function to set the bounding box 00202 of this gadget. 00203 */ 00204 virtual void _set_bbox(const os_box &bbox); 00205 00206 /* 00207 Parameters : void 00208 Returns : os_box - The bounding box of this gadget. 00209 Description : Representation specific function to get the bounding box 00210 of this gadget. 00211 */ 00212 virtual os_box _get_bbox() const; 00213 }; 00214 00215 /* 00216 Parameters : void 00217 Returns : - 00218 Description : Destructor function. 00219 */ 00220 inline gadget_b::~gadget_b() {} 00221 00222 /* 00223 Parameters : flags - The new flag settings. 00224 Returns : void 00225 Description : Set the flags for this gadget. 00226 */ 00227 inline void gadget_b::set_flags(bits flags) 00228 { 00229 _set_flags(flags); 00230 } 00231 00232 /* 00233 Parameters : void 00234 Returns : gadget_flags - The flag settings for this gadget. 00235 Description : Return the flag word for this gadget. 00236 */ 00237 inline gadget_flags gadget_b::get_flags() const 00238 { 00239 return _get_flags(); 00240 } 00241 00242 /* 00243 Parameters : faded - The new faded state. 00244 Returns : void 00245 Description : Set the faded state for this gadget. 00246 */ 00247 inline void gadget_b::set_faded(bool faded) 00248 { 00249 gadget_flags flags = _get_flags(); 00250 _set_flags(faded ? flags | gadget_FADED : flags & ~gadget_FADED); 00251 } 00252 00253 /* 00254 Parameters : void 00255 Returns : bool - The faded state. 00256 Description : Get the faded state for this gadget. 00257 */ 00258 inline bool gadget_b::get_faded() const 00259 { 00260 return BOOL(_get_flags() & gadget_FADED); 00261 } 00262 00263 /* 00264 Parameters : back - The at back state. 00265 Returns : void 00266 Description : Set the at back state for this gadget. 00267 */ 00268 inline void gadget_b::set_at_back(bool back) 00269 { 00270 gadget_flags flags = _get_flags(); 00271 _set_flags(back ? flags | gadget_AT_BACK : flags & ~gadget_AT_BACK); 00272 } 00273 00274 /* 00275 Parameters : void 00276 Returns : bool - The at back state. 00277 Description : Get the at back state for this gadget. 00278 */ 00279 inline bool gadget_b::get_at_back() const 00280 { 00281 return BOOL(_get_flags() & gadget_AT_BACK); 00282 } 00283 00284 /* 00285 Parameters : help - The help message text. 00286 Returns : void 00287 Description : Set the help message text for this gadget. 00288 */ 00289 inline void gadget_b::set_help_message(const char *help) 00290 { 00291 _set_help_message(help); 00292 } 00293 00294 /* 00295 Parameters : help - The help message text. 00296 Returns : void 00297 Description : Set the help message text for this gadget. 00298 */ 00299 inline void gadget_b::set_help_message(const string &help) 00300 { 00301 _set_help_message(help.c_str()); 00302 } 00303 00304 /* 00305 Parameters : void 00306 Returns : size_t - The size of buffer required to hold the help 00307 message. 00308 Description : Get the size of buffer required to read the help message. 00309 */ 00310 inline size_t gadget_b::get_help_message_size() const 00311 { 00312 return _get_help_message(NULL, 0); 00313 } 00314 00315 /* 00316 Parameters : help - Pointer to buffer to hold the help text. 00317 size - The size of the buffer. 00318 Returns : size_t - Number of bytes written to the buffer. 00319 Description : Get the help message that is associated with this gadget. 00320 */ 00321 inline size_t gadget_b::get_help_message(char *help, size_t size) const 00322 { 00323 return _get_help_message(help, size); 00324 } 00325 00326 /* 00327 Parameters : void 00328 Returns : int - The type of this gadget. 00329 Description : Get the type of this gadget. 00330 */ 00331 inline int gadget_b::get_type() const 00332 { 00333 return _get_type(); 00334 } 00335 00336 /* 00337 Parameters : bbox - The new bounding box for this gadget. 00338 Returns : void 00339 Description : Set the bounding box of this gadget. 00340 */ 00341 inline void gadget_b::set_bbox(const os_box &bbox) 00342 { 00343 _set_bbox(bbox); 00344 } 00345 00346 /* 00347 Parameters : void 00348 Returns : os_box - The bounding box of this gadget. 00349 Description : Get the bounding box of this gadget. 00350 */ 00351 inline os_box gadget_b::get_bbox() const 00352 { 00353 return _get_bbox(); 00354 } 00355 00356 /* 00357 Parameters : void 00358 Returns : - 00359 Description : Protected constructor to prevent creation of abstract 00360 base class. 00361 */ 00362 inline gadget_b::gadget_b() {} 00363 00364 #endif
1.3.3