You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
738 lines
23 KiB
738 lines
23 KiB
15 years ago
|
#include "systemclient.h"
|
||
|
|
||
15 years ago
|
#include <tqlayout.h>
|
||
|
#include <tqdrawutil.h>
|
||
|
#include <tqbitmap.h>
|
||
|
#include <tqtooltip.h>
|
||
|
#include <tqlabel.h>
|
||
|
#include <tqcursor.h>
|
||
15 years ago
|
|
||
|
#include <kpixmapeffect.h>
|
||
|
#include <kdrawutil.h>
|
||
|
#include <klocale.h>
|
||
|
#include <kapplication.h>
|
||
|
#include <kdebug.h>
|
||
|
|
||
13 years ago
|
// Default button tqlayout
|
||
15 years ago
|
const char default_left[] = "X";
|
||
|
const char default_right[] = "HSIA";
|
||
|
|
||
|
namespace System {
|
||
|
|
||
|
static unsigned char iconify_bits[] = {
|
||
|
0x00, 0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00};
|
||
|
|
||
|
static unsigned char maximize_bits[] = {
|
||
|
0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0x00};
|
||
|
|
||
|
static unsigned char r_minmax_bits[] = {
|
||
|
0x0c, 0x18, 0x33, 0x67, 0xcf, 0x9f, 0x3f, 0x3f};
|
||
|
|
||
|
static unsigned char l_minmax_bits[] = {
|
||
|
0x30, 0x18, 0xcc, 0xe6, 0xf3, 0xf9, 0xfc, 0xfc};
|
||
|
|
||
|
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};
|
||
|
|
||
|
static KPixmap *aUpperGradient=0;
|
||
|
static KPixmap *iUpperGradient=0;
|
||
|
|
||
|
static KPixmap *btnPix=0;
|
||
|
static KPixmap *btnPixDown=0;
|
||
|
static KPixmap *iBtnPix=0;
|
||
|
static KPixmap *iBtnPixDown=0;
|
||
15 years ago
|
static TQColor *btnForeground;
|
||
15 years ago
|
|
||
|
static bool pixmaps_created = false;
|
||
|
|
||
15 years ago
|
static void drawButtonFrame(KPixmap *pix, const TQColorGroup &g)
|
||
15 years ago
|
{
|
||
15 years ago
|
TQPainter p;
|
||
15 years ago
|
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();
|
||
|
}
|
||
|
|
||
|
static void create_pixmaps()
|
||
|
{
|
||
|
if(pixmaps_created)
|
||
|
return;
|
||
|
pixmaps_created = true;
|
||
|
|
||
15 years ago
|
if(TQPixmap::defaultDepth() > 8){
|
||
15 years ago
|
// titlebar
|
||
|
aUpperGradient = new KPixmap;
|
||
|
aUpperGradient->resize(32, 18);
|
||
|
iUpperGradient = new KPixmap;
|
||
|
iUpperGradient->resize(32, 18);
|
||
13 years ago
|
TQColor bgColor = kapp->tqpalette().active().background();
|
||
15 years ago
|
KPixmapEffect::gradient(*aUpperGradient,
|
||
|
KDecoration::options()->color(KDecorationOptions::ColorFrame, true).light(130),
|
||
|
bgColor,
|
||
|
KPixmapEffect::VerticalGradient);
|
||
|
KPixmapEffect::gradient(*iUpperGradient,
|
||
|
KDecoration::options()->color(KDecorationOptions::ColorFrame, false).light(130),
|
||
|
bgColor,
|
||
|
KPixmapEffect::VerticalGradient);
|
||
|
|
||
|
// 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);
|
||
|
|
||
15 years ago
|
TQColor hColor(KDecoration::options()->color(KDecorationOptions::ColorButtonBg, false));
|
||
15 years ago
|
KPixmapEffect::gradient(iInternal,
|
||
|
hColor.dark(120),
|
||
|
hColor.light(120),
|
||
|
KPixmapEffect::DiagonalGradient);
|
||
|
KPixmapEffect::gradient(iPix,
|
||
|
hColor.light(150),
|
||
|
hColor.dark(150),
|
||
|
KPixmapEffect::DiagonalGradient);
|
||
|
|
||
|
hColor =KDecoration::options()->color(KDecorationOptions::ColorButtonBg, true);
|
||
|
KPixmapEffect::gradient(aInternal,
|
||
|
hColor.dark(120),
|
||
|
hColor.light(120),
|
||
|
KPixmapEffect::DiagonalGradient);
|
||
|
KPixmapEffect::gradient(aPix,
|
||
|
hColor.light(150),
|
||
|
hColor.dark(150),
|
||
|
KPixmapEffect::DiagonalGradient);
|
||
13 years ago
|
bitBlt(TQT_TQPAINTDEVICE(&aPix), 1, 1, TQT_TQPAINTDEVICE(&aInternal), 0, 0, 8, 8, TQt::CopyROP, true);
|
||
|
bitBlt(TQT_TQPAINTDEVICE(&iPix), 1, 1, TQT_TQPAINTDEVICE(&iInternal), 0, 0, 8, 8, TQt::CopyROP, true);
|
||
15 years ago
|
|
||
|
// normal buttons
|
||
|
btnPix = new KPixmap;
|
||
|
btnPix->resize(14, 14);
|
||
13 years ago
|
bitBlt(TQT_TQPAINTDEVICE(btnPix), 2, 2, TQT_TQPAINTDEVICE(&aPix), 0, 0, 10, 10, TQt::CopyROP, true);
|
||
|
drawButtonFrame(btnPix, KDecoration::options()->tqcolorGroup(KDecorationOptions::ColorFrame, true));
|
||
15 years ago
|
|
||
|
iBtnPix = new KPixmap;
|
||
|
iBtnPix->resize(14, 14);
|
||
13 years ago
|
bitBlt(TQT_TQPAINTDEVICE(iBtnPix), 2, 2, TQT_TQPAINTDEVICE(&iPix), 0, 0, 10, 10, TQt::CopyROP, true);
|
||
|
drawButtonFrame(iBtnPix, KDecoration::options()->tqcolorGroup(KDecorationOptions::ColorFrame, false));
|
||
15 years ago
|
|
||
|
|
||
|
// pressed buttons
|
||
|
hColor = KDecoration::options()->color(KDecorationOptions::ColorButtonBg, false);
|
||
|
KPixmapEffect::gradient(iInternal,
|
||
|
hColor.light(130),
|
||
|
hColor.dark(130),
|
||
|
KPixmapEffect::DiagonalGradient);
|
||
|
KPixmapEffect::gradient(iPix,
|
||
|
hColor.light(150),
|
||
|
hColor.dark(150),
|
||
|
KPixmapEffect::DiagonalGradient);
|
||
|
|
||
|
hColor =KDecoration::options()->color(KDecorationOptions::ColorButtonBg, true);
|
||
|
KPixmapEffect::gradient(aInternal,
|
||
|
hColor.light(130),
|
||
|
hColor.dark(130),
|
||
|
KPixmapEffect::DiagonalGradient);
|
||
|
KPixmapEffect::gradient(aPix,
|
||
|
hColor.light(150),
|
||
|
hColor.dark(150),
|
||
|
KPixmapEffect::DiagonalGradient);
|
||
13 years ago
|
bitBlt(TQT_TQPAINTDEVICE(&aPix), 1, 1, TQT_TQPAINTDEVICE(&aInternal), 0, 0, 8, 8, TQt::CopyROP, true);
|
||
|
bitBlt(TQT_TQPAINTDEVICE(&iPix), 1, 1, TQT_TQPAINTDEVICE(&iInternal), 0, 0, 8, 8, TQt::CopyROP, true);
|
||
15 years ago
|
|
||
|
btnPixDown = new KPixmap;
|
||
|
btnPixDown->resize(14, 14);
|
||
13 years ago
|
bitBlt(TQT_TQPAINTDEVICE(btnPixDown), 2, 2, TQT_TQPAINTDEVICE(&aPix), 0, 0, 10, 10, TQt::CopyROP, true);
|
||
|
drawButtonFrame(btnPixDown, KDecoration::options()->tqcolorGroup(KDecorationOptions::ColorFrame,
|
||
15 years ago
|
true));
|
||
|
|
||
|
iBtnPixDown = new KPixmap;
|
||
|
iBtnPixDown->resize(14, 14);
|
||
13 years ago
|
bitBlt(TQT_TQPAINTDEVICE(iBtnPixDown), 2, 2, TQT_TQPAINTDEVICE(&iPix), 0, 0, 10, 10, TQt::CopyROP, true);
|
||
|
drawButtonFrame(iBtnPixDown, KDecoration::options()->tqcolorGroup(KDecorationOptions::ColorFrame,
|
||
15 years ago
|
false));
|
||
|
}
|
||
13 years ago
|
if(tqGray(KDecoration::options()->color(KDecorationOptions::ColorButtonBg, true).rgb()) > 128)
|
||
|
btnForeground = new TQColor(TQt::black);
|
||
15 years ago
|
else
|
||
13 years ago
|
btnForeground = new TQColor(TQt::white);
|
||
15 years ago
|
}
|
||
|
|
||
|
static void delete_pixmaps()
|
||
|
{
|
||
|
if(aUpperGradient){
|
||
|
delete aUpperGradient;
|
||
|
delete iUpperGradient;
|
||
|
delete btnPix;
|
||
|
delete btnPixDown;
|
||
|
delete iBtnPix;
|
||
|
delete iBtnPixDown;
|
||
|
aUpperGradient = 0;
|
||
|
}
|
||
|
delete btnForeground;
|
||
|
pixmaps_created = false;
|
||
|
}
|
||
|
|
||
|
SystemButton::SystemButton(SystemClient *parent, const char *name,
|
||
15 years ago
|
const unsigned char *bitmap, const TQString& tip)
|
||
|
: TQButton(parent->widget(), name)
|
||
15 years ago
|
{
|
||
|
setTipText(tip);
|
||
|
setBackgroundMode( NoBackground );
|
||
|
setCursor(ArrowCursor);
|
||
|
resize(14, 14);
|
||
|
if(bitmap)
|
||
|
setBitmap(bitmap);
|
||
|
client = parent;
|
||
|
}
|
||
|
|
||
15 years ago
|
void SystemButton::setTipText(const TQString &tip)
|
||
15 years ago
|
{
|
||
|
if (KDecoration::options()->showTooltips())
|
||
|
{
|
||
15 years ago
|
TQToolTip::remove(this );
|
||
|
TQToolTip::add(this, tip );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
|
||
13 years ago
|
TQSize SystemButton::tqsizeHint() const
|
||
15 years ago
|
{
|
||
15 years ago
|
return(TQSize(14, 14));
|
||
15 years ago
|
}
|
||
|
|
||
|
void SystemButton::reset()
|
||
|
{
|
||
13 years ago
|
tqrepaint(false);
|
||
15 years ago
|
}
|
||
|
|
||
|
void SystemButton::setBitmap(const unsigned char *bitmap)
|
||
|
{
|
||
15 years ago
|
deco = TQBitmap(8, 8, bitmap, true);
|
||
15 years ago
|
deco.setMask(deco);
|
||
13 years ago
|
tqrepaint();
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void SystemButton::drawButton(TQPainter *p)
|
||
15 years ago
|
{
|
||
|
if(btnPixDown){
|
||
|
if(client->isActive())
|
||
|
p->drawPixmap(0, 0, isDown() ? *btnPixDown : *btnPix);
|
||
|
else
|
||
|
p->drawPixmap(0, 0, isDown() ? *iBtnPixDown : *iBtnPix);
|
||
|
}
|
||
|
else{
|
||
13 years ago
|
TQColorGroup g = KDecoration::options()->tqcolorGroup(KDecorationOptions::ColorFrame,
|
||
15 years ago
|
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
|
||
13 years ago
|
g = KDecoration::options()->tqcolorGroup(KDecorationOptions::ColorButtonBg, client->isActive());
|
||
15 years ago
|
p->fillRect(3, 3, width()-6, height()-6, g.background());
|
||
|
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);
|
||
|
|
||
|
}
|
||
|
|
||
|
if(!deco.isNull()){
|
||
|
p->setPen(*btnForeground);
|
||
|
p->drawPixmap(isDown() ? 4 : 3, isDown() ? 4 : 3, deco);
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void SystemButton::mousePressEvent( TQMouseEvent* e )
|
||
15 years ago
|
{
|
||
|
last_button = e->button();
|
||
13 years ago
|
TQMouseEvent me ( e->type(), e->pos(), e->globalPos(), Qt::LeftButton, e->state() );
|
||
15 years ago
|
TQButton::mousePressEvent( &me );
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void SystemButton::mouseReleaseEvent( TQMouseEvent* e )
|
||
15 years ago
|
{
|
||
|
last_button = e->button();
|
||
13 years ago
|
TQMouseEvent me ( e->type(), e->pos(), e->globalPos(), Qt::LeftButton, e->state() );
|
||
15 years ago
|
TQButton::mouseReleaseEvent( &me );
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
|
|
||
|
SystemClient::SystemClient(KDecorationBridge* bridge, KDecorationFactory* factory)
|
||
|
: KDecoration(bridge, factory)
|
||
|
{}
|
||
|
|
||
|
SystemClient::~SystemClient()
|
||
|
{
|
||
|
for (int n=0; n<ButtonTypeCount; n++) {
|
||
|
if (button[n]) delete button[n];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void SystemClient::init()
|
||
|
{
|
||
|
createMainWidget(0);
|
||
|
widget()->installEventFilter( this );
|
||
|
|
||
15 years ago
|
TQGridLayout* g = new TQGridLayout(widget(), 0, 0, 2);
|
||
15 years ago
|
|
||
|
if (isPreview())
|
||
|
{
|
||
15 years ago
|
g->addWidget(new TQLabel(i18n("<center><b>System++ preview</b></center>"), widget()), 1, 1);
|
||
15 years ago
|
}
|
||
|
else
|
||
|
{
|
||
15 years ago
|
g->addItem(new TQSpacerItem( 0, 0 ), 1, 1); // no widget in the middle
|
||
15 years ago
|
}
|
||
15 years ago
|
// g->addItem( new TQSpacerItem( 0, 0, TQSizePolicy::Fixed, TQSizePolicy::Expanding ) );
|
||
15 years ago
|
g->setRowStretch(1, 10);
|
||
|
|
||
|
g->addColSpacing(0, 2);
|
||
|
g->addColSpacing(2, 2);
|
||
|
g->addRowSpacing(2, 6);
|
||
|
|
||
15 years ago
|
TQBoxLayout* hb = new TQBoxLayout(0, TQBoxLayout::LeftToRight, 0, 0, 0);
|
||
|
hb->setResizeMode(TQLayout::FreeResize);
|
||
15 years ago
|
g->addLayout( hb, 0, 1 );
|
||
|
hb->addSpacing(3);
|
||
|
|
||
15 years ago
|
titlebar = new TQSpacerItem(10, 14, TQSizePolicy::Expanding,
|
||
|
TQSizePolicy::Minimum);
|
||
15 years ago
|
|
||
|
// setup titlebar buttons
|
||
|
for (int n=0; n<ButtonTypeCount; n++) button[n] = 0;
|
||
|
addButtons(hb, KDecoration::options()->customButtonPositions() ?
|
||
15 years ago
|
KDecoration::options()->titleButtonsLeft() : TQString(default_left));
|
||
15 years ago
|
hb->addSpacing(2);
|
||
|
hb->addItem(titlebar);
|
||
|
hb->addSpacing(3);
|
||
|
addButtons(hb, KDecoration::options()->customButtonPositions() ?
|
||
15 years ago
|
KDecoration::options()->titleButtonsRight() : TQString(default_right));
|
||
15 years ago
|
hb->addSpacing(2);
|
||
|
|
||
15 years ago
|
widget()->setBackgroundMode(TQWidget::NoBackground);
|
||
15 years ago
|
recalcTitleBuffer();
|
||
|
}
|
||
|
|
||
15 years ago
|
void SystemClient::addButtons(TQBoxLayout *hb, const TQString& s)
|
||
15 years ago
|
{
|
||
|
unsigned char *minmax_bits;
|
||
|
int l_max = KDecoration::options()->titleButtonsLeft().find('A');
|
||
|
if (s.length() > 0) {
|
||
|
for (unsigned n=0; n < s.length(); n++) {
|
||
|
switch (s[n]) {
|
||
|
case 'X': // Close button
|
||
|
if ((!button[ButtonClose]) && isCloseable()) {
|
||
|
button[ButtonClose] = new SystemButton(this, "close", NULL, i18n("Close"));
|
||
15 years ago
|
connect( button[ButtonClose], TQT_SIGNAL( clicked() ), this, ( TQT_SLOT( closeWindow() ) ) );
|
||
15 years ago
|
hb->addWidget(button[ButtonClose]);
|
||
|
hb->addSpacing(1);
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case 'S': // Sticky button
|
||
|
if (!button[ButtonSticky]) {
|
||
|
button[ButtonSticky] = new SystemButton(this, "sticky", NULL, i18n("On all desktops"));
|
||
|
if(isOnAllDesktops())
|
||
|
button[ButtonSticky]->setBitmap(unsticky_bits);
|
||
|
else
|
||
|
button[ButtonSticky]->setBitmap(sticky_bits);
|
||
15 years ago
|
connect( button[ButtonSticky], TQT_SIGNAL( clicked() ), this, ( TQT_SLOT( toggleOnAllDesktops() ) ) );
|
||
15 years ago
|
hb->addWidget(button[ButtonSticky]);
|
||
|
hb->addSpacing(1);
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case 'I': // Minimize button
|
||
|
if ((!button[ButtonMinimize]) && isMinimizable()) {
|
||
|
button[ButtonMinimize] = new SystemButton(this, "iconify", iconify_bits, i18n("Minimize"));
|
||
15 years ago
|
connect( button[ButtonMinimize], TQT_SIGNAL( clicked() ), this, ( TQT_SLOT( minimize() ) ) );
|
||
15 years ago
|
hb->addWidget(button[ButtonMinimize]);
|
||
|
hb->addSpacing(1);
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case 'A': // Maximize button
|
||
|
if ((!button[ButtonMaximize]) && isMaximizable()) {
|
||
|
if (maximizeMode()==MaximizeFull) {
|
||
|
if (KDecoration::options()->customButtonPositions() && (l_max>-1))
|
||
|
minmax_bits = l_minmax_bits;
|
||
|
else
|
||
|
minmax_bits = r_minmax_bits;
|
||
|
button[ButtonMaximize] = new SystemButton(this, "maximize", minmax_bits, i18n("Restore"));
|
||
|
}
|
||
|
else
|
||
|
button[ButtonMaximize] = new SystemButton(this, "maximize", maximize_bits, i18n("Maximize"));
|
||
15 years ago
|
connect( button[ButtonMaximize], TQT_SIGNAL( clicked() ), this, ( TQT_SLOT( maxButtonClicked() ) ) );
|
||
15 years ago
|
hb->addWidget(button[ButtonMaximize]);
|
||
|
hb->addSpacing(1);
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case 'H': // Help button
|
||
|
if ((!button[ButtonHelp]) && providesContextHelp()) {
|
||
|
button[ButtonHelp] = new SystemButton(this, "help", question_bits, i18n("Help"));
|
||
15 years ago
|
connect( button[ButtonHelp], TQT_SIGNAL( clicked() ), this, ( TQT_SLOT( showContextHelp() ) ) );
|
||
15 years ago
|
hb->addWidget(button[ButtonHelp]);
|
||
|
hb->addSpacing(1);
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
bool SystemClient::eventFilter( TQObject* o, TQEvent* e )
|
||
15 years ago
|
{
|
||
13 years ago
|
if( TQT_BASE_OBJECT(o) != TQT_BASE_OBJECT(widget()))
|
||
15 years ago
|
return false;
|
||
|
switch( e->type())
|
||
|
{
|
||
15 years ago
|
case TQEvent::Resize:
|
||
13 years ago
|
resizeEvent(TQT_TQRESIZEEVENT( e ) );
|
||
15 years ago
|
return true;
|
||
15 years ago
|
case TQEvent::Paint:
|
||
13 years ago
|
paintEvent(TQT_TQPAINTEVENT( e ) );
|
||
15 years ago
|
return true;
|
||
15 years ago
|
case TQEvent::MouseButtonDblClick:
|
||
13 years ago
|
mouseDoubleClickEvent(TQT_TQMOUSEEVENT( e ) );
|
||
15 years ago
|
return true;
|
||
15 years ago
|
case TQEvent::MouseButtonPress:
|
||
13 years ago
|
processMousePressEvent(TQT_TQMOUSEEVENT( e ) );
|
||
15 years ago
|
return true;
|
||
15 years ago
|
case TQEvent::Wheel:
|
||
13 years ago
|
wheelEvent( TQT_TQWHEELEVENT( e ));
|
||
15 years ago
|
return true;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
void SystemClient::reset(unsigned long)
|
||
|
{
|
||
|
titleBuffer.resize(0, 0);
|
||
|
recalcTitleBuffer();
|
||
13 years ago
|
widget()->tqrepaint();
|
||
15 years ago
|
if (button[ButtonClose])
|
||
|
button[ButtonClose]->reset();
|
||
|
if (button[ButtonSticky])
|
||
|
button[ButtonSticky]->reset();
|
||
|
if (button[ButtonMinimize])
|
||
|
button[ButtonMinimize]->reset();
|
||
|
if (button[ButtonMaximize])
|
||
|
button[ButtonMaximize]->reset();
|
||
|
if (button[ButtonHelp])
|
||
|
button[ButtonHelp]->reset();
|
||
|
}
|
||
|
|
||
|
void SystemClient::maxButtonClicked()
|
||
|
{
|
||
|
maximize( button[ButtonMaximize]->last_button );
|
||
|
}
|
||
|
|
||
15 years ago
|
void SystemClient::resizeEvent( TQResizeEvent* )
|
||
15 years ago
|
{
|
||
|
//Client::resizeEvent( e );
|
||
|
recalcTitleBuffer();
|
||
|
doShape();
|
||
|
/*
|
||
|
if ( isVisibleToTLW() && !testWFlags( WStaticContents )) {
|
||
15 years ago
|
TQPainter p( this );
|
||
13 years ago
|
TQRect t = titlebar->tqgeometry();
|
||
15 years ago
|
t.setTop( 0 );
|
||
15 years ago
|
TQRegion r = rect();
|
||
15 years ago
|
r = r.subtract( t );
|
||
|
p.setClipRegion( r );
|
||
|
p.eraseRect( rect() );
|
||
|
}*/
|
||
|
}
|
||
|
|
||
15 years ago
|
void SystemClient::resize( const TQSize& s )
|
||
15 years ago
|
{
|
||
|
widget()->resize( s );
|
||
|
}
|
||
|
|
||
|
|
||
13 years ago
|
TQSize SystemClient::tqminimumSize() const
|
||
15 years ago
|
{
|
||
13 years ago
|
return widget()->tqminimumSize();
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
|
void SystemClient::recalcTitleBuffer()
|
||
|
{
|
||
|
if(oldTitle == caption() && width() == titleBuffer.width())
|
||
|
return;
|
||
15 years ago
|
TQFontMetrics fm(options()->font(true));
|
||
15 years ago
|
titleBuffer.resize(width(), 18);
|
||
15 years ago
|
TQPainter p;
|
||
15 years ago
|
p.begin(&titleBuffer);
|
||
|
if(aUpperGradient)
|
||
|
p.drawTiledPixmap(0, 0, width(), 18, *aUpperGradient);
|
||
|
else
|
||
|
p.fillRect(0, 0, width(), 18,
|
||
13 years ago
|
options()->tqcolorGroup(KDecorationOptions::ColorFrame, true).
|
||
15 years ago
|
brush(TQColorGroup::Button));
|
||
15 years ago
|
|
||
13 years ago
|
TQRect t = titlebar->tqgeometry();
|
||
15 years ago
|
t.setTop( 2 );
|
||
|
t.setLeft( t.left() + 4 );
|
||
|
t.setRight( t.right() - 2 );
|
||
|
|
||
15 years ago
|
TQRegion r(t.x(), 0, t.width(), 18);
|
||
|
r -= TQRect(t.x()+((t.width()-fm.width(caption()))/2)-4,
|
||
15 years ago
|
0, fm.width(caption())+8, 18);
|
||
|
p.setClipRegion(r);
|
||
|
int i, ly;
|
||
|
for(i=0, ly=4; i < 4; ++i, ly+=3){
|
||
|
p.setPen(options()->color(KDecorationOptions::ColorTitleBar, true).light(150));
|
||
|
p.drawLine(0, ly, width()-1, ly);
|
||
|
p.setPen(options()->color(KDecorationOptions::ColorTitleBar, true).dark(120));
|
||
|
p.drawLine(0, ly+1, width()-1, ly+1);
|
||
|
}
|
||
|
p.setClipRect(t);
|
||
|
p.setPen(options()->color(KDecorationOptions::ColorFont, true));
|
||
|
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()
|
||
|
{
|
||
|
recalcTitleBuffer();
|
||
13 years ago
|
widget()->tqrepaint(titlebar->tqgeometry(), false);
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void SystemClient::drawRoundFrame(TQPainter &p, int x, int y, int w, int h)
|
||
15 years ago
|
{
|
||
|
kDrawRoundButton(&p, x, y, w, h,
|
||
13 years ago
|
options()->tqcolorGroup(KDecorationOptions::ColorFrame, isActive()), false);
|
||
15 years ago
|
|
||
|
}
|
||
|
|
||
15 years ago
|
void SystemClient::paintEvent( TQPaintEvent* )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQPainter p(widget());
|
||
13 years ago
|
TQRect t = titlebar->tqgeometry();
|
||
15 years ago
|
|
||
13 years ago
|
TQBrush fillBrush(TQBrush(widget()->tqcolorGroup().brush(TQColorGroup::Background)).pixmap() ?
|
||
|
widget()->tqcolorGroup().brush(TQColorGroup::Background) :
|
||
|
options()->tqcolorGroup(KDecorationOptions::ColorFrame, isActive()).
|
||
15 years ago
|
brush(TQColorGroup::Button));
|
||
15 years ago
|
|
||
|
p.fillRect(1, 18, width()-2, height()-19, fillBrush);
|
||
|
|
||
|
t.setTop( 2 );
|
||
|
t.setLeft( t.left() + 4 );
|
||
|
t.setRight( t.right() - 2 );
|
||
|
|
||
|
if(isActive())
|
||
|
p.drawPixmap(0, 0, titleBuffer);
|
||
|
else{
|
||
|
if(iUpperGradient)
|
||
|
p.drawTiledPixmap(0, 0, width(), 18, *iUpperGradient);
|
||
|
else
|
||
|
p.fillRect(0, 0, width(), 18, fillBrush);
|
||
|
p.setPen(options()->color(KDecorationOptions::ColorFont, isActive()));
|
||
|
p.setFont(options()->font(isActive()));
|
||
|
p.drawText(t, AlignCenter, caption() );
|
||
|
}
|
||
|
|
||
13 years ago
|
p.setPen(options()->tqcolorGroup(KDecorationOptions::ColorFrame, isActive()).light());
|
||
15 years ago
|
p.drawLine(width()-20, height()-7, width()-10, height()-7);
|
||
|
p.drawLine(width()-20, height()-5, width()-10, height()-5);
|
||
13 years ago
|
p.setPen(options()->tqcolorGroup(KDecorationOptions::ColorFrame, isActive()).dark());
|
||
15 years ago
|
p.drawLine(width()-20, height()-6, width()-10, height()-6);
|
||
|
p.drawLine(width()-20, height()-4, width()-10, height()-4);
|
||
|
|
||
|
drawRoundFrame(p, 0, 0, width(), height());
|
||
|
}
|
||
|
|
||
13 years ago
|
#define TQCOORDARRLEN(x) sizeof(x)/(sizeof(TQCOORD)*2)
|
||
15 years ago
|
|
||
|
void SystemClient::doShape()
|
||
|
{
|
||
15 years ago
|
// using a bunch of TQRect lines seems much more efficent than bitmaps or
|
||
15 years ago
|
// point arrays
|
||
|
|
||
15 years ago
|
TQRegion mask;
|
||
15 years ago
|
kRoundMaskRegion(mask, 0, 0, width(), height());
|
||
|
setMask(mask);
|
||
|
}
|
||
|
|
||
15 years ago
|
void SystemClient::showEvent(TQShowEvent *)
|
||
15 years ago
|
{
|
||
|
// Client::showEvent(ev);
|
||
|
doShape();
|
||
|
widget()->show();
|
||
13 years ago
|
// widget()->tqrepaint();
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
/*void SystemClient::windowWrapperShowEvent( TQShowEvent* )
|
||
15 years ago
|
{
|
||
|
doShape();
|
||
|
}*/
|
||
|
|
||
15 years ago
|
void SystemClient::mouseDoubleClickEvent( TQMouseEvent * e )
|
||
15 years ago
|
{
|
||
13 years ago
|
if ( e->button() == Qt::LeftButton && titlebar->tqgeometry().contains( e->pos() ) )
|
||
15 years ago
|
titlebarDblClickOperation();
|
||
|
}
|
||
|
|
||
15 years ago
|
void SystemClient::wheelEvent( TQWheelEvent *e )
|
||
15 years ago
|
{
|
||
13 years ago
|
if (isSetShade() || TQRect( 0, 0, width(), titlebar->tqgeometry().height() ).contains( e->pos() ) )
|
||
15 years ago
|
titlebarMouseWheelOperation( e->delta());
|
||
|
}
|
||
|
|
||
|
void SystemClient::maximizeChange()
|
||
|
{
|
||
|
unsigned char *minmax_bits;
|
||
|
int l_max = KDecoration::options()->titleButtonsLeft().find('A');
|
||
|
if (KDecoration::options()->customButtonPositions() && (l_max>-1))
|
||
|
minmax_bits = l_minmax_bits;
|
||
|
else
|
||
|
minmax_bits = r_minmax_bits;
|
||
|
if (button[ButtonMaximize]) {
|
||
|
button[ButtonMaximize]->setBitmap((maximizeMode()==MaximizeFull) ? minmax_bits : maximize_bits);
|
||
|
button[ButtonMaximize]->setTipText((maximizeMode()==MaximizeFull) ? i18n("Restore") : i18n("Maximize"));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void SystemClient::activeChange()
|
||
|
{
|
||
13 years ago
|
widget()->tqrepaint(false);
|
||
15 years ago
|
if (button[ButtonClose])
|
||
|
button[ButtonClose]->reset();
|
||
|
if (button[ButtonSticky])
|
||
|
button[ButtonSticky]->reset();
|
||
|
if (button[ButtonMinimize])
|
||
|
button[ButtonMinimize]->reset();
|
||
|
if (button[ButtonMaximize])
|
||
|
button[ButtonMaximize]->reset();
|
||
|
if (button[ButtonHelp])
|
||
|
button[ButtonHelp]->reset();
|
||
|
}
|
||
|
|
||
|
void SystemClient::iconChange()
|
||
|
{
|
||
|
// if (button[BtnMenu] && button[BtnMenu]->isVisible())
|
||
13 years ago
|
// button[BtnMenu]->tqrepaint(false);
|
||
15 years ago
|
}
|
||
|
|
||
|
void SystemClient::desktopChange()
|
||
|
{
|
||
|
if (button[ButtonSticky]) {
|
||
|
button[ButtonSticky]->setBitmap(isOnAllDesktops() ? unsticky_bits : sticky_bits);
|
||
|
button[ButtonSticky]->setTipText(isOnAllDesktops() ? i18n("Not on all desktops") : i18n("On all desktops"));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/*void SystemClient::stickyChange(bool on)
|
||
|
{
|
||
|
}*/
|
||
|
|
||
15 years ago
|
KDecoration::Position SystemClient::mousePosition(const TQPoint &p) const
|
||
15 years ago
|
{
|
||
|
return KDecoration::mousePosition(p);
|
||
|
}
|
||
|
|
||
|
void SystemClient::borders(int& left, int& right, int& top, int& bottom) const
|
||
|
{
|
||
|
left = 4;
|
||
|
right = 4;
|
||
|
top = 18;
|
||
|
bottom = 8;
|
||
|
|
||
|
/* if ((maximizeMode()==MaximizeFull) && !options()->moveResizeMaximizedWindows()) {
|
||
|
left = right = bottom = 0;
|
||
|
top = 1 + titleHeight + (borderSize-1);
|
||
|
}*/
|
||
|
}
|
||
|
|
||
|
SystemDecoFactory::SystemDecoFactory()
|
||
|
{
|
||
|
create_pixmaps();
|
||
|
}
|
||
|
|
||
|
SystemDecoFactory::~SystemDecoFactory()
|
||
|
{
|
||
|
delete_pixmaps();
|
||
|
}
|
||
|
|
||
|
KDecoration *SystemDecoFactory::createDecoration( KDecorationBridge *b )
|
||
|
{
|
||
|
return new SystemClient(b, this);
|
||
|
}
|
||
|
|
||
|
bool SystemDecoFactory::reset( unsigned long changed )
|
||
|
{
|
||
|
System::delete_pixmaps();
|
||
|
System::create_pixmaps();
|
||
|
// Ensure changes in tooltip state get applied
|
||
|
resetDecorations(changed);
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
bool SystemDecoFactory::supports( Ability ability )
|
||
|
{
|
||
|
switch( ability )
|
||
|
{
|
||
|
case AbilityAnnounceButtons:
|
||
|
case AbilityButtonOnAllDesktops:
|
||
|
case AbilityButtonHelp:
|
||
|
case AbilityButtonMinimize:
|
||
|
case AbilityButtonMaximize:
|
||
|
case AbilityButtonClose:
|
||
|
return true;
|
||
|
default:
|
||
|
return false;
|
||
|
};
|
||
|
}
|
||
|
|
||
15 years ago
|
TQValueList<KDecorationFactory::BorderSize> SystemDecoFactory::borderSizes() const
|
||
15 years ago
|
{ // the list must be sorted
|
||
15 years ago
|
return TQValueList< BorderSize >() << BorderNormal;
|
||
15 years ago
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
extern "C" KDE_EXPORT KDecorationFactory *create_factory()
|
||
|
{
|
||
|
return new System::SystemDecoFactory();
|
||
|
}
|
||
|
|
||
|
#include "systemclient.moc"
|