diff options
Diffstat (limited to 'kwin-styles/riscos')
24 files changed, 2911 insertions, 0 deletions
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 <clushkou@gmx.net> + + 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 <clushkou@gmx.net> + + 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 <rik@kde.org> + + 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 <qtooltip.h> +#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 <rik@kde.org> + + 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 <qpixmap.h> +#include <qwidget.h> +#include <klocale.h> +#include <kdecoration.h> + +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 <rik@kde.org> + + 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 <rik@kde.org> + + 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 <rik@kde.org> + + 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 <rik@kde.org> + + 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 <rik@kde.org> + + 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 <rik@kde.org> + + 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 <rik@kde.org> + + 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 <rik@kde.org> + + 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 <rik@kde.org> + + 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 <unistd.h> // for usleep +#include <config.h> // for usleep on non-linux platforms +#include <math.h> // for sin and cos + +#include <qapplication.h> +#include <qimage.h> +#include <qlabel.h> +#include <qlayout.h> +#include <qpainter.h> + +#include <netwm.h> + +#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<QResizeEvent*>(e)); + return true; + case QEvent::Paint: + paintEvent(static_cast<QPaintEvent*>(e)); + return true; + case QEvent::MouseButtonDblClick: + mouseDoubleClickEvent(static_cast<QMouseEvent*>(e)); + return true; + case QEvent::MouseButtonPress: + processMousePressEvent(static_cast<QMouseEvent*>(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<Button> *buttonList = &leftButtonList_; + + for (unsigned int i = 0; i < buttons.length(); ++i) + { + Button * tb = NULL; + + switch (buttons[i].latin1()) + { + case 'S': // Sticky + tb = new StickyButton(widget()); + connect(this, SIGNAL(stickyChanged(bool)), + tb, SLOT(setOn(bool))); + connect(tb, SIGNAL(toggleSticky()), this, SLOT(slotToggleSticky())); + emit(stickyChanged(isOnAllDesktops())); + break; + + case 'H': // Help + if (providesContextHelp()) + { + tb = new HelpButton(widget()); + connect(tb, SIGNAL(help()), this, SLOT(showContextHelp())); + } + break; + + case 'I': // Minimize + if (isMinimizable()) + { + tb = new IconifyButton(widget()); + connect(tb, SIGNAL(iconify()), this, SLOT(minimize())); + } + break; + + case 'A': // Maximize + if (isMaximizable()) + { + tb = new MaximiseButton(widget()); + connect(tb, SIGNAL(maximizeClicked(ButtonState)), + this, SLOT(slotMaximizeClicked(ButtonState))); + connect(this, SIGNAL(maximizeChanged(bool)), + tb, SLOT(setOn(bool))); + emit(maximizeChanged(maximizeMode() == MaximizeFull)); + } + break; + + case 'F': // Above + tb = new AboveButton(widget()); + connect(tb, SIGNAL(above()), this, SLOT(slotAbove())); + break; + + case 'B': // Lower + tb = new LowerButton(widget()); + connect(tb, SIGNAL(lower()), this, SLOT(slotLower())); + break; + + case 'X': // Close + if (isCloseable()) + { + tb = new CloseButton(widget()); + connect(tb, SIGNAL(closeWindow()), this, SLOT(closeWindow())); + } + break; + + case '|': + buttonList = &rightButtonList_; + break; + } + + if (tb != NULL) + { + connect(this, SIGNAL(activeChanged(bool)), tb, SLOT(setActive(bool))); + buttonList->append(tb); + } + } + + for (QPtrListIterator<Button> it(leftButtonList_); it.current(); ++it) + { + it.current()->setAlignment(Button::Left); + titleLayout_->addWidget(it.current()); + } + + titleSpacer_ = new QSpacerItem(0, Static::instance()->titleHeight(), + QSizePolicy::Expanding, QSizePolicy::Fixed); + + titleLayout_->addItem(titleSpacer_); + + for (QPtrListIterator<Button> it(rightButtonList_); it.current(); ++it) + { + it.current()->setAlignment(Button::Right); + titleLayout_->addWidget(it.current()); + } +} + +void Manager::resetLayout() +{ + delete topLayout_; + topLayout_ = new QVBoxLayout(widget(), 0, 0); + topLayout_->setResizeMode(QLayout::FreeResize); + + titleLayout_ = new QBoxLayout(topLayout_, QBoxLayout::LeftToRight, 0, 0); + titleLayout_->setResizeMode(QLayout::FreeResize); + + createTitle(); + + QBoxLayout *midLayout = new QBoxLayout(topLayout_, QBoxLayout::LeftToRight, + 0, 0); + midLayout->setResizeMode(QLayout::FreeResize); + midLayout->addSpacing(1); + if (isPreview()) + midLayout->addWidget( + new QLabel(i18n("<center><b>RiscOS preview</b></center>"), widget())); + midLayout->addSpacing(1); + + if (isResizable()) + topLayout_->addSpacing(Static::instance()->resizeHeight()); + else + topLayout_->addSpacing(1); +} + +// -------------------- + +Factory::Factory() +{ + (void) RiscOS::Static::instance(); +} + +Factory::~Factory() +{ + delete RiscOS::Static::instance(); +} + +bool Factory::reset(unsigned long /*changed*/) +{ + RiscOS::Static::instance()->reset(); + return true; +} + +bool Factory::supports( Ability ability ) +{ + switch( ability ) + { + case AbilityAnnounceButtons: + case AbilityButtonOnAllDesktops: + case AbilityButtonHelp: + case AbilityButtonMinimize: + case AbilityButtonMaximize: + case AbilityButtonClose: + case AbilityButtonAboveOthers: + case AbilityButtonBelowOthers: + return true; + default: + return false; + }; +} + +KDecoration* Factory::createDecoration(KDecorationBridge *bridge) +{ + return new Manager(bridge, this); +} + +} // End namespace + +// vim:ts=2:sw=2:tw=78 +#include "Manager.moc" diff --git a/kwin-styles/riscos/Manager.h b/kwin-styles/riscos/Manager.h new file mode 100644 index 00000000..1d30b7a6 --- /dev/null +++ b/kwin-styles/riscos/Manager.h @@ -0,0 +1,123 @@ +/* + RISC OS KWin client + + Copyright 2000 + Rik Hemsley <rik@kde.org> + + 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_MANAGER_H +#define RISC_OS_MANAGER_H + +#include <qdict.h> +#include <kdecoration.h> +#include <kdecorationfactory.h> + +class QSpacerItem; +class QVBoxLayout; +class QBoxLayout; + +namespace RiscOS +{ + +class LowerButton; +class CloseButton; +class IconifyButton; +class MaximiseButton; +class StickyButton; +class HelpButton; +class Button; + +class Manager : public KDecoration +{ + Q_OBJECT + + public: + + Manager(KDecorationBridge*, KDecorationFactory*); + ~Manager(); + void init(); + bool eventFilter(QObject*, QEvent*); + void reset(unsigned long changed); + void borders(int&, int&, int&, int&) const; + void resize(const QSize&); + QSize minimumSize() const; + void activeChange(); + void captionChange(); + void iconChange(); + void maximizeChange(); + void desktopChange(); + void shadeChange(); + + signals: + + void maximizeChanged(bool); + void stickyChanged(bool); + void activeChanged(bool); + + public slots: + + void slotAbove(); + void slotLower(); + void slotMaximizeClicked(ButtonState); + void slotToggleSticky(); + + protected: + + KDecoration::Position mousePosition(const QPoint &) const; + void paletteChange(const QPalette &); + void activeChange(bool); + void stickyChange(bool); + void paintEvent(QPaintEvent *); + void resizeEvent(QResizeEvent *); + void mouseDoubleClickEvent(QMouseEvent *); + void wheelEvent(QWheelEvent *e); + bool animateMinimize(bool); + void updateButtonVisibility(); + void updateTitleBuffer(); + + void createTitle(); + void resetLayout(); + + private: + + QVBoxLayout *topLayout_; + QBoxLayout *titleLayout_; + QSpacerItem *titleSpacer_; + + QPixmap titleBuf_; + QPtrList<Button> leftButtonList_; + QPtrList<Button> rightButtonList_; +}; + +class Factory : public QObject, public KDecorationFactory +{ + Q_OBJECT + + public: + Factory(); + ~Factory(); + virtual bool reset(unsigned long changed); + virtual KDecoration* createDecoration(KDecorationBridge*); + virtual bool supports( Ability ability ); +}; + +} // End namespace + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/kwin-styles/riscos/MaximiseButton.cpp b/kwin-styles/riscos/MaximiseButton.cpp new file mode 100644 index 00000000..b82f2867 --- /dev/null +++ b/kwin-styles/riscos/MaximiseButton.cpp @@ -0,0 +1,98 @@ +/* + RISC OS KWin client + + Copyright 2000 + Rik Hemsley <rik@kde.org> + + 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 "MaximiseButton.h" + +#include <qtooltip.h> + +namespace RiscOS +{ + +/* XPM */ +static const char * const maximise_xpm[] = { +"12 12 3 1", +" c None", +". c #000000", +"+ c #FFFFFF", +" ", +" ........ ", +" .++++++++. ", +" .++++++++. ", +" .++++++++. ", +" .++++++++. ", +" .++++++++. ", +" .++++++++. ", +" .++++++++. ", +" .++++++++. ", +" ........ ", +" "}; + +/* XPM */ +static const char * const unmaximise_xpm[] = { +"12 12 3 1", +" c None", +". c #000000", +"+ c #FFFFFF", +" ", +" ", +" ...... ", +" .++++++. ", +" .++++++. ", +" .++++++. ", +" .++++++. ", +" .++++++. ", +" .++++++. ", +" ...... ", +" ", +" "}; + +MaximiseButton::MaximiseButton(QWidget * parent) + : Button(parent, i18n("Maximize"), + (ButtonState)(LeftButton|MidButton|RightButton)), + on_(false) +{ + setPixmap(QPixmap((const char **)maximise_xpm)); +} + +void MaximiseButton::setOn(bool on) +{ + on_ = on; + setPixmap(on_ ? QPixmap((const char **)unmaximise_xpm) + : QPixmap((const char **)maximise_xpm)); + repaint(); + QToolTip::remove(this); + QToolTip::add(this, on_ ? i18n("Restore") : i18n("Maximize")); +} + +void MaximiseButton::mouseReleaseEvent(QMouseEvent *e) +{ + Button::mouseReleaseEvent(e); + + if (!rect().contains(e->pos())) + return; + emit(maximizeClicked(lastButton_)); +} + +} // End namespace + +// vim:ts=2:sw=2:tw=78 +#include "MaximiseButton.moc" diff --git a/kwin-styles/riscos/MaximiseButton.h b/kwin-styles/riscos/MaximiseButton.h new file mode 100644 index 00000000..7da4bc0a --- /dev/null +++ b/kwin-styles/riscos/MaximiseButton.h @@ -0,0 +1,60 @@ +/* + RISC OS KWin client + + Copyright 2000 + Rik Hemsley <rik@kde.org> + + 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_MAXIMISE_BUTTON_H +#define RISC_OS_MAXIMISE_BUTTON_H + +#include "Button.h" + +namespace RiscOS +{ + +class MaximiseButton : public Button +{ + Q_OBJECT + + public: + + MaximiseButton(QWidget *parent); + + public slots: + + void setOn(bool); + + signals: + + void maximizeClicked(ButtonState); + + protected: + + void mouseReleaseEvent(QMouseEvent *); + + private: + + bool on_; +}; + +} // End namespace + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/kwin-styles/riscos/Palette.h b/kwin-styles/riscos/Palette.h new file mode 100644 index 00000000..e13457a6 --- /dev/null +++ b/kwin-styles/riscos/Palette.h @@ -0,0 +1,69 @@ +/* + RISC OS KWin client + + Copyright 2000 + Rik Hemsley <rik@kde.org> + + 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_PALETTE_H +#define RISC_OS_PALETTE_H + +#include <qmemarray.h> +#include <qglobal.h> + +namespace RiscOS +{ + +class Palette +{ + public: + + Palette() + { + data_.resize(8); + + data_[0] = 0xFFFFFFFF; + data_[1] = 0xFFDCDCDC; + data_[2] = 0xFFC3C3C3; + data_[3] = 0xFFA0A0A0; + data_[4] = 0xFF808080; + data_[5] = 0xFF585858; + data_[6] = 0xFF303030; + data_[7] = 0xFF000000; + } + + QRgb& operator [] (int idx) + { + return data_[idx]; + } + + QRgb operator [] (int idx) const + { + return data_[idx]; + } + + private: + + QMemArray<QRgb> data_; +}; + +} // End namespace + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/kwin-styles/riscos/README b/kwin-styles/riscos/README new file mode 100644 index 00000000..04ebd85d --- /dev/null +++ b/kwin-styles/riscos/README @@ -0,0 +1,90 @@ +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/kwin-styles/riscos/Static.cpp b/kwin-styles/riscos/Static.cpp new file mode 100644 index 00000000..675cdfc1 --- /dev/null +++ b/kwin-styles/riscos/Static.cpp @@ -0,0 +1,540 @@ +/* + RISC OS KWin client + + Copyright 2000 + Rik Hemsley <rik@kde.org> + + 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. +*/ + +// for enable-final +#ifdef Bool +#undef Bool +#endif + +#include <qimage.h> +#include <qpixmap.h> +#include <qpainter.h> +#include <qptrlist.h> + +#include <kdecoration.h> + +// #include <ksimpleconfig.h> + +#include "Static.h" + +namespace RiscOS +{ + +/* XPM */ +static const char * const texture_xpm[] = { +"64 12 3 1", +" c None", +"a c #000000", +"b c #FFFFFF", +" b b b b b b b a b ", +" b aa b aaa aaa b a b aab bb a ", +" b b a b b b b aa b b aa ", +" b b b a a b b b b aa ab ab ", +" b b b b b b b ba ", +" aaa aaa aa b b b b b b ", +" b b bb a b aa b a a aaa a b ", +" b b b b b a b b b b b", +" b b b b a a b b aa b baa ", +" a b a bb aa bb aa aaa b aa a ", +" a a aab b b aa aab a b ", +" b a b b aaa a b bb b b b b"}; + +Static* Static::instance_ = NULL; + +Static::Static() +{ + instance_ = this; + _init(); +} + +Static::~Static() +{ + instance_ = NULL; +} + +const QPixmap& Static::titleTextLeft(bool active) const +{ + return active ? aTitleTextLeft_ : iTitleTextLeft_; +} + +const QPixmap& Static::titleTextRight(bool active) const +{ + return active ? aTitleTextRight_ : iTitleTextRight_; +} + +const QPixmap& Static::resizeMidLeft(bool active) const +{ + return active ? aResizeMidLeft_ : iResizeMidLeft_; +} + +const QPixmap& Static::resizeMidRight(bool active) const +{ + return active ? aResizeMidRight_ : iResizeMidRight_; +} + +const QPixmap& Static::titleTextMid(bool active) const +{ + return active ? aTitleTextMid_ : iTitleTextMid_; +} + +const QPixmap& Static::resizeMidMid(bool active) const +{ + return active ? aResizeMid_ : iResizeMid_; +} + +const QPixmap& Static::resize(bool active) const +{ + return active ? aResize_ : iResize_; +} + +int Static::animationStyle() const +{ + return animationStyle_; +} + +int Static::titleHeight() const +{ + return titleHeight_; +} + +int Static::resizeHeight() const +{ + return resizeHeight_; +} + +void Static::_drawBorder(QPixmap &pix, int w, int h) +{ + // 0111111113 + // 1122222235 + // 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(); + + painter_.resetXForm(); +} + +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 Static::_init() +{ + hicolour_ = QPixmap::defaultDepth() > 8; + animationStyle_ = 0; + updatePixmaps(); +} + +void Static::reset() +{ + updatePixmaps(); +// Workspace::self()->slotResetAllClientsDelayed(); +} + +void Static::updatePixmaps() +{ + _initSizes(); + + _resizeAllPixmaps(); + + _blankAllPixmaps(); + + if (hicolour_) + { + _initPalettes(); + _initTextures(); + } + + _drawTitleTextAreaSides(); + + _drawResizeCentralAreaSides(); + + _drawTitleTextAreaBackground(); + + _drawResizeCentralAreaBackground(); + + _drawResizeHandles(); + + _drawButtonBackgrounds(); +} + +void Static::_createTexture(QPixmap &px, int t, bool active) +{ + const QImage texture(QPixmap((const char **)texture_xpm).convertToImage()); + const QRgb w(qRgb(255, 255, 255)); + const QRgb b(qRgb(0, 0, 0)); + + QColor c(KDecoration::options()->color(KDecoration::ColorType(t), active)); + + QRgb mid (c.rgb()); + QRgb light (c.light(110).rgb()); + QRgb dark (c.dark(110).rgb()); + + QRgb* data(reinterpret_cast<QRgb *>(texture.bits())); + + for (int x = 0; x < 64*12; x++) + if (data[x] == w) + data[x] = light; + else if (data[x] == b) + data[x] = dark; + else + data[x] = mid; + + px.convertFromImage(texture); +} + +const QPixmap& Static::buttonBase(bool active, bool down) const +{ + if (active) + return down ? aButtonDown_ : aButtonUp_; + else + return down ? iButtonDown_ : iButtonUp_; +} + +void Static::_initSizes() +{ + QFont f(KDecoration::options()->font(true)); // XXX false doesn't work right at the moment + + QFontMetrics fm(f); + + int h = fm.height(); + + titleHeight_ = h + 6; + + if (titleHeight_ < 20) + titleHeight_ = 20; + + buttonSize_ = titleHeight_ - 1; + + resizeHeight_ = 10; +} + +void Static::_resizeAllPixmaps() +{ + aResize_ .resize(30, resizeHeight_); + iResize_ .resize(30, resizeHeight_); + aTitleTextLeft_ .resize( 3, titleHeight_); + aTitleTextRight_.resize( 3, titleHeight_); + iTitleTextLeft_ .resize( 3, titleHeight_); + iTitleTextRight_.resize( 3, titleHeight_); + aTitleTextMid_ .resize(64, titleHeight_); + iTitleTextMid_ .resize(64, titleHeight_); + aResizeMidLeft_ .resize( 3, resizeHeight_); + aResizeMidRight_.resize( 3, resizeHeight_); + iResizeMidLeft_ .resize( 3, resizeHeight_); + iResizeMidRight_.resize( 3, resizeHeight_); + aResizeMid_ .resize(64, resizeHeight_); + iResizeMid_ .resize(64, resizeHeight_); + + aButtonUp_ .resize(buttonSize_, buttonSize_); + iButtonUp_ .resize(buttonSize_, buttonSize_); + aButtonDown_ .resize(buttonSize_, buttonSize_); + iButtonDown_ .resize(buttonSize_, buttonSize_); +} + +void Static::_blankAllPixmaps() +{ + aResize_ .fill(Qt::black); + iResize_ .fill(Qt::black); + aTitleTextLeft_ .fill(Qt::black); + aTitleTextRight_.fill(Qt::black); + iTitleTextLeft_ .fill(Qt::black); + iTitleTextRight_.fill(Qt::black); + aTitleTextMid_ .fill(Qt::black); + iTitleTextMid_ .fill(Qt::black); + aResizeMidLeft_ .fill(Qt::black); + aResizeMidRight_.fill(Qt::black); + iResizeMidLeft_ .fill(Qt::black); + iResizeMidRight_.fill(Qt::black); + aResizeMid_ .fill(Qt::black); + iResizeMid_ .fill(Qt::black); + aButtonUp_ .fill(Qt::black); + iButtonUp_ .fill(Qt::black); + aButtonDown_ .fill(Qt::black); + iButtonDown_ .fill(Qt::black); +} + +void Static::_initPalettes() +{ + const KDecorationOptions* options = KDecoration::options(); + setPalette(aButPal_, options->color(KDecoration::ColorButtonBg, true)); + setPalette(iButPal_, options->color(KDecoration::ColorButtonBg, false)); + + setPalette(aTitlePal_, options->color(KDecoration::ColorTitleBar, true)); + setPalette(iTitlePal_, options->color(KDecoration::ColorTitleBar, false)); + + setPalette(aResizePal_, options->color(KDecoration::ColorTitleBar, true)); + setPalette(iResizePal_, options->color(KDecoration::ColorTitleBar, false)); +} + +void Static::_initTextures() +{ + _createTexture(aTexture_, KDecoration::ColorTitleBar, true); + _createTexture(iTexture_, KDecoration::ColorTitleBar, false); + _createTexture(abTexture_, KDecoration::ColorButtonBg, true); + _createTexture(ibTexture_, KDecoration::ColorButtonBg, false); +} + +void Static::_drawTitleTextAreaSides() +{ + QPixmap temp(4, titleHeight_); + temp.fill(Qt::black); + + transx = transy = 0.0; + + palette_ = aTitlePal_; + down_ = false; + + _drawBorder(temp, 4, titleHeight_ - 2); + + painter_.begin(&aTitleTextLeft_); + painter_.drawPixmap(1, 1, temp, 0, 1); + painter_.end(); + + painter_.begin(&aTitleTextRight_); + painter_.drawPixmap(0, 1, temp, 2, 1); + painter_.end(); + + palette_ = iTitlePal_; + _drawBorder(temp, 4, titleHeight_ - 2); + + painter_.begin(&iTitleTextLeft_); + painter_.drawPixmap(1, 1, temp, 0, 1); + painter_.end(); + + painter_.begin(&iTitleTextRight_); + painter_.drawPixmap(0, 1, temp, 2, 1); + painter_.end(); +} + +void Static::_drawResizeCentralAreaSides() +{ + QPixmap temp(4, resizeHeight_); + temp.fill(Qt::black); + + transy = 1.0; + + palette_ = aResizePal_; + + _drawBorder(temp, 4, resizeHeight_ - 3); + + painter_.begin(&aResizeMidLeft_); + painter_.drawPixmap(0, 1, temp, 0, 1); + painter_.end(); + + painter_.begin(&aResizeMidRight_); + painter_.drawPixmap(0, 1, temp, 2, 1); + painter_.end(); + + palette_ = iResizePal_; + _drawBorder(temp, 4, resizeHeight_ - 3); + + painter_.begin(&iResizeMidLeft_); + painter_.drawPixmap(0, 1, temp, 0, 1); + painter_.end(); + + painter_.begin(&iResizeMidRight_); + painter_.drawPixmap(0, 1, temp, 2, 1); + painter_.end(); +} + +void Static::_drawTitleTextAreaBackground() +{ + QPixmap temp(70, titleHeight_); + temp.fill(Qt::black); + + transx = transy = 0.0; + + palette_ = aTitlePal_; + _drawBorder(temp, 70, titleHeight_ - 3); + + painter_.begin(&aTitleTextMid_); + painter_.drawPixmap(0, 1, temp, 2, 0); + if (hicolour_) + painter_.drawTiledPixmap(0, 4, 64, titleHeight_ - 8, aTexture_); + painter_.end(); + + palette_ = iTitlePal_; + _drawBorder(temp, 70, titleHeight_ - 3); + + painter_.begin(&iTitleTextMid_); + painter_.drawPixmap(0, 1, temp, 2, 0); + if (hicolour_) + painter_.drawTiledPixmap(0, 4, 64, titleHeight_ - 8, iTexture_); + painter_.end(); +} + +void Static::_drawResizeCentralAreaBackground() +{ + QPixmap temp(70, titleHeight_); + temp.fill(Qt::black); + + transy = 1.0; + + palette_ = aResizePal_; + _drawBorder(temp, 70, resizeHeight_ - 3); + + painter_.begin(&aResizeMid_); + painter_.drawPixmap(0, 0, temp, 2, 0); + if (hicolour_) + painter_.drawTiledPixmap(0, 4, 64, resizeHeight_ - 8, aTexture_); + painter_.end(); + + palette_ = iResizePal_; + _drawBorder(temp, 70, 7); + + painter_.begin(&iResizeMid_); + painter_.drawPixmap(0, 0, temp, 2, 0); + if (hicolour_) + painter_.drawTiledPixmap(0, 4, 64, resizeHeight_ - 8, iTexture_); + painter_.end(); +} + +void Static::_drawResizeHandles() +{ + transx = transy = 1.0; + + down_ = false; + + palette_ = aResizePal_; + _drawBorder(aResize_, 28, resizeHeight_ - 3); + + if (hicolour_) + { + painter_.begin(&aResize_); + painter_.drawTiledPixmap(4, 4, 20, resizeHeight_ - 8, aTexture_); + painter_.end(); + } + + palette_ = iResizePal_; + _drawBorder(iResize_, 28, resizeHeight_ - 3); + + if (hicolour_) + { + painter_.begin(&iResize_); + painter_.drawTiledPixmap(4, 4, 20, resizeHeight_ - 8, iTexture_); + painter_.end(); + } +} + +void Static::_drawButtonBackgrounds() +{ + buttonSize_ -= 2; + + down_ = false; + transx = 0.0; + transy = 1.0; + palette_ = aButPal_; + _drawBorder(aButtonUp_, buttonSize_, buttonSize_); + down_ = true; + _drawBorder(aButtonDown_, buttonSize_, buttonSize_); + + palette_ = iButPal_; + _drawBorder(iButtonDown_, buttonSize_, buttonSize_); + down_ = false; + _drawBorder(iButtonUp_, buttonSize_, buttonSize_); + + painter_.begin(&aButtonUp_); + + if (hicolour_) + painter_.drawTiledPixmap(2, 4, buttonSize_ - 4, buttonSize_ - 5, + abTexture_); + + painter_.end(); + + painter_.begin(&iButtonUp_); + if (hicolour_) + painter_.drawTiledPixmap(2, 4, buttonSize_ - 4, buttonSize_ - 5, + ibTexture_); + + painter_.end(); +} + +} // End namespace + +// vim:ts=2:sw=2:tw=78 + diff --git a/kwin-styles/riscos/Static.h b/kwin-styles/riscos/Static.h new file mode 100644 index 00000000..8a01d03b --- /dev/null +++ b/kwin-styles/riscos/Static.h @@ -0,0 +1,134 @@ +/* + RISC OS KWin client + + Copyright 2000 + Rik Hemsley <rik@kde.org> + + 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_STATIC_H +#define RISC_OS_STATIC_H + +#include <qimage.h> +#include <qpixmap.h> +#include <qpainter.h> +#include <qstringlist.h> + +#include "Palette.h" + +namespace RiscOS +{ + +enum SymbolType { Lower, Close, Iconify, Max, Unmax }; + +class Static +{ + public: + + Static(); + + ~Static(); + + static Static* instance() + { + if (instance_ == 0) + new Static; + + return instance_; + } + + void reset(); + void updatePixmaps(); + + const QPixmap& titleTextLeft(bool active) const; + const QPixmap& titleTextRight(bool active) const; + const QPixmap& resizeMidLeft(bool active) const; + const QPixmap& resizeMidRight(bool active) const; + const QPixmap& titleTextMid(bool active) const; + const QPixmap& resizeMidMid(bool active) const; + const QPixmap& buttonBase(bool active, bool down) const; + const QPixmap& resize(bool active) const; + + int animationStyle() const; + int titleHeight() const; + int resizeHeight() const; + + private: + + void _init(); + + void _drawBorder(QPixmap&, int, int); + void _createTexture(QPixmap&, int, bool); + + void _initSizes(); + + void _resizeAllPixmaps(); + void _blankAllPixmaps(); + + void _initPalettes(); + void _initTextures(); + + void _drawTitleTextAreaSides(); + void _drawResizeCentralAreaSides(); + void _drawTitleTextAreaBackground(); + void _drawResizeCentralAreaBackground(); + void _drawResizeHandles(); + void _drawButtonBackgrounds(); + + static Static *instance_; + + Palette + aTitlePal_, + iTitlePal_, + aResizePal_, + iResizePal_, + aButPal_, + iButPal_; + + QPixmap + aButtonUp_, iButtonUp_, + aButtonDown_, iButtonDown_, + aResize_, iResize_, + aResizeDown_, iResizeDown_, + aTitleTextLeft_, iTitleTextLeft_, + aTitleTextRight_, iTitleTextRight_, + aTitleTextMid_, iTitleTextMid_, + aResizeMidLeft_, iResizeMidLeft_, + aResizeMidRight_, iResizeMidRight_, + aResizeMid_, iResizeMid_; + + QPixmap aTexture_, iTexture_, abTexture_, ibTexture_; + + QPainter painter_; + bool down_; + Palette palette_; + double transx, transy; + + int animationStyle_; + + int titleHeight_; + int buttonSize_; + int resizeHeight_; + + bool hicolour_; +}; + +} // End namespace + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/kwin-styles/riscos/StickyButton.cpp b/kwin-styles/riscos/StickyButton.cpp new file mode 100644 index 00000000..808f04c7 --- /dev/null +++ b/kwin-styles/riscos/StickyButton.cpp @@ -0,0 +1,99 @@ +/* + RISC OS KWin client + + Copyright 2000 + Rik Hemsley <rik@kde.org> + + 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 "StickyButton.h" + +#include <qtooltip.h> + +namespace RiscOS +{ + +/* XPM */ +static const char * const unsticky_xpm[] = { +"12 12 3 1", +" c None", +". c #000000", +"+ c #FFFFFF", +" ... ", +" .+++. ", +" .+++. ", +" .+++. ", +" .+++. ", +" .+++++. ", +" .+++++++. ", +".+++++++++. ", +".....+..... ", +" .+. ", +" .+. ", +" . "}; + +/* XPM */ +static const char * const sticky_xpm[] = { +"12 12 3 1", +" c None", +". c #000000", +"+ c #FFFFFF", +" . ", +" .+. ", +" .+++. ", +" .+++++.", +" ....+++++. ", +" .++++++. ", +" .++++. ", +" .+++. ", +" .+..+. ", +" .+. .. ", +".+. . ", +".. "}; + + +StickyButton::StickyButton(QWidget *parent) + : Button(parent, i18n("On all desktops")), on_(false) +{ + setPixmap(QPixmap((const char **)sticky_xpm)); +} + +void StickyButton::setOn(bool on) +{ + on_ = on; + setPixmap(on_ ? QPixmap((const char **)unsticky_xpm) : + QPixmap((const char **)sticky_xpm)); + repaint(); + QToolTip::remove(this); + QToolTip::add(this, on_ ? i18n("Not on all desktops") + : i18n("On all desktops")); +} + +void StickyButton::mouseReleaseEvent(QMouseEvent *e) +{ + Button::mouseReleaseEvent(e); + + if (!rect().contains(e->pos())) + return; + + emit(toggleSticky()); +} + +} // End namespace + +// vim:ts=2:sw=2:tw=78 +#include "StickyButton.moc" diff --git a/kwin-styles/riscos/StickyButton.h b/kwin-styles/riscos/StickyButton.h new file mode 100644 index 00000000..fb7746ae --- /dev/null +++ b/kwin-styles/riscos/StickyButton.h @@ -0,0 +1,60 @@ +/* + RISC OS KWin client + + Copyright 2000 + Rik Hemsley <rik@kde.org> + + 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_STICKY_BUTTON_H +#define RISC_OS_STICKY_BUTTON_H + +#include "Button.h" + +namespace RiscOS +{ + +class StickyButton : public Button +{ + Q_OBJECT + + public: + + StickyButton(QWidget *parent); + + public slots: + + void setOn(bool); + + signals: + + void toggleSticky(); + + protected: + + void mouseReleaseEvent(QMouseEvent *); + + private: + + bool on_; +}; + +} // End namespace + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/kwin-styles/riscos/riscos.desktop b/kwin-styles/riscos/riscos.desktop new file mode 100644 index 00000000..194b3017 --- /dev/null +++ b/kwin-styles/riscos/riscos.desktop @@ -0,0 +1,11 @@ +[Desktop Entry] +Name=RISC OS +Name[cs]=Risc OS +Name[cy]= RISC OS +Name[hi]=रिस्क ओएस +Name[ta]=RISC இ.த +Name[th]=ระบบปฏิบัติการบนชิพ RISC +Name[uk]=RISC ОС +Name[xh]=i RISC OS +Name[zu]=IRISC OS +X-KDE-Library=kwin3_riscos |