Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members

button_b.h

Go to the documentation of this file.
00001 /*
00002     File        : button_b.h
00003     Date        : 19-Sep-02
00004     Description : Base class to represent a button 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 button_b_h
00025 #define button_b_h
00026 
00027 // Include oslib header files
00028 #include "oslib/button.h"
00029 #include "oslib/wimp.h"
00030 
00031 // Include alexlib header files
00032 #ifndef gadget_b_h
00033 #include "gadget_b.h"
00034 #endif
00035 #ifndef gadget_w_string_h
00036 #include "gadget_w_string.h"
00037 #endif
00038 
00039 // A base class to represent a button gadget
00040 class button_b : public virtual gadget_b,
00041                  public gadget_w_string
00042 {
00043 public:
00044 
00045     /*
00046         Parameters  : task  - Should the task's sprite area be used instead
00047                               of the Wimp sprite pool.
00048         Returns     : void
00049         Description : Set the task sprite area status for this button.
00050     */
00051     void set_task_sprite_area(bool task = TRUE);
00052 
00053     /*
00054         Parameters  : void
00055         Returns     : bool  - The task sprite area status.
00056         Description : Get the task sprite area status for this button.
00057     */
00058     bool get_task_sprite_area() const;
00059 
00060     /*
00061         Parameters  : menu  - The return menu clicks status.
00062         Returns     : void
00063         Description : Set the return menu clicks status for this button.
00064     */
00065     void set_allow_menu_clicks(bool menu = TRUE);
00066 
00067     /*
00068         Parameters  : void
00069         Returns     : bool  - The return menu clicks status.
00070         Description : Get the return menu clicks status for this button.
00071     */
00072     bool get_allow_menu_clicks() const;
00073 
00074     /*
00075         Parameters  : clear - Icon flags to clear.
00076                       eor   - Icon flags to toggle.
00077         Returns     : void
00078         Description : Set the icon flags for this button.
00079     */
00080     void set_icon_flags(wimp_icon_flags clear, wimp_icon_flags eor);
00081 
00082     /*
00083         Parameters  : void
00084         Returns     : wimp_icon_flags   - The current icon flags.
00085         Description : Get the icon flags for this button.
00086     */
00087     wimp_icon_flags get_icon_flags() const;
00088 
00089     /*
00090         Parameters  : validation    - The validation string.
00091         Returns     : void
00092         Description : Set the validation string for this button.
00093     */
00094     void set_validation(const char *validation);
00095 
00096     /*
00097         Parameters  : validation    - The validation string.
00098         Returns     : void
00099         Description : Set the validation string for this button.
00100     */
00101     void set_validation(const string &validation);
00102 
00103     /*
00104         Parameters  : void
00105         Returns     : size_t    - The size of buffer required to hold the
00106                                   validation string.
00107         Description : Get the size of buffer required to read the validation
00108                       string.
00109     */
00110     size_t get_validation_size() const;
00111 
00112     /*
00113         Parameters  : validation    - Pointer to buffer to hold the validation
00114                                       string.
00115                       size          - The size of the buffer.
00116         Returns     : size_t        - Number of bytes written to the buffer.
00117         Description : Get the validation string for this gadget.
00118     */
00119     size_t get_validation(char *validation, size_t size) const;
00120 
00121     /*
00122         Parameters  : void
00123         Returns     : string    - The validation string.
00124         Description : Get the validation string for this gadget.
00125     */
00126     string get_validation() const;
00127 
00128     /*
00129         Parameters  : value     - The text string to set.
00130         Returns     : button_b  - This object.
00131         Description : Set the value of this gadget. To reduce flicker the value
00132                       is not updated unless it has changed.
00133     */
00134     button_b &operator=(const char *value);
00135 
00136     /*
00137         Parameters  : value     - The text string to set.
00138         Returns     : button_b  - This object.
00139         Description : Set the value of this gadget. To reduce flicker the value
00140                       is not updated unless it has changed.
00141     */
00142     button_b &operator=(const string &value);
00143 
00144 protected:
00145 
00146     /*
00147         Parameters  : clear - Icon flags to clear.
00148                       eor   - Icon flags to toggle.
00149         Returns     : void
00150         Description : Representation specific function to set the icon flags
00151                       for this button.
00152     */
00153     virtual void _set_icon_flags(wimp_icon_flags clear,
00154                                  wimp_icon_flags eor) = 0;
00155 
00156     /*
00157         Parameters  : void
00158         Returns     : wimp_icon_flags   - The current icon flags.
00159         Description : Representation specific function to get the icon flags
00160                       for this button.
00161     */
00162     virtual wimp_icon_flags _get_icon_flags() const = 0;
00163 
00164     /*
00165         Parameters  : validation    - The text string to set.
00166         Returns     : void
00167         Description : Representation specific function to set the validation
00168                       string.
00169     */
00170     virtual void _set_validation(const char *validation) = 0;
00171 
00172     /*
00173         Parameters  : validation    - Pointer to buffer to hold the validation
00174                                       string, or NULL to read the size of
00175                                       buffer required.
00176                       size          - The size of the buffer.
00177         Returns     : size_t        - Number of bytes written to the buffer, or
00178                                       the buffer size required if NULL passed.
00179         Description : Representation specific function to get the validation
00180                       string or the buffer size required.
00181     */
00182     virtual size_t _get_validation(char *validation, size_t size) const = 0;
00183 };
00184 
00185 /*
00186     Parameters  : task  - Should the task's sprite area be used instead
00187                           of the Wimp sprite pool.
00188     Returns     : void
00189     Description : Set the task sprite area status for this button.
00190 */
00191 inline void button_b::set_task_sprite_area(bool task)
00192 {
00193     gadget_flags flags = _get_flags();
00194     _set_flags(task
00195                ? flags | button_TASK_SPRITE_AREA
00196                : flags & ~button_TASK_SPRITE_AREA);
00197 }
00198 
00199 /*
00200     Parameters  : void
00201     Returns     : bool  - The task sprite area status.
00202     Description : Get the task sprite area status for this button.
00203 */
00204 inline bool button_b::get_task_sprite_area() const
00205 {
00206     return BOOL(_get_flags() & button_TASK_SPRITE_AREA);
00207 }
00208 
00209 /*
00210     Parameters  : menu  - The return menu clicks status.
00211     Returns     : void
00212     Description : Set the return menu clicks status for this button.
00213 */
00214 inline void button_b::set_allow_menu_clicks(bool menu)
00215 {
00216     gadget_flags flags = _get_flags();
00217     _set_flags(menu
00218                ? flags | button_ALLOW_MENU_CLICKS
00219                : flags & ~button_ALLOW_MENU_CLICKS);
00220 }
00221 
00222 /*
00223     Parameters  : void
00224     Returns     : bool  - The return menu clicks status.
00225     Description : Get the return menu clicks status for this button.
00226 */
00227 inline bool button_b::get_allow_menu_clicks() const
00228 {
00229     return BOOL(_get_flags() & button_ALLOW_MENU_CLICKS);
00230 }
00231 
00232 /*
00233     Parameters  : clear - Icon flags to clear.
00234                   eor   - Icon flags to toggle.
00235     Returns     : void
00236     Description : Set the icon flags for this button.
00237 */
00238 inline void button_b::set_icon_flags(wimp_icon_flags clear,
00239                                         wimp_icon_flags eor)
00240 {
00241     _set_icon_flags(clear, eor);
00242 }
00243 
00244 /*
00245     Parameters  : void
00246     Returns     : wimp_icon_flags   - The current icon flags.
00247     Description : Get the icon flags for this button.
00248 */
00249 inline wimp_icon_flags button_b::get_icon_flags() const
00250 {
00251     return _get_icon_flags();
00252 }
00253 
00254 /*
00255     Parameters  : validation    - The validation string.
00256     Returns     : void
00257     Description : Set the validation string for this button.
00258 */
00259 inline void button_b::set_validation(const char *validation)
00260 {
00261     _set_validation(validation);
00262 }
00263 
00264 /*
00265     Parameters  : validation    - The validation string.
00266     Returns     : void
00267     Description : Set the validation string for this button.
00268 */
00269 inline void button_b::set_validation(const string &validation)
00270 {
00271     _set_validation(validation.c_str());
00272 }
00273 
00274 /*
00275     Parameters  : void
00276     Returns     : size_t    - The size of buffer required to hold the
00277                               validation string.
00278     Description : Get the size of buffer required to read the validation
00279                   string.
00280 */
00281 inline size_t button_b::get_validation_size() const
00282 {
00283     return _get_validation(NULL, 0);
00284 }
00285 
00286 /*
00287     Parameters  : validation    - Pointer to buffer to hold the validation
00288                                   string.
00289                   size          - The size of the buffer.
00290     Returns     : size_t        - Number of bytes written to the buffer.
00291     Description : Get the validation string for this gadget.
00292 */
00293 inline size_t button_b::get_validation(char *validation, size_t size) const
00294 {
00295     return _get_validation(validation, size);
00296 }
00297 
00298 #endif

Generated on Sun Jan 26 10:18:43 2025 for NBLib by doxygen 1.3.3