2000-04-10 17:18:21 +00:00
|
|
|
/*
|
2000-07-15 11:27:55 +00:00
|
|
|
RISC OS KWin client
|
2000-09-25 15:30:51 +00:00
|
|
|
|
2000-04-10 17:18:21 +00:00
|
|
|
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., 59 Temple Place - Suite 330,
|
|
|
|
Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <qpainter.h>
|
2000-09-28 14:29:57 +00:00
|
|
|
#include <qimage.h>
|
2000-04-10 17:18:21 +00:00
|
|
|
#include <qlayout.h>
|
|
|
|
#include "../../options.h"
|
|
|
|
#include "../../workspace.h"
|
|
|
|
|
|
|
|
#include "Manager.h"
|
|
|
|
#include "Static.h"
|
2000-09-27 21:33:15 +00:00
|
|
|
#include "LowerButton.h"
|
|
|
|
#include "CloseButton.h"
|
|
|
|
#include "IconifyButton.h"
|
|
|
|
#include "MaximiseButton.h"
|
2000-09-27 22:51:57 +00:00
|
|
|
#include "StickyButton.h"
|
|
|
|
#include "HelpButton.h"
|
2000-04-10 17:18:21 +00:00
|
|
|
|
|
|
|
extern "C"
|
|
|
|
{
|
2000-09-25 15:30:51 +00:00
|
|
|
Client * allocate(Workspace * workSpace, WId winId, int)
|
2000-04-10 17:18:21 +00:00
|
|
|
{
|
2000-07-15 11:27:55 +00:00
|
|
|
return new RiscOS::Manager(workSpace, winId);
|
2000-04-10 17:18:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-07-15 11:27:55 +00:00
|
|
|
namespace RiscOS
|
2000-04-10 17:18:21 +00:00
|
|
|
{
|
|
|
|
|
2000-09-28 14:29:57 +00:00
|
|
|
|
2000-04-10 17:18:21 +00:00
|
|
|
Manager::Manager(
|
|
|
|
Workspace * workSpace,
|
|
|
|
WId id,
|
|
|
|
QWidget * parent,
|
|
|
|
const char * name
|
|
|
|
)
|
2000-04-12 00:13:14 +00:00
|
|
|
: Client(workSpace, id, parent, name)
|
2000-04-10 17:18:21 +00:00
|
|
|
{
|
|
|
|
setBackgroundMode(NoBackground);
|
|
|
|
|
|
|
|
connect(options, SIGNAL(resetClients()), this, SLOT(slotReset()));
|
|
|
|
|
2000-09-27 21:33:15 +00:00
|
|
|
QVBoxLayout * l = new QVBoxLayout(this, 0, 0);
|
|
|
|
|
|
|
|
lower_ = new LowerButton (this);
|
|
|
|
close_ = new CloseButton (this);
|
2000-09-27 22:51:57 +00:00
|
|
|
sticky_ = new StickyButton (this);
|
2000-09-27 21:33:15 +00:00
|
|
|
iconify_ = new IconifyButton (this);
|
|
|
|
maximise_ = new MaximiseButton (this);
|
2000-09-27 22:51:57 +00:00
|
|
|
help_ = new HelpButton (this);
|
|
|
|
|
|
|
|
if (!providesContextHelp())
|
|
|
|
help_->hide();
|
2000-09-27 21:33:15 +00:00
|
|
|
|
|
|
|
lower_ ->setAlignment(Button::Left);
|
|
|
|
close_ ->setAlignment(Button::Left);
|
2000-09-27 22:51:57 +00:00
|
|
|
sticky_ ->setAlignment(Button::Left);
|
|
|
|
help_ ->setAlignment(Button::Right);
|
2000-09-27 21:33:15 +00:00
|
|
|
iconify_ ->setAlignment(Button::Right);
|
|
|
|
maximise_ ->setAlignment(Button::Right);
|
|
|
|
|
|
|
|
// Lower | Close | Text | Iconify | Maximise
|
|
|
|
|
|
|
|
QHBoxLayout * titleLayout = new QHBoxLayout(l);
|
|
|
|
|
|
|
|
titleLayout->addWidget(lower_);
|
|
|
|
titleLayout->addWidget(close_);
|
2000-09-27 22:51:57 +00:00
|
|
|
titleLayout->addWidget(sticky_);
|
2000-09-27 21:33:15 +00:00
|
|
|
titleSpacer_ = new QSpacerItem(0, 20);
|
|
|
|
titleLayout->addItem(titleSpacer_);
|
2000-09-27 22:51:57 +00:00
|
|
|
titleLayout->addWidget(help_);
|
2000-09-27 21:33:15 +00:00
|
|
|
titleLayout->addWidget(iconify_);
|
|
|
|
titleLayout->addWidget(maximise_);
|
2000-04-10 17:18:21 +00:00
|
|
|
|
2000-09-27 21:33:15 +00:00
|
|
|
QHBoxLayout * midLayout = new QHBoxLayout(l);
|
|
|
|
midLayout->addSpacing(1);
|
|
|
|
midLayout->addWidget(windowWrapper());
|
|
|
|
midLayout->addSpacing(1);
|
|
|
|
|
|
|
|
l->addSpacing(10);
|
|
|
|
|
2000-09-27 22:51:57 +00:00
|
|
|
connect(lower_, SIGNAL(lowerClient()), SLOT(lower()));
|
|
|
|
connect(close_, SIGNAL(closeClient()), SLOT(closeWindow()));
|
|
|
|
connect(iconify_, SIGNAL(iconifyClient()), SLOT(iconify()));
|
|
|
|
connect(sticky_, SIGNAL(stickClient()), SLOT(stick()));
|
|
|
|
connect(sticky_, SIGNAL(unstickClient()), SLOT(unstick()));
|
|
|
|
connect(maximise_, SIGNAL(maximiseClient()), SLOT(maximize()));
|
|
|
|
connect(maximise_, SIGNAL(vMaxClient()), SLOT(vMax()));
|
|
|
|
connect(maximise_, SIGNAL(raiseClient()), SLOT(raise()));
|
|
|
|
connect(help_, SIGNAL(help()), SLOT(help()));
|
|
|
|
|
|
|
|
connect(
|
|
|
|
this, SIGNAL(maximiseChanged(bool)),
|
|
|
|
maximise_, SLOT(setOn(bool)));
|
|
|
|
|
|
|
|
connect(
|
|
|
|
this, SIGNAL(stickyChanged(bool)),
|
|
|
|
sticky_, SLOT(setOn(bool)));
|
2000-04-10 17:18:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Manager::~Manager()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Manager::slotReset()
|
|
|
|
{
|
|
|
|
Static::instance()->update();
|
2000-09-27 21:33:15 +00:00
|
|
|
repaint();
|
2000-04-10 17:18:21 +00:00
|
|
|
}
|
2000-09-25 15:30:51 +00:00
|
|
|
|
2000-04-10 17:18:21 +00:00
|
|
|
void
|
|
|
|
Manager::captionChange(const QString &)
|
|
|
|
{
|
2000-09-27 21:33:15 +00:00
|
|
|
repaint();
|
2000-04-10 17:18:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Manager::paletteChange(const QPalette &)
|
|
|
|
{
|
2000-09-25 15:30:51 +00:00
|
|
|
Static::instance()->update();
|
2000-09-27 21:33:15 +00:00
|
|
|
repaint();
|
2000-04-10 17:18:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-09-27 22:51:57 +00:00
|
|
|
Manager::activeChange(bool b)
|
2000-04-10 17:18:21 +00:00
|
|
|
{
|
2000-09-27 22:51:57 +00:00
|
|
|
lower_ ->setActive(b);
|
|
|
|
close_ ->setActive(b);
|
|
|
|
sticky_ ->setActive(b);
|
|
|
|
iconify_ ->setActive(b);
|
|
|
|
maximise_ ->setActive(b);
|
|
|
|
help_ ->setActive(b);
|
|
|
|
|
2000-09-27 21:33:15 +00:00
|
|
|
repaint();
|
2000-04-10 17:18:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Manager::maximizeChange(bool b)
|
|
|
|
{
|
2000-05-11 03:52:24 +00:00
|
|
|
emit(maximiseChanged(b));
|
2000-04-10 17:18:21 +00:00
|
|
|
}
|
|
|
|
|
2000-09-27 22:51:57 +00:00
|
|
|
void
|
|
|
|
Manager::stickyChange(bool b)
|
|
|
|
{
|
|
|
|
emit(stickyChanged(b));
|
|
|
|
}
|
|
|
|
|
2000-04-10 17:18:21 +00:00
|
|
|
void
|
|
|
|
Manager::paintEvent(QPaintEvent * e)
|
|
|
|
{
|
2000-09-27 21:33:15 +00:00
|
|
|
QPainter p(this);
|
|
|
|
|
2000-04-10 17:18:21 +00:00
|
|
|
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());
|
2000-09-25 15:30:51 +00:00
|
|
|
|
2000-04-10 17:18:21 +00:00
|
|
|
if (intersectsRight)
|
|
|
|
p.drawLine(width() - 1, r.top(), width() - 1, r.bottom());
|
|
|
|
}
|
2000-09-25 15:30:51 +00:00
|
|
|
|
2000-09-27 21:33:15 +00:00
|
|
|
Static * s = Static::instance();
|
|
|
|
|
|
|
|
bool active = isActive();
|
|
|
|
|
|
|
|
QRect tr = titleSpacer_->geometry();
|
|
|
|
|
|
|
|
// Title bar.
|
|
|
|
p.drawPixmap(tr.left(), 0, s->titleTextLeft(active));
|
|
|
|
|
|
|
|
p.drawTiledPixmap(tr.left() + 3, 0, tr.width() - 6, 20, s->titleTextMid(active));
|
|
|
|
p.setPen(options->color(Options::Font, active));
|
2000-09-28 00:39:22 +00:00
|
|
|
p.setFont(options->font(active));
|
2000-09-27 21:33:15 +00:00
|
|
|
p.drawText(tr.left() + 4, 0, tr.width() - 8, 18, AlignCenter, caption());
|
|
|
|
|
|
|
|
p.drawPixmap(tr.right() - 2, 0, s->titleTextRight(active));
|
|
|
|
|
|
|
|
// Resize bar.
|
|
|
|
|
|
|
|
int rbt = height() - 10; // Resize bar top.
|
|
|
|
|
|
|
|
p.drawPixmap(0, rbt, s->resize(active));
|
|
|
|
|
|
|
|
p.drawPixmap(30, rbt, s->resizeMidLeft(active));
|
|
|
|
p.drawTiledPixmap(32, rbt, width() - 34, 10, s->resizeMidMid(active));
|
|
|
|
p.drawPixmap(width() - 32, rbt, s->resizeMidRight(active));
|
|
|
|
|
|
|
|
p.drawPixmap(width() - 30, rbt, s->resize(active));
|
2000-05-11 03:52:24 +00:00
|
|
|
}
|
|
|
|
|
2000-05-10 19:55:13 +00:00
|
|
|
void
|
2000-07-15 11:27:55 +00:00
|
|
|
Manager::lower()
|
2000-05-10 19:55:13 +00:00
|
|
|
{
|
2000-07-15 11:27:55 +00:00
|
|
|
workspace()->lowerClient(this);
|
2000-05-11 03:52:24 +00:00
|
|
|
}
|
2000-05-10 19:55:13 +00:00
|
|
|
|
2000-05-11 03:52:24 +00:00
|
|
|
void
|
|
|
|
Manager::raise()
|
|
|
|
{
|
|
|
|
workspace()->raiseClient(this);
|
2000-05-10 19:55:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-05-11 03:52:24 +00:00
|
|
|
Manager::vMax()
|
2000-05-10 19:55:13 +00:00
|
|
|
{
|
2000-05-11 03:52:24 +00:00
|
|
|
maximize(MaximizeVertical);
|
|
|
|
}
|
2000-05-10 19:55:13 +00:00
|
|
|
|
2000-09-27 22:51:57 +00:00
|
|
|
void
|
|
|
|
Manager::stick()
|
|
|
|
{
|
|
|
|
setSticky(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Manager::unstick()
|
|
|
|
{
|
|
|
|
setSticky(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Manager::help()
|
|
|
|
{
|
|
|
|
contextHelp();
|
|
|
|
}
|
|
|
|
|
2000-05-11 03:52:24 +00:00
|
|
|
void
|
2000-09-27 21:33:15 +00:00
|
|
|
Manager::resizeEvent(QResizeEvent *)
|
2000-05-10 19:55:13 +00:00
|
|
|
{
|
2000-09-27 21:33:15 +00:00
|
|
|
int sizeProblem = 0;
|
|
|
|
|
|
|
|
if (width() < 80) sizeProblem = 3;
|
|
|
|
else if (width() < 100) sizeProblem = 2;
|
2000-10-01 15:40:29 +00:00
|
|
|
else if (width() < 180) sizeProblem = 1;
|
2000-09-27 21:33:15 +00:00
|
|
|
|
|
|
|
switch (sizeProblem) {
|
|
|
|
|
|
|
|
case 1:
|
|
|
|
lower_ ->hide();
|
2000-09-27 22:51:57 +00:00
|
|
|
sticky_ ->hide();
|
|
|
|
help_ ->hide();
|
2000-09-27 21:33:15 +00:00
|
|
|
iconify_ ->show();
|
|
|
|
maximise_ ->hide();
|
|
|
|
close_ ->show();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
lower_ ->hide();
|
2000-09-27 22:51:57 +00:00
|
|
|
sticky_ ->hide();
|
|
|
|
help_ ->hide();
|
2000-09-27 21:33:15 +00:00
|
|
|
iconify_ ->hide();
|
|
|
|
maximise_ ->hide();
|
|
|
|
close_ ->show();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3:
|
|
|
|
lower_ ->hide();
|
2000-09-27 22:51:57 +00:00
|
|
|
sticky_ ->hide();
|
|
|
|
help_ ->hide();
|
2000-09-27 21:33:15 +00:00
|
|
|
iconify_ ->hide();
|
|
|
|
maximise_ ->hide();
|
|
|
|
close_ ->hide();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 0:
|
|
|
|
default:
|
|
|
|
lower_ ->show();
|
2000-09-27 22:51:57 +00:00
|
|
|
sticky_ ->show();
|
|
|
|
if (providesContextHelp())
|
|
|
|
help_->show();
|
2000-09-27 21:33:15 +00:00
|
|
|
iconify_ ->show();
|
|
|
|
maximise_ ->show();
|
|
|
|
close_ ->show();
|
|
|
|
break;
|
|
|
|
}
|
2000-10-01 15:40:29 +00:00
|
|
|
|
|
|
|
repaint();
|
2000-05-10 19:55:13 +00:00
|
|
|
}
|
2000-04-10 17:18:21 +00:00
|
|
|
|
2000-09-27 21:33:15 +00:00
|
|
|
Client::MousePosition
|
|
|
|
Manager::mousePosition(const QPoint & p) const
|
2000-05-11 04:17:35 +00:00
|
|
|
{
|
2000-09-27 21:33:15 +00:00
|
|
|
MousePosition m = Center;
|
|
|
|
|
|
|
|
if (p.y() > (height() - 10)) {
|
|
|
|
// Keep order !
|
|
|
|
if (p.x() >= (width() - 30))
|
|
|
|
m = BottomRight;
|
|
|
|
else if (p.x() <= 30)
|
|
|
|
m = BottomLeft;
|
|
|
|
else
|
|
|
|
m = Bottom;
|
|
|
|
}
|
2000-05-11 04:17:35 +00:00
|
|
|
|
2000-09-27 21:33:15 +00:00
|
|
|
return m;
|
2000-05-11 04:17:35 +00:00
|
|
|
}
|
|
|
|
|
2000-09-25 15:30:51 +00:00
|
|
|
void
|
2000-09-27 21:33:15 +00:00
|
|
|
Manager::mouseDoubleClickEvent(QMouseEvent * e)
|
2000-09-11 03:34:01 +00:00
|
|
|
{
|
2000-09-27 21:33:15 +00:00
|
|
|
if (titleSpacer_->geometry().contains(e->pos()))
|
|
|
|
workspace()
|
|
|
|
->performWindowOperation(this, options->operationTitlebarDblClick());
|
|
|
|
workspace()->requestFocus(this);
|
2000-09-11 03:34:01 +00:00
|
|
|
}
|
|
|
|
|
2000-04-10 17:18:21 +00:00
|
|
|
} // End namespace
|
|
|
|
|
|
|
|
// vim:ts=2:sw=2:tw=78
|
2000-06-29 21:36:40 +00:00
|
|
|
#include "Manager.moc"
|