b2client.h
00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __B2CLIENT_H
00010 #define __B2CLIENT_H
00011
00012 #include <qvariant.h>
00013 #include <qbutton.h>
00014 #include <qbitmap.h>
00015 #include <kpixmap.h>
00016 #include <kdecoration.h>
00017 #include <kdecorationfactory.h>
00018
00019 class QSpacerItem;
00020 class QBoxLayout;
00021 class QGridLayout;
00022
00023 namespace B2 {
00024
00025 class B2Client;
00026
00027 class B2Button : public QButton
00028 {
00029 public:
00030 B2Button(B2Client *_client=0, QWidget *parent=0, const QString& tip=NULL, const int realizeBtns = LeftButton);
00031 ~B2Button() {};
00032
00033 void setBg(const QColor &c){bg = c;}
00034 void setPixmaps(KPixmap *pix, KPixmap *pixDown, KPixmap *iPix,
00035 KPixmap *iPixDown);
00036 void setPixmaps(int button_id);
00037 void setToggle(){setToggleType(Toggle);}
00038 void setActive(bool on){setOn(on);}
00039 void setUseMiniIcon(){useMiniIcon = true;}
00040 QSize sizeHint() const;
00041 QSizePolicy sizePolicy() const;
00042 protected:
00043 virtual void drawButton(QPainter *p);
00044 void drawButtonLabel(QPainter *){;}
00045
00046 bool useMiniIcon;
00047 KPixmap *pNorm, *pDown, *iNorm, *iDown;
00048 QColor bg;
00049
00050 void mousePressEvent( QMouseEvent* e );
00051 void mouseReleaseEvent( QMouseEvent* e );
00052
00053 public:
00054 B2Client* client;
00055 int last_button;
00056 int realizeButtons;
00057 };
00058
00059 class B2Titlebar : public QWidget
00060 {
00061 friend class B2Client;
00062 public:
00063 B2Titlebar(B2Client *parent);
00064 ~B2Titlebar(){;}
00065 bool isFullyObscured() const {return isfullyobscured;}
00066 void recalcBuffer();
00067 QSpacerItem *captionSpacer;
00068 protected:
00069 void paintEvent( QPaintEvent* );
00070 bool x11Event(XEvent *e);
00071 void mouseDoubleClickEvent( QMouseEvent * );
00072 void mousePressEvent( QMouseEvent * );
00073 void mouseReleaseEvent( QMouseEvent * );
00074 void mouseMoveEvent(QMouseEvent *);
00075 void resizeEvent(QResizeEvent *ev);
00076 private:
00077 void drawTitlebar(QPainter &p, bool state);
00078
00079 B2Client *client;
00080 QString oldTitle;
00081 KPixmap titleBuffer;
00082 QPoint moveOffset;
00083 bool set_x11mask;
00084 bool isfullyobscured;
00085 bool shift_move;
00086 };
00087
00088 class B2Client : public KDecoration
00089 {
00090 Q_OBJECT
00091 friend class B2Titlebar;
00092 public:
00093 B2Client(KDecorationBridge *b, KDecorationFactory *f);
00094 ~B2Client(){;}
00095 void init();
00096 void unobscureTitlebar();
00097 void titleMoveAbs(int new_ofs);
00098 void titleMoveRel(int xdiff);
00099
00100 virtual bool drawbound(const QRect& geom, bool clear);
00101 protected:
00102 void resizeEvent( QResizeEvent* );
00103 void paintEvent( QPaintEvent* );
00104 void showEvent( QShowEvent* );
00105 void windowWrapperShowEvent( QShowEvent* );
00106 void captionChange();
00107 void desktopChange();
00108 void shadeChange();
00109 void activeChange();
00110 void maximizeChange();
00111 void iconChange();
00112 void doShape();
00113 Position mousePosition( const QPoint& p ) const;
00114 void resize(const QSize&);
00115 void borders(int &, int &, int &, int &) const;
00116 QSize minimumSize() const;
00117 bool eventFilter(QObject *, QEvent *);
00118 private slots:
00119 void menuButtonPressed();
00120
00121 void maxButtonClicked();
00122 private:
00123 void addButtons(const QString& s, const QString tips[],
00124 B2Titlebar* tb, QBoxLayout* titleLayout);
00125 void positionButtons();
00126 void calcHiddenButtons();
00127 enum ButtonType{BtnMenu=0, BtnSticky, BtnIconify, BtnMax, BtnClose,
00128 BtnHelp, BtnCount};
00129 B2Button* button[BtnCount];
00130 QGridLayout *g;
00131 QSpacerItem *spacer;
00132 QSpacerItem *leftSpacer;
00133 QSpacerItem *rightSpacer;
00134 B2Titlebar *titlebar;
00135 int bar_x_ofs;
00136 int in_unobs;
00137 };
00138
00139 class B2ClientFactory : public QObject, public KDecorationFactory
00140 {
00141 public:
00142 B2ClientFactory();
00143 virtual ~B2ClientFactory();
00144 virtual KDecoration *createDecoration(KDecorationBridge *);
00145 virtual bool reset(unsigned long changed);
00146 QValueList< B2ClientFactory::BorderSize > borderSizes() const;
00147 };
00148
00149 }
00150
00151 #endif
This file is part of the documentation for kwin Library Version 3.2.2.