Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
javastyle.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4#include <QtGui>
5
6#include "javastyle.h"
7#include <math.h>
8
9static const int windowsItemFrame = 2;
10static const int windowsSepHeight = 2;
11static const int windowsItemHMargin = 3;
12static const int windowsItemVMargin = 2;
13static const int windowsArrowHMargin = 6;
14static const int windowsTabSpacing = 12;
15static const int windowsCheckMarkHMargin = 2;
16static const int windowsRightBorder = 15;
17static const int windowsCheckMarkWidth = 12;
18
19JavaStyle::JavaStyle()
20{
21 qApp->setPalette(standardPalette());
22}
23
24
25inline QPoint JavaStyle::adjustScrollPoint(const QPoint &point,
26 Qt::Orientation orientation,
27 bool add) const
28{
29 int adder = add ? -1 : 1;
30 QPoint retPoint;
31
32 if (orientation == Qt::Horizontal) {
33 retPoint = QPoint(point.y() * adder, point.x());
34 } else {
35 retPoint = QPoint(point.x(), point.y() * adder);
36 }
37
38 return retPoint;
39}
40
41QPalette JavaStyle::standardPalette() const
42{
44
46 QColor(184, 207, 229));
48 Qt::black);
49 palette.setBrush(QPalette::Active, QPalette::Background,
50 QColor(238, 238, 238));
52 QColor(238 ,238, 238));
54 palette.setBrush(QPalette::Active, QPalette::AlternateBase, QColor(238, 238, 238));
57
58 palette.setBrush(QPalette::Active, QPalette::Light, QColor(163, 184, 204)); // focusFrameColor
59 palette.setBrush(QPalette::Active, QPalette::Midlight, QColor(99, 130, 191)); // tabBarBorderColor
60 palette.setBrush(QPalette::Active, QPalette::Dark, QColor(106, 104, 100));
61 palette.setBrush(QPalette::Active, QPalette::Mid, QColor(122, 138, 153)); //defaultFrameColor
62 palette.setBrush(QPalette::Active, QPalette::Shadow, QColor(122, 138, 153)); // defaultFrame
63
64 palette.setBrush(QPalette::Active, QPalette::Highlight, QColor(184, 207, 229));
66
67 palette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(184, 207, 229));
69
71 QColor(238, 238, 238));
73 QColor(153, 153, 153));
74 palette.setBrush(QPalette::Disabled, QPalette::Background, QColor(238, 238, 238));
75
77 QColor(184, 207, 229));
78 palette.setBrush(QPalette::Inactive, QPalette::Background,
79 QColor(238, 238, 238));
81 QColor(238 ,238, 238));
82 palette.setBrush(QPalette::Inactive, QPalette::Light, QColor(163, 184, 204)); // focusFrameColor
83 palette.setBrush(QPalette::Inactive, QPalette::Midlight, QColor(99, 130, 191)); // tabBarBorderColor
84 palette.setBrush(QPalette::Inactive, QPalette::Dark,QColor(106, 104, 100));
85 palette.setBrush(QPalette::Inactive, QPalette::Mid, QColor(122, 138, 153)); //defaultFrame
86 palette.setBrush(QPalette::Inactive, QPalette::Shadow, QColor(122, 138, 153)); // defaultFrame
87
88 return palette;
89}
90
91inline void JavaStyle::drawScrollBarArrow(const QRect &rect, QPainter *painter,
92 const QStyleOptionSlider *option,
93 bool add) const
94{
95
96 painter->save();
97
98 Qt::Orientation orient = option->orientation;
100
101 if (add) {
102 if (orient == Qt::Vertical) {
103 offset = rect.bottomLeft();
104 } else {
105 offset = rect.topRight();
106 }
107 } else {
108 offset = rect.topLeft();
109 }
110
111 QPainterPath arrow;
112 arrow.moveTo(offset + adjustScrollPoint(QPoint(4, 8), orient, add));
113 arrow.lineTo(offset + adjustScrollPoint(QPoint(7, 5), orient, add));
114 arrow.lineTo(offset + adjustScrollPoint(QPoint(8, 5), orient, add));
115 arrow.lineTo(offset + adjustScrollPoint(QPoint(11, 8), orient, add));
116 arrow.lineTo(offset + adjustScrollPoint(QPoint(4, 8), orient, add));
117
118 QColor fillColor;
119 if (option->state & State_Sunken)
120 fillColor = QColor(option->palette.color(QPalette::Button));
121 else
122 fillColor = option->palette.color(QPalette::Background);
123
124 painter->fillRect(rect, fillColor);
125
126 painter->setPen(option->palette.color(QPalette::Base));
127 int adjust = option->state & State_Sunken ? 0 : 1;
128 painter->drawRect(rect.adjusted(adjust, adjust, -1, -1));
129 painter->setPen(option->palette.color(QPalette::Mid));
130 painter->drawRect(rect.adjusted(0, 0, -1, -1));
131
132 painter->setPen(option->palette.color(QPalette::WindowText));
134 painter->drawPath(arrow);
135
136 painter->restore();
137}
138
139inline QPoint JavaStyle::adjustScrollHandlePoint(Qt::Orientation orig,
140 const QPoint &point) const
141{
142 QPoint retPoint;
143
144 if (orig == Qt::Vertical)
145 retPoint = point;
146 else
147 retPoint = QPoint(point.y(), point.x());
148
149 return retPoint;
150}
151
152void JavaStyle::drawControl(ControlElement control, const QStyleOption *option,
153 QPainter *painter, const QWidget *widget) const
154{
155
156 painter->save();
157
158 switch (control) {
159 case CE_ToolBoxTabShape: {
160 const QStyleOptionToolBox *box =
161 qstyleoption_cast<const QStyleOptionToolBox *>(option);
162
163 painter->save();
164
165 if (box->direction == Qt::RightToLeft) {
166 painter->rotate(1);
167 painter->translate(box->rect.width(), -box->rect.height());
168 }
169
170 int textWidth = box->fontMetrics.horizontalAdvance(box->text) + 20;
171
172 QPolygon innerLine;
173 innerLine << (box->rect.topLeft() + QPoint(0, 1)) <<
174 (box->rect.topLeft() + QPoint(textWidth, 1)) <<
175 (box->rect.bottomLeft() + QPoint(textWidth + 15, -3)) <<
176 (box->rect.bottomRight() + QPoint(0, -3)) <<
177 box->rect.bottomRight() <<
178 box->rect.bottomLeft() <<
179 box->rect.topLeft();
180
181 painter->setPen(box->palette.color(QPalette::Base));
182 painter->setBrush(QColor(200, 221, 242));
183 painter->drawPolygon(innerLine);
184
185 QPolygon outerLine;
186 outerLine << (box->rect.bottomRight() + QPoint(0, -3)) <<
187 box->rect.bottomRight() <<
188 box->rect.bottomLeft() <<
189 box->rect.topLeft() <<
190 (box->rect.topLeft() + QPoint(textWidth, 0)) <<
191 (box->rect.bottomLeft() + QPoint(textWidth + 15, -4)) <<
192 (box->rect.bottomRight() + QPoint(0, -4));
193
194 painter->setPen(box->palette.color(QPalette::Midlight));
196 painter->drawPolyline(outerLine);
197
198 painter->restore();
199 break;
200 }
201 case CE_DockWidgetTitle: {
202 const QStyleOptionDockWidget *docker =
203 qstyleoption_cast<const QStyleOptionDockWidget *>(option);
204
205 QRect rect = docker->rect;
206 QRect titleRect = rect;
207 if (docker->verticalTitleBar) {
209
210 titleRect = QRect(r.left() + rect.bottom()
211 - titleRect.bottom(),
212 r.top() + titleRect.left() - rect.left(),
213 titleRect.height(), titleRect.width());
214
215 painter->translate(r.left(), r.top() + r.width());
216 painter->rotate(-90);
217 painter->translate(-r.left(), -r.top());
218
219 rect = r;
220 }
221
222 QLinearGradient gradient(rect.topLeft(),
223 rect.bottomLeft());
224 gradient.setColorAt(1.0, QColor(191, 212, 231));
225 gradient.setColorAt(0.3, Qt::white);
226 gradient.setColorAt(0.0, QColor(221, 232, 243));
227
229 painter->setBrush(gradient);
230 painter->drawRect(rect.adjusted(0, 0, -1, -1));
231
232 if (!docker->title.isEmpty()) {
233 QRect textRect = docker->fontMetrics.boundingRect(docker->title);
234 textRect.moveCenter(rect.center());
235
236 QFont font = painter->font();
239 painter->setPen(docker->palette.text().color());
240 painter->drawText(textRect, docker->title,
243 }
244 break;
245 }
246 case CE_RubberBand: {
247 painter->setPen(option->palette.color(QPalette::Active,
249 painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
250 break;
251 }
252 case CE_SizeGrip: {
253 break;
254 }
255 case CE_HeaderSection: {
257 qstyleoption_cast<const QStyleOptionHeader *>(option);
258
260 painter->setBrush(option->palette.color(QPalette::Active,
261 QPalette::Background));
262 painter->drawRect(option->rect);
263
264 painter->setPen(header->palette.color(QPalette::Mid));
265 if (header->orientation == Qt::Horizontal) {
266 if (header->position == QStyleOptionHeader::Beginning ||
268 painter->drawRect(header->rect.adjusted(0, 0, -1, -1));
269 painter->setPen(header->palette.color(QPalette::Base));
270 painter->drawLine(header->rect.bottomLeft() + QPoint(1, -1),
271 header->rect.topLeft() + QPoint(1, 1));
272 painter->drawLine(header->rect.topLeft() + QPoint(1, 1),
273 header->rect.topRight() + QPoint(-1, 1));
274 } else {
275 painter->drawLine(header->rect.bottomRight(),
276 header->rect.topRight());
277 painter->drawLine(header->rect.topLeft(),
278 header->rect.topRight());
279 painter->drawLine(header->rect.bottomLeft(),
280 header->rect.bottomRight());
281 painter->setPen(option->palette.color(QPalette::Base));
282 painter->drawLine(header->rect.bottomLeft() + QPoint(0, -1),
283 header->rect.topLeft() + QPoint(0, 1));
284 painter->drawLine(header->rect.topLeft() + QPoint(1, 1),
285 header->rect.topRight() + QPoint(-1, 1));
286 }
287 } else { // Vertical
288 if (header->position == QStyleOptionHeader::Beginning ||
290 painter->drawRect(header->rect.adjusted(0, 0, -1, -1));
291 painter->setPen(header->palette.color(QPalette::Base));
292 painter->drawLine(header->rect.bottomLeft() + QPoint(1, -1),
293 header->rect.topLeft() + QPoint(1, 1));
294 painter->drawLine(header->rect.topLeft() + QPoint(1, 1),
295 header->rect.topRight() + QPoint(-1, 1));
296 } else {
297 painter->drawLine(header->rect.bottomLeft(),
298 header->rect.bottomRight());
299 painter->drawLine(header->rect.topLeft(),
300 header->rect.bottomLeft());
301 painter->drawLine(header->rect.topRight(),
302 header->rect.bottomRight());
303 painter->setPen(header->palette.color(QPalette::Base));
304 painter->drawLine(header->rect.topLeft(),
305 header->rect.topRight() + QPoint(-1, 0));
306 painter->drawLine(header->rect.bottomLeft() + QPoint(1, -1),
307 header->rect.topLeft() + QPoint(1, 0));
308 }
309 }
310 break;
311 }
312 case CE_ToolBar: {
313 QRect rect = option->rect;
314
315 QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
316 gradient.setColorAt(1.0, QColor(221, 221, 221));
317 gradient.setColorAt(0.0, QColor(241, 241, 241));
318
319 if (option->state & State_Horizontal) {
320 painter->setPen(QColor(204, 204, 204));
321 painter->setBrush(gradient);
322 } else {
324 painter->setBrush(option->palette.color(QPalette::Background));
325 }
326 painter->drawRect(rect.adjusted(0, 0, -1, -1));
327 break;
328 }
329 case CE_ProgressBar: {
330 const QStyleOptionProgressBar *bar =
331 qstyleoption_cast<const QStyleOptionProgressBar *>(option);
332
333 QRect rect = bar->rect;
334 if (bar->orientation == Qt::Vertical) {
335 rect = QRect(rect.left(), rect.top(), rect.height(), rect.width());
337 m.translate(rect.height()-1, 0);
338 m.rotate(90.0);
340 }
341
343 painter->drawRect(rect.adjusted(0, 0, -1, -1));
344
345 QRect grooveRect = subElementRect(SE_ProgressBarGroove, bar,
346 widget);
347 if (bar->orientation == Qt::Vertical) {
348 grooveRect = QRect(grooveRect.left(), grooveRect.top(),
349 grooveRect.height(), grooveRect.width());
350 }
351
352 QStyleOptionProgressBar grooveBar = *bar;
353 grooveBar.rect = grooveRect;
354
355 drawControl(CE_ProgressBarGroove, &grooveBar, painter, widget);
356
357 QRect progressRect = subElementRect(SE_ProgressBarContents, bar,
358 widget);
359 if (bar->orientation == Qt::Vertical) {
360 progressRect = QRect(progressRect.left(), progressRect.top(),
361 progressRect.height(), progressRect.width());
362 progressRect.adjust(0, 0, 0, -1);
363 }
364 QStyleOptionProgressBar progressOpt = *bar;
365 progressOpt.rect = progressRect;
366 drawControl(CE_ProgressBarContents, &progressOpt, painter, widget);
367
368 QRect labelRect = subElementRect(SE_ProgressBarLabel, bar, widget);
369 if (bar->orientation == Qt::Vertical) {
370 labelRect = QRect(labelRect.left(), labelRect.top(),
371 labelRect.height(), labelRect.width());
372 }
373 QStyleOptionProgressBar subBar = *bar;
374 subBar.rect = labelRect;
375 if (bar->textVisible)
376 drawControl(CE_ProgressBarLabel, &subBar, painter, widget);
377
378 break;
379 }
380 case CE_ProgressBarGroove: {
381 painter->setBrush(option->palette.color(QPalette::Background));
383 painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
384
385 painter->setPen(option->palette.color(QPalette::Button));
386 painter->drawLine(option->rect.topLeft() + QPoint(0, 0),
387 option->rect.topRight() + QPoint(0, 0));
388 break;
389 }
390 case CE_ProgressBarContents: {
391 const QStyleOptionProgressBar *bar =
392 qstyleoption_cast<const QStyleOptionProgressBar *>(option);
393 int progress = int((double(bar->progress) /
394 double(bar->maximum - bar->minimum)) *
395 bar->rect.width());
396
399 QRect progressRect = QRect(bar->rect.topLeft(), QPoint(progress,
400 bar->rect.bottom()));
401 painter->drawRect(progressRect);
402
405
406 painter->drawLine(bar->rect.bottomLeft(), bar->rect.topLeft());
407 painter->drawLine(bar->rect.topLeft(), QPoint(progress,
408 bar->rect.top()));
409 break;
410 }
411 case CE_ProgressBarLabel: {
412 painter->save();
413 const QStyleOptionProgressBar *bar =
414 qstyleoption_cast<const QStyleOptionProgressBar *>(option);
415
416 QRect rect = bar->rect;
417 QRect leftRect;
418
419 int progressIndicatorPos = int((double(bar->progress) /
420 double(bar->maximum - bar->minimum)) *
421 bar->rect.width());
422
423 QFont font;
424 font.setBold(true);
427
428 if (progressIndicatorPos >= 0 &&
429 progressIndicatorPos <= rect.width()) {
430 leftRect = QRect(bar->rect.topLeft(),
431 QPoint(progressIndicatorPos,
432 bar->rect.bottom()));
433 } else if (progressIndicatorPos > rect.width()) {
435 } else {
437 }
438
440 textRect.moveCenter(option->rect.center());
443 if (!leftRect.isNull()) {
448 }
449
450 painter->restore();
451 break;
452 }
453 case CE_MenuBarEmptyArea: {
454 QRect emptyArea = option->rect.adjusted(0, 0, -1, -1);
455 QLinearGradient gradient(emptyArea.topLeft(), emptyArea.bottomLeft()
456 - QPoint(0, 1));
457 gradient.setColorAt(0.0, option->palette.color(QPalette::Base));
458 gradient.setColorAt(1.0, QColor(223, 223, 223));
459
460 painter->setPen(QColor(238, 238, 238));
461 painter->setBrush(gradient);
462 painter->drawRect(emptyArea.adjusted(0, 0, 0, -1));
463 break;
464 }
465 case CE_MenuBarItem: {
466 if (!(option->state & State_Sunken)) {
467 QLinearGradient gradient(option->rect.topLeft(),
468 option->rect.bottomLeft());
469 gradient.setColorAt(0.0, Qt::white);
470 gradient.setColorAt(1.0, QColor(223, 223, 223));
471
473 painter->setBrush(gradient);
474 } else {
475 painter->setBrush(option->palette.color(QPalette::Light));
476 }
477
478 painter->drawRect(option->rect);
479 if (option->state & State_Sunken) {
480 painter->setPen(option->palette.color(QPalette::Mid));
481 painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
482 painter->setPen(option->palette.color(QPalette::Base));
484 painter->drawLine(option->rect.bottomRight() + QPoint(0, -1),
485 option->rect.topRight() + QPoint(0, -1));
486 }
488 break;
489 }
490 case CE_MenuItem: {
491 const QStyleOptionMenuItem *menuItem =
492 qstyleoption_cast<const QStyleOptionMenuItem *>(option);
493
494 bool selected = menuItem->state & State_Selected;
495 bool checkable = menuItem->checkType !=
497 bool checked = menuItem->checked;
498
500 QPoint center = menuItem->rect.center();
501
503 painter->drawLine(QPoint(menuItem->rect.left() - 2, center.y()),
504 QPoint(menuItem->rect.right(), center.y()));
506 painter->drawLine(QPoint(menuItem->rect.left() - 2,
507 center.y() + 1),
508 QPoint(menuItem->rect.right(),
509 center.y() + 1));
510
511 break;
512 }
513
514 if (selected) {
517 painter->drawRect(menuItem->rect);
519 painter->drawLine(menuItem->rect.topLeft(),
520 menuItem->rect.topRight());
522 painter->drawLine(menuItem->rect.bottomLeft(),
523 menuItem->rect.bottomRight());
524 }
525
526 if (checkable) {
527 QRect checkRect(option->rect.left() + 5,
528 option->rect.center().y() - 5, 10, 10);
531 button.rect = checkRect;
532 button.state = menuItem->state;
533 if (button.state & State_Sunken)
534 button.state ^= State_Sunken;
535 if (checked)
536 button.state |= State_On;
537 button.palette = menuItem->palette;
538 drawPrimitive(PE_IndicatorRadioButton, &button, painter,
539 widget);
540 } else {
541 QBrush buttonBrush = gradientBrush(option->rect);
542 painter->setBrush(buttonBrush);
543 painter->setPen(option->palette.color(QPalette::Mid));
544
545 painter->drawRect(checkRect);
546
547 if (checked) {
548 QImage image(":/images/checkboxchecked.png");
549 painter->drawImage(QPoint(option->rect.left() + 5,
550 option->rect.center().y() - 8), image);
551 }
552 }
553 }
554
555 bool dis = !(menuItem->state & State_Enabled);
556 bool act = menuItem->state & State_Selected;
557 const QStyleOption *opt = option;
558 const QStyleOptionMenuItem *menuitem = menuItem;
559 int checkcol = qMax(menuitem->maxIconWidth, 20);
560 if (menuItem->icon.isNull())
561 checkcol = 0;
562
563 QPainter *p = painter;
564 QRect vCheckRect = visualRect(opt->direction, menuitem->rect,
565 QRect(menuitem->rect.x(),
566 menuitem->rect.y(),
567 checkcol, menuitem->rect.height()));
568 if (!menuItem->icon.isNull()) {
570 if (act && !dis)
573 if (checked)
574 pixmap = menuItem->icon.pixmap(
575 pixelMetric(PM_SmallIconSize), mode, QIcon::On);
576 else
577 pixmap = menuItem->icon.pixmap(
578 pixelMetric(PM_SmallIconSize), mode);
579 int pixw = pixmap.width();
580 int pixh = pixmap.height();
581
582 int adjustedIcon = checkable ? 15 : 0;
583 QRect pmr(0, 0, pixw, pixh);
584 pmr.moveCenter(vCheckRect.center());
585 painter->setPen(menuItem->palette.text().color());
586 if (checkable && checked)
587 painter->drawPixmap(QPoint(pmr.left() +
588 adjustedIcon, pmr.top() + 1), pixmap);
589 else
590 painter->drawPixmap(pmr.topLeft() +
591 QPoint(adjustedIcon, 0), pixmap);
592 }
593
594 if (selected) {
596 } else {
597 painter->setPen(menuItem->palette.text().color());
598 }
599 int x, y, w, h;
600 menuitem->rect.getRect(&x, &y, &w, &h);
601 int tab = menuitem->tabWidth;
602 QColor discol;
603 if (dis) {
604 discol = menuitem->palette.text().color();
605 p->setPen(discol);
606 }
607 int xm = windowsItemFrame + checkcol + windowsItemHMargin;
608 int xpos = menuitem->rect.x() + xm;
610 if (!menuItem->icon.isNull())
611 textRect.setRect(xpos, y + windowsItemVMargin, w - xm -
612 windowsRightBorder - tab + 1, h - 2 * windowsItemVMargin);
613 else
614 textRect.setRect(menuItem->rect.left() + 9,
616 w - xm - windowsRightBorder - tab,
617 h - 2 * windowsItemVMargin);
618
619 if (checkable)
620 textRect.adjust(10, 0, 10, 0);
621
622 QRect vTextRect = visualRect(opt->direction, menuitem->rect,
623 textRect);
624 QString s = menuitem->text;
625 if (!s.isEmpty()) {
626 qsizetype t = s.indexOf(u'\t');
627 int text_flags = Qt::AlignVCenter | Qt::TextShowMnemonic |
629 if (!styleHint(SH_UnderlineShortcut, menuitem, widget))
630 text_flags |= Qt::TextHideMnemonic;
631 text_flags |= Qt::AlignLeft;
632 if (t >= 0) {
633 QRect vShortcutRect = visualRect(opt->direction,
634 menuitem->rect,
636 QPoint(menuitem->rect.right(), textRect.bottom())));
637 if (dis && !act) {
638 p->setPen(menuitem->palette.light().color());
639 p->drawText(vShortcutRect.adjusted(1, 1, 1, 1),
640 text_flags,
641 s.mid(t + 1));
642 p->setPen(discol);
643 }
644 p->drawText(vShortcutRect, text_flags, s.mid(t + 1));
645 s = s.left(t);
646 }
647 QFont font = menuitem->font;
648 if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem)
649 font.setBold(true);
650 p->setFont(font);
651 if (dis && !act) {
652 p->setPen(menuitem->palette.light().color());
653 p->drawText(vTextRect.adjusted(1,1,1,1), text_flags,
654 s.left(t));
655 p->setPen(discol);
656 }
657 p->drawText(vTextRect, text_flags, s.left(t));
658 }
659
661 QPoint center = menuItem->rect.center();
662 QPoint drawStart(menuItem->rect.right() - 6, center.y() + 4);
663
664 QPainterPath arrow;
665 arrow.moveTo(drawStart);
666 arrow.lineTo(drawStart + QPoint(0, -8));
667 arrow.lineTo(drawStart + QPoint(4, -5));
668 arrow.lineTo(drawStart + QPoint(4, -4));
669 arrow.lineTo(drawStart + QPoint(0, 0));
670
671 painter->save();
674 painter->drawPath(arrow);
675 painter->restore();
676 }
677
678 break;
679 }
680 case CE_MenuVMargin: {
681 break;
682 }
683 case CE_MenuHMargin: {
684 break;
685 }
686 case CE_Splitter: {
687 drawSplitter(option, painter, option->state & State_Horizontal);
688 break;
689 }
690 case CE_ScrollBarAddPage: {
691 case CE_ScrollBarSubPage:
692 const QStyleOptionSlider *scrollBar =
693 qstyleoption_cast<const QStyleOptionSlider *>(option);
694 QRect myRect;
696 myRect = QRect(option->rect.topLeft(),
697 option->rect.bottomRight()).adjusted(0, 0, 1, -1);
698 } else {
699 myRect = option->rect;
700 }
701
703 painter->setBrush(option->palette.color(QPalette::Background));
704 painter->drawRect(myRect);
705
708 painter->drawRect(myRect.adjusted(0, 0, -1, 0));
710 painter->drawLine(myRect.bottomLeft() + QPoint(1, 0),
711 myRect.topLeft() + QPoint(1, 1));
712 painter->drawLine(myRect.topLeft() + QPoint(1, 1),
713 myRect.topRight() + QPoint(-1, 1));
714 break;
715 }
716 case CE_ScrollBarSubLine: {
717 const QStyleOptionSlider *scrollBar =
718 qstyleoption_cast<const QStyleOptionSlider *>(option);
719 int scrollBarExtent = pixelMetric(PM_ScrollBarExtent);
720 QRect scrollBarSubLine = option->rect;
721
722 QRect button1;
723 QRect button2;
724
726 button1.setRect(scrollBarSubLine.left(), scrollBarSubLine.top(),
727 16, scrollBarExtent);
728 button2.setRect(scrollBarSubLine.right() - 15,
729 scrollBarSubLine.top(), 16, scrollBarExtent);
730 } else {
731 button1.setRect(scrollBarSubLine.left(), scrollBarSubLine.top(),
732 scrollBarExtent, 16);
733 button2.setRect(scrollBarSubLine.left(),
734 scrollBarSubLine.bottom() - 15, scrollBarExtent, 16);
735 }
736
737 painter->fillRect(button2, Qt::blue);
738
739 drawScrollBarArrow(button1, painter, scrollBar);
740 drawScrollBarArrow(button2, painter, scrollBar);
741 break;
742 }
743 case CE_ScrollBarAddLine: {
744 const QStyleOptionSlider *scrollBar =
745 qstyleoption_cast<const QStyleOptionSlider *>(option);
746 QRect button(option->rect.left(), option->rect.top(), 16, 16);
747 drawScrollBarArrow(button, painter, scrollBar, true);
748 break;
749 }
750 case CE_ScrollBarSlider: {
751 const QStyleOptionSlider *scrollBar =
752 qstyleoption_cast<const QStyleOptionSlider *>(option);
753
755 painter->drawRect(scrollBar->rect.adjusted(-1, 0, -3, -1));
756
757 QPoint g1, g2;
759 g1 = option->rect.topLeft();
760 g2 = option->rect.bottomLeft();
761 } else {
762 g1 = option->rect.topLeft();
763 g2 = option->rect.topRight();
764 }
765
766 if (scrollBar->state & State_Enabled) {
767 QLinearGradient gradient(g1, g2);
768 gradient.setColorAt(1.0, QColor(188, 210, 230));
769 gradient.setColorAt(0.3, Qt::white);
770 gradient.setColorAt(0.0, QColor(223, 233, 243));
771 painter->setBrush(gradient);
772 } else {
775 }
776 painter->drawRect(scrollBar->rect.adjusted(0, 0, -1, -1));
777
778 int sliderLength = option->rect.height();
779 int drawPos = scrollBar->orientation == Qt::Vertical ?
780 (sliderLength / 2) + 1 : 1 - ((option->rect.width() / 2));
781
782 QPoint origin;
784 origin = option->rect.bottomLeft();
785 else
786 origin = option->rect.topLeft();
787
789 painter->drawLine(origin + adjustScrollHandlePoint(
791 QPoint(4, -drawPos)),
792 origin + adjustScrollHandlePoint(
794 QPoint(13, -drawPos)));
795 painter->drawLine(origin + adjustScrollHandlePoint(
797 QPoint(4, 2 - drawPos)),
798 origin + adjustScrollHandlePoint(
800 QPoint(13, 2 - drawPos)));
801 painter->drawLine(origin + adjustScrollHandlePoint(
803 QPoint(4, 4 - drawPos)),
804 origin + adjustScrollHandlePoint(
806 QPoint(13, 4 - drawPos)));
807
808 painter->setPen(option->palette.color(QPalette::Midlight));
809 painter->drawLine(origin + adjustScrollHandlePoint(
811 QPoint(3, -(drawPos + 1))),
812 origin + adjustScrollHandlePoint(
814 QPoint(12, -(drawPos + 1))));
815 painter->drawLine(origin + adjustScrollHandlePoint(
817 QPoint(3, 1 - drawPos)),
818 origin + adjustScrollHandlePoint(
820 QPoint(12, 1 - drawPos)));
821 painter->drawLine(origin + adjustScrollHandlePoint(
823 QPoint(3, 3 - drawPos)),
824 origin + adjustScrollHandlePoint(
826 QPoint(12, 3 - drawPos)));
827
828 break;
829 }
830 case CE_TabBarTabLabel: {
831 QStyleOptionTab copy =
832 *qstyleoption_cast<const QStyleOptionTab *>(option);
833 if (copy.state & State_HasFocus)
834 copy.state ^= State_HasFocus;
836 QCommonStyle::drawControl(CE_TabBarTabLabel, &copy, painter,
837 widget);
838 break;
839 }
840 case CE_TabBarTabShape: {
841 const QStyleOptionTab *tab =
842 qstyleoption_cast<const QStyleOptionTab *>(option);
843 QRect myRect = option->rect;
844 QPoint bottomLeft, bottomRight, topLeft, topRight;
845
846 if ((tab->position == QStyleOptionTab::Beginning) ||
847 (tab->position == QStyleOptionTab::OnlyOneTab)) {
848 if (tab->shape == QTabBar::RoundedSouth ||
849 tab->shape == QTabBar::RoundedNorth) {
850 myRect = myRect.adjusted(2, 0, 0, 0);
851 } else {
852 myRect = myRect.adjusted(0, 2, 0, 0);
853 }
854 }
855
856 switch (tab->shape) {
858 topLeft = myRect.topLeft();
859 topRight = myRect.topRight();
860 bottomLeft = myRect.bottomLeft();
861 bottomRight = myRect.bottomRight();
862 break;
864 topLeft = myRect.bottomLeft();
865 topRight = myRect.bottomRight();
866 bottomLeft = myRect.topLeft();
867 bottomRight = myRect.topRight();
868 break;
870 topLeft = myRect.topLeft();
871 topRight = myRect.bottomLeft();
872 bottomLeft = myRect.topRight();
873 bottomRight = myRect.bottomRight();
874 break;
876 topLeft = myRect.topRight();
877 topRight = myRect.bottomRight();
878 bottomLeft = myRect.topLeft();
879 bottomRight = myRect.bottomLeft();
880 break;
881 default:
882 ;
883 }
884
885 QPainterPath outerPath;
886 outerPath.moveTo(bottomLeft + adjustTabPoint(QPoint(0, -2),
887 tab->shape));
888 outerPath.lineTo(bottomLeft + adjustTabPoint(QPoint(0, -14),
889 tab->shape));
890 outerPath.lineTo(topLeft + adjustTabPoint(QPoint(6 , 0),
891 tab->shape));
892 outerPath.lineTo(topRight + adjustTabPoint(QPoint(0, 0),
893 tab->shape));
894 outerPath.lineTo(bottomRight + adjustTabPoint(QPoint(0, -2),
895 tab->shape));
896
897 if (tab->state & State_Selected ||
898 tab->position == QStyleOptionTab::OnlyOneTab) {
899 QPainterPath innerPath;
900 innerPath.moveTo(topLeft + adjustTabPoint(QPoint(6, 2),
901 tab->shape));
902 innerPath.lineTo(topRight + adjustTabPoint(QPoint(-1, 2),
903 tab->shape));
904 innerPath.lineTo(bottomRight + adjustTabPoint(QPoint(-1 , -2),
905 tab->shape));
906 innerPath.lineTo(bottomLeft + adjustTabPoint(QPoint(2 , -2),
907 tab->shape));
908 innerPath.lineTo(bottomLeft + adjustTabPoint(QPoint(2 , -14),
909 tab->shape));
910 innerPath.lineTo(topLeft + adjustTabPoint(QPoint(6, 2),
911 tab->shape));
912
913 QPainterPath whitePath;
914 whitePath.moveTo(bottomLeft + adjustTabPoint(QPoint(1, -2),
915 tab->shape));
916 whitePath.lineTo(bottomLeft + adjustTabPoint(QPoint(1, -14),
917 tab->shape));
918 whitePath.lineTo(topLeft + adjustTabPoint(QPoint(6, 1),
919 tab->shape));
920 whitePath.lineTo(topRight + adjustTabPoint(QPoint(-1, 1),
921 tab->shape));
922
923 painter->setPen(tab->palette.color(QPalette::Midlight));
924 painter->setBrush(QColor(200, 221, 242));
925 painter->drawPath(outerPath);
926 painter->setPen(QColor(200, 221, 242));
927 painter->drawRect(QRect(bottomLeft + adjustTabPoint(
928 QPoint(2, -3), tab->shape),
929 bottomRight + adjustTabPoint(
930 QPoint(-2, 0), tab->shape)));
931 painter->setPen(tab->palette.color(QPalette::Base));
933 painter->drawPath(whitePath);
934
935 if (option->state & State_HasFocus) {
936 painter->setPen(option->palette.color(QPalette::Mid));
937 painter->drawPath(innerPath);
938 }
939 } else {
940 painter->setPen(tab->palette.color(QPalette::Mid));
941 painter->drawPath(outerPath);
942 }
943 break;
944 }
945 case CE_PushButtonLabel:
946 painter->save();
947
948 if (const QStyleOptionButton *button =
949 qstyleoption_cast<const QStyleOptionButton *>(option)) {
950 QRect ir = button->rect;
952 if (!styleHint(SH_UnderlineShortcut, button, widget))
954
955 if (!button->icon.isNull()) {
956 QPoint point;
957
958 QIcon::Mode mode = button->state & State_Enabled ? QIcon::Normal
960 if (mode == QIcon::Normal && button->state & State_HasFocus)
963 if (button->state & State_On)
965
967 state);
968 int w = pixmap.width();
969 int h = pixmap.height();
970
971 if (!button->text.isEmpty())
973
974 point = QPoint(ir.x() + ir.width() / 2 - w / 2,
975 ir.y() + ir.height() / 2 - h / 2);
976
977 if (button->direction == Qt::RightToLeft)
978 point.rx() += pixmap.width();
979
980 painter->drawPixmap(visualPos(button->direction, button->rect,
981 point), pixmap);
982
983 if (button->direction == Qt::RightToLeft)
984 ir.translate(-point.x() - 2, 0);
985 else
986 ir.translate(point.x() + pixmap.width(), 0);
987
988 if (!button->text.isEmpty())
989 tf |= Qt::AlignLeft;
990
991 } else {
992 tf |= Qt::AlignHCenter;
993 }
994
995 if (button->fontMetrics.height() > 14)
996 ir.translate(0, 1);
997
998 drawItemText(painter, ir, tf, button->palette, (button->state &
999 State_Enabled),
1001 }
1002
1003 painter->restore();
1004 break;
1005
1006 default:
1008 }
1009 painter->restore();
1010}
1011
1012inline QPoint JavaStyle::adjustTabPoint(const QPoint &point,
1013 QTabBar::Shape shape) const
1014{
1015 QPoint rPoint;
1016
1017 switch (shape) {
1019 rPoint = QPoint(point.y(), point.x());
1020 break;
1022 rPoint = QPoint(point.x(), point.y() * -1);
1023 break;
1025 rPoint = QPoint(point.y() * -1, point.x());
1026 break;
1027 default:
1028 rPoint = point;
1029 }
1030 return rPoint;
1031}
1032
1033QRect JavaStyle::subControlRect(ComplexControl control,
1035 SubControl subControl,
1036 const QWidget *widget) const
1037{
1038 QRect rect = QCommonStyle::subControlRect(control, option, subControl,
1039 widget);
1040
1041 switch (control) {
1042 case CC_TitleBar: {
1043 const QStyleOptionTitleBar *bar =
1044 qstyleoption_cast<const QStyleOptionTitleBar *>(option);
1045
1046 switch (subControl) {
1047 case SC_TitleBarMinButton: {
1048 rect = QRect(bar->rect.topRight() + QPoint(-68, 2),
1049 QSize(15, 15));
1050 break;
1051 }
1052 case SC_TitleBarMaxButton: {
1053 rect = QRect(bar->rect.topRight() + QPoint(-43, 3),
1054 QSize(15, 15));
1055 break;
1056 }
1057 case SC_TitleBarCloseButton: {
1058 rect = QRect(bar->rect.topRight() + QPoint(-18, 3),
1059 QSize(15, 15));
1060 break;
1061 }
1062 case SC_TitleBarLabel: {
1063 QRect labelRect = bar->fontMetrics.boundingRect(bar->text);
1064 rect = labelRect;
1065 rect.translate(bar->rect.left() + 30, 0);
1066 rect.moveTop(bar->rect.top());
1067 rect.adjust(0, 2, 2, 2);
1068 break;
1069 }
1070 case SC_TitleBarSysMenu: {
1071 rect = QRect(bar->rect.topLeft() + QPoint(6, 3),
1072 QSize(16, 16));
1073 break;
1074 }
1075 default:
1076 ;
1077 }
1078 break;
1079 }
1080 case CC_GroupBox: {
1081 const QStyleOptionGroupBox *box =
1082 qstyleoption_cast<const QStyleOptionGroupBox *>(option);
1083 bool hasCheckbox = box->subControls & SC_GroupBoxCheckBox;
1084 int checkAdjust = 13;
1085
1086 QRect textRect = box->fontMetrics.boundingRect(box->text);
1087
1088 switch (subControl) {
1089 case SC_GroupBoxFrame: {
1090 rect = box->rect;
1091 break;
1092 }
1093 case SC_GroupBoxCheckBox: {
1094 if (hasCheckbox) {
1095 rect = QRect(box->rect.topLeft() + QPoint(7, 4 +
1096 (textRect.height() / 2 - checkAdjust / 2)),
1097 QSize(checkAdjust, checkAdjust));
1098 }
1099 else {
1100 rect = QRect();
1101 }
1102 break;
1103 }
1104 case SC_GroupBoxLabel: {
1105 rect = QRect(box->rect.topLeft() + QPoint(7 + (hasCheckbox ?
1106 checkAdjust + 2 : 0), 4), textRect.size());
1107 break;
1108 }
1109 case SC_GroupBoxContents: {
1110 rect = box->rect.adjusted(10, 10 + textRect.height(), -10,
1111 -10);
1112 break;
1113 }
1114 default:
1115 ;
1116 }
1117 break;
1118 }
1119 case CC_SpinBox: {
1120 const QStyleOptionSpinBox *spinBox =
1121 qstyleoption_cast<const QStyleOptionSpinBox *>(option);
1122 int spinnerWidth = 16;
1123 QRect myRect = spinBox->rect;
1124 QPoint center = myRect.center();
1125 int frameWidth = pixelMetric(PM_SpinBoxFrameWidth, spinBox, widget);
1126
1127 switch (subControl) {
1128 case SC_SpinBoxUp: {
1129 rect = QRect(myRect.topRight() + QPoint(-16, 0),
1130 QSize(16, center.y() - myRect.topRight().y()));
1131 break;
1132 }
1133 case SC_SpinBoxDown: {
1134 rect = QRect(QPoint(myRect.bottomRight().x() - 16,
1135 center.y() + 1),
1136 QSize(16, myRect.bottomRight().y() -
1137 center.y() - 1));
1138 break;
1139 }
1140 case SC_SpinBoxFrame: {
1141 rect = QRect(myRect.topLeft(), myRect.bottomRight() +
1142 QPoint(-16, 0));
1143 break;
1144 }
1145 case SC_SpinBoxEditField: {
1146 rect = QRect(myRect.topLeft() + QPoint(2, 2),
1147 myRect.bottomRight() + QPoint(-15 - frameWidth, -2));
1148 break;
1149 }
1150 default:
1151 ;
1152 }
1153 break;
1154 }
1155 case CC_ToolButton: {
1157 qstyleoption_cast<const QStyleOptionToolButton *>(option);
1158
1159 switch (subControl) {
1160 case SC_ToolButton: {
1161 rect = option->rect.adjusted(1, 1, -1, -1);
1162 break;
1163 }
1164 case SC_ToolButtonMenu: {
1165 rect = QRect(option->rect.bottomRight() +
1166 QPoint(-11, -11), QSize(10, 10));
1167 break;
1168 }
1169 }
1170 break;
1171 }
1172 case CC_ComboBox: {
1173 const QStyleOptionComboBox *combo =
1174 qstyleoption_cast<const QStyleOptionComboBox *>(option);
1175
1176 bool reverse = combo->direction == Qt::RightToLeft;
1177
1178 switch (subControl) {
1179 case SC_ComboBoxFrame:
1180 rect = combo->rect;
1181 break;
1182 case SC_ComboBoxArrow:
1183 if (reverse) {
1184 rect = QRect(combo->rect.topLeft(),
1185 combo->rect.bottomLeft() + QPoint(17, 0));
1186 } else {
1187 rect = QRect(combo->rect.topRight() + QPoint(-17, 0),
1188 combo->rect.bottomRight());
1189 }
1190 break;
1191 case SC_ComboBoxEditField:
1192 if (reverse) {
1193 rect = QRect(combo->rect.topLeft() + QPoint(19, 2),
1194 combo->rect.bottomRight() + QPoint(-2, 2));
1195 } else {
1196 rect = QRect(combo->rect.topLeft() + QPoint(2, 2),
1197 combo->rect.bottomRight() + QPoint(-19, -2));
1198 }
1199 break;
1200 case SC_ComboBoxListBoxPopup:
1201 rect = combo->rect;
1202 break;
1203 }
1204 break;
1205 }
1206 case CC_ScrollBar: {
1207 const QStyleOptionSlider *scrollBar =
1208 qstyleoption_cast<const QStyleOptionSlider *>(option);
1209 int scrollBarExtent = pixelMetric(PM_ScrollBarExtent, scrollBar,
1210 widget);
1211 int sliderMaxLength = ((scrollBar->orientation == Qt::Horizontal) ?
1212 scrollBar->rect.width() :
1213 scrollBar->rect.height()) - (16 * 3);
1214 int sliderMinLength = pixelMetric(PM_ScrollBarSliderMin, scrollBar,
1215 widget);
1216 int sliderLength;
1217
1219 uint valueRange = scrollBar->maximum - scrollBar->minimum;
1220 sliderLength = (scrollBar->pageStep * sliderMaxLength) /
1221 (valueRange + scrollBar->pageStep);
1222
1223 if (sliderLength < sliderMinLength || valueRange > INT_MAX / 2)
1224 sliderLength = sliderMinLength;
1225 if (sliderLength > sliderMaxLength)
1226 sliderLength = sliderMaxLength;
1227 } else {
1228 sliderLength = sliderMaxLength;
1229 }
1230 int sliderStart = 16 + sliderPositionFromValue(scrollBar->minimum,
1233 sliderMaxLength - sliderLength,
1234 scrollBar->upsideDown);
1235 QRect scrollBarRect = scrollBar->rect;
1236
1237 switch (subControl) {
1238 case SC_ScrollBarSubLine:
1240 rect.setRect(scrollBarRect.left(), scrollBarRect.top(),
1241 scrollBarRect.width() - 16, scrollBarExtent);
1242 } else {
1243 rect.setRect(scrollBarRect.left(), scrollBarRect.top(),
1244 scrollBarExtent, scrollBarRect.height() - 16);
1245 }
1246 break;
1247 case SC_ScrollBarAddLine:
1249 rect.setRect(scrollBarRect.right() - 15,
1250 scrollBarRect.top(), 16, scrollBarExtent);
1251 } else {
1252 rect.setRect(scrollBarRect.left(), scrollBarRect.bottom()
1253 - 15, scrollBarExtent, 16);
1254 }
1255 break;
1256 case SC_ScrollBarSubPage:
1258 rect.setRect(scrollBarRect.left() + 16, scrollBarRect.top(),
1259 sliderStart - (scrollBarRect.left() + 16),
1260 scrollBarExtent);
1261 } else {
1262 rect.setRect(scrollBarRect.left(), scrollBarRect.top() + 16,
1263 scrollBarExtent,
1264 sliderStart - (scrollBarRect.left() + 16));
1265 }
1266 break;
1267 case SC_ScrollBarAddPage:
1269 rect.setRect(sliderStart + sliderLength, 0,
1270 sliderMaxLength - sliderStart -
1271 sliderLength + 16, scrollBarExtent);
1272 else
1273 rect.setRect(0, sliderStart + sliderLength,
1274 scrollBarExtent, sliderMaxLength -
1275 sliderStart - sliderLength + 16);
1276 break;
1277 case SC_ScrollBarGroove:
1279 rect = scrollBarRect.adjusted(16, 0, -32, 0);
1280 } else {
1281 rect = scrollBarRect.adjusted(0, 16, 0, -32);
1282 }
1283 break;
1284 case SC_ScrollBarSlider:
1286 rect.setRect(sliderStart, 0, sliderLength,
1287 scrollBarExtent);
1288 } else {
1289 rect.setRect(0, sliderStart, scrollBarExtent,
1290 sliderLength);
1291 }
1292 break;
1293 default:
1294 return QCommonStyle::subControlRect(control, option,
1295 subControl, widget);
1296 }
1297 break;
1298 }
1299 case CC_Slider: {
1300 const QStyleOptionSlider *slider =
1301 qstyleoption_cast<const QStyleOptionSlider *>(option);
1302 rect = slider->rect;
1303 int tickSize = pixelMetric(PM_SliderTickmarkOffset, option, widget);
1304 int handleSize = pixelMetric(PM_SliderControlThickness, option,
1305 widget);
1306
1307 int dist = slider->orientation == Qt::Vertical ? slider->rect.height() :
1308 slider->rect.width();
1309 int pos = QStyle::sliderPositionFromValue(slider->minimum,
1310 slider->maximum, slider->sliderValue, dist - handleSize);
1311
1312 switch (subControl) {
1313 case SC_SliderGroove: {
1314 QPoint center = rect.center();
1315
1316 if (slider->orientation == Qt::Horizontal) {
1317 rect.setHeight(handleSize);
1318 if (slider->tickPosition == QSlider::TicksBelow) {
1319 center.ry() -= tickSize;
1320 }
1321 } else {
1322 rect.adjust(0, 0, 0, 0);
1323 rect.setWidth(handleSize);
1324 if (slider->tickPosition == QSlider::TicksBelow) {
1325 center.rx() -= tickSize;
1326 }
1327 }
1328 rect.moveCenter(center);
1329 break;
1330 }
1331 case SC_SliderHandle: {
1332 QPoint center = rect.center();
1333
1334 if (slider->orientation == Qt::Horizontal) {
1335 rect.setHeight(handleSize);
1336 if (slider->tickPosition == QSlider::TicksBelow) {
1337 center.ry() -= tickSize;
1338 }
1339
1340 rect.moveCenter(center);
1341
1342 if (slider->upsideDown)
1343 rect.setLeft(slider->rect.right() -
1344 pos - (handleSize - 1));
1345 else
1346 rect.setLeft(pos);
1347
1348 rect.setWidth(handleSize - 1);
1349 } else {
1350 rect.setWidth(handleSize);
1351 if (slider->tickPosition == QSlider::TicksBelow) {
1352 center.rx() -= tickSize;
1353 }
1354
1355 rect.moveCenter(center);
1356
1357 if (slider->upsideDown)
1358 rect.setTop(slider->rect.bottom() -
1359 ((pos + handleSize) - 2));
1360 else
1361 rect.setTop(slider->rect.top() + pos);
1362
1363 rect.setHeight(handleSize);
1364 }
1365 break;
1366 }
1367 case SC_SliderTickmarks: {
1368 QPoint center = slider->rect.center();
1369
1370 if (slider->tickPosition & QSlider::TicksBelow) {
1371 if (slider->orientation == Qt::Horizontal) {
1372 rect.setHeight(tickSize);
1373 center.ry() += tickSize / 2;
1374 rect.adjust(6, 0, -10, 0);
1375 } else {
1376 rect.setWidth(tickSize);
1377 center.rx() += tickSize / 2;
1378 rect.adjust(0, 6, 0, -10);
1379 }
1380 } else {
1381 rect = QRect();
1382 }
1383 rect.moveCenter(center);
1384 break;
1385 }
1386 default:
1387 ;
1388 }
1389 break;
1390 }
1391 default:
1392 return QCommonStyle::subControlRect(control, option, subControl,
1393 widget);
1394 }
1395 return rect;
1396}
1397
1398static const char * const sliderHandleImage[] = {
1399 "15 16 7 1",
1400 " c None",
1401 "+ c #FFFFFF",
1402 "@ c #FFFFFF",
1403 "$ c #FFFFFF",
1404 "( c #E5EDF5",
1405 ") c #F2F6FA",
1406 "[ c #FFFFFF",
1407 " +++++++++++++ ",
1408 "+@@@@@@@@@@@@@+",
1409 "+@(((((((((((@+",
1410 "+@(((((((((((@+",
1411 "+@)))))))))))@+",
1412 "+@[[[[[[[[[[[@+",
1413 "+@[[[[[[[[[[[@+",
1414 "+@)))))))))))@+",
1415 "+@)))))))))))@+",
1416 " +@)))))))))@+ ",
1417 " +@(((((((@+ ",
1418 " +@(((((@+ ",
1419 " +@(((@+ ",
1420 " +@(@+ ",
1421 " +@+ ",
1422 " + "};
1423
1424
1425void JavaStyle::drawComplexControl(ComplexControl control,
1428 const QWidget *widget) const
1429{
1430 painter->save();
1431
1432 switch (control) {
1433 case CC_TitleBar: {
1434 const QStyleOptionTitleBar *bar =
1435 qstyleoption_cast<const QStyleOptionTitleBar *>(option);
1436
1437 bool sunken = bar->state & State_Sunken;
1438
1439 QLinearGradient gradient(bar->rect.bottomLeft(),
1440 bar->rect.topLeft());
1441 gradient.setColorAt(0.0, QColor(191, 212, 231));
1442 gradient.setColorAt(0.7, Qt::white);
1443 gradient.setColorAt(1.0, QColor(221, 232, 243));
1444
1446 if (bar->titleBarState & State_Active) {
1447 painter->setBrush(gradient);
1448 }
1449 else
1451 QPalette::Background));
1452
1453 painter->drawRect(bar->rect.adjusted(0, 0, -1, -1));
1454
1455 painter->setBrush(QColor(233, 233, 233));
1456 painter->drawRect(QRect(bar->rect.bottomLeft() + QPoint(0, 1),
1457 bar->rect.bottomRight() + QPoint(0, 2)));
1458
1459 QRect minButtonRect = subControlRect(control, bar,
1460 SC_TitleBarMinButton);
1461 QRect maxButtonRect = subControlRect(control, bar,
1462 SC_TitleBarMaxButton);
1463 QRect closeButtonRect = subControlRect(control, bar,
1464 SC_TitleBarCloseButton);
1465 QRect systemButtonRect = subControlRect(control, bar,
1466 SC_TitleBarSysMenu);
1467 QRect labelRect = subControlRect(control, bar, SC_TitleBarLabel);
1468 QRect gripRect = QRect(QPoint(labelRect.right() + 5, bar->rect.top() + 5),
1469 QPoint(minButtonRect.left() - 5,
1470 bar->rect.bottom() - 4));
1471
1472 QColor textColor = option->palette.color(QPalette::Text);
1473 painter->setPen(textColor);
1475
1476 drawItemText(painter, labelRect, Qt::TextShowMnemonic |
1478 bar->palette, bar->state & State_Enabled, bar->text,
1479 textColor.isValid() ? QPalette::NoRole :
1480 QPalette::WindowText);
1481
1482 for (int i = 0; i < gripRect.width(); ++i) {
1484 : Qt::white);
1485
1486 for (int j = 0; j < 4; ++j) {
1487 painter->drawPoint(i + gripRect.left(),
1488 gripRect.top() - 2 + i % 4 + 4 * j);
1489 }
1490 }
1491
1492 QPixmap maximizePixmap(":/images/internalmaximize.png");
1493 QPixmap minimizePixmap(":/images/internalminimize.png");
1494 QPixmap closePixmap(":/images/internalclose.png");
1495 QPixmap internalPixmap(":/images/internalsystem.png");
1496 QPixmap internalCloseDownPixmap(":/images/internalclosedown.png");
1497 QPixmap minimizeDownPixmap(":/images/internalminimizedown.png");
1498 QPixmap maximizeDownPixmap(":/images/internalmaximizedown.png");
1499
1500 if (bar->activeSubControls & SC_TitleBarCloseButton &&
1501 bar->state & State_Sunken)
1502 painter->drawPixmap(closeButtonRect.topLeft(),
1503 internalCloseDownPixmap);
1504 else
1505 painter->drawPixmap(closeButtonRect.topLeft(), closePixmap);
1506
1507 if (bar->activeSubControls & SC_TitleBarMinButton &&
1508 bar->state & State_Sunken)
1509 painter->drawPixmap(minButtonRect.topLeft(),
1510 minimizeDownPixmap);
1511 else
1512 painter->drawPixmap(minButtonRect.topLeft(), minimizePixmap);
1513
1514 if (bar->activeSubControls & SC_TitleBarMaxButton &&
1515 bar->state & State_Sunken)
1516 painter->drawPixmap(maxButtonRect.topLeft(),
1517 maximizeDownPixmap);
1518 else
1519 painter->drawPixmap(maxButtonRect.topLeft(), maximizePixmap);
1520
1521 painter->drawPixmap(systemButtonRect.topLeft(), internalPixmap);
1522
1523 break;
1524 }
1525 case CC_GroupBox: {
1526 const QStyleOptionGroupBox *box =
1527 qstyleoption_cast<const QStyleOptionGroupBox *>(option);
1528
1529 QRect frameRect = subControlRect(control, box, SC_GroupBoxFrame);
1530 QRect labelRect = subControlRect(control, box, SC_GroupBoxLabel);
1531 QRect contentsRect = subControlRect(control, box,
1532 SC_GroupBoxContents);
1533 QRect checkerRect = subControlRect(control, box,
1534 SC_GroupBoxCheckBox);
1535
1536 int y = labelRect.center().y();
1537
1538 painter->setPen(box->palette.color(QPalette::Button));
1539 painter->drawRect(frameRect.adjusted(2, y - frameRect.top(), -2,
1540 -2));
1541
1542 painter->setPen(box->palette.color(QPalette::Background));
1543
1544 if (box->subControls & SC_GroupBoxCheckBox) {
1545 painter->drawLine(checkerRect.left() - 1, y,
1546 checkerRect.right() + 2, y);
1547 QStyleOptionButton checker;
1548 checker.QStyleOption::operator=(*box);
1549 checker.rect = checkerRect;
1550 drawPrimitive(PE_IndicatorCheckBox, &checker, painter, widget);
1551 }
1552
1553 if (box->subControls & SC_GroupBoxLabel && !box->text.isEmpty()) {
1554 painter->drawLine(labelRect.left() - 1, y,
1555 labelRect.right() +1, y);
1556
1557 QColor textColor = box->textColor;
1558 if (textColor.isValid())
1559 painter->setPen(textColor);
1560
1561 drawItemText(painter, labelRect, Qt::TextShowMnemonic |
1562 Qt::AlignHCenter | int(box->textAlignment),
1563 box->palette, box->state & State_Enabled,
1564 box->text, textColor.isValid() ? QPalette::NoRole :
1565 QPalette::WindowText);
1566 }
1567 break;
1568 }
1569 case CC_SpinBox: {
1570 const QStyleOptionSpinBox *spinner =
1571 qstyleoption_cast<const QStyleOptionSpinBox *>(option);
1572
1573 QRect frameRect = subControlRect(control, spinner, SC_SpinBoxFrame);
1574 QRect upRect = subControlRect(control, spinner, SC_SpinBoxUp);
1575 QRect downRect = subControlRect(control, spinner, SC_SpinBoxDown);
1576
1578 painter->drawRect(frameRect.adjusted(1, 1, -1, -1));
1579 painter->drawPoint(frameRect.bottomLeft());
1580
1581 painter->setPen(spinner->palette.color(QPalette::Mid));
1582 painter->drawRect(frameRect.adjusted(0, 0, -1, -2));
1583
1584 bool isEnabled = (spinner->state & State_Enabled);
1585 bool hover = isEnabled && (spinner->state & State_MouseOver);
1586 bool sunken = (spinner->state & State_Sunken);
1587 bool upIsActive = (spinner->activeSubControls == SC_SpinBoxUp);
1588 bool downIsActive = (spinner->activeSubControls == SC_SpinBoxDown);
1589 bool stepUpEnabled = spinner->stepEnabled &
1591 bool stepDownEnabled = spinner->stepEnabled &
1593
1594 painter->setBrush(spinner->palette.color(QPalette::Background));
1595
1596 painter->drawRect(upRect);
1597 if (upIsActive && stepUpEnabled) {
1598 if (sunken) {
1599 drawSunkenButtonShadow(painter, upRect,
1600 spinner->palette.color(QPalette::Mid));
1601 } else if (hover) {
1602 drawButtonHoverFrame(painter, upRect,
1603 spinner->palette.color(QPalette::Mid),
1604 spinner->palette.color(QPalette::Button));
1605 }
1606 }
1607
1608 QStyleOptionSpinBox upSpin = *spinner;
1609 upSpin.rect = upRect;
1610 drawPrimitive(PE_IndicatorSpinUp, &upSpin, painter, widget);
1611
1612 painter->drawRect(downRect);
1613 if (downIsActive && stepDownEnabled) {
1614 if (sunken) {
1615 drawSunkenButtonShadow(painter, downRect,
1616 spinner->palette.color(QPalette::Mid));
1617 } else if (hover) {
1618 drawButtonHoverFrame(painter, downRect,
1619 spinner->palette.color(QPalette::Mid),
1620 spinner->palette.color(QPalette::Button));
1621 }
1622 }
1623
1624 QStyleOptionSpinBox downSpin = *spinner;
1625 downSpin.rect = downRect;
1626 drawPrimitive(PE_IndicatorSpinDown, &downSpin, painter, widget);
1627
1628 break;
1629 }
1630 case CC_ToolButton: {
1632 qstyleoption_cast<const QStyleOptionToolButton *>(option);
1633
1635 painter->drawRect(button->rect.adjusted(1, 1, -1, -1));
1636
1637 QStyleOptionToolButton panelOption = *button;
1638 QRect panelRect;
1639 if (!(button->state & State_MouseOver) &&
1640 !(button->state & State_On)) {
1641 painter->setPen(QColor(153, 153, 153));
1642 painter->drawRect(button->rect.adjusted(0, 0, -2, -2));
1643
1644 panelRect = subControlRect(control, option, SC_ToolButton);
1645 panelOption.rect = panelRect;
1646 } else {
1647 panelOption.rect.adjust(0, 0, -1, -1);
1648 }
1649
1650 QRect menuRect = subControlRect(control, option, SC_ToolButtonMenu);
1651
1652 drawPrimitive(PE_PanelButtonTool, &panelOption, painter, widget);
1653
1654 QStyleOptionToolButton menuOption = *button;
1655 menuOption.rect = menuRect;
1656
1658 int fw = 5;
1659
1660 drawControl(CE_ToolButtonLabel, &label, painter, widget);
1661 if (button->subControls & SC_ToolButtonMenu) {
1663 drawPrimitive(PE_IndicatorArrowDown, &menuOption, painter, widget);
1664 }
1665
1666 if (button->state & State_HasFocus) {
1667 QStyleOptionToolButton focusOption = *button;
1668 focusOption.rect = label.rect.adjusted(-1, -1, 1, 1);
1669
1670 drawPrimitive(PE_FrameFocusRect, &focusOption, painter, widget);
1671 }
1672
1673 break;
1674 }
1675 case CC_ComboBox: {
1676 const QStyleOptionComboBox *combo =
1677 qstyleoption_cast<const QStyleOptionComboBox *>(option);
1678
1679 QRect frameRect = subControlRect(control, option, SC_ComboBoxFrame,
1680 widget);
1682
1683 if (option->state & State_HasFocus)
1684 painter->setBrush(option->palette.color(QPalette::Light));
1685 else
1686 painter->setBrush(combo->palette.color(QPalette::Background));
1687
1688 painter->drawRect(frameRect.adjusted(0, 0, -1, -1));
1689
1690 QRect arrowRect = subControlRect(control, option, SC_ComboBoxArrow,
1691 widget);
1694
1695 if (combo->direction == Qt::LeftToRight) {
1696 painter->drawRect(QRect(frameRect.topLeft() + QPoint(1, 1),
1697 arrowRect.bottomLeft() + QPoint(-2, -2)));
1698 } else {
1699 painter->drawRect(QRect(arrowRect.topLeft() + QPoint(1, 1),
1700 frameRect.bottomRight() + QPoint(-2, -2)));
1701 }
1702
1704 button.rect = arrowRect;
1705 button.state = combo->state;
1706 button.palette = combo->palette;
1707
1708 if (button.state & State_On)
1709 button.state ^= State_On;
1710
1711 painter->save();
1712 drawButtonBackground(&button, painter, false);
1713 painter->restore();
1714
1715 QPoint center = arrowRect.center();
1716 QPoint offset = QPoint(arrowRect.bottomLeft().x() + 1,
1717 center.y() + 7);
1718 QPainterPath arrow;
1719 arrow.moveTo(offset + QPoint(4, -8));
1720 arrow.lineTo(offset + QPoint(7, -5));
1721 arrow.lineTo(offset + QPoint(8, -5));
1722 arrow.lineTo(offset + QPoint(11, -8));
1723 arrow.lineTo(offset + QPoint(4, -8));
1724
1727
1728 painter->drawPath(arrow);
1729
1730 QRect fieldRect = subControlRect(control, option,
1731 SC_ComboBoxEditField, widget);
1732
1733 break;
1734 }
1735 case CC_Slider: {
1736 const QStyleOptionSlider *slider =
1737 qstyleoption_cast<const QStyleOptionSlider *>(option);
1738
1739 bool horizontal = slider->orientation == Qt::Horizontal;
1740
1741 QRect groove = subControlRect(control, option, SC_SliderGroove,
1742 widget);
1743 QRect ticks = subControlRect(control, option, SC_SliderTickmarks,
1744 widget);
1745 QRect handle = subControlRect(control, option, SC_SliderHandle,
1746 widget);
1747
1748 QRect afterHandle = QRect(handle.topLeft() + xySwitch(QPoint(4, 6), horizontal),
1749 groove.bottomRight() + xySwitch(QPoint(-4, -6), horizontal));
1750 QRect beforeHandle = QRect(groove.topLeft() + xySwitch(QPoint(4, 6), horizontal),
1751 handle.bottomRight() + xySwitch(QPoint(-4, -6), horizontal));
1752
1753 if (slider->upsideDown || !horizontal) {
1754 QRect remember;
1755 remember = afterHandle;
1756 afterHandle = beforeHandle;
1757 beforeHandle = remember;
1758 }
1759
1760 painter->setPen(slider->palette.color(QPalette::Mid));
1761 painter->setBrush(option->palette.color(QPalette::Background));
1762 painter->drawRect(afterHandle);
1763 painter->setPen(slider->palette.color(QPalette::Light));
1764 painter->drawLine(afterHandle.topLeft() + xySwitch(QPoint(0, 1), horizontal),
1765 afterHandle.topRight() + xySwitch(QPoint(0, 1), horizontal));
1766 painter->setPen(option->palette.color(QPalette::Midlight));
1767
1768 if (horizontal) {
1769 painter->setBrush(gradientBrush(QRect(QPoint(groove.x(),
1770 handle.y() + 1),
1771 QSize(groove.width(),
1772 handle.height() + 1))));
1773 } else {
1774 QRect rect = QRect(QPoint(groove.x(),
1775 handle.x() - 1),
1776 QSize(groove.height(),
1777 handle.width() + 1));
1778 QLinearGradient gradient(groove.bottomLeft(),
1779 groove.bottomRight());
1780 gradient.setColorAt(1.0, QColor(188, 210, 230));
1781 gradient.setColorAt(0.3, Qt::white);
1782 gradient.setColorAt(0.0, QColor(223, 233, 243));
1783
1784 painter->setBrush(gradient);
1785 }
1786
1787 painter->drawRect(beforeHandle);
1788
1789 QPainterPath handlePath;
1790 QPainterPath innerPath;
1791 QPoint topLeft, topRight, bottomLeft;
1792 if (horizontal) {
1793 topLeft = handle.topLeft();
1794 topRight = handle.topRight();
1795 bottomLeft = handle.bottomLeft();
1796 } else {
1797 topLeft = handle.bottomLeft();
1798 topRight = handle.topLeft();
1799 bottomLeft = handle.topRight();
1800 }
1801
1802 if (horizontal) {
1804
1805 image.setColor(1,
1806 option->palette.color(QPalette::Midlight).rgb());
1807 image.setColor(2,
1808 option->palette.color(QPalette::Button).rgb());
1809
1810 if (!(slider->state & State_Enabled)) {
1811 image.setColor(4, slider->palette.color(QPalette::Background).rgb());
1812 image.setColor(5, slider->palette.color(QPalette::Background).rgb());
1813 image.setColor(6, slider->palette.color(QPalette::Background).rgb());
1814 }
1815
1816 painter->drawImage(handle.topLeft(), image);
1817 } else {
1818 QImage image(":/images/verticalsliderhandle.png");
1819 painter->drawImage(handle.topLeft(), image);
1820 }
1821
1822 if (slider->tickPosition & QSlider::TicksBelow) {
1823 painter->setPen(slider->palette.color(QPalette::Light));
1824 int tickInterval = slider->tickInterval ? slider->tickInterval :
1825 slider->pageStep;
1826
1827 for (int i = 0; i <= slider->maximum; i += tickInterval) {
1828 if (horizontal) {
1829 int pos = int(((i / double(slider->maximum)) *
1830 ticks.width()) - 1);
1831 painter->drawLine(QPoint(ticks.left() + pos,
1832 ticks.top() + 2), QPoint(ticks.left() + pos, ticks.top() + 8));
1833 } else {
1834 int pos = int(((i / double(slider->maximum)) *
1835 ticks.height()) - 1);
1836 painter->drawLine(QPoint(ticks.left() + 2, ticks.bottom() - pos),
1837 QPoint(ticks.right() - 2, ticks.bottom() - pos));
1838 }
1839 }
1840 if (horizontal) {
1841 painter->drawLine(QPoint(ticks.right(), ticks.top() + 2),
1842 QPoint(ticks.right(), ticks.top() + 8));
1843 } else {
1844 painter->drawLine(QPoint(ticks.left() + 2, ticks.top()),
1845 QPoint(ticks.right() - 2, ticks.top()));
1846 }
1847 }
1848 break;
1849 }
1850 default:
1852 }
1853 painter->restore();
1854}
1855
1856inline void JavaStyle::drawSunkenButtonShadow(QPainter *painter,
1857 QRect rect,
1858 const QColor &frameColor,
1859 bool reverse) const
1860{
1861 painter->save();
1862
1863 painter->setPen(frameColor);
1864
1865 if (!reverse) {
1866 painter->drawLine(QLine(QPoint(rect.x() + 1, rect.y() + 1),
1867 QPoint(rect.x() + rect.width() - 1, rect.y() + 1)));
1868 painter->drawLine(QLine(QPoint(rect.x() + 1, rect.y()),
1869 QPoint(rect.x() + 1, rect.y() + rect.height())));
1870 } else {
1871 painter->drawLine(QLine(QPoint(rect.right(), rect.bottom()),
1872 QPoint(rect.right(), rect.top())));
1873 painter->drawLine(QLine(QPoint(rect.left(), rect.top() + 1),
1874 QPoint(rect.right(), rect.top() + 1)));
1875 }
1876 painter->restore();
1877}
1878
1879inline void JavaStyle::drawButtonHoverFrame(QPainter *painter, QRect rect,
1880 const QColor &frameColor,
1881 const QColor &activeFrame) const
1882{
1883 painter->save();
1884
1885 painter->setPen(activeFrame);
1887 rect.adjust(1, 1, -1, -1);
1888 painter->setPen(frameColor);
1890 rect.adjust(1, 1, -1, -1);
1891 painter->setPen(activeFrame);
1893
1894 painter->restore();
1895}
1896
1897QStyle::SubControl JavaStyle::hitTestComplexControl(ComplexControl control,
1899 const QPoint &pos,
1900 const QWidget *widget) const
1901{
1902 SubControl ret = SC_None;
1903
1904 switch (control) {
1905 case CC_TitleBar: {
1906 const QStyleOptionTitleBar *bar =
1907 qstyleoption_cast<const QStyleOptionTitleBar *>(option);
1908
1909 QRect maximize = subControlRect(control, bar, SC_TitleBarMaxButton);
1910 if (maximize.contains(pos)) {
1911 ret = SC_TitleBarMaxButton;
1912 break;
1913 }
1914 QRect minimize = subControlRect(control, bar, SC_TitleBarMinButton);
1915 if (minimize.contains(pos)) {
1916 ret = SC_TitleBarMinButton;
1917 break;
1918 }
1919 QRect close = subControlRect(control, bar, SC_TitleBarCloseButton);
1920 if (close.contains(pos)) {
1921 ret = SC_TitleBarCloseButton;
1922 break;
1923 }
1924 QRect system = subControlRect(control, bar, SC_TitleBarSysMenu);
1925 if (system.contains(pos)) {
1926 ret = SC_TitleBarSysMenu;
1927 break;
1928 }
1929 ret = SC_TitleBarLabel;
1930 break;
1931 }
1932 case CC_ScrollBar:
1933 if (const QStyleOptionSlider *scrollBar =
1934 qstyleoption_cast<const QStyleOptionSlider *>(option)) {
1935 QRect slider = subControlRect(control, scrollBar,
1936 SC_ScrollBarSlider, widget);
1937 if (slider.contains(pos)) {
1938 ret = SC_ScrollBarSlider;
1939 break;
1940 }
1941
1942 QRect scrollBarAddLine = subControlRect(control, scrollBar,
1943 SC_ScrollBarAddLine, widget);
1944 if (scrollBarAddLine.contains(pos)) {
1945 ret = SC_ScrollBarAddLine;
1946 break;
1947 }
1948
1949 QRect scrollBarSubPage = subControlRect(control, scrollBar,
1950 SC_ScrollBarSubPage, widget);
1951 if (scrollBarSubPage.contains(pos)) {
1952 ret = SC_ScrollBarSubPage;
1953 break;
1954 }
1955
1956 QRect scrollBarAddPage = subControlRect(control, scrollBar,
1957 SC_ScrollBarAddPage, widget);
1958 if (scrollBarAddPage.contains(pos)) {
1959 ret = SC_ScrollBarAddPage;
1960 break;
1961 }
1962
1963 QRect scrollBarSubLine = subControlRect(control, scrollBar,
1964 SC_ScrollBarSubLine, widget);
1965 if (scrollBarSubLine.contains(pos)) {
1966 ret = SC_ScrollBarSubLine;
1967 break;
1968 }
1969 }
1970 break;
1971
1972 default:
1974 widget);
1975 }
1976 return ret;
1977}
1978
1979void JavaStyle::polish(QWidget *widget)
1980{
1981 if (qobject_cast<QCheckBox *>(widget) ||
1982 qobject_cast<QRadioButton *>(widget) ||
1983 qobject_cast<QPushButton *>(widget) ||
1984 qobject_cast<QToolButton *>(widget) ||
1985 qobject_cast<QSpinBox *>(widget) ||
1986 qobject_cast<QGroupBox *>(widget))
1988}
1989
1990void JavaStyle::unpolish(QWidget *widget)
1991{
1992 if (qobject_cast<QPushButton *>(widget) ||
1993 qobject_cast<QCheckBox *>(widget) ||
1994 qobject_cast<QRadioButton *>(widget) ||
1995 qobject_cast<QToolButton *>(widget) ||
1996 qobject_cast<QSpinBox *>(widget) ||
1997 qobject_cast<QGroupBox *>(widget))
1999}
2000
2001void JavaStyle::drawSplitter(const QStyleOption *option, QPainter *painter,
2002 bool horizontal) const
2003{
2004 QRect rect = option->rect;
2005
2007 painter->setBrush(option->palette.color(QPalette::Background));
2008
2010
2011 QColor colors[] = { Qt::white, option->palette.color(QPalette::Mid) };
2012 int iterations = horizontal ? rect.height() - 1 : rect.width() - 1;
2013 for (int i = 0; i < iterations; ++i) {
2014 painter->setPen(colors[i % 2]);
2015 painter->drawPoint(xySwitch(QPoint(rect.x() + 0 + (i % 4),
2016 rect.y() + i), horizontal));
2017 }
2018}
2019
2020inline QPoint JavaStyle::xySwitch(const QPoint &point, bool horizontal) const
2021{
2022 QPoint retPoint = point;
2023
2024 if (!horizontal) {
2025 retPoint = QPoint(point.y(), point.x());
2026 }
2027
2028 return retPoint;
2029}
2030
2031void JavaStyle::drawPrimitive(PrimitiveElement element,
2032 const QStyleOption *option,
2034 const QWidget *widget) const
2035{
2036 painter->save();
2037
2038 switch (element) {
2039 case PE_PanelButtonBevel:
2040 case PE_FrameButtonBevel: {
2041 painter->save();
2042 painter->setBrush(option->palette.background());
2044 painter->drawRect(option->rect);
2045 painter->restore();
2046 break;
2047 }
2048 case PE_IndicatorBranch: {
2049 painter->save();
2050 QColor lineColor(204, 204, 255);
2051 QPixmap openPixmap(":/images/jtreeopen.png");
2052 QPixmap closedPixmap(":/images/jtreeclosed.png");
2053 QRect pixmapRect(QPoint(0, 0), QSize(12, 12));
2054 pixmapRect.moveCenter(option->rect.center());
2055 pixmapRect.translate(2, 0);
2056 QPoint center = option->rect.center();
2057
2058 painter->setPen(lineColor);
2060
2061 if (option->state & State_Item) {
2062 painter->drawLine(center,
2063 QPoint(option->rect.right(), center.y()));
2064
2065 painter->drawLine(center, QPoint(center.x(),
2066 option->rect.top()));
2067
2068 if (option->state & State_Sibling) {
2069 painter->drawLine(center, QPoint(center.x(),
2070 option->rect.bottom()));
2071 }
2072
2073 if (option->state & State_Children)
2074 if (option->state & State_Open)
2075 painter->drawPixmap(pixmapRect.topLeft(), closedPixmap);
2076 else
2077 painter->drawPixmap(pixmapRect.topLeft(), openPixmap);
2078 } else if (option->state & State_Sibling) {
2079 painter->drawLine(center.x(), option->rect.top(), center.x(),
2080 option->rect.bottom());
2081 }
2082
2083 painter->restore();
2084 break;
2085 }
2086 case PE_IndicatorItemViewItemCheck: {
2087 break;
2088 }
2089 case PE_FrameWindow: {
2090 painter->save();
2091 bool active = option->state & State_Active;
2092
2094 painter->setBrush(active ? option->palette.color(QPalette::Midlight)
2095 : option->palette.color(QPalette::Mid));
2096
2097 painter->drawRect(QRect(option->rect.topLeft(), option->rect.bottomLeft() + QPoint(5, 0)));
2098 painter->drawRect(QRect(option->rect.bottomLeft(), option->rect.bottomRight() + QPoint(0, -5)));
2099 painter->drawRect(QRect(option->rect.bottomRight() + QPoint(-5, 0), option->rect.topRight()));
2100 painter->drawRect(QRect(option->rect.topLeft(), option->rect.topRight() + QPoint(0, 4)));
2101
2104 painter->drawLine(option->rect.topLeft() + QPoint(2, 14),
2105 option->rect.bottomLeft() + QPoint(2, -14));
2106
2107 painter->drawLine(option->rect.topRight() + QPoint(-2, 14),
2108 option->rect.bottomRight() + QPoint(-2, -14));
2109
2110 painter->drawLine(option->rect.topLeft() + QPoint(14, 2),
2111 option->rect.topRight() + QPoint(-14, 2));
2112
2113 painter->drawLine(option->rect.bottomLeft() + QPoint(14, -2),
2114 option->rect.bottomRight() + QPoint(-14, -2));
2115
2116 painter->setPen(active ? option->palette.color(QPalette::Light) :
2118 painter->drawLine(option->rect.topLeft() + QPoint(3, 15),
2119 option->rect.bottomLeft() + QPoint(3, -13));
2120
2121 painter->drawLine(option->rect.topRight() + QPoint(-1, 15),
2122 option->rect.bottomRight() + QPoint(-1, -13));
2123
2124 painter->drawLine(option->rect.topLeft() + QPoint(15, 3),
2125 option->rect.topRight() + QPoint(-13, 3));
2126
2127 painter->drawLine(option->rect.bottomLeft() + QPoint(15, -1),
2128 option->rect.bottomRight() + QPoint(-13, -1));
2129
2130 painter->restore();
2131 break;
2132 }
2133 case PE_IndicatorSpinUp: {
2134 const QStyleOptionSpinBox *spinner =
2135 qstyleoption_cast<const QStyleOptionSpinBox *>(option);
2136 int add = spinner->state & State_Sunken &&
2137 spinner->activeSubControls & SC_SpinBoxUp ? 1 : 0;
2138
2139 QPoint center = option->rect.center();
2140 painter->drawLine(center.x() + add, center.y() + 1 + add,
2141 center.x() + 2 + add, center.y() + 1 + add);
2142 painter->drawPoint(center.x() + 1 + add, center.y() + add);
2143 break;
2144 }
2145 case PE_IndicatorSpinDown: {
2146 const QStyleOptionSpinBox *spinner =
2147 qstyleoption_cast<const QStyleOptionSpinBox *>(option);
2148
2149 int add = spinner->state & State_Sunken &&
2150 spinner->activeSubControls & SC_SpinBoxDown ? 1 : 0;
2151 QPoint center = option->rect.center();
2152 painter->drawLine(center.x() + add, center.y() + add,
2153 center.x() + 2 + add, center.y() + add);
2154 painter->drawPoint(center.x() + 1 + add, center.y() + 1 + add);
2155 break;
2156 }
2157 case PE_FrameDockWidget: {
2158 drawPrimitive(PE_FrameWindow, option, painter, widget);
2159 break;
2160 }
2161 case PE_IndicatorToolBarHandle: {
2162 QPoint offset;
2163 bool horizontal = option->state & State_Horizontal;
2164
2165 if (horizontal)
2166 offset = option->rect.topLeft();
2167 else
2168 offset = option->rect.topLeft();
2169
2170 int iterations = horizontal ? option->rect.height() :
2171 option->rect.width();
2172
2173 for (int i = 0; i < iterations; ++i) {
2174 painter->setPen(i % 2 ? Qt::white :
2175 option->palette.color(QPalette::Mid));
2176 int add = i % 4;
2177 painter->drawPoint(offset + xySwitch(QPoint(add, i),
2178 horizontal));
2179 painter->drawPoint(offset + xySwitch(QPoint(add + 4, i),
2180 horizontal));
2181 if (add + 8 < 10)
2182 painter->drawPoint(offset + xySwitch(QPoint(add + 8, i),
2183 horizontal));
2184 }
2185
2186 break;
2187 }
2188 case PE_IndicatorToolBarSeparator: {
2189 break;
2190 }
2191 case PE_PanelButtonTool: {
2193 qstyleoption_cast<const QStyleOptionToolButton *>(option);
2194
2195 if (!button) {
2197 if (!(option->state & State_Enabled))
2198 painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
2199 drawButtonBackground(option, painter, false);
2200 break;
2201 }
2202
2203 if (button->state & State_MouseOver || button->state & State_On) {
2204 QStyleOptionButton bevel;
2205 bevel.state = button->state;
2206 bevel.rect = button->rect;
2207 bevel.palette = button->palette;
2208
2209 drawButtonBackground(&bevel, painter, false);
2210 } else {
2212 painter->setBrush(button->palette.color(QPalette::Background));
2213
2214 painter->drawRect(button->rect.adjusted(0, 0, -1, -1));
2215 }
2216 break;
2217 }
2218 case PE_FrameMenu: {
2219 painter->setPen(option->palette.color(QPalette::Midlight));
2220 painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
2221 break;
2222 }
2223 case PE_PanelButtonCommand: {
2224 const QStyleOptionButton *btn =
2225 qstyleoption_cast<const QStyleOptionButton *>(option);
2226 bool hover = (btn->state & State_Enabled) &&
2227 (btn->state & State_MouseOver);
2228 bool sunken = btn->state & State_Sunken;
2230 bool on = option->state & State_On;
2231
2232 drawButtonBackground(option, painter, false);
2233
2234 QRect rect = option->rect.adjusted(0, 0, -1, -1);
2235 if (hover && !sunken && !isDefault && !on) {
2236 drawButtonHoverFrame(painter, rect,
2239 } else if (isDefault) {
2240 drawPrimitive(PE_FrameDefaultButton, option, painter, widget);
2241 }
2242 break;
2243 }
2244 case PE_FrameDefaultButton: {
2245 painter->setPen(option->palette.color(QPalette::Mid));
2246 QRect rect = option->rect.adjusted(0, 0, -1, -1);
2248 painter->drawRect(rect.adjusted(1, 1, -1, -1));
2249 break;
2250 }
2252 case PE_IndicatorCheckBox: {
2253 painter->save();
2254 drawButtonBackground(option, painter, true);
2255
2256 if (option->state & State_Enabled &&
2257 option->state & State_MouseOver &&
2258 !(option->state & State_Sunken)) {
2259 painter->setPen(option->palette.color(QPalette::Button));
2260 QRect rect = option->rect.adjusted(1, 1, -2, -2);
2262 rect = rect.adjusted(1, 1, -1, -1);
2264 }
2265
2266 if (option->state & State_On) {
2267 QImage image(":/images/checkboxchecked.png");
2268 painter->drawImage(option->rect.topLeft(), image);
2269 }
2270 painter->restore();
2271 break;
2273 }
2274 case PE_IndicatorRadioButton: {
2275 painter->save();
2276 QBrush radioBrush = option->palette.button();
2277
2278 if (!(option->state & State_Sunken) &&
2279 option->state & State_Enabled)
2280 radioBrush = gradientBrush(option->rect);
2281
2282 painter->setBrush(radioBrush);
2283 if (option->state & State_Enabled)
2284 painter->setPen(option->palette.color(QPalette::Mid));
2285 else
2286 painter->setPen(option->palette.color(QPalette::Disabled,
2288 painter->drawEllipse(option->rect.adjusted(0, 0, -1, -1));
2289
2290 if (option->state & State_MouseOver &&
2291 option->state & State_Enabled &&
2292 !(option->state & State_Sunken)) {
2293 gradientBrush(option->rect);
2294 painter->setPen(option->palette.color(QPalette::Button));
2296 QRect rect = option->rect.adjusted(1, 1, -2, -2);
2298 rect = rect.adjusted(1, 1, -1, -1);
2300 }
2301
2302 if (option->state & State_On) {
2303 painter->setBrush(option->palette.color(QPalette::Text));
2305 painter->drawEllipse(option->rect.adjusted(3, 3, -3, -3));
2306 }
2307 if (option->state & State_Sunken &&
2308 option->state & State_Enabled) {
2309 painter->setPen(option->palette.color(QPalette::Mid));
2310 painter->drawArc(option->rect.adjusted(1, 1, -2, -2), 80 * 16,
2311 100 * 16);
2312 }
2313 painter->restore();
2314 break;
2315 }
2316 case PE_FrameTabWidget: {
2317 painter->setPen(option->palette.color(QPalette::Midlight));
2318 painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
2320 painter->drawRect(option->rect.adjusted(1, 1, -2, -2));
2321 break;
2322 }
2323 case PE_Frame:
2324 case PE_FrameLineEdit: {
2325 const QStyleOptionFrame *frame =
2326 qstyleoption_cast<const QStyleOptionFrame *>(option);
2327
2329 painter->drawRect(frame->rect.adjusted(0, 0, -2, -2));
2331 painter->drawRect(frame->rect.adjusted(1, 1, -1, -1));
2333 QPalette::Background));
2335 frame->rect.bottomLeft() + QPoint(1, -1));
2337 frame->rect.topRight() + QPoint(-1, 1));
2338 break;
2339 }
2340 case PE_FrameFocusRect: {
2341 painter->setPen(option->palette.color(QPalette::Light));
2343 QRect rect = option->rect;
2344 rect = rect.adjusted(0,0, -1, -1);
2346 break;
2347 }
2348 default:
2350 }
2351 painter->restore();
2352}
2353
2355void JavaStyle::drawButtonBackground(const QStyleOption *option,
2356 QPainter *painter, bool isCheckbox) const
2357{
2358 QBrush buttonBrush = option->palette.button();
2359 bool sunken = option->state & State_Sunken;
2360 bool disabled = !(option->state & State_Enabled);
2361 bool on = option->state & State_On;
2362
2363 if (!sunken && !disabled && (!on || isCheckbox))
2364 buttonBrush = gradientBrush(option->rect);
2365
2366 painter->fillRect(option->rect, buttonBrush);
2367
2368 QRect rect = option->rect.adjusted(0, 0, -1, -1);
2369
2370 if (disabled)
2371 painter->setPen(option->palette.color(QPalette::Disabled,
2373 else
2374 painter->setPen(option->palette.color(QPalette::Mid));
2375
2377
2378 if (sunken && !disabled) {
2379 drawSunkenButtonShadow(painter, rect,
2380 option->palette.color(QPalette::Mid),
2381 option->direction == Qt::RightToLeft);
2382 }
2383}
2385
2386QBrush JavaStyle::gradientBrush(const QRect &rect) const
2387{
2388 QLinearGradient gradient(rect.topLeft(), rect.bottomLeft());
2389 gradient.setColorAt(1.0, QColor(188, 210, 230));
2390 gradient.setColorAt(0.3, Qt::white);
2391 gradient.setColorAt(0.0, QColor(223, 233, 243));
2392
2393 return QBrush(gradient);
2394}
2395
2396QRect JavaStyle::subElementRect(SubElement element,
2397 const QStyleOption *option,
2398 const QWidget *widget) const
2399{
2400 QRect rect;
2401
2402 switch (element) {
2403 case SE_ToolBoxTabContents: {
2404 const QStyleOptionToolBox *box =
2405 qstyleoption_cast<const QStyleOptionToolBox *>(option);
2406
2407 rect.moveTopLeft(box->rect.topLeft() + QPoint(0, 2));
2408 rect.setHeight(box->rect.height() - 4);
2409 rect.setWidth(box->fontMetrics.horizontalAdvance(box->text) + 15);
2410 break;
2411 }
2412 case SE_ProgressBarLabel:
2413 case SE_ProgressBarGroove:
2414 case SE_ProgressBarContents: {
2415 rect = option->rect.adjusted(1, 1, -1, -1);
2416 break;
2417 }
2418 case SE_PushButtonFocusRect: {
2419 const QStyleOptionButton *btn =
2420 qstyleoption_cast<const QStyleOptionButton *>(option);
2421
2424 rect.height());
2425
2426 if (!btn->icon.isNull()) {
2427 rect.adjust(0, 0, btn->iconSize.width(), btn->iconSize.height()
2428 > rect.height() ? btn->iconSize.height() - rect.height() : 0);
2429 rect.translate(-btn->iconSize.width(), 0);
2430 rect.adjust(-1, -1, 1, 1);
2431 }
2432 rect = QRect(int(ceil((btn->rect.width() - rect.width()) / 2.0)),
2433 int(ceil((btn->rect.height() - rect.height()) / 2.0)),
2434 rect.width() - 1, rect.height());
2435 rect.adjust(-1, 0, 1, 0);
2436
2437 break;
2438 }
2439 default:
2441 }
2442 return rect;
2443}
2444
2445int JavaStyle::pixelMetric(PixelMetric metric,
2446 const QStyleOption* /* option */,
2447 const QWidget* /*widget*/) const
2448{
2449 int value = 0;
2450
2451 switch (metric) {
2452 case PM_ButtonShiftHorizontal:
2453 case PM_ButtonShiftVertical:
2454 case PM_TabBarTabShiftHorizontal:
2455 case PM_ButtonDefaultIndicator:
2456 case PM_TabBarTabShiftVertical:
2457 value = 0;
2458 break;
2459 case PM_TabBarBaseOverlap:
2460 case PM_DefaultFrameWidth:
2461 value = 2;
2462 break;
2463 case PM_TabBarTabVSpace:
2464 value = 4;
2465 break;
2466 case PM_ScrollBarExtent:
2467 value = 16;
2468 break;
2469 case PM_ScrollBarSliderMin:
2470 value = 26;
2471 break;
2472 case PM_SplitterWidth:
2473 value = 8;
2474 break;
2475 case PM_SliderThickness:
2476 value = 16;
2477 break;
2478 case PM_SliderControlThickness:
2479 value = 16;
2480 break;
2481 case PM_SliderTickmarkOffset:
2482 value = 10;
2483 break;
2484 case PM_SliderSpaceAvailable:
2485 break;
2486 case PM_MenuPanelWidth:
2487 value = 1;
2488 break;
2489 case PM_MenuVMargin:
2490 value = 2;
2491 break;
2492 case PM_MenuBarPanelWidth:
2493 value = 1;
2494 break;
2495 case PM_MenuBarItemSpacing:
2496 value = 0;
2497 break;
2498 case PM_MenuBarHMargin:
2499 value = 3;
2500 break;
2501 case PM_MenuBarVMargin:
2502 value = 0;
2503 break;
2504 case PM_ComboBoxFrameWidth:
2505 value = 1;
2506 break;
2507 case PM_MenuButtonIndicator:
2508 value = 15;
2509 break;
2510 case PM_ToolBarItemMargin:
2511 value = 3;
2512 break;
2513 case PM_ToolBarHandleExtent:
2514 value = 13;
2515 break;
2516 case PM_SpinBoxFrameWidth:
2517 value = 2;
2518 break;
2519 case PM_TitleBarHeight: {
2520 value = 21;
2521 break;
2522 case PM_MDIFrameWidth:
2523 value = 6;
2524 break;
2525 }
2526 case PM_DockWidgetFrameWidth: {
2527 value = 5;
2528 break;
2529 }
2530 default:
2532 }
2533 return value;
2534}
2535
2536
2537int JavaStyle::styleHint(StyleHint hint, const QStyleOption *option,
2538 const QWidget *widget,
2539 QStyleHintReturn *returnData) const
2540{
2541 int ret;
2542
2543 switch (hint) {
2544 case SH_Table_GridLineColor: {
2545 ret = static_cast<int>(option->palette.color(QPalette::Mid).rgba());
2546 break;
2547 }
2549 ret = 1;
2550 break;
2551 default:
2552 ret = QCommonStyle::styleHint(hint, option, widget, returnData);
2553 }
2554 return ret;
2555}
2556
2557QPixmap JavaStyle::standardPixmap(StandardPixmap standardPixmap,
2558 const QStyleOption *option,
2559 const QWidget *widget) const
2560{
2562 widget);
2563
2564 QPixmap maximizePixmap(":/images/internalmaximize.png");
2565 QPixmap minimizePixmap(":/images/internalminimize.png");
2566 QPixmap closePixmap(":/images/internalclose.png");
2567 QPixmap internalPixmap(":/images/internalsystem.png");
2568 QPixmap internalCloseDownPixmap(":/images/internalclosedown.png");
2569 QPixmap minimizeDownPixmap(":/images/internalminimizedown.png");
2570 QPixmap maximizeDownPixmap(":/images/internalmaximizedown.png");
2571 QPixmap dirOpenPixmap(":/images/open24.png");
2572 QPixmap filePixmap(":/images/file.png");
2573
2574 switch (standardPixmap) {
2575 case SP_DirLinkIcon:
2576 case SP_DirClosedIcon:
2577 case SP_DirIcon:
2578 case SP_DirOpenIcon: {
2579 pixmap = closePixmap;
2580 break;
2581 }
2582 case SP_FileIcon: {
2583 pixmap = filePixmap;
2584 break;
2585 }
2586 case SP_FileDialogBack: {
2587 pixmap = QPixmap(":/images/fileback.png");
2588 break;
2589 }
2590 case SP_FileDialogToParent: {
2591 pixmap = QPixmap(":/images/fileparent.png");
2592 break;
2593 }
2594 case SP_FileDialogNewFolder: {
2595 pixmap = QPixmap(":/images/open24.png");
2596 break;
2597 }
2598 case SP_FileDialogListView: {
2599 pixmap = QPixmap(":/images/filelist.png");
2600 break;
2601 }
2602 case SP_FileDialogDetailedView: {
2603 pixmap = QPixmap(":/images/filedetail.png");
2604 break;
2605 }
2606 case SP_MessageBoxInformation: {
2607 pixmap = QPixmap(":/images/information.png");
2608 break;
2609 }
2610 case SP_MessageBoxWarning: {
2611 pixmap = QPixmap(":/images/warning.png");
2612 }
2613 case SP_MessageBoxCritical: {
2614 pixmap = QPixmap(":/images/critical.png");
2615 break;
2616 }
2617 case SP_MessageBoxQuestion: {
2618 pixmap = QPixmap(":/images/question.png");
2619 break;
2620 }
2621 case SP_TitleBarNormalButton:
2622 pixmap = maximizePixmap;
2623 break;
2624 case SP_TitleBarCloseButton:
2625 pixmap = closePixmap;
2626 break;
2627 default:
2628 ;
2629 }
2630
2631 return pixmap;
2632}
2633
2634QSize JavaStyle::sizeFromContents(ContentsType type,
2635 const QStyleOption *option,
2636 const QSize &contentsSize,
2637 const QWidget *widget) const
2638{
2639 switch (type) {
2640 case CT_ComboBox: {
2641 return QSize(contentsSize.width() + 27, contentsSize.height());
2642 }
2643 case CT_Slider: {
2644 const QStyleOptionSlider *slider =
2645 qstyleoption_cast<const QStyleOptionSlider *>(option);
2646 if (slider->tickPosition == QSlider::TicksBelow) {
2647 return QSize(contentsSize.width(), contentsSize.height() + 15);
2648 } else {
2649 return contentsSize;
2650 }
2651 }
2652 case CT_MenuBarItem: {
2653 const QStyleOptionMenuItem *menuItem =
2654 qstyleoption_cast<const QStyleOptionMenuItem *>(option);
2655 QFontMetrics metrics(menuItem->font);
2656 QRect boundingRect = metrics.boundingRect(menuItem->text);
2657 int width = boundingRect.width() + 14;
2658 int height = boundingRect.height() + 3;
2659 if (height < 20)
2660 height = 20;
2661
2662 return QSize(width, height);
2663 }
2664 case CT_MenuItem: {
2665 const QStyleOptionMenuItem *menuItem =
2666 qstyleoption_cast<const QStyleOptionMenuItem *>(option);
2668 contentsSize, widget);
2669
2671 return defaultSize;
2672
2673 int width = 30;
2674 int height = 0;
2675
2676 if (!menuItem->icon.isNull()) {
2677 width += 20;
2678 height += 20;
2679 }
2680 if (!menuItem->text.isEmpty()) {
2681 QFontMetrics metrics(menuItem->font);
2682 QString text = menuItem->text;
2683 text.remove(u'\t');
2684 QRect textRect = metrics.boundingRect(text);
2685 width += textRect.width();
2686 if (height < textRect.height())
2687 height += textRect.height();
2688 }
2690 width += 10;
2691 if (height < 10)
2692 height = 10;
2693 }
2694 return QSize(width, height);
2695 }
2696 default:
2697 return QCommonStyle::sizeFromContents(type, option, contentsSize,
2698 widget);
2699 }
2700}
QIcon icon
the icon shown on the button
QSize iconSize
the icon size used for this button.
QString text
the text shown on the button
int pageStep
the page step.
Qt::Orientation orientation
the orientation of the slider
int sliderPosition
the current slider position
int minimum
the sliders's minimum value
int maximum
the slider's maximum value
\inmodule QtGui
Definition qbrush.h:30
const QColor & color() const
Returns the brush color.
Definition qbrush.h:121
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
bool isValid() const noexcept
Returns true if the color is valid; otherwise returns false.
Definition qcolor.h:285
int pixelMetric(PixelMetric m, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr) const override
\reimp
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *widget=nullptr) const override
\reimp
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=nullptr) const override
\reimp
QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr) const override
\reimp
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const override
\reimp
SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *w=nullptr) const override
\reimp
int styleHint(StyleHint sh, const QStyleOption *opt=nullptr, const QWidget *w=nullptr, QStyleHintReturn *shret=nullptr) const override
\reimp
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *w=nullptr) const override
\reimp
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w=nullptr) const override
\reimp
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const override
\reimp
\reentrant \inmodule QtGui
int height() const
Returns the height of the font.
QRect boundingRect(QChar) const
Returns the rectangle that is covered by ink if character ch were to be drawn at the origin of the co...
int horizontalAdvance(const QString &, int len=-1) const
Returns the horizontal advance in pixels of the first len characters of text.
\reentrant
Definition qfont.h:22
void setPointSize(int)
Sets the point size to pointSize.
Definition qfont.cpp:985
int pointSize() const
Returns the point size of the font.
Definition qfont.cpp:884
void setBold(bool)
If enable is true sets the font's weight to \l{Weight}{QFont::Bold}; otherwise sets the weight to \l{...
Definition qfont.h:373
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
Definition qicon.cpp:1019
Mode
This enum type describes the mode for which a pixmap is intended to be used.
Definition qicon.h:22
@ Disabled
Definition qicon.h:22
@ Normal
Definition qicon.h:22
@ Active
Definition qicon.h:22
State
This enum describes the state for which a pixmap is intended to be used.
Definition qicon.h:23
@ Off
Definition qicon.h:23
@ On
Definition qicon.h:23
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
Returns a pixmap with the requested size, mode, and state, generating one if necessary.
Definition qicon.cpp:834
\inmodule QtGui
Definition qimage.h:37
\inmodule QtCore\compares equality \compareswith equality QLineF \endcompareswith
Definition qline.h:18
\inmodule QtGui
Definition qbrush.h:394
\inmodule QtGui
void moveTo(const QPointF &p)
Moves the current point to the given point, implicitly starting a new subpath and closing the previou...
void lineTo(const QPointF &p)
Adds a straight line from the current position to the given endPoint.
The QPainter class performs low-level painting on widgets and other paint devices.
Definition qpainter.h:46
void drawPoint(const QPointF &pt)
Draws a single point at the given position using the current pen's color.
Definition qpainter.h:545
void drawRect(const QRectF &rect)
Draws the current rectangle with the current pen and brush.
Definition qpainter.h:519
void drawPath(const QPainterPath &path)
Draws the given painter path using the current pen for outline and the current brush for filling.
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
Enables clipping, and sets the clip region to the given rectangle using the given clip operation.
void setPen(const QColor &color)
This is an overloaded member function, provided for convenience. It differs from the above function o...
void drawLine(const QLineF &line)
Draws a line defined by line.
Definition qpainter.h:442
const QFont & font() const
Returns the currently set font used for drawing text.
void restore()
Restores the current painter state (pops a saved state off the stack).
void rotate(qreal a)
Rotates the coordinate system clockwise.
void save()
Saves the current painter state (pushes the state onto a stack).
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
Draws the rectangular portion source of the given image into the target rectangle in the paint device...
void setFont(const QFont &f)
Sets the painter's font to the given font.
void drawText(const QPointF &p, const QString &s)
Draws the given text with the currently defined text direction, beginning at the given position.
void drawPolyline(const QPointF *points, int pointCount)
Draws the polyline defined by the first pointCount points in points using the current pen.
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
Draws the rectangular portion source of the given pixmap into the given target in the paint device.
void drawArc(const QRectF &rect, int a, int alen)
Draws the arc defined by the given rectangle, startAngle and spanAngle.
void drawEllipse(const QRectF &r)
Draws the ellipse defined by the given rectangle.
void setBrush(const QBrush &brush)
Sets the painter's brush to the given brush.
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
Draws the polygon defined by the first pointCount points in the array points using the current pen an...
void translate(const QPointF &offset)
Translates the coordinate system by the given offset; i.e.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
void setTransform(const QTransform &transform, bool combine=false)
The QPalette class contains color groups for each widget state.
Definition qpalette.h:19
const QBrush & button() const
Returns the button brush of the current color group.
Definition qpalette.h:84
const QBrush & text() const
Returns the text foreground brush of the current color group.
Definition qpalette.h:88
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
Definition qpalette.h:67
@ Inactive
Definition qpalette.h:49
@ Disabled
Definition qpalette.h:49
@ HighlightedText
Definition qpalette.h:53
@ BrightText
Definition qpalette.h:52
@ AlternateBase
Definition qpalette.h:55
@ ButtonText
Definition qpalette.h:52
@ WindowText
Definition qpalette.h:51
@ Highlight
Definition qpalette.h:53
@ Midlight
Definition qpalette.h:51
const QBrush & buttonText() const
Returns the button text foreground brush of the current color group.
Definition qpalette.h:96
const QBrush & highlightedText() const
Returns the highlighted text brush of the current color group.
Definition qpalette.h:99
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
int width() const
Returns the width of the pixmap.
Definition qpixmap.cpp:468
\inmodule QtCore\reentrant
Definition qpoint.h:25
constexpr int & rx() noexcept
Returns a reference to the x coordinate of this point.
Definition qpoint.h:155
constexpr int x() const noexcept
Returns the x coordinate of this point.
Definition qpoint.h:130
constexpr int y() const noexcept
Returns the y coordinate of this point.
Definition qpoint.h:135
The QPolygon class provides a list of points using integer precision.
Definition qpolygon.h:23
\inmodule QtCore\reentrant
Definition qrect.h:30
constexpr QPoint bottomLeft() const noexcept
Returns the position of the rectangle's bottom-left corner.
Definition qrect.h:230
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
Definition qrect.h:373
constexpr void moveCenter(const QPoint &p) noexcept
Moves the rectangle, leaving the center point at the given position.
Definition qrect.h:328
constexpr int height() const noexcept
Returns the height of the rectangle.
Definition qrect.h:239
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
Definition qrect.h:182
constexpr QPoint topLeft() const noexcept
Returns the position of the rectangle's top-left corner.
Definition qrect.h:221
constexpr QRect adjusted(int x1, int y1, int x2, int y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
Definition qrect.h:370
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
Definition qrect.h:176
constexpr QPoint topRight() const noexcept
Returns the position of the rectangle's top-right corner.
Definition qrect.h:227
bool contains(const QRect &r, bool proper=false) const noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qrect.cpp:855
constexpr int left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
Definition qrect.h:173
constexpr void setRect(int x, int y, int w, int h) noexcept
Sets the coordinates of the rectangle's top-left corner to ({x}, {y}), and its size to the given widt...
Definition qrect.h:346
constexpr QRect transposed() const noexcept
Definition qrect.h:267
constexpr void translate(int dx, int dy) noexcept
Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position.
Definition qrect.h:245
constexpr QPoint bottomRight() const noexcept
Returns the position of the rectangle's bottom-right corner.
Definition qrect.h:224
constexpr int width() const noexcept
Returns the width of the rectangle.
Definition qrect.h:236
constexpr QPoint center() const noexcept
Returns the center point of the rectangle.
Definition qrect.h:233
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
Definition qrect.h:179
\inmodule QtCore
Definition qsize.h:25
constexpr int height() const noexcept
Returns the height.
Definition qsize.h:133
constexpr int width() const noexcept
Returns the width.
Definition qsize.h:130
@ TicksBelow
Definition qslider.h:29
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
qsizetype indexOf(QLatin1StringView s, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition qstring.cpp:4517
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
QString & remove(qsizetype i, qsizetype len)
Removes n characters from the string, starting at the given position index, and returns a reference t...
Definition qstring.cpp:3466
\variable QStyleOptionGraphicsItem::exposedRect
\variable QStyleOptionHeaderV2::textElideMode
ButtonFeatures features
\variable QStyleOptionToolButton::features
\variable QStyleOptionMenuItem::menuItemType
QStyle::SubControls activeSubControls
\variable QStyleOptionComplex::subControls
\variable QStyleOptionFocusRect::backgroundColor
\variable QStyleOptionFrame::features
The QStyleOptionHeader class is used to describe the parameters for drawing a header.
\variable QStyleOptionProgressBar::minimum
MenuItemType menuItemType
\variable QStyleOptionButton::features
\variable QStyleOptionToolBox::selectedPosition
\variable QStyleOptionComboBox::editable
\variable QStyleOptionDockWidget::title
The QStyleOption class stores the parameters used by QStyle functions.
QFontMetrics fontMetrics
QStyle::State state
QPalette palette
Qt::LayoutDirection direction
virtual QPalette standardPalette() const
Returns the style's standard palette.
Definition qstyle.cpp:2301
@ SH_Menu_Scrollable
Definition qstyle.h:615
static int sliderPositionFromValue(int min, int max, int val, int space, bool upsideDown=false)
Converts the given logicalValue to a pixel position.
Definition qstyle.cpp:2222
SubControl
This enum describes the available sub controls.
Definition qstyle.h:347
Shape
This enum type lists the built-in shapes supported by QTabBar.
Definition qtabbar.h:42
@ RoundedSouth
Definition qtabbar.h:42
@ RoundedNorth
Definition qtabbar.h:42
@ RoundedWest
Definition qtabbar.h:42
@ RoundedEast
Definition qtabbar.h:42
\reentrant
Definition qtextoption.h:18
The QTransform class specifies 2D transformations of a coordinate system.
Definition qtransform.h:20
QTransform & rotate(qreal a, Qt::Axis axis=Qt::ZAxis, qreal distanceToPlane=1024.0f)
QTransform & translate(qreal dx, qreal dy)
Moves the coordinate system dx along the x axis and dy along the y axis, and returns a reference to t...
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
void setAttribute(Qt::WidgetAttribute, bool on=true)
Sets the attribute attribute on this widget if on is true; otherwise clears the attribute.
QPalette palette
the widget's palette
Definition qwidget.h:132
QFontMetrics fontMetrics() const
Returns the font metrics for the widget's current font.
Definition qwidget.h:847
QRect rect
the internal geometry of the widget excluding any window frame
Definition qwidget.h:116
QOpenGLWidget * widget
[1]
QString text
QPushButton * button
[2]
drawPrimitive(PE_IndicatorCheckBox, &subopt, p, widget)
rect
[4]
QStyleOptionButton opt
p drawControl(QStyle::CE_CheckBox, opt)
else opt state
[0]
QRect textRect
const QStyleOptionButton * btn
[3]
static const int windowsCheckMarkHMargin
Definition javastyle.cpp:15
static const int windowsItemFrame
Definition javastyle.cpp:9
static const int windowsItemHMargin
Definition javastyle.cpp:11
static const int windowsArrowHMargin
Definition javastyle.cpp:13
static const int windowsItemVMargin
Definition javastyle.cpp:12
static const int windowsSepHeight
Definition javastyle.cpp:10
static const int windowsCheckMarkWidth
Definition javastyle.cpp:17
static const char *const sliderHandleImage[]
static const int windowsTabSpacing
Definition javastyle.cpp:14
static const int windowsRightBorder
Definition javastyle.cpp:16
bool isEnabled()
Definition qcompare.h:63
@ AlignVCenter
Definition qnamespace.h:155
@ AlignHCenter
Definition qnamespace.h:148
@ AlignCenter
Definition qnamespace.h:163
@ AlignLeft
Definition qnamespace.h:144
@ WA_Hover
Definition qnamespace.h:340
@ IntersectClip
@ LeftToRight
@ RightToLeft
Orientation
Definition qnamespace.h:98
@ Horizontal
Definition qnamespace.h:99
@ Vertical
Definition qnamespace.h:100
@ TextSingleLine
Definition qnamespace.h:170
@ TextDontClip
Definition qnamespace.h:171
@ TextHideMnemonic
Definition qnamespace.h:178
@ TextShowMnemonic
Definition qnamespace.h:173
@ white
Definition qnamespace.h:31
@ blue
Definition qnamespace.h:37
@ black
Definition qnamespace.h:30
@ red
Definition qnamespace.h:35
@ NoPen
@ NoBrush
QTextStream & center(QTextStream &stream)
Calls QTextStream::setFieldAlignment(QTextStream::AlignCenter) on stream and returns stream.
Definition image.cpp:4
static jboolean copy(JNIEnv *, jobject)
#define qApp
static QString header(const QString &name)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static void visualRect(QRectF *geom, Qt::LayoutDirection dir, const QRectF &contentsRect)
return ret
Button
constexpr const T & qMax(const T &a, const T &b)
Definition qminmax.h:42
GLuint64 GLenum void * handle
GLint GLint GLint GLint GLint x
[0]
GLenum mode
const GLfloat * m
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLboolean r
[2]
GLsizei GLenum const void GLuint GLsizei GLfloat * metrics
GLint GLsizei width
GLuint color
[2]
GLenum type
GLuint GLsizei const GLchar * label
[43]
GLenum GLuint GLintptr offset
GLsizei const GLint * box
GLint y
GLfloat GLfloat GLfloat GLfloat h
GLdouble s
[6]
Definition qopenglext.h:235
GLdouble GLdouble t
Definition qopenglext.h:243
GLfloat GLfloat p
[1]
GLuint GLenum option
static const QRectF boundingRect(const QPointF *points, int pointCount)
static void add(QPainterPath &path, const QWingedEdge &list, int edge, QPathEdge::Traversal traversal)
static QT_BEGIN_NAMESPACE const QRgb colors[][14]
static QT_BEGIN_NAMESPACE QVariant hint(QPlatformIntegration::StyleHint h)
ptrdiff_t qsizetype
Definition qtypes.h:165
unsigned int uint
Definition qtypes.h:34
#define disabled
static const int windowsItemFrame
static const int windowsItemHMargin
static const int windowsItemVMargin
static const int windowsRightBorder
std::uniform_real_distribution dist(1, 2.5)
[2]
QScrollBar * scrollBar
widget render & pixmap
QPainter painter(this)
[7]
QFrame frame
[0]
QSpinBox * spinBox
[0]