| 1 |
#ifndef _GTKMM_CHILDPROPERTYPROXY_H |
| 2 |
#define _GTKMM_CHILDPROPERTYPROXY_H |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#include <gtkmm/childpropertyproxy_base.h> |
| 23 |
|
| 24 |
namespace Gtk |
| 25 |
{ |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
template <class T> |
| 41 |
class ChildPropertyProxy : public ChildPropertyProxy_Base |
| 42 |
{ |
| 43 |
public: |
| 44 |
typedef T PropertyType; |
| 45 |
|
| 46 |
ChildPropertyProxy(Gtk::Container* parent, Gtk::Widget& child, const char* property_name) |
| 47 |
: ChildPropertyProxy_Base(parent, child, property_name) {} |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
void set_value(const PropertyType& data); |
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
PropertyType get_value() const; |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
void reset_value() |
| 62 |
{ reset_property_(); } |
| 63 |
|
| 64 |
ChildPropertyProxy<T>& operator=(const PropertyType& data) |
| 65 |
{ set_value(data); return *this; } |
| 66 |
|
| 67 |
operator PropertyType() const |
| 68 |
{ return get_value(); } |
| 69 |
|
| 70 |
SignalProxyChildProperty signal_changed(); |
| 71 |
}; |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
template <class T> |
| 78 |
class ChildPropertyProxy_WriteOnly : public ChildPropertyProxy_Base |
| 79 |
{ |
| 80 |
public: |
| 81 |
typedef T PropertyType; |
| 82 |
|
| 83 |
ChildPropertyProxy_WriteOnly(Gtk::Container* parent, Gtk::Widget& child, const char* property_name) |
| 84 |
: ChildPropertyProxy_Base(parent, child, property_name) {} |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
void set_value(const PropertyType& data); |
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
void reset_value() |
| 94 |
{ reset_property_(); } |
| 95 |
|
| 96 |
ChildPropertyProxy_WriteOnly<T>& operator=(const PropertyType& data) |
| 97 |
{ set_value(data); return *this; } |
| 98 |
}; |
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
template <class T> |
| 104 |
class ChildPropertyProxy_ReadOnly : public ChildPropertyProxy_Base |
| 105 |
{ |
| 106 |
public: |
| 107 |
typedef T PropertyType; |
| 108 |
|
| 109 |
|
| 110 |
ChildPropertyProxy_ReadOnly(const Gtk::Container* parent, const Gtk::Widget& child, const char* property_name) |
| 111 |
: ChildPropertyProxy_Base(const_cast<Gtk::Container*>(parent), const_cast<Gtk::Widget&>(child), property_name) {} |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
PropertyType get_value() const; |
| 117 |
|
| 118 |
operator PropertyType() const |
| 119 |
{ return get_value(); } |
| 120 |
}; |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
#ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 126 |
|
| 127 |
template <class T> |
| 128 |
void ChildPropertyProxy<T>::set_value(const T& data) |
| 129 |
{ |
| 130 |
Glib::Value<T> value; |
| 131 |
value.init(Glib::Value<T>::value_type()); |
| 132 |
|
| 133 |
value.set(data); |
| 134 |
set_property_(value); |
| 135 |
} |
| 136 |
|
| 137 |
template <class T> |
| 138 |
T ChildPropertyProxy<T>::get_value() const |
| 139 |
{ |
| 140 |
Glib::Value<T> value; |
| 141 |
value.init(Glib::Value<T>::value_type()); |
| 142 |
|
| 143 |
get_property_(value); |
| 144 |
return value.get(); |
| 145 |
} |
| 146 |
|
| 147 |
template <class T> |
| 148 |
SignalProxyChildProperty ChildPropertyProxy<T>::signal_changed() |
| 149 |
{ |
| 150 |
return SignalProxyChildProperty(&child_, property_name_); |
| 151 |
} |
| 152 |
|
| 153 |
template <class T> |
| 154 |
void ChildPropertyProxy_WriteOnly<T>::set_value(const T& data) |
| 155 |
{ |
| 156 |
Glib::Value<T> value; |
| 157 |
value.init(Glib::Value<T>::value_type()); |
| 158 |
|
| 159 |
value.set(data); |
| 160 |
set_property_(value); |
| 161 |
} |
| 162 |
|
| 163 |
template <class T> |
| 164 |
T ChildPropertyProxy_ReadOnly<T>::get_value() const |
| 165 |
{ |
| 166 |
Glib::Value<T> value; |
| 167 |
value.init(Glib::Value<T>::value_type()); |
| 168 |
|
| 169 |
get_property_(value); |
| 170 |
return value.get(); |
| 171 |
} |
| 172 |
|
| 173 |
#endif |
| 174 |
|
| 175 |
} |
| 176 |
|
| 177 |
#endif |