2002-05-17 16:33:48 +00:00
|
|
|
|
/*
|
|
|
|
|
*
|
2002-06-29 22:25:38 +00:00
|
|
|
|
* Keramik KWin client (version 0.8)
|
2002-05-17 16:33:48 +00:00
|
|
|
|
*
|
2004-06-27 16:18:56 +00:00
|
|
|
|
* Copyright (C) 2002 Fredrik H<EFBFBD>lund <fredrik@kde.org>
|
2002-05-17 16:33:48 +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
|
2005-10-05 08:44:32 +00:00
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
2005-07-04 19:02:09 +00:00
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2002-05-17 16:33:48 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <kconfig.h>
|
|
|
|
|
#include <klocale.h>
|
|
|
|
|
#include <kiconeffect.h>
|
|
|
|
|
|
2006-05-13 16:33:18 +00:00
|
|
|
|
#include <QPainter>
|
2006-05-11 08:04:23 +00:00
|
|
|
|
#include <QLayout>
|
2006-05-13 16:33:18 +00:00
|
|
|
|
#include <QBitmap>
|
|
|
|
|
#include <QStyle>
|
2006-05-11 08:04:23 +00:00
|
|
|
|
#include <QToolTip>
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
#include <QLabel>
|
2005-07-28 14:59:42 +00:00
|
|
|
|
#include <QEvent>
|
|
|
|
|
#include <QApplication>
|
2006-04-12 15:13:31 +00:00
|
|
|
|
#include <QStyle>
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
|
|
2003-09-18 17:07:49 +00:00
|
|
|
|
#include "keramik.h"
|
2002-05-17 16:33:48 +00:00
|
|
|
|
#include "keramik.moc"
|
|
|
|
|
|
2003-09-18 17:07:49 +00:00
|
|
|
|
|
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
// -------------------------------------------------------------------------------------------
|
|
|
|
|
|
2006-04-30 08:34:55 +00:00
|
|
|
|
static void flip( QPixmap *&pix )
|
|
|
|
|
{
|
|
|
|
|
QPixmap *tmp = new QPixmap( pix->transformed( QWMatrix(-1,0,0,1,pix->width(),0) ) );
|
|
|
|
|
delete pix;
|
|
|
|
|
pix = tmp;
|
|
|
|
|
}
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2006-04-30 08:34:55 +00:00
|
|
|
|
static void flip( QBitmap *&pix )
|
|
|
|
|
{
|
|
|
|
|
QBitmap *tmp = new QBitmap( pix->transformed( QWMatrix(-1,0,0,1,pix->width(),0) ) );
|
|
|
|
|
delete pix;
|
|
|
|
|
pix = tmp;
|
|
|
|
|
}
|
2002-06-24 18:33:20 +00:00
|
|
|
|
|
2002-06-29 22:25:38 +00:00
|
|
|
|
namespace Keramik
|
2002-06-23 08:39:44 +00:00
|
|
|
|
{
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2002-09-15 19:13:38 +00:00
|
|
|
|
const int buttonMargin = 9; // Margin between the window edge and the buttons
|
|
|
|
|
const int buttonSpacing = 4; // Spacing between the titlebar buttons
|
|
|
|
|
const int iconSpacing = 5; // Spacing between the icon and the text label
|
2002-06-24 18:33:20 +00:00
|
|
|
|
|
|
|
|
|
// Default button layout
|
|
|
|
|
const char default_left[] = "M";
|
2002-07-19 13:33:45 +00:00
|
|
|
|
const char default_right[] = "HIAX";
|
2002-06-24 18:33:20 +00:00
|
|
|
|
|
|
|
|
|
// Titlebar button bitmaps
|
2003-09-16 19:40:07 +00:00
|
|
|
|
const unsigned char menu_bits[] = {
|
2002-06-24 18:33:20 +00:00
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0xf0, 0x07, 0x00,
|
|
|
|
|
0xe0, 0x03, 0x00, 0xc0, 0x01, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00};
|
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
const unsigned char on_all_desktops_bits[] = {
|
2002-06-24 18:33:20 +00:00
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0xf0, 0x0f, 0x00,
|
|
|
|
|
0xf0, 0x0f, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00};
|
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
const unsigned char not_on_all_desktops_bits[] = {
|
2002-06-24 18:33:20 +00:00
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00,
|
|
|
|
|
0xf0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00};
|
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
const unsigned char help_bits[] = {
|
2002-06-24 18:33:20 +00:00
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00,
|
|
|
|
|
0xf0, 0x07, 0x00, 0x30, 0x06, 0x00, 0x00, 0x07, 0x00, 0x80, 0x03, 0x00,
|
|
|
|
|
0x80, 0x01, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x80, 0x01, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00};
|
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
const unsigned char minimize_bits[] = {
|
2002-06-24 18:33:20 +00:00
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0xf0, 0x0f, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00};
|
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
const unsigned char maximize_bits[] = {
|
2002-06-24 18:33:20 +00:00
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x80, 0x01, 0x00, 0xc0, 0x03, 0x00, 0xe0, 0x07, 0x00, 0xf0, 0x0f, 0x00,
|
|
|
|
|
0xf0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0xf0, 0x0f, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00};
|
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
const unsigned char restore_bits[] = {
|
2002-06-24 18:33:20 +00:00
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0xf0, 0x0f, 0x00, 0xf0, 0x0f, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00,
|
|
|
|
|
0xf0, 0x0f, 0x00, 0xe0, 0x07, 0x00, 0xc0, 0x03, 0x00, 0x80, 0x01, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00};
|
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
const unsigned char close_bits[] = {
|
2002-06-24 18:33:20 +00:00
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x30, 0x0c, 0x00, 0x70, 0x0e, 0x00, 0xe0, 0x07, 0x00, 0xc0, 0x03, 0x00,
|
|
|
|
|
0xc0, 0x03, 0x00, 0xe0, 0x07, 0x00, 0x70, 0x0e, 0x00, 0x30, 0x0c, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00};
|
|
|
|
|
|
2004-07-22 11:23:28 +00:00
|
|
|
|
const unsigned char above_on_bits[] = {
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0xf0, 0x0f, 0x00,
|
|
|
|
|
0x80, 0x01, 0x00, 0xe0, 0x07, 0x00, 0xc0, 0x03, 0x00, 0x80, 0x01, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00 };
|
|
|
|
|
|
|
|
|
|
const unsigned char above_off_bits[] = {
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0xc0, 0x03, 0x00,
|
|
|
|
|
0xe0, 0x07, 0x00, 0x80, 0x01, 0x00, 0xf0, 0x0f, 0x00, 0xf0, 0x0f, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00 };
|
|
|
|
|
|
|
|
|
|
const unsigned char below_on_bits[] = {
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0xc0, 0x03, 0x00,
|
|
|
|
|
0xe0, 0x07, 0x00, 0x80, 0x01, 0x00, 0xf0, 0x0f, 0x00, 0xf0, 0x0f, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00 };
|
|
|
|
|
|
|
|
|
|
const unsigned char below_off_bits[] = {
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0xf0, 0x0f, 0x00,
|
|
|
|
|
0x80, 0x01, 0x00, 0xe0, 0x07, 0x00, 0xc0, 0x03, 0x00, 0x80, 0x01, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00 };
|
|
|
|
|
|
|
|
|
|
const unsigned char shade_on_bits[] = {
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0xf0, 0x0f, 0x00,
|
|
|
|
|
0x10, 0x08, 0x00, 0x10, 0x08, 0x00, 0x10, 0x08, 0x00, 0x10, 0x08, 0x00,
|
|
|
|
|
0x10, 0x08, 0x00, 0x10, 0x08, 0x00, 0x10, 0x08, 0x00, 0xf0, 0x0f, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00 };
|
|
|
|
|
|
|
|
|
|
const unsigned char shade_off_bits[] = {
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x0f, 0x00, 0xf0, 0x0f, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
|
|
|
0x00, 0x00, 0x00 };
|
2002-06-24 18:33:20 +00:00
|
|
|
|
|
|
|
|
|
KeramikHandler *clientHandler = NULL;
|
|
|
|
|
bool keramik_initialized = false;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
KeramikHandler::KeramikHandler()
|
|
|
|
|
{
|
|
|
|
|
for ( int i = 0; i < NumTiles; i++ ) {
|
|
|
|
|
activeTiles[i] = NULL;
|
|
|
|
|
inactiveTiles[i] = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
settings_cache = NULL;
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
// Create the button deco bitmaps
|
2006-04-12 15:13:31 +00:00
|
|
|
|
buttonDecos[ Menu ] = new QBitmap( QBitmap::fromData( QSize( 17, 17 ), menu_bits ) );
|
|
|
|
|
buttonDecos[ OnAllDesktops ] = new QBitmap( QBitmap::fromData( QSize( 17, 17 ), on_all_desktops_bits ) );
|
|
|
|
|
buttonDecos[ NotOnAllDesktops ] = new QBitmap( QBitmap::fromData( QSize( 17, 17 ), not_on_all_desktops_bits ) );
|
|
|
|
|
buttonDecos[ Help ] = new QBitmap( QBitmap::fromData( QSize( 17, 17 ), help_bits ) );
|
|
|
|
|
buttonDecos[ Minimize ] = new QBitmap( QBitmap::fromData( QSize( 17, 17 ), minimize_bits ) );
|
|
|
|
|
buttonDecos[ Maximize ] = new QBitmap( QBitmap::fromData( QSize( 17, 17 ), maximize_bits ) );
|
|
|
|
|
buttonDecos[ Restore ] = new QBitmap( QBitmap::fromData( QSize( 17, 17 ), restore_bits ) );
|
|
|
|
|
buttonDecos[ Close ] = new QBitmap( QBitmap::fromData( QSize( 17, 17 ), close_bits ) );
|
|
|
|
|
buttonDecos[ AboveOn ] = new QBitmap( QBitmap::fromData( QSize( 17, 17 ), above_on_bits ) );
|
|
|
|
|
buttonDecos[ AboveOff ] = new QBitmap( QBitmap::fromData( QSize( 17, 17 ), above_off_bits ) );
|
|
|
|
|
buttonDecos[ BelowOn ] = new QBitmap( QBitmap::fromData( QSize( 17, 17 ), below_on_bits ) );
|
|
|
|
|
buttonDecos[ BelowOff ] = new QBitmap( QBitmap::fromData( QSize( 17, 17 ), below_off_bits ) );
|
|
|
|
|
buttonDecos[ ShadeOn ] = new QBitmap( QBitmap::fromData( QSize( 17, 17 ), shade_on_bits ) );
|
|
|
|
|
buttonDecos[ ShadeOff ] = new QBitmap( QBitmap::fromData( QSize( 17, 17 ), shade_off_bits ) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
// Selfmask the bitmaps
|
|
|
|
|
for ( int i = 0; i < NumButtonDecos; i++ )
|
|
|
|
|
buttonDecos[i]->setMask( *buttonDecos[i] );
|
|
|
|
|
|
|
|
|
|
// Flip the bitmaps horizontally in right-to-left mode
|
2005-11-10 11:50:13 +00:00
|
|
|
|
if ( QApplication::isRightToLeft() ) {
|
2006-04-30 08:34:55 +00:00
|
|
|
|
for ( int i = 0; i < Help; ++i )
|
|
|
|
|
::flip( buttonDecos[i] );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2006-04-30 08:34:55 +00:00
|
|
|
|
for ( int i = Help + 1; i < NumButtonDecos; ++i )
|
|
|
|
|
::flip( buttonDecos[i] );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
readConfig();
|
|
|
|
|
createPixmaps();
|
|
|
|
|
|
|
|
|
|
keramik_initialized = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
KeramikHandler::~KeramikHandler()
|
|
|
|
|
{
|
|
|
|
|
keramik_initialized = false;
|
|
|
|
|
destroyPixmaps();
|
|
|
|
|
|
|
|
|
|
for ( int i = 0; i < NumButtonDecos; i++ )
|
|
|
|
|
delete buttonDecos[i];
|
|
|
|
|
|
2003-09-18 17:07:49 +00:00
|
|
|
|
delete settings_cache;
|
2002-08-27 15:12:14 +00:00
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
clientHandler = NULL;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeramikHandler::createPixmaps()
|
|
|
|
|
{
|
2003-09-28 09:59:11 +00:00
|
|
|
|
int heightOffset;
|
|
|
|
|
int widthOffset;
|
|
|
|
|
switch(options()->preferredBorderSize(this)) {
|
|
|
|
|
case BorderLarge:
|
|
|
|
|
widthOffset = 4;
|
|
|
|
|
heightOffset = 0;
|
|
|
|
|
break;
|
|
|
|
|
case BorderVeryLarge:
|
|
|
|
|
widthOffset = 8;
|
|
|
|
|
heightOffset = 0;
|
|
|
|
|
break;
|
|
|
|
|
case BorderHuge:
|
|
|
|
|
widthOffset = 14;
|
|
|
|
|
heightOffset = 0;
|
|
|
|
|
break;
|
|
|
|
|
case BorderVeryHuge:
|
|
|
|
|
widthOffset = 23;
|
|
|
|
|
heightOffset = 10;
|
|
|
|
|
break;
|
|
|
|
|
case BorderOversized:
|
|
|
|
|
widthOffset = 36;
|
|
|
|
|
heightOffset = 25;
|
|
|
|
|
break;
|
|
|
|
|
case BorderTiny:
|
|
|
|
|
case BorderNormal:
|
|
|
|
|
default:
|
|
|
|
|
widthOffset = 0;
|
|
|
|
|
heightOffset = 0;
|
|
|
|
|
}
|
|
|
|
|
int fontHeight = QFontMetrics(options()->font(true)).height();
|
|
|
|
|
if (fontHeight > heightOffset + 20)
|
|
|
|
|
heightOffset = fontHeight - 20;
|
2003-10-31 17:05:21 +00:00
|
|
|
|
|
2003-09-28 09:59:11 +00:00
|
|
|
|
QString size = (heightOffset < 8) ? "" : (heightOffset < 20) ? "-large" : "-huge";
|
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
QColor titleColor, captionColor, buttonColor;
|
|
|
|
|
QImage *titleCenter = NULL, *captionLeft = NULL,
|
|
|
|
|
*captionRight = NULL, *captionCenter = NULL;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
// Active tiles
|
|
|
|
|
// -------------------------------------------------------------------------
|
2006-04-10 11:57:13 +00:00
|
|
|
|
captionColor = KDecoration::options()->color( ColorTitleBar, true );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
titleColor = KDecoration::options()->color( ColorTitleBlend, true );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
// Load the titlebar corners.
|
2006-04-10 11:57:13 +00:00
|
|
|
|
activeTiles[ TitleLeft ] = loadPixmap( "titlebar-left", titleColor );
|
2002-06-24 18:33:20 +00:00
|
|
|
|
activeTiles[ TitleRight ] = loadPixmap( "titlebar-right", titleColor );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
// Load the titlebar center tile image (this will be used as
|
|
|
|
|
// the background for the caption bubble tiles).
|
|
|
|
|
titleCenter = loadImage( "titlebar-center", titleColor );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
|
|
|
|
// Load the small version of the caption bubble corner & center images.
|
2006-04-10 11:57:13 +00:00
|
|
|
|
captionLeft = loadImage( "caption-small-left", captionColor );
|
|
|
|
|
captionRight = loadImage( "caption-small-right", captionColor );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
captionCenter = loadImage( "caption-small-center", captionColor );
|
|
|
|
|
|
|
|
|
|
// Create the caption bubble tiles (by blending the images onto the titlebar)
|
2006-04-10 11:57:13 +00:00
|
|
|
|
activeTiles[ CaptionSmallLeft ] = composite( captionLeft, titleCenter );
|
|
|
|
|
activeTiles[ CaptionSmallRight ] = composite( captionRight, titleCenter );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
activeTiles[ CaptionSmallCenter ] = composite( captionCenter, titleCenter );
|
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
delete captionLeft;
|
|
|
|
|
delete captionRight;
|
|
|
|
|
delete captionCenter;
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
|
|
|
|
// Now do the same with the large version
|
2006-04-10 11:57:13 +00:00
|
|
|
|
captionLeft = loadImage( "caption-large-left", captionColor );
|
|
|
|
|
captionRight = loadImage( "caption-large-right", captionColor );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
captionCenter = loadImage( "caption-large-center", captionColor );
|
|
|
|
|
|
2006-04-10 11:57:13 +00:00
|
|
|
|
activeTiles[ CaptionLargeLeft ] = composite( captionLeft, titleCenter );
|
|
|
|
|
activeTiles[ CaptionLargeRight ] = composite( captionRight, titleCenter );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
activeTiles[ CaptionLargeCenter ] = composite( captionCenter, titleCenter );
|
|
|
|
|
|
|
|
|
|
delete captionLeft;
|
|
|
|
|
delete captionRight;
|
|
|
|
|
delete captionCenter;
|
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
// Create the titlebar center tile
|
2006-04-12 15:13:31 +00:00
|
|
|
|
activeTiles[ TitleCenter ] = new QPixmap( QPixmap::fromImage( *titleCenter ) );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
delete titleCenter;
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
// Load the left & right border pixmaps
|
2006-04-10 11:57:13 +00:00
|
|
|
|
activeTiles[ BorderLeft ] = loadPixmap( "border-left", titleColor );
|
2002-06-24 18:33:20 +00:00
|
|
|
|
activeTiles[ BorderRight ] = loadPixmap( "border-right", titleColor );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
// Load the bottom grabbar pixmaps
|
2002-09-01 22:50:34 +00:00
|
|
|
|
if ( largeGrabBars ) {
|
2006-04-10 11:57:13 +00:00
|
|
|
|
activeTiles[ GrabBarLeft ] = loadPixmap( "grabbar-left", titleColor );
|
|
|
|
|
activeTiles[ GrabBarRight ] = loadPixmap( "grabbar-right", titleColor );
|
2002-09-01 22:50:34 +00:00
|
|
|
|
activeTiles[ GrabBarCenter ] = loadPixmap( "grabbar-center", titleColor );
|
|
|
|
|
} else {
|
2006-04-10 11:57:13 +00:00
|
|
|
|
activeTiles[ GrabBarLeft ] = loadPixmap( "bottom-left", titleColor );
|
|
|
|
|
activeTiles[ GrabBarRight ] = loadPixmap( "bottom-right", titleColor );
|
2002-09-01 22:50:34 +00:00
|
|
|
|
activeTiles[ GrabBarCenter ] = loadPixmap( "bottom-center", titleColor );
|
|
|
|
|
}
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
// Inactive tiles
|
|
|
|
|
// -------------------------------------------------------------------------
|
2006-04-10 11:57:13 +00:00
|
|
|
|
captionColor = KDecoration::options()->color( ColorTitleBar, false );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
titleColor = KDecoration::options()->color( ColorTitleBlend, false );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
2006-04-10 11:57:13 +00:00
|
|
|
|
inactiveTiles[ TitleLeft ] = loadPixmap( "titlebar-left", titleColor );
|
2002-06-24 18:33:20 +00:00
|
|
|
|
inactiveTiles[ TitleRight ] = loadPixmap( "titlebar-right", titleColor );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
titleCenter = loadImage( "titlebar-center", titleColor );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
2006-04-10 11:57:13 +00:00
|
|
|
|
captionLeft = loadImage( "caption-small-left", captionColor );
|
|
|
|
|
captionRight = loadImage( "caption-small-right", captionColor );
|
2002-06-24 18:33:20 +00:00
|
|
|
|
captionCenter = loadImage( "caption-small-center", captionColor );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
2006-04-10 11:57:13 +00:00
|
|
|
|
inactiveTiles[ CaptionSmallLeft ] = composite( captionLeft, titleCenter );
|
|
|
|
|
inactiveTiles[ CaptionSmallRight ] = composite( captionRight, titleCenter );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
inactiveTiles[ CaptionSmallCenter ] = composite( captionCenter, titleCenter );
|
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
delete captionLeft;
|
|
|
|
|
delete captionRight;
|
|
|
|
|
delete captionCenter;
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
2006-04-12 15:13:31 +00:00
|
|
|
|
inactiveTiles[ TitleCenter ] = new QPixmap( QPixmap::fromImage( *titleCenter ) );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
delete titleCenter;
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
2006-04-10 11:57:13 +00:00
|
|
|
|
inactiveTiles[ BorderLeft ] = loadPixmap( "border-left", titleColor );
|
2002-06-24 18:33:20 +00:00
|
|
|
|
inactiveTiles[ BorderRight ] = loadPixmap( "border-right", titleColor );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
2002-09-01 22:50:34 +00:00
|
|
|
|
if ( largeGrabBars ) {
|
2006-04-10 11:57:13 +00:00
|
|
|
|
inactiveTiles[ GrabBarLeft ] = loadPixmap( "grabbar-left", titleColor );
|
|
|
|
|
inactiveTiles[ GrabBarRight ] = loadPixmap( "grabbar-right", titleColor );
|
2002-09-01 22:50:34 +00:00
|
|
|
|
inactiveTiles[ GrabBarCenter ] = loadPixmap( "grabbar-center", titleColor );
|
|
|
|
|
} else {
|
2006-04-10 11:57:13 +00:00
|
|
|
|
inactiveTiles[ GrabBarLeft ] = loadPixmap( "bottom-left", titleColor );
|
|
|
|
|
inactiveTiles[ GrabBarRight ] = loadPixmap( "bottom-right", titleColor );
|
2002-09-01 22:50:34 +00:00
|
|
|
|
inactiveTiles[ GrabBarCenter ] = loadPixmap( "bottom-center", titleColor );
|
|
|
|
|
}
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
// Buttons
|
|
|
|
|
// -------------------------------------------------------------------------
|
2003-09-16 19:40:07 +00:00
|
|
|
|
buttonColor = QColor(); //KDecoration::options()->color( ButtonBg, true );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
2006-04-10 11:57:13 +00:00
|
|
|
|
titleButtonRound = loadPixmap( "titlebutton-round"+size, buttonColor );
|
2003-09-28 09:59:11 +00:00
|
|
|
|
titleButtonSquare = loadPixmap( "titlebutton-square"+size, buttonColor );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
|
|
|
|
|
// Prepare the tiles for use
|
|
|
|
|
// -------------------------------------------------------------------------
|
2005-11-10 11:50:13 +00:00
|
|
|
|
if ( QApplication::isRightToLeft() ) {
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
// Fix lighting
|
2002-06-29 22:25:38 +00:00
|
|
|
|
flip( activeTiles[CaptionSmallLeft], activeTiles[CaptionSmallRight] );
|
|
|
|
|
flip( inactiveTiles[CaptionSmallLeft], inactiveTiles[CaptionSmallRight] );
|
|
|
|
|
|
|
|
|
|
flip( activeTiles[CaptionLargeLeft], activeTiles[CaptionLargeRight] );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
flip( activeTiles[TitleLeft], activeTiles[TitleRight] );
|
|
|
|
|
flip( inactiveTiles[TitleLeft], inactiveTiles[TitleRight] );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
flip( activeTiles[BorderLeft], activeTiles[BorderRight] );
|
|
|
|
|
flip( inactiveTiles[BorderLeft], inactiveTiles[BorderRight] );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
flip( activeTiles[GrabBarLeft], activeTiles[GrabBarRight] );
|
|
|
|
|
flip( inactiveTiles[GrabBarLeft], inactiveTiles[GrabBarRight] );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
2006-04-30 08:34:55 +00:00
|
|
|
|
::flip( titleButtonRound );
|
|
|
|
|
::flip( titleButtonSquare );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
2002-06-24 18:33:20 +00:00
|
|
|
|
|
|
|
|
|
// Pretile the center & border tiles for optimal performance
|
2002-06-29 22:25:38 +00:00
|
|
|
|
pretile( activeTiles[ CaptionSmallCenter ], 64, Qt::Horizontal );
|
|
|
|
|
pretile( activeTiles[ CaptionLargeCenter ], 64, Qt::Horizontal );
|
2002-06-24 18:33:20 +00:00
|
|
|
|
pretile( activeTiles[ TitleCenter ], 64, Qt::Horizontal );
|
|
|
|
|
pretile( activeTiles[ GrabBarCenter ], 128, Qt::Horizontal );
|
|
|
|
|
pretile( activeTiles[ BorderLeft ], 128, Qt::Vertical );
|
|
|
|
|
pretile( activeTiles[ BorderRight ], 128, Qt::Vertical );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
|
|
|
|
pretile( inactiveTiles[ CaptionSmallCenter ], 64, Qt::Horizontal );
|
2002-06-24 18:33:20 +00:00
|
|
|
|
pretile( inactiveTiles[ TitleCenter ], 64, Qt::Horizontal );
|
|
|
|
|
pretile( inactiveTiles[ GrabBarCenter ], 128, Qt::Horizontal );
|
|
|
|
|
pretile( inactiveTiles[ BorderLeft ], 128, Qt::Vertical );
|
|
|
|
|
pretile( inactiveTiles[ BorderRight ], 128, Qt::Vertical );
|
2003-10-31 17:05:21 +00:00
|
|
|
|
|
2003-09-28 09:59:11 +00:00
|
|
|
|
if (heightOffset > 0) {
|
|
|
|
|
addHeight (heightOffset, activeTiles[TitleLeft]);
|
|
|
|
|
addHeight (heightOffset, activeTiles[TitleCenter]);
|
|
|
|
|
addHeight (heightOffset, activeTiles[TitleRight]);
|
|
|
|
|
addHeight (heightOffset, activeTiles[CaptionSmallLeft]);
|
|
|
|
|
addHeight (heightOffset, activeTiles[CaptionSmallCenter]);
|
|
|
|
|
addHeight (heightOffset, activeTiles[CaptionSmallRight]);
|
|
|
|
|
addHeight (heightOffset, activeTiles[CaptionLargeLeft]);
|
|
|
|
|
addHeight (heightOffset, activeTiles[CaptionLargeCenter]);
|
|
|
|
|
addHeight (heightOffset, activeTiles[CaptionLargeRight]);
|
2003-10-31 17:05:21 +00:00
|
|
|
|
|
2003-09-28 09:59:11 +00:00
|
|
|
|
addHeight (heightOffset, inactiveTiles[TitleLeft]);
|
|
|
|
|
addHeight (heightOffset, inactiveTiles[TitleCenter]);
|
|
|
|
|
addHeight (heightOffset, inactiveTiles[TitleRight]);
|
|
|
|
|
addHeight (heightOffset, inactiveTiles[CaptionSmallLeft]);
|
|
|
|
|
addHeight (heightOffset, inactiveTiles[CaptionSmallCenter]);
|
|
|
|
|
addHeight (heightOffset, inactiveTiles[CaptionSmallRight]);
|
|
|
|
|
}
|
2003-10-31 17:05:21 +00:00
|
|
|
|
|
2003-09-28 09:59:11 +00:00
|
|
|
|
if (widthOffset > 0) {
|
|
|
|
|
addWidth (widthOffset, activeTiles[BorderLeft], true, activeTiles[GrabBarCenter]);
|
|
|
|
|
addWidth (widthOffset, activeTiles[BorderRight], false, activeTiles[GrabBarCenter]);
|
|
|
|
|
addWidth (widthOffset, inactiveTiles[BorderLeft], true, inactiveTiles[GrabBarCenter]);
|
|
|
|
|
addWidth (widthOffset, inactiveTiles[BorderRight], false, inactiveTiles[GrabBarCenter]);
|
2003-10-31 17:05:21 +00:00
|
|
|
|
|
2003-09-28 09:59:11 +00:00
|
|
|
|
if (largeGrabBars)
|
|
|
|
|
widthOffset = widthOffset*3/2;
|
2003-10-31 17:05:21 +00:00
|
|
|
|
|
2003-09-28 09:59:11 +00:00
|
|
|
|
addHeight (widthOffset, activeTiles[GrabBarLeft]);
|
|
|
|
|
addHeight (widthOffset, activeTiles[GrabBarCenter]);
|
|
|
|
|
addHeight (widthOffset, activeTiles[GrabBarRight]);
|
|
|
|
|
addHeight (widthOffset, inactiveTiles[GrabBarLeft]);
|
|
|
|
|
addHeight (widthOffset, inactiveTiles[GrabBarCenter]);
|
|
|
|
|
addHeight (widthOffset, inactiveTiles[GrabBarRight]);
|
|
|
|
|
}
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeramikHandler::destroyPixmaps()
|
|
|
|
|
{
|
|
|
|
|
for ( int i = 0; i < NumTiles; i++ ) {
|
2003-09-18 17:07:49 +00:00
|
|
|
|
delete activeTiles[i];
|
|
|
|
|
delete inactiveTiles[i];
|
|
|
|
|
activeTiles[i] = NULL;
|
|
|
|
|
inactiveTiles[i] = NULL;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete titleButtonRound;
|
|
|
|
|
delete titleButtonSquare;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-28 09:59:11 +00:00
|
|
|
|
void KeramikHandler::addWidth (int width, QPixmap *&pix, bool left, QPixmap *bottomPix) {
|
|
|
|
|
int w = pix->width()+width;
|
|
|
|
|
int h = pix->height();
|
|
|
|
|
|
|
|
|
|
QPixmap *tmp = new QPixmap (w, h);
|
|
|
|
|
tmp->fill ();
|
|
|
|
|
QPainter p;
|
|
|
|
|
p.begin (tmp);
|
2003-10-31 17:05:21 +00:00
|
|
|
|
|
2003-09-28 09:59:11 +00:00
|
|
|
|
for (int i = 0; i < h; i++)
|
|
|
|
|
p.drawPixmap (0, i, *bottomPix, i%2, 0, w,1);
|
2003-10-31 17:05:21 +00:00
|
|
|
|
|
2003-09-28 09:59:11 +00:00
|
|
|
|
if (left)
|
|
|
|
|
p.drawPixmap(0, 0, *pix);
|
|
|
|
|
else
|
|
|
|
|
p.drawPixmap(width, 0, *pix);
|
2003-10-31 17:05:21 +00:00
|
|
|
|
|
2003-09-28 09:59:11 +00:00
|
|
|
|
p.end();
|
|
|
|
|
|
|
|
|
|
delete pix;
|
|
|
|
|
pix = tmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeramikHandler::addHeight (int height, QPixmap *&pix) {
|
|
|
|
|
int w = pix->width();
|
|
|
|
|
int h = pix->height()+height;
|
|
|
|
|
|
|
|
|
|
QPixmap *tmp = new QPixmap (w, h);
|
|
|
|
|
QPainter p;
|
|
|
|
|
p.begin (tmp);
|
|
|
|
|
if (pix->height() > 10) {
|
|
|
|
|
p.drawPixmap(0, 0, *pix, 0, 0, w, 11);
|
|
|
|
|
for (int i = 0; i < height; i+=2)
|
|
|
|
|
p.drawPixmap(0, 11+i, *pix, 0, 11, w, 2);
|
|
|
|
|
p.drawPixmap(0, 11+height, *pix, 0, 11, w, -1);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
int lines = h-3;
|
|
|
|
|
int factor = pix->height()-3;
|
|
|
|
|
for (int i = 0; i < lines; i++)
|
|
|
|
|
p.drawPixmap(0, i, *pix, 0, i*factor/lines, w, 1);
|
|
|
|
|
p.drawPixmap(0, lines, *pix, 0, factor, w, 3);
|
|
|
|
|
}
|
|
|
|
|
p.end();
|
|
|
|
|
|
|
|
|
|
delete pix;
|
|
|
|
|
pix = tmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
void KeramikHandler::flip( QPixmap *&pix1, QPixmap *&pix2 )
|
|
|
|
|
{
|
|
|
|
|
// Flip the pixmaps horizontally
|
2005-11-11 10:13:57 +00:00
|
|
|
|
QPixmap *tmp = new QPixmap( pix1->transformed( QMatrix(-1,0,0,1,pix1->width(),0) ) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
delete pix1;
|
2005-11-11 10:13:57 +00:00
|
|
|
|
pix1 = new QPixmap( pix2->transformed( QMatrix(-1,0,0,1,pix2->width(),0) ) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
delete pix2;
|
|
|
|
|
pix2 = tmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
void KeramikHandler::pretile( QPixmap *&pix, int size, Qt::Orientation dir )
|
|
|
|
|
{
|
|
|
|
|
QPixmap *newpix;
|
|
|
|
|
QPainter p;
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
if ( dir == Qt::Horizontal )
|
|
|
|
|
newpix = new QPixmap( size, pix->height() );
|
|
|
|
|
else
|
|
|
|
|
newpix = new QPixmap( pix->width(), size );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
p.begin( newpix );
|
|
|
|
|
p.drawTiledPixmap( newpix->rect(), *pix ) ;
|
|
|
|
|
p.end();
|
|
|
|
|
|
|
|
|
|
delete pix;
|
|
|
|
|
pix = newpix;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
void KeramikHandler::readConfig()
|
|
|
|
|
{
|
|
|
|
|
KConfig *c = new KConfig( "kwinkeramikrc" );
|
|
|
|
|
|
|
|
|
|
c->setGroup( "General" );
|
2006-01-03 14:01:15 +00:00
|
|
|
|
showIcons = c->readEntry( "ShowAppIcons", QVariant(true )).toBool();
|
|
|
|
|
shadowedText = c->readEntry( "UseShadowedText", QVariant(true )).toBool();
|
|
|
|
|
smallCaptionBubbles = c->readEntry( "SmallCaptionBubbles", QVariant(false )).toBool();
|
|
|
|
|
largeGrabBars = c->readEntry( "LargeGrabBars", QVariant(true )).toBool();
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
if ( ! settings_cache ) {
|
|
|
|
|
settings_cache = new SettingsCache;
|
2002-09-01 22:50:34 +00:00
|
|
|
|
settings_cache->largeGrabBars = largeGrabBars;
|
2003-09-28 09:59:11 +00:00
|
|
|
|
settings_cache->smallCaptionBubbles = smallCaptionBubbles;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
delete c;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
QPixmap *KeramikHandler::composite( QImage *over, QImage *under )
|
2002-05-17 16:33:48 +00:00
|
|
|
|
{
|
2006-04-12 15:13:31 +00:00
|
|
|
|
QImage dest( over->width(), over->height(), QImage::Format_RGB32 );
|
2002-06-24 18:33:20 +00:00
|
|
|
|
int width = over->width(), height = over->height();
|
|
|
|
|
|
|
|
|
|
// Clear the destination image
|
|
|
|
|
Q_UINT32 *data = reinterpret_cast<Q_UINT32*>( dest.bits() );
|
|
|
|
|
for (int i = 0; i < width * height; i++)
|
2003-09-16 19:40:07 +00:00
|
|
|
|
*(data++) = 0;
|
2002-06-24 18:33:20 +00:00
|
|
|
|
|
|
|
|
|
// Copy the under image (bottom aligned) to the destination image
|
|
|
|
|
for (int y1 = height - under->height(), y2 = 0; y1 < height; y1++, y2++ )
|
|
|
|
|
{
|
|
|
|
|
register Q_UINT32 *dst = reinterpret_cast<Q_UINT32*>( dest.scanLine(y1) );
|
|
|
|
|
register Q_UINT32 *src = reinterpret_cast<Q_UINT32*>( under->scanLine(y2) );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
for ( int x = 0; x < width; x++ )
|
|
|
|
|
*(dst++) = *(src++);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Blend the over image onto the destination
|
|
|
|
|
register Q_UINT32 *dst = reinterpret_cast<Q_UINT32*>( dest.bits() );
|
|
|
|
|
register Q_UINT32 *src = reinterpret_cast<Q_UINT32*>( over->bits() );
|
|
|
|
|
for ( int i = 0; i < width * height; i++ )
|
|
|
|
|
{
|
|
|
|
|
int r1 = qRed( *dst ), g1 = qGreen( *dst ), b1 = qBlue( *dst );
|
|
|
|
|
int r2 = qRed( *src ), g2 = qGreen( *src ), b2 = qBlue( *src );
|
|
|
|
|
int a = qAlpha( *src );
|
|
|
|
|
|
|
|
|
|
if ( a == 0xff )
|
|
|
|
|
*dst = *src;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
else if ( a != 0x00 )
|
|
|
|
|
*dst = qRgba( Q_UINT8( r1 + (((r2 - r1) * a) >> 8) ),
|
|
|
|
|
Q_UINT8( g1 + (((g2 - g1) * a) >> 8) ),
|
|
|
|
|
Q_UINT8( b1 + (((b2 - b1) * a) >> 8) ),
|
|
|
|
|
0xff );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
else if ( qAlpha(*dst) == 0x00 )
|
|
|
|
|
*dst = 0;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
src++; dst++;
|
|
|
|
|
}
|
2002-08-31 22:37:35 +00:00
|
|
|
|
|
|
|
|
|
// Create the final pixmap and return it
|
2006-04-12 15:13:31 +00:00
|
|
|
|
return new QPixmap( QPixmap::fromImage( dest ) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
QImage *KeramikHandler::loadImage( const QString &name, const QColor &col )
|
2002-05-17 16:33:48 +00:00
|
|
|
|
{
|
2002-06-24 18:33:20 +00:00
|
|
|
|
if ( col.isValid() ) {
|
2005-07-28 14:59:42 +00:00
|
|
|
|
QImage *img = new QImage( ":/pics/" + name + ".png" );
|
2002-06-24 18:33:20 +00:00
|
|
|
|
KIconEffect::colorize( *img, col, 1.0 );
|
|
|
|
|
return img;
|
|
|
|
|
} else
|
2005-07-28 14:59:42 +00:00
|
|
|
|
return new QImage( ":/pics/" + name + ".png" );
|
2002-06-24 18:33:20 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
QPixmap *KeramikHandler::loadPixmap( const QString &name, const QColor &col )
|
|
|
|
|
{
|
|
|
|
|
QImage *img = loadImage( name, col );
|
2006-04-12 15:13:31 +00:00
|
|
|
|
QPixmap *pix = new QPixmap( QPixmap::fromImage( *img ) );
|
2002-06-24 18:33:20 +00:00
|
|
|
|
delete img;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
return pix;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
bool KeramikHandler::reset( unsigned long changed )
|
2002-05-17 16:33:48 +00:00
|
|
|
|
{
|
|
|
|
|
keramik_initialized = false;
|
2002-09-01 22:50:34 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
bool needHardReset = false;
|
|
|
|
|
bool pixmapsInvalid = false;
|
|
|
|
|
|
|
|
|
|
// Re-read the config file
|
|
|
|
|
readConfig();
|
|
|
|
|
|
2003-09-28 09:59:11 +00:00
|
|
|
|
if ( changed & SettingBorder )
|
|
|
|
|
{
|
|
|
|
|
pixmapsInvalid = true;
|
|
|
|
|
needHardReset = true;
|
|
|
|
|
}
|
|
|
|
|
if ( changed & SettingFont )
|
|
|
|
|
{
|
|
|
|
|
pixmapsInvalid = true;
|
|
|
|
|
needHardReset = true;
|
|
|
|
|
}
|
2002-05-17 16:33:48 +00:00
|
|
|
|
// Check if the color scheme has changed
|
2003-09-16 19:40:07 +00:00
|
|
|
|
if ( changed & SettingColors )
|
2002-06-24 18:33:20 +00:00
|
|
|
|
{
|
2002-05-17 16:33:48 +00:00
|
|
|
|
pixmapsInvalid = true;
|
|
|
|
|
}
|
|
|
|
|
// Check if button positions have changed
|
2002-09-01 22:50:34 +00:00
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
if ( changed & SettingButtons ) {
|
2002-05-17 16:33:48 +00:00
|
|
|
|
needHardReset = true;
|
|
|
|
|
}
|
2002-09-01 22:50:34 +00:00
|
|
|
|
|
|
|
|
|
// Check if tooltips options have changed
|
2003-09-16 19:40:07 +00:00
|
|
|
|
if ( changed & SettingTooltips ) {
|
2002-09-01 22:50:34 +00:00
|
|
|
|
needHardReset = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( (settings_cache->largeGrabBars != largeGrabBars) ) {
|
|
|
|
|
pixmapsInvalid = true;
|
|
|
|
|
needHardReset = true;
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-28 09:59:11 +00:00
|
|
|
|
if ( (settings_cache->smallCaptionBubbles != smallCaptionBubbles) ) {
|
|
|
|
|
needHardReset = true;
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
// Update our config cache
|
2003-09-16 19:40:07 +00:00
|
|
|
|
settings_cache->largeGrabBars = largeGrabBars;
|
2003-09-28 09:59:11 +00:00
|
|
|
|
settings_cache->smallCaptionBubbles = smallCaptionBubbles;
|
2002-09-01 22:50:34 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
// Do we need to recreate the pixmaps?
|
|
|
|
|
if ( pixmapsInvalid ) {
|
|
|
|
|
destroyPixmaps();
|
|
|
|
|
createPixmaps();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
keramik_initialized = true;
|
|
|
|
|
|
|
|
|
|
// Do we need to "hit the wooden hammer" ?
|
2003-09-16 19:40:07 +00:00
|
|
|
|
if ( !needHardReset )
|
2003-09-18 17:07:49 +00:00
|
|
|
|
resetDecorations( changed );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
return needHardReset;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-11-05 15:33:09 +00:00
|
|
|
|
bool KeramikHandler::supports( Ability ability )
|
|
|
|
|
{
|
|
|
|
|
switch( ability )
|
|
|
|
|
{
|
|
|
|
|
case AbilityAnnounceButtons:
|
|
|
|
|
case AbilityButtonMenu:
|
|
|
|
|
case AbilityButtonOnAllDesktops:
|
|
|
|
|
case AbilityButtonSpacer:
|
|
|
|
|
case AbilityButtonHelp:
|
|
|
|
|
case AbilityButtonMinimize:
|
|
|
|
|
case AbilityButtonMaximize:
|
|
|
|
|
case AbilityButtonClose:
|
|
|
|
|
case AbilityButtonAboveOthers:
|
|
|
|
|
case AbilityButtonBelowOthers:
|
|
|
|
|
case AbilityButtonShade:
|
|
|
|
|
return true;
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
const QPixmap *KeramikHandler::tile( TilePixmap tilePix, bool active ) const
|
|
|
|
|
{
|
|
|
|
|
return ( active ? activeTiles[ tilePix ] : inactiveTiles[ tilePix ] );
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
KDecoration* KeramikHandler::createDecoration( KDecorationBridge* bridge )
|
|
|
|
|
{
|
|
|
|
|
return new KeramikClient( bridge, this );
|
|
|
|
|
}
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2005-07-28 14:59:42 +00:00
|
|
|
|
QList< KeramikHandler::BorderSize > KeramikHandler::borderSizes() const
|
2003-09-28 09:59:11 +00:00
|
|
|
|
{ // the list must be sorted
|
2005-07-28 14:59:42 +00:00
|
|
|
|
return QList< BorderSize >() << BorderNormal << BorderLarge <<
|
2003-09-28 09:59:11 +00:00
|
|
|
|
BorderVeryLarge << BorderHuge << BorderVeryHuge << BorderOversized;
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
// -------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-11-02 11:03:41 +00:00
|
|
|
|
KeramikButton::KeramikButton( KeramikClient* c, const char *name, Button btn, const QString &tip, const int realizeBtns )
|
2005-07-28 14:59:42 +00:00
|
|
|
|
: Q3Button( c->widget(), name ),
|
|
|
|
|
client( c ), button( btn ), hover( false ), lastbutton( Qt::NoButton )
|
2002-05-17 16:33:48 +00:00
|
|
|
|
{
|
2003-11-02 11:03:41 +00:00
|
|
|
|
realizeButtons = realizeBtns;
|
|
|
|
|
|
2005-09-21 09:14:36 +00:00
|
|
|
|
this->setToolTip( tip ); // FRAME
|
2006-04-12 15:13:31 +00:00
|
|
|
|
setAttribute( Qt::WA_NoSystemBackground );
|
2005-10-27 09:07:06 +00:00
|
|
|
|
setCursor( Qt::ArrowCursor );
|
2003-09-28 09:59:11 +00:00
|
|
|
|
int size = clientHandler->roundButton()->height();
|
|
|
|
|
setFixedSize( size, size );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2006-03-06 14:44:06 +00:00
|
|
|
|
setCheckable( (button == OnAllDesktopsButton) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
KeramikButton::~KeramikButton()
|
|
|
|
|
{
|
|
|
|
|
// Empty.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeramikButton::enterEvent( QEvent *e )
|
|
|
|
|
{
|
2005-07-28 14:59:42 +00:00
|
|
|
|
Q3Button::enterEvent( e );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
hover = true;
|
2006-04-12 15:13:31 +00:00
|
|
|
|
repaint();
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeramikButton::leaveEvent( QEvent *e )
|
|
|
|
|
{
|
2005-07-28 14:59:42 +00:00
|
|
|
|
Q3Button::leaveEvent( e );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
hover = false;
|
2006-04-12 15:13:31 +00:00
|
|
|
|
repaint();
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeramikButton::mousePressEvent( QMouseEvent *e )
|
|
|
|
|
{
|
|
|
|
|
lastbutton = e->button();
|
2006-04-12 15:13:31 +00:00
|
|
|
|
QMouseEvent me( e->type(), e->pos(), e->globalPos(),
|
|
|
|
|
(e->button()&realizeButtons)?Qt::LeftButton : Qt::NoButton,
|
|
|
|
|
(e->button()&realizeButtons)?Qt::LeftButton : Qt::NoButton,
|
|
|
|
|
e->modifiers() );
|
2005-07-28 14:59:42 +00:00
|
|
|
|
Q3Button::mousePressEvent( &me );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeramikButton::mouseReleaseEvent( QMouseEvent *e )
|
|
|
|
|
{
|
|
|
|
|
lastbutton = e->button();
|
2006-04-12 15:13:31 +00:00
|
|
|
|
QMouseEvent me( e->type(), e->pos(), e->globalPos(),
|
|
|
|
|
(e->button()&realizeButtons)?Qt::LeftButton : Qt::NoButton,
|
|
|
|
|
(e->button()&realizeButtons)?Qt::LeftButton : Qt::NoButton,
|
|
|
|
|
e->modifiers() );
|
2005-07-28 14:59:42 +00:00
|
|
|
|
Q3Button::mouseReleaseEvent( &me );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeramikButton::drawButton( QPainter *p )
|
|
|
|
|
{
|
|
|
|
|
const QPixmap *pix;
|
|
|
|
|
const QBitmap *deco;
|
2003-09-28 09:59:11 +00:00
|
|
|
|
int size = clientHandler->roundButton()->height();
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
// Get the bevel from the client handler
|
2003-09-16 19:40:07 +00:00
|
|
|
|
if ( button == MenuButton || button == OnAllDesktopsButton || button == HelpButton )
|
2002-05-17 16:33:48 +00:00
|
|
|
|
pix = clientHandler->roundButton();
|
|
|
|
|
else
|
|
|
|
|
pix = clientHandler->squareButton();
|
|
|
|
|
|
|
|
|
|
// Draw the button background
|
2003-09-28 09:59:11 +00:00
|
|
|
|
const QPixmap *background = clientHandler->tile( TitleCenter, client->isActive() );
|
|
|
|
|
p->drawPixmap( 0, 0, *background,
|
|
|
|
|
0, (background->height()-size+1)/2, size, size );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
if ( isDown() ) {
|
|
|
|
|
// Pressed
|
2005-11-10 11:50:13 +00:00
|
|
|
|
p->drawPixmap( QPoint(), *pix, QStyle::visualRect( QApplication::isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight, QRect(2*size, 0, size, size), pix->rect() ) );
|
2006-04-10 11:57:13 +00:00
|
|
|
|
p->translate( QApplication::isRightToLeft() ? -1 : 1, 1 );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
} else if ( hover )
|
|
|
|
|
// Mouse over
|
2005-11-10 11:50:13 +00:00
|
|
|
|
p->drawPixmap( QPoint(), *pix, QStyle::visualRect( QApplication::isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight, QRect(size, 0, size, size), pix->rect() ) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
else
|
|
|
|
|
// Normal
|
2005-11-10 11:50:13 +00:00
|
|
|
|
p->drawPixmap( QPoint(), *pix, QStyle::visualRect( QApplication::isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight, QRect(0, 0, size, size), pix->rect() ) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
// Draw the button deco on the bevel
|
|
|
|
|
switch ( button ) {
|
|
|
|
|
case MenuButton:
|
|
|
|
|
deco = clientHandler->buttonDeco( Menu );
|
|
|
|
|
break;
|
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
case OnAllDesktopsButton:
|
2004-07-22 11:23:28 +00:00
|
|
|
|
deco = clientHandler->buttonDeco( client->isOnAllDesktops() ? NotOnAllDesktops : OnAllDesktops );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case HelpButton:
|
|
|
|
|
deco = clientHandler->buttonDeco( Help );
|
2002-06-24 18:33:20 +00:00
|
|
|
|
// The '?' won't be flipped around in the ctor, so we need to
|
|
|
|
|
// shift it to the right to compensate for the button shadow
|
|
|
|
|
// being on the left side of the button in RTL mode.
|
2005-11-10 11:50:13 +00:00
|
|
|
|
if ( QApplication::isRightToLeft() )
|
2002-06-24 18:33:20 +00:00
|
|
|
|
p->translate( 2, 0 );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
break;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
case MinButton:
|
2003-09-16 19:40:07 +00:00
|
|
|
|
deco = clientHandler->buttonDeco( Minimize );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
break;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
|
|
|
|
case MaxButton:
|
|
|
|
|
deco = clientHandler->buttonDeco( client->maximizeMode() == KeramikClient::MaximizeFull ? Restore : Maximize );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case CloseButton:
|
|
|
|
|
deco = clientHandler->buttonDeco( Close );
|
|
|
|
|
break;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2004-07-22 11:23:28 +00:00
|
|
|
|
case AboveButton:
|
|
|
|
|
deco = clientHandler->buttonDeco( client->keepAbove() ? AboveOn : AboveOff );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case BelowButton:
|
|
|
|
|
deco = clientHandler->buttonDeco( client->keepBelow() ? BelowOn : BelowOff );
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ShadeButton:
|
|
|
|
|
deco = clientHandler->buttonDeco( client->isSetShade() ? ShadeOn : ShadeOff );
|
|
|
|
|
break;
|
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
default:
|
|
|
|
|
deco = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
p->setPen( Qt::black ); // ### hardcoded color
|
2006-04-21 11:43:32 +00:00
|
|
|
|
if (deco)
|
|
|
|
|
p->drawPixmap( (size-17)/2, (size-17)/2, *deco );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
KeramikClient::KeramikClient( KDecorationBridge* bridge, KDecorationFactory* factory )
|
|
|
|
|
: KDecoration( bridge, factory ),
|
2002-05-17 16:33:48 +00:00
|
|
|
|
activeIcon( NULL ), inactiveIcon( NULL ), captionBufferDirty( true ), maskDirty( true )
|
|
|
|
|
{
|
2003-09-16 19:40:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KeramikClient::init()
|
|
|
|
|
{
|
2004-07-22 11:23:28 +00:00
|
|
|
|
connect( this, SIGNAL( keepAboveChanged( bool )), SLOT( keepAboveChange( bool )));
|
|
|
|
|
connect( this, SIGNAL( keepBelowChanged( bool )), SLOT( keepBelowChange( bool )));
|
|
|
|
|
|
2005-07-28 14:59:42 +00:00
|
|
|
|
createMainWidget( Qt::WResizeNoErase );
|
|
|
|
|
widget()->setAttribute( Qt::WA_StaticContents );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
widget()->installEventFilter( this );
|
2003-09-18 17:07:49 +00:00
|
|
|
|
|
|
|
|
|
// Minimize flicker
|
2006-04-12 15:13:31 +00:00
|
|
|
|
widget()->setAttribute( Qt::WA_NoSystemBackground );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
for ( int i=0; i < NumButtons; i++ )
|
|
|
|
|
button[i] = NULL;
|
2003-09-18 17:07:49 +00:00
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
createLayout();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void KeramikClient::createLayout()
|
|
|
|
|
{
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
QVBoxLayout *mainLayout = new QVBoxLayout( widget() );
|
2006-04-12 15:13:31 +00:00
|
|
|
|
QBoxLayout *titleLayout = new QBoxLayout( QBoxLayout::LeftToRight );
|
|
|
|
|
titleLayout->setMargin( 0 );
|
|
|
|
|
titleLayout->setSpacing( 0 );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
QHBoxLayout *windowLayout = new QHBoxLayout();
|
|
|
|
|
|
2002-06-29 22:25:38 +00:00
|
|
|
|
largeTitlebar = ( !maximizedVertical() && clientHandler->largeCaptionBubbles() );
|
|
|
|
|
largeCaption = ( isActive() && largeTitlebar );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-09-01 22:50:34 +00:00
|
|
|
|
int grabBarHeight = clientHandler->grabBarHeight();
|
2002-06-29 22:25:38 +00:00
|
|
|
|
int topSpacing = ( largeTitlebar ? 4 : 1 );
|
2003-09-28 09:59:11 +00:00
|
|
|
|
int leftBorderWidth = clientHandler->tile( BorderLeft, true )->width();
|
|
|
|
|
int rightBorderWidth = clientHandler->tile( BorderRight, true )->width();
|
2002-06-29 22:25:38 +00:00
|
|
|
|
topSpacer = new QSpacerItem( 10, topSpacing,
|
|
|
|
|
QSizePolicy::Expanding, QSizePolicy::Minimum );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2002-06-29 22:25:38 +00:00
|
|
|
|
mainLayout->addItem( topSpacer );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-09-01 22:50:34 +00:00
|
|
|
|
mainLayout->addLayout( titleLayout ); // Titlebar
|
|
|
|
|
mainLayout->addLayout( windowLayout, 1 ); // Left border + window + right border
|
|
|
|
|
mainLayout->addSpacing( grabBarHeight ); // Bottom grab bar
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
titleLayout->setSpacing( buttonSpacing );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
titleLayout->addSpacing( buttonMargin ); // Left button margin
|
2003-09-16 19:40:07 +00:00
|
|
|
|
addButtons( titleLayout, options()->customButtonPositions() ?
|
|
|
|
|
options()->titleButtonsLeft() : QString(default_left) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2002-06-29 22:25:38 +00:00
|
|
|
|
titlebar = new QSpacerItem( 10, clientHandler->titleBarHeight(largeTitlebar)
|
|
|
|
|
- topSpacing, QSizePolicy::Expanding, QSizePolicy::Minimum );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
titleLayout->addItem( titlebar );
|
|
|
|
|
|
|
|
|
|
titleLayout->addSpacing( buttonSpacing );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
addButtons( titleLayout, options()->customButtonPositions() ?
|
|
|
|
|
options()->titleButtonsRight() : QString(default_right) );
|
2002-06-24 18:33:20 +00:00
|
|
|
|
titleLayout->addSpacing( buttonMargin - 1 ); // Right button margin
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2003-09-28 09:59:11 +00:00
|
|
|
|
windowLayout->addSpacing( leftBorderWidth ); // Left border
|
2003-10-30 18:01:43 +00:00
|
|
|
|
if( isPreview())
|
2004-11-05 17:02:03 +00:00
|
|
|
|
windowLayout->addWidget( new QLabel( i18n( "<center><b>Keramik preview</b></center>" ), widget()));
|
2003-10-30 18:01:43 +00:00
|
|
|
|
else
|
|
|
|
|
windowLayout->addItem( new QSpacerItem( 0, 0 )); //no widget in the middle
|
2003-09-28 09:59:11 +00:00
|
|
|
|
windowLayout->addSpacing( rightBorderWidth ); // Right border
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
KeramikClient::~KeramikClient()
|
|
|
|
|
{
|
2003-09-18 17:07:49 +00:00
|
|
|
|
delete activeIcon;
|
|
|
|
|
delete inactiveIcon;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
activeIcon = inactiveIcon = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-18 17:07:49 +00:00
|
|
|
|
void KeramikClient::reset( unsigned long )
|
2002-05-17 16:33:48 +00:00
|
|
|
|
{
|
2002-06-29 22:25:38 +00:00
|
|
|
|
if ( clientHandler->largeCaptionBubbles() && !largeTitlebar )
|
|
|
|
|
{
|
|
|
|
|
// We're switching from small caption bubbles to large
|
|
|
|
|
if ( !maximizedVertical() ) {
|
|
|
|
|
topSpacer->changeSize( 10, 4, QSizePolicy::Expanding, QSizePolicy::Minimum );
|
|
|
|
|
largeTitlebar = true;
|
|
|
|
|
largeCaption = isActive();
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
|
|
|
|
widget()->layout()->activate();
|
|
|
|
|
|
2002-06-29 22:25:38 +00:00
|
|
|
|
// Compensate for the titlebar size change
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
|
|
|
|
// TODO This is wrong, this may break size increments (see bug #53784).
|
|
|
|
|
// FRAME
|
|
|
|
|
widget()->setGeometry( widget()->x(), widget()->y() - 3, width(), height() + 3 );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if ( !clientHandler->largeCaptionBubbles() && largeTitlebar )
|
|
|
|
|
{
|
|
|
|
|
// We're switching from large caption bubbles to small
|
|
|
|
|
topSpacer->changeSize( 10, 1, QSizePolicy::Expanding, QSizePolicy::Minimum );
|
|
|
|
|
largeTitlebar = largeCaption = false;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
|
|
|
|
widget()->layout()->activate();
|
|
|
|
|
|
2002-06-29 22:25:38 +00:00
|
|
|
|
// Compensate for the titlebar size change
|
2003-09-16 19:40:07 +00:00
|
|
|
|
// FRAME
|
|
|
|
|
widget()->setGeometry( widget()->x(), widget()->y() + 3, width(), height() - 3 );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
}
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
calculateCaptionRect();
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
captionBufferDirty = maskDirty = true;
|
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
// Only repaint the window if it's visible
|
2002-06-29 22:25:38 +00:00
|
|
|
|
// (i.e. not minimized and on the current desktop)
|
2003-09-16 19:40:07 +00:00
|
|
|
|
if ( widget()->isVisible() ) {
|
2006-04-12 15:13:31 +00:00
|
|
|
|
widget()->repaint();
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
for ( int i = 0; i < NumButtons; i++ )
|
2006-04-12 15:13:31 +00:00
|
|
|
|
if ( button[i] ) button[i]->repaint();
|
2002-06-24 18:33:20 +00:00
|
|
|
|
}
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
|
2002-08-27 15:12:14 +00:00
|
|
|
|
void KeramikClient::addButtons( QBoxLayout *layout, const QString &s )
|
2002-05-17 16:33:48 +00:00
|
|
|
|
{
|
2005-07-28 14:59:42 +00:00
|
|
|
|
for ( int i=0; i < s.length(); i++ )
|
2002-08-27 15:12:14 +00:00
|
|
|
|
{
|
2006-04-12 15:13:31 +00:00
|
|
|
|
switch ( s[i].toLatin1() )
|
2002-05-17 16:33:48 +00:00
|
|
|
|
{
|
|
|
|
|
// Menu button
|
|
|
|
|
case 'M' :
|
|
|
|
|
if ( !button[MenuButton] ) {
|
2005-07-28 14:59:42 +00:00
|
|
|
|
button[MenuButton] = new KeramikButton( this, "menu", MenuButton, i18n("Menu"), Qt::LeftButton|Qt::RightButton );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
connect( button[MenuButton], SIGNAL( pressed() ), SLOT( menuButtonPressed() ) );
|
|
|
|
|
layout->addWidget( button[MenuButton] );
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
// OnAllDesktops button
|
2002-05-17 16:33:48 +00:00
|
|
|
|
case 'S' :
|
2003-09-16 19:40:07 +00:00
|
|
|
|
if ( !button[OnAllDesktopsButton] ) {
|
2003-09-18 17:07:49 +00:00
|
|
|
|
button[OnAllDesktopsButton] = new KeramikButton( this, "on_all_desktops",
|
2004-06-27 16:18:56 +00:00
|
|
|
|
OnAllDesktopsButton, isOnAllDesktops()?i18n("Not on all desktops"):i18n("On all desktops") );
|
2004-01-09 18:20:29 +00:00
|
|
|
|
if(isOnAllDesktops())
|
|
|
|
|
button[OnAllDesktopsButton]->toggle();
|
2003-09-16 19:40:07 +00:00
|
|
|
|
connect( button[OnAllDesktopsButton], SIGNAL( clicked() ), SLOT( toggleOnAllDesktops() ) );
|
|
|
|
|
layout->addWidget( button[OnAllDesktopsButton] );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
break;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
// Help button
|
|
|
|
|
case 'H' :
|
|
|
|
|
if ( !button[HelpButton] && providesContextHelp() ) {
|
|
|
|
|
button[HelpButton] = new KeramikButton( this, "help", HelpButton, i18n("Help") );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
connect( button[HelpButton], SIGNAL( clicked() ), SLOT( showContextHelp() ) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
layout->addWidget( button[HelpButton] );
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// Minimize button
|
|
|
|
|
case 'I' :
|
|
|
|
|
if ( !button[MinButton] && isMinimizable() ) {
|
2003-09-16 19:40:07 +00:00
|
|
|
|
button[MinButton] = new KeramikButton( this, "minimize", MinButton, i18n("Minimize") );
|
|
|
|
|
connect( button[MinButton], SIGNAL( clicked() ), SLOT( minimize() ) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
layout->addWidget( button[MinButton] );
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// Maximize button
|
|
|
|
|
case 'A' :
|
|
|
|
|
if ( !button[MaxButton] && isMaximizable() ) {
|
2005-07-28 14:59:42 +00:00
|
|
|
|
button[MaxButton] = new KeramikButton( this, "maximize", MaxButton, i18n("Maximize"), Qt::LeftButton|Qt::MidButton|Qt::RightButton );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
connect( button[MaxButton], SIGNAL( clicked() ), SLOT( slotMaximize() ) );
|
|
|
|
|
layout->addWidget( button[MaxButton] );
|
|
|
|
|
}
|
|
|
|
|
break;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
// Close button
|
|
|
|
|
case 'X' :
|
2002-08-28 15:17:31 +00:00
|
|
|
|
if ( !button[CloseButton] && isCloseable() ) {
|
2002-05-17 16:33:48 +00:00
|
|
|
|
button[CloseButton] = new KeramikButton( this, "close", CloseButton, i18n("Close") );
|
|
|
|
|
connect( button[CloseButton], SIGNAL( clicked() ), SLOT( closeWindow() ) );
|
|
|
|
|
layout->addWidget( button[CloseButton] );
|
|
|
|
|
}
|
|
|
|
|
break;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2004-07-22 11:23:28 +00:00
|
|
|
|
// Above button
|
|
|
|
|
case 'F' :
|
|
|
|
|
if ( !button[AboveButton]) {
|
|
|
|
|
button[AboveButton] = new KeramikButton( this, "above", AboveButton, i18n("Keep Above Others") );
|
|
|
|
|
connect( button[AboveButton], SIGNAL( clicked() ), SLOT( slotAbove() ) );
|
|
|
|
|
layout->addWidget( button[AboveButton] );
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// Below button
|
|
|
|
|
case 'B' :
|
|
|
|
|
if ( !button[BelowButton]) {
|
|
|
|
|
button[BelowButton] = new KeramikButton( this, "below", BelowButton, i18n("Keep Below Others") );
|
|
|
|
|
connect( button[BelowButton], SIGNAL( clicked() ), SLOT( slotBelow() ) );
|
|
|
|
|
layout->addWidget( button[BelowButton] );
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
// Shade button
|
|
|
|
|
case 'L' :
|
|
|
|
|
if ( !button[ShadeButton] && isShadeable() ) {
|
|
|
|
|
button[ShadeButton] = new KeramikButton( this, "shade", ShadeButton,
|
|
|
|
|
isSetShade() ? i18n("Unshade") : i18n( "Shade" ));
|
|
|
|
|
connect( button[ShadeButton], SIGNAL( clicked() ), SLOT( slotShade() ) );
|
|
|
|
|
layout->addWidget( button[ShadeButton] );
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
// Additional spacing
|
|
|
|
|
case '_' :
|
|
|
|
|
layout->addSpacing( buttonSpacing );
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeramikClient::updateMask()
|
|
|
|
|
{
|
|
|
|
|
if ( !keramik_initialized )
|
|
|
|
|
return;
|
|
|
|
|
|
2002-06-29 22:25:38 +00:00
|
|
|
|
// To maximize performance this code uses precalculated bounding rects
|
|
|
|
|
// to set the window mask. This saves us from having to allocate a 1bpp
|
|
|
|
|
// pixmap, paint the mask on it and then have the X server iterate
|
|
|
|
|
// over the pixels to compute the bounding rects from it.
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2003-09-18 17:07:49 +00:00
|
|
|
|
QRegion r;
|
2002-06-29 22:25:38 +00:00
|
|
|
|
register int w, y = 0;
|
|
|
|
|
int nrects;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2005-11-10 11:50:13 +00:00
|
|
|
|
if ( QApplication::isRightToLeft() ) {
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2002-06-29 22:25:38 +00:00
|
|
|
|
// If the caption bubble is visible and extends above the titlebar
|
|
|
|
|
if ( largeCaption && captionRect.width() >= 25 ) {
|
|
|
|
|
register int x = captionRect.left();
|
|
|
|
|
w = captionRect.width();
|
2003-09-18 17:07:49 +00:00
|
|
|
|
r += QRegion( x + 11, y++, w - 19, 1 );
|
2006-04-10 11:57:13 +00:00
|
|
|
|
r += QRegion( x + 9, y++, w - 15, 1 );
|
|
|
|
|
r += QRegion( x + 7, y++, w - 12, 1 );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
} else {
|
|
|
|
|
nrects = 8;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-06-29 22:25:38 +00:00
|
|
|
|
// Do we have a large titlebar with a retracted caption bubble?
|
|
|
|
|
// (i.e. the style is set to use large caption bubbles, we're
|
|
|
|
|
// not maximized and not active)
|
|
|
|
|
if ( largeTitlebar )
|
|
|
|
|
y = 3;
|
|
|
|
|
}
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
|
|
|
|
w = width(); // FRAME
|
2002-06-29 22:25:38 +00:00
|
|
|
|
|
|
|
|
|
// The rounded titlebar corners
|
2003-09-18 17:07:49 +00:00
|
|
|
|
r += QRegion( 9, y++, w - 17, 1 );
|
|
|
|
|
r += QRegion( 7, y++, w - 13, 1 );
|
2006-04-10 11:57:13 +00:00
|
|
|
|
r += QRegion( 5, y++, w - 9, 1 );
|
|
|
|
|
r += QRegion( 4, y++, w - 7, 1 );
|
|
|
|
|
r += QRegion( 3, y++, w - 5, 1 );
|
|
|
|
|
r += QRegion( 2, y++, w - 4, 1 );
|
|
|
|
|
r += QRegion( 1, y++, w - 2, 2 );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
} else {
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2002-06-29 22:25:38 +00:00
|
|
|
|
// If the caption bubble is visible and extends above the titlebar
|
|
|
|
|
if ( largeCaption && captionRect.width() >= 25 ) {
|
|
|
|
|
nrects = 11;
|
|
|
|
|
register int x = captionRect.left();
|
|
|
|
|
w = captionRect.width();
|
2003-09-18 17:07:49 +00:00
|
|
|
|
r += QRegion( x + 8, y++, w - 19, 1 );
|
|
|
|
|
r += QRegion( x + 6, y++, w - 15, 1 );
|
|
|
|
|
r += QRegion( x + 5, y++, w - 12, 1 );
|
2002-06-29 22:25:38 +00:00
|
|
|
|
} else {
|
|
|
|
|
nrects = 8;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2002-06-29 22:25:38 +00:00
|
|
|
|
// Do we have a large titlebar with a retracted caption bubble?
|
|
|
|
|
// (i.e. the style is set to use large caption bubbles, we're
|
|
|
|
|
// not maximized and not active)
|
|
|
|
|
if ( largeTitlebar )
|
|
|
|
|
y = 3;
|
|
|
|
|
}
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
w = width(); // FRAME
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2002-06-29 22:25:38 +00:00
|
|
|
|
// The rounded titlebar corners
|
2003-09-18 17:07:49 +00:00
|
|
|
|
r += QRegion( 8, y++, w - 17, 1 );
|
|
|
|
|
r += QRegion( 6, y++, w - 13, 1 );
|
2006-04-10 11:57:13 +00:00
|
|
|
|
r += QRegion( 4, y++, w - 9, 1 );
|
|
|
|
|
r += QRegion( 3, y++, w - 7, 1 );
|
|
|
|
|
r += QRegion( 2, y++, w - 5, 1 );
|
|
|
|
|
r += QRegion( 2, y++, w - 4, 1 );
|
|
|
|
|
r += QRegion( 1, y++, w - 2, 2 );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-06-29 22:25:38 +00:00
|
|
|
|
y++;
|
2002-06-24 18:33:20 +00:00
|
|
|
|
|
2002-06-29 22:25:38 +00:00
|
|
|
|
// The part of the window below the titlebar
|
2003-09-18 17:07:49 +00:00
|
|
|
|
r += QRegion( 0, y, w, height() - y );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2003-09-18 17:07:49 +00:00
|
|
|
|
setMask( r, YXBanded );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
maskDirty = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeramikClient::updateCaptionBuffer()
|
|
|
|
|
{
|
|
|
|
|
if ( !keramik_initialized )
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
bool active = isActive();
|
|
|
|
|
QPixmap *icon = NULL;
|
|
|
|
|
|
|
|
|
|
if ( captionBuffer.size() != captionRect.size() )
|
2006-04-26 16:05:58 +00:00
|
|
|
|
captionBuffer = QPixmap( captionRect.size() );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2003-09-18 17:07:49 +00:00
|
|
|
|
if ( captionBuffer.isNull() )
|
|
|
|
|
return;
|
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
QPainter p( &captionBuffer );
|
|
|
|
|
|
|
|
|
|
// Draw the caption bubble
|
2002-06-29 22:25:38 +00:00
|
|
|
|
if ( active && largeCaption ) {
|
|
|
|
|
p.drawPixmap( 0, 0, *clientHandler->tile( CaptionLargeLeft, true ) );
|
|
|
|
|
p.drawTiledPixmap( 15, 0, captionRect.width() - 30, captionRect.height(),
|
|
|
|
|
*clientHandler->tile( CaptionLargeCenter, true ) );
|
|
|
|
|
p.drawPixmap( captionRect.width() - 15, 0, *clientHandler->tile( CaptionLargeRight, true ) );
|
|
|
|
|
} else {
|
|
|
|
|
p.drawPixmap( 0, 0, *clientHandler->tile( CaptionSmallLeft, active ) );
|
|
|
|
|
p.drawTiledPixmap( 15, 0, captionRect.width() - 30, captionRect.height(),
|
|
|
|
|
*clientHandler->tile( CaptionSmallCenter, active ) );
|
|
|
|
|
p.drawPixmap( captionRect.width() - 15, 0, *clientHandler->tile( CaptionSmallRight, active ) );
|
|
|
|
|
}
|
2002-08-31 22:37:35 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
if ( clientHandler->showAppIcons() )
|
|
|
|
|
{
|
2006-04-12 15:13:31 +00:00
|
|
|
|
QStyle *style = button[ 0 ]->style();
|
2002-05-17 16:33:48 +00:00
|
|
|
|
if ( active ) {
|
2002-06-24 18:33:20 +00:00
|
|
|
|
if ( ! activeIcon )
|
2006-04-12 15:13:31 +00:00
|
|
|
|
activeIcon = new QPixmap( this->icon().pixmap( style->pixelMetric( QStyle::PM_SmallIconSize ), QIcon::Normal )); // FRAME
|
2002-05-17 16:33:48 +00:00
|
|
|
|
icon = activeIcon;
|
|
|
|
|
} else {
|
|
|
|
|
if ( ! inactiveIcon ) {
|
2006-04-12 15:13:31 +00:00
|
|
|
|
QImage img = this->icon().pixmap( style->pixelMetric( QStyle::PM_SmallIconSize ), QIcon::Normal ).toImage();
|
2002-05-17 16:33:48 +00:00
|
|
|
|
KIconEffect::semiTransparent( img );
|
2006-04-12 15:13:31 +00:00
|
|
|
|
inactiveIcon = new QPixmap( QPixmap::fromImage( img ) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
icon = inactiveIcon;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
p.setFont( options()->font( active ) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
int tw = p.fontMetrics().width( caption() ) +
|
|
|
|
|
( clientHandler->showAppIcons() ? 16 + iconSpacing : 0 );
|
|
|
|
|
|
2006-02-17 21:54:55 +00:00
|
|
|
|
int xpos = qMax( (captionRect.width() - tw) / 3, 8 );
|
2005-11-10 11:50:13 +00:00
|
|
|
|
QRect tr = QStyle::visualRect( QApplication::isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight, QRect(xpos, 1, captionRect.width() - xpos - 10,
|
2002-05-17 16:33:48 +00:00
|
|
|
|
captionRect.height() - 4), captionBuffer.rect() );
|
|
|
|
|
|
|
|
|
|
//p.setPen( Qt::red ); // debug
|
|
|
|
|
//p.drawRect( tr ); // debug
|
2002-08-31 22:37:35 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
// Application icon
|
|
|
|
|
if ( clientHandler->showAppIcons() )
|
|
|
|
|
{
|
2005-11-10 11:50:13 +00:00
|
|
|
|
QRect iconRect = QStyle::visualRect( QApplication::isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight, QRect(tr.x(),
|
2002-06-24 18:33:20 +00:00
|
|
|
|
1 + (captionRect.height() - 4 - 16) / 2, 16, 16), tr );
|
|
|
|
|
QRect r( icon->rect() );
|
|
|
|
|
r.moveCenter( iconRect.center() );
|
2002-08-31 22:37:35 +00:00
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
if ( tr.width() > 16 ) {
|
2002-05-17 16:33:48 +00:00
|
|
|
|
p.drawPixmap( r, *icon );
|
2002-06-24 18:33:20 +00:00
|
|
|
|
} else {
|
|
|
|
|
QRect sr( 0, 0, icon->width(), icon->height() );
|
2002-08-31 22:37:35 +00:00
|
|
|
|
|
2005-11-10 11:50:13 +00:00
|
|
|
|
if ( QApplication::isRightToLeft() )
|
2006-02-22 10:23:10 +00:00
|
|
|
|
sr.adjust( icon->width() - tr.width(), 0, 0, 0 );
|
2002-06-24 18:33:20 +00:00
|
|
|
|
else
|
2006-02-22 10:23:10 +00:00
|
|
|
|
sr.adjust( 0, 0, -( icon->width() - tr.width() ), 0 );
|
2002-08-31 22:37:35 +00:00
|
|
|
|
|
2002-06-24 18:33:20 +00:00
|
|
|
|
p.drawPixmap( r.x() + sr.x(), r.y() + sr.y(), *icon,
|
|
|
|
|
sr.x(), sr.y(), sr.width(), sr.height() );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
2002-08-31 22:37:35 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
//p.drawRect( r ); // debug
|
2002-08-31 22:37:35 +00:00
|
|
|
|
|
2005-11-10 11:50:13 +00:00
|
|
|
|
if ( QApplication::isRightToLeft() )
|
2006-02-22 10:23:10 +00:00
|
|
|
|
tr.adjust( 0, 0, -(16 + iconSpacing), 0 );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
else
|
2006-02-22 10:23:10 +00:00
|
|
|
|
tr.adjust( (16 + iconSpacing), 0, 0, 0 );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Draw the titlebar text
|
2005-10-27 09:07:06 +00:00
|
|
|
|
int flags = Qt::AlignVCenter | Qt::TextSingleLine;
|
2005-11-10 11:50:13 +00:00
|
|
|
|
flags |= ( QApplication::isRightToLeft() ? Qt::AlignRight : Qt::AlignLeft );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
if ( clientHandler->useShadowedText() )
|
|
|
|
|
{
|
2005-11-10 11:50:13 +00:00
|
|
|
|
p.translate( QApplication::isRightToLeft() ? -1 : 1, 1 );
|
2005-01-22 01:13:39 +00:00
|
|
|
|
//p.setPen( options()->color(ColorTitleBar, active).dark() );
|
|
|
|
|
if (qGray(options()->color(ColorFont, active).rgb()) < 100)
|
|
|
|
|
p.setPen( QColor(200,200,200) );
|
|
|
|
|
else
|
2005-07-28 14:59:42 +00:00
|
|
|
|
p.setPen( Qt::black );
|
2002-08-31 22:37:35 +00:00
|
|
|
|
p.drawText( tr, flags, caption() );
|
2005-11-10 11:50:13 +00:00
|
|
|
|
p.translate( QApplication::isRightToLeft() ? 1 : -1, -1 );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
p.setPen( options()->color( ColorFont, active ) );
|
2002-08-31 22:37:35 +00:00
|
|
|
|
p.drawText( tr, flags, caption() );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
captionBufferDirty = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeramikClient::calculateCaptionRect()
|
|
|
|
|
{
|
2003-09-16 19:40:07 +00:00
|
|
|
|
QFontMetrics fm( options()->font(isActive()) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
int cw = fm.width( caption() ) + 95;
|
2002-06-29 22:25:38 +00:00
|
|
|
|
int titleBaseY = ( largeTitlebar ? 3 : 0 );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
if ( clientHandler->showAppIcons() )
|
|
|
|
|
cw += 16 + 4; // icon width + space
|
|
|
|
|
|
2006-02-17 21:54:55 +00:00
|
|
|
|
cw = qMin( cw, titlebar->geometry().width() );
|
2005-11-10 11:50:13 +00:00
|
|
|
|
captionRect = QStyle::visualRect( QApplication::isRightToLeft() ? Qt::RightToLeft : Qt::LeftToRight, QRect(titlebar->geometry().x(), (largeCaption ? 0 : titleBaseY),
|
2002-06-29 22:25:38 +00:00
|
|
|
|
cw, clientHandler->titleBarHeight(largeCaption) ),
|
2002-05-17 16:33:48 +00:00
|
|
|
|
titlebar->geometry() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
void KeramikClient::captionChange()
|
2002-05-17 16:33:48 +00:00
|
|
|
|
{
|
|
|
|
|
QRect r( captionRect );
|
|
|
|
|
calculateCaptionRect();
|
|
|
|
|
|
|
|
|
|
if ( r.size() != captionRect.size() )
|
|
|
|
|
maskDirty = true;
|
|
|
|
|
|
|
|
|
|
captionBufferDirty = true;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2006-04-12 15:13:31 +00:00
|
|
|
|
widget()->repaint( r | captionRect );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeramikClient::iconChange()
|
|
|
|
|
{
|
|
|
|
|
if ( clientHandler->showAppIcons() ) {
|
|
|
|
|
|
|
|
|
|
// Force updateCaptionBuffer() to recreate the cached icons
|
2004-05-09 16:45:04 +00:00
|
|
|
|
delete activeIcon;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2004-05-09 16:45:04 +00:00
|
|
|
|
delete inactiveIcon;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
activeIcon = inactiveIcon = NULL;
|
|
|
|
|
|
|
|
|
|
captionBufferDirty = true;
|
2006-04-12 15:13:31 +00:00
|
|
|
|
widget()->repaint( captionRect );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
void KeramikClient::activeChange()
|
2002-05-17 16:33:48 +00:00
|
|
|
|
{
|
2003-09-16 19:40:07 +00:00
|
|
|
|
bool active = isActive();
|
2002-05-17 16:33:48 +00:00
|
|
|
|
// Note: It's assumed that the same font will always be used for both active
|
|
|
|
|
// and inactive windows, since the fonts kcm hasn't supported setting
|
|
|
|
|
// different fonts for different window states for some time.
|
2002-06-29 22:25:38 +00:00
|
|
|
|
if ( largeTitlebar ) {
|
|
|
|
|
largeCaption = ( active && !maximizedVertical() );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
calculateCaptionRect();
|
|
|
|
|
maskDirty = true;
|
|
|
|
|
}
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
captionBufferDirty = true;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2006-04-12 15:13:31 +00:00
|
|
|
|
widget()->repaint();
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
for ( int i=0; i < NumButtons; i++ )
|
2006-04-12 15:13:31 +00:00
|
|
|
|
if ( button[i] ) button[i]->repaint();
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
void KeramikClient::maximizeChange()
|
2002-05-17 16:33:48 +00:00
|
|
|
|
{
|
2002-06-29 22:25:38 +00:00
|
|
|
|
if ( clientHandler->largeCaptionBubbles() )
|
|
|
|
|
{
|
2003-09-16 19:40:07 +00:00
|
|
|
|
if ( maximizeMode() & MaximizeVertical ) {
|
2002-06-29 22:25:38 +00:00
|
|
|
|
// We've been maximized - shrink the titlebar by 3 pixels
|
|
|
|
|
topSpacer->changeSize( 10, 1, QSizePolicy::Expanding, QSizePolicy::Minimum );
|
|
|
|
|
largeCaption = largeTitlebar = false;
|
|
|
|
|
|
|
|
|
|
calculateCaptionRect();
|
|
|
|
|
captionBufferDirty = maskDirty = true;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
|
|
|
|
widget()->layout()->activate();
|
2006-04-12 15:13:31 +00:00
|
|
|
|
widget()->repaint();
|
2003-09-16 19:40:07 +00:00
|
|
|
|
} else if (( maximizeMode() & MaximizeVertical ) == 0 && !largeTitlebar ) {
|
2002-06-29 22:25:38 +00:00
|
|
|
|
// We've been restored - enlarge the titlebar by 3 pixels
|
|
|
|
|
topSpacer->changeSize( 10, 4, QSizePolicy::Expanding, QSizePolicy::Minimum );
|
|
|
|
|
largeCaption = largeTitlebar = true;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-06-29 22:25:38 +00:00
|
|
|
|
calculateCaptionRect();
|
|
|
|
|
captionBufferDirty = maskDirty = true;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
|
|
|
|
widget()->layout()->activate();
|
2006-04-12 15:13:31 +00:00
|
|
|
|
widget()->repaint();
|
2002-06-29 22:25:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
if ( button[ MaxButton ] ) {
|
2005-09-21 09:14:36 +00:00
|
|
|
|
button[ MaxButton ]->setToolTip( maximizeMode() == MaximizeFull ? i18n("Restore") : i18n("Maximize") );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
button[ MaxButton ]->repaint();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
void KeramikClient::desktopChange()
|
2002-05-17 16:33:48 +00:00
|
|
|
|
{
|
2003-09-16 19:40:07 +00:00
|
|
|
|
if ( button[ OnAllDesktopsButton ] )
|
|
|
|
|
{
|
2006-04-12 15:13:31 +00:00
|
|
|
|
button[ OnAllDesktopsButton ]->repaint();
|
2005-09-21 09:14:36 +00:00
|
|
|
|
button[ OnAllDesktopsButton ]->setToolTip( isOnAllDesktops() ? i18n("Not on all desktops") : i18n("On all desktops") );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
}
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-07-22 11:23:28 +00:00
|
|
|
|
void KeramikClient::shadeChange()
|
|
|
|
|
{
|
|
|
|
|
if ( button[ ShadeButton ] )
|
|
|
|
|
{
|
2006-04-12 15:13:31 +00:00
|
|
|
|
button[ ShadeButton ]->repaint();
|
2005-09-21 09:14:36 +00:00
|
|
|
|
button[ ShadeButton ]->setToolTip( isSetShade() ? i18n("Unshade") : i18n("Shade") );
|
2004-07-22 11:23:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeramikClient::keepAboveChange( bool )
|
|
|
|
|
{
|
|
|
|
|
if ( button[ AboveButton ] )
|
2006-04-12 15:13:31 +00:00
|
|
|
|
button[ AboveButton ]->repaint();
|
2004-07-22 11:23:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeramikClient::keepBelowChange( bool )
|
|
|
|
|
{
|
|
|
|
|
if ( button[ BelowButton ] )
|
2006-04-12 15:13:31 +00:00
|
|
|
|
button[ BelowButton ]->repaint();
|
2004-07-22 11:23:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
void KeramikClient::menuButtonPressed()
|
|
|
|
|
{
|
2004-06-04 13:09:47 +00:00
|
|
|
|
QPoint menuTop ( button[MenuButton]->rect().topLeft() );
|
|
|
|
|
QPoint menuBottom ( button[MenuButton]->rect().bottomRight() );
|
|
|
|
|
menuTop += QPoint(-6, -3);
|
|
|
|
|
menuBottom += QPoint(6, 3);
|
|
|
|
|
KDecorationFactory* f = factory();
|
2006-04-26 16:05:58 +00:00
|
|
|
|
showWindowMenu( QRect( button[MenuButton]->mapToGlobal( menuTop ),
|
2004-06-04 13:09:47 +00:00
|
|
|
|
button[MenuButton]->mapToGlobal( menuBottom )) );
|
|
|
|
|
if( !f->exists( this )) // 'this' was destroyed
|
|
|
|
|
return;
|
2002-08-27 15:12:14 +00:00
|
|
|
|
button[MenuButton]->setDown(false);
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeramikClient::slotMaximize()
|
|
|
|
|
{
|
2004-07-22 15:17:54 +00:00
|
|
|
|
maximize( button[ MaxButton ]->lastButton() );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2004-07-22 11:23:28 +00:00
|
|
|
|
void KeramikClient::slotAbove()
|
|
|
|
|
{
|
|
|
|
|
setKeepAbove( !keepAbove());
|
2006-04-12 15:13:31 +00:00
|
|
|
|
button[ AboveButton ]->repaint();
|
2004-07-22 11:23:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeramikClient::slotBelow()
|
|
|
|
|
{
|
|
|
|
|
setKeepBelow( !keepBelow());
|
2006-04-12 15:13:31 +00:00
|
|
|
|
button[ BelowButton ]->repaint();
|
2004-07-22 11:23:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeramikClient::slotShade()
|
|
|
|
|
{
|
|
|
|
|
setShade( !isSetShade());
|
2006-04-12 15:13:31 +00:00
|
|
|
|
button[ ShadeButton ]->repaint();
|
2004-07-22 11:23:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
void KeramikClient::paintEvent( QPaintEvent *e )
|
|
|
|
|
{
|
|
|
|
|
if ( !keramik_initialized )
|
|
|
|
|
return;
|
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
QPainter p( widget());
|
2002-05-17 16:33:48 +00:00
|
|
|
|
QRect updateRect( e->rect() );
|
|
|
|
|
bool active = isActive();
|
|
|
|
|
|
2002-06-29 22:25:38 +00:00
|
|
|
|
int titleBaseY = ( largeTitlebar ? 3 : 0 );
|
|
|
|
|
int titleBarHeight = clientHandler->titleBarHeight( largeTitlebar );
|
2002-09-01 22:50:34 +00:00
|
|
|
|
int grabBarHeight = clientHandler->grabBarHeight();
|
2002-11-16 00:05:16 +00:00
|
|
|
|
int leftBorderWidth = clientHandler->tile( BorderLeft, active )->width();
|
|
|
|
|
int rightBorderWidth = clientHandler->tile( BorderRight, active )->width();
|
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
if ( maskDirty )
|
|
|
|
|
updateMask();
|
2002-11-16 00:05:16 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
// Titlebar
|
|
|
|
|
// -----------------------------------------------------------------------
|
2002-06-29 22:25:38 +00:00
|
|
|
|
if ( updateRect.y() < titleBarHeight )
|
2002-05-17 16:33:48 +00:00
|
|
|
|
{
|
2002-06-29 22:25:38 +00:00
|
|
|
|
int titleBarBaseHeight = titleBarHeight - titleBaseY;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
if ( captionBufferDirty )
|
|
|
|
|
updateCaptionBuffer();
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
// Top left corner
|
|
|
|
|
if ( updateRect.x() < 15 )
|
2002-06-29 22:25:38 +00:00
|
|
|
|
p.drawPixmap( 0, titleBaseY,
|
|
|
|
|
*clientHandler->tile( TitleLeft, active ) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
// Space between the top left corner and the caption bubble
|
2002-06-24 18:33:20 +00:00
|
|
|
|
if ( updateRect.x() < captionRect.left() && updateRect.right() >= 15 ) {
|
2006-02-17 21:54:55 +00:00
|
|
|
|
int x1 = qMax( 15, updateRect.x() );
|
|
|
|
|
int x2 = qMin( captionRect.left(), updateRect.right() );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-06-29 22:25:38 +00:00
|
|
|
|
p.drawTiledPixmap( x1, titleBaseY, x2 - x1 + 1, titleBarBaseHeight,
|
2002-05-17 16:33:48 +00:00
|
|
|
|
*clientHandler->tile( TitleCenter, active ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Caption bubble
|
2002-06-24 18:33:20 +00:00
|
|
|
|
if ( updateRect.x() <= captionRect.right() && updateRect.right() > 15 ) {
|
|
|
|
|
if ( captionRect.width() >= 25 )
|
2002-05-17 16:33:48 +00:00
|
|
|
|
p.drawPixmap( captionRect.left(), active ? 0 : titleBaseY, captionBuffer );
|
|
|
|
|
else
|
|
|
|
|
p.drawTiledPixmap( captionRect.x(), titleBaseY, captionRect.width(),
|
2002-06-29 22:25:38 +00:00
|
|
|
|
titleBarBaseHeight, *clientHandler->tile( TitleCenter, active ) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
// Space between the caption bubble and the top right corner
|
2003-09-16 19:40:07 +00:00
|
|
|
|
if ( updateRect.right() > captionRect.right() && updateRect.x() < width() - 15 ) { // FRAME
|
2006-02-17 21:54:55 +00:00
|
|
|
|
int x1 = qMax( captionRect.right() + 1, updateRect.x() );
|
|
|
|
|
int x2 = qMin( width() - 15, updateRect.right() );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-06-29 22:25:38 +00:00
|
|
|
|
p.drawTiledPixmap( x1, titleBaseY, x2 - x1 + 1, titleBarBaseHeight,
|
2002-05-17 16:33:48 +00:00
|
|
|
|
*clientHandler->tile( TitleCenter, active ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Top right corner
|
2002-06-24 18:33:20 +00:00
|
|
|
|
if ( updateRect.right() >= width() - 15 )
|
2002-06-29 22:25:38 +00:00
|
|
|
|
p.drawPixmap( width() - 15, titleBaseY,
|
|
|
|
|
*clientHandler->tile( TitleRight, active ) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Borders
|
|
|
|
|
// -----------------------------------------------------------------------
|
2002-09-01 22:50:34 +00:00
|
|
|
|
if ( updateRect.bottom() >= titleBarHeight &&
|
|
|
|
|
updateRect.top() < height() - grabBarHeight )
|
2002-05-17 16:33:48 +00:00
|
|
|
|
{
|
2006-02-17 21:54:55 +00:00
|
|
|
|
int top = qMax( titleBarHeight, updateRect.top() );
|
|
|
|
|
int bottom = qMin( updateRect.bottom(), height() - grabBarHeight );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
// Left border
|
2002-11-16 00:05:16 +00:00
|
|
|
|
if ( updateRect.x() < leftBorderWidth )
|
|
|
|
|
p.drawTiledPixmap( 0, top, leftBorderWidth, bottom - top + 1,
|
|
|
|
|
*clientHandler->tile( BorderLeft, active ) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
// Right border
|
2002-11-16 00:05:16 +00:00
|
|
|
|
if ( e->rect().right() > width() - rightBorderWidth - 1 )
|
|
|
|
|
p.drawTiledPixmap( width() - rightBorderWidth, top, rightBorderWidth,
|
|
|
|
|
bottom - top + 1, *clientHandler->tile( BorderRight, active ) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
// Bottom grab bar
|
|
|
|
|
// -----------------------------------------------------------------------
|
2002-09-01 22:50:34 +00:00
|
|
|
|
if ( updateRect.bottom() >= height() - grabBarHeight ) {
|
2002-05-17 16:33:48 +00:00
|
|
|
|
// Bottom left corner
|
|
|
|
|
if ( updateRect.x() < 9 )
|
2002-09-01 22:50:34 +00:00
|
|
|
|
p.drawPixmap( 0, height() - grabBarHeight,
|
2002-06-29 22:25:38 +00:00
|
|
|
|
*clientHandler->tile( GrabBarLeft, active ) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
// Space between the left corner and the right corner
|
|
|
|
|
if ( updateRect.x() < width() - 9 ) {
|
2006-02-17 21:54:55 +00:00
|
|
|
|
int x1 = qMax( 9, updateRect.x() );
|
|
|
|
|
int x2 = qMin( width() - 9, updateRect.right() );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
2002-09-01 22:50:34 +00:00
|
|
|
|
p.drawTiledPixmap( x1, height() - grabBarHeight, x2 - x1 + 1,
|
|
|
|
|
grabBarHeight, *clientHandler->tile( GrabBarCenter, active ) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Bottom right corner
|
|
|
|
|
if ( updateRect.right() > width() - 9 )
|
2002-09-01 22:50:34 +00:00
|
|
|
|
p.drawPixmap( width() - 9, height() - grabBarHeight,
|
2002-06-29 22:25:38 +00:00
|
|
|
|
*clientHandler->tile( GrabBarRight, active ) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
2002-10-30 16:15:58 +00:00
|
|
|
|
|
|
|
|
|
// Extra drawline for the 1 pixel empty space QLayout leaves when a window is shaded.
|
2003-09-16 19:40:07 +00:00
|
|
|
|
p.setPen( options()->color( ColorTitleBlend, active ) );
|
|
|
|
|
p.drawLine( leftBorderWidth, height() - grabBarHeight - 1,
|
2002-11-16 00:05:16 +00:00
|
|
|
|
width() - rightBorderWidth - 1, height() - grabBarHeight - 1 );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeramikClient::resizeEvent( QResizeEvent *e )
|
|
|
|
|
{
|
2003-09-16 19:40:07 +00:00
|
|
|
|
// FRAME Client::resizeEvent( e );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
QRect r( captionRect );
|
|
|
|
|
calculateCaptionRect();
|
|
|
|
|
|
|
|
|
|
if ( r.size() != captionRect.size() )
|
|
|
|
|
captionBufferDirty = true;
|
|
|
|
|
|
|
|
|
|
maskDirty = true;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
|
|
|
|
|
if ( widget()->isVisible() )
|
2002-05-17 16:33:48 +00:00
|
|
|
|
{
|
2003-09-16 19:40:07 +00:00
|
|
|
|
widget()->update( widget()->rect() );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
int dx = 0;
|
|
|
|
|
int dy = 0;
|
|
|
|
|
|
|
|
|
|
if ( e->oldSize().width() != width() )
|
|
|
|
|
dx = 32 + QABS( e->oldSize().width() - width() );
|
|
|
|
|
|
|
|
|
|
if ( e->oldSize().height() != height() )
|
|
|
|
|
dy = 8 + QABS( e->oldSize().height() - height() );
|
|
|
|
|
|
|
|
|
|
if ( dy )
|
2003-09-16 19:40:07 +00:00
|
|
|
|
widget()->update( 0, height() - dy + 1, width(), dy );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
|
|
|
|
if ( dx )
|
|
|
|
|
{
|
2003-09-16 19:40:07 +00:00
|
|
|
|
widget()->update( width() - dx + 1, 0, dx, height() );
|
|
|
|
|
widget()->update( QRect( QPoint(4,4), titlebar->geometry().bottomLeft() - QPoint(1,0) ) );
|
|
|
|
|
widget()->update( QRect( titlebar->geometry().topRight(), QPoint( width() - 4,
|
2002-06-29 22:25:38 +00:00
|
|
|
|
titlebar->geometry().bottom() ) ) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
// Titlebar needs no paint event
|
2005-07-28 14:59:42 +00:00
|
|
|
|
QApplication::postEvent( this, new QPaintEvent( titlebar->geometry() ) );
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void KeramikClient::mouseDoubleClickEvent( QMouseEvent *e )
|
|
|
|
|
{
|
2005-07-28 14:59:42 +00:00
|
|
|
|
if ( e->button() == Qt::LeftButton
|
2005-05-05 12:43:19 +00:00
|
|
|
|
&& QRect( 0, 0, width(), clientHandler->titleBarHeight( largeTitlebar ) ).contains( e->pos() ) )
|
2003-09-16 19:40:07 +00:00
|
|
|
|
titlebarDblClickOperation();
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-12-15 15:10:17 +00:00
|
|
|
|
KeramikClient::Position KeramikClient::mousePosition( const QPoint &p ) const
|
2002-05-17 16:33:48 +00:00
|
|
|
|
{
|
2002-06-29 22:25:38 +00:00
|
|
|
|
int titleBaseY = (largeTitlebar ? 3 : 0);
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2002-09-15 19:13:38 +00:00
|
|
|
|
int leftBorder = clientHandler->tile( BorderLeft, true )->width();
|
|
|
|
|
int rightBorder = width() - clientHandler->tile( BorderRight, true )->width() - 1;
|
|
|
|
|
int bottomBorder = height() - clientHandler->grabBarHeight() - 1;
|
2003-10-03 13:51:02 +00:00
|
|
|
|
int bottomCornerSize = 3*clientHandler->tile( BorderRight, true )->width()/2 + 24;
|
2002-09-15 19:13:38 +00:00
|
|
|
|
|
|
|
|
|
// Test if the mouse is over the titlebar area
|
|
|
|
|
if ( p.y() < titleBaseY + 11 ) {
|
|
|
|
|
// Test for the top left corner
|
|
|
|
|
if ( p.x() < leftBorder + 11 ) {
|
2002-05-17 16:33:48 +00:00
|
|
|
|
if ( (p.y() < titleBaseY + 3 && p.x() < leftBorder + 11) ||
|
|
|
|
|
(p.y() < titleBaseY + 6 && p.x() < leftBorder + 6) ||
|
|
|
|
|
(p.y() < titleBaseY + 11 && p.x() < leftBorder + 3) )
|
2003-12-15 15:10:17 +00:00
|
|
|
|
return PositionTopLeft;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-09-15 19:13:38 +00:00
|
|
|
|
// Test for the top right corner
|
|
|
|
|
if ( p.x() > rightBorder - 11 ) {
|
2002-05-17 16:33:48 +00:00
|
|
|
|
if ( (p.y() < titleBaseY + 3 && p.x() > rightBorder - 11) ||
|
|
|
|
|
(p.y() < titleBaseY + 6 && p.x() > rightBorder - 6) ||
|
|
|
|
|
(p.y() < titleBaseY + 11 && p.x() > rightBorder - 3) )
|
2003-12-15 15:10:17 +00:00
|
|
|
|
return PositionTopRight;
|
2002-09-15 19:13:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test for the top border
|
|
|
|
|
if ( p.y() <= 3 || (p.y() <= titleBaseY+3 &&
|
|
|
|
|
(p.x() < captionRect.left() || p.x() > captionRect.right()) ) )
|
2003-12-15 15:10:17 +00:00
|
|
|
|
return PositionTop;
|
2002-09-15 19:13:38 +00:00
|
|
|
|
|
|
|
|
|
// The cursor must be over the center of the titlebar.
|
2003-12-15 15:10:17 +00:00
|
|
|
|
return PositionCenter;
|
2002-09-15 19:13:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Test the sides
|
|
|
|
|
else if ( p.y() < bottomBorder ) {
|
|
|
|
|
// Test for the left side
|
|
|
|
|
if ( p.x() < leftBorder ) {
|
|
|
|
|
if ( p.y() < height() - bottomCornerSize )
|
2003-12-15 15:10:17 +00:00
|
|
|
|
return PositionLeft;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
else
|
2003-12-15 15:10:17 +00:00
|
|
|
|
return PositionBottomLeft;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
2002-09-15 19:13:38 +00:00
|
|
|
|
|
|
|
|
|
// Test for the right side
|
|
|
|
|
else if ( p.x() > rightBorder ) {
|
|
|
|
|
if ( p.y() < height() - bottomCornerSize )
|
2003-12-15 15:10:17 +00:00
|
|
|
|
return PositionRight;
|
2002-09-15 19:13:38 +00:00
|
|
|
|
else
|
2003-12-15 15:10:17 +00:00
|
|
|
|
return PositionBottomRight;
|
2002-09-15 19:13:38 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The cursor must be over the center of the window
|
2003-12-15 15:10:17 +00:00
|
|
|
|
return PositionCenter;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-09-15 19:13:38 +00:00
|
|
|
|
// Test the grab bar / bottom border
|
|
|
|
|
else {
|
|
|
|
|
// Test for the bottom left corner
|
|
|
|
|
if ( p.x() < bottomCornerSize )
|
2003-12-15 15:10:17 +00:00
|
|
|
|
return PositionBottomLeft;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2002-09-15 19:13:38 +00:00
|
|
|
|
// Test for the bottom right corner
|
|
|
|
|
else if ( p.x() > width() - bottomCornerSize - 1 )
|
2003-12-15 15:10:17 +00:00
|
|
|
|
return PositionBottomRight;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2002-09-15 19:13:38 +00:00
|
|
|
|
// The cursor must be over the bottom border
|
2003-12-15 15:10:17 +00:00
|
|
|
|
return PositionBottom;
|
2002-09-15 19:13:38 +00:00
|
|
|
|
}
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2002-09-15 19:13:38 +00:00
|
|
|
|
// We should never get here
|
2003-12-15 15:10:17 +00:00
|
|
|
|
return PositionCenter;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-18 17:07:49 +00:00
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
void KeramikClient::resize( const QSize& s )
|
|
|
|
|
{
|
2003-09-18 17:07:49 +00:00
|
|
|
|
widget()->resize( s );
|
2003-09-16 19:40:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-18 17:07:49 +00:00
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
void KeramikClient::borders( int& left, int& right, int& top, int& bottom ) const
|
|
|
|
|
{
|
2003-11-01 16:46:18 +00:00
|
|
|
|
int titleBarHeight = clientHandler->titleBarHeight( clientHandler->largeCaptionBubbles() );
|
2003-09-18 17:07:49 +00:00
|
|
|
|
int grabBarHeight = clientHandler->grabBarHeight();
|
|
|
|
|
int leftBorderWidth = clientHandler->tile( BorderLeft, isActive() )->width();
|
|
|
|
|
int rightBorderWidth = clientHandler->tile( BorderRight, isActive() )->width();
|
|
|
|
|
|
|
|
|
|
left = leftBorderWidth;
|
|
|
|
|
right = rightBorderWidth;
|
|
|
|
|
top = titleBarHeight;
|
|
|
|
|
bottom = grabBarHeight;
|
|
|
|
|
|
|
|
|
|
if ( ( maximizeMode() & MaximizeHorizontal ) && !options()->moveResizeMaximizedWindows())
|
|
|
|
|
left = right = 0;
|
2003-11-01 16:46:18 +00:00
|
|
|
|
if( maximizeMode() & MaximizeVertical)
|
|
|
|
|
{
|
|
|
|
|
top = clientHandler->titleBarHeight( false );
|
|
|
|
|
if( !options()->moveResizeMaximizedWindows())
|
|
|
|
|
bottom = 0;
|
|
|
|
|
}
|
2003-09-16 19:40:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-18 17:07:49 +00:00
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
QSize KeramikClient::minimumSize() const
|
|
|
|
|
{
|
2003-09-18 17:07:49 +00:00
|
|
|
|
return widget()->minimumSize();
|
2003-09-16 19:40:07 +00:00
|
|
|
|
}
|
|
|
|
|
|
2003-09-18 17:07:49 +00:00
|
|
|
|
|
2003-09-16 19:40:07 +00:00
|
|
|
|
bool KeramikClient::eventFilter( QObject* o, QEvent* e )
|
|
|
|
|
{
|
2003-09-18 17:07:49 +00:00
|
|
|
|
if ( o != widget() )
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
switch ( e->type() )
|
2003-09-16 19:40:07 +00:00
|
|
|
|
{
|
2003-09-18 17:07:49 +00:00
|
|
|
|
case QEvent::Resize:
|
|
|
|
|
resizeEvent( static_cast< QResizeEvent* >( e ) );
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
case QEvent::Paint:
|
|
|
|
|
paintEvent( static_cast< QPaintEvent* >( e ) );
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
case QEvent::MouseButtonDblClick:
|
|
|
|
|
mouseDoubleClickEvent( static_cast< QMouseEvent* >( e ) );
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
case QEvent::MouseButtonPress:
|
|
|
|
|
processMousePressEvent( static_cast< QMouseEvent* >( e ) );
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return false;
|
2003-09-16 19:40:07 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-07-26 10:41:28 +00:00
|
|
|
|
} // namespace Keramik
|
2002-05-17 16:33:48 +00:00
|
|
|
|
|
2002-09-01 22:50:34 +00:00
|
|
|
|
|
|
|
|
|
|
2002-05-17 16:33:48 +00:00
|
|
|
|
// -------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
|
{
|
2004-11-21 16:19:09 +00:00
|
|
|
|
KDE_EXPORT KDecorationFactory *create_factory()
|
2002-05-17 16:33:48 +00:00
|
|
|
|
{
|
2002-08-27 18:08:20 +00:00
|
|
|
|
Keramik::clientHandler = new Keramik::KeramikHandler();
|
2003-09-16 19:40:07 +00:00
|
|
|
|
return Keramik::clientHandler;
|
2002-05-17 16:33:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// vim: set noet ts=4 sw=4:
|