2000-01-03 13:13:57 +00:00
|
|
|
#include <kconfig.h>
|
|
|
|
#include "kwmthemeclient.h"
|
|
|
|
#include <kglobal.h>
|
|
|
|
#include <qapplication.h>
|
|
|
|
#include <qcursor.h>
|
|
|
|
#include <qabstractlayout.h>
|
|
|
|
#include <qlayout.h>
|
|
|
|
#include <qtoolbutton.h>
|
|
|
|
#include <qlabel.h>
|
|
|
|
#include <qdrawutil.h>
|
|
|
|
#include <kpixmapeffect.h>
|
2000-12-11 20:27:43 +00:00
|
|
|
#include <kstddirs.h>
|
|
|
|
#include <kglobal.h>
|
2000-01-03 13:13:57 +00:00
|
|
|
#include <klocale.h>
|
|
|
|
#include <qbitmap.h>
|
|
|
|
#include <qtooltip.h>
|
|
|
|
#include "../../workspace.h"
|
|
|
|
#include "../../options.h"
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
Client *allocate(Workspace *ws, WId w)
|
|
|
|
{
|
|
|
|
return(new KWMThemeClient(ws, w));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-03-31 19:10:22 +00:00
|
|
|
|
2000-01-03 13:13:57 +00:00
|
|
|
enum FramePixmap{FrameTop=0, FrameBottom, FrameLeft, FrameRight, FrameTopLeft,
|
|
|
|
FrameTopRight, FrameBottomLeft, FrameBottomRight};
|
|
|
|
|
|
|
|
static QPixmap *framePixmaps[8];
|
|
|
|
static QPixmap *menuPix, *iconifyPix, *closePix, *maxPix, *minmaxPix,
|
|
|
|
*pinupPix, *pindownPix;
|
2001-01-16 21:45:23 +00:00
|
|
|
static KPixmap *aTitlePix = 0;
|
|
|
|
static KPixmap *iTitlePix = 0;
|
2000-01-03 13:13:57 +00:00
|
|
|
static KPixmapEffect::GradientType grType;
|
|
|
|
static int maxExtent, titleAlign;
|
|
|
|
static bool titleGradient = true;
|
|
|
|
static bool pixmaps_created = false;
|
|
|
|
static bool titleSunken = false;
|
|
|
|
static bool titleTransparent;
|
|
|
|
|
|
|
|
extern Options *options;
|
|
|
|
|
|
|
|
static void init_theme()
|
|
|
|
{
|
2000-01-03 13:16:39 +00:00
|
|
|
const char *keys[] = {"wm_top", "wm_bottom", "wm_left", "wm_right",
|
2000-01-03 13:13:57 +00:00
|
|
|
"wm_topleft", "wm_topright", "wm_bottomleft", "wm_bottomright"};
|
|
|
|
|
|
|
|
if(pixmaps_created)
|
|
|
|
return;
|
|
|
|
pixmaps_created = true;
|
|
|
|
|
|
|
|
KConfig *config = KGlobal::config();
|
|
|
|
config->setGroup("General");
|
2000-12-12 17:40:56 +00:00
|
|
|
QString tmpStr;
|
2000-01-03 13:13:57 +00:00
|
|
|
|
2001-01-24 23:53:37 +00:00
|
|
|
for(int i=0; i < 8; ++i)
|
|
|
|
{
|
2000-12-12 17:40:56 +00:00
|
|
|
framePixmaps[i] = new QPixmap(locate("appdata",
|
|
|
|
"pics/"+config->readEntry(keys[i], " ")));
|
2001-01-24 23:53:37 +00:00
|
|
|
if(framePixmaps[i]->isNull())
|
2000-12-11 20:27:43 +00:00
|
|
|
qWarning("Unable to load frame pixmap for %s", keys[i]);
|
2000-01-03 13:13:57 +00:00
|
|
|
}
|
|
|
|
maxExtent = framePixmaps[FrameTop]->height();
|
|
|
|
if(framePixmaps[FrameBottom]->height() > maxExtent)
|
|
|
|
maxExtent = framePixmaps[FrameBottom]->height();
|
|
|
|
if(framePixmaps[FrameLeft]->width() > maxExtent)
|
|
|
|
maxExtent = framePixmaps[FrameLeft]->width();
|
|
|
|
if(framePixmaps[FrameRight]->width() > maxExtent)
|
|
|
|
maxExtent = framePixmaps[FrameRight]->width();
|
|
|
|
|
2000-12-12 17:40:56 +00:00
|
|
|
menuPix = new QPixmap(locate("appdata",
|
|
|
|
"pics/"+config->readEntry("menu", " ")));
|
|
|
|
iconifyPix = new QPixmap(locate("appdata",
|
|
|
|
"pics/"+config->readEntry("iconify", " ")));
|
|
|
|
maxPix = new QPixmap(locate("appdata",
|
|
|
|
"pics/"+config->readEntry("maximize", " ")));
|
|
|
|
minmaxPix = new QPixmap(locate("appdata",
|
|
|
|
"pics/"+config->readEntry("maximizedown", " ")));
|
|
|
|
closePix = new QPixmap(locate("appdata",
|
|
|
|
"pics/"+config->readEntry("close", " ")));
|
|
|
|
pinupPix = new QPixmap(locate("appdata",
|
|
|
|
"pics/"+config->readEntry("pinup", " ")));
|
|
|
|
pindownPix = new QPixmap(locate("appdata",
|
|
|
|
"pics/"+config->readEntry("pindown", " ")));
|
|
|
|
if(menuPix->isNull())
|
|
|
|
menuPix->load(locate("appdata", "pics/menu.png"));
|
2000-03-31 19:10:22 +00:00
|
|
|
if(iconifyPix->isNull())
|
2000-12-12 17:40:56 +00:00
|
|
|
iconifyPix->load(locate("appdata", "pics/iconify.png"));
|
2000-03-31 19:10:22 +00:00
|
|
|
if(maxPix->isNull())
|
2000-12-12 17:40:56 +00:00
|
|
|
maxPix->load(locate("appdata", "pics/maximize.png"));
|
2000-03-31 19:10:22 +00:00
|
|
|
if(minmaxPix->isNull())
|
2000-12-12 17:40:56 +00:00
|
|
|
minmaxPix->load(locate("appdata", "pics/maximizedown.png"));
|
2000-03-31 19:10:22 +00:00
|
|
|
if(closePix->isNull())
|
2000-12-12 17:40:56 +00:00
|
|
|
closePix->load(locate("appdata", "pics/close.png"));
|
2000-03-31 19:10:22 +00:00
|
|
|
if(pinupPix->isNull())
|
2000-12-12 17:40:56 +00:00
|
|
|
pinupPix->load(locate("appdata", "pics/pinup.png"));
|
2000-03-31 19:10:22 +00:00
|
|
|
if(pindownPix->isNull())
|
2000-12-12 17:40:56 +00:00
|
|
|
pindownPix->load(locate("appdata", "pics/pindown.png"));
|
2000-01-03 13:13:57 +00:00
|
|
|
|
2000-12-12 17:40:56 +00:00
|
|
|
tmpStr = config->readEntry("TitleAlignment");
|
2000-01-03 13:13:57 +00:00
|
|
|
if(tmpStr == "right")
|
|
|
|
titleAlign = Qt::AlignRight | Qt::AlignVCenter;
|
|
|
|
else if(tmpStr == "middle")
|
|
|
|
titleAlign = Qt::AlignCenter;
|
|
|
|
else
|
|
|
|
titleAlign = Qt::AlignLeft | Qt::AlignVCenter;
|
2000-04-27 11:29:25 +00:00
|
|
|
titleSunken = config->readBoolEntry("TitleFrameShaded", true);
|
|
|
|
titleSunken = true; // FIXME
|
2000-01-03 13:13:57 +00:00
|
|
|
titleTransparent = config->readBoolEntry("PixmapUnderTitleText", true);
|
|
|
|
|
|
|
|
tmpStr = config->readEntry("TitlebarLook");
|
|
|
|
if(tmpStr == "shadedVertical"){
|
|
|
|
aTitlePix = new KPixmap;
|
|
|
|
aTitlePix->resize(32, 20);
|
|
|
|
KPixmapEffect::gradient(*aTitlePix,
|
|
|
|
options->color(Options::TitleBar, true),
|
|
|
|
options->color(Options::TitleBlend, true),
|
|
|
|
KPixmapEffect::VerticalGradient);
|
|
|
|
iTitlePix = new KPixmap;
|
|
|
|
iTitlePix->resize(32, 20);
|
|
|
|
KPixmapEffect::gradient(*iTitlePix,
|
|
|
|
options->color(Options::TitleBar, false),
|
|
|
|
options->color(Options::TitleBlend, false),
|
|
|
|
KPixmapEffect::VerticalGradient);
|
|
|
|
titleGradient = false; // we can just tile this
|
|
|
|
|
|
|
|
}
|
|
|
|
else if(tmpStr == "shadedHorizontal")
|
|
|
|
grType = KPixmapEffect::HorizontalGradient;
|
|
|
|
else if(tmpStr == "shadedDiagonal")
|
|
|
|
grType = KPixmapEffect::DiagonalGradient;
|
|
|
|
else if(tmpStr == "shadedCrossDiagonal")
|
|
|
|
grType = KPixmapEffect::CrossDiagonalGradient;
|
|
|
|
else if(tmpStr == "shadedPyramid")
|
|
|
|
grType = KPixmapEffect::PyramidGradient;
|
|
|
|
else if(tmpStr == "shadedRectangle")
|
|
|
|
grType = KPixmapEffect::RectangleGradient;
|
|
|
|
else if(tmpStr == "shadedPipeCross")
|
|
|
|
grType = KPixmapEffect::PipeCrossGradient;
|
|
|
|
else if(tmpStr == "shadedElliptic")
|
|
|
|
grType = KPixmapEffect::EllipticGradient;
|
2000-04-27 11:29:25 +00:00
|
|
|
else{
|
2000-01-03 13:13:57 +00:00
|
|
|
titleGradient = false;
|
2000-04-27 11:29:25 +00:00
|
|
|
tmpStr = config->readEntry("TitlebarPixmapActive", "");
|
|
|
|
if(!tmpStr.isEmpty()){
|
|
|
|
aTitlePix = new KPixmap;
|
2000-12-12 17:40:56 +00:00
|
|
|
aTitlePix->load(locate("appdata", "pics/" + tmpStr));
|
2000-04-27 11:29:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
aTitlePix = NULL;
|
|
|
|
tmpStr = config->readEntry("TitlebarPixmapInactive", "");
|
|
|
|
if(!tmpStr.isEmpty()){
|
|
|
|
iTitlePix = new KPixmap;
|
2000-12-12 17:40:56 +00:00
|
|
|
iTitlePix->load(locate("appdata", "pics/" + tmpStr));
|
2000-04-27 11:29:25 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
iTitlePix = NULL;
|
|
|
|
}
|
2000-01-03 13:13:57 +00:00
|
|
|
}
|
|
|
|
|
2001-01-16 21:45:23 +00:00
|
|
|
void
|
|
|
|
KWMThemeClient::slotReset()
|
|
|
|
{
|
|
|
|
if (!pixmaps_created) return;
|
|
|
|
pixmaps_created = false;
|
|
|
|
|
|
|
|
for(int i=0; i < 8; ++i)
|
|
|
|
delete framePixmaps[i];
|
|
|
|
|
|
|
|
delete menuPix;
|
|
|
|
delete iconifyPix;
|
|
|
|
delete closePix;
|
|
|
|
delete maxPix;
|
|
|
|
delete minmaxPix;
|
|
|
|
delete pinupPix;
|
|
|
|
delete pindownPix;
|
|
|
|
delete aTitlePix;
|
|
|
|
aTitlePix = 0;
|
|
|
|
delete iTitlePix;
|
|
|
|
iTitlePix = 0;
|
|
|
|
|
|
|
|
titleGradient = true;
|
|
|
|
pixmaps_created = false;
|
|
|
|
titleSunken = false;
|
|
|
|
|
|
|
|
init_theme();
|
|
|
|
}
|
|
|
|
|
2000-01-03 13:13:57 +00:00
|
|
|
void MyButton::drawButtonLabel(QPainter *p)
|
|
|
|
{
|
|
|
|
if(pixmap()){
|
|
|
|
style().drawItem(p, 0, 0, width(), height(), AlignCenter, colorGroup(),
|
|
|
|
true, pixmap(), QString::null);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
KWMThemeClient::KWMThemeClient( Workspace *ws, WId w, QWidget *parent,
|
|
|
|
const char *name )
|
2000-12-13 10:21:31 +00:00
|
|
|
: Client( ws, w, parent, name, WResizeNoErase | WNorthWestGravity)
|
2000-01-03 13:13:57 +00:00
|
|
|
{
|
2001-01-22 23:30:08 +00:00
|
|
|
stickyBtn = maxBtn = 0;
|
2000-01-03 13:13:57 +00:00
|
|
|
init_theme();
|
2001-01-16 21:45:23 +00:00
|
|
|
connect(options, SIGNAL(resetClients()), this, SLOT(slotReset()));
|
2000-01-03 13:13:57 +00:00
|
|
|
QGridLayout *layout = new QGridLayout(this);
|
|
|
|
layout->addColSpacing(0, maxExtent);
|
|
|
|
layout->addColSpacing(2, maxExtent);
|
|
|
|
|
|
|
|
layout->addRowSpacing(0, maxExtent);
|
|
|
|
|
|
|
|
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Fixed,
|
|
|
|
QSizePolicy::Expanding));
|
|
|
|
|
|
|
|
layout->addWidget(windowWrapper(), 2, 1);
|
|
|
|
layout->addRowSpacing(3, maxExtent);
|
|
|
|
layout->setRowStretch(2, 10);
|
|
|
|
layout->setColStretch(1, 10);
|
|
|
|
|
|
|
|
QHBoxLayout* hb = new QHBoxLayout;
|
|
|
|
layout->addLayout( hb, 1, 1 );
|
|
|
|
|
|
|
|
KConfig *config = KGlobal::config();
|
|
|
|
config->setGroup("Buttons");
|
|
|
|
QString val;
|
|
|
|
MyButton *btn;
|
|
|
|
int i;
|
|
|
|
static const char *defaultButtons[]={"Menu","Sticky","Off","Iconify",
|
|
|
|
"Maximize","Close"};
|
|
|
|
static const char keyOffsets[]={"ABCDEF"};
|
|
|
|
for(i=0; i < 6; ++i){
|
|
|
|
if(i == 3){
|
|
|
|
titlebar = new QSpacerItem(10, 20, QSizePolicy::Expanding,
|
|
|
|
QSizePolicy::Minimum );
|
|
|
|
hb->addItem( titlebar );
|
|
|
|
}
|
|
|
|
QString key("Button");
|
|
|
|
key += QChar(keyOffsets[i]);
|
|
|
|
val = config->readEntry(key, defaultButtons[i]);
|
|
|
|
if(val == "Menu"){
|
|
|
|
btn = new MyButton(this, "menu");
|
|
|
|
btn->setPixmap(*menuPix);
|
|
|
|
hb->addWidget(btn);
|
|
|
|
btn->setFixedSize(20, 20);
|
|
|
|
}
|
|
|
|
else if(val == "Sticky"){
|
|
|
|
stickyBtn = new MyButton(this, "sticky");
|
|
|
|
stickyBtn->setPixmap(*pinupPix);
|
|
|
|
connect(stickyBtn, SIGNAL( clicked() ), this, SLOT(toggleSticky()));
|
|
|
|
hb->addWidget(stickyBtn);
|
|
|
|
stickyBtn->setFixedSize(20, 20);
|
|
|
|
}
|
|
|
|
else if(val == "Iconify"){
|
|
|
|
btn = new MyButton(this, "iconify");
|
|
|
|
btn->setPixmap(*iconifyPix);
|
|
|
|
connect(btn, SIGNAL(clicked()), this, SLOT(iconify()));
|
|
|
|
hb->addWidget(btn);
|
|
|
|
btn->setFixedSize(20, 20);
|
|
|
|
}
|
|
|
|
else if(val == "Maximize"){
|
|
|
|
maxBtn = new MyButton(this, "max");
|
|
|
|
maxBtn->setPixmap(*maxPix);
|
|
|
|
connect(maxBtn, SIGNAL(clicked()), this, SLOT(maximize()));
|
|
|
|
hb->addWidget(maxBtn);
|
|
|
|
maxBtn->setFixedSize(20, 20);
|
|
|
|
}
|
|
|
|
else if(val == "Close"){
|
|
|
|
btn = new MyButton(this, "close");
|
|
|
|
btn->setPixmap(*closePix);
|
|
|
|
connect(btn, SIGNAL(clicked()), this, SLOT(closeWindow()));
|
|
|
|
hb->addWidget(btn);
|
|
|
|
btn->setFixedSize(20, 20);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
if(val != "Off")
|
2000-12-11 20:27:43 +00:00
|
|
|
qWarning("KWin: Unrecognized button value: %s", val.latin1());
|
2000-01-03 13:13:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if(titleGradient){
|
|
|
|
aGradient = new KPixmap;
|
|
|
|
iGradient = new KPixmap;
|
|
|
|
}
|
|
|
|
else{
|
2001-01-16 21:45:23 +00:00
|
|
|
aGradient = 0;
|
|
|
|
iGradient = 0;
|
2000-01-03 13:13:57 +00:00
|
|
|
}
|
|
|
|
|
2000-04-27 11:29:25 +00:00
|
|
|
setBackgroundMode(NoBackground);
|
2000-01-03 13:13:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KWMThemeClient::drawTitle(QPainter &p)
|
|
|
|
{
|
|
|
|
QRect r = titlebar->geometry();
|
|
|
|
|
|
|
|
if(titleSunken){
|
|
|
|
qDrawShadeRect(&p, r, options->colorGroup(Options::Frame, isActive()),
|
|
|
|
true, 1, 0);
|
|
|
|
r.setRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2);
|
|
|
|
}
|
|
|
|
|
|
|
|
KPixmap *fill = isActive() ? aTitlePix : iTitlePix;
|
|
|
|
if(fill)
|
|
|
|
p.drawTiledPixmap(r, *fill);
|
|
|
|
else if(titleGradient){
|
|
|
|
fill = isActive() ? aGradient : iGradient;
|
|
|
|
if(fill->width() != r.width()){
|
|
|
|
fill->resize(r.width(), 20);
|
|
|
|
KPixmapEffect::gradient(*fill,
|
|
|
|
options->color(Options::TitleBar, isActive()),
|
|
|
|
options->color(Options::TitleBlend, isActive()),
|
|
|
|
grType);
|
|
|
|
}
|
|
|
|
p.drawTiledPixmap(r, *fill);
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
p.fillRect(r, options->colorGroup(Options::TitleBar, isActive()).
|
|
|
|
brush(QColorGroup::Button));
|
|
|
|
}
|
|
|
|
p.setFont(options->font(isActive()));
|
|
|
|
p.setPen(options->color(Options::Font, isActive()));
|
2001-01-24 23:53:37 +00:00
|
|
|
// Add left & right margin
|
|
|
|
r.setLeft(r.left()+5);
|
|
|
|
r.setRight(r.right()-5);
|
2000-01-03 13:13:57 +00:00
|
|
|
p.drawText(r, titleAlign, caption());
|
|
|
|
}
|
|
|
|
|
|
|
|
void KWMThemeClient::resizeEvent( QResizeEvent* e)
|
|
|
|
{
|
|
|
|
Client::resizeEvent( e );
|
|
|
|
doShape();
|
|
|
|
if ( isVisibleToTLW() && !testWFlags( WNorthWestGravity )) {
|
|
|
|
QPainter p( this );
|
|
|
|
QRect t = titlebar->geometry();
|
|
|
|
t.setTop( 0 );
|
|
|
|
QRegion r = rect();
|
|
|
|
r = r.subtract( t );
|
|
|
|
p.setClipRegion( r );
|
|
|
|
p.eraseRect( rect() );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void KWMThemeClient::captionChange( const QString& )
|
|
|
|
{
|
|
|
|
repaint( titlebar->geometry(), false );
|
|
|
|
}
|
|
|
|
|
2001-01-24 23:53:37 +00:00
|
|
|
void KWMThemeClient::paintEvent( QPaintEvent*e )
|
2000-01-03 13:13:57 +00:00
|
|
|
{
|
|
|
|
QPainter p;
|
2000-04-27 11:29:25 +00:00
|
|
|
p.begin(this);
|
|
|
|
|
2000-01-03 13:13:57 +00:00
|
|
|
// first the corners
|
|
|
|
int w1 = framePixmaps[FrameTopLeft]->width();
|
|
|
|
int h1 = framePixmaps[FrameTopLeft]->height();
|
|
|
|
if (w1 > width()/2) w1 = width()/2;
|
|
|
|
if (h1 > height()/2) h1 = height()/2;
|
2000-03-31 19:10:22 +00:00
|
|
|
bitBlt(this, 0,0, framePixmaps[FrameTopLeft],
|
|
|
|
0,0, w1, h1);
|
2000-01-03 13:13:57 +00:00
|
|
|
|
|
|
|
int w2 = framePixmaps[FrameTopRight]->width();
|
|
|
|
int h2 = framePixmaps[FrameTopRight]->height();
|
|
|
|
if (w2 > width()/2) w2 = width()/2;
|
|
|
|
if (h2 > height()/2) h2 = height()/2;
|
2000-03-31 19:10:22 +00:00
|
|
|
bitBlt(this, width()-w2,0, framePixmaps[FrameTopRight],
|
|
|
|
framePixmaps[FrameTopRight]->width()-w2,0,w2, h2);
|
2000-01-03 13:13:57 +00:00
|
|
|
|
|
|
|
int w3 = framePixmaps[FrameBottomLeft]->width();
|
|
|
|
int h3 = framePixmaps[FrameBottomLeft]->height();
|
|
|
|
if (w3 > width()/2) w3 = width()/2;
|
|
|
|
if (h3 > height()/2) h3 = height()/2;
|
2000-03-31 19:10:22 +00:00
|
|
|
bitBlt(this, 0,height()-h3, framePixmaps[FrameBottomLeft],
|
|
|
|
0,framePixmaps[FrameBottomLeft]->height()-h3,w3, h3);
|
2000-01-03 13:13:57 +00:00
|
|
|
|
|
|
|
int w4 = framePixmaps[FrameBottomRight]->width();
|
|
|
|
int h4 = framePixmaps[FrameBottomRight]->height();
|
|
|
|
if (w4 > width()/2) w4 = width()/2;
|
|
|
|
if (h4 > height()/2) h4 = height()/2;
|
2000-03-31 19:10:22 +00:00
|
|
|
bitBlt(this, width()-w4,height()-h4, framePixmaps[FrameBottomRight],
|
|
|
|
framePixmaps[FrameBottomRight]->width()-w4,
|
|
|
|
framePixmaps[FrameBottomRight]->height()-h4,
|
|
|
|
w4, h4);
|
2000-01-03 13:13:57 +00:00
|
|
|
|
2000-03-31 19:10:22 +00:00
|
|
|
QPixmap *curPix = framePixmaps[FrameTop];
|
2001-01-24 23:53:37 +00:00
|
|
|
p.drawTiledPixmap(w1, maxExtent-curPix->height(), width()-w2-w1,
|
2000-12-11 20:27:43 +00:00
|
|
|
curPix->height(), *curPix);
|
2000-03-31 19:10:22 +00:00
|
|
|
curPix = framePixmaps[FrameBottom];
|
2001-01-24 23:53:37 +00:00
|
|
|
p.drawTiledPixmap(w3, height()-maxExtent, width()-w3-w4,
|
2000-12-11 20:27:43 +00:00
|
|
|
curPix->height(), *curPix);
|
2000-03-31 19:10:22 +00:00
|
|
|
curPix = framePixmaps[FrameLeft];
|
2001-01-24 23:53:37 +00:00
|
|
|
p.drawTiledPixmap(maxExtent-curPix->width(), h1, curPix->width(),
|
2000-12-11 20:27:43 +00:00
|
|
|
height()-h1-h3, *curPix);
|
2000-03-31 19:10:22 +00:00
|
|
|
|
2000-12-11 20:27:43 +00:00
|
|
|
curPix = framePixmaps[FrameRight];
|
2001-01-24 23:53:37 +00:00
|
|
|
p.drawTiledPixmap(width()-maxExtent, h2, curPix->width(),
|
2000-12-11 20:27:43 +00:00
|
|
|
height()-h2-h4, *curPix);
|
2000-01-03 13:13:57 +00:00
|
|
|
drawTitle(p);
|
|
|
|
p.end();
|
|
|
|
}
|
|
|
|
|
|
|
|
void KWMThemeClient::doShape()
|
|
|
|
{
|
|
|
|
QBitmap mask(width(), height());
|
|
|
|
mask.fill(color0);
|
|
|
|
QPainter p;
|
|
|
|
|
|
|
|
// first the corners
|
|
|
|
int w1 = framePixmaps[FrameTopLeft]->width();
|
|
|
|
int h1 = framePixmaps[FrameTopLeft]->height();
|
|
|
|
if (w1 > width()/2) w1 = width()/2;
|
|
|
|
if (h1 > height()/2) h1 = height()/2;
|
2000-03-31 19:10:22 +00:00
|
|
|
bitBlt(&mask, 0,0,framePixmaps[FrameTopLeft]->mask(),
|
|
|
|
0,0,w1, h1);
|
2000-01-03 13:13:57 +00:00
|
|
|
int w2 = framePixmaps[FrameTopRight]->width();
|
|
|
|
int h2 = framePixmaps[FrameTopRight]->height();
|
|
|
|
if (w2 > width()/2) w2 = width()/2;
|
|
|
|
if (h2 > height()/2) h2 = height()/2;
|
2000-03-31 19:10:22 +00:00
|
|
|
bitBlt(&mask, width()-w2,0,framePixmaps[FrameTopRight]->mask(),
|
|
|
|
framePixmaps[FrameTopRight]->width()-w2,0,w2, h2);
|
2000-01-03 13:13:57 +00:00
|
|
|
|
|
|
|
int w3 = framePixmaps[FrameBottomLeft]->width();
|
|
|
|
int h3 = framePixmaps[FrameBottomLeft]->height();
|
|
|
|
if (w3 > width()/2) w3 = width()/2;
|
|
|
|
if (h3 > height()/2) h3 = height()/2;
|
2000-03-31 19:10:22 +00:00
|
|
|
bitBlt(&mask, 0,height()-h3,framePixmaps[FrameBottomLeft]->mask(),
|
|
|
|
0, framePixmaps[FrameBottomLeft]->height()-h3,w3, h3);
|
2000-01-03 13:13:57 +00:00
|
|
|
|
|
|
|
int w4 = framePixmaps[FrameBottomRight]->width();
|
|
|
|
int h4 = framePixmaps[FrameBottomRight]->height();
|
|
|
|
if (w4 > width()/2) w4 = width()/2;
|
|
|
|
if (h4 > height()/2) h4 = height()/2;
|
2000-03-31 19:10:22 +00:00
|
|
|
bitBlt(&mask, width()-w4,height()-h4,framePixmaps[FrameBottomRight]->mask(),
|
|
|
|
framePixmaps[FrameBottomRight]->width()-w4,
|
|
|
|
framePixmaps[FrameBottomRight]->height()-h4,
|
|
|
|
w4, h4);
|
2000-01-03 13:13:57 +00:00
|
|
|
|
2000-12-11 20:27:43 +00:00
|
|
|
p.begin(&mask);
|
2000-03-31 19:10:22 +00:00
|
|
|
const QBitmap *curPix = framePixmaps[FrameTop]->mask();
|
2001-01-16 23:52:11 +00:00
|
|
|
if (curPix)
|
2001-01-24 23:53:37 +00:00
|
|
|
p.drawTiledPixmap(w1, maxExtent-curPix->height(), width()-w2-w1,
|
2001-01-16 23:52:11 +00:00
|
|
|
curPix->height(), *curPix);
|
2000-03-31 19:10:22 +00:00
|
|
|
curPix = framePixmaps[FrameBottom]->mask();
|
2001-01-16 23:52:11 +00:00
|
|
|
if (curPix)
|
2001-01-24 23:53:37 +00:00
|
|
|
p.drawTiledPixmap(w3, height()-maxExtent, width()-w3-w4,
|
2000-12-11 20:27:43 +00:00
|
|
|
curPix->height(), *curPix);
|
2000-03-31 19:10:22 +00:00
|
|
|
curPix = framePixmaps[FrameLeft]->mask();
|
2001-01-16 23:52:11 +00:00
|
|
|
if (curPix)
|
2001-01-24 23:53:37 +00:00
|
|
|
p.drawTiledPixmap(maxExtent-curPix->width(), h1, curPix->width(),
|
2000-12-11 20:27:43 +00:00
|
|
|
height()-h1-h3, *curPix);
|
2000-03-31 19:10:22 +00:00
|
|
|
curPix = framePixmaps[FrameRight]->mask();
|
2001-01-16 23:52:11 +00:00
|
|
|
if (curPix)
|
2001-01-24 23:53:37 +00:00
|
|
|
p.drawTiledPixmap(width()-maxExtent, h2, curPix->width(),
|
2000-12-11 20:27:43 +00:00
|
|
|
height()-h2-h4, *curPix);
|
2000-03-31 19:10:22 +00:00
|
|
|
p.setBrush(color1);
|
|
|
|
p.setPen(color1);
|
2001-01-24 23:53:37 +00:00
|
|
|
p.fillRect(maxExtent, maxExtent, width()-2*maxExtent,
|
|
|
|
height()-2*maxExtent, color1);
|
2000-01-03 13:13:57 +00:00
|
|
|
p.end();
|
|
|
|
setMask(mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void KWMThemeClient::showEvent(QShowEvent *ev)
|
|
|
|
{
|
|
|
|
Client::showEvent(ev);
|
|
|
|
doShape();
|
|
|
|
repaint(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void KWMThemeClient::windowWrapperShowEvent( QShowEvent* )
|
|
|
|
{
|
|
|
|
doShape();
|
|
|
|
}
|
|
|
|
|
|
|
|
void KWMThemeClient::mouseDoubleClickEvent( QMouseEvent * e )
|
|
|
|
{
|
|
|
|
if (titlebar->geometry().contains( e->pos() ) )
|
|
|
|
setShade( !isShade() );
|
|
|
|
workspace()->requestFocus( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
void KWMThemeClient::stickyChange(bool on)
|
|
|
|
{
|
2001-01-22 23:30:08 +00:00
|
|
|
if (stickyBtn)
|
|
|
|
stickyBtn->setPixmap(on ? *pinupPix : *pindownPix);
|
2000-01-03 13:13:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void KWMThemeClient::maximizeChange(bool m)
|
|
|
|
{
|
2001-01-22 23:30:08 +00:00
|
|
|
if (maxBtn)
|
|
|
|
maxBtn->setPixmap(m ? *minmaxPix : *maxPix);
|
2000-01-03 13:13:57 +00:00
|
|
|
}
|
|
|
|
|
2000-12-13 10:21:31 +00:00
|
|
|
Client::MousePosition KWMThemeClient::mousePosition(const QPoint &p) const
|
|
|
|
{
|
|
|
|
MousePosition m = Client::mousePosition(p);
|
|
|
|
// corners
|
|
|
|
if(p.y() < framePixmaps[FrameTop]->height() &&
|
|
|
|
p.x() < framePixmaps[FrameLeft]->width()){
|
|
|
|
m = TopLeft;
|
|
|
|
}
|
|
|
|
else if(p.y() < framePixmaps[FrameTop]->height() &&
|
|
|
|
p.x() > width()-framePixmaps[FrameRight]->width()){
|
|
|
|
m = TopRight;
|
|
|
|
}
|
|
|
|
else if(p.y() > height()-framePixmaps[FrameBottom]->height() &&
|
|
|
|
p.x() < framePixmaps[FrameLeft]->width()){
|
|
|
|
m = BottomLeft;
|
|
|
|
}
|
|
|
|
else if(p.y() > height()-framePixmaps[FrameBottom]->height() &&
|
|
|
|
p.x() > width()-framePixmaps[FrameRight]->width()){
|
|
|
|
m = BottomRight;
|
|
|
|
} // edges
|
|
|
|
else if(p.y() < framePixmaps[FrameTop]->height())
|
|
|
|
m = Top;
|
|
|
|
else if(p.y() > height()-framePixmaps[FrameBottom]->height())
|
|
|
|
m = Bottom;
|
|
|
|
else if(p.x() < framePixmaps[FrameLeft]->width())
|
|
|
|
m = Left;
|
|
|
|
else if(p.x() > width()-framePixmaps[FrameRight]->width())
|
|
|
|
m = Right;
|
|
|
|
return(m);
|
|
|
|
}
|
|
|
|
|
2000-01-03 13:13:57 +00:00
|
|
|
void KWMThemeClient::init()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-06-29 21:36:40 +00:00
|
|
|
#include "kwmthemeclient.moc"
|