00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef __B2CLIENT_H
00010 #define __B2CLIENT_H
00011
00012 #include <tqvariant.h>
00013 #include <tqdatetime.h>
00014 #include <tqbutton.h>
00015 #include <tqbitmap.h>
00016 #include <kpixmap.h>
00017 #include <kdecoration.h>
00018 #include <kdecorationfactory.h>
00019
00020 class TQSpacerItem;
00021 class TQBoxLayout;
00022 class TQGridLayout;
00023
00024 namespace B2 {
00025
00026 class B2Client;
00027
00028 class B2Button : public QButton
00029 {
00030 public:
00031 B2Button(B2Client *_client=0, TQWidget *parent=0, const TQString& tip=NULL, const int realizeBtns = LeftButton);
00032 ~B2Button() {};
00033
00034 void setBg(const TQColor &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 TQSize sizeHint() const;
00042 TQSizePolicy sizePolicy() const;
00043 protected:
00044 virtual void drawButton(TQPainter *p);
00045 void drawButtonLabel(TQPainter *){;}
00046
00047 void mousePressEvent( TQMouseEvent* e );
00048 void mouseReleaseEvent( TQMouseEvent* e );
00049 private:
00050 void enterEvent(TQEvent *e);
00051 void leaveEvent(TQEvent *e);
00052
00053 bool useMiniIcon;
00054 KPixmap *icon[6];
00055 TQColor 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 TQSpacerItem *captionSpacer;
00073 protected:
00074 void paintEvent( TQPaintEvent* );
00075 bool x11Event(XEvent *e);
00076 void mouseDoubleClickEvent( TQMouseEvent * );
00077 void wheelEvent(TQWheelEvent *);
00078 void mousePressEvent( TQMouseEvent * );
00079 void mouseReleaseEvent( TQMouseEvent * );
00080 void mouseMoveEvent(TQMouseEvent *);
00081 void resizeEvent(TQResizeEvent *ev);
00082 private:
00083 void drawTitlebar(TQPainter &p, bool state);
00084
00085 B2Client *client;
00086 TQString oldTitle;
00087 KPixmap titleBuffer;
00088 TQPoint moveOffset;
00089 bool set_x11mask;
00090 bool isfullyobscured;
00091 bool shift_move;
00092 };
00093
00094 class B2Client : public KDecoration
00095 {
00096 Q_OBJECT
00097 friend class B2Titlebar;
00098 public:
00099 B2Client(KDecorationBridge *b, KDecorationFactory *f);
00100 ~B2Client(){;}
00101 void init();
00102 void unobscureTitlebar();
00103 void titleMoveAbs(int new_ofs);
00104 void titleMoveRel(int xdiff);
00105
00106 virtual bool drawbound(const TQRect& geom, bool clear);
00107 protected:
00108 void resizeEvent( TQResizeEvent* );
00109 void paintEvent( TQPaintEvent* );
00110 void showEvent( TQShowEvent* );
00111 void windowWrapperShowEvent( TQShowEvent* );
00112 void captionChange();
00113 void desktopChange();
00114 void shadeChange();
00115 void activeChange();
00116 void maximizeChange();
00117 void iconChange();
00118 void doShape();
00119 Position mousePosition( const TQPoint& p ) const;
00120 void resize(const TQSize&);
00121 void borders(int &, int &, int &, int &) const;
00122 TQSize minimumSize() const;
00123 bool eventFilter(TQObject *, TQEvent *);
00124 private slots:
00125 void menuButtonPressed();
00126
00127 void maxButtonClicked();
00128 void shadeButtonClicked();
00129 void resizeButtonPressed();
00130 private:
00131 void addButtons(const TQString& s, const TQString tips[],
00132 B2Titlebar* tb, TQBoxLayout* titleLayout);
00133 void positionButtons();
00134 void calcHiddenButtons();
00135 bool mustDrawHandle() const;
00136
00137 enum ButtonType{BtnMenu=0, BtnSticky, BtnIconify, BtnMax, BtnClose,
00138 BtnHelp, BtnShade, BtnResize, BtnCount};
00139 B2Button* button[BtnCount];
00140 TQGridLayout *g;
00141
00142 TQSpacerItem *topSpacer;
00143 TQSpacerItem *bottomSpacer;
00144 TQSpacerItem *leftSpacer;
00145 TQSpacerItem *rightSpacer;
00146 B2Titlebar *titlebar;
00147 int bar_x_ofs;
00148 int in_unobs;
00149 TQTime time;
00150 bool resizable;
00151 };
00152
00153 class B2ClientFactory : public TQObject, public KDecorationFactory
00154 {
00155 public:
00156 B2ClientFactory();
00157 virtual ~B2ClientFactory();
00158 virtual KDecoration *createDecoration(KDecorationBridge *);
00159 virtual bool reset(unsigned long changed);
00160 virtual bool supports( Ability ability );
00161 TQValueList< B2ClientFactory::BorderSize > borderSizes() const;
00162 };
00163
00164 }
00165
00166 #endif