diff options
Diffstat (limited to 'src/gui/styles')
-rw-r--r-- | src/gui/styles/qs60style.cpp | 231 | ||||
-rw-r--r-- | src/gui/styles/qs60style_p.h | 13 | ||||
-rw-r--r-- | src/gui/styles/qs60style_symbian.cpp | 280 |
3 files changed, 358 insertions, 166 deletions
diff --git a/src/gui/styles/qs60style.cpp b/src/gui/styles/qs60style.cpp index 24c1608..c082125 100644 --- a/src/gui/styles/qs60style.cpp +++ b/src/gui/styles/qs60style.cpp @@ -10,33 +10,37 @@ ****************************************************************************/ #include "qs60style_p.h" + #include "qapplication.h" #include "qpainter.h" #include "qstyleoption.h" #include "qresizeevent" #include "qpixmapcache" -#include "qlistview.h" + #include "qcalendarwidget.h" -#include "qtabbar.h" +#include "qdial.h" +#include "qdialog.h" +#include "qerrormessage.h" +#include "qgroupbox.h" +#include "qheaderview.h" +#include "qlist.h" #include "qlistwidget.h" +#include "qlistview.h" #include "qmenu.h" -#include "qpushbutton.h" #include "qmenubar.h" +#include "qmessagebox.h" +#include "qpushbutton.h" +#include "qscrollbar.h" +#include "qtabbar.h" #include "qtablewidget.h" +#include "qtableview.h" #include "qtoolbar.h" -#include "qgroupbox.h" #include "qtoolbutton.h" +#include "qtreeview.h" + #include "private/qtoolbarextension_p.h" #include "private/qcombobox_p.h" #include "private/qwidget_p.h" -#include "qscrollbar.h" -#include "qlist.h" -#include "qtableview.h" -#include "qheaderview.h" -#include "qtreeview.h" -#include "qdialog.h" -#include "qmessagebox.h" -#include "qerrormessage.h" #if !defined(QT_NO_STYLE_S60) || defined(QT_PLUGIN) @@ -92,19 +96,19 @@ const short *QS60StylePrivate::m_pmPointer = QS60StylePrivate::data[0]; bool QS60StylePrivate::m_backgroundValid = false; const struct QS60StylePrivate::frameElementCenter QS60StylePrivate::m_frameElementsData[] = { - {SE_ButtonNormal, QS60StyleEnums::SP_QsnFrButtonTbCenter}, - {SE_ButtonPressed, QS60StyleEnums::SP_QsnFrButtonTbCenterPressed}, - {SE_FrameLineEdit, QS60StyleEnums::SP_QsnFrInputCenter}, - {SE_ListHighlight, QS60StyleEnums::SP_QsnFrListCenter}, - {SE_OptionsMenu, QS60StyleEnums::SP_QsnFrPopupCenter}, - {SE_SettingsList, QS60StyleEnums::SP_QsnFrSetOptCenter}, - {SE_TableItem, QS60StyleEnums::SP_QsnFrCaleCenter}, - {SE_TableHeaderItem, QS60StyleEnums::SP_QsnFrCaleHeadingCenter}, - {SE_ToolTip, QS60StyleEnums::SP_QsnFrPopupPreviewCenter}, - {SE_ToolBar, QS60StyleEnums::SP_QsnFrPopupSubCenter}, - {SE_ToolBarButton, QS60StyleEnums::SP_QsnFrSctrlButtonCenter}, - {SE_ToolBarButtonPressed, QS60StyleEnums::SP_QsnFrSctrlButtonCenterPressed}, - {SE_PanelBackground, QS60StyleEnums::SP_QsnFrSetOptCenter}, + {SE_ButtonNormal, QS60StyleEnums::SP_QsnFrButtonTbCenter}, + {SE_ButtonPressed, QS60StyleEnums::SP_QsnFrButtonTbCenterPressed}, + {SE_FrameLineEdit, QS60StyleEnums::SP_QsnFrInputCenter}, + {SE_ListHighlight, QS60StyleEnums::SP_QsnFrListCenter}, + {SE_OptionsMenu, QS60StyleEnums::SP_QsnFrPopupCenter}, + {SE_SettingsList, QS60StyleEnums::SP_QsnFrSetOptCenter}, + {SE_TableItem, QS60StyleEnums::SP_QsnFrCaleCenter}, + {SE_TableHeaderItem, QS60StyleEnums::SP_QsnFrCaleHeadingCenter}, + {SE_ToolTip, QS60StyleEnums::SP_QsnFrPopupPreviewCenter}, + {SE_ToolBar, QS60StyleEnums::SP_QsnFrPopupSubCenter}, + {SE_ToolBarButton, QS60StyleEnums::SP_QsnFrSctrlButtonCenter}, + {SE_ToolBarButtonPressed, QS60StyleEnums::SP_QsnFrSctrlButtonCenterPressed}, + {SE_PanelBackground, QS60StyleEnums::SP_QsnFrSetOptCenter}, }; static const int frameElementsCount = int(sizeof(QS60StylePrivate::m_frameElementsData)/sizeof(QS60StylePrivate::m_frameElementsData[0])); @@ -323,6 +327,14 @@ void QS60StylePrivate::drawSkinElement(SkinElements element, QPainter *painter, case SE_PanelBackground: drawFrame(SF_PanelBackground, painter, rect, flags | SF_PointNorth); break; + case SE_ScrollBarHandlePressedHorizontal: + drawRow(QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed, QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed, + QS60StyleEnums::SP_QsnCpScrollHandleTopPressed, Qt::Horizontal, painter, rect, flags | SF_PointEast); + break; + case SE_ScrollBarHandlePressedVertical: + drawRow(QS60StyleEnums::SP_QsnCpScrollHandleTopPressed, QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed, + QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed, Qt::Vertical, painter, rect, flags | SF_PointNorth); + break; default: break; } @@ -347,6 +359,10 @@ QSize QS60StylePrivate::partSize(QS60StyleEnums::SkinParts part, SkinElementFlag result.scale(pixelMetric(QStyle::PM_SliderLength), pixelMetric(QStyle::PM_SliderControlThickness), Qt::IgnoreAspectRatio); break; + + case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed: + case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed: + case QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed: case QS60StyleEnums::SP_QsnCpScrollBgBottom: case QS60StyleEnums::SP_QsnCpScrollBgMiddle: case QS60StyleEnums::SP_QsnCpScrollBgTop: @@ -512,7 +528,7 @@ void QS60StylePrivate::setThemePalette(QApplication *app) const widgetPalette.setBrush(QPalette::Window, QS60StylePrivate::backgroundTexture()); widgetPalette.setColor(QPalette::Base, Qt::transparent); // set button and tooltipbase based on pixel colors - QColor buttonColor = colorFromFrameGraphics(QS60StylePrivate::SF_ButtonNormal); + const QColor buttonColor = colorFromFrameGraphics(QS60StylePrivate::SF_ButtonNormal); widgetPalette.setColor(QPalette::Button, buttonColor ); widgetPalette.setColor(QPalette::Light, widgetPalette.color(QPalette::Button).lighter()); widgetPalette.setColor(QPalette::Dark, widgetPalette.color(QPalette::Button).darker()); @@ -621,7 +637,14 @@ void QS60Style::polish(QWidget *widget) widgetPalette.setColor(QPalette::All, QPalette::HighlightedText, QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 24, 0)); QApplication::setPalette(widgetPalette, "QLineEdit"); - + } else if (qobject_cast<QDial *> (widget)) { + const QColor color(QS60StylePrivate::s60Color(QS60StyleEnums::CL_QsnTextColors, 6, 0)); + widgetPalette.setColor(QPalette::WindowText, color); + widgetPalette.setColor(QPalette::Button, QApplication::palette().color(QPalette::Button)); + widgetPalette.setColor(QPalette::Dark, color.darker()); + widgetPalette.setColor(QPalette::Light, color.lighter()); + QApplication::setPalette(widgetPalette, "QDial"); + } } } @@ -795,8 +818,19 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom const QS60StylePrivate::SkinElements grooveElement = horizontal ? QS60StylePrivate::SE_ScrollBarGrooveHorizontal : QS60StylePrivate::SE_ScrollBarGrooveVertical; QS60StylePrivate::drawSkinElement(grooveElement, painter, grooveRect, flags); + + QStyle::SubControls subControls = optionSlider->subControls; + + // select correct slider (horizontal/vertical/pressed) + const bool sliderPressed = ((optionSlider->state & QStyle::State_Sunken) && (subControls & SC_ScrollBarSlider)); const QS60StylePrivate::SkinElements handleElement = - horizontal ? QS60StylePrivate::SE_ScrollBarHandleHorizontal : QS60StylePrivate::SE_ScrollBarHandleVertical; + horizontal ? + ( sliderPressed ? + QS60StylePrivate::SE_ScrollBarHandlePressedHorizontal : + QS60StylePrivate::SE_ScrollBarHandleHorizontal ) : + ( sliderPressed ? + QS60StylePrivate::SE_ScrollBarHandlePressedVertical : + QS60StylePrivate::SE_ScrollBarHandleVertical); QS60StylePrivate::drawSkinElement(handleElement, painter, scrollBarSlider, flags); } break; @@ -858,13 +892,8 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom QS60StylePrivate::drawSkinElement(skinElement, painter, cmbxEditField, flags); if (sub & SC_ComboBoxArrow) { - const int iconRectWidth = buttonOption.rect.width()>>1; - const int nudgeWidth = iconRectWidth>>1; - // Draw the little arrow - const QRect arrowRect(((buttonOption.rect.left()+buttonOption.rect.right())>>1) - nudgeWidth, - buttonOption.rect.center().y()-(buttonOption.rect.height()>>2)+nudgeWidth, iconRectWidth, iconRectWidth); - + buttonOption.rect.adjust(1, 1, -1, -1); painter->save(); painter->setPen(option->palette.buttonText().color()); drawPrimitive(PE_IndicatorSpinDown, &buttonOption, painter, widget); @@ -1106,15 +1135,20 @@ void QS60Style::drawComplexControl(ComplexControl control, const QStyleOptionCom } break; #endif //QT_NO_GROUPBOX +#ifndef QT_NO_DIAL + case CC_Dial: + if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { + QStyleOptionSlider optionSlider = *slider; + QCommonStyle::drawComplexControl(control, &optionSlider, painter, widget); + } + break; +#endif //QT_NO_DIAL //todo: remove non-used complex widgets in final version case CC_TitleBar: #ifdef QT3_SUPPORT case CC_Q3ListView: #endif //QT3_SUPPORT -#ifndef QT_NO_DIAL - case CC_Dial: -#endif //QT_NO_DIAL #ifndef QT_NO_WORKSPACE case CC_MdiControls: #endif //QT_NO_WORKSPACE @@ -1206,6 +1240,16 @@ void QS60Style::drawControl(ControlElement element, const QStyleOption *option, case CE_ToolButtonLabel: if (const QStyleOptionToolButton *toolBtn = qstyleoption_cast<const QStyleOptionToolButton *>(option)) { QStyleOptionToolButton optionToolButton = *toolBtn; + + if (!optionToolButton.icon.isNull() && (optionToolButton.state & QStyle::State_Sunken) + && (optionToolButton.state & State_Enabled)) { + + const QIcon::State state = optionToolButton.state & State_On ? QIcon::On : QIcon::Off; + const QPixmap pm(optionToolButton.icon.pixmap(optionToolButton.rect.size().boundedTo(optionToolButton.iconSize), + QIcon::Normal, state)); + optionToolButton.icon = generatedIconPixmap(QIcon::Selected, pm, &optionToolButton); + } + QCommonStyle::drawControl(element, &optionToolButton, painter, widget); } break; @@ -1886,8 +1930,12 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti drawPrimitive(PE_IndicatorCheckBox, option, painter, widget); // ... or normal "tick" selection at the end. } else if (option->state & QStyle::State_Selected) { + QRect tickRect = option->rect; + const int frameBorderWidth = QS60StylePrivate::pixelMetric(PM_Custom_FrameCornerWidth); + // adjust tickmark rect to exclude frame border + tickRect.adjust(0,-frameBorderWidth,0,-frameBorderWidth); QS60StyleEnums::SkinParts skinPart = QS60StyleEnums::SP_QgnIndiMarkedAdd; - QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, + QS60StylePrivate::drawSkinPart(skinPart, painter, tickRect, (flags | QS60StylePrivate::SF_ColorSkinned)); } } @@ -1931,70 +1979,43 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti case PE_IndicatorArrowRight: case PE_IndicatorArrowUp: { - if (option->rect.width() <= 1 || option->rect.height() <= 1) - break; - QRect r = option->rect; - int size = qMin(r.height(), r.width()); - int border = size/5; - int sqsize = 2*(size>>1); - QImage image(sqsize, sqsize, QImage::Format_ARGB32); - image.fill(Qt::transparent); - QPainter imagePainter(&image); - - QPolygon a; - int halfsqsize = sqsize>>1; - int borderlessSqSize = sqsize - border; - switch (element) { - case PE_IndicatorArrowUp: - a.setPoints(3, border, halfsqsize, halfsqsize, border, borderlessSqSize, halfsqsize); - break; - case PE_IndicatorArrowDown: - a.setPoints(3, border, halfsqsize, halfsqsize, borderlessSqSize, borderlessSqSize, halfsqsize); - break; - case PE_IndicatorArrowRight: - a.setPoints(3, borderlessSqSize, halfsqsize, halfsqsize, border, halfsqsize, borderlessSqSize); - break; - case PE_IndicatorArrowLeft: - a.setPoints(3, border, halfsqsize, halfsqsize, border, halfsqsize, borderlessSqSize); - break; - default: - break; - } - - int bsx = 0; - int bsy = 0; - - if (option->state & State_Sunken) { - bsx = pixelMetric(PM_ButtonShiftHorizontal); - bsy = pixelMetric(PM_ButtonShiftVertical); - } - - QRect bounds = a.boundingRect(); - int sx = halfsqsize - bounds.center().x() - 1; - int sy = halfsqsize - bounds.center().y() - 1; - QPalette themeColor = option->palette; - imagePainter.translate(sx + bsx, sy + bsy); - imagePainter.setPen(themeColor.buttonText().color()); - - if (!(option->state & State_Enabled)) { - imagePainter.translate(1, 1); - imagePainter.setPen(themeColor.light().color()); - imagePainter.drawPolygon(a); - imagePainter.translate(-1, -1); - imagePainter.setPen(themeColor.mid().color()); - } - imagePainter.drawPolygon(a); - imagePainter.end(); - int xOffset = r.x() + ((r.width() - size)>>1); - int yOffset = r.y() + ((r.height() - size)>>1); - - painter->drawImage(xOffset, yOffset, image); + QS60StyleEnums::SkinParts skinPart; + if (element==PE_IndicatorArrowDown) + skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowDown; + else if (element==PE_IndicatorArrowLeft) + skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowLeft; + else if (element==PE_IndicatorArrowRight) + skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowRight; + else if (element==PE_IndicatorArrowUp) + skinPart = QS60StyleEnums::SP_QgnGrafScrollArrowUp; + + QS60StylePrivate::drawSkinPart(skinPart, painter, option->rect, flags); } break; #endif //QT_NO_TOOLBUTTON #ifndef QT_NO_SPINBOX case PE_IndicatorSpinDown: case PE_IndicatorSpinUp: + if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { + QStyleOptionSpinBox optionSpinBox = *spinBox; + const QS60StyleEnums::SkinParts part = (element == PE_IndicatorSpinUp) ? + QS60StyleEnums::SP_QgnGrafScrollArrowUp : + QS60StyleEnums::SP_QgnGrafScrollArrowDown; + const int adjustment = qMin(optionSpinBox.rect.width(), optionSpinBox.rect.height())/6; + optionSpinBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment ); + QS60StylePrivate::drawSkinPart(part, painter, optionSpinBox.rect,flags); + } +#ifndef QT_NO_COMBOBOX + else if (const QStyleOptionFrame *cmb = qstyleoption_cast<const QStyleOptionFrame *>(option)) { + // We want to draw down arrow here for comboboxes as well. + const QS60StyleEnums::SkinParts part = QS60StyleEnums::SP_QgnGrafScrollArrowDown; + QStyleOptionFrame comboBox = *cmb; + const int adjustment = qMin(comboBox.rect.width(), comboBox.rect.height())/6; + comboBox.rect.translate(0, (element == PE_IndicatorSpinDown) ? adjustment : -adjustment ); + QS60StylePrivate::drawSkinPart(part, painter, comboBox.rect,flags); + } +#endif //QT_NO_COMBOBOX + break; case PE_IndicatorSpinMinus: case PE_IndicatorSpinPlus: if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { @@ -2154,7 +2175,6 @@ void QS60Style::drawPrimitive(PrimitiveElement element, const QStyleOption *opti if (option->rect.width() <= option->rect.height()) verticalMagic = 3; iconRect.translate(3, verticalMagic - resizeValue); - iconRect.adjust(-3,5,0,0); QS60StylePrivate::drawSkinPart(skinPart, painter, iconRect, flags); } } @@ -2225,6 +2245,12 @@ QSize QS60Style::sizeFromContents(ContentsType ct, const QStyleOption *opt, { QSize sz(csz); switch (ct) { + case CT_PushButton: + sz = QCommonStyle::sizeFromContents( ct, opt, csz, widget); + if (const QAbstractButton *buttonWidget = (qobject_cast<const QAbstractButton *>(widget))) + if (buttonWidget->isCheckable()) + sz += QSize(pixelMetric(PM_IndicatorWidth) + pixelMetric(PM_CheckBoxLabelSpacing), 0); + break; case CT_LineEdit: if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) sz += QSize(2*f->lineWidth, 4*f->lineWidth); @@ -2266,6 +2292,8 @@ int QS60Style::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget *w case SH_ComboBox_PopupFrameStyle: retValue = QFrame::NoFrame; break; + case SH_Dial_BackgroundRole: + retValue = QPalette::Base; default: break; } @@ -2349,10 +2377,8 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple case CC_SpinBox: if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { const int frameThickness = spinbox->frame ? pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; - const int buttonMargin = 2; //spinbox->frame ? /*QS60StylePrivate::pixelMetric(QStyle::PM_ButtonMargin)*/2 : 0; - const int buttonWidth = - QS60StylePrivate::pixelMetric(QStyle::PM_ButtonIconSize) + 2*buttonMargin; - //todo: buttonMargin commented out as WAY too big in pixel metrics + const int buttonMargin = spinbox->frame ? 2 : 0; + const int buttonWidth = QS60StylePrivate::pixelMetric(QStyle::PM_ButtonIconSize) + 2*buttonMargin; QSize buttonSize; buttonSize.setHeight(qMax(8, spinbox->rect.height() - frameThickness)); buttonSize.setWidth(buttonWidth); @@ -2400,8 +2426,7 @@ QRect QS60Style::subControlRect(ComplexControl control, const QStyleOptionComple ret = cmb->rect; const int width = cmb->rect.width(); const int height = cmb->rect.height(); - //todo: buttonMargin commented out as WAY too big in pixel metrics - const int buttonMargin = cmb->frame ? /*QS60StylePrivate::pixelMetric(QStyle::PM_ButtonMargin)*/2 : 0; + const int buttonMargin = cmb->frame ? 2 : 0; // lets use spinbox frame here as well, as no combobox specific value available. const int frameThickness = cmb->frame ? pixelMetric(PM_SpinBoxFrameWidth, cmb, widget) : 0; const int buttonWidth = QS60StylePrivate::pixelMetric(QStyle::PM_ButtonIconSize); diff --git a/src/gui/styles/qs60style_p.h b/src/gui/styles/qs60style_p.h index 8fe1c5d..da34efb 100644 --- a/src/gui/styles/qs60style_p.h +++ b/src/gui/styles/qs60style_p.h @@ -79,6 +79,10 @@ public: SP_QgnGrafBarFrameSideL, SP_QgnGrafBarFrameSideR, SP_QgnGrafBarProgress, + SP_QgnGrafScrollArrowDown, + SP_QgnGrafScrollArrowLeft, + SP_QgnGrafScrollArrowRight, + SP_QgnGrafScrollArrowUp, SP_QgnGrafTabActiveL, SP_QgnGrafTabActiveM, SP_QgnGrafTabActiveR, @@ -109,7 +113,10 @@ public: SP_QgnPropFolderCurrent, SP_QgnPropFolderSmall, SP_QgnPropFolderSmallNew, - SP_QgnPropPhoneMemcLarge, + SP_QgnPropPhoneMemcLarge, + SP_QsnCpScrollHandleBottomPressed, //ScrollBar handle, pressed state + SP_QsnCpScrollHandleMiddlePressed, + SP_QsnCpScrollHandleTopPressed, SP_QsnBgScreen, SP_QsnCpScrollBgBottom, SP_QsnCpScrollBgMiddle, @@ -282,7 +289,9 @@ public: SE_ToolBar, SE_ToolBarButton, SE_ToolBarButtonPressed, - SE_PanelBackground + SE_PanelBackground, + SE_ScrollBarHandlePressedHorizontal, //only for 5.0+ + SE_ScrollBarHandlePressedVertical, }; enum SkinFrameElements { diff --git a/src/gui/styles/qs60style_symbian.cpp b/src/gui/styles/qs60style_symbian.cpp index b54f819..35dfe13 100644 --- a/src/gui/styles/qs60style_symbian.cpp +++ b/src/gui/styles/qs60style_symbian.cpp @@ -80,6 +80,7 @@ public: const QSize &size, QS60StylePrivate::SkinElementFlags flags); static QColor colorValue(const TAknsItemID &colorGroup, int colorIndex); static QPixmap fromFbsBitmap(CFbsBitmap *icon, CFbsBitmap *mask, QS60StylePrivate::SkinElementFlags flags, QImage::Format format); + static QPixmap generateMissingThemeGraphic(QS60StyleEnums::SkinParts &part, const QSize &size, QS60StylePrivate::SkinElementFlags flags); private: static QPixmap createSkinnedGraphicsL(QS60StyleEnums::SkinParts part, @@ -94,54 +95,11 @@ private: static void unCompressBitmapL(const TRect& aTrgRect, CFbsBitmap* aTrgBitmap, CFbsBitmap* aSrcBitmap); static void colorGroupAndIndex(QS60StyleEnums::SkinParts skinID, TAknsItemID &colorGroup, int colorIndex); - static const TDesC& mapFallBackFileName(const int fileID); + static void fallbackInfo(const QS60StyleEnums::SkinParts &stylepart, TDes& fallbackFileName, TInt& fallbackIndex); static bool checkSupport(const int supportedRelease); static TAknsItemID checkAndUpdateReleaseSpecificGraphics(int part); // Array to match the skin ID, fallback graphics and Qt widget graphics. static const partMapEntry m_partMap[]; - static const fallbackMapEntry m_fallbackMap[]; -}; - -//FallbackMap has fallback graphics from various mbm-files in case that the requested icon is not in -//active or root skin. -// No fallback graphics for screen elements (it is guaranteed that the root skin contains these). -const fallbackMapEntry QS60StyleModeSpecifics::m_fallbackMap[] = { - {QS60StyleEnums::SP_QgnGrafBarWait, EAvkonMbm, EMbmAvkonQgn_graf_bar_wait_1}, - {QS60StyleEnums::SP_QgnGrafBarFrameCenter, EAvkonMbm, EMbmAvkonQgn_graf_bar_frame_center}, - {QS60StyleEnums::SP_QgnGrafBarFrameSideL, EAvkonMbm, EMbmAvkonQgn_graf_bar_frame_side_l}, - {QS60StyleEnums::SP_QgnGrafBarFrameSideR, EAvkonMbm, EMbmAvkonQgn_graf_bar_frame_side_r}, - {QS60StyleEnums::SP_QgnGrafBarProgress, EAvkonMbm, EMbmAvkonQgn_graf_bar_progress}, - {QS60StyleEnums::SP_QgnGrafTabActiveL, EAvkonMbm, EMbmAvkonQgn_graf_tab_active_l}, - {QS60StyleEnums::SP_QgnGrafTabActiveM, EAvkonMbm, EMbmAvkonQgn_graf_tab_active_m}, - {QS60StyleEnums::SP_QgnGrafTabActiveR, EAvkonMbm, EMbmAvkonQgn_graf_tab_active_r}, - {QS60StyleEnums::SP_QgnGrafTabPassiveL, EAvkonMbm, EMbmAvkonQgn_graf_tab_passive_l}, - {QS60StyleEnums::SP_QgnGrafTabPassiveM, EAvkonMbm, EMbmAvkonQgn_graf_tab_passive_m}, - {QS60StyleEnums::SP_QgnGrafTabPassiveR, EAvkonMbm, EMbmAvkonQgn_graf_tab_passive_r}, - {QS60StyleEnums::SP_QgnIndiCheckboxOff, EAvkonMbm, EMbmAvkonQgn_indi_checkbox_off}, - {QS60StyleEnums::SP_QgnIndiCheckboxOn, EAvkonMbm, EMbmAvkonQgn_indi_checkbox_on}, - {QS60StyleEnums::SP_QgnIndiHlColSuper, EAvkonMbm, 0x4456 }, /* EMbmAvkonQgn_indi_hl_col_super */ - {QS60StyleEnums::SP_QgnIndiHlExpSuper, EAvkonMbm, 0x4458 }, /* EMbmAvkonQgn_indi_hl_exp_super */ - {QS60StyleEnums::SP_QgnIndiHlLineBranch, EAvkonMbm, 0x445A }, /* EMbmAvkonQgn_indi_hl_line_branch */ - {QS60StyleEnums::SP_QgnIndiHlLineEnd, EAvkonMbm, 0x445C }, /* EMbmAvkonQgn_indi_hl_line_end */ - {QS60StyleEnums::SP_QgnIndiHlLineStraight, EAvkonMbm, 0x445E }, /* EMbmAvkonQgn_indi_hl_line_straight */ - {QS60StyleEnums::SP_QgnIndiMarkedAdd, EAvkonMbm, EMbmAvkonQgn_indi_marked_add }, - {QS60StyleEnums::SP_QgnIndiNaviArrowLeft, EAvkonMbm, EMbmAvkonQgn_indi_navi_arrow_left }, - {QS60StyleEnums::SP_QgnIndiNaviArrowRight, EAvkonMbm, EMbmAvkonQgn_indi_navi_arrow_right}, - {QS60StyleEnums::SP_QgnIndiRadiobuttOff, EAvkonMbm, EMbmAvkonQgn_indi_radiobutt_off }, - {QS60StyleEnums::SP_QgnIndiRadiobuttOn, EAvkonMbm, EMbmAvkonQgn_indi_radiobutt_on }, - {QS60StyleEnums::SP_QgnIndiSliderEdit, EAvkonMbm, EMbmAvkonQgn_indi_slider_edit }, - {QS60StyleEnums::SP_QgnIndiSubMenu, EAvkonMbm, EMbmAvkonQgn_indi_submenu }, - {QS60StyleEnums::SP_QgnNoteErased, EAvkonMbm, EMbmAvkonQgn_note_erased }, - {QS60StyleEnums::SP_QgnNoteError, EAvkonMbm, EMbmAvkonQgn_note_error }, - {QS60StyleEnums::SP_QgnNoteInfo, EAvkonMbm, EMbmAvkonQgn_note_info }, - {QS60StyleEnums::SP_QgnNoteOk, EAvkonMbm, EMbmAvkonQgn_note_ok }, - {QS60StyleEnums::SP_QgnNoteQuery, EAvkonMbm, EMbmAvkonQgn_note_query }, - {QS60StyleEnums::SP_QgnNoteWarning, EAvkonMbm, EMbmAvkonQgn_note_warning }, - {QS60StyleEnums::SP_QgnPropFileSmall, EAvkonMbm, EMbmAvkonQgn_prop_file_small }, - {QS60StyleEnums::SP_QgnPropFolderCurrent, EAvkonMbm, EMbmAvkonQgn_prop_folder_current }, - {QS60StyleEnums::SP_QgnPropFolderSmall, EAvkonMbm, EMbmAvkonQgn_prop_folder_small }, - {QS60StyleEnums::SP_QgnPropFolderSmallNew, EAvkonMbm, EMbmAvkonQgn_prop_folder_small_new}, - {QS60StyleEnums::SP_QgnPropPhoneMemcLarge, EAvkonMbm, EMbmAvkonQgn_prop_phone_memc_large} }; const partMapEntry QS60StyleModeSpecifics::m_partMap[] = { @@ -150,6 +108,10 @@ const partMapEntry QS60StyleModeSpecifics::m_partMap[] = { /* SP_QgnGrafBarFrameSideL */ {KAknsIIDQgnGrafBarFrameSideL, EDrawIcon, ES60_AllReleases, -1,-1}, /* SP_QgnGrafBarFrameSideR */ {KAknsIIDQgnGrafBarFrameSideR, EDrawIcon, ES60_AllReleases, -1,-1}, /* SP_QgnGrafBarProgress */ {KAknsIIDQgnGrafBarProgress, EDrawIcon, ES60_AllReleases, -1,-1}, + /* SP_QgnGrafScrollArrowDown */ {KAknsIIDQgnGrafScrollArrowDown, EDrawIcon, ES60_AllReleases, -1,-1}, + /* SP_QgnGrafScrollArrowLeft */ {KAknsIIDQgnGrafScrollArrowLeft, EDrawIcon, ES60_AllReleases, -1,-1}, + /* SP_QgnGrafScrollArrowRight */ {KAknsIIDQgnGrafScrollArrowRight, EDrawIcon, ES60_AllReleases, -1,-1}, + /* SP_QgnGrafScrollArrowUp */ {KAknsIIDQgnGrafScrollArrowUp, EDrawIcon, ES60_AllReleases, -1,-1}, /* SP_QgnGrafTabActiveL */ {KAknsIIDQgnGrafTabActiveL, EDrawIcon, ES60_AllReleases, -1,-1}, /* SP_QgnGrafTabActiveM */ {KAknsIIDQgnGrafTabActiveM, EDrawIcon, ES60_AllReleases, -1,-1}, /* SP_QgnGrafTabActiveR */ {KAknsIIDQgnGrafTabActiveR, EDrawIcon, ES60_AllReleases, -1,-1}, @@ -184,6 +146,11 @@ const partMapEntry QS60StyleModeSpecifics::m_partMap[] = { /* SP_QgnPropFolderSmallNew */ {KAknsIIDQgnPropFolderSmallNew, EDrawIcon, ES60_AllReleases, -1,-1}, /* SP_QgnPropPhoneMemcLarge */ {KAknsIIDQgnPropPhoneMemcLarge, EDrawIcon, ES60_AllReleases, -1,-1}, + // 3.1 & 3.2 do not have pressed state for scrollbar, so use normal scrollbar graphics instead. + /* SP_QsnCpScrollHandleBottomPressed*/ {KAknsIIDQsnCpScrollHandleBottom, EDrawIcon, ES60_3_1 | ES60_3_2, EAknsMajorGeneric, 0x20f8}, /*KAknsIIDQsnCpScrollHandleBottomPressed*/ + /* SP_QsnCpScrollHandleMiddlePressed*/ {KAknsIIDQsnCpScrollHandleMiddle, EDrawIcon, ES60_3_1 | ES60_3_2, EAknsMajorGeneric, 0x20f9}, /*KAknsIIDQsnCpScrollHandleMiddlePressed*/ + /* SP_QsnCpScrollHandleTopPressed*/ {KAknsIIDQsnCpScrollHandleTop, EDrawIcon, ES60_3_1 | ES60_3_2, EAknsMajorGeneric, 0x20fa}, /*KAknsIIDQsnCpScrollHandleTopPressed*/ + /* SP_QsnBgScreen */ {KAknsIIDQsnBgScreen, EDrawBackground, ES60_AllReleases, -1,-1}, /* SP_QsnCpScrollBgBottom */ {KAknsIIDQsnCpScrollBgBottom, EDrawIcon, ES60_AllReleases, -1,-1}, @@ -355,14 +322,157 @@ QPixmap QS60StyleModeSpecifics::colorSkinnedGraphics( return error ? QPixmap() : colorGraphics; } -const TDesC& QS60StyleModeSpecifics::mapFallBackFileName(const int fileID) -{ - switch(fileID){ - case ELastMbm: - return KNullDesC(); - case EAvkonMbm: +void QS60StyleModeSpecifics::fallbackInfo(const QS60StyleEnums::SkinParts &stylepart, TDes& fallbackFileName, TInt& fallbackIndex) +{ + switch(stylepart) { + case QS60StyleEnums::SP_QgnGrafBarWait: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_graf_bar_wait_1; + break; + case QS60StyleEnums::SP_QgnGrafBarFrameCenter: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_graf_bar_frame_center; + break; + case QS60StyleEnums::SP_QgnGrafBarFrameSideL: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_graf_bar_frame_side_l; + break; + case QS60StyleEnums::SP_QgnGrafBarFrameSideR: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_graf_bar_frame_side_r; + break; + case QS60StyleEnums::SP_QgnGrafBarProgress: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_graf_bar_progress; + break; + case QS60StyleEnums::SP_QgnGrafTabActiveL: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_graf_tab_active_l; + break; + case QS60StyleEnums::SP_QgnGrafTabActiveM: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_graf_tab_active_m; + break; + case QS60StyleEnums::SP_QgnGrafTabActiveR: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_graf_tab_active_r; + break; + case QS60StyleEnums::SP_QgnGrafTabPassiveL: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_graf_tab_passive_l; + break; + case QS60StyleEnums::SP_QgnGrafTabPassiveM: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_graf_tab_passive_m; + break; + case QS60StyleEnums::SP_QgnGrafTabPassiveR: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_graf_tab_passive_r; + break; + case QS60StyleEnums::SP_QgnIndiCheckboxOff: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_indi_checkbox_off; + break; + case QS60StyleEnums::SP_QgnIndiCheckboxOn: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_indi_checkbox_on; + break; + case QS60StyleEnums::SP_QgnIndiHlColSuper: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = 0x4456; /* EMbmAvkonQgn_indi_hl_col_super */ + break; + case QS60StyleEnums::SP_QgnIndiHlExpSuper: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = 0x4458; /* EMbmAvkonQgn_indi_hl_exp_super */ + break; + case QS60StyleEnums::SP_QgnIndiHlLineBranch: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = 0x445A; /* EMbmAvkonQgn_indi_hl_line_branch */ + break; + case QS60StyleEnums::SP_QgnIndiHlLineEnd: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = 0x445C; /* EMbmAvkonQgn_indi_hl_line_end */ + break; + case QS60StyleEnums::SP_QgnIndiHlLineStraight: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = 0x445E; /* EMbmAvkonQgn_indi_hl_line_straight */ + break; + case QS60StyleEnums::SP_QgnIndiMarkedAdd: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_indi_marked_add; + break; + case QS60StyleEnums::SP_QgnIndiNaviArrowLeft: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_indi_navi_arrow_left; + break; + case QS60StyleEnums::SP_QgnIndiNaviArrowRight: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_indi_navi_arrow_right; + break; + case QS60StyleEnums::SP_QgnIndiRadiobuttOff: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_indi_radiobutt_off; + break; + case QS60StyleEnums::SP_QgnIndiRadiobuttOn: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_indi_radiobutt_on; + break; + case QS60StyleEnums::SP_QgnIndiSliderEdit: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_indi_slider_edit; + break; + case QS60StyleEnums::SP_QgnIndiSubMenu: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_indi_submenu; + break; + case QS60StyleEnums::SP_QgnNoteErased: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_note_erased; + break; + case QS60StyleEnums::SP_QgnNoteError: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_note_error; + break; + case QS60StyleEnums::SP_QgnNoteInfo: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_note_info; + break; + case QS60StyleEnums::SP_QgnNoteOk: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_note_ok; + break; + case QS60StyleEnums::SP_QgnNoteQuery: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_note_query; + break; + case QS60StyleEnums::SP_QgnNoteWarning: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_note_warning; + break; + case QS60StyleEnums::SP_QgnPropFileSmall: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_prop_file_small; + break; + case QS60StyleEnums::SP_QgnPropFolderCurrent: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_prop_folder_current; + break; + case QS60StyleEnums::SP_QgnPropFolderSmall: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_prop_folder_small; + break; + case QS60StyleEnums::SP_QgnPropFolderSmallNew: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_prop_folder_small_new; + break; + case QS60StyleEnums::SP_QgnPropPhoneMemcLarge: + fallbackFileName = KAvkonBitmapFile(); + fallbackIndex = EMbmAvkonQgn_prop_phone_memc_large; + break; default: - return KAvkonBitmapFile(); + fallbackFileName = KNullDesC(); + fallbackIndex = -1; + break; } } @@ -372,10 +482,12 @@ QPixmap QS60StyleModeSpecifics::colorSkinnedGraphicsL( { const int stylepartIndex = (int)stylepart; const TAknsItemID skinId = m_partMap[stylepartIndex].skinID; - const TDesC& fallbackFileName = mapFallBackFileName(m_fallbackMap[stylepartIndex].fallbackGraphicID); - const TInt fallbackGraphicID = - (fallbackFileName!=KNullDesC) ? m_fallbackMap[stylepartIndex].fallbackGraphicID : KErrNotFound; + TInt fallbackGraphicID = -1; + HBufC* iconFile = HBufC::NewLC( KMaxFileName ); + TPtr fileNamePtr = iconFile->Des(); + fallbackInfo(stylepart, fileNamePtr, fallbackGraphicID); + TAknsItemID colorGroup = KAknsIIDQsnIconColors; int colorIndex = 0; colorGroupAndIndex(stylepart, colorGroup, colorIndex); @@ -390,11 +502,11 @@ QPixmap QS60StyleModeSpecifics::colorSkinnedGraphicsL( fallbackGraphicID == KErrNotFound?KErrNotFound:fallbackGraphicID+1; //masks are auto-generated as next in mif files MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance(); AknsUtils::CreateColorIconLC( - skinInstance, skinId, colorGroup, colorIndex, icon, iconMask, fallbackFileName, fallbackGraphicID , fallbackGraphicsMaskID, KRgbBlack); + skinInstance, skinId, colorGroup, colorIndex, icon, iconMask, fileNamePtr, fallbackGraphicID , fallbackGraphicsMaskID, KRgbBlack); User::LeaveIfError(AknIconUtils::SetSize(icon, targetSize, EAspectRatioNotPreserved)); User::LeaveIfError(AknIconUtils::SetSize(iconMask, targetSize, EAspectRatioNotPreserved)); QPixmap result = fromFbsBitmap(icon, iconMask, flags, qt_TDisplayMode2Format(icon->DisplayMode())); - CleanupStack::PopAndDestroy(2); //icon, iconMask + CleanupStack::PopAndDestroy(3); //icon, iconMask, iconFile return result; } @@ -537,20 +649,21 @@ QPixmap QS60StyleModeSpecifics::createSkinnedGraphicsL( switch (drawType) { case EDrawIcon: { - const TDesC& fallbackFileName = mapFallBackFileName(m_fallbackMap[stylepartIndex].fallbackGraphicID); - const TInt fallbackGraphicID = - (fallbackFileName!=KNullDesC) ? m_fallbackMap[stylepartIndex].fallbackGraphicID : KErrNotFound; + TInt fallbackGraphicID = -1; + HBufC* iconFile = HBufC::NewLC( KMaxFileName ); + TPtr fileNamePtr = iconFile->Des(); + fallbackInfo(part, fileNamePtr, fallbackGraphicID); CFbsBitmap *icon = 0; CFbsBitmap *iconMask = 0; const TInt fallbackGraphicsMaskID = fallbackGraphicID == KErrNotFound?KErrNotFound:fallbackGraphicID+1; //masks are auto-generated as next in mif files // QS60WindowSurface::unlockBitmapHeap(); - AknsUtils::CreateIconLC(skinInstance, skinId, icon, iconMask, fallbackFileName, fallbackGraphicID , fallbackGraphicsMaskID); + AknsUtils::CreateIconLC(skinInstance, skinId, icon, iconMask, fileNamePtr, fallbackGraphicID , fallbackGraphicsMaskID); User::LeaveIfError(AknIconUtils::SetSize(icon, targetSize, EAspectRatioNotPreserved)); User::LeaveIfError(AknIconUtils::SetSize(iconMask, targetSize, EAspectRatioNotPreserved)); result = fromFbsBitmap(icon, iconMask, flags, qt_TDisplayMode2Format(icon->DisplayMode())); - CleanupStack::PopAndDestroy(2); // iconMask, icon + CleanupStack::PopAndDestroy(3); // iconMask, icon, iconFile // QS60WindowSurface::lockBitmapHeap(); break; } @@ -878,6 +991,47 @@ short QS60StylePrivate::pixelMetric(int metric) #endif // QT_S60STYLE_LAYOUTDATA_SIMULATED } +QPixmap QS60StyleModeSpecifics::generateMissingThemeGraphic(QS60StyleEnums::SkinParts &part, + const QSize &size, QS60StylePrivate::SkinElementFlags flags) +{ + if (!QS60StylePrivate::isTouchSupported()) + return QPixmap(); + + QS60StyleEnums::SkinParts updatedPart = part; + switch(part){ + // AVKON UI has a abnormal handling for scrollbar graphics. It is possible that the root + // skin does not contain mandatory graphics for scrollbar pressed states. Therefore, AVKON UI + // creates dynamically these graphics by modifying the normal state scrollbar graphics slightly. + // S60Style needs to work similarly. Therefore if skingraphics call provides to be a miss + // (i.e. result is not valid), style needs to draw normal graphics instead and apply some + // modifications (similar to generatedIconPixmap()) to the result. + case QS60StyleEnums::SP_QsnCpScrollHandleBottomPressed: + updatedPart = QS60StyleEnums::SP_QsnCpScrollHandleBottom; + break; + case QS60StyleEnums::SP_QsnCpScrollHandleMiddlePressed: + updatedPart = QS60StyleEnums::SP_QsnCpScrollHandleMiddle; + break; + case QS60StyleEnums::SP_QsnCpScrollHandleTopPressed: + updatedPart = QS60StyleEnums::SP_QsnCpScrollHandleTop; + break; + default: + break; + } + if (part==updatedPart) { + return QPixmap(); + } else { + QPixmap result = skinnedGraphics(updatedPart, size, flags); + // TODO: fix this + QStyleOption opt; + // opt.palette = q->standardPalette(); + + // For now, always generate new icon based on "selected". In the future possibly, expand + // this to consist other possibilities as well. + result = QApplication::style()->generatedIconPixmap(QIcon::Selected, result, &opt); + return result; + } +} + QPixmap QS60StylePrivate::part(QS60StyleEnums::SkinParts part, const QSize &size, SkinElementFlags flags) { @@ -893,6 +1047,10 @@ QPixmap QS60StylePrivate::part(QS60StyleEnums::SkinParts part, // opt.palette = q->standardPalette(); result = QApplication::style()->generatedIconPixmap(QIcon::Disabled, result, &opt); } + + if (!result) + result = QS60StyleModeSpecifics::generateMissingThemeGraphic(part, size, flags); + return result; } |