20#include "customproperty.h"
25#include <tqsizepolicy.h>
33CustomProperty::CustomProperty( Property *parent)
38CustomProperty::~CustomProperty()
45 m_property->emitPropertyChanged();
50SizeCustomProperty::SizeCustomProperty( Property *property)
53 if(property && (property-> type() == Size) ) {
54 TQSize s = property->value().toSize();
55 new Property( "width", s.width(), i18n( "Width"), i18n( "Width"), Size_Width, property);
56 new Property( "height", s.height(), i18n( "Height"), i18n( "Height"), Size_Height, property);
60SizeCustomProperty::~SizeCustomProperty()
69 switch(m_property->type()) {
70 case Size_Width: case Size_Height:
83 if(m_property->parent()) {
84 TQSize s = m_property->parent()->value().toSize();
86 if(m_property->type() == Size_Height)
87 s.setHeight( value.toInt());
88 else if(m_property->type() == Size_Width)
89 s.setWidth( value.toInt());
91 m_property->parent()->setValue(s, true, false);
94 TQSize s = value.toSize();
95 m_property->child( "width")->setValue(s.width(), rememberOldValue, false);
96 m_property->child( "height")->setValue(s.height(), rememberOldValue, false);
103 if(!m_property || !m_property->parent())
106 if(m_property->type() == Size_Height)
107 return m_property->parent()->value().toSize().height();
108 else if(m_property->type() == Size_Width)
109 return m_property->parent()->value().toSize().width();
116PointCustomProperty::PointCustomProperty( Property *property)
119 if(property && (property-> type() == Point) ) {
120 TQPoint p = property->value().toPoint();
121 new Property( "x", p.x(), i18n( "X"), i18n( "X"), Point_X, property);
122 new Property( "y", p.y(), i18n( "Y"), i18n( "Y"), Point_Y, property);
126PointCustomProperty::~PointCustomProperty()
135 switch(m_property->type()) {
136 case Point_X: case Point_Y:
149 if(m_property->parent()) {
150 TQPoint p = m_property->parent()->value().toPoint();
152 if(m_property->type() == Point_X)
153 p.setX( value.toInt());
154 else if(m_property->type() == Point_Y)
155 p.setY( value.toInt());
157 m_property->parent()->setValue(p, true, false);
160 TQPoint p = value.toPoint();
161 m_property->child( "x")->setValue(p.x(), rememberOldValue, false);
162 m_property->child( "y")->setValue(p.y(), rememberOldValue, false);
169 if(!m_property || !m_property->parent())
172 if(m_property->type() == Point_X)
173 return m_property->parent()->value().toPoint().x();
174 else if(m_property->type() == Point_Y)
175 return m_property->parent()->value().toPoint().y();
182RectCustomProperty::RectCustomProperty( Property *property)
185 if(property && (property-> type() == Rect) ) {
186 TQRect r = property->value().toRect();
187 new Property( "x", r.x(), i18n( "X"), i18n( "X"), Rect_X, property);
188 new Property( "y", r.y(), i18n( "Y"), i18n( "Y"), Rect_Y, property);
189 new Property( "width", r.width(), i18n( "Width"), i18n( "Width"), Rect_Width, property);
190 new Property( "height", r.height(), i18n( "Height"), i18n( "Height"), Rect_Height, property);
194RectCustomProperty::~RectCustomProperty()
203 switch(m_property->type()) {
204 case Rect_X: case Rect_Y: case Rect_Width: case Rect_Height:
217 if(m_property->parent()) {
218 TQRect r = m_property->parent()->value().toRect();
220 if(m_property->type() == Rect_X) {
222 const int delta = value.toInt() - r.x();
223 r.setX( value.toInt());
224 r.setWidth(r.width()+delta);
226 else if(m_property->type() == Rect_Y) {
228 const int delta = value.toInt() - r.y();
229 r.setY( value.toInt());
230 r.setHeight(r.height()+delta);
232 else if(m_property->type() == Rect_Width)
233 r.setWidth( value.toInt());
234 else if(m_property->type() == Rect_Height)
235 r.setHeight( value.toInt());
237 m_property->parent()->setValue(r, true, false);
240 TQRect r = value.toRect();
241 m_property->child( "x")->setValue(r.x(), rememberOldValue, false);
242 m_property->child( "y")->setValue(r.y(), rememberOldValue, false);
243 m_property->child( "width")->setValue(r.width(), rememberOldValue, false);
244 m_property->child( "height")->setValue(r.height(), rememberOldValue, false);
251 if(!m_property || !m_property->parent())
254 if(m_property->type() == Rect_X)
255 return m_property->parent()->value().toRect().x();
256 else if(m_property->type() == Rect_Y)
257 return m_property->parent()->value().toRect().y();
258 else if(m_property->type() == Rect_Width)
259 return m_property->parent()->value().toRect().width();
260 else if(m_property->type() == Rect_Height)
261 return m_property->parent()->value().toRect().height();
269SizePolicyCustomProperty::SizePolicyCustomProperty( Property *property)
274 TQValueList<TQVariant> keys;
275 keys << TQSizePolicy::Fixed
276 << TQSizePolicy::Minimum
277 << TQSizePolicy::Maximum
278 << TQSizePolicy::Preferred
279 << TQSizePolicy::Expanding
280 << TQSizePolicy::MinimumExpanding
281 << TQSizePolicy::Ignored;
282 TQStringList strings;
283 strings << i18n( "Size Policy", "Fixed")
284 << i18n( "Size Policy", "Minimum")
285 << i18n( "Size Policy", "Maximum")
286 << i18n( "Size Policy", "Preferred")
287 << i18n( "Size Policy", "Expanding")
288 << i18n( "Size Policy", "Minimum Expanding")
289 << i18n( "Size Policy", "Ignored");
291 new Property( "hSizeType", new Property::ListData(keys, strings),
292 (int)property->value().toSizePolicy().horData(),
293 i18n( "Horz. Size Type"),i18n( "Horizontal Size Type"),
294 SizePolicy_HorData, property);
295 new Property( "vSizeType", new Property::ListData(keys, strings),
296 (int)property->value().toSizePolicy().verData(),
297 i18n( "Vert. Size Type"), i18n( "Vertical Size Type"),
298 SizePolicy_VerData, property);
299 new Property( "hStretch",
300 property->value().toSizePolicy().horStretch(),
301 i18n( "Horz. Stretch"), i18n( "Horizontal Stretch"),
302 SizePolicy_HorStretch, property);
303 new Property( "vStretch",
304 property->value().toSizePolicy().verStretch(),
305 i18n( "Vert. Stretch"), i18n( "Vertical Stretch"),
306 SizePolicy_VerStretch, property);
310SizePolicyCustomProperty::~SizePolicyCustomProperty()
320 switch(m_property->type()) {
321 case SizePolicy_HorData:
322 case SizePolicy_VerData:
323 case SizePolicy_HorStretch:
324 case SizePolicy_VerStretch:
337 if(m_property->parent()) {
338 TQSizePolicy v = m_property->parent()->value().toSizePolicy();
340 if(m_property->type() == SizePolicy_HorData)
341 v.setHorData(TQSizePolicy::SizeType( value.toInt()));
342 else if(m_property->type() == SizePolicy_VerData)
343 v.setVerData(TQSizePolicy::SizeType( value.toInt()));
344 else if(m_property->type() == SizePolicy_HorStretch)
345 v.setHorStretch( value.toInt());
346 else if(m_property->type() == SizePolicy_VerStretch)
347 v.setVerStretch( value.toInt());
349 m_property->parent()->setValue(v, true, false);
352 TQSizePolicy v = value.toSizePolicy();
353 m_property->child( "hSizeType")->setValue(v.horData(), rememberOldValue, false);
354 m_property->child( "vSizeType")->setValue(v.verData(), rememberOldValue, false);
355 m_property->child( "hStretch")->setValue(v.horStretch(), rememberOldValue, false);
356 m_property->child( "vStretch")->setValue(v.verStretch(), rememberOldValue, false);
363 if(!m_property || !m_property->parent())
366 if(m_property->type() == SizePolicy_HorData)
367 return m_property->parent()->value().toSizePolicy().horData();
368 else if(m_property->type() == SizePolicy_VerData)
369 return m_property->parent()->value().toSizePolicy().verData();
370 else if(m_property->type() == SizePolicy_HorStretch)
371 return m_property->parent()->value().toSizePolicy().horStretch();
372 else if(m_property->type() == SizePolicy_VerStretch)
373 return m_property->parent()->value().toSizePolicy().verStretch();
Base class for custom properties.
void emitPropertyChanged()
void setValue(const TQVariant &value, bool rememberOldValue)
The base class representing a single property.
void setValue(const TQVariant &value, bool rememberOldValue)
void setValue(const TQVariant &value, bool rememberOldValue)
void setValue(const TQVariant &value, bool rememberOldValue)
Namespace for a set of classes implementing generic properties framework.
@ Rect rectangle (x,y, width, height)
@ Size size (width, height)
@ SizePolicy size policy (horizontal, vertical)
|