2003-11-02 11:03:41 +00:00
|
|
|
/*
|
2001-08-22 10:11:06 +00:00
|
|
|
* B-II KWin Client
|
|
|
|
*
|
|
|
|
* Changes:
|
|
|
|
* Customizable button positions by Karol Szwed <gallium@kde.org>
|
2004-05-21 10:37:36 +00:00
|
|
|
* Ported to the kde3.2 API by Luciano Montanaro <mikelima@cirulla.net>
|
2003-11-02 11:03:41 +00:00
|
|
|
*/
|
2001-08-22 10:11:06 +00:00
|
|
|
|
2001-06-19 14:32:08 +00:00
|
|
|
#ifndef __B2CLIENT_H
|
|
|
|
#define __B2CLIENT_H
|
|
|
|
|
2001-08-18 23:44:37 +00:00
|
|
|
#include <qvariant.h>
|
2004-05-22 00:31:07 +00:00
|
|
|
#include <qdatetime.h>
|
2005-07-28 14:59:42 +00:00
|
|
|
#include <q3button.h>
|
2001-06-19 14:32:08 +00:00
|
|
|
#include <qbitmap.h>
|
2005-07-28 14:59:42 +00:00
|
|
|
//Added by qt3to4:
|
|
|
|
#include <QPaintEvent>
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QEvent>
|
|
|
|
#include <QBoxLayout>
|
|
|
|
#include <QShowEvent>
|
|
|
|
#include <QResizeEvent>
|
|
|
|
#include <QMouseEvent>
|
2001-06-19 14:32:08 +00:00
|
|
|
#include <kpixmap.h>
|
2003-09-20 17:44:49 +00:00
|
|
|
#include <kdecoration.h>
|
|
|
|
#include <kdecorationfactory.h>
|
2001-08-22 10:11:06 +00:00
|
|
|
|
|
|
|
class QSpacerItem;
|
2002-08-27 15:12:14 +00:00
|
|
|
class QBoxLayout;
|
2001-06-19 14:32:08 +00:00
|
|
|
class QGridLayout;
|
|
|
|
|
2002-08-27 18:08:20 +00:00
|
|
|
namespace B2 {
|
2001-06-19 14:32:08 +00:00
|
|
|
|
2003-09-20 17:44:49 +00:00
|
|
|
class B2Client;
|
2002-08-27 18:08:20 +00:00
|
|
|
|
2005-07-28 14:59:42 +00:00
|
|
|
class B2Button : public Q3Button
|
2001-06-19 14:32:08 +00:00
|
|
|
{
|
|
|
|
public:
|
2005-07-28 14:59:42 +00:00
|
|
|
B2Button(B2Client *_client=0, QWidget *parent=0, const QString& tip=NULL, const int realizeBtns = Qt::LeftButton);
|
2001-09-08 10:12:23 +00:00
|
|
|
~B2Button() {};
|
2001-07-01 10:10:17 +00:00
|
|
|
|
2001-06-19 14:32:08 +00:00
|
|
|
void setBg(const QColor &c){bg = c;}
|
|
|
|
void setPixmaps(KPixmap *pix, KPixmap *pixDown, KPixmap *iPix,
|
|
|
|
KPixmap *iPixDown);
|
|
|
|
void setPixmaps(int button_id);
|
2005-07-28 14:59:42 +00:00
|
|
|
void setToggle(){setCheckable(true);}
|
2006-02-22 10:47:36 +00:00
|
|
|
void setActive(bool on){setChecked(on);}
|
2001-06-19 14:32:08 +00:00
|
|
|
void setUseMiniIcon(){useMiniIcon = true;}
|
|
|
|
QSize sizeHint() const;
|
|
|
|
QSizePolicy sizePolicy() const;
|
|
|
|
protected:
|
|
|
|
virtual void drawButton(QPainter *p);
|
|
|
|
void drawButtonLabel(QPainter *){;}
|
2003-11-02 11:03:41 +00:00
|
|
|
|
2001-06-19 14:32:08 +00:00
|
|
|
void mousePressEvent( QMouseEvent* e );
|
|
|
|
void mouseReleaseEvent( QMouseEvent* e );
|
2004-05-23 22:59:13 +00:00
|
|
|
private:
|
|
|
|
void enterEvent(QEvent *e);
|
|
|
|
void leaveEvent(QEvent *e);
|
|
|
|
|
|
|
|
bool useMiniIcon;
|
|
|
|
KPixmap *icon[6];
|
|
|
|
QColor bg; //only use one color (the rest is pixmap) so forget QPalette ;)
|
2001-06-19 14:32:08 +00:00
|
|
|
|
|
|
|
public:
|
2003-09-20 17:44:49 +00:00
|
|
|
B2Client* client;
|
2006-03-04 22:27:27 +00:00
|
|
|
Qt::MouseButtons last_button;
|
2003-11-02 11:03:41 +00:00
|
|
|
int realizeButtons;
|
2004-05-23 22:59:13 +00:00
|
|
|
bool hover;
|
2001-06-19 14:32:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class B2Titlebar : public QWidget
|
|
|
|
{
|
2003-09-20 17:44:49 +00:00
|
|
|
friend class B2Client;
|
2001-06-19 14:32:08 +00:00
|
|
|
public:
|
|
|
|
B2Titlebar(B2Client *parent);
|
|
|
|
~B2Titlebar(){;}
|
|
|
|
bool isFullyObscured() const {return isfullyobscured;}
|
|
|
|
void recalcBuffer();
|
2001-08-22 10:11:06 +00:00
|
|
|
QSpacerItem *captionSpacer;
|
2001-06-19 14:32:08 +00:00
|
|
|
protected:
|
|
|
|
void paintEvent( QPaintEvent* );
|
|
|
|
bool x11Event(XEvent *e);
|
|
|
|
void mouseDoubleClickEvent( QMouseEvent * );
|
|
|
|
void mousePressEvent( QMouseEvent * );
|
|
|
|
void mouseReleaseEvent( QMouseEvent * );
|
|
|
|
void mouseMoveEvent(QMouseEvent *);
|
|
|
|
void resizeEvent(QResizeEvent *ev);
|
2003-09-20 17:44:49 +00:00
|
|
|
private:
|
|
|
|
void drawTitlebar(QPainter &p, bool state);
|
2003-11-02 11:03:41 +00:00
|
|
|
|
2003-09-20 17:44:49 +00:00
|
|
|
B2Client *client;
|
2001-06-19 14:32:08 +00:00
|
|
|
QString oldTitle;
|
|
|
|
KPixmap titleBuffer;
|
2003-09-20 17:44:49 +00:00
|
|
|
QPoint moveOffset;
|
2001-06-19 14:32:08 +00:00
|
|
|
bool set_x11mask;
|
|
|
|
bool isfullyobscured;
|
|
|
|
bool shift_move;
|
|
|
|
};
|
|
|
|
|
2003-09-20 17:44:49 +00:00
|
|
|
class B2Client : public KDecoration
|
2001-06-19 14:32:08 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
friend class B2Titlebar;
|
|
|
|
public:
|
2003-09-20 17:44:49 +00:00
|
|
|
B2Client(KDecorationBridge *b, KDecorationFactory *f);
|
2001-06-19 14:32:08 +00:00
|
|
|
~B2Client(){;}
|
2003-09-20 17:44:49 +00:00
|
|
|
void init();
|
2001-06-19 14:32:08 +00:00
|
|
|
void unobscureTitlebar();
|
|
|
|
void titleMoveAbs(int new_ofs);
|
|
|
|
void titleMoveRel(int xdiff);
|
2003-09-21 20:43:44 +00:00
|
|
|
// transparent stuff
|
|
|
|
virtual bool drawbound(const QRect& geom, bool clear);
|
2001-06-19 14:32:08 +00:00
|
|
|
protected:
|
|
|
|
void resizeEvent( QResizeEvent* );
|
|
|
|
void paintEvent( QPaintEvent* );
|
|
|
|
void showEvent( QShowEvent* );
|
|
|
|
void windowWrapperShowEvent( QShowEvent* );
|
2003-09-20 17:44:49 +00:00
|
|
|
void captionChange();
|
|
|
|
void desktopChange();
|
|
|
|
void shadeChange();
|
|
|
|
void activeChange();
|
|
|
|
void maximizeChange();
|
2001-06-19 14:32:08 +00:00
|
|
|
void iconChange();
|
|
|
|
void doShape();
|
2003-12-15 15:10:17 +00:00
|
|
|
Position mousePosition( const QPoint& p ) const;
|
2003-09-20 17:44:49 +00:00
|
|
|
void resize(const QSize&);
|
|
|
|
void borders(int &, int &, int &, int &) const;
|
|
|
|
QSize minimumSize() const;
|
|
|
|
bool eventFilter(QObject *, QEvent *);
|
2001-06-19 14:32:08 +00:00
|
|
|
private slots:
|
|
|
|
void menuButtonPressed();
|
2003-10-15 16:50:29 +00:00
|
|
|
//void slotReset();
|
2001-06-19 14:32:08 +00:00
|
|
|
void maxButtonClicked();
|
2004-05-15 23:15:01 +00:00
|
|
|
void shadeButtonClicked();
|
2004-07-25 13:49:19 +00:00
|
|
|
void resizeButtonPressed();
|
2001-06-19 14:32:08 +00:00
|
|
|
private:
|
2003-11-02 11:03:41 +00:00
|
|
|
void addButtons(const QString& s, const QString tips[],
|
2002-08-27 15:12:14 +00:00
|
|
|
B2Titlebar* tb, QBoxLayout* titleLayout);
|
2001-06-19 14:32:08 +00:00
|
|
|
void positionButtons();
|
2001-08-22 10:11:06 +00:00
|
|
|
void calcHiddenButtons();
|
2004-07-28 16:44:42 +00:00
|
|
|
bool mustDrawHandle() const;
|
2004-06-20 10:03:04 +00:00
|
|
|
|
2001-06-19 14:32:08 +00:00
|
|
|
enum ButtonType{BtnMenu=0, BtnSticky, BtnIconify, BtnMax, BtnClose,
|
2004-06-20 10:03:04 +00:00
|
|
|
BtnHelp, BtnShade, BtnResize, BtnCount};
|
2001-08-22 10:11:06 +00:00
|
|
|
B2Button* button[BtnCount];
|
2001-06-19 14:32:08 +00:00
|
|
|
QGridLayout *g;
|
2005-03-27 14:01:20 +00:00
|
|
|
// Border spacers
|
|
|
|
QSpacerItem *topSpacer;
|
|
|
|
QSpacerItem *bottomSpacer;
|
2003-10-04 18:53:44 +00:00
|
|
|
QSpacerItem *leftSpacer;
|
|
|
|
QSpacerItem *rightSpacer;
|
2001-06-19 14:32:08 +00:00
|
|
|
B2Titlebar *titlebar;
|
2003-09-20 17:44:49 +00:00
|
|
|
int bar_x_ofs;
|
2001-06-19 14:32:08 +00:00
|
|
|
int in_unobs;
|
2004-05-22 00:31:07 +00:00
|
|
|
QTime time;
|
2004-10-25 10:17:59 +00:00
|
|
|
bool resizable;
|
2001-06-19 14:32:08 +00:00
|
|
|
};
|
|
|
|
|
2003-09-20 17:44:49 +00:00
|
|
|
class B2ClientFactory : public QObject, public KDecorationFactory
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
B2ClientFactory();
|
|
|
|
virtual ~B2ClientFactory();
|
|
|
|
virtual KDecoration *createDecoration(KDecorationBridge *);
|
|
|
|
virtual bool reset(unsigned long changed);
|
2004-11-05 15:33:09 +00:00
|
|
|
virtual bool supports( Ability ability );
|
2005-07-28 14:59:42 +00:00
|
|
|
QList< B2ClientFactory::BorderSize > borderSizes() const;
|
2003-09-20 17:44:49 +00:00
|
|
|
};
|
|
|
|
|
2003-07-26 10:41:28 +00:00
|
|
|
}
|
2001-06-19 14:32:08 +00:00
|
|
|
|
|
|
|
#endif
|