Back to index

kdeartwork  4.3.2
nextclient.h
Go to the documentation of this file.
00001 /********************************************************************
00002 This program is free software; you can redistribute it and/or modify
00003 it under the terms of the GNU General Public License as published by
00004 the Free Software Foundation; either version 2 of the License, or
00005 (at your option) any later version.
00006 
00007 This program is distributed in the hope that it will be useful,
00008 but WITHOUT ANY WARRANTY; without even the implied warranty of
00009 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00010 GNU General Public License for more details.
00011 
00012 You should have received a copy of the GNU General Public License
00013 along with this program.  If not, see <http://www.gnu.org/licenses/>.
00014 *********************************************************************/
00015 
00016 #ifndef __NEXTCLIENT_H
00017 #define __NEXTCLIENT_H
00018 
00019 //#include <QVariant>
00020 
00021 #include <QBitmap>
00022 #include <QPixmap>
00023 
00024 //Added by qt3to4:
00025 #include <QPaintEvent>
00026 #include <QEvent>
00027 #include <QBoxLayout>
00028 #include <QLabel>
00029 #include <QShowEvent>
00030 #include <QResizeEvent>
00031 #include <QMouseEvent>
00032 
00033 #include <qlayout.h>
00034 #include <q3button.h>
00035 #include <kdecoration.h>
00036 #include <kdecorationfactory.h>
00037 #include <kcommondecoration.h>
00038 
00039 class QLabel;
00040 class QSpacerItem;
00041 
00042 namespace KStep {
00043 
00044 class NextClient;
00045 
00046 class NextButton : public QAbstractButton
00047 {
00048 public:
00049     NextButton(NextClient *parent=0, 
00050                const unsigned char *bitmap=NULL, int bw=0, int bh=0,
00051                const QString& tip=NULL, const int realizeBtns = Qt::LeftButton);
00052     void setBitmap(const unsigned char *bitmap, int bw, int bh);
00053     void reset();
00054     Qt::MouseButton lastButton() { return last_button; }
00055 
00056 protected:
00057     void mousePressEvent( QMouseEvent* e );
00058     void mouseReleaseEvent( QMouseEvent* e );
00059     virtual void paintEvent(QPaintEvent *e);
00060 
00061     QPixmap aBackground, iBackground;
00062     QBitmap deco;
00063     NextClient *client;
00064     Qt::MouseButton last_button;
00065     int realizeButtons;
00066 };
00067 
00068 class NextClient : public KDecoration
00069 {
00070     Q_OBJECT
00071 public:
00072     NextClient(KDecorationBridge *b, KDecorationFactory *f);
00073     ~NextClient() {;}
00074     void init();
00075     virtual bool drawbound(const QRect& geom, bool clear);
00076 protected:
00077     bool eventFilter(QObject *o, QEvent *e);
00078     void resizeEvent( QResizeEvent* );
00079     void paintEvent( QPaintEvent* );
00080     void showEvent( QShowEvent* );
00081 
00082     void mouseDoubleClickEvent( QMouseEvent * );
00083     void captionChange();
00084     void desktopChange();
00085     void activeChange();
00086     void shadeChange();
00087     void iconChange();
00088     QSize minimumSize() const;
00089     void resize(const QSize &size);
00090     void borders(int &left, int &right, int &top, int &bottom) const;
00091     void reset(unsigned long changed);
00092     void calcHiddenButtons();
00093     void updateActiveBuffer();
00094 
00095     Position mousePosition(const QPoint &) const;
00096     void maximizeChange();
00097 
00098 protected slots:
00099     void slotReset();
00100     void menuButtonPressed();
00101     void maximizeButtonClicked();
00102     void shadeClicked();
00103     void aboveClicked();
00104     void belowClicked();
00105     void resizePressed();
00106 
00107     void keepAboveChange(bool above);
00108     void keepBelowChange(bool below);
00109 
00110 private:
00111     void initializeButtonsAndTitlebar(QBoxLayout* titleLayout);
00112     void addButtons(QBoxLayout* titleLayout, const QString& buttons);
00113     bool mustDrawHandle() const;
00114 
00115     QSpacerItem* titlebar;
00116 
00117     // Helpful constants for buttons in array
00118     enum { CLOSE_IDX = 0,
00119            HELP_IDX,
00120            ICONIFY_IDX,
00121            MAXIMIZE_IDX,
00122            MENU_IDX,
00123            SHADE_IDX,
00124            ABOVE_IDX,
00125            BELOW_IDX,
00126            RESIZE_IDX,
00127            STICKY_IDX,
00128            MAX_NUM_BUTTONS = STICKY_IDX + 1 };
00129 
00130     // WARNING: button[i] may be null for any given i.  Make sure you
00131     // always check for null before doing button[i]->foo().
00132     NextButton* button[MAX_NUM_BUTTONS];
00133 };
00134 
00135 class NextClientFactory: public QObject, public KDecorationFactory
00136 {
00137 public:
00138     NextClientFactory();
00139     virtual ~NextClientFactory();
00140     virtual KDecoration *createDecoration(KDecorationBridge *);
00141     virtual bool reset(unsigned long changed);
00142     virtual bool supports(Ability ability) const;
00143 
00144     virtual QList< NextClientFactory::BorderSize > borderSizes() const;
00145 
00146 };
00147 
00148 }
00149 
00150 #endif