00001 /* 00002 File : writablefield_b.h 00003 Date : 19-Sep-02 00004 Description : Base class to represent a writable field 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 writablefield_b_h 00025 #define writablefield_b_h 00026 00027 // Include oslib header files 00028 #include "oslib/writablefield.h" 00029 00030 // Include alexlib header files 00031 #ifndef gadget_b_h 00032 #include "gadget_b.h" 00033 #endif 00034 #ifndef gadget_w_allowable_h 00035 #include "gadget_w_allowable.h" 00036 #endif 00037 #ifndef gadget_w_justification_h 00038 #include "gadget_w_justification.h" 00039 #endif 00040 #ifndef gadget_w_string_h 00041 #include "gadget_w_string.h" 00042 #endif 00043 00044 // A base class to represent a writable field gadget 00045 class writablefield_b : public virtual gadget_b, 00046 public gadget_w_allowable, 00047 public gadget_w_justification, 00048 public gadget_w_string 00049 { 00050 public: 00051 00052 /* 00053 Parameters : generate - The generate event status. 00054 Returns : void 00055 Description : Set the WritableField_ValueChanged event status. 00056 */ 00057 void set_generate_value_changed(bool generate = TRUE); 00058 00059 /* 00060 Parameters : void 00061 Returns : bool - The generate event status. 00062 Description : Get the WritableField_ValueChanged event status. 00063 */ 00064 bool get_generate_value_changed() const; 00065 00066 /* 00067 Parameters : conceal - The conceal text status. 00068 Returns : void 00069 Description : Set the conceal text status for this writable field. 00070 */ 00071 void set_conceal_text(bool conceal = TRUE); 00072 00073 /* 00074 Parameters : void 00075 Returns : bool - The conceal text status. 00076 Description : Get the conceal text status for this writable field. 00077 */ 00078 bool get_conceal_text() const; 00079 00080 /* 00081 Parameters : value - The text string to set. 00082 Returns : writablefield_b - This object. 00083 Description : Set the value of this gadget. To reduce flicker the value 00084 is not updated unless it has changed. 00085 */ 00086 writablefield_b &operator=(const char *value); 00087 00088 /* 00089 Parameters : value - The text string to set. 00090 Returns : writablefield_b - 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 writablefield_b &operator=(const string &value); 00095 00096 protected: 00097 00098 /* 00099 Parameters : position - The field justification. 00100 Returns : void 00101 Description : Gadget specific function to set the justification. 00102 */ 00103 virtual void _set_justification(justification position); 00104 00105 /* 00106 Parameters : void 00107 Returns : bool - The field justification. 00108 Description : Gadget specific function to Get the justification. 00109 */ 00110 virtual justification _get_justification() const; 00111 }; 00112 00113 /* 00114 Parameters : generate - The generate event status. 00115 Returns : void 00116 Description : Set the WritableField_ValueChanged event status. 00117 */ 00118 inline void writablefield_b::set_generate_value_changed(bool generate) 00119 { 00120 gadget_flags flags = _get_flags(); 00121 _set_flags(generate 00122 ? flags | writablefield_GENERATE_USER_VALUE_CHANGED 00123 : flags & ~writablefield_GENERATE_USER_VALUE_CHANGED); 00124 } 00125 00126 /* 00127 Parameters : void 00128 Returns : bool - The generate event status. 00129 Description : Get the WritableField_ValueChanged event status. 00130 */ 00131 inline bool writablefield_b::get_generate_value_changed() const 00132 { 00133 return BOOL(_get_flags() & writablefield_GENERATE_USER_VALUE_CHANGED); 00134 } 00135 00136 /* 00137 Parameters : conceal - The conceal text status. 00138 Returns : void 00139 Description : Set the conceal text status for this writable field. 00140 */ 00141 inline void writablefield_b::set_conceal_text(bool conceal) 00142 { 00143 gadget_flags flags = _get_flags(); 00144 _set_flags(conceal 00145 ? flags | writablefield_CONCEAL_TEXT 00146 : flags & ~writablefield_CONCEAL_TEXT); 00147 } 00148 00149 /* 00150 Parameters : void 00151 Returns : bool - The conceal text status. 00152 Description : Get the conceal text status for this writable field. 00153 */ 00154 inline bool writablefield_b::get_conceal_text() const 00155 { 00156 return BOOL(_get_flags() & writablefield_CONCEAL_TEXT); 00157 } 00158 00159 #endif
1.3.3