2003-10-04 23:55:55 +00:00
|
|
|
/*
|
|
|
|
* Laptop KWin Client
|
|
|
|
*
|
2004-05-21 10:37:36 +00:00
|
|
|
* Ported to the kde3.2 API by Luciano Montanaro <mikelima@cirulla.net>
|
2003-10-04 23:55:55 +00:00
|
|
|
*/
|
2001-06-20 11:17:03 +00:00
|
|
|
#ifndef __KDECLIENT_H
|
|
|
|
#define __KDECLIENT_H
|
|
|
|
|
2003-09-17 08:53:04 +00:00
|
|
|
#include <qbutton.h>
|
2001-06-20 11:17:03 +00:00
|
|
|
#include <qbitmap.h>
|
|
|
|
#include <kpixmap.h>
|
2003-09-17 08:53:04 +00:00
|
|
|
#include <kdecoration.h>
|
|
|
|
#include <kdecorationfactory.h>
|
|
|
|
|
2001-06-20 11:17:03 +00:00
|
|
|
class QLabel;
|
|
|
|
class QSpacerItem;
|
2002-08-27 15:12:14 +00:00
|
|
|
class QBoxLayout;
|
2003-09-17 08:53:04 +00:00
|
|
|
class QGridLayout;
|
2001-06-20 11:17:03 +00:00
|
|
|
|
2002-08-27 18:08:20 +00:00
|
|
|
namespace Laptop {
|
2001-06-20 11:17:03 +00:00
|
|
|
|
2003-09-17 08:53:04 +00:00
|
|
|
class LaptopClient;
|
2002-08-27 18:08:20 +00:00
|
|
|
|
2003-10-11 12:34:09 +00:00
|
|
|
class LaptopButton : public QButton
|
2001-06-20 11:17:03 +00:00
|
|
|
{
|
|
|
|
public:
|
2003-10-11 12:34:09 +00:00
|
|
|
LaptopButton(int w, int h, LaptopClient *parent=0, const char *name=0,
|
2003-11-02 11:03:41 +00:00
|
|
|
const unsigned char *bitmap=NULL, const QString& tip=NULL, const int realizeBtns = LeftButton);
|
2001-06-20 11:17:03 +00:00
|
|
|
void setBitmap(const unsigned char *bitmap);
|
|
|
|
void reset();
|
|
|
|
QSize sizeHint() const;
|
|
|
|
int last_button;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void mousePressEvent( QMouseEvent* e )
|
|
|
|
{
|
|
|
|
last_button = e->button();
|
2003-11-02 11:03:41 +00:00
|
|
|
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), (e->button()&realizeButtons)?LeftButton:NoButton, e->state() );
|
2003-09-17 08:53:04 +00:00
|
|
|
QButton::mousePressEvent( &me );
|
2001-06-20 11:17:03 +00:00
|
|
|
}
|
|
|
|
void mouseReleaseEvent( QMouseEvent* e )
|
|
|
|
{
|
|
|
|
last_button = e->button();
|
2003-11-02 11:03:41 +00:00
|
|
|
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), (e->button()&realizeButtons)?LeftButton:NoButton, e->state() );
|
2003-09-17 08:53:04 +00:00
|
|
|
QButton::mouseReleaseEvent( &me );
|
2001-06-20 11:17:03 +00:00
|
|
|
}
|
|
|
|
virtual void drawButton(QPainter *p);
|
|
|
|
void drawButtonLabel(QPainter *) {}
|
2003-09-17 08:53:04 +00:00
|
|
|
LaptopClient *client;
|
2001-06-20 11:17:03 +00:00
|
|
|
QSize defaultSize;
|
|
|
|
QBitmap deco;
|
2003-11-02 11:03:41 +00:00
|
|
|
int realizeButtons;
|
2001-06-20 11:17:03 +00:00
|
|
|
};
|
|
|
|
|
2003-09-17 08:53:04 +00:00
|
|
|
class LaptopClient : public KDecoration
|
2001-06-20 11:17:03 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
enum Buttons{BtnHelp=0, BtnSticky, BtnMax, BtnIconify, BtnClose};
|
2003-09-17 08:53:04 +00:00
|
|
|
LaptopClient( KDecorationBridge* b, KDecorationFactory* f );
|
2001-06-20 11:17:03 +00:00
|
|
|
~LaptopClient() {}
|
2003-09-17 08:53:04 +00:00
|
|
|
void init();
|
2001-06-20 11:17:03 +00:00
|
|
|
protected:
|
2003-09-17 08:53:04 +00:00
|
|
|
bool eventFilter( QObject* o, QEvent* e );
|
2001-06-20 11:17:03 +00:00
|
|
|
void resizeEvent( QResizeEvent* );
|
|
|
|
void paintEvent( QPaintEvent* );
|
|
|
|
void showEvent( QShowEvent* );
|
|
|
|
void mouseDoubleClickEvent( QMouseEvent* );
|
2003-09-17 08:53:04 +00:00
|
|
|
void captionChange();
|
|
|
|
void maximizeChange();
|
2001-06-20 11:17:03 +00:00
|
|
|
void doShape();
|
2003-09-17 08:53:04 +00:00
|
|
|
void activeChange();
|
2003-12-15 15:10:17 +00:00
|
|
|
Position mousePosition(const QPoint &) const;
|
2003-09-17 08:53:04 +00:00
|
|
|
void desktopChange();
|
|
|
|
void shadeChange();
|
|
|
|
void iconChange();
|
|
|
|
QSize minimumSize() const;
|
|
|
|
void resize( const QSize& );
|
|
|
|
void borders( int&, int&, int&, int& ) const;
|
|
|
|
void reset( unsigned long );
|
2001-06-20 11:17:03 +00:00
|
|
|
void calcHiddenButtons();
|
|
|
|
void updateActiveBuffer();
|
2003-09-17 08:53:04 +00:00
|
|
|
private:
|
|
|
|
bool isTool() const;
|
|
|
|
bool isTransient() const;
|
2001-06-20 11:17:03 +00:00
|
|
|
protected slots:
|
|
|
|
void slotMaximize();
|
|
|
|
private:
|
2003-10-11 12:34:09 +00:00
|
|
|
LaptopButton* button[5];
|
2003-09-17 08:53:04 +00:00
|
|
|
QGridLayout *g;
|
2002-08-27 15:12:14 +00:00
|
|
|
QBoxLayout* hb;
|
2003-09-17 08:53:04 +00:00
|
|
|
QSpacerItem* titlebar;
|
|
|
|
QSpacerItem* spacer;
|
2001-06-20 11:17:03 +00:00
|
|
|
KPixmap activeBuffer;
|
2003-09-17 08:53:04 +00:00
|
|
|
int lastButtonWidth;
|
2001-06-20 11:17:03 +00:00
|
|
|
int lastBufferWidth;
|
2003-09-17 08:53:04 +00:00
|
|
|
bool hiddenItems;
|
|
|
|
bool bufferDirty;
|
|
|
|
};
|
|
|
|
|
|
|
|
class LaptopClientFactory : public QObject, public KDecorationFactory
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
LaptopClientFactory();
|
|
|
|
virtual ~LaptopClientFactory();
|
|
|
|
virtual KDecoration* createDecoration( KDecorationBridge* );
|
|
|
|
virtual bool reset( unsigned long changed );
|
2003-10-02 16:46:13 +00:00
|
|
|
virtual QValueList< BorderSize > borderSizes() const;
|
|
|
|
private:
|
|
|
|
void findPreferredHandleSize();
|
2001-06-20 11:17:03 +00:00
|
|
|
};
|
|
|
|
|
2003-07-26 10:41:28 +00:00
|
|
|
}
|
2001-06-20 11:17:03 +00:00
|
|
|
|
|
|
|
#endif
|