Fix polygon
[kdeartwork.git] / kwin-styles / icewm / icewm.h
blob9f026347ea829aa467b3d769d7ca7224bb05df29
1 /*
2 $Id$
4 Gallium-IceWM themeable KWin client
6 Copyright 2001
7 Karol Szwed <gallium@kde.org>
8 http://gallium.n3.net/
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public
12 License as published by the Free Software Foundation; either
13 version 2 of the License, or (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; see the file COPYING. If not, write to
22 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
23 Boston, MA 02110-1301, USA.
25 -----------------------------------------------------------------------------
26 This client loads most icewm 1.0.X pixmap themes, without taking into account
27 specific font settings for clients, or coloured mouse cursors. Titlebar
28 fonts can be changed via the kde control center. Bi-colour mouse cursors
29 may be added in future if requested by users, as well as theme font support.
30 Any styles using inbuilt icewm titlebar drawing without using pixmaps (e.g.
31 Warp4, win95 etc.) are not fully supported, and may cause drawing errors,
32 as these themes use in-built icewm drawing mechanisms.
34 When a pixmap theme is not present (or a corrupt one is present) then very
35 plain title decorations are painted instead, so that users don't see
36 non-painted window areas where possible ;)
38 At a later date, frame shaping may be added if really requested, and an
39 update to support the latest icewm 1.1.X theme format may be made.
42 #ifndef __KDEGALLIUM_ICEWM_H
43 #define __KDEGALLIUM_ICEWM_H
45 #include <q3button.h>
46 #include <qlayout.h>
47 //Added by qt3to4:
48 #include <QPixmap>
49 #include <QPaintEvent>
50 #include <QGridLayout>
51 #include <QEvent>
52 #include <QBoxLayout>
53 #include <QLabel>
54 #include <QShowEvent>
55 #include <QResizeEvent>
56 #include <QMouseEvent>
57 #include <kpixmap.h>
58 #include <kdecoration.h>
59 #include <kdecorationfactory.h>
60 #include <kcommondecoration.h>
61 #include <q3button.h>
62 class QLabel;
63 class QSpacerItem;
64 class QBoxLayout;
65 class QGridLayout;
67 namespace IceWM {
69 class IceWMClient;
71 // Pixmap group
72 enum { InActive=0, Active };
73 // Pixmap stretching mode
74 enum { Qt::Vertical=0, Qt::Horizontal=1 };
77 // Handles the resetClients() signal from the Options class,
78 // and manages the dynamic pixmaps, configuration and theme changing
79 class ThemeHandler: public KDecorationFactory
81 public:
82 ThemeHandler();
83 ~ThemeHandler();
85 virtual KDecoration* createDecoration( KDecorationBridge* );
86 virtual bool reset( unsigned long changed );
87 virtual bool supports( Ability ability );
89 private:
90 bool initialized;
91 QString themeName;
93 void readConfig();
94 QColor decodeColor( QString& s );
95 bool isFrameValid();
96 void initTheme();
97 void freePixmaps();
98 void freePixmapGroup( QPixmap* p[] );
99 void setPixmap( QPixmap* p[], QString s1, QString s2, bool
100 stretch=false, bool stretchHoriz=true );
101 void setPixmapButton( QPixmap* p[], QString s1, QString s2);
102 QPixmap* stretchPixmap( QPixmap* src, bool stretchHoriz=true,
103 int stretchSize=-1);
104 QPixmap* duplicateValidPixmap( bool act, int size = -1 );
105 void convertButtons( QString& s );
106 QString reverseString( QString s );
110 class IceWMButton : public Q3Button
112 public:
113 IceWMButton( IceWMClient *parent=0, const char *name=0,
114 QPixmap* (*p)[2]=0L, bool isToggle=false,
115 const QString& tip=NULL, const int realizeBtns = Qt::LeftButton );
116 void setTipText(const QString &tip);
117 void usePixmap( QPixmap* (*p)[2] );
118 QSize sizeHint() const;
119 void turnOn( bool isOn );
120 ButtonState last_button;
122 protected:
123 void mousePressEvent( QMouseEvent* e );
124 void mouseReleaseEvent( QMouseEvent* e );
126 void drawButton( QPainter *p );
127 void drawButtonLabel( QPainter * ) {;}
129 private:
130 int m_realizeButtons;
131 IceWMClient* client;
132 QPixmap* (*pix)[2]; // Points to active/inactive pixmap array
136 class IceWMClient : public KDecoration
138 Q_OBJECT
139 public:
140 IceWMClient( KDecorationBridge* bridge, KDecorationFactory* factory );
141 ~IceWMClient();
143 virtual void init();
144 virtual void resize(const QSize&);
145 virtual bool eventFilter( QObject* o, QEvent* e );
147 protected:
148 void resizeEvent( QResizeEvent* );
149 void paintEvent( QPaintEvent* );
150 void showEvent( QShowEvent* );
151 void mouseDoubleClickEvent( QMouseEvent * );
152 virtual void captionChange();
153 virtual void maximizeChange();
154 virtual void shadeChange();
155 virtual void activeChange();
156 // void shadeChange(bool); /* KWin Client class doesn't provide this yet */
157 Position mousePosition( const QPoint& ) const;
158 void renderMenuIcons();
159 void iconChange();
160 virtual void desktopChange( );
161 virtual void borders(int&, int&, int&, int&) const;
162 virtual QSize minimumSize() const;
164 protected slots:
165 void slotMaximize();
166 void menuButtonPressed();
167 void menuButtonReleased();
168 void toggleShade();
170 private:
171 // These are all the icewm button types :)
172 enum Buttons{ BtnSysMenu=0, BtnClose, BtnMaximize, BtnMinimize,
173 BtnHide, BtnRollup, BtnDepth, BtnCount };
175 QString shortenCaption( const QString* s );
176 void calcHiddenButtons();
177 int titleTextWidth( const QString& s );
178 void addClientButtons( const QString& s );
179 QSpacerItem* addPixmapSpacer( QPixmap* p[],
180 QSizePolicy::SizeType = QSizePolicy::Maximum, int hsize = -1 );
182 IceWMButton* button[ IceWMClient::BtnCount ];
183 QPixmap* menuButtonWithIconPix[2];
184 QSpacerItem* titleSpacerJ;
185 QSpacerItem* titleSpacerL;
186 QSpacerItem* titleSpacerS;
187 QSpacerItem* titleSpacerP;
188 QSpacerItem* titlebar;
189 QSpacerItem* titleSpacerM;
190 QSpacerItem* titleSpacerB;
191 QSpacerItem* titleSpacerR;
192 QSpacerItem* titleSpacerQ;
193 QBoxLayout* hb;
194 QGridLayout* grid;
195 bool m_closing;
200 #endif
202 // vim: ts=4