buttons.h
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 #ifndef __BUTTONS_H_
00032 #define __BUTTONS_H_
00033
00034 #include <qbitmap.h>
00035 #include <qevent.h>
00036 #include <qdragobject.h>
00037 #include <qlistbox.h>
00038
00039 #include <klistview.h>
00040
00041 class KDecorationFactory;
00042
00046 class Button
00047 {
00048 public:
00049 Button();
00050 Button(const QString& name, const QBitmap& icon, QChar type, bool duplicate, bool supported);
00051 virtual ~Button();
00052
00053 QString name;
00054 QBitmap icon;
00055 QChar type;
00056 bool duplicate;
00057 bool supported;
00058 };
00059
00060 class ButtonDrag : public QStoredDrag
00061 {
00062 public:
00063 ButtonDrag( Button btn, QWidget* parent, const char* name=0 );
00064 ~ButtonDrag() {};
00065
00066 static bool canDecode( QDropEvent* e );
00067 static bool decode( QDropEvent* e, Button& btn );
00068 };
00069
00073 class ButtonDropSiteItem
00074 {
00075 public:
00076 ButtonDropSiteItem(const Button& btn);
00077 ~ButtonDropSiteItem();
00078
00079 Button button();
00080
00081 QRect rect;
00082 int width();
00083 int height();
00084
00085 void draw(QPainter *p, const QColorGroup& cg, QRect rect);
00086
00087 private:
00088 Button m_button;
00089 };
00090
00094 class ButtonSourceItem : public QListViewItem
00095 {
00096 public:
00097 ButtonSourceItem(QListView * parent, const Button& btn);
00098 virtual ~ButtonSourceItem();
00099
00100 void paintCell(QPainter *p, const QColorGroup &cg, int column, int width, int align);
00101
00102 void setButton(const Button& btn);
00103 Button button() const;
00104 private:
00105 Button m_button;
00106 bool m_dirty;
00107 };
00108
00112 class ButtonSource : public KListView
00113 {
00114 Q_OBJECT
00115
00116 public:
00117 ButtonSource(QWidget *parent = 0, const char* name = 0);
00118 virtual ~ButtonSource();
00119
00120 QSize sizeHint() const;
00121
00122 void hideAllButtons();
00123 void showAllButtons();
00124
00125 public slots:
00126 void hideButton(QChar btn);
00127 void showButton(QChar btn);
00128
00129 protected:
00130 bool acceptDrag(QDropEvent* e) const;
00131 virtual QDragObject *dragObject();
00132 };
00133
00134 typedef QValueList<ButtonDropSiteItem*> ButtonList;
00135
00139 class ButtonDropSite: public QFrame
00140 {
00141 Q_OBJECT
00142
00143 public:
00144 ButtonDropSite( QWidget* parent=0, const char* name=0 );
00145 ~ButtonDropSite();
00146
00147
00148
00149 ButtonList buttonsLeft;
00150 ButtonList buttonsRight;
00151 void clearLeft();
00152 void clearRight();
00153
00154 signals:
00155 void buttonAdded(QChar btn);
00156 void buttonRemoved(QChar btn);
00157 void changed();
00158
00159 public slots:
00160 bool removeSelectedButton();
00161 void recalcItemGeometry();
00162
00163 protected:
00164 void resizeEvent(QResizeEvent*);
00165 void dragEnterEvent( QDragEnterEvent* e );
00166 void dragMoveEvent( QDragMoveEvent* e );
00167 void dragLeaveEvent( QDragLeaveEvent* e );
00168 void dropEvent( QDropEvent* e );
00169 void mousePressEvent( QMouseEvent* e );
00170
00171 void drawContents( QPainter* p );
00172 ButtonDropSiteItem *buttonAt(QPoint p);
00173 bool removeButton(ButtonDropSiteItem *item);
00174 int calcButtonListWidth(const ButtonList& buttons);
00175 void drawButtonList(QPainter *p, const ButtonList& buttons, int offset);
00176
00177 QRect leftDropArea();
00178 QRect rightDropArea();
00179
00180 private:
00184 bool getItemIterator(ButtonDropSiteItem *item, ButtonList* &list, ButtonList::iterator &iterator);
00185
00186 void cleanDropVisualizer();
00187 QRect m_oldDropVisualizer;
00188
00189 ButtonDropSiteItem *m_selected;
00190 };
00191
00192 class ButtonPositionWidget : public QWidget
00193 {
00194 Q_OBJECT
00195
00196 public:
00197 ButtonPositionWidget(QWidget *parent = 0, const char* name = 0);
00198 ~ButtonPositionWidget();
00199
00203 void setDecorationFactory(KDecorationFactory *factory);
00204
00205 QString buttonsLeft() const;
00206 QString buttonsRight() const;
00207 void setButtonsLeft(const QString &buttons);
00208 void setButtonsRight(const QString &buttons);
00209
00210 signals:
00211 void changed();
00212
00213 private:
00214 void clearButtonList(const ButtonList& btns);
00215 Button getButton(QChar type, bool& success);
00216
00217 ButtonDropSite* m_dropSite;
00218 ButtonSource *m_buttonSource;
00219
00220 KDecorationFactory *m_factory;
00221 QString m_supportedButtons;
00222 };
00223
00224
00225 #endif
00226
00227
This file is part of the documentation for kwin Library Version 3.4.3.