2001-04-16 14:55:07 +00:00
|
|
|
/*
|
2001-06-04 11:49:35 +00:00
|
|
|
$Id$
|
|
|
|
|
2001-04-16 14:55:07 +00:00
|
|
|
Gallium-IceWM themeable KWin client
|
|
|
|
|
|
|
|
Copyright 2001
|
2001-06-04 11:49:35 +00:00
|
|
|
Karol Szwed <gallium@kde.org>
|
2001-04-16 14:55:07 +00:00
|
|
|
http://gallium.n3.net/
|
|
|
|
|
2001-07-02 05:37:25 +00:00
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; see the file COPYING. If not, write to
|
|
|
|
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA.
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------
|
2001-04-16 14:55:07 +00:00
|
|
|
This client loads most icewm 1.0.X pixmap themes, without taking into account
|
|
|
|
specific font settings for clients, or coloured mouse cursors. Titlebar
|
|
|
|
fonts can be changed via the kde control center. Bi-colour mouse cursors
|
|
|
|
may be added in future if requested by users, as well as theme font support.
|
|
|
|
Any styles using inbuilt icewm titlebar drawing without using pixmaps (e.g.
|
|
|
|
Warp4, win95 etc.) are not fully supported, and may cause drawing errors,
|
|
|
|
as these themes use in-built icewm drawing mechanisms.
|
|
|
|
|
|
|
|
When a pixmap theme is not present (or a corrupt one is present) then very
|
|
|
|
plain title decorations are painted instead, so that users don't see
|
|
|
|
non-painted window areas where possible ;)
|
|
|
|
|
|
|
|
At a later date, frame shaping may be added if really requested, and an
|
|
|
|
update to support the latest icewm 1.1.X theme format may be made.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __KDEGALLIUM_ICEWM_H
|
|
|
|
#define __KDEGALLIUM_ICEWM_H
|
|
|
|
|
|
|
|
#include <qbutton.h>
|
|
|
|
#include <qlayout.h>
|
|
|
|
#include <kpixmap.h>
|
|
|
|
#include "../../client.h"
|
2001-07-01 10:10:17 +00:00
|
|
|
#include "../../kwinbutton.h"
|
2001-04-16 14:55:07 +00:00
|
|
|
class QLabel;
|
|
|
|
class QSpacerItem;
|
2002-08-27 15:12:14 +00:00
|
|
|
class QBoxLayout;
|
2001-04-16 14:55:07 +00:00
|
|
|
class QGridLayout;
|
|
|
|
|
2002-08-27 18:08:20 +00:00
|
|
|
namespace IceWM {
|
|
|
|
|
|
|
|
using namespace KWinInternal;
|
2001-04-16 14:55:07 +00:00
|
|
|
|
|
|
|
// Pixmap group
|
|
|
|
enum { InActive=0, Active };
|
|
|
|
// Pixmap stretching mode
|
|
|
|
enum { Vertical=0, Horizontal=1 };
|
|
|
|
|
|
|
|
|
|
|
|
// Handles the resetClients() signal from the Options class,
|
|
|
|
// and manages the dynamic pixmaps, configuration and theme changing
|
|
|
|
class ThemeHandler: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
ThemeHandler();
|
|
|
|
~ThemeHandler();
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void slotReset();
|
|
|
|
|
|
|
|
private:
|
2002-08-27 18:08:20 +00:00
|
|
|
bool initialized;
|
2001-04-25 10:41:06 +00:00
|
|
|
QString themeName;
|
|
|
|
|
2001-04-16 14:55:07 +00:00
|
|
|
void readConfig();
|
|
|
|
QColor decodeColor( QString& s );
|
|
|
|
bool isFrameValid();
|
|
|
|
void initTheme();
|
|
|
|
void freePixmaps();
|
|
|
|
void freePixmapGroup( QPixmap* p[] );
|
2001-06-04 11:49:35 +00:00
|
|
|
void setPixmap( QPixmap* p[], QString s1, QString s2, bool
|
|
|
|
stretch=false, bool stretchHoriz=true );
|
|
|
|
QPixmap* stretchPixmap( QPixmap* src, bool stretchHoriz=true,
|
|
|
|
int stretchSize=-1);
|
2001-04-25 10:41:06 +00:00
|
|
|
QPixmap* duplicateValidPixmap( bool act, int size = -1 );
|
2001-04-16 14:55:07 +00:00
|
|
|
void convertButtons( QString& s );
|
|
|
|
QString reverseString( QString s );
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-08-27 18:08:20 +00:00
|
|
|
class IceWMButton : public KWinButton
|
2001-04-16 14:55:07 +00:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
IceWMButton( Client *parent=0, const char *name=0,
|
2001-07-01 10:10:17 +00:00
|
|
|
QPixmap* (*p)[2]=0L, bool isToggle=false,
|
|
|
|
const QString& tip=NULL );
|
2001-04-16 14:55:07 +00:00
|
|
|
void usePixmap( QPixmap* (*p)[2] );
|
|
|
|
QSize sizeHint() const;
|
|
|
|
void turnOn( bool isOn );
|
|
|
|
int last_button;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void mousePressEvent( QMouseEvent* e );
|
|
|
|
void mouseReleaseEvent( QMouseEvent* e );
|
|
|
|
|
|
|
|
void drawButton( QPainter *p );
|
|
|
|
void drawButtonLabel( QPainter * ) {;}
|
|
|
|
|
|
|
|
private:
|
2001-07-01 10:10:17 +00:00
|
|
|
Client* client;
|
2001-06-04 11:49:35 +00:00
|
|
|
QPixmap* (*pix)[2]; // Points to active/inactive pixmap array
|
2001-04-16 14:55:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2002-08-27 18:08:20 +00:00
|
|
|
class IceWMClient : public Client
|
2001-04-16 14:55:07 +00:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
IceWMClient( Workspace *ws, WId w, QWidget *parent=0, const char *name=0 );
|
|
|
|
~IceWMClient();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
void resizeEvent( QResizeEvent* );
|
|
|
|
void paintEvent( QPaintEvent* );
|
|
|
|
void showEvent( QShowEvent* );
|
|
|
|
void mouseDoubleClickEvent( QMouseEvent * );
|
|
|
|
void captionChange( const QString& name );
|
|
|
|
void maximizeChange(bool m);
|
|
|
|
void activeChange(bool);
|
2001-06-04 11:49:35 +00:00
|
|
|
// void shadeChange(bool); /* KWin Client class doesn't provide this yet */
|
2001-04-16 14:55:07 +00:00
|
|
|
MousePosition mousePosition( const QPoint& ) const;
|
|
|
|
void renderMenuIcons();
|
|
|
|
void iconChange();
|
2001-06-04 11:49:35 +00:00
|
|
|
void stickyChange(bool on);
|
2001-04-16 14:55:07 +00:00
|
|
|
|
|
|
|
protected slots:
|
|
|
|
void slotMaximize();
|
|
|
|
void menuButtonPressed();
|
|
|
|
|
|
|
|
private:
|
2001-04-24 08:17:17 +00:00
|
|
|
// These are all the icewm button types :)
|
2001-06-04 11:49:35 +00:00
|
|
|
enum Buttons{ BtnSysMenu=0, BtnClose, BtnMaximize, BtnMinimize,
|
|
|
|
BtnHide, BtnRollup, BtnDepth, BtnCount };
|
2001-04-24 08:17:17 +00:00
|
|
|
|
2001-04-25 10:41:06 +00:00
|
|
|
QString shortenCaption( const QString* s );
|
2001-04-24 08:17:17 +00:00
|
|
|
void calcHiddenButtons();
|
2001-04-22 13:00:05 +00:00
|
|
|
int titleTextWidth( const QString& s );
|
|
|
|
void addClientButtons( const QString& s );
|
2001-06-04 11:49:35 +00:00
|
|
|
QSpacerItem* addPixmapSpacer( QPixmap* p[],
|
|
|
|
QSizePolicy::SizeType = QSizePolicy::Maximum, int hsize = -1 );
|
2001-04-16 14:55:07 +00:00
|
|
|
|
|
|
|
IceWMButton* button[ IceWMClient::BtnCount ];
|
|
|
|
QPixmap* menuButtonWithIconPix[2];
|
|
|
|
QSpacerItem* titleSpacerJ;
|
|
|
|
QSpacerItem* titleSpacerL;
|
|
|
|
QSpacerItem* titleSpacerS;
|
|
|
|
QSpacerItem* titleSpacerP;
|
|
|
|
QSpacerItem* titlebar;
|
|
|
|
QSpacerItem* titleSpacerM;
|
|
|
|
QSpacerItem* titleSpacerB;
|
|
|
|
QSpacerItem* titleSpacerR;
|
|
|
|
QSpacerItem* titleSpacerQ;
|
2002-08-27 15:12:14 +00:00
|
|
|
QBoxLayout* hb;
|
2001-04-16 14:55:07 +00:00
|
|
|
QGridLayout* grid;
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|
2001-06-04 11:49:35 +00:00
|
|
|
|
|
|
|
// vim: ts=4
|