kwin Library API Documentation

keramik.h

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