00001 /* 00002 File : writablefield_c.h 00003 Date : 19-Sep-02 00004 Description : 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_c_h 00025 #define writablefield_c_h 00026 00027 // Include alexlib header files 00028 #ifndef gadget_c_h 00029 #include "gadget_c.h" 00030 #endif 00031 #ifndef gadget_w_font_h 00032 #include "gadget_w_font.h" 00033 #endif 00034 #ifndef writablefield_b_h 00035 #include "writablefield_b.h" 00036 #endif 00037 00038 // A class to represent a writable field gadget 00039 class writablefield_c : public virtual gadget_b, 00040 public gadget_c, 00041 public writablefield_b, 00042 public gadget_w_font 00043 { 00044 public: 00045 00046 /* 00047 Parameters : component - The component ID of this writable field. 00048 object - The object ID of this writable field's parent 00049 window. 00050 Returns : - 00051 Description : Constructor function. This does not create a 00052 writable field; it merely creates an object to represent 00053 the writable field. 00054 */ 00055 writablefield_c(toolbox_c component = toolbox_NULL_COMPONENT, 00056 toolbox_o object = toolbox_NULL_OBJECT); 00057 00058 /* 00059 Parameters : value - The text string to set. 00060 Returns : writablefield_c - This object. 00061 Description : Set the value of this gadget. To reduce flicker the value 00062 is not updated unless it has changed. 00063 */ 00064 writablefield_c &operator=(const char *value); 00065 00066 /* 00067 Parameters : value - The text string to set. 00068 Returns : writablefield_c - This object. 00069 Description : Set the value of this gadget. To reduce flicker the value 00070 is not updated unless it has changed. 00071 */ 00072 writablefield_c &operator=(const string &value); 00073 00074 protected: 00075 00076 /* 00077 Parameters : allowed - The new set of allowable characters, or NULL 00078 to allow all characters. 00079 Returns : void 00080 Description : Gadget specific function to define the set of allowable 00081 characters. 00082 */ 00083 virtual void _set_allowable(const char *allowed); 00084 00085 /* 00086 Parameters : value - The text string to set. 00087 Returns : void 00088 Description : Gadget specific function to set the value. 00089 */ 00090 virtual void _set_value(const char *value); 00091 00092 /* 00093 Parameters : value - Pointer to buffer to hold the value, or NULL 00094 to read the size of buffer required. 00095 size - The size of the buffer. 00096 Returns : size_t - Number of bytes written to the buffer, or 00097 the buffer size required if NULL passed. 00098 Description : Gadget specific function to get the value or the buffer 00099 size required. 00100 */ 00101 virtual size_t _get_value(char *value, size_t size) const; 00102 00103 /* 00104 Parameters : font - The name of the font to use, or NULL to use the 00105 system font. 00106 xsize - The width in 16ths of a point. 00107 ysize - The height in 16ths of a point. 00108 Returns : void 00109 Description : Gadget specific function to set the font. 00110 */ 00111 virtual void _set_font(const char *font, int xsize, int ysize); 00112 }; 00113 00114 /* 00115 Parameters : component - The component ID of this writable field. 00116 object - The object ID of this writable field's parent 00117 window. 00118 Returns : - 00119 Description : Constructor function. This does not create a 00120 writable field; it merely creates an object to represent 00121 the writable field. 00122 */ 00123 inline writablefield_c::writablefield_c(toolbox_c component, toolbox_o object) 00124 : gadget_c(component, object) {} 00125 00126 #endif
1.3.3