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