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