diff --git a/clients/kde/Bitmaps.h b/clients/kde/Bitmaps.h new file mode 100644 index 0000000000..b9b5da70d9 --- /dev/null +++ b/clients/kde/Bitmaps.h @@ -0,0 +1,21 @@ +static unsigned char iconify_bits[] = { + 0xff, 0xff, 0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18}; + +static unsigned char close_bits[] = { + 0xc3, 0x66, 0x3c, 0x18, 0x3c, 0x66, 0xc3, 0x00 }; + +static unsigned char maximize_bits[] = { + 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0xff, 0xff }; + +static unsigned char minmax_bits[] = { + 0x0c, 0x18, 0x33, 0x67, 0xcf, 0x9f, 0x3f, 0x3f}; + +static unsigned char unsticky_bits[] = { + 0x00, 0x18, 0x18, 0x7e, 0x7e, 0x18, 0x18, 0x00}; + +static unsigned char sticky_bits[] = { + 0x00, 0x00, 0x00, 0x7e, 0x7e, 0x00, 0x00, 0x00}; + +static unsigned char question_bits[] = { + 0x3c, 0x66, 0x60, 0x30, 0x18, 0x00, 0x18, 0x18}; + diff --git a/clients/kde/Button.cpp b/clients/kde/Button.cpp new file mode 100644 index 0000000000..ac18463ac3 --- /dev/null +++ b/clients/kde/Button.cpp @@ -0,0 +1,71 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include "Button.h" +#include "Static.h" + +namespace Default +{ + +Button::Button(QWidget * parent, SymbolType t) + : QWidget (parent, "Button", WRepaintNoErase | WPaintUnclipped), + type_ (t), + align_ (Left), + down_ (false), + active_ (false) +{ + if (type_ == Sticky) + setFixedWidth(Static::instance()->buttonWidth2()); + else + setFixedWidth(Static::instance()->buttonWidth1()); +} + +Button::~Button() +{ + // Empty. +} + + void +Button::updateDisplay() +{ + setBackgroundPixmap(Static::instance()->button(type_, active_, down_)); + repaint(true); +} + + void +Button::setType(SymbolType t) +{ + type_ = t; + updateDisplay(); +} + + void +Button::setActive(bool b) +{ + active_ = b; + updateDisplay(); +} + +} // End namespace + +// vim:ts=2:sw=2:tw=78 +#include "Button.moc" diff --git a/clients/kde/Button.h b/clients/kde/Button.h new file mode 100644 index 0000000000..fe84e9d838 --- /dev/null +++ b/clients/kde/Button.h @@ -0,0 +1,69 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef DEFAULT_BUTTON_H +#define DEFAULT_BUTTON_H + +#include "Static.h" +#include + +namespace Default +{ + +class Button : public QWidget +{ + Q_OBJECT + + public: + + enum Alignment { Left, Right }; + + Button(QWidget * parent, SymbolType); + virtual ~Button(); + + void updateDisplay(); + + void setAlign(Alignment a) { align_ = a; updateDisplay(); } + void setType(SymbolType t); + + void setActive(bool); + + protected: + + bool active() const { return active_; } + + void mousePressEvent(QMouseEvent *) { down_ = true; updateDisplay(); } + void mouseReleaseEvent(QMouseEvent *) { down_ = false; updateDisplay(); } + + private: + + SymbolType type_; + Alignment align_; + bool down_; + bool active_; +}; + +} // End namespace + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/clients/kde/CloseButton.cpp b/clients/kde/CloseButton.cpp new file mode 100644 index 0000000000..450d375826 --- /dev/null +++ b/clients/kde/CloseButton.cpp @@ -0,0 +1,61 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include "CloseButton.h" + +namespace Default +{ + +CloseButton::CloseButton(QWidget * parent) + : Button(parent, Close) +{ +} + + void +CloseButton::mouseReleaseEvent(QMouseEvent * e) +{ + Button::mouseReleaseEvent(e); + + if (!rect().contains(e->pos())) + return; + + switch (e->button()) + { + case RightButton: + emit(closeClient()); + break; + + case MidButton: + emit(closeClient()); + break; + + case LeftButton: + default: + emit(closeClient()); + break; + } +} + +} // End namespace; + +// vim:ts=2:sw=2:tw=78 +#include "CloseButton.moc" diff --git a/clients/kde/CloseButton.h b/clients/kde/CloseButton.h new file mode 100644 index 0000000000..465cdc66e8 --- /dev/null +++ b/clients/kde/CloseButton.h @@ -0,0 +1,52 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef DEFAULT_CLOSE_BUTTON_H +#define DEFAULT_CLOSE_BUTTON_H + +#include "Button.h" + +namespace Default +{ + +class CloseButton : public Button +{ + Q_OBJECT + + public: + + CloseButton(QWidget * parent); + + signals: + + void closeClient(); + + protected: + + void mouseReleaseEvent(QMouseEvent *); +}; + +} // End namespace; + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/clients/kde/DBWidget.cpp b/clients/kde/DBWidget.cpp new file mode 100644 index 0000000000..af4599c727 --- /dev/null +++ b/clients/kde/DBWidget.cpp @@ -0,0 +1,64 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include "DBWidget.h" + +namespace Default +{ + +DBWidget::DBWidget(QWidget * parent, const char * name) + : QWidget(parent, name, WResizeNoErase | WRepaintNoErase | WPaintUnclipped | +WNorthWestGravity) +{ + buf_.resize(20, 20); + setBackgroundMode(NoBackground); +} + + void +DBWidget::updateDisplay() +{ + updatePixmap(); + repaint(false); +} + + void +DBWidget::paintEvent(QPaintEvent * e) +{ + QRect r(e->rect()); + bitBlt(this, r.topLeft(), &buf_, r, Qt::CopyROP); +} + + void +DBWidget::resizeEvent(QResizeEvent * e) +{ + QWidget::resizeEvent(e); + + if ( (buf_.width() < size().width()) || + (QABS(size().width() - buf_.width()) > 128) ) + buf_.resize(((size().width() / 128)* 128) + 128, size().height()); + + updateDisplay(); +} + +} // End namespace + +// vim:ts=2:sw=2:tw=78 diff --git a/clients/kde/DBWidget.h b/clients/kde/DBWidget.h new file mode 100644 index 0000000000..9988012be5 --- /dev/null +++ b/clients/kde/DBWidget.h @@ -0,0 +1,63 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef DEFAULT_DOUBLE_BUFFERED_WIDGET_H +#define DEFAULT_DOUBLE_BUFFERED_WIDGET_H + +#include +#include + +namespace Default +{ + +class DBWidget : public QWidget +{ + public: + + DBWidget(QWidget * parent = 0, const char * name = 0); + virtual ~DBWidget() { /* Empty */ } + + virtual void updateDisplay(); + + protected: + + virtual void updatePixmap() = 0; + + virtual void paintEvent(QPaintEvent * e); + virtual void resizeEvent(QResizeEvent * e); + + QPixmap & buf() { return buf_; } + + + private: + + DBWidget(const DBWidget &); + DBWidget & operator = (const DBWidget &); + + QPixmap buf_; +}; + +} // End namespace + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/clients/kde/Defines.h b/clients/kde/Defines.h new file mode 100644 index 0000000000..77d3251c37 --- /dev/null +++ b/clients/kde/Defines.h @@ -0,0 +1,7 @@ +#ifndef DEFAULT_DEFINES_H +#define DEFAULT_DEFINES_H + +#define RESIZE_SIDE_WIDTH 30 +#define RESIZE_BAR_HEIGHT 6 + +#endif diff --git a/clients/kde/IconifyButton.cpp b/clients/kde/IconifyButton.cpp new file mode 100644 index 0000000000..2c92f175de --- /dev/null +++ b/clients/kde/IconifyButton.cpp @@ -0,0 +1,63 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include "IconifyButton.h" + +namespace Default +{ + +IconifyButton::IconifyButton(QWidget * parent) + : Button(parent, Iconify) +{ +} + + void +IconifyButton::mouseReleaseEvent(QMouseEvent * e) +{ + Button::mouseReleaseEvent(e); + + if (!rect().contains(e->pos())) + return; + + switch (e->button()) + { + case RightButton: + emit(iconifyClient()); + break; + + case MidButton: + emit(iconifyClient()); + break; + + case LeftButton: + default: + emit(iconifyClient()); + break; + } + + +} + +} // End namespace; + +// vim:ts=2:sw=2:tw=78 +#include "IconifyButton.moc" diff --git a/clients/kde/IconifyButton.h b/clients/kde/IconifyButton.h new file mode 100644 index 0000000000..5bcccf7e74 --- /dev/null +++ b/clients/kde/IconifyButton.h @@ -0,0 +1,52 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef DEFAULT_ICONIFY_BUTTON_H +#define DEFAULT_ICONIFY_BUTTON_H + +#include "Button.h" + +namespace Default +{ + +class IconifyButton : public Button +{ + Q_OBJECT + + public: + + IconifyButton(QWidget * parent); + + signals: + + void iconifyClient(); + + protected: + + void mouseReleaseEvent(QMouseEvent *); +}; + +} // End namespace; + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/clients/kde/Manager.cpp b/clients/kde/Manager.cpp new file mode 100644 index 0000000000..53ce606802 --- /dev/null +++ b/clients/kde/Manager.cpp @@ -0,0 +1,222 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include +#include + +#include "../../options.h" +#include "../../workspace.h" + +#include "Manager.h" +#include "Static.h" +#include "TitleBar.h" +#include "ResizeBar.h" + +extern "C" +{ + Client * allocate(Workspace * workSpace, WId winId) + { + return new Default::Manager(workSpace, winId); + } +} + +namespace Default +{ + +Manager::Manager( + Workspace * workSpace, + WId id, + QWidget * parent, + const char * name +) + : Client(workSpace, id, parent, name) +{ + setBackgroundMode(NoBackground); + + connect(options, SIGNAL(resetClients()), this, SLOT(slotReset())); + + titleBar_ = new TitleBar(this); + resizeBar_ = new ResizeBar(this, this); + + activateLayout(); +} + +Manager::~Manager() +{ +} + + void +Manager::slotReset() +{ + Static::instance()->update(); + _updateDisplay(); +} + + void +Manager::captionChange(const QString &) +{ + titleBar_->updateText(); +} + + void +Manager::stickyChange(bool b) +{ + emit(stickyStatusChanged(b)); +} + + void +Manager::paletteChange(const QPalette &) +{ + Static::instance()->update(); + _updateDisplay(); +} + + void +Manager::activeChange(bool b) +{ + titleBar_->setActive(b); +} + + void +Manager::maximizeChange(bool b) +{ + emit(maximiseChanged(b)); +} + + void +Manager::_updateDisplay() +{ + titleBar_->updateDisplay(); + resizeBar_->updateDisplay(); +} + + void +Manager::setShade(bool) +{ + // Wait for parent class version to work. +} + + void +Manager::paintEvent(QPaintEvent * e) +{ + QRect r(e->rect()); + + bool intersectsLeft = + r.intersects(QRect(0, 0, 1, height())); + + bool intersectsRight = + r.intersects(QRect(width() - 1, 0, width(), height())); + + if (intersectsLeft || intersectsRight) { + + QPainter p(this); + 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()); + } +} + + Client::MousePosition +Manager::mousePosition(const QPoint & p) const +{ + if (titleBar_->rect().contains(p)) + return Client::Center; + else + return Client::Nowhere; +} + + void +Manager::toggleSticky() +{ + setSticky(!isSticky()); +} + + void +Manager::raise() +{ + workspace()->raiseClient(this); +} + + void +Manager::vMax() +{ + maximize(MaximizeVertical); +} + + void +Manager::resizeEvent(QResizeEvent * e) +{ + Client::resizeEvent(e); + _updateLayout(); +} + + void +Manager::_updateLayout() +{ + titleBar_ -> setGeometry( + 0, + 0, + width(), + Static::instance()->titleHeight() + ); + + windowWrapper() -> setGeometry( + 1, + Static::instance()->titleHeight(), + width() - 2, + height() - Static::instance()->titleHeight() - RESIZE_BAR_HEIGHT + ); + + resizeBar_ -> setGeometry( + 0, + height() - RESIZE_BAR_HEIGHT, + width(), + RESIZE_BAR_HEIGHT + ); + + _updateDisplay(); +} + + void +Manager::activateLayout() +{ + _updateLayout(); +} + + void +Manager::fakeMouseEvent(QMouseEvent * e, QWidget * w) +{ + QPoint adjustedPos = w->pos() + e->pos(); + + QMouseEvent fake(e->type(), adjustedPos, e->button(), e->state()); + + Client::event(&fake); +} + +} // End namespace + +// vim:ts=2:sw=2:tw=78 +#include "Manager.moc" diff --git a/clients/kde/Manager.h b/clients/kde/Manager.h new file mode 100644 index 0000000000..7f2f654e26 --- /dev/null +++ b/clients/kde/Manager.h @@ -0,0 +1,88 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef DEFAULT_MANAGER_H +#define DEFAULT_MANAGER_H + +#include "../../client.h" + +namespace Default +{ + +class TitleBar; +class ResizeBar; + +class Manager : public Client +{ + Q_OBJECT + + public: + + Manager(Workspace *, WId, QWidget * parent = 0, const char * name = 0); + ~Manager(); + + void setShade(bool); + + void fakeMouseEvent(QMouseEvent *, QWidget *); + + signals: + + void maximiseChanged(bool); + void stickyStatusChanged(bool); + + public slots: + + void toggleSticky(); + void raise(); + void vMax(); + + protected: + + Client::MousePosition mousePosition(const QPoint &) const; + void paletteChange(const QPalette &); + void activeChange(bool); + void maximizeChange(bool); + void paintEvent(QPaintEvent *); + void resizeEvent(QResizeEvent *); + void activateLayout(); + + protected slots: + + void captionChange(const QString &); + void stickyChange(bool); + void slotReset(); + + private: + + void _updateDisplay(); + void _updateLayout(); + + TitleBar * titleBar_; + ResizeBar * resizeBar_; + +}; + +} // End namespace + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/clients/kde/MaximiseButton.cpp b/clients/kde/MaximiseButton.cpp new file mode 100644 index 0000000000..f6dc95f636 --- /dev/null +++ b/clients/kde/MaximiseButton.cpp @@ -0,0 +1,69 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include "MaximiseButton.h" + +namespace Default +{ + +MaximiseButton::MaximiseButton(QWidget * parent) + : Button(parent, Max) +{ +} + + void +MaximiseButton::setOn(bool on) +{ + setType(on ? Unmax: Max); + updateDisplay(); +} + + void +MaximiseButton::mouseReleaseEvent(QMouseEvent * e) +{ + Button::mouseReleaseEvent(e); + + if (!rect().contains(e->pos())) + return; + + switch (e->button()) + { + case RightButton: + emit(maximiseClient()); + break; + + case MidButton: + emit(vMaxClient()); + break; + + case LeftButton: + default: + emit(raiseClient()); + emit(maximiseClient()); + break; + } +} + +} // End namespace + +// vim:ts=2:sw=2:tw=78 +#include "MaximiseButton.moc" diff --git a/clients/kde/MaximiseButton.h b/clients/kde/MaximiseButton.h new file mode 100644 index 0000000000..ea2bf595ce --- /dev/null +++ b/clients/kde/MaximiseButton.h @@ -0,0 +1,58 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef DEFAULT_MAXIMISE_BUTTON_H +#define DEFAULT_MAXIMISE_BUTTON_H + +#include "Button.h" + +namespace Default +{ + +class MaximiseButton : public Button +{ + Q_OBJECT + + public: + + MaximiseButton(QWidget * parent); + + public slots: + + void setOn(bool); + + signals: + + void maximiseClient(); + void raiseClient(); + void vMaxClient(); + + protected: + + void mouseReleaseEvent(QMouseEvent *); +}; + +} // End namespace + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/clients/kde/ResizeBar.cpp b/clients/kde/ResizeBar.cpp new file mode 100644 index 0000000000..22f561d60c --- /dev/null +++ b/clients/kde/ResizeBar.cpp @@ -0,0 +1,63 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include "ResizeBar.h" +#include "ResizeMid.h" +#include "ResizeSide.h" + +#include + +namespace Default +{ + +ResizeBar::ResizeBar(QWidget * parent, Manager * client) + : QWidget (parent, "ResizeBar"), + client_ (client) +{ + setBackgroundMode(NoBackground); + + left_ = new ResizeSide(this, client_, ResizeSide::Left); + mid_ = new ResizeMid(this, client_); + right_ = new ResizeSide(this, client_, ResizeSide::Right); + + mid_->move(30, 0); +} + + void +ResizeBar::updateDisplay() +{ + left_ ->updateDisplay(); + mid_ ->updateDisplay(); + right_->updateDisplay(); +} + + void +ResizeBar::resizeEvent(QResizeEvent *) +{ + mid_->resize(width() - 60, mid_->height()); + right_->move(width() - 30, 0); +} + +} // End namespace + +// vim:ts=2:sw=2:tw=78 +#include "ResizeBar.moc" diff --git a/clients/kde/ResizeBar.h b/clients/kde/ResizeBar.h new file mode 100644 index 0000000000..449e834067 --- /dev/null +++ b/clients/kde/ResizeBar.h @@ -0,0 +1,62 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef DEFAULT_RESIZE_BAR_H +#define DEFAULT_RESIZE_BAR_H + +#include + +namespace Default +{ + +class Manager; + +class ResizeMid; +class ResizeSide; + +class ResizeBar : public QWidget +{ + Q_OBJECT + + public: + + ResizeBar(QWidget * parent, Manager * client); + void updateDisplay(); + + protected: + + void resizeEvent(QResizeEvent *); + + private: + + Manager * client_; + + ResizeSide * left_; + ResizeMid * mid_; + ResizeSide * right_; +}; + +} // End namespace + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/clients/kde/ResizeMid.cpp b/clients/kde/ResizeMid.cpp new file mode 100644 index 0000000000..b6ead24fc3 --- /dev/null +++ b/clients/kde/ResizeMid.cpp @@ -0,0 +1,91 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include +#include +#include + +#include "ResizeMid.h" +#include "Manager.h" +#include "Static.h" + +namespace Default +{ + +ResizeMid::ResizeMid(QWidget * parent, Manager * client) + : DBWidget(parent, "ResizeMid"), + client_(client) +{ + setFixedHeight(RESIZE_BAR_HEIGHT); + setCursor(Qt::sizeVerCursor); +} + +ResizeMid::~ResizeMid() +{ + // Empty. +} + + void +ResizeMid::updatePixmap() +{ + QPainter p(&buf()); + + QColorGroup g( + client_->isActive() ? + palette().active() : + palette().inactive() + ); + + QBrush b(g.button()); + + QStyle * style = kapp->kstyle(); + + if (0 != style) + style->drawPanel(&p, 0, 0, width(), height(), g, false, 2, &b); + else + kapp->style().drawPanel(&p, 0, 0, width(), height(), g, false, 2, &b); +} + + void +ResizeMid::mouseMoveEvent(QMouseEvent * e) +{ + QRect g = client_->geometry(); + g.setBottom(e->globalPos().y()); + + QSize adjustedSize = client_->adjustedSize(g.size()); + + if (adjustedSize != client_->size()) { + g.setBottom(g.top() + adjustedSize.height()); + client_->setGeometry(g); + } +} + + void +ResizeMid::mousePressEvent(QMouseEvent * e) +{ + if (e->button() == LeftButton) + client_->raise(); +} + +} // End namespace + +// vim:ts=2:sw=2:tw=78 diff --git a/clients/kde/ResizeMid.h b/clients/kde/ResizeMid.h new file mode 100644 index 0000000000..25b455cd3d --- /dev/null +++ b/clients/kde/ResizeMid.h @@ -0,0 +1,56 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef DEFAULT_RESIZE_MID_H +#define DEFAULT_RESIZE_MID_H + +#include "DBWidget.h" + +namespace Default +{ + +class Manager; + +class ResizeMid : public DBWidget +{ + public: + + ResizeMid(QWidget * parent, Manager * client); + virtual ~ResizeMid(); + + protected: + + void updatePixmap(); + + void mousePressEvent(QMouseEvent *); + void mouseMoveEvent(QMouseEvent *); + + private: + + Manager * client_; +}; + +} // End namespace + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/clients/kde/ResizeSide.cpp b/clients/kde/ResizeSide.cpp new file mode 100644 index 0000000000..b617704fd1 --- /dev/null +++ b/clients/kde/ResizeSide.cpp @@ -0,0 +1,102 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include +#include +#include + +#include "ResizeSide.h" +#include "Manager.h" +#include "Static.h" + +namespace Default +{ + +ResizeSide::ResizeSide(QWidget * parent, Manager * client, Side s) + : QWidget (parent, "ResizeSide"), + client_ (client), + side_ (s) +{ + setCursor(side_ == Left ? Qt::sizeBDiagCursor : Qt::sizeFDiagCursor); + setFixedSize(RESIZE_SIDE_WIDTH, RESIZE_BAR_HEIGHT); + updateDisplay(); +} + + void +ResizeSide::mouseMoveEvent(QMouseEvent * e) +{ + QRect g = client_->geometry(); + g.setBottom(e->globalPos().y()); + if (side_ == Left) + g.setLeft(e->globalPos().x()); + else + g.setRight(e->globalPos().x()); + + QSize adjustedSize = client_->adjustedSize(g.size()); + + if (adjustedSize != client_->size()) { + + if (side_ == Left) + g.setLeft(g.right() - adjustedSize.width()); + else + g.setRight(g.left() + adjustedSize.width()); + + g.setBottom(g.top() + adjustedSize.height()); + + client_->setGeometry(g); + } +} + + void +ResizeSide::updateDisplay() +{ + QPixmap pix(size()); + QPainter p(&pix); + + QColorGroup g( + client_->isActive() ? + palette().active() : + palette().inactive() + ); + + QBrush b(g.button()); + + QStyle * style = kapp->kstyle(); + + if (0 != style) + style->drawPanel(&p, 0, 0, width(), height(), g, false, 2, &b); + else + kapp->style().drawPanel(&p, 0, 0, width(), height(), g, false, 2, &b); + + setBackgroundPixmap(pix); +} + + void +ResizeSide::mousePressEvent(QMouseEvent * e) +{ + if (e->button() == LeftButton) + client_->raise(); +} + +} // End namespace + +// vim:ts=2:sw=2:tw=78 diff --git a/clients/kde/ResizeSide.h b/clients/kde/ResizeSide.h new file mode 100644 index 0000000000..a0cd7bdb77 --- /dev/null +++ b/clients/kde/ResizeSide.h @@ -0,0 +1,57 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef DEFAULT_RESIZE_SIDE_H +#define DEFAULT_RESIZE_SIDE_H + +#include + +namespace Default +{ + +class Manager; + +class ResizeSide : public QWidget +{ + public: + + enum Side { Left, Right }; + + ResizeSide(QWidget * parent, Manager * client, Side); + void updateDisplay(); + + protected: + + void mousePressEvent(QMouseEvent *); + void mouseMoveEvent(QMouseEvent *); + + private: + + Manager * client_; + Side side_; +}; + +} // End namespace + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/clients/kde/Static.cpp b/clients/kde/Static.cpp new file mode 100644 index 0000000000..b0cfea5ca1 --- /dev/null +++ b/clients/kde/Static.cpp @@ -0,0 +1,324 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include +#include +#include +#include + +#include "../../options.h" + +#include "Static.h" + +namespace Default +{ + +static void drawButtonFrame(KPixmap & pix, const QColorGroup &g, bool sunken) +{ + QPainter p; + + int w = pix.width(); + int h = pix.height(); + + p.begin(&pix); + + p.setPen(g.dark()); + + p.drawLine(0, 0, w-1, 0); + p.drawLine(0, 0, 0, h-1); + + p.setPen(sunken ? g.dark() : g.light()); + p.drawLine(1, 1, w-2, 1); + p.drawLine(1, 1, 1, h-2); + + p.setPen(sunken ? g.light() : g.dark()); + p.drawLine(w-2, 1, w-2, h-2); + p.drawLine(1, h-2, w-2, h-2); + + p.setPen(g.light()); + p.drawLine(w-1, 0, w-1, h-1); + p.drawLine(0, h-1, w-1, h-1); + + p.end(); +} + + +Static * Static::instance_ = 0L; + + void +Static::_init() +{ + aResize_.setOptimization(QPixmap::MemoryOptim); + iResize_.setOptimization(QPixmap::MemoryOptim); + aResize_.resize(30, RESIZE_BAR_HEIGHT); + iResize_.resize(30, RESIZE_BAR_HEIGHT); + aResize_.fill(Qt::black); + iResize_.fill(Qt::black); + + aTitle_ .setOptimization(QPixmap::BestOptim); + iTitle_ .setOptimization(QPixmap::BestOptim); + + aResizeMidLeft_ .setOptimization(QPixmap::BestOptim); + aResizeMidRight_ .setOptimization(QPixmap::BestOptim); + aResizeMid_ .setOptimization(QPixmap::BestOptim); + + iResizeMidLeft_ .setOptimization(QPixmap::BestOptim); + iResizeMidRight_ .setOptimization(QPixmap::BestOptim); + iResizeMid_ .setOptimization(QPixmap::BestOptim); + + aResizeMidLeft_ .resize(3, 12); + aResizeMidRight_ .resize(3, 12); + aResizeMidLeft_ .fill(Qt::black); + aResizeMidRight_ .fill(Qt::black); + + iResizeMidLeft_ .resize(3, 12); + iResizeMidRight_ .resize(3, 12); + iResizeMidLeft_ .fill(Qt::black); + iResizeMidRight_ .fill(Qt::black); + + aResizeMid_ .resize(128, RESIZE_BAR_HEIGHT); + iResizeMid_ .resize(128, RESIZE_BAR_HEIGHT); + aResizeMid_ .fill(Qt::black); + iResizeMid_ .fill(Qt::black); + + _loadGlyphs(); + + update(); +} + + void +Static::update() +{ + QPainter p; + + titleHeight_ = 24; + btnWidth1_ = 36; + btnWidth2_ = 24; + + unsigned int availableTitleHeight = titleHeight_ - 6; + + aTitle_.resize(36, availableTitleHeight); + iTitle_.resize(36, availableTitleHeight); + + aTitleText_.resize(36, availableTitleHeight); + iTitleText_.resize(36, availableTitleHeight); + + aTitleLeft_.resize(2, availableTitleHeight); + iTitleLeft_.resize(2, availableTitleHeight); + + aTitleRight_.resize(2, availableTitleHeight); + iTitleRight_.resize(2, availableTitleHeight); + + QColor bgColor, light, dark; + QColorGroup buttonBgColorGroup = options->colorGroup(Options::ButtonBg, true); + KPixmapEffect::GradientType vertGrad = KPixmapEffect::VerticalGradient; + KPixmapEffect::GradientType diagGrad = KPixmapEffect::DiagonalGradient; + QSize buttonSize1(btnWidth1_, availableTitleHeight); + QSize buttonSize2(btnWidth2_, availableTitleHeight); + + // Titlebar + + bgColor = options->color(Options::TitleBar, true); + + light = bgColor.light(120); + dark = bgColor.dark(120); + + KPixmapEffect::gradient(aTitle_, light, dark, vertGrad); + KPixmapEffect::gradient(aTitleText_, light, dark, vertGrad); + KPixmapEffect::gradient(aTitleLeft_, light, dark, vertGrad); + KPixmapEffect::gradient(aTitleRight_, light, dark, vertGrad); + + p.begin(&aTitle_); + p.setPen(dark); + p.drawLine(0, 0, 36, 0); + p.setPen(light); + p.drawLine(0, availableTitleHeight - 1, 36, availableTitleHeight - 1); + p.end(); + + p.begin(&aTitleText_); + p.setPen(dark); + p.drawLine(0, 0, 36, 0); + p.setPen(light); + p.drawLine(0, availableTitleHeight - 1, 36, availableTitleHeight - 1); + p.end(); + + p.begin(&aTitleLeft_); + p.setPen(dark); + p.drawPoint(1, 0); + p.drawLine(0, 0, 0, availableTitleHeight - 1); + p.setPen(light); + p.drawPoint(1, availableTitleHeight - 1); + p.end(); + + p.begin(&aTitleRight_); + p.setPen(dark); + p.drawPoint(0, 1); + p.setPen(light); + p.drawLine(1, 0, 1, availableTitleHeight - 1); + p.drawPoint(0, availableTitleHeight - 1); + p.end(); + + bgColor = options->color(Options::TitleBar, false); + light = bgColor.light(120); + dark = bgColor.dark(120); + + KPixmapEffect::gradient(iTitle_, light, dark, vertGrad); + KPixmapEffect::gradient(iTitleText_, light, dark, vertGrad); + KPixmapEffect::gradient(iTitleLeft_, light, dark, vertGrad); + KPixmapEffect::gradient(iTitleRight_, light, dark, vertGrad); + + p.begin(&iTitle_); + p.setPen(dark); + p.drawLine(0, 0, 36, 0); + p.setPen(light); + p.drawLine(0, availableTitleHeight - 1, 36, availableTitleHeight - 1); + p.end(); + + p.begin(&iTitleText_); + p.setPen(dark); + p.drawLine(0, 0, 36, 0); + p.setPen(light); + p.drawLine(0, availableTitleHeight - 1, 36, availableTitleHeight - 1); + p.end(); + + p.begin(&iTitleLeft_); + p.setPen(dark); + p.drawPoint(1, 0); + p.drawLine(0, 0, 0, availableTitleHeight - 1); + p.setPen(light); + p.drawPoint(1, availableTitleHeight - 1); + p.end(); + + p.begin(&iTitleRight_); + p.setPen(dark); + p.drawPoint(0, 1); + p.setPen(light); + p.drawLine(1, 0, 1, availableTitleHeight - 1); + p.drawPoint(0, availableTitleHeight - 1); + p.end(); + + p.begin(&aTitle_); + p.setPen(options->color(Options::TitleBar, true).light(150)); + + for (unsigned int y = 3; y < availableTitleHeight - 3; y += 3) + for (unsigned int x = 1; x < 36; x += 3) + p.drawPoint(x, y); + + p.setPen(options->color(Options::TitleBar, true).dark(150)); + + for (unsigned int y = 3; y < availableTitleHeight - 3; y += 3) + for (unsigned int x = 1; x < 36; x += 3) + p.drawPoint(x + 1, y + 1); + p.end(); + + // Buttons + + bgColor = buttonBgColorGroup.background(); + light = bgColor.light(120); + dark = bgColor.dark(120); + + btnPix1_ .resize(buttonSize1); + btnDownPix1_ .resize(buttonSize1); + btnPix2_ .resize(buttonSize2); + btnDownPix2_ .resize(buttonSize2); + + iBtnPix1_ .resize(buttonSize1); + iBtnDownPix1_ .resize(buttonSize1); + iBtnPix2_ .resize(buttonSize2); + iBtnDownPix2_ .resize(buttonSize2); + + KPixmapEffect::gradient(btnPix1_, light, dark, diagGrad); + KPixmapEffect::gradient(btnDownPix1_, dark, light, diagGrad); + KPixmapEffect::gradient(btnPix2_, light, dark, diagGrad); + KPixmapEffect::gradient(btnDownPix2_, dark, light, diagGrad); + + KPixmapEffect::gradient(iBtnPix1_, light, dark, diagGrad); + KPixmapEffect::gradient(iBtnDownPix1_, dark, light, diagGrad); + KPixmapEffect::gradient(iBtnPix2_, light, dark, diagGrad); + KPixmapEffect::gradient(iBtnDownPix2_, dark, light, diagGrad); + + drawButtonFrame(btnPix1_, buttonBgColorGroup, false); + drawButtonFrame(btnDownPix1_, buttonBgColorGroup, true); + drawButtonFrame(btnPix2_, buttonBgColorGroup, false); + drawButtonFrame(btnDownPix2_, buttonBgColorGroup, true); + + drawButtonFrame(iBtnPix1_, buttonBgColorGroup, false); + drawButtonFrame(iBtnDownPix1_, buttonBgColorGroup, true); + drawButtonFrame(iBtnPix2_, buttonBgColorGroup, false); + drawButtonFrame(iBtnDownPix2_, buttonBgColorGroup, true); + + p.flush(); +} + + QPixmap +Static::button(SymbolType t, bool active, bool down) +{ + bool buttonSize2 = (t == Sticky || t == Unsticky); + QPixmap px = buttonPixmap(!buttonSize2, active, down); + + QBitmap b = glyph(t); + b.setMask(b); + + QPainter p(&px); + QPoint offset((buttonSize2 ? btnWidth2_ : btnWidth1_) / 2 - 4, (titleHeight_ - 6) / 2 - 4); + p.drawPixmap(offset, b); + + return px; +} + +static unsigned char iconify_bits[] = { + 0xff, 0xff, 0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18}; + +static unsigned char close_bits[] = { + 0xc3, 0x66, 0x3c, 0x18, 0x3c, 0x66, 0xc3, 0x00 }; + +static unsigned char maximize_bits[] = { + 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0xff, 0xff }; + +static unsigned char unmax_bits[] = { + 0x30, 0x18, 0xcc, 0xe6, 0xf3, 0xf9, 0xfc, 0xfc}; + +static unsigned char unsticky_bits[] = { + 0x3c, 0x42, 0x99, 0xbd, 0xbd, 0x99, 0x42, 0x3c}; + +static unsigned char sticky_bits[] = { + 0x3c, 0x42, 0x81, 0x81, 0x81, 0x81, 0x42, 0x3c}; + +static unsigned char question_bits[] = { + 0x3c, 0x66, 0x60, 0x30, 0x18, 0x00, 0x18, 0x18}; + + + void +Static::_loadGlyphs() +{ + glyphClose_ = QBitmap(8, 8, close_bits); + glyphMaximise_ = QBitmap(8, 8, maximize_bits); + glyphUnmaximise_ = QBitmap(8, 8, unmax_bits); + glyphSticky_ = QBitmap(8, 8, sticky_bits); + glyphUnsticky_ = QBitmap(8, 8, unsticky_bits); + glyphIconify_ = QBitmap(8, 8, iconify_bits); +} + +} // End namespace + +// vim:ts=2:sw=2:tw=78 + diff --git a/clients/kde/Static.h b/clients/kde/Static.h new file mode 100644 index 0000000000..3ea118b7de --- /dev/null +++ b/clients/kde/Static.h @@ -0,0 +1,177 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef DEFAULT_STATIC_H +#define DEFAULT_STATIC_H + +#include +#include +#include +#include + +#include + +#include "Defines.h" + +namespace Default +{ + +enum SymbolType { Sticky, Unsticky, Close, Iconify, Max, Unmax }; + +class Static +{ + + public: + + Static() + { + instance_ = this; + _init(); + } + + ~Static() + { + instance_ = 0L; + } + + static Static * instance() + { + if (0 == instance_) + new Static; + + return instance_; + } + + void update(); + + const QPixmap & title(bool active) const + { return active ? aTitle_ : iTitle_; } + + const QPixmap & titleText(bool active) const + { return active ? aTitleText_ : iTitleText_; } + + const QPixmap & titleLeft(bool active) const + { return active ? aTitleLeft_ : iTitleLeft_; } + + const QPixmap & titleRight(bool active) const + { return active ? aTitleRight_ : iTitleRight_; } + + const QPixmap & resizeMidLeft(bool active) const + { return active ? aResizeMidLeft_ : iResizeMidLeft_; } + + const QPixmap & resizeMidRight(bool active) const + { return active ? aResizeMidRight_ : iResizeMidRight_; } + + const QPixmap & resizeMidMid(bool active) const + { return active ? aResizeMid_ : iResizeMid_; } + + QPixmap button(SymbolType t, bool active, bool down); + + const QPixmap & resize(bool active) const + { return active ? aResize_ : iResize_; } + + const QBitmap & glyph(SymbolType t) const + { + switch (t) { + case Close: return glyphClose_; + case Sticky: return glyphSticky_; + case Unsticky: return glyphUnsticky_; + case Iconify: return glyphIconify_; + case Max: return glyphMaximise_; + case Unmax: return glyphUnmaximise_; + default: return glyphClose_; + } + } + + unsigned int buttonWidth1() const { return btnWidth1_; } + unsigned int buttonWidth2() const { return btnWidth2_; } + unsigned int titleHeight() const { return titleHeight_; } + + const KPixmap & buttonPixmap(int n, bool active, bool down) const + { + if (active) { + if (n == 1) + if (down) + return btnDownPix1_; + else + return btnPix1_; + else + if (down) + return btnDownPix2_; + else + return btnPix2_; + } else { + if (n == 1) + if (down) + return iBtnDownPix1_; + else + return iBtnPix1_; + else + if (down) + return iBtnDownPix2_; + else + return iBtnPix2_; + } + + } + + private: + + void _init(); + void _loadGlyphs(); + + static Static * instance_; + + QPixmap + aResize_, iResize_, + aResizeDown_, iResizeDown_, + aResizeMidLeft_, aResizeMidRight_, + iResizeMidLeft_, iResizeMidRight_, + aResizeMid_, iResizeMid_; + + QBitmap + glyphClose_, + glyphSticky_, + glyphUnsticky_, + glyphIconify_, + glyphMaximise_, + glyphUnmaximise_; + + KPixmap aTitle_, iTitle_; + KPixmap aTitleLeft_, iTitleLeft_; + KPixmap aTitleRight_, iTitleRight_; + KPixmap aTitleText_, iTitleText_; + + KPixmap btnPix1_, btnDownPix1_, iBtnPix1_, iBtnDownPix1_; + KPixmap btnPix2_, btnDownPix2_, iBtnPix2_, iBtnDownPix2_; + + unsigned int btnWidth1_; + unsigned int btnWidth2_; + + unsigned int titleHeight_; +}; + +} // End namespace + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/clients/kde/StickyButton.cpp b/clients/kde/StickyButton.cpp new file mode 100644 index 0000000000..31df7e68ae --- /dev/null +++ b/clients/kde/StickyButton.cpp @@ -0,0 +1,59 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include "StickyButton.h" + +namespace Default +{ + +StickyButton::StickyButton(QWidget * parent) + : Button(parent, Sticky) +{ +} + + void +StickyButton::mouseReleaseEvent(QMouseEvent * e) +{ + Button::mouseReleaseEvent(e); + + if (!rect().contains(e->pos())) + return; + + switch (e->button()) + { + default: + emit(toggleSticky()); + break; + } +} + + void +StickyButton::setOn(bool b) +{ + setType(b ? Unsticky : Sticky); + updateDisplay(); +} + +} // End namespace; + +// vim:ts=2:sw=2:tw=78 +#include "StickyButton.moc" diff --git a/clients/kde/StickyButton.h b/clients/kde/StickyButton.h new file mode 100644 index 0000000000..2f615c606a --- /dev/null +++ b/clients/kde/StickyButton.h @@ -0,0 +1,56 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef DEFAULT_STICKY_BUTTON_H +#define DEFAULT_STICKY_BUTTON_H + +#include "Button.h" + +namespace Default +{ + +class StickyButton : public Button +{ + Q_OBJECT + + public: + + StickyButton(QWidget * parent); + + signals: + + void toggleSticky(); + + protected slots: + + void setOn(bool); + + protected: + + void mouseReleaseEvent(QMouseEvent *); +}; + +} // End namespace; + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/clients/kde/TitleBar.cpp b/clients/kde/TitleBar.cpp new file mode 100644 index 0000000000..88a64652b4 --- /dev/null +++ b/clients/kde/TitleBar.cpp @@ -0,0 +1,202 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include + +#include "Manager.h" +#include "TitleBar.h" +#include "TitleText.h" +#include "CloseButton.h" +#include "IconifyButton.h" +#include "StickyButton.h" +#include "MaximiseButton.h" + +namespace Default +{ + +TitleBar::TitleBar(Manager * client) + : QWidget(client) +{ + close_ = new CloseButton (this); + text_ = new TitleText (this, client); + iconify_ = new IconifyButton (this); + maximise_ = new MaximiseButton (this); + sticky_ = new StickyButton (this); + + // Close | Text | Sticky | Iconify | Maximise + + QHBoxLayout * layout = new QHBoxLayout(this); + layout->setMargin(3); + + layout->addWidget(close_); + layout->addSpacing(2); + layout->addWidget(text_, 1); + layout->addSpacing(2); + layout->addWidget(sticky_); + layout->addWidget(iconify_); + layout->addWidget(maximise_); + + connect( + close_, SIGNAL(closeClient()), + client, SLOT(closeWindow()) + ); + + connect( + sticky_, SIGNAL(toggleSticky()), + client, SLOT(toggleSticky()) + ); + + connect( + client, SIGNAL(stickyStatusChanged(bool)), + sticky_, SLOT(setOn(bool)) + ); + + connect( + iconify_, SIGNAL(iconifyClient()), + client, SLOT(iconify()) + ); + + connect( + maximise_, SIGNAL(maximiseClient()), + client, SLOT(maximize()) + ); + + connect( + maximise_, SIGNAL(vMaxClient()), + client, SLOT(vMax()) + ); + + connect( + maximise_, SIGNAL(raiseClient()), + client, SLOT(raise()) + ); + + connect( + client, SIGNAL(maximiseChanged(bool)), + maximise_, SLOT(setOn(bool)) + ); +} + + void +TitleBar::updateDisplay() +{ + close_ ->updateDisplay(); + text_ ->updateDisplay(); + iconify_ ->updateDisplay(); + maximise_ ->updateDisplay(); +} + + void +TitleBar::updateText() +{ + text_->updateDisplay(); +} + +TitleBar::~TitleBar() +{ +} + + void +TitleBar::resizeEvent(QResizeEvent *) +{ + int sizeProblem = 0; + + if (width() < 80) sizeProblem = 3; + else if (width() < 100) sizeProblem = 2; + else if (width() < 120) sizeProblem = 1; + + switch (sizeProblem) { + + case 1: + close_ ->show(); + sticky_ ->hide(); + iconify_ ->show(); + maximise_ ->hide(); + break; + + case 2: + close_ ->show(); + sticky_ ->hide(); + iconify_ ->hide(); + maximise_ ->hide(); + break; + + case 3: + close_ ->hide(); + sticky_ ->hide(); + iconify_ ->hide(); + maximise_ ->hide(); + break; + + case 0: + default: + close_ ->show(); + sticky_ ->show(); + iconify_ ->show(); + maximise_ ->show(); + break; + } +} + + void +TitleBar::setActive(bool b) +{ + sticky_->setActive(b); + close_->setActive(b); + text_->setActive(b); + iconify_->setActive(b); + maximise_->setActive(b); +} + + void +TitleBar::paintEvent(QPaintEvent * e) +{ + QRect r(e->rect()); + + bool intersectsLeft = + r.intersects(QRect(0, 0, 1, height())); + + bool intersectsRight = + r.intersects(QRect(width() - 1, 0, width(), height())); + + bool intersectsTop = + r.intersects(QRect(0, 0, width(), 1)); + + if (intersectsTop || intersectsLeft || intersectsRight) { + + QPainter p(this); + p.setPen(Qt::black); + + if (intersectsTop) + p.drawLine(r.left(), 0, r.right(), 0); + + if (intersectsLeft) + p.drawLine(0, r.top(), 0, r.bottom()); + + if (intersectsRight) + p.drawLine(width() - 1, r.top(), width() - 1, r.bottom()); + } +} + +} // End namespace + +// vim:ts=2:sw=2:tw=78 diff --git a/clients/kde/TitleBar.h b/clients/kde/TitleBar.h new file mode 100644 index 0000000000..4741a6fee8 --- /dev/null +++ b/clients/kde/TitleBar.h @@ -0,0 +1,71 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef DEFAULT_TITLE_BAR_H +#define DEFAULT_TITLE_BAR_H + +#include + +namespace Default +{ + +class Manager; +class StickyButton; +class CloseButton; +class TitleText; +class IconifyButton; +class MaximiseButton; + +class TitleBar : public QWidget +{ + public: + + TitleBar(Manager * client); + virtual ~TitleBar(); + + void updateDisplay(); + void updateText(); + void updateMaximise(bool); + + void setActive(bool); + + protected: + + void resizeEvent(QResizeEvent *); + void paintEvent(QPaintEvent *); + + private: + + CloseButton * close_; + + TitleText * text_; + + StickyButton * sticky_; + IconifyButton * iconify_; + MaximiseButton * maximise_; +}; + +} // End namespace + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/clients/kde/TitleText.cpp b/clients/kde/TitleText.cpp new file mode 100644 index 0000000000..e6d8d369d3 --- /dev/null +++ b/clients/kde/TitleText.cpp @@ -0,0 +1,103 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#include + +#include "../../options.h" + +#include "TitleText.h" +#include "Manager.h" +#include "Static.h" + +namespace Default +{ + +TitleText::TitleText(QWidget * parent, Manager * client) + : DBWidget(parent, "TitleText"), + client_(client), + active_(false) +{ +} + +TitleText::~TitleText() +{ +} + + void +TitleText::setActive(bool b) +{ + active_ = b; + updateDisplay(); +} + + void +TitleText::updatePixmap() +{ + QPainter p(&buf()); + + Static * s = Static::instance(); + + p.drawPixmap(0, 0, s->titleLeft(active_)); + p.drawPixmap(width() - 2, 0, s->titleRight(active_)); + p.drawTiledPixmap(2, 0, width() - 2, height(), s->title(active_)); + + QFontMetrics fm(options->font()); + unsigned int w = fm.width(client_->caption()); + p.drawTiledPixmap( + width() / 2 - w / 2, 0, + w, height(), + s->titleText(active_) + ); + + p.setPen(options->color(Options::Font, active_)); + p.setFont(options->font()); + p.drawText(4, 0, width() - 8, height(), AlignCenter, client_->caption()); +} + + void +TitleText::mousePressEvent(QMouseEvent * e) +{ + client_->fakeMouseEvent(e, this); +} + + void +TitleText::mouseReleaseEvent(QMouseEvent * e) +{ + client_->fakeMouseEvent(e, this); +} + + void +TitleText::mouseMoveEvent(QMouseEvent * e) +{ + client_->fakeMouseEvent(e, this); +} + + void +TitleText::mouseDoubleClickEvent(QMouseEvent * e) +{ + client_->fakeMouseEvent(e, this); +} + +} // End namespace + +// vim:ts=2:sw=2:tw=78 + diff --git a/clients/kde/TitleText.h b/clients/kde/TitleText.h new file mode 100644 index 0000000000..04b8cce9eb --- /dev/null +++ b/clients/kde/TitleText.h @@ -0,0 +1,64 @@ +/* + Default 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., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef DEFAULT_TITLE_TEXT_H +#define DEFAULT_TITLE_TEXT_H + +#include +#include + +#include "DBWidget.h" + +namespace Default +{ + +class Manager; + +class TitleText : public DBWidget +{ + public: + + TitleText(QWidget * parent, Manager * client); + virtual ~TitleText(); + + void setActive(bool); + + protected: + + void updatePixmap(); + + void mousePressEvent(QMouseEvent *); + void mouseReleaseEvent(QMouseEvent *); + void mouseMoveEvent(QMouseEvent *); + void mouseDoubleClickEvent(QMouseEvent *); + + private: + + Manager * client_; + bool active_; +}; + +} // End namespace + +#endif + +// vim:ts=2:sw=2:tw=78 diff --git a/clients/kde/kde.desktop b/clients/kde/kde.desktop new file mode 100644 index 0000000000..019a6fe4cf --- /dev/null +++ b/clients/kde/kde.desktop @@ -0,0 +1,3 @@ +[Desktop Entry] +Name=KDE +X-KDE-Library=libkwinkde