2001-03-17 11:49:51 +00:00
|
|
|
/*
|
2001-06-04 09:51:23 +00:00
|
|
|
*
|
|
|
|
* Gallium-Quartz KWin client
|
|
|
|
*
|
2005-03-22 23:06:32 +00:00
|
|
|
* Copyright (C) 2005 Sandro Giessl <sandro@giessl.com>
|
2001-06-04 09:51:23 +00:00
|
|
|
* Copyright 2001
|
2001-07-15 12:15:41 +00:00
|
|
|
* Karol Szwed <gallium@kde.org>
|
2001-06-04 09:51:23 +00:00
|
|
|
* http://gallium.n3.net/
|
|
|
|
*
|
2001-07-15 12:15:41 +00:00
|
|
|
* Based on the KDE default client.
|
2001-06-04 09:51:23 +00:00
|
|
|
*
|
|
|
|
* Includes mini titlebars for ToolWindow Support.
|
|
|
|
* Button positions are now customizable.
|
|
|
|
*
|
|
|
|
*/
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2001-04-22 09:31:42 +00:00
|
|
|
#include <kconfig.h>
|
|
|
|
#include <kdrawutil.h>
|
2003-09-18 15:27:12 +00:00
|
|
|
#include <kglobal.h>
|
2001-07-01 10:10:17 +00:00
|
|
|
#include <klocale.h>
|
2003-09-18 15:27:12 +00:00
|
|
|
#include <kpixmapeffect.h>
|
2001-03-17 11:49:51 +00:00
|
|
|
#include <qbitmap.h>
|
2003-09-18 15:27:12 +00:00
|
|
|
#include <qdrawutil.h>
|
2001-10-12 12:29:15 +00:00
|
|
|
#include <qimage.h>
|
2003-11-10 13:57:21 +00:00
|
|
|
#include <qapplication.h>
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2003-09-18 15:27:12 +00:00
|
|
|
#include "quartz.h"
|
2005-07-28 14:59:42 +00:00
|
|
|
//Added by qt3to4:
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <QPaintEvent>
|
2002-08-27 18:08:20 +00:00
|
|
|
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2002-08-27 18:08:20 +00:00
|
|
|
namespace Quartz {
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2004-06-04 11:28:54 +00:00
|
|
|
static const unsigned char iconify_bits[] = {
|
2001-03-17 11:49:51 +00:00
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x00,
|
|
|
|
0x7e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
|
|
|
2004-06-04 11:28:54 +00:00
|
|
|
static const unsigned char close_bits[] = {
|
2001-03-17 11:49:51 +00:00
|
|
|
0x00, 0x00, 0x86, 0x01, 0xcc, 0x00, 0x78, 0x00, 0x30, 0x00, 0x78, 0x00,
|
|
|
|
0xcc, 0x00, 0x86, 0x01, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
2004-06-04 11:28:54 +00:00
|
|
|
static const unsigned char maximize_bits[] = {
|
2001-03-17 11:49:51 +00:00
|
|
|
0xff, 0x01, 0xff, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
|
|
|
|
0x01, 0x01, 0x01, 0x01, 0xff, 0x01, 0x00, 0x00};
|
|
|
|
|
2004-06-04 11:28:54 +00:00
|
|
|
static const unsigned char minmax_bits[] = {
|
2001-03-17 11:49:51 +00:00
|
|
|
0xfc, 0x00, 0xfc, 0x00, 0x84, 0x00, 0xbf, 0x00, 0xbf, 0x00, 0xe1, 0x00,
|
|
|
|
0x21, 0x00, 0x21, 0x00, 0x3f, 0x00, 0x00, 0x00};
|
|
|
|
|
2004-06-04 11:28:54 +00:00
|
|
|
static const unsigned char question_bits[] = {
|
2001-03-17 11:49:51 +00:00
|
|
|
0x00, 0x00, 0x3c, 0x00, 0x66, 0x00, 0x60, 0x00, 0x30, 0x00, 0x18, 0x00,
|
|
|
|
0x00, 0x00, 0x18, 0x00, 0x18, 0x00, 0x00, 0x00};
|
|
|
|
|
2004-06-04 11:28:54 +00:00
|
|
|
static const unsigned char pindown_white_bits[] = {
|
2001-04-22 09:31:42 +00:00
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x80, 0x1f, 0xa0, 0x03,
|
|
|
|
0xb0, 0x01, 0x30, 0x01, 0xf0, 0x00, 0x70, 0x00, 0x20, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
2004-06-04 11:28:54 +00:00
|
|
|
static const unsigned char pindown_gray_bits[] = {
|
2001-04-22 09:31:42 +00:00
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c,
|
|
|
|
0x00, 0x0e, 0x00, 0x06, 0x00, 0x00, 0x80, 0x07, 0xc0, 0x03, 0xe0, 0x01,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
2004-06-04 11:28:54 +00:00
|
|
|
static const unsigned char pindown_dgray_bits[] = {
|
2001-04-22 09:31:42 +00:00
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x10, 0x70, 0x20, 0x50, 0x20,
|
|
|
|
0x48, 0x30, 0xc8, 0x38, 0x08, 0x1f, 0x08, 0x18, 0x10, 0x1c, 0x10, 0x0e,
|
|
|
|
0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
2004-06-04 11:28:54 +00:00
|
|
|
static const unsigned char pinup_white_bits[] = {
|
2001-04-22 09:31:42 +00:00
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x11,
|
|
|
|
0x3f, 0x15, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
2004-06-04 11:28:54 +00:00
|
|
|
static const unsigned char pinup_gray_bits[] = {
|
2001-04-22 09:31:42 +00:00
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x80, 0x0a, 0xbf, 0x0a, 0x80, 0x15, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
2004-06-04 11:28:54 +00:00
|
|
|
static const unsigned char pinup_dgray_bits[] = {
|
2001-04-22 09:31:42 +00:00
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x40, 0x31, 0x40, 0x2e,
|
|
|
|
0x40, 0x20, 0x40, 0x20, 0x7f, 0x2a, 0x40, 0x3f, 0xc0, 0x31, 0xc0, 0x20,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
2004-07-25 11:14:07 +00:00
|
|
|
static const unsigned char above_on_bits[] = {
|
|
|
|
0x00, 0x00, 0xfe, 0x01, 0xfe, 0x01, 0x30, 0x00, 0xfc, 0x00, 0x78, 0x00,
|
|
|
|
0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
|
|
|
static const unsigned char above_off_bits[] = {
|
|
|
|
0x30, 0x00, 0x78, 0x00, 0xfc, 0x00, 0x30, 0x00, 0xfe, 0x01, 0xfe, 0x01,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
|
|
|
static const unsigned char below_on_bits[] = {
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x78, 0x00, 0xfc, 0x00,
|
|
|
|
0x30, 0x00, 0xfe, 0x01, 0xfe, 0x01, 0x00, 0x00};
|
|
|
|
|
|
|
|
static const unsigned char below_off_bits[] = {
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0xfe, 0x01,
|
|
|
|
0x30, 0x00, 0xfc, 0x00, 0x78, 0x00, 0x30, 0x00};
|
|
|
|
|
|
|
|
static const unsigned char shade_on_bits[] = {
|
|
|
|
0x00, 0x00, 0xfe, 0x01, 0xfe, 0x01, 0xfe, 0x01, 0x02, 0x01, 0x02, 0x01,
|
|
|
|
0x02, 0x01, 0x02, 0x01, 0xfe, 0x01, 0x00, 0x00};
|
|
|
|
|
|
|
|
static const unsigned char shade_off_bits[] = {
|
|
|
|
0x00, 0x00, 0xfe, 0x01, 0xfe, 0x01, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
|
|
|
|
2001-04-22 09:31:42 +00:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Titlebar button positions
|
2003-09-18 15:27:12 +00:00
|
|
|
bool onAllDesktopsButtonOnLeft = true;
|
2001-05-26 02:34:47 +00:00
|
|
|
bool coloredFrame = true;
|
2005-01-14 17:56:02 +00:00
|
|
|
bool extraSlim = false;
|
2001-04-22 09:31:42 +00:00
|
|
|
|
|
|
|
KPixmap* titleBlocks = NULL;
|
|
|
|
KPixmap* ititleBlocks = NULL;
|
|
|
|
KPixmap* pinDownPix = NULL;
|
|
|
|
KPixmap* pinUpPix = NULL;
|
|
|
|
KPixmap* ipinDownPix = NULL;
|
|
|
|
KPixmap* ipinUpPix = NULL;
|
2003-09-29 16:35:12 +00:00
|
|
|
static int normalTitleHeight;
|
|
|
|
static int toolTitleHeight;
|
|
|
|
static int borderWidth;
|
2001-04-22 09:31:42 +00:00
|
|
|
|
2001-05-26 02:34:47 +00:00
|
|
|
bool quartz_initialized = false;
|
2001-04-22 09:31:42 +00:00
|
|
|
QuartzHandler* clientHandler;
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
QuartzHandler::QuartzHandler()
|
|
|
|
{
|
2001-05-26 02:34:47 +00:00
|
|
|
quartz_initialized = false;
|
2001-04-22 09:31:42 +00:00
|
|
|
readConfig();
|
|
|
|
createPixmaps();
|
2001-05-26 02:34:47 +00:00
|
|
|
quartz_initialized = true;
|
2001-04-22 09:31:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
QuartzHandler::~QuartzHandler()
|
|
|
|
{
|
2001-05-26 02:34:47 +00:00
|
|
|
quartz_initialized = false;
|
2001-04-22 09:31:42 +00:00
|
|
|
freePixmaps();
|
|
|
|
}
|
|
|
|
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2003-09-18 15:27:12 +00:00
|
|
|
KDecoration* QuartzHandler::createDecoration( KDecorationBridge* bridge )
|
|
|
|
{
|
|
|
|
return new QuartzClient( bridge, this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool QuartzHandler::reset(unsigned long changed)
|
2001-04-22 09:31:42 +00:00
|
|
|
{
|
2001-05-26 02:34:47 +00:00
|
|
|
quartz_initialized = false;
|
2001-04-22 09:31:42 +00:00
|
|
|
freePixmaps();
|
|
|
|
readConfig();
|
|
|
|
createPixmaps();
|
2001-05-26 02:34:47 +00:00
|
|
|
quartz_initialized = true;
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2003-09-18 15:27:12 +00:00
|
|
|
// Do we need to "hit the wooden hammer" ?
|
|
|
|
bool needHardReset = true;
|
2003-09-29 16:35:12 +00:00
|
|
|
if (changed & SettingColors)
|
2003-09-18 15:27:12 +00:00
|
|
|
{
|
|
|
|
needHardReset = false;
|
2005-03-21 15:53:41 +00:00
|
|
|
} else if (changed & SettingButtons) {
|
|
|
|
// handled by KCommonDecoration
|
|
|
|
needHardReset = false;
|
2003-09-18 15:27:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (needHardReset) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
resetDecorations(changed);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
2001-04-22 09:31:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-11-05 15:33:09 +00:00
|
|
|
bool QuartzHandler::supports( Ability ability )
|
|
|
|
{
|
|
|
|
switch( ability )
|
|
|
|
{
|
|
|
|
case AbilityAnnounceButtons:
|
|
|
|
case AbilityButtonMenu:
|
|
|
|
case AbilityButtonOnAllDesktops:
|
|
|
|
case AbilityButtonHelp:
|
|
|
|
case AbilityButtonMinimize:
|
|
|
|
case AbilityButtonMaximize:
|
|
|
|
case AbilityButtonClose:
|
|
|
|
case AbilityButtonAboveOthers:
|
|
|
|
case AbilityButtonBelowOthers:
|
|
|
|
case AbilityButtonShade:
|
2005-03-21 15:53:41 +00:00
|
|
|
case AbilityButtonSpacer:
|
2004-11-05 15:33:09 +00:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-22 09:31:42 +00:00
|
|
|
void QuartzHandler::readConfig()
|
|
|
|
{
|
2001-06-04 09:51:23 +00:00
|
|
|
KConfig conf("kwinquartzrc");
|
|
|
|
conf.setGroup("General");
|
2006-01-03 14:01:15 +00:00
|
|
|
coloredFrame = conf.readEntry( "UseTitleBarBorderColors", QVariant(true )).toBool();
|
|
|
|
extraSlim = conf.readEntry( "UseQuartzExtraSlim", QVariant(false )).toBool();
|
2001-05-26 02:34:47 +00:00
|
|
|
|
2003-09-18 15:27:12 +00:00
|
|
|
// A small hack to make the on all desktops button look nicer
|
|
|
|
onAllDesktopsButtonOnLeft = KDecoration::options()->titleButtonsLeft().contains( 'S' );
|
2005-11-10 11:50:13 +00:00
|
|
|
if ( QApplication::isRightToLeft() )
|
2003-11-10 13:57:21 +00:00
|
|
|
onAllDesktopsButtonOnLeft = !onAllDesktopsButtonOnLeft;
|
2003-09-29 16:35:12 +00:00
|
|
|
switch(options()->preferredBorderSize(this)) {
|
|
|
|
case BorderLarge:
|
|
|
|
borderWidth = 8;
|
|
|
|
break;
|
|
|
|
case BorderVeryLarge:
|
|
|
|
borderWidth = 12;
|
|
|
|
break;
|
|
|
|
case BorderHuge:
|
|
|
|
borderWidth = 18;
|
|
|
|
break;
|
|
|
|
case BorderVeryHuge:
|
|
|
|
borderWidth = 27;
|
|
|
|
break;
|
|
|
|
case BorderOversized:
|
|
|
|
borderWidth = 40;
|
|
|
|
break;
|
|
|
|
case BorderTiny:
|
|
|
|
case BorderNormal:
|
|
|
|
default:
|
2005-01-14 17:56:02 +00:00
|
|
|
borderWidth = extraSlim?2:4;
|
2003-09-29 16:35:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
normalTitleHeight = QFontMetrics(options()->font(true)).height();
|
2005-01-14 17:56:02 +00:00
|
|
|
int nTH_limit=extraSlim?14:18;
|
|
|
|
normalTitleHeight = QFontMetrics(options()->font(true)).height()-(extraSlim?1:0);
|
|
|
|
if (normalTitleHeight < nTH_limit) normalTitleHeight = nTH_limit;
|
2003-09-29 16:35:12 +00:00
|
|
|
if (normalTitleHeight < borderWidth) normalTitleHeight = borderWidth;
|
2003-11-02 11:03:41 +00:00
|
|
|
|
2003-09-29 16:35:12 +00:00
|
|
|
toolTitleHeight = QFontMetrics(options()->font(true, true)).height();
|
|
|
|
if (toolTitleHeight < 12) toolTitleHeight = 12;
|
|
|
|
if (toolTitleHeight < borderWidth) toolTitleHeight = borderWidth;
|
2001-04-22 09:31:42 +00:00
|
|
|
}
|
2001-03-17 11:49:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
// This does the colour transition magic. (You say "Oh, is that it?")
|
2001-04-22 09:31:42 +00:00
|
|
|
// This may be made configurable at a later stage
|
|
|
|
void QuartzHandler::drawBlocks( KPixmap *pi, KPixmap &p, const QColor &c1, const QColor &c2 )
|
2001-03-17 11:49:51 +00:00
|
|
|
{
|
2001-04-22 09:31:42 +00:00
|
|
|
QPainter px;
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2001-04-22 09:31:42 +00:00
|
|
|
px.begin( pi );
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2001-04-22 09:31:42 +00:00
|
|
|
// Draw a background gradient first
|
|
|
|
KPixmapEffect::gradient(p, c1, c2, KPixmapEffect::HorizontalGradient);
|
2003-11-02 11:03:41 +00:00
|
|
|
|
2003-09-29 16:35:12 +00:00
|
|
|
int factor = (pi->height()-2)/4;
|
|
|
|
int square = factor - (factor+2)/4;
|
2003-11-02 11:03:41 +00:00
|
|
|
|
2003-09-29 16:35:12 +00:00
|
|
|
int x = pi->width() - 5*factor - square;
|
|
|
|
int y = (pi->height() - 4*factor)/2;
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2006-04-10 11:57:13 +00:00
|
|
|
px.fillRect( x, y, square, square, c1.light(120) );
|
|
|
|
px.fillRect( x, y+factor, square, square, c1 );
|
2003-09-29 16:35:12 +00:00
|
|
|
px.fillRect( x, y+2*factor, square, square, c1.light(110) );
|
|
|
|
px.fillRect( x, y+3*factor, square, square, c1 );
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2006-04-10 11:57:13 +00:00
|
|
|
px.fillRect( x+factor, y, square, square, c1.light(110) );
|
|
|
|
px.fillRect( x+factor, y+factor, square, square, c2.light(110) );
|
2003-09-29 16:35:12 +00:00
|
|
|
px.fillRect( x+factor, y+2*factor, square, square, c1.light(120) );
|
|
|
|
px.fillRect( x+factor, y+3*factor, square, square, c2.light(130) );
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2006-04-10 11:57:13 +00:00
|
|
|
px.fillRect( x+2*factor, y+factor, square, square, c1.light(110) );
|
2003-09-29 16:35:12 +00:00
|
|
|
px.fillRect( x+2*factor, y+2*factor, square, square, c2.light(120) );
|
|
|
|
px.fillRect( x+2*factor, y+3*factor, square, square, c2.light(150) );
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2006-04-10 11:57:13 +00:00
|
|
|
px.fillRect( x+3*factor, y, square, square, c1.dark(110) );
|
2003-09-29 16:35:12 +00:00
|
|
|
px.fillRect( x+3*factor, y+2*factor, square, square, c2.light(120) );
|
|
|
|
px.fillRect( x+3*factor, y+3*factor, square, square, c1.dark(120) );
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2006-04-10 11:57:13 +00:00
|
|
|
px.fillRect( x+4*factor, y+factor, square, square, c1.light(110) );
|
2003-09-29 16:35:12 +00:00
|
|
|
px.fillRect( x+4*factor, y+3*factor, square, square, c1.dark(110) );
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2003-09-29 16:35:12 +00:00
|
|
|
px.fillRect( x+5*factor, y+2*factor, square, square, c2.light(120));
|
|
|
|
px.fillRect( x+5*factor, y+3*factor, square, square, c2.light(110) );
|
2001-03-17 11:49:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// This paints the button pixmaps upon loading the style.
|
2001-04-22 09:31:42 +00:00
|
|
|
void QuartzHandler::createPixmaps()
|
2001-03-17 11:49:51 +00:00
|
|
|
{
|
|
|
|
// Obtain titlebar blend colours, and create the block stuff on pixmaps.
|
2006-03-04 22:27:27 +00:00
|
|
|
QColorGroup g2 = options()->palette(ColorTitleBlend, true).active();
|
2001-03-17 11:49:51 +00:00
|
|
|
QColor c2 = g2.background();
|
2006-03-04 22:27:27 +00:00
|
|
|
g2 = options()->palette(ColorTitleBar, true ).active();
|
2001-04-22 09:31:42 +00:00
|
|
|
QColor c = g2.background().light(130);
|
|
|
|
|
|
|
|
titleBlocks = new KPixmap();
|
2003-09-29 16:35:12 +00:00
|
|
|
titleBlocks->resize( normalTitleHeight*25/18, normalTitleHeight );
|
2001-04-22 02:26:16 +00:00
|
|
|
drawBlocks( titleBlocks, *titleBlocks, c, c2 );
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2006-03-04 22:27:27 +00:00
|
|
|
g2 = options()->palette(ColorTitleBlend, false).active();
|
2001-03-17 11:49:51 +00:00
|
|
|
c2 = g2.background();
|
2006-03-04 22:27:27 +00:00
|
|
|
g2 = options()->palette(ColorTitleBar, false ).active();
|
2001-04-22 09:31:42 +00:00
|
|
|
c = g2.background().light(130);
|
|
|
|
|
|
|
|
ititleBlocks = new KPixmap();
|
2003-09-29 16:35:12 +00:00
|
|
|
ititleBlocks->resize( normalTitleHeight*25/18, normalTitleHeight );
|
2001-04-22 02:26:16 +00:00
|
|
|
drawBlocks( ititleBlocks, *ititleBlocks, c, c2 );
|
2001-04-22 09:31:42 +00:00
|
|
|
|
2003-09-18 15:27:12 +00:00
|
|
|
// Set the on all desktops pin pixmaps;
|
2001-05-26 02:34:47 +00:00
|
|
|
QColorGroup g;
|
2001-04-22 09:31:42 +00:00
|
|
|
QPainter p;
|
2001-05-26 02:34:47 +00:00
|
|
|
|
2006-03-04 22:27:27 +00:00
|
|
|
g = options()->palette( onAllDesktopsButtonOnLeft ? ColorTitleBar : ColorTitleBlend, true ).active();
|
2003-09-18 15:27:12 +00:00
|
|
|
c = onAllDesktopsButtonOnLeft ? g.background().light(130) : g.background();
|
2006-03-04 22:27:27 +00:00
|
|
|
g2 = options()->palette( ColorButtonBg, true ).active();
|
2001-05-26 02:34:47 +00:00
|
|
|
|
2001-04-22 09:31:42 +00:00
|
|
|
pinUpPix = new KPixmap();
|
|
|
|
pinUpPix->resize(16, 16);
|
|
|
|
p.begin( pinUpPix );
|
|
|
|
p.fillRect( 0, 0, 16, 16, c);
|
2001-05-26 02:34:47 +00:00
|
|
|
kColorBitmaps( &p, g2, 0, 1, 16, 16, true, pinup_white_bits,
|
|
|
|
pinup_gray_bits, NULL, NULL, pinup_dgray_bits, NULL );
|
2001-04-22 09:31:42 +00:00
|
|
|
p.end();
|
|
|
|
|
|
|
|
pinDownPix = new KPixmap();
|
|
|
|
pinDownPix->resize(16, 16);
|
|
|
|
p.begin( pinDownPix );
|
|
|
|
p.fillRect( 0, 0, 16, 16, c);
|
2003-09-18 15:27:12 +00:00
|
|
|
kColorBitmaps( &p, g2, 0, 1, 16, 16, true, pindown_white_bits,
|
2001-05-26 02:34:47 +00:00
|
|
|
pindown_gray_bits, NULL, NULL, pindown_dgray_bits, NULL );
|
2001-04-22 09:31:42 +00:00
|
|
|
p.end();
|
|
|
|
|
|
|
|
|
|
|
|
// Inactive pins
|
2006-03-04 22:27:27 +00:00
|
|
|
g = options()->palette( onAllDesktopsButtonOnLeft ? ColorTitleBar : ColorTitleBlend, false ).active();
|
2003-09-18 15:27:12 +00:00
|
|
|
c = onAllDesktopsButtonOnLeft ? g.background().light(130) : g.background();
|
2006-03-04 22:27:27 +00:00
|
|
|
g2 = options()->palette( ColorButtonBg, false ).active();
|
2001-05-26 02:34:47 +00:00
|
|
|
|
2001-04-22 09:31:42 +00:00
|
|
|
ipinUpPix = new KPixmap();
|
|
|
|
ipinUpPix->resize(16, 16);
|
|
|
|
p.begin( ipinUpPix );
|
|
|
|
p.fillRect( 0, 0, 16, 16, c);
|
2003-09-18 15:27:12 +00:00
|
|
|
kColorBitmaps( &p, g2, 0, 1, 16, 16, true, pinup_white_bits,
|
2001-05-26 02:34:47 +00:00
|
|
|
pinup_gray_bits, NULL, NULL, pinup_dgray_bits, NULL );
|
2001-04-22 09:31:42 +00:00
|
|
|
p.end();
|
|
|
|
|
|
|
|
ipinDownPix = new KPixmap();
|
|
|
|
ipinDownPix->resize(16, 16);
|
|
|
|
p.begin( ipinDownPix );
|
|
|
|
p.fillRect( 0, 0, 16, 16, c);
|
2001-05-26 02:34:47 +00:00
|
|
|
kColorBitmaps( &p, g2, 0, 1, 16, 16, true, pindown_white_bits,
|
|
|
|
pindown_gray_bits, NULL, NULL, pindown_dgray_bits, NULL );
|
2001-04-22 09:31:42 +00:00
|
|
|
p.end();
|
2001-03-17 11:49:51 +00:00
|
|
|
}
|
|
|
|
|
2001-04-22 09:31:42 +00:00
|
|
|
|
|
|
|
void QuartzHandler::freePixmaps()
|
2001-04-22 02:26:16 +00:00
|
|
|
{
|
2003-11-10 13:44:08 +00:00
|
|
|
delete titleBlocks;
|
|
|
|
delete ititleBlocks;
|
|
|
|
|
|
|
|
// On all desktops pin images
|
|
|
|
delete pinUpPix;
|
|
|
|
delete ipinUpPix;
|
|
|
|
delete pinDownPix;
|
|
|
|
delete ipinDownPix;
|
2001-04-22 02:26:16 +00:00
|
|
|
}
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2001-04-22 09:31:42 +00:00
|
|
|
|
2005-07-28 14:59:42 +00:00
|
|
|
QList< QuartzHandler::BorderSize > QuartzHandler::borderSizes() const
|
2003-09-29 16:35:12 +00:00
|
|
|
{ // the list must be sorted
|
2005-07-28 14:59:42 +00:00
|
|
|
return QList< BorderSize >() << BorderNormal << BorderLarge <<
|
2003-09-29 16:35:12 +00:00
|
|
|
BorderVeryLarge << BorderHuge << BorderVeryHuge << BorderOversized;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
QuartzButton::QuartzButton(ButtonType type, QuartzClient *parent, const char *name)
|
2006-03-04 22:27:27 +00:00
|
|
|
: KCommonDecorationButton(type, parent)
|
2001-03-17 11:49:51 +00:00
|
|
|
{
|
|
|
|
// Eliminate any possible background flicker
|
2005-07-28 14:59:42 +00:00
|
|
|
setBackgroundMode( Qt::NoBackground );
|
2003-11-02 11:03:41 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
deco = 0;
|
2001-03-17 11:49:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-04-22 09:31:42 +00:00
|
|
|
QuartzButton::~QuartzButton()
|
|
|
|
{
|
2003-11-10 13:44:08 +00:00
|
|
|
delete deco;
|
2001-04-22 09:31:42 +00:00
|
|
|
}
|
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
void QuartzButton::reset(unsigned long changed)
|
|
|
|
{
|
|
|
|
if (changed&DecorationReset || changed&ManualReset || changed&SizeChange || changed&StateChange) {
|
|
|
|
switch (type() ) {
|
|
|
|
case CloseButton:
|
|
|
|
setBitmap(close_bits);
|
|
|
|
break;
|
|
|
|
case HelpButton:
|
|
|
|
setBitmap(question_bits);
|
|
|
|
break;
|
|
|
|
case MinButton:
|
|
|
|
setBitmap(iconify_bits);
|
|
|
|
break;
|
|
|
|
case MaxButton:
|
2006-02-22 09:52:11 +00:00
|
|
|
setBitmap( isChecked() ? minmax_bits : maximize_bits );
|
2005-03-21 15:53:41 +00:00
|
|
|
break;
|
|
|
|
case OnAllDesktopsButton:
|
|
|
|
setBitmap(0);
|
|
|
|
break;
|
|
|
|
case ShadeButton:
|
2006-02-22 09:52:11 +00:00
|
|
|
setBitmap( isChecked() ? shade_on_bits : shade_off_bits );
|
2005-03-21 15:53:41 +00:00
|
|
|
break;
|
|
|
|
case AboveButton:
|
2006-02-22 09:52:11 +00:00
|
|
|
setBitmap( isChecked() ? above_on_bits : above_off_bits );
|
2005-03-21 15:53:41 +00:00
|
|
|
break;
|
|
|
|
case BelowButton:
|
2006-02-22 09:52:11 +00:00
|
|
|
setBitmap( isChecked() ? below_on_bits : below_off_bits );
|
2005-03-21 15:53:41 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
setBitmap(0);
|
|
|
|
break;
|
|
|
|
}
|
2001-04-22 09:31:42 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
this->update();
|
|
|
|
}
|
2001-03-17 11:49:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void QuartzButton::setBitmap(const unsigned char *bitmap)
|
|
|
|
{
|
2005-03-21 15:53:41 +00:00
|
|
|
delete deco;
|
|
|
|
deco = 0;
|
2003-09-18 15:27:12 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
if (bitmap) {
|
|
|
|
deco = new QBitmap(10, 10, bitmap, true);
|
|
|
|
deco->setMask( *deco );
|
|
|
|
repaint( false );
|
2003-09-18 15:27:12 +00:00
|
|
|
}
|
2001-03-17 11:49:51 +00:00
|
|
|
}
|
|
|
|
|
2005-08-17 09:15:59 +00:00
|
|
|
void QuartzButton::paintEvent(QPaintEvent *)
|
|
|
|
{
|
|
|
|
QPainter p(this);
|
|
|
|
drawButton(&p);
|
|
|
|
}
|
|
|
|
|
2001-04-22 09:31:42 +00:00
|
|
|
void QuartzButton::drawButton(QPainter *p)
|
2001-03-17 11:49:51 +00:00
|
|
|
{
|
2001-05-26 02:34:47 +00:00
|
|
|
// Never paint if the pixmaps have not been created
|
|
|
|
if (!quartz_initialized)
|
|
|
|
return;
|
|
|
|
|
2001-04-22 09:31:42 +00:00
|
|
|
QColor c;
|
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
if (isLeft() )
|
|
|
|
c = KDecoration::options()->color(KDecoration::ColorTitleBar, decoration()->isActive()).light(130);
|
2001-04-22 09:31:42 +00:00
|
|
|
else
|
2005-03-21 15:53:41 +00:00
|
|
|
c = KDecoration::options()->color(KDecoration::ColorTitleBlend, decoration()->isActive());
|
2001-04-22 09:31:42 +00:00
|
|
|
|
|
|
|
// Fill the button background with an appropriate color
|
|
|
|
p->fillRect(0, 0, width(), height(), c );
|
|
|
|
|
|
|
|
// If we have a decoration bitmap, then draw that
|
2003-09-18 15:27:12 +00:00
|
|
|
// otherwise we paint a menu button (with mini icon), or a onAllDesktops button.
|
2001-04-22 09:31:42 +00:00
|
|
|
if( deco )
|
|
|
|
{
|
|
|
|
int xOff = (width()-10)/2;
|
|
|
|
int yOff = (height()-10)/2;
|
|
|
|
p->setPen( Qt::black );
|
|
|
|
p->drawPixmap(isDown() ? xOff+2: xOff+1, isDown() ? yOff+2 : yOff+1, *deco);
|
2005-03-21 15:53:41 +00:00
|
|
|
p->setPen( KDecoration::options()->color(KDecoration::ColorButtonBg, decoration()->isActive()).light(150) );
|
2001-04-22 09:31:42 +00:00
|
|
|
p->drawPixmap(isDown() ? xOff+1: xOff, isDown() ? yOff+1 : yOff, *deco);
|
2003-09-18 15:27:12 +00:00
|
|
|
} else
|
2001-04-22 09:31:42 +00:00
|
|
|
{
|
|
|
|
QPixmap btnpix;
|
|
|
|
int Offset = 0;
|
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
if (type() == OnAllDesktopsButton)
|
2001-04-22 09:31:42 +00:00
|
|
|
{
|
|
|
|
if (isDown())
|
|
|
|
Offset = 1;
|
|
|
|
|
2003-09-18 15:27:12 +00:00
|
|
|
// Select the right onAllDesktops button to paint
|
2005-03-21 15:53:41 +00:00
|
|
|
if (decoration()->isActive())
|
2006-02-22 09:52:11 +00:00
|
|
|
btnpix = isChecked() ? *pinDownPix : *pinUpPix;
|
2001-05-26 02:34:47 +00:00
|
|
|
else
|
2006-02-22 09:52:11 +00:00
|
|
|
btnpix = isChecked() ? *ipinDownPix : *ipinUpPix;
|
2001-05-26 02:34:47 +00:00
|
|
|
|
2001-04-22 09:31:42 +00:00
|
|
|
} else
|
2005-07-28 14:59:42 +00:00
|
|
|
btnpix = decoration()->icon().pixmap( QIcon::Small, QIcon::Normal);
|
2001-04-22 09:31:42 +00:00
|
|
|
|
|
|
|
// Shrink the miniIcon for tiny titlebars.
|
2003-09-29 16:35:12 +00:00
|
|
|
if ( height() < 16)
|
2001-04-22 09:31:42 +00:00
|
|
|
{
|
|
|
|
QPixmap tmpPix;
|
|
|
|
|
|
|
|
// Smooth scale the image
|
2006-04-22 18:12:21 +00:00
|
|
|
tmpPix.convertFromImage( btnpix.toImage().scaled(height(), height(), Qt::IgnoreAspectRatio,Qt::SmoothTransformation));
|
2001-04-22 09:31:42 +00:00
|
|
|
p->drawPixmap( 0, 0, tmpPix );
|
2003-09-29 16:35:12 +00:00
|
|
|
} else {
|
|
|
|
Offset += (height() - 16)/2;
|
2003-09-18 15:27:12 +00:00
|
|
|
p->drawPixmap( Offset, Offset, btnpix );
|
2003-09-29 16:35:12 +00:00
|
|
|
}
|
2001-04-22 09:31:42 +00:00
|
|
|
}
|
|
|
|
}
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
QuartzClient::QuartzClient(KDecorationBridge* bridge, KDecorationFactory* factory)
|
|
|
|
: KCommonDecoration (bridge, factory)
|
2001-04-22 09:31:42 +00:00
|
|
|
{
|
2001-03-17 11:49:51 +00:00
|
|
|
}
|
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
QString QuartzClient::visibleName() const
|
2001-03-17 11:49:51 +00:00
|
|
|
{
|
2005-03-21 15:53:41 +00:00
|
|
|
return i18n("Quartz");
|
2001-04-22 09:31:42 +00:00
|
|
|
}
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
QString QuartzClient::defaultButtonsLeft() const
|
2001-04-22 09:31:42 +00:00
|
|
|
{
|
2005-03-21 15:53:41 +00:00
|
|
|
return "M";
|
2001-03-17 11:49:51 +00:00
|
|
|
}
|
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
QString QuartzClient::defaultButtonsRight() const
|
2003-09-18 15:27:12 +00:00
|
|
|
{
|
2005-03-21 15:53:41 +00:00
|
|
|
return "HIAX";
|
2003-09-18 15:27:12 +00:00
|
|
|
}
|
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
bool QuartzClient::decorationBehaviour(DecorationBehaviour behaviour) const
|
2001-03-17 11:49:51 +00:00
|
|
|
{
|
2005-03-21 15:53:41 +00:00
|
|
|
switch (behaviour) {
|
|
|
|
case DB_MenuClose:
|
|
|
|
return false;
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
case DB_WindowMask:
|
|
|
|
return false;
|
2003-09-18 15:27:12 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
case DB_ButtonHide:
|
|
|
|
return true;
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
default:
|
|
|
|
return KCommonDecoration::decorationBehaviour(behaviour);
|
2003-09-18 15:27:12 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-03-26 13:18:32 +00:00
|
|
|
int QuartzClient::layoutMetric(LayoutMetric lm, bool respectWindowState, const KCommonDecorationButton *btn) const
|
2003-09-18 15:27:12 +00:00
|
|
|
{
|
2005-03-21 15:53:41 +00:00
|
|
|
bool maximized = maximizeMode()==MaximizeFull && !options()->moveResizeMaximizedWindows();
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
switch (lm) {
|
|
|
|
case LM_BorderLeft:
|
|
|
|
case LM_BorderRight:
|
|
|
|
case LM_BorderBottom:
|
|
|
|
case LM_TitleEdgeLeft:
|
|
|
|
case LM_TitleEdgeRight:
|
2001-04-22 09:31:42 +00:00
|
|
|
{
|
2005-03-21 15:53:41 +00:00
|
|
|
if (respectWindowState && maximized) {
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return borderSize;
|
2001-04-22 09:31:42 +00:00
|
|
|
}
|
|
|
|
}
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
case LM_TitleEdgeTop:
|
|
|
|
return borderSize-1;
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
case LM_TitleEdgeBottom:
|
|
|
|
return 1;
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
case LM_TitleBorderLeft:
|
|
|
|
case LM_TitleBorderRight:
|
|
|
|
return 5;
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
case LM_TitleHeight:
|
|
|
|
return titleHeight;
|
2001-06-04 09:51:23 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
case LM_ButtonWidth:
|
|
|
|
case LM_ButtonHeight:
|
|
|
|
return titleHeight-2;
|
2001-06-04 09:51:23 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
case LM_ButtonSpacing:
|
|
|
|
return 1;
|
2004-07-25 11:14:07 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
case LM_ExplicitButtonSpacer:
|
|
|
|
return 3;
|
|
|
|
|
|
|
|
default:
|
2005-03-26 13:18:32 +00:00
|
|
|
return KCommonDecoration::layoutMetric(lm, respectWindowState, btn);
|
2005-03-21 15:53:41 +00:00
|
|
|
}
|
2004-07-25 11:14:07 +00:00
|
|
|
}
|
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
KCommonDecorationButton *QuartzClient::createButton(ButtonType type)
|
2004-07-25 11:14:07 +00:00
|
|
|
{
|
2005-03-21 15:53:41 +00:00
|
|
|
switch (type) {
|
|
|
|
case MenuButton:
|
|
|
|
return new QuartzButton(MenuButton, this, "menu");
|
2004-07-25 11:14:07 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
case OnAllDesktopsButton:
|
|
|
|
return new QuartzButton(OnAllDesktopsButton, this, "on_all_desktops");
|
2004-07-25 11:14:07 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
case HelpButton:
|
|
|
|
return new QuartzButton(HelpButton, this, "help");
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
case MinButton:
|
|
|
|
return new QuartzButton(MinButton, this, "minimize");
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
case MaxButton:
|
|
|
|
return new QuartzButton(MaxButton, this, "maximize");
|
2004-07-25 11:14:07 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
case CloseButton:
|
|
|
|
return new QuartzButton(CloseButton, this, "close");
|
2004-07-25 11:14:07 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
case AboveButton:
|
|
|
|
return new QuartzButton(AboveButton, this, "above");
|
2004-07-25 11:14:07 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
case BelowButton:
|
|
|
|
return new QuartzButton(BelowButton, this, "below");
|
2004-07-25 11:14:07 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
case ShadeButton:
|
|
|
|
return new QuartzButton(ShadeButton, this, "shade");
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
default:
|
|
|
|
return 0;
|
2003-09-18 15:27:12 +00:00
|
|
|
}
|
2001-03-17 11:49:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-03-21 15:53:41 +00:00
|
|
|
void QuartzClient::init()
|
|
|
|
{
|
|
|
|
// Finally, toolWindows look small
|
|
|
|
if ( isToolWindow() ) {
|
|
|
|
titleHeight = toolTitleHeight;
|
|
|
|
largeButtons = false;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
titleHeight = normalTitleHeight;
|
|
|
|
largeButtons = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
borderSize = borderWidth;
|
|
|
|
|
|
|
|
KCommonDecoration::init();
|
|
|
|
}
|
|
|
|
|
|
|
|
void QuartzClient::reset( unsigned long changed )
|
2001-03-17 11:49:51 +00:00
|
|
|
{
|
2005-03-21 15:53:41 +00:00
|
|
|
if (changed & SettingColors || changed & SettingFont)
|
|
|
|
{
|
|
|
|
// repaint the whole thing
|
|
|
|
widget()->repaint(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
KCommonDecoration::reset(changed);
|
2001-03-17 11:49:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Quartz Paint magic goes here.
|
|
|
|
void QuartzClient::paintEvent( QPaintEvent* )
|
|
|
|
{
|
2001-05-26 02:34:47 +00:00
|
|
|
// Never paint if the pixmaps have not been created
|
|
|
|
if (!quartz_initialized)
|
2003-09-18 15:27:12 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
const bool maxFull = (maximizeMode()==MaximizeFull) && !options()->moveResizeMaximizedWindows();
|
2001-05-26 02:34:47 +00:00
|
|
|
|
|
|
|
QColorGroup g;
|
2003-09-18 15:27:12 +00:00
|
|
|
QPainter p(widget());
|
2001-03-17 11:49:51 +00:00
|
|
|
|
|
|
|
// Obtain widget bounds.
|
2003-09-18 15:27:12 +00:00
|
|
|
QRect r(widget()->rect());
|
2001-03-17 11:49:51 +00:00
|
|
|
int x = r.x();
|
|
|
|
int y = r.y();
|
|
|
|
int x2 = r.width() - 1;
|
|
|
|
int y2 = r.height() - 1;
|
|
|
|
int w = r.width();
|
|
|
|
int h = r.height();
|
|
|
|
|
|
|
|
// Draw part of the frame that is the title color
|
2001-05-26 02:34:47 +00:00
|
|
|
|
|
|
|
if( coloredFrame )
|
2006-03-04 22:27:27 +00:00
|
|
|
g = options()->palette(ColorTitleBar, isActive()).active();
|
2001-05-26 02:34:47 +00:00
|
|
|
else
|
2006-03-04 22:27:27 +00:00
|
|
|
g = options()->palette(ColorFrame, isActive()).active();
|
2003-09-18 15:27:12 +00:00
|
|
|
|
2001-03-17 11:49:51 +00:00
|
|
|
// Draw outer highlights and lowlights
|
|
|
|
p.setPen( g.light().light(120) );
|
|
|
|
p.drawLine( x, y, x2-1, y );
|
|
|
|
p.drawLine( x, y+1, x, y2-1 );
|
|
|
|
p.setPen( g.dark().light(120) );
|
|
|
|
p.drawLine( x2, y, x2, y2 );
|
|
|
|
p.drawLine( x, y2, x2, y2 );
|
|
|
|
|
|
|
|
// Fill out the border edges
|
2003-09-18 15:27:12 +00:00
|
|
|
QColor frameColor;
|
2001-05-26 02:34:47 +00:00
|
|
|
if ( coloredFrame)
|
2003-09-18 15:27:12 +00:00
|
|
|
frameColor = g.background().light(130);
|
2001-05-26 02:34:47 +00:00
|
|
|
else
|
2003-09-18 15:27:12 +00:00
|
|
|
frameColor = g.background();
|
|
|
|
if (borderSize > 2) {
|
|
|
|
p.fillRect(x+1, y+1, w-2, borderSize-2, frameColor); // top
|
|
|
|
if (!maxFull) {
|
|
|
|
p.fillRect(x+1, y+h-(borderSize-1), w-2, borderSize-2, frameColor); // bottom
|
|
|
|
p.fillRect(x+1, y+borderSize-1, borderSize-1, h-2*(borderSize-1), frameColor); // left
|
|
|
|
p.fillRect(x+w-(borderSize), y+borderSize-1, borderSize-1, h-2*(borderSize-1), frameColor); // right
|
|
|
|
}
|
|
|
|
}
|
2001-03-17 11:49:51 +00:00
|
|
|
|
|
|
|
// Draw a frame around the wrapped widget.
|
|
|
|
p.setPen( g.background() );
|
2003-09-18 15:27:12 +00:00
|
|
|
if (maxFull) {
|
|
|
|
p.drawLine(x+1, y+titleHeight+(borderSize-1), w-2, y+titleHeight+(borderSize-1));
|
|
|
|
} else {
|
|
|
|
p.drawRect( x+(borderSize-1), y+titleHeight+(borderSize-1), w-2*(borderSize-1), h-titleHeight-2*(borderSize-1) );
|
|
|
|
}
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2003-09-18 15:27:12 +00:00
|
|
|
// Drawing this extra line removes non-drawn areas when shaded
|
|
|
|
p.drawLine( x+borderSize, y2-borderSize, x2-borderSize, y2-borderSize);
|
2001-06-04 09:51:23 +00:00
|
|
|
|
2001-03-17 11:49:51 +00:00
|
|
|
// Highlight top corner
|
|
|
|
p.setPen( g.light().light(160) );
|
|
|
|
p.drawPoint( x, y );
|
|
|
|
p.setPen( g.light().light(140) );
|
|
|
|
p.drawPoint( x+1, y );
|
|
|
|
p.drawPoint( x, y+1 );
|
|
|
|
|
|
|
|
// Draw the title bar.
|
|
|
|
// ===================
|
2005-03-21 15:53:41 +00:00
|
|
|
int r_x, r_y, r_x2, r_y2;
|
2006-02-22 15:08:04 +00:00
|
|
|
widget()->rect().getCoords(&r_x, &r_y, &r_x2, &r_y2);
|
2005-03-21 15:53:41 +00:00
|
|
|
const int titleEdgeLeft = layoutMetric(LM_TitleEdgeLeft);
|
|
|
|
const int titleEdgeTop = layoutMetric(LM_TitleEdgeTop);
|
|
|
|
const int titleEdgeRight = layoutMetric(LM_TitleEdgeRight);
|
|
|
|
const int titleEdgeBottom = layoutMetric(LM_TitleEdgeBottom);
|
|
|
|
const int ttlHeight = layoutMetric(LM_TitleHeight);
|
|
|
|
const int titleEdgeBottomBottom = r_y+titleEdgeTop+ttlHeight+titleEdgeBottom-1;
|
|
|
|
r = QRect(r_x+titleEdgeLeft+buttonsLeftWidth(), r_y+titleEdgeTop,
|
|
|
|
r_x2-titleEdgeRight-buttonsRightWidth()-(r_x+titleEdgeLeft+buttonsLeftWidth()),
|
|
|
|
titleEdgeBottomBottom-(r_y+titleEdgeTop) );
|
2001-03-17 11:49:51 +00:00
|
|
|
|
|
|
|
// Obtain titlebar blend colours
|
2003-09-18 15:27:12 +00:00
|
|
|
QColor c1 = options()->color(ColorTitleBar, isActive() ).light(130);
|
|
|
|
QColor c2 = options()->color(ColorTitleBlend, isActive() );
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2003-09-18 15:27:12 +00:00
|
|
|
// Create a disposable pixmap buffer for the titlebar
|
2001-03-17 11:49:51 +00:00
|
|
|
KPixmap* titleBuffer = new KPixmap;
|
2003-09-18 15:27:12 +00:00
|
|
|
titleBuffer->resize( maxFull?w-2:(w-2*(borderSize-1)), titleHeight );
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2005-07-28 14:59:42 +00:00
|
|
|
QPainter p2( titleBuffer );
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2003-09-29 16:35:12 +00:00
|
|
|
// subtract titleBlocks pixmap width and some
|
|
|
|
int rightoffset = r.x()+r.width()-titleBlocks->width()-borderSize;
|
2002-08-27 15:12:14 +00:00
|
|
|
|
2001-04-22 09:31:42 +00:00
|
|
|
p2.fillRect( 0, 0, w, r.height(), c1 );
|
2003-09-18 15:27:12 +00:00
|
|
|
p2.fillRect( rightoffset, 0, maxFull?w-rightoffset:w-rightoffset-2*(borderSize-1), r.height(), c2 );
|
2001-03-17 11:49:51 +00:00
|
|
|
|
|
|
|
// 8 bit displays will be a bit dithered, but they still look ok.
|
|
|
|
if ( isActive() )
|
2001-04-22 09:31:42 +00:00
|
|
|
p2.drawPixmap( rightoffset, 0, *titleBlocks );
|
|
|
|
else
|
|
|
|
p2.drawPixmap( rightoffset, 0, *ititleBlocks );
|
2001-03-17 11:49:51 +00:00
|
|
|
|
2003-09-18 15:27:12 +00:00
|
|
|
// Draw the title text on the pixmap, and with a smaller font
|
|
|
|
// for toolwindows than the default.
|
|
|
|
QFont fnt;
|
|
|
|
if ( largeButtons ) {
|
|
|
|
fnt = options()->font(true, false); // font not small
|
|
|
|
} else {
|
|
|
|
fnt = options()->font(true, true); // font small
|
|
|
|
fnt.setWeight( QFont::Normal ); // and disable bold
|
|
|
|
}
|
2001-03-17 11:49:51 +00:00
|
|
|
p2.setFont( fnt );
|
|
|
|
|
2003-09-18 15:27:12 +00:00
|
|
|
p2.setPen( options()->color(ColorFont, isActive() ));
|
2003-09-29 16:35:12 +00:00
|
|
|
p2.drawText(r.x()+4-borderSize, 0, r.width()-3, r.height(),
|
2005-07-28 14:59:42 +00:00
|
|
|
Qt::AlignLeft | Qt::AlignVCenter, caption() );
|
2001-03-17 11:49:51 +00:00
|
|
|
p2.end();
|
|
|
|
|
2003-09-18 15:27:12 +00:00
|
|
|
p.drawPixmap( maxFull?1:borderSize-1, borderSize-1, *titleBuffer );
|
2001-03-17 11:49:51 +00:00
|
|
|
|
|
|
|
delete titleBuffer;
|
|
|
|
}
|
|
|
|
|
2003-07-26 10:41:28 +00:00
|
|
|
}
|
2001-04-22 09:31:42 +00:00
|
|
|
|
|
|
|
// Extended KWin plugin interface
|
|
|
|
/////////////////////////////////
|
2001-04-22 05:39:17 +00:00
|
|
|
extern "C"
|
|
|
|
{
|
2004-11-21 16:19:09 +00:00
|
|
|
KDE_EXPORT KDecorationFactory *create_factory()
|
2001-04-22 09:31:42 +00:00
|
|
|
{
|
2003-09-18 15:27:12 +00:00
|
|
|
Quartz::clientHandler = new Quartz::QuartzHandler();
|
|
|
|
return Quartz::clientHandler;
|
2001-04-22 09:31:42 +00:00
|
|
|
}
|
2001-04-22 05:39:17 +00:00
|
|
|
}
|
|
|
|
|
2001-04-22 09:31:42 +00:00
|
|
|
|
|
|
|
|
2001-03-17 11:49:51 +00:00
|
|
|
#include "quartz.moc"
|
2001-05-26 02:34:47 +00:00
|
|
|
// vim: ts=4
|
2005-03-21 15:53:41 +00:00
|
|
|
// kate: space-indent off; tab-width 4;
|