From 0c4afbf8befabb9a78685a1e351b46ebcf18a1ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Thu, 22 Jul 2004 11:23:28 +0000 Subject: [PATCH] Add support for above, below and shade buttons. svn path=/trunk/kdebase/kwin/; revision=331725 --- clients/keramik/keramik.cpp | 139 +++++++++++++++++++++++++++++++++++- clients/keramik/keramik.h | 13 +++- 2 files changed, 148 insertions(+), 4 deletions(-) diff --git a/clients/keramik/keramik.cpp b/clients/keramik/keramik.cpp index b252def9f2..27a0fac7ca 100644 --- a/clients/keramik/keramik.cpp +++ b/clients/keramik/keramik.cpp @@ -111,6 +111,47 @@ namespace Keramik 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + 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 }; KeramikHandler *clientHandler = NULL; bool keramik_initialized = false; @@ -141,6 +182,12 @@ KeramikHandler::KeramikHandler() buttonDecos[ Maximize ] = new QBitmap( 17, 17, maximize_bits, true ); buttonDecos[ Restore ] = new QBitmap( 17, 17, restore_bits, true ); buttonDecos[ Close ] = new QBitmap( 17, 17, close_bits, true ); + buttonDecos[ AboveOn ] = new QBitmap( 17, 17, above_on_bits, true ); + buttonDecos[ AboveOff ] = new QBitmap( 17, 17, above_off_bits, true ); + buttonDecos[ BelowOn ] = new QBitmap( 17, 17, below_on_bits, true ); + buttonDecos[ BelowOff ] = new QBitmap( 17, 17, below_off_bits, true ); + buttonDecos[ ShadeOn ] = new QBitmap( 17, 17, shade_on_bits, true ); + buttonDecos[ ShadeOff ] = new QBitmap( 17, 17, shade_off_bits, true ); // Selfmask the bitmaps for ( int i = 0; i < NumButtonDecos; i++ ) @@ -776,7 +823,7 @@ void KeramikButton::drawButton( QPainter *p ) break; case OnAllDesktopsButton: - deco = clientHandler->buttonDeco( isOn() ? NotOnAllDesktops : OnAllDesktops ); + deco = clientHandler->buttonDeco( client->isOnAllDesktops() ? NotOnAllDesktops : OnAllDesktops ); break; case HelpButton: @@ -800,6 +847,18 @@ void KeramikButton::drawButton( QPainter *p ) deco = clientHandler->buttonDeco( Close ); break; + 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; + default: deco = NULL; } @@ -822,6 +881,9 @@ KeramikClient::KeramikClient( KDecorationBridge* bridge, KDecorationFactory* fac void KeramikClient::init() { + connect( this, SIGNAL( keepAboveChanged( bool )), SLOT( keepAboveChange( bool ))); + connect( this, SIGNAL( keepBelowChanged( bool )), SLOT( keepBelowChange( bool ))); + createMainWidget( WStaticContents | WResizeNoErase | WRepaintNoErase ); widget()->installEventFilter( this ); @@ -1000,6 +1062,34 @@ void KeramikClient::addButtons( QBoxLayout *layout, const QString &s ) } break; + // 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; + // Additional spacing case '_' : layout->addSpacing( buttonSpacing ); @@ -1308,12 +1398,38 @@ void KeramikClient::desktopChange() { if ( button[ OnAllDesktopsButton ] ) { + button[ OnAllDesktopsButton ]->repaint( true ); QToolTip::remove( button[ OnAllDesktopsButton ] ); QToolTip::add( button[ OnAllDesktopsButton ], isOnAllDesktops() ? i18n("Not on all desktops") : i18n("On all desktops") ); } } +void KeramikClient::shadeChange() +{ + if ( button[ ShadeButton ] ) + { + button[ ShadeButton ]->repaint( true ); + QToolTip::remove( button[ ShadeButton ] ); + QToolTip::add( button[ ShadeButton ], isSetShade() ? i18n("Unshade") : i18n("Shade") ); + } +} + + +void KeramikClient::keepAboveChange( bool ) +{ + if ( button[ AboveButton ] ) + button[ AboveButton ]->repaint( true ); +} + + +void KeramikClient::keepBelowChange( bool ) +{ + if ( button[ BelowButton ] ) + button[ BelowButton ]->repaint( true ); +} + + void KeramikClient::menuButtonPressed() { QPoint menuTop ( button[MenuButton]->rect().topLeft() ); @@ -1348,6 +1464,27 @@ void KeramikClient::slotMaximize() } +void KeramikClient::slotAbove() +{ + setKeepAbove( !keepAbove()); + button[ AboveButton ]->repaint( true ); +} + + +void KeramikClient::slotBelow() +{ + setKeepBelow( !keepBelow()); + button[ BelowButton ]->repaint( true ); +} + + +void KeramikClient::slotShade() +{ + setShade( !isSetShade()); + button[ ShadeButton ]->repaint( true ); +} + + void KeramikClient::paintEvent( QPaintEvent *e ) { if ( !keramik_initialized ) diff --git a/clients/keramik/keramik.h b/clients/keramik/keramik.h index 1a40a542fb..485638c5cc 100644 --- a/clients/keramik/keramik.h +++ b/clients/keramik/keramik.h @@ -41,10 +41,12 @@ namespace Keramik { BorderLeft, BorderRight, NumTiles }; enum Button { MenuButton=0, OnAllDesktopsButton, HelpButton, MinButton, - MaxButton, CloseButton, NumButtons }; + MaxButton, CloseButton, AboveButton, BelowButton, ShadeButton, + NumButtons }; enum ButtonDeco { Menu=0, OnAllDesktops, NotOnAllDesktops, Help, Minimize, Maximize, - Restore, Close, NumButtonDecos }; + Restore, Close, AboveOn, AboveOff, BelowOn, BelowOff, ShadeOn, ShadeOff, + NumButtonDecos }; struct SettingsCache { @@ -152,7 +154,7 @@ namespace Keramik { virtual void captionChange(); virtual void maximizeChange(); virtual void desktopChange(); - virtual void shadeChange() {}; + virtual void shadeChange(); private: void createLayout(); @@ -175,6 +177,11 @@ namespace Keramik { private slots: void menuButtonPressed(); void slotMaximize(); + void slotAbove(); + void slotBelow(); + void slotShade(); + void keepAboveChange( bool ); + void keepBelowChange( bool ); private: QSpacerItem *topSpacer, *titlebar;