1999-12-24 01:36:47 +00:00
|
|
|
#include "systemclient.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-01-03 13:13:57 +00:00
|
|
|
#include <kdrawutil.h>
|
2000-01-23 13:39:20 +00:00
|
|
|
#include <kapp.h>
|
1999-12-24 01:36:47 +00:00
|
|
|
#include <qbitmap.h>
|
|
|
|
#include "../../workspace.h"
|
|
|
|
#include "../../options.h"
|
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
|
|
|
Client *allocate(Workspace *ws, WId w)
|
|
|
|
{
|
|
|
|
return(new SystemClient(ws, w));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned char iconify_bits[] = {
|
2000-04-28 02:44:29 +00:00
|
|
|
0x00, 0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00};
|
1999-12-24 01:36:47 +00:00
|
|
|
|
|
|
|
static unsigned char maximize_bits[] = {
|
2000-04-28 02:44:29 +00:00
|
|
|
0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0x00};
|
|
|
|
|
1999-12-24 01:36:47 +00:00
|
|
|
static unsigned char minmax_bits[] = {
|
|
|
|
0x0c, 0x18, 0x33, 0x67, 0xcf, 0x9f, 0x3f, 0x3f};
|
|
|
|
|
|
|
|
static unsigned char unsticky_bits[] = {
|
|
|
|
0x00, 0x18, 0x18, 0x7e, 0x7e, 0x18, 0x18, 0x00};
|
|
|
|
|
|
|
|
static unsigned char sticky_bits[] = {
|
|
|
|
0x00, 0x00, 0x00, 0x7e, 0x7e, 0x00, 0x00, 0x00};
|
|
|
|
|
|
|
|
static unsigned char question_bits[] = {
|
|
|
|
0x3c, 0x66, 0x60, 0x30, 0x18, 0x00, 0x18, 0x18};
|
|
|
|
|
2000-01-23 13:39:20 +00:00
|
|
|
static KPixmap *aUpperGradient=0;
|
|
|
|
static KPixmap *iUpperGradient=0;
|
2000-04-28 02:44:29 +00:00
|
|
|
|
|
|
|
static KPixmap *btnPix=0;
|
|
|
|
static KPixmap *btnPixDown=0;
|
|
|
|
static KPixmap *iBtnPix=0;
|
|
|
|
static KPixmap *iBtnPixDown=0;
|
|
|
|
static QColor btnForeground;
|
|
|
|
|
1999-12-24 01:36:47 +00:00
|
|
|
static bool pixmaps_created = false;
|
|
|
|
|
2000-04-28 02:44:29 +00:00
|
|
|
static void drawButtonFrame(KPixmap *pix, const QColorGroup &g)
|
|
|
|
{
|
2000-04-28 10:10:27 +00:00
|
|
|
QPainter p;
|
2000-04-28 02:44:29 +00:00
|
|
|
p.begin(pix);
|
|
|
|
p.setPen(g.mid());
|
|
|
|
p.drawLine(0, 0, 13, 0);
|
|
|
|
p.drawLine(0, 0, 0, 13);
|
|
|
|
p.setPen(g.light());
|
|
|
|
p.drawLine(13, 0, 13, 13);
|
|
|
|
p.drawLine(0, 13, 13, 13);
|
|
|
|
p.setPen(g.dark());
|
|
|
|
p.drawRect(1, 1, 12, 12);
|
|
|
|
p.end();
|
|
|
|
}
|
|
|
|
|
1999-12-24 01:36:47 +00:00
|
|
|
static void create_pixmaps()
|
|
|
|
{
|
|
|
|
if(pixmaps_created)
|
|
|
|
return;
|
|
|
|
pixmaps_created = true;
|
|
|
|
|
|
|
|
QPainter p;
|
2000-04-08 23:40:56 +00:00
|
|
|
if(QPixmap::defaultDepth() > 8){
|
2000-04-28 02:44:29 +00:00
|
|
|
// titlebar
|
2000-01-23 13:39:20 +00:00
|
|
|
aUpperGradient = new KPixmap;
|
|
|
|
aUpperGradient->resize(32, 18);
|
|
|
|
iUpperGradient = new KPixmap;
|
|
|
|
iUpperGradient->resize(32, 18);
|
|
|
|
QColor bgColor = kapp->palette().normal().background();
|
|
|
|
KPixmapEffect::gradient(*aUpperGradient,
|
|
|
|
options->color(Options::Frame, true).light(130),
|
|
|
|
bgColor,
|
|
|
|
KPixmapEffect::VerticalGradient);
|
|
|
|
KPixmapEffect::gradient(*iUpperGradient,
|
|
|
|
options->color(Options::Frame, false).light(130),
|
|
|
|
bgColor,
|
|
|
|
KPixmapEffect::VerticalGradient);
|
2000-04-28 02:44:29 +00:00
|
|
|
|
|
|
|
// buttons
|
|
|
|
KPixmap aPix;
|
|
|
|
aPix.resize(12, 12);
|
|
|
|
KPixmap iPix;
|
|
|
|
iPix.resize(12, 12);
|
|
|
|
KPixmap aInternal;
|
|
|
|
aInternal.resize(8, 8);
|
|
|
|
KPixmap iInternal;
|
|
|
|
iInternal.resize(8, 8);
|
|
|
|
|
|
|
|
QColor hColor(options->color(Options::ButtonBg, false));
|
|
|
|
KPixmapEffect::gradient(iInternal,
|
|
|
|
hColor.dark(120),
|
|
|
|
hColor.light(120),
|
|
|
|
KPixmapEffect::DiagonalGradient);
|
|
|
|
KPixmapEffect::gradient(iPix,
|
|
|
|
hColor.light(150),
|
|
|
|
hColor.dark(150),
|
|
|
|
KPixmapEffect::DiagonalGradient);
|
|
|
|
|
|
|
|
hColor =options->color(Options::ButtonBg, true);
|
|
|
|
KPixmapEffect::gradient(aInternal,
|
|
|
|
hColor.dark(120),
|
|
|
|
hColor.light(120),
|
|
|
|
KPixmapEffect::DiagonalGradient);
|
|
|
|
KPixmapEffect::gradient(aPix,
|
|
|
|
hColor.light(150),
|
|
|
|
hColor.dark(150),
|
|
|
|
KPixmapEffect::DiagonalGradient);
|
|
|
|
bitBlt(&aPix, 1, 1, &aInternal, 0, 0, 8, 8, Qt::CopyROP, true);
|
|
|
|
bitBlt(&iPix, 1, 1, &iInternal, 0, 0, 8, 8, Qt::CopyROP, true);
|
|
|
|
|
|
|
|
// normal buttons
|
|
|
|
btnPix = new KPixmap;
|
|
|
|
btnPix->resize(14, 14);
|
|
|
|
bitBlt(btnPix, 2, 2, &aPix, 0, 0, 10, 10, Qt::CopyROP, true);
|
2000-04-28 10:10:27 +00:00
|
|
|
drawButtonFrame(btnPix, options->colorGroup(Options::Frame, true));
|
2000-04-28 02:44:29 +00:00
|
|
|
|
|
|
|
iBtnPix = new KPixmap;
|
|
|
|
iBtnPix->resize(14, 14);
|
|
|
|
bitBlt(iBtnPix, 2, 2, &iPix, 0, 0, 10, 10, Qt::CopyROP, true);
|
2000-04-28 10:10:27 +00:00
|
|
|
drawButtonFrame(iBtnPix, options->colorGroup(Options::Frame, false));
|
2000-04-28 02:44:29 +00:00
|
|
|
|
2000-04-01 01:18:12 +00:00
|
|
|
|
2000-04-28 02:44:29 +00:00
|
|
|
// pressed buttons
|
|
|
|
hColor = options->color(Options::ButtonBg, false);
|
|
|
|
KPixmapEffect::gradient(iInternal,
|
|
|
|
hColor.light(130),
|
|
|
|
hColor.dark(130),
|
|
|
|
KPixmapEffect::DiagonalGradient);
|
|
|
|
KPixmapEffect::gradient(iPix,
|
|
|
|
hColor.light(150),
|
|
|
|
hColor.dark(150),
|
|
|
|
KPixmapEffect::DiagonalGradient);
|
|
|
|
|
|
|
|
hColor =options->color(Options::ButtonBg, true);
|
|
|
|
KPixmapEffect::gradient(aInternal,
|
|
|
|
hColor.light(130),
|
|
|
|
hColor.dark(130),
|
|
|
|
KPixmapEffect::DiagonalGradient);
|
|
|
|
KPixmapEffect::gradient(aPix,
|
|
|
|
hColor.light(150),
|
|
|
|
hColor.dark(150),
|
|
|
|
KPixmapEffect::DiagonalGradient);
|
|
|
|
bitBlt(&aPix, 1, 1, &aInternal, 0, 0, 8, 8, Qt::CopyROP, true);
|
|
|
|
bitBlt(&iPix, 1, 1, &iInternal, 0, 0, 8, 8, Qt::CopyROP, true);
|
|
|
|
|
|
|
|
btnPixDown = new KPixmap;
|
|
|
|
btnPixDown->resize(14, 14);
|
|
|
|
bitBlt(btnPixDown, 2, 2, &aPix, 0, 0, 10, 10, Qt::CopyROP, true);
|
2000-04-28 10:10:27 +00:00
|
|
|
drawButtonFrame(btnPixDown, options->colorGroup(Options::Frame,
|
2000-04-28 02:44:29 +00:00
|
|
|
true));
|
|
|
|
|
|
|
|
iBtnPixDown = new KPixmap;
|
|
|
|
iBtnPixDown->resize(14, 14);
|
|
|
|
bitBlt(iBtnPixDown, 2, 2, &iPix, 0, 0, 10, 10, Qt::CopyROP, true);
|
2000-04-28 10:10:27 +00:00
|
|
|
drawButtonFrame(iBtnPixDown, options->colorGroup(Options::Frame,
|
2000-04-28 02:44:29 +00:00
|
|
|
false));
|
2000-01-23 13:39:20 +00:00
|
|
|
}
|
2000-04-28 02:44:29 +00:00
|
|
|
if(qGray(options->color(Options::ButtonBg, true).rgb()) > 128)
|
|
|
|
btnForeground = Qt::black;
|
|
|
|
else
|
|
|
|
btnForeground = Qt::white;
|
|
|
|
}
|
1999-12-24 01:36:47 +00:00
|
|
|
|
|
|
|
|
2000-04-28 02:44:29 +00:00
|
|
|
SystemButton::SystemButton(Client *parent, const char *name,
|
1999-12-24 01:36:47 +00:00
|
|
|
const unsigned char *bitmap)
|
|
|
|
: QButton(parent, name)
|
|
|
|
{
|
2000-01-23 23:33:29 +00:00
|
|
|
resize(14, 14);
|
|
|
|
|
|
|
|
if(bitmap)
|
|
|
|
setBitmap(bitmap);
|
2000-04-28 02:44:29 +00:00
|
|
|
client = parent;
|
2000-01-23 23:33:29 +00:00
|
|
|
}
|
1999-12-24 01:36:47 +00:00
|
|
|
|
2000-03-18 12:35:05 +00:00
|
|
|
QSize SystemButton::sizeHint() const
|
|
|
|
{
|
|
|
|
return(QSize(14, 14));
|
|
|
|
}
|
|
|
|
|
2000-01-23 23:33:29 +00:00
|
|
|
void SystemButton::reset()
|
|
|
|
{
|
2000-04-28 10:10:27 +00:00
|
|
|
repaint(false);
|
1999-12-24 01:36:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SystemButton::setBitmap(const unsigned char *bitmap)
|
|
|
|
{
|
|
|
|
deco = QBitmap(8, 8, bitmap, true);
|
|
|
|
deco.setMask(deco);
|
|
|
|
repaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemButton::drawButton(QPainter *p)
|
|
|
|
{
|
2000-04-28 02:59:07 +00:00
|
|
|
if(btnPixDown){
|
|
|
|
if(client->isActive())
|
|
|
|
p->drawPixmap(0, 0, isDown() ? *btnPixDown : *btnPix);
|
|
|
|
else
|
|
|
|
p->drawPixmap(0, 0, isDown() ? *iBtnPixDown : *iBtnPix);
|
|
|
|
}
|
|
|
|
else{
|
2000-04-28 10:10:27 +00:00
|
|
|
QColorGroup g = options->colorGroup(Options::Frame,
|
2000-04-28 02:59:07 +00:00
|
|
|
client->isActive());
|
|
|
|
int x2 = width()-1;
|
|
|
|
int y2 = height()-1;
|
|
|
|
// outer frame
|
|
|
|
p->setPen(g.mid());
|
|
|
|
p->drawLine(0, 0, x2, 0);
|
|
|
|
p->drawLine(0, 0, 0, y2);
|
|
|
|
p->setPen(g.light());
|
|
|
|
p->drawLine(x2, 0, x2, y2);
|
|
|
|
p->drawLine(0, x2, y2, x2);
|
|
|
|
p->setPen(g.dark());
|
|
|
|
p->drawRect(1, 1, width()-2, height()-2);
|
|
|
|
// inner frame
|
2000-04-28 10:10:27 +00:00
|
|
|
g = options->colorGroup(Options::ButtonBg, client->isActive());
|
|
|
|
p->fillRect(3, 3, width()-6, height()-6, g.background());
|
2000-04-28 02:59:07 +00:00
|
|
|
p->setPen(isDown() ? g.mid() : g.light());
|
|
|
|
p->drawLine(2, 2, x2-2, 2);
|
|
|
|
p->drawLine(2, 2, 2, y2-2);
|
|
|
|
p->setPen(isDown() ? g.light() : g.mid());
|
|
|
|
p->drawLine(x2-2, 2, x2-2, y2-2);
|
|
|
|
p->drawLine(2, x2-2, y2-2, x2-2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2000-04-28 02:44:29 +00:00
|
|
|
if(!deco.isNull()){
|
|
|
|
p->setPen(btnForeground);
|
|
|
|
p->drawPixmap(isDown() ? 4 : 3, isDown() ? 4 : 3, deco);
|
|
|
|
}
|
1999-12-24 01:36:47 +00:00
|
|
|
}
|
|
|
|
|
2000-01-23 23:33:29 +00:00
|
|
|
void SystemClient::slotReset()
|
|
|
|
{
|
|
|
|
if(aUpperGradient){
|
|
|
|
delete aUpperGradient;
|
|
|
|
delete iUpperGradient;
|
2000-04-28 02:44:29 +00:00
|
|
|
delete btnPix;
|
|
|
|
delete btnPixDown;
|
|
|
|
delete iBtnPix;
|
|
|
|
delete iBtnPixDown;
|
2000-01-23 23:33:29 +00:00
|
|
|
}
|
|
|
|
pixmaps_created = false;
|
|
|
|
create_pixmaps();
|
2000-04-01 01:18:12 +00:00
|
|
|
titleBuffer.resize(0, 0);
|
|
|
|
recalcTitleBuffer();
|
2000-01-23 23:33:29 +00:00
|
|
|
button[0]->reset();
|
|
|
|
button[1]->reset();
|
|
|
|
button[2]->reset();
|
|
|
|
button[3]->reset();
|
|
|
|
if(button[4])
|
|
|
|
button[4]->reset();
|
|
|
|
}
|
|
|
|
|
1999-12-24 01:36:47 +00:00
|
|
|
SystemClient::SystemClient( Workspace *ws, WId w, QWidget *parent,
|
|
|
|
const char *name )
|
|
|
|
: Client( ws, w, parent, name, WResizeNoErase )
|
|
|
|
{
|
|
|
|
create_pixmaps();
|
2000-01-23 23:33:29 +00:00
|
|
|
connect(options, SIGNAL(resetClients()), this, SLOT(slotReset()));
|
1999-12-24 01:36:47 +00:00
|
|
|
bool help = providesContextHelp();
|
|
|
|
|
|
|
|
QGridLayout* g = new QGridLayout(this, 0, 0, 2);
|
|
|
|
g->setRowStretch(1, 10);
|
|
|
|
g->addWidget(windowWrapper(), 1, 1 );
|
|
|
|
g->addItem( new QSpacerItem( 0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ) );
|
|
|
|
|
|
|
|
g->addColSpacing(0, 2);
|
|
|
|
g->addColSpacing(2, 2);
|
|
|
|
g->addRowSpacing(2, 6);
|
|
|
|
|
2000-04-28 02:44:29 +00:00
|
|
|
button[0] = new SystemButton(this, "close"/*, close_bits*/);
|
1999-12-24 01:36:47 +00:00
|
|
|
button[1] = new SystemButton(this, "sticky");
|
|
|
|
if(isSticky())
|
|
|
|
button[1]->setBitmap(unsticky_bits);
|
|
|
|
else
|
|
|
|
button[1]->setBitmap(sticky_bits);
|
|
|
|
button[2] = new SystemButton(this, "iconify", iconify_bits);
|
|
|
|
button[3] = new SystemButton(this, "maximize", maximize_bits);
|
|
|
|
if(help){
|
|
|
|
button[4] = new SystemButton(this, "help", question_bits);
|
|
|
|
connect( button[4], SIGNAL( clicked() ), this, ( SLOT( contextHelp() ) ) );
|
|
|
|
}
|
2000-01-23 23:33:29 +00:00
|
|
|
else
|
|
|
|
button[4] = NULL;
|
1999-12-24 01:36:47 +00:00
|
|
|
|
|
|
|
connect( button[0], SIGNAL( clicked() ), this, ( SLOT( closeWindow() ) ) );
|
|
|
|
connect( button[1], SIGNAL( clicked() ), this, ( SLOT( toggleSticky() ) ) );
|
|
|
|
connect( button[2], SIGNAL( clicked() ), this, ( SLOT( iconify() ) ) );
|
|
|
|
connect( button[3], SIGNAL( clicked() ), this, ( SLOT( maximize() ) ) );
|
|
|
|
|
2000-03-25 23:14:21 +00:00
|
|
|
QHBoxLayout* hb = new QHBoxLayout(0);
|
2000-03-18 12:35:05 +00:00
|
|
|
hb->setResizeMode(QLayout::FreeResize);
|
1999-12-24 01:36:47 +00:00
|
|
|
g->addLayout( hb, 0, 1 );
|
2000-03-25 23:14:21 +00:00
|
|
|
hb->addSpacing(3);
|
2000-03-18 12:35:05 +00:00
|
|
|
hb->addWidget( button[0]);
|
2000-03-25 22:23:09 +00:00
|
|
|
titlebar = new QSpacerItem(10, 14, QSizePolicy::Expanding,
|
1999-12-24 01:36:47 +00:00
|
|
|
QSizePolicy::Minimum);
|
2000-03-25 23:14:21 +00:00
|
|
|
hb->addSpacing(3);
|
1999-12-24 01:36:47 +00:00
|
|
|
hb->addItem(titlebar);
|
|
|
|
hb->addSpacing(3);
|
|
|
|
if(help){
|
2000-03-18 12:35:05 +00:00
|
|
|
hb->addWidget( button[4]);
|
1999-12-24 01:36:47 +00:00
|
|
|
hb->addSpacing(1);
|
|
|
|
}
|
2000-03-18 12:35:05 +00:00
|
|
|
hb->addWidget( button[1]);
|
1999-12-24 01:36:47 +00:00
|
|
|
hb->addSpacing(1);
|
2000-03-18 12:35:05 +00:00
|
|
|
hb->addWidget( button[2]);
|
1999-12-24 01:36:47 +00:00
|
|
|
hb->addSpacing(1);
|
2000-03-18 12:35:05 +00:00
|
|
|
hb->addWidget( button[3]);
|
1999-12-24 01:36:47 +00:00
|
|
|
hb->addSpacing(3);
|
|
|
|
|
2000-04-01 01:18:12 +00:00
|
|
|
setBackgroundMode(NoBackground);
|
|
|
|
recalcTitleBuffer();
|
|
|
|
|
1999-12-24 01:36:47 +00:00
|
|
|
}
|
|
|
|
|
2000-04-01 01:18:12 +00:00
|
|
|
void SystemClient::resizeEvent( QResizeEvent* )
|
1999-12-24 01:36:47 +00:00
|
|
|
{
|
2000-04-01 01:18:12 +00:00
|
|
|
//Client::resizeEvent( e );
|
|
|
|
recalcTitleBuffer();
|
1999-12-24 01:36:47 +00:00
|
|
|
doShape();
|
2000-04-01 01:18:12 +00:00
|
|
|
/*
|
1999-12-24 01:36:47 +00:00
|
|
|
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() );
|
2000-04-01 01:18:12 +00:00
|
|
|
}*/
|
1999-12-24 01:36:47 +00:00
|
|
|
}
|
|
|
|
|
2000-04-01 01:18:12 +00:00
|
|
|
void SystemClient::recalcTitleBuffer()
|
1999-12-24 01:36:47 +00:00
|
|
|
{
|
2000-04-01 01:18:12 +00:00
|
|
|
if(oldTitle == caption() && width() == titleBuffer.width())
|
|
|
|
return;
|
|
|
|
QFontMetrics fm(options->font(true));
|
|
|
|
titleBuffer.resize(width(), 18);
|
|
|
|
QPainter p;
|
|
|
|
p.begin(&titleBuffer);
|
|
|
|
if(aUpperGradient)
|
|
|
|
p.drawTiledPixmap(0, 0, width(), 18, *aUpperGradient);
|
|
|
|
else
|
|
|
|
p.fillRect(0, 0, width(), 18,
|
|
|
|
options->colorGroup(Options::Frame, true).
|
|
|
|
brush(QColorGroup::Button));
|
|
|
|
|
|
|
|
QRect t = titlebar->geometry();
|
|
|
|
t.setTop( 2 );
|
|
|
|
t.setLeft( t.left() + 4 );
|
|
|
|
t.setRight( t.right() - 2 );
|
|
|
|
|
|
|
|
QRegion r(t.x(), 0, t.width(), 18);
|
|
|
|
r -= QRect(t.x()+((t.width()-fm.width(caption()))/2)-4,
|
|
|
|
0, fm.width(caption())+8, 18);
|
|
|
|
p.setClipRegion(r);
|
|
|
|
int i, ly;
|
|
|
|
for(i=0, ly=4; i < 4; ++i, ly+=3){
|
2000-04-28 15:53:00 +00:00
|
|
|
p.setPen(options->color(Options::TitleBar, true).light(150));
|
2000-04-01 01:18:12 +00:00
|
|
|
p.drawLine(0, ly, width()-1, ly);
|
2000-04-28 15:53:00 +00:00
|
|
|
p.setPen(options->color(Options::TitleBar, true).dark(120));
|
2000-04-01 01:18:12 +00:00
|
|
|
p.drawLine(0, ly+1, width()-1, ly+1);
|
|
|
|
}
|
|
|
|
p.setClipRect(t);
|
2000-04-28 15:53:00 +00:00
|
|
|
p.setPen(options->color(Options::Font, true));
|
2000-04-01 01:18:12 +00:00
|
|
|
p.setFont(options->font(true));
|
|
|
|
|
|
|
|
p.drawText(t.x()+((t.width()-fm.width(caption()))/2)-4,
|
|
|
|
0, fm.width(caption())+8, 18, AlignCenter, caption());
|
|
|
|
p.setClipping(false);
|
|
|
|
p.end();
|
|
|
|
oldTitle = caption();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemClient::captionChange( const QString &)
|
|
|
|
{
|
|
|
|
recalcTitleBuffer();
|
1999-12-24 01:36:47 +00:00
|
|
|
repaint( titlebar->geometry(), false );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemClient::drawRoundFrame(QPainter &p, int x, int y, int w, int h)
|
|
|
|
{
|
2000-01-03 13:13:57 +00:00
|
|
|
kDrawRoundButton(&p, x, y, w, h,
|
|
|
|
options->colorGroup(Options::Frame, isActive()), false);
|
|
|
|
|
1999-12-24 01:36:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void SystemClient::paintEvent( QPaintEvent* )
|
|
|
|
{
|
|
|
|
QPainter p( this );
|
|
|
|
QRect t = titlebar->geometry();
|
|
|
|
|
|
|
|
QBrush fillBrush(colorGroup().brush(QColorGroup::Background).pixmap() ?
|
|
|
|
colorGroup().brush(QColorGroup::Background) :
|
|
|
|
options->colorGroup(Options::Frame, isActive()).
|
|
|
|
brush(QColorGroup::Button));
|
|
|
|
|
2000-04-01 01:18:12 +00:00
|
|
|
p.fillRect(1, 18, width()-2, height()-19, fillBrush);
|
1999-12-24 01:36:47 +00:00
|
|
|
|
|
|
|
t.setTop( 2 );
|
|
|
|
t.setLeft( t.left() + 4 );
|
|
|
|
t.setRight( t.right() - 2 );
|
2000-04-01 01:18:12 +00:00
|
|
|
|
|
|
|
if(isActive())
|
|
|
|
p.drawPixmap(0, 0, titleBuffer);
|
|
|
|
else{
|
|
|
|
if(iUpperGradient)
|
|
|
|
p.drawTiledPixmap(0, 0, width(), 18, *iUpperGradient);
|
2000-01-23 13:39:20 +00:00
|
|
|
else
|
2000-04-08 23:40:56 +00:00
|
|
|
p.fillRect(0, 0, width(), 18, fillBrush);
|
2000-04-28 15:53:00 +00:00
|
|
|
p.setPen(options->color(Options::Font, isActive()));
|
2000-04-01 01:18:12 +00:00
|
|
|
p.setFont(options->font(isActive()));
|
|
|
|
p.drawText(t, AlignCenter, caption() );
|
1999-12-24 01:36:47 +00:00
|
|
|
}
|
2000-04-01 01:18:12 +00:00
|
|
|
|
1999-12-24 01:36:47 +00:00
|
|
|
|
|
|
|
|
|
|
|
p.setPen(options->colorGroup(Options::Frame, isActive()).light());
|
|
|
|
p.drawLine(width()-20, height()-7, width()-10, height()-7);
|
|
|
|
p.drawLine(width()-20, height()-5, width()-10, height()-5);
|
|
|
|
p.setPen(options->colorGroup(Options::Frame, isActive()).dark());
|
|
|
|
p.drawLine(width()-20, height()-6, width()-10, height()-6);
|
|
|
|
p.drawLine(width()-20, height()-4, width()-10, height()-4);
|
2000-01-23 13:39:20 +00:00
|
|
|
|
|
|
|
drawRoundFrame(p, 0, 0, width(), height());
|
1999-12-24 01:36:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
|
|
|
|
|
|
|
|
void SystemClient::doShape()
|
|
|
|
{
|
|
|
|
// using a bunch of QRect lines seems much more efficent than bitmaps or
|
|
|
|
// point arrays
|
|
|
|
|
2000-01-03 13:13:57 +00:00
|
|
|
QRegion mask;
|
|
|
|
kRoundMaskRegion(mask, 0, 0, width(), height());
|
1999-12-24 01:36:47 +00:00
|
|
|
setMask(mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemClient::showEvent(QShowEvent *ev)
|
|
|
|
{
|
|
|
|
Client::showEvent(ev);
|
|
|
|
doShape();
|
|
|
|
repaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemClient::windowWrapperShowEvent( QShowEvent* )
|
|
|
|
{
|
|
|
|
doShape();
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemClient::mouseDoubleClickEvent( QMouseEvent * e )
|
|
|
|
{
|
|
|
|
if (titlebar->geometry().contains( e->pos() ) )
|
|
|
|
setShade( !isShade() );
|
|
|
|
workspace()->requestFocus( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemClient::stickyChange(bool on)
|
|
|
|
{
|
|
|
|
button[1]->setBitmap(on ? unsticky_bits : sticky_bits);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemClient::maximizeChange(bool m)
|
|
|
|
{
|
|
|
|
button[3]->setBitmap(m ? minmax_bits : maximize_bits);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SystemClient::init()
|
|
|
|
{
|
|
|
|
//
|
|
|
|
}
|
|
|
|
|
2000-04-28 10:10:27 +00:00
|
|
|
void SystemClient::activeChange(bool)
|
|
|
|
{
|
|
|
|
repaint(false);
|
|
|
|
button[0]->reset();
|
|
|
|
button[1]->reset();
|
|
|
|
button[2]->reset();
|
|
|
|
button[3]->reset();
|
|
|
|
if(button[4])
|
|
|
|
button[4]->reset();
|
|
|
|
}
|
|
|
|
|
1999-12-24 01:36:47 +00:00
|
|
|
|