You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
768 lines
18 KiB
768 lines
18 KiB
15 years ago
|
/*
|
||
|
RISC OS KWin client
|
||
|
|
||
|
Copyright 2000
|
||
|
Rik Hemsley <rik@kde.org>
|
||
|
|
||
|
This program is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU General Public
|
||
|
License as published by the Free Software Foundation; either
|
||
|
version 2 of the License, or (at your option) any later version.
|
||
|
|
||
|
This program is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU General Public License
|
||
|
along with this program; see the file COPYING. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
|
#include <unistd.h> // for usleep
|
||
|
#include <config.h> // for usleep on non-linux platforms
|
||
|
#include <math.h> // for sin and cos
|
||
|
|
||
15 years ago
|
#include <tqapplication.h>
|
||
|
#include <tqimage.h>
|
||
|
#include <tqlabel.h>
|
||
|
#include <tqlayout.h>
|
||
|
#include <tqpainter.h>
|
||
15 years ago
|
|
||
|
#include <netwm.h>
|
||
|
|
||
|
#include "Manager.h"
|
||
|
#include "Static.h"
|
||
|
#include "AboveButton.h"
|
||
|
#include "CloseButton.h"
|
||
|
#include "HelpButton.h"
|
||
|
#include "IconifyButton.h"
|
||
|
#include "LowerButton.h"
|
||
|
#include "MaximiseButton.h"
|
||
|
#include "StickyButton.h"
|
||
|
|
||
|
extern "C"
|
||
|
{
|
||
|
KDE_EXPORT KDecorationFactory* create_factory()
|
||
|
{
|
||
|
return new RiscOS::Factory();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
namespace RiscOS
|
||
|
{
|
||
|
|
||
|
Manager::Manager(KDecorationBridge *bridge,
|
||
|
KDecorationFactory *factory)
|
||
|
: KDecoration(bridge, factory),
|
||
|
topLayout_ (NULL),
|
||
|
titleLayout_ (NULL),
|
||
|
titleSpacer_ (NULL)
|
||
|
{
|
||
|
}
|
||
|
|
||
|
Manager::~Manager()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void Manager::init()
|
||
|
{
|
||
|
createMainWidget(WNoAutoErase);
|
||
|
|
||
|
widget()->installEventFilter(this);
|
||
|
widget()->setBackgroundMode(NoBackground);
|
||
|
|
||
|
leftButtonList_.setAutoDelete(true);
|
||
|
rightButtonList_.setAutoDelete(true);
|
||
|
|
||
|
resetLayout();
|
||
|
}
|
||
|
|
||
15 years ago
|
bool Manager::eventFilter(TQObject *o, TQEvent *e)
|
||
15 years ago
|
{
|
||
13 years ago
|
if (TQT_BASE_OBJECT(o) != TQT_BASE_OBJECT(widget())) return false;
|
||
15 years ago
|
switch (e->type())
|
||
|
{
|
||
15 years ago
|
case TQEvent::Resize:
|
||
13 years ago
|
resizeEvent(TQT_TQRESIZEEVENT(e));
|
||
15 years ago
|
return true;
|
||
15 years ago
|
case TQEvent::Paint:
|
||
13 years ago
|
paintEvent(TQT_TQPAINTEVENT(e));
|
||
15 years ago
|
return true;
|
||
15 years ago
|
case TQEvent::MouseButtonDblClick:
|
||
13 years ago
|
mouseDoubleClickEvent(TQT_TQMOUSEEVENT(e));
|
||
15 years ago
|
return true;
|
||
15 years ago
|
case TQEvent::MouseButtonPress:
|
||
13 years ago
|
processMousePressEvent(TQT_TQMOUSEEVENT(e));
|
||
15 years ago
|
return true;
|
||
15 years ago
|
case TQEvent::Wheel:
|
||
13 years ago
|
wheelEvent( TQT_TQWHEELEVENT( e ));
|
||
15 years ago
|
return true;
|
||
15 years ago
|
case TQEvent::MouseButtonRelease:
|
||
15 years ago
|
return false;
|
||
15 years ago
|
case TQEvent::Show:
|
||
15 years ago
|
return false;
|
||
15 years ago
|
case TQEvent::MouseMove:
|
||
15 years ago
|
return false;
|
||
15 years ago
|
case TQEvent::Enter:
|
||
15 years ago
|
return false;
|
||
15 years ago
|
case TQEvent::Leave:
|
||
15 years ago
|
return false;
|
||
15 years ago
|
case TQEvent::Move:
|
||
15 years ago
|
return false;
|
||
|
default:
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void Manager::reset(unsigned long /*changed*/)
|
||
|
{
|
||
|
resetLayout();
|
||
|
}
|
||
|
|
||
|
void Manager::borders(int &left, int &right, int &top, int &bottom) const
|
||
|
{
|
||
|
left = right = 1;
|
||
|
top = Static::instance()->titleHeight();
|
||
|
bottom = isResizable() ? Static::instance()->resizeHeight() : 1;
|
||
|
}
|
||
|
|
||
15 years ago
|
void Manager::resize(const TQSize &s)
|
||
15 years ago
|
{
|
||
|
widget()->resize(s);
|
||
|
}
|
||
|
|
||
13 years ago
|
TQSize Manager::tqminimumSize() const
|
||
15 years ago
|
{
|
||
13 years ago
|
return widget()->tqminimumSize();
|
||
15 years ago
|
}
|
||
|
|
||
|
void Manager::activeChange()
|
||
|
{
|
||
|
updateTitleBuffer();
|
||
13 years ago
|
widget()->tqrepaint();
|
||
15 years ago
|
emit(activeChanged(isActive()));
|
||
|
}
|
||
|
|
||
|
void Manager::captionChange()
|
||
|
{
|
||
|
updateTitleBuffer();
|
||
13 years ago
|
widget()->tqrepaint();
|
||
15 years ago
|
}
|
||
|
|
||
|
void Manager::iconChange()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void Manager::maximizeChange()
|
||
|
{
|
||
|
emit(maximizeChanged(maximizeMode() == MaximizeFull));
|
||
|
}
|
||
|
|
||
|
void Manager::desktopChange()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
void Manager::shadeChange()
|
||
|
{
|
||
|
}
|
||
|
|
||
15 years ago
|
void Manager::paintEvent(TQPaintEvent *e)
|
||
15 years ago
|
{
|
||
15 years ago
|
TQPainter p(widget());
|
||
15 years ago
|
|
||
15 years ago
|
TQRect r(e->rect());
|
||
15 years ago
|
|
||
15 years ago
|
bool intersectsLeft = r.intersects(TQRect(0, 0, 1, height()));
|
||
15 years ago
|
|
||
|
bool intersectsRight =
|
||
15 years ago
|
r.intersects(TQRect(width() - 1, 0, width(), height()));
|
||
15 years ago
|
|
||
|
if (intersectsLeft || intersectsRight)
|
||
|
{
|
||
13 years ago
|
p.setPen(TQt::black);
|
||
15 years ago
|
|
||
|
if (intersectsLeft)
|
||
|
p.drawLine(0, r.top(), 0, r.bottom());
|
||
|
|
||
|
if (intersectsRight)
|
||
|
p.drawLine(width() - 1, r.top(), width() - 1, r.bottom());
|
||
|
}
|
||
|
|
||
|
Static * s = Static::instance();
|
||
|
|
||
|
bool active = isActive();
|
||
|
|
||
|
// Title bar.
|
||
|
|
||
13 years ago
|
TQRect tr = titleSpacer_->tqgeometry();
|
||
15 years ago
|
bitBlt(widget(), tr.topLeft(), &titleBuf_);
|
||
|
|
||
|
// Resize bar.
|
||
|
|
||
|
if (isResizable())
|
||
|
{
|
||
|
int rbt = height() - Static::instance()->resizeHeight(); // Resize bar top
|
||
|
|
||
|
bitBlt(widget(), 0, rbt, &(s->resize(active)));
|
||
|
bitBlt(widget(), 30, rbt, &(s->resizeMidLeft(active)));
|
||
|
|
||
|
p.drawTiledPixmap(32, rbt, width() - 34,
|
||
|
Static::instance()->resizeHeight(),
|
||
|
s->resizeMidMid(active));
|
||
|
|
||
|
bitBlt(widget(), width() - 32, rbt, &(s->resizeMidRight(active)));
|
||
|
bitBlt(widget(), width() - 30, rbt, &(s->resize(active)));
|
||
|
}
|
||
|
else
|
||
|
p.drawLine(1, height() - 1, width() - 2, height() - 1);
|
||
|
}
|
||
|
|
||
15 years ago
|
void Manager::resizeEvent(TQResizeEvent*)
|
||
15 years ago
|
{
|
||
|
updateButtonVisibility();
|
||
|
updateTitleBuffer();
|
||
13 years ago
|
widget()->tqrepaint();
|
||
15 years ago
|
}
|
||
|
|
||
|
void Manager::updateButtonVisibility()
|
||
|
{
|
||
|
#if 0
|
||
|
enum SizeProblem = { None, Small, Medium, Big };
|
||
|
SizeProblem sizeProblem = None;
|
||
|
|
||
|
if (width() < 80) sizeProblem = Big;
|
||
|
else if (width() < 100) sizeProblem = Medium;
|
||
|
else if (width() < 180) sizeProblem = Small;
|
||
|
|
||
|
switch (sizeProblem) {
|
||
|
|
||
|
case Small:
|
||
|
above_ ->hide();
|
||
|
lower_ ->hide();
|
||
|
sticky_ ->hide();
|
||
|
help_ ->hide();
|
||
|
iconify_ ->show();
|
||
|
maximise_ ->hide();
|
||
|
close_ ->show();
|
||
|
break;
|
||
|
|
||
|
case Medium:
|
||
|
above_ ->hide();
|
||
|
lower_ ->hide();
|
||
|
sticky_ ->hide();
|
||
|
help_ ->hide();
|
||
|
iconify_ ->hide();
|
||
|
maximise_ ->hide();
|
||
|
close_ ->show();
|
||
|
break;
|
||
|
|
||
|
case Big:
|
||
|
above_ ->hide();
|
||
|
lower_ ->hide();
|
||
|
sticky_ ->hide();
|
||
|
help_ ->hide();
|
||
|
iconify_ ->hide();
|
||
|
maximise_ ->hide();
|
||
|
close_ ->hide();
|
||
|
break;
|
||
|
|
||
|
case None:
|
||
|
default:
|
||
|
above_ ->show();
|
||
|
lower_ ->show();
|
||
|
sticky_ ->show();
|
||
|
if (providesContextHelp())
|
||
|
help_->show();
|
||
|
iconify_ ->show();
|
||
|
maximise_ ->show();
|
||
|
close_ ->show();
|
||
|
break;
|
||
|
}
|
||
|
|
||
13 years ago
|
tqlayout()->activate();
|
||
15 years ago
|
#endif
|
||
|
}
|
||
|
|
||
|
void Manager::updateTitleBuffer()
|
||
|
{
|
||
|
bool active = isActive();
|
||
|
|
||
|
Static * s = Static::instance();
|
||
|
|
||
13 years ago
|
TQRect tr = titleSpacer_->tqgeometry();
|
||
15 years ago
|
|
||
|
if (tr.width() == 0 || tr.height() == 0)
|
||
|
titleBuf_.resize(8, 8);
|
||
|
else
|
||
|
titleBuf_.resize(tr.size());
|
||
|
|
||
15 years ago
|
TQPainter p(&titleBuf_);
|
||
15 years ago
|
|
||
|
p.drawPixmap(0, 0, s->titleTextLeft(active));
|
||
|
|
||
|
p.drawTiledPixmap(3, 0, tr.width() - 6, Static::instance()->titleHeight(),
|
||
|
s->titleTextMid(active));
|
||
|
|
||
|
p.setPen(options()->color(KDecorationOptions::ColorFont, active));
|
||
|
|
||
|
p.setFont(options()->font(active));
|
||
|
|
||
|
p.drawText(4, 2, tr.width() - 8, Static::instance()->titleHeight() - 4,
|
||
|
AlignCenter, caption());
|
||
|
|
||
|
p.drawPixmap(tr.width() - 3, 0, s->titleTextRight(active));
|
||
|
}
|
||
|
|
||
15 years ago
|
KDecoration::Position Manager::mousePosition(const TQPoint& p) const
|
||
15 years ago
|
{
|
||
|
Position m = PositionCenter;
|
||
|
|
||
|
// Look out for off-by-one errors here.
|
||
|
|
||
|
if (isResizable())
|
||
|
{
|
||
|
if (p.y() > (height() - (Static::instance()->resizeHeight() + 1)))
|
||
|
{
|
||
|
// Keep order !
|
||
|
|
||
|
if (p.x() >= (width() - 30))
|
||
|
m = PositionBottomRight;
|
||
|
else if (p.x() <= 30)
|
||
|
m = PositionBottomLeft;
|
||
|
else
|
||
|
m = PositionBottom;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
m = PositionCenter;
|
||
|
// Client::mousePosition(p);
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
m = PositionCenter;
|
||
|
// Client::mousePosition(p);
|
||
|
}
|
||
|
|
||
|
return m;
|
||
|
}
|
||
|
|
||
15 years ago
|
void Manager::mouseDoubleClickEvent(TQMouseEvent *e)
|
||
15 years ago
|
{
|
||
13 years ago
|
if (e->button() == Qt::LeftButton && titleSpacer_->tqgeometry().contains(e->pos()))
|
||
15 years ago
|
titlebarDblClickOperation();
|
||
|
}
|
||
|
|
||
15 years ago
|
void Manager::wheelEvent(TQWheelEvent *e)
|
||
15 years ago
|
{
|
||
13 years ago
|
if (isSetShade() || titleLayout_->tqgeometry().contains(e->pos()) )
|
||
15 years ago
|
titlebarMouseWheelOperation( e->delta());
|
||
|
}
|
||
|
|
||
15 years ago
|
void Manager::paletteChange(const TQPalette &)
|
||
15 years ago
|
{
|
||
|
resetLayout();
|
||
|
}
|
||
|
|
||
|
void Manager::stickyChange(bool b)
|
||
|
{
|
||
|
emit(stickyChanged(b));
|
||
|
}
|
||
|
|
||
|
void Manager::slotToggleSticky()
|
||
|
{
|
||
|
toggleOnAllDesktops();
|
||
|
emit(stickyChanged(isOnAllDesktops()));
|
||
|
}
|
||
|
|
||
|
void Manager::slotAbove()
|
||
|
{
|
||
|
setKeepAbove(!keepAbove());
|
||
|
}
|
||
|
|
||
|
void Manager::slotLower()
|
||
|
{
|
||
|
setKeepBelow(!keepBelow());
|
||
|
}
|
||
|
|
||
|
void Manager::slotMaximizeClicked(ButtonState state)
|
||
|
{
|
||
|
#if KDE_IS_VERSION(3, 3, 0)
|
||
|
maximize(state);
|
||
|
#else
|
||
|
switch (state)
|
||
|
{
|
||
|
case RightButton:
|
||
|
maximize(maximizeMode() ^ MaximizeHorizontal);
|
||
|
break;
|
||
|
|
||
|
case MidButton:
|
||
|
maximize(maximizeMode() ^ MaximizeVertical);
|
||
|
break;
|
||
|
|
||
|
case LeftButton:
|
||
|
default:
|
||
|
maximize(maximizeMode() == MaximizeFull ? MaximizeRestore
|
||
|
: MaximizeFull);
|
||
|
break;
|
||
|
}
|
||
|
#endif
|
||
|
emit(maximizeChanged(maximizeMode() == MaximizeFull));
|
||
|
}
|
||
|
|
||
|
bool Manager::animateMinimize(bool iconify)
|
||
|
{
|
||
|
int style = Static::instance()->animationStyle();
|
||
|
|
||
|
switch (style)
|
||
|
{
|
||
|
case 1:
|
||
|
{
|
||
|
// Double twisting double back, with pike ;)
|
||
|
|
||
|
if (!iconify) // No animation for restore.
|
||
|
return true;
|
||
|
|
||
|
// Go away quick.
|
||
|
helperShowHide(false);
|
||
13 years ago
|
tqApp->syncX();
|
||
15 years ago
|
|
||
15 years ago
|
TQRect r = iconGeometry();
|
||
15 years ago
|
|
||
|
if (!r.isValid())
|
||
|
return true;
|
||
|
|
||
|
// Algorithm taken from Window Maker (http://www.windowmaker.org)
|
||
|
|
||
|
int sx = geometry().x();
|
||
|
int sy = geometry().y();
|
||
|
int sw = width();
|
||
|
int sh = height();
|
||
|
int dx = r.x();
|
||
|
int dy = r.y();
|
||
|
int dw = r.width();
|
||
|
int dh = r.height();
|
||
|
|
||
|
double steps = 12;
|
||
|
|
||
|
double xstep = double((dx-sx)/steps);
|
||
|
double ystep = double((dy-sy)/steps);
|
||
|
double wstep = double((dw-sw)/steps);
|
||
|
double hstep = double((dh-sh)/steps);
|
||
|
|
||
|
double cx = sx;
|
||
|
double cy = sy;
|
||
|
double cw = sw;
|
||
|
double ch = sh;
|
||
|
|
||
|
double finalAngle = 3.14159265358979323846;
|
||
|
|
||
|
double delta = finalAngle / steps;
|
||
|
|
||
15 years ago
|
TQPainter p(workspaceWidget());
|
||
13 years ago
|
p.setRasterOp(TQt::NotROP);
|
||
15 years ago
|
|
||
|
for (double angle = 0; ; angle += delta)
|
||
|
{
|
||
|
if (angle > finalAngle)
|
||
|
angle = finalAngle;
|
||
|
|
||
|
double dx = (cw / 10) - ((cw / 5) * sin(angle));
|
||
|
double dch = (ch / 2) * cos(angle);
|
||
|
double midy = cy + (ch / 2);
|
||
|
|
||
15 years ago
|
TQPoint p1(int(cx + dx), int(midy - dch));
|
||
|
TQPoint p2(int(cx + cw - dx), p1.y());
|
||
|
TQPoint p3(int(cx + dw + dx), int(midy + dch));
|
||
|
TQPoint p4(int(cx - dx), p3.y());
|
||
15 years ago
|
|
||
|
grabXServer();
|
||
|
|
||
|
p.drawLine(p1, p2);
|
||
|
p.drawLine(p2, p3);
|
||
|
p.drawLine(p3, p4);
|
||
|
p.drawLine(p4, p1);
|
||
|
|
||
|
p.flush();
|
||
|
|
||
|
usleep(500);
|
||
|
|
||
|
p.drawLine(p1, p2);
|
||
|
p.drawLine(p2, p3);
|
||
|
p.drawLine(p3, p4);
|
||
|
p.drawLine(p4, p1);
|
||
|
|
||
|
ungrabXServer();
|
||
|
|
||
|
cx += xstep;
|
||
|
cy += ystep;
|
||
|
cw += wstep;
|
||
|
ch += hstep;
|
||
|
|
||
|
if (angle >= finalAngle)
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case 2:
|
||
|
{
|
||
|
// KVirc style ? Maybe. For qwertz.
|
||
|
|
||
|
if (!iconify) // No animation for restore.
|
||
|
return true;
|
||
|
|
||
|
// Go away quick.
|
||
|
helperShowHide(false);
|
||
13 years ago
|
tqApp->syncX();
|
||
15 years ago
|
|
||
|
int stepCount = 12;
|
||
|
|
||
15 years ago
|
TQRect r(geometry());
|
||
15 years ago
|
|
||
|
int dx = r.width() / (stepCount * 2);
|
||
|
int dy = r.height() / (stepCount * 2);
|
||
|
|
||
15 years ago
|
TQPainter p(workspaceWidget());
|
||
13 years ago
|
p.setRasterOp(TQt::NotROP);
|
||
15 years ago
|
|
||
|
for (int step = 0; step < stepCount; step++)
|
||
|
{
|
||
|
r.moveBy(dx, dy);
|
||
|
r.setWidth(r.width() - 2 * dx);
|
||
|
r.setHeight(r.height() - 2 * dy);
|
||
|
|
||
|
grabXServer();
|
||
|
|
||
|
p.drawRect(r);
|
||
|
p.flush();
|
||
|
usleep(200);
|
||
|
p.drawRect(r);
|
||
|
|
||
|
ungrabXServer();
|
||
|
}
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
|
||
|
default:
|
||
|
{
|
||
15 years ago
|
TQRect icongeom = iconGeometry();
|
||
15 years ago
|
|
||
|
if (!icongeom.isValid())
|
||
|
return true;
|
||
|
|
||
15 years ago
|
TQRect wingeom = geometry();
|
||
15 years ago
|
|
||
15 years ago
|
TQPainter p(workspaceWidget());
|
||
15 years ago
|
|
||
13 years ago
|
p.setRasterOp(TQt::NotROP);
|
||
15 years ago
|
#if 0
|
||
|
if (iconify)
|
||
15 years ago
|
p.setClipRegion(TQRegion(workspaceWidget()->rect()) - wingeom);
|
||
15 years ago
|
#endif
|
||
|
grabXServer();
|
||
|
|
||
|
p.drawLine(wingeom.bottomRight(), icongeom.bottomRight());
|
||
|
p.drawLine(wingeom.bottomLeft(), icongeom.bottomLeft());
|
||
|
p.drawLine(wingeom.topLeft(), icongeom.topLeft());
|
||
|
p.drawLine(wingeom.topRight(), icongeom.topRight());
|
||
|
|
||
|
p.flush();
|
||
|
|
||
13 years ago
|
tqApp->syncX();
|
||
15 years ago
|
|
||
|
usleep(30000);
|
||
|
|
||
|
p.drawLine(wingeom.bottomRight(), icongeom.bottomRight());
|
||
|
p.drawLine(wingeom.bottomLeft(), icongeom.bottomLeft());
|
||
|
p.drawLine(wingeom.topLeft(), icongeom.topLeft());
|
||
|
p.drawLine(wingeom.topRight(), icongeom.topRight());
|
||
|
|
||
|
ungrabXServer();
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
void Manager::createTitle()
|
||
|
{
|
||
|
leftButtonList_.clear();
|
||
|
rightButtonList_.clear();
|
||
|
|
||
15 years ago
|
TQString buttons;
|
||
15 years ago
|
|
||
|
if (options()->customButtonPositions())
|
||
|
buttons = options()->titleButtonsLeft() + "|" +
|
||
|
options()->titleButtonsRight();
|
||
|
else
|
||
|
buttons = "XSH|IA";
|
||
|
|
||
15 years ago
|
TQPtrList<Button> *buttonList = &leftButtonList_;
|
||
15 years ago
|
|
||
|
for (unsigned int i = 0; i < buttons.length(); ++i)
|
||
|
{
|
||
|
Button * tb = NULL;
|
||
|
|
||
|
switch (buttons[i].latin1())
|
||
|
{
|
||
|
case 'S': // Sticky
|
||
|
tb = new StickyButton(widget());
|
||
15 years ago
|
connect(this, TQT_SIGNAL(stickyChanged(bool)),
|
||
|
tb, TQT_SLOT(setOn(bool)));
|
||
|
connect(tb, TQT_SIGNAL(toggleSticky()), this, TQT_SLOT(slotToggleSticky()));
|
||
15 years ago
|
emit(stickyChanged(isOnAllDesktops()));
|
||
|
break;
|
||
|
|
||
|
case 'H': // Help
|
||
|
if (providesContextHelp())
|
||
|
{
|
||
|
tb = new HelpButton(widget());
|
||
15 years ago
|
connect(tb, TQT_SIGNAL(help()), this, TQT_SLOT(showContextHelp()));
|
||
15 years ago
|
}
|
||
|
break;
|
||
|
|
||
|
case 'I': // Minimize
|
||
|
if (isMinimizable())
|
||
|
{
|
||
|
tb = new IconifyButton(widget());
|
||
15 years ago
|
connect(tb, TQT_SIGNAL(iconify()), this, TQT_SLOT(minimize()));
|
||
15 years ago
|
}
|
||
|
break;
|
||
|
|
||
|
case 'A': // Maximize
|
||
|
if (isMaximizable())
|
||
|
{
|
||
|
tb = new MaximiseButton(widget());
|
||
15 years ago
|
connect(tb, TQT_SIGNAL(maximizeClicked(ButtonState)),
|
||
|
this, TQT_SLOT(slotMaximizeClicked(ButtonState)));
|
||
|
connect(this, TQT_SIGNAL(maximizeChanged(bool)),
|
||
|
tb, TQT_SLOT(setOn(bool)));
|
||
15 years ago
|
emit(maximizeChanged(maximizeMode() == MaximizeFull));
|
||
|
}
|
||
|
break;
|
||
|
|
||
|
case 'F': // Above
|
||
|
tb = new AboveButton(widget());
|
||
15 years ago
|
connect(tb, TQT_SIGNAL(above()), this, TQT_SLOT(slotAbove()));
|
||
15 years ago
|
break;
|
||
|
|
||
|
case 'B': // Lower
|
||
|
tb = new LowerButton(widget());
|
||
15 years ago
|
connect(tb, TQT_SIGNAL(lower()), this, TQT_SLOT(slotLower()));
|
||
15 years ago
|
break;
|
||
|
|
||
|
case 'X': // Close
|
||
|
if (isCloseable())
|
||
|
{
|
||
|
tb = new CloseButton(widget());
|
||
15 years ago
|
connect(tb, TQT_SIGNAL(closeWindow()), this, TQT_SLOT(closeWindow()));
|
||
15 years ago
|
}
|
||
|
break;
|
||
|
|
||
|
case '|':
|
||
|
buttonList = &rightButtonList_;
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
if (tb != NULL)
|
||
|
{
|
||
15 years ago
|
connect(this, TQT_SIGNAL(activeChanged(bool)), tb, TQT_SLOT(setActive(bool)));
|
||
15 years ago
|
buttonList->append(tb);
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
for (TQPtrListIterator<Button> it(leftButtonList_); it.current(); ++it)
|
||
15 years ago
|
{
|
||
13 years ago
|
it.current()->tqsetAlignment(Button::Left);
|
||
15 years ago
|
titleLayout_->addWidget(it.current());
|
||
|
}
|
||
|
|
||
15 years ago
|
titleSpacer_ = new TQSpacerItem(0, Static::instance()->titleHeight(),
|
||
|
TQSizePolicy::Expanding, TQSizePolicy::Fixed);
|
||
15 years ago
|
|
||
|
titleLayout_->addItem(titleSpacer_);
|
||
|
|
||
15 years ago
|
for (TQPtrListIterator<Button> it(rightButtonList_); it.current(); ++it)
|
||
15 years ago
|
{
|
||
13 years ago
|
it.current()->tqsetAlignment(Button::Right);
|
||
15 years ago
|
titleLayout_->addWidget(it.current());
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void Manager::resetLayout()
|
||
|
{
|
||
|
delete topLayout_;
|
||
15 years ago
|
topLayout_ = new TQVBoxLayout(widget(), 0, 0);
|
||
|
topLayout_->setResizeMode(TQLayout::FreeResize);
|
||
15 years ago
|
|
||
15 years ago
|
titleLayout_ = new TQBoxLayout(topLayout_, TQBoxLayout::LeftToRight, 0, 0);
|
||
|
titleLayout_->setResizeMode(TQLayout::FreeResize);
|
||
15 years ago
|
|
||
|
createTitle();
|
||
|
|
||
15 years ago
|
TQBoxLayout *midLayout = new TQBoxLayout(topLayout_, TQBoxLayout::LeftToRight,
|
||
15 years ago
|
0, 0);
|
||
15 years ago
|
midLayout->setResizeMode(TQLayout::FreeResize);
|
||
15 years ago
|
midLayout->addSpacing(1);
|
||
|
if (isPreview())
|
||
|
midLayout->addWidget(
|
||
15 years ago
|
new TQLabel(i18n("<center><b>RiscOS preview</b></center>"), widget()));
|
||
15 years ago
|
midLayout->addSpacing(1);
|
||
|
|
||
|
if (isResizable())
|
||
|
topLayout_->addSpacing(Static::instance()->resizeHeight());
|
||
|
else
|
||
|
topLayout_->addSpacing(1);
|
||
|
}
|
||
|
|
||
|
// --------------------
|
||
|
|
||
|
Factory::Factory()
|
||
|
{
|
||
|
(void) RiscOS::Static::instance();
|
||
|
}
|
||
|
|
||
|
Factory::~Factory()
|
||
|
{
|
||
|
delete RiscOS::Static::instance();
|
||
|
}
|
||
|
|
||
|
bool Factory::reset(unsigned long /*changed*/)
|
||
|
{
|
||
|
RiscOS::Static::instance()->reset();
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
bool Factory::supports( Ability ability )
|
||
|
{
|
||
|
switch( ability )
|
||
|
{
|
||
|
case AbilityAnnounceButtons:
|
||
|
case AbilityButtonOnAllDesktops:
|
||
|
case AbilityButtonHelp:
|
||
|
case AbilityButtonMinimize:
|
||
|
case AbilityButtonMaximize:
|
||
|
case AbilityButtonClose:
|
||
|
case AbilityButtonAboveOthers:
|
||
|
case AbilityButtonBelowOthers:
|
||
|
return true;
|
||
|
default:
|
||
|
return false;
|
||
|
};
|
||
|
}
|
||
|
|
||
|
KDecoration* Factory::createDecoration(KDecorationBridge *bridge)
|
||
|
{
|
||
|
return new Manager(bridge, this);
|
||
|
}
|
||
|
|
||
|
} // End namespace
|
||
|
|
||
|
// vim:ts=2:sw=2:tw=78
|
||
|
#include "Manager.moc"
|