00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef KDMITEM_H
00023 #define KDMITEM_H
00024
00025 #include <tqobject.h>
00026 #include <tqvaluelist.h>
00027 #include <tqrect.h>
00028 #include <tqdom.h>
00029
00030 class KdmItem;
00031 class KdmLayoutBox;
00032 class KdmLayoutFixed;
00033
00034 class TQPainter;
00035 class TQLayoutItem;
00036
00083 class KdmItem : public TQObject {
00084 Q_OBJECT
00085
00086 friend class KdmThemer;
00087
00088 public:
00092 KdmItem( KdmItem *parent, const TQDomNode &node = TQDomNode(), const char *name = 0 );
00093 KdmItem( TQWidget *parent, const TQDomNode &node = TQDomNode(), const char *name = 0 );
00094
00095 virtual ~KdmItem();
00096
00102 virtual void setGeometry( const TQRect &newGeometry, bool force );
00103
00109 void paint( TQPainter *painter, const TQRect &boundaries );
00110
00114 virtual void update();
00115
00120 void mouseEvent( int x, int y, bool pressed = false, bool released = false );
00121
00129 virtual TQRect placementHint( const TQRect &parentGeometry );
00130
00135 void setBoxLayout( const TQDomNode &node = TQDomNode() );
00136
00141 void setFixedLayout( const TQDomNode &node = TQDomNode() );
00142
00143 TQString type() const { return itemType; }
00144 void setType( const TQString &t ) { itemType = t; }
00145 void setBaseDir( const TQString &bd ) { basedir = bd; }
00146
00147 TQString baseDir() const
00148 {
00149 if (basedir.isEmpty() && parent())
00150 return static_cast<KdmItem *>( parent()->qt_cast( "KdmItem" ) )->baseDir();
00151 return basedir;
00152 }
00153
00154 KdmItem *findNode( const TQString &id ) const;
00155 virtual void setWidget( TQWidget *widget );
00156 TQWidget *widget() const { return myWidget; }
00157 virtual void setLayoutItem( TQLayoutItem *item );
00158
00159 virtual void hide( bool force = false );
00160 virtual void show( bool force = false );
00161
00162 bool isHidden() const { return isShown != Shown; }
00163 bool isExplicitlyHidden() const { return isShown == ExplicitlyHidden; }
00164 TQRect rect() const { return area; }
00165
00166 TQWidget *parentWidget() const;
00167 TQString getId() const { return id; }
00168
00169 signals:
00170 void needUpdate( int x, int y, int w, int h );
00171 void activated( const TQString &id );
00172
00173 protected slots:
00174 void widgetGone();
00175 void layoutItemGone();
00176
00177 protected:
00184 virtual TQSize sizeHint();
00185
00194 virtual void drawContents( TQPainter *painter, const TQRect ®ion ) = 0;
00195
00200 virtual void statusChanged();
00201
00205 void needUpdate();
00206
00207
00208 enum ItemState { Snormal, Sactive, Sprelight } state;
00209
00210 static KdmItem *currentActive;
00211
00212
00213 struct {
00214 bool incrementalPaint;
00215 } properties;
00216
00217
00218 TQRect area;
00219
00220
00221 enum DataType { DTnone, DTpixel, DTnpixel, DTpercent, DTbox };
00222 struct {
00223 enum DataType xType, yType, wType, hType;
00224 int x;
00225 int y;
00226 int width;
00227 int height;
00228 TQString anchor;
00229 } pos;
00230
00231
00232
00233
00234
00235 void addChildItem( KdmItem *item );
00236
00237
00238
00239
00240
00241 void parseAttribute( const TQString &, int &, enum DataType & );
00242 void parseFont( const TQString &, TQFont & );
00243 void parseColor( const TQString &, TQColor & );
00244
00245 void inheritFromButton( KdmItem *button );
00246 void init( const TQDomNode &node = TQDomNode(), const char *name = 0 );
00247
00248 TQString itemType, id;
00249 TQValueList<KdmItem *> m_children;
00250
00251 int m_backgroundModifier;
00252
00253
00254 enum { MNone = 0, MFixed = 1, MBox = 2 } currentManager;
00255 KdmLayoutBox *boxManager;
00256 KdmLayoutFixed *fixedManager;
00257
00258
00259 TQImage *image;
00260
00261
00262 TQString basedir;
00263
00264 TQWidget *myWidget;
00265 TQLayoutItem *myLayoutItem;
00266
00267 enum { InitialHidden, ExplicitlyHidden, Shown } isShown;
00268
00269 KdmItem *buttonParent;
00270 };
00271
00272 #endif