kwin Library API Documentation

laptopclient.h

00001 /*
00002  * Laptop KWin Client
00003  *
00004  * Ported to the kde3.2 API by Luciano Montanaro <mikelima@cirulla.net>
00005  */
00006 #ifndef __KDECLIENT_H
00007 #define __KDECLIENT_H
00008 
00009 #include <qbutton.h>
00010 #include <qbitmap.h>
00011 #include <kpixmap.h>
00012 #include <kdecoration.h>
00013 #include <kdecorationfactory.h>
00014 
00015 class QLabel;
00016 class QLayout;
00017 class QSpacerItem;
00018 class QBoxLayout;
00019 class QGridLayout;
00020 
00021 namespace Laptop {
00022 
00023 class LaptopClient;
00024 
00025 class LaptopButton : public QButton
00026 {
00027 public:
00028     LaptopButton(int w, int h, LaptopClient *parent=0, const char *name=0,
00029                  const unsigned char *bitmap=NULL, const QString& tip=NULL, const int realizeBtns = LeftButton);
00030     void setBitmap(const unsigned char *bitmap);
00031     void reset();
00032     QSize sizeHint() const;
00033     ButtonState last_button;
00034 
00035 protected:
00036     void mousePressEvent( QMouseEvent* e )
00037     {
00038     last_button = e->button();
00039     QMouseEvent me ( e->type(), e->pos(), e->globalPos(), (e->button()&realizeButtons)?LeftButton:NoButton, e->state() );
00040     QButton::mousePressEvent( &me );
00041     }
00042     void mouseReleaseEvent( QMouseEvent* e )
00043     {
00044     last_button = e->button();
00045     QMouseEvent me ( e->type(), e->pos(), e->globalPos(), (e->button()&realizeButtons)?LeftButton:NoButton, e->state() );
00046     QButton::mouseReleaseEvent( &me );
00047     }
00048     virtual void drawButton(QPainter *p);
00049     void drawButtonLabel(QPainter *) {}
00050     LaptopClient *client;
00051     QSize defaultSize;
00052     QBitmap deco;
00053     int realizeButtons;
00054 };
00055 
00056 class LaptopClient : public KDecoration
00057 {
00058     Q_OBJECT
00059 public:
00060     enum Buttons{BtnHelp=0, BtnSticky, BtnMax, BtnIconify, BtnClose, BtnTypeCount};
00061     LaptopClient( KDecorationBridge* b, KDecorationFactory* f );
00062     ~LaptopClient();
00063     void init();
00064 protected:
00065     bool eventFilter( QObject* o, QEvent* e );
00066     void resizeEvent( QResizeEvent* );
00067     void paintEvent( QPaintEvent* );
00068     void showEvent( QShowEvent* );
00069     void mouseDoubleClickEvent( QMouseEvent* );
00070     void captionChange();
00071     void maximizeChange();
00072     void doShape();
00073     void activeChange();
00074     Position mousePosition(const QPoint &) const;
00075     void desktopChange();
00076     void shadeChange();
00077     void iconChange();
00078     QSize minimumSize() const;
00079     void resize( const QSize& );
00080     void borders( int&, int&, int&, int& ) const;
00081     void reset( unsigned long );
00082     void calcHiddenButtons();
00083     void updateActiveBuffer();
00084 private:
00085     void addButtons(QBoxLayout* layout, int, const QString& buttons);
00086     bool mustDrawHandle() const;
00087     bool isTool() const;
00088     bool isTransient() const;
00089 protected slots:
00090     void slotMaximize();
00091 private:
00092     LaptopButton* button[BtnTypeCount];
00093     QGridLayout *g;
00094     QBoxLayout* hb;
00095     QSpacerItem* titlebar;
00096     QSpacerItem* spacer;
00097     KPixmap activeBuffer;
00098     int lastButtonWidth;
00099     int lastBufferWidth;
00100     bool hiddenItems;
00101     bool bufferDirty;
00102 };
00103 
00104 class LaptopClientFactory : public QObject, public KDecorationFactory
00105 {
00106 public:
00107     LaptopClientFactory();
00108     virtual ~LaptopClientFactory();
00109     virtual KDecoration* createDecoration( KDecorationBridge* );
00110     virtual bool reset( unsigned long changed );
00111     virtual bool supports( Ability ability );
00112     virtual QValueList< BorderSize > borderSizes() const;
00113 private:
00114     void findPreferredHandleSize();
00115 };
00116 
00117 }
00118 
00119 #endif
KDE Logo
This file is part of the documentation for kwin Library Version 3.4.3.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Nov 4 00:48:56 2005 by doxygen 1.4.4 written by Dimitri van Heesch, © 1997-2003