diff --git a/clients/riscos/Button.cpp b/clients/riscos/Button.cpp index ac18463ac3..a5031de397 100644 --- a/clients/riscos/Button.cpp +++ b/clients/riscos/Button.cpp @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -23,7 +23,7 @@ #include "Button.h" #include "Static.h" -namespace Default +namespace RiscOS { Button::Button(QWidget * parent, SymbolType t) @@ -33,10 +33,7 @@ Button::Button(QWidget * parent, SymbolType t) down_ (false), active_ (false) { - if (type_ == Sticky) - setFixedWidth(Static::instance()->buttonWidth2()); - else - setFixedWidth(Static::instance()->buttonWidth1()); + setFixedSize(19, 20); } Button::~Button() @@ -47,7 +44,10 @@ Button::~Button() void Button::updateDisplay() { - setBackgroundPixmap(Static::instance()->button(type_, active_, down_)); + setBackgroundPixmap( + Static::instance()->button(type_, active_, down_) + ); + repaint(true); } diff --git a/clients/riscos/Button.h b/clients/riscos/Button.h index fe84e9d838..20c6e3b252 100644 --- a/clients/riscos/Button.h +++ b/clients/riscos/Button.h @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -20,13 +20,13 @@ Boston, MA 02111-1307, USA. */ -#ifndef DEFAULT_BUTTON_H -#define DEFAULT_BUTTON_H +#ifndef RISC_OS_BUTTON_H +#define RISC_OS_BUTTON_H #include "Static.h" #include -namespace Default +namespace RiscOS { class Button : public QWidget diff --git a/clients/riscos/CloseButton.cpp b/clients/riscos/CloseButton.cpp index 450d375826..39bbf05639 100644 --- a/clients/riscos/CloseButton.cpp +++ b/clients/riscos/CloseButton.cpp @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -22,7 +22,7 @@ #include "CloseButton.h" -namespace Default +namespace RiscOS { CloseButton::CloseButton(QWidget * parent) diff --git a/clients/riscos/CloseButton.h b/clients/riscos/CloseButton.h index 465cdc66e8..31fc7641cf 100644 --- a/clients/riscos/CloseButton.h +++ b/clients/riscos/CloseButton.h @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -20,12 +20,12 @@ Boston, MA 02111-1307, USA. */ -#ifndef DEFAULT_CLOSE_BUTTON_H -#define DEFAULT_CLOSE_BUTTON_H +#ifndef RISC_OS_CLOSE_BUTTON_H +#define RISC_OS_CLOSE_BUTTON_H #include "Button.h" -namespace Default +namespace RiscOS { class CloseButton : public Button diff --git a/clients/riscos/DBWidget.cpp b/clients/riscos/DBWidget.cpp index af4599c727..76fc926676 100644 --- a/clients/riscos/DBWidget.cpp +++ b/clients/riscos/DBWidget.cpp @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -22,12 +22,11 @@ #include "DBWidget.h" -namespace Default +namespace RiscOS { DBWidget::DBWidget(QWidget * parent, const char * name) - : QWidget(parent, name, WResizeNoErase | WRepaintNoErase | WPaintUnclipped | -WNorthWestGravity) + : QWidget(parent, name, WResizeNoErase | WRepaintNoErase | WPaintUnclipped) { buf_.resize(20, 20); setBackgroundMode(NoBackground); diff --git a/clients/riscos/DBWidget.h b/clients/riscos/DBWidget.h index 9988012be5..a2a4716aa5 100644 --- a/clients/riscos/DBWidget.h +++ b/clients/riscos/DBWidget.h @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -20,13 +20,13 @@ Boston, MA 02111-1307, USA. */ -#ifndef DEFAULT_DOUBLE_BUFFERED_WIDGET_H -#define DEFAULT_DOUBLE_BUFFERED_WIDGET_H +#ifndef RISC_OS_DOUBLE_BUFFERED_WIDGET_H +#define RISC_OS_DOUBLE_BUFFERED_WIDGET_H #include #include -namespace Default +namespace RiscOS { class DBWidget : public QWidget diff --git a/clients/riscos/IconifyButton.cpp b/clients/riscos/IconifyButton.cpp index 2c92f175de..d1724553cc 100644 --- a/clients/riscos/IconifyButton.cpp +++ b/clients/riscos/IconifyButton.cpp @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -22,7 +22,7 @@ #include "IconifyButton.h" -namespace Default +namespace RiscOS { IconifyButton::IconifyButton(QWidget * parent) diff --git a/clients/riscos/IconifyButton.h b/clients/riscos/IconifyButton.h index 5bcccf7e74..ad6880d610 100644 --- a/clients/riscos/IconifyButton.h +++ b/clients/riscos/IconifyButton.h @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -20,12 +20,12 @@ Boston, MA 02111-1307, USA. */ -#ifndef DEFAULT_ICONIFY_BUTTON_H -#define DEFAULT_ICONIFY_BUTTON_H +#ifndef RISC_OS_ICONIFY_BUTTON_H +#define RISC_OS_ICONIFY_BUTTON_H #include "Button.h" -namespace Default +namespace RiscOS { class IconifyButton : public Button diff --git a/clients/riscos/Makefile.am b/clients/riscos/Makefile.am index 4f84ededd4..d42c89cb02 100644 --- a/clients/riscos/Makefile.am +++ b/clients/riscos/Makefile.am @@ -1,13 +1,13 @@ INCLUDES = $(all_includes) -lib_LTLIBRARIES = libkwindefault.la +lib_LTLIBRARIES = libkwinriscos.la -libkwindefault_la_SOURCES = \ +libkwinriscos_la_SOURCES = \ Button.cpp \ CloseButton.cpp \ DBWidget.cpp \ IconifyButton.cpp \ -StickyButton.cpp \ +LowerButton.cpp \ Manager.cpp \ MaximiseButton.cpp \ ResizeBar.cpp \ @@ -16,8 +16,8 @@ ResizeSide.cpp \ TitleBar.cpp \ TitleText.cpp \ Static.cpp -libkwindefault_la_LIBADD = ../../kwin.la -libkwindefault_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) +libkwinriscos_la_LIBADD = ../../kwin.la +libkwinriscos_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) METASOURCES = AUTO noinst_HEADERS = \ @@ -25,7 +25,7 @@ Button.h \ CloseButton.h \ DBWidget.h \ IconifyButton.h \ -StickyButton.h \ +LowerButton.h \ Manager.h \ MaximiseButton.h \ ResizeBar.h \ @@ -36,7 +36,7 @@ TitleText.h \ Static.h lnkdir = $(kde_datadir)/kwin/ -lnk_DATA = default.desktop +lnk_DATA = riscos.desktop EXTRA_DIST = $(lnk_DATA) diff --git a/clients/riscos/Manager.cpp b/clients/riscos/Manager.cpp index 53ce606802..d00c7d654a 100644 --- a/clients/riscos/Manager.cpp +++ b/clients/riscos/Manager.cpp @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -35,11 +35,11 @@ extern "C" { Client * allocate(Workspace * workSpace, WId winId) { - return new Default::Manager(workSpace, winId); + return new RiscOS::Manager(workSpace, winId); } } -namespace Default +namespace RiscOS { Manager::Manager( @@ -77,12 +77,6 @@ Manager::captionChange(const QString &) titleBar_->updateText(); } - void -Manager::stickyChange(bool b) -{ - emit(stickyStatusChanged(b)); -} - void Manager::paletteChange(const QPalette &) { @@ -149,9 +143,9 @@ Manager::mousePosition(const QPoint & p) const } void -Manager::toggleSticky() +Manager::lower() { - setSticky(!isSticky()); + workspace()->lowerClient(this); } void @@ -176,27 +170,10 @@ Manager::resizeEvent(QResizeEvent * e) void Manager::_updateLayout() { - titleBar_ -> setGeometry( - 0, - 0, - width(), - Static::instance()->titleHeight() - ); - - windowWrapper() -> setGeometry( - 1, - Static::instance()->titleHeight(), - width() - 2, - height() - Static::instance()->titleHeight() - RESIZE_BAR_HEIGHT - ); - - resizeBar_ -> setGeometry( - 0, - height() - RESIZE_BAR_HEIGHT, - width(), - RESIZE_BAR_HEIGHT - ); - + titleBar_ -> setGeometry(0, 0, width(), 20); + windowWrapper() -> setGeometry(1, 20, width() - 2, height() - 30); + resizeBar_ -> setGeometry(0, height() - 10, width(), 10); + _updateDisplay(); } diff --git a/clients/riscos/Manager.h b/clients/riscos/Manager.h index 7f2f654e26..65adad068f 100644 --- a/clients/riscos/Manager.h +++ b/clients/riscos/Manager.h @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -20,12 +20,12 @@ Boston, MA 02111-1307, USA. */ -#ifndef DEFAULT_MANAGER_H -#define DEFAULT_MANAGER_H +#ifndef RISC_OS_MANAGER_H +#define RISC_OS_MANAGER_H #include "../../client.h" -namespace Default +namespace RiscOS { class TitleBar; @@ -47,11 +47,10 @@ class Manager : public Client signals: void maximiseChanged(bool); - void stickyStatusChanged(bool); public slots: - void toggleSticky(); + void lower(); void raise(); void vMax(); @@ -68,7 +67,6 @@ class Manager : public Client protected slots: void captionChange(const QString &); - void stickyChange(bool); void slotReset(); private: diff --git a/clients/riscos/MaximiseButton.cpp b/clients/riscos/MaximiseButton.cpp index f6dc95f636..677ab6526a 100644 --- a/clients/riscos/MaximiseButton.cpp +++ b/clients/riscos/MaximiseButton.cpp @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -22,7 +22,7 @@ #include "MaximiseButton.h" -namespace Default +namespace RiscOS { MaximiseButton::MaximiseButton(QWidget * parent) diff --git a/clients/riscos/MaximiseButton.h b/clients/riscos/MaximiseButton.h index ea2bf595ce..a23c8ec4df 100644 --- a/clients/riscos/MaximiseButton.h +++ b/clients/riscos/MaximiseButton.h @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -20,12 +20,12 @@ Boston, MA 02111-1307, USA. */ -#ifndef DEFAULT_MAXIMISE_BUTTON_H -#define DEFAULT_MAXIMISE_BUTTON_H +#ifndef RISC_OS_MAXIMISE_BUTTON_H +#define RISC_OS_MAXIMISE_BUTTON_H #include "Button.h" -namespace Default +namespace RiscOS { class MaximiseButton : public Button diff --git a/clients/riscos/README b/clients/riscos/README index 278bfc87cd..04ebd85d4e 100644 --- a/clients/riscos/README +++ b/clients/riscos/README @@ -1 +1,90 @@ -Default KWin theme +This theme emulates the look and feel of the RISC OS 'window manager'. +Actually, RISC OS doesn't have a window manager in the same way X +does, but if you imagine it does, this is an emulation of that ;) + +The look is obviously quite different, but coming anywhere close to +the unique look of RISC OS would be quite blatantly obvious, so to +avoid copyright issues, the look of this theme is unique. You may +consider it to be RISC OS grown up ;) + +Functions that will be implemented but are currently missing: + Transparent resize. + Shading. + Backward-resize. + NOTE: Backward-resize is an interesting feature and quite useful. + If you resize a window such that you hit the screen edge + in the process, the window resizes 'backwards' (i.e. + moves in the opposite direction to your drag and at the + same time continues increasing in size). So instead + of having to let go of the resize handle, move the window + and resize again, it just does what you want it to do. + +Button functions: (Missing functionality is marked with TODO) + +Button One: + + Left button: TODO + Lower window and drop focus. This is currently unimplemented + in kwin itself. + +Button Two: + + Left button: Close window. + + Right button: TODO, if I can be bothered. + Close window. + If window is filer window, open another filer window + in parent dir. + If window is document window, open a filer window in + dir containing document. + If you hold Shift, the window doesn't close. + NOTE: + This requires app support. + If I were to implement this, I would do it in konqy + and probably not bother for other apps. + +Titlebar: + + Left button: Raise, focus and move window + + Middle button: Move window + + Right button: Menu + Note: Buttons are this way around for compatibility with + other kwin themes. + +Button Three: + + Left button: Iconify window. + +Button Four: + + Left button: Maximise or restore window plus raise and focus. + + Middle button: Maximise vertically or restore window plus raise and focus. + + Right button: Maximise or restore window. + +Resize bar left/right: + + Left button: Move that corner (resizes window) and raise + + Other buttons: Same without raising + +Resize bar centre: + + Left button: Move that edge (resizes window) and raise + + Other buttons: Same without raising + +The lower bar is used for resizing. It works in the NeXT style. +This doesn't exist on RISC OS. In RISC OS, there is a 'resize handle' +in the lower right corner of the window (actually inside the window). + +To emulate this would mean covering part of the window with the decorations, +which is not acceptable. RISC OS gets away with it by making sure that +there is a vertical scrollbar visible at all times, which is just stupid. +It's also an impossibility with X11, as the window manager does not know +anything about scrollbars - they belong to the application, so don't ask +me to implement it. + diff --git a/clients/riscos/ResizeBar.cpp b/clients/riscos/ResizeBar.cpp index 22f561d60c..e36ccd665f 100644 --- a/clients/riscos/ResizeBar.cpp +++ b/clients/riscos/ResizeBar.cpp @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -26,7 +26,7 @@ #include -namespace Default +namespace RiscOS { ResizeBar::ResizeBar(QWidget * parent, Manager * client) @@ -53,7 +53,7 @@ ResizeBar::updateDisplay() void ResizeBar::resizeEvent(QResizeEvent *) { - mid_->resize(width() - 60, mid_->height()); + mid_->resize(width() - 60, 10); right_->move(width() - 30, 0); } diff --git a/clients/riscos/ResizeBar.h b/clients/riscos/ResizeBar.h index 449e834067..10bb81c6cc 100644 --- a/clients/riscos/ResizeBar.h +++ b/clients/riscos/ResizeBar.h @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -20,12 +20,12 @@ Boston, MA 02111-1307, USA. */ -#ifndef DEFAULT_RESIZE_BAR_H -#define DEFAULT_RESIZE_BAR_H +#ifndef RISC_OS_RESIZE_BAR_H +#define RISC_OS_RESIZE_BAR_H #include -namespace Default +namespace RiscOS { class Manager; diff --git a/clients/riscos/ResizeMid.cpp b/clients/riscos/ResizeMid.cpp index b6ead24fc3..5429c94710 100644 --- a/clients/riscos/ResizeMid.cpp +++ b/clients/riscos/ResizeMid.cpp @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -20,22 +20,20 @@ Boston, MA 02111-1307, USA. */ -#include -#include -#include +#include #include "ResizeMid.h" #include "Manager.h" #include "Static.h" -namespace Default +namespace RiscOS { ResizeMid::ResizeMid(QWidget * parent, Manager * client) : DBWidget(parent, "ResizeMid"), client_(client) { - setFixedHeight(RESIZE_BAR_HEIGHT); + setFixedHeight(10); setCursor(Qt::sizeVerCursor); } @@ -49,20 +47,9 @@ ResizeMid::updatePixmap() { QPainter p(&buf()); - QColorGroup g( - client_->isActive() ? - palette().active() : - palette().inactive() - ); - - QBrush b(g.button()); - - QStyle * style = kapp->kstyle(); - - if (0 != style) - style->drawPanel(&p, 0, 0, width(), height(), g, false, 2, &b); - else - kapp->style().drawPanel(&p, 0, 0, width(), height(), g, false, 2, &b); + p.drawPixmap(0, 0, Static::instance()->resizeMidLeft(client_->isActive())); + p.drawPixmap(width() - 2, 0, Static::instance()->resizeMidRight(client_->isActive())); + p.drawTiledPixmap(2, 0, width() - 4, 10, Static::instance()->resizeMidMid(client_->isActive())); } void diff --git a/clients/riscos/ResizeMid.h b/clients/riscos/ResizeMid.h index 25b455cd3d..111d9bae66 100644 --- a/clients/riscos/ResizeMid.h +++ b/clients/riscos/ResizeMid.h @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -20,12 +20,12 @@ Boston, MA 02111-1307, USA. */ -#ifndef DEFAULT_RESIZE_MID_H -#define DEFAULT_RESIZE_MID_H +#ifndef RISC_OS_RESIZE_MID_H +#define RISC_OS_RESIZE_MID_H #include "DBWidget.h" -namespace Default +namespace RiscOS { class Manager; diff --git a/clients/riscos/ResizeSide.cpp b/clients/riscos/ResizeSide.cpp index b617704fd1..f06e4d7a02 100644 --- a/clients/riscos/ResizeSide.cpp +++ b/clients/riscos/ResizeSide.cpp @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -21,14 +21,12 @@ */ #include -#include -#include #include "ResizeSide.h" #include "Manager.h" #include "Static.h" -namespace Default +namespace RiscOS { ResizeSide::ResizeSide(QWidget * parent, Manager * client, Side s) @@ -37,7 +35,7 @@ ResizeSide::ResizeSide(QWidget * parent, Manager * client, Side s) side_ (s) { setCursor(side_ == Left ? Qt::sizeBDiagCursor : Qt::sizeFDiagCursor); - setFixedSize(RESIZE_SIDE_WIDTH, RESIZE_BAR_HEIGHT); + setFixedSize(30, 10); updateDisplay(); } @@ -69,25 +67,7 @@ ResizeSide::mouseMoveEvent(QMouseEvent * e) void ResizeSide::updateDisplay() { - QPixmap pix(size()); - QPainter p(&pix); - - QColorGroup g( - client_->isActive() ? - palette().active() : - palette().inactive() - ); - - QBrush b(g.button()); - - QStyle * style = kapp->kstyle(); - - if (0 != style) - style->drawPanel(&p, 0, 0, width(), height(), g, false, 2, &b); - else - kapp->style().drawPanel(&p, 0, 0, width(), height(), g, false, 2, &b); - - setBackgroundPixmap(pix); + setBackgroundPixmap(Static::instance()->resize(client_->isActive())); } void diff --git a/clients/riscos/ResizeSide.h b/clients/riscos/ResizeSide.h index a0cd7bdb77..1b31e9d2c0 100644 --- a/clients/riscos/ResizeSide.h +++ b/clients/riscos/ResizeSide.h @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -20,12 +20,12 @@ Boston, MA 02111-1307, USA. */ -#ifndef DEFAULT_RESIZE_SIDE_H -#define DEFAULT_RESIZE_SIDE_H +#ifndef RISC_OS_RESIZE_SIDE_H +#define RISC_OS_RESIZE_SIDE_H #include -namespace Default +namespace RiscOS { class Manager; diff --git a/clients/riscos/Static.cpp b/clients/riscos/Static.cpp index b0cfea5ca1..235c80ab31 100644 --- a/clients/riscos/Static.cpp +++ b/clients/riscos/Static.cpp @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -23,59 +23,300 @@ #include #include #include -#include #include "../../options.h" #include "Static.h" -namespace Default +namespace RiscOS { -static void drawButtonFrame(KPixmap & pix, const QColorGroup &g, bool sunken) + void +Static::_drawButtonBorder(QPixmap & pix) { - QPainter p; - - int w = pix.width(); - int h = pix.height(); - - p.begin(&pix); - - p.setPen(g.dark()); - - p.drawLine(0, 0, w-1, 0); - p.drawLine(0, 0, 0, h-1); - - p.setPen(sunken ? g.dark() : g.light()); - p.drawLine(1, 1, w-2, 1); - p.drawLine(1, 1, 1, h-2); - - p.setPen(sunken ? g.light() : g.dark()); - p.drawLine(w-2, 1, w-2, h-2); - p.drawLine(1, h-2, w-2, h-2); - - p.setPen(g.light()); - p.drawLine(w-1, 0, w-1, h-1); - p.drawLine(0, h-1, w-1, h-1); - - p.end(); + _drawBorder(pix, 17, 17); } + void +Static::_drawBorder(QPixmap & pix, int w, int h) +{ +// 0111111113 +// 1022222235 +// 12 46 +// 12 46 +// 12 46 +// 1344444476 +// 3566666667 + + painter_.begin(&pix); + painter_.translate(transx, transy); + + QColor c0 = down_ ? palette_[7] : palette_[0]; + QColor c1 = down_ ? palette_[6] : palette_[1]; + QColor c2 = down_ ? palette_[5] : palette_[2]; + QColor c3 = down_ ? palette_[4] : palette_[3]; + QColor c4 = down_ ? palette_[3] : palette_[4]; + QColor c5 = down_ ? palette_[2] : palette_[5]; + QColor c6 = down_ ? palette_[2] : palette_[6]; + QColor c7 = down_ ? palette_[1] : palette_[7]; + + painter_.setPen(c0); + painter_.drawPoint(0, 0); + + painter_.setPen(c1); + painter_.drawPoint(1, 1); + painter_.drawLine(1, 0, w - 1, 0); + painter_.drawLine(0, 1, 0, h - 1); + + painter_.setPen(c2); + painter_.drawLine(2, 1, w - 2, 1); + painter_.drawLine(1, 2, 1, h - 2); + + painter_.setPen(c3); + painter_.drawPoint(0, h); + painter_.drawPoint(1, h - 1); + painter_.drawPoint(w, 0); + painter_.drawPoint(w - 1, 1); + painter_.fillRect(2, 2, w - 2, h - 2, c3); + + painter_.setPen(c4); + painter_.drawLine(2, h - 1, w - 2, h - 1); + painter_.drawLine(w - 1, 2, w - 1, h - 2); + + painter_.setPen(c5); + painter_.drawPoint(w, 1); + painter_.drawPoint(1, h); + + painter_.setPen(c6); + painter_.drawLine(w, 2, w, h - 1); + painter_.drawLine(2, h, w - 1, h); + + painter_.setPen(c7); + painter_.drawPoint(w - 1, h - 1); + painter_.drawPoint(w, h); + + painter_.end(); +} + + void +Static::_drawCloseSymbol(QPixmap & pixmap) +{ + painter_.begin(&pixmap); + painter_.translate(transx, transy); + + painter_.setPen(QColor(palette_[1])); + painter_.drawLine(2, 0, 11, 9); + painter_.drawLine(0, 2, 9, 11); + + painter_.drawLine(0, 9, 9, 0); + painter_.drawLine(2, 11, 11, 2); + + painter_.drawPoint(0, 1); + painter_.drawPoint(1, 0); + painter_.drawPoint(10, 0); + painter_.drawPoint(11, 1); + painter_.drawPoint(0, 10); + painter_.drawPoint(1, 11); + painter_.drawPoint(10, 11); + painter_.drawPoint(11, 10); + + painter_.setPen(QColor(palette_[6])); + painter_.drawLine(1, 2, 9, 10); + painter_.drawLine(1, 1, 10, 10); + painter_.drawLine(2, 1, 10, 9); + + painter_.drawLine(1, 9, 9, 1); + painter_.drawLine(1, 10, 10, 1); + painter_.drawLine(2, 10, 10, 2); + + painter_.end(); +} + + void +Static::_drawIconifySymbol(QPixmap & pixmap) +{ + painter_.begin(&pixmap); + painter_.translate(transx, transy); + + painter_.setPen(QColor(palette_[1])); + painter_.drawRect(1, 4, 10, 4); + + painter_.setPen(QColor(palette_[3])); + painter_.drawPoint(1, 4); + painter_.drawPoint(1, 7); + painter_.drawPoint(10, 4); + painter_.drawPoint(10, 7); + + painter_.setPen(QColor(palette_[6])); + painter_.drawLine(2, 5, 9, 5); + painter_.drawLine(2, 6, 9, 6); + + painter_.end(); +} + + void +Static::_drawLowerSymbol(QPixmap & pixmap) +{ + painter_.begin(&pixmap); + painter_.translate(transx, transy); + + painter_.fillRect(1, 1, 6, 6, QColor(palette_[6])); + painter_.fillRect(5, 5, 6, 6, QColor(palette_[3])); + + painter_.setPen(QColor(palette_[1])); + painter_.drawRect(0, 0, 8, 8); + painter_.drawRect(4, 4, 8, 8); + + painter_.setPen(QColor(palette_[3])); + painter_.drawPoint(0, 0); + painter_.drawPoint(7, 0); + painter_.drawPoint(0, 7); + painter_.drawPoint(3, 7); + painter_.drawPoint(7, 3); + painter_.drawPoint(4, 4); + painter_.drawPoint(11, 4); + painter_.drawPoint(4, 11); + painter_.drawPoint(11, 11); + + painter_.setPen(QColor(palette_[5])); + painter_.drawPoint(5, 7); + painter_.drawPoint(7, 5); + + painter_.setPen(QColor(palette_[4])); + painter_.drawPoint(7, 6); + painter_.drawPoint(7, 7); + painter_.drawPoint(6, 7); + + painter_.end(); +} + + void +Static::_drawMaxSymbol(QPixmap & pixmap) +{ + painter_.begin(&pixmap); + painter_.translate(transx, transy); + + painter_.setPen(QColor(palette_[1])); + painter_.drawRect(2, 2, 8, 8); + + painter_.setPen(QColor(palette_[3])); + painter_.drawPoint(2, 2); + painter_.drawPoint(2, 9); + painter_.drawPoint(9, 9); + painter_.drawPoint(9, 2); + + painter_.fillRect(3, 3, 6, 6, QColor(palette_[6])); + + painter_.end(); +} + + void +Static::_drawUnmaxSymbol(QPixmap & pixmap) +{ + painter_.begin(&pixmap); + painter_.translate(transx, transy); + + painter_.setPen(QColor(palette_[1])); + painter_.drawRect(0, 0, 12, 12); + + painter_.setPen(QColor(palette_[3])); + painter_.drawPoint(0, 0); + painter_.drawPoint(0, 11); + painter_.drawPoint(11, 0); + painter_.drawPoint(11, 11); + + painter_.fillRect(1, 1, 10, 10, QColor(palette_[6])); + + painter_.end(); +} + + void +setPalette(Palette & pal, QColor c) +{ + pal[3] = c.rgb(); + + int h, s, v; + c.hsv(&h, &s, &v); + + if (v < 72) + c.setHsv(h, s, 72); + + pal[0] = c.light(200).rgb(); + pal[1] = c.light(166).rgb(); + pal[2] = c.light(125).rgb(); + pal[4] = c.dark(133).rgb(); + pal[5] = c.dark(166).rgb(); + pal[6] = c.dark(200).rgb(); + pal[7] = c.dark(300).rgb(); +} + + void +setInversePalette(Palette & pal, QColor c) +{ + pal[4] = c.rgb(); + + int h, s, v; + c.hsv(&h, &s, &v); + + if (v < 72) + c.setHsv(h, s, 72); + + pal[7] = c.light(200).rgb(); + pal[6] = c.light(166).rgb(); + pal[5] = c.light(125).rgb(); + pal[3] = c.dark(133).rgb(); + pal[2] = c.dark(166).rgb(); + pal[1] = c.dark(200).rgb(); + pal[0] = c.dark(300).rgb(); +} Static * Static::instance_ = 0L; void Static::_init() { + buttonPixmaps_.append(&aIconify_); + buttonPixmaps_.append(&aClose_); + buttonPixmaps_.append(&aLower_); + buttonPixmaps_.append(&aMax_); + buttonPixmaps_.append(&aUnmax_); + buttonPixmaps_.append(&iIconify_); + buttonPixmaps_.append(&iClose_); + buttonPixmaps_.append(&iLower_); + buttonPixmaps_.append(&iMax_); + buttonPixmaps_.append(&iUnmax_); + buttonPixmaps_.append(&aIconifyDown_); + buttonPixmaps_.append(&aCloseDown_); + buttonPixmaps_.append(&aLowerDown_); + buttonPixmaps_.append(&aMaxDown_); + buttonPixmaps_.append(&aUnmaxDown_); + buttonPixmaps_.append(&iIconifyDown_); + buttonPixmaps_.append(&iCloseDown_); + buttonPixmaps_.append(&iLowerDown_); + buttonPixmaps_.append(&iMaxDown_); + buttonPixmaps_.append(&iUnmaxDown_); + + for (QListIterator it(buttonPixmaps_); it.current(); ++it) { + + it.current()->setOptimization(QPixmap::MemoryOptim); + it.current()->resize(19, 20); + it.current()->fill(Qt::black); + } + aResize_.setOptimization(QPixmap::MemoryOptim); iResize_.setOptimization(QPixmap::MemoryOptim); - aResize_.resize(30, RESIZE_BAR_HEIGHT); - iResize_.resize(30, RESIZE_BAR_HEIGHT); + aResize_.resize(30, 10); + iResize_.resize(30, 10); aResize_.fill(Qt::black); iResize_.fill(Qt::black); - aTitle_ .setOptimization(QPixmap::BestOptim); - iTitle_ .setOptimization(QPixmap::BestOptim); + aTitleTextLeft_ .setOptimization(QPixmap::BestOptim); + aTitleTextRight_ .setOptimization(QPixmap::BestOptim); + aTitleTextMid_ .setOptimization(QPixmap::BestOptim); + + iTitleTextLeft_ .setOptimization(QPixmap::BestOptim); + iTitleTextRight_ .setOptimization(QPixmap::BestOptim); + iTitleTextMid_ .setOptimization(QPixmap::BestOptim); aResizeMidLeft_ .setOptimization(QPixmap::BestOptim); aResizeMidRight_ .setOptimization(QPixmap::BestOptim); @@ -85,6 +326,21 @@ Static::_init() iResizeMidRight_ .setOptimization(QPixmap::BestOptim); iResizeMid_ .setOptimization(QPixmap::BestOptim); + aTitleTextLeft_ .resize(3, 20); + aTitleTextRight_ .resize(3, 20); + aTitleTextLeft_ .fill(Qt::black); + aTitleTextRight_ .fill(Qt::black); + + iTitleTextLeft_ .resize(3, 20); + iTitleTextRight_ .resize(3, 20); + iTitleTextLeft_ .fill(Qt::black); + iTitleTextRight_ .fill(Qt::black); + + aTitleTextMid_ .resize(128, 20); + iTitleTextMid_ .resize(128, 20); + aTitleTextMid_ .fill(Qt::black); + iTitleTextMid_ .fill(Qt::black); + aResizeMidLeft_ .resize(3, 12); aResizeMidRight_ .resize(3, 12); aResizeMidLeft_ .fill(Qt::black); @@ -95,227 +351,275 @@ Static::_init() iResizeMidLeft_ .fill(Qt::black); iResizeMidRight_ .fill(Qt::black); - aResizeMid_ .resize(128, RESIZE_BAR_HEIGHT); - iResizeMid_ .resize(128, RESIZE_BAR_HEIGHT); + aResizeMid_ .resize(128, 10); + iResizeMid_ .resize(128, 10); aResizeMid_ .fill(Qt::black); iResizeMid_ .fill(Qt::black); - _loadGlyphs(); - update(); } void Static::update() { - QPainter p; + // ------------------------------------------------------------------------- + // Palettes + // ------------------------------------------------------------------------- - titleHeight_ = 24; - btnWidth1_ = 36; - btnWidth2_ = 24; + Palette aBut, iBut; + Palette aSym, iSym; - unsigned int availableTitleHeight = titleHeight_ - 6; + if (QPixmap::defaultDepth() > 8) { - aTitle_.resize(36, availableTitleHeight); - iTitle_.resize(36, availableTitleHeight); + setPalette(aBut, options->color(Options::ButtonBg, true)); + setPalette(iBut, options->color(Options::ButtonBg, false)); - aTitleText_.resize(36, availableTitleHeight); - iTitleText_.resize(36, availableTitleHeight); + QColor btnForeground; + if(qGray(options->color(Options::ButtonBg, true).rgb()) > 128) + btnForeground = Qt::black; + else + btnForeground = Qt::white; + setInversePalette(aSym, btnForeground); + if(qGray(options->color(Options::ButtonBg, false).rgb()) > 128) + btnForeground = Qt::black; + else + btnForeground = Qt::white; + setInversePalette(iSym, btnForeground); + + setPalette(aTitlePal_, options->color(Options::TitleBar, true)); + setPalette(iTitlePal_, options->color(Options::TitleBar, false)); - aTitleLeft_.resize(2, availableTitleHeight); - iTitleLeft_.resize(2, availableTitleHeight); + setPalette(aResizePal_, options->color(Options::Handle, true)); + setPalette(iResizePal_, options->color(Options::Handle, false)); + } - aTitleRight_.resize(2, availableTitleHeight); - iTitleRight_.resize(2, availableTitleHeight); + // ------------------------------------------------------------------------- + // Bevels + // ------------------------------------------------------------------------- - QColor bgColor, light, dark; - QColorGroup buttonBgColorGroup = options->colorGroup(Options::ButtonBg, true); - KPixmapEffect::GradientType vertGrad = KPixmapEffect::VerticalGradient; - KPixmapEffect::GradientType diagGrad = KPixmapEffect::DiagonalGradient; - QSize buttonSize1(btnWidth1_, availableTitleHeight); - QSize buttonSize2(btnWidth2_, availableTitleHeight); + transx = transy = 0.0; - // Titlebar + // Create sides of title text area and resize bar middle. - bgColor = options->color(Options::TitleBar, true); + QPixmap temp(4, 20); + temp.fill(Qt::black); + palette_ = aTitlePal_; + down_ = false; - light = bgColor.light(120); - dark = bgColor.dark(120); + _drawBorder(temp, 4, 18); - KPixmapEffect::gradient(aTitle_, light, dark, vertGrad); - KPixmapEffect::gradient(aTitleText_, light, dark, vertGrad); - KPixmapEffect::gradient(aTitleLeft_, light, dark, vertGrad); - KPixmapEffect::gradient(aTitleRight_, light, dark, vertGrad); + painter_.begin(&aTitleTextLeft_); + painter_.drawPixmap(1, 1, temp, 0, 1); + painter_.end(); - p.begin(&aTitle_); - p.setPen(dark); - p.drawLine(0, 0, 36, 0); - p.setPen(light); - p.drawLine(0, availableTitleHeight - 1, 36, availableTitleHeight - 1); - p.end(); + painter_.begin(&aTitleTextRight_); + painter_.drawPixmap(0, 1, temp, 2, 1); + painter_.end(); - p.begin(&aTitleText_); - p.setPen(dark); - p.drawLine(0, 0, 36, 0); - p.setPen(light); - p.drawLine(0, availableTitleHeight - 1, 36, availableTitleHeight - 1); - p.end(); + palette_ = iTitlePal_; + _drawBorder(temp, 4, 18); - p.begin(&aTitleLeft_); - p.setPen(dark); - p.drawPoint(1, 0); - p.drawLine(0, 0, 0, availableTitleHeight - 1); - p.setPen(light); - p.drawPoint(1, availableTitleHeight - 1); - p.end(); + painter_.begin(&iTitleTextLeft_); + painter_.drawPixmap(1, 1, temp, 0, 1); + painter_.end(); - p.begin(&aTitleRight_); - p.setPen(dark); - p.drawPoint(0, 1); - p.setPen(light); - p.drawLine(1, 0, 1, availableTitleHeight - 1); - p.drawPoint(0, availableTitleHeight - 1); - p.end(); + painter_.begin(&iTitleTextRight_); + painter_.drawPixmap(0, 1, temp, 2, 1); + painter_.end(); + + transy = 1.0; - bgColor = options->color(Options::TitleBar, false); - light = bgColor.light(120); - dark = bgColor.dark(120); + palette_ = aResizePal_; + temp.resize(4, 10); + temp.fill(Qt::black); + _drawBorder(temp, 4, 7); - KPixmapEffect::gradient(iTitle_, light, dark, vertGrad); - KPixmapEffect::gradient(iTitleText_, light, dark, vertGrad); - KPixmapEffect::gradient(iTitleLeft_, light, dark, vertGrad); - KPixmapEffect::gradient(iTitleRight_, light, dark, vertGrad); + painter_.begin(&aResizeMidLeft_); + painter_.drawPixmap(0, 1, temp, 0, 1); + painter_.end(); - p.begin(&iTitle_); - p.setPen(dark); - p.drawLine(0, 0, 36, 0); - p.setPen(light); - p.drawLine(0, availableTitleHeight - 1, 36, availableTitleHeight - 1); - p.end(); + painter_.begin(&aResizeMidRight_); + painter_.drawPixmap(0, 1, temp, 2, 1); + painter_.end(); - p.begin(&iTitleText_); - p.setPen(dark); - p.drawLine(0, 0, 36, 0); - p.setPen(light); - p.drawLine(0, availableTitleHeight - 1, 36, availableTitleHeight - 1); - p.end(); + palette_ = iResizePal_; + _drawBorder(temp, 4, 7); - p.begin(&iTitleLeft_); - p.setPen(dark); - p.drawPoint(1, 0); - p.drawLine(0, 0, 0, availableTitleHeight - 1); - p.setPen(light); - p.drawPoint(1, availableTitleHeight - 1); - p.end(); + painter_.begin(&iResizeMidLeft_); + painter_.drawPixmap(0, 1, temp, 0, 1); + painter_.end(); - p.begin(&iTitleRight_); - p.setPen(dark); - p.drawPoint(0, 1); - p.setPen(light); - p.drawLine(1, 0, 1, availableTitleHeight - 1); - p.drawPoint(0, availableTitleHeight - 1); - p.end(); + painter_.begin(&iResizeMidRight_); + painter_.drawPixmap(0, 1, temp, 2, 1); + painter_.end(); - p.begin(&aTitle_); - p.setPen(options->color(Options::TitleBar, true).light(150)); + transx = transy = 0.0; - for (unsigned int y = 3; y < availableTitleHeight - 3; y += 3) - for (unsigned int x = 1; x < 36; x += 3) - p.drawPoint(x, y); + temp.resize(132, 20); + + temp.fill(Qt::black); - p.setPen(options->color(Options::TitleBar, true).dark(150)); + palette_ = aTitlePal_; + _drawBorder(temp, 132, 17); + + painter_.begin(&aTitleTextMid_); + painter_.drawPixmap(0, 1, temp, 2, 0); + painter_.end(); - for (unsigned int y = 3; y < availableTitleHeight - 3; y += 3) - for (unsigned int x = 1; x < 36; x += 3) - p.drawPoint(x + 1, y + 1); - p.end(); + palette_ = iTitlePal_; + _drawBorder(temp, 132, 17); + + painter_.begin(&iTitleTextMid_); + painter_.drawPixmap(0, 1, temp, 2, 0); + painter_.end(); - // Buttons + transy = 1.0; - bgColor = buttonBgColorGroup.background(); - light = bgColor.light(120); - dark = bgColor.dark(120); + temp.fill(Qt::black); - btnPix1_ .resize(buttonSize1); - btnDownPix1_ .resize(buttonSize1); - btnPix2_ .resize(buttonSize2); - btnDownPix2_ .resize(buttonSize2); + palette_ = aResizePal_; + _drawBorder(temp, 132, 7); + + painter_.begin(&aResizeMid_); + painter_.drawPixmap(0, 0, temp, 2, 0); + painter_.end(); - iBtnPix1_ .resize(buttonSize1); - iBtnDownPix1_ .resize(buttonSize1); - iBtnPix2_ .resize(buttonSize2); - iBtnDownPix2_ .resize(buttonSize2); + palette_ = iResizePal_; + _drawBorder(temp, 132, 7); + + painter_.begin(&iResizeMid_); + painter_.drawPixmap(0, 0, temp, 2, 0); + painter_.end(); - KPixmapEffect::gradient(btnPix1_, light, dark, diagGrad); - KPixmapEffect::gradient(btnDownPix1_, dark, light, diagGrad); - KPixmapEffect::gradient(btnPix2_, light, dark, diagGrad); - KPixmapEffect::gradient(btnDownPix2_, dark, light, diagGrad); + down_ = false; - KPixmapEffect::gradient(iBtnPix1_, light, dark, diagGrad); - KPixmapEffect::gradient(iBtnDownPix1_, dark, light, diagGrad); - KPixmapEffect::gradient(iBtnPix2_, light, dark, diagGrad); - KPixmapEffect::gradient(iBtnDownPix2_, dark, light, diagGrad); + palette_ = aBut; + transx = transy = 1.0; + _drawButtonBorder(aClose_); + _drawButtonBorder(aLower_); + transx = 0.0; + _drawButtonBorder(aIconify_); + _drawButtonBorder(aMax_); + _drawButtonBorder(aUnmax_); - drawButtonFrame(btnPix1_, buttonBgColorGroup, false); - drawButtonFrame(btnDownPix1_, buttonBgColorGroup, true); - drawButtonFrame(btnPix2_, buttonBgColorGroup, false); - drawButtonFrame(btnDownPix2_, buttonBgColorGroup, true); + palette_ = iBut; + transx = transy = 1.0; + _drawButtonBorder(iClose_); + _drawButtonBorder(iLower_); + transx = 0.0; + _drawButtonBorder(iIconify_); + _drawButtonBorder(iMax_); + _drawButtonBorder(iUnmax_); - drawButtonFrame(iBtnPix1_, buttonBgColorGroup, false); - drawButtonFrame(iBtnDownPix1_, buttonBgColorGroup, true); - drawButtonFrame(iBtnPix2_, buttonBgColorGroup, false); - drawButtonFrame(iBtnDownPix2_, buttonBgColorGroup, true); + down_ = true; - p.flush(); + palette_ = aBut; + transx = transy = 1.0; + _drawButtonBorder(aCloseDown_); + _drawButtonBorder(aLowerDown_); + transx = 0.0; + _drawButtonBorder(aIconifyDown_); + _drawButtonBorder(aMaxDown_); + _drawButtonBorder(aUnmaxDown_); + + palette_ = iBut; + transx = transy = 1.0; + _drawButtonBorder(iCloseDown_); + _drawButtonBorder(iLowerDown_); + transx = 0.0; + _drawButtonBorder(iIconifyDown_); + _drawButtonBorder(iMaxDown_); + _drawButtonBorder(iUnmaxDown_); + + // ------------------------------------------------------------------------- + // Button symbols + // ------------------------------------------------------------------------- + + transy = 4.0; + + palette_ = aSym; + + transx = 4.0; + _drawCloseSymbol (aClose_); + _drawLowerSymbol (aLower_); + transx = 3.0; + _drawIconifySymbol (aIconify_); + _drawMaxSymbol (aMax_); + _drawUnmaxSymbol (aUnmax_); + + transx = 4.0; + _drawCloseSymbol (aCloseDown_); + _drawLowerSymbol (aLowerDown_); + transx = 3.0; + _drawIconifySymbol (aIconifyDown_); + _drawMaxSymbol (aMaxDown_); + _drawUnmaxSymbol (aUnmaxDown_); + + palette_ = iSym; + + transx = 4.0; + _drawCloseSymbol (iClose_); + _drawLowerSymbol (iLower_); + transx = 3.0; + _drawIconifySymbol (iIconify_); + _drawMaxSymbol (iMax_); + _drawUnmaxSymbol (iUnmax_); + + transx = 4.0; + _drawCloseSymbol (iCloseDown_); + _drawLowerSymbol (iLowerDown_); + transx = 3.0; + _drawIconifySymbol (iIconifyDown_); + _drawMaxSymbol (iMaxDown_); + _drawUnmaxSymbol (iUnmaxDown_); + + // ------------------------------------------------------------------------- + // Resize handles + // ------------------------------------------------------------------------- + + transx = transy = 1.0; + + down_ = false; + + palette_ = aResizePal_; + _drawBorder(aResize_, 28, 7); + + palette_ = iResizePal_; + _drawBorder(iResize_, 28, 7); } QPixmap Static::button(SymbolType t, bool active, bool down) { - bool buttonSize2 = (t == Sticky || t == Unsticky); - QPixmap px = buttonPixmap(!buttonSize2, active, down); + QPixmap p(19, 20); - QBitmap b = glyph(t); - b.setMask(b); + if (down) { - QPainter p(&px); - QPoint offset((buttonSize2 ? btnWidth2_ : btnWidth1_) / 2 - 4, (titleHeight_ - 6) / 2 - 4); - p.drawPixmap(offset, b); + switch (t) { - return px; -} + case Iconify: p = active ? aIconifyDown_ : iIconifyDown_; break; + case Close: p = active ? aCloseDown_ : iCloseDown_; break; + case Lower: p = active ? aLowerDown_ : iLowerDown_; break; + case Max: p = active ? aMaxDown_ : iMaxDown_; break; + case Unmax: p = active ? aUnmaxDown_ : iUnmaxDown_; break; + default: break; + } + + } else { -static unsigned char iconify_bits[] = { - 0xff, 0xff, 0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18}; + switch (t) { -static unsigned char close_bits[] = { - 0xc3, 0x66, 0x3c, 0x18, 0x3c, 0x66, 0xc3, 0x00 }; + case Iconify: p = active ? aIconify_ : iIconify_; break; + case Close: p = active ? aClose_ : iClose_; break; + case Lower: p = active ? aLower_ : iLower_; break; + case Max: p = active ? aMax_ : iMax_; break; + case Unmax: p = active ? aUnmax_ : iUnmax_; break; + default: break; + } -static unsigned char maximize_bits[] = { - 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0xff, 0xff }; + } -static unsigned char unmax_bits[] = { - 0x30, 0x18, 0xcc, 0xe6, 0xf3, 0xf9, 0xfc, 0xfc}; - -static unsigned char unsticky_bits[] = { - 0x3c, 0x42, 0x99, 0xbd, 0xbd, 0x99, 0x42, 0x3c}; - -static unsigned char sticky_bits[] = { - 0x3c, 0x42, 0x81, 0x81, 0x81, 0x81, 0x42, 0x3c}; - -static unsigned char question_bits[] = { - 0x3c, 0x66, 0x60, 0x30, 0x18, 0x00, 0x18, 0x18}; - - - void -Static::_loadGlyphs() -{ - glyphClose_ = QBitmap(8, 8, close_bits); - glyphMaximise_ = QBitmap(8, 8, maximize_bits); - glyphUnmaximise_ = QBitmap(8, 8, unmax_bits); - glyphSticky_ = QBitmap(8, 8, sticky_bits); - glyphUnsticky_ = QBitmap(8, 8, unsticky_bits); - glyphIconify_ = QBitmap(8, 8, iconify_bits); + return p; } } // End namespace diff --git a/clients/riscos/Static.h b/clients/riscos/Static.h index 3ea118b7de..ee556e7acb 100644 --- a/clients/riscos/Static.h +++ b/clients/riscos/Static.h @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -20,22 +20,20 @@ Boston, MA 02111-1307, USA. */ -#ifndef DEFAULT_STATIC_H -#define DEFAULT_STATIC_H +#ifndef RISC_OS_STATIC_H +#define RISC_OS_STATIC_H #include #include #include -#include -#include -#include "Defines.h" +#include "Palette.h" -namespace Default +namespace RiscOS { -enum SymbolType { Sticky, Unsticky, Close, Iconify, Max, Unmax }; +enum SymbolType { Lower, Close, Iconify, Max, Unmax }; class Static { @@ -63,111 +61,67 @@ class Static void update(); - const QPixmap & title(bool active) const - { return active ? aTitle_ : iTitle_; } + QPixmap titleTextLeft(bool active) + { return active ? aTitleTextLeft_ : iTitleTextLeft_; } - const QPixmap & titleText(bool active) const - { return active ? aTitleText_ : iTitleText_; } + QPixmap titleTextRight(bool active) + { return active ? aTitleTextRight_ : iTitleTextRight_; } - const QPixmap & titleLeft(bool active) const - { return active ? aTitleLeft_ : iTitleLeft_; } - - const QPixmap & titleRight(bool active) const - { return active ? aTitleRight_ : iTitleRight_; } - - const QPixmap & resizeMidLeft(bool active) const + QPixmap resizeMidLeft(bool active) { return active ? aResizeMidLeft_ : iResizeMidLeft_; } - const QPixmap & resizeMidRight(bool active) const + QPixmap resizeMidRight(bool active) { return active ? aResizeMidRight_ : iResizeMidRight_; } - const QPixmap & resizeMidMid(bool active) const + QPixmap titleTextMid(bool active) + { return active ? aTitleTextMid_ : iTitleTextMid_; } + + QPixmap resizeMidMid(bool active) { return active ? aResizeMid_ : iResizeMid_; } QPixmap button(SymbolType t, bool active, bool down); - const QPixmap & resize(bool active) const + QPixmap resize(bool active) { return active ? aResize_ : iResize_; } - const QBitmap & glyph(SymbolType t) const - { - switch (t) { - case Close: return glyphClose_; - case Sticky: return glyphSticky_; - case Unsticky: return glyphUnsticky_; - case Iconify: return glyphIconify_; - case Max: return glyphMaximise_; - case Unmax: return glyphUnmaximise_; - default: return glyphClose_; - } - } - - unsigned int buttonWidth1() const { return btnWidth1_; } - unsigned int buttonWidth2() const { return btnWidth2_; } - unsigned int titleHeight() const { return titleHeight_; } - - const KPixmap & buttonPixmap(int n, bool active, bool down) const - { - if (active) { - if (n == 1) - if (down) - return btnDownPix1_; - else - return btnPix1_; - else - if (down) - return btnDownPix2_; - else - return btnPix2_; - } else { - if (n == 1) - if (down) - return iBtnDownPix1_; - else - return iBtnPix1_; - else - if (down) - return iBtnDownPix2_; - else - return iBtnPix2_; - } - - } + Palette & standardPalette() + { return standardPal_; } private: + void _drawButtonBorder (QPixmap &); + void _drawBorder (QPixmap &, int, int); + void _drawCloseSymbol (QPixmap &); + void _drawIconifySymbol(QPixmap &); + void _drawLowerSymbol (QPixmap &); + void _drawMaxSymbol (QPixmap &); + void _drawUnmaxSymbol (QPixmap &); + void _init(); - void _loadGlyphs(); static Static * instance_; - QPixmap - aResize_, iResize_, - aResizeDown_, iResizeDown_, - aResizeMidLeft_, aResizeMidRight_, - iResizeMidLeft_, iResizeMidRight_, - aResizeMid_, iResizeMid_; + Palette standardPal_, aTitlePal_, iTitlePal_, aResizePal_, iResizePal_; - QBitmap - glyphClose_, - glyphSticky_, - glyphUnsticky_, - glyphIconify_, - glyphMaximise_, - glyphUnmaximise_; + QPixmap aIconify_, aClose_, aLower_, aMax_, aUnmax_, + iIconify_, iClose_, iLower_, iMax_, iUnmax_, + aResize_, iResize_, + aIconifyDown_, aCloseDown_, aLowerDown_, aMaxDown_, aUnmaxDown_, + iIconifyDown_, iCloseDown_, iLowerDown_, iMaxDown_, iUnmaxDown_, + aResizeDown_, iResizeDown_, + aTitleTextLeft_, aTitleTextRight_, + aResizeMidLeft_, aResizeMidRight_, + iTitleTextLeft_, iTitleTextRight_, + iResizeMidLeft_, iResizeMidRight_, + aTitleTextMid_, iTitleTextMid_, + aResizeMid_, iResizeMid_; - KPixmap aTitle_, iTitle_; - KPixmap aTitleLeft_, iTitleLeft_; - KPixmap aTitleRight_, iTitleRight_; - KPixmap aTitleText_, iTitleText_; + QList buttonPixmaps_; - KPixmap btnPix1_, btnDownPix1_, iBtnPix1_, iBtnDownPix1_; - KPixmap btnPix2_, btnDownPix2_, iBtnPix2_, iBtnDownPix2_; - - unsigned int btnWidth1_; - unsigned int btnWidth2_; - - unsigned int titleHeight_; + QPainter painter_; + bool down_; + Palette palette_; + double transx, transy; }; } // End namespace diff --git a/clients/riscos/TitleBar.cpp b/clients/riscos/TitleBar.cpp index 88a64652b4..e135a25593 100644 --- a/clients/riscos/TitleBar.cpp +++ b/clients/riscos/TitleBar.cpp @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -27,78 +27,51 @@ #include "TitleText.h" #include "CloseButton.h" #include "IconifyButton.h" -#include "StickyButton.h" +#include "LowerButton.h" #include "MaximiseButton.h" -namespace Default +namespace RiscOS { TitleBar::TitleBar(Manager * client) : QWidget(client) { + setBackgroundMode(NoBackground); + + lower_ = new LowerButton (this); close_ = new CloseButton (this); text_ = new TitleText (this, client); iconify_ = new IconifyButton (this); maximise_ = new MaximiseButton (this); - sticky_ = new StickyButton (this); - // Close | Text | Sticky | Iconify | Maximise + lower_ ->setAlign(Button::Left); + close_ ->setAlign(Button::Left); + iconify_ ->setAlign(Button::Right); + maximise_ ->setAlign(Button::Right); - QHBoxLayout * layout = new QHBoxLayout(this); - layout->setMargin(3); + // Lower | Close | Text | Iconify | Maximise + QHBoxLayout * layout = new QHBoxLayout(this); + + layout->addWidget(lower_); layout->addWidget(close_); - layout->addSpacing(2); layout->addWidget(text_, 1); - layout->addSpacing(2); - layout->addWidget(sticky_); layout->addWidget(iconify_); layout->addWidget(maximise_); - connect( - close_, SIGNAL(closeClient()), - client, SLOT(closeWindow()) - ); - - connect( - sticky_, SIGNAL(toggleSticky()), - client, SLOT(toggleSticky()) - ); - - connect( - client, SIGNAL(stickyStatusChanged(bool)), - sticky_, SLOT(setOn(bool)) - ); - - connect( - iconify_, SIGNAL(iconifyClient()), - client, SLOT(iconify()) - ); - - connect( - maximise_, SIGNAL(maximiseClient()), - client, SLOT(maximize()) - ); - - connect( - maximise_, SIGNAL(vMaxClient()), - client, SLOT(vMax()) - ); - - connect( - maximise_, SIGNAL(raiseClient()), - client, SLOT(raise()) - ); - - connect( - client, SIGNAL(maximiseChanged(bool)), - maximise_, SLOT(setOn(bool)) - ); + connect(lower_, SIGNAL(lowerClient()), client, SLOT(lower())); + connect(close_, SIGNAL(closeClient()), client, SLOT(closeWindow())); + connect(iconify_, SIGNAL(iconifyClient()), client, SLOT(iconify())); + connect(maximise_, SIGNAL(maximiseClient()), client, SLOT(maximize())); + connect(maximise_, SIGNAL(vMaxClient()), client, SLOT(vMax())); + connect(maximise_, SIGNAL(raiseClient()), client, SLOT(raise())); + connect(client, SIGNAL(maximiseChanged(bool)), maximise_, SLOT(setOn(bool))); } void TitleBar::updateDisplay() { + lower_ ->updateDisplay(); close_ ->updateDisplay(); text_ ->updateDisplay(); iconify_ ->updateDisplay(); @@ -127,32 +100,32 @@ TitleBar::resizeEvent(QResizeEvent *) switch (sizeProblem) { case 1: - close_ ->show(); - sticky_ ->hide(); + lower_ ->hide(); iconify_ ->show(); maximise_ ->hide(); + close_ ->show(); break; case 2: - close_ ->show(); - sticky_ ->hide(); + lower_ ->hide(); iconify_ ->hide(); maximise_ ->hide(); + close_ ->show(); break; case 3: - close_ ->hide(); - sticky_ ->hide(); + lower_ ->hide(); iconify_ ->hide(); maximise_ ->hide(); + close_ ->hide(); break; case 0: default: - close_ ->show(); - sticky_ ->show(); + lower_ ->show(); iconify_ ->show(); maximise_ ->show(); + close_ ->show(); break; } } @@ -160,43 +133,13 @@ TitleBar::resizeEvent(QResizeEvent *) void TitleBar::setActive(bool b) { - sticky_->setActive(b); + lower_->setActive(b); close_->setActive(b); text_->setActive(b); iconify_->setActive(b); maximise_->setActive(b); } - void -TitleBar::paintEvent(QPaintEvent * e) -{ - QRect r(e->rect()); - - bool intersectsLeft = - r.intersects(QRect(0, 0, 1, height())); - - bool intersectsRight = - r.intersects(QRect(width() - 1, 0, width(), height())); - - bool intersectsTop = - r.intersects(QRect(0, 0, width(), 1)); - - if (intersectsTop || intersectsLeft || intersectsRight) { - - QPainter p(this); - p.setPen(Qt::black); - - if (intersectsTop) - p.drawLine(r.left(), 0, r.right(), 0); - - if (intersectsLeft) - p.drawLine(0, r.top(), 0, r.bottom()); - - if (intersectsRight) - p.drawLine(width() - 1, r.top(), width() - 1, r.bottom()); - } -} - } // End namespace // vim:ts=2:sw=2:tw=78 diff --git a/clients/riscos/TitleBar.h b/clients/riscos/TitleBar.h index 4741a6fee8..2e26656d1f 100644 --- a/clients/riscos/TitleBar.h +++ b/clients/riscos/TitleBar.h @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -20,16 +20,16 @@ Boston, MA 02111-1307, USA. */ -#ifndef DEFAULT_TITLE_BAR_H -#define DEFAULT_TITLE_BAR_H +#ifndef RISC_OS_TITLE_BAR_H +#define RISC_OS_TITLE_BAR_H #include -namespace Default +namespace RiscOS { class Manager; -class StickyButton; +class LowerButton; class CloseButton; class TitleText; class IconifyButton; @@ -51,15 +51,14 @@ class TitleBar : public QWidget protected: void resizeEvent(QResizeEvent *); - void paintEvent(QPaintEvent *); private: + LowerButton * lower_; CloseButton * close_; TitleText * text_; - StickyButton * sticky_; IconifyButton * iconify_; MaximiseButton * maximise_; }; diff --git a/clients/riscos/TitleText.cpp b/clients/riscos/TitleText.cpp index e6d8d369d3..eb2e1cde17 100644 --- a/clients/riscos/TitleText.cpp +++ b/clients/riscos/TitleText.cpp @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -28,7 +28,7 @@ #include "Manager.h" #include "Static.h" -namespace Default +namespace RiscOS { TitleText::TitleText(QWidget * parent, Manager * client) @@ -55,22 +55,13 @@ TitleText::updatePixmap() QPainter p(&buf()); Static * s = Static::instance(); - - p.drawPixmap(0, 0, s->titleLeft(active_)); - p.drawPixmap(width() - 2, 0, s->titleRight(active_)); - p.drawTiledPixmap(2, 0, width() - 2, height(), s->title(active_)); - - QFontMetrics fm(options->font()); - unsigned int w = fm.width(client_->caption()); - p.drawTiledPixmap( - width() / 2 - w / 2, 0, - w, height(), - s->titleText(active_) - ); + p.drawPixmap(0, 0, s->titleTextLeft(active_)); + p.drawPixmap(width() - 3, 0, s->titleTextRight(active_)); + p.drawTiledPixmap(3, 0, width() - 6, 20, s->titleTextMid(active_)); p.setPen(options->color(Options::Font, active_)); p.setFont(options->font()); - p.drawText(4, 0, width() - 8, height(), AlignCenter, client_->caption()); + p.drawText(4, 0, width() - 8, 18, AlignCenter, client_->caption()); } void diff --git a/clients/riscos/TitleText.h b/clients/riscos/TitleText.h index 04b8cce9eb..72606af6bc 100644 --- a/clients/riscos/TitleText.h +++ b/clients/riscos/TitleText.h @@ -1,5 +1,5 @@ /* - Default KWin client + RISC OS KWin client Copyright 2000 Rik Hemsley @@ -20,15 +20,15 @@ Boston, MA 02111-1307, USA. */ -#ifndef DEFAULT_TITLE_TEXT_H -#define DEFAULT_TITLE_TEXT_H +#ifndef RISC_OS_TITLE_TEXT_H +#define RISC_OS_TITLE_TEXT_H #include #include #include "DBWidget.h" -namespace Default +namespace RiscOS { class Manager;