Code from Utils.* moved into Static.*

Removed link testing and debug flags from Makefile.am

Some magic to give a nice 3D look even when specified background colour
is dark (looks good with NeXT colour scheme now).

BTW, what's the point in translating 'RISC OS' ? It's a brand name,
like IBM.

svn path=/trunk/kdebase/kwin/; revision=46360
This commit is contained in:
Rik Hemsley 2000-04-12 00:13:14 +00:00
parent 84e0076486
commit 6f2db8d4c7
13 changed files with 85 additions and 181 deletions

View file

@ -33,7 +33,7 @@ namespace RiscOS
{ {
Button::Button(QWidget * parent, Manager * client, SymbolType t) Button::Button(QWidget * parent, Manager * client, SymbolType t)
: QWidget (parent, "Button"), : QWidget (parent, "Button", WRepaintNoErase | WPaintUnclipped),
client_ (client), client_ (client),
type_ (t), type_ (t),
align_ (Left), align_ (Left),
@ -51,6 +51,7 @@ Button::~Button()
Button::updateDisplay() Button::updateDisplay()
{ {
setBackgroundPixmap(Static::instance()->button(type_, client_->isActive(), down_)); setBackgroundPixmap(Static::instance()->button(type_, client_->isActive(), down_));
repaint(true);
} }
} // End namespace } // End namespace

View file

@ -1,5 +1,3 @@
KDE_CXXFLAGS = -O0 -g3 -W -Wall
INCLUDES = $(all_includes) INCLUDES = $(all_includes)
lib_LTLIBRARIES = libkwinriscos.la lib_LTLIBRARIES = libkwinriscos.la
@ -17,7 +15,6 @@ ResizeMid.cpp \
ResizeSide.cpp \ ResizeSide.cpp \
TitleBar.cpp \ TitleBar.cpp \
TitleText.cpp \ TitleText.cpp \
Utils.cpp \
Static.cpp Static.cpp
METASOURCES = AUTO METASOURCES = AUTO
@ -34,7 +31,6 @@ ResizeMid.h \
ResizeSide.h \ ResizeSide.h \
TitleBar.h \ TitleBar.h \
TitleText.h \ TitleText.h \
Utils.h \
Static.h Static.h
lnkdir = $(kde_datadir)/kwin/ lnkdir = $(kde_datadir)/kwin/
@ -42,6 +38,5 @@ lnk_DATA = riscos.desktop
EXTRA_DIST = $(lnk_DATA) EXTRA_DIST = $(lnk_DATA)
libkwinriscos_la_LIBADD = ../../kwin.la -lqt -lX11 libkwinriscos_la_LDFLAGS = $(all_libraries) -version-info 1:0:0 -module -rdynamic
libkwinriscos_la_LDFLAGS = $(all_libraries) -version-info 1:0:0 -module -rdynamic -no-undefined

View file

@ -48,9 +48,9 @@ Manager::Manager(
QWidget * parent, QWidget * parent,
const char * name const char * name
) )
: Client(workSpace, id, parent, name, WResizeNoErase | WRepaintNoErase | WPaintUnclipped) : Client(workSpace, id, parent, name)
{ {
Static::instance()->update(); Static::instance();
setBackgroundMode(NoBackground); setBackgroundMode(NoBackground);
@ -59,24 +59,21 @@ Manager::Manager(
titleBar_ = new TitleBar(this, this); titleBar_ = new TitleBar(this, this);
resizeBar_ = new ResizeBar(this, this); resizeBar_ = new ResizeBar(this, this);
// Layout // Border Window Border
// Border
// Window
// Border
QHBoxLayout * windowLayout = new QHBoxLayout(0, "windowLayout"); QHBoxLayout * windowLayout = new QHBoxLayout(0, "windowLayout");
windowLayout->addSpacing(1); windowLayout->addSpacing(1);
windowLayout->addWidget(windowWrapper(), 1); windowLayout->addWidget(windowWrapper(), 1);
windowLayout->addSpacing(1); windowLayout->addSpacing(1);
// Border // Titlebar (has own single pixel border)
// Titlebar // Window
// Window layout // Resize bar (has own single pixel border)
// Resize bar
QVBoxLayout * mainLayout = new QVBoxLayout(this, 0, 0, "mainLayout"); QVBoxLayout * mainLayout = new QVBoxLayout(this, 0, 0, "mainLayout");
mainLayout->addWidget(titleBar_); mainLayout->addWidget(titleBar_);
mainLayout->addLayout(windowLayout, 1); mainLayout->addLayout(windowLayout, 1);
mainLayout->addWidget(resizeBar_); mainLayout->addWidget(resizeBar_);
updateDisplay();
} }
Manager::~Manager() Manager::~Manager()

View file

@ -35,10 +35,8 @@ MaximiseButton::MaximiseButton(QWidget * parent, Manager * client)
void void
MaximiseButton::setOn(bool on) MaximiseButton::setOn(bool on)
{ {
if (on) setType(on ? Unmax: Max);
setType(Unmax); updateDisplay();
else
setType(Max);
} }
void void

View file

@ -25,13 +25,12 @@
#include "ResizeSide.h" #include "ResizeSide.h"
#include "Manager.h" #include "Manager.h"
#include "Static.h" #include "Static.h"
#include "Utils.h"
namespace RiscOS namespace RiscOS
{ {
ResizeSide::ResizeSide(QWidget * parent, Manager * client, Side s) ResizeSide::ResizeSide(QWidget * parent, Manager * client, Side s)
: QWidget (parent, "ResizeSide"), : QWidget (parent, "ResizeSide", WRepaintNoErase | WPaintUnclipped)
client_ (client), client_ (client),
side_ (s) side_ (s)
{ {

View file

@ -25,7 +25,6 @@
#include "ResizeMid.h" #include "ResizeMid.h"
#include "Manager.h" #include "Manager.h"
#include "Static.h" #include "Static.h"
#include "Utils.h"
namespace RiscOS namespace RiscOS
{ {

View file

@ -25,7 +25,6 @@
#include "ResizeRight.h" #include "ResizeRight.h"
#include "Manager.h" #include "Manager.h"
#include "Static.h" #include "Static.h"
#include "Utils.h"
namespace RiscOS namespace RiscOS
{ {

View file

@ -25,7 +25,6 @@
#include "ResizeSide.h" #include "ResizeSide.h"
#include "Manager.h" #include "Manager.h"
#include "Static.h" #include "Static.h"
#include "Utils.h"
namespace RiscOS namespace RiscOS
{ {

View file

@ -27,7 +27,6 @@
#include "../../options.h" #include "../../options.h"
#include "Static.h" #include "Static.h"
#include "Utils.h"
namespace RiscOS namespace RiscOS
{ {
@ -99,35 +98,6 @@ Static::_drawBorder(QPixmap & pix, int w, int h)
painter_.end(); painter_.end();
} }
QPixmap
recolour(const QImage & inputImage, const Palette & newPalette)
{
QImage image(inputImage);
Palette & standard = Static::instance()->standardPalette();
int ncols = image.numColors();
QRgb r;
for (int i = 0; i < ncols; i++) {
r = image.color(i);
for (int c = 0; c < 8; c++) {
if (r == standard[c])
{
image.setColor(i, newPalette[c]);
continue;
}
}
}
QPixmap output;
output.convertFromImage(image);
return output;
}
void void
Static::_drawCloseSymbol(QPixmap & pixmap) Static::_drawCloseSymbol(QPixmap & pixmap)
{ {
@ -191,7 +161,7 @@ Static::_drawLowerSymbol(QPixmap & pixmap)
painter_.translate(transx, transy); painter_.translate(transx, transy);
painter_.fillRect(1, 1, 6, 6, QColor(palette_[6])); painter_.fillRect(1, 1, 6, 6, QColor(palette_[6]));
painter_.fillRect(5, 5, 6, 6, QColor(palette_[6])); painter_.fillRect(5, 5, 6, 6, QColor(palette_[3]));
painter_.setPen(QColor(palette_[1])); painter_.setPen(QColor(palette_[1]));
painter_.drawRect(0, 0, 8, 8); painter_.drawRect(0, 0, 8, 8);
@ -247,7 +217,7 @@ Static::_drawUnmaxSymbol(QPixmap & pixmap)
painter_.translate(transx, transy); painter_.translate(transx, transy);
painter_.setPen(QColor(palette_[1])); painter_.setPen(QColor(palette_[1]));
painter_.drawRect(0, 0, 11, 11); painter_.drawRect(0, 0, 12, 12);
painter_.setPen(QColor(palette_[3])); painter_.setPen(QColor(palette_[3]));
painter_.drawPoint(0, 0); painter_.drawPoint(0, 0);
@ -263,10 +233,17 @@ Static::_drawUnmaxSymbol(QPixmap & pixmap)
void void
setPalette(Palette & pal, QColor c) setPalette(Palette & pal, QColor c)
{ {
pal[3] = c.rgb();
int h, s, v;
c.hsv(&h, &s, &v);
if (v < 72)
c.setHsv(h, s, 72);
pal[0] = c.light(200).rgb(); pal[0] = c.light(200).rgb();
pal[1] = c.light(166).rgb(); pal[1] = c.light(166).rgb();
pal[2] = c.light(125).rgb(); pal[2] = c.light(125).rgb();
pal[3] = c.rgb();
pal[4] = c.dark(133).rgb(); pal[4] = c.dark(133).rgb();
pal[5] = c.dark(166).rgb(); pal[5] = c.dark(166).rgb();
pal[6] = c.dark(200).rgb(); pal[6] = c.dark(200).rgb();
@ -276,10 +253,17 @@ setPalette(Palette & pal, QColor c)
void void
setInversePalette(Palette & pal, QColor c) setInversePalette(Palette & pal, QColor c)
{ {
pal[4] = c.rgb();
int h, s, v;
c.hsv(&h, &s, &v);
if (v < 72)
c.setHsv(h, s, 72);
pal[7] = c.light(200).rgb(); pal[7] = c.light(200).rgb();
pal[6] = c.light(166).rgb(); pal[6] = c.light(166).rgb();
pal[5] = c.light(125).rgb(); pal[5] = c.light(125).rgb();
pal[4] = c.rgb();
pal[3] = c.dark(133).rgb(); pal[3] = c.dark(133).rgb();
pal[2] = c.dark(166).rgb(); pal[2] = c.dark(166).rgb();
pal[1] = c.dark(200).rgb(); pal[1] = c.dark(200).rgb();
@ -326,34 +310,51 @@ Static::_init()
aResize_.fill(Qt::black); aResize_.fill(Qt::black);
iResize_.fill(Qt::black); iResize_.fill(Qt::black);
aTitleTextLeft_.resize(3, 20); aTitleTextLeft_ .setOptimization(QPixmap::BestOptim);
aTitleTextRight_.resize(3, 20); aTitleTextRight_ .setOptimization(QPixmap::BestOptim);
aTitleTextLeft_.fill(Qt::black); aTitleTextMid_ .setOptimization(QPixmap::BestOptim);
aTitleTextRight_.fill(Qt::black);
iTitleTextLeft_.resize(3, 20);
iTitleTextRight_.resize(3, 20);
iTitleTextLeft_.fill(Qt::black);
iTitleTextRight_.fill(Qt::black);
aTitleTextMid_.resize(128, 20);
iTitleTextMid_.resize(128, 20);
aTitleTextMid_.fill(Qt::black);
iTitleTextMid_.fill(Qt::black);
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, 10); iTitleTextLeft_ .setOptimization(QPixmap::BestOptim);
iResizeMid_.resize(128, 10); iTitleTextRight_ .setOptimization(QPixmap::BestOptim);
aResizeMid_.fill(Qt::black); iTitleTextMid_ .setOptimization(QPixmap::BestOptim);
iResizeMid_.fill(Qt::black);
aResizeMidLeft_ .setOptimization(QPixmap::BestOptim);
aResizeMidRight_ .setOptimization(QPixmap::BestOptim);
aResizeMid_ .setOptimization(QPixmap::BestOptim);
iResizeMidLeft_ .setOptimization(QPixmap::BestOptim);
iResizeMidRight_ .setOptimization(QPixmap::BestOptim);
iResizeMid_ .setOptimization(QPixmap::BestOptim);
aTitleTextLeft_ .resize(3, 20);
aTitleTextRight_ .resize(3, 20);
aTitleTextLeft_ .fill(Qt::black);
aTitleTextRight_ .fill(Qt::black);
iTitleTextLeft_ .resize(3, 20);
iTitleTextRight_ .resize(3, 20);
iTitleTextLeft_ .fill(Qt::black);
iTitleTextRight_ .fill(Qt::black);
aTitleTextMid_ .resize(128, 20);
iTitleTextMid_ .resize(128, 20);
aTitleTextMid_ .fill(Qt::black);
iTitleTextMid_ .fill(Qt::black);
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, 10);
iResizeMid_ .resize(128, 10);
aResizeMid_ .fill(Qt::black);
iResizeMid_ .fill(Qt::black);
update(); update();
} }

View file

@ -88,14 +88,15 @@ class Static
private: private:
void _drawButtonBorder(QPixmap &); void _drawButtonBorder (QPixmap &);
void _drawBorder(QPixmap &, int w, int h); void _drawBorder (QPixmap &, int, int);
void _drawCloseSymbol (QPixmap &);
void _drawIconifySymbol(QPixmap &);
void _drawLowerSymbol (QPixmap &);
void _drawMaxSymbol (QPixmap &);
void _drawUnmaxSymbol (QPixmap &);
void _init(); void _init();
void _drawCloseSymbol(QPixmap & pixmap);
void _drawIconifySymbol(QPixmap & pixmap);
void _drawLowerSymbol(QPixmap & pixmap);
void _drawMaxSymbol(QPixmap & pixmap);
void _drawUnmaxSymbol(QPixmap & pixmap);
static Static * instance_; static Static * instance_;
@ -125,5 +126,5 @@ class Static
} // End namespace } // End namespace
#endif #endif
// vim:ts=2:sw=2:tw=78 // vim:ts=2:sw=2:tw=78

View file

@ -28,7 +28,6 @@
#include "TitleText.h" #include "TitleText.h"
#include "Manager.h" #include "Manager.h"
#include "Static.h" #include "Static.h"
#include "Utils.h"
namespace RiscOS namespace RiscOS
{ {
@ -38,7 +37,6 @@ TitleText::TitleText(QWidget * parent, Manager * client)
client_(client) client_(client)
{ {
setFixedHeight(20); setFixedHeight(20);
updatePixmap();
} }
TitleText::~TitleText() TitleText::~TitleText()

View file

@ -1,36 +0,0 @@
/*
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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <qpainter.h>
#include <qimage.h>
#include "../../options.h"
#include "Utils.h"
#include "Static.h"
namespace RiscOS
{
} // End namespace
// vim:ts=2:sw=2:tw=78

View file

@ -1,47 +0,0 @@
/*
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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef RISC_OS_UTILS_H
#define RISC_OS_UTILS_H
#include <qarray.h>
#include <qpixmap.h>
#include "Palette.h"
namespace RiscOS {
void drawBorder(
QPixmap & pix,
int x, int y,
int w, int h,
const Palette & pal,
bool down = false
);
QPixmap recolour(const QImage &, const Palette &);
} // End namespace
#endif
// vim:ts=2:sw=2:tw=78