summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/liquid/liquid.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp
index e6d8310..4a65952 100644
--- a/noncore/styles/liquid/liquid.cpp
+++ b/noncore/styles/liquid/liquid.cpp
@@ -1,139 +1,141 @@
/*-
* Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved.
*/
//
// (c) 2002 Robert 'sandman' Griebl
//
#ifndef INCLUDE_MENUITEM_DEF
#define INCLUDE_MENUITEM_DEF
#endif
#include <qmenudata.h>
#include "liquid.h"
//#include "liquiddeco.h"
#include <qapplication.h>
#include <qpe/config.h>
#include "effects.h"
#include <qpalette.h>
#include <qbitmap.h>
#include <qtabbar.h>
#include <qpopupmenu.h>
#include <qobjectlist.h>
#include <qimage.h>
#include <qtimer.h>
#include <qpixmapcache.h>
#include <qradiobutton.h>
#include <qcombobox.h>
#include <qdrawutil.h>
#include <qwidgetlist.h>
#include <qtoolbutton.h>
#include <qheader.h>
#include <unistd.h>
#include <qmenubar.h>
#include <qprogressbar.h>
#include <qlineedit.h>
+#include <qlistbox.h>
#include <stdio.h>
#include "htmlmasks.h"
#include "embeddata.h"
+
typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *,
QColorGroup &, bool, bool);
QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl);
void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color)
{
QImage img(pix.convertToImage());
QImageEffect::fade(img, 0.9, color);
int x, y;
int r, g, b;
for(y=0; y < img.height(); y+=3){
unsigned int *data = (unsigned int *) img.scanLine(y);
for(x=0; x < img.width(); ++x){
r = qRed(data[x]);
g = qGreen(data[x]);
b = qBlue(data[x]);
if(r-10)
r-=10;
if(g-10)
g-=10;
if(b-10)
b-=10;
data[x] = qRgb(r, g, b);
}
}
pix.convertFromImage(img);
}
TransMenuHandler::TransMenuHandler(QObject *parent)
: QObject(parent)
{
pixDict.setAutoDelete(true);
reloadSettings();
}
void TransMenuHandler::reloadSettings()
{
pixDict.clear();
Config config ( "qpe" );
config. setGroup ( "Liquid-Style" );
type = config. readNumEntry("Type", TransStippleBg);
color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name()));
fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name()));
opacity = config. readNumEntry("Opacity", 10);
if ( opacity < -20 )
opacity = 20;
else if ( opacity > 20 )
opacity = 20;
shadowText = config. readBoolEntry("ShadowText", true);
}
bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev)
{
QWidget *p = (QWidget *)obj;
if(ev->type() == QEvent::Show){
if(type == TransStippleBg || type == TransStippleBtn ||
type == Custom){
QApplication::syncX();
QPixmap *pix = new QPixmap;
if(p->testWFlags(Qt::WType_Popup)){
QRect r(p->x(), p->y(), p->width(), p->height());
QRect deskR = QApplication::desktop()->rect();
if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){
r.setBottom(deskR.bottom());
r.setRight(deskR.right());
}
*pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(),
r.width(), r.height());
}
else{ // tear off menu
pix->resize(p->width(), p->height());
pix->fill(Qt::black.rgb());
}
if(type == TransStippleBg){
stripePixmap(*pix, p->colorGroup().background());
}
else if(type == TransStippleBtn){
stripePixmap(*pix, p->colorGroup().button());
}
else{
QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color);
}
pixDict.insert(p->winId(), pix);
if ( !p->inherits("QPopupMenu"))
p->setBackgroundPixmap(*pix);
QObjectList *ol = p-> queryList("QWidget");
for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
QWidget *wid = (QWidget *) it.current ( );
@@ -1315,193 +1317,194 @@ void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p)
}
if(act){
QFont font = btn->font();
font.setBold(true);
p->setFont(font);
QColor shadow(btn->colorGroup().button().dark(130));
drawItem( p, x1+1, y1+1, w, h,
AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(),
btn->pixmap(), btn->text(), -1,
&shadow);
drawItem( p, x1, y1, w, h,
AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(),
btn->pixmap(), btn->text(), -1, &btn->colorGroup().light());
}
else{
/* Too blurry
drawItem( p, x1+1, y1+1, w, h,
AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(),
btn->pixmap(), btn->text(), -1,
&btn->colorGroup().button().dark(115));
*/
drawItem( p, x1, y1, w, h,
AlignCenter | ShowPrefix,
btn->colorGroup(), btn->isEnabled(),
btn->pixmap(), btn->text(), -1,
&btn->colorGroup().buttonText());
}
}
void LiquidStyle::drawButtonMask(QPainter *p, int x, int y, int w, int h)
{
int x2 = x+w-1;
int y2 = y+h-1;
p->setPen(Qt::color1);
p->fillRect(x, y, w, h, Qt::color0);
if(w < 21 || h < 21){
// outer rect
p->drawLine(x, y+2, x, y2-2); // l
p->drawLine(x2, y+2, x2, y2-2); // r
p->drawLine(x+2, y, x2-2, y); // t
p->drawLine(x+2, y2, x2-2, y2); // b
p->drawLine(x+1, y+1, x2-1, y+1); // top second line
p->drawLine(x+1, y2-1, x2-1, y2-1); // bottom second line
p->fillRect(x+1, y+2, w-2, h-4, Qt::color1);
}
else{
int x2 = x+w-1;
int y2 = y+h-1;
int bx2 = htmlBtnMaskBmp.width()-1;
int by2 = htmlBtnMaskBmp.height()-1;
p->drawPixmap(0, 0, htmlBtnMaskBmp, 0, 0, 10, 10); // tl
p->drawPixmap(x2-9, 0, htmlBtnMaskBmp, bx2-9, 0, 10, 10); // tr
p->drawPixmap(0, y2-9, htmlBtnMaskBmp, 0, by2-9, 10, 10); // bl
p->drawPixmap(x2-9, y2-9, htmlBtnMaskBmp, bx2-9, by2-9, 10, 10); // br
// fills
p->fillRect(10, 0, w-20, 10, Qt::color1); // top
p->fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom
p->fillRect(0, 10, w, h-20, Qt::color1); // middle
}
}
void LiquidStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken,
const QBrush */*fill*/)
{
if(currentHeader && p->device() == currentHeader){
int id = currentHeader->sectionAt(x);
bool isHeaderHover = id != -1 && id == headerHoverID;
drawClearBevel(p, x, y, w, h, sunken ?
g.button() : isHeaderHover ? g.button().light(110) :
g.background(), g.background());
}
else
drawClearBevel(p, x, y, w, h, sunken ? g.button() : g.background(),
g.background());
}
QRect LiquidStyle::buttonRect(int x, int y, int w, int h)
{
return(QRect(x+5, y+5, w-10, h-10));
}
void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h,
const QColorGroup &g, bool sunken,
bool edit, bool, const QBrush *)
{
bool isActive = false;
if (( painter->device()->devType() == QInternal::Widget ) &&
(
( qApp-> focusWidget ( ) == painter-> device ( )) ||
(
edit &&
((QWidget *) painter-> device ( ))-> inherits ( "QComboBox" ) &&
- ( qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->lineEdit ( ))
+ ( qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->lineEdit ( ) ||
+ qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->listBox ( ))
)
)
) {
isActive = true;
}
bool isMasked = false;
if(painter->device()->devType() == QInternal::Widget)
isMasked = ((QWidget*)painter->device())->autoMask();
// TODO: Do custom code, don't just call drawRoundButton into a pixmap
QPixmap tmpPix(w, h);
QPainter p(&tmpPix);
drawRoundButton(&p, g.button(), g.background(), 0, 0, w, h, false,
sunken, false, isMasked);
if(!isActive){
p.setClipRect(0, 0, w-17, h);
drawRoundButton(&p, g.background(), g.background(), 0, 0, w, h, false,
sunken, false, isMasked);
}
p.end();
int x2 = x+w-1;
int y2 = y+h-1;
int bx2 = btnMaskBmp.width()-1;
int by2 = btnMaskBmp.height()-1;
QBitmap btnMask(w, h);
QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp;
p.begin(&btnMask);
p.fillRect(0, 0, w, h, Qt::color0);
p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl
p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr
p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl
p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br
// fills
p.fillRect(10, 0, w-20, 10, Qt::color1); // top
p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom
p.fillRect(0, 10, w, h-20, Qt::color1); // middle
p.end();
tmpPix.setMask(btnMask);
painter->drawPixmap(x, y, tmpPix);
painter->setPen(g.button().dark(120));
painter->drawLine(x2-16, y+1, x2-16, y2-1);
if(edit){
painter->setPen(g.mid());
painter->drawRect(x+8, y+2, w-25, h-4);
}
int arrow_h = h / 3;
int arrow_w = arrow_h;
int arrow_x = w - arrow_w - 6;
int arrow_y = (h - arrow_h) / 2;
drawArrow(painter, DownArrow, false, arrow_x, arrow_y, arrow_w, arrow_h, g, true);
}
void LiquidStyle::drawComboButtonMask(QPainter *p, int x, int y, int w, int h)
{
drawButtonMask(p, x, y, w, h);
}
QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h)
{
//return(QRect(x+3, y+3, w - (h / 3) - 13, h-6));
return(QRect(x+9, y+3, w - (h / 3) - 20, h-6));
}
QRect LiquidStyle::comboButtonFocusRect(int /*x*/, int /*y*/, int /*w*/, int /*h*/)
{
return QRect ( );
// return(QRect(x+5, y+3, w-(h/3)-13, h-5));
}
void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb,
int sliderStart, uint controls,
uint activeControl)
{
int sliderMin, sliderMax, sliderLength, buttonDim;
scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
if (sliderStart > sliderMax)
sliderStart = sliderMax;
bool horiz = sb->orientation() == QScrollBar::Horizontal;
QColorGroup g = sb->colorGroup();
QRect addB, subHC, subB;
QRect addPageR, subPageR, sliderR;
int addX, addY, subX, subY;
int len = horiz ? sb->width() : sb->height();
int extent = horiz ? sb->height() : sb->width();
// a few apps (ie: KSpread), are broken and use a hardcoded scrollbar
// extent of 16. Luckily, most apps (ie: Kate), seem fixed by now.
bool brokenApp;
if(extent == 16)