49#include <QtCore/qalgorithms.h>
50#include <QtCore/QCache>
51#include <QtCore/QEvent>
52#include <QtCore/QVariant>
53#include <QtGui/QAbstractItemView>
54#include <QtGui/QApplication>
55#include <QtGui/QDialogButtonBox>
56#include <QtGui/QFormLayout>
58#include <QtGui/QLabel>
59#include <QtGui/QKeyEvent>
60#include <QtGui/QPainter>
61#include <QtGui/QScrollBar>
62#include <QtGui/QStyleOption>
74static const qint32
u_arrow[]={-1,-3, 0,-3, -2,-2, 1,-2, -3,-1, 2,-1, -4,0, 3,0, -4,1, 3,1};
75static const qint32
d_arrow[]={-4,-2, 3,-2, -4,-1, 3,-1, -3,0, 2,0, -2,1, 1,1, -1,2, 0,2};
76static const qint32
l_arrow[]={-3,-1, -3,0, -2,-2, -2,1, -1,-3, -1,2, 0,-4, 0,3, 1,-4, 1,3};
77static const qint32
r_arrow[]={-2,-4, -2,3, -1,-4, -1,3, 0,-3, 0,2, 1,-2, 1,1, 2,-1, 2,0};
78#define QCOORDARRLEN(x) sizeof(x)/(sizeof(qint32)*2)
95 QPixmap left, center, right;
108 QCache<quint64, SelectionTiles> selectionCache;
112 int hintCounter, controlCounter, subElementCounter;
115KStylePrivate::KStylePrivate() : m_componentData()
122 QString
name(QApplication::applicationName());
132 selectionCache.setMaxCost(10);
133 controlCounter = subElementCounter =
X_KdeBase;
210 ColorMode(ColorMode::BWAutoContrastMode, QPalette::Button));
212 ColorMode(ColorMode::BWAutoContrastMode, QPalette::ButtonText));
281#warning "mem leak: need to delete bOpt"
333 if (!element.contains(check))
335 int id = elements->value(element, 0);
339 elements->insert(element,
id);
346 return (StyleHint)
newStyleElement(element,
"SH_", d->hintCounter, &d->styleElements);
351 return (ControlElement)
newStyleElement(element,
"CE_", d->controlCounter, &d->styleElements);
356 return (SubElement)
newStyleElement(element,
"SE_", d->subElementCounter, &d->styleElements);
362#if defined(Q_WS_X11) && !defined(Q_WS_MAEMO_5) || defined(Q_WS_WIN)
363 return QString(
"oxygen");
376 if (!widget || widget->style()->metaObject()->indexOfClassInfo(
"X-KDE-CustomElements") < 0)
379 const QString originalName = widget->objectName();
380 widget->setObjectName(element);
381 const int id = widget->style()->styleHint(type, 0, widget);
382 widget->setObjectName(originalName);
403 if (qobject_cast<QLabel*>(w) ) {
404 w->installEventFilter(
this);
408 if (QAbstractItemView *itemView = qobject_cast<QAbstractItemView*>(w) ) {
409 itemView->viewport()->setAttribute(Qt::WA_Hover);
412 QCommonStyle::polish(w);
416 if (qobject_cast<QLabel*>(w) ) {
417 w->removeEventFilter(
this);
420 QCommonStyle::unpolish(w);
424 QCommonStyle::polish(a);
428 QCommonStyle::unpolish(a);
432 QCommonStyle::polish(pal);
435 int flags,
bool enabled,
436 const QString &text)
const
438 return QCommonStyle::itemTextRect(fm, r, flags, enabled, text);
442 return QCommonStyle::itemPixmapRect(r, flags, pixmap);
445 int flags,
const QPalette &pal,
bool enabled,
446 const QString &text, QPalette::ColorRole textRole)
const
448 QCommonStyle::drawItemText(painter, rect, flags, pal, enabled,
452 int alignment,
const QPixmap &pixmap)
const
454 QCommonStyle::drawItemPixmap(painter, rect, alignment, pixmap);
465 switch (standardIcon) {
466 case QStyle::SP_DesktopIcon:
467 return KIcon(
"user-desktop");
468 case QStyle::SP_TrashIcon:
469 return KIcon(
"user-trash");
470 case QStyle::SP_ComputerIcon:
471 return KIcon(
"computer");
472 case QStyle::SP_DriveFDIcon:
473 return KIcon(
"media-floppy");
474 case QStyle::SP_DriveHDIcon:
475 return KIcon(
"drive-harddisk");
476 case QStyle::SP_DriveCDIcon:
477 case QStyle::SP_DriveDVDIcon:
478 return KIcon(
"drive-optical");
479 case QStyle::SP_DriveNetIcon:
480 return KIcon(
"folder-remote");
481 case QStyle::SP_DirHomeIcon:
482 return KIcon(
"user-home");
483 case QStyle::SP_DirOpenIcon:
484 return KIcon(
"document-open-folder");
485 case QStyle::SP_DirClosedIcon:
486 return KIcon(
"folder");
487 case QStyle::SP_DirIcon:
488 return KIcon(
"folder");
489 case QStyle::SP_DirLinkIcon:
490 return KIcon(
"folder");
491 case QStyle::SP_FileIcon:
492 return KIcon(
"text-plain");
493 case QStyle::SP_FileLinkIcon:
494 return KIcon(
"text-plain");
495 case QStyle::SP_FileDialogStart:
496 return KIcon(
"media-playback-start");
497 case QStyle::SP_FileDialogEnd:
498 return KIcon(
"media-playback-stop");
499 case QStyle::SP_FileDialogToParent:
500 return KIcon(
"go-up");
501 case QStyle::SP_FileDialogNewFolder:
502 return KIcon(
"folder-new");
503 case QStyle::SP_FileDialogDetailedView:
504 return KIcon(
"view-list-details");
505 case QStyle::SP_FileDialogInfoView:
506 return KIcon(
"document-properties");
507 case QStyle::SP_FileDialogContentsView:
508 return KIcon(
"view-list-icons");
509 case QStyle::SP_FileDialogListView:
510 return KIcon(
"view-list-text");
511 case QStyle::SP_FileDialogBack:
512 return KIcon(
"go-previous");
513 case QStyle::SP_MessageBoxInformation:
514 return KIcon(
"dialog-information");
515 case QStyle::SP_MessageBoxWarning:
516 return KIcon(
"dialog-warning");
517 case QStyle::SP_MessageBoxCritical:
518 return KIcon(
"dialog-error");
519 case QStyle::SP_MessageBoxQuestion:
520 return KIcon(
"dialog-information");
521 case QStyle::SP_DialogOkButton:
522 return KIcon(
"dialog-ok");
523 case QStyle::SP_DialogCancelButton:
524 return KIcon(
"dialog-cancel");
525 case QStyle::SP_DialogHelpButton:
526 return KIcon(
"help-contents");
527 case QStyle::SP_DialogOpenButton:
528 return KIcon(
"document-open");
529 case QStyle::SP_DialogSaveButton:
530 return KIcon(
"document-save");
531 case QStyle::SP_DialogCloseButton:
532 return KIcon(
"dialog-close");
533 case QStyle::SP_DialogApplyButton:
534 return KIcon(
"dialog-ok-apply");
535 case QStyle::SP_DialogResetButton:
536 return KIcon(
"document-revert");
537 case QStyle::SP_DialogDiscardButton:
538 return KIcon(
"dialog-cancel");
539 case QStyle::SP_DialogYesButton:
540 return KIcon(
"dialog-ok-apply");
541 case QStyle::SP_DialogNoButton:
542 return KIcon(
"dialog-cancel");
543 case QStyle::SP_ArrowUp:
544 return KIcon(
"go-up");
545 case QStyle::SP_ArrowDown:
546 return KIcon(
"go-down");
547 case QStyle::SP_ArrowLeft:
548 return KIcon(
"go-previous-view");
549 case QStyle::SP_ArrowRight:
550 return KIcon(
"go-next-view");
551 case QStyle::SP_ArrowBack:
552 return KIcon(
"go-previous");
553 case QStyle::SP_ArrowForward:
554 return KIcon(
"go-next");
555 case QStyle::SP_BrowserReload:
556 return KIcon(
"view-refresh");
557 case QStyle::SP_BrowserStop:
558 return KIcon(
"process-stop");
559 case QStyle::SP_MediaPlay:
560 return KIcon(
"media-playback-start");
561 case QStyle::SP_MediaStop:
562 return KIcon(
"media-playback-stop");
563 case QStyle::SP_MediaPause:
564 return KIcon(
"media-playback-pause");
565 case QStyle::SP_MediaSkipForward:
566 return KIcon(
"media-skip-forward");
567 case QStyle::SP_MediaSkipBackward:
568 return KIcon(
"media-skip-backward");
569 case QStyle::SP_MediaSeekForward:
570 return KIcon(
"media-seek-forward");
571 case QStyle::SP_MediaSeekBackward:
572 return KIcon(
"media-seek-backward");
573 case QStyle::SP_MediaVolume:
574 return KIcon(
"audio-volume-medium");
575 case QStyle::SP_MediaVolumeMuted:
576 return KIcon(
"audio-volume-muted");
579 return QStyle::standardIconImplementation(standardIcon, option, widget);
586 return QCommonStyle::standardPixmap(standardPixmap, opt, widget);
589 const QStyleOption *opt)
const
591 return QCommonStyle::generatedIconPixmap(iconMode, pixmap, opt);
596 p->drawRect(r.x(), r.y(), r.width() - 1, r.height() - 1);
601 return QRect(in.x() + (in.width() - w)/2, in.y() + (in.height() - h)/2, w, h);
606 return centerRect(in, size.width(), size.height());
612 const QStyleOption* opt,
613 const QRect &r,
const QPalette &pal,
614 State flags, QPainter* p,
624 case Tree::VerticalBranch:
625 case Tree::HorizontalBranch:
627 p->fillRect(r, QBrush(Qt::Dense4Pattern));
629 case Tree::ExpanderOpen:
630 case Tree::ExpanderClosed:
632 p->setPen(pal.text().color());
634 int signLineSize = r.width()/4;
635 p->drawLine(r.center().x() - signLineSize, r.center().y(),
636 r.center().x() + signLineSize, r.center().y());
637 if (primitive == Tree::ExpanderClosed)
638 p->drawLine(r.center().x(), r.center().y() - signLineSize,
639 r.center().x(), r.center().y() + signLineSize);
653 case SpinBox::PlusSymbol:
654 case SpinBox::MinusSymbol:
656 p->setPen( pal.buttonText().color() );
658 int l = qMin( r.width()-2, r.height()-2 );
659 QPoint c = r.center();
661 p->drawLine( c.x()-l/2, c.y(), c.x()+l/2, c.y() );
662 if (primitive == SpinBox::PlusSymbol ) {
663 p->drawLine( c.x(), c.y()-l/2, c.x(), c.y()+l/2 );
677 if (primitive == GroupBox::FlatFrame) {
678 QPen oldPen = p->pen();
679 p->setPen(pal.color(QPalette::WindowText) );
680 p->drawLine(r.topLeft(), r.topRight() );
689 if (primitive == ToolBoxTab::Panel) {
700 case DockWidget::TitlePanel:
701 p->fillRect(r, pal.color(QPalette::Highlight) );
704 case DockWidget::SeparatorHandle:
718 case Window::TitlePanel:
719 p->fillRect(r, pal.color(QPalette::Highlight) );
722 case Window::ButtonMenu:
725 extractOption<KStyle::TitleButtonOption*>(kOpt);
726 if (!tbkOpts->
icon.isNull()) {
727 tbkOpts->
icon.paint(p, r);
729 QStyleOption tool(0);
732 QPixmap pm =
standardPixmap(SP_TitleBarMenuButton, &tool, widget);
741 case Window::ButtonMin:
742 case Window::ButtonMax:
743 case Window::ButtonRestore:
744 case Window::ButtonClose:
745 case Window::ButtonShade:
746 case Window::ButtonUnshade:
747 case Window::ButtonHelp:
750 extractOption<KStyle::TitleButtonOption*>(kOpt);
751 State bflags = flags;
752 bflags &= ~State_Sunken;
754 bflags |= State_Sunken;
767 if (primitive == TabBar::EastText || primitive == TabBar::WestText)
771 if (primitive == TabBar::WestText)
773 tr.translate(r.x(), r.height() + r.y());
778 tr.translate(r.width() + r.x(), r.y());
783 p->setTransform(tr,
true);
785 QRect(0, 0, r.height(), r.width()), pal, flags, p, widget, kOpt);
795 if (primitive == Generic::Text)
806 drawItemText(p, r, Qt::AlignVCenter | Qt::TextShowMnemonic | textOpts->
hAlign, pal, flags & State_Enabled,
810 else if (primitive == Generic::Icon)
814 QIcon::State iconState;
817 if (flags & State_Enabled)
819 mode = QIcon::Active;
821 mode = QIcon::Normal;
823 mode = QIcon::Disabled;
825 if( (flags & State_On) || (flags & State_Sunken) )
826 iconState = QIcon::On;
828 iconState = QIcon::Off;
830 QSize size = iconOpts->
size;
833 QPixmap icon = iconOpts->
icon.pixmap(size, mode, iconState);
834 p->drawPixmap(
centerRect(r, icon.size()), icon);
836 else if (primitive == Generic::FocusIndicator)
840 pen.setStyle(Qt::DotLine);
844 else if (primitive >= Generic::ArrowUp && primitive <= Generic::ArrowLeft)
849 QColor arrowColor = colorOpt->
color.
color(pal);
855 case Generic::ArrowUp:
859 case Generic::ArrowDown:
863 case Generic::ArrowLeft:
871 if ( flags & State_Enabled )
874 poly.translate(r.x() + r.width()/2 - 1, r.y() + r.height()/2);
876 p->setPen(arrowColor);
877 p->drawPolygon(poly);
882 poly.translate(r.x() + r.width()/2, r.y() + r.height()/2 + 1);
883 p->setPen( pal.color( QPalette::Light ) );
884 p->drawPolygon(poly);
885 poly.translate(-1,-1);
886 p->setPen(pal.mid().color());
887 p->drawPolygon(poly);
903 if (metrics.size() <= widget)
904 metrics.resize(widget + 1);
906 QVector<int>& widgetMetrics = metrics[widget];
907 if (widgetMetrics.size() <=
metric)
908 widgetMetrics.resize(
metric + 1);
910 widgetMetrics[
metric] = value;
914 const QStyleOption* opt,
920 if (metrics.size() <= widget)
923 const QVector<int>& widgetMetrics = metrics[widget];
924 if (widgetMetrics.size() <=
metric)
927 return widgetMetrics[
metric];
930QSize KStyle::expandDim(
const QSize& orig, WidgetType wt,
int baseMarginMetric,
931 const QStyleOption* opt,
const QWidget* w,
bool rotated)
const
933 int addWidth = 2*widgetLayoutProp(wt, baseMarginMetric + MainMargin, opt, w) +
934 widgetLayoutProp(wt, baseMarginMetric + Left, opt, w) +
935 widgetLayoutProp(wt, baseMarginMetric + Right, opt, w);
937 int addHeight = 2*widgetLayoutProp(wt, baseMarginMetric + MainMargin, opt, w) +
938 widgetLayoutProp(wt, baseMarginMetric + Top, opt, w) +
939 widgetLayoutProp(wt, baseMarginMetric + Bot, opt, w);
941 return QSize(orig.width() + (rotated? addHeight: addWidth),
942 orig.height() + (rotated? addWidth: addHeight));
945QRect KStyle::insideMargin(
const QRect &orig, WidgetType wt,
946 int baseMarginMetric,
947 const QStyleOption* opt,
const QWidget* w)
const
949 int x1 = orig.topLeft().x();
950 int y1 = orig.topLeft().y();
951 int x2 = orig.bottomRight().x();
952 int y2 = orig.bottomRight().y();
966 return QRect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
969QRect KStyle::handleRTL(
const QStyleOption* opt,
const QRect& subRect)
const
971 return visualRect(opt->direction, opt->rect, subRect);
974QPoint KStyle::handleRTL(
const QStyleOption* opt,
const QPoint& pos)
const
976 return visualPos(opt->direction, opt->rect, pos);
982 State flags = option->state;
983 QRect r = option->rect;
984 QPalette pal = option->palette;
988 case PE_FrameFocusRect:
991 case PE_IndicatorArrowUp:
994 case PE_IndicatorArrowDown:
997 case PE_IndicatorArrowLeft:
1000 case PE_IndicatorArrowRight:
1003 case PE_IndicatorMenuCheckMark:
1007 case PE_IndicatorCheckBox:
1008 if (flags & State_NoChange)
1010 else if (flags & State_On)
1015 case PE_IndicatorRadioButton:
1016 if (flags & State_On)
1021 case PE_IndicatorBranch:
1023 int centerX = r.x() + r.width()/2;
1024 int centerY = r.y() + r.height()/2;
1026 int expanderAdjust = 0;
1028 if (flags & State_Children)
1031 int sizeLimit = qMin(qMin(r.width(), r.height()),
1033 if ((sizeLimit & 1) == 0)
1036 expanderAdjust = sizeLimit/2 + 1;
1038 QRect expanderRect = QRect(centerX - sizeLimit/2, centerY - sizeLimit/2,
1039 sizeLimit, sizeLimit);
1042 option, expanderRect, pal, flags, painter, widget);
1047 if (flags & (State_Item | State_Children | State_Sibling))
1049 QRect topLine = QRect(QPoint(centerX, r.y()), QPoint(centerX, centerY - expanderAdjust));
1054 if (flags & State_Item)
1057 if (option->direction == Qt::LeftToRight)
1058 horLine = QRect(QPoint(centerX + expanderAdjust, centerY),
1059 QPoint(r.right(), centerY));
1061 horLine = QRect(QPoint(r.left(), centerY),
1062 QPoint(centerX - expanderAdjust, centerY));
1067 if (flags & State_Sibling)
1069 QRect botLine = QRect(QPoint(centerX, centerY + expanderAdjust),
1070 QPoint(centerX, r.bottom()));
1078 case PE_IndicatorHeaderArrow:
1080 const QStyleOptionHeader *hOpt = qstyleoption_cast<const QStyleOptionHeader *>(option);
1082 if (flags&State_UpArrow || (hOpt && hOpt->sortIndicator==QStyleOptionHeader::SortUp))
1083 primitive = Generic::ArrowUp;
1084 else if (flags&State_DownArrow || (hOpt && hOpt->sortIndicator==QStyleOptionHeader::SortDown))
1085 primitive = Generic::ArrowDown;
1090 case PE_FrameTabBarBase:
1095 case PE_IndicatorTabTear:
1100 case PE_FrameTabWidget:
1106 case PE_PanelLineEdit:
1112 case PE_FrameLineEdit:
1118 case PE_FrameGroupBox:
1120 if (
const QStyleOptionFrame *fOpt =
1121 qstyleoption_cast<const QStyleOptionFrame *>(option))
1123 QStyleOptionFrameV2 fOpt2(*fOpt);
1125 if (fOpt2.features & QStyleOptionFrameV2::Flat) {
1134 case PE_FrameStatusBar:
1140 case PE_FrameDockWidget:
1146 case PE_IndicatorDockWidgetResizeHandle:
1153 case PE_FrameWindow:
1165 case PE_IndicatorToolBarHandle:
1167 if (flags & State_Horizontal)
1169 option,r,pal,flags,painter,widget);
1172 option,r,pal,flags,painter,widget);
1176 case PE_IndicatorToolBarSeparator:
1180 case PE_PanelButtonCommand:
1184 case PE_FrameDefaultButton:
1188 case PE_PanelButtonTool:
1192 case PE_IndicatorButtonDropDown:
1196 case PE_PanelItemViewItem: {
1198 const QStyleOptionViewItemV4 *opt = qstyleoption_cast<const QStyleOptionViewItemV4*>(option);
1199 const QAbstractItemView *view = qobject_cast<const QAbstractItemView *>(widget);
1200 bool hover = (option->state & State_MouseOver) && (!view ||
1201 view->selectionMode() != QAbstractItemView::NoSelection);
1203 bool hasCustomBackground = opt->backgroundBrush.style() != Qt::NoBrush &&
1204 !(option->state & State_Selected);
1205 bool hasSolidBackground = !hasCustomBackground || opt->backgroundBrush.style() == Qt::SolidPattern;
1207 const qreal rounding = 2.5;
1209 if (!hover && !(option->state & State_Selected) && !hasCustomBackground &&
1210 !(opt->features & QStyleOptionViewItemV2::Alternate))
1213 QPalette::ColorGroup cg;
1214 if (option->state & State_Enabled)
1215 cg = (option->state & State_Active) ? QPalette::Normal : QPalette::Inactive;
1217 cg = QPalette::Disabled;
1221 if (hasCustomBackground && hasSolidBackground)
1222 color = opt->backgroundBrush.color();
1224 color = option->palette.color(cg, QPalette::Highlight);
1226 if (hover && !hasCustomBackground) {
1227 if (!(option->state & State_Selected))
1228 color.setAlphaF(.20);
1230 color = color.lighter(110);
1233 if (opt && (opt->features & QStyleOptionViewItemV2::Alternate))
1234 painter->fillRect(option->rect, option->palette.brush(cg, QPalette::AlternateBase));
1236 if (!hover && !(option->state & State_Selected) && !hasCustomBackground)
1239 quint64 key = quint64(option->rect.height()) << 32 | color.rgba();
1240 SelectionTiles* tiles = d->selectionCache.object(key);
1241 if (!tiles && hasSolidBackground)
1243 QImage image(32 + 16, option->rect.height(), QImage::Format_ARGB32_Premultiplied);
1246 QRect r = image.rect().adjusted(0, 0, -1, -1);
1248 QPainterPath path1, path2;
1249 path1.addRoundedRect(r, rounding, rounding);
1250 path2.addRoundedRect(r.adjusted(1, 1, -1, -1), rounding - 1, rounding - 1);
1255 int lightenAmount = hasCustomBackground ? 110 : 130;
1256 QLinearGradient gradient(0, 0, 0, r.bottom());
1257 gradient.setColorAt(0, color.lighter(lightenAmount));
1258 gradient.setColorAt(1, color);
1261 p.setRenderHint(QPainter::Antialiasing);
1262 p.translate(.5, .5);
1263 p.setPen(QPen(color, 1));
1264 p.setBrush(gradient);
1266 p.strokePath(path2, QPen(QColor(255, 255, 255, 64), 1));
1269 QPixmap pixmap = QPixmap::fromImage(image);
1271 tiles =
new SelectionTiles;
1272 tiles->left = pixmap.copy(0, 0, 8, image.height());
1273 tiles->center = pixmap.copy(8, 0, 32, image.height());
1274 tiles->right = pixmap.copy(40, 0, 8, image.height());
1276 d->selectionCache.insert(key, tiles);
1278 else if (hasCustomBackground && !hasSolidBackground)
1280 const QPointF oldBrushOrigin = painter->brushOrigin();
1281 painter->setBrushOrigin(opt->rect.topLeft());
1282 painter->setBrush(opt->backgroundBrush);
1283 painter->setPen(Qt::NoPen);
1284 painter->drawRect(opt->rect);
1285 painter->setBrushOrigin(oldBrushOrigin);
1289 bool roundedLeft =
false;
1290 bool roundedRight =
false;
1292 roundedLeft = (opt->viewItemPosition == QStyleOptionViewItemV4::Beginning);
1293 roundedRight = (opt->viewItemPosition == QStyleOptionViewItemV4::End);
1294 if (opt->viewItemPosition == QStyleOptionViewItemV4::OnlyOne ||
1295 opt->viewItemPosition == QStyleOptionViewItemV4::Invalid ||
1296 (view && view->selectionBehavior() != QAbstractItemView::SelectRows))
1299 roundedRight =
true;
1303 QRect r = option->rect;
1304 bool reverseLayout = option->direction == Qt::RightToLeft;
1306 if (!reverseLayout ? roundedLeft : roundedRight) {
1307 painter->drawPixmap(r.topLeft(), tiles->left);
1308 r.adjust(8, 0, 0, 0);
1310 if (!reverseLayout ? roundedRight : roundedLeft) {
1311 painter->drawPixmap(r.right() - 8 + 1, r.top(), tiles->right);
1312 r.adjust(0, 0, -8, 0);
1315 painter->drawTiledPixmap(r, tiles->center);
1324 QCommonStyle::drawPrimitive(elem, option, painter, widget);
1330 State flags = option->state;
1331 QRect r = option->rect;
1332 QPalette pal = option->palette;
1338 const QStyleOptionButton* bOpt = qstyleoption_cast<const QStyleOptionButton*>(option);
1342 drawControl(CE_PushButtonBevel, option, p, widget);
1345 QRect labelRect = r;
1348 if ((bOpt->features & QStyleOptionButton::DefaultButton) || (bOpt->features & QStyleOptionButton::AutoDefaultButton))
1349 labelRect = insideMargin(labelRect,
WT_PushButton, PushButton::DefaultIndicatorMargin, option, widget);
1352 labelRect = insideMargin(labelRect,
WT_PushButton, PushButton::ContentsMargin, option, widget);
1356 QStyleOptionButton bOptTmp = *bOpt;
1357 bOptTmp.rect = labelRect;
1358 drawControl(CE_PushButtonLabel, &bOptTmp, p, widget);
1361 if (flags & State_HasFocus)
1363 QRect focusRect = insideMargin(r,
WT_PushButton, PushButton::FocusMargin, option, widget);
1365 QStyleOptionFocusRect foOpts;
1366 foOpts.palette = pal;
1367 foOpts.rect = focusRect;
1368 foOpts.state = flags;
1376 case CE_PushButtonBevel:
1378 const QStyleOptionButton* bOpt = qstyleoption_cast<const QStyleOptionButton*>(option);
1382 if (bOpt->features & QStyleOptionButton::DefaultButton)
1385 QRect bevelRect = r;
1387 if ((bOpt->features & QStyleOptionButton::DefaultButton) || (bOpt->features & QStyleOptionButton::AutoDefaultButton))
1388 bevelRect = insideMargin(r,
WT_PushButton, PushButton::DefaultIndicatorMargin, option, widget);
1391 QStyleOptionButton bOptTmp = *bOpt;
1392 bOptTmp.rect = bevelRect;
1398 case CE_PushButtonLabel:
1400 const QStyleOptionButton* bOpt = qstyleoption_cast<const QStyleOptionButton*>(option);
1406 r.getRect(&x, &y, &w, &h);
1409 bool active = (flags & State_On) || (flags & State_Sunken);
1417 if (bOpt->features & QStyleOptionButton::HasMenu)
1421 w -= indicatorWidth + indicatorSpacing;
1425 handleRTL(bOpt, QRect(x + w + indicatorSpacing, y, indicatorWidth, h)),
1426 pal, flags, p, widget);
1430 if (!bOpt->icon.isNull())
1433 icoOpt.
icon = bOpt->icon;
1434 icoOpt.
size = bOpt->iconSize;
1435 icoOpt.
active = flags & State_HasFocus;
1437 if (!bOpt->text.isEmpty())
1443 int length = bOpt->iconSize.width() + margin
1444 + p->fontMetrics().size(Qt::TextShowMnemonic, bOpt->text).width();
1447 int offset = (w - length)/2;
1450 QRect rect = QRect(QPoint(x + offset, y + h/2 - bOpt->iconSize.height()/2), bOpt->iconSize);
1452 handleRTL(bOpt, rect),
1453 pal, flags, p, widget, &icoOpt);
1456 x += offset + bOpt->iconSize.width() + margin;
1457 w = length - bOpt->iconSize.width() - margin;
1465 pal, flags, p, widget, &icoOpt);
1471 int textW = p->fontMetrics().size(Qt::TextShowMnemonic, bOpt->text).width();
1478 pal, flags, p, widget, &lbOpt);
1483 case CE_DockWidgetTitle:
1485 const QStyleOptionDockWidget* dwOpt = ::qstyleoption_cast<const QStyleOptionDockWidget*>(option);
1488 QRect textRect = insideMargin(r,
WT_DockWidget, DockWidget::TitleMargin, option, widget);
1498 case CE_ToolBoxTabShape:
1512 const QStyleOptionButton* bOpt = qstyleoption_cast<const QStyleOptionButton*>(option);
1516 QRect checkBox =
subElementRect(SE_CheckBoxIndicator, option, widget);
1517 QStyleOptionButton bOptTmp = *bOpt;
1518 bOptTmp.rect = checkBox;
1522 bOptTmp.rect =
subElementRect(SE_CheckBoxContents, option, widget);
1523 drawControl(CE_CheckBoxLabel, &bOptTmp, p, widget);
1526 if (flags & State_HasFocus)
1528 QRect focusRect =
subElementRect(SE_CheckBoxFocusRect, option, widget);
1530 pal, flags, p, widget);
1535 case CE_CheckBoxLabel:
1537 const QStyleOptionButton* bOpt = qstyleoption_cast<const QStyleOptionButton*>(option);
1542 if (!bOpt->icon.isNull())
1545 icoOpt.
icon = bOpt->icon;
1546 icoOpt.
size = bOpt->iconSize;
1547 icoOpt.
active = flags & State_HasFocus;
1549 QRect iconRect(r.x(), r.y() + (r.height()-bOpt->iconSize.height())/2,
1550 bOpt->iconSize.width(), bOpt->iconSize.height());
1552 handleRTL(bOpt, iconRect),
1553 pal, flags, p, widget, &icoOpt);
1555 textShift = bOpt->iconSize.width() +
1560 if (!bOpt->text.isEmpty() ) {
1563 handleRTL(bOpt, r.adjusted(textShift,0,0,0)),
1564 pal, flags, p, widget, &lbOpt);
1570 case CE_RadioButton:
1572 const QStyleOptionButton* bOpt = qstyleoption_cast<const QStyleOptionButton*>(option);
1576 QRect indicator =
subElementRect(SE_RadioButtonIndicator, option, widget);
1577 QStyleOptionButton bOptTmp = *bOpt;
1578 bOptTmp.rect = indicator;
1579 drawPrimitive(PE_IndicatorRadioButton, &bOptTmp, p, widget);
1582 bOptTmp.rect =
subElementRect(SE_RadioButtonContents, option, widget);
1583 drawControl(CE_RadioButtonLabel, &bOptTmp, p, widget);
1586 if (flags & State_HasFocus)
1588 QRect focusRect =
subElementRect(SE_RadioButtonFocusRect, option, widget);
1590 pal, flags, p, widget);
1595 case CE_RadioButtonLabel:
1597 const QStyleOptionButton* bOpt = qstyleoption_cast<const QStyleOptionButton*>(option);
1602 if (!bOpt->icon.isNull())
1605 icoOpt.
icon = bOpt->icon;
1606 icoOpt.
active = flags & State_HasFocus;
1607 icoOpt.
size = bOpt->iconSize;
1609 QRect iconRect(r.x(), r.y() + (r.height()-bOpt->iconSize.height())/2,
1610 bOpt->iconSize.width(), bOpt->iconSize.height());
1612 handleRTL(bOpt, iconRect),
1613 pal, flags, p, widget, &icoOpt);
1615 textShift = bOpt->iconSize.width() +
1621 handleRTL(bOpt, r.adjusted(textShift,0,0,0)),
1622 pal, flags, p, widget, &lbOpt);
1629 case CE_ProgressBarGroove:
1632 pal, flags, p, widget);
1636 case CE_ProgressBarContents:
1638 const QStyleOptionProgressBar* pbOpt = qstyleoption_cast<const QStyleOptionProgressBar*>(option);
1639 const QStyleOptionProgressBarV2* pbOpt2 = qstyleoption_cast<const QStyleOptionProgressBarV2*>(option);
1643 double progress = pbOpt->progress - pbOpt->minimum;
1644 int steps = qMax(pbOpt->maximum - pbOpt->minimum, 1);
1645 bool busyIndicator = (pbOpt->minimum == 0 && pbOpt->maximum == 0);
1646 bool horizontal = !pbOpt2 || pbOpt2->orientation == Qt::Horizontal;
1649 if (!progress && ! busyIndicator)
1657 widthFrac = progress / steps;
1660 int width = qMin(r.width(), (
int)(widthFrac *
double(r.width())));
1661 int height = qMin(r.height(), (
int)(widthFrac * r.height()));
1673 if (size < 1) size = 1;
1676 int remSize = (horizontal ? r.width() : r.height()) - size;
1677 if (remSize <= 0) remSize = 1;
1679 int pstep = int(progress)%(2*remSize);
1681 if (pstep > remSize)
1685 pstep = -(pstep - 2*remSize);
1688 QRect indicatorRect;
1690 indicatorRect = QRect(r.x() + pstep, r.y(), size, r.height());
1692 indicatorRect = QRect(r.x(), r.y() + pstep, r.width(), size);
1694 pal, flags, p, widget);
1698 QRect indicatorRect;
1700 indicatorRect = QRect(r.x(), r.y(), width, r.height());
1702 indicatorRect = QRect(r.x(), r.bottom()-height+1, r.width(), height);
1704 pal, flags, p, widget);
1709 case CE_ProgressBarLabel:
1711 const QStyleOptionProgressBar* pbOpt = qstyleoption_cast<const QStyleOptionProgressBar*>(option);
1712 const QStyleOptionProgressBarV2* pbOpt2 = qstyleoption_cast<const QStyleOptionProgressBarV2*>(option);
1716 bool horizontal = !pbOpt2 || pbOpt2->orientation == Qt::Horizontal;
1717 bool reverseLayout = option->direction == Qt::RightToLeft;
1722 if (!horizontal && !reverseLayout)
1724 p->translate(r.topRight());
1727 else if (!horizontal)
1729 p->translate(r.bottomLeft());
1733 if (useSideText(pbOpt))
1735 lbOpt.
color = QPalette::ButtonText;
1738 if (option->direction == Qt::LeftToRight)
1739 lbOpt.
hAlign = Qt::AlignRight;
1741 lbOpt.
hAlign = Qt::AlignLeft;
1747 horizontal? r.adjusted(0, marWidth, 0, -marWidth) : QRect(0, marWidth, r.height(), r.width()-marWidth),
1748 pal, flags, p, widget, &lbOpt);
1752 if (pbOpt->textAlignment == Qt::AlignLeft)
1753 lbOpt.
hAlign = Qt::AlignHCenter;
1755 lbOpt.
hAlign = pbOpt->textAlignment;
1759 double progress = pbOpt->progress - pbOpt->minimum;
1760 int steps = qMax(pbOpt->maximum - pbOpt->minimum, 1);
1761 bool busyIndicator = (steps <= 1);
1773 double widthFrac = progress / steps;;
1774 width = qMin(r.width(), (
int)(widthFrac * r.width()));
1775 height = qMin(r.height(), (
int)(widthFrac * r.height()));
1780 if (width || height)
1783 p->setClipRect(handleRTL(option, QRect(r.x(), r.y(), width, r.height())));
1784 else if (!reverseLayout)
1785 p->setClipRect(QRect(r.height()-height, 0, r.height(), r.width()));
1787 p->setClipRect(QRect(0, 0, height, r.width()));
1788 lbOpt.
color = QPalette::HighlightedText;
1790 horizontal? r: QRect(0,0,r.height(),r.width()),
1791 pal, flags, p, widget, &lbOpt);
1794 p->setClipRect(handleRTL(option, QRect(r.x() + width, r.y(), r.width() - width, r.height())));
1795 else if (!reverseLayout)
1796 p->setClipRect(QRect(0, 0, r.height()-height, r.width()));
1798 p->setClipRect(QRect(height, 0, r.height()-height, r.width()));
1799 lbOpt.
color = QPalette::ButtonText;
1801 horizontal? r: QRect(0,0,r.height(),r.width()),
1802 pal, flags, p, widget, &lbOpt);
1803 p->setClipping(
false);
1807 lbOpt.
color = QPalette::ButtonText;
1809 horizontal? r: QRect(0,0,r.height(),r.width()),
1810 pal, flags, p, widget, &lbOpt);
1818 case CE_MenuBarItem:
1820 const QStyleOptionMenuItem* mOpt = ::qstyleoption_cast<const QStyleOptionMenuItem*>(option);
1825 pal, flags, p, widget);
1828 QRect textRect = insideMargin(r,
WT_MenuBarItem, MenuBarItem::Margin, option, widget);
1833 pal, flags, p, widget, &lbOpt);
1838 case CE_MenuBarEmptyArea:
1841 pal, flags, p, widget);
1845 case CE_MenuEmptyArea:
1846 case CE_MenuVMargin:
1847 case CE_MenuHMargin:
1850 pal, flags, p, widget);
1859 pal, flags, p, widget);
1861 const QStyleOptionMenuItem* miOpt = ::qstyleoption_cast<const QStyleOptionMenuItem*>(option);
1862 if (!miOpt || miOpt->menuItemType == QStyleOptionMenuItem::EmptyArea)
return;
1865 QRect ir = insideMargin(r,
WT_MenuItem, MenuItem::Margin, option, widget);
1870 int iconColW = miOpt->maxIconWidth;
1875 int leftColW = iconColW;
1877 bool checkAlongsideIcon = (miOpt->menuHasCheckableItems &&
1879 if (checkAlongsideIcon)
1881 leftColW = checkColW + checkSpace + iconColW;
1889 QRect leftColRect(ir.x(), r.y(), leftColW, r.height());
1891 pal, flags, p, widget);
1894 if (miOpt->menuItemType == QStyleOptionMenuItem::Separator)
1901 bool active = (flags & State_Selected);
1909 MenuItem::ActiveTextColor :
1910 MenuItem::TextColor, option, widget))
1912 MenuItem::ActiveDisabledTextColor:
1913 MenuItem::DisabledTextColor, option, widget));
1916 leftColRect = QRect(ir.x(), ir.y(), leftColW, ir.height());
1918 if (!checkAlongsideIcon && !miOpt->icon.isNull() )
1924 option, handleRTL(option, leftColRect), pal, flags,
1932 if (checkAlongsideIcon)
1934 checkColRect = QRect(leftColRect.x(), leftColRect.y(),
1935 checkColW, leftColRect.height() );
1939 checkColRect = leftColRect;
1942 bool checked = miOpt->checked;
1943 if (miOpt->checkType == QStyleOptionMenuItem::NonExclusive)
1946 option, handleRTL(option, checkColRect), pal, flags,
1949 else if (miOpt->checkType == QStyleOptionMenuItem::Exclusive)
1952 option, handleRTL(option, checkColRect), pal, flags,
1957 if (!miOpt->icon.isNull())
1962 if (checkAlongsideIcon)
1964 iconColRect = QRect(leftColRect.x()+checkColW+checkSpace, leftColRect.y(),
1965 leftColRect.width()-(checkColW+checkSpace), leftColRect.height() );
1969 iconColRect = leftColRect;
1972 icoOpt.
icon = miOpt->icon;
1973 icoOpt.
active = flags & State_Selected;
1975 handleRTL(option,
centerRect(iconColRect, iconSize, iconSize)),
1976 pal, flags, p, widget, &icoOpt);
1983 QString text = miOpt->text;
1984 QRect textRect = QRect(ir.x() + leftColW, ir.y(), ir.width() - leftColW - rightColW, ir.height());
1985 QFont font = miOpt->font;
1986 const QFont oldFont = p->font();
1989 int tabPos = miOpt->text.indexOf(QLatin1Char(
'\t'));
1992 text = miOpt->text.left(tabPos);
1993 QString accl = miOpt->text.mid (tabPos + 1);
1997 lbOpt.
color = textColor;
1998 lbOpt.
hAlign = Qt::AlignRight;
2000 pal, flags, p, widget, &lbOpt);
2005 lbOpt.
color = textColor;
2007 pal, flags, p, widget, &lbOpt);
2009 p->setFont(oldFont);
2012 if (miOpt->menuItemType == QStyleOptionMenuItem::SubMenu)
2015 arrowColor.
color = textColor;
2019 QRect arrowRect(ir.x() + ir.width() - aw, ir.y(), aw, ir.height());
2021 Generic::ArrowRight : Generic::ArrowLeft,
2022 option, handleRTL(option, arrowRect), pal, flags, p, widget, &arrowColor);
2028 case CE_ScrollBarAddLine:
2029 case CE_ScrollBarSubLine:
2031 const QStyleOptionSlider* slOpt = ::qstyleoption_cast<const QStyleOptionSlider*>(option);
2035 r = internalSubControlRect(CC_ScrollBar, slOpt,
2036 element == CE_ScrollBarAddLine ? SC_ScrollBarAddLine : SC_ScrollBarSubLine, widget);
2037 const_cast<QStyleOption*
>(option)->rect = r;
2040 bool doubleButton =
false;
2044 doubleButton =
true;
2046 doubleButton =
true;
2050 if (flags & State_Horizontal)
2055 bool leftAdds, rightAdds;
2056 if (slOpt->direction == Qt::LeftToRight)
2068 if (flags & State_Sunken)
2070 if (((slOpt->activeSubControls & SC_ScrollBarAddLine) && leftAdds) ||
2071 ((slOpt->activeSubControls & SC_ScrollBarSubLine) && !leftAdds))
2072 ab = DoubleButtonOption::Left;
2074 if (((slOpt->activeSubControls & SC_ScrollBarAddLine) && rightAdds) ||
2075 ((slOpt->activeSubControls & SC_ScrollBarSubLine) && !rightAdds))
2076 ab = DoubleButtonOption::Right;
2081 option, r, pal, flags, p, widget, &bOpt);
2084 QRect leftSubButton = QRect(r.x(), r.y(), r.width()/2, r.height());
2088 if (ab == DoubleButtonOption::Left)
2092 flags, p, widget, &colOpt);
2095 QRect rightSubButton;
2096 rightSubButton.setBottomRight(r.bottomRight());
2097 rightSubButton.setLeft (leftSubButton.right() + 1);
2098 rightSubButton.setTop (r.top());
2102 if (ab == DoubleButtonOption::Right)
2106 flags, p, widget, &colOpt);
2115 if (flags & State_Sunken)
2117 if (slOpt->activeSubControls & SC_ScrollBarSubLine)
2118 ab = DoubleButtonOption::Top;
2120 if (slOpt->activeSubControls & SC_ScrollBarAddLine)
2121 ab = DoubleButtonOption::Bottom;
2127 option, r, pal, flags, p, widget, &bOpt);
2133 if (ab == DoubleButtonOption::Top)
2137 QRect topSubButton = QRect(r.x(), r.y(), r.width(), r.height()/2);
2139 flags, p, widget, &colOpt);
2143 botSubButton.setBottomRight(r.bottomRight());
2144 botSubButton.setLeft (r.left());
2145 botSubButton.setTop (topSubButton.bottom() + 1);
2149 if (ab == DoubleButtonOption::Bottom)
2153 flags, p, widget, &colOpt);
2158 if (flags & State_Horizontal)
2161 option, r, pal, flags, p, widget);
2164 bool active =
false;
2166 if (element == CE_ScrollBarAddLine)
2168 if (slOpt->direction == Qt::LeftToRight)
2169 primitive = Generic::ArrowRight;
2171 primitive = Generic::ArrowLeft;
2173 if ((slOpt->activeSubControls & SC_ScrollBarAddLine) && (flags & State_Sunken))
2178 if (slOpt->direction == Qt::LeftToRight)
2179 primitive = Generic::ArrowLeft;
2181 primitive = Generic::ArrowRight;
2183 if ((slOpt->activeSubControls & SC_ScrollBarSubLine) && (flags & State_Sunken))
2193 flags, p, widget, &colOpt);
2198 option, r, pal, flags, p, widget);
2201 bool active =
false;
2203 if (element == CE_ScrollBarAddLine)
2205 primitive = Generic::ArrowDown;
2206 if ((slOpt->activeSubControls & SC_ScrollBarAddLine) && (flags & State_Sunken))
2211 primitive = Generic::ArrowUp;
2212 if ((slOpt->activeSubControls & SC_ScrollBarSubLine) && (flags & State_Sunken))
2222 flags, p, widget, &colOpt);
2232 case CE_ScrollBarSlider:
2235 (flags & State_Horizontal) ? ScrollBar::SliderHor :
2236 ScrollBar::SliderVert,
2237 option, r, pal, flags, p, widget);
2241 case CE_ScrollBarAddPage:
2243 const QStyleOptionSlider* slOpt = ::qstyleoption_cast<const QStyleOptionSlider*>(option);
2246 if (flags & State_Horizontal)
2248 (slOpt->direction == Qt::LeftToRight) ? ScrollBar::GrooveAreaHorRight :
2249 ScrollBar::GrooveAreaHorLeft,
2250 option, r, pal, flags, p, widget);
2253 option, r, pal, flags, p, widget);
2257 case CE_ScrollBarSubPage:
2259 const QStyleOptionSlider* slOpt = ::qstyleoption_cast<const QStyleOptionSlider*>(option);
2262 if (flags & State_Horizontal)
2264 (slOpt->direction == Qt::LeftToRight) ? ScrollBar::GrooveAreaHorLeft :
2265 ScrollBar::GrooveAreaHorRight,
2266 option, r, pal, flags, p, widget);
2269 option, r, pal, flags, p, widget);
2275 case CE_TabBarTabShape:
2277 const QStyleOptionTab* tabOpt = qstyleoption_cast<const QStyleOptionTab*>(option);
2278 if (!tabOpt)
return;
2281 int tabOverlap =
pixelMetric(PM_TabBarTabOverlap, option, widget);
2282 bool beginning = tabOpt->position == QStyleOptionTab::Beginning;
2283 bool onlyOne = tabOpt->position == QStyleOptionTab::OnlyOneTab;
2284 if (!beginning && !onlyOne) {
2285 switch (tabSide(tabOpt)) {
2288 if (option->direction == Qt::LeftToRight)
2289 r.adjust(-tabOverlap, 0, 0, 0);
2291 r.adjust(0, 0, tabOverlap, 0);
2295 r.adjust(0, -tabOverlap, 0, 0);
2302 switch (tabSide(tabOpt))
2305 prim = TabBar::NorthTab;
break;
2307 prim = TabBar::SouthTab;
break;
2309 prim = TabBar::EastTab;
break;
2311 prim = TabBar::WestTab;
break;
2319 case CE_TabBarTabLabel:
2321 const QStyleOptionTab* tabOpt = qstyleoption_cast<const QStyleOptionTab*>(option);
2322 if (!tabOpt)
return;
2325 QRect labelRect =
subElementRect(SE_TabBarTabText, option, widget);
2327 Side tabSd = tabSide(tabOpt);
2331 if (!tabOpt->icon.isNull())
2333 QStyleOptionTabV3 tabV3(*tabOpt);
2334 QSize iconSize = tabV3.iconSize;
2335 if (!iconSize.isValid()) {
2337 iconSize = QSize(iconExtent, iconExtent);
2341 icoOpt.
icon = tabOpt->icon;
2342 icoOpt.
active = flags & State_Selected;
2343 icoOpt.
size = iconSize;
2345 if (tabOpt->text.isNull())
2349 pal, flags, p, widget, &icoOpt);
2356 if (tabSd == North || tabSd == South)
2361 if (tabOpt->direction == Qt::LeftToRight)
2364 iconRect = QRect(labelRect.x(), labelRect.y() + (labelRect.height() - iconSize.height() + 1) / 2,
2365 iconSize.width(), iconSize.height());
2368 labelRect.setLeft(labelRect.x() + iconSize.width() +
2374 iconRect = QRect(labelRect.x() + labelRect.width() - iconSize.width(),
2375 labelRect.y() + (labelRect.height() - iconSize.height() + 1) / 2, iconSize.width(), iconSize.height());
2377 labelRect.setWidth(labelRect.width() - iconSize.width() -
2383 bool aboveIcon =
false;
2384 if (tabSd == West && tabOpt->direction == Qt::RightToLeft)
2386 if (tabSd == East && tabOpt->direction == Qt::LeftToRight)
2391 iconRect = QRect(labelRect.x() + (labelRect.width() - iconSize.width() + 1) / 2, labelRect.y(),
2392 iconSize.width(), iconSize.height());
2393 labelRect.setTop(labelRect.y() + iconSize.height() +
2398 iconRect = QRect(labelRect.x() + (labelRect.width() - iconSize.width() + 1) / 2,
2399 labelRect.y() + labelRect.height() - iconSize.height(),
2400 iconSize.width(), iconSize.height());
2401 labelRect.setHeight(labelRect.height() - iconSize.height() -
2408 pal, flags, p, widget, &icoOpt);
2412 if (!tabOpt->text.isNull())
2416 lbOpt.
color = widget->foregroundRole();
2418 int primitive = Generic::Text;
2421 primitive = TabBar::EastText;
2422 else if (tabSd == West)
2423 primitive = TabBar::WestText;
2426 pal, flags, p, widget, &lbOpt);
2430 if (tabOpt->state & State_HasFocus)
2432 QRect focusRect = marginAdjustedTab(tabOpt, TabBar::TabFocusMargin);
2434 pal, flags, p, widget);
2441 if (flags & State_Horizontal)
2449 case CE_HeaderSection:
2451 if (
const QStyleOptionHeader *
header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
2453 option, r, pal, flags, p, widget);
2458 case CE_HeaderLabel:
2460 if (
const QStyleOptionHeader *
header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
2462 if (!
header->icon.isNull()) {
2463 bool enabled = flags & State_Enabled;
2464 QPixmap pm =
header->icon.pixmap(
pixelMetric(PM_SmallIconSize), enabled?QIcon::Normal:QIcon::Disabled);
2467 bool reverseLayout =
header->direction == Qt::RightToLeft;
2468 int iy = r.top()+(r.height()-pm.height())/2;
2469 int ix = reverseLayout ? r.right()-pm.width() : r.left();
2470 QRect iconRect = QRect(ix, iy, pm.width(), pm.height() );
2480 textRect.setRight(r.right()-iconRect.width()-spacing );
2484 textRect.setLeft(r.x()+iconRect.width()+spacing );
2497 if (flags&State_Horizontal)
2508 QCommonStyle::drawControl(element, option, p, widget);
2516 case SH_ComboBox_ListMouseTracking:
2519 case SH_MenuBar_MouseTracking:
2520 case SH_Menu_MouseTracking:
2523 case SH_Menu_SubMenuPopupDelay:
2526 case SH_TitleBar_NoBorder:
2529 case SH_GroupBox_TextLabelVerticalAlignment:
2531 return Qt::AlignTop;
2533 return Qt::AlignVCenter;
2535 case SH_GroupBox_TextLabelColor:
2539 return cm.
color(option ? option->palette : qApp->palette()).rgba();
2542 case SH_DialogButtonLayout:
2543 return QDialogButtonBox::KdeLayout;
2545 case SH_ScrollBar_MiddleClickAbsolutePosition:
2549 case SH_ItemView_ShowDecorationSelected:
2552 case SH_ItemView_ActivateItemOnSingleClick:
2557 return d->styleElements.value(widget->objectName(), 0);
2560 case SH_FormLayoutFormAlignment:
2561 return Qt::AlignLeft | Qt::AlignTop;
2564 case SH_FormLayoutLabelAlignment:
2565 return Qt::AlignRight;
2567 case SH_FormLayoutFieldGrowthPolicy:
2568 return QFormLayout::ExpandingFieldsGrow;
2570 case SH_FormLayoutWrapPolicy:
2571 return QFormLayout::DontWrapRows;
2573 case SH_MessageBox_TextInteractionFlags:
2576 case SH_DialogButtonBox_ButtonsHaveIcons:
2579 case SH_ItemView_ArrowKeysNavigateIntoChildren:
2586 return QCommonStyle::styleHint(hint, option, widget, returnData);
2593 case PM_SmallIconSize:
2594 case PM_ButtonIconSize:
2596 case PM_ToolBarIconSize:
2598 case PM_LargeIconSize:
2600 case PM_MessageBoxIconSize:
2604 case PM_DefaultFrameWidth:
2605 if (qstyleoption_cast<const QStyleOptionGroupBox *>(option) )
2610 case PM_DefaultChildMargin:
2611 case PM_DefaultTopLevelMargin:
2614 case PM_LayoutHorizontalSpacing:
2615 case PM_LayoutVerticalSpacing:
2619 case PM_DefaultLayoutSpacing:
2622 case PM_LayoutLeftMargin:
2623 case PM_LayoutTopMargin:
2624 case PM_LayoutRightMargin:
2625 case PM_LayoutBottomMargin:
2627 PixelMetric marginMetric;
2628 if ((option && (option->state & QStyle::State_Window))
2629 || (widget && widget->isWindow())) {
2630 marginMetric = PM_DefaultTopLevelMargin;
2632 marginMetric = PM_DefaultChildMargin;
2637 case PM_ButtonMargin:
2640 case PM_ButtonDefaultIndicator:
2645 case PM_ButtonShiftHorizontal:
2647 case PM_ButtonShiftVertical:
2649 case PM_MenuButtonIndicator:
2650 if (qstyleoption_cast<const QStyleOptionToolButton*>(option))
2655 case PM_SplitterWidth:
2658 case PM_IndicatorWidth:
2659 case PM_IndicatorHeight:
2662 case PM_ExclusiveIndicatorWidth:
2663 case PM_ExclusiveIndicatorHeight:
2666 case PM_CheckListControllerSize:
2667 case PM_CheckListButtonSize:
2671 return qMax(checkBoxSize, radioButtonSize);
2674 case PM_DockWidgetFrameWidth:
2677 case PM_DockWidgetSeparatorExtent:
2683 case PM_DockWidgetTitleMargin:
2686 case PM_ProgressBarChunkWidth:
2689 case PM_MenuBarPanelWidth:
2692 case PM_MenuBarHMargin:
2701 case PM_MenuBarVMargin:
2708 case PM_MenuBarItemSpacing:
2711 case PM_MenuDesktopFrameWidth:
2714 case PM_MenuPanelWidth:
2736 case PM_MenuScrollerHeight:
2739 case PM_MenuTearoffHeight:
2742 case PM_TabBarTabHSpace:
2744 const QStyleOptionTab* tabOpt = qstyleoption_cast<const QStyleOptionTab*>(option);
2748 if (tabOpt->text.isNull() && !tabOpt->icon.isNull())
2750 if (tabOpt->icon.isNull() && !tabOpt->text.isNull())
2757 case PM_TabBarTabVSpace:
2760 case PM_TabBarBaseHeight:
2763 case PM_TabBarBaseOverlap:
2766 case PM_TabBarTabOverlap:
2769 case PM_TabBarScrollButtonWidth:
2772 case PM_TabBarTabShiftVertical:
2775 case PM_TabBarTabShiftHorizontal:
2778 case PM_SliderControlThickness:
2781 case PM_SliderLength:
2784 case PM_SliderThickness:
2790 case PM_SpinBoxFrameWidth:
2793 case PM_ComboBoxFrameWidth:
2796 case PM_HeaderMarkSize:
2799 case PM_HeaderMargin:
2802 case PM_ToolBarFrameWidth:
2805 case PM_ToolBarHandleExtent:
2808 case PM_ToolBarSeparatorExtent:
2811 case PM_ToolBarExtensionExtent:
2814 case PM_ToolBarItemMargin:
2817 case PM_ToolBarItemSpacing:
2820 case PM_ScrollBarExtent:
2823 case PM_TitleBarHeight:
2830 return QCommonStyle::pixelMetric(
metric, option, widget);
2835 Q_UNUSED(control1); Q_UNUSED(control2); Q_UNUSED(orientation);
2837 return pixelMetric(PM_DefaultLayoutSpacing, option, widget);
2841bool KStyle::isVerticalTab(
const QStyleOptionTab* tbOpt)
const
2843 switch (tbOpt->shape)
2845 case QTabBar::RoundedWest:
2846 case QTabBar::RoundedEast:
2847 case QTabBar::TriangularWest:
2848 case QTabBar::TriangularEast:
2855bool KStyle::isReflectedTab(
const QStyleOptionTab* tbOpt)
const
2857 switch (tbOpt->shape)
2859 case QTabBar::RoundedEast:
2860 case QTabBar::TriangularEast:
2861 case QTabBar::RoundedSouth:
2862 case QTabBar::TriangularSouth:
2869KStyle::Side KStyle::tabSide(
const QStyleOptionTab* tbOpt)
const
2871 switch (tbOpt->shape)
2873 case QTabBar::RoundedEast:
2874 case QTabBar::TriangularEast:
2876 case QTabBar::RoundedWest:
2877 case QTabBar::TriangularWest:
2879 case QTabBar::RoundedNorth:
2880 case QTabBar::TriangularNorth:
2887QRect KStyle::marginAdjustedTab(
const QStyleOptionTab* tabOpt,
int property)
const
2889 QRect r = tabOpt->rect;
2893 bool vertical = isVerticalTab (tabOpt);
2894 bool flip = isReflectedTab(tabOpt);
2896 QRect idializedGeometry = vertical ? QRect(0, 0, r.height(), r.width())
2897 : QRect(0, 0, r.width(), r.height());
2899 QRect contentArea = insideMargin(idializedGeometry, WT_TabBar, property, tabOpt, 0);
2901 int leftMargin = contentArea.x();
2902 int rightMargin = idializedGeometry.width() - 1 - contentArea.right();
2903 int topMargin = contentArea.y();
2904 int botMargin = idializedGeometry.height() - 1 - contentArea.bottom();
2908 int t = rightMargin;
2909 rightMargin = topMargin;
2910 topMargin = leftMargin;
2911 leftMargin = botMargin;
2915 qSwap(leftMargin, rightMargin);
2919 qSwap(topMargin, botMargin);
2921 if (tabOpt->direction == Qt::RightToLeft)
2922 qSwap(leftMargin, rightMargin);
2926 QRect(QPoint(leftMargin, topMargin),
2927 QPoint(r.width() - 1 - rightMargin,
2928 r.height() - 1 - botMargin));
2929 geom.translate(r.topLeft());
2933bool KStyle::useSideText(
const QStyleOptionProgressBar* pbOpt)
const
2938 if (!pbOpt)
return false;
2940 if (!pbOpt->textVisible)
return false;
2942 if (pbOpt->textAlignment & Qt::AlignHCenter)
return false;
2946 if (pbOpt->minimum == pbOpt->maximum)
return false;
2948 int widthAlloc = pbOpt->fontMetrics.width(QLatin1String(
"100%"));
2950 if (pbOpt->fontMetrics.width(pbOpt->text) > widthAlloc)
2956int KStyle::sideTextWidth(
const QStyleOptionProgressBar* pbOpt)
const
2958 return pbOpt->fontMetrics.width(QLatin1String(
"100%")) +
2964 QRect r = option->rect;
2968 case SE_PushButtonContents:
2970 const QStyleOptionButton* bOpt = qstyleoption_cast<const QStyleOptionButton*>(option);
2971 if (!bOpt)
return r;
2973 if ((bOpt->features & QStyleOptionButton::DefaultButton) || (bOpt->features & QStyleOptionButton::AutoDefaultButton))
2974 r = insideMargin(r,
WT_PushButton, PushButton::DefaultIndicatorMargin, option, widget);
2976 return insideMargin(r,
WT_PushButton, PushButton::ContentsMargin, option, widget);
2979 case SE_PushButtonFocusRect:
2981 const QStyleOptionButton* bOpt = qstyleoption_cast<const QStyleOptionButton*>(option);
2982 if (!bOpt)
return r;
2984 if ((bOpt->features & QStyleOptionButton::DefaultButton) || (bOpt->features & QStyleOptionButton::AutoDefaultButton))
2985 r = insideMargin(r,
WT_PushButton, PushButton::DefaultIndicatorMargin, option, widget);
2987 return insideMargin(r,
WT_PushButton, PushButton::FocusMargin, option, widget);
2990 case SE_ToolBoxTabContents:
2992 return insideMargin(r,
WT_ToolBoxTab, ToolBoxTab::Margin, option, widget);
2995 case SE_CheckBoxContents:
2999 return handleRTL(option, r);
3002 case SE_RadioButtonContents:
3006 return handleRTL(option, r);
3009 case SE_CheckBoxFocusRect:
3011 const QStyleOptionButton* bOpt = qstyleoption_cast<const QStyleOptionButton*>(option);
3012 if (!bOpt)
return r;
3016 if (bOpt->text.isEmpty())
3020 handleRTL(option,
subElementRect(SE_CheckBoxIndicator, option, widget) );
3021 ret = insideMargin(checkRect,
WT_CheckBox, CheckBox::NoLabelFocusMargin, option, widget);
3026 QRect contentsRect =
3027 handleRTL(option,
subElementRect(SE_CheckBoxContents, option, widget) );
3028 ret = insideMargin(contentsRect,
WT_CheckBox, CheckBox::FocusMargin, option, widget);
3031 return handleRTL(option, ret);
3034 case SE_RadioButtonFocusRect:
3037 QRect contentsRect =
3038 handleRTL(option,
subElementRect(SE_RadioButtonContents, option, widget) );
3041 return handleRTL(option,
3043 RadioButton::FocusMargin, option, widget) );
3046 case SE_ProgressBarGroove:
3048 const QStyleOptionProgressBar* pbOpt = ::qstyleoption_cast<const QStyleOptionProgressBar*>(option);
3049 if (useSideText(pbOpt))
3051 r.setWidth(r.width() - sideTextWidth(pbOpt));
3059 case SE_ProgressBarContents:
3061 QRect grooveRect =
subElementRect(SE_ProgressBarGroove, option, widget);
3062 return insideMargin(grooveRect,
WT_ProgressBar, ProgressBar::GrooveMargin, option, widget);
3065 case SE_ProgressBarLabel:
3067 const QStyleOptionProgressBar* pbOpt = ::qstyleoption_cast<const QStyleOptionProgressBar*>(option);
3068 if (useSideText(pbOpt))
3070 int width = sideTextWidth(pbOpt);
3071 return QRect(r.x() + r.width() - width, r.y(), width, r.height());
3079 case SE_TabWidgetTabContents:
3081 const QStyleOptionTabWidgetFrame* tabOpt = qstyleoption_cast<const QStyleOptionTabWidgetFrame*>(option);
3085 if (tabOpt->lineWidth == 0)
break;
3089 QRect pane = QCommonStyle::subElementRect(SE_TabWidgetTabPane, option, widget);
3093 int bot = m+widgetLayoutProp(
WT_TabWidget, TabWidget::ContentsMargin+
Bot,
3095 int left = m+widgetLayoutProp(
WT_TabWidget, TabWidget::ContentsMargin+
Left,
3100 switch (tabOpt->shape) {
3101 case QTabBar::RoundedNorth:
3102 case QTabBar::TriangularNorth:
3103 return pane.adjusted(left,top,-right,-bot);
3104 case QTabBar::RoundedEast:
3105 case QTabBar::TriangularEast:
3106 return pane.adjusted(bot,left, -top,-right);
3107 case QTabBar::RoundedSouth:
3108 case QTabBar::TriangularSouth:
3109 return pane.adjusted(right,bot, -left,-top);
3110 case QTabBar::RoundedWest:
3111 case QTabBar::TriangularWest:
3112 return pane.adjusted(top,right, -bot,-left);
3116 case SE_TabBarTabText:
3118 const QStyleOptionTab* tabOpt = qstyleoption_cast<const QStyleOptionTab*>(option);
3119 if (!tabOpt)
return QRect();
3121 QRect r = marginAdjustedTab(tabOpt, TabBar::TabContentsMargin);
3122 QStyleOptionTabV3 tov3(*tabOpt);
3126 case QTabBar::RoundedNorth:
3127 case QTabBar::TriangularNorth:
3128 case QTabBar::RoundedSouth:
3129 case QTabBar::TriangularSouth:
3130 if (tov3.direction == Qt::LeftToRight)
3131 r.adjust(tov3.leftButtonSize.width(), 0, -tov3.rightButtonSize.width(), 0);
3133 r.adjust(tov3.rightButtonSize.width(), 0, -tov3.leftButtonSize.width(), 0);
3135 case QTabBar::RoundedEast:
3136 case QTabBar::TriangularEast:
3137 r.adjust(0, tov3.leftButtonSize.width(), 0, -tov3.rightButtonSize.width());
3139 case QTabBar::RoundedWest:
3140 case QTabBar::TriangularWest:
3141 r.adjust(0, tov3.rightButtonSize.width(), 0, -tov3.leftButtonSize.width());
3152 return QCommonStyle::subElementRect(sr, option, widget);
3156 QPainter *p,
const QWidget* w)
const
3159 State flags = opt->state;
3160 QRect r = opt->rect;
3161 QPalette pal = opt->palette;
3167 QStyleOptionComplex* mutableOpt =
const_cast<QStyleOptionComplex*
>(opt);
3168 if ((mutableOpt->subControls & SC_ScrollBarSubLine) || (mutableOpt->subControls & SC_ScrollBarAddLine))
3171 mutableOpt->subControls |= SC_ScrollBarSubPage | SC_ScrollBarAddLine;
3179 const QStyleOptionQ3ListView* lvOpt = qstyleoption_cast<const QStyleOptionQ3ListView*>(opt);
3182 if (lvOpt->subControls & SC_Q3ListView)
3183 QCommonStyle::drawComplexControl(cc, opt, p, w);
3185 if (lvOpt->items.isEmpty())
3189 if (lvOpt->subControls & (SC_Q3ListViewBranch | SC_Q3ListViewExpand))
3191 QStyleOptionQ3ListViewItem item = lvOpt->items.at(0);
3196 opt.palette = lvOpt->palette;
3197 opt.direction = Qt::LeftToRight;
3203 int cX = w ? w->property(
"contentsX").toInt() : 0;
3204 int cY = w ? w->property(
"contentsY").toInt() : 0;
3206 QPoint adjustCoords = p->matrix().map(QPoint(0,0)) + QPoint(cX, cY);
3207 p->translate(-adjustCoords);
3209 if (lvOpt->activeSubControls == SC_All && (lvOpt->subControls & SC_Q3ListViewExpand)) {
3214 opt.rect = QRect(r.topLeft() + adjustCoords, r.size());
3215 opt.state = State_Sibling;
3221 while (childPos < lvOpt->items.size() && y < r.height())
3223 const QStyleOptionQ3ListViewItem& child = lvOpt->items.at(childPos);
3224 if (!(child.features & QStyleOptionQ3ListViewItem::Visible))
3231 opt.rect = QRect(r.x() + adjustCoords.x(), y + adjustCoords.y(),
3232 r.width(), child.height);
3233 opt.state = State_Item;
3235 if (child.features & QStyleOptionQ3ListViewItem::Expandable || child.childCount)
3237 opt.state |= State_Children;
3238 opt.state |= (child.state & State_Open);
3243 for (siblingPos = childPos + 1; siblingPos < lvOpt->items.size(); ++siblingPos)
3245 if (lvOpt->items.at(siblingPos).features & QStyleOptionQ3ListViewItem::Visible)
3247 opt.state |= State_Sibling;
3253 if (y + child.height > 0)
3261 if ((opt.state & State_Children) && (opt.state & State_Sibling))
3263 opt.state = State_Sibling;
3264 opt.rect = QRect(r.x() + adjustCoords.x(),
3265 y + adjustCoords.y() + child.height,
3266 r.width(), child.totalHeight - child.height);
3267 if (opt.rect.height())
3271 y += child.totalHeight;
3272 childPos = siblingPos;
3276 p->translate(adjustCoords);
3283 if (
const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt))
3285 QRect groove =
subControlRect(CC_Slider, slider, SC_SliderGroove, w);
3286 QRect handle =
subControlRect(CC_Slider, slider, SC_SliderHandle, w);
3287 bool hor = slider->orientation == Qt::Horizontal;
3289 if (slider->subControls & SC_SliderTickmarks)
3292 QStyleOptionSlider tmpSlider = *slider;
3293 tmpSlider.subControls = SC_SliderTickmarks;
3294 QCommonStyle::drawComplexControl(cc, &tmpSlider, p, w);
3297 if ((slider->subControls & SC_SliderGroove) && groove.isValid())
3302 if (slider->subControls & SC_SliderHandle)
3306 if (slider->state & State_HasFocus) {
3317 if (
const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(opt) )
3319 bool activeSbUp = sb->activeSubControls&SC_SpinBoxUp && (flags & State_Sunken);
3320 bool activeSbDown = sb->activeSubControls&SC_SpinBoxDown && (flags & State_Sunken);
3322 if (sb->subControls & SC_SpinBoxFrame)
3327 if (sb->subControls & SC_SpinBoxEditField)
3329 QRect editField =
subControlRect(CC_SpinBox, opt, SC_SpinBoxEditField, w);
3333 QRect upRect, downRect;
3334 if (sb->subControls & (SC_SpinBoxUp | SC_SpinBoxDown))
3338 QRect buttonAreaRect = upRect | downRect;
3342 if (sb->subControls & SC_SpinBoxUp)
3345 State upFlags = flags;
3347 upFlags |= State_Sunken;
3349 upFlags &= ~State_Sunken;
3355 if (sb->buttonSymbols == QAbstractSpinBox::PlusMinus)
3356 primitive = SpinBox::PlusSymbol;
3358 primitive = Generic::ArrowUp;
3362 if (sb->subControls & SC_SpinBoxDown)
3365 State downFlags = flags;
3367 downFlags |= State_Sunken;
3369 downFlags &= ~State_Sunken;
3375 if (sb->buttonSymbols == QAbstractSpinBox::PlusMinus)
3376 primitive = SpinBox::MinusSymbol;
3378 primitive = Generic::ArrowDown;
3388 if (
const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt) )
3390 if (cb->subControls & SC_ComboBoxFrame)
3395 if (cb->state & State_HasFocus) {
3396 QRect editField =
subControlRect(CC_ComboBox, opt, SC_ComboBoxEditField, w);
3397 QRect focusRect = insideMargin(editField,
WT_ComboBox, ComboBox::FocusMargin, opt, w);
3402 if (cb->subControls & SC_ComboBoxEditField)
3404 QRect editField =
subControlRect(CC_ComboBox, opt, SC_ComboBoxEditField, w);
3408 if (cb->subControls & SC_ComboBoxArrow)
3410 QRect buttonRect =
subControlRect(CC_ComboBox, opt, SC_ComboBoxArrow, w);
3424 if (
const QStyleOptionToolButton *tool = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) {
3429 State bflags = tool->state;
3430 if (bflags & State_AutoRaise) {
3431 if (!(bflags & State_MouseOver)) {
3432 bflags &= ~State_Raised;
3435 State mflags = bflags;
3437 QStyleOption tOpt(0);
3440 if (tool->subControls & SC_ToolButton) {
3441 if (bflags & (State_Sunken | State_On | State_Raised)) {
3442 tOpt.rect = buttonRect;
3443 tOpt.state = bflags;
3448 if (tool->subControls & SC_ToolButtonMenu) {
3449 tOpt.rect = menuRect;
3450 tOpt.state = mflags;
3452 }
else if (tool->features & QStyleOptionToolButton::HasMenu) {
3462 QRect r = QRect(buttonRect.right() + xOff, buttonRect.bottom() + yOff, size, size);
3464 tOpt.state = bflags;
3469 if (flags & State_HasFocus) {
3470 QRect focusRect = insideMargin(r,
WT_ToolButton, ToolButton::FocusMargin, opt, w);
3471 tOpt.rect = focusRect;
3472 tOpt.state = bflags;
3477 QStyleOptionToolButton labelOpt = *tool;
3478 labelOpt.rect = buttonRect;
3488 const QStyleOptionTitleBar *tb =
3489 qstyleoption_cast<const QStyleOptionTitleBar *>(opt);
3498 QRect textRect =
subControlRect(CC_TitleBar, tb, SC_TitleBarLabel, w);
3502 pal, flags, p, w, &textOpt);
3505 buttonKOpt.
icon = tb->icon;
3507 if ((tb->subControls & SC_TitleBarSysMenu) &&
3508 (tb->titleBarFlags & Qt::WindowSystemMenuHint))
3510 buttonKOpt.
active = (tb->activeSubControls & SC_TitleBarSysMenu)
3511 && (tb->state & State_Sunken);
3512 QRect br =
subControlRect(CC_TitleBar, tb, SC_TitleBarSysMenu, w);
3517 if ((tb->subControls & SC_TitleBarMinButton) &&
3518 (tb->titleBarFlags & Qt::WindowMinimizeButtonHint))
3520 buttonKOpt.
active = (tb->activeSubControls & SC_TitleBarMinButton)
3521 && (tb->state & State_Sunken);
3522 QRect br =
subControlRect(CC_TitleBar, tb, SC_TitleBarMinButton, w);
3527 if ((tb->subControls & SC_TitleBarMaxButton) &&
3528 (tb->titleBarFlags & Qt::WindowMaximizeButtonHint))
3530 buttonKOpt.
active = (tb->activeSubControls & SC_TitleBarMaxButton)
3531 && (tb->state & State_Sunken);
3532 QRect br =
subControlRect(CC_TitleBar, tb, SC_TitleBarMaxButton, w);
3537 if ((tb->subControls & SC_TitleBarCloseButton) &&
3538 (tb->titleBarFlags & Qt::WindowSystemMenuHint))
3542 buttonKOpt.
active = (tb->activeSubControls & SC_TitleBarCloseButton)
3543 && (tb->state & State_Sunken);
3544 QRect br =
subControlRect(CC_TitleBar, tb, SC_TitleBarCloseButton, w);
3549 if ((tb->subControls & SC_TitleBarNormalButton) &&
3550 (((tb->titleBarFlags & Qt::WindowMinimizeButtonHint) &&
3551 (tb->titleBarState & Qt::WindowMinimized)) ||
3552 ((tb->titleBarFlags & Qt::WindowMaximizeButtonHint) &&
3553 (tb->titleBarState & Qt::WindowMaximized))))
3555 buttonKOpt.
active = (tb->activeSubControls & SC_TitleBarNormalButton)
3556 && (tb->state & State_Sunken);
3557 QRect br =
subControlRect(CC_TitleBar, tb, SC_TitleBarNormalButton, w);
3562 if (tb->subControls & SC_TitleBarShadeButton)
3564 buttonKOpt.
active = (tb->activeSubControls & SC_TitleBarShadeButton)
3565 && (tb->state & State_Sunken);
3566 QRect br =
subControlRect(CC_TitleBar, tb, SC_TitleBarShadeButton, w);
3571 if (tb->subControls & SC_TitleBarUnshadeButton)
3573 buttonKOpt.
active = (tb->activeSubControls & SC_TitleBarUnshadeButton)
3574 && (tb->state & State_Sunken);
3575 QRect br =
subControlRect(CC_TitleBar, tb, SC_TitleBarUnshadeButton, w);
3580 if ((tb->subControls & SC_TitleBarContextHelpButton)
3581 && (tb->titleBarFlags & Qt::WindowContextHelpButtonHint))
3583 buttonKOpt.
active = (tb->activeSubControls & SC_TitleBarContextHelpButton)
3584 && (tb->state & State_Sunken);
3585 QRect br =
subControlRect(CC_TitleBar, tb, SC_TitleBarContextHelpButton, w);
3597 QCommonStyle::drawComplexControl(cc, opt, p, w);
3601QRect KStyle::internalSubControlRect (ComplexControl control,
const QStyleOptionComplex* option,
3602 SubControl subControl,
const QWidget* widget)
const
3604 QRect r = option->rect;
3606 if (control == CC_ScrollBar)
3611 case SC_ScrollBarSubLine:
3614 if (widgetLayoutProp(WT_ScrollBar, ScrollBar::DoubleTopButton, option, widget))
3615 majorSize = widgetLayoutProp(WT_ScrollBar, ScrollBar::DoubleButtonHeight, option, widget);
3617 majorSize = widgetLayoutProp(WT_ScrollBar, ScrollBar::SingleButtonHeight, option, widget);
3619 if (option->state & State_Horizontal)
3620 return handleRTL(option, QRect(r.x(), r.y(), majorSize, r.height()));
3622 return handleRTL(option, QRect(r.x(), r.y(), r.width(), majorSize));
3627 case SC_ScrollBarAddLine:
3630 if (
widgetLayoutProp(WT_ScrollBar, ScrollBar::DoubleBotButton, option, widget))
3631 majorSize =
widgetLayoutProp(WT_ScrollBar, ScrollBar::DoubleButtonHeight, option, widget);
3633 majorSize =
widgetLayoutProp(WT_ScrollBar, ScrollBar::SingleButtonHeight, option, widget);
3635 if (option->state & State_Horizontal)
3636 return handleRTL(option, QRect(r.right() - majorSize + 1, r.y(), majorSize, r.height()));
3638 return handleRTL(option, QRect(r.x(), r.bottom() - majorSize + 1, r.width(), majorSize));
3651 SubControl subControl,
const QWidget* widget)
const
3653 QRect r = option->rect;
3664 case SC_ScrollBarSubLine:
3665 case SC_ScrollBarAddLine:
3669 case SC_ScrollBarGroove:
3671 QRect top = handleRTL(option, internalSubControlRect(control, option, SC_ScrollBarSubLine, widget));
3672 QRect bot = handleRTL(option, internalSubControlRect(control, option, SC_ScrollBarAddLine, widget));
3674 QPoint topLeftCorner, botRightCorner;
3675 if (option->state & State_Horizontal)
3677 topLeftCorner = QPoint(top.right() + 1, top.top());
3678 botRightCorner = QPoint(bot.left() - 1, top.bottom());
3682 topLeftCorner = QPoint(top.left(), top.bottom() + 1);
3683 botRightCorner = QPoint(top.right(), bot.top() - 1);
3686 return handleRTL(option, QRect(topLeftCorner, botRightCorner));
3689 case SC_ScrollBarFirst:
3690 case SC_ScrollBarLast:
3693 case SC_ScrollBarSlider:
3695 const QStyleOptionSlider* slOpt = ::qstyleoption_cast<const QStyleOptionSlider*>(option);
3698 QRect groove = handleRTL(option,
subControlRect(control, option, SC_ScrollBarGroove, widget));
3701 if (slOpt->minimum == slOpt->maximum)
3706 if (option->state & State_Horizontal)
3707 space = groove.width();
3709 space = groove.height();
3712 int sliderSize = int(space *
float(slOpt->pageStep) /
3713 (slOpt->maximum - slOpt->minimum + slOpt->pageStep));
3718 if (sliderSize > space)
3722 space = space - sliderSize;
3728 int pos = qRound(
float(slOpt->sliderPosition - slOpt->minimum)/
3729 (slOpt->maximum - slOpt->minimum)*space);
3730 if (option->state & State_Horizontal)
3731 return handleRTL(option, QRect(groove.x() + pos, groove.y(), sliderSize, groove.height()));
3733 return handleRTL(option, QRect(groove.x(), groove.y() + pos, groove.width(), sliderSize));
3736 case SC_ScrollBarSubPage:
3739 QRect slider = handleRTL(option,
subControlRect(control, option, SC_ScrollBarSlider, widget));
3740 QRect groove = handleRTL(option,
subControlRect(control, option, SC_ScrollBarGroove, widget));
3743 if (option->state & State_Horizontal)
3744 return handleRTL(option, QRect(groove.x(), groove.y(), slider.x() - groove.x(), groove.height()));
3746 return handleRTL(option, QRect(groove.x(), groove.y(), groove.width(), slider.y() - groove.y()));
3749 case SC_ScrollBarAddPage:
3752 QRect slider = handleRTL(option,
subControlRect(control, option, SC_ScrollBarSlider, widget));
3753 QRect groove = handleRTL(option,
subControlRect(control, option, SC_ScrollBarGroove, widget));
3756 if (option->state & State_Horizontal)
3757 return handleRTL(option,
3758 QRect(slider.right() + 1, groove.y(), groove.right() - slider.right(), groove.height()));
3760 return handleRTL(option,
3761 QRect(groove.x(), slider.bottom() + 1, groove.width(), groove.bottom() - slider.bottom()));
3771 if (
const QStyleOptionSpinBox *sb = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
3777 int bmr = bm + widgetLayoutProp(
WT_SpinBox, SpinBox::ButtonMargin +
Right, option, widget);
3778 int bmt = bm + widgetLayoutProp(
WT_SpinBox, SpinBox::ButtonMargin +
Top, option, widget);
3779 int bmb = bm + widgetLayoutProp(
WT_SpinBox, SpinBox::ButtonMargin +
Bot, option, widget);
3780 int bs = widgetLayoutProp(
WT_SpinBox, SpinBox::ButtonSpacing, option, widget);
3781 bool symmButtons = widgetLayoutProp(
WT_SpinBox, SpinBox::SymmetricButtons, option, widget);
3782 bool supportFrameless = widgetLayoutProp(
WT_SpinBox, SpinBox::SupportFrameless, option, widget);
3785 if (supportFrameless && !sb->frame)
3789 bmt = bmb = bmr = 0;
3792 const int buttonsWidth = bw-bml-bmr;
3793 const int buttonsLeft = r.right()-bw+bml+1;
3796 int availableButtonHeight = r.height()-bmt-bmb - bs;
3802 if (availableButtonHeight%2 != 0)
3807 availableButtonHeight = r.height()-bmt-bmb - bs;
3810 int heightUp = availableButtonHeight / 2;
3811 int heightDown = availableButtonHeight - heightUp;
3814 switch (subControl) {
3816 return handleRTL(option,
3817 QRect(buttonsLeft, r.top()+bmt, buttonsWidth, heightUp) );
3818 case SC_SpinBoxDown:
3819 return handleRTL(option,
3820 QRect(buttonsLeft, r.bottom()-bmb-heightDown+1, buttonsWidth, heightDown) );
3821 case SC_SpinBoxEditField:
3823 QRect labelRect(r.left()+fw, r.top()+fw, r.width()-fw-bw, r.height()-2*fw);
3824 labelRect = insideMargin(labelRect,
WT_SpinBox, SpinBox::ContentsMargin, option, widget);
3825 return handleRTL(option, labelRect );
3827 case SC_SpinBoxFrame:
3828 return (sb->frame || !supportFrameless) ? r : QRect();
3837 if (
const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(option)) {
3843 int bmr = bm + widgetLayoutProp(
WT_ComboBox, ComboBox::ButtonMargin +
Right, option, widget);
3844 int bmt = bm + widgetLayoutProp(
WT_ComboBox, ComboBox::ButtonMargin +
Top, option, widget);
3845 int bmb = bm + widgetLayoutProp(
WT_ComboBox, ComboBox::ButtonMargin +
Bot, option, widget);
3846 bool supportFrameless = widgetLayoutProp(
WT_ComboBox, ComboBox::SupportFrameless, option, widget);
3849 if (supportFrameless && !cb->frame)
3853 bmt = bmb = bmr = 0;
3856 switch (subControl) {
3857 case SC_ComboBoxFrame:
3858 return (cb->frame || !supportFrameless) ? r : QRect();
3859 case SC_ComboBoxArrow:
3860 return handleRTL(option,
3861 QRect(r.right()-bw+bml+1, r.top()+bmt, bw-bml-bmr, r.height()-bmt-bmb) );
3862 case SC_ComboBoxEditField:
3864 QRect labelRect(r.left()+fw, r.top()+fw, r.width()-fw-bw, r.height()-2*fw);
3865 labelRect = insideMargin(labelRect,
WT_ComboBox, ComboBox::ContentsMargin, option, widget);
3866 return handleRTL(option, labelRect );
3868 case SC_ComboBoxListBoxPopup:
3881 const QStyleOptionTitleBar *tbOpt =
3882 qstyleoption_cast<const QStyleOptionTitleBar *>(option);
3886 QRect ret = insideMargin(r,
WT_Window, Window::TitleMargin, option, widget);
3888 const int btnHeight = ret.height();
3893 bool isMinimized = tbOpt->titleBarState & Qt::WindowMinimized;
3894 bool isMaximized = tbOpt->titleBarState & Qt::WindowMaximized;
3898 bool menuCloseBtn = tbOpt->titleBarFlags & Qt::WindowSystemMenuHint;
3899 bool minBtn = !isMinimized &&
3900 (tbOpt->titleBarFlags & Qt::WindowMinimizeButtonHint);
3901 bool maxBtn = !isMaximized &&
3902 (tbOpt->titleBarFlags & Qt::WindowMaximizeButtonHint);
3904 (isMinimized && (tbOpt->titleBarFlags & Qt::WindowMinimizeButtonHint)) ||
3905 (isMaximized && (tbOpt->titleBarFlags & Qt::WindowMaximizeButtonHint));
3906 bool shadeBtn = tbOpt->titleBarFlags & Qt::WindowShadeButtonHint;
3907 bool helpBtn = tbOpt->titleBarFlags & Qt::WindowContextHelpButtonHint;
3910 int btnOffsetCount = 0;
3912 switch (subControl) {
3913 case SC_TitleBarLabel:
3915 if (tbOpt->titleBarFlags & Qt::WindowTitleHint)
3925 if (minBtn) ++cRight;
3926 if (restoreBtn) ++cRight;
3927 if (maxBtn) ++cRight;
3928 if (shadeBtn) ++cRight;
3929 if (helpBtn) ++cRight;
3931 ret.adjust( cLeft*btnWidth+(cLeft-1)*btnSpace+titleSpace, 0,
3932 -(titleSpace+cRight*btnWidth+(cRight-1)*btnSpace), 0 );
3937 case SC_TitleBarSysMenu:
3939 if (tbOpt->titleBarFlags & Qt::WindowSystemMenuHint) {
3940 ret.setRect(ret.left(), ret.top(), btnWidth, btnHeight);
3945 case SC_TitleBarContextHelpButton:
3948 case SC_TitleBarMinButton:
3951 else if (subControl == SC_TitleBarMinButton)
3953 case SC_TitleBarNormalButton:
3956 else if (subControl == SC_TitleBarNormalButton)
3958 case SC_TitleBarMaxButton:
3961 else if (subControl == SC_TitleBarMaxButton)
3963 case SC_TitleBarShadeButton:
3964 if (!isMinimized && shadeBtn)
3966 else if (subControl == SC_TitleBarShadeButton)
3968 case SC_TitleBarUnshadeButton:
3969 if (isMinimized && shadeBtn)
3971 else if (subControl == SC_TitleBarUnshadeButton)
3973 case SC_TitleBarCloseButton:
3977 else if (subControl == SC_TitleBarCloseButton)
3980 ret.setRect(ret.right()-btnOffsetCount*btnWidth-(btnOffsetCount-1)*btnSpace,
3981 ret.top(), btnWidth, btnHeight);
3989 return visualRect(tbOpt->direction, tbOpt->rect, ret);
3997 return QCommonStyle::subControlRect(control, option, subControl, widget);
4004static bool preceeds(
const QPoint &pt,
const QRect &bound,
4005 const QStyleOption* opt)
4007 if (opt->state & QStyle::State_Horizontal)
4010 if (opt->direction == Qt::LeftToRight)
4011 return pt.x() < bound.right();
4013 return pt.x() > bound.x();
4017 return pt.y() < bound.y();
4023 const QStyleOption* opt)
4025 if (opt->state & QStyle::State_Horizontal)
4028 if (opt->direction == Qt::LeftToRight)
4029 return pt.x() < totalRect.center().x() ? QStyle::SC_ScrollBarSubLine : QStyle::SC_ScrollBarAddLine;
4031 return pt.x() > totalRect.center().x() ? QStyle::SC_ScrollBarSubLine : QStyle::SC_ScrollBarAddLine;
4035 return pt.y() < totalRect.center().y() ? QStyle::SC_ScrollBarSubLine : QStyle::SC_ScrollBarAddLine;
4040 const QPoint& pt,
const QWidget* w)
const
4042 if (cc == CC_ScrollBar)
4045 QRect groove =
subControlRect(CC_ScrollBar, opt, SC_ScrollBarGroove, w);
4047 if (groove.contains(pt))
4051 QRect slider =
subControlRect(CC_ScrollBar, opt, SC_ScrollBarSlider, w);
4053 if (slider.contains(pt))
4054 return SC_ScrollBarSlider;
4055 else if (
preceeds(pt, slider, opt))
4056 return SC_ScrollBarSubPage;
4058 return SC_ScrollBarAddPage;
4068 QRect buttonRect = internalSubControlRect(CC_ScrollBar, opt, SC_ScrollBarSubLine, w);
4072 return SC_ScrollBarSubLine;
4079 QRect buttonRect = internalSubControlRect(CC_ScrollBar, opt, SC_ScrollBarAddLine, w);
4083 return SC_ScrollBarAddLine;
4088 return QCommonStyle::hitTestComplexControl(cc, opt, pt, w);
4098 const QStyleOptionButton* bOpt = qstyleoption_cast<const QStyleOptionButton*>(option);
4099 if (!bOpt)
return contentsSize;
4101 QSize size = contentsSize;
4103 if ((bOpt->features & QStyleOptionButton::DefaultButton) || (bOpt->features & QStyleOptionButton::AutoDefaultButton))
4104 size = expandDim(size,
WT_PushButton, PushButton::DefaultIndicatorMargin, option, widget);
4107 size = expandDim(size,
WT_PushButton, PushButton::ContentsMargin, option, widget);
4109 if (bOpt->features & QStyleOptionButton::HasMenu) {
4113 if (!bOpt->text.isEmpty() && !bOpt->icon.isNull()) {
4128 QSize size = contentsSize;
4129 int menuAreaWidth = 0;
4130 if (
const QStyleOptionToolButton* tbOpt = qstyleoption_cast<const QStyleOptionToolButton*>(option)) {
4131 if (tbOpt->features & QStyleOptionToolButton::MenuButtonPopup)
4132 menuAreaWidth =
pixelMetric(QStyle::PM_MenuButtonIndicator, option, widget);
4133 else if (tbOpt->features & QStyleOptionToolButton::HasMenu)
4137 size.setWidth(size.width() - menuAreaWidth);
4138 if (size.width() < size.height())
4139 size.setWidth(size.height());
4140 size.setWidth(size.width() + menuAreaWidth);
4142 return expandDim(size,
WT_ToolButton, ToolButton::ContentsMargin, option, widget);
4152 QSize size = expandDim(contentsSize,
WT_CheckBox, CheckBox::FocusMargin, option, widget);
4155 size.setHeight(qMax(size.height(), indicator));
4158 size.setWidth(size.width() + indicator + spacer);
4163 case CT_RadioButton:
4170 QSize size = expandDim(contentsSize,
WT_RadioButton, RadioButton::FocusMargin, option, widget);
4173 size.setHeight(qMax(size.height(), indicator));
4176 size.setWidth(size.width() + indicator + spacer);
4181 case CT_ProgressBar:
4183 QSize size = contentsSize;
4185 const QStyleOptionProgressBar* pbOpt = ::qstyleoption_cast<const QStyleOptionProgressBar*>(option);
4186 if (useSideText(pbOpt))
4189 size.setWidth(size.width() + sideTextWidth(pbOpt));
4204 return QSize(contentsSize.width() + extraW, contentsSize.height() + extraH);
4215 return QSize(contentsSize.width() + extraW, contentsSize.height() + extraH);
4220 const QStyleOptionMenuItem* miOpt = ::qstyleoption_cast<const QStyleOptionMenuItem*>(option);
4221 if (!miOpt)
return contentsSize;
4226 switch (miOpt->menuItemType)
4228 case QStyleOptionMenuItem::Normal:
4229 case QStyleOptionMenuItem::DefaultItem:
4230 case QStyleOptionMenuItem::SubMenu:
4232 int iconColW = miOpt->maxIconWidth;
4235 int leftColW = iconColW;
4236 if (miOpt->menuHasCheckableItems &&
4249 QFontMetrics fm(miOpt->font);
4252 int tabPos = miOpt->text.indexOf(QLatin1Char(
'\t'));
4256 textW = contentsSize.width();
4264 textW = contentsSize.width() +
4269 insideSize = QSize(leftColW + textW + rightColW, h);
4273 case QStyleOptionMenuItem::Separator:
4281 case QStyleOptionMenuItem::Scroller:
4282 case QStyleOptionMenuItem::TearOff:
4283 case QStyleOptionMenuItem::Margin:
4284 case QStyleOptionMenuItem::EmptyArea:
4285 return contentsSize;
4289 return expandDim(insideSize,
WT_MenuItem, MenuItem::Margin, option, widget);
4292 case CT_MenuBarItem:
4293 return expandDim(contentsSize,
WT_MenuBarItem, MenuBarItem::Margin, option, widget);
4301 bool rotated =
false;
4302 if (
const QStyleOptionTab *tabOpt = qstyleoption_cast<const QStyleOptionTab*>(option)) {
4303 rotated = isVerticalTab(tabOpt);
4306 return expandDim(contentsSize,
WT_TabBar, TabBar::TabContentsMargin, option, widget, rotated);
4311 const QStyleOptionTabWidgetFrame* tabOpt = qstyleoption_cast<const QStyleOptionTabWidgetFrame*>(option);
4319 widgetLayoutProp(
WT_TabWidget, TabWidget::ContentsMargin+
Left, option, widget) +
4320 widgetLayoutProp(
WT_TabWidget, TabWidget::ContentsMargin+
Right, option, widget);
4322 switch (tabOpt->shape) {
4323 case QTabBar::RoundedNorth:
4324 case QTabBar::TriangularNorth:
4325 case QTabBar::RoundedWest:
4326 case QTabBar::TriangularWest:
4327 return contentsSize + QSize(hor, vert);
4328 case QTabBar::RoundedSouth:
4329 case QTabBar::TriangularSouth:
4330 case QTabBar::RoundedEast:
4331 case QTabBar::TriangularEast:
4332 return contentsSize + QSize(vert,hor);
4336 case CT_HeaderSection:
4338 if (
const QStyleOptionHeader *
header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
4339 QSize iconSize =
header->icon.isNull() ? QSize(0,0) : QSize(22,22);
4340 QSize textSize =
header->fontMetrics.size(0,
header->text);
4342 int w = iconSize.width() + iconSpacing + textSize.width();
4343 int h = qMax(iconSize.height(), textSize.height() );
4345 return expandDim(QSize(w, h),
WT_Header, Header::ContentsMargin, option, widget);
4352 QSize size = contentsSize;
4355 size = expandDim(size,
WT_ComboBox, ComboBox::ContentsMargin, option, widget);
4371 return QCommonStyle::sizeFromContents(type, option, contentsSize, widget);
4376 if (QCommonStyle::eventFilter(obj, ev) )
4379 if (
QLabel *lbl = qobject_cast<QLabel*>(obj) ) {
4380 QWidget *buddy = lbl->buddy();
4382 switch (ev->type() ) {
4383 case QEvent::MouseButtonPress:
4385 QMouseEvent *mev =
dynamic_cast<QMouseEvent*
>(ev);
4388 if (lbl->rect().contains(mev->pos() ) ) {
4394 case QEvent::MouseButtonRelease:
4396 QMouseEvent *mev =
dynamic_cast<QMouseEvent*
>(ev);
4405 if (lbl->rect().contains(mev->pos() ) ) {
4406 buddy->setFocus(Qt::ShortcutFocusReason);
4411 if (obj == clickedLabel && buddy->isEnabled()) {
4414 QStyleOptionFocusRect foOpts;
4415 QRect foRect(0,0,lbl->width(),lbl->height());
4416 foOpts.palette = lbl->palette();
4417 foOpts.rect = foRect;
4419 foRect, lbl->palette(), 0, &p, lbl);
4433 mode(PaletteEntryMode),
4442KStyle::ColorMode::operator int()
const
4444 return int(role) | int(mode);
4449 mode = (encoded & BWAutoContrastMode) ? BWAutoContrastMode : PaletteEntryMode;
4450 role = QPalette::ColorRole(encoded & (~BWAutoContrastMode));
4455 QColor palColor = palette.color(role);
4457 if (mode == BWAutoContrastMode) {
4458 if (qGray(palColor.rgb()) > 128) {
4459 palColor = Qt::black;
4461 palColor = Qt::white;
4480 hAlign = Qt::AlignLeft;
SkipMainComponentRegistration
static bool showIconsOnPushButtons()
This function determines if the user wishes to see icons on the push buttons.
static QPalette createApplicationPalette(const KSharedConfigPtr &config=KSharedConfigPtr())
Used to obtain the QPalette that will be used to set the application palette.
@ Small
Small icons, e.g. for buttons.
@ Dialog
Icons for use in dialog titles, page lists, etc.
static KIconLoader * global()
Returns the global icon loader initialized with the global KComponentData.
int currentSize(KIconLoader::Group group) const
Returns the current size of the icon group.
@ SizeHuge
huge sized icons for iconviews
A wrapper around QIcon that provides KDE icon features.
static KSharedConfig::Ptr openConfig(const KComponentData &componentData, const QString &fileName=QString(), OpenFlags mode=FullConfig, const char *resourceType="config")
A representation for colors for use as a widget layout property.
Mode
KStyle understands two kinds of colors:
QColor color(const QPalette &palette)
Return the color corresponding to our role from the palette, automatically compensating for the contr...
ColorMode(QPalette::ColorRole _role)
Constructor, using a the given palette role _role and a default mode.
SubElement newSubElement(const QString &element)
void drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
QRect centerRect(const QRect &in, int w, int h) const
Returns a w x h QRect center inside the 'in' rectangle.
QPalette standardPalette() const
static StyleHint customStyleHint(const QString &element, const QWidget *widget)
Runtime element extension This is just convenience and does /not/ require the using widgets style to ...
void drawComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w) const
int pixelMetric(PixelMetric metric, const QStyleOption *opt=0, const QWidget *w=0) const
void drawInsideRect(QPainter *p, const QRect &r) const
Draws inside the rectangle using a thinkness 0 pen.
void setWidgetLayoutProp(WidgetType widget, int metric, int value)
Interface for the style to configure various metrics that KStyle has customizable.
QRect itemTextRect(const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const
QRect subControlRect(ComplexControl control, const QStyleOptionComplex *opt, SubControl subControl, const QWidget *w) const
static ControlElement customControlElement(const QString &element, const QWidget *widget)
WidgetType
This enum is used to represent KStyle's concept of a widget, and to associate drawing requests and me...
static SubElement customSubElement(const QString &element, const QWidget *widget)
StyleHint newStyleHint(const QString &element)
Runtime element extension, allows inheriting styles to add support custom elements merges supporting ...
SubControl hitTestComplexControl(ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *w) const
int styleHint(StyleHint hint, const QStyleOption *opt, const QWidget *w, QStyleHintReturn *returnData) const
void drawPrimitive(PrimitiveElement elem, const QStyleOption *opt, QPainter *p, const QWidget *w) const
QSize sizeFromContents(ContentsType type, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w) const
bool eventFilter(QObject *, QEvent *)
int layoutSpacingImplementation(QSizePolicy::ControlType control1, QSizePolicy::ControlType control2, Qt::Orientation orientation, const QStyleOption *option, const QWidget *widget) const
static QString defaultStyle()
Returns the default widget style.
QRect subElementRect(SubElement subRect, const QStyleOption *opt, const QWidget *w) const
QPixmap standardPixmap(StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=0) const
virtual void drawKStylePrimitive(WidgetType widgetType, int primitive, const QStyleOption *opt, const QRect &r, const QPalette &pal, State flags, QPainter *p, const QWidget *widget=0, Option *kOpt=0) const
Draws primitives which are used inside KStyle.
QRect itemPixmapRect(const QRect &r, int flags, const QPixmap &pixmap) const
ControlElement newControlElement(const QString &element)
virtual int widgetLayoutProp(WidgetType widgetType, int metric, const QStyleOption *opt=0, const QWidget *w=0) const
Used to obtain information about KStyle layout properties and metrics.
@ Bot
Apply an additional bottom margin.
@ Top
Apply an additional top margin.
@ Left
Apply an additional left margin.
@ Right
Apply an additional right margin.
QIcon standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option=0, const QWidget *widget=0) const
void drawItemText(QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const
void drawControl(ControlElement elem, const QStyleOption *opt, QPainter *p, const QWidget *w) const
QPixmap generatedIconPixmap(QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const
float metric(float dx, float dy)
#define KDE_DEFAULT_SINGLECLICK
static bool preceeds(const QPoint &pt, const QRect &bound, const QStyleOption *opt)
static const qint32 d_arrow[]
static const qint32 r_arrow[]
static const qint32 l_arrow[]
static QStyle::SubControl buttonPortion(const QRect &totalRect, const QPoint &pt, const QStyleOption *opt)
static int newStyleElement(const QString &element, const char *check, int &counter, QHash< QString, int > *elements)
static const QStyle::StyleHint SH_KCustomStyleElement
static const qint32 u_arrow[]
KStyle for KDE4 Copyright (C) 2004-2005 Maksim Orlovich maksim@kde.org Copyright (C) 2005,...
static const int X_KdeBase
static int customStyleElement(QStyle::StyleHint type, const QString &element, QWidget *widget)
const KComponentData & mainComponent()
const char * name(StandardAction id)
This will return the internal name of a given standard action.
Option representing the color of the thing to draw.
ColorMode color
Color to use for the drawing.
Option for drawing icons: represents whether the icon should be active or not.
bool active
Is the icon active?
QIcon icon
Icon drawn by this option.
Base for our own option classes.
Option representing text drawing info. For Generic::Text.
QString text
The text to draw.
Qt::Alignment hAlign
The horizontal alignment, default is Qt::AlignLeft.
void init()
Called by the constructor to set the default value of hAlign.