00001 /* 00002 File : optionbutton_b.h 00003 Date : 19-Sep-02 00004 Description : Base class to represent an option 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 optionbutton_b_h 00025 #define optionbutton_b_h 00026 00027 // Include oslib header files 00028 #include "oslib/optionbutton.h" 00029 00030 // Include alexlib header files 00031 #ifndef gadget_b_h 00032 #include "gadget_b.h" 00033 #endif 00034 #ifndef gadget_w_boolean_h 00035 #include "gadget_w_boolean.h" 00036 #endif 00037 #ifndef gadget_w_event_h 00038 #include "gadget_w_event.h" 00039 #endif 00040 #ifndef gadget_w_text_h 00041 #include "gadget_w_text.h" 00042 #endif 00043 00044 // Extra oslib style definitions for option buttons 00045 #define optionbutton_GENERATE_STATE_CHANGED ((gadget_flags) 0x1u) 00046 #define optionbutton_ON ((gadget_flags) 0x4u) 00047 00048 // A base class to represent an option button gadget 00049 class optionbutton_b : public virtual gadget_b, 00050 public gadget_w_boolean, 00051 public gadget_w_event, 00052 public gadget_w_text 00053 { 00054 public: 00055 00056 /* 00057 Parameters : generate - The generate event status. 00058 Returns : void 00059 Description : Set the OptionButton_StateChanged event status. 00060 */ 00061 void set_generate_state_changed(bool generate = TRUE); 00062 00063 /* 00064 Parameters : void 00065 Returns : bool - The generate event status. 00066 Description : Get the OptionButton_StateChanged event status. 00067 */ 00068 bool get_generate_state_changed() const; 00069 00070 /* 00071 Parameters : value - The value to set. 00072 Returns : optionbutton_b - This object. 00073 Description : Set the value of this gadget. To reduce flicker the value 00074 is not updated unless it has changed. 00075 */ 00076 optionbutton_b &operator=(bool value); 00077 }; 00078 00079 /* 00080 Parameters : generate - The generate event status. 00081 Returns : void 00082 Description : Set the OptionButton_StateChanged event status. 00083 */ 00084 inline void optionbutton_b::set_generate_state_changed(bool generate) 00085 { 00086 gadget_flags flags = _get_flags(); 00087 _set_flags(generate 00088 ? flags | optionbutton_GENERATE_STATE_CHANGED 00089 : flags & ~optionbutton_GENERATE_STATE_CHANGED); 00090 } 00091 00092 /* 00093 Parameters : void 00094 Returns : bool - The generate event status. 00095 Description : Get the OptionButton_StateChanged event status. 00096 */ 00097 inline bool optionbutton_b::get_generate_state_changed() const 00098 { 00099 return BOOL(_get_flags() & optionbutton_GENERATE_STATE_CHANGED); 00100 } 00101 00102 #endif
1.3.3