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
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 #ifndef __KASBAR_H
00060 #define __KASBAR_H
00061
00062 #include <tqwidget.h>
00063 #include <tqpoint.h>
00064 #include <tqptrlist.h>
00065 #include <tqlayout.h>
00066
00067 #include "kasresources.h"
00068
00069 class KRootPixmap;
00070
00071 class KasItem;
00072 class KasResources;
00073
00074 typedef TQPtrList<KasItem> KasItemList;
00075
00076
00080 class KDE_EXPORT KasBar : public QWidget
00081 {
00082 Q_OBJECT
00083 Q_PROPERTY( int maxBoxes READ maxBoxes )
00084 Q_PROPERTY( uint boxesPerLine READ boxesPerLine )
00085 Q_PROPERTY( Direction direction READ direction )
00086 Q_PROPERTY( Orientation orientation READ orientation )
00087 Q_PROPERTY( bool masked READ isMasked )
00088 Q_ENUMS( Direction )
00089
00090 friend class KasItem;
00091 public:
00092 KasBar( Orientation o, TQWidget *parent=0, const char *name=0, WFlags f=0 );
00093 KasBar( Orientation o, KasBar *master,
00094 TQWidget* parent=0, const char* name=0, WFlags f=0 );
00095
00096 virtual ~KasBar();
00097
00098 typedef TQBoxLayout::Direction Direction;
00099
00101 bool isTopLevel() const { return !master_; }
00102
00104 KasBar *master() const { return master_; }
00105
00107 virtual KasBar *createChildBar( Orientation o, TQWidget *parent, const char *name=0 );
00108
00110 virtual KasResources *resources();
00111
00113 bool hasResources() const { return (res ? true : false); }
00114
00115
00116
00117
00118 void append( KasItem *i );
00119 void insert( int index, KasItem *i );
00120 void remove( KasItem *i );
00121 void clear();
00122 KasItem *take( KasItem *i ) { return items.take( indexOf(i) ); }
00123 KasItem *itemAt( uint i ) { return items.at( i ); }
00124 int indexOf( KasItem *i ) { return items.find( i ); }
00125
00126 KasItemList *itemList() { return &items; }
00127
00128
00129
00130
00131
00133 enum ItemSize { Enormous, Huge, Large, Medium, Small, Custom };
00134
00135 int itemSize() const { return itemSize_; }
00136 int itemExtent() const { return itemExtent_; }
00137
00139 unsigned int itemCount() const { return items.count(); }
00140
00141 int maxBoxes() const { return maxBoxes_; }
00142 uint boxesPerLine() const { return boxesPerLine_; }
00143
00144 void setOrientation( Orientation o );
00145 Orientation orientation() const { return orient; }
00146
00147 void setDirection( Direction dir );
00148 Direction direction() const { return direction_; }
00149
00150 bool isDetached() const { return detached; }
00151 TQPoint detachedPosition() const { return detachedPos; }
00152
00153 bool isDrag() const { return inDrag; }
00154
00155 TQSize sizeHint( Orientation, TQSize max );
00156
00157
00158
00159
00160
00161 bool isMasked() const { return useMask_; }
00162
00164 bool isTransparent() const { return transparent_; }
00165
00167 bool hasTint() const { return enableTint_; }
00168
00170 void setTint( double amount, TQColor color );
00171
00173 void setTintAmount( double amount ) { setTint( amount, tintColour_ ); }
00174
00176 double tintAmount() const { return tintAmount_; }
00177
00179 TQColor tintColor() const { return tintColour_; }
00180
00182 bool paintInactiveFrames() const { return paintInactiveFrame_; }
00183
00184
00185
00186
00187
00188 void updateItem( KasItem *i );
00189
00191 void repaintItem(KasItem *i, bool erase = true );
00192
00194 KasItem* itemAt(const TQPoint &p);
00195
00197 TQPoint itemPos( KasItem *i );
00198
00200 KasItem *itemUnderMouse() const { return itemUnderMouse_; }
00201
00202 public slots:
00203
00204
00205
00206 void setMaxBoxes( int count );
00207 void setBoxesPerLine( int count );
00208
00209 void setItemSize( int size );
00210 void setItemExtent( int size );
00211 void setDetachedPosition( const TQPoint &pos );
00212
00213 virtual void updateLayout();
00214
00215 void updateMouseOver();
00216 void updateMouseOver( TQPoint pos );
00217
00219 void setTint( bool enable );
00220
00222 void setTransparent( bool enable );
00223
00225 void setTintColor( const TQColor &c );
00226
00228 void setTintAmount( int percent );
00229
00230 void setBackground( const TQPixmap &pix );
00231
00232 void setMasked( bool mask );
00233
00234 void setPaintInactiveFrames( bool enable );
00235
00236 void toggleOrientation();
00237 void toggleDetached();
00238 void setDetached( bool detach );
00239
00241 virtual void rereadMaster();
00242
00243 virtual void addTestItems();
00244
00245 signals:
00246
00247 void detachedChanged( bool );
00248 void detachedPositionChanged( const TQPoint & );
00249 void dragStarted();
00250
00251 void directionChanged();
00252
00254 void layoutChanged();
00255
00257 void itemSizeChanged( int );
00258
00259 void configChanged();
00260
00261 protected:
00262 KRootPixmap *rootPixmap() const { return rootPix; }
00263
00265 void mousePressEvent(TQMouseEvent *ev);
00266
00268 void mouseReleaseEvent(TQMouseEvent *ev);
00269
00271 void mouseMoveEvent(TQMouseEvent *ev);
00272
00274 void dragMoveEvent(TQDragMoveEvent *ev);
00275
00277 void paintBackground( TQPainter *p, const TQRect &r );
00278
00280 void paintEvent(TQPaintEvent *ev);
00281
00283 void resizeEvent(TQResizeEvent *ev);
00284
00285 private:
00286
00287 TQPixmap offscreen;
00288 KasBar *master_;
00289 KasItemList items;
00290 Orientation orient;
00291 Direction direction_;
00292 KasItem *itemUnderMouse_;
00293 uint boxesPerLine_;
00294 TQPoint pressPos;
00295 bool inDrag;
00296 bool detached;
00297 int maxBoxes_;
00298 int itemSize_;
00299 int itemExtent_;
00300 TQPoint detachedPos;
00301 bool paintInactiveFrame_;
00302
00303
00304 bool transparent_;
00305 KPixmap bg;
00306 KRootPixmap *rootPix;
00307 bool enableTint_;
00308 double tintAmount_;
00309 TQColor tintColour_;
00310 bool useMask_;
00311
00312
00313 KasResources *res;
00314 };
00315
00316
00317
00318 #endif