00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef __SCIM_PROPERTY_H
00033 #define __SCIM_PROPERTY_H
00034
00035 namespace scim {
00036
00037 #define SCIM_PROPERTY_ACTIVE 0x01
00038 #define SCIM_PROPERTY_VISIBLE 0x02
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068 class Property
00069 {
00070 String m_key;
00071 String m_label;
00072 String m_icon;
00073 String m_tip;
00074 uint16 m_state;
00075
00076 public:
00077
00078
00079
00080 Property () : m_state (0) { }
00081
00082
00083
00084
00085 Property (const String &key,
00086 const String &label,
00087 const String &icon = String (""),
00088 const String &tip = String (""))
00089 : m_key (key), m_label (label), m_icon (icon),
00090 m_tip (tip), m_state (SCIM_PROPERTY_VISIBLE | SCIM_PROPERTY_ACTIVE) { }
00091
00092
00093
00094
00095
00096
00097 bool valid () const { return m_key.length (); }
00098
00099
00100
00101
00102
00103
00104 bool visible () const { return m_state & SCIM_PROPERTY_VISIBLE; }
00105
00106
00107
00108
00109
00110
00111
00112
00113 bool active () const { return m_state & SCIM_PROPERTY_ACTIVE; }
00114
00115
00116
00117
00118 const String & get_key () const { return m_key; }
00119
00120
00121
00122
00123 const String & get_label () const { return m_label; }
00124
00125
00126
00127
00128 const String & get_icon () const { return m_icon; }
00129
00130
00131
00132
00133 const String & get_tip () const { return m_tip; }
00134
00135
00136
00137
00138 void set_key (const String & key) { m_key = key; }
00139
00140
00141
00142
00143 void set_label (const String & label) { m_label = label; }
00144
00145
00146
00147
00148 void set_icon (const String & icon) { m_icon = icon; }
00149
00150
00151
00152
00153 void set_tip (const String & tip) { m_tip = tip; }
00154
00155
00156
00157
00158
00159
00160 void set_active (bool active) {
00161 if (active) m_state |= SCIM_PROPERTY_ACTIVE;
00162 else m_state &= (~ SCIM_PROPERTY_ACTIVE);
00163 }
00164
00165 void show (bool visible = true) {
00166 if (visible) m_state |= SCIM_PROPERTY_VISIBLE;
00167 else m_state &= ~SCIM_PROPERTY_VISIBLE;
00168 }
00169
00170 void hide (bool hidden = true) { show (!hidden); }
00171
00172
00173
00174
00175
00176
00177 bool is_a_leaf_of (const Property &node) const {
00178 if (m_key.length () > node.m_key.length () &&
00179 m_key.substr (0, node.m_key.length ()) == node.m_key &&
00180 m_key [node.m_key.length ()] == '/')
00181 return true;
00182 return false;
00183 }
00184 };
00185
00186 inline bool
00187 operator < (const Property &lhs, const Property &rhs) {
00188 return lhs.get_key () < rhs.get_key ();
00189 }
00190
00191 inline bool
00192 operator < (const Property &lhs, const String &rhs) {
00193 return lhs.get_key () < rhs;
00194 }
00195
00196 inline bool
00197 operator < (const String &lhs, const Property &rhs) {
00198 return lhs < rhs.get_key ();
00199 }
00200
00201 inline bool
00202 operator == (const Property &lhs, const Property &rhs) {
00203 return lhs.get_key () == rhs.get_key ();
00204 }
00205
00206 inline bool
00207 operator == (const Property &lhs, const String &rhs) {
00208 return lhs.get_key () == rhs;
00209 }
00210
00211 inline bool
00212 operator == (const String &lhs, const Property &rhs) {
00213 return lhs == rhs.get_key ();
00214 }
00215
00216 inline bool
00217 operator != (const Property &lhs, const Property &rhs) {
00218 return lhs.get_key () != rhs.get_key ();
00219 }
00220
00221 inline bool
00222 operator != (const Property &lhs, const String &rhs) {
00223 return lhs.get_key () != rhs;
00224 }
00225
00226 inline bool
00227 operator != (const String &lhs, const Property &rhs) {
00228 return lhs != rhs.get_key ();
00229 }
00230
00231
00232
00233
00234
00235
00236
00237 typedef std::vector<Property> PropertyList;
00238
00239
00240
00241 }
00242
00243 #endif //__SCIM_PROPERTY_H
00244
00245
00246
00247