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.
|
|
|
|
*/
|
|
|
|
|
2000-10-14 23:45:05 +00:00
|
|
|
#include <unistd.h> // for usleep
|
2000-10-17 08:15:00 +00:00
|
|
|
#include <config.h> // for usleep on non-linux platforms
|
2000-10-27 02:16:14 +00:00
|
|
|
#include <math.h> // for sin and cos
|
2000-10-14 23:45:05 +00:00
|
|
|
|
2000-04-10 17:18:21 +00:00
|
|
|
#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>
|
2000-10-10 22:03:50 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
#include <kapp.h>
|
2000-10-14 23:45:05 +00:00
|
|
|
#include <netwm.h>
|
|
|
|
|
2000-04-10 17:18:21 +00:00
|
|
|
#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-10-21 18:51:08 +00:00
|
|
|
Client * allocate(Workspace * workSpace, WId winId, int tool)
|
2000-04-10 17:18:21 +00:00
|
|
|
{
|
2000-10-21 18:51:08 +00:00
|
|
|
if (tool)
|
|
|
|
return new RiscOS::ToolManager(workSpace, winId);
|
|
|
|
else
|
|
|
|
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);
|
|
|
|
|
2000-10-10 22:03:50 +00:00
|
|
|
QStringList leftButtons = Static::instance()->leftButtons();
|
|
|
|
QStringList rightButtons = Static::instance()->rightButtons();
|
|
|
|
|
2000-09-27 21:33:15 +00:00
|
|
|
QVBoxLayout * l = new QVBoxLayout(this, 0, 0);
|
2000-10-21 22:05:42 +00:00
|
|
|
l->setResizeMode(QLayout::FreeResize);
|
2000-09-27 21:33:15 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
2000-10-10 22:03:50 +00:00
|
|
|
buttonDict_.insert("Lower", lower_);
|
|
|
|
buttonDict_.insert("Close", close_);
|
|
|
|
buttonDict_.insert("Sticky", sticky_);
|
|
|
|
buttonDict_.insert("Iconify", iconify_);
|
|
|
|
buttonDict_.insert("Maximize", maximise_);
|
|
|
|
buttonDict_.insert("Help", help_);
|
|
|
|
|
2000-10-11 17:21:49 +00:00
|
|
|
if (!providesContextHelp())
|
|
|
|
help_->hide();
|
|
|
|
|
2000-10-10 22:03:50 +00:00
|
|
|
QStringList::ConstIterator it;
|
2000-09-27 21:33:15 +00:00
|
|
|
|
2000-10-10 22:03:50 +00:00
|
|
|
for (it = leftButtons.begin(); it != leftButtons.end(); ++it)
|
|
|
|
if (buttonDict_[*it])
|
|
|
|
buttonDict_[*it]->setAlignment(Button::Left);
|
|
|
|
|
|
|
|
for (it = rightButtons.begin(); it != rightButtons.end(); ++it)
|
|
|
|
if (buttonDict_[*it])
|
2000-10-21 18:51:08 +00:00
|
|
|
buttonDict_[*it]->setAlignment(Button::Right);
|
2000-09-27 21:33:15 +00:00
|
|
|
|
|
|
|
QHBoxLayout * titleLayout = new QHBoxLayout(l);
|
2000-10-21 22:05:42 +00:00
|
|
|
titleLayout->setResizeMode(QLayout::FreeResize);
|
2000-09-27 21:33:15 +00:00
|
|
|
|
2000-10-10 22:03:50 +00:00
|
|
|
for (it = leftButtons.begin(); it != leftButtons.end(); ++it)
|
|
|
|
if (buttonDict_[*it])
|
|
|
|
titleLayout->addWidget(buttonDict_[*it]);
|
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
titleSpacer_ =
|
|
|
|
new QSpacerItem(
|
|
|
|
0,
|
|
|
|
Static::instance()->titleHeight(),
|
|
|
|
QSizePolicy::Expanding,
|
|
|
|
QSizePolicy::Fixed
|
|
|
|
);
|
|
|
|
|
2000-09-27 21:33:15 +00:00
|
|
|
titleLayout->addItem(titleSpacer_);
|
2000-10-10 22:03:50 +00:00
|
|
|
|
|
|
|
for (it = rightButtons.begin(); it != rightButtons.end(); ++it)
|
|
|
|
if (buttonDict_[*it])
|
|
|
|
titleLayout->addWidget(buttonDict_[*it]);
|
2000-04-10 17:18:21 +00:00
|
|
|
|
2000-09-27 21:33:15 +00:00
|
|
|
QHBoxLayout * midLayout = new QHBoxLayout(l);
|
2000-10-21 22:05:42 +00:00
|
|
|
midLayout->setResizeMode(QLayout::FreeResize);
|
2000-09-27 21:33:15 +00:00
|
|
|
midLayout->addSpacing(1);
|
|
|
|
midLayout->addWidget(windowWrapper());
|
|
|
|
midLayout->addSpacing(1);
|
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
l->addSpacing(Static::instance()->resizeHeight());
|
2000-09-27 21:33:15 +00:00
|
|
|
|
2000-10-11 17:21:49 +00:00
|
|
|
connect(options, SIGNAL(resetClients()), this, SLOT(slotReset()));
|
2000-04-10 17:18:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Manager::~Manager()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
// Title bar.
|
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
QRect tr = titleSpacer_->geometry();
|
|
|
|
bitBlt(this, tr.topLeft(), &titleBuf_);
|
2000-09-27 21:33:15 +00:00
|
|
|
|
|
|
|
// Resize bar.
|
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
int rbt = height() - Static::instance()->resizeHeight(); // Resize bar top.
|
2000-09-27 21:33:15 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
bitBlt(this, 0, rbt, &(s->resize(active)));
|
|
|
|
bitBlt(this, 30, rbt, &(s->resizeMidLeft(active)));
|
2000-09-27 21:33:15 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
p.drawTiledPixmap(
|
|
|
|
32,
|
|
|
|
rbt,
|
|
|
|
width() - 34,
|
|
|
|
Static::instance()->resizeHeight(),
|
|
|
|
s->resizeMidMid(active)
|
|
|
|
);
|
2000-09-27 21:33:15 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
bitBlt(this, width() - 32, rbt, &(s->resizeMidRight(active)));
|
|
|
|
bitBlt(this, width() - 30, rbt, &(s->resize(active)));
|
2000-05-11 03:52:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2000-10-21 22:05:42 +00:00
|
|
|
Manager::resizeEvent(QResizeEvent * e)
|
2000-05-10 19:55:13 +00:00
|
|
|
{
|
2000-10-21 22:05:42 +00:00
|
|
|
Client::resizeEvent(e);
|
2000-10-27 02:16:14 +00:00
|
|
|
updateButtonVisibility();
|
|
|
|
updateTitleBuffer();
|
|
|
|
repaint();
|
|
|
|
}
|
2000-10-21 22:05:42 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
void
|
|
|
|
Manager::updateButtonVisibility()
|
|
|
|
{
|
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-31 02:48:56 +00:00
|
|
|
|
|
|
|
layout()->activate();
|
2000-10-27 02:16:14 +00:00
|
|
|
}
|
2000-10-01 15:40:29 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
void
|
|
|
|
Manager::updateTitleBuffer()
|
|
|
|
{
|
|
|
|
bool active = isActive();
|
|
|
|
|
|
|
|
Static * s = Static::instance();
|
|
|
|
|
|
|
|
QRect tr = titleSpacer_->geometry();
|
|
|
|
|
2000-10-31 02:48:56 +00:00
|
|
|
if (tr.width() == 0 || tr.height() == 0)
|
|
|
|
titleBuf_.resize(8, 8);
|
|
|
|
else
|
|
|
|
titleBuf_.resize(tr.size());
|
2000-10-27 02:16:14 +00:00
|
|
|
|
|
|
|
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(Options::Font, active));
|
|
|
|
|
|
|
|
p.setFont(options->font(true)); // XXX false doesn't work right at the moment
|
|
|
|
|
|
|
|
p.drawText(
|
|
|
|
4,
|
|
|
|
2,
|
|
|
|
tr.width() - 8,
|
|
|
|
Static::instance()->titleHeight() - 4,
|
|
|
|
AlignCenter, caption()
|
|
|
|
);
|
|
|
|
|
|
|
|
p.drawPixmap(tr.width() - 3, 0, s->titleTextRight(active));
|
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;
|
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
if (p.y() > (height() - Static::instance()->resizeHeight())) {
|
2000-09-27 21:33:15 +00:00
|
|
|
// 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-10-11 17:21:49 +00:00
|
|
|
void
|
|
|
|
Manager::slotReset()
|
|
|
|
{
|
2000-10-27 02:16:14 +00:00
|
|
|
for (QDictIterator<Button> it(buttonDict_); it.current(); ++it)
|
|
|
|
it.current()->update();
|
2000-10-11 17:21:49 +00:00
|
|
|
Static::instance()->update();
|
|
|
|
repaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Manager::captionChange(const QString &)
|
|
|
|
{
|
2000-10-27 02:16:14 +00:00
|
|
|
updateTitleBuffer();
|
2000-10-11 17:21:49 +00:00
|
|
|
repaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Manager::paletteChange(const QPalette &)
|
|
|
|
{
|
2000-10-27 02:16:14 +00:00
|
|
|
slotReset();
|
2000-10-11 17:21:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Manager::activeChange(bool b)
|
|
|
|
{
|
|
|
|
emit(activeChanged(b));
|
2000-10-27 02:16:14 +00:00
|
|
|
updateTitleBuffer();
|
2000-10-11 17:21:49 +00:00
|
|
|
repaint();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Manager::maximizeChange(bool b)
|
|
|
|
{
|
|
|
|
emit(maximiseChanged(b));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Manager::stickyChange(bool b)
|
|
|
|
{
|
|
|
|
emit(stickyChanged(b));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Manager::slotLower()
|
|
|
|
{
|
|
|
|
workspace()->lowerClient(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Manager::slotRaise()
|
|
|
|
{
|
|
|
|
workspace()->raiseClient(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Manager::slotVMax()
|
|
|
|
{
|
|
|
|
maximize(MaximizeVertical);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Manager::slotSetSticky(bool b)
|
|
|
|
{
|
|
|
|
setSticky(b);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
Manager::slotHelp()
|
|
|
|
{
|
|
|
|
contextHelp();
|
|
|
|
}
|
|
|
|
|
2000-10-14 23:45:05 +00:00
|
|
|
void
|
|
|
|
Manager::animateIconifyOrDeiconify(bool iconify)
|
|
|
|
{
|
2000-10-27 02:16:14 +00:00
|
|
|
animate(iconify, Static::instance()->animationStyle());
|
2000-10-14 23:45:05 +00:00
|
|
|
}
|
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
void Manager::animate(bool iconify, int style)
|
2000-10-21 18:51:08 +00:00
|
|
|
{
|
2000-10-27 02:16:14 +00:00
|
|
|
switch (style) {
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
// Double twisting double back, with pike ;)
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
if (!iconify) // No animation for restore.
|
|
|
|
return;
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
// Go away quick.
|
|
|
|
hide();
|
|
|
|
qApp->syncX();
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
NETRect r = netWinInfo()->iconGeometry();
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
if (!QRect(r.pos.x, r.pos.y, r.size.width, r.size.height).isValid())
|
|
|
|
return;
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
// Algorithm taken from Window Maker (http://www.windowmaker.org)
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
int sx = x();
|
|
|
|
int sy = y();
|
|
|
|
int sw = width();
|
|
|
|
int sh = height();
|
|
|
|
int dx = r.pos.x;
|
|
|
|
int dy = r.pos.y;
|
|
|
|
int dw = r.size.width;
|
|
|
|
int dh = r.size.height;
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
double steps = 12;
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
double xstep = double((dx-sx)/steps);
|
|
|
|
double ystep = double((dy-sy)/steps);
|
|
|
|
double wstep = double((dw-sw)/steps);
|
|
|
|
double hstep = double((dh-sh)/steps);
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
double cx = sx;
|
|
|
|
double cy = sy;
|
|
|
|
double cw = sw;
|
|
|
|
double ch = sh;
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
double finalAngle = 3.14159265358979323846;
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
double delta = finalAngle / steps;
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
QPainter p(workspace()->desktopWidget());
|
|
|
|
p.setRasterOp(Qt::NotROP);
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
for (double angle = 0; ; angle += delta) {
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
if (angle > finalAngle)
|
|
|
|
angle = finalAngle;
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
double dx = (cw / 10) - ((cw / 5) * sin(angle));
|
|
|
|
double dch = (ch / 2) * cos(angle);
|
|
|
|
double midy = cy + (ch / 2);
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
QPoint p1(cx + dx, midy - dch);
|
|
|
|
QPoint p2(cx + cw - dx, p1.y());
|
|
|
|
QPoint p3(cx + dw + dx, midy + dch);
|
|
|
|
QPoint p4(cx - dx, p3.y());
|
|
|
|
|
|
|
|
XGrabServer(qt_xdisplay());
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
p.drawLine(p1, p2);
|
|
|
|
p.drawLine(p2, p3);
|
|
|
|
p.drawLine(p3, p4);
|
|
|
|
p.drawLine(p4, p1);
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
p.flush();
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
usleep(500);
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
p.drawLine(p1, p2);
|
|
|
|
p.drawLine(p2, p3);
|
|
|
|
p.drawLine(p3, p4);
|
|
|
|
p.drawLine(p4, p1);
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
XUngrabServer(qt_xdisplay());
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
kapp->processEvents();
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
cx += xstep;
|
|
|
|
cy += ystep;
|
|
|
|
cw += wstep;
|
|
|
|
ch += hstep;
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
if (angle >= finalAngle)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-28 02:32:07 +00:00
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
// KVirc style ? Maybe. For qwertz.
|
|
|
|
|
|
|
|
if (!iconify) // No animation for restore.
|
|
|
|
return;
|
|
|
|
|
|
|
|
// Go away quick.
|
|
|
|
hide();
|
|
|
|
qApp->syncX();
|
|
|
|
|
|
|
|
int stepCount = 12;
|
|
|
|
|
|
|
|
QRect r(geometry());
|
|
|
|
|
|
|
|
int dx = r.width() / (stepCount * 2);
|
|
|
|
int dy = r.height() / (stepCount * 2);
|
|
|
|
|
|
|
|
QPainter p(workspace()->desktopWidget());
|
|
|
|
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);
|
|
|
|
|
|
|
|
XGrabServer(qt_xdisplay());
|
|
|
|
|
|
|
|
p.drawRect(r);
|
|
|
|
p.flush();
|
|
|
|
usleep(200);
|
|
|
|
p.drawRect(r);
|
|
|
|
|
|
|
|
XUngrabServer(qt_xdisplay());
|
|
|
|
|
|
|
|
kapp->processEvents();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
NETRect r = netWinInfo()->iconGeometry();
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
QRect icongeom(r.pos.x, r.pos.y, r.size.width, r.size.height);
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
if (!icongeom.isValid())
|
|
|
|
return;
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
QRect wingeom(x(), y(), width(), height());
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
QPainter p(workspace()->desktopWidget());
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
p.setRasterOp(Qt::NotROP);
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
if (iconify)
|
|
|
|
p.setClipRegion(
|
|
|
|
QRegion(workspace()->desktopWidget()->rect()) - wingeom
|
|
|
|
);
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
XGrabServer(qt_xdisplay());
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
p.drawLine(wingeom.bottomRight(), icongeom.bottomRight());
|
|
|
|
p.drawLine(wingeom.bottomLeft(), icongeom.bottomLeft());
|
|
|
|
p.drawLine(wingeom.topLeft(), icongeom.topLeft());
|
|
|
|
p.drawLine(wingeom.topRight(), icongeom.topRight());
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
p.flush();
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
qApp->syncX();
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
usleep(30000);
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
p.drawLine(wingeom.bottomRight(), icongeom.bottomRight());
|
|
|
|
p.drawLine(wingeom.bottomLeft(), icongeom.bottomLeft());
|
|
|
|
p.drawLine(wingeom.topLeft(), icongeom.topLeft());
|
|
|
|
p.drawLine(wingeom.topRight(), icongeom.topRight());
|
2000-10-21 18:51:08 +00:00
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
XUngrabServer(qt_xdisplay());
|
|
|
|
}
|
|
|
|
break;
|
2000-10-21 18:51:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
ToolManager::ToolManager(
|
|
|
|
Workspace * workSpace,
|
|
|
|
WId id,
|
|
|
|
QWidget * parent,
|
|
|
|
const char * name
|
|
|
|
)
|
|
|
|
: Manager(workSpace, id, parent, name)
|
2000-10-21 18:51:08 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2000-10-27 02:16:14 +00:00
|
|
|
ToolManager::~ToolManager()
|
2000-10-21 18:51:08 +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"
|