3 * Keramik KWin client (version 0.8)
5 * Copyright (C) 2002 Fredrik Höglund <fredrik@kde.org>
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the license, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; see the file COPYING. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
27 #include <QAbstractButton>
28 #include <kdecoration.h>
29 #include <kdecorationfactory.h>
36 enum TilePixmap
{ TitleLeft
=0, TitleCenter
, TitleRight
,
37 CaptionSmallLeft
, CaptionSmallCenter
, CaptionSmallRight
,
38 CaptionLargeLeft
, CaptionLargeCenter
, CaptionLargeRight
,
39 GrabBarLeft
, GrabBarCenter
, GrabBarRight
,
40 BorderLeft
, BorderRight
, NumTiles
};
42 enum Button
{ MenuButton
=0, OnAllDesktopsButton
, HelpButton
, MinButton
,
43 MaxButton
, CloseButton
, AboveButton
, BelowButton
, ShadeButton
,
46 enum ButtonDeco
{ Menu
=0, OnAllDesktops
, NotOnAllDesktops
, Help
, Minimize
, Maximize
,
47 Restore
, Close
, AboveOn
, AboveOff
, BelowOn
, BelowOff
, ShadeOn
, ShadeOff
,
53 bool smallCaptionBubbles
:1;
56 class KeramikHandler
: public KDecorationFactory
62 virtual QList
< BorderSize
> borderSizes() const;
63 virtual bool reset( unsigned long changed
);
64 virtual KDecoration
* createDecoration( KDecorationBridge
* );
65 virtual bool supports( Ability ability
) const;
67 bool showAppIcons() const { return showIcons
; }
68 bool useShadowedText() const { return shadowedText
; }
69 bool largeCaptionBubbles() const { return !smallCaptionBubbles
; }
71 int titleBarHeight( bool large
) const {
72 return ( large
? activeTiles
[CaptionLargeCenter
]->height()
73 : activeTiles
[CaptionSmallCenter
]->height() );
76 int grabBarHeight() const
77 { return activeTiles
[GrabBarCenter
]->height(); }
79 const QPixmap
*roundButton() const { return titleButtonRound
; }
80 const QPixmap
*squareButton() const { return titleButtonSquare
; }
81 const QBitmap
*buttonDeco( ButtonDeco deco
) const
82 { return buttonDecos
[ deco
]; }
84 inline const QPixmap
*tile( TilePixmap tilePix
, bool active
) const;
89 void destroyPixmaps();
91 void addWidth (int width
, QPixmap
*&pix
, bool left
, QPixmap
*bottomPix
);
92 void addHeight (int height
, QPixmap
*&pix
);
93 void flip( QPixmap
*&, QPixmap
*& );
94 void pretile( QPixmap
*&, int, Qt::Orientation
);
95 QPixmap
*composite( QImage
*, QImage
* );
96 QImage
*loadImage( const QString
&, const QColor
& );
97 QPixmap
*loadPixmap( const QString
&, const QColor
& );
99 bool showIcons
:1, shadowedText
:1,
100 smallCaptionBubbles
:1, largeGrabBars
:1;
101 SettingsCache
*settings_cache
;
103 QPixmap
*activeTiles
[ NumTiles
];
104 QPixmap
*inactiveTiles
[ NumTiles
];
105 QBitmap
*buttonDecos
[ NumButtonDecos
];
107 QPixmap
*titleButtonRound
, *titleButtonSquare
;
109 }; // class KeramikHandler
112 class KeramikButton
: public QAbstractButton
115 KeramikButton( KeramikClient
*, Button
, const QString
&, const int realizeBtns
= Qt::LeftButton
);
118 Qt::MouseButtons
lastButton() const { return lastbutton
; }
121 void enterEvent( QEvent
* );
122 void leaveEvent( QEvent
* );
123 void mousePressEvent( QMouseEvent
* );
124 void mouseReleaseEvent( QMouseEvent
* );
125 void paintEvent( QPaintEvent
* );
128 KeramikClient
*client
;
131 Qt::MouseButtons lastbutton
;
133 }; // class KeramikButton
136 class KeramikClient
: public KDecoration
142 KeramikClient( KDecorationBridge
* bridge
, KDecorationFactory
* factory
);
145 virtual void reset( unsigned long changed
);
146 virtual Position
mousePosition( const QPoint
& p
) const;
147 virtual void borders( int& left
, int& right
, int& top
, int& bottom
) const;
148 virtual void resize( const QSize
& s
);
149 virtual QSize
minimumSize() const;
150 virtual bool eventFilter( QObject
* o
, QEvent
* e
);
151 virtual void activeChange();
152 virtual void captionChange();
153 virtual void maximizeChange();
154 virtual void desktopChange();
155 virtual void shadeChange();
159 void addButtons( QBoxLayout
*, const QString
& );
160 void updateMask(); // FRAME
161 void updateCaptionBuffer();
163 void resizeEvent( QResizeEvent
*); // FRAME
164 void paintEvent( QPaintEvent
*); // FRAME
165 void mouseDoubleClickEvent( QMouseEvent
* ); // FRAME
166 int width() const { return widget()->width(); }
167 int height() const { return widget()->height(); }
169 void calculateCaptionRect();
171 inline bool maximizedVertical() const {
172 return ( maximizeMode() & MaximizeVertical
);
176 void menuButtonPressed();
181 void keepAboveChange( bool );
182 void keepBelowChange( bool );
185 QSpacerItem
*topSpacer
, *titlebar
;
186 KeramikButton
*button
[ NumButtons
];
188 QPixmap captionBuffer
;
189 QPixmap
*activeIcon
, *inactiveIcon
;
190 bool captionBufferDirty
:1, maskDirty
:1;
191 bool largeCaption
:1, largeTitlebar
:1;
192 }; // class KeramikClient
194 } // namespace Keramik
196 #endif // ___KERAMIK_H
198 // vim: set noet ts=4 sw=4: