Back to index

kdeartwork  4.3.2
glowclient.h
Go to the documentation of this file.
00001 /***************************************************************************
00002                           glowclient.h  -  description
00003                              -------------------
00004     begin                : Thu Sep 6 2001
00005     copyright            : (C) 2001 by Henning Burchardt
00006     email                : h_burchardt@gmx.net
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef GLOW_CLIENT_H
00019 #define GLOW_CLIENT_H
00020 
00021 #include <vector>
00022 #include <map>
00023 #include <kdecoration.h>
00024 #include <kdecorationfactory.h>
00025 #include <kcommondecoration.h>
00026 //Added by qt3to4:
00027 #include <QPixmap>
00028 #include <QPaintEvent>
00029 #include <QGridLayout>
00030 #include <QEvent>
00031 #include <QBoxLayout>
00032 #include <Q3ValueList>
00033 #include <QShowEvent>
00034 #include <QVBoxLayout>
00035 #include <QResizeEvent>
00036 #include <QMouseEvent>
00037 
00038 class QPixmap;
00039 class QBitmap;
00040 class QTimer;
00041 class QBoxLayout;
00042 class QGridLayout;
00043 class QVBoxLayout;
00044 class QSpacerItem;
00045 
00046 namespace Glow
00047 {
00048 
00049 class GlowButton;
00050 class GlowButtonFactory;
00051 
00052 //-----------------------------------------------------------------------------
00053 // GlowTheme
00054 //-----------------------------------------------------------------------------
00055 
00056 struct GlowTheme
00057 {
00058        QSize buttonSize;
00059        
00060        QString backgroundPixmap;
00061        QString backgroundAlphaPixmap;
00062 
00063        QString stickyOnPixmap;
00064        QString stickyOffPixmap;
00065        QString maximizeOnPixmap;
00066        QString maximizeOffPixmap;
00067        QString helpPixmap;
00068        QString closePixmap;
00069        QString iconifyPixmap;
00070 
00071        QString stickyOnGlowPixmap;
00072        QString stickyOffGlowPixmap;
00073        QString maximizeOnGlowPixmap;
00074        QString maximizeOffGlowPixmap;
00075        QString helpGlowPixmap;
00076        QString closeGlowPixmap;
00077        QString iconifyGlowPixmap;
00078 };
00079 
00080 static GlowTheme default_glow_theme = {
00081        QSize (17, 17),
00082        "background.png", "background_alpha.png",
00083        "stickyon.png", "stickyoff.png",
00084        "maximizeon.png", "maximizeoff.png",
00085        "help.png", "close.png", "iconify.png",
00086        "stickyon_glow.png", "stickyoff_glow.png",
00087        "maximizeon_glow.png", "maximizeoff_glow.png",
00088        "help_glow.png", "close_glow.png", "iconify_glow.png" };
00089 
00090 //-----------------------------------------------------------------------------
00091 // GlowClientConfig
00092 //-----------------------------------------------------------------------------
00093 
00094 class GlowClientConfig
00095 {
00096 public:
00097        GlowClientConfig();
00098 
00099        void load (KDecorationFactory *factory);
00100 
00101        QColor stickyButtonGlowColor;
00102        QColor helpButtonGlowColor;
00103        QColor iconifyButtonGlowColor;
00104        QColor maximizeButtonGlowColor;
00105        QColor closeButtonGlowColor;
00106        bool showResizeHandle;
00107        int titlebarGradientType;
00108        QString themeName;
00109 };
00110 
00111 //-----------------------------------------------------------------------------
00112 // GlowClientGlobals
00113 //-----------------------------------------------------------------------------
00114 
00115 class GlowClientGlobals : public KDecorationFactory
00116 {
00117 public:
00118        enum PixmapType { StickyOn, StickyOff, Help, Iconify, MaximizeOn,
00119               MaximizeOff, Close };
00120 
00121        static GlowClientGlobals *instance();
00122        
00123        ~GlowClientGlobals();
00124 
00125        virtual KDecoration* createDecoration( KDecorationBridge* b );
00126        virtual bool reset( unsigned long changed );
00127     virtual bool supports( Ability ability );
00128        QList< KDecorationDefines::BorderSize >  borderSizes() const;
00129        
00130        QString getPixmapName(PixmapType type, bool isActive);
00131 
00132        GlowTheme * theme() const { return _theme; }
00133        GlowClientConfig * config() const { return _config; }
00134        GlowButtonFactory * buttonFactory() { return _button_factory; }
00135 
00136 private:
00137        static GlowClientGlobals *m_instance;
00138        
00139        GlowTheme * _theme;
00140        GlowClientConfig * _config;
00141        GlowButtonFactory * _button_factory;
00142 
00143        GlowClientGlobals();
00144        void readConfig();
00145        void readTheme ();
00146        bool createPixmaps();
00147        void deletePixmaps();
00148        bool createPixmap(PixmapType type,bool isActive);
00149        const QString getPixmapTypeName(PixmapType type);
00150 };
00151 
00152 //-----------------------------------------------------------------------------
00153 // GlowClient
00154 //-----------------------------------------------------------------------------
00155 
00156 class GlowClient : public KDecoration
00157 {
00158        Q_OBJECT
00159 public:
00160        GlowClient( KDecorationBridge* b, KDecorationFactory* f );
00161        ~GlowClient();
00162        
00163        virtual void init();
00164        virtual void borders( int&, int&, int&, int& ) const;
00165        virtual void resize( const QSize& );
00166        virtual QSize minimumSize() const;
00167 
00168 protected:
00169        virtual void resizeEvent( QResizeEvent * );
00170        virtual void paintEvent( QPaintEvent * );
00171        virtual void showEvent( QShowEvent * );
00172        virtual void mouseDoubleClickEvent( QMouseEvent * );
00173        virtual void maximizeChange();
00174        virtual void activeChange();
00175        virtual void iconChange();
00176        virtual void desktopChange();
00177        virtual void shadeChange();
00178        virtual void captionChange();
00179        virtual Position mousePosition(const QPoint &) const;
00180        virtual bool eventFilter( QObject* o, QEvent* e );
00181 
00182 private:
00183        std::vector<GlowButton*> m_buttonList;
00184        std::vector<GlowButton*> m_leftButtonList;
00185        std::vector<GlowButton*> m_rightButtonList;
00186        GlowButton *m_stickyButton;
00187        GlowButton *m_helpButton;
00188        GlowButton *m_minimizeButton;
00189        GlowButton *m_maximizeButton;
00190        GlowButton *m_closeButton;
00191        QBoxLayout *m_leftButtonLayout;
00192        QBoxLayout *m_rightButtonLayout;
00193        QSpacerItem * _bottom_spacer;
00194        QSpacerItem * _title_spacer;
00195        QVBoxLayout * _main_layout;
00196 
00197        void createButtons();
00198        void updateButtonPositions();
00204        void updateButtonPixmaps();
00205        void resetLayout();
00206        void doShape();
00207        bool isLeft(GlowButton *button);
00208        bool isRight(GlowButton *button);
00209 
00210 protected slots:
00211        void slotMaximize();
00212 };
00213 
00214 } // namespace
00215 
00216 #endif