2002-05-17 16:33:48 +00:00
|
|
|
|
/*
|
2003-09-16 19:40:07 +00:00
|
|
|
|
*
|
2002-06-29 22:25:38 +00:00
|
|
|
|
* Keramik KWin client (version 0.8)
|
2002-05-17 16:33:48 +00:00
|
|
|
|
*
|
|
|
|
|
* Copyright (C) 2002 Fredrik H<EFBFBD>glund <fredrik@kde.org>
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __KERAMIK_H
|
|
|
|
|
#define __KERAMIK_H
|
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
#include <qbutton.h>
|
|
|
|
|
#include <kdecoration.h>
|
|
|
|
|
#include <kdecorationfactory.h>
|
|
|
|
|
|
2002-08-31 22:37:35 +00:00
|
|
|
|
#include "tiles.h"
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
class QSpacerItem;
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
|
|
|
|
namespace Keramik {
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
enum TilePixmap { TitleLeft=0, TitleCenter, TitleRight,
|
2002-06-29 22:25:38 +00:00
|
|
|
|
CaptionSmallLeft, CaptionSmallCenter, CaptionSmallRight,
|
|
|
|
|
CaptionLargeLeft, CaptionLargeCenter, CaptionLargeRight,
|
|
|
|
|
GrabBarLeft, GrabBarCenter, GrabBarRight,
|
|
|
|
|
BorderLeft, BorderRight, NumTiles };
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
enum Button { MenuButton=0, OnAllDesktopsButton, HelpButton, MinButton,
|
2004-07-22 11:23:28 +00:00
|
|
|
|
MaxButton, CloseButton, AboveButton, BelowButton, ShadeButton,
|
|
|
|
|
NumButtons };
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
enum ButtonDeco { Menu=0, OnAllDesktops, NotOnAllDesktops, Help, Minimize, Maximize,
|
2004-07-22 11:23:28 +00:00
|
|
|
|
Restore, Close, AboveOn, AboveOff, BelowOn, BelowOff, ShadeOn, ShadeOff,
|
|
|
|
|
NumButtonDecos };
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
struct SettingsCache
|
|
|
|
|
{
|
2002-09-01 22:50:34 +00:00
|
|
|
|
bool largeGrabBars:1;
|
2003-09-28 09:59:11 +00:00
|
|
|
|
bool smallCaptionBubbles:1;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
};
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2003-09-18 17:07:49 +00:00
|
|
|
|
class KeramikHandler : public KDecorationFactory
|
|
|
|
|
{
|
2002-05-17 16:33:48 +00:00
|
|
|
|
public:
|
|
|
|
|
KeramikHandler();
|
|
|
|
|
~KeramikHandler();
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2003-09-28 09:59:11 +00:00
|
|
|
|
virtual QValueList< BorderSize > borderSizes() const;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
virtual bool reset( unsigned long changed );
|
|
|
|
|
virtual KDecoration* createDecoration( KDecorationBridge* );
|
2004-11-05 15:33:09 +00:00
|
|
|
|
virtual bool supports( Ability ability );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-06-29 22:25:38 +00:00
|
|
|
|
bool showAppIcons() const { return showIcons; }
|
|
|
|
|
bool useShadowedText() const { return shadowedText; }
|
|
|
|
|
bool largeCaptionBubbles() const { return !smallCaptionBubbles; }
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-06-29 22:25:38 +00:00
|
|
|
|
int titleBarHeight( bool large ) const {
|
|
|
|
|
return ( large ? activeTiles[CaptionLargeCenter]->height()
|
|
|
|
|
: activeTiles[CaptionSmallCenter]->height() );
|
|
|
|
|
}
|
2002-09-01 22:50:34 +00:00
|
|
|
|
|
|
|
|
|
int grabBarHeight() const
|
|
|
|
|
{ return activeTiles[GrabBarCenter]->height(); }
|
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
const QPixmap *roundButton() const { return titleButtonRound; }
|
|
|
|
|
const QPixmap *squareButton() const { return titleButtonSquare; }
|
|
|
|
|
const QBitmap *buttonDeco( ButtonDeco deco ) const
|
|
|
|
|
{ return buttonDecos[ deco ]; }
|
|
|
|
|
|
|
|
|
|
inline const QPixmap *tile( TilePixmap tilePix, bool active ) const;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void readConfig();
|
|
|
|
|
void createPixmaps();
|
|
|
|
|
void destroyPixmaps();
|
|
|
|
|
|
2003-09-28 09:59:11 +00:00
|
|
|
|
void addWidth (int width, QPixmap *&pix, bool left, QPixmap *bottomPix);
|
|
|
|
|
void addHeight (int height, QPixmap *&pix);
|
2002-05-17 16:33:48 +00:00
|
|
|
|
void flip( QPixmap *&, QPixmap *& );
|
|
|
|
|
void flip( QPixmap *& );
|
2002-06-24 18:33:20 +00:00
|
|
|
|
void pretile( QPixmap *&, int, Qt::Orientation );
|
|
|
|
|
QPixmap *composite( QImage *, QImage * );
|
|
|
|
|
QImage *loadImage( const QString &, const QColor & );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
QPixmap *loadPixmap( const QString &, const QColor & );
|
|
|
|
|
|
2002-09-01 22:50:34 +00:00
|
|
|
|
bool showIcons:1, shadowedText:1,
|
|
|
|
|
smallCaptionBubbles:1, largeGrabBars:1;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
SettingsCache *settings_cache;
|
2002-08-31 22:37:35 +00:00
|
|
|
|
KeramikImageDb *imageDb;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
QPixmap *activeTiles[ NumTiles ];
|
|
|
|
|
QPixmap *inactiveTiles[ NumTiles ];
|
|
|
|
|
QBitmap *buttonDecos[ NumButtonDecos ];
|
|
|
|
|
|
|
|
|
|
QPixmap *titleButtonRound, *titleButtonSquare;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}; // class KeramikHandler
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
|
|
|
|
class KeramikClient;
|
|
|
|
|
class KeramikButton : public QButton
|
2002-05-17 16:33:48 +00:00
|
|
|
|
{
|
|
|
|
|
public:
|
2003-11-02 11:03:41 +00:00
|
|
|
|
KeramikButton( KeramikClient *, const char *, Button, const QString &, const int realizeBtns = LeftButton );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
~KeramikButton();
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2004-07-22 15:17:54 +00:00
|
|
|
|
ButtonState lastButton() const { return lastbutton; }
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
private:
|
|
|
|
|
void enterEvent( QEvent * );
|
|
|
|
|
void leaveEvent( QEvent * );
|
|
|
|
|
void mousePressEvent( QMouseEvent * );
|
|
|
|
|
void mouseReleaseEvent( QMouseEvent * );
|
|
|
|
|
void drawButton( QPainter * );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
private:
|
2003-09-16 19:40:07 +00:00
|
|
|
|
KeramikClient *client;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
Button button;
|
|
|
|
|
bool hover;
|
2004-07-22 15:17:54 +00:00
|
|
|
|
ButtonState lastbutton;
|
2003-11-02 11:03:41 +00:00
|
|
|
|
int realizeButtons;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}; // class KeramikButton
|
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
|
|
|
|
class KeramikClient : public KDecoration
|
2002-05-17 16:33:48 +00:00
|
|
|
|
{
|
2003-09-18 17:07:49 +00:00
|
|
|
|
Q_OBJECT
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
public:
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
|
|
|
|
KeramikClient( KDecorationBridge* bridge, KDecorationFactory* factory );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
~KeramikClient();
|
2003-09-16 19:40:07 +00:00
|
|
|
|
virtual void init();
|
2003-09-18 17:07:49 +00:00
|
|
|
|
virtual void reset( unsigned long changed );
|
2003-12-15 15:10:17 +00:00
|
|
|
|
virtual Position mousePosition( const QPoint& p ) const;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
virtual void borders( int& left, int& right, int& top, int& bottom ) const;
|
|
|
|
|
virtual void resize( const QSize& s );
|
|
|
|
|
virtual QSize minimumSize() const;
|
|
|
|
|
virtual bool eventFilter( QObject* o, QEvent* e );
|
|
|
|
|
virtual void activeChange();
|
|
|
|
|
virtual void captionChange();
|
|
|
|
|
virtual void maximizeChange();
|
|
|
|
|
virtual void desktopChange();
|
2004-07-22 11:23:28 +00:00
|
|
|
|
virtual void shadeChange();
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
private:
|
2003-09-16 19:40:07 +00:00
|
|
|
|
void createLayout();
|
2002-08-27 15:12:14 +00:00
|
|
|
|
void addButtons( QBoxLayout*, const QString & );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
void updateMask(); // FRAME
|
2002-05-17 16:33:48 +00:00
|
|
|
|
void updateCaptionBuffer();
|
|
|
|
|
void iconChange();
|
2003-09-16 19:40:07 +00:00
|
|
|
|
void resizeEvent( QResizeEvent *); // FRAME
|
|
|
|
|
void paintEvent( QPaintEvent *); // FRAME
|
|
|
|
|
void mouseDoubleClickEvent( QMouseEvent * ); // FRAME
|
|
|
|
|
int width() const { return widget()->width(); }
|
|
|
|
|
int height() const { return widget()->height(); }
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
void calculateCaptionRect();
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
|
|
|
|
inline bool maximizedVertical() const {
|
|
|
|
|
return ( maximizeMode() & MaximizeVertical );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
}
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
private slots:
|
2003-09-16 19:40:07 +00:00
|
|
|
|
void menuButtonPressed();
|
2002-05-17 16:33:48 +00:00
|
|
|
|
void slotMaximize();
|
2004-07-22 11:23:28 +00:00
|
|
|
|
void slotAbove();
|
|
|
|
|
void slotBelow();
|
|
|
|
|
void slotShade();
|
|
|
|
|
void keepAboveChange( bool );
|
|
|
|
|
void keepBelowChange( bool );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
private:
|
2002-06-29 22:25:38 +00:00
|
|
|
|
QSpacerItem *topSpacer, *titlebar;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
KeramikButton *button[ NumButtons ];
|
|
|
|
|
QRect captionRect;
|
|
|
|
|
QPixmap captionBuffer;
|
|
|
|
|
QPixmap *activeIcon, *inactiveIcon;
|
2002-06-29 22:25:38 +00:00
|
|
|
|
bool captionBufferDirty:1, maskDirty:1;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
bool largeCaption:1, largeTitlebar:1;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}; // class KeramikClient
|
|
|
|
|
|
2002-06-29 22:25:38 +00:00
|
|
|
|
} // namespace Keramik
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
#endif // ___KERAMIK_H
|
|
|
|
|
|
|
|
|
|
// vim: set noet ts=4 sw=4:
|