summaryrefslogtreecommitdiff
authorsandman <sandman>2002-12-03 00:59:30 (UTC)
committer sandman <sandman>2002-12-03 00:59:30 (UTC)
commit26557b9370b3d1f28224374f8a035ae9051a1317 (patch) (unidiff)
treeb45c67bd4d71910f1faf020e23a01b648d2effbf
parentc3c95ff297355f7024c15134bbc1d15d340bf8fd (diff)
downloadopie-26557b9370b3d1f28224374f8a035ae9051a1317.zip
opie-26557b9370b3d1f28224374f8a035ae9051a1317.tar.gz
opie-26557b9370b3d1f28224374f8a035ae9051a1317.tar.bz2
small fix regarding focus handling on combo-boxes
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,91 +1,93 @@
1/*- 1/*-
2 * Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved. 2 * Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved.
3 */ 3 */
4 4
5// 5//
6// (c) 2002 Robert 'sandman' Griebl 6// (c) 2002 Robert 'sandman' Griebl
7// 7//
8 8
9 9
10#ifndef INCLUDE_MENUITEM_DEF 10#ifndef INCLUDE_MENUITEM_DEF
11#define INCLUDE_MENUITEM_DEF 11#define INCLUDE_MENUITEM_DEF
12#endif 12#endif
13 13
14#include <qmenudata.h> 14#include <qmenudata.h>
15#include "liquid.h" 15#include "liquid.h"
16//#include "liquiddeco.h" 16//#include "liquiddeco.h"
17#include <qapplication.h> 17#include <qapplication.h>
18#include <qpe/config.h> 18#include <qpe/config.h>
19#include "effects.h" 19#include "effects.h"
20#include <qpalette.h> 20#include <qpalette.h>
21#include <qbitmap.h> 21#include <qbitmap.h>
22#include <qtabbar.h> 22#include <qtabbar.h>
23#include <qpopupmenu.h> 23#include <qpopupmenu.h>
24#include <qobjectlist.h> 24#include <qobjectlist.h>
25#include <qimage.h> 25#include <qimage.h>
26#include <qtimer.h> 26#include <qtimer.h>
27#include <qpixmapcache.h> 27#include <qpixmapcache.h>
28#include <qradiobutton.h> 28#include <qradiobutton.h>
29#include <qcombobox.h> 29#include <qcombobox.h>
30#include <qdrawutil.h> 30#include <qdrawutil.h>
31#include <qwidgetlist.h> 31#include <qwidgetlist.h>
32#include <qtoolbutton.h> 32#include <qtoolbutton.h>
33#include <qheader.h> 33#include <qheader.h>
34#include <unistd.h> 34#include <unistd.h>
35#include <qmenubar.h> 35#include <qmenubar.h>
36#include <qprogressbar.h> 36#include <qprogressbar.h>
37#include <qlineedit.h> 37#include <qlineedit.h>
38#include <qlistbox.h>
38 39
39#include <stdio.h> 40#include <stdio.h>
40 41
41#include "htmlmasks.h" 42#include "htmlmasks.h"
42#include "embeddata.h" 43#include "embeddata.h"
43 44
45
44typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, 46typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *,
45 QColorGroup &, bool, bool); 47 QColorGroup &, bool, bool);
46 48
47QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl); 49QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl);
48 50
49void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color) 51void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color)
50{ 52{
51 QImage img(pix.convertToImage()); 53 QImage img(pix.convertToImage());
52 QImageEffect::fade(img, 0.9, color); 54 QImageEffect::fade(img, 0.9, color);
53 int x, y; 55 int x, y;
54 int r, g, b; 56 int r, g, b;
55 for(y=0; y < img.height(); y+=3){ 57 for(y=0; y < img.height(); y+=3){
56 unsigned int *data = (unsigned int *) img.scanLine(y); 58 unsigned int *data = (unsigned int *) img.scanLine(y);
57 for(x=0; x < img.width(); ++x){ 59 for(x=0; x < img.width(); ++x){
58 r = qRed(data[x]); 60 r = qRed(data[x]);
59 g = qGreen(data[x]); 61 g = qGreen(data[x]);
60 b = qBlue(data[x]); 62 b = qBlue(data[x]);
61 if(r-10) 63 if(r-10)
62 r-=10; 64 r-=10;
63 if(g-10) 65 if(g-10)
64 g-=10; 66 g-=10;
65 if(b-10) 67 if(b-10)
66 b-=10; 68 b-=10;
67 data[x] = qRgb(r, g, b); 69 data[x] = qRgb(r, g, b);
68 } 70 }
69 } 71 }
70 pix.convertFromImage(img); 72 pix.convertFromImage(img);
71} 73}
72 74
73TransMenuHandler::TransMenuHandler(QObject *parent) 75TransMenuHandler::TransMenuHandler(QObject *parent)
74 : QObject(parent) 76 : QObject(parent)
75{ 77{
76 pixDict.setAutoDelete(true); 78 pixDict.setAutoDelete(true);
77 reloadSettings(); 79 reloadSettings();
78} 80}
79 81
80void TransMenuHandler::reloadSettings() 82void TransMenuHandler::reloadSettings()
81{ 83{
82 pixDict.clear(); 84 pixDict.clear();
83 85
84 Config config ( "qpe" ); 86 Config config ( "qpe" );
85 config. setGroup ( "Liquid-Style" ); 87 config. setGroup ( "Liquid-Style" );
86 88
87 type = config. readNumEntry("Type", TransStippleBg); 89 type = config. readNumEntry("Type", TransStippleBg);
88 color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name())); 90 color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name()));
89 fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name())); 91 fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name()));
90 opacity = config. readNumEntry("Opacity", 10); 92 opacity = config. readNumEntry("Opacity", 10);
91 if ( opacity < -20 ) 93 if ( opacity < -20 )
@@ -1363,97 +1365,98 @@ void LiquidStyle::drawButtonMask(QPainter *p, int x, int y, int w, int h)
1363 else{ 1365 else{
1364 int x2 = x+w-1; 1366 int x2 = x+w-1;
1365 int y2 = y+h-1; 1367 int y2 = y+h-1;
1366 int bx2 = htmlBtnMaskBmp.width()-1; 1368 int bx2 = htmlBtnMaskBmp.width()-1;
1367 int by2 = htmlBtnMaskBmp.height()-1; 1369 int by2 = htmlBtnMaskBmp.height()-1;
1368 p->drawPixmap(0, 0, htmlBtnMaskBmp, 0, 0, 10, 10); // tl 1370 p->drawPixmap(0, 0, htmlBtnMaskBmp, 0, 0, 10, 10); // tl
1369 p->drawPixmap(x2-9, 0, htmlBtnMaskBmp, bx2-9, 0, 10, 10); // tr 1371 p->drawPixmap(x2-9, 0, htmlBtnMaskBmp, bx2-9, 0, 10, 10); // tr
1370 p->drawPixmap(0, y2-9, htmlBtnMaskBmp, 0, by2-9, 10, 10); // bl 1372 p->drawPixmap(0, y2-9, htmlBtnMaskBmp, 0, by2-9, 10, 10); // bl
1371 p->drawPixmap(x2-9, y2-9, htmlBtnMaskBmp, bx2-9, by2-9, 10, 10); // br 1373 p->drawPixmap(x2-9, y2-9, htmlBtnMaskBmp, bx2-9, by2-9, 10, 10); // br
1372 // fills 1374 // fills
1373 p->fillRect(10, 0, w-20, 10, Qt::color1); // top 1375 p->fillRect(10, 0, w-20, 10, Qt::color1); // top
1374 p->fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom 1376 p->fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom
1375 p->fillRect(0, 10, w, h-20, Qt::color1); // middle 1377 p->fillRect(0, 10, w, h-20, Qt::color1); // middle
1376 } 1378 }
1377} 1379}
1378 1380
1379void LiquidStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h, 1381void LiquidStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h,
1380 const QColorGroup &g, bool sunken, 1382 const QColorGroup &g, bool sunken,
1381 const QBrush */*fill*/) 1383 const QBrush */*fill*/)
1382{ 1384{
1383 if(currentHeader && p->device() == currentHeader){ 1385 if(currentHeader && p->device() == currentHeader){
1384 int id = currentHeader->sectionAt(x); 1386 int id = currentHeader->sectionAt(x);
1385 bool isHeaderHover = id != -1 && id == headerHoverID; 1387 bool isHeaderHover = id != -1 && id == headerHoverID;
1386 drawClearBevel(p, x, y, w, h, sunken ? 1388 drawClearBevel(p, x, y, w, h, sunken ?
1387 g.button() : isHeaderHover ? g.button().light(110) : 1389 g.button() : isHeaderHover ? g.button().light(110) :
1388 g.background(), g.background()); 1390 g.background(), g.background());
1389 } 1391 }
1390 else 1392 else
1391 drawClearBevel(p, x, y, w, h, sunken ? g.button() : g.background(), 1393 drawClearBevel(p, x, y, w, h, sunken ? g.button() : g.background(),
1392 g.background()); 1394 g.background());
1393} 1395}
1394 1396
1395QRect LiquidStyle::buttonRect(int x, int y, int w, int h) 1397QRect LiquidStyle::buttonRect(int x, int y, int w, int h)
1396{ 1398{
1397 return(QRect(x+5, y+5, w-10, h-10)); 1399 return(QRect(x+5, y+5, w-10, h-10));
1398} 1400}
1399 1401
1400void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h, 1402void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h,
1401 const QColorGroup &g, bool sunken, 1403 const QColorGroup &g, bool sunken,
1402 bool edit, bool, const QBrush *) 1404 bool edit, bool, const QBrush *)
1403{ 1405{
1404 bool isActive = false; 1406 bool isActive = false;
1405 if (( painter->device()->devType() == QInternal::Widget ) && 1407 if (( painter->device()->devType() == QInternal::Widget ) &&
1406 ( 1408 (
1407 ( qApp-> focusWidget ( ) == painter-> device ( )) || 1409 ( qApp-> focusWidget ( ) == painter-> device ( )) ||
1408 ( 1410 (
1409 edit && 1411 edit &&
1410 ((QWidget *) painter-> device ( ))-> inherits ( "QComboBox" ) && 1412 ((QWidget *) painter-> device ( ))-> inherits ( "QComboBox" ) &&
1411 ( qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->lineEdit ( )) 1413 ( qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->lineEdit ( ) ||
1414 qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->listBox ( ))
1412 ) 1415 )
1413 ) 1416 )
1414 ) { 1417 ) {
1415 isActive = true; 1418 isActive = true;
1416 } 1419 }
1417 1420
1418 bool isMasked = false; 1421 bool isMasked = false;
1419 if(painter->device()->devType() == QInternal::Widget) 1422 if(painter->device()->devType() == QInternal::Widget)
1420 isMasked = ((QWidget*)painter->device())->autoMask(); 1423 isMasked = ((QWidget*)painter->device())->autoMask();
1421 // TODO: Do custom code, don't just call drawRoundButton into a pixmap 1424 // TODO: Do custom code, don't just call drawRoundButton into a pixmap
1422 QPixmap tmpPix(w, h); 1425 QPixmap tmpPix(w, h);
1423 QPainter p(&tmpPix); 1426 QPainter p(&tmpPix);
1424 1427
1425 drawRoundButton(&p, g.button(), g.background(), 0, 0, w, h, false, 1428 drawRoundButton(&p, g.button(), g.background(), 0, 0, w, h, false,
1426 sunken, false, isMasked); 1429 sunken, false, isMasked);
1427 if(!isActive){ 1430 if(!isActive){
1428 p.setClipRect(0, 0, w-17, h); 1431 p.setClipRect(0, 0, w-17, h);
1429 drawRoundButton(&p, g.background(), g.background(), 0, 0, w, h, false, 1432 drawRoundButton(&p, g.background(), g.background(), 0, 0, w, h, false,
1430 sunken, false, isMasked); 1433 sunken, false, isMasked);
1431 } 1434 }
1432 p.end(); 1435 p.end();
1433 int x2 = x+w-1; 1436 int x2 = x+w-1;
1434 int y2 = y+h-1; 1437 int y2 = y+h-1;
1435 int bx2 = btnMaskBmp.width()-1; 1438 int bx2 = btnMaskBmp.width()-1;
1436 int by2 = btnMaskBmp.height()-1; 1439 int by2 = btnMaskBmp.height()-1;
1437 QBitmap btnMask(w, h); 1440 QBitmap btnMask(w, h);
1438 QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp; 1441 QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp;
1439 p.begin(&btnMask); 1442 p.begin(&btnMask);
1440 p.fillRect(0, 0, w, h, Qt::color0); 1443 p.fillRect(0, 0, w, h, Qt::color0);
1441 p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl 1444 p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl
1442 p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr 1445 p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr
1443 p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl 1446 p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl
1444 p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br 1447 p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br
1445 // fills 1448 // fills
1446 p.fillRect(10, 0, w-20, 10, Qt::color1); // top 1449 p.fillRect(10, 0, w-20, 10, Qt::color1); // top
1447 p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom 1450 p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom
1448 p.fillRect(0, 10, w, h-20, Qt::color1); // middle 1451 p.fillRect(0, 10, w, h-20, Qt::color1); // middle
1449 p.end(); 1452 p.end();
1450 tmpPix.setMask(btnMask); 1453 tmpPix.setMask(btnMask);
1451 1454
1452 painter->drawPixmap(x, y, tmpPix); 1455 painter->drawPixmap(x, y, tmpPix);
1453 1456
1454 painter->setPen(g.button().dark(120)); 1457 painter->setPen(g.button().dark(120));
1455 painter->drawLine(x2-16, y+1, x2-16, y2-1); 1458 painter->drawLine(x2-16, y+1, x2-16, y2-1);
1456 1459
1457 if(edit){ 1460 if(edit){
1458 painter->setPen(g.mid()); 1461 painter->setPen(g.mid());
1459 painter->drawRect(x+8, y+2, w-25, h-4); 1462 painter->drawRect(x+8, y+2, w-25, h-4);