src/hbcore/style/hbstyle.cpp
changeset 5 627c4a0fd0e7
parent 3 11d3954df52a
child 6 c3690ec91ef8
equal deleted inserted replaced
3:11d3954df52a 5:627c4a0fd0e7
    21 ** If you have questions regarding the use of this file, please contact
    21 ** If you have questions regarding the use of this file, please contact
    22 ** Nokia at developer.feedback@nokia.com.
    22 ** Nokia at developer.feedback@nokia.com.
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 
    25 
       
    26 #include "hbstyle_p.h"
    26 #include "hbstyleoptionslider_p.h"
    27 #include "hbstyleoptionslider_p.h"
    27 #include "hbstyleoptionsliderelement_p.h"
    28 #include "hbstyleoptionsliderelement_p.h"
    28 #include "hbstyleoptionpushbutton_p.h"
    29 #include "hbstyleoptionpushbutton_p.h"
    29 #include "hbstyleoptiontoolbutton_p.h"
    30 #include "hbstyleoptiontoolbutton_p.h"
    30 #include "hbstyleoptiontooltip_p.h"
    31 #include "hbstyleoptiontooltip_p.h"
    47 #include "hbstyleoptionmessagebox_p.h"
    48 #include "hbstyleoptionmessagebox_p.h"
    48 #include "hbstyleoptionnavigationbutton_p.h"
    49 #include "hbstyleoptionnavigationbutton_p.h"
    49 #include "hbstyleoptionindicatorbutton_p.h"
    50 #include "hbstyleoptionindicatorbutton_p.h"
    50 #include "hbstyleoptionsignalindicator_p.h"
    51 #include "hbstyleoptionsignalindicator_p.h"
    51 #include "hbstyleoptionbatteryindicator_p.h"
    52 #include "hbstyleoptionbatteryindicator_p.h"
    52 #include "hbstyle_p.h"
       
    53 #include "hbstyleloader.h"
    53 #include "hbstyleloader.h"
    54 #include "hbwidgetloader_p.h"
    54 #include "hbwidgetloader_p.h"
    55 #include "hbwidget_p.h"
    55 #include "hbwidget_p.h"
    56 #include "hbstyleoptionratingslider_p.h"
    56 #include "hbstyleoptionratingslider_p.h"
    57 #include "hbstyleoptiondataformviewitem_p.h"
    57 #include "hbstyleoptiondataformviewitem_p.h"
   130     Whenever the widget's state changes in a way that needs changes in drawing the primitive
   130     Whenever the widget's state changes in a way that needs changes in drawing the primitive
   131     (such as button pressed down -> change the button background image) then the widget needs to
   131     (such as button pressed down -> change the button background image) then the widget needs to
   132     call the updatePrimitive method.
   132     call the updatePrimitive method.
   133 
   133 
   134     Generally primitives should be updated only when a state change occurs. When a widget uses primitives to construct
   134     Generally primitives should be updated only when a state change occurs. When a widget uses primitives to construct
   135     itself it does not need a paint() method at all since primitives (widget's childs) are doing the drawing. 
   135     itself it does not need a paint() method at all since primitives (widget's children) are doing the drawing. 
   136     Painting for the primitives occurs from the graphics scene.
   136     Painting for the primitives occurs from the graphics scene.
   137 
   137 
   138 */
   138 */
   139 
   139 
   140 /*!
   140 /*!
  3382 
  3382 
  3383             case P_RatingSlider_frame:{
  3383             case P_RatingSlider_frame:{
  3384                 if (const HbStyleOptionRatingSlider *opt = qstyleoption_cast<const HbStyleOptionRatingSlider *>(option)) {                   
  3384                 if (const HbStyleOptionRatingSlider *opt = qstyleoption_cast<const HbStyleOptionRatingSlider *>(option)) {                   
  3385                     HbRepeatItem *repeatItem = static_cast<HbRepeatItem*>(item);
  3385                     HbRepeatItem *repeatItem = static_cast<HbRepeatItem*>(item);
  3386                     repeatItem->setRepeatingNumber(opt->noOfStars);
  3386                     repeatItem->setRepeatingNumber(opt->noOfStars);
  3387                     if(opt->unRatedGraphicsName != QString()){
  3387                     if (!opt->unRatedGraphicsName.isEmpty()) {
  3388                         repeatItem->setName(opt->unRatedGraphicsName);
  3388                         repeatItem->setName(opt->unRatedGraphicsName);
  3389                     }
  3389                     }
  3390                     else {
  3390                     else {
  3391                         repeatItem->setName(QLatin1String("qtg_graf_ratingslider_unrated"));
  3391                         repeatItem->setName(QLatin1String("qtg_graf_ratingslider_unrated"));
  3392                     }
  3392                     }
  3401                     HbRepeatMaskItem *repeatItem = static_cast<HbRepeatMaskItem*>(item);
  3401                     HbRepeatMaskItem *repeatItem = static_cast<HbRepeatMaskItem*>(item);
  3402                     repeatItem->setMaskValue(opt->progressValue);
  3402                     repeatItem->setMaskValue(opt->progressValue);
  3403                     repeatItem->setMaximum(opt->noOfIntervals);
  3403                     repeatItem->setMaximum(opt->noOfIntervals);
  3404                     repeatItem->setInverted(opt->inverted);
  3404                     repeatItem->setInverted(opt->inverted);
  3405                     repeatItem->setRepeatingNumber(opt->noOfStars);
  3405                     repeatItem->setRepeatingNumber(opt->noOfStars);
  3406                     if(opt->ratedGraphicsName != QString()){
  3406                     if (!opt->ratedGraphicsName.isEmpty()) {
  3407                         repeatItem->setName(opt->ratedGraphicsName);
  3407                         repeatItem->setName(opt->ratedGraphicsName);
  3408                     }
  3408                     }
  3409                     else {
  3409                     else {
  3410                         repeatItem->setName(QLatin1String("qtg_graf_ratingslider_rated"));
  3410                         repeatItem->setName(QLatin1String("qtg_graf_ratingslider_rated"));
  3411                     }
  3411                     }
  3760     } else {
  3760     } else {
  3761         qDebug() << "HbStyle::polishItem : -- item name: " << name << "(missing item)";
  3761         qDebug() << "HbStyle::polishItem : -- item name: " << name << "(missing item)";
  3762     }
  3762     }
  3763 #endif
  3763 #endif
  3764 
  3764 
  3765     HbDeviceProfile profile(HbDeviceProfile::profile(widget));
       
  3766 
       
  3767     const HbVector<HbCss::Declaration> decl = declarations(styleRules, name, widget, profile);
       
  3768 #ifdef HBSTYLE_DEBUG
       
  3769     qDebug() << "HbStyle::polishItem : -- Number of maching CSS declarations: " << decl.count();
       
  3770 #endif
       
  3771     HbCss::ValueExtractor extractor(decl, layoutParameters, profile);
       
  3772     HbCss::GeometryValues geomValues;
       
  3773     HbCss::PositionValues posValues;
       
  3774 
       
  3775     bool extracted = extractor.extractGeometry(geomValues);
       
  3776 #ifndef HBSTYLE_DEBUG
       
  3777     Q_UNUSED(extracted);
       
  3778 #endif
       
  3779 #ifdef HBSTYLE_DEBUG
       
  3780     if ( !extracted ) {
       
  3781         qDebug() << "HbStyle::polishItem : -- No geometry overrides found";
       
  3782     }
       
  3783 #endif
       
  3784     extracted = extractor.extractPosition(posValues);
       
  3785 #ifdef HBSTYLE_DEBUG
       
  3786     if ( !extracted ) {
       
  3787         qDebug() << "HbStyle::polishItem : -- No position overrides found";
       
  3788     }
       
  3789 #endif
       
  3790 
       
  3791     if ( item ) {
       
  3792         if (posValues.mFlags & HbCss::ExtractedZValue) {
       
  3793 #ifdef HBSTYLE_DEBUG
       
  3794             qDebug() << "HbStyle::polishItem : -- Setting zvalue: " << posValues.mZ;
       
  3795 #endif
       
  3796             item->setZValue(posValues.mZ);
       
  3797         }
       
  3798     }
       
  3799 
       
  3800     QGraphicsWidget *gWidget = (item && item->isWidget())
       
  3801         ? static_cast<QGraphicsWidget*>(item)
       
  3802         : 0;
       
  3803     if ( gWidget ) {
       
  3804         if (posValues.mFlags & HbCss::ExtractedLayoutDirection) {
       
  3805 #ifdef HBSTYLE_DEBUG
       
  3806             qDebug() << "HbStyle::polishItem : -- Setting layout direction: " << posValues.mLayoutDirection;
       
  3807 #endif
       
  3808             if (posValues.mLayoutDirection == HbCss::LayoutDirection_LeftToRight) {
       
  3809                 gWidget->setLayoutDirection(Qt::LeftToRight);
       
  3810             } else if (posValues.mLayoutDirection == HbCss::LayoutDirection_RightToLeft) {
       
  3811                 gWidget->setLayoutDirection(Qt::RightToLeft);
       
  3812             } else {
       
  3813                 gWidget->unsetLayoutDirection();
       
  3814             }
       
  3815         }
       
  3816     }
       
  3817 
       
  3818     HbWidgetBase *hbWidget = qobject_cast<HbWidgetBase*>(gWidget);
       
  3819     if ( hbWidget ) {
       
  3820         HbWidgetBasePrivate* hbWidget_p = HbWidgetBasePrivate::d_ptr(hbWidget);
       
  3821         QFont font;
       
  3822         HbFontSpec fontSpec;
       
  3823         int dummy;
       
  3824         if (extractor.extractFont(&font, &fontSpec, &dummy)) {
       
  3825             if ( !fontSpec.isNull() ) {
       
  3826                 if ( font == QFont() ) {
       
  3827 #ifdef HBSTYLE_DEBUG
       
  3828                     qDebug() << "HbStyle::polishItem : -- Setting fontspec: " << fontSpec.role();
       
  3829 #endif
       
  3830                     hbWidget->setFontSpec(fontSpec);
       
  3831                 } else {
       
  3832 #ifdef HBSTYLE_DEBUG
       
  3833                     qDebug() << "HbStyle::polishItem : -- Setting fontspec with overrides: "
       
  3834                              << fontSpec.role() << font;
       
  3835 #endif
       
  3836                     hbWidget->setFont(fontSpec.font().resolve(font));
       
  3837                 }
       
  3838             } else {
       
  3839 #ifdef HBSTYLE_DEBUG
       
  3840                 qDebug() << "HbStyle::polishItem : -- Setting explicit font: " << font;
       
  3841 #endif
       
  3842                 hbWidget->setFont(font);
       
  3843             }
       
  3844         }
       
  3845 
       
  3846         HbIconItem* icon = qobject_cast<HbIconItem*>(hbWidget);
       
  3847         if (icon) {
       
  3848             Qt::AspectRatioMode mode;
       
  3849             if (extractor.extractAspectRatioMode(&mode) 
       
  3850                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_IconAspectRatioMode)) {
       
  3851 #ifdef HBSTYLE_DEBUG
       
  3852                 qDebug() << "HbStyle::polishItem : -- Setting aspect ratio mode: " << mode;
       
  3853 #endif
       
  3854                 icon->setAspectRatioMode(mode);
       
  3855                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_IconAspectRatioMode, false);
       
  3856             }
       
  3857             if(!hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_IconBrush)){
       
  3858                 QBrush brush;
       
  3859                 QString uri;
       
  3860                 HbCss::Repeat repeat = HbCss::Repeat_XY;
       
  3861                 Qt::Alignment alignment = Qt::AlignTop | Qt::AlignLeft;
       
  3862                 HbCss::Attachment attachment = HbCss::Attachment_Scroll;
       
  3863                 HbCss::Origin origin = HbCss::Origin_Padding;
       
  3864                 HbCss::Origin clip = HbCss::Origin_Border;
       
  3865                 if (extractor.extractBackground(&brush, &uri, &repeat, &alignment, &origin, &attachment, &clip)) {
       
  3866 #ifdef HBSTYLE_DEBUG
       
  3867                     qDebug() << "HbStyle::polishItem : -- Setting icon background: " << brush;
       
  3868 #endif
       
  3869                     icon->setBrush( brush );
       
  3870                 } else {
       
  3871 #ifdef HBSTYLE_DEBUG
       
  3872                     qDebug() << "HbStyle::polishItem : -- Resetting icon background";
       
  3873 #endif
       
  3874                     icon->setBrush( QBrush() );
       
  3875                 }
       
  3876                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_IconBrush, false);
       
  3877             }
       
  3878         }
       
  3879 
       
  3880         HbTextItem* text = qobject_cast<HbTextItem*>(hbWidget);
       
  3881         if (text) {
       
  3882             HbCss::TextValues textValues;
       
  3883             if ( extractor.extractTextValues( textValues ) ) {
       
  3884                 if ( textValues.mFlags & HbCss::ExtractedLineCountMin
       
  3885                     && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin)) {
       
  3886 #ifdef HBSTYLE_DEBUG
       
  3887                     qDebug() << "HbStyle::polishItem : -- Setting text min lines: " << textValues.mLineCountMin;
       
  3888 #endif
       
  3889                     text->setMinimumLines( textValues.mLineCountMin );
       
  3890                     hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin, false);
       
  3891                 }
       
  3892                 if ( textValues.mFlags & HbCss::ExtractedLineCountMax
       
  3893                     && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMax)) {
       
  3894 #ifdef HBSTYLE_DEBUG
       
  3895                     qDebug() << "HbStyle::polishItem : -- Setting text max lines: " << textValues.mLineCountMax;
       
  3896 #endif
       
  3897                     text->setMaximumLines( textValues.mLineCountMax );
       
  3898                     hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMax, false);
       
  3899                 }
       
  3900             }
       
  3901             if ( posValues.mFlags & HbCss::ExtractedTextAlign 
       
  3902                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign)) {
       
  3903 #ifdef HBSTYLE_DEBUG
       
  3904                 qDebug() << "HbStyle::polishItem : -- Setting text alignment: " << posValues.mTextAlignment;
       
  3905 #endif
       
  3906                 text->setAlignment( posValues.mTextAlignment );
       
  3907                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign, false);
       
  3908             }
       
  3909             if ( posValues.mFlags & HbCss::ExtractedWrapMode 
       
  3910                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextWrapMode)) {
       
  3911 #ifdef HBSTYLE_DEBUG
       
  3912                 qDebug() << "HbStyle::polishItem : -- Setting wrap mode : " << posValues.mTextWrapMode;
       
  3913 #endif
       
  3914                 text->setTextWrapping( posValues.mTextWrapMode );
       
  3915                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextWrapMode, false);
       
  3916             }
       
  3917         }
       
  3918 
       
  3919         HbRichTextItem* richtext = qobject_cast<HbRichTextItem*>(hbWidget);
       
  3920         if (richtext) {
       
  3921             if ( posValues.mFlags & HbCss::ExtractedTextAlign
       
  3922                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign)) {
       
  3923 #ifdef HBSTYLE_DEBUG
       
  3924                 qDebug() << "HbStyle::polishItem : -- Setting text alignment: " << posValues.mTextAlignment;
       
  3925 #endif
       
  3926                 richtext->setAlignment( posValues.mTextAlignment );
       
  3927                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign, false);
       
  3928             }
       
  3929             if ( posValues.mFlags & HbCss::ExtractedWrapMode 
       
  3930                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextWrapMode)) {
       
  3931 #ifdef HBSTYLE_DEBUG
       
  3932                 qDebug() << "HbStyle::polishItem : -- Setting wrap mode : " << posValues.mTextWrapMode;
       
  3933 #endif
       
  3934                 richtext->setTextWrapping( posValues.mTextWrapMode );
       
  3935                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextWrapMode, false);
       
  3936             }
       
  3937         }
       
  3938 
       
  3939         HbFrameItem *frame = qobject_cast<HbFrameItem*>(hbWidget);
       
  3940         if (frame && !frame->frameDrawer().d->testBorderApiProtectionFlag()) {
       
  3941             qreal borderWidths[HbCss::NumEdges] = { 0.0,0.0,0.0,0.0 };
       
  3942             QBrush borderColors[HbCss::NumEdges];
       
  3943             HbCss::BorderStyle borderStyles[HbCss::NumEdges];
       
  3944             QSize borderRadii[4];
       
  3945 
       
  3946             if (extractor.extractBorder(borderWidths,borderColors,borderStyles,borderRadii)) {
       
  3947 #ifdef HBSTYLE_DEBUG
       
  3948                 qDebug() << "HbStyle::polishItem : -- Setting border widths (l,t,r,b):"
       
  3949                     << borderWidths[HbCss::LeftEdge]
       
  3950                     << borderWidths[HbCss::TopEdge]
       
  3951                     << borderWidths[HbCss::RightEdge]
       
  3952                     << borderWidths[HbCss::BottomEdge];
       
  3953 #endif
       
  3954                 frame->frameDrawer().setBorderWidths(
       
  3955                     borderWidths[HbCss::LeftEdge],
       
  3956                     borderWidths[HbCss::TopEdge],
       
  3957                     borderWidths[HbCss::RightEdge],
       
  3958                     borderWidths[HbCss::BottomEdge]);
       
  3959                 frame->frameDrawer().d->setBorderApiProtectionFlag(false);
       
  3960             }
       
  3961         }
       
  3962         if ( hbWidget->inherits( "HbLineEdit" ) ) {
       
  3963             HbCss::TextValues textValues;
       
  3964             if ( extractor.extractTextValues( textValues ) ) {
       
  3965                 if ( textValues.mFlags & HbCss::ExtractedLineCountMin
       
  3966                     && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin)) {
       
  3967 #ifdef HBSTYLE_DEBUG
       
  3968                     qDebug() << "HbStyle::polishItem : -- Setting text min lines: " << textValues.mLineCountMin;
       
  3969 #endif
       
  3970                     hbWidget->setProperty( "minRows", textValues.mLineCountMin );
       
  3971                     hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin, false);
       
  3972                 }
       
  3973                 if ( textValues.mFlags & HbCss::ExtractedLineCountMax
       
  3974                     && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin)) {
       
  3975 #ifdef HBSTYLE_DEBUG
       
  3976                     qDebug() << "HbStyle::polishItem : -- Setting text max lines: " << textValues.mLineCountMax;
       
  3977 #endif
       
  3978                     hbWidget->setProperty( "maxRows", textValues.mLineCountMax );
       
  3979                     hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMax, false);
       
  3980                 }
       
  3981             }
       
  3982         }
       
  3983     }
       
  3984 
       
  3985     QGraphicsLayoutItem* lItem = (item && item->isWidget()) ? (QGraphicsLayoutItem*)static_cast<QGraphicsWidget*>(item) : 0;
  3765     QGraphicsLayoutItem* lItem = (item && item->isWidget()) ? (QGraphicsLayoutItem*)static_cast<QGraphicsWidget*>(item) : 0;
  3986     if ( !lItem ) {
  3766     if ( !lItem ) {
  3987         lItem = widget->layoutPrimitive(name);
  3767         lItem = widget->layoutPrimitive(name);
  3988         if ( lItem && !lItem->graphicsItem() ) {
  3768         if ( lItem && !lItem->graphicsItem() ) {
  3989             // assume it is spacer
  3769             // assume it is spacer
  3990             static_cast<HbMeshLayout*>(widget->layout())->setItemId( lItem, name );
  3770             static_cast<HbMeshLayout*>(widget->layout())->setItemId( lItem, name );
  3991         }
  3771         }
  3992     }
  3772     }
       
  3773 
       
  3774     HbDeviceProfile profile(HbDeviceProfile::profile(widget));
       
  3775 
       
  3776     const HbVector<HbCss::Declaration> decl = declarations(styleRules, name, widget, profile);
       
  3777 #ifdef HBSTYLE_DEBUG
       
  3778     qDebug() << "HbStyle::polishItem : -- Number of matching CSS declarations: " << decl.count();
       
  3779 #endif
       
  3780     HbCss::ValueExtractor extractor(decl, layoutParameters, profile);
       
  3781     HbCss::KnownProperties prop;
       
  3782 
       
  3783     if ( !extractor.extractKnownProperties(prop) ) {
       
  3784 #ifdef HBSTYLE_DEBUG
       
  3785         qDebug() << "HbStyle::polishItem : -- No polish overrides found";
       
  3786 #endif
       
  3787         return;
       
  3788     }
       
  3789 
       
  3790     if ( item ) {
       
  3791         if (prop.mFlags & HbCss::ExtractedZValue) {
       
  3792 #ifdef HBSTYLE_DEBUG
       
  3793             qDebug() << "HbStyle::polishItem : -- Setting zvalue: " << prop.mZ;
       
  3794 #endif
       
  3795             item->setZValue(prop.mZ);
       
  3796         }
       
  3797     }
       
  3798 
       
  3799     QGraphicsWidget *gWidget = (item && item->isWidget())
       
  3800         ? static_cast<QGraphicsWidget*>(item)
       
  3801         : 0;
       
  3802     if ( gWidget ) {
       
  3803         if (prop.mFlags & HbCss::ExtractedLayoutDir) {
       
  3804 #ifdef HBSTYLE_DEBUG
       
  3805             qDebug() << "HbStyle::polishItem : -- Setting layout direction: " << prop.mLayoutDir;
       
  3806 #endif
       
  3807             if (prop.mLayoutDir == HbCss::LayoutDirection_LeftToRight) {
       
  3808                 gWidget->setLayoutDirection(Qt::LeftToRight);
       
  3809             } else if (prop.mLayoutDir == HbCss::LayoutDirection_RightToLeft) {
       
  3810                 gWidget->setLayoutDirection(Qt::RightToLeft);
       
  3811             } else {
       
  3812                 gWidget->unsetLayoutDirection();
       
  3813             }
       
  3814         }
       
  3815     }
       
  3816 
       
  3817     HbWidgetBase *hbWidget = qobject_cast<HbWidgetBase*>(gWidget);
       
  3818     if ( hbWidget ) {
       
  3819         HbWidgetBasePrivate* hbWidget_p = HbWidgetBasePrivate::d_ptr(hbWidget);
       
  3820         if ( prop.mFlags & HbCss::ExtractedFontSpec ) {
       
  3821             if ( !(prop.mFlags & HbCss::ExtractedFont) ) {
       
  3822 #ifdef HBSTYLE_DEBUG
       
  3823                 qDebug() << "HbStyle::polishItem : -- Setting fontspec: " << prop.mFontSpec.role() << prop.mFontSpec.textHeight();
       
  3824 #endif
       
  3825                 hbWidget->setFontSpec(prop.mFontSpec);
       
  3826             } else {
       
  3827 #ifdef HBSTYLE_DEBUG
       
  3828                 qDebug() << "HbStyle::polishItem : -- Setting fontspec with overrides: "
       
  3829                          << prop.mFontSpec.role() << prop.mFontSpec.textHeight() << prop.mFont;
       
  3830 #endif
       
  3831                 hbWidget->setFont(prop.mFontSpec.font().resolve(prop.mFont));
       
  3832             }
       
  3833         } else if ( prop.mFlags & HbCss::ExtractedFont ) {
       
  3834 #ifdef HBSTYLE_DEBUG
       
  3835             qDebug() << "HbStyle::polishItem : -- Setting explicit font: " << prop.mFont;
       
  3836 #endif
       
  3837             hbWidget->setFont(prop.mFont);
       
  3838         }
       
  3839 
       
  3840         HbIconItem* icon = qobject_cast<HbIconItem*>(hbWidget);
       
  3841         if (icon) {
       
  3842             if (prop.mFlags & HbCss::ExtractedAspectRatioMode
       
  3843                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_IconAspectRatioMode)) {
       
  3844 #ifdef HBSTYLE_DEBUG
       
  3845                 qDebug() << "HbStyle::polishItem : -- Setting aspect ratio mode: " << prop.mAspectRatioMode;
       
  3846 #endif
       
  3847                 icon->setAspectRatioMode(prop.mAspectRatioMode);
       
  3848                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_IconAspectRatioMode, false);
       
  3849             }
       
  3850         }
       
  3851 
       
  3852         HbTextItem* text = qobject_cast<HbTextItem*>(hbWidget);
       
  3853         if (text) {
       
  3854             if ( prop.mFlags & HbCss::ExtractedMinLines
       
  3855                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin)) {
       
  3856 #ifdef HBSTYLE_DEBUG
       
  3857                 qDebug() << "HbStyle::polishItem : -- Setting text min lines: " << prop.mMinLines;
       
  3858 #endif
       
  3859                 text->setMinimumLines( prop.mMinLines );
       
  3860                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin, false);
       
  3861             }
       
  3862             if ( prop.mFlags & HbCss::ExtractedMaxLines
       
  3863                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMax)) {
       
  3864 #ifdef HBSTYLE_DEBUG
       
  3865                 qDebug() << "HbStyle::polishItem : -- Setting text max lines: " << prop.mMaxLines;
       
  3866 #endif
       
  3867                 text->setMaximumLines( prop.mMaxLines );
       
  3868                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMax, false);
       
  3869             }
       
  3870             if ( prop.mFlags & HbCss::ExtractedTextAlign 
       
  3871                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign)) {
       
  3872 #ifdef HBSTYLE_DEBUG
       
  3873                 qDebug() << "HbStyle::polishItem : -- Setting text alignment: " << prop.mTextAlignment;
       
  3874 #endif
       
  3875                 text->setAlignment( prop.mTextAlignment );
       
  3876                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign, false);
       
  3877             }
       
  3878             if ( prop.mFlags & HbCss::ExtractedWrapMode 
       
  3879                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextWrapMode)) {
       
  3880 #ifdef HBSTYLE_DEBUG
       
  3881                 qDebug() << "HbStyle::polishItem : -- Setting wrap mode : " << prop.mTextWrapMode;
       
  3882 #endif
       
  3883                 text->setTextWrapping( prop.mTextWrapMode );
       
  3884                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextWrapMode, false);
       
  3885             }
       
  3886         }
       
  3887 
       
  3888         HbRichTextItem* richtext = qobject_cast<HbRichTextItem*>(hbWidget);
       
  3889         if (richtext) {
       
  3890             if ( prop.mFlags & HbCss::ExtractedTextAlign
       
  3891                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign)) {
       
  3892 #ifdef HBSTYLE_DEBUG
       
  3893                 qDebug() << "HbStyle::polishItem : -- Setting text alignment: " << prop.mTextAlignment;
       
  3894 #endif
       
  3895                 richtext->setAlignment( prop.mTextAlignment );
       
  3896                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextAlign, false);
       
  3897             }
       
  3898             if ( prop.mFlags & HbCss::ExtractedWrapMode 
       
  3899                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextWrapMode)) {
       
  3900 #ifdef HBSTYLE_DEBUG
       
  3901                 qDebug() << "HbStyle::polishItem : -- Setting wrap mode : " << prop.mTextWrapMode;
       
  3902 #endif
       
  3903                 richtext->setTextWrapping( prop.mTextWrapMode );
       
  3904                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextWrapMode, false);
       
  3905             }
       
  3906         }
       
  3907 
       
  3908         HbFrameItem *frame = qobject_cast<HbFrameItem*>(hbWidget);
       
  3909         if (frame && !frame->frameDrawer().d->testBorderApiProtectionFlag()) {
       
  3910             if (prop.mFlags & HbCss::ExtractedBorderWidths) {
       
  3911 #ifdef HBSTYLE_DEBUG
       
  3912                 qDebug() << "HbStyle::polishItem : -- Setting border widths (l,t,r,b):"
       
  3913                     << prop.mBorderWidths[HbCss::LeftEdge]
       
  3914                     << prop.mBorderWidths[HbCss::TopEdge]
       
  3915                     << prop.mBorderWidths[HbCss::RightEdge]
       
  3916                     << prop.mBorderWidths[HbCss::BottomEdge];
       
  3917 #endif
       
  3918                 frame->frameDrawer().setBorderWidths(
       
  3919                     prop.mBorderWidths[HbCss::LeftEdge],
       
  3920                     prop.mBorderWidths[HbCss::TopEdge],
       
  3921                     prop.mBorderWidths[HbCss::RightEdge],
       
  3922                     prop.mBorderWidths[HbCss::BottomEdge]);
       
  3923                 frame->frameDrawer().d->setBorderApiProtectionFlag(false);
       
  3924             }
       
  3925         }
       
  3926         if ( hbWidget->inherits( "HbLineEdit" ) ) {
       
  3927             if ( prop.mFlags & HbCss::ExtractedMinLines
       
  3928                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin)) {
       
  3929 #ifdef HBSTYLE_DEBUG
       
  3930                 qDebug() << "HbStyle::polishItem : -- Setting text min lines: " << prop.mMinLines;
       
  3931 #endif
       
  3932                 hbWidget->setProperty( "minRows", prop.mMinLines );
       
  3933                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin, false);
       
  3934             }
       
  3935             if ( prop.mFlags & HbCss::ExtractedMaxLines
       
  3936                 && !hbWidget_p->testApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMin)) {
       
  3937 #ifdef HBSTYLE_DEBUG
       
  3938                 qDebug() << "HbStyle::polishItem : -- Setting text max lines: " << prop.mMaxLines;
       
  3939 #endif
       
  3940                 hbWidget->setProperty( "maxRows", prop.mMaxLines );
       
  3941                 hbWidget_p->setApiProtectionFlag(HbWidgetBasePrivate::AC_TextLinesMax, false);
       
  3942             }
       
  3943         }
       
  3944     }
       
  3945 
  3993     if ( lItem ) {
  3946     if ( lItem ) {
  3994         if ( geomValues.mFlags & HbCss::ExtractedMinW ) {
  3947         if ( prop.mFlags & HbCss::ExtractedMinW ) {
  3995 #ifdef HBSTYLE_DEBUG
  3948 #ifdef HBSTYLE_DEBUG
  3996             qDebug() << "HbStyle::polishItem : -- Setting minimum width: " << geomValues.mMinW;
  3949             qDebug() << "HbStyle::polishItem : -- Setting minimum width: " << prop.mMinW;
  3997 #endif
  3950 #endif
  3998             lItem->setMinimumWidth( geomValues.mMinW );
  3951             lItem->setMinimumWidth( prop.mMinW );
  3999         }
  3952         }
  4000         if ( geomValues.mFlags & HbCss::ExtractedMinH ) {
  3953         if ( prop.mFlags & HbCss::ExtractedMinH ) {
  4001 #ifdef HBSTYLE_DEBUG
  3954 #ifdef HBSTYLE_DEBUG
  4002             qDebug() << "HbStyle::polishItem : -- Setting minimum height: " << geomValues.mMinH;
  3955             qDebug() << "HbStyle::polishItem : -- Setting minimum height: " << prop.mMinH;
  4003 #endif
  3956 #endif
  4004             lItem->setMinimumHeight( geomValues.mMinH );
  3957             lItem->setMinimumHeight( prop.mMinH );
  4005         }
  3958         }
  4006         if ( geomValues.mFlags & HbCss::ExtractedPrefW ) {
  3959         if ( prop.mFlags & HbCss::ExtractedPrefW ) {
  4007 #ifdef HBSTYLE_DEBUG
  3960 #ifdef HBSTYLE_DEBUG
  4008             qDebug() << "HbStyle::polishItem : -- Setting preferred width: " << geomValues.mPrefW;
  3961             qDebug() << "HbStyle::polishItem : -- Setting preferred width: " << prop.mPrefW;
  4009 #endif
  3962 #endif
  4010             lItem->setPreferredWidth( geomValues.mPrefW );
  3963             lItem->setPreferredWidth( prop.mPrefW );
  4011         }
  3964         }
  4012         if ( geomValues.mFlags & HbCss::ExtractedPrefH ) {
  3965         if ( prop.mFlags & HbCss::ExtractedPrefH ) {
  4013 #ifdef HBSTYLE_DEBUG
  3966 #ifdef HBSTYLE_DEBUG
  4014             qDebug() << "HbStyle::polishItem : -- Setting preferred height: " << geomValues.mPrefH;
  3967             qDebug() << "HbStyle::polishItem : -- Setting preferred height: " << prop.mPrefH;
  4015 #endif
  3968 #endif
  4016             lItem->setPreferredHeight( geomValues.mPrefH );
  3969             lItem->setPreferredHeight( prop.mPrefH );
  4017         }
  3970         }
  4018         if ( geomValues.mFlags & HbCss::ExtractedMaxW ) {
  3971         if ( prop.mFlags & HbCss::ExtractedMaxW ) {
  4019 #ifdef HBSTYLE_DEBUG
  3972 #ifdef HBSTYLE_DEBUG
  4020             qDebug() << "HbStyle::polishItem : -- Setting maximum width: " << geomValues.mMaxW;
  3973             qDebug() << "HbStyle::polishItem : -- Setting maximum width: " << prop.mMaxW;
  4021 #endif
  3974 #endif
  4022             lItem->setMaximumWidth( geomValues.mMaxW );
  3975             lItem->setMaximumWidth( prop.mMaxW );
  4023         }
  3976         }
  4024         if ( geomValues.mFlags & HbCss::ExtractedMaxH ) {
  3977         if ( prop.mFlags & HbCss::ExtractedMaxH ) {
  4025 #ifdef HBSTYLE_DEBUG
  3978 #ifdef HBSTYLE_DEBUG
  4026             qDebug() << "HbStyle::polishItem : -- Setting maximum height: " << geomValues.mMaxH;
  3979             qDebug() << "HbStyle::polishItem : -- Setting maximum height: " << prop.mMaxH;
  4027 #endif
  3980 #endif
  4028             lItem->setMaximumHeight( geomValues.mMaxH );
  3981             lItem->setMaximumHeight( prop.mMaxH );
  4029         }
  3982         }
  4030         QSizePolicy itemPol = lItem->sizePolicy();
  3983         QSizePolicy itemPol = lItem->sizePolicy();
  4031         if ( geomValues.mFlags & HbCss::ExtractedPolHor ) {
  3984         if ( prop.mFlags & HbCss::ExtractedPolHor ) {
  4032 #ifdef HBSTYLE_DEBUG
  3985 #ifdef HBSTYLE_DEBUG
  4033             qDebug() << "HbStyle::polishItem : -- Setting horizontal size policy: " << geomValues.mSizePolicy.horizontalPolicy();
  3986             qDebug() << "HbStyle::polishItem : -- Setting horizontal size policy: " << prop.mSizePolicy.horizontalPolicy();
  4034 #endif
  3987 #endif
  4035             itemPol.setHorizontalPolicy(geomValues.mSizePolicy.horizontalPolicy());
  3988             itemPol.setHorizontalPolicy(prop.mSizePolicy.horizontalPolicy());
  4036         }
  3989         }
  4037         if ( geomValues.mFlags & HbCss::ExtractedPolVer ) {
  3990         if ( prop.mFlags & HbCss::ExtractedPolVer ) {
  4038 #ifdef HBSTYLE_DEBUG
  3991 #ifdef HBSTYLE_DEBUG
  4039             qDebug() << "HbStyle::polishItem : -- Setting vertical size policy: " << geomValues.mSizePolicy.verticalPolicy();
  3992             qDebug() << "HbStyle::polishItem : -- Setting vertical size policy: " << prop.mSizePolicy.verticalPolicy();
  4040 #endif
  3993 #endif
  4041             itemPol.setVerticalPolicy(geomValues.mSizePolicy.verticalPolicy());
  3994             itemPol.setVerticalPolicy(prop.mSizePolicy.verticalPolicy());
  4042         }
  3995         }
  4043         lItem->setSizePolicy(itemPol);
  3996         lItem->setSizePolicy(itemPol);
  4044     }
  3997     }
  4045 
  3998 
  4046     if (layoutDefined) {
  3999     if (layoutDefined) {
  4047         HbMeshLayout *layout = static_cast<HbMeshLayout*>(widget->layout());
  4000         HbMeshLayout *layout = static_cast<HbMeshLayout*>(widget->layout());
  4048         if ( layout ) {
  4001         if ( layout ) {
  4049             if (posValues.mFlags & HbCss::ExtractedLeft) {
  4002             if (prop.mFlags & HbCss::ExtractedLeft) {
  4050 #ifdef HBSTYLE_DEBUG
  4003 #ifdef HBSTYLE_DEBUG
  4051                 qDebug() << "HbStyle::polishItem : -- Setting left override: " << posValues.mLeft;
  4004                 qDebug() << "HbStyle::polishItem : -- Setting left override: " << prop.mLeft;
  4052 #endif
  4005 #endif
  4053                 layout->overrideSpacing(name, Hb::LeftEdge, posValues.mLeft);
  4006                 layout->overrideSpacing(name, Hb::LeftEdge, prop.mLeft);
  4054             }
  4007             }
  4055             if (posValues.mFlags & HbCss::ExtractedRight) {
  4008             if (prop.mFlags & HbCss::ExtractedRight) {
  4056 #ifdef HBSTYLE_DEBUG
  4009 #ifdef HBSTYLE_DEBUG
  4057                 qDebug() << "HbStyle::polishItem : -- Setting right override: " << posValues.mRight;
  4010                 qDebug() << "HbStyle::polishItem : -- Setting right override: " << prop.mRight;
  4058 #endif
  4011 #endif
  4059                 layout->overrideSpacing(name, Hb::RightEdge, posValues.mRight);
  4012                 layout->overrideSpacing(name, Hb::RightEdge, prop.mRight);
  4060             }
  4013             }
  4061             if (posValues.mFlags & HbCss::ExtractedTop) {
  4014             if (prop.mFlags & HbCss::ExtractedTop) {
  4062 #ifdef HBSTYLE_DEBUG
  4015 #ifdef HBSTYLE_DEBUG
  4063                 qDebug() << "HbStyle::polishItem : -- Setting top override: " << posValues.mTop;
  4016                 qDebug() << "HbStyle::polishItem : -- Setting top override: " << prop.mTop;
  4064 #endif
  4017 #endif
  4065                 layout->overrideSpacing(name, Hb::TopEdge, posValues.mTop);
  4018                 layout->overrideSpacing(name, Hb::TopEdge, prop.mTop);
  4066             }
  4019             }
  4067             if (posValues.mFlags & HbCss::ExtractedBottom) {
  4020             if (prop.mFlags & HbCss::ExtractedBottom) {
  4068 #ifdef HBSTYLE_DEBUG
  4021 #ifdef HBSTYLE_DEBUG
  4069                 qDebug() << "HbStyle::polishItem : -- Setting bottom override: " << posValues.mBottom;
  4022                 qDebug() << "HbStyle::polishItem : -- Setting bottom override: " << prop.mBottom;
  4070 #endif
  4023 #endif
  4071                 layout->overrideSpacing(name, Hb::BottomEdge, posValues.mBottom);
  4024                 layout->overrideSpacing(name, Hb::BottomEdge, prop.mBottom);
  4072             }
  4025             }
  4073             if (posValues.mFlags & HbCss::ExtractedCenterH) {
  4026             if (prop.mFlags & HbCss::ExtractedCenterH) {
  4074 #ifdef HBSTYLE_DEBUG
  4027 #ifdef HBSTYLE_DEBUG
  4075                 qDebug() << "HbStyle::polishItem : -- Setting centerh override: " << posValues.mCenterH;
  4028                 qDebug() << "HbStyle::polishItem : -- Setting centerh override: " << prop.mCenterH;
  4076 #endif
  4029 #endif
  4077                 layout->overrideSpacing(name, Hb::CenterHEdge, posValues.mCenterH);
  4030                 layout->overrideSpacing(name, Hb::CenterHEdge, prop.mCenterH);
  4078             }
  4031             }
  4079             if (posValues.mFlags & HbCss::ExtractedCenterV) {
  4032             if (prop.mFlags & HbCss::ExtractedCenterV) {
  4080 #ifdef HBSTYLE_DEBUG
  4033 #ifdef HBSTYLE_DEBUG
  4081                 qDebug() << "HbStyle::polishItem : -- Setting centerv override: " << posValues.mCenterV;
  4034                 qDebug() << "HbStyle::polishItem : -- Setting centerv override: " << prop.mCenterV;
  4082 #endif
  4035 #endif
  4083                 layout->overrideSpacing(name, Hb::CenterVEdge, posValues.mCenterV);
  4036                 layout->overrideSpacing(name, Hb::CenterVEdge, prop.mCenterV);
  4084             }
  4037             }
  4085         }
  4038         }
  4086     }
  4039     }
  4087 }
  4040 }
  4088 
  4041 
  4149     if (!styleRules.count()) {
  4102     if (!styleRules.count()) {
  4150         return;
  4103         return;
  4151     }
  4104     }
  4152     const HbVector<HbCss::Declaration> decl = declarations(styleRules, "", widget, profile);
  4105     const HbVector<HbCss::Declaration> decl = declarations(styleRules, "", widget, profile);
  4153 #ifdef HBSTYLE_DEBUG
  4106 #ifdef HBSTYLE_DEBUG
  4154     qDebug() << "HbStyle::polish : Number of maching CSS declarations: " << decl.count();
  4107     qDebug() << "HbStyle::polish : Number of matching CSS declarations: " << decl.count();
  4155 #endif
  4108 #endif
  4156     d->ensureLayoutParameters(profile);
  4109     d->ensureLayoutParameters(profile);
  4157 
  4110 
  4158     HbCss::ValueExtractor extractor(decl, d->layoutParameters, profile);
  4111     HbCss::ValueExtractor extractor(decl, d->layoutParameters, profile);
  4159     QString layoutName;
  4112     QString layoutName;
  4160     QString sectionName;
  4113     QString sectionName;
  4161 
  4114 
  4162     if ( params.count() ) {
  4115     if ( params.count() ) {
  4163 #ifdef HBSTYLE_DEBUG
  4116 #ifdef HBSTYLE_DEBUG
  4164         qDebug() << "HbStyle::polish : Extracting parameters.";
  4117         qDebug() << "HbStyle::polish : Extracting custom properties.";
  4165 #endif
  4118 #endif
  4166         extractor.extractParameters( params.params(), params.values() );
  4119         extractor.extractCustomProperties( params.keys(), params.values() );
  4167     }
  4120     }
  4168 
  4121 
  4169     bool layoutDefined = extractor.extractLayout(&layoutName, &sectionName);
  4122     bool layoutDefined = extractor.extractLayout(layoutName, sectionName);
  4170 #ifdef HBSTYLE_DEBUG
  4123 #ifdef HBSTYLE_DEBUG
  4171     if (!layoutDefined) {
  4124     if (!layoutDefined) {
  4172         qDebug() << "HbStyle::polish : Couldn't find layout name for the widget.";
  4125         qDebug() << "HbStyle::polish : Couldn't find layout name for the widget.";
  4173     } else {
  4126     } else {
  4174         qDebug() << "HbStyle::polish : Layout name: " << layoutName;
  4127         qDebug() << "HbStyle::polish : Layout name: " << layoutName;
  4266     
  4219     
  4267     HbDeviceProfile profile;
  4220     HbDeviceProfile profile;
  4268     const HbVector<HbCss::Declaration> decl = declarations(styleRules, name, 0, profile);
  4221     const HbVector<HbCss::Declaration> decl = declarations(styleRules, name, 0, profile);
  4269 
  4222 
  4270 #ifdef HBSTYLE_DEBUG
  4223 #ifdef HBSTYLE_DEBUG
  4271    qDebug() << "HbStyle::updateThemedItems : -- Number of maching CSS declarations: " << decl.count();
  4224    qDebug() << "HbStyle::updateThemedItems : -- Number of matching CSS declarations: " << decl.count();
  4272 #endif
  4225 #endif
  4273    ensureColorParameters();
  4226    ensureColorParameters();
  4274    HbCss::ValueExtractor extractor(decl, colorParameters, profile);
  4227    HbCss::ValueExtractor extractor(decl, colorParameters, profile);
  4275    
  4228    
  4276     QColor col;
  4229     QColor col;
  4277     bool extracted = extractor.extractColor( &col );
  4230     bool extracted = extractor.extractColor( col );
  4278     if (!extracted || !col.isValid()) {
  4231     if (!extracted || !col.isValid()) {
  4279         // Setting non black or white default color to make it visisble in black or white theme
  4232         // Setting non black or white default color to make it visisble in black or white theme
  4280         col.setRgb(255,0,255);
  4233         col.setRgb(255,0,255);
  4281     }
  4234     }
  4282    //apply the themed color to text-item
  4235    //apply the themed color to text-item
  4442     Q_D( const HbStyle );
  4395     Q_D( const HbStyle );
  4443     d->ensureLayoutParameters(effectiveProfile);
  4396     d->ensureLayoutParameters(effectiveProfile);
  4444     HbCss::ValueExtractor valueExtractor(d->layoutParameters, true, effectiveProfile);
  4397     HbCss::ValueExtractor valueExtractor(d->layoutParameters, true, effectiveProfile);
  4445     // todo: parsing variable/expression is done here so that there is no need to change API
  4398     // todo: parsing variable/expression is done here so that there is no need to change API
  4446     // also parameters method not changed (this change is done for docml/widgetml parsing)
  4399     // also parameters method not changed (this change is done for docml/widgetml parsing)
  4447     if (param.startsWith("var(") && param.endsWith(")")) {
  4400     if (param.startsWith(QLatin1String("var(")) && param.endsWith(QLatin1String(")"))) {
  4448         return valueExtractor.extractValue(param.mid(4,param.length()-5), value);
  4401         return valueExtractor.extractVariableValue(param.mid(4,param.length()-5), value);
  4449     } else if (param.startsWith("-var(") && param.endsWith(")")) {
  4402     } else if (param.startsWith(QLatin1String("-var(")) && param.endsWith(QLatin1String(")"))) {
  4450         bool retVal = valueExtractor.extractValue(param.mid(5,param.length()-6), value);
  4403         bool retVal = valueExtractor.extractVariableValue(param.mid(5,param.length()-6), value);
  4451         value = -value;
  4404         value = -value;
  4452         return retVal;
  4405         return retVal;
  4453     } else if (param.startsWith("expr(") && param.endsWith(")")) {
  4406     } else if (param.startsWith(QLatin1String("expr(")) && param.endsWith(QLatin1String(")"))) {
  4454         QString expressionString = param.mid(5,param.length()-6);
  4407         QString expressionString = param.mid(5,param.length()-6);
  4455         return valueExtractor.extractExpressionValue(expressionString, value);
  4408         return valueExtractor.extractExpressionValue(expressionString, value);
  4456     } else if (param.startsWith("-expr(") && param.endsWith(")")) {
  4409     } else if (param.startsWith(QLatin1String("-expr(")) && param.endsWith(QLatin1String(")"))) {
  4457         QString expressionString = param.mid(6,param.length()-7);
  4410         QString expressionString = param.mid(6,param.length()-7);
  4458         bool retVal = valueExtractor.extractExpressionValue(expressionString, value);
  4411         bool retVal = valueExtractor.extractExpressionValue(expressionString, value);
  4459         value = -value;
  4412         value = -value;
  4460         return retVal;
  4413         return retVal;
  4461     }
  4414     }
  4462 
  4415 
  4463     return valueExtractor.extractValue(param, value);    
  4416     return valueExtractor.extractVariableValue(param, value);    
  4464 }
  4417 }
  4465 
  4418 
  4466 /*!
  4419 /*!
  4467     Returns copy of all global style parameters. Both names and values 
  4420     Returns copy of all global style parameters. Both names and values 
  4468     of the parameters are returned. The values are returned in pixels.
  4421     of the parameters are returned. The values are returned in pixels.
  4487     d->ensureLayoutParameters(effectiveProfile);
  4440     d->ensureLayoutParameters(effectiveProfile);
  4488     HbCss::ValueExtractor valueExtractor(d->layoutParameters, true, effectiveProfile);
  4441     HbCss::ValueExtractor valueExtractor(d->layoutParameters, true, effectiveProfile);
  4489     qreal value = 0;
  4442     qreal value = 0;
  4490     QHash<QString, HbCss::Declaration>::const_iterator i = d->layoutParameters.constBegin();
  4443     QHash<QString, HbCss::Declaration>::const_iterator i = d->layoutParameters.constBegin();
  4491     while (i != d->layoutParameters.constEnd()) {
  4444     while (i != d->layoutParameters.constEnd()) {
  4492         if (valueExtractor.extractValue(i.key(), value)) {
  4445         if (valueExtractor.extractVariableValue(i.key(), value)) {
  4493             params.addParameter(i.key(), value);
  4446             params.addParameter(i.key(), value);
  4494         }
  4447         }
  4495         ++i;
  4448         ++i;
  4496     }
  4449     }
  4497 }
  4450 }
  4536     if (!styleRules.count()) {
  4489     if (!styleRules.count()) {
  4537         return;
  4490         return;
  4538     }
  4491     }
  4539     const HbVector<HbCss::Declaration> decl = declarations(styleRules, "", widget, profile);
  4492     const HbVector<HbCss::Declaration> decl = declarations(styleRules, "", widget, profile);
  4540 #ifdef HBSTYLE_DEBUG
  4493 #ifdef HBSTYLE_DEBUG
  4541     qDebug() << "HbStyle::widgetParameters : Number of maching CSS declarations: " << decl.count();
  4494     qDebug() << "HbStyle::widgetParameters : Number of matching CSS declarations: " << decl.count();
  4542 #endif
  4495 #endif
  4543     d->ensureLayoutParameters(profile);
  4496     d->ensureLayoutParameters(profile);
  4544 
  4497 
  4545     HbCss::ValueExtractor extractor(decl, d->layoutParameters, profile);
  4498     HbCss::ValueExtractor extractor(decl, d->layoutParameters, profile);
  4546     extractor.extractParameters( params.params(), params.values() );
  4499     extractor.extractCustomProperties( params.keys(), params.values() );
  4547 }
  4500 }
  4548 
  4501 
  4549 
  4502 
  4550 /*!
  4503 /*!
  4551 \internal
  4504 \internal
  4675     bool firstParse(layoutParameters.isEmpty());
  4628     bool firstParse(layoutParameters.isEmpty());
  4676     bool addSpecialParams(firstParse);
  4629     bool addSpecialParams(firstParse);
  4677     if (firstParse) {
  4630     if (firstParse) {
  4678         HbCss::Parser parser;
  4631         HbCss::Parser parser;
  4679         parser.init(GLOBAL_PARAMETERS_LOCATION, true);
  4632         parser.init(GLOBAL_PARAMETERS_LOCATION, true);
  4680         HbCss::StyleSheet *styleSheet = new(HbCss::StyleSheet);
  4633         HbCss::StyleSheet *styleSheet = HbMemoryUtils::create<HbCss::StyleSheet>(HbMemoryManager::HeapMemory);
  4681         parser.parse(styleSheet);
  4634         parser.parse(styleSheet);
  4682 
  4635 
  4683         HbStyleSelector selector;
  4636         HbStyleSelector selector;
  4684         selector.styleSheets.append(styleSheet);
  4637         selector.styleSheets.append(styleSheet);
  4685         selector.variableRuleSets(&layoutParameters);
  4638         selector.variableRuleSets(&layoutParameters);
  4692         QSizeF pSize = profile.logicalSize();
  4645         QSizeF pSize = profile.logicalSize();
  4693 
  4646 
  4694         {
  4647         {
  4695             HbCss::Declaration decl;
  4648             HbCss::Declaration decl;
  4696             decl.property = "hb-param-screen-width";
  4649             decl.property = "hb-param-screen-width";
  4697             decl.propertyId = HbCss::UnknownProperty;
  4650             decl.propertyId = HbCss::Property_Unknown;
  4698             HbCss::Value val;
  4651             HbCss::Value val;
  4699             val.type = HbCss::Value::Number;
  4652             val.type = HbCss::Value::Number;
  4700             val.variant = HbVariant((double)pSize.width(),HbMemoryManager::HeapMemory);
  4653             val.variant = HbVariant((double)pSize.width(),HbMemoryManager::HeapMemory);
  4701             decl.values.append(val);
  4654             decl.values.append(val);
  4702             layoutParameters.insert(decl.property, decl);
  4655             layoutParameters.insert(decl.property, decl);
  4703         }
  4656         }
  4704         {
  4657         {
  4705             HbCss::Declaration decl;
  4658             HbCss::Declaration decl;
  4706             decl.property = "hb-param-screen-height";
  4659             decl.property = "hb-param-screen-height";
  4707             decl.propertyId = HbCss::UnknownProperty;
  4660             decl.propertyId = HbCss::Property_Unknown;
  4708             HbCss::Value val;
  4661             HbCss::Value val;
  4709             val.type = HbCss::Value::Number;
  4662             val.type = HbCss::Value::Number;
  4710             val.variant = HbVariant((double)pSize.height(),HbMemoryManager::HeapMemory);
  4663             val.variant = HbVariant((double)pSize.height(),HbMemoryManager::HeapMemory);
  4711             decl.values.append(val);
  4664             decl.values.append(val);
  4712             layoutParameters.insert(decl.property, decl);
  4665             layoutParameters.insert(decl.property, decl);
  4713         }
  4666         }
  4714         {
  4667         {
  4715             HbCss::Declaration decl;
  4668             HbCss::Declaration decl;
  4716             decl.property = "hb-param-screen-short-edge";
  4669             decl.property = "hb-param-screen-short-edge";
  4717             decl.propertyId = HbCss::UnknownProperty;
  4670             decl.propertyId = HbCss::Property_Unknown;
  4718             HbCss::Value val;
  4671             HbCss::Value val;
  4719             val.type = HbCss::Value::Number;
  4672             val.type = HbCss::Value::Number;
  4720             val.variant = HbVariant((double)qMin(pSize.height(),pSize.width()),HbMemoryManager::HeapMemory);
  4673             val.variant = HbVariant((double)qMin(pSize.height(),pSize.width()),HbMemoryManager::HeapMemory);
  4721             decl.values.append(val);
  4674             decl.values.append(val);
  4722             layoutParameters.insert(decl.property, decl);
  4675             layoutParameters.insert(decl.property, decl);
  4723         }
  4676         }
  4724         {
  4677         {
  4725             HbCss::Declaration decl;
  4678             HbCss::Declaration decl;
  4726             decl.property = "hb-param-screen-long-edge";
  4679             decl.property = "hb-param-screen-long-edge";
  4727             decl.propertyId = HbCss::UnknownProperty;
  4680             decl.propertyId = HbCss::Property_Unknown;
  4728             HbCss::Value val;
  4681             HbCss::Value val;
  4729             val.type = HbCss::Value::Number;
  4682             val.type = HbCss::Value::Number;
  4730             val.variant = HbVariant((double)qMax(pSize.height(),pSize.width()),HbMemoryManager::HeapMemory);
  4683             val.variant = HbVariant((double)qMax(pSize.height(),pSize.width()),HbMemoryManager::HeapMemory);
  4731             decl.values.append(val);
  4684             decl.values.append(val);
  4732             layoutParameters.insert(decl.property, decl);
  4685             layoutParameters.insert(decl.property, decl);