4 Gallium-IceWM themeable KWin client
7 Karol Szwed <gallium@kde.org>
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
49 #include <QPaintEvent>
50 #include <QGridLayout>
55 #include <QResizeEvent>
56 #include <QMouseEvent>
58 #include <kdecoration.h>
59 #include <kdecorationfactory.h>
60 #include <kcommondecoration.h>
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
85 virtual KDecoration
* createDecoration( KDecorationBridge
* );
86 virtual bool reset( unsigned long changed
);
87 virtual bool supports( Ability ability
);
94 QColor
decodeColor( QString
& s
);
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,
104 QPixmap
* duplicateValidPixmap( bool act
, int size
= -1 );
105 void convertButtons( QString
& s
);
106 QString
reverseString( QString s
);
110 class IceWMButton
: public Q3Button
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
;
123 void mousePressEvent( QMouseEvent
* e
);
124 void mouseReleaseEvent( QMouseEvent
* e
);
126 void drawButton( QPainter
*p
);
127 void drawButtonLabel( QPainter
* ) {;}
130 int m_realizeButtons
;
132 QPixmap
* (*pix
)[2]; // Points to active/inactive pixmap array
136 class IceWMClient
: public KDecoration
140 IceWMClient( KDecorationBridge
* bridge
, KDecorationFactory
* factory
);
144 virtual void resize(const QSize
&);
145 virtual bool eventFilter( QObject
* o
, QEvent
* e
);
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();
160 virtual void desktopChange( );
161 virtual void borders(int&, int&, int&, int&) const;
162 virtual QSize
minimumSize() const;
166 void menuButtonPressed();
167 void menuButtonReleased();
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
;