00001 /* 00002 File : gadget_w_boolean.h 00003 Date : 19-Sep-02 00004 Description : Class to represent a toolbox gadget that has a boolean value. 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_w_boolean_h 00025 #define gadget_w_boolean_h 00026 00027 // Include oslib header files 00028 #include "oslib/macros.h" 00029 #include "oslib/types.h" 00030 00031 // A class to represent a gadget with a boolean value 00032 class gadget_w_boolean 00033 { 00034 public: 00035 00036 /* 00037 Parameters : value - The value to set. 00038 Returns : void 00039 Description : Set the value of this gadget. 00040 */ 00041 void set_value(bool value); 00042 00043 /* 00044 Parameters : value - The value to set. 00045 Returns : gadget_w_boolean - This object. 00046 Description : Set the value of this gadget. To reduce flicker the value 00047 is not updated unless it has changed. 00048 */ 00049 gadget_w_boolean &operator=(bool value); 00050 00051 /* 00052 Parameters : void 00053 Returns : bool - The value 00054 Description : Get the value of this gadget. 00055 */ 00056 bool get_value() const; 00057 00058 /* 00059 Parameters : void 00060 Returns : int - The value. 00061 Description : Get the value of this gadget. 00062 */ 00063 bool operator()() const; 00064 00065 protected: 00066 00067 /* 00068 Parameters : value - The value to set. 00069 Returns : void 00070 Description : Gadget specific function to set the value. 00071 */ 00072 virtual void _set_value(bool value) = 0; 00073 00074 /* 00075 Parameters : void 00076 Returns : bool - The value 00077 Description : Gadget specific function to get the value. 00078 */ 00079 virtual bool _get_value() const = 0; 00080 }; 00081 00082 /* 00083 Parameters : value - The value to set. 00084 Returns : void 00085 Description : Set the value of this gadget. 00086 */ 00087 inline void gadget_w_boolean::set_value(bool value) 00088 { 00089 _set_value(BOOL(value)); 00090 } 00091 00092 /* 00093 Parameters : value - The value to set. 00094 Returns : gadget_w_boolean - This object. 00095 Description : Set the value of this gadget. To reduce flicker the value 00096 is not updated unless it has changed. 00097 */ 00098 inline gadget_w_boolean &gadget_w_boolean::operator=(bool value) 00099 { 00100 value = BOOL(value); 00101 if (value != _get_value()) _set_value(value); 00102 return *this; 00103 } 00104 00105 /* 00106 Parameters : void 00107 Returns : bool - The value 00108 Description : Get the value of this gadget. 00109 */ 00110 inline bool gadget_w_boolean::get_value() const 00111 { 00112 return _get_value(); 00113 } 00114 00115 /* 00116 Parameters : void 00117 Returns : bool - The value. 00118 Description : Get the value of this gadget. 00119 */ 00120 inline bool gadget_w_boolean::operator()() const 00121 { 00122 return _get_value(); 00123 } 00124 00125 #endif
1.3.3