1
/****************************************************************************
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
5
** This file is part of the style module of the Qt Toolkit.
7
** This file may be distributed under the terms of the Q Public License
8
** as defined by Trolltech AS of Norway and appearing in the file
9
** LICENSE.QPL included in the packaging of this file.
11
** This file may be distributed and/or modified under the terms of the
12
** GNU General Public License version 2 as published by the Free Software
13
** Foundation and appearing in the file LICENSE.GPL included in the
14
** packaging of this file.
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
17
** information about Qt Commercial License Agreements.
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
21
** Contact info@trolltech.com if any conditions of this licensing are
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
27
****************************************************************************/
29
#include "qmotifstyle.h"
31
#if !defined(QT_NO_STYLE_MOTIF) || defined(QT_PLUGIN)
34
#include "qapplication.h"
36
#include "qdrawutil.h"
40
#include "qpushbutton.h"
41
#include "qscrollbar.h"
43
#include "qtabwidget.h"
44
#include "qlistview.h"
45
#include "qsplitter.h"
47
#include "qcombobox.h"
48
#include "qlineedit.h"
49
#include "qprogressbar.h"
51
#include "qfocusframe.h"
53
#include "qpainterpath.h"
57
#include "qx11info_x11.h"
60
// old constants that might still be useful...
61
static const int motifItemFrame = 2; // menu item frame width
62
static const int motifSepHeight = 2; // separator item height
63
static const int motifItemHMargin = 3; // menu item hor text margin
64
static const int motifItemVMargin = 2; // menu item ver text margin
65
static const int motifArrowHMargin = 6; // arrow horizontal margin
66
static const int motifTabSpacing = 12; // space between text and tab
67
static const int motifCheckMarkHMargin = 2; // horiz. margins of check mark
68
static const int motifCheckMarkSpace = 12;
72
\class QMotifStyle qmotifstyle.h
73
\brief The QMotifStyle class provides Motif look and feel.
77
This class implements the Motif look and feel. It closely
78
resembles the original Motif look as defined by the Open Group,
79
but with some minor improvements. The Motif style is Qt's default
80
GUI style on Unix platforms.
83
\sa QWindowsXPStyle, QMacStyle, QWindowsStyle, QPlastiqueStyle, QCDEStyle
87
\variable QMotifStyle::focus
92
Constructs a QMotifStyle.
94
If \a useHighlightCols is false (the default), the style will
95
polish the application's color palette to emulate the Motif way of
96
highlighting, which is a simple inversion between the base and the
99
QMotifStyle::QMotifStyle(bool useHighlightCols) : QCommonStyle()
102
highlightCols = useHighlightCols;
110
QMotifStyle::~QMotifStyle()
116
If \a arg is false, the style will polish the application's color
117
palette to emulate the Motif way of highlighting, which is a
118
simple inversion between the base and the text color.
120
The effect will show up the next time an application palette is
121
set via QApplication::setPalette(). The current color palette of
122
the application remains unchanged.
126
void QMotifStyle::setUseHighlightColors(bool arg)
132
Returns true if the style treats the highlight colors of the
133
palette in a Motif-like manner, which is a simple inversion
134
between the base and the text color; otherwise returns false. The
137
bool QMotifStyle::useHighlightColors() const
139
return highlightCols;
144
void QMotifStyle::polish(QPalette& pal)
146
if (pal.brush(QPalette::Active, QPalette::Light) == pal.brush(QPalette::Active, QPalette::Base)) {
147
QColor nlight = pal.color(QPalette::Active, QPalette::Light).dark(108);
148
pal.setColor(QPalette::Active, QPalette::Light, nlight) ;
149
pal.setColor(QPalette::Disabled, QPalette::Light, nlight) ;
150
pal.setColor(QPalette::Inactive, QPalette::Light, nlight) ;
156
// force the ugly motif way of highlighting *sigh*
157
pal.setColor(QPalette::Active, QPalette::Highlight,
158
pal.color(QPalette::Active, QPalette::Text));
159
pal.setColor(QPalette::Active, QPalette::HighlightedText,
160
pal.color(QPalette::Active, QPalette::Base));
161
pal.setColor(QPalette::Disabled, QPalette::Highlight,
162
pal.color(QPalette::Disabled, QPalette::Text));
163
pal.setColor(QPalette::Disabled, QPalette::HighlightedText,
164
pal.color(QPalette::Disabled, QPalette::Base));
165
pal.setColor(QPalette::Inactive, QPalette::Highlight,
166
pal.color(QPalette::Active, QPalette::Text));
167
pal.setColor(QPalette::Inactive, QPalette::HighlightedText,
168
pal.color(QPalette::Active, QPalette::Base));
174
Keep QStyle::polish() visible.
176
void QMotifStyle::polish(QWidget* w)
184
Keep QStyle::polish() visible.
186
void QMotifStyle::polish(QApplication* a)
191
static void rot(QPolygon& a, int n)
193
QPolygon r(a.size());
194
for (int i = 0; i < (int)a.size(); i++) {
196
case 1: r.setPoint(i,-a[i].y(),a[i].x()); break;
197
case 2: r.setPoint(i,-a[i].x(),-a[i].y()); break;
198
case 3: r.setPoint(i,a[i].y(),-a[i].x()); break;
208
void QMotifStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p,
209
const QWidget *w) const
212
case PE_Q3CheckListExclusiveIndicator:
213
if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) {
214
if (lv->items.isEmpty())
217
if (lv->state & State_Enabled)
218
p->setPen(QPen(opt->palette.text().color()));
220
p->setPen(QPen(lv->palette.color(QPalette::Disabled, QPalette::Text)));
223
int cx = opt->rect.width()/2 - 1;
224
int cy = opt->rect.height()/2;
225
int e = opt->rect.width()/2 - 1;
226
for (int i = 0; i < 3; i++) { //penWidth 2 doesn't quite work
227
a.setPoints(4, cx-e, cy, cx, cy-e, cx+e, cy, cx, cy+e);
231
if (opt->state & State_On) {
232
if (lv->state & State_Enabled)
233
p->setPen(QPen(opt->palette.text().color()));
235
p->setPen(QPen(lv->palette.color(QPalette::Disabled,
237
QBrush saveBrush = p->brush();
238
p->setBrush(opt->palette.text());
240
a.setPoints(4, cx-e, cy, cx, cy-e, cx+e, cy, cx, cy+e);
242
p->setBrush(saveBrush);
247
case PE_FrameTabWidget:
249
qDrawShadePanel(p, opt->rect, opt->palette, QStyle::State_None, pixelMetric(PM_DefaultFrameWidth));
251
case PE_FrameFocusRect:
252
if (const QStyleOptionFocusRect *fropt = qstyleoption_cast<const QStyleOptionFocusRect *>(opt)) {
253
if ((fropt->state & State_HasFocus) && focus && focus->isVisible())
255
QCommonStyle::drawPrimitive(pe, opt, p, w);
259
case PE_IndicatorToolBarHandle: {
261
p->translate(opt->rect.x(), opt->rect.y());
263
QColor dark(opt->palette.dark().color());
264
QColor light(opt->palette.light().color());
266
if (opt->state & State_Horizontal) {
267
int h = opt->rect.height();
269
if (opt->state & State_On)
270
p->fillRect(1, 1, 8, h - 2, opt->palette.highlight());
271
QPolygon a(2 * ((h-6)/3));
274
p->drawLine(8, 1, 8, h-2);
275
for(i=0; 2*i < a.size(); i ++) {
276
a.setPoint(2*i, 5, y+1+3*i);
277
a.setPoint(2*i+1, 2, y+2+3*i);
281
p->drawLine(9, 1, 9, h-2);
282
for(i=0; 2*i < a.size(); i++) {
283
a.setPoint(2*i, 4, y+3*i);
284
a.setPoint(2*i+1, 1, y+1+3*i);
288
// p->setPen(QPen(Qt::darkGray));
289
// p->drawLine(0, opt->rect.height() - 1,
290
// tbExtent, opt->rect.height() - 1);
294
int w = opt->rect.width();
296
if (opt->state & State_On)
297
p->fillRect(1, 1, w - 2, 9, opt->palette.highlight());
298
QPolygon a(2 * ((w-6)/3));
302
p->drawLine(1, 8, w-2, 8);
303
for(i=0; 2*i < a.size(); i ++) {
304
a.setPoint(2*i, x+1+3*i, 6);
305
a.setPoint(2*i+1, x+2+3*i, 3);
309
p->drawLine(1, 9, w-2, 9);
310
for(i=0; 2*i < a.size(); i++) {
311
a.setPoint(2*i, x+3*i, 5);
312
a.setPoint(2*i+1, x+1+3*i, 2);
316
// p->setPen(QPen(Qt::darkGray));
317
// p->drawLine(opt->rect.width() - 1, 0,
318
// opt->rect.width() - 1, tbExtent);
325
case PE_PanelButtonCommand:
326
case PE_PanelButtonBevel:
327
case PE_PanelButtonTool: {
329
if (opt->state & State_Sunken)
330
fill = opt->palette.brush(QPalette::Mid);
331
else if ((opt->state & State_On) && (opt->state & State_Enabled))
332
fill = QBrush(opt->palette.mid().color(), Qt::Dense4Pattern);
334
fill = opt->palette.brush(QPalette::Button);
335
qDrawShadePanel(p, opt->rect, opt->palette, bool(opt->state & (State_Sunken | State_On)),
336
pixelMetric(PM_DefaultFrameWidth), &fill);
339
case PE_IndicatorCheckBox: {
340
bool on = opt->state & State_On;
341
bool down = opt->state & State_Sunken;
342
bool showUp = !(down ^ on);
343
QBrush fill = opt->palette.brush((showUp || opt->state & State_NoChange) ?QPalette::Button : QPalette::Mid);
344
if (opt->state & State_NoChange) {
345
qDrawPlainRect(p, opt->rect, opt->palette.text().color(),
347
p->drawLine(opt->rect.x() + opt->rect.width() - 1, opt->rect.y(),
348
opt->rect.x(), opt->rect.y() + opt->rect.height() - 1);
350
qDrawShadePanel(p, opt->rect, opt->palette, !showUp,
351
pixelMetric(PM_DefaultFrameWidth), &fill);
353
if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText))
354
p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern));
357
case PE_IndicatorRadioButton: {
358
#define INTARRLEN(x) sizeof(x)/(sizeof(int)*2)
359
int inner_pts[] = { // used for filling diamond
360
2,opt->rect.height()/2,
361
opt->rect.width()/2,2,
362
opt->rect.width()-3,opt->rect.height()/2,
363
opt->rect.width()/2,opt->rect.height()-3
365
int top_pts[] = { // top (^) of diamond
366
0,opt->rect.height()/2,
367
opt->rect.width()/2,0,
368
opt->rect.width()-2,opt->rect.height()/2-1,
369
opt->rect.width()-3,opt->rect.height()/2-1,
370
opt->rect.width()/2,1,
371
1,opt->rect.height()/2,
372
2,opt->rect.height()/2,
373
opt->rect.width()/2,2,
374
opt->rect.width()-4,opt->rect.height()/2-1
376
int bottom_pts[] = { // bottom (v) of diamond
377
1,opt->rect.height()/2+1,
378
opt->rect.width()/2,opt->rect.height()-1,
379
opt->rect.width()-1,opt->rect.height()/2,
380
opt->rect.width()-2,opt->rect.height()/2,
381
opt->rect.width()/2,opt->rect.height()-2,
382
2,opt->rect.height()/2+1,
383
3,opt->rect.height()/2+1,
384
opt->rect.width()/2,opt->rect.height()-3,
385
opt->rect.width()-3,opt->rect.height()/2
387
bool on = opt->state & State_On;
388
bool down = opt->state & State_Sunken;
389
bool showUp = !(down ^ on);
390
QPen oldPen = p->pen();
391
QBrush oldBrush = p->brush();
392
QPolygon a(INTARRLEN(inner_pts), inner_pts);
393
p->setPen(Qt::NoPen);
394
p->setBrush(opt->palette.brush(showUp ? QPalette::Button : QPalette::Mid));
395
a.translate(opt->rect.x(), opt->rect.y());
397
p->setPen(showUp ? opt->palette.light().color() : opt->palette.dark().color());
398
p->setBrush(Qt::NoBrush);
399
a.setPoints(INTARRLEN(top_pts), top_pts);
400
a.translate(opt->rect.x(), opt->rect.y());
402
p->setPen(showUp ? opt->palette.dark().color() : opt->palette.light().color());
403
a.setPoints(INTARRLEN(bottom_pts), bottom_pts);
404
a.translate(opt->rect.x(), opt->rect.y());
406
if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText))
407
p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern));
409
p->setBrush(oldBrush);
412
case PE_IndicatorSpinUp:
413
case PE_IndicatorSpinPlus:
414
case PE_IndicatorSpinDown:
415
case PE_IndicatorSpinMinus:
416
case PE_IndicatorArrowUp:
417
case PE_IndicatorArrowDown:
418
case PE_IndicatorArrowRight:
419
case PE_IndicatorArrowLeft: {
420
QRect rect = opt->rect;
425
if (pe == PE_IndicatorSpinPlus || pe == PE_IndicatorSpinUp)
426
pe = PE_IndicatorArrowUp;
427
else if (pe == PE_IndicatorSpinMinus || pe == PE_IndicatorSpinDown)
428
pe = PE_IndicatorArrowDown;
429
bool vertical = pe == PE_IndicatorArrowUp || pe == PE_IndicatorArrowDown;
430
bool horizontal = !vertical;
431
int dim = rect.width() < rect.height() ? rect.width() : rect.height();
432
int colspec = 0x0000;
434
if (!(opt->state & State_Enabled))
439
// adjust size and center (to fix rotation below)
440
if (rect.width() > dim) {
441
rect.setX(rect.x() + ((rect.width() - dim) / 2));
444
if (rect.height() > dim) {
445
rect.setY(rect.y() + ((rect.height() - dim) / 2));
450
if (pixelMetric(PM_DefaultFrameWidth) < 2) { // thin style
451
bFill.resize( dim & 1 ? 3 : 4 );
455
bLeft.putPoints( 0, 2, 0, 0, 0, dim-1 );
456
bTop.putPoints( 0, 2, 1, 0, dim-1, dim/2 );
457
bBot.putPoints( 0, 2, 1, dim-1, dim-1, dim/2 );
459
if ( dim > 6 ) { // dim>6: must fill interior
460
bFill.putPoints( 0, 2, 0, dim-1, 0, 0 );
461
if ( dim & 1 ) // if size is an odd number
462
bFill.setPoint( 2, dim - 1, dim / 2 );
464
bFill.putPoints( 2, 2, dim-1, dim/2-1, dim-1, dim/2 );
468
bFill.resize(dim & 1 ? 3 : 4);
469
bTop.resize((dim/2)*2);
470
bBot.resize(dim & 1 ? dim + 1 : dim);
471
bLeft.resize(dim > 4 ? 4 : 2);
472
bLeft.putPoints(0, 2, 0,0, 0,dim-1);
474
bLeft.putPoints(2, 2, 1,2, 1,dim-3);
475
bTop.putPoints(0, 4, 1,0, 1,1, 2,1, 3,1);
476
bBot.putPoints(0, 4, 1,dim-1, 1,dim-2, 2,dim-2, 3,dim-2);
478
for(int i=0; i<dim/2-2 ; i++) {
479
bTop.putPoints(i*2+4, 2, 2+i*2,2+i, 5+i*2, 2+i);
480
bBot.putPoints(i*2+4, 2, 2+i*2,dim-3-i, 5+i*2,dim-3-i);
482
if (dim & 1) // odd number size: extra line
483
bBot.putPoints(dim-1, 2, dim-3,dim/2, dim-1,dim/2);
484
if (dim > 6) { // dim>6: must fill interior
485
bFill.putPoints(0, 2, 1,dim-3, 1,2);
486
if (dim & 1) // if size is an odd number
487
bFill.setPoint(2, dim - 3, dim / 2);
489
bFill.putPoints(2, 2, dim-4,dim/2-1, dim-4,dim/2);
493
if (dim == 3) { // 3x3 arrow pattern
494
bLeft.setPoints(4, 0,0, 0,2, 1,1, 1,1);
495
bTop .setPoints(2, 1,0, 1,0);
496
bBot .setPoints(2, 1,2, 2,1);
498
else { // 2x2 arrow pattern
499
bLeft.setPoints(2, 0,0, 0,1);
500
bTop .setPoints(2, 1,0, 1,0);
501
bBot .setPoints(2, 1,1, 1,1);
505
// We use rot() and translate() as it is more efficient that
506
// matrix transformations on the painter, and because it still
507
// works with QT_NO_TRANSFORMATIONS defined.
509
if (pe == PE_IndicatorArrowUp || pe == PE_IndicatorArrowLeft) {
515
bFill.translate(0, rect.height() - 1);
516
bLeft.translate(0, rect.height() - 1);
517
bTop.translate(0, rect.height() - 1);
518
bBot.translate(0, rect.height() - 1);
524
bFill.translate(rect.width() - 1, rect.height() - 1);
525
bLeft.translate(rect.width() - 1, rect.height() - 1);
526
bTop.translate(rect.width() - 1, rect.height() - 1);
527
bBot.translate(rect.width() - 1, rect.height() - 1);
529
if (opt->state & State_Sunken)
530
colspec = horizontal ? 0x2334 : 0x2343;
532
colspec = horizontal ? 0x1443 : 0x1434;
539
bFill.translate(rect.width() - 1, 0);
540
bLeft.translate(rect.width() - 1, 0);
541
bTop.translate(rect.width() - 1, 0);
542
bBot.translate(rect.width() - 1, 0);
544
if (opt->state & State_Sunken)
545
colspec = horizontal ? 0x2443 : 0x2434;
547
colspec = horizontal ? 0x1334 : 0x1343;
549
bFill.translate(rect.x(), rect.y());
550
bLeft.translate(rect.x(), rect.y());
551
bTop.translate(rect.x(), rect.y());
552
bBot.translate(rect.x(), rect.y());
554
const QColor *cols[5];
555
if (opt->state & State_Enabled) {
557
cols[1] = &opt->palette.button().color();
558
cols[2] = &opt->palette.mid().color();
559
cols[3] = &opt->palette.light().color();
560
cols[4] = &opt->palette.dark().color();
563
cols[1] = &opt->palette.mid().color();
564
cols[2] = &opt->palette.mid().color();
565
cols[3] = &opt->palette.mid().color();
566
cols[4] = &opt->palette.mid().color();
569
#define CMID *cols[(colspec>>12) & 0xf]
570
#define CLEFT *cols[(colspec>>8) & 0xf]
571
#define CTOP *cols[(colspec>>4) & 0xf]
572
#define CBOT *cols[colspec & 0xf]
574
QPen savePen = p->pen();
575
QBrush saveBrush = p->brush();
577
QBrush brush = opt->palette.brush((opt->state & State_Enabled) ?
578
QPalette::Button : QPalette::Mid);
581
p->drawPolygon(bFill);
582
p->setBrush(Qt::NoBrush);
585
p->drawPolyline(bLeft);
587
p->drawPolyline(bTop);
589
p->drawPolyline(bBot);
591
p->setBrush(saveBrush);
597
if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText))
598
p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern));
601
case PE_IndicatorDockWidgetResizeHandle: {
602
const int motifOffset = 10;
603
int sw = pixelMetric(PM_SplitterWidth);
604
if (opt->state & State_Horizontal) {
605
int yPos = opt->rect.y() + opt->rect.height() / 2;
606
int kPos = opt->rect.width() - motifOffset - sw;
609
qDrawShadeLine(p, 0, yPos, kPos, yPos, opt->palette);
610
qDrawShadePanel(p, kPos, yPos - sw / 2 + 1, kSize, kSize,
611
opt->palette, false, 1, &opt->palette.brush(QPalette::Button));
612
qDrawShadeLine(p, kPos + kSize - 1, yPos, opt->rect.width(), yPos, opt->palette);
614
int xPos = opt->rect.x() + opt->rect.width() / 2;
615
int kPos = motifOffset;
618
qDrawShadeLine(p, xPos, kPos + kSize - 1, xPos, opt->rect.height(), opt->palette);
619
qDrawShadePanel(p, xPos - sw / 2 + 1, kPos, kSize, kSize, opt->palette,
620
false, 1, &opt->palette.brush(QPalette::Button));
621
qDrawShadeLine(p, xPos, 0, xPos, kPos, opt->palette);
625
case PE_IndicatorMenuCheckMark: {
628
int posX = opt->rect.x() + (opt->rect.width() - markW) / 2 - 1;
629
int posY = opt->rect.y() + (opt->rect.height() - markH) / 2;
630
int dfw = pixelMetric(PM_DefaultFrameWidth);
633
// Could do with some optimizing/caching...
638
for (i=0; i<3; i++) {
639
a.setPoint(2*i, xx, yy);
640
a.setPoint(2*i+1, xx, yy+2);
644
for (i=3; i<7; i++) {
645
a.setPoint(2*i, xx, yy);
646
a.setPoint(2*i+1, xx, yy+2);
649
if (! (opt->state & State_Enabled) && ! (opt->state & State_On)) {
651
p->setPen(opt->palette.highlightedText().color());
653
for (pnt = 0; pnt < (int)a.size(); pnt++)
656
for (pnt = 0; pnt < (int)a.size(); pnt++)
659
p->setPen(opt->palette.text().color());
662
qDrawShadePanel(p, posX-2, posY-2, markW+4, markH+6, opt->palette, true, dfw);
664
qDrawShadePanel(p, posX, posY, markW, markH, opt->palette, true, dfw,
665
&opt->palette.brush(QPalette::Mid));
669
case PE_IndicatorProgressChunk:
670
p->fillRect(opt->rect.x(), opt->rect.y() + 2, opt->rect.width(),
671
opt->rect.height() - 4, opt->palette.brush(QPalette::Highlight));
675
QCommonStyle::drawPrimitive(pe, opt, p, w);
684
void QMotifStyle::drawControl(ControlElement element, const QStyleOption *opt, QPainter *p,
685
const QWidget *widget) const
689
QStyleOption handleOpt = *opt;
690
if (handleOpt.state & State_Horizontal)
691
handleOpt.state &= ~State_Horizontal;
693
handleOpt.state |= State_Horizontal;
694
drawPrimitive(PE_IndicatorDockWidgetResizeHandle, &handleOpt, p, widget);
697
case CE_ScrollBarSubLine:
698
case CE_ScrollBarAddLine:{
700
if (element == CE_ScrollBarAddLine)
701
pe = (opt->state & State_Horizontal) ? (opt->direction == Qt::LeftToRight ? PE_IndicatorArrowRight : PE_IndicatorArrowLeft) : PE_IndicatorArrowDown;
703
pe = (opt->state & State_Horizontal) ? (opt->direction == Qt::LeftToRight ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight) : PE_IndicatorArrowUp;
704
QStyleOption arrowOpt = *opt;
705
arrowOpt.state |= State_Enabled;
706
drawPrimitive(pe, &arrowOpt, p, widget);
707
if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText)) {
708
int fw = pixelMetric(PM_DefaultFrameWidth);
709
p->fillRect(opt->rect.adjusted(fw, fw, -fw, -fw), QBrush(p->background().color(), Qt::Dense5Pattern));
713
case CE_ScrollBarSubPage:
714
case CE_ScrollBarAddPage:
715
p->fillRect(opt->rect, opt->palette.brush((opt->state & State_Enabled) ? QPalette::Mid : QPalette::Background));
718
case CE_ScrollBarSlider: {
719
QStyleOption bevelOpt = *opt;
720
bevelOpt.state |= State_Raised;
721
bevelOpt.state &= ~(State_Sunken | State_On);
723
p->setBrushOrigin(bevelOpt.rect.topLeft());
724
drawPrimitive(PE_PanelButtonBevel, &bevelOpt, p, widget);
726
if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText))
727
p->fillRect(opt->rect, QBrush(p->background().color(), Qt::Dense5Pattern));
732
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
733
bool isRadio = (element == CE_RadioButton);
734
QStyleOptionButton subopt = *btn;
735
subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator
736
: SE_CheckBoxIndicator, btn, widget);
737
drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox,
739
subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents
740
: SE_CheckBoxContents, btn, widget);
741
drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, p, widget);
742
if ((btn->state & State_HasFocus) && (!focus || !focus->isVisible())) {
743
QStyleOptionFocusRect fropt;
744
fropt.QStyleOption::operator=(*btn);
745
fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect
746
: SE_CheckBoxFocusRect, btn, widget);
747
drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
752
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
753
drawControl(CE_PushButtonBevel, btn, p, widget);
754
QStyleOptionButton subopt = *btn;
755
subopt.rect = subElementRect(SE_PushButtonContents, btn, widget);
756
drawControl(CE_PushButtonLabel, &subopt, p, widget);
757
if ((btn->state & State_HasFocus) && (!focus || !focus->isVisible())) {
758
QStyleOptionFocusRect fropt;
759
fropt.QStyleOption::operator=(*btn);
760
fropt.rect = subElementRect(SE_PushButtonFocusRect, btn, widget);
761
drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);
765
case CE_PushButtonBevel:
766
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
767
int diw, x1, y1, x2, y2;
768
p->setPen(opt->palette.foreground().color());
769
p->setBrush(QBrush(opt->palette.button().color(), Qt::NoBrush));
770
diw = pixelMetric(PM_ButtonDefaultIndicator);
771
opt->rect.getCoords(&x1, &y1, &x2, &y2);
772
if (btn->features & (QStyleOptionButton::AutoDefaultButton|QStyleOptionButton::DefaultButton)) {
778
if (btn->features & QStyleOptionButton::DefaultButton) {
782
x1, y1, x2, y1, x2, y2, x1, y2, x1, y1+1,
783
x2-1, y1+1, x2-1, y2-1, x1+1, y2-1, x1+1, y1+1);
784
p->setPen(opt->palette.shadow().color());
791
qDrawShadePanel(p, opt->rect.adjusted(1, 1, -1, -1), opt->palette, true);
794
if (!(btn->features & QStyleOptionButton::Flat) ||
795
(btn->state & (State_Sunken | State_On))) {
796
QStyleOptionButton newOpt = *btn;
797
newOpt.rect = QRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
798
p->setBrushOrigin(p->brushOrigin());
799
drawPrimitive(PE_PanelButtonCommand, &newOpt, p, widget);
804
case CE_TabBarTabShape:
805
if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) {
806
const int default_frame = pixelMetric(PM_DefaultFrameWidth, tab, widget);
807
const int frame_offset = (default_frame > 1) ? 1 : 0;
809
if (tab->shape == QTabBar::RoundedNorth || tab->shape == QTabBar::RoundedEast ||
810
tab->shape == QTabBar::RoundedSouth || tab->shape == QTabBar::RoundedWest) {
812
QRect tabRect = opt->rect;
813
QColor tabLight = opt->palette.light().color();
814
QColor tabDark = opt->palette.dark().color();
815
if(tab->shape == QTabBar::RoundedWest) {
816
tabDark = opt->palette.light().color();
817
tabLight = opt->palette.dark().color();
818
tabRect = QRect(0, 0, tabRect.height(), tabRect.width());
819
p->translate(opt->rect.left(), opt->rect.bottom());
821
} else if(tab->shape == QTabBar::RoundedSouth) {
822
tabDark = opt->palette.light().color();
823
tabLight = opt->palette.dark().color();
824
tabRect = QRect(0, 0, tabRect.width(), tabRect.height());
825
p->translate(opt->rect.right(), opt->rect.bottom());
827
} else if(tab->shape == QTabBar::RoundedEast) {
828
tabRect = QRect(0, 0, tabRect.height(), tabRect.width());
829
p->translate(opt->rect.right(), opt->rect.top());
833
if (default_frame > 1) {
835
p->drawLine(tabRect.left(), tabRect.bottom(),
836
tabRect.right(), tabRect.bottom());
838
p->drawLine(tabRect.left(), tabRect.bottom()-1,
839
tabRect.right(), tabRect.bottom()-1);
840
if (tabRect.left() == 0)
841
p->drawPoint(tabRect.bottomLeft());
844
p->drawLine(tabRect.left(), tabRect.bottom(),
845
tabRect.right(), tabRect.bottom());
848
if (opt->state & State_Selected) {
849
p->fillRect(QRect(tabRect.left()+1, tabRect.bottom()-frame_offset,
850
tabRect.width()-3, 2),
851
tab->palette.brush(QPalette::Active, QPalette::Background));
852
p->setPen(tab->palette.background().color());
853
p->drawLine(tabRect.left()+1, tabRect.bottom(),
854
tabRect.left()+1, tabRect.top()+2);
859
p->drawLine(tabRect.left(), tabRect.bottom()-1,
860
tabRect.left(), tabRect.top() + 2);
861
p->drawPoint(tabRect.left()+1, tabRect.top() + 1);
862
p->drawLine(tabRect.left()+2, tabRect.top(),
863
tabRect.right() - 2, tabRect.top());
864
p->drawPoint(tabRect.left(), tabRect.bottom());
866
if (default_frame > 1) {
867
p->drawLine(tabRect.left()+1, tabRect.bottom(),
868
tabRect.left()+1, tabRect.top() + 2);
869
p->drawLine(tabRect.left()+2, tabRect.top()+1,
870
tabRect.right() - 2, tabRect.top()+1);
874
p->drawLine(tabRect.right() - 1, tabRect.top() + 2,
875
tabRect.right() - 1, tabRect.bottom() - 1 +
876
((opt->state & State_Selected) ? frame_offset : -frame_offset));
877
if (default_frame > 1) {
878
p->drawPoint(tabRect.right() - 1, tabRect.top() + 1);
879
p->drawLine(tabRect.right(), tabRect.top() + 2, tabRect.right(),
881
((opt->state & State_Selected) ?
882
((tab->position == QStyleOptionTab::End) ? 0:1):1+frame_offset));
883
p->drawPoint(tabRect.right() - 1, tabRect.top() + 1);
887
QCommonStyle::drawControl(element, opt, p, widget);
890
case CE_ProgressBarGroove:
891
qDrawShadePanel(p, opt->rect, opt->palette, true, 2);
894
case CE_ProgressBarLabel:
895
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
896
const int unit_width = pixelMetric(PM_ProgressBarChunkWidth, opt, widget);
897
int u = opt->rect.width() / unit_width;
898
int p_v = pb->progress;
899
int t_s = qMax(0, pb->maximum - pb->minimum);
900
if (u > 0 && pb->progress >= INT_MAX / u && t_s >= u) {
901
// scale down to something usable.
905
if (pb->textVisible && t_s) {
906
int nu = (u * p_v + t_s/2) / t_s;
907
int x = unit_width * nu;
908
QRect left(opt->rect.x(), opt->rect.y(), x, opt->rect.height());
909
QRect right(opt->rect.x() + x, opt->rect.y(), opt->rect.width() - x, opt->rect.height());
910
const QRect &highlighted = visualRect(pb->direction, pb->rect, left);
911
const QRect &background = visualRect(pb->direction, pb->rect, right);
912
p->setPen(opt->palette.highlightedText().color());
913
p->setClipRect(highlighted);
914
p->drawText(opt->rect, Qt::AlignCenter | Qt::TextSingleLine, pb->text);
916
if (pb->progress != pb->maximum) {
917
p->setClipRect(background);
918
p->setPen(opt->palette.highlight().color());
919
p->drawText(opt->rect, Qt::AlignCenter | Qt::TextSingleLine, pb->text);
925
case CE_MenuTearoff: {
926
if(opt->state & State_Selected) {
927
if(pixelMetric(PM_MenuPanelWidth, opt, widget) > 1)
928
qDrawShadePanel(p, opt->rect.x(), opt->rect.y(), opt->rect.width(),
929
opt->rect.height(), opt->palette, false, motifItemFrame,
930
&opt->palette.brush(QPalette::Button));
932
qDrawShadePanel(p, opt->rect.x()+1, opt->rect.y()+1, opt->rect.width()-2,
933
opt->rect.height()-2, opt->palette, true, 1, &opt->palette.brush(QPalette::Button));
935
p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
937
p->setPen(QPen(opt->palette.dark().color(), 1, Qt::DashLine));
938
p->drawLine(opt->rect.x()+2, opt->rect.y()+opt->rect.height()/2-1, opt->rect.x()+opt->rect.width()-4,
939
opt->rect.y()+opt->rect.height()/2-1);
940
p->setPen(QPen(opt->palette.light().color(), 1, Qt::DashLine));
941
p->drawLine(opt->rect.x()+2, opt->rect.y()+opt->rect.height()/2, opt->rect.x()+opt->rect.width()-4,
942
opt->rect.y()+opt->rect.height()/2);
946
if (const QStyleOptionMenuItem *menuitem = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
947
int maxpmw = menuitem->maxIconWidth;
948
if(menuitem->menuHasCheckableItems)
949
maxpmw = qMax(maxpmw, motifCheckMarkSpace);
952
opt->rect.getRect(&x, &y, &w, &h);
954
if(menuitem->menuItemType == QStyleOptionMenuItem::Separator) { // draw separator
955
p->setPen(opt->palette.dark().color());
956
p->drawLine(x, y, x+w, y);
957
p->setPen(opt->palette.light().color());
958
p->drawLine(x, y+1, x+w, y+1);
962
int pw = motifItemFrame;
963
if((opt->state & State_Selected) && (opt->state & State_Enabled)) { // active item frame
964
if(pixelMetric(PM_MenuPanelWidth, opt) > 1)
965
qDrawShadePanel(p, x, y, w, h, opt->palette, false, pw,
966
&opt->palette.brush(QPalette::Button));
968
qDrawShadePanel(p, x+1, y+1, w-2, h-2, opt->palette, true, 1,
969
&opt->palette.brush(QPalette::Button));
970
} else { // incognito frame
971
p->fillRect(x, y, w, h, opt->palette.brush(QPalette::Button));
974
QRect vrect = visualRect(opt->direction, opt->rect,
975
QRect(x+motifItemFrame, y+motifItemFrame, maxpmw,
976
h-2*motifItemFrame));
977
int xvis = vrect.x();
978
if (menuitem->checked) {
979
if(!menuitem->icon.isNull())
980
qDrawShadePanel(p, xvis, y+motifItemFrame, maxpmw, h-2*motifItemFrame,
981
opt->palette, true, 1, &opt->palette.brush(QPalette::Midlight));
982
} else if (!(opt->state & State_Selected)) {
983
p->fillRect(xvis, y+motifItemFrame, maxpmw, h-2*motifItemFrame,
984
opt->palette.brush(QPalette::Button));
987
if(!menuitem->icon.isNull()) { // draw icon
988
QIcon::Mode mode = QIcon::Normal; // no disabled icons in Motif
989
if ((opt->state & State_Selected) && !!(opt->state & State_Enabled))
990
mode = QIcon::Active;
992
if (menuitem->checkType != QStyleOptionMenuItem::NotCheckable && menuitem->checked)
993
pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize), mode, QIcon::On);
995
pixmap = menuitem->icon.pixmap(pixelMetric(PM_SmallIconSize), mode);
997
int pixw = pixmap.width();
998
int pixh = pixmap.height();
999
QRect pmr(0, 0, pixw, pixh);
1000
pmr.moveCenter(vrect.center());
1001
p->setPen(opt->palette.text().color());
1002
p->drawPixmap(pmr.topLeft(), pixmap);
1004
} else if (menuitem->checkType != QStyleOptionMenuItem::NotCheckable) { // just "checking"...
1006
int mh = h - 2*motifItemFrame;
1007
if (menuitem->checked) {
1008
QStyleOptionMenuItem newMenuItem = *menuitem;
1009
newMenuItem.state = State_None;
1010
if ((opt->state & State_Enabled))
1011
newMenuItem.state |= State_Enabled;
1012
if ((opt->state & State_Selected))
1013
newMenuItem.state |= State_On;
1014
newMenuItem.rect = QRect(xvis, y+motifItemFrame, mw, mh);
1015
drawPrimitive(PE_IndicatorMenuCheckMark, &newMenuItem, p, widget);
1019
p->setPen(opt->palette.buttonText().color());
1022
if (!(opt->state & State_Enabled)) {
1023
discol = opt->palette.text().color();
1027
int xm = motifItemFrame + maxpmw + motifItemHMargin;
1029
vrect = visualRect(opt->direction, opt->rect,
1030
QRect(x+xm, y+motifItemVMargin, w-xm-menuitem->tabWidth,
1031
h-2*motifItemVMargin));
1034
QString s = menuitem->text;
1035
if (!s.isNull()) { // draw text
1036
int t = s.indexOf('\t');
1037
int m = motifItemVMargin;
1038
int text_flags = Qt::AlignVCenter|Qt::TextShowMnemonic | Qt::TextDontClip | Qt::TextSingleLine;
1039
text_flags |= Qt::AlignLeft;
1040
if (t >= 0) { // draw tab text
1041
QRect vr = visualRect(opt->direction, opt->rect,
1042
QRect(x+w-menuitem->tabWidth-motifItemHMargin-motifItemFrame,
1043
y+motifItemVMargin, menuitem->tabWidth,
1044
h-2*motifItemVMargin));
1046
QRect tr(xv, y+m, menuitem->tabWidth, h-2*m);
1047
p->drawText(tr, text_flags, s.mid(t+1));
1048
if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText))
1049
p->fillRect(tr, QBrush(p->background().color(), Qt::Dense5Pattern));
1052
QRect tr(xvis, y+m, w - xm - menuitem->tabWidth + 1, h-2*m);
1053
p->drawText(tr, text_flags, s.left(t));
1054
if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText))
1055
p->fillRect(tr, QBrush(p->background().color(), Qt::Dense5Pattern));
1057
if (menuitem->menuItemType == QStyleOptionMenuItem::SubMenu) { // draw sub menu arrow
1058
int dim = (h-2*motifItemFrame) / 2;
1059
QStyle::PrimitiveElement arrow = (QApplication::isRightToLeft() ? PE_IndicatorArrowLeft : PE_IndicatorArrowRight);
1060
QStyleOption arrowOpt = *opt;
1061
arrowOpt.rect = visualRect(opt->direction, opt->rect,
1062
QRect(x+w - motifArrowHMargin - motifItemFrame - dim,
1063
y+h/2-dim/2, dim, dim));
1064
if ((opt->state & State_Selected))
1065
arrowOpt.state = (State_Sunken | ((opt->state & State_Enabled) ? State_Enabled : State_None));
1067
arrowOpt.state = ((opt->state & State_Enabled) ? State_Enabled : State_None);
1068
drawPrimitive(arrow, &arrowOpt, p, widget);
1072
case CE_MenuBarItem:
1073
if (opt->state & State_Selected) // active item
1074
qDrawShadePanel(p, opt->rect, opt->palette, false, motifItemFrame,
1075
&opt->palette.brush(QPalette::Button));
1077
p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
1078
QCommonStyle::drawControl(element, opt, p, widget);
1081
case CE_HeaderSection:
1083
p->setBrushOrigin(opt->rect.topLeft());
1084
qDrawShadePanel(p, opt->rect, opt->palette, bool(opt->state & (State_Sunken|State_On)),
1085
pixelMetric(PM_DefaultFrameWidth),
1086
&opt->palette.brush((opt->state & State_Sunken) ? QPalette::Mid : QPalette::Button));
1089
case CE_RubberBand: {
1091
p->setClipping(false);
1093
path.addRect(opt->rect);
1094
path.addRect(opt->rect.adjusted(4, 4, -4, -4));
1096
p->fillPath(path, opt->palette.base());
1097
p->fillPath(path, QBrush(opt->palette.foreground().color(), Qt::Dense4Pattern));
1102
QCommonStyle::drawControl(element, opt, p, widget);
1106
static int get_combo_extra_width(int h, int w, int *return_awh=0)
1112
} else if (h < 14) {
1117
tmp = (awh * 3) / 2;
1129
static void get_combo_parameters(const QRect &r,
1130
int &ew, int &awh, int &ax,
1131
int &ay, int &sh, int &dh,
1134
ew = get_combo_extra_width(r.height(), r.width(), &awh);
1141
ay = r.y() + (r.height()-awh-sh-dh)/2;
1149
ax = r.x() + r.width() - ew;
1156
void QMotifStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p,
1157
const QWidget *widget) const
1161
if (const QStyleOptionToolButton *toolbutton
1162
= qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
1163
QRect button, menuarea;
1164
button = subControlRect(cc, toolbutton, SC_ToolButton, widget);
1165
menuarea = subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget);
1167
State bflags = toolbutton->state;
1169
if (bflags & State_AutoRaise) {
1170
if (!(bflags & State_MouseOver)) {
1171
bflags &= ~State_Raised;
1174
State mflags = bflags;
1176
if (toolbutton->activeSubControls & SC_ToolButton)
1177
bflags |= State_Sunken;
1178
if (toolbutton->activeSubControls & SC_ToolButtonMenu)
1179
mflags |= State_Sunken;
1181
QStyleOption tool(0);
1182
tool.palette = toolbutton->palette;
1183
if (toolbutton->subControls & SC_ToolButton) {
1184
if (bflags & (State_Sunken | State_On | State_Raised)) {
1186
tool.state = bflags;
1187
drawPrimitive(PE_PanelButtonTool, &tool, p, widget);
1191
if (toolbutton->subControls & SC_ToolButtonMenu) {
1192
tool.rect = menuarea;
1193
tool.state = mflags;
1194
if (mflags & (State_Sunken | State_On | State_Raised))
1195
drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget);
1196
drawPrimitive(PE_IndicatorArrowDown, &tool, p, widget);
1199
if ((toolbutton->state & State_HasFocus) && (!focus || !focus->isVisible())) {
1200
QStyleOptionFocusRect fr;
1201
fr.QStyleOption::operator=(*toolbutton);
1202
fr.rect = toolbutton->rect.adjusted(3, 3, -3, -3);
1203
drawPrimitive(PE_FrameFocusRect, &fr, p, widget);
1205
QStyleOptionToolButton label = *toolbutton;
1206
int fw = pixelMetric(PM_DefaultFrameWidth, opt, widget);
1207
label.rect = button.adjusted(fw, fw, -fw, -fw);
1208
drawControl(CE_ToolButtonLabel, &label, p, widget);
1212
if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
1213
QStyleOptionSpinBox copy = *spinbox;
1214
PrimitiveElement pe;
1216
if (spinbox->frame && (spinbox->subControls & SC_SpinBoxFrame)) {
1217
QRect r = subControlRect(CC_SpinBox, spinbox, SC_SpinBoxFrame, widget);
1218
qDrawShadePanel(p, r, opt->palette, false, pixelMetric(PM_SpinBoxFrameWidth));
1220
int fw = pixelMetric(QStyle::PM_DefaultFrameWidth);
1221
r = subControlRect(CC_SpinBox, spinbox, SC_SpinBoxEditField, widget).adjusted(-fw,-fw,fw,fw);
1222
QStyleOptionFrame lineOpt;
1223
lineOpt.QStyleOption::operator=(*opt);
1225
lineOpt.lineWidth = fw;
1226
lineOpt.midLineWidth = 0;
1227
lineOpt.state |= QStyle::State_Sunken;
1228
drawPrimitive(QStyle::PE_FrameLineEdit, &lineOpt, p, widget);
1231
if (spinbox->subControls & SC_SpinBoxUp) {
1232
copy.subControls = SC_SpinBoxUp;
1233
QPalette pal2 = spinbox->palette;
1234
if (!(spinbox->stepEnabled & QAbstractSpinBox::StepUpEnabled)) {
1235
pal2.setCurrentColorGroup(QPalette::Disabled);
1236
copy.state &= ~State_Enabled;
1239
copy.palette = pal2;
1241
if (spinbox->activeSubControls == SC_SpinBoxUp && (spinbox->state & State_Sunken)) {
1242
copy.state |= State_On;
1243
copy.state |= State_Sunken;
1245
copy.state |= State_Raised;
1246
copy.state &= ~State_Sunken;
1248
pe = (spinbox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinPlus
1249
: PE_IndicatorSpinUp);
1251
copy.rect = subControlRect(CC_SpinBox, spinbox, SC_SpinBoxUp, widget);
1252
drawPrimitive(pe, ©, p, widget);
1255
if (spinbox->subControls & SC_SpinBoxDown) {
1256
copy.subControls = SC_SpinBoxDown;
1257
copy.state = spinbox->state;
1258
QPalette pal2 = spinbox->palette;
1259
if (!(spinbox->stepEnabled & QAbstractSpinBox::StepDownEnabled)) {
1260
pal2.setCurrentColorGroup(QPalette::Disabled);
1261
copy.state &= ~State_Enabled;
1263
copy.palette = pal2;
1265
if (spinbox->activeSubControls == SC_SpinBoxDown && (spinbox->state & State_Sunken)) {
1266
copy.state |= State_On;
1267
copy.state |= State_Sunken;
1269
copy.state |= State_Raised;
1270
copy.state &= ~State_Sunken;
1272
pe = (spinbox->buttonSymbols == QAbstractSpinBox::PlusMinus ? PE_IndicatorSpinMinus
1273
: PE_IndicatorSpinDown);
1275
copy.rect = subControlRect(CC_SpinBox, spinbox, SC_SpinBoxDown, widget);
1276
drawPrimitive(pe, ©, p, widget);
1282
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
1283
QRect groove = subControlRect(CC_Slider, opt, SC_SliderGroove, widget),
1284
handle = subControlRect(CC_Slider, opt, SC_SliderHandle, widget);
1286
if ((opt->subControls & SC_SliderGroove) && groove.isValid()) {
1287
qDrawShadePanel(p, groove, opt->palette, true, pixelMetric(PM_DefaultFrameWidth),
1288
&opt->palette.brush((opt->state & State_Enabled) ? QPalette::Mid : QPalette::Background));
1289
if ((opt->state & State_HasFocus) && (!focus || !focus->isVisible())) {
1290
QStyleOption focusOpt = *opt;
1291
focusOpt.rect = subElementRect(SE_SliderFocusRect, opt, widget);
1292
drawPrimitive(PE_FrameFocusRect, &focusOpt, p, widget);
1296
if ((opt->subControls & SC_SliderHandle) && handle.isValid()) {
1297
QStyleOption bevelOpt = *opt;
1298
bevelOpt.state = (opt->state | State_Raised) & ~State_Sunken;
1299
bevelOpt.rect = handle;
1301
p->setBrushOrigin(bevelOpt.rect.topLeft());
1302
drawPrimitive(PE_PanelButtonBevel, &bevelOpt, p, widget);
1305
if (slider->orientation == Qt::Horizontal) {
1306
int mid = handle.x() + handle.width() / 2;
1307
qDrawShadeLine(p, mid, handle.y(), mid, handle.y() + handle.height() - 2,
1308
opt->palette, true, 1);
1310
int mid = handle.y() + handle.height() / 2;
1311
qDrawShadeLine(p, handle.x(), mid, handle.x() + handle.width() - 2, mid, opt->palette,
1314
if (!(opt->state & State_Enabled) && styleHint(SH_DitherDisabledText))
1315
p->fillRect(handle, QBrush(p->background().color(), Qt::Dense5Pattern));
1318
if (opt->subControls & SC_SliderTickmarks) {
1319
QStyleOptionComplex tickOpt = *opt;
1320
tickOpt.subControls = SC_SliderTickmarks;
1321
QCommonStyle::drawComplexControl(cc, &tickOpt, p, widget);
1327
if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
1328
if (opt->subControls & SC_ComboBoxArrow) {
1329
int awh, ax, ay, sh, sy, dh, ew;
1330
int fw = cb->frame ? pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0;
1333
QStyleOptionButton btn;
1334
btn.QStyleOption::operator=(*cb);
1335
btn.state |= QStyle::State_Raised;
1336
drawPrimitive(PE_PanelButtonCommand, &btn, p, widget);
1338
p->fillRect(opt->rect, opt->palette.brush(QPalette::Button));
1341
QRect tr = opt->rect;
1342
tr.adjust(fw, fw, -fw, -fw);
1343
get_combo_parameters(tr, ew, awh, ax, ay, sh, dh, sy);
1345
QRect ar = QStyle::visualRect(opt->direction, opt->rect, QRect(ax,ay,awh,awh));
1347
QStyleOption arrowOpt = *opt;
1349
arrowOpt.state |= State_Enabled;
1350
drawPrimitive(PE_IndicatorArrowDown, &arrowOpt, p, widget);
1353
// draws the shaded line under the arrow
1354
p->setPen(opt->palette.light().color());
1355
p->drawLine(ar.x(), sy, ar.x()+awh-1, sy);
1356
p->drawLine(ar.x(), sy, ar.x(), sy+sh-1);
1357
p->setPen(opt->palette.dark().color());
1358
p->drawLine(ar.x()+1, sy+sh-1, ar.x()+awh-1, sy+sh-1);
1359
p->drawLine(ar.x()+awh-1, sy+1, ar.x()+awh-1, sy+sh-1);
1361
if ((cb->state & State_HasFocus) && (!focus || !focus->isVisible())) {
1362
QStyleOptionFocusRect focus;
1363
focus.QStyleOption::operator=(*opt);
1364
focus.rect = subElementRect(SE_ComboBoxFocusRect, opt, widget);
1365
focus.backgroundColor = opt->palette.button().color();
1366
drawPrimitive(PE_FrameFocusRect, &focus, p, widget);
1370
if (opt->subControls & SC_ComboBoxEditField) {
1372
QRect er = subControlRect(CC_ComboBox, opt, SC_ComboBoxEditField, widget);
1373
er.adjust(-1, -1, 1, 1);
1374
qDrawShadePanel(p, er, opt->palette, true, 1,
1375
&opt->palette.brush(QPalette::Base));
1378
p->setPen(opt->palette.buttonText().color());
1382
case CC_ScrollBar: {
1383
if (opt->subControls & SC_ScrollBarGroove)
1384
qDrawShadePanel(p, opt->rect, opt->palette, true,
1385
pixelMetric(PM_DefaultFrameWidth, opt, widget),
1386
&opt->palette.brush((opt->state & State_Enabled) ? QPalette::Mid : QPalette::Background));
1388
QCommonStyle::drawComplexControl(cc, opt, p, widget);
1393
if (opt->subControls & (SC_Q3ListViewBranch | SC_Q3ListViewExpand)) {
1395
if (opt->subControls & SC_Q3ListView)
1396
QCommonStyle::drawComplexControl(cc, opt, p, widget);
1397
if (const QStyleOptionQ3ListView *lv = qstyleoption_cast<const QStyleOptionQ3ListView *>(opt)) {
1398
QStyleOptionQ3ListViewItem item = lv->items.at(0);
1399
int y = opt->rect.y();
1402
if ((opt->activeSubControls & SC_All) && (opt->subControls & SC_Q3ListViewExpand)) {
1405
dotlines[0] = QPoint(opt->rect.right(), opt->rect.top());
1406
dotlines[1] = QPoint(opt->rect.right(), opt->rect.bottom());
1408
int linetop = 0, linebot = 0;
1409
// each branch needs at most two lines, ie. four end points
1410
dotlines.resize(item.childCount * 4);
1413
// skip the stuff above the exposed rectangle
1414
for (i = 1; i < lv->items.size(); ++i) {
1415
QStyleOptionQ3ListViewItem child = lv->items.at(i);
1416
if (child.height + y > 0)
1418
y += child.totalHeight;
1421
int bx = opt->rect.width() / 2;
1423
// paint stuff in the magical area
1424
while (i < lv->items.size() && y < lv->rect.height()) {
1425
QStyleOptionQ3ListViewItem child = lv->items.at(i);
1426
if (child.features & QStyleOptionQ3ListViewItem::Visible) {
1428
if (!(item.features & QStyleOptionQ3ListViewItem::MultiLine))
1431
lh = p->fontMetrics().height() + 2 * lv->itemMargin;
1432
lh = qMax(lh, QApplication::globalStrut().height());
1436
if ((child.features & QStyleOptionQ3ListViewItem::Expandable || child.childCount > 0) &&
1439
p->setPen(opt->palette.text().color());
1440
p->drawRect(bx-4, linebot-4, 9, 9);
1442
if ((child.state & State_Open))
1443
a.setPoints(3, bx-2, linebot-2,
1445
bx+2, linebot-2); //Qt::RightArrow
1447
a.setPoints(3, bx-2, linebot-2,
1449
bx-2, linebot+2); //Qt::DownArrow
1450
p->setBrush(opt->palette.text());
1452
p->setBrush(Qt::NoBrush);
1454
dotlines[c++] = QPoint(bx, linetop);
1455
dotlines[c++] = QPoint(bx, linebot - 5);
1456
dotlines[c++] = QPoint(bx + 5, linebot);
1457
dotlines[c++] = QPoint(opt->rect.width(), linebot);
1458
linetop = linebot + 5;
1461
dotlines[c++] = QPoint(bx+1, linebot);
1462
dotlines[c++] = QPoint(opt->rect.width(), linebot);
1464
y += child.totalHeight;
1469
// Expand line height to edge of rectangle if there's any
1470
// visible child below
1471
while (i < lv->items.size() && lv->items.at(i).height <= 0)
1473
if (i < lv->items.size())
1474
linebot = opt->rect.height();
1476
if (linetop < linebot) {
1477
dotlines[c++] = QPoint(bx, linetop);
1478
dotlines[c++] = QPoint(bx, linebot);
1482
int line; // index into dotlines
1483
p->setPen(opt->palette.text().color());
1484
if (opt->subControls & SC_Q3ListViewBranch) for(line = 0; line < c; line += 2) {
1485
p->drawLine(dotlines[line].x(), dotlines[line].y(),
1486
dotlines[line+1].x(), dotlines[line+1].y());
1492
QCommonStyle::drawComplexControl(cc, opt, p, widget);
1499
int QMotifStyle::pixelMetric(PixelMetric pm, const QStyleOption *opt,
1500
const QWidget *widget) const
1505
case PM_ButtonDefaultIndicator:
1509
case PM_ToolBarFrameWidth:
1510
ret = pixelMetric(PM_DefaultFrameWidth);
1513
case PM_ToolBarItemMargin:
1517
case PM_ButtonShiftHorizontal:
1518
case PM_ButtonShiftVertical:
1522
case PM_SplitterWidth:
1523
ret = qMax(10, QApplication::globalStrut().width());
1526
case PM_SliderLength:
1530
case PM_SliderThickness:
1531
ret = 16 + 4 * pixelMetric(PM_DefaultFrameWidth);
1534
case PM_SliderControlThickness:
1535
if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
1536
int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height() : sl->rect.width();
1537
int ticks = sl->tickPosition;
1539
if (ticks & QSlider::TicksAbove)
1541
if (ticks & QSlider::TicksBelow)
1548
int thick = 6; // Magic constant to get 5 + 16 + 5
1551
//### the two sides may be unequal in size
1553
thick += (space * 2) / (n + 2);
1558
case PM_SliderSpaceAvailable:
1559
if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
1560
if (sl->orientation == Qt::Horizontal)
1561
ret = sl->rect.width() - pixelMetric(PM_SliderLength, opt, widget) - 6;
1563
ret = sl->rect.height() - pixelMetric(PM_SliderLength, opt, widget) - 6;
1567
case PM_DockWidgetFrameWidth:
1571
case PM_DockWidgetHandleExtent:
1575
case PM_ProgressBarChunkWidth:
1579
case PM_ExclusiveIndicatorWidth:
1580
case PM_ExclusiveIndicatorHeight:
1584
case PM_MenuBarHMargin:
1585
ret = 2; // really ugly, but Motif
1589
ret = QCommonStyle::pixelMetric(pm, opt, widget);
1600
QMotifStyle::subControlRect(ComplexControl cc, const QStyleOptionComplex *opt,
1601
SubControl sc, const QWidget *widget) const
1605
if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) {
1606
int fw = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0;
1608
bs.setHeight(opt->rect.height()/2 - fw);
1609
bs.setWidth(qMin(bs.height() * 8 / 5, opt->rect.width() / 4)); // 1.6 -approximate golden mean
1610
bs = bs.expandedTo(QApplication::globalStrut());
1613
x = opt->rect.width() - y - bs.width();
1616
const int margin = spinbox->frame ? 4 : 0;
1619
return visualRect(spinbox->direction, spinbox->rect,
1620
QRect(x, y, bs.width(), bs.height() - 1));
1621
case SC_SpinBoxDown:
1622
return visualRect(spinbox->direction, spinbox->rect,
1623
QRect(x, y + bs.height() + 1, bs.width(), bs.height() - 1));
1624
case SC_SpinBoxEditField:
1625
return visualRect(spinbox->direction, spinbox->rect,
1626
QRect(lx + margin, fw + margin, rx - margin,
1627
spinbox->rect.height() - 2*fw - 2 * margin));
1628
case SC_SpinBoxFrame:
1629
return visualRect(spinbox->direction, spinbox->rect, spinbox->rect);
1636
if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
1637
if (sc == SC_SliderHandle) {
1638
int tickOffset = pixelMetric(PM_SliderTickmarkOffset, opt, widget);
1639
int thickness = pixelMetric(PM_SliderControlThickness, opt, widget);
1640
bool horizontal = slider->orientation == Qt::Horizontal;
1641
int len = pixelMetric(PM_SliderLength, opt, widget);
1642
int motifBorder = pixelMetric(PM_DefaultFrameWidth);
1643
int sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum, slider->sliderPosition,
1644
horizontal ? slider->rect.width() - len - 2 * motifBorder
1645
: slider->rect.height() - len - 2 * motifBorder,
1646
slider->upsideDown);
1648
return visualRect(slider->direction, slider->rect,
1649
QRect(sliderPos + motifBorder, tickOffset + motifBorder, len,
1650
thickness - 2 * motifBorder));
1651
return visualRect(slider->direction, slider->rect,
1652
QRect(tickOffset + motifBorder, sliderPos + motifBorder,
1653
thickness - 2 * motifBorder, len));
1659
if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) {
1660
int dfw = pixelMetric(PM_DefaultFrameWidth);
1661
QRect rect = visualRect(scrollbar->direction, scrollbar->rect,
1662
QCommonStyle::subControlRect(cc, scrollbar, sc, widget));
1663
if (sc == SC_ScrollBarSlider) {
1664
if (scrollbar->orientation == Qt::Horizontal)
1665
rect.adjust(-dfw, dfw, dfw, -dfw);
1667
rect.adjust(dfw, -dfw, -dfw, dfw);
1668
} else if (sc != SC_ScrollBarGroove)
1669
if (scrollbar->orientation == Qt::Horizontal)
1670
rect.adjust(0, dfw, 0, -dfw);
1672
rect.adjust(dfw, 0, -dfw, 0);
1673
return visualRect(scrollbar->direction, scrollbar->rect, rect);
1678
if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) {
1680
case SC_ComboBoxArrow: {
1681
int ew, awh, sh, dh, ax, ay, sy;
1682
int fw = cb->frame ? pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0;
1683
QRect cr = opt->rect;
1684
cr.adjust(fw, fw, -fw, -fw);
1685
get_combo_parameters(cr, ew, awh, ax, ay, sh, dh, sy);
1686
return visualRect(cb->direction, cb->rect, QRect(QPoint(ax, ay), cr.bottomRight()));
1689
case SC_ComboBoxEditField: {
1690
int fw = cb->frame ? pixelMetric(PM_ComboBoxFrameWidth, opt, widget) : 0;
1691
QRect rect = opt->rect;
1692
rect.adjust(fw, fw, -fw, -fw);
1693
int ew = get_combo_extra_width(rect.height(), rect.width());
1694
rect.adjust(1, 1, -1-ew, -1);
1695
return visualRect(cb->direction, cb->rect, rect);
1706
return QCommonStyle::subControlRect(cc, opt, sc, widget);
1713
QMotifStyle::sizeFromContents(ContentsType ct, const QStyleOption *opt,
1714
const QSize &contentsSize, const QWidget *widget) const
1716
QSize sz(contentsSize);
1723
case CT_RadioButton:
1725
sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget);
1726
sz.rwidth() += motifItemFrame;
1730
if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) {
1731
sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget);
1732
if (!btn->text.isEmpty() && (btn->features & (QStyleOptionButton::AutoDefaultButton|QStyleOptionButton::DefaultButton)))
1733
sz.setWidth(qMax(75, sz.width()));
1734
sz += QSize(0, 1); // magical extra pixel
1738
case CT_MenuBarItem: {
1740
sz += QSize(5*motifItemHMargin+1, 2*motifItemVMargin + motifItemFrame);
1744
if (const QStyleOptionMenuItem *mi = qstyleoption_cast<const QStyleOptionMenuItem *>(opt)) {
1745
sz = QCommonStyle::sizeFromContents(ct, opt, sz, widget);
1746
int w = sz.width(), h = sz.height();
1748
if (mi->menuItemType == QStyleOptionMenuItem::Separator) {
1753
// a little bit of border can never harm
1754
w += 2*motifItemHMargin + 2*motifItemFrame;
1756
if (!mi->text.isNull() && mi->text.indexOf('\t') >= 0)
1757
// string contains tab
1758
w += motifTabSpacing;
1759
else if (mi->menuItemType == QStyleOptionMenuItem::SubMenu)
1760
// submenu indicator needs some room if we don't have a tab column
1761
w += motifArrowHMargin + 4*motifItemFrame;
1763
int checkColumn = mi->maxIconWidth;
1764
if (mi->menuHasCheckableItems)
1765
checkColumn = qMax(checkColumn, motifCheckMarkSpace);
1766
if (checkColumn > 0)
1767
w += checkColumn + motifCheckMarkHMargin;
1775
sz = QCommonStyle::sizeFromContents(ct, opt, contentsSize, widget);
1786
QMotifStyle::subElementRect(SubElement sr, const QStyleOption *opt, const QWidget *widget) const
1791
case SE_SliderFocusRect:
1792
rect = QCommonStyle::subElementRect(sr, opt, widget);
1793
rect.adjust(2, 2, -2, -2);
1796
case SE_CheckBoxIndicator:
1797
case SE_RadioButtonIndicator:
1799
rect = visualRect(opt->direction, opt->rect,
1800
QCommonStyle::subElementRect(sr, opt, widget));
1801
rect.adjust(motifItemFrame,0, motifItemFrame,0);
1802
rect = visualRect(opt->direction, opt->rect, rect);
1806
case SE_ComboBoxFocusRect:
1808
int awh, ax, ay, sh, sy, dh, ew;
1809
int fw = pixelMetric(PM_DefaultFrameWidth, opt, widget);
1810
QRect tr = opt->rect;
1812
tr.adjust(fw, fw, -fw, -fw);
1813
get_combo_parameters(tr, ew, awh, ax, ay, sh, dh, sy);
1814
rect.setRect(ax-2, ay-2, awh+4, awh+sh+dh+4);
1818
case SE_Q3DockWindowHandleRect:
1819
if (const QStyleOptionQ3DockWindow *dw = qstyleoption_cast<const QStyleOptionQ3DockWindow *>(opt)) {
1820
if (!dw->docked || !dw->closeEnabled)
1821
rect.setRect(0, 0, opt->rect.width(), opt->rect.height());
1823
if (dw->state == State_Horizontal)
1824
rect.setRect(2, 15, opt->rect.width()-2, opt->rect.height() - 15);
1826
rect.setRect(0, 2, opt->rect.width() - 15, opt->rect.height() - 2);
1828
rect = visualRect(dw->direction, dw->rect, rect);
1832
case SE_ProgressBarLabel:
1833
case SE_ProgressBarGroove:
1834
case SE_ProgressBarContents:
1835
if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
1837
if (pb->textVisible)
1838
textw = pb->fontMetrics.width("100%") + 6;
1840
if (pb->textAlignment == Qt::AlignLeft || pb->textAlignment == Qt::AlignCenter) {
1843
if(sr == SE_ProgressBarLabel)
1844
rect.setCoords(opt->rect.right() - textw, opt->rect.top(),
1845
opt->rect.right(), opt->rect.bottom());
1847
rect.setCoords(opt->rect.left(), opt->rect.top(),
1848
opt->rect.right() - textw, opt->rect.bottom());
1850
rect = visualRect(pb->direction, pb->rect, rect);
1853
case SE_CheckBoxContents:
1854
case SE_RadioButtonContents: {
1855
QRect ir = visualRect(opt->direction, opt->rect,
1856
subElementRect(sr == SE_CheckBoxContents ? SE_CheckBoxIndicator
1857
: SE_RadioButtonIndicator,
1859
rect.setRect(ir.right() + 10, opt->rect.y(),
1860
opt->rect.width() - ir.width() - 10, opt->rect.height());
1861
rect = visualRect(opt->direction, opt->rect, rect);
1863
case SE_CheckBoxClickRect:
1864
case SE_RadioButtonClickRect:
1865
rect = visualRect(opt->direction, opt->rect, opt->rect);
1869
rect = QCommonStyle::subElementRect(sr, opt, widget);
1874
#ifndef QT_NO_IMAGEIO_XPM
1875
static const char * const qt_menu_xpm[] = {
1903
"................"};
1906
static const char * const qt_close_xpm[] = {
1923
static const char * const qt_maximize_xpm[] = {
1940
static const char * const qt_minimize_xpm[] = {
1957
#if 0 // ### not used???
1958
static const char * const qt_normalize_xpm[] = {
1976
static const char * const qt_normalizeup_xpm[] = {
1993
static const char * const qt_shade_xpm[] = {
1994
"12 12 2 1", "# c #000000",
2010
static const char * const qt_unshade_xpm[] = {
2028
static const char * dock_window_close_xpm[] = {
2041
// Message box icons, from page 210 of the Windows style guide.
2043
// Hand-drawn to resemble Microsoft's icons, but in the Mac/Netscape palette.
2044
// Thanks to TrueColor displays, it is slightly more efficient to have
2047
static const char * const information_xpm[]={
2054
"...........********.............",
2055
"........***aaaaaaaa***..........",
2056
"......**aaaaaaaaaaaaaa**........",
2057
".....*aaaaaaaaaaaaaaaaaa*.......",
2058
"....*aaaaaaaabbbbaaaaaaaac......",
2059
"...*aaaaaaaabbbbbbaaaaaaaac.....",
2060
"..*aaaaaaaaabbbbbbaaaaaaaaac....",
2061
".*aaaaaaaaaaabbbbaaaaaaaaaaac...",
2062
".*aaaaaaaaaaaaaaaaaaaaaaaaaac*..",
2063
"*aaaaaaaaaaaaaaaaaaaaaaaaaaaac*.",
2064
"*aaaaaaaaaabbbbbbbaaaaaaaaaaac*.",
2065
"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
2066
"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
2067
"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
2068
"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
2069
"*aaaaaaaaaaaabbbbbaaaaaaaaaaac**",
2070
".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
2071
".*aaaaaaaaaaabbbbbaaaaaaaaaac***",
2072
"..*aaaaaaaaaabbbbbaaaaaaaaac***.",
2073
"...caaaaaaabbbbbbbbbaaaaaac****.",
2074
"....caaaaaaaaaaaaaaaaaaaac****..",
2075
".....caaaaaaaaaaaaaaaaaac****...",
2076
"......ccaaaaaaaaaaaaaacc****....",
2077
".......*cccaaaaaaaaccc*****.....",
2078
"........***cccaaaac*******......",
2079
"..........****caaac*****........",
2080
".............*caaac**...........",
2081
"...............caac**...........",
2082
"................cac**...........",
2083
".................cc**...........",
2084
"..................***...........",
2085
"...................**..........."};
2087
static const char* const warning_xpm[]={
2093
".............***................",
2094
"............*aaa*...............",
2095
"...........*aaaaa*b.............",
2096
"...........*aaaaa*bb............",
2097
"..........*aaaaaaa*bb...........",
2098
"..........*aaaaaaa*bb...........",
2099
".........*aaaaaaaaa*bb..........",
2100
".........*aaaaaaaaa*bb..........",
2101
"........*aaaaaaaaaaa*bb.........",
2102
"........*aaaa***aaaa*bb.........",
2103
".......*aaaa*****aaaa*bb........",
2104
".......*aaaa*****aaaa*bb........",
2105
"......*aaaaa*****aaaaa*bb.......",
2106
"......*aaaaa*****aaaaa*bb.......",
2107
".....*aaaaaa*****aaaaaa*bb......",
2108
".....*aaaaaa*****aaaaaa*bb......",
2109
"....*aaaaaaaa***aaaaaaaa*bb.....",
2110
"....*aaaaaaaa***aaaaaaaa*bb.....",
2111
"...*aaaaaaaaa***aaaaaaaaa*bb....",
2112
"...*aaaaaaaaaa*aaaaaaaaaa*bb....",
2113
"..*aaaaaaaaaaa*aaaaaaaaaaa*bb...",
2114
"..*aaaaaaaaaaaaaaaaaaaaaaa*bb...",
2115
".*aaaaaaaaaaaa**aaaaaaaaaaa*bb..",
2116
".*aaaaaaaaaaa****aaaaaaaaaa*bb..",
2117
"*aaaaaaaaaaaa****aaaaaaaaaaa*bb.",
2118
"*aaaaaaaaaaaaa**aaaaaaaaaaaa*bb.",
2119
"*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
2120
"*aaaaaaaaaaaaaaaaaaaaaaaaaaa*bbb",
2121
".*aaaaaaaaaaaaaaaaaaaaaaaaa*bbbb",
2122
"..*************************bbbbb",
2123
"....bbbbbbbbbbbbbbbbbbbbbbbbbbb.",
2124
".....bbbbbbbbbbbbbbbbbbbbbbbbb.."};
2126
static const char* const critical_xpm[]={
2132
"...........********.............",
2133
".........************...........",
2134
".......****************.........",
2135
"......******************........",
2136
".....********************a......",
2137
"....**********************a.....",
2138
"...************************a....",
2139
"..*******b**********b*******a...",
2140
"..******bbb********bbb******a...",
2141
".******bbbbb******bbbbb******a..",
2142
".*******bbbbb****bbbbb*******a..",
2143
"*********bbbbb**bbbbb*********a.",
2144
"**********bbbbbbbbbb**********a.",
2145
"***********bbbbbbbb***********aa",
2146
"************bbbbbb************aa",
2147
"************bbbbbb************aa",
2148
"***********bbbbbbbb***********aa",
2149
"**********bbbbbbbbbb**********aa",
2150
"*********bbbbb**bbbbb*********aa",
2151
".*******bbbbb****bbbbb*******aa.",
2152
".******bbbbb******bbbbb******aa.",
2153
"..******bbb********bbb******aaa.",
2154
"..*******b**********b*******aa..",
2155
"...************************aaa..",
2156
"....**********************aaa...",
2157
"....a********************aaa....",
2158
".....a******************aaa.....",
2159
"......a****************aaa......",
2160
".......aa************aaaa.......",
2161
".........aa********aaaaa........",
2162
"...........aaaaaaaaaaa..........",
2163
".............aaaaaaa............"};
2165
static const char *const question_xpm[] = {
2172
"...........********.............",
2173
"........***aaaaaaaa***..........",
2174
"......**aaaaaaaaaaaaaa**........",
2175
".....*aaaaaaaaaaaaaaaaaa*.......",
2176
"....*aaaaaaaaaaaaaaaaaaaac......",
2177
"...*aaaaaaaabbbbbbaaaaaaaac.....",
2178
"..*aaaaaaaabaaabbbbaaaaaaaac....",
2179
".*aaaaaaaabbaaaabbbbaaaaaaaac...",
2180
".*aaaaaaaabbbbaabbbbaaaaaaaac*..",
2181
"*aaaaaaaaabbbbaabbbbaaaaaaaaac*.",
2182
"*aaaaaaaaaabbaabbbbaaaaaaaaaac*.",
2183
"*aaaaaaaaaaaaabbbbaaaaaaaaaaac**",
2184
"*aaaaaaaaaaaaabbbaaaaaaaaaaaac**",
2185
"*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
2186
"*aaaaaaaaaaaaabbaaaaaaaaaaaaac**",
2187
"*aaaaaaaaaaaaaaaaaaaaaaaaaaaac**",
2188
".*aaaaaaaaaaaabbaaaaaaaaaaaac***",
2189
".*aaaaaaaaaaabbbbaaaaaaaaaaac***",
2190
"..*aaaaaaaaaabbbbaaaaaaaaaac***.",
2191
"...caaaaaaaaaabbaaaaaaaaaac****.",
2192
"....caaaaaaaaaaaaaaaaaaaac****..",
2193
".....caaaaaaaaaaaaaaaaaac****...",
2194
"......ccaaaaaaaaaaaaaacc****....",
2195
".......*cccaaaaaaaaccc*****.....",
2196
"........***cccaaaac*******......",
2197
"..........****caaac*****........",
2198
".............*caaac**...........",
2199
"...............caac**...........",
2200
"................cac**...........",
2201
".................cc**...........",
2202
"..................***...........",
2203
"...................**...........",
2211
QMotifStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt,
2212
const QWidget *widget) const
2214
#ifndef QT_NO_IMAGEIO_XPM
2215
switch (standardPixmap) {
2216
case SP_TitleBarMenuButton:
2217
return QPixmap((const char **)qt_menu_xpm);
2218
case SP_TitleBarShadeButton:
2219
return QPixmap((const char **)qt_shade_xpm);
2220
case SP_TitleBarUnshadeButton:
2221
return QPixmap((const char **)qt_unshade_xpm);
2222
case SP_TitleBarNormalButton:
2223
return QPixmap((const char **)qt_normalizeup_xpm);
2224
case SP_TitleBarMinButton:
2225
return QPixmap((const char **)qt_minimize_xpm);
2226
case SP_TitleBarMaxButton:
2227
return QPixmap((const char **)qt_maximize_xpm);
2228
case SP_TitleBarCloseButton:
2229
return QPixmap((const char **)qt_close_xpm);
2230
case SP_DockWidgetCloseButton:
2231
return QPixmap((const char **)dock_window_close_xpm);
2233
case SP_MessageBoxInformation:
2234
case SP_MessageBoxWarning:
2235
case SP_MessageBoxCritical:
2236
case SP_MessageBoxQuestion:
2238
const char * const * xpm_data;
2239
switch (standardPixmap) {
2240
case SP_MessageBoxInformation:
2241
xpm_data = information_xpm;
2243
case SP_MessageBoxWarning:
2244
xpm_data = warning_xpm;
2246
case SP_MessageBoxCritical:
2247
xpm_data = critical_xpm;
2249
case SP_MessageBoxQuestion:
2250
xpm_data = question_xpm;
2258
QImage image((const char **) xpm_data);
2259
// All that color looks ugly in Motif
2260
const QPalette &pal = QApplication::palette();
2261
switch (standardPixmap) {
2262
case SP_MessageBoxInformation:
2263
case SP_MessageBoxQuestion:
2264
image.setColor(2, 0xff000000 |
2265
pal.color(QPalette::Active, QPalette::Dark).rgb());
2266
image.setColor(3, 0xff000000 |
2267
pal.color(QPalette::Active, QPalette::Base).rgb());
2268
image.setColor(4, 0xff000000 |
2269
pal.color(QPalette::Active, QPalette::Text).rgb());
2271
case SP_MessageBoxWarning:
2272
image.setColor(1, 0xff000000 |
2273
pal.color(QPalette::Active, QPalette::Base).rgb());
2274
image.setColor(2, 0xff000000 |
2275
pal.color(QPalette::Active, QPalette::Text).rgb());
2276
image.setColor(3, 0xff000000 |
2277
pal.color(QPalette::Active, QPalette::Dark).rgb());
2279
case SP_MessageBoxCritical:
2280
image.setColor(1, 0xff000000 |
2281
pal.color(QPalette::Active, QPalette::Dark).rgb());
2282
image.setColor(2, 0xff000000 |
2283
pal.color(QPalette::Active, QPalette::Text).rgb());
2284
image.setColor(3, 0xff000000 |
2285
pal.color(QPalette::Active, QPalette::Base).rgb());
2290
image = pm.toImage();
2300
return QCommonStyle::standardPixmap(standardPixmap, opt, widget);
2304
bool QMotifStyle::event(QEvent *e)
2306
if(e->type() == QEvent::FocusIn) {
2307
if (QWidget *focusWidget = QApplication::focusWidget()) {
2309
focus = new QFocusFrame(focusWidget);
2310
focus->setWidget(focusWidget);
2313
focus->setWidget(0);
2315
} else if(e->type() == QEvent::FocusOut) {
2317
focus->setWidget(0);
2325
QMotifStyle::styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *widget,
2326
QStyleHintReturn *returnData) const
2333
ret = Qt::MotifStyle;
2336
case SH_DrawMenuBarSeparator:
2340
case SH_ScrollBar_MiddleClickAbsolutePosition:
2341
case SH_Slider_SloppyKeyEvents:
2342
case SH_ProgressDialog_CenterCancelButton:
2343
case SH_Menu_SpaceActivatesItem:
2344
case SH_ScrollView_FrameOnlyAroundContents:
2345
case SH_DitherDisabledText:
2349
case SH_Menu_SubMenuPopupDelay:
2353
case SH_ProgressDialog_TextLabelAlignment:
2354
ret = Qt::AlignLeft | Qt::AlignVCenter;
2357
case SH_ItemView_ChangeHighlightOnFocus:
2361
case SH_MenuBar_DismissOnSecondClick:
2365
case SH_MessageBox_UseBorderForButtonSpacing:
2369
case SH_Dial_BackgroundRole:
2370
ret = QPalette::Mid;
2374
ret = QCommonStyle::styleHint(hint, opt, widget, returnData);
2382
QPalette QMotifStyle::standardPalette() const
2385
QColor background(0xcf, 0xcf, 0xcf);
2386
if (QX11Info::appDepth() <= 8)
2387
background = QColor(0xc0, 0xc0, 0xc0);
2389
QColor background = QColor(0xcf, 0xcf, 0xcf);
2392
QColor light = background.light();
2393
QColor mid = QColor(0xa6, 0xa6, 0xa6);
2394
QColor dark = QColor(0x79, 0x7d, 0x79);
2395
QPalette palette(Qt::black, background, light, dark, mid, Qt::black, Qt::white);
2396
palette.setBrush(QPalette::Disabled, QPalette::Foreground, dark);
2397
palette.setBrush(QPalette::Disabled, QPalette::Text, dark);
2398
palette.setBrush(QPalette::Disabled, QPalette::ButtonText, dark);
2399
palette.setBrush(QPalette::Disabled, QPalette::Base, background);