From 8b2aa1b5301ab60368a03e36df4ff5216726e87d Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeartwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kwin-styles/riscos/AboveButton.cpp | 65 +++ kwin-styles/riscos/AboveButton.h | 50 +++ kwin-styles/riscos/Button.cpp | 153 +++++++ kwin-styles/riscos/Button.h | 81 ++++ kwin-styles/riscos/CloseButton.cpp | 66 +++ kwin-styles/riscos/CloseButton.h | 52 +++ kwin-styles/riscos/HelpButton.cpp | 66 +++ kwin-styles/riscos/HelpButton.h | 52 +++ kwin-styles/riscos/IconifyButton.cpp | 66 +++ kwin-styles/riscos/IconifyButton.h | 52 +++ kwin-styles/riscos/LowerButton.cpp | 66 +++ kwin-styles/riscos/LowerButton.h | 52 +++ kwin-styles/riscos/Makefile.am | 39 ++ kwin-styles/riscos/Manager.cpp | 767 ++++++++++++++++++++++++++++++++++ kwin-styles/riscos/Manager.h | 123 ++++++ kwin-styles/riscos/MaximiseButton.cpp | 98 +++++ kwin-styles/riscos/MaximiseButton.h | 60 +++ kwin-styles/riscos/Palette.h | 69 +++ kwin-styles/riscos/README | 90 ++++ kwin-styles/riscos/Static.cpp | 540 ++++++++++++++++++++++++ kwin-styles/riscos/Static.h | 134 ++++++ kwin-styles/riscos/StickyButton.cpp | 99 +++++ kwin-styles/riscos/StickyButton.h | 60 +++ kwin-styles/riscos/riscos.desktop | 11 + 24 files changed, 2911 insertions(+) create mode 100644 kwin-styles/riscos/AboveButton.cpp create mode 100644 kwin-styles/riscos/AboveButton.h create mode 100644 kwin-styles/riscos/Button.cpp create mode 100644 kwin-styles/riscos/Button.h create mode 100644 kwin-styles/riscos/CloseButton.cpp create mode 100644 kwin-styles/riscos/CloseButton.h create mode 100644 kwin-styles/riscos/HelpButton.cpp create mode 100644 kwin-styles/riscos/HelpButton.h create mode 100644 kwin-styles/riscos/IconifyButton.cpp create mode 100644 kwin-styles/riscos/IconifyButton.h create mode 100644 kwin-styles/riscos/LowerButton.cpp create mode 100644 kwin-styles/riscos/LowerButton.h create mode 100644 kwin-styles/riscos/Makefile.am create mode 100644 kwin-styles/riscos/Manager.cpp create mode 100644 kwin-styles/riscos/Manager.h create mode 100644 kwin-styles/riscos/MaximiseButton.cpp create mode 100644 kwin-styles/riscos/MaximiseButton.h create mode 100644 kwin-styles/riscos/Palette.h create mode 100644 kwin-styles/riscos/README create mode 100644 kwin-styles/riscos/Static.cpp create mode 100644 kwin-styles/riscos/Static.h create mode 100644 kwin-styles/riscos/StickyButton.cpp create mode 100644 kwin-styles/riscos/StickyButton.h create mode 100644 kwin-styles/riscos/riscos.desktop (limited to 'kwin-styles/riscos') diff --git a/kwin-styles/riscos/AboveButton.cpp b/kwin-styles/riscos/AboveButton.cpp new file mode 100644 index 00000000..738b7f79 --- /dev/null +++ b/kwin-styles/riscos/AboveButton.cpp @@ -0,0 +1,65 @@ +/* + RISC OS KWin client + + Copyright 2004 + Carsten Clever + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "AboveButton.h" + +namespace RiscOS +{ + +/* XPM */ +static const char * const above_xpm[] = { +"12 12 3 1", +" c None", +". c #000000", +"+ c #FFFFFF", +" ", +" ..... ", +".+++++. ", +".+++++. ", +".+++++..... ", +".+++++.++++.", +".+++++.++++.", +" .....+++++.", +" .+++++.", +" .+++++.", +" ..... ", +" "}; + +AboveButton::AboveButton(QWidget *parent) + : Button(parent, i18n("Keep above others")) +{ + setPixmap(QPixmap((const char **)above_xpm)); +} + +void AboveButton::mouseReleaseEvent(QMouseEvent *e) +{ + Button::mouseReleaseEvent(e); + + if (!rect().contains(e->pos())) + return; + + emit(above()); +} + +} // End namespace + +#include "AboveButton.moc" diff --git a/kwin-styles/riscos/AboveButton.h b/kwin-styles/riscos/AboveButton.h new file mode 100644 index 00000000..b7a910ec --- /dev/null +++ b/kwin-styles/riscos/AboveButton.h @@ -0,0 +1,50 @@ +/* + RISC OS KWin client + + Copyright 2004 + Carsten Clever + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef RISC_OS_ABOVE_BUTTON_H +#define RISC_OS_ABOVE_BUTTON_H + +#include "Button.h" + +namespace RiscOS +{ + +class AboveButton : public Button +{ + Q_OBJECT + + public: + + AboveButton(QWidget *parent); + + signals: + + void above(); + + protected: + + void mouseReleaseEvent(QMouseEvent*); +}; + +} // End namespace + +#endif diff --git a/kwin-styles/riscos/Button.cpp b/kwin-styles/riscos/Button.cpp new file mode 100644 index 00000000..d4da6ecc --- /dev/null +++ b/kwin-styles/riscos/Button.cpp @@ -0,0 +1,153 @@ +/* + RISC OS KWin client + + Copyright 2000 + Rik Hemsley + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include +#include "Button.h" +#include "Static.h" + +namespace RiscOS +{ + +Button::Button(QWidget *parent, const QString& tip, + const ButtonState realizeButtons) + : QWidget(parent, "Button", 0), + realizeButtons_(realizeButtons), + lastButton_(NoButton), + alignment_(Left), + down_ (false), + active_ (false) +{ + QToolTip::add(this, tip); + setBackgroundColor(Qt::black); + + setFixedSize(Static::instance()->titleHeight() - 1, + Static::instance()->titleHeight()); +} + +Button::~Button() +{ + // Empty. +} + +void Button::setAlignment(Alignment a) +{ + alignment_ = a; + repaint(); +} + +void Button::setActive(bool b) +{ + active_ = b; + repaint(); +} + +Button::Alignment Button::alignment() const +{ + return alignment_; +} + +void Button::mousePressEvent(QMouseEvent *e) +{ + down_ = true; + lastButton_ = e->button(); + repaint(); + + QMouseEvent me(e->type(), e->pos(), e->globalPos(), + (e->button()&realizeButtons_) ? LeftButton : NoButton, + e->state()); + QWidget::mousePressEvent(&me); +} + +void Button::mouseReleaseEvent(QMouseEvent *e) +{ + down_ = false; + lastButton_ = e->button(); + repaint(); + QMouseEvent me(e->type(), e->pos(), e->globalPos(), + (e->button()&realizeButtons_) ? LeftButton : NoButton, + e->state()); + QWidget::mouseReleaseEvent(&me); +} + +void Button::setPixmap(const QPixmap &p) +{ + if (QPixmap::defaultDepth() <= 8) + aPixmap_ = iPixmap_ = p; + else + { + QRgb light; + QRgb* data = NULL; + QRgb w = qRgb(255, 255, 255); + + QImage aTx(p.convertToImage()); + QImage iTx(aTx.copy()); + + const KDecorationOptions* options = KDecoration::options(); + light = options->color(KDecoration::ColorButtonBg, true).light(150).rgb(); + + if (light == qRgb(0, 0, 0)) + light = qRgb(228, 228, 228); + + data = (QRgb *)aTx.bits(); + + for (int x = 0; x < 144; x++) + if (data[x] == w) + data[x] = light; + + light = options->color(KDecoration::ColorButtonBg, false).light(150).rgb(); + + if (light == qRgb(0, 0, 0)) + light = qRgb(228, 228, 228); + + data = (QRgb *)iTx.bits(); + + for (int x = 0; x < 144; x++) + if (data[x] == w) + data[x] = light; + + aPixmap_.convertFromImage(aTx); + iPixmap_.convertFromImage(iTx); + + if (0 != p.mask()) + { + aPixmap_.setMask(*p.mask()); + iPixmap_.setMask(*p.mask()); + } + } + repaint(); +} + +void Button::paintEvent(QPaintEvent *) +{ + bitBlt(this, alignment_ == Left ? 1 : 0, 0, + &Static::instance()->buttonBase(active_, down_)); + + int i = width() / 2 - 6; + + bitBlt(this, alignment_ == Left ? i + 1 : i, + i + 1, active_ ? &aPixmap_ : &iPixmap_); +} + +} // End namespace + +// vim:ts=2:sw=2:tw=78 +#include "Button.moc" diff --git a/kwin-styles/riscos/Button.h b/kwin-styles/riscos/Button.h new file mode 100644 index 00000000..1289a2fa --- /dev/null +++ b/kwin-styles/riscos/Button.h @@ -0,0 +1,81 @@ +/* + RISC OS KWin client + + Copyright 2000 + Rik Hemsley + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef RISC_OS_BUTTON_H +#define RISC_OS_BUTTON_H + +#include +#include +#include +#include + +namespace RiscOS +{ + +class Button : public QWidget +{ + Q_OBJECT + + public: + + enum Type { Lower, Close, Iconify, Maximise, Sticky, Help }; + + enum Alignment { Left, Right }; + + Button(QWidget *parent, const QString &tip, + const ButtonState realizeButton = LeftButton); + virtual ~Button(); + + void setAlignment(Alignment); + + Alignment alignment() const; + + protected slots: + + void setActive(bool); + + protected: + + void paintEvent(QPaintEvent *); + + void mousePressEvent(QMouseEvent *); + void mouseReleaseEvent(QMouseEvent *); + void mouseMoveEvent(QMouseEvent *) { /* Empty. */ } + + void setPixmap(const QPixmap &); + + ButtonState realizeButtons_; + ButtonState lastButton_; + + private: + + Alignment alignment_; + bool down_; + bool active_; + QPixmap aPixmap_, iPixmap_; +}; + +} // End namespace + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/kwin-styles/riscos/CloseButton.cpp b/kwin-styles/riscos/CloseButton.cpp new file mode 100644 index 00000000..4f2066cf --- /dev/null +++ b/kwin-styles/riscos/CloseButton.cpp @@ -0,0 +1,66 @@ +/* + RISC OS KWin client + + Copyright 2000 + Rik Hemsley + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "CloseButton.h" + +namespace RiscOS +{ + +/* XPM */ +static const char * const close_xpm[] = { +"12 12 3 1", +" c None", +". c #000000", +"+ c #FFFFFF", +" . . ", +" .+. .+. ", +".+++. .+++.", +" .+++..+++. ", +" .++++++. ", +" .++++. ", +" .++++. ", +" .++++++. ", +" .+++..+++. ", +".+++. .+++.", +" .+. .+. ", +" . . "}; + +CloseButton::CloseButton(QWidget *parent) + : Button(parent, i18n("Close")) +{ + setPixmap(QPixmap((const char **)close_xpm)); +} + +void CloseButton::mouseReleaseEvent(QMouseEvent *e) +{ + Button::mouseReleaseEvent(e); + + if (!rect().contains(e->pos())) + return; + + emit(closeWindow()); +} + +} // End namespace; + +// vim:ts=2:sw=2:tw=78 +#include "CloseButton.moc" diff --git a/kwin-styles/riscos/CloseButton.h b/kwin-styles/riscos/CloseButton.h new file mode 100644 index 00000000..73791b76 --- /dev/null +++ b/kwin-styles/riscos/CloseButton.h @@ -0,0 +1,52 @@ +/* + RISC OS KWin client + + Copyright 2000 + Rik Hemsley + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef RISC_OS_CLOSE_BUTTON_H +#define RISC_OS_CLOSE_BUTTON_H + +#include "Button.h" + +namespace RiscOS +{ + +class CloseButton : public Button +{ + Q_OBJECT + + public: + + CloseButton(QWidget *parent); + + signals: + + void closeWindow(); + + protected: + + void mouseReleaseEvent(QMouseEvent *); +}; + +} // End namespace; + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/kwin-styles/riscos/HelpButton.cpp b/kwin-styles/riscos/HelpButton.cpp new file mode 100644 index 00000000..a3d36668 --- /dev/null +++ b/kwin-styles/riscos/HelpButton.cpp @@ -0,0 +1,66 @@ +/* + RISC OS KWin client + + Copyright 2000 + Rik Hemsley + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "HelpButton.h" + +namespace RiscOS +{ + +/* XPM */ +static const char * const help_xpm[] = { +"12 12 3 1", +" c None", +". c #FFFFFF", +"+ c #000000", +" . ++++ . ", +" .+....+. ", +" +......+ ", +"..+......+..", +" +......+ ", +" +......+ ", +" .+....+. ", +" . ++ + . ", +" + ++ ", +" ++ + ", +" + ++ ", +" ++ "}; + +HelpButton::HelpButton(QWidget *parent) + : Button(parent, i18n("Help")) +{ + setPixmap(QPixmap((const char **)help_xpm)); +} + +void HelpButton::mouseReleaseEvent(QMouseEvent *e) +{ + Button::mouseReleaseEvent(e); + + if (!rect().contains(e->pos())) + return; + + emit(help()); +} + +} // End namespace; + +// vim:ts=2:sw=2:tw=78 +#include "HelpButton.moc" diff --git a/kwin-styles/riscos/HelpButton.h b/kwin-styles/riscos/HelpButton.h new file mode 100644 index 00000000..89d76453 --- /dev/null +++ b/kwin-styles/riscos/HelpButton.h @@ -0,0 +1,52 @@ +/* + RISC OS KWin client + + Copyright 2000 + Rik Hemsley + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef RISC_OS_HELP_BUTTON_H +#define RISC_OS_HELP_BUTTON_H + +#include "Button.h" + +namespace RiscOS +{ + +class HelpButton : public Button +{ + Q_OBJECT + + public: + + HelpButton(QWidget *parent); + + signals: + + void help(); + + protected: + + void mouseReleaseEvent(QMouseEvent *); +}; + +} // End namespace; + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/kwin-styles/riscos/IconifyButton.cpp b/kwin-styles/riscos/IconifyButton.cpp new file mode 100644 index 00000000..760194f5 --- /dev/null +++ b/kwin-styles/riscos/IconifyButton.cpp @@ -0,0 +1,66 @@ +/* + RISC OS KWin client + + Copyright 2000 + Rik Hemsley + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "IconifyButton.h" + +namespace RiscOS +{ + +/* XPM */ +static const char * const iconify_xpm[] = { +"12 12 3 1", +" c None", +". c #000000", +"+ c #FFFFFF", +" ", +" ", +" ", +" ", +" .......... ", +".++++++++++.", +".++++++++++.", +" .......... ", +" ", +" ", +" ", +" "}; + +IconifyButton::IconifyButton(QWidget *parent) + : Button(parent, i18n("Minimize")) +{ + setPixmap(QPixmap((const char **)iconify_xpm)); +} + +void IconifyButton::mouseReleaseEvent(QMouseEvent *e) +{ + Button::mouseReleaseEvent(e); + + if (!rect().contains(e->pos())) + return; + + emit(iconify()); +} + +} // End namespace; + +// vim:ts=2:sw=2:tw=78 +#include "IconifyButton.moc" diff --git a/kwin-styles/riscos/IconifyButton.h b/kwin-styles/riscos/IconifyButton.h new file mode 100644 index 00000000..9c940713 --- /dev/null +++ b/kwin-styles/riscos/IconifyButton.h @@ -0,0 +1,52 @@ +/* + RISC OS KWin client + + Copyright 2000 + Rik Hemsley + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef RISC_OS_ICONIFY_BUTTON_H +#define RISC_OS_ICONIFY_BUTTON_H + +#include "Button.h" + +namespace RiscOS +{ + +class IconifyButton : public Button +{ + Q_OBJECT + + public: + + IconifyButton(QWidget *parent); + + signals: + + void iconify(); + + protected: + + void mouseReleaseEvent(QMouseEvent *); +}; + +} // End namespace; + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/kwin-styles/riscos/LowerButton.cpp b/kwin-styles/riscos/LowerButton.cpp new file mode 100644 index 00000000..a14c6149 --- /dev/null +++ b/kwin-styles/riscos/LowerButton.cpp @@ -0,0 +1,66 @@ +/* + RISC OS KWin client + + Copyright 2000 + Rik Hemsley + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include "LowerButton.h" + +namespace RiscOS +{ + +/* XPM */ +static const char * const lower_xpm[] = { +"12 12 3 1", +" c None", +". c #000000", +"+ c #FFFFFF", +" ", +" ..... ", +".+++++. ", +".+++++. ", +".+++++..... ", +".++++.+++++.", +".++++.+++++.", +" .....+++++.", +" .+++++.", +" .+++++.", +" ..... ", +" "}; + +LowerButton::LowerButton(QWidget *parent) + : Button(parent, i18n("Keep below others")) +{ + setPixmap(QPixmap((const char **)lower_xpm)); +} + +void LowerButton::mouseReleaseEvent(QMouseEvent *e) +{ + Button::mouseReleaseEvent(e); + + if (!rect().contains(e->pos())) + return; + + emit(lower()); +} + +} // End namespace; + +// vim:ts=2:sw=2:tw=78 +#include "LowerButton.moc" diff --git a/kwin-styles/riscos/LowerButton.h b/kwin-styles/riscos/LowerButton.h new file mode 100644 index 00000000..ec5ab474 --- /dev/null +++ b/kwin-styles/riscos/LowerButton.h @@ -0,0 +1,52 @@ +/* + RISC OS KWin client + + Copyright 2000 + Rik Hemsley + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#ifndef RISC_OS_LOWER_BUTTON_H +#define RISC_OS_LOWER_BUTTON_H + +#include "Button.h" + +namespace RiscOS +{ + +class LowerButton : public Button +{ + Q_OBJECT + + public: + + LowerButton(QWidget *parent); + + signals: + + void lower(); + + protected: + + void mouseReleaseEvent(QMouseEvent *); +}; + +} // End namespace; + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/kwin-styles/riscos/Makefile.am b/kwin-styles/riscos/Makefile.am new file mode 100644 index 00000000..2a7d9764 --- /dev/null +++ b/kwin-styles/riscos/Makefile.am @@ -0,0 +1,39 @@ +AUTOMAKE_OPTIONS = foreign + +KDE_CXXFLAGS = -DQT_PLUGIN + +INCLUDES = $(all_includes) + +kwindir = $(kde_datadir)/kwin/ +kwin_DATA = riscos.desktop + +noinst_HEADERS = AboveButton.h \ + Button.h \ + CloseButton.h \ + HelpButton.h \ + IconifyButton.h \ + LowerButton.h \ + Manager.h \ + MaximiseButton.h \ + Palette.h \ + Static.h \ + StickyButton.h + +kde_module_LTLIBRARIES = kwin3_riscos.la +kwin3_riscos_la_SOURCES = AboveButton.cpp \ + Button.cpp \ + CloseButton.cpp \ + HelpButton.cpp \ + IconifyButton.cpp \ + LowerButton.cpp \ + Manager.cpp \ + MaximiseButton.cpp \ + Static.cpp \ + StickyButton.cpp + +kwin3_riscos_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module +kwin3_riscos_la_LIBADD = $(LIB_KDEUI) -lkdecorations +kwin3_riscos_la_METASOURCES = AUTO + +EXTRA_DIST = $(kwin_DATA) + diff --git a/kwin-styles/riscos/Manager.cpp b/kwin-styles/riscos/Manager.cpp new file mode 100644 index 00000000..a890ac63 --- /dev/null +++ b/kwin-styles/riscos/Manager.cpp @@ -0,0 +1,767 @@ +/* + RISC OS KWin client + + Copyright 2000 + Rik Hemsley + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public + License as published by the Free Software Foundation; either + version 2 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02110-1301, USA. +*/ + +#include // for usleep +#include // for usleep on non-linux platforms +#include // for sin and cos + +#include +#include +#include +#include +#include + +#include + +#include "Manager.h" +#include "Static.h" +#include "AboveButton.h" +#include "CloseButton.h" +#include "HelpButton.h" +#include "IconifyButton.h" +#include "LowerButton.h" +#include "MaximiseButton.h" +#include "StickyButton.h" + +extern "C" +{ + KDE_EXPORT KDecorationFactory* create_factory() + { + return new RiscOS::Factory(); + } +} + + +namespace RiscOS +{ + +Manager::Manager(KDecorationBridge *bridge, + KDecorationFactory *factory) + : KDecoration(bridge, factory), + topLayout_ (NULL), + titleLayout_ (NULL), + titleSpacer_ (NULL) +{ +} + +Manager::~Manager() +{ +} + +void Manager::init() +{ + createMainWidget(WNoAutoErase); + + widget()->installEventFilter(this); + widget()->setBackgroundMode(NoBackground); + + leftButtonList_.setAutoDelete(true); + rightButtonList_.setAutoDelete(true); + + resetLayout(); +} + +bool Manager::eventFilter(QObject *o, QEvent *e) +{ + if (o != widget()) return false; + switch (e->type()) + { + case QEvent::Resize: + resizeEvent(static_cast(e)); + return true; + case QEvent::Paint: + paintEvent(static_cast(e)); + return true; + case QEvent::MouseButtonDblClick: + mouseDoubleClickEvent(static_cast(e)); + return true; + case QEvent::MouseButtonPress: + processMousePressEvent(static_cast(e)); + return true; + case QEvent::Wheel: + wheelEvent( static_cast< QWheelEvent* >( e )); + return true; + case QEvent::MouseButtonRelease: + return false; + case QEvent::Show: + return false; + case QEvent::MouseMove: + return false; + case QEvent::Enter: + return false; + case QEvent::Leave: + return false; + case QEvent::Move: + return false; + default: + return false; + } +} + +void Manager::reset(unsigned long /*changed*/) +{ + resetLayout(); +} + +void Manager::borders(int &left, int &right, int &top, int &bottom) const +{ + left = right = 1; + top = Static::instance()->titleHeight(); + bottom = isResizable() ? Static::instance()->resizeHeight() : 1; +} + +void Manager::resize(const QSize &s) +{ + widget()->resize(s); +} + +QSize Manager::minimumSize() const +{ + return widget()->minimumSize(); +} + +void Manager::activeChange() +{ + updateTitleBuffer(); + widget()->repaint(); + emit(activeChanged(isActive())); +} + +void Manager::captionChange() +{ + updateTitleBuffer(); + widget()->repaint(); +} + +void Manager::iconChange() +{ +} + +void Manager::maximizeChange() +{ + emit(maximizeChanged(maximizeMode() == MaximizeFull)); +} + +void Manager::desktopChange() +{ +} + +void Manager::shadeChange() +{ +} + +void Manager::paintEvent(QPaintEvent *e) +{ + QPainter p(widget()); + + QRect r(e->rect()); + + bool intersectsLeft = r.intersects(QRect(0, 0, 1, height())); + + bool intersectsRight = + r.intersects(QRect(width() - 1, 0, width(), height())); + + if (intersectsLeft || intersectsRight) + { + p.setPen(Qt::black); + + if (intersectsLeft) + p.drawLine(0, r.top(), 0, r.bottom()); + + if (intersectsRight) + p.drawLine(width() - 1, r.top(), width() - 1, r.bottom()); + } + + Static * s = Static::instance(); + + bool active = isActive(); + + // Title bar. + + QRect tr = titleSpacer_->geometry(); + bitBlt(widget(), tr.topLeft(), &titleBuf_); + + // Resize bar. + + if (isResizable()) + { + int rbt = height() - Static::instance()->resizeHeight(); // Resize bar top + + bitBlt(widget(), 0, rbt, &(s->resize(active))); + bitBlt(widget(), 30, rbt, &(s->resizeMidLeft(active))); + + p.drawTiledPixmap(32, rbt, width() - 34, + Static::instance()->resizeHeight(), + s->resizeMidMid(active)); + + bitBlt(widget(), width() - 32, rbt, &(s->resizeMidRight(active))); + bitBlt(widget(), width() - 30, rbt, &(s->resize(active))); + } + else + p.drawLine(1, height() - 1, width() - 2, height() - 1); +} + +void Manager::resizeEvent(QResizeEvent*) +{ + updateButtonVisibility(); + updateTitleBuffer(); + widget()->repaint(); +} + +void Manager::updateButtonVisibility() +{ +#if 0 + enum SizeProblem = { None, Small, Medium, Big }; + SizeProblem sizeProblem = None; + + if (width() < 80) sizeProblem = Big; + else if (width() < 100) sizeProblem = Medium; + else if (width() < 180) sizeProblem = Small; + + switch (sizeProblem) { + + case Small: + above_ ->hide(); + lower_ ->hide(); + sticky_ ->hide(); + help_ ->hide(); + iconify_ ->show(); + maximise_ ->hide(); + close_ ->show(); + break; + + case Medium: + above_ ->hide(); + lower_ ->hide(); + sticky_ ->hide(); + help_ ->hide(); + iconify_ ->hide(); + maximise_ ->hide(); + close_ ->show(); + break; + + case Big: + above_ ->hide(); + lower_ ->hide(); + sticky_ ->hide(); + help_ ->hide(); + iconify_ ->hide(); + maximise_ ->hide(); + close_ ->hide(); + break; + + case None: + default: + above_ ->show(); + lower_ ->show(); + sticky_ ->show(); + if (providesContextHelp()) + help_->show(); + iconify_ ->show(); + maximise_ ->show(); + close_ ->show(); + break; + } + + layout()->activate(); +#endif +} + +void Manager::updateTitleBuffer() +{ + bool active = isActive(); + + Static * s = Static::instance(); + + QRect tr = titleSpacer_->geometry(); + + if (tr.width() == 0 || tr.height() == 0) + titleBuf_.resize(8, 8); + else + titleBuf_.resize(tr.size()); + + QPainter p(&titleBuf_); + + p.drawPixmap(0, 0, s->titleTextLeft(active)); + + p.drawTiledPixmap(3, 0, tr.width() - 6, Static::instance()->titleHeight(), + s->titleTextMid(active)); + + p.setPen(options()->color(KDecorationOptions::ColorFont, active)); + + p.setFont(options()->font(active)); + + p.drawText(4, 2, tr.width() - 8, Static::instance()->titleHeight() - 4, + AlignCenter, caption()); + + p.drawPixmap(tr.width() - 3, 0, s->titleTextRight(active)); +} + +KDecoration::Position Manager::mousePosition(const QPoint& p) const +{ + Position m = PositionCenter; + + // Look out for off-by-one errors here. + + if (isResizable()) + { + if (p.y() > (height() - (Static::instance()->resizeHeight() + 1))) + { + // Keep order ! + + if (p.x() >= (width() - 30)) + m = PositionBottomRight; + else if (p.x() <= 30) + m = PositionBottomLeft; + else + m = PositionBottom; + } + else + { + m = PositionCenter; + // Client::mousePosition(p); + } + } + else + { + m = PositionCenter; + // Client::mousePosition(p); + } + + return m; +} + +void Manager::mouseDoubleClickEvent(QMouseEvent *e) +{ + if (e->button() == LeftButton && titleSpacer_->geometry().contains(e->pos())) + titlebarDblClickOperation(); +} + +void Manager::wheelEvent(QWheelEvent *e) +{ + if (isSetShade() || titleLayout_->geometry().contains(e->pos()) ) + titlebarMouseWheelOperation( e->delta()); +} + +void Manager::paletteChange(const QPalette &) +{ + resetLayout(); +} + +void Manager::stickyChange(bool b) +{ + emit(stickyChanged(b)); +} + +void Manager::slotToggleSticky() +{ + toggleOnAllDesktops(); + emit(stickyChanged(isOnAllDesktops())); +} + +void Manager::slotAbove() +{ + setKeepAbove(!keepAbove()); +} + +void Manager::slotLower() +{ + setKeepBelow(!keepBelow()); +} + +void Manager::slotMaximizeClicked(ButtonState state) +{ +#if KDE_IS_VERSION(3, 3, 0) + maximize(state); +#else + switch (state) + { + case RightButton: + maximize(maximizeMode() ^ MaximizeHorizontal); + break; + + case MidButton: + maximize(maximizeMode() ^ MaximizeVertical); + break; + + case LeftButton: + default: + maximize(maximizeMode() == MaximizeFull ? MaximizeRestore + : MaximizeFull); + break; + } +#endif + emit(maximizeChanged(maximizeMode() == MaximizeFull)); +} + +bool Manager::animateMinimize(bool iconify) +{ + int style = Static::instance()->animationStyle(); + + switch (style) + { + case 1: + { + // Double twisting double back, with pike ;) + + if (!iconify) // No animation for restore. + return true; + + // Go away quick. + helperShowHide(false); + qApp->syncX(); + + QRect r = iconGeometry(); + + if (!r.isValid()) + return true; + + // Algorithm taken from Window Maker (http://www.windowmaker.org) + + int sx = geometry().x(); + int sy = geometry().y(); + int sw = width(); + int sh = height(); + int dx = r.x(); + int dy = r.y(); + int dw = r.width(); + int dh = r.height(); + + double steps = 12; + + double xstep = double((dx-sx)/steps); + double ystep = double((dy-sy)/steps); + double wstep = double((dw-sw)/steps); + double hstep = double((dh-sh)/steps); + + double cx = sx; + double cy = sy; + double cw = sw; + double ch = sh; + + double finalAngle = 3.14159265358979323846; + + double delta = finalAngle / steps; + + QPainter p(workspaceWidget()); + p.setRasterOp(Qt::NotROP); + + for (double angle = 0; ; angle += delta) + { + if (angle > finalAngle) + angle = finalAngle; + + double dx = (cw / 10) - ((cw / 5) * sin(angle)); + double dch = (ch / 2) * cos(angle); + double midy = cy + (ch / 2); + + QPoint p1(int(cx + dx), int(midy - dch)); + QPoint p2(int(cx + cw - dx), p1.y()); + QPoint p3(int(cx + dw + dx), int(midy + dch)); + QPoint p4(int(cx - dx), p3.y()); + + grabXServer(); + + p.drawLine(p1, p2); + p.drawLine(p2, p3); + p.drawLine(p3, p4); + p.drawLine(p4, p1); + + p.flush(); + + usleep(500); + + p.drawLine(p1, p2); + p.drawLine(p2, p3); + p.drawLine(p3, p4); + p.drawLine(p4, p1); + + ungrabXServer(); + + cx += xstep; + cy += ystep; + cw += wstep; + ch += hstep; + + if (angle >= finalAngle) + break; + } + } + break; + + case 2: + { + // KVirc style ? Maybe. For qwertz. + + if (!iconify) // No animation for restore. + return true; + + // Go away quick. + helperShowHide(false); + qApp->syncX(); + + int stepCount = 12; + + QRect r(geometry()); + + int dx = r.width() / (stepCount * 2); + int dy = r.height() / (stepCount * 2); + + QPainter p(workspaceWidget()); + p.setRasterOp(Qt::NotROP); + + for (int step = 0; step < stepCount; step++) + { + r.moveBy(dx, dy); + r.setWidth(r.width() - 2 * dx); + r.setHeight(r.height() - 2 * dy); + + grabXServer(); + + p.drawRect(r); + p.flush(); + usleep(200); + p.drawRect(r); + + ungrabXServer(); + } + } + break; + + + default: + { + QRect icongeom = iconGeometry(); + + if (!icongeom.isValid()) + return true; + + QRect wingeom = geometry(); + + QPainter p(workspaceWidget()); + + p.setRasterOp(Qt::NotROP); +#if 0 + if (iconify) + p.setClipRegion(QRegion(workspaceWidget()->rect()) - wingeom); +#endif + grabXServer(); + + p.drawLine(wingeom.bottomRight(), icongeom.bottomRight()); + p.drawLine(wingeom.bottomLeft(), icongeom.bottomLeft()); + p.drawLine(wingeom.topLeft(), icongeom.topLeft()); + p.drawLine(wingeom.topRight(), icongeom.topRight()); + + p.flush(); + + qApp->syncX(); + + usleep(30000); + + p.drawLine(wingeom.bottomRight(), icongeom.bottomRight()); + p.drawLine(wingeom.bottomLeft(), icongeom.bottomLeft()); + p.drawLine(wingeom.topLeft(), icongeom.topLeft()); + p.drawLine(wingeom.topRight(), icongeom.topRight()); + + ungrabXServer(); + } + break; + } + return true; +} + +void Manager::createTitle() +{ + leftButtonList_.clear(); + rightButtonList_.clear(); + + QString buttons; + + if (options()->customButtonPositions()) + buttons = options()->titleButtonsLeft() + "|" + + options()->titleButtonsRight(); + else + buttons = "XSH|IA"; + + QPtrList