This I have had sitting on my HD for awhile, an ultra cool KWin style to go with the B2 widget style :)

It uses Be-like shaped titlebars, KDE standard buttons, has a shaped resize
handle, and automatically detects if you are on a highcolor display and if so
uses gradients based off the current color scheme. BTW, the buttons don't
necessarily match the titlebar but use the button foreground setting in KDE's
display settings so you can change them to whatever you like.

If no one objects I'll probably disable the old Be style. Unlike this style it
uses Be-like buttons but the drawing isn't very fancy and Be's two buttons are
a big restriction in KDE.

You can see a screenshot at:
http://www.mosfet.org/b2kwin.gif

svn path=/trunk/kdebase/kwin/; revision=44420
This commit is contained in:
Daniel M. Duley 2000-03-24 00:22:35 +00:00
parent 0383f22204
commit 8724699214
6 changed files with 862 additions and 1 deletions

View file

@ -1 +1 @@
SUBDIRS=be kstep system kwmtheme
SUBDIRS=be kstep system kwmtheme b2

20
clients/b2/Makefile.am Normal file
View file

@ -0,0 +1,20 @@
INCLUDES = $(all_includes)
lib_LTLIBRARIES = libkwinb2.la
libkwinb2_la_SOURCES = b2client.cpp
METASOURCES = AUTO
noinst_HEADERS = b2client.h
lnkdir = $(kde_datadir)/kwin/
lnk_DATA = b2.desktop
EXTRA_DIST = $(lnk_DATA)
libkwinb2_la_LDFLAGS = $(all_libraries) -version-info 1:0:0 -module
###KMAKE-start (don't edit or delete this block)
###KMAKE-end

3
clients/b2/b2.desktop Normal file
View file

@ -0,0 +1,3 @@
[Desktop Entry]
Name=B II
X-KDE-Library=libkwinb2

671
clients/b2/b2client.cpp Normal file
View file

@ -0,0 +1,671 @@
#include "b2client.h"
#include <qapplication.h>
#include <qcursor.h>
#include <qabstractlayout.h>
#include <qlayout.h>
#include <qtoolbutton.h>
#include <qlabel.h>
#include <qdrawutil.h>
#include <kpixmapeffect.h>
#include <kdrawutil.h>
#include <qbitmap.h>
#include "../../workspace.h"
#include "../../options.h"
#include "bitmaps.h"
extern "C"
{
Client *allocate(Workspace *ws, WId w)
{
return(new B2Client(ws, w));
}
}
// TODO: stick all these in an array
static KPixmap *aClosePix=0, *aClosePixDown;
static KPixmap *iClosePix, *iClosePixDown;
static KPixmap *aMaxPix, *aMaxPixDown;
static KPixmap *iMaxPix, *iMaxPixDown;
static KPixmap *aNormalizePix, *aNormalizePixDown;
static KPixmap *iNormalizePix, *iNormalizePixDown;
static KPixmap *aIconifyPix, *aIconifyPixDown;
static KPixmap *iIconifyPix, *iIconifyPixDown;
static KPixmap *aPinupPix, *aPinupPixDown;
static KPixmap *iPinupPix, *iPinupPixDown;
static KPixmap *aMenuPix, *aMenuPixDown;
static KPixmap *iMenuPix, *iMenuPixDown;
static KPixmap *aHelpPix, *aHelpPixDown;
static KPixmap *iHelpPix, *iHelpPixDown;
static bool pixmaps_created = false;
static void drawB2Rect(KPixmap *pix, const QColor &primary, bool down)
{
QPainter p;
QColor hColor = primary.light(150);
QColor lColor = primary.dark(150);
if(QPixmap::defaultDepth() > 8){
if(down)
KPixmapEffect::gradient(*pix, lColor, hColor,
KPixmapEffect::DiagonalGradient);
else
KPixmapEffect::gradient(*pix, hColor, lColor,
KPixmapEffect::DiagonalGradient);
}
else
pix->fill(primary);
int x2 = pix->width()-1;
int y2 = pix->height()-1;
p.begin(pix);
p.setPen(down ? hColor : lColor);
p.drawLine(0, 0, x2, 0);
p.drawLine(0, 0, 0, y2);
p.drawLine(1, x2-1, y2-1, x2-1);
p.drawLine(x2-1, 1, x2-1, y2-1);
p.setPen(down ? lColor : hColor);
p.drawRect(1, 1, x2, y2);
p.end();
}
static void create_pixmaps();
static void redraw_pixmaps();
QPixmap* kwin_get_menu_pix_hack()
{
create_pixmaps();
//return menu_pix; FIXME
return aMenuPix;
}
static void create_pixmaps()
{
if ( pixmaps_created )
return;
pixmaps_created = true;
// TODO: Stick all these in an array
aClosePix = new KPixmap;
aClosePix->resize(16, 16);
aClosePixDown = new KPixmap;
aClosePixDown->resize(16, 16);
iClosePix = new KPixmap;
iClosePix->resize(16, 16);
iClosePixDown = new KPixmap;
iClosePixDown->resize(16, 16);
aMaxPix = new KPixmap;
aMaxPixDown = new KPixmap;
iMaxPix = new KPixmap;
iMaxPixDown = new KPixmap;
aNormalizePix = new KPixmap();
aNormalizePix->resize(16, 16);
aNormalizePixDown = new KPixmap();
aNormalizePixDown->resize(16, 16);
aIconifyPix = new KPixmap;
aIconifyPix->resize(10, 10);
aIconifyPixDown = new KPixmap;
aIconifyPixDown->resize(10, 10);
iNormalizePix = new KPixmap();
iNormalizePix->resize(16, 16);
iNormalizePixDown = new KPixmap();
iNormalizePixDown->resize(16, 16);
iIconifyPix = new KPixmap;
iIconifyPix->resize(10, 10);
iIconifyPixDown = new KPixmap;
iIconifyPixDown->resize(10, 10);
aPinupPix = new KPixmap;
aPinupPix->resize(16, 16);
aPinupPixDown = new KPixmap;
aPinupPixDown->resize(16, 16);
iPinupPix = new KPixmap;
iPinupPix->resize(16, 16);
iPinupPixDown = new KPixmap;
iPinupPixDown->resize(16, 16);
aMenuPix = new KPixmap;
aMenuPix->resize(16, 16);
aMenuPixDown = new KPixmap;
aMenuPixDown->resize(16, 16);
iMenuPix = new KPixmap;
iMenuPix->resize(16, 16);
iMenuPixDown = new KPixmap;
iMenuPixDown->resize(16, 16);
aHelpPix = new KPixmap;
aHelpPix->resize(16, 16);
aHelpPixDown = new KPixmap;
aHelpPixDown->resize(16, 16);
iHelpPix = new KPixmap;
iHelpPix->resize(16, 16);
iHelpPixDown = new KPixmap;
iHelpPixDown->resize(16, 16);
// there seems to be no way to load X bitmaps from data properly, so
// we need to create new ones for each mask :P
QBitmap pinupMask(16, 16, pinup_mask_bits, true);
aPinupPix->setMask(pinupMask);
iPinupPix->setMask(pinupMask);
QBitmap pindownMask(16, 16, pindown_mask_bits, true);
aPinupPixDown->setMask(pindownMask);
iPinupPixDown->setMask(pindownMask);
QBitmap menuMask(16, 16, menu_mask_bits, true);
aMenuPix->setMask(menuMask);
iMenuPix->setMask(menuMask);
aMenuPixDown->setMask(menuMask);
iMenuPixDown->setMask(menuMask);
QBitmap helpMask(16, 16, help_mask_bits, true);
aHelpPix->setMask(helpMask);
iHelpPix->setMask(helpMask);
aHelpPixDown->setMask(helpMask);
iHelpPixDown->setMask(helpMask);
redraw_pixmaps();
}
B2Button::B2Button(KPixmap *pix, KPixmap *pixDown, QWidget *parent,
const char *name)
: QButton(parent, name)
{
pNorm = pix;
pDown = pixDown;
setFixedSize(16, 16);
setFocusPolicy(NoFocus);
resize(16, 16);
}
QSize B2Button::sizeHint() const
{
return(QSize(16, 16));
}
QSizePolicy B2Button::sizePolicy() const
{
return(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed));
}
void B2Button::drawButton(QPainter *p)
{
p->fillRect(rect(), bg);
// hehe, nasty casts - I'm such a bad boy ;-)
if(useMiniIcon && !(((B2Client*)parent())->miniIcon().isNull())){
QPixmap miniIcon = ((B2Client*)parent())->miniIcon();
p->drawPixmap((width()-miniIcon.width())/2,
(height()-miniIcon.height())/2, miniIcon);
}
else{
if(isOn() || isDown())
p->drawPixmap((width()-pDown->width())/2,
(height()-pDown->height())/2, *pDown);
else
p->drawPixmap((width()-pNorm->width())/2,
(height()-pNorm->height())/2, *pNorm);
}
}
void B2Button::setPixmaps(KPixmap *pix, KPixmap *pixDown)
{
pNorm = pix;
pDown = pixDown;
repaint(false);
}
B2Client::B2Client( Workspace *ws, WId w, QWidget *parent,
const char *name )
: Client( ws, w, parent, name, WResizeNoErase )
{
create_pixmaps();
g = new QGridLayout( this, 0, 0);
g->addMultiCellWidget(windowWrapper(), 1, 1, 1, 2);
g->addColSpacing(0, 4);
g->addColSpacing(1, providesContextHelp() ? 102 : 85);
g->setColStretch(2, 1);
g->setRowStretch(1, 1);
g->addColSpacing(3, 4);
g->addRowSpacing(2, 8);
// titlebar
g->addRowSpacing(0, 20);
int i;
for(i=0; i < 6; ++i){
button[i] = new B2Button(this);
button[i]->setFixedSize(16, 16);
}
button[BtnSticky]->setToggle();
button[BtnSticky]->setDown(isSticky());
button[BtnMenu]->setUseMiniIcon();
if(!providesContextHelp())
button[5]->hide();
if(isActive()){
button[BtnMenu]->setPixmaps(aMenuPix, aMenuPixDown);
button[BtnSticky]->setPixmaps(aPinupPix, aPinupPixDown);
button[BtnIconify]->setPixmaps(aIconifyPix, aIconifyPixDown);
button[BtnClose]->setPixmaps(aClosePix, aClosePixDown);
button[BtnHelp]->setPixmaps(aHelpPix, aHelpPixDown);
if(isMaximized())
button[BtnMax]->setPixmaps(aNormalizePix, aNormalizePixDown);
else
button[BtnMax]->setPixmaps(aMaxPix, aMaxPixDown);
}
else{
button[BtnMenu]->setPixmaps(iMenuPix, iMenuPixDown); // fixme
button[BtnSticky]->setPixmaps(iPinupPix, iPinupPixDown);
button[BtnIconify]->setPixmaps(iIconifyPix, iIconifyPixDown);
button[BtnClose]->setPixmaps(iClosePix, iClosePixDown);
button[BtnHelp]->setPixmaps(iHelpPix, iHelpPixDown);
if(isMaximized())
button[BtnMax]->setPixmaps(iNormalizePix, iNormalizePixDown);
else
button[BtnMax]->setPixmaps(iMaxPix, iMaxPixDown);
}
QColor c = options->colorGroup(Options::TitleBar, isActive()).
color(QColorGroup::Button);
for(i=0; i < 6; ++i)
button[i]->setBg(c);
positionButtons();
connect(button[BtnMenu], SIGNAL(clicked()), this, SLOT(menuButtonPressed()));
connect(button[BtnSticky], SIGNAL(clicked()), this, SLOT(toggleSticky()));
connect(button[BtnIconify], SIGNAL(clicked()), this, SLOT(iconify()));
connect(button[BtnMax], SIGNAL(clicked()), this, SLOT(maximize()));
connect(button[BtnClose], SIGNAL(clicked()), this, SLOT(closeWindow()));
connect(button[BtnHelp], SIGNAL(clicked()), this, SLOT(contextHelp()));
connect(options, SIGNAL(resetClients()), this, SLOT(slotReset()));
}
void B2Client::resizeEvent( QResizeEvent* e)
{
Client::resizeEvent( e );
positionButtons();
doShape();
if ( isVisibleToTLW() && !testWFlags( WNorthWestGravity )) {
QPainter p( this );
QRect t = g->cellGeometry(0, 1);
t.setRight(button[BtnClose]->x()+17);
t.setHeight(20);
QRegion r = rect();
r = r.subtract( t );
p.setClipRegion( r );
p.eraseRect( rect() );
}
}
void B2Client::captionChange( const QString &)
{
positionButtons();
doShape();
repaint();
}
void B2Client::paintEvent( QPaintEvent* )
{
QPainter p( this );
QRect t = g->cellGeometry(0, 1);
t.setRight(button[BtnClose]->x()+17);
t.setHeight(20);
// inner window rect
p.drawRect(3, t.bottom(), width()-6, height()-t.height()-6);
// outer frame rect
p.drawRect(0, t.bottom()-3, width(), height()-t.height());
// frame shade panel
qDrawShadePanel(&p, 1, t.bottom()-2, width()-2, height()-t.height()-2,
options->colorGroup(Options::Frame, isActive()),
false);
// black titlebar frame
p.setPen(Qt::black);
p.drawLine(0, 0, 0, height()-5);
p.drawLine(0, 0, t.right()+4, 0);
p.drawLine(t.right()+4, 0, t.right()+4, t.bottom());
// titlebar fill
qDrawShadeRect(&p, 1, 1, t.width()+6, t.height()-1,
options->colorGroup(Options::TitleBar, isActive()),
false, 1, 0,
&options->colorGroup(Options::TitleBar, isActive()).
brush(QColorGroup::Button));
//bottom handle rect
int hx = width()-40;
int hw = 40;
//p.drawRect(hx, height()-8, hw, 8);
p.drawLine(width()-1, height()-8, width()-1, height()-1);
p.drawLine(hx, height()-1, width()-1, height()-1);
p.drawLine(hx, height()-4, hx, height()-1);
p.fillRect(hx+1, height()-7, hw-2, 6,
options->colorGroup(Options::Frame, isActive())
.brush(QColorGroup::Button));
p.setPen(options->colorGroup(Options::Frame, isActive()).dark());
p.drawLine(width()-2, height()-8, width()-2, height()-2);
p.drawLine(hx+1, height()-2, width()-2, height()-2);
p.setPen(options->colorGroup(Options::Frame, isActive()).light());
p.drawLine(hx+1, height()-6, hx+1, height()-3);
p.drawLine(hx+1, height()-7, width()-3, height()-7);
p.setPen(options->color(Options::Font, isActive()));
p.setFont(options->font(isActive()));
t.setX(providesContextHelp() ? button[BtnHelp]->x()+17 :
button[BtnSticky]->x()+17);
t.setRight(button[BtnIconify]->x()-1);
p.drawText(t, AlignLeft | AlignVCenter, caption());
}
#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
void B2Client::doShape()
{
QRect t = g->cellGeometry(0, 1);
t.setRight(button[BtnClose]->x()+17);
t.setHeight(20);
QRegion mask(QRect(0, 0, width(), height()));
// top to the tilebar right
mask -= QRect(t.width()+8, 0, width()-t.width()-8, t.height()-4);
mask -= QRect(width()-1, t.height()-4, 1, 1); // top right point
mask -= QRect(width()-1, height()-1, 1, 1); // bottom right point
mask -= QRect(0, height()-5, 1, 1); // bottom left point
mask -= QRect(width()-1, height()-1, 1, 1); // bottom right point
mask -= QRect(width()-40, height()-1, 1, 1); // handle left point
mask -= QRect(0, height()-4, width()-40, 4); // bottom left
setMask(mask);
}
void B2Client::showEvent(QShowEvent *ev)
{
Client::showEvent(ev);
doShape();
repaint();
}
void B2Client::windowWrapperShowEvent( QShowEvent* )
{
doShape();
}
void B2Client::mouseDoubleClickEvent( QMouseEvent * e )
{
if (e->pos().y() < 19)
setShade( !isShade() );
workspace()->requestFocus( this );
}
void B2Client::stickyChange(bool on)
{
button[1]->setDown(on);
}
void B2Client::maximizeChange(bool m)
{
if(m){
if(isActive())
button[BtnMax]->setPixmaps(aNormalizePix, aNormalizePixDown);
else
button[BtnMax]->setPixmaps(iNormalizePix, iNormalizePixDown);
}
else{
if(isActive())
button[BtnMax]->setPixmaps(aMaxPix, aMaxPixDown);
else
button[BtnMax]->setPixmaps(iMaxPix, iMaxPixDown);
}
button[BtnMax]->repaint();
}
void B2Client::activeChange(bool on)
{
if(on){
button[BtnMenu]->setPixmaps(aMenuPix, aMenuPixDown);
button[BtnSticky]->setPixmaps(aPinupPix, aPinupPixDown);
button[BtnIconify]->setPixmaps(aIconifyPix, aIconifyPixDown);
button[BtnClose]->setPixmaps(aClosePix, aClosePixDown);
button[BtnHelp]->setPixmaps(aHelpPix, aHelpPixDown);
if(isMaximized())
button[BtnMax]->setPixmaps(aNormalizePix, aNormalizePixDown);
else
button[BtnMax]->setPixmaps(aMaxPix, aMaxPixDown);
}
else{
button[BtnMenu]->setPixmaps(iMenuPix, iMenuPixDown);
button[BtnSticky]->setPixmaps(iPinupPix, iPinupPixDown);
button[BtnIconify]->setPixmaps(iIconifyPix, iIconifyPixDown);
button[BtnClose]->setPixmaps(iClosePix, iClosePixDown);
button[BtnHelp]->setPixmaps(iHelpPix, iHelpPixDown);
if(isMaximized())
button[BtnMax]->setPixmaps(iNormalizePix, iNormalizePixDown);
else
button[BtnMax]->setPixmaps(iMaxPix, iMaxPixDown);
}
int i;
QColor c = options->colorGroup(Options::TitleBar, on).
color(QColorGroup::Button);
for(i=0; i < 6; ++i){
button[i]->setBg(c);
button[i]->repaint();
}
Client::activeChange(on);
}
void B2Client::init()
{
//
}
void B2Client::menuButtonPressed()
{
workspace()->clientPopup(this)->
popup(button[BtnMenu]->mapToGlobal(button[BtnMenu]->
rect().bottomLeft()));
}
void B2Client::slotReset()
{
redraw_pixmaps();
QColor c = options->colorGroup(Options::TitleBar, isActive()).
color(QColorGroup::Button);
int i;
for(i=0; i < 6; ++i){
button[i]->setBg(c);
button[i]->repaint(false);
}
repaint();
}
static void redraw_pixmaps()
{
QColorGroup aGrp = options->colorGroup(Options::ButtonSingleColor, true);
QColorGroup iGrp = options->colorGroup(Options::ButtonSingleColor, false);
// close
drawB2Rect(aClosePix, aGrp.button(), false);
drawB2Rect(aClosePixDown, aGrp.button(), true);
drawB2Rect(iClosePix, iGrp.button(), false);
drawB2Rect(iClosePixDown, iGrp.button(), true);
// maximize
*aMaxPix = *aClosePix;
aMaxPix->detach();
*aMaxPixDown = *aClosePixDown;
aMaxPixDown->detach();
*iMaxPix = *iClosePix;
iMaxPix->detach();
*iMaxPixDown = *iClosePixDown;
iMaxPixDown->detach();
// normalize
KPixmap smallBox;
smallBox.resize(10, 10);
KPixmap largeBox;
largeBox.resize(12, 12);
drawB2Rect(&smallBox, aGrp.button(), false);
drawB2Rect(&largeBox, aGrp.button(), false);
aNormalizePix->fill(options->color(Options::TitleBar, true));
bitBlt(aNormalizePix, 3, 3, &largeBox, 0, 0, 12, 12, Qt::CopyROP, true);
bitBlt(aNormalizePix, 0, 0, &smallBox, 0, 0, 10, 10, Qt::CopyROP, true);
bitBlt(aIconifyPix, 0, 0, &smallBox, 0, 0, 10, 10, Qt::CopyROP, true);
drawB2Rect(&smallBox, aGrp.button(), true);
drawB2Rect(&largeBox, aGrp.button(), true);
aNormalizePixDown->fill(options->color(Options::TitleBar, true));
bitBlt(aNormalizePixDown, 3, 3, &largeBox, 0, 0, 12, 12, Qt::CopyROP, true);
bitBlt(aNormalizePixDown, 0, 0, &smallBox, 0, 0, 10, 10, Qt::CopyROP, true);
bitBlt(aIconifyPixDown, 0, 0, &smallBox, 0, 0, 10, 10, Qt::CopyROP, true);
drawB2Rect(&smallBox, iGrp.button(), false);
drawB2Rect(&largeBox, iGrp.button(), false);
iNormalizePix->fill(options->color(Options::TitleBar, false));
bitBlt(iNormalizePix, 3, 3, &largeBox, 0, 0, 12, 12, Qt::CopyROP, true);
bitBlt(iNormalizePix, 0, 0, &smallBox, 0, 0, 10, 10, Qt::CopyROP, true);
bitBlt(iIconifyPix, 0, 0, &smallBox, 0, 0, 10, 10, Qt::CopyROP, true);
drawB2Rect(&smallBox, iGrp.button(), true);
drawB2Rect(&largeBox, iGrp.button(), true);
iNormalizePixDown->fill(options->color(Options::TitleBar, false));
bitBlt(iNormalizePixDown, 3, 3, &largeBox, 0, 0, 12, 12, Qt::CopyROP, true);
bitBlt(iNormalizePixDown, 0, 0, &smallBox, 0, 0, 10, 10, Qt::CopyROP, true);
bitBlt(iIconifyPixDown, 0, 0, &smallBox, 0, 0, 10, 10, Qt::CopyROP, true);
QPainter p;
// x for close
p.begin(aClosePix);
kColorBitmaps(&p, aGrp, 0, 0, 16, 16, true, close_white_bits,
NULL, NULL, close_dgray_bits, NULL, NULL);
p.end();
p.begin(aClosePixDown);
kColorBitmaps(&p, aGrp, 0, 0, 16, 16, true, close_white_bits,
NULL, NULL, close_dgray_bits, NULL, NULL);
p.end();
p.begin(iClosePix);
kColorBitmaps(&p, iGrp, 0, 0, 16, 16, true, close_white_bits,
NULL, NULL, close_dgray_bits, NULL, NULL);
p.end();
p.begin(iClosePixDown);
kColorBitmaps(&p, iGrp, 0, 0, 16, 16, true, close_white_bits,
NULL, NULL, close_dgray_bits, NULL, NULL);
p.end();
// pin
p.begin(aPinupPix);
kColorBitmaps(&p, aGrp, 0, 0, 16, 16, true, pinup_white_bits,
pinup_gray_bits, NULL, pinup_dgray_bits, NULL, NULL);
p.end();
p.begin(aPinupPixDown);
kColorBitmaps(&p, aGrp, 0, 0, 16, 16, true, pindown_white_bits,
pindown_gray_bits, NULL, pindown_dgray_bits, NULL, NULL);
p.end();
p.begin(iPinupPix);
kColorBitmaps(&p, iGrp, 0, 0, 16, 16, true, pinup_white_bits,
pinup_gray_bits, NULL, pinup_dgray_bits, NULL, NULL);
p.end();
p.begin(iPinupPixDown);
kColorBitmaps(&p, iGrp, 0, 0, 16, 16, true, pindown_white_bits,
pindown_gray_bits, NULL, pindown_dgray_bits, NULL, NULL);
p.end();
// menu
p.begin(aMenuPix);
kColorBitmaps(&p, aGrp, 0, 0, 16, 16, true, menu_white_bits,
NULL, NULL, menu_dgray_bits, NULL, NULL);
p.end();
p.begin(aMenuPixDown);
kColorBitmaps(&p, aGrp, 0, 0, 16, 16, true, menu_white_bits,
NULL, NULL, menu_dgray_bits, NULL, NULL);
p.end();
p.begin(iMenuPix);
kColorBitmaps(&p, iGrp, 0, 0, 16, 16, true, menu_white_bits,
NULL, NULL, menu_dgray_bits, NULL, NULL);
p.end();
p.begin(iMenuPixDown);
kColorBitmaps(&p, iGrp, 0, 0, 16, 16, true, menu_white_bits,
NULL, NULL, menu_dgray_bits, NULL, NULL);
p.end();
// help
p.begin(aHelpPix);
kColorBitmaps(&p, aGrp, 0, 0, 16, 16, true, help_light_bits,
NULL, NULL, help_dark_bits, NULL, NULL);
p.end();
p.begin(aHelpPixDown);
kColorBitmaps(&p, aGrp, 0, 0, 16, 16, true, help_light_bits,
NULL, NULL, help_dark_bits, NULL, NULL);
p.end();
p.begin(iHelpPix);
kColorBitmaps(&p, aGrp, 0, 0, 16, 16, true, help_light_bits,
NULL, NULL, help_dark_bits, NULL, NULL);
p.end();
p.begin(iHelpPixDown);
kColorBitmaps(&p, aGrp, 0, 0, 16, 16, true, help_light_bits,
NULL, NULL, help_dark_bits, NULL, NULL);
p.end();
}
void B2Client::positionButtons()
{
QFontMetrics fm(options->font(isActive()));
int textLen = fm.width(caption());
int xpos = 4;
button[BtnMenu]->move(xpos, 2);
xpos+=17;
button[BtnSticky]->move(xpos, 2);
xpos+=17;
if(providesContextHelp()){
button[BtnHelp]->move(xpos, 2);
xpos+=17;
}
if(xpos + textLen+52 < width()-8)
xpos += textLen+1;
else
xpos = width()-8-52;
button[BtnIconify]->move(xpos, 2);
xpos+=17;
button[BtnMax]->move(xpos, 2);
xpos+=17;
button[BtnClose]->move(xpos, 2);
}
#include "b2client.moc"

69
clients/b2/b2client.h Normal file
View file

@ -0,0 +1,69 @@
#ifndef __B2CLIENT_H
#define __B2CLIENT_H
#include <qtoolbutton.h>
#include <qbitmap.h>
#include <kpixmap.h>
#include "../../client.h"
class QLabel;
//class QSpacerItem;
//class QHBoxLayout;
class QGridLayout;
class B2Button : public QButton
{
public:
B2Button(QWidget *parent=0, const char *name=0)
: QButton(parent, name){useMiniIcon = false;}
B2Button(KPixmap *pix, KPixmap *pixDown, QWidget *parent=0, const char *name=0);
void setBg(const QColor &c){bg = c;}
void setPixmaps(KPixmap *pix, KPixmap *pixDown);
void setToggle(){setToggleType(Toggle);}
void setActive(bool on){setOn(on);}
void setUseMiniIcon(){useMiniIcon = true;}
QSize sizeHint() const;
QSizePolicy sizePolicy() const;
protected:
virtual void drawButton(QPainter *p);
void drawButtonLabel(QPainter *){;}
bool useMiniIcon;
KPixmap *pNorm, *pDown;
QColor bg; //only use one color (the rest is pixmap) so forget QPalette ;)
};
class B2Client : public Client
{
Q_OBJECT
public:
B2Client( Workspace *ws, WId w, QWidget *parent=0, const char *name=0 );
~B2Client(){;}
protected:
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 activeChange(bool on);
void maximizeChange(bool m);
void doShape();
private slots:
void menuButtonPressed();
void slotReset();
private:
void positionButtons();
enum ButtonType{BtnMenu=0, BtnSticky, BtnIconify, BtnMax, BtnClose,
BtnHelp};
//B2Button* button[5];
B2Button* button[6];
//QSpacerItem* titlebar;
//QHBoxLayout *tLayout;
QGridLayout *g;
};
#endif

98
clients/b2/bitmaps.h Normal file
View file

@ -0,0 +1,98 @@
#ifndef __STDCLIENT_BITMAPS_H
#define __STDCLIENT_BITMAPS_H
/**
* The standard client has the capability to color it's titlebar buttons
* according to the new color scheme. In order to do this it needs a bitmap
* for each shade which it draws into a pixmap with the appropriate color.
* These are all the bitmaps.
*/
static unsigned char close_white_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x04, 0x10, 0x04, 0x08, 0x08, 0x04, 0x10, 0x02,
0x20, 0x01, 0x40, 0x00, 0x40, 0x00, 0x20, 0x01, 0x10, 0x02, 0x08, 0x04,
0x04, 0x08, 0x04, 0x10, 0x00, 0x00, 0x00, 0x00};
static unsigned char close_dgray_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x08, 0x20, 0x18, 0x30, 0x30, 0x18, 0x60, 0x0c,
0xc0, 0x06, 0x80, 0x03, 0x80, 0x03, 0xc0, 0x06, 0x60, 0x0c, 0x30, 0x18,
0x18, 0x30, 0x08, 0x20, 0x00, 0x00, 0x00, 0x00};
static unsigned char menu_white_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xfc, 0x3f, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char menu_dgray_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x20, 0xf8, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char menu_mask_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xfc, 0x3f, 0x04, 0x20, 0xfc, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char pindown_white_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x80, 0x1f, 0xa0, 0x03,
0xb0, 0x01, 0x30, 0x01, 0xf0, 0x00, 0x70, 0x00, 0x20, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char pindown_gray_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c,
0x00, 0x0e, 0x00, 0x06, 0x00, 0x00, 0x80, 0x07, 0xc0, 0x03, 0xe0, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char pindown_dgray_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x10, 0x70, 0x20, 0x50, 0x20,
0x48, 0x30, 0xc8, 0x38, 0x08, 0x1f, 0x08, 0x18, 0x10, 0x1c, 0x10, 0x0e,
0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char pindown_mask_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x1f, 0xf0, 0x3f, 0xf0, 0x3f,
0xf8, 0x3f, 0xf8, 0x3f, 0xf8, 0x1f, 0xf8, 0x1f, 0xf0, 0x1f, 0xf0, 0x0f,
0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char pinup_white_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x11,
0x3f, 0x15, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char pinup_gray_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0x0a, 0xbf, 0x0a, 0x80, 0x15, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char pinup_dgray_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x40, 0x31, 0x40, 0x2e,
0x40, 0x20, 0x40, 0x20, 0x7f, 0x2a, 0x40, 0x3f, 0xc0, 0x31, 0xc0, 0x20,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char pinup_mask_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x20, 0xc0, 0x31, 0xc0, 0x3f,
0xff, 0x3f, 0xff, 0x3f, 0xff, 0x3f, 0xc0, 0x3f, 0xc0, 0x31, 0xc0, 0x20,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char help_mask_bits[] = {
0x00,0x00,0x00,0x00,0xe0,0x03,0xf0,0x07,0x70,0x0e,0x60,0x0e,0x00,0x0f,0x80,
0x07,0xc0,0x03,0xc0,0x01,0x80,0x01,0xc0,0x00,0xc0,0x01,0x80,0x01,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x4c,0x0b,0x08,0x58,0x65,0x09,0x08,0x90,0x00,0x00,
0x00,0x09,0x04,0x00,0x00,0x72,0x6f,0x6f,0x74,0x00,0x24,0x31,0x24,0x47,0x6b,
0x65,0x44,0x78,0x63 };
static unsigned char help_dark_bits[] = {
0x00,0x00,0x00,0x00,0xe0,0x03,0x30,0x06,0x30,0x06,0x00,0x06,0x00,0x03,0x80,
0x01,0xc0,0x00,0xc0,0x00,0x00,0x00,0xc0,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x65,0x64,0x28,0x29,0x00,0x00,0x00,0x00,0x90,0x00,0x00,
0x00,0x21,0x00,0x00,0x00,0x34,0xfe,0x12,0x2b,0x00,0x00,0xff,0xff,0x58,0xc0,
0x01,0x2b,0x45,0xfe };
static unsigned char help_light_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x01,0x40,0x08,0x60,0x08,0x00,0x0c,0x00,
0x06,0x00,0x03,0x00,0x01,0x80,0x01,0x00,0x00,0x00,0x01,0x80,0x01,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x4c,0x0b,0x08,0x58,0x65,0x09,0x08,0x90,0x00,0x00,
0x00,0x09,0x04,0x00,0x00,0x72,0x6f,0x6f,0x74,0x00,0x24,0x31,0x24,0x47,0x6b,
0x65,0x44,0x78,0x63 };
#endif