00001 /* 00002 File : gadget_c.h 00003 Date : 19-Sep-02 00004 Description : 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_c_h 00025 #define gadget_c_h 00026 00027 // Include cpplib header files 00028 #include "vector.h" 00029 00030 // Include alexlib header files 00031 #ifndef gadget_b_h 00032 #include "gadget_b.h" 00033 #endif 00034 00035 // A class to represent a generic gadget 00036 class gadget_c : public virtual gadget_b 00037 { 00038 public: 00039 00040 // IDs for this gadget 00041 toolbox_o object; 00042 toolbox_c component; 00043 00044 /* 00045 Parameters : component - The component ID of this gadget. 00046 object - The object ID of this gadget's parent window. 00047 Returns : - 00048 Description : Constructor function. This does not create a gadget; it 00049 merely creates an object to represent the gadget. 00050 */ 00051 gadget_c(toolbox_c component = toolbox_NULL_COMPONENT, 00052 toolbox_o object = toolbox_NULL_OBJECT); 00053 00054 /* 00055 Parameters : object - The object ID of this gadget's parent window. 00056 Returns : void 00057 Description : Set the object ID of this gadget's parent window. 00058 */ 00059 void set_object(toolbox_o object = toolbox_NULL_OBJECT); 00060 00061 /* 00062 Parameters : void 00063 Returns : toolbox_o - The object ID of this gadget's parent window. 00064 Description : Get the object ID of this gadget's parent window. 00065 */ 00066 toolbox_o get_object() const; 00067 00068 /* 00069 Parameters : component - The component ID of this gadget. 00070 Returns : void 00071 Description : Set the component ID of this gadget. 00072 */ 00073 void set_component(toolbox_c component = toolbox_NULL_COMPONENT); 00074 00075 /* 00076 Parameters : void 00077 Returns : toolbox_c - The component ID of this gadget. 00078 Description : Get the component ID of this gadget. 00079 */ 00080 toolbox_c get_component() const; 00081 00082 /* 00083 Parameters : void 00084 Returns : size_t - The size of buffer required to hold the icon 00085 list. 00086 Description : Get the size of buffer required to read the icon list. 00087 */ 00088 size_t get_icon_list_size() const; 00089 00090 /* 00091 Parameters : buffer - Pointer to buffer to hold the icon list. 00092 size - The size of the buffer. 00093 Returns : size_t - The number of bytes written to the buffer. 00094 Description : Get the list of Wimp icon numbers for the icons used to 00095 implement this gadget. 00096 */ 00097 size_t get_icon_list(wimp_i *buffer, size_t size) const; 00098 00099 /* 00100 Parameters : void 00101 Returns : vector<wimp_i> - The icon list. 00102 Description : Get the list of Wimp icon numbers for the icons used to 00103 implement this gadget. 00104 */ 00105 vector<wimp_i> get_icon_list() const; 00106 00107 /* 00108 Parameters : void 00109 Returns : void 00110 Description : Set the input focus to this gadget. 00111 */ 00112 void set_focus(); 00113 00114 protected: 00115 00116 /* 00117 Parameters : flags - The new flag settings. 00118 Returns : void 00119 Description : Representation specific function to set the flags for 00120 this gadget. 00121 */ 00122 virtual void _set_flags(bits flags); 00123 00124 /* 00125 Parameters : void 00126 Returns : gadget_flags - The flag settings for this gadget. 00127 Description : Representation specific function to get the flags for 00128 this gadget. 00129 */ 00130 virtual gadget_flags _get_flags() const; 00131 00132 /* 00133 Parameters : help - The help text. 00134 Returns : void 00135 Description : Representation specific function to set the help text. 00136 */ 00137 virtual void _set_help_message(const char *help); 00138 00139 /* 00140 Parameters : help - Pointer to buffer to hold the help text, or 00141 NULL to read the size of buffer required. 00142 size - The size of the buffer. 00143 Returns : size_t - Number of bytes written to the buffer, or 00144 the buffer size required if NULL passed. 00145 Description : Representation specific function to get the help text or 00146 the buffer size required. 00147 */ 00148 virtual size_t _get_help_message(char *help, size_t size) const; 00149 00150 /* 00151 Parameters : void 00152 Returns : int - The type of this gadget. 00153 Description : Representation specific function to get the type of this 00154 gadget. 00155 */ 00156 virtual int _get_type() const; 00157 00158 /* 00159 Parameters : bbox - The new bounding box for this gadget. 00160 Returns : void 00161 Description : Representation specific function to set the bounding box 00162 of this gadget. 00163 */ 00164 virtual void _set_bbox(const os_box &bbox); 00165 00166 /* 00167 Parameters : void 00168 Returns : os_box - The bounding box of this gadget. 00169 Description : Representation specific function to get the bounding box 00170 of this gadget. 00171 */ 00172 virtual os_box _get_bbox() const; 00173 }; 00174 00175 /* 00176 Parameters : component - The component ID of this gadget. 00177 object - The object ID of this gadget's parent window. 00178 Returns : - 00179 Description : Constructor function. This does not create a gadget; it 00180 merely creates an object to represent the gadget. 00181 */ 00182 inline gadget_c::gadget_c(toolbox_c component, toolbox_o object) 00183 { 00184 gadget_c::object = object; 00185 gadget_c::component = component; 00186 } 00187 00188 /* 00189 Parameters : object - The object ID of this gadget's parent window. 00190 Returns : void 00191 Description : Set the object ID of this gadget's parent window. 00192 */ 00193 inline void gadget_c::set_object(toolbox_o object) 00194 { 00195 gadget_c::object = object; 00196 } 00197 00198 /* 00199 Parameters : void 00200 Returns : toolbox_o - The object ID of this gadget's parent window. 00201 Description : Get the object ID of this gadget's parent window. 00202 */ 00203 inline toolbox_o gadget_c::get_object() const 00204 { 00205 return object; 00206 } 00207 00208 /* 00209 Parameters : component - The component ID of this gadget. 00210 Returns : void 00211 Description : Set the component ID of this gadget. 00212 */ 00213 inline void gadget_c::set_component(toolbox_c component) 00214 { 00215 gadget_c::component = component; 00216 } 00217 00218 /* 00219 Parameters : void 00220 Returns : toolbox_c - The component ID of this gadget. 00221 Description : Get the component ID of this gadget. 00222 */ 00223 inline toolbox_c gadget_c::get_component() const 00224 { 00225 return component; 00226 } 00227 00228 /* 00229 Parameters : void 00230 Returns : size_t - The size of buffer required to hold the icon 00231 list. 00232 Description : Get the size of buffer required to read the icon list. 00233 */ 00234 inline size_t gadget_c::get_icon_list_size() const 00235 { 00236 return gadget_get_icon_list(0, object, component, NULL, 0); 00237 } 00238 00239 /* 00240 Parameters : buffer - Pointer to buffer to hold the icon list. 00241 size - The size of the buffer. 00242 Returns : size_t - The number of bytes written to the buffer. 00243 Description : Get the list of Wimp icon numbers for the icons used to 00244 implement this gadget. 00245 */ 00246 inline size_t gadget_c::get_icon_list(wimp_i *buffer, size_t size) const 00247 { 00248 return gadget_get_icon_list(0, object, component, buffer, size); 00249 } 00250 00251 /* 00252 Parameters : void 00253 Returns : void 00254 Description : Set the input focus to this gadget. 00255 */ 00256 inline void gadget_c::set_focus() 00257 { 00258 gadget_set_focus(0, object, component); 00259 } 00260 00261 /* 00262 Parameters : flags - The new flag settings. 00263 Returns : void 00264 Description : Representation specific function to set the flags for 00265 this gadget. 00266 */ 00267 inline void gadget_c::_set_flags(bits flags) 00268 { 00269 gadget_set_flags(0, object, component, flags); 00270 } 00271 00272 /* 00273 Parameters : void 00274 Returns : gadget_flags - The flag settings for this gadget. 00275 Description : Representation specific function to get the flags for 00276 this gadget. 00277 */ 00278 inline gadget_flags gadget_c::_get_flags() const 00279 { 00280 return gadget_get_flags(0, object, component); 00281 } 00282 00283 /* 00284 Parameters : void 00285 Returns : int - The type of this gadget. 00286 Description : Representation specific function to get the type of this 00287 gadget. 00288 */ 00289 inline int gadget_c::_get_type() const 00290 { 00291 return gadget_get_type(0, object, component); 00292 } 00293 00294 #endif
1.3.3