kwin Library API Documentation

kdedefault.h

00001 /*
00002  *
00003  *  KDE2 Default KWin client
00004  *
00005  *  Copyright (C) 1999, 2001 Daniel Duley <mosfet@kde.org>
00006  *  Matthias Ettrich <ettrich@kde.org>
00007  *  Karol Szwed <gallium@kde.org>
00008  *
00009  *  Draws mini titlebars for tool windows.
00010  *  Many features are now customizable.
00011  */
00012 
00013 #ifndef _KDE_DEFAULT_H
00014 #define _KDE_DEFAULT_H
00015 
00016 #include <qbutton.h>
00017 #include <qbitmap.h>
00018 #include <qdatetime.h>
00019 #include <kpixmap.h>
00020 #include <kdecoration.h>
00021 #include <kdecorationfactory.h>
00022 
00023 class QSpacerItem;
00024 class QBoxLayout;
00025 class QGridLayout;
00026 
00027 namespace Default {
00028 
00029 class KDEDefaultClient;
00030 
00031 class KDEDefaultHandler: public KDecorationFactory
00032 {
00033     public:
00034         KDEDefaultHandler();
00035         ~KDEDefaultHandler();
00036                 KDecoration* createDecoration( KDecorationBridge* b );
00037         bool reset( unsigned long changed );
00038         virtual QValueList< BorderSize > borderSizes() const;
00039         virtual bool supports( Ability ability );
00040 
00041     private:
00042         unsigned long readConfig( bool update );
00043         void createPixmaps();
00044         void freePixmaps();
00045         void drawButtonBackground(KPixmap *pix,
00046                 const QColorGroup &g, bool sunken);
00047 };
00048 
00049 
00050 class KDEDefaultButton : public QButton, public KDecorationDefines
00051 {
00052     public:
00053         KDEDefaultButton(KDEDefaultClient *parent=0, const char *name=0,
00054              bool largeButton=true, bool isLeftButton=true,
00055              bool isStickyButton=false, const unsigned char *bitmap=NULL,
00056              const QString& tip=NULL, const int realizeBtns = LeftButton);
00057         ~KDEDefaultButton();
00058 
00059         ButtonState last_button;
00060         void turnOn( bool isOn );
00061         void setBitmap(const unsigned char *bitmap);
00062         QSize sizeHint() const;
00063 
00064     protected:
00065         void enterEvent(QEvent *);
00066         void leaveEvent(QEvent *);
00067         void mousePressEvent( QMouseEvent* e );
00068         void mouseReleaseEvent( QMouseEvent* e );
00069         void drawButton(QPainter *p);
00070         void drawButtonLabel(QPainter*) {;}
00071 
00072         QBitmap* deco;
00073         bool    large;
00074         bool    isLeft;
00075         bool    isSticky;
00076         bool    isMouseOver;
00077         KDEDefaultClient* client;
00078 
00079         int realizeButtons;
00080 };
00081 
00082 
00083 class KDEDefaultClient : public KDecoration
00084 {
00085     Q_OBJECT
00086 
00087     public:
00088         KDEDefaultClient( KDecorationBridge* b, KDecorationFactory* f );
00089         ~KDEDefaultClient() {;}
00090                 void init();
00091                 void borders( int&, int&, int&, int& ) const;
00092                 void resize( const QSize& );
00093                 QSize minimumSize() const;
00094                 void reset( unsigned long changed );
00095 
00096     protected:
00097                 bool eventFilter( QObject*, QEvent* );
00098         void resizeEvent( QResizeEvent* );
00099         void paintEvent( QPaintEvent* );
00100         void showEvent( QShowEvent* );
00101         void mouseDoubleClickEvent( QMouseEvent * );
00102         void captionChange();
00103         void maximizeChange();
00104         void activeChange();
00105         void iconChange();
00106         void desktopChange();
00107                 void shadeChange();
00108         Position mousePosition(const QPoint &) const;
00109 
00110     protected slots:
00111         void slotMaximize();
00112                 void slotAbove();
00113                 void slotBelow();
00114                 void slotShade();
00115         void menuButtonPressed();
00116             void menuButtonReleased();
00117                 void keepAboveChange( bool );
00118                 void keepBelowChange( bool );
00119 
00120     private:
00121         void doShape();
00122         void calcHiddenButtons();
00123         bool mustDrawHandle() const;
00124         void addClientButtons( const QString& s, bool isLeft=true );
00125                 bool isTool() const;
00126 
00127         enum Buttons{ BtnHelp=0, BtnMax, BtnIconify, BtnClose,
00128             BtnMenu, BtnSticky, BtnAbove, BtnBelow, BtnShade, BtnCount };
00129         KDEDefaultButton* button[ KDEDefaultClient::BtnCount ];
00130         int           lastButtonWidth;
00131         int           titleHeight;
00132         bool          largeButtons;
00133         QGridLayout*  g;
00134         QBoxLayout*   hb;
00135         QSpacerItem*  titlebar;
00136         QSpacerItem*  spacer;
00137         bool m_closing;
00138 };
00139 
00140 }
00141 
00142 #endif
00143 // vim: ts=4
KDE Logo
This file is part of the documentation for kwin Library Version 3.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jun 14 16:47:03 2006 by doxygen 1.4.4 written by Dimitri van Heesch, © 1997-2003