diff --git a/clients/Makefile.am b/clients/Makefile.am index a6fc8aeddb..85a5968377 100644 --- a/clients/Makefile.am +++ b/clients/Makefile.am @@ -1 +1 @@ -SUBDIRS=be kstep system +SUBDIRS=be kstep system kwmtheme diff --git a/clients/kwmtheme/Makefile.am b/clients/kwmtheme/Makefile.am new file mode 100644 index 0000000000..b324a1786a --- /dev/null +++ b/clients/kwmtheme/Makefile.am @@ -0,0 +1,20 @@ + +INCLUDES = $(all_includes) + +lib_LTLIBRARIES = libkwinkwmtheme.la + +libkwinkwmtheme_la_SOURCES = kwmthemeclient.cpp + +METASOURCES = AUTO +noinst_HEADERS = kwmthemeclient.h + +lnkdir = $(kde_datadir)/kwin/ +lnk_DATA = #kwmtheme.desktop + +EXTRA_DIST = $(lnk_DATA) + +libkwinkwmtheme_la_LDFLAGS = $(all_libraries) -version-info 1:0:0 -module + +###KMAKE-start (don't edit or delete this block) + +###KMAKE-end diff --git a/clients/kwmtheme/kwmtheme.desktop b/clients/kwmtheme/kwmtheme.desktop new file mode 100644 index 0000000000..a3bbcde249 --- /dev/null +++ b/clients/kwmtheme/kwmtheme.desktop @@ -0,0 +1,3 @@ +[Desktop Entry] +Name=KWM Theme +X-KDE-Library=libkwinkwmtheme diff --git a/clients/kwmtheme/kwmthemeclient.cpp b/clients/kwmtheme/kwmthemeclient.cpp new file mode 100644 index 0000000000..68ea30c807 --- /dev/null +++ b/clients/kwmtheme/kwmthemeclient.cpp @@ -0,0 +1,605 @@ +#include +#include "kwmthemeclient.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "../../workspace.h" +#include "../../options.h" + +extern "C" +{ + Client *allocate(Workspace *ws, WId w) + { + return(new KWMThemeClient(ws, w)); + } +} + + +enum FramePixmap{FrameTop=0, FrameBottom, FrameLeft, FrameRight, FrameTopLeft, + FrameTopRight, FrameBottomLeft, FrameBottomRight}; + +static QPixmap *framePixmaps[8]; +static QPixmap *menuPix, *iconifyPix, *closePix, *maxPix, *minmaxPix, + *pinupPix, *pindownPix; +static KPixmap *aTitlePix = NULL; +static KPixmap *iTitlePix = NULL; +static KPixmapEffect::GradientType grType; +static int maxExtent, titleAlign; +static bool titleGradient = true; +static bool pixmaps_created = false; +static bool titleSunken = false; +static bool titleTransparent; + +extern Options *options; + +static void init_theme() +{ + static char *keys[] = {"wm_top", "wm_bottom", "wm_left", "wm_right", + "wm_topleft", "wm_topright", "wm_bottomleft", "wm_bottomright"}; + + if(pixmaps_created) + return; + pixmaps_created = true; + + KIconLoader *ldr = KGlobal::iconLoader(); + KConfig *config = KGlobal::config(); + config->setGroup("General"); + + int i; + for(i=0; i < 8; ++i){ + framePixmaps[i] = new QPixmap(ldr->loadIcon(keys[i])); + if(framePixmaps[i]->isNull()) + warning("Unable to load frame pixmap for %s", keys[i]); + else + warning("Loaded pixmap %d", i+1); + } + maxExtent = framePixmaps[FrameTop]->height(); + if(framePixmaps[FrameBottom]->height() > maxExtent) + maxExtent = framePixmaps[FrameBottom]->height(); + if(framePixmaps[FrameLeft]->width() > maxExtent) + maxExtent = framePixmaps[FrameLeft]->width(); + if(framePixmaps[FrameRight]->width() > maxExtent) + maxExtent = framePixmaps[FrameRight]->width(); + + menuPix = new QPixmap(ldr->loadIcon("menu")); + iconifyPix = new QPixmap(ldr->loadIcon("iconify")); + maxPix = new QPixmap(ldr->loadIcon("maximize")); + minmaxPix = new QPixmap(ldr->loadIcon("maximizedown")); + closePix = new QPixmap(ldr->loadIcon("close")); + pinupPix = new QPixmap(ldr->loadIcon("pinup")); + pindownPix = new QPixmap(ldr->loadIcon("pindown")); + + QString tmpStr = config->readEntry("TitleAlignment"); + if(tmpStr == "right") + titleAlign = Qt::AlignRight | Qt::AlignVCenter; + else if(tmpStr == "middle") + titleAlign = Qt::AlignCenter; + else + titleAlign = Qt::AlignLeft | Qt::AlignVCenter; + titleSunken = config->readBoolEntry("TitleFrameShaded", false); + titleTransparent = config->readBoolEntry("PixmapUnderTitleText", true); + + tmpStr = config->readEntry("TitlebarLook"); + if(tmpStr == "shadedVertical"){ + aTitlePix = new KPixmap; + aTitlePix->resize(32, 20); + KPixmapEffect::gradient(*aTitlePix, + options->color(Options::TitleBar, true), + options->color(Options::TitleBlend, true), + KPixmapEffect::VerticalGradient); + iTitlePix = new KPixmap; + iTitlePix->resize(32, 20); + KPixmapEffect::gradient(*iTitlePix, + options->color(Options::TitleBar, false), + options->color(Options::TitleBlend, false), + KPixmapEffect::VerticalGradient); + titleGradient = false; // we can just tile this + + } + else if(tmpStr == "shadedHorizontal") + grType = KPixmapEffect::HorizontalGradient; + else if(tmpStr == "shadedDiagonal") + grType = KPixmapEffect::DiagonalGradient; + else if(tmpStr == "shadedCrossDiagonal") + grType = KPixmapEffect::CrossDiagonalGradient; + else if(tmpStr == "shadedPyramid") + grType = KPixmapEffect::PyramidGradient; + else if(tmpStr == "shadedRectangle") + grType = KPixmapEffect::RectangleGradient; + else if(tmpStr == "shadedPipeCross") + grType = KPixmapEffect::PipeCrossGradient; + else if(tmpStr == "shadedElliptic") + grType = KPixmapEffect::EllipticGradient; + else + titleGradient = false; +} + +void MyButton::drawButtonLabel(QPainter *p) +{ + if(pixmap()){ + style().drawItem(p, 0, 0, width(), height(), AlignCenter, colorGroup(), + true, pixmap(), QString::null); + } +} + +KWMThemeClient::KWMThemeClient( Workspace *ws, WId w, QWidget *parent, + const char *name ) + : Client( ws, w, parent, name, WResizeNoErase ) +{ + init_theme(); + + QGridLayout *layout = new QGridLayout(this); + layout->addColSpacing(0, maxExtent); + layout->addColSpacing(2, maxExtent); + + layout->addRowSpacing(0, maxExtent); + + layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Fixed, + QSizePolicy::Expanding)); + + layout->addWidget(windowWrapper(), 2, 1); + layout->addRowSpacing(3, maxExtent); + layout->setRowStretch(2, 10); + layout->setColStretch(1, 10); + + QHBoxLayout* hb = new QHBoxLayout; + layout->addLayout( hb, 1, 1 ); + + KConfig *config = KGlobal::config(); + config->setGroup("Buttons"); + QString val; + MyButton *btn; + int i; + static const char *defaultButtons[]={"Menu","Sticky","Off","Iconify", + "Maximize","Close"}; + static const char keyOffsets[]={"ABCDEF"}; + for(i=0; i < 6; ++i){ + if(i == 3){ + titlebar = new QSpacerItem(10, 20, QSizePolicy::Expanding, + QSizePolicy::Minimum ); + hb->addItem( titlebar ); + } + QString key("Button"); + key += QChar(keyOffsets[i]); + val = config->readEntry(key, defaultButtons[i]); + if(val == "Menu"){ + btn = new MyButton(this, "menu"); + btn->setPixmap(*menuPix); + hb->addWidget(btn); + btn->setFixedSize(20, 20); + } + else if(val == "Sticky"){ + stickyBtn = new MyButton(this, "sticky"); + stickyBtn->setPixmap(*pinupPix); + connect(stickyBtn, SIGNAL( clicked() ), this, SLOT(toggleSticky())); + hb->addWidget(stickyBtn); + stickyBtn->setFixedSize(20, 20); + } + else if(val == "Iconify"){ + btn = new MyButton(this, "iconify"); + btn->setPixmap(*iconifyPix); + connect(btn, SIGNAL(clicked()), this, SLOT(iconify())); + hb->addWidget(btn); + btn->setFixedSize(20, 20); + } + else if(val == "Maximize"){ + maxBtn = new MyButton(this, "max"); + maxBtn->setPixmap(*maxPix); + connect(maxBtn, SIGNAL(clicked()), this, SLOT(maximize())); + hb->addWidget(maxBtn); + maxBtn->setFixedSize(20, 20); + } + else if(val == "Close"){ + btn = new MyButton(this, "close"); + btn->setPixmap(*closePix); + connect(btn, SIGNAL(clicked()), this, SLOT(closeWindow())); + hb->addWidget(btn); + btn->setFixedSize(20, 20); + } + else{ + if(val != "Off") + warning("KWin: Unrecognized button value: %s", val.latin1()); + } + } + if(titleGradient){ + aGradient = new KPixmap; + iGradient = new KPixmap; + } + else{ + aGradient = NULL; + iGradient = NULL; + } + +} + +void KWMThemeClient::drawTitle(QPainter &p) +{ + QRect r = titlebar->geometry(); + + if(titleSunken){ + qDrawShadeRect(&p, r, options->colorGroup(Options::Frame, isActive()), + true, 1, 0); + r.setRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2); + } + + KPixmap *fill = isActive() ? aTitlePix : iTitlePix; + if(fill) + p.drawTiledPixmap(r, *fill); + else if(titleGradient){ + fill = isActive() ? aGradient : iGradient; + if(fill->width() != r.width()){ + fill->resize(r.width(), 20); + KPixmapEffect::gradient(*fill, + options->color(Options::TitleBar, isActive()), + options->color(Options::TitleBlend, isActive()), + grType); + } + p.drawTiledPixmap(r, *fill); + } + else{ + p.fillRect(r, options->colorGroup(Options::TitleBar, isActive()). + brush(QColorGroup::Button)); + } + p.setFont(options->font(isActive())); + p.setPen(options->color(Options::Font, isActive())); + p.drawText(r, titleAlign, caption()); +} + +void KWMThemeClient::resizeEvent( QResizeEvent* e) +{ + Client::resizeEvent( e ); + doShape(); + if ( isVisibleToTLW() && !testWFlags( WNorthWestGravity )) { + QPainter p( this ); + QRect t = titlebar->geometry(); + t.setTop( 0 ); + QRegion r = rect(); + r = r.subtract( t ); + p.setClipRegion( r ); + p.eraseRect( rect() ); + } +} + +void KWMThemeClient::captionChange( const QString& ) +{ + repaint( titlebar->geometry(), false ); +} + +void KWMThemeClient::paintEvent( QPaintEvent* ) +{ + QPainter p; + p.begin(this); + int x,y; + // first the corners + int w1 = framePixmaps[FrameTopLeft]->width(); + int h1 = framePixmaps[FrameTopLeft]->height(); + if (w1 > width()/2) w1 = width()/2; + if (h1 > height()/2) h1 = height()/2; + p.drawPixmap(0,0,*(framePixmaps[FrameTopLeft]), + 0,0, w1, h1); + + int w2 = framePixmaps[FrameTopRight]->width(); + int h2 = framePixmaps[FrameTopRight]->height(); + if (w2 > width()/2) w2 = width()/2; + if (h2 > height()/2) h2 = height()/2; + p.drawPixmap(width()-w2,0,*(framePixmaps[FrameTopRight]), + framePixmaps[FrameTopRight]->width()-w2,0,w2, h2); + + int w3 = framePixmaps[FrameBottomLeft]->width(); + int h3 = framePixmaps[FrameBottomLeft]->height(); + if (w3 > width()/2) w3 = width()/2; + if (h3 > height()/2) h3 = height()/2; + p.drawPixmap(0,height()-h3,*(framePixmaps[FrameBottomLeft]), + 0,framePixmaps[FrameBottomLeft]->height()-h3,w3, h3); + + int w4 = framePixmaps[FrameBottomRight]->width(); + int h4 = framePixmaps[FrameBottomRight]->height(); + if (w4 > width()/2) w4 = width()/2; + if (h4 > height()/2) h4 = height()/2; + p.drawPixmap(width()-w4,height()-h4,*(framePixmaps[FrameBottomRight]), + framePixmaps[FrameBottomRight]->width()-w4, + framePixmaps[FrameBottomRight]->height()-h4, + w4, h4); + + QPixmap pm; + QWMatrix m; + int n,s,w; + //top + pm = *(framePixmaps[FrameTop]); + + s = width()-w2-w1; + n = s/pm.width(); + w = n>0?s/n:s; + m.reset(); + m.scale(w/(float)pm.width(), 1); + pm = pm.xForm(m); + + x = w1; + while (1){ + if (pm.width() < width()-w2-x){ + p.drawPixmap(x,maxExtent-pm.height()-1, + pm); + x += pm.width(); + } + else { + p.drawPixmap(x,maxExtent-pm.height()-1, + pm, + 0,0,width()-w2-x,pm.height()); + break; + } + } + + //bottom + pm = *(framePixmaps[FrameBottom]); + + s = width()-w4-w3; + n = s/pm.width(); + w = n>0 ? s/n : s; + m.reset(); + m.scale(w/(float)pm.width(), 1); + pm = pm.xForm(m); + + x = w3; + while (1){ + if (pm.width() < width()-w4-x){ + p.drawPixmap(x,height()-maxExtent+1,pm); + x += pm.width(); + } + else { + p.drawPixmap(x,height()-maxExtent+1,pm, + 0,0,width()-w4-x,pm.height()); + break; + } + } + + //left + pm = *(framePixmaps[FrameLeft]); + + s = height()-h3-h1; + n = s/pm.height(); + w = n>0 ? s/n : s; + m.reset(); + m.scale(1, w/(float)pm.height()); + pm = pm.xForm(m); + + y = h1; + while (1){ + if (pm.height() < height()-h3-y){ + p.drawPixmap(maxExtent-pm.width()-1, y, + pm); + y += pm.height(); + } + else { + p.drawPixmap(maxExtent-pm.width()-1, y, + pm, + 0,0, pm.width(), + height()-h3-y); + break; + } + } + + //right + pm = *(framePixmaps[FrameRight]); + + s = height()-h4-h2; + n = s/pm.height(); + w = n>0 ? s/n : s; + m.reset(); + m.scale(1, w/(float)pm.height()); + pm = pm.xForm(m); + + y = h2; + while (1){ + if (pm.height() < height()-h4-y){ + p.drawPixmap(width()-maxExtent+1, y, + pm); + y += pm.height(); + } + else { + p.drawPixmap(width()-maxExtent+1, y, + pm, + 0,0, pm.width(), + height()-h4-y); + break; + } + } + drawTitle(p); + p.end(); +} + +void KWMThemeClient::doShape() +{ + QBitmap mask(width(), height()); + mask.fill(color0); + QPainter p; + p.begin(&mask); + p.setBrush(color1); + p.setPen(color1); + + int x,y; + // first the corners + int w1 = framePixmaps[FrameTopLeft]->width(); + int h1 = framePixmaps[FrameTopLeft]->height(); + if (w1 > width()/2) w1 = width()/2; + if (h1 > height()/2) h1 = height()/2; + p.drawPixmap(0,0,*(framePixmaps[FrameTopLeft]->mask()), + 0,0,w1, h1); + int w2 = framePixmaps[FrameTopRight]->width(); + int h2 = framePixmaps[FrameTopRight]->height(); + if (w2 > width()/2) w2 = width()/2; + if (h2 > height()/2) h2 = height()/2; + p.drawPixmap(width()-w2,0,*(framePixmaps[FrameTopRight]->mask()), + framePixmaps[FrameTopRight]->width()-w2,0,w2, h2); + + int w3 = framePixmaps[FrameBottomLeft]->width(); + int h3 = framePixmaps[FrameBottomLeft]->height(); + if (w3 > width()/2) w3 = width()/2; + if (h3 > height()/2) h3 = height()/2; + p.drawPixmap(0,height()-h3,*(framePixmaps[FrameBottomLeft]->mask()), + 0, framePixmaps[FrameBottomLeft]->height()-h3,w3, h3); + + int w4 = framePixmaps[FrameBottomRight]->width(); + int h4 = framePixmaps[FrameBottomRight]->height(); + if (w4 > width()/2) w4 = width()/2; + if (h4 > height()/2) h4 = height()/2; + p.drawPixmap(width()-w4,height()-h4,*(framePixmaps[FrameBottomRight]->mask()), + framePixmaps[FrameBottomRight]->width()-w4, + framePixmaps[FrameBottomRight]->height()-h4, + w4, h4); + + + QPixmap pm; + QWMatrix m; + int n,s,w; + //top + pm = *(framePixmaps[FrameTop]->mask()); + + s = width()-w2-w1; + n = s/pm.width(); + w = n>0?s/n:s; + m.reset(); + m.scale(w/(float)pm.width(), 1); + pm = pm.xForm(m); + + x = w1; + while (1){ + if (pm.width() < width()-w2-x){ + p.drawPixmap(x,maxExtent-pm.height()-1, + pm); + x += pm.width(); + } + else { + p.drawPixmap(x,maxExtent-pm.height()-1, + pm, + 0,0,width()-w2-x,pm.height()); + break; + } + } + + //bottom + pm = *(framePixmaps[FrameBottom]->mask()); + + s = width()-w4-w3; + n = s/pm.width(); + w = n>0?s/n:s; + m.reset(); + m.scale(w/(float)pm.width(), 1); + pm = pm.xForm(m); + + x = w3; + while (1){ + if (pm.width() < width()-w4-x){ + p.drawPixmap(x,height()-maxExtent+1,pm); + x += pm.width(); + } + else { + p.drawPixmap(x,height()-maxExtent+1,pm, + 0,0,width()-w4-x,pm.height()); + break; + } + } + + //left + pm = *(framePixmaps[FrameLeft]->mask()); + + s = height()-h3-h1; + n = s/pm.height(); + w = n>0?s/n:s; + m.reset(); + m.scale(1, w/(float)pm.height()); + pm = pm.xForm(m); + + y = h1; + while (1){ + if (pm.height() < height()-h3-y){ + p.drawPixmap(maxExtent-pm.width()-1, y, + pm); + y += pm.height(); + } + else { + p.drawPixmap(maxExtent-pm.width()-1, y, + pm, + 0,0, pm.width(), + height()-h3-y); + break; + } + } + + //right + pm = *(framePixmaps[FrameRight]->mask()); + + s = height()-h4-h2; + n = s/pm.height(); + w = n>0?s/n:s; + m.reset(); + m.scale(1, w/(float)pm.height()); + pm = pm.xForm(m); + + y = h2; + while (1){ + if (pm.height() < height()-h4-y){ + p.drawPixmap(width()-maxExtent+1, y, + pm); + y += pm.height(); + } + else { + p.drawPixmap(width()-maxExtent+1, y, + pm, + 0,0, pm.width(), + height()-h4-y); + break; + } + } + + p.fillRect(maxExtent-1, maxExtent-1, width()-2*maxExtent+2, height()-2*maxExtent+2, color1); + + p.end(); + setMask(mask); +} + + +void KWMThemeClient::showEvent(QShowEvent *ev) +{ + Client::showEvent(ev); + doShape(); + repaint(false); +} + +void KWMThemeClient::windowWrapperShowEvent( QShowEvent* ) +{ + doShape(); +} + +void KWMThemeClient::mouseDoubleClickEvent( QMouseEvent * e ) +{ + if (titlebar->geometry().contains( e->pos() ) ) + setShade( !isShade() ); + workspace()->requestFocus( this ); +} + +void KWMThemeClient::stickyChange(bool on) +{ + stickyBtn->setPixmap(on ? *pinupPix : *pindownPix); +} + +void KWMThemeClient::maximizeChange(bool m) +{ + maxBtn->setPixmap(m ? *minmaxPix : *maxPix); +} + +void KWMThemeClient::init() +{ + // +} + + diff --git a/clients/kwmtheme/kwmthemeclient.h b/clients/kwmtheme/kwmthemeclient.h new file mode 100644 index 0000000000..9aacc9fa77 --- /dev/null +++ b/clients/kwmtheme/kwmthemeclient.h @@ -0,0 +1,47 @@ +#ifndef __KWMTHEMECLIENT_H +#define __KWMTHEMECLIENT_H + +#include +#include +#include +#include "../../client.h" +class QLabel; +class QSpacerItem; + +// QToolButton uses a 1 pixel border :P +class MyButton : public QToolButton +{ +public: + MyButton(QWidget *parent=0, const char *name=0) + : QToolButton(parent, name){;} +protected: + void drawButtonLabel(QPainter *p); +}; + +class KWMThemeClient : public Client +{ + Q_OBJECT +public: + KWMThemeClient( Workspace *ws, WId w, QWidget *parent=0, const char *name=0 ); + ~KWMThemeClient(){;} +protected: + void doShape(); + void drawTitle(QPainter &p); + void resizeEvent( QResizeEvent* ); + void paintEvent( QPaintEvent* ); + void showEvent( QShowEvent* ); + void windowWrapperShowEvent( QShowEvent* ); + void mouseDoubleClickEvent( QMouseEvent * ); + void init(); + void captionChange( const QString& name ); + void stickyChange(bool on); + void maximizeChange(bool m); +private: + KPixmap *aGradient, *iGradient; + MyButton *maxBtn, *stickyBtn; + QSpacerItem *titlebar; +}; + + + +#endif diff --git a/clients/system/systemclient.cpp b/clients/system/systemclient.cpp index 129eae014d..3442429ea1 100644 --- a/clients/system/systemclient.cpp +++ b/clients/system/systemclient.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "../../workspace.h" #include "../../options.h" @@ -271,6 +272,10 @@ void SystemClient::captionChange( const QString& ) void SystemClient::drawRoundFrame(QPainter &p, int x, int y, int w, int h) { + kDrawRoundButton(&p, x, y, w, h, + options->colorGroup(Options::Frame, isActive()), false); + + /* int x2=x+w-1, y2=y+h-1; QPointArray hPntArray, lPntArray; hPntArray.putPoints(0, 12, x+4,y+1, x+5,y+1, // top left @@ -297,7 +302,7 @@ void SystemClient::drawRoundFrame(QPainter &p, int x, int y, int w, int h) p.drawLine(x+6, y2-1, x2-6, y2-1); p.drawLine(x2, y+6, x2, y2-6); p.drawLine(x2-1, y+6, x2-1, y2-6); - p.drawPoints(lPntArray); + p.drawPoints(lPntArray); */ } void SystemClient::paintEvent( QPaintEvent* ) @@ -351,7 +356,10 @@ void SystemClient::doShape() // using a bunch of QRect lines seems much more efficent than bitmaps or // point arrays - QRegion mask(QRect(6, 0, width()-12, height())); + QRegion mask; + kRoundMaskRegion(mask, 0, 0, width(), height()); + /* + (QRect(6, 0, width()-12, height())); mask += QRegion(QRect(5, 1, 1, height()-2)); // left mask += QRegion(QRect(4, 1, 1, height()-2)); mask += QRegion(QRect(3, 2, 1, height()-4)); @@ -364,11 +372,8 @@ void SystemClient::doShape() mask += QRegion(QRect(x2-3, 2, 1, height()-4)); mask += QRegion(QRect(x2-2, 3, 1, height()-6)); mask += QRegion(QRect(x2-1, 4, 1, height()-8)); - mask += QRegion(QRect(x2, 6, 1, height()-12)); - + mask += QRegion(QRect(x2, 6, 1, height()-12)); */ setMask(mask); - - } void SystemClient::showEvent(QShowEvent *ev) diff --git a/stdclient.cpp b/stdclient.cpp index 2ed228b059..ab22efca57 100644 --- a/stdclient.cpp +++ b/stdclient.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include "workspace.h" #include "options.h" @@ -66,150 +67,91 @@ QPixmap* kwin_get_menu_pix_hack() return menu_pix; } -/** - * Pixmap creation routine that creates full pixmaps out of bitmaps - * for each shade and the user defined titlebutton foreground colors. There - * is a large amount of QBitmap constructors/copies here since loadFromData - * with type XBM doesn't seem to work with QBitmaps, the only way I could get - * a load from data is via the constructor :( Matthias, do you know about - * this? - */ static void create_pixmaps() { if ( pixmaps_created ) return; pixmaps_created = true; + QColorGroup aGrp = options->colorGroup(Options::ButtonFg, true); + QColorGroup iGrp = options->colorGroup(Options::ButtonFg, false); - QPainter pact, pdis; - QBitmap bitmap; - QColor actHigh = options->color(Options::ButtonFg, true).light(150); - QColor actMed = options->color(Options::ButtonFg, true); - QColor actLow = options->color(Options::ButtonFg, true).dark(120); - QColor disHigh = options->color(Options::ButtonFg, false).light(150); - QColor disMed = options->color(Options::ButtonFg, false); - QColor disLow = options->color(Options::ButtonFg, false).dark(120); - + QPainter aPainter, iPainter; close_pix = new QPixmap(16, 16); dis_close_pix = new QPixmap(16, 16); - pact.begin(close_pix); pdis.begin(dis_close_pix); - bitmap = QBitmap(16, 16, close_white_bits, true); - bitmap.setMask(bitmap); - pact.setPen(actHigh); pdis.setPen(disHigh); - pact.drawPixmap(0, 0, bitmap); - pdis.drawPixmap(0, 0, bitmap); - bitmap = QBitmap(16, 16, close_dgray_bits, true); - pact.setPen(actLow); pdis.setPen(disLow); - pact.drawPixmap(0, 0, bitmap); - pdis.drawPixmap(0, 0, bitmap); - pact.end(); pdis.end(); - bitmap = QBitmap(16, 16, close_mask_bits, true); - close_pix->setMask(bitmap); dis_close_pix->setMask(bitmap); + aPainter.begin(close_pix); iPainter.begin(dis_close_pix); + kColorBitmaps(&aPainter, aGrp, 0, 0, 16, 16, true, close_white_bits, + NULL, NULL, close_dgray_bits, NULL, NULL); + kColorBitmaps(&iPainter, iGrp, 0, 0, 16, 16, true, close_white_bits, + NULL, NULL, close_dgray_bits, NULL, NULL); + aPainter.end(); iPainter.end(); + close_pix->setMask(QBitmap(16, 16, close_mask_bits, true)); + dis_close_pix->setMask(*close_pix->mask()); minimize_pix = new QPixmap(16, 16); dis_minimize_pix = new QPixmap(16, 16); - pact.begin(minimize_pix); pdis.begin(dis_minimize_pix); - bitmap = QBitmap(16, 16, iconify_white_bits, true); - bitmap.setMask(bitmap); - pact.setPen(actHigh); pdis.setPen(disHigh); - pact.drawPixmap(0, 0, bitmap); - pdis.drawPixmap(0, 0, bitmap); - bitmap = QBitmap(16, 16, iconify_dgray_bits, true); - pact.setPen(actLow); pdis.setPen(disLow); - pact.drawPixmap(0, 0, bitmap); - pdis.drawPixmap(0, 0, bitmap); - pact.end(); pdis.end(); - bitmap = QBitmap(16, 16, iconify_mask_bits, true); - minimize_pix->setMask(bitmap); dis_minimize_pix->setMask(bitmap); + aPainter.begin(minimize_pix); iPainter.begin(dis_minimize_pix); + kColorBitmaps(&aPainter, aGrp, 0, 0, 16, 16, true, iconify_white_bits, + NULL, NULL, iconify_dgray_bits, NULL, NULL); + kColorBitmaps(&iPainter, iGrp, 0, 0, 16, 16, true, iconify_white_bits, + NULL, NULL, iconify_dgray_bits, NULL, NULL); + aPainter.end(); iPainter.end(); + minimize_pix->setMask(QBitmap(16, 16, iconify_mask_bits, true)); + dis_minimize_pix->setMask(*minimize_pix->mask()); maximize_pix = new QPixmap(16, 16); dis_maximize_pix = new QPixmap(16, 16); - pact.begin(maximize_pix); pdis.begin(dis_maximize_pix); - bitmap = QBitmap(16, 16, maximize_white_bits, true); - bitmap.setMask(bitmap); - pact.setPen(actHigh); pdis.setPen(disHigh); - pact.drawPixmap(0, 0, bitmap); - pdis.drawPixmap(0, 0, bitmap); - bitmap = QBitmap(16, 16, maximize_dgray_bits, true); - pact.setPen(actLow); pdis.setPen(disLow); - pact.drawPixmap(0, 0, bitmap); - pdis.drawPixmap(0, 0, bitmap); - pact.end(); pdis.end(); - bitmap = QBitmap(16, 16, maximize_mask_bits, true); - maximize_pix->setMask(bitmap); dis_maximize_pix->setMask(bitmap); + aPainter.begin(maximize_pix); iPainter.begin(dis_maximize_pix); + kColorBitmaps(&aPainter, aGrp, 0, 0, 16, 16, true, maximize_white_bits, + NULL, NULL, maximize_dgray_bits, NULL, NULL); + kColorBitmaps(&iPainter, iGrp, 0, 0, 16, 16, true, maximize_white_bits, + NULL, NULL, maximize_dgray_bits, NULL, NULL); + aPainter.end(); iPainter.end(); + maximize_pix->setMask(QBitmap(16, 16, maximize_mask_bits, true)); + dis_maximize_pix->setMask(*maximize_pix->mask()); normalize_pix = new QPixmap(16, 16); dis_normalize_pix = new QPixmap(16, 16); - pact.begin(normalize_pix); pdis.begin(dis_normalize_pix); - bitmap = QBitmap(16, 16, maximizedown_white_bits, true); - bitmap.setMask(bitmap); - pact.setPen(actHigh); pdis.setPen(disHigh); - pact.drawPixmap(0, 0, bitmap); - pdis.drawPixmap(0, 0, bitmap); - bitmap = QBitmap(16, 16, maximizedown_dgray_bits, true); - pact.setPen(actLow); pdis.setPen(disLow); - pact.drawPixmap(0, 0, bitmap); - pdis.drawPixmap(0, 0, bitmap); - pact.end(); pdis.end(); - bitmap = QBitmap(16, 16, maximizedown_mask_bits, true); - normalize_pix->setMask(bitmap); dis_normalize_pix->setMask(bitmap); + aPainter.begin(normalize_pix); iPainter.begin(dis_normalize_pix); + kColorBitmaps(&aPainter, aGrp, 0, 0, 16, 16, true, maximizedown_white_bits, + NULL, NULL, maximizedown_dgray_bits, NULL, NULL); + kColorBitmaps(&iPainter, iGrp, 0, 0, 16, 16, true, maximizedown_white_bits, + NULL, NULL, maximizedown_dgray_bits, NULL, NULL); + aPainter.end(); iPainter.end(); + normalize_pix->setMask(QBitmap(16, 16, maximizedown_mask_bits, true)); + dis_normalize_pix->setMask(*normalize_pix->mask()); menu_pix = new QPixmap(16, 16); dis_menu_pix = new QPixmap(16, 16); - pact.begin(menu_pix); pdis.begin(dis_menu_pix); - bitmap = QBitmap(16, 16, menu_white_bits, true); - bitmap.setMask(bitmap); - pact.setPen(actHigh); pdis.setPen(disHigh); - pact.drawPixmap(0, 0, bitmap); - pdis.drawPixmap(0, 0, bitmap); - bitmap = QBitmap(16, 16, menu_dgray_bits, true); - pact.setPen(actLow); pdis.setPen(disLow); - pact.drawPixmap(0, 0, bitmap); - pdis.drawPixmap(0, 0, bitmap); - pact.end(); pdis.end(); - bitmap = QBitmap(16, 16, menu_mask_bits, true); - menu_pix->setMask(bitmap); dis_menu_pix->setMask(bitmap); + aPainter.begin(menu_pix); iPainter.begin(dis_menu_pix); + kColorBitmaps(&aPainter, aGrp, 0, 0, 16, 16, true, menu_white_bits, + NULL, NULL, menu_dgray_bits, NULL, NULL); + kColorBitmaps(&iPainter, iGrp, 0, 0, 16, 16, true, menu_white_bits, + NULL, NULL, menu_dgray_bits, NULL, NULL); + aPainter.end(); iPainter.end(); + menu_pix->setMask(QBitmap(16, 16, menu_mask_bits, true)); + dis_menu_pix->setMask(*menu_pix->mask()); pinup_pix = new QPixmap(16, 16); dis_pinup_pix = new QPixmap(16, 16); - pact.begin(pinup_pix); pdis.begin(dis_pinup_pix); - bitmap = QBitmap(16, 16, pinup_white_bits, true); - bitmap.setMask(bitmap); - pact.setPen(actHigh); pdis.setPen(disHigh); - pact.drawPixmap(0, 0, bitmap); - pdis.drawPixmap(0, 0, bitmap); - bitmap = QBitmap(16, 16, pinup_gray_bits, true); - pact.setPen(actMed); pdis.setPen(disMed); - pact.drawPixmap(0, 0, bitmap); - pdis.drawPixmap(0, 0, bitmap); - bitmap = QBitmap(16, 16, pinup_dgray_bits, true); - bitmap.setMask(bitmap); - pact.setPen(actLow); pdis.setPen(disLow); - pact.drawPixmap(0, 0, bitmap); - pdis.drawPixmap(0, 0, bitmap); - pact.end(); pdis.end(); - bitmap = QBitmap(16, 16, pinup_mask_bits, true); - pinup_pix->setMask(bitmap); dis_pinup_pix->setMask(bitmap); + aPainter.begin(pinup_pix); iPainter.begin(dis_pinup_pix); + kColorBitmaps(&aPainter, aGrp, 0, 0, 16, 16, true, pinup_white_bits, + pinup_gray_bits, NULL, pinup_dgray_bits, NULL, NULL); + kColorBitmaps(&iPainter, iGrp, 0, 0, 16, 16, true, pinup_white_bits, + pinup_gray_bits, NULL, pinup_dgray_bits, NULL, NULL); + aPainter.end(); iPainter.end(); + pinup_pix->setMask(QBitmap(16, 16, pinup_mask_bits, true)); + dis_pinup_pix->setMask(*pinup_pix->mask()); pindown_pix = new QPixmap(16, 16); dis_pindown_pix = new QPixmap(16, 16); - pact.begin(pindown_pix); pdis.begin(dis_pindown_pix); - bitmap = QBitmap(16, 16, pindown_white_bits, true); - bitmap.setMask(bitmap); - pact.setPen(actHigh); pdis.setPen(disHigh); - pact.drawPixmap(0, 0, bitmap); - pdis.drawPixmap(0, 0, bitmap); - bitmap = QBitmap(16, 16, pindown_gray_bits, true); - pact.setPen(actMed); pdis.setPen(disMed); - pact.drawPixmap(0, 0, bitmap); - pdis.drawPixmap(0, 0, bitmap); - bitmap = QBitmap(16, 16, pindown_dgray_bits, true); - bitmap.setMask(bitmap); - pact.setPen(actLow); pdis.setPen(disLow); - pact.drawPixmap(0, 0, bitmap); - pdis.drawPixmap(0, 0, bitmap); - pact.end(); pdis.end(); - bitmap = QBitmap(16, 16, pindown_mask_bits, true); - pindown_pix->setMask(bitmap); dis_pindown_pix->setMask(bitmap); + aPainter.begin(pindown_pix); iPainter.begin(dis_pindown_pix); + kColorBitmaps(&aPainter, aGrp, 0, 0, 16, 16, true, pindown_white_bits, + pindown_gray_bits, NULL, pindown_dgray_bits, NULL, NULL); + kColorBitmaps(&iPainter, iGrp, 0, 0, 16, 16, true, pindown_white_bits, + pindown_gray_bits, NULL, pindown_dgray_bits, NULL, NULL); + aPainter.end(); iPainter.end(); + pindown_pix->setMask(QBitmap(16, 16, pindown_mask_bits, true)); + dis_pindown_pix->setMask(*pindown_pix->mask()); question_mark_pix = new QPixmap(question_mark );