00001 /* 00002 File : gadget_w_show_t.h 00003 Date : 19-Sep-02 00004 Description : Class to represent a toolbox gadget template that allows 00005 another object to be shown. 00006 00007 Copyright © 1995-2002 Alexander Thoukydides 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License 00011 as published by the Free Software Foundation; either version 2 00012 of the License, or (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program; if not, write to the Free Software 00021 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA 00022 */ 00023 00024 // Only include header file once 00025 #ifndef gadget_w_show_t_h 00026 #define gadget_w_show_t_h 00027 00028 // Include cpplib header files 00029 #include "string.h" 00030 00031 // A class to represent a gadget template with a selectable event 00032 class gadget_w_show_t 00033 { 00034 public: 00035 00036 /* 00037 Parameters : object - The name of the object to show. 00038 Returns : void 00039 Description : Set the object to show. 00040 */ 00041 void set_show(const char *object); 00042 00043 /* 00044 Parameters : object - The name of the object to show. 00045 Returns : void 00046 Description : Set the object to show. 00047 */ 00048 void set_show(const string &object); 00049 00050 /* 00051 Parameters : void 00052 Returns : size_t - The size of buffer required to hold the 00053 object name. 00054 Description : Get the size of the buffer required to read the object 00055 to show. 00056 */ 00057 size_t get_show_size() const; 00058 00059 /* 00060 Parameters : object - Pointer to buffer to hold the object name. 00061 size - The size of the buffer. 00062 Returns : size_t - Number of bytes written to the buffer. 00063 Description : Get the object to show. 00064 */ 00065 size_t get_show(char *object, size_t size) const; 00066 00067 /* 00068 Parameters : void 00069 Returns : string - The name of the object to show. 00070 Description : Get the object to show. 00071 */ 00072 string get_show() const; 00073 00074 protected: 00075 00076 /* 00077 Parameters : object - The name of the object to show. 00078 Returns : void 00079 Description : Gadget specific function to set the object to show. 00080 */ 00081 virtual void _set_show(const char *object) = 0; 00082 00083 /* 00084 Parameters : object - Pointer to buffer to hold the object name, 00085 or NULL to read the size of buffer required. 00086 size - The size of the buffer. 00087 Returns : size_t - Number of bytes written to the buffer, or 00088 the buffer size required if NULL passed. 00089 Description : Gadget specific function to get the object to show or 00090 the buffer size required. 00091 */ 00092 virtual size_t _get_show(char *object, size_t size) const = 0; 00093 }; 00094 00095 /* 00096 Parameters : object - The name of the object to show. 00097 Returns : void 00098 Description : Set the object to show. 00099 */ 00100 inline void gadget_w_show_t::set_show(const char *object) 00101 { 00102 _set_show(object); 00103 } 00104 00105 /* 00106 Parameters : object - The name of the object to show. 00107 Returns : void 00108 Description : Set the object to show. 00109 */ 00110 inline void gadget_w_show_t::set_show(const string &object) 00111 { 00112 _set_show(object.c_str()); 00113 } 00114 00115 /* 00116 Parameters : void 00117 Returns : size_t - The size of buffer required to hold the 00118 object name. 00119 Description : Get the size of the buffer required to read the object 00120 to show. 00121 */ 00122 inline size_t gadget_w_show_t::get_show_size() const 00123 { 00124 return _get_show(NULL, 0); 00125 } 00126 00127 /* 00128 Parameters : object - Pointer to buffer to hold the object name. 00129 size - The size of the buffer. 00130 Returns : size_t - Number of bytes written to the buffer. 00131 Description : Get the object to show. 00132 */ 00133 inline size_t gadget_w_show_t::get_show(char *object, size_t size) const 00134 { 00135 return _get_show(object, size); 00136 } 00137 00138 #endif
1.3.3