53 #include "javastyle.h"
56 static const int windowsItemFrame = 2;
57 static const int windowsSepHeight = 2;
58 static const int windowsItemHMargin = 3;
59 static const int windowsItemVMargin = 2;
60 static const int windowsArrowHMargin = 6;
61 static const int windowsTabSpacing = 12;
62 static const int windowsCheckMarkHMargin = 2;
63 static const int windowsRightBorder = 15;
64 static const int windowsCheckMarkWidth = 12;
66 JavaStyle::JavaStyle()
68 qApp->setPalette(standardPalette());
72 inline QPoint JavaStyle::adjustScrollPoint(
const QPoint &point,
76 int adder =
add ? -1 : 1;
80 retPoint =
QPoint(point.
y() * adder, point.
x());
82 retPoint =
QPoint(point.
x(), point.
y() * adder);
88 QPalette JavaStyle::standardPalette()
const
139 const QStyleOptionSlider *
option,
166 if (
option->state & State_Sunken)
174 int adjust =
option->state & State_Sunken ? 0 : 1;
187 const QPoint &point)
const
194 retPoint =
QPoint(point.
y(), point.
x());
206 case CE_ToolBoxTabShape: {
208 qstyleoption_cast<const QStyleOptionToolBox *>(
option);
217 int textWidth =
box->fontMetrics.horizontalAdvance(
box->text) + 20;
220 innerLine << (
box->rect.topLeft() +
QPoint(0, 1)) <<
221 (
box->rect.topLeft() +
QPoint(textWidth, 1)) <<
222 (
box->rect.bottomLeft() +
QPoint(textWidth + 15, -3)) <<
223 (
box->rect.bottomRight() +
QPoint(0, -3)) <<
224 box->rect.bottomRight() <<
225 box->rect.bottomLeft() <<
233 outerLine << (
box->rect.bottomRight() +
QPoint(0, -3)) <<
234 box->rect.bottomRight() <<
235 box->rect.bottomLeft() <<
236 box->rect.topLeft() <<
237 (
box->rect.topLeft() +
QPoint(textWidth, 0)) <<
238 (
box->rect.bottomLeft() +
QPoint(textWidth + 15, -4)) <<
239 (
box->rect.bottomRight() +
QPoint(0, -4));
248 case CE_DockWidgetTitle: {
250 qstyleoption_cast<const QStyleOptionDockWidget *>(
option);
259 r.top() + titleRect.
left() -
rect.left(),
271 gradient.setColorAt(1.0,
QColor(191, 212, 231));
273 gradient.setColorAt(0.0,
QColor(221, 232, 243));
293 case CE_RubberBand: {
302 case CE_HeaderSection: {
304 qstyleoption_cast<const QStyleOptionHeader *>(
option);
327 header->rect.bottomRight());
345 header->rect.bottomRight());
347 header->rect.bottomLeft());
349 header->rect.bottomRight());
363 gradient.setColorAt(1.0,
QColor(221, 221, 221));
364 gradient.setColorAt(0.0,
QColor(241, 241, 241));
366 if (
option->state & State_Horizontal) {
376 case CE_ProgressBar: {
378 qstyleoption_cast<const QStyleOptionProgressBar *>(
option);
384 m.translate(
rect.height()-1, 0);
392 QRect grooveRect = subElementRect(SE_ProgressBarGroove, bar,
400 grooveBar.
rect = grooveRect;
404 QRect progressRect = subElementRect(SE_ProgressBarContents, bar,
407 progressRect =
QRect(progressRect.
left(), progressRect.
top(),
409 progressRect.
adjust(0, 0, 0, -1);
412 progressOpt.
rect = progressRect;
415 QRect labelRect = subElementRect(SE_ProgressBarLabel, bar,
widget);
421 subBar.
rect = labelRect;
427 case CE_ProgressBarGroove: {
437 case CE_ProgressBarContents: {
439 qstyleoption_cast<const QStyleOptionProgressBar *>(
option);
440 int progress = int((
double(bar->
progress) /
458 case CE_ProgressBarLabel: {
461 qstyleoption_cast<const QStyleOptionProgressBar *>(
option);
466 int progressIndicatorPos = int((
double(bar->
progress) /
475 if (progressIndicatorPos >= 0 &&
476 progressIndicatorPos <=
rect.width()) {
478 QPoint(progressIndicatorPos,
480 }
else if (progressIndicatorPos >
rect.width()) {
500 case CE_MenuBarEmptyArea: {
505 gradient.setColorAt(1.0,
QColor(223, 223, 223));
512 case CE_MenuBarItem: {
513 if (!(
option->state & State_Sunken)) {
515 option->rect.bottomLeft());
517 gradient.setColorAt(1.0,
QColor(223, 223, 223));
526 if (
option->state & State_Sunken) {
539 qstyleoption_cast<const QStyleOptionMenuItem *>(
option);
541 bool selected = menuItem->
state & State_Selected;
544 bool checked = menuItem->
checked;
575 option->rect.center().y() - 5, 10, 10);
580 if (
button.state & State_Sunken)
581 button.state ^= State_Sunken;
602 bool dis = !(menuItem->
state & State_Enabled);
603 bool act = menuItem->
state & State_Selected;
625 pixelMetric(PM_SmallIconSize),
mode);
626 int pixw =
pixmap.width();
627 int pixh =
pixmap.height();
629 int adjustedIcon = checkable ? 15 : 0;
630 QRect pmr(0, 0, pixw, pixh);
631 pmr.moveCenter(vCheckRect.
center());
633 if (checkable && checked)
635 adjustedIcon, pmr.top() + 1),
pixmap);
648 int tab = menuitem->tabWidth;
654 int xm = windowsItemFrame + checkcol + windowsItemHMargin;
655 int xpos = menuitem->
rect.
x() + xm;
659 windowsRightBorder - tab + 1,
h - 2 * windowsItemVMargin);
662 y + windowsItemVMargin,
663 w - xm - windowsRightBorder - tab,
664 h - 2 * windowsItemVMargin);
676 if (!styleHint(SH_UnderlineShortcut, menuitem,
widget))
686 p->drawText(vShortcutRect.
adjusted(1, 1, 1, 1),
691 p->drawText(vShortcutRect, text_flags,
s.mid(
t + 1));
700 p->drawText(vTextRect.
adjusted(1,1,1,1), text_flags,
704 p->drawText(vTextRect, text_flags,
s.left(
t));
727 case CE_MenuVMargin: {
730 case CE_MenuHMargin: {
737 case CE_ScrollBarAddPage: {
738 case CE_ScrollBarSubPage:
740 qstyleoption_cast<const QStyleOptionSlider *>(
option);
763 case CE_ScrollBarSubLine: {
765 qstyleoption_cast<const QStyleOptionSlider *>(
option);
766 int scrollBarExtent = pixelMetric(PM_ScrollBarExtent);
774 16, scrollBarExtent);
776 scrollBarSubLine.
top(), 16, scrollBarExtent);
779 scrollBarExtent, 16);
781 scrollBarSubLine.
bottom() - 15, scrollBarExtent, 16);
790 case CE_ScrollBarAddLine: {
792 qstyleoption_cast<const QStyleOptionSlider *>(
option);
797 case CE_ScrollBarSlider: {
799 qstyleoption_cast<const QStyleOptionSlider *>(
option);
806 g1 =
option->rect.topLeft();
807 g2 =
option->rect.bottomLeft();
809 g1 =
option->rect.topLeft();
810 g2 =
option->rect.topRight();
815 gradient.setColorAt(1.0,
QColor(188, 210, 230));
817 gradient.setColorAt(0.0,
QColor(223, 233, 243));
825 int sliderLength =
option->rect.height();
827 (sliderLength / 2) + 1 : 1 - ((
option->rect.width() / 2));
831 origin =
option->rect.bottomLeft();
833 origin =
option->rect.topLeft();
839 origin + adjustScrollHandlePoint(
845 origin + adjustScrollHandlePoint(
847 QPoint(13, 2 - drawPos)));
851 origin + adjustScrollHandlePoint(
853 QPoint(13, 4 - drawPos)));
858 QPoint(3, -(drawPos + 1))),
859 origin + adjustScrollHandlePoint(
861 QPoint(12, -(drawPos + 1))));
865 origin + adjustScrollHandlePoint(
867 QPoint(12, 1 - drawPos)));
871 origin + adjustScrollHandlePoint(
873 QPoint(12, 3 - drawPos)));
877 case CE_TabBarTabLabel: {
878 QStyleOptionTab copy =
879 *qstyleoption_cast<const QStyleOptionTab *>(
option);
880 if (copy.state & State_HasFocus)
881 copy.state ^= State_HasFocus;
887 case CE_TabBarTabShape: {
888 const QStyleOptionTab *tab =
889 qstyleoption_cast<const QStyleOptionTab *>(
option);
891 QPoint bottomLeft, bottomRight, topLeft, topRight;
893 if ((tab->position == QStyleOptionTab::Beginning) ||
894 (tab->position == QStyleOptionTab::OnlyOneTab)) {
897 myRect = myRect.
adjusted(2, 0, 0, 0);
899 myRect = myRect.
adjusted(0, 2, 0, 0);
903 switch (tab->shape) {
933 outerPath.
moveTo(bottomLeft + adjustTabPoint(
QPoint(0, -2),
935 outerPath.
lineTo(bottomLeft + adjustTabPoint(
QPoint(0, -14),
937 outerPath.
lineTo(topLeft + adjustTabPoint(
QPoint(6 , 0),
939 outerPath.
lineTo(topRight + adjustTabPoint(
QPoint(0, 0),
941 outerPath.
lineTo(bottomRight + adjustTabPoint(
QPoint(0, -2),
944 if (tab->state & State_Selected ||
945 tab->position == QStyleOptionTab::OnlyOneTab) {
949 innerPath.
lineTo(topRight + adjustTabPoint(
QPoint(-1, 2),
951 innerPath.
lineTo(bottomRight + adjustTabPoint(
QPoint(-1 , -2),
953 innerPath.
lineTo(bottomLeft + adjustTabPoint(
QPoint(2 , -2),
955 innerPath.
lineTo(bottomLeft + adjustTabPoint(
QPoint(2 , -14),
961 whitePath.
moveTo(bottomLeft + adjustTabPoint(
QPoint(1, -2),
963 whitePath.
lineTo(bottomLeft + adjustTabPoint(
QPoint(1, -14),
967 whitePath.
lineTo(topRight + adjustTabPoint(
QPoint(-1, 1),
975 QPoint(2, -3), tab->shape),
976 bottomRight + adjustTabPoint(
977 QPoint(-2, 0), tab->shape)));
982 if (
option->state & State_HasFocus) {
992 case CE_PushButtonLabel:
996 qstyleoption_cast<const QStyleOptionButton *>(
option)) {
1010 if (
button->state & State_On)
1059 inline QPoint JavaStyle::adjustTabPoint(
const QPoint &point,
1066 rPoint =
QPoint(point.
y(), point.
x());
1069 rPoint =
QPoint(point.
x(), point.
y() * -1);
1072 rPoint =
QPoint(point.
y() * -1, point.
x());
1080 QRect JavaStyle::subControlRect(ComplexControl control,
1082 SubControl subControl,
1091 qstyleoption_cast<const QStyleOptionTitleBar *>(
option);
1093 switch (subControl) {
1094 case SC_TitleBarMinButton: {
1099 case SC_TitleBarMaxButton: {
1104 case SC_TitleBarCloseButton: {
1109 case SC_TitleBarLabel: {
1114 rect.adjust(0, 2, 2, 2);
1117 case SC_TitleBarSysMenu: {
1129 qstyleoption_cast<const QStyleOptionGroupBox *>(
option);
1130 bool hasCheckbox =
box->subControls & SC_GroupBoxCheckBox;
1131 int checkAdjust = 13;
1135 switch (subControl) {
1136 case SC_GroupBoxFrame: {
1140 case SC_GroupBoxCheckBox: {
1144 QSize(checkAdjust, checkAdjust));
1151 case SC_GroupBoxLabel: {
1156 case SC_GroupBoxContents: {
1167 const QStyleOptionSpinBox *
spinBox =
1168 qstyleoption_cast<const QStyleOptionSpinBox *>(
option);
1169 int spinnerWidth = 16;
1172 int frameWidth = pixelMetric(PM_SpinBoxFrameWidth,
spinBox,
widget);
1174 switch (subControl) {
1175 case SC_SpinBoxUp: {
1180 case SC_SpinBoxDown: {
1187 case SC_SpinBoxFrame: {
1192 case SC_SpinBoxEditField: {
1202 case CC_ToolButton: {
1204 qstyleoption_cast<const QStyleOptionToolButton *>(
option);
1206 switch (subControl) {
1207 case SC_ToolButton: {
1211 case SC_ToolButtonMenu: {
1221 qstyleoption_cast<const QStyleOptionComboBox *>(
option);
1225 switch (subControl) {
1226 case SC_ComboBoxFrame:
1229 case SC_ComboBoxArrow:
1238 case SC_ComboBoxEditField:
1247 case SC_ComboBoxListBoxPopup:
1253 case CC_ScrollBar: {
1255 qstyleoption_cast<const QStyleOptionSlider *>(
option);
1256 int scrollBarExtent = pixelMetric(PM_ScrollBarExtent,
scrollBar,
1261 int sliderMinLength = pixelMetric(PM_ScrollBarSliderMin,
scrollBar,
1270 if (sliderLength < sliderMinLength || valueRange > INT_MAX / 2)
1271 sliderLength = sliderMinLength;
1272 if (sliderLength > sliderMaxLength)
1273 sliderLength = sliderMaxLength;
1275 sliderLength = sliderMaxLength;
1280 sliderMaxLength - sliderLength,
1284 switch (subControl) {
1285 case SC_ScrollBarSubLine:
1287 rect.setRect(scrollBarRect.
left(), scrollBarRect.
top(),
1288 scrollBarRect.
width() - 16, scrollBarExtent);
1290 rect.setRect(scrollBarRect.
left(), scrollBarRect.
top(),
1291 scrollBarExtent, scrollBarRect.
height() - 16);
1294 case SC_ScrollBarAddLine:
1296 rect.setRect(scrollBarRect.
right() - 15,
1297 scrollBarRect.
top(), 16, scrollBarExtent);
1300 - 15, scrollBarExtent, 16);
1303 case SC_ScrollBarSubPage:
1305 rect.setRect(scrollBarRect.
left() + 16, scrollBarRect.
top(),
1306 sliderStart - (scrollBarRect.
left() + 16),
1309 rect.setRect(scrollBarRect.
left(), scrollBarRect.
top() + 16,
1311 sliderStart - (scrollBarRect.
left() + 16));
1314 case SC_ScrollBarAddPage:
1316 rect.setRect(sliderStart + sliderLength, 0,
1317 sliderMaxLength - sliderStart -
1318 sliderLength + 16, scrollBarExtent);
1320 rect.setRect(0, sliderStart + sliderLength,
1321 scrollBarExtent, sliderMaxLength -
1322 sliderStart - sliderLength + 16);
1324 case SC_ScrollBarGroove:
1331 case SC_ScrollBarSlider:
1333 rect.setRect(sliderStart, 0, sliderLength,
1336 rect.setRect(0, sliderStart, scrollBarExtent,
1347 const QStyleOptionSlider *slider =
1348 qstyleoption_cast<const QStyleOptionSlider *>(
option);
1349 rect = slider->rect;
1350 int tickSize = pixelMetric(PM_SliderTickmarkOffset,
option,
widget);
1351 int handleSize = pixelMetric(PM_SliderControlThickness,
option,
1355 slider->rect.width();
1357 slider->maximum, slider->sliderValue,
dist - handleSize);
1359 switch (subControl) {
1360 case SC_SliderGroove: {
1364 rect.setHeight(handleSize);
1369 rect.adjust(0, 0, 0, 0);
1370 rect.setWidth(handleSize);
1378 case SC_SliderHandle: {
1382 rect.setHeight(handleSize);
1389 if (slider->upsideDown)
1390 rect.setLeft(slider->rect.right() -
1391 pos - (handleSize - 1));
1395 rect.setWidth(handleSize - 1);
1397 rect.setWidth(handleSize);
1404 if (slider->upsideDown)
1405 rect.setTop(slider->rect.bottom() -
1406 ((
pos + handleSize) - 2));
1408 rect.setTop(slider->rect.top() +
pos);
1410 rect.setHeight(handleSize);
1414 case SC_SliderTickmarks: {
1419 rect.setHeight(tickSize);
1420 center.ry() += tickSize / 2;
1421 rect.adjust(6, 0, -10, 0);
1423 rect.setWidth(tickSize);
1424 center.rx() += tickSize / 2;
1425 rect.adjust(0, 6, 0, -10);
1445 static const char *
const sliderHandleImage[] = {
1472 void JavaStyle::drawComplexControl(ComplexControl control,
1482 qstyleoption_cast<const QStyleOptionTitleBar *>(
option);
1484 bool sunken = bar->
state & State_Sunken;
1488 gradient.setColorAt(0.0,
QColor(191, 212, 231));
1490 gradient.setColorAt(1.0,
QColor(221, 232, 243));
1506 QRect minButtonRect = subControlRect(control, bar,
1507 SC_TitleBarMinButton);
1508 QRect maxButtonRect = subControlRect(control, bar,
1509 SC_TitleBarMaxButton);
1510 QRect closeButtonRect = subControlRect(control, bar,
1511 SC_TitleBarCloseButton);
1512 QRect systemButtonRect = subControlRect(control, bar,
1513 SC_TitleBarSysMenu);
1514 QRect labelRect = subControlRect(control, bar, SC_TitleBarLabel);
1529 for (
int i = 0;
i < gripRect.
width(); ++
i) {
1533 for (
int j = 0;
j < 4; ++
j) {
1535 gripRect.
top() - 2 +
i % 4 + 4 *
j);
1539 QPixmap maximizePixmap(
":/images/internalmaximize.png");
1540 QPixmap minimizePixmap(
":/images/internalminimize.png");
1541 QPixmap closePixmap(
":/images/internalclose.png");
1542 QPixmap internalPixmap(
":/images/internalsystem.png");
1543 QPixmap internalCloseDownPixmap(
":/images/internalclosedown.png");
1544 QPixmap minimizeDownPixmap(
":/images/internalminimizedown.png");
1545 QPixmap maximizeDownPixmap(
":/images/internalmaximizedown.png");
1548 bar->
state & State_Sunken)
1550 internalCloseDownPixmap);
1555 bar->
state & State_Sunken)
1557 minimizeDownPixmap);
1562 bar->
state & State_Sunken)
1564 maximizeDownPixmap);
1574 qstyleoption_cast<const QStyleOptionGroupBox *>(
option);
1576 QRect frameRect = subControlRect(control,
box, SC_GroupBoxFrame);
1577 QRect labelRect = subControlRect(control,
box, SC_GroupBoxLabel);
1578 QRect contentsRect = subControlRect(control,
box,
1579 SC_GroupBoxContents);
1580 QRect checkerRect = subControlRect(control,
box,
1581 SC_GroupBoxCheckBox);
1591 if (
box->subControls & SC_GroupBoxCheckBox) {
1593 checkerRect.
right() + 2,
y);
1595 checker.QStyleOption::operator=(*box);
1596 checker.
rect = checkerRect;
1600 if (
box->subControls & SC_GroupBoxLabel && !
box->text.isEmpty()) {
1602 labelRect.
right() +1,
y);
1610 box->palette,
box->state & State_Enabled,
1617 const QStyleOptionSpinBox *spinner =
1618 qstyleoption_cast<const QStyleOptionSpinBox *>(
option);
1620 QRect frameRect = subControlRect(control, spinner, SC_SpinBoxFrame);
1621 QRect upRect = subControlRect(control, spinner, SC_SpinBoxUp);
1622 QRect downRect = subControlRect(control, spinner, SC_SpinBoxDown);
1631 bool isEnabled = (spinner->state & State_Enabled);
1632 bool hover = isEnabled && (spinner->state & State_MouseOver);
1633 bool sunken = (spinner->state & State_Sunken);
1634 bool upIsActive = (spinner->activeSubControls == SC_SpinBoxUp);
1635 bool downIsActive = (spinner->activeSubControls == SC_SpinBoxDown);
1636 bool stepUpEnabled = spinner->stepEnabled &
1638 bool stepDownEnabled = spinner->stepEnabled &
1644 if (upIsActive && stepUpEnabled) {
1646 drawSunkenButtonShadow(
painter, upRect,
1649 drawButtonHoverFrame(
painter, upRect,
1655 QStyleOptionSpinBox upSpin = *spinner;
1656 upSpin.rect = upRect;
1660 if (downIsActive && stepDownEnabled) {
1662 drawSunkenButtonShadow(
painter, downRect,
1665 drawButtonHoverFrame(
painter, downRect,
1671 QStyleOptionSpinBox downSpin = *spinner;
1672 downSpin.rect = downRect;
1677 case CC_ToolButton: {
1679 qstyleoption_cast<const QStyleOptionToolButton *>(
option);
1686 if (!(
button->state & State_MouseOver) &&
1687 !(
button->state & State_On)) {
1691 panelRect = subControlRect(control,
option, SC_ToolButton);
1692 panelOption.
rect = panelRect;
1697 QRect menuRect = subControlRect(control,
option, SC_ToolButtonMenu);
1702 menuOption.
rect = menuRect;
1708 if (
button->subControls & SC_ToolButtonMenu) {
1713 if (
button->state & State_HasFocus) {
1724 qstyleoption_cast<const QStyleOptionComboBox *>(
option);
1726 QRect frameRect = subControlRect(control,
option, SC_ComboBoxFrame,
1730 if (
option->state & State_HasFocus)
1737 QRect arrowRect = subControlRect(control,
option, SC_ComboBoxArrow,
1755 if (
button.state & State_On)
1756 button.state ^= State_On;
1778 SC_ComboBoxEditField,
widget);
1783 const QStyleOptionSlider *slider =
1784 qstyleoption_cast<const QStyleOptionSlider *>(
option);
1788 QRect groove = subControlRect(control,
option, SC_SliderGroove,
1790 QRect ticks = subControlRect(control,
option, SC_SliderTickmarks,
1798 handle.bottomRight() + xySwitch(
QPoint(-4, -6), horizontal));
1800 if (slider->upsideDown || !horizontal) {
1802 remember = afterHandle;
1803 afterHandle = beforeHandle;
1804 beforeHandle = remember;
1827 gradient.setColorAt(1.0,
QColor(188, 210, 230));
1829 gradient.setColorAt(0.0,
QColor(223, 233, 243));
1838 QPoint topLeft, topRight, bottomLeft;
1840 topLeft =
handle.topLeft();
1841 topRight =
handle.topRight();
1842 bottomLeft =
handle.bottomLeft();
1844 topLeft =
handle.bottomLeft();
1845 topRight =
handle.topLeft();
1846 bottomLeft =
handle.topRight();
1857 if (!(slider->state & State_Enabled)) {
1865 QImage image(
":/images/verticalsliderhandle.png");
1871 int tickInterval = slider->tickInterval ? slider->tickInterval :
1874 for (
int i = 0;
i <= slider->maximum;
i += tickInterval) {
1876 int pos = int(((
i /
double(slider->maximum)) *
1877 ticks.
width()) - 1);
1881 int pos = int(((
i /
double(slider->maximum)) *
1905 const QColor &frameColor,
1927 const QColor &frameColor,
1928 const QColor &activeFrame)
const
1934 rect.adjust(1, 1, -1, -1);
1937 rect.adjust(1, 1, -1, -1);
1949 SubControl
ret = SC_None;
1954 qstyleoption_cast<const QStyleOptionTitleBar *>(
option);
1956 QRect maximize = subControlRect(control, bar, SC_TitleBarMaxButton);
1958 ret = SC_TitleBarMaxButton;
1961 QRect minimize = subControlRect(control, bar, SC_TitleBarMinButton);
1963 ret = SC_TitleBarMinButton;
1966 QRect close = subControlRect(control, bar, SC_TitleBarCloseButton);
1968 ret = SC_TitleBarCloseButton;
1971 QRect system = subControlRect(control, bar, SC_TitleBarSysMenu);
1973 ret = SC_TitleBarSysMenu;
1976 ret = SC_TitleBarLabel;
1980 if (
const QStyleOptionSlider *
scrollBar =
1981 qstyleoption_cast<const QStyleOptionSlider *>(
option)) {
1983 SC_ScrollBarSlider,
widget);
1985 ret = SC_ScrollBarSlider;
1990 SC_ScrollBarAddLine,
widget);
1992 ret = SC_ScrollBarAddLine;
1997 SC_ScrollBarSubPage,
widget);
1999 ret = SC_ScrollBarSubPage;
2004 SC_ScrollBarAddPage,
widget);
2006 ret = SC_ScrollBarAddPage;
2011 SC_ScrollBarSubLine,
widget);
2013 ret = SC_ScrollBarSubLine;
2028 if (qobject_cast<QCheckBox *>(
widget) ||
2029 qobject_cast<QRadioButton *>(
widget) ||
2030 qobject_cast<QPushButton *>(
widget) ||
2031 qobject_cast<QToolButton *>(
widget) ||
2032 qobject_cast<QSpinBox *>(
widget) ||
2033 qobject_cast<QGroupBox *>(
widget))
2039 if (qobject_cast<QPushButton *>(
widget) ||
2040 qobject_cast<QCheckBox *>(
widget) ||
2041 qobject_cast<QRadioButton *>(
widget) ||
2042 qobject_cast<QToolButton *>(
widget) ||
2043 qobject_cast<QSpinBox *>(
widget) ||
2044 qobject_cast<QGroupBox *>(
widget))
2049 bool horizontal)
const
2063 rect.y() +
i), horizontal));
2067 inline QPoint JavaStyle::xySwitch(
const QPoint &point,
bool horizontal)
const
2072 retPoint =
QPoint(point.
y(), point.
x());
2086 case PE_PanelButtonBevel:
2087 case PE_FrameButtonBevel: {
2095 case PE_IndicatorBranch: {
2097 QColor lineColor(204, 204, 255);
2098 QPixmap openPixmap(
":/images/jtreeopen.png");
2099 QPixmap closedPixmap(
":/images/jtreeclosed.png");
2101 pixmapRect.moveCenter(
option->rect.center());
2102 pixmapRect.translate(2, 0);
2108 if (
option->state & State_Item) {
2115 if (
option->state & State_Sibling) {
2120 if (
option->state & State_Children)
2121 if (
option->state & State_Open)
2125 }
else if (
option->state & State_Sibling) {
2133 case PE_IndicatorItemViewItemCheck: {
2136 case PE_FrameWindow: {
2138 bool active =
option->state & State_Active;
2180 case PE_IndicatorSpinUp: {
2181 const QStyleOptionSpinBox *spinner =
2182 qstyleoption_cast<const QStyleOptionSpinBox *>(
option);
2183 int add = spinner->state & State_Sunken &&
2184 spinner->activeSubControls & SC_SpinBoxUp ? 1 : 0;
2192 case PE_IndicatorSpinDown: {
2193 const QStyleOptionSpinBox *spinner =
2194 qstyleoption_cast<const QStyleOptionSpinBox *>(
option);
2196 int add = spinner->state & State_Sunken &&
2197 spinner->activeSubControls & SC_SpinBoxDown ? 1 : 0;
2204 case PE_FrameDockWidget: {
2208 case PE_IndicatorToolBarHandle: {
2210 bool horizontal =
option->state & State_Horizontal;
2235 case PE_IndicatorToolBarSeparator: {
2238 case PE_PanelButtonTool: {
2240 qstyleoption_cast<const QStyleOptionToolButton *>(
option);
2244 if (!(
option->state & State_Enabled))
2250 if (
button->state & State_MouseOver ||
button->state & State_On) {
2256 drawButtonBackground(&bevel,
painter,
false);
2265 case PE_FrameMenu: {
2270 case PE_PanelButtonCommand: {
2272 qstyleoption_cast<const QStyleOptionButton *>(
option);
2273 bool hover = (
btn->
state & State_Enabled) &&
2275 bool sunken =
btn->
state & State_Sunken;
2277 bool on =
option->state & State_On;
2282 if (hover && !sunken && !isDefault && !on) {
2286 }
else if (isDefault) {
2291 case PE_FrameDefaultButton: {
2299 case PE_IndicatorCheckBox: {
2303 if (
option->state & State_Enabled &&
2304 option->state & State_MouseOver &&
2305 !(
option->state & State_Sunken)) {
2309 rect =
rect.adjusted(1, 1, -1, -1);
2313 if (
option->state & State_On) {
2321 case PE_IndicatorRadioButton: {
2325 if (!(
option->state & State_Sunken) &&
2326 option->state & State_Enabled)
2327 radioBrush = gradientBrush(
option->rect);
2330 if (
option->state & State_Enabled)
2337 if (
option->state & State_MouseOver &&
2338 option->state & State_Enabled &&
2339 !(
option->state & State_Sunken)) {
2340 gradientBrush(
option->rect);
2345 rect =
rect.adjusted(1, 1, -1, -1);
2349 if (
option->state & State_On) {
2354 if (
option->state & State_Sunken &&
2355 option->state & State_Enabled) {
2363 case PE_FrameTabWidget: {
2371 case PE_FrameLineEdit: {
2373 qstyleoption_cast<const QStyleOptionFrame *>(
option);
2387 case PE_FrameFocusRect: {
2406 bool sunken =
option->state & State_Sunken;
2408 bool on =
option->state & State_On;
2410 if (!sunken && !
disabled && (!on || isCheckbox))
2411 buttonBrush = gradientBrush(
option->rect);
2436 gradient.setColorAt(1.0,
QColor(188, 210, 230));
2438 gradient.setColorAt(0.0,
QColor(223, 233, 243));
2443 QRect JavaStyle::subElementRect(SubElement element,
2450 case SE_ToolBoxTabContents: {
2452 qstyleoption_cast<const QStyleOptionToolBox *>(
option);
2455 rect.setHeight(
box->rect.height() - 4);
2456 rect.setWidth(
box->fontMetrics.horizontalAdvance(
box->text) + 15);
2459 case SE_ProgressBarLabel:
2460 case SE_ProgressBarGroove:
2461 case SE_ProgressBarContents: {
2465 case SE_PushButtonFocusRect: {
2467 qstyleoption_cast<const QStyleOptionButton *>(
option);
2477 rect.adjust(-1, -1, 1, 1);
2482 rect.adjust(-1, 0, 1, 0);
2492 int JavaStyle::pixelMetric(PixelMetric metric,
2499 case PM_ButtonShiftHorizontal:
2500 case PM_ButtonShiftVertical:
2501 case PM_TabBarTabShiftHorizontal:
2502 case PM_ButtonDefaultIndicator:
2503 case PM_TabBarTabShiftVertical:
2506 case PM_TabBarBaseOverlap:
2507 case PM_DefaultFrameWidth:
2510 case PM_TabBarTabVSpace:
2513 case PM_ScrollBarExtent:
2516 case PM_ScrollBarSliderMin:
2519 case PM_SplitterWidth:
2522 case PM_SliderThickness:
2525 case PM_SliderControlThickness:
2528 case PM_SliderTickmarkOffset:
2531 case PM_SliderSpaceAvailable:
2533 case PM_MenuPanelWidth:
2536 case PM_MenuVMargin:
2539 case PM_MenuBarPanelWidth:
2542 case PM_MenuBarItemSpacing:
2545 case PM_MenuBarHMargin:
2548 case PM_MenuBarVMargin:
2551 case PM_ComboBoxFrameWidth:
2554 case PM_MenuButtonIndicator:
2557 case PM_ToolBarItemMargin:
2560 case PM_ToolBarHandleExtent:
2563 case PM_SpinBoxFrameWidth:
2566 case PM_TitleBarHeight: {
2569 case PM_MDIFrameWidth:
2573 case PM_DockWidgetFrameWidth: {
2591 case SH_Table_GridLineColor: {
2604 QPixmap JavaStyle::standardPixmap(StandardPixmap standardPixmap,
2611 QPixmap maximizePixmap(
":/images/internalmaximize.png");
2612 QPixmap minimizePixmap(
":/images/internalminimize.png");
2613 QPixmap closePixmap(
":/images/internalclose.png");
2614 QPixmap internalPixmap(
":/images/internalsystem.png");
2615 QPixmap internalCloseDownPixmap(
":/images/internalclosedown.png");
2616 QPixmap minimizeDownPixmap(
":/images/internalminimizedown.png");
2617 QPixmap maximizeDownPixmap(
":/images/internalmaximizedown.png");
2618 QPixmap dirOpenPixmap(
":/images/open24.png");
2619 QPixmap filePixmap(
":/images/file.png");
2621 switch (standardPixmap) {
2622 case SP_DirLinkIcon:
2623 case SP_DirClosedIcon:
2625 case SP_DirOpenIcon: {
2633 case SP_FileDialogBack: {
2637 case SP_FileDialogToParent: {
2641 case SP_FileDialogNewFolder: {
2645 case SP_FileDialogListView: {
2649 case SP_FileDialogDetailedView: {
2653 case SP_MessageBoxInformation: {
2657 case SP_MessageBoxWarning: {
2660 case SP_MessageBoxCritical: {
2664 case SP_MessageBoxQuestion: {
2668 case SP_TitleBarNormalButton:
2671 case SP_TitleBarCloseButton:
2681 QSize JavaStyle::sizeFromContents(ContentsType
type,
2683 const QSize &contentsSize,
2691 const QStyleOptionSlider *slider =
2692 qstyleoption_cast<const QStyleOptionSlider *>(
option);
2696 return contentsSize;
2699 case CT_MenuBarItem: {
2701 qstyleoption_cast<const QStyleOptionMenuItem *>(
option);
2713 qstyleoption_cast<const QStyleOptionMenuItem *>(
option);
small capitals from c petite p scientific i
[1]
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
The QBrush class defines the fill pattern of shapes drawn by QPainter.
const QColor & color() const
The QColor class provides colors based on RGB, HSV or CMYK values.
bool isValid() const noexcept
int pixelMetric(PixelMetric m, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr) const override
QSize sizeFromContents(ContentsType ct, const QStyleOption *opt, const QSize &contentsSize, const QWidget *widget=nullptr) const override
QRect subElementRect(SubElement r, const QStyleOption *opt, const QWidget *widget=nullptr) const override
QPixmap standardPixmap(StandardPixmap sp, const QStyleOption *opt=nullptr, const QWidget *widget=nullptr) const override
void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const override
SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *w=nullptr) const override
int styleHint(StyleHint sh, const QStyleOption *opt=nullptr, const QWidget *w=nullptr, QStyleHintReturn *shret=nullptr) const override
QRect subControlRect(ComplexControl cc, const QStyleOptionComplex *opt, SubControl sc, const QWidget *w=nullptr) const override
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w=nullptr) const override
void drawPrimitive(PrimitiveElement pe, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const override
The QFont class specifies a query for a font used for drawing text.
The QFontMetrics class provides font metrics information.
QRect boundingRect(QChar) const
int horizontalAdvance(const QString &, int len=-1) const
QPixmap pixmap(const QSize &size, Mode mode=Normal, State state=Off) const
The QImage class provides a hardware-independent image representation that allows direct access to th...
The QLine class provides a two-dimensional vector using integer precision.
The QLinearGradient class is used in combination with QBrush to specify a linear gradient brush.
The QPainter class performs low-level painting on widgets and other paint devices.
void drawPoint(const QPointF &pt)
void drawRect(const QRectF &rect)
void drawPath(const QPainterPath &path)
void setClipRect(const QRectF &, Qt::ClipOperation op=Qt::ReplaceClip)
void setPen(const QColor &color)
void drawLine(const QLineF &line)
const QFont & font() const
void drawImage(const QRectF &targetRect, const QImage &image, const QRectF &sourceRect, Qt::ImageConversionFlags flags=Qt::AutoColor)
void setFont(const QFont &f)
void drawText(const QPointF &p, const QString &s)
void drawPolyline(const QPointF *points, int pointCount)
void drawPixmap(const QRectF &targetRect, const QPixmap &pixmap, const QRectF &sourceRect)
void drawArc(const QRectF &rect, int a, int alen)
void drawEllipse(const QRectF &r)
void setBrush(const QBrush &brush)
void drawPolygon(const QPointF *points, int pointCount, Qt::FillRule fillRule=Qt::OddEvenFill)
void translate(const QPointF &offset)
void fillRect(const QRectF &, const QBrush &)
void setTransform(const QTransform &transform, bool combine=false)
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
void moveTo(const QPointF &p)
void lineTo(const QPointF &p)
The QPalette class contains color groups for each widget state.
const QBrush & button() const
const QBrush & text() const
const QBrush & light() const
const QColor & color(ColorGroup cg, ColorRole cr) const
const QBrush & buttonText() const
const QBrush & highlightedText() const
The QPixmap class is an off-screen image representation that can be used as a paint device.
The QPoint class defines a point in the plane using integer precision.
constexpr int & rx() noexcept
constexpr int x() const noexcept
constexpr int y() const noexcept
The QPolygon class provides a list of points using integer precision. \inmodule QtGui.
The QRect class defines a rectangle in the plane using integer precision.
constexpr QPoint bottomLeft() const noexcept
constexpr void adjust(int x1, int y1, int x2, int y2) noexcept
constexpr void moveCenter(const QPoint &p) noexcept
constexpr void getRect(int *x, int *y, int *w, int *h) const
constexpr int height() const noexcept
constexpr bool isNull() const noexcept
constexpr int bottom() const noexcept
constexpr QPoint topLeft() const noexcept
constexpr QRect adjusted(int x1, int y1, int x2, int y2) const noexcept
constexpr int top() const noexcept
constexpr QPoint topRight() const noexcept
bool contains(const QRect &r, bool proper=false) const noexcept
constexpr int left() const noexcept
constexpr void setRect(int x, int y, int w, int h) noexcept
constexpr int x() const noexcept
constexpr QSize size() const noexcept
constexpr void translate(int dx, int dy) noexcept
constexpr QPoint bottomRight() const noexcept
constexpr int width() const noexcept
constexpr int y() const noexcept
constexpr QPoint center() const noexcept
constexpr int right() const noexcept
The QSize class defines the size of a two-dimensional object using integer point precision.
constexpr int height() const noexcept
constexpr int width() const noexcept
The QString class provides a Unicode character string.
static QString static QString qsizetype indexOf(QChar c, qsizetype from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QString & remove(qsizetype i, qsizetype len)
the exposed rectangle, in item coordinates
virtual QPalette standardPalette() const
static int sliderPositionFromValue(int min, int max, int val, int space, bool upsideDown=false)
an OR combination of the tool button's features
QStyle::SubControls activeSubControls
the background color on which the focus rectangle is being drawn
a bitwise OR of the features that describe this frame.
The QStyleOption class stores the parameters used by QStyle functions.
Qt::LayoutDirection direction
a bitwise OR of the features that describe this button
the position of the selected tab in relation to this tab
The QTextOption class provides a description of general rich text properties. \inmodule QtGui.
void drawControl(ControlElement element, QPainter *painter, const QWidget *widget, const QRect &rect, const QColorGroup &colorGroup, SFlags how=Style_Default, const QStyleOption &option=QStyleOption::Default) const
[1]
drawPrimitive(PE_IndicatorCheckBox, &subopt, p, widget)
const QStyleOptionButton * btn
[3]
QTextStream & center(QTextStream &stream)
EGLOutputLayerEXT EGLint EGLAttrib value
GLuint64 GLenum void * handle
GLint GLint GLint GLint GLint x
[0]
GLfloat GLfloat GLfloat w
[0]
GLint GLsizei GLsizei height
GLsizei GLenum const void GLuint GLsizei GLfloat * metrics
GLuint GLsizei const GLchar * label
[43]
GLenum GLuint GLintptr offset
GLfloat GLfloat GLfloat GLfloat h
std::uniform_real_distribution dist(1, 2.5)
[2]
QHttpRequestHeader header("GET", QUrl::toPercentEncoding("/index.html"))
[1]
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
void add(int &result, const int &sum)