Many fixes to RISC OS client. Still needs major work to be perfect.

Changed spaces to tab for ettrich in client.cpp ;)
Changed something that looked like it was trying to do manhattanLength()
so it actually does.

svn path=/trunk/kdebase/kwin/; revision=49144
This commit is contained in:
Rik Hemsley 2000-05-11 03:52:24 +00:00
parent 3ac4896a57
commit baa151afb3
20 changed files with 205 additions and 197 deletions

View file

@ -946,7 +946,7 @@ void Client::mouseMoveEvent( QMouseEvent * e)
if ( !moveResizeMode )
{
QPoint p( e->pos() - moveOffset );
if ( (QABS( p.x()) >= 4) || (QABS( p.y() ) >= 4 )) {
if (p.manhattanLength() >= 6) {
moveResizeMode = TRUE;
Events::raise( isResize() ? Events::ResizeStart : Events::MoveStart );
grabMouse( cursor() ); // to keep the right cursor
@ -1501,7 +1501,7 @@ void Client::setShade( bool s )
clearWFlags( WNorthWestGravity );
resize ( s );
windowWrapper()->show();
activateLayout();
activateLayout();
repaint();
if ( isActive() )
workspace()->requestFocus( this );

View file

@ -20,24 +20,18 @@
Boston, MA 02111-1307, USA.
*/
#include <qpixmap.h>
#include <qpainter.h>
#include "../../options.h"
#include "Button.h"
#include "Manager.h"
#include "Static.h"
namespace RiscOS
{
Button::Button(QWidget * parent, Manager * client, SymbolType t)
Button::Button(QWidget * parent, SymbolType t)
: QWidget (parent, "Button", WRepaintNoErase | WPaintUnclipped),
client_ (client),
type_ (t),
align_ (Left),
down_ (false)
down_ (false),
active_ (false)
{
setFixedSize(19, 20);
}
@ -50,9 +44,26 @@ Button::~Button()
void
Button::updateDisplay()
{
setBackgroundPixmap(Static::instance()->button(type_, client_->isActive(), down_));
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

View file

@ -23,42 +23,45 @@
#ifndef RISC_OS_BUTTON_H
#define RISC_OS_BUTTON_H
#include <qwidget.h>
#include "Static.h"
#include <qwidget.h>
namespace RiscOS
{
class Manager;
class Button : public QWidget
{
Q_OBJECT
public:
enum Alignment { Left, Right };
Button(QWidget * parent, Manager * client, SymbolType);
enum SymbolType;
Button(QWidget * parent, SymbolType);
virtual ~Button();
void updateDisplay();
void setAlign(Alignment a) { align_ = a; updateDisplay(); }
void setType(SymbolType t) { type_ = t; updateDisplay(); }
void setType(SymbolType t);
void setActive(bool);
protected:
Manager * client() { return client_; }
bool active() const { return active_; }
void mousePressEvent(QMouseEvent *) { down_ = true; updateDisplay(); }
void mouseReleaseEvent(QMouseEvent *) { down_ = false; updateDisplay(); }
private:
Manager * client_;
SymbolType type_;
Alignment align_;
bool down_;
bool active_;
};
} // End namespace

View file

@ -21,14 +21,12 @@
*/
#include "CloseButton.h"
#include "Manager.h"
#include "Static.h"
namespace RiscOS
{
CloseButton::CloseButton(QWidget * parent, Manager * client)
: Button(parent, client, Close)
CloseButton::CloseButton(QWidget * parent)
: Button(parent, Close)
{
}
@ -43,16 +41,16 @@ CloseButton::mouseReleaseEvent(QMouseEvent * e)
switch (e->button())
{
case RightButton:
client()->closeWindow();
emit(closeClient());
break;
case MidButton:
client()->closeWindow();
emit(closeClient());
break;
case LeftButton:
default:
client()->closeWindow();
emit(closeClient());
break;
}
}

View file

@ -28,13 +28,17 @@
namespace RiscOS
{
class Manager;
class CloseButton : public Button
{
Q_OBJECT
public:
CloseButton(QWidget * parent, Manager * client);
CloseButton(QWidget * parent);
signals:
void closeClient();
protected:

View file

@ -21,14 +21,12 @@
*/
#include "IconifyButton.h"
#include "Manager.h"
#include "Static.h"
namespace RiscOS
{
IconifyButton::IconifyButton(QWidget * parent, Manager * client)
: Button(parent, client, Iconify)
IconifyButton::IconifyButton(QWidget * parent)
: Button(parent, Iconify)
{
}
@ -43,16 +41,16 @@ IconifyButton::mouseReleaseEvent(QMouseEvent * e)
switch (e->button())
{
case RightButton:
client()->iconify();
emit(iconifyClient());
break;
case MidButton:
client()->iconify();
emit(iconifyClient());
break;
case LeftButton:
default:
client()->iconify();
emit(iconifyClient());
break;
}

View file

@ -28,14 +28,17 @@
namespace RiscOS
{
class Manager;
class IconifyButton : public Button
{
Q_OBJECT
public:
IconifyButton(QWidget * parent, Manager * client);
IconifyButton(QWidget * parent);
signals:
void iconifyClient();
protected:

View file

@ -20,17 +20,13 @@
Boston, MA 02111-1307, USA.
*/
#include "../../workspace.h"
#include "LowerButton.h"
#include "Manager.h"
#include "Static.h"
namespace RiscOS
{
LowerButton::LowerButton(QWidget * parent, Manager * client)
: Button(parent, client, Lower)
LowerButton::LowerButton(QWidget * parent)
: Button(parent, Lower)
{
}
@ -45,13 +41,12 @@ LowerButton::mouseReleaseEvent(QMouseEvent * e)
switch (e->button())
{
default:
client()->workspace()->lowerClient(client());
emit(lowerClient());
break;
}
}
} // End namespace;
// vim:ts=2:sw=2:tw=78

View file

@ -28,13 +28,17 @@
namespace RiscOS
{
class Manager;
class LowerButton : public Button
{
Q_OBJECT
public:
LowerButton(QWidget * parent, Manager * client);
LowerButton(QWidget * parent);
signals:
void lowerClient();
protected:

View file

@ -38,5 +38,6 @@ lnk_DATA = riscos.desktop
EXTRA_DIST = $(lnk_DATA)
libkwinriscos_la_LDFLAGS = $(all_libraries) -version-info 1:0:0 -module -rdynamic
libkwinriscos_la_LIBADD = $(LIB_QT) ../../kwin.la
libkwinriscos_la_LDFLAGS = $(all_libraries) -version-info 1:0:0 -module -rdynamic -no-undefined

View file

@ -50,30 +50,14 @@ Manager::Manager(
)
: Client(workSpace, id, parent, name)
{
Static::instance();
setBackgroundMode(NoBackground);
connect(options, SIGNAL(resetClients()), this, SLOT(slotReset()));
titleBar_ = new TitleBar(this, this);
titleBar_ = new TitleBar(this);
resizeBar_ = new ResizeBar(this, this);
// Border Window Border
QHBoxLayout * windowLayout = new QHBoxLayout(0, "windowLayout");
windowLayout->addSpacing(1);
windowLayout->addWidget(windowWrapper(), 1);
windowLayout->addSpacing(1);
// Titlebar (has own single pixel border)
// Window
// Resize bar (has own single pixel border)
QVBoxLayout * mainLayout = new QVBoxLayout(this, 0, 0, "mainLayout");
mainLayout->addWidget(titleBar_);
mainLayout->addLayout(windowLayout, 1);
mainLayout->addWidget(resizeBar_);
updateDisplay();
activateLayout();
}
Manager::~Manager()
@ -84,8 +68,7 @@ Manager::~Manager()
Manager::slotReset()
{
Static::instance()->update();
titleBar_->updateDisplay();
resizeBar_->updateDisplay();
_updateDisplay();
}
void
@ -98,46 +81,23 @@ Manager::captionChange(const QString &)
Manager::paletteChange(const QPalette &)
{
Static::instance()->update();
titleBar_->updateDisplay();
_updateDisplay();
}
void
Manager::activeChange(bool)
Manager::activeChange(bool b)
{
titleBar_->updateDisplay();
resizeBar_->updateDisplay();
titleBar_->setActive(b);
}
void
Manager::maximizeChange(bool b)
{
titleBar_->updateMaximise(b);
emit(maximiseChanged(b));
}
void
Manager::maximizeAndRaise()
{
maximize(MaximizeFull);
workspace()->raiseClient(this);
workspace()->requestFocus(this);
}
void
Manager::maximizeVertically()
{
maximize(MaximizeVertical);
workspace()->raiseClient(this);
workspace()->requestFocus(this);
}
void
Manager::maximizeNoRaise()
{
maximize(MaximizeFull);
}
void
Manager::updateDisplay()
Manager::_updateDisplay()
{
titleBar_->updateDisplay();
resizeBar_->updateDisplay();
@ -173,31 +133,54 @@ Manager::paintEvent(QPaintEvent * e)
}
}
void
Manager::mouseMoveEvent(QMouseEvent * e)
Client::MousePosition
Manager::mousePosition(const QPoint & p) const
{
if ((e->pos().x() == 0) || (e->pos().y() == 0))
return;
Client::mouseMoveEvent(e);
if (titleBar_->rect().contains(p))
return Client::Center;
else
return Client::Nowhere;
}
void
Manager::mousePressEvent(QMouseEvent * e)
Manager::lower()
{
if ((e->pos().x() == 0) || (e->pos().y() == 0))
return;
Client::mousePressEvent(e);
workspace()->lowerClient(this);
}
void
Manager::mouseReleaseEvent(QMouseEvent * e)
Manager::raise()
{
if ((e->pos().x() == 0) || (e->pos().y() == 0))
return;
workspace()->raiseClient(this);
}
Client::mouseReleaseEvent(e);
void
Manager::vMax()
{
maximize(MaximizeVertical);
}
void
Manager::resizeEvent(QResizeEvent * e)
{
Client::resizeEvent(e);
_updateLayout();
}
void
Manager::_updateLayout()
{
titleBar_ -> setGeometry(0, 0, width(), 20);
windowWrapper() -> setGeometry(1, 20, width() - 2, height() - 30);
resizeBar_ -> setGeometry(0, height() - 10, width(), 10);
_updateDisplay();
}
void
Manager::activateLayout()
{
_updateLayout();
}
} // End namespace

View file

@ -35,35 +35,44 @@ class Manager : public Client
{
Q_OBJECT
friend class TitleText;
public:
Manager(Workspace *, WId, QWidget * parent = 0, const char * name = 0);
~Manager();
void maximizeVertically();
void maximizeAndRaise();
void maximizeNoRaise();
void setShade(bool);
void updateDisplay();
signals:
void maximiseChanged(bool);
public slots:
void lower();
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 mouseMoveEvent(QMouseEvent *);
void mousePressEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *);
void resizeEvent(QResizeEvent *);
void activateLayout();
protected slots:
void captionChange(const QString &);
void slotReset();
private:
void _updateDisplay();
void _updateLayout();
TitleBar * titleBar_;
ResizeBar * resizeBar_;

View file

@ -21,14 +21,12 @@
*/
#include "MaximiseButton.h"
#include "Static.h"
#include "Manager.h"
namespace RiscOS
{
MaximiseButton::MaximiseButton(QWidget * parent, Manager * client)
: Button(parent, client, Max)
MaximiseButton::MaximiseButton(QWidget * parent)
: Button(parent, Max)
{
}
@ -50,16 +48,17 @@ MaximiseButton::mouseReleaseEvent(QMouseEvent * e)
switch (e->button())
{
case RightButton:
client()->maximizeNoRaise();
emit(maximiseClient());
break;
case MidButton:
client()->maximizeVertically();
emit(vMaxClient());
break;
case LeftButton:
default:
client()->maximizeAndRaise();
emit(raiseClient());
emit(maximiseClient());
break;
}
}

View file

@ -23,23 +23,29 @@
#ifndef RISC_OS_MAXIMISE_BUTTON_H
#define RISC_OS_MAXIMISE_BUTTON_H
#include <qwidget.h>
#include "Button.h"
namespace RiscOS
{
class Manager;
class MaximiseButton : public Button
{
Q_OBJECT
public:
MaximiseButton(QWidget * parent, Manager * client);
MaximiseButton(QWidget * parent);
public slots:
void setOn(bool);
signals:
void maximiseClient();
void raiseClient();
void vMaxClient();
protected:
void mouseReleaseEvent(QMouseEvent *);

View file

@ -84,4 +84,7 @@ in the lower right corner of the window (actually inside the window).
To emulate this would mean covering part of the window with the decorations,
which is not acceptable. RISC OS gets away with it by making sure that
there is a vertical scrollbar visible at all times, which is just stupid.
It's also an impossibility with X11, as the window manager does not know
anything about scrollbars - they belong to the application, so don't ask
me to implement it.

View file

@ -36,7 +36,6 @@ ResizeBar::ResizeBar(QWidget * parent, Manager * client)
client_ (client)
{
setBackgroundMode(NoBackground);
setFixedHeight(10);
left_ = new ResizeSide(this, client_, ResizeSide::Left);
mid_ = new ResizeMid(this, client_);

View file

@ -33,18 +33,16 @@
namespace RiscOS
{
TitleBar::TitleBar(QWidget * parent, Manager * client)
: QWidget(parent),
client_(client)
TitleBar::TitleBar(Manager * client)
: QWidget(client)
{
setBackgroundMode(NoBackground);
setFixedHeight(20);
lower_ = new LowerButton (this, client_);
close_ = new CloseButton (this, client_);
text_ = new TitleText (this, client_);
iconify_ = new IconifyButton (this, client_);
maximise_ = new MaximiseButton (this, client_);
lower_ = new LowerButton (this);
close_ = new CloseButton (this);
text_ = new TitleText (this, client);
iconify_ = new IconifyButton (this);
maximise_ = new MaximiseButton (this);
lower_ ->setAlign(Button::Left);
close_ ->setAlign(Button::Left);
@ -60,6 +58,14 @@ TitleBar::TitleBar(QWidget * parent, Manager * client)
layout->addWidget(text_, 1);
layout->addWidget(iconify_);
layout->addWidget(maximise_);
connect(lower_, SIGNAL(lowerClient()), client, SLOT(lower()));
connect(close_, SIGNAL(closeClient()), client, SLOT(closeWindow()));
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
@ -72,12 +78,6 @@ TitleBar::updateDisplay()
maximise_ ->updateDisplay();
}
void
TitleBar::updateMaximise(bool b)
{
maximise_->setOn(b);
}
void
TitleBar::updateText()
{
@ -89,7 +89,7 @@ TitleBar::~TitleBar()
}
void
TitleBar::resizeEvent(QResizeEvent * e)
TitleBar::resizeEvent(QResizeEvent *)
{
int sizeProblem = 0;
@ -128,8 +128,16 @@ TitleBar::resizeEvent(QResizeEvent * e)
close_ ->show();
break;
}
}
QWidget::resizeEvent(e);
void
TitleBar::setActive(bool b)
{
lower_->setActive(b);
close_->setActive(b);
text_->setActive(b);
iconify_->setActive(b);
maximise_->setActive(b);
}
} // End namespace

View file

@ -39,13 +39,15 @@ class TitleBar : public QWidget
{
public:
TitleBar(QWidget * parent, Manager * client);
TitleBar(Manager * client);
virtual ~TitleBar();
void updateDisplay();
void updateText();
void updateMaximise(bool);
void setActive(bool);
protected:
void resizeEvent(QResizeEvent *);
@ -59,8 +61,6 @@ class TitleBar : public QWidget
IconifyButton * iconify_;
MaximiseButton * maximise_;
Manager * client_;
};
} // End namespace

View file

@ -34,25 +34,33 @@ namespace RiscOS
TitleText::TitleText(QWidget * parent, Manager * client)
: DBWidget(parent, "TitleText"),
client_(client)
client_(client),
active_(false)
{
setFixedHeight(20);
}
TitleText::~TitleText()
{
}
void
TitleText::setActive(bool b)
{
active_ = b;
updateDisplay();
}
void
TitleText::updatePixmap()
{
QPainter p(&buf());
p.drawPixmap(0, 0, Static::instance()->titleTextLeft(client_->isActive()));
p.drawPixmap(width() - 3, 0, Static::instance()->titleTextRight(client_->isActive()));
p.drawTiledPixmap(3, 0, width() - 6, 20, Static::instance()->titleTextMid(client_->isActive()));
Static * s = Static::instance();
p.setPen(options->color(Options::Font, client_->isActive()));
p.drawPixmap(0, 0, s->titleTextLeft(active_));
p.drawPixmap(width() - 3, 0, s->titleTextRight(active_));
p.drawTiledPixmap(3, 0, width() - 6, 20, s->titleTextMid(active_));
p.setPen(options->color(Options::Font, active_));
p.setFont(options->font());
p.drawText(4, 0, width() - 8, 18, AlignCenter, client_->caption());
}
@ -60,50 +68,25 @@ TitleText::updatePixmap()
void
TitleText::mousePressEvent(QMouseEvent * e)
{
switch (e->button()) {
case MidButton:
clientPosToMousePos_ = e->globalPos() - client_->pos();
break;
case LeftButton:
clientPosToMousePos_ = e->globalPos() - client_->pos();
client_->workspace()->raiseClient(client_);
client_->workspace()->requestFocus(client_);
break;
case RightButton:
client_->workspace()->clientPopup(client_)->popup(e->globalPos());
break;
default:
break;
}
client_->mousePressEvent(e);
}
void
TitleText::mouseReleaseEvent(QMouseEvent *)
TitleText::mouseReleaseEvent(QMouseEvent * e)
{
// Anything to do ?
client_->mouseReleaseEvent(e);
}
void
TitleText::mouseMoveEvent(QMouseEvent * e)
{
// Need to be a little clever here.
QPoint adjustedForCursor = e->globalPos() - clientPosToMousePos_;
QPoint adjustedForSnap =
client_->workspace()->adjustClientPosition(client_, adjustedForCursor);
client_->move(adjustedForSnap);
client_->mouseMoveEvent(e);
}
void
TitleText::mouseDoubleClickEvent(QMouseEvent *)
TitleText::mouseDoubleClickEvent(QMouseEvent * e)
{
client_->setShade(!client_->isShade());
client_->mouseDoubleClickEvent(e);
}
} // End namespace

View file

@ -40,6 +40,8 @@ class TitleText : public DBWidget
TitleText(QWidget * parent, Manager * client);
virtual ~TitleText();
void setActive(bool);
protected:
void updatePixmap();
@ -52,8 +54,7 @@ class TitleText : public DBWidget
private:
Manager * client_;
QPoint clientPosToMousePos_;
bool active_;
};
} // End namespace