kwin Library API Documentation

keramik.h

00001 /*
00002  * $Id: keramik.h,v 1.12 2003/12/15 15:10:16 lunakl Exp $
00003  *
00004  * Keramik KWin client (version 0.8)
00005  *
00006  * Copyright (C) 2002 Fredrik Höglund <fredrik@kde.org>
00007  *
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the license, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; see the file COPYING.  If not, write to
00020  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00021  * Boston, MA 02111-1307, USA.
00022  */
00023 
00024 
00025 #ifndef __KERAMIK_H
00026 #define __KERAMIK_H
00027 
00028 #include <qbutton.h>
00029 #include <kdecoration.h>
00030 #include <kdecorationfactory.h>
00031 
00032 #include "tiles.h"
00033 
00034 class QSpacerItem;
00035 
00036 namespace Keramik {
00037 
00038     enum TilePixmap  { TitleLeft=0, TitleCenter, TitleRight,
00039                        CaptionSmallLeft, CaptionSmallCenter, CaptionSmallRight,
00040                        CaptionLargeLeft, CaptionLargeCenter, CaptionLargeRight,
00041                        GrabBarLeft, GrabBarCenter, GrabBarRight,
00042                        BorderLeft, BorderRight, NumTiles };
00043 
00044     enum Button      { MenuButton=0, OnAllDesktopsButton, HelpButton, MinButton,
00045                        MaxButton, CloseButton, NumButtons };
00046 
00047     enum ButtonDeco  { Menu=0, OnAllDesktops, NotOnAllDesktops, Help, Minimize, Maximize,
00048                        Restore, Close, NumButtonDecos };
00049 
00050     struct SettingsCache
00051     {
00052         bool largeGrabBars:1;
00053         bool smallCaptionBubbles:1;
00054     };
00055 
00056     class KeramikHandler : public KDecorationFactory
00057     {
00058         public:
00059             KeramikHandler();
00060             ~KeramikHandler();
00061 
00062             virtual QValueList< BorderSize > borderSizes() const;
00063             virtual bool reset( unsigned long changed );
00064                         virtual KDecoration* createDecoration( KDecorationBridge* );
00065 
00066             bool showAppIcons() const        { return showIcons; }
00067             bool useShadowedText() const     { return shadowedText; }
00068             bool largeCaptionBubbles() const { return !smallCaptionBubbles; }
00069 
00070             int titleBarHeight( bool large ) const {
00071                 return ( large ? activeTiles[CaptionLargeCenter]->height()
00072                         : activeTiles[CaptionSmallCenter]->height() );
00073             }
00074 
00075             int grabBarHeight() const
00076                 { return activeTiles[GrabBarCenter]->height(); }
00077 
00078             const QPixmap *roundButton() const  { return titleButtonRound; }
00079             const QPixmap *squareButton() const { return titleButtonSquare; }
00080             const QBitmap *buttonDeco( ButtonDeco deco ) const
00081                 { return buttonDecos[ deco ]; }
00082 
00083             inline const QPixmap *tile( TilePixmap tilePix, bool active ) const;
00084 
00085         private:
00086             void readConfig();
00087             void createPixmaps();
00088             void destroyPixmaps();
00089 
00090             void addWidth  (int width,  QPixmap *&pix, bool left, QPixmap *bottomPix);
00091             void addHeight (int height, QPixmap *&pix);
00092             void flip( QPixmap *&, QPixmap *& );
00093             void flip( QPixmap *& );
00094             void pretile( QPixmap *&, int, Qt::Orientation );
00095             QPixmap *composite( QImage *, QImage * );
00096             QImage  *loadImage( const QString &, const QColor & );
00097             QPixmap *loadPixmap( const QString &, const QColor & );
00098 
00099             bool showIcons:1, shadowedText:1,
00100                 smallCaptionBubbles:1, largeGrabBars:1;
00101             SettingsCache *settings_cache;
00102             KeramikImageDb *imageDb;
00103 
00104             QPixmap *activeTiles[ NumTiles ];
00105             QPixmap *inactiveTiles[ NumTiles ];
00106             QBitmap *buttonDecos[ NumButtonDecos ];
00107 
00108             QPixmap *titleButtonRound, *titleButtonSquare;
00109 
00110     }; // class KeramikHandler
00111 
00112     class KeramikClient;
00113     class KeramikButton : public QButton
00114     {
00115         public:
00116             KeramikButton( KeramikClient *, const char *, Button, const QString &, const int realizeBtns = LeftButton );
00117             ~KeramikButton();
00118 
00119             int lastButton() const { return lastbutton; }
00120 
00121         private:
00122             void enterEvent( QEvent * );
00123             void leaveEvent( QEvent * );
00124             void mousePressEvent( QMouseEvent * );
00125             void mouseReleaseEvent( QMouseEvent * );
00126             void drawButton( QPainter * );
00127 
00128         private:
00129             KeramikClient *client;
00130             Button button;
00131             bool hover;
00132             int lastbutton;
00133             int realizeButtons;
00134     }; // class KeramikButton
00135 
00136 
00137     class KeramikClient : public KDecoration
00138     {
00139         Q_OBJECT
00140 
00141         public:
00142 
00143             KeramikClient( KDecorationBridge* bridge, KDecorationFactory* factory );
00144             ~KeramikClient();
00145                         virtual void init();
00146             virtual void reset( unsigned long changed );
00147             virtual Position mousePosition( const QPoint& p ) const;
00148                 virtual void borders( int& left, int& right, int& top, int& bottom ) const;
00149             virtual void resize( const QSize& s );
00150             virtual QSize minimumSize() const;
00151             virtual bool eventFilter( QObject* o, QEvent* e );
00152             virtual void activeChange();
00153             virtual void captionChange();
00154                         virtual void maximizeChange();
00155                         virtual void desktopChange();
00156                         virtual void shadeChange() {};
00157 
00158         private:
00159             void createLayout();
00160             void addButtons( QBoxLayout*, const QString & );
00161             void updateMask(); // FRAME
00162             void updateCaptionBuffer();
00163             void iconChange();
00164             void resizeEvent( QResizeEvent *); // FRAME
00165             void paintEvent( QPaintEvent *); // FRAME
00166             void mouseDoubleClickEvent( QMouseEvent * ); // FRAME
00167             int width() const { return widget()->width(); }
00168             int height() const { return widget()->height(); }
00169 
00170             void calculateCaptionRect();
00171 
00172             inline bool maximizedVertical() const {
00173                 return ( maximizeMode() & MaximizeVertical );
00174             }
00175 
00176         private slots:
00177             void menuButtonPressed();
00178             void slotMaximize();
00179 
00180         private:
00181             QSpacerItem   *topSpacer, *titlebar;
00182             KeramikButton *button[ NumButtons ];
00183             QRect          captionRect;
00184             QPixmap        captionBuffer;
00185             QPixmap       *activeIcon, *inactiveIcon;
00186             bool           captionBufferDirty:1, maskDirty:1;
00187             bool           largeCaption:1, largeTitlebar:1;
00188     }; // class KeramikClient
00189 
00190 } // namespace Keramik
00191 
00192 #endif // ___KERAMIK_H
00193 
00194 // vim: set noet ts=4 sw=4:
KDE Logo
This file is part of the documentation for kwin Library Version 3.2.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Mar 5 04:41:14 2004 by doxygen 1.3.6-20040222 written by Dimitri van Heesch, © 1997-2003