2007-11-29 15:32:50 +00:00
|
|
|
/*********************************************************************
|
|
|
|
B-II KWin Client
|
2009-11-18 12:48:48 +00:00
|
|
|
|
2007-11-29 15:32:50 +00:00
|
|
|
Changes:
|
|
|
|
Customizable button positions by Karol Szwed <gallium@kde.org>
|
|
|
|
Ported to the kde3.2 API by Luciano Montanaro <mikelima@cirulla.net>
|
2009-11-18 12:48:48 +00:00
|
|
|
|
|
|
|
Added option to turn off titlebar autorelocation
|
|
|
|
Copyright (c) 2009 Jussi Kekkonen <tmt@ubuntu.com>
|
2007-11-29 15:32:50 +00:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*********************************************************************/
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
#ifndef __B2CLIENT_H
|
|
|
|
#define __B2CLIENT_H
|
|
|
|
|
|
|
|
#include <QDateTime>
|
2007-04-30 12:26:01 +00:00
|
|
|
#include <QAbstractButton>
|
2007-04-29 17:35:43 +00:00
|
|
|
//Added by qt3to4:
|
|
|
|
#include <QPaintEvent>
|
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QEvent>
|
|
|
|
#include <QBoxLayout>
|
|
|
|
#include <QShowEvent>
|
|
|
|
#include <QResizeEvent>
|
|
|
|
#include <QMouseEvent>
|
2007-04-30 12:26:01 +00:00
|
|
|
#include <QBitmap>
|
2007-04-29 17:35:43 +00:00
|
|
|
#include <QPixmap>
|
|
|
|
#include <kdecoration.h>
|
|
|
|
#include <kdecorationfactory.h>
|
|
|
|
|
|
|
|
class QSpacerItem;
|
|
|
|
class QBoxLayout;
|
|
|
|
class QGridLayout;
|
|
|
|
|
|
|
|
namespace B2 {
|
|
|
|
|
|
|
|
class B2Client;
|
|
|
|
|
2007-04-30 12:26:01 +00:00
|
|
|
class B2Button : public QAbstractButton
|
2007-04-29 17:35:43 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-09-02 19:11:09 +00:00
|
|
|
explicit B2Button(B2Client *_client=0, QWidget *parent=0, const QString& tip=NULL, const int realizeBtns = Qt::LeftButton);
|
2007-04-30 12:23:20 +00:00
|
|
|
~B2Button() {}
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void setBg(const QColor &c){bg = c;}
|
|
|
|
void setPixmaps(QPixmap *pix, QPixmap *pixDown, QPixmap *iPix,
|
|
|
|
QPixmap *iPixDown);
|
|
|
|
void setPixmaps(int button_id);
|
|
|
|
void setToggle(){setCheckable(true);}
|
|
|
|
void setActive(bool on){setChecked(on);}
|
|
|
|
void setUseMiniIcon(){useMiniIcon = true;}
|
|
|
|
QSize sizeHint() const;
|
|
|
|
QSizePolicy sizePolicy() const;
|
|
|
|
protected:
|
2007-04-30 12:26:01 +00:00
|
|
|
virtual void paintEvent(QPaintEvent *e);
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
void mousePressEvent( QMouseEvent* e );
|
|
|
|
void mouseReleaseEvent( QMouseEvent* e );
|
|
|
|
private:
|
|
|
|
void enterEvent(QEvent *e);
|
|
|
|
void leaveEvent(QEvent *e);
|
|
|
|
|
|
|
|
bool useMiniIcon;
|
|
|
|
QPixmap *icon[6];
|
|
|
|
QColor bg; //only use one color (the rest is pixmap) so forget QPalette ;)
|
|
|
|
|
|
|
|
public:
|
|
|
|
B2Client* client;
|
|
|
|
Qt::MouseButtons last_button;
|
|
|
|
int realizeButtons;
|
|
|
|
bool hover;
|
|
|
|
};
|
|
|
|
|
|
|
|
class B2Titlebar : public QWidget
|
|
|
|
{
|
|
|
|
friend class B2Client;
|
|
|
|
public:
|
|
|
|
B2Titlebar(B2Client *parent);
|
|
|
|
~B2Titlebar(){;}
|
|
|
|
bool isFullyObscured() const {return isfullyobscured;}
|
|
|
|
void recalcBuffer();
|
|
|
|
QSpacerItem *captionSpacer;
|
|
|
|
protected:
|
2007-06-22 22:54:23 +00:00
|
|
|
void paintEvent(QPaintEvent *e);
|
2007-04-29 17:35:43 +00:00
|
|
|
bool x11Event(XEvent *e);
|
2007-06-22 22:54:23 +00:00
|
|
|
void mouseDoubleClickEvent(QMouseEvent *e);
|
|
|
|
void mousePressEvent(QMouseEvent *e);
|
|
|
|
void mouseReleaseEvent(QMouseEvent *e);
|
|
|
|
void mouseMoveEvent(QMouseEvent *e);
|
|
|
|
void resizeEvent(QResizeEvent *e);
|
|
|
|
void wheelEvent(QWheelEvent *e);
|
2007-04-29 17:35:43 +00:00
|
|
|
private:
|
|
|
|
void drawTitlebar(QPainter &p, bool state);
|
|
|
|
|
|
|
|
B2Client *client;
|
|
|
|
QString oldTitle;
|
|
|
|
QPixmap titleBuffer;
|
|
|
|
QPoint moveOffset;
|
|
|
|
bool set_x11mask;
|
|
|
|
bool isfullyobscured;
|
|
|
|
bool shift_move;
|
|
|
|
};
|
|
|
|
|
|
|
|
class B2Client : public KDecoration
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
friend class B2Titlebar;
|
|
|
|
public:
|
|
|
|
B2Client(KDecorationBridge *b, KDecorationFactory *f);
|
|
|
|
~B2Client(){;}
|
|
|
|
void init();
|
|
|
|
void unobscureTitlebar();
|
|
|
|
void titleMoveAbs(int new_ofs);
|
|
|
|
void titleMoveRel(int xdiff);
|
|
|
|
// transparent stuff
|
|
|
|
virtual bool drawbound(const QRect& geom, bool clear);
|
|
|
|
protected:
|
|
|
|
void resizeEvent( QResizeEvent* );
|
|
|
|
void paintEvent( QPaintEvent* );
|
|
|
|
void showEvent( QShowEvent* );
|
|
|
|
void windowWrapperShowEvent( QShowEvent* );
|
|
|
|
void captionChange();
|
|
|
|
void desktopChange();
|
|
|
|
void shadeChange();
|
|
|
|
void activeChange();
|
|
|
|
void maximizeChange();
|
|
|
|
void iconChange();
|
|
|
|
void doShape();
|
|
|
|
Position mousePosition( const QPoint& p ) const;
|
|
|
|
void resize(const QSize&);
|
|
|
|
void borders(int &, int &, int &, int &) const;
|
|
|
|
QSize minimumSize() const;
|
|
|
|
bool eventFilter(QObject *, QEvent *);
|
|
|
|
private slots:
|
|
|
|
void menuButtonPressed();
|
|
|
|
//void slotReset();
|
|
|
|
void maxButtonClicked();
|
|
|
|
void shadeButtonClicked();
|
|
|
|
void resizeButtonPressed();
|
|
|
|
private:
|
|
|
|
void addButtons(const QString& s, const QString tips[],
|
|
|
|
B2Titlebar* tb, QBoxLayout* titleLayout);
|
|
|
|
void positionButtons();
|
|
|
|
void calcHiddenButtons();
|
|
|
|
bool mustDrawHandle() const;
|
2009-11-18 12:48:48 +00:00
|
|
|
bool autoMoveTitlebar() const;
|
2007-04-29 17:35:43 +00:00
|
|
|
|
|
|
|
enum ButtonType{BtnMenu=0, BtnSticky, BtnIconify, BtnMax, BtnClose,
|
|
|
|
BtnHelp, BtnShade, BtnResize, BtnCount};
|
|
|
|
B2Button* button[BtnCount];
|
|
|
|
QGridLayout *g;
|
|
|
|
// Border spacers
|
|
|
|
QSpacerItem *topSpacer;
|
|
|
|
QSpacerItem *bottomSpacer;
|
|
|
|
QSpacerItem *leftSpacer;
|
|
|
|
QSpacerItem *rightSpacer;
|
|
|
|
B2Titlebar *titlebar;
|
|
|
|
int bar_x_ofs;
|
|
|
|
int in_unobs;
|
|
|
|
QTime time;
|
|
|
|
bool resizable;
|
|
|
|
};
|
|
|
|
|
|
|
|
class B2ClientFactory : public QObject, public KDecorationFactory
|
|
|
|
{
|
2007-05-13 17:47:20 +00:00
|
|
|
Q_OBJECT
|
2007-04-29 17:35:43 +00:00
|
|
|
public:
|
|
|
|
B2ClientFactory();
|
|
|
|
virtual ~B2ClientFactory();
|
|
|
|
virtual KDecoration *createDecoration(KDecorationBridge *);
|
|
|
|
virtual bool reset(unsigned long changed);
|
2007-11-01 16:07:38 +00:00
|
|
|
virtual bool supports( Ability ability ) const;
|
2007-04-29 17:35:43 +00:00
|
|
|
QList< B2ClientFactory::BorderSize > borderSizes() const;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|