src/hbcore/image/hbframedrawer.cpp
changeset 5 627c4a0fd0e7
parent 2 06ff229162e9
child 6 c3690ec91ef8
equal deleted inserted replaced
3:11d3954df52a 5:627c4a0fd0e7
    23 **
    23 **
    24 ****************************************************************************/
    24 ****************************************************************************/
    25 #include "hbframedrawer.h"
    25 #include "hbframedrawer.h"
    26 #include "hbframedrawer_p.h"
    26 #include "hbframedrawer_p.h"
    27 #include "hbimagetraces_p.h"
    27 #include "hbimagetraces_p.h"
       
    28 #include "hbmaskableiconimpl_p.h"
    28 
    29 
    29 #include <hbinstance.h>
    30 #include <hbinstance.h>
    30 #include <hbiconimpl_p.h>
    31 #include <hbiconimpl_p.h>
    31 #include <hbiconloader_p.h>
    32 #include <hbiconloader_p.h>
    32 #include "hbmaskableiconimpl_p.h"
    33 
    33 
    34 
    34 #include <QPainter>
    35 #include <QPainter>
    35 #include <QIcon>
    36 #include <QIcon>
    36 #include <QPixmap>
    37 #include <QPixmap>
    37 #include <QDebug>
    38 #include <QDebug>
    38 #include <QBitmap>
    39 #include <QBitmap>
    39 
    40 
    40 /*!
    41 /*!
    41 	@stable
    42     @stable
    42     @hbcore
    43     @hbcore
    43     \class HbFrameDrawer
    44     \class HbFrameDrawer
    44     \brief HbFrameDrawer draws frames graphics.
    45     \brief HbFrameDrawer draws frames graphics.
    45 
    46 
    46     This class is not intended to be derived from.
    47     This class is not intended to be derived from.
    47 
    48 
    48     Frame graphics mean graphics that consist of either 3 or 9 parts that are positioned
    49     Frame graphics mean graphics that consist of either 3 or 9 parts that are positioned
    49     and scaled followingly.
    50     and scaled followingly.
    50     
    51 
    51     A 9-piece frame consists of a 3x3 grid, where the corner parts have a fixed size and
    52     A 9-piece frame consists of a 3x3 grid, where the corner parts have a fixed size and
    52     the other parts are scaled.
    53     the other parts are scaled.
    53     
    54 
    54     A 3-piece frame consists of 3 parts tiled either horizontally of vertically. The side
    55     A 3-piece frame consists of 3 parts tiled either horizontally or vertically. The side
    55     parts preserve their aspect ratio and the center part is scaled to fill the remaining space.
    56     parts preserve their aspect ratio and the center part is scaled to fill the remaining space.
    56 
    57 
    57     For convenience, frame drawer can also draw the frame with a single graphic.
    58     For convenience, frame drawer can also draw the frame with a single graphic.
    58 
    59 
    59     The frame drawer implements the logic of scaling and positioning the frame parts and
    60     The frame drawer implements the logic of scaling and positioning the frame parts and
    60     takes care that there are no visible gaps between the frame parts when the whole frame
    61     takes care that there are no visible gaps between the frame parts when the whole frame
    61     is painted to the display even if the frame bounding rectangle uses floating point accuracy.
    62     is painted to the display even if the frame bounding rectangle uses floating point accuracy.
    62 
    63 
    63     Filenames for 9-piece frame graphics are defined according to the following.
    64     Filenames for 9-piece frame graphics are defined according to the following convention.
    64 
    65 
    65     - top left        <name>_tl.<ext>
    66     - top left        <name>_tl.<ext>
    66     - top             <name>_t.<ext>
    67     - top             <name>_t.<ext>
    67     - top right       <name>_tr.<ext>
    68     - top right       <name>_tr.<ext>
    68     - left            <name>_l.<ext>
    69     - left            <name>_l.<ext>
    70     - right           <name>_r.<ext>
    71     - right           <name>_r.<ext>
    71     - bottom left     <name>_bl.<ext>
    72     - bottom left     <name>_bl.<ext>
    72     - bottom          <name>_b.<ext>
    73     - bottom          <name>_b.<ext>
    73     - bottom right    <name>_br.<ext>
    74     - bottom right    <name>_br.<ext>
    74 
    75 
    75     Filenames for 3-piece horizontal frame graphics are defined according to the following.
    76     Filenames for 3-piece horizontal frame graphics are defined according to the following convention.
    76 
    77 
    77     - left            <name>_l.<ext>
    78     - left            <name>_l.<ext>
    78     - center          <name>_c.<ext>
    79     - center          <name>_c.<ext>
    79     - right           <name>_r.<ext>
    80     - right           <name>_r.<ext>
    80 
    81 
    81     Filenames for 3-piece vertical frame graphics are defined according to the following.
    82     Filenames for 3-piece vertical frame graphics are defined according to the following convention.
    82 
    83 
    83     - top             <name>_t.<ext>
    84     - top             <name>_t.<ext>
    84     - center          <name>_c.<ext>
    85     - center          <name>_c.<ext>
    85     - bottom          <name>_b.<ext>
    86     - bottom          <name>_b.<ext>
    86 
    87 
    91     frame graphics piece with filename <name>.<ext> to draw the frame.
    92     frame graphics piece with filename <name>.<ext> to draw the frame.
    92     If even that does not exist, nothing is drawn.
    93     If even that does not exist, nothing is drawn.
    93 
    94 
    94     See class HbIcon for information of supported icon formats and file locations.
    95     See class HbIcon for information of supported icon formats and file locations.
    95 
    96 
    96     The frame drawer stores the whole generated frame graphics in a pixmap for
    97     The frame drawer stores the entire generated frame graphics in a pixmap for
    97     improving the speed of the paint operations. Therefore, the frame drawer instance should not
    98     improving the speed of the paint operations. Therefore, the frame drawer instance should not
    98     be re-created each time the frame needs to be rendered.
    99     be re-created each time the frame needs to be rendered.
    99 
   100 
   100     Example of how to create a frame drawer and use it.
   101     Example of how to create a frame drawer and use it.
   101 
   102 
   112   \b Undefined The frame type is undefined. It must be defined before being able to draw the frame.
   113   \b Undefined The frame type is undefined. It must be defined before being able to draw the frame.
   113 
   114 
   114   \b OnePiece The frame consist of a single graphic piece, which is scaled to the frame's bounding rectangle.
   115   \b OnePiece The frame consist of a single graphic piece, which is scaled to the frame's bounding rectangle.
   115 
   116 
   116   \b ThreePiecesHorizontal The frame consists of three graphic pieces that are tiled horizontally.
   117   \b ThreePiecesHorizontal The frame consists of three graphic pieces that are tiled horizontally.
   117             As default, the side parts preserve their aspect ratio and the center part is scaled to fill the remaining space.
   118             By default, the side parts preserve their aspect ratio and the center part is scaled to fill the remaining space.
   118             Filenames for 3-piece horizontal frame graphics are defined according to the following.
   119             Filenames for 3-piece horizontal frame graphics are defined according to the following.
   119 
   120 
   120             - left            <name>_l.<ext>
   121             - left            <name>_l.<ext>
   121             - center          <name>_c.<ext>
   122             - center          <name>_c.<ext>
   122             - right           <name>_r.<ext>
   123             - right           <name>_r.<ext>
   123 
   124 
   124   \b ThreePiecesVertical The frame consists of three graphic pieces that are tiled vertically.
   125   \b ThreePiecesVertical The frame consists of three graphic pieces that are tiled vertically.
   125             As default, the side parts preserve their aspect ratio and the center part is scaled to fill the remaining space.
   126             By default, the side parts preserve their aspect ratio and the center part is scaled to fill the remaining space.
   126             Filenames for 3-piece vertical frame graphics are defined according to the following.
   127             Filenames for 3-piece vertical frame graphics are defined according to the following.
   127 
   128 
   128             - top             <name>_t.<ext>
   129             - top             <name>_t.<ext>
   129             - center          <name>_c.<ext>
   130             - center          <name>_c.<ext>
   130             - bottom          <name>_b.<ext>
   131             - bottom          <name>_b.<ext>
   131 
   132 
   132   \b NinePieces The frame consists of a 3x3 grid of graphic pieces, where as default the corner
   133   \b NinePieces The frame consists of a 3x3 grid of graphic pieces, where by default the corner
   133             parts have a fixed size and the other parts are scaled.
   134             parts have a fixed size and the other parts are scaled.
   134             Filenames for 9-piece frame graphics are defined according to the following.
   135             Filenames for 9-piece frame graphics are defined according to the following.
   135 
   136 
   136             - top left        <name>_tl.<ext>
   137             - top left        <name>_tl.<ext>
   137             - top             <name>_t.<ext>
   138             - top             <name>_t.<ext>
   166     color(),
   167     color(),
   167     icon(0),
   168     icon(0),
   168     maskChanged(false),
   169     maskChanged(false),
   169     clipPath(QPainterPath())
   170     clipPath(QPainterPath())
   170 {
   171 {
   171     borderWidths[0]=0.0;
   172     borderWidths[0] = 0.0;
   172     borderWidths[1]=0.0;
   173     borderWidths[1] = 0.0;
   173     borderWidths[2]=0.0;
   174     borderWidths[2] = 0.0;
   174     borderWidths[3]=0.0;
   175     borderWidths[3] = 0.0;
   175     //Register the HbFrameDrawerPrivate Instance to HbIconLoader
   176     //Register the HbFrameDrawerPrivate Instance to HbIconLoader
   176     HbIconLoader::global()->storeFrameDrawerInfo(this);
   177     HbIconLoader::global()->storeFrameDrawerInfo(this);
   177 }
   178 }
   178 
   179 
   179 /*!
   180 /*!
   185     type(type),
   186     type(type),
   186     mask(QPixmap()),
   187     mask(QPixmap()),
   187     frameParts(0),
   188     frameParts(0),
   188     mirroring(HbIcon::Default),
   189     mirroring(HbIcon::Default),
   189     defaultMirroring(Unknown),
   190     defaultMirroring(Unknown),
   190     flags( 0 ),
   191     flags(0),
   191     layoutDirection(Qt::LeftToRight),
   192     layoutDirection(Qt::LeftToRight),
   192     graphicsItem(0),
   193     graphicsItem(0),
   193     color(),
   194     color(),
   194     icon(0),
   195     icon(0),
   195     maskChanged(false),
   196     maskChanged(false),
   196     clipPath(QPainterPath())
   197     clipPath(QPainterPath())
   197 {
   198 {
   198     borderWidths[0]=0.0;
   199     borderWidths[0] = 0.0;
   199     borderWidths[1]=0.0;
   200     borderWidths[1] = 0.0;
   200     borderWidths[2]=0.0;
   201     borderWidths[2] = 0.0;
   201     borderWidths[3]=0.0;
   202     borderWidths[3] = 0.0;
   202 
   203 
   203     // Remove possible file extension
   204     // Remove possible file extension
   204     int index = this->frameGraphicsName.lastIndexOf(QChar('.'));
   205     int index = this->frameGraphicsName.lastIndexOf(QChar('.'));
   205     if (index>0) {
   206     if (index > 0) {
   206         this->frameGraphicsName.resize(index);
   207         this->frameGraphicsName.resize(index);
   207     }
   208     }
   208     //Register the HbFrameDrawerPrivate Instance to HbIconLoader
   209     //Register the HbFrameDrawerPrivate Instance to HbIconLoader
   209     HbIconLoader::global()->storeFrameDrawerInfo(this);
   210     HbIconLoader::global()->storeFrameDrawerInfo(this);
   210 }
   211 }
   219     rect(other.rect),
   220     rect(other.rect),
   220     mask(QPixmap()),
   221     mask(QPixmap()),
   221     frameParts(other.frameParts),
   222     frameParts(other.frameParts),
   222     mirroring(other.mirroring),
   223     mirroring(other.mirroring),
   223     defaultMirroring(other.defaultMirroring),
   224     defaultMirroring(other.defaultMirroring),
   224     flags( other.flags ),
   225     flags(other.flags),
   225     layoutDirection( other.layoutDirection ),
   226     layoutDirection(other.layoutDirection),
   226     graphicsItem( other.graphicsItem ),
   227     graphicsItem(other.graphicsItem),
   227     color(other.color),
   228     color(other.color),
   228     icon(0),
   229     icon(0),
   229     maskChanged(false),
   230     maskChanged(false),
   230     clipPath(QPainterPath())
   231     clipPath(QPainterPath())
   231 {
   232 {
   232     borderWidths[0]=other.borderWidths[0];
   233     borderWidths[0] = other.borderWidths[0];
   233     borderWidths[1]=other.borderWidths[1];
   234     borderWidths[1] = other.borderWidths[1];
   234     borderWidths[2]=other.borderWidths[2];
   235     borderWidths[2] = other.borderWidths[2];
   235     borderWidths[3]=other.borderWidths[3];
   236     borderWidths[3] = other.borderWidths[3];
   236     //Register the HbFrameDrawerPrivate Instance to HbIconLoader
   237     //Register the HbFrameDrawerPrivate Instance to HbIconLoader
   237     HbIconLoader::global()->storeFrameDrawerInfo(this);
   238     HbIconLoader::global()->storeFrameDrawerInfo(this);
   238 }
   239 }
   239 
   240 
   240 /*!
   241 /*!
   253 void HbFrameDrawerPrivate::prepareFrameIcon()
   254 void HbFrameDrawerPrivate::prepareFrameIcon()
   254 {
   255 {
   255     if (!frameParts) {
   256     if (!frameParts) {
   256         checkFrameParts();
   257         checkFrameParts();
   257     }
   258     }
   258     if ((!icon ) && (!fallbackMaskableIconList.count()) ) {
   259     if ((!icon) && (!fallbackMaskableIconList.count())) {
   259         createFrameIcon();
   260         createFrameIcon();
   260     }
   261     }
   261 }
   262 }
   262 
   263 
   263 /*!
   264 /*!
   265 *
   266 *
   266 * \sa HbFrameDrawerPrivate::setBorderApiProtectionFlag()
   267 * \sa HbFrameDrawerPrivate::setBorderApiProtectionFlag()
   267 */
   268 */
   268 bool HbFrameDrawerPrivate::testBorderApiProtectionFlag() const
   269 bool HbFrameDrawerPrivate::testBorderApiProtectionFlag() const
   269 {
   270 {
   270 	return flags & HbFrameDrawerPrivate::BorderWidthSetByApi;
   271     return flags & HbFrameDrawerPrivate::BorderWidthSetByApi;
   271 }
   272 }
   272 
   273 
   273 /*!
   274 /*!
   274 * Clears the flag denoting that the border widths have been set by API.
   275 * Clears the flag denoting that the border widths have been set by API.
   275 * This will cause control of border widths to return to the CSS system.
   276 * This will cause control of border widths to return to the CSS system.
   276 *
   277 *
   277 * \sa HbFrameDrawerPrivate::testBorderApiProtectionFlag()
   278 * \sa HbFrameDrawerPrivate::testBorderApiProtectionFlag()
   278 */
   279 */
   279 void HbFrameDrawerPrivate::setBorderApiProtectionFlag(bool on)
   280 void HbFrameDrawerPrivate::setBorderApiProtectionFlag(bool on)
   280 {
   281 {
   281 	if(on){
   282     if (on) {
   282 		flags |= HbFrameDrawerPrivate::BorderWidthSetByApi;
   283         flags |= HbFrameDrawerPrivate::BorderWidthSetByApi;
   283 	}else{
   284     } else {
   284 		flags &= ~HbFrameDrawerPrivate::BorderWidthSetByApi;
   285         flags &= ~HbFrameDrawerPrivate::BorderWidthSetByApi;
   285 	}
   286     }
   286 }
   287 }
   287 
   288 
   288 /*!
   289 /*!
   289 * Checks whether all the frame parts are available for the given frame type.
   290 * Checks whether all the frame parts are available for the given frame type.
   290 * Fallback is 1-part frame rendering.
   291 * Fallback is 1-part frame rendering.
   312 QStringList HbFrameDrawerPrivate::fileNameSuffixList() const
   313 QStringList HbFrameDrawerPrivate::fileNameSuffixList() const
   313 {
   314 {
   314     // If the suffix list has been set explicitly, return that if it contains enough suffixes.
   315     // If the suffix list has been set explicitly, return that if it contains enough suffixes.
   315     if (!suffixList.isEmpty()) {
   316     if (!suffixList.isEmpty()) {
   316         switch (type) {
   317         switch (type) {
   317             case HbFrameDrawer::ThreePiecesHorizontal: // fall through
   318         case HbFrameDrawer::ThreePiecesHorizontal: // fall through
   318             case HbFrameDrawer::ThreePiecesVertical:
   319         case HbFrameDrawer::ThreePiecesVertical:
   319                 if (suffixList.count() >= 3) {
   320             if (suffixList.count() >= 3) {
   320                     return suffixList;
       
   321                 }
       
   322                 break;
       
   323 
       
   324             case HbFrameDrawer::NinePieces:
       
   325                 if (suffixList.count() >= 9) {
       
   326                     return suffixList;
       
   327                 }
       
   328                 break;
       
   329             
       
   330             default:
       
   331                 return suffixList;
   321                 return suffixList;
   332         }
   322             }
   333     } 
   323             break;
       
   324 
       
   325         case HbFrameDrawer::NinePieces:
       
   326             if (suffixList.count() >= 9) {
       
   327                 return suffixList;
       
   328             }
       
   329             break;
       
   330 
       
   331         default:
       
   332             return suffixList;
       
   333         }
       
   334     }
   334 
   335 
   335     // Otherwise, return default suffix list.
   336     // Otherwise, return default suffix list.
   336     QStringList list;
   337     QStringList list;
   337 
   338 
   338     switch (type) {
   339     switch (type) {
   339         case HbFrameDrawer::ThreePiecesHorizontal:
   340     case HbFrameDrawer::ThreePiecesHorizontal:
   340             list << "_l" << "_c" << "_r";
   341         list << "_l" << "_c" << "_r";
   341             break;
   342         break;
   342         case HbFrameDrawer::ThreePiecesVertical:
   343     case HbFrameDrawer::ThreePiecesVertical:
   343             list << "_t" << "_c" << "_b";
   344         list << "_t" << "_c" << "_b";
   344             break;
   345         break;
   345         case HbFrameDrawer::NinePieces:
   346     case HbFrameDrawer::NinePieces:
   346             list << "_tl" << "_t" << "_tr" << "_l" << "_c" << "_r" << "_bl" << "_b" << "_br";
   347         list << "_tl" << "_t" << "_tr" << "_l" << "_c" << "_r" << "_bl" << "_b" << "_br";
   347             break;
   348         break;
   348         default:
   349     default:
   349             break;
   350         break;
   350     }
   351     }
   351 
   352 
   352     return list;
   353     return list;
   353 }
   354 }
   354 
   355 
   355 /*!
   356 /*!
   356 * Creates a consolidated HbIconImpl (Icon) with the available piece information 
   357 * Creates a consolidated HbIconImpl (Icon) with the available piece information
   357 * If failed to create the same, then creates HbIconImpls for the pieces.
   358 * If failed to create the same, then creates HbIconImpls for the pieces.
   358 * \internal
   359 * \internal
   359 */
   360 */
   360 void HbFrameDrawerPrivate::createFrameIcon()
   361 void HbFrameDrawerPrivate::createFrameIcon()
   361 {
   362 {
   365     data.multiPartIconId = multiPartIconId();
   366     data.multiPartIconId = multiPartIconId();
   366     multiPartSizeData = data;
   367     multiPartSizeData = data;
   367 
   368 
   368     // Create the frame icon and add it in the icon cache
   369     // Create the frame icon and add it in the icon cache
   369     HbIconLoader *loader = HbIconLoader::global();
   370     HbIconLoader *loader = HbIconLoader::global();
   370     
   371 
   371     //If it's one-piece frame-item, it's loaded using HbIconLoader::loadIcon()
   372     //If it's one-piece frame-item, it's loaded using HbIconLoader::loadIcon()
   372     if (frameParts == 1) {
   373     if (frameParts == 1) {
   373         HbIconImpl * iconImpl =  loader->loadIcon(frameGraphicsName, HbIconLoader::AnyType,
   374         HbIconImpl *iconImpl =  loader->loadIcon(frameGraphicsName, HbIconLoader::AnyType,
   374                                  HbIconLoader::AnyPurpose,
   375                                 HbIconLoader::AnyPurpose,
   375                                  frameIconSize,
   376                                 frameIconSize,
   376                                  Qt::IgnoreAspectRatio,
   377                                 Qt::IgnoreAspectRatio,
   377                                  QIcon::Normal,
   378                                 QIcon::Normal,
   378                                  iconLoaderOptions());
   379                                 iconLoaderOptions());
   379         if (iconImpl) {
   380         if (iconImpl) {
   380             icon = new HbMaskableIconImpl(iconImpl);
   381             icon = new HbMaskableIconImpl(iconImpl);
   381         }
   382         }
   382 
   383 
   383     } else {
   384     } else {
   385         QStringList list = fileNameSuffixList();
   386         QStringList list = fileNameSuffixList();
   386         int nameListCount = list.count();
   387         int nameListCount = list.count();
   387         for (int i = 0; i < nameListCount; i++) {
   388         for (int i = 0; i < nameListCount; i++) {
   388             multiPieceFileNames.append(frameGraphicsName + list[i]);
   389             multiPieceFileNames.append(frameGraphicsName + list[i]);
   389             if (data.pixmapSizes[i].isEmpty()) {
   390             if (data.pixmapSizes[i].isEmpty()) {
   390                 data.pixmapSizes[i] = QSize(0,0);
   391                 data.pixmapSizes[i] = QSize(0, 0);
   391             }
   392             }
   392         }
   393         }
   393 
   394 
   394         QVector<HbIconImpl *> listOfIcons;
   395         QVector<HbIconImpl *> listOfIcons;
   395         
   396 
   396         //For multi-piece frame-items, HbIocnLoader::loadMultipieceIcon is used
   397         //For multi-piece frame-items, HbIocnLoader::loadMultipieceIcon is used
   397         //This function returns the consolidate (stitched) icon created on the themeserver.
   398         //This function returns the consolidate (stitched) icon created on the themeserver.
   398         //If the consolidated icon-creation on themeserver fails, then server returns a list
   399         //If the consolidated icon-creation on themeserver fails, then server returns a list
   399         //of individual frame-items.
   400         //of individual frame-items.
   400         HbIconImpl * iconImpl = loader->loadMultiPieceIcon(multiPieceFileNames, data, frameIconSize,
   401         HbIconImpl *iconImpl = loader->loadMultiPieceIcon(multiPieceFileNames, data, frameIconSize,
   401                                           Qt::IgnoreAspectRatio, QIcon::Normal, iconLoaderOptions(),
   402                                Qt::IgnoreAspectRatio, QIcon::Normal, iconLoaderOptions(),
   402                                           listOfIcons, color);
   403                                listOfIcons, color);
   403 
   404 
   404         if (iconImpl) {
   405         if (iconImpl) {
   405             icon = new HbMaskableIconImpl(iconImpl);
   406             icon = new HbMaskableIconImpl(iconImpl);
   406         } else {
   407         } else {
   407             int implCount = listOfIcons.count();
   408             int implCount = listOfIcons.count();
   408             for (int i = 0; i < implCount; i++) {
   409             for (int i = 0; i < implCount; i++) {
   409                 fallbackMaskableIconList.append(new HbMaskableIconImpl(listOfIcons[i]));
   410                 fallbackMaskableIconList.append(new HbMaskableIconImpl(listOfIcons[i]));
   410             }
   411             }
   411         }
   412         }
   412  
   413 
   413     }
   414     }
   414 }
   415 }
   415 
   416 
   416 /*!
   417 /*!
   417 \internal
   418 \internal
   434             centeredRect.setHeight(size.height());
   435             centeredRect.setHeight(size.height());
   435         }
   436         }
   436 
   437 
   437         if (!mask.isNull() && maskChanged) {
   438         if (!mask.isNull() && maskChanged) {
   438             icon->setMask(mask);
   439             icon->setMask(mask);
   439         } 
   440         }
   440         //paint the stitched icon
   441         //paint the stitched icon
   441         icon->paint(painter, centeredRect, Qt::AlignHCenter, clipPath);
   442         icon->paint(painter, centeredRect, Qt::AlignHCenter, clipPath);
   442         if ( icon->isCreatedOnServer() ) {
   443         if (icon->isCreatedOnServer()) {
   443             iconType = icon->iconImpl()->iconData().type;
   444             iconType = icon->iconImpl()->iconData().type;
   444         }
   445         }
   445 
   446 
   446         #ifdef HB_FRAME_DRAWER_TRACES
   447 #ifdef HB_FRAME_DRAWER_TRACES
   447         qDebug() << "FRAMENAME: " << frameGraphicsName << "Drawn at: "
   448         qDebug() << "FRAMENAME: " << frameGraphicsName << "Drawn at: "
   448         << centeredRect.topLeft().x() << "," << centeredRect.topLeft().y() << " | "
   449                  << centeredRect.topLeft().x() << "," << centeredRect.topLeft().y() << " | "
   449         << centeredRect.bottomRight().x() << "," << centeredRect.bottomRight().y();
   450                  << centeredRect.bottomRight().x() << "," << centeredRect.bottomRight().y();
   450         #endif
   451 #endif
   451     } else {
   452     } else {
   452         for (int i = 0; i < fileNameSuffixList().count(); i++) {
   453         for (int i = 0; i < fileNameSuffixList().count(); i++) {
   453             if (i < fallbackMaskableIconList.count() && fallbackMaskableIconList[i]) {
   454             if (i < fallbackMaskableIconList.count() && fallbackMaskableIconList[i]) {
   454                 QPoint position = multiPartSizeData.targets[i].topLeft();
   455                 QPoint position = multiPartSizeData.targets[i].topLeft();
   455                 if (isMirrored()) {
   456                 if (isMirrored()) {
   467                     pieceMask = mask.copy(maskRect);
   468                     pieceMask = mask.copy(maskRect);
   468                     fallbackMaskableIconList[i]->setMask(pieceMask);
   469                     fallbackMaskableIconList[i]->setMask(pieceMask);
   469                 }
   470                 }
   470                 if (!multiPartSizeData.targets[i].isEmpty()) {
   471                 if (!multiPartSizeData.targets[i].isEmpty()) {
   471                     fallbackMaskableIconList[i]->paint(painter,
   472                     fallbackMaskableIconList[i]->paint(painter,
   472                             QRect(position, multiPartSizeData.pixmapSizes[i]),
   473                                                        QRect(position, multiPartSizeData.pixmapSizes[i]),
   473                             Qt::AlignHCenter, clipPath);
   474                                                        Qt::AlignHCenter, clipPath);
   474                 }
   475                 }
   475             }
   476             }
   476         }
   477         }
   477         if ( fallbackMaskableIconList[0]->iconImpl()
   478         if (fallbackMaskableIconList[0]->iconImpl()
   478              && fallbackMaskableIconList[0]->iconImpl()->isCreatedOnServer() ) {
   479                 && fallbackMaskableIconList[0]->iconImpl()->isCreatedOnServer()) {
   479             if ( fallbackMaskableIconList[0]->iconImpl()->iconData().type != INVALID_FORMAT ) {
   480             if (fallbackMaskableIconList[0]->iconImpl()->iconData().type != INVALID_FORMAT) {
   480                 // store the icon type
   481                 // store the icon type
   481                 iconType = fallbackMaskableIconList[0]->iconImpl()->iconData().type;
   482                 iconType = fallbackMaskableIconList[0]->iconImpl()->iconData().type;
   482             }
   483             }
   483         }
   484         }
   484     }
   485     }
   486 }
   487 }
   487 
   488 
   488 /*!
   489 /*!
   489 \internal
   490 \internal
   490 */
   491 */
   491 bool HbFrameDrawerPrivate::fillWholeRect() const 
   492 bool HbFrameDrawerPrivate::fillWholeRect() const
   492 {
   493 {
   493     return flags & HbFrameDrawerPrivate::FillWholeRect;
   494     return flags & HbFrameDrawerPrivate::FillWholeRect;
   494 }
   495 }
   495 
   496 
   496 /*!
   497 /*!
   497 * Calculates frame part rectangles and icon sizes based on the following information.
   498 * Calculates frame part rectangles and icon sizes based on the following information.
   498 * - frame bounding rectangle
   499 * - frame bounding rectangle
   499 * - frame inner rectangle (optional)
   500 * - frame inner rectangle (optional)
   500 * - default sizes of the frame corner (9-piece) or side (3-piece) graphics.
   501 * - default sizes of the frame corner (9-piece) or side (3-piece) graphics.
   501 * 
   502 *
   502 * Note! Integer pixel sizes are used in this function to avoid one pixel gaps between the frame parts.
   503 * Note! Integer pixel sizes are used in this function to avoid one pixel gaps between the frame parts.
   503 * \internal
   504 * \internal
   504 */
   505 */
   505 QSize HbFrameDrawerPrivate::divideSpace(HbMultiPartSizeData &data)
   506 QSize HbFrameDrawerPrivate::divideSpace(HbMultiPartSizeData &data)
   506 {
   507 {
   535         int rightWidth;
   536         int rightWidth;
   536 
   537 
   537         if (borderWidths[0] == 0 && borderWidths[2] == 0) {
   538         if (borderWidths[0] == 0 && borderWidths[2] == 0) {
   538             QSizeF leftSize = defaultSize(suffixList.at(0)); // index 0 is leftmost frame part
   539             QSizeF leftSize = defaultSize(suffixList.at(0)); // index 0 is leftmost frame part
   539             QSizeF rightSize = defaultSize(suffixList.at(2)); // index 2 is rightmost frame part
   540             QSizeF rightSize = defaultSize(suffixList.at(2)); // index 2 is rightmost frame part
   540             
   541 
   541             if (fillWholeRect()) {
   542             if (fillWholeRect()) {
   542                 leftSize.scale(rect.size(), Qt::KeepAspectRatio);
   543                 leftSize.scale(rect.size(), Qt::KeepAspectRatio);
   543                 rightSize.scale(rect.size(), Qt::KeepAspectRatio);
   544                 rightSize.scale(rect.size(), Qt::KeepAspectRatio);
   544             } else {
   545             } else {
   545                 int leftHeight = leftSize.toSize().height();
   546                 int leftHeight = leftSize.toSize().height();
   571 
   572 
   572         // Do all 3 pieces fit?
   573         // Do all 3 pieces fit?
   573         if (fullWidth >= leftWidth + rightWidth) {
   574         if (fullWidth >= leftWidth + rightWidth) {
   574             data.targets[0] = QRect(0, 0, leftWidth, fullHeight);
   575             data.targets[0] = QRect(0, 0, leftWidth, fullHeight);
   575             data.targets[1] = QRect(leftWidth, 0, centerWidth, fullHeight);
   576             data.targets[1] = QRect(leftWidth, 0, centerWidth, fullHeight);
   576             data.targets[2] = QRect(fullWidth-rightWidth, 0, rightWidth, fullHeight);
   577             data.targets[2] = QRect(fullWidth - rightWidth, 0, rightWidth, fullHeight);
   577 
   578 
   578             data.pixmapSizes[0] = QSize(leftWidth, fullHeight);
   579             data.pixmapSizes[0] = QSize(leftWidth, fullHeight);
   579             data.pixmapSizes[1] = QSize(centerWidth, fullHeight);
   580             data.pixmapSizes[1] = QSize(centerWidth, fullHeight);
   580             data.pixmapSizes[2] = QSize(rightWidth, fullHeight);
   581             data.pixmapSizes[2] = QSize(rightWidth, fullHeight);
   581 
   582 
   582             data.sources[0] = QRect(QPoint(0,0), data.pixmapSizes[0]);
   583             data.sources[0] = QRect(QPoint(0, 0), data.pixmapSizes[0]);
   583             data.sources[1] = QRect(QPoint(0,0), data.pixmapSizes[1]);
   584             data.sources[1] = QRect(QPoint(0, 0), data.pixmapSizes[1]);
   584             data.sources[2] = QRect(QPoint(0,0), data.pixmapSizes[2]);
   585             data.sources[2] = QRect(QPoint(0, 0), data.pixmapSizes[2]);
   585         } else {
   586         } else {
   586             // Only sides fit
   587             // Only sides fit
   587             int totalSideWidth = leftWidth + rightWidth;
   588             int totalSideWidth = leftWidth + rightWidth;
   588             data.targets[0] = QRect(0, 0, leftWidth * fullWidth / totalSideWidth, fullHeight);
   589             data.targets[0] = QRect(0, 0, leftWidth * fullWidth / totalSideWidth, fullHeight);
   589             data.targets[1] = QRect();
   590             data.targets[1] = QRect();
   604         int bottomHeight;
   605         int bottomHeight;
   605 
   606 
   606         if (borderWidths[1] == 0 && borderWidths[3] == 0) {
   607         if (borderWidths[1] == 0 && borderWidths[3] == 0) {
   607             QSizeF topSize = defaultSize(suffixList.at(0)); // index 0 is top frame part
   608             QSizeF topSize = defaultSize(suffixList.at(0)); // index 0 is top frame part
   608             QSizeF bottomSize = defaultSize(suffixList.at(2)); // index 2 is bottom frame part
   609             QSizeF bottomSize = defaultSize(suffixList.at(2)); // index 2 is bottom frame part
   609             
   610 
   610             if (fillWholeRect()) {
   611             if (fillWholeRect()) {
   611                 topSize.scale(rect.size(), Qt::KeepAspectRatio);
   612                 topSize.scale(rect.size(), Qt::KeepAspectRatio);
   612                 bottomSize.scale(rect.size(), Qt::KeepAspectRatio);
   613                 bottomSize.scale(rect.size(), Qt::KeepAspectRatio);
   613             } else {
   614             } else {
   614                 int topWidth = topSize.toSize().width();
   615                 int topWidth = topSize.toSize().width();
   645 
   646 
   646             data.pixmapSizes[0] = QSize(fullWidth, topHeight);
   647             data.pixmapSizes[0] = QSize(fullWidth, topHeight);
   647             data.pixmapSizes[1] = QSize(fullWidth, centerHeight);
   648             data.pixmapSizes[1] = QSize(fullWidth, centerHeight);
   648             data.pixmapSizes[2] = QSize(fullWidth, bottomHeight);
   649             data.pixmapSizes[2] = QSize(fullWidth, bottomHeight);
   649 
   650 
   650             data.sources[0] = QRect(QPoint(0,0), data.pixmapSizes[0]);
   651             data.sources[0] = QRect(QPoint(0, 0), data.pixmapSizes[0]);
   651             data.sources[1] = QRect(QPoint(0,0), data.pixmapSizes[1]);
   652             data.sources[1] = QRect(QPoint(0, 0), data.pixmapSizes[1]);
   652             data.sources[2] = QRect(QPoint(0,0), data.pixmapSizes[2]);
   653             data.sources[2] = QRect(QPoint(0, 0), data.pixmapSizes[2]);
   653         } else {
   654         } else {
   654             // Only sides fit
   655             // Only sides fit
   655             int totalSideHeight = topHeight + bottomHeight;
   656             int totalSideHeight = topHeight + bottomHeight;
   656             data.targets[0] = QRect(0, 0, fullWidth, topHeight * fullHeight / totalSideHeight);
   657             data.targets[0] = QRect(0, 0, fullWidth, topHeight * fullHeight / totalSideHeight);
   657             data.targets[1] = QRect();
   658             data.targets[1] = QRect();
   658             data.targets[2] = QRect(0, data.targets[0].height(), fullWidth, fullHeight - data.targets[0].height());
   659             data.targets[2] = QRect(0, data.targets[0].height(), fullWidth, fullHeight - data.targets[0].height());
   659 
   660 
   660             data.pixmapSizes[0] = QSize(fullWidth,data.targets[0].height());
   661             data.pixmapSizes[0] = QSize(fullWidth, data.targets[0].height());
   661             data.pixmapSizes[1] = QSize();
   662             data.pixmapSizes[1] = QSize();
   662             data.pixmapSizes[2] = QSize(fullWidth,data.targets[2].height());
   663             data.pixmapSizes[2] = QSize(fullWidth, data.targets[2].height());
   663 
   664 
   664             data.sources[0] = data.targets[0];
   665             data.sources[0] = data.targets[0];
   665             data.sources[1] = QRect();
   666             data.sources[1] = QRect();
   666             data.sources[2] = data.targets[2];
   667             data.sources[2] = data.targets[2];
   667             data.sources[2].moveTop(data.pixmapSizes[2].height() - data.targets[2].height());
   668             data.sources[2].moveTop(data.pixmapSizes[2].height() - data.targets[2].height());
   679             brSize = QSizeF(borderWidths[2], borderWidths[3]).toSize();
   680             brSize = QSizeF(borderWidths[2], borderWidths[3]).toSize();
   680         }
   681         }
   681 
   682 
   682         // Do all 9 pieces fit?
   683         // Do all 9 pieces fit?
   683         if (fullWidth >= tlSize.width() + brSize.width() &&
   684         if (fullWidth >= tlSize.width() + brSize.width() &&
   684             fullHeight >= tlSize.height() + brSize.height()) {
   685                 fullHeight >= tlSize.height() + brSize.height()) {
   685 
   686 
   686             int centerWidth = fullWidth - tlSize.width() - brSize.width();
   687             int centerWidth = fullWidth - tlSize.width() - brSize.width();
   687             int centerHeight = fullHeight - tlSize.height() - brSize.height();
   688             int centerHeight = fullHeight - tlSize.height() - brSize.height();
   688 
   689 
   689             data.targets[0] = QRect(0, 0, tlSize.width(), tlSize.height());
   690             data.targets[0] = QRect(0, 0, tlSize.width(), tlSize.height());
   704             data.pixmapSizes[5] = data.targets[5].size();
   705             data.pixmapSizes[5] = data.targets[5].size();
   705             data.pixmapSizes[6] = data.targets[6].size();
   706             data.pixmapSizes[6] = data.targets[6].size();
   706             data.pixmapSizes[7] = data.targets[7].size();
   707             data.pixmapSizes[7] = data.targets[7].size();
   707             data.pixmapSizes[8] = data.targets[8].size();
   708             data.pixmapSizes[8] = data.targets[8].size();
   708 
   709 
   709             data.sources[0] = QRect(QPoint(0,0), data.pixmapSizes[0]);
   710             data.sources[0] = QRect(QPoint(0, 0), data.pixmapSizes[0]);
   710             data.sources[1] = QRect(QPoint(0,0), data.pixmapSizes[1]);
   711             data.sources[1] = QRect(QPoint(0, 0), data.pixmapSizes[1]);
   711             data.sources[2] = QRect(QPoint(0,0), data.pixmapSizes[2]);
   712             data.sources[2] = QRect(QPoint(0, 0), data.pixmapSizes[2]);
   712             data.sources[3] = QRect(QPoint(0,0), data.pixmapSizes[3]);
   713             data.sources[3] = QRect(QPoint(0, 0), data.pixmapSizes[3]);
   713             data.sources[4] = QRect(QPoint(0,0), data.pixmapSizes[4]);
   714             data.sources[4] = QRect(QPoint(0, 0), data.pixmapSizes[4]);
   714             data.sources[5] = QRect(QPoint(0,0), data.pixmapSizes[5]);
   715             data.sources[5] = QRect(QPoint(0, 0), data.pixmapSizes[5]);
   715             data.sources[6] = QRect(QPoint(0,0), data.pixmapSizes[6]);
   716             data.sources[6] = QRect(QPoint(0, 0), data.pixmapSizes[6]);
   716             data.sources[7] = QRect(QPoint(0,0), data.pixmapSizes[7]);
   717             data.sources[7] = QRect(QPoint(0, 0), data.pixmapSizes[7]);
   717             data.sources[8] = QRect(QPoint(0,0), data.pixmapSizes[8]);
   718             data.sources[8] = QRect(QPoint(0, 0), data.pixmapSizes[8]);
   718 
   719 
   719         } else {
   720         } else {
   720             // All 9 pieces do not fit.
   721             // All 9 pieces do not fit.
   721             // Corners are drawn always but it is possible that either left&right or top&bottom parts get drawn also.
   722             // Corners are drawn always but it is possible that either left&right or top&bottom parts get drawn also.
   722             int totalCornerWidth = tlSize.width() + brSize.width();
   723             int totalCornerWidth = tlSize.width() + brSize.width();
   733             if (totalCornerHeight > fullHeight) {
   734             if (totalCornerHeight > fullHeight) {
   734                 splitPointY = tlSize.height() * fullHeight / totalCornerHeight;
   735                 splitPointY = tlSize.height() * fullHeight / totalCornerHeight;
   735             }
   736             }
   736 
   737 
   737             calculateShrinkedNinePieceCorners(
   738             calculateShrinkedNinePieceCorners(
   738                     data, tlSize, brSize,
   739                 data, tlSize, brSize,
   739                     QSize(fullWidth, fullHeight), QPoint(splitPointX, splitPointY));
   740                 QSize(fullWidth, fullHeight), QPoint(splitPointX, splitPointY));
   740 
   741 
   741             // Left and right get drawn if corners height does not cover the total height
   742             // Left and right get drawn if corners height does not cover the total height
   742             if (!splitPointY) {
   743             if (!splitPointY) {
   743                 data.targets[3] = QRect(0, data.targets[0].height(), data.targets[0].width(), fullHeight - tlSize.height() - brSize.height());
   744                 data.targets[3] = QRect(0, data.targets[0].height(), data.targets[0].width(), fullHeight - tlSize.height() - brSize.height());
   744                 data.targets[5] = QRect(splitPointX, data.targets[0].height(), data.targets[2].width(), data.targets[3].height());
   745                 data.targets[5] = QRect(splitPointX, data.targets[0].height(), data.targets[2].width(), data.targets[3].height());
   768             data.pixmapSizes[6] = data.targets[6].size();
   769             data.pixmapSizes[6] = data.targets[6].size();
   769             data.pixmapSizes[7] = data.targets[7].size();
   770             data.pixmapSizes[7] = data.targets[7].size();
   770             data.pixmapSizes[8] = data.targets[8].size();
   771             data.pixmapSizes[8] = data.targets[8].size();
   771 
   772 
   772             data.sources[0] = data.targets[0];
   773             data.sources[0] = data.targets[0];
   773             data.sources[1] = QRect(QPoint(0,0), data.pixmapSizes[1]);
   774             data.sources[1] = QRect(QPoint(0, 0), data.pixmapSizes[1]);
   774             data.sources[2] = QRect(QPoint(0,0), data.pixmapSizes[2]);
   775             data.sources[2] = QRect(QPoint(0, 0), data.pixmapSizes[2]);
   775             data.sources[2].setBottomLeft(QPoint(data.pixmapSizes[2].width() - data.targets[2].width(), data.targets[2].height() - 1));
   776             data.sources[2].setBottomLeft(QPoint(data.pixmapSizes[2].width() - data.targets[2].width(), data.targets[2].height() - 1));
   776             data.sources[3] = QRect(QPoint(0,0), data.pixmapSizes[3]);
   777             data.sources[3] = QRect(QPoint(0, 0), data.pixmapSizes[3]);
   777             data.sources[4] = QRect(); // center is always empty
   778             data.sources[4] = QRect(); // center is always empty
   778             data.sources[5] = QRect(QPoint(0,0), data.pixmapSizes[5]);
   779             data.sources[5] = QRect(QPoint(0, 0), data.pixmapSizes[5]);
   779             data.sources[6] = QRect(QPoint(0,0), data.pixmapSizes[6]);
   780             data.sources[6] = QRect(QPoint(0, 0), data.pixmapSizes[6]);
   780             data.sources[6].setTopRight(QPoint(data.targets[6].width() - 1, data.pixmapSizes[6].height() - data.targets[6].height()));
   781             data.sources[6].setTopRight(QPoint(data.targets[6].width() - 1, data.pixmapSizes[6].height() - data.targets[6].height()));
   781             data.sources[7] = QRect(QPoint(0,0), data.pixmapSizes[7]);
   782             data.sources[7] = QRect(QPoint(0, 0), data.pixmapSizes[7]);
   782             data.sources[8] = QRect(QPoint(0,0), data.pixmapSizes[8]);
   783             data.sources[8] = QRect(QPoint(0, 0), data.pixmapSizes[8]);
   783             data.sources[8].setTopLeft(QPoint(data.pixmapSizes[8].width() - data.targets[8].width(), data.pixmapSizes[8].height() - data.targets[8].height()));
   784             data.sources[8].setTopLeft(QPoint(data.pixmapSizes[8].width() - data.targets[8].width(), data.pixmapSizes[8].height() - data.targets[8].height()));
   784         }
   785         }
   785     }
   786     }
   786 
   787 
   787 #ifdef HB_FRAME_DRAWER_TRACES
   788 #ifdef HB_FRAME_DRAWER_TRACES
   794 
   795 
   795 /*!
   796 /*!
   796 \internal
   797 \internal
   797 */
   798 */
   798 void HbFrameDrawerPrivate::calculateShrinkedNinePieceCorners(
   799 void HbFrameDrawerPrivate::calculateShrinkedNinePieceCorners(
   799         HbMultiPartSizeData &data,
   800     HbMultiPartSizeData &data,
   800         const QSize& tlSize, const QSize& brSize,
   801     const QSize &tlSize, const QSize &brSize,
   801         const QSize& fullSize, const QPoint& splitPoint)
   802     const QSize &fullSize, const QPoint &splitPoint)
   802 {
   803 {
   803     // Make sure that corner sizes don't exceed frames full size
   804     // Make sure that corner sizes don't exceed frames full size
   804 
   805 
   805     // Top-left corner
   806     // Top-left corner
   806     int topLeftWidth = splitPoint.x() ? splitPoint.x() : tlSize.width();
   807     int topLeftWidth = splitPoint.x() ? splitPoint.x() : tlSize.width();
   807     int topLeftHeight = splitPoint.y() ? splitPoint.y() : tlSize.height();
   808     int topLeftHeight = splitPoint.y() ? splitPoint.y() : tlSize.height();
   808     data.targets[0] = QRect(
   809     data.targets[0] = QRect(
   809         0,
   810                           0,
   810         0,
   811                           0,
   811         topLeftWidth < fullSize.width() ? topLeftWidth : fullSize.width(),
   812                           topLeftWidth < fullSize.width() ? topLeftWidth : fullSize.width(),
   812         topLeftHeight < fullSize.height() ? topLeftHeight : fullSize.height());
   813                           topLeftHeight < fullSize.height() ? topLeftHeight : fullSize.height());
   813 
   814 
   814     // Top-right corner
   815     // Top-right corner
   815     int topRightX = splitPoint.x() ? splitPoint.x() : fullSize.width() - brSize.width();
   816     int topRightX = splitPoint.x() ? splitPoint.x() : fullSize.width() - brSize.width();
   816     int topRightWidth = splitPoint.x() ? fullSize.width() - splitPoint.x() : brSize.width();
   817     int topRightWidth = splitPoint.x() ? fullSize.width() - splitPoint.x() : brSize.width();
   817     if (topRightWidth > fullSize.width()) {
   818     if (topRightWidth > fullSize.width()) {
   848     int bottomRightHeight = splitPoint.y() ? fullSize.height() - splitPoint.y() : brSize.height();
   849     int bottomRightHeight = splitPoint.y() ? fullSize.height() - splitPoint.y() : brSize.height();
   849     if (bottomRightHeight > fullSize.height()) {
   850     if (bottomRightHeight > fullSize.height()) {
   850         bottomRightHeight = fullSize.height();
   851         bottomRightHeight = fullSize.height();
   851         bottomRightY = 0;
   852         bottomRightY = 0;
   852     }
   853     }
   853     data.targets[8] = QRect( bottomRightX, bottomRightY, bottomRightWidth, bottomRightHeight);
   854     data.targets[8] = QRect(bottomRightX, bottomRightY, bottomRightWidth, bottomRightHeight);
   854 }
   855 }
   855 
   856 
   856 /*!
   857 /*!
   857 \internal
   858 \internal
   858 */
   859 */
   878         if (defaultMirroring == Enabled) {
   879         if (defaultMirroring == Enabled) {
   879             basedOnLayoutDir = true;
   880             basedOnLayoutDir = true;
   880         } else if (defaultMirroring == Disabled) {
   881         } else if (defaultMirroring == Disabled) {
   881             return false;
   882             return false;
   882         }
   883         }
   883     // Forced
   884         // Forced
   884     } else if (mirroring == HbIcon::Forced) {
   885     } else if (mirroring == HbIcon::Forced) {
   885         return true;
   886         return true;
   886     // Prevented
   887         // Prevented
   887     } else if (mirroring == HbIcon::Prevented) {
   888     } else if (mirroring == HbIcon::Prevented) {
   888         return false;
   889         return false;
   889     // LayoutDirection
   890         // LayoutDirection
   890     } else if (mirroring == HbIcon::LayoutDirection) {
   891     } else if (mirroring == HbIcon::LayoutDirection) {
   891         basedOnLayoutDir = true;
   892         basedOnLayoutDir = true;
   892     }
   893     }
   893 
   894 
   894     if (basedOnLayoutDir) {
   895     if (basedOnLayoutDir) {
   895         Qt::LayoutDirection usedDirection = Qt::LeftToRight; // default;
   896         Qt::LayoutDirection usedDirection = Qt::LeftToRight; // default;
   896         if ( flags&HbFrameDrawerPrivate::LayoutDirectionSet ) {
   897         if (flags & HbFrameDrawerPrivate::LayoutDirectionSet) {
   897             usedDirection = layoutDirection;
   898             usedDirection = layoutDirection;
   898         } else {
   899         } else {
   899 			usedDirection = QApplication::layoutDirection();
   900             usedDirection = QApplication::layoutDirection();
   900         }
   901         }
   901 
   902 
   902         return usedDirection == Qt::LeftToRight ? false : true;
   903         return usedDirection == Qt::LeftToRight ? false : true;
   903     }
   904     }
   904 
   905 
   912 \internal
   913 \internal
   913 */
   914 */
   914 bool HbFrameDrawerPrivate::hasBorderWidths() const
   915 bool HbFrameDrawerPrivate::hasBorderWidths() const
   915 {
   916 {
   916     return borderWidths[1] > 0
   917     return borderWidths[1] > 0
   917         || borderWidths[2] > 0
   918            || borderWidths[2] > 0
   918         || borderWidths[2] > 0
   919            || borderWidths[2] > 0
   919         || borderWidths[3] > 0;
   920            || borderWidths[3] > 0;
   920 }
   921 }
   921 
   922 
   922 /*!
   923 /*!
   923 \internal
   924 \internal
   924 */
   925 */
   925 void HbFrameDrawerPrivate::reset(bool resetFrameCount, bool unloadedByServer)
   926 void HbFrameDrawerPrivate::reset(bool resetFrameCount, bool unloadedByServer)
   926 {
   927 {
   927     unLoadIcon(unloadedByServer);
   928     unLoadIcon(unloadedByServer);
   928     if ( resetFrameCount ) {
   929     if (resetFrameCount) {
   929         frameParts = 0;
   930         frameParts = 0;
   930     }
   931     }
   931 }
   932 }
   932 
   933 
   933 /*!
   934 /*!
   934 *	Resets the MaskableIcon 
   935 *   Resets the MaskableIcon
   935 */
   936 */
   936 void HbFrameDrawerPrivate::resetMaskableIcon()
   937 void HbFrameDrawerPrivate::resetMaskableIcon()
   937 {
   938 {
   938 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON)    
   939 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON)
   939     HbIconLoader *loader = HbIconLoader::global();
   940     HbIconLoader *loader = HbIconLoader::global();
   940     if ( icon ) {  
   941     if (icon) {
   941       //consolidated icon case 
   942         //consolidated icon case
   942       icon->decrementRefCount();    
   943         icon->decrementRefCount();
   943       if ( icon->refCount() == 0 && icon->isCreatedOnServer() ) {
   944         if (icon->refCount() == 0 && icon->isCreatedOnServer()) {
   944           // remove the item from cache and delete the icon
   945             // remove the item from cache and delete the icon
   945           loader->removeItemInCache( icon->iconImpl() );
   946             loader->removeItemInCache(icon->iconImpl());
   946           icon->dispose();
   947             icon->dispose();
   947       }
   948         }
   948       icon = 0;              
   949         icon = 0;
   949     } else {            
   950     } else {
   950         int count = fallbackMaskableIconList.count();
   951         int count = fallbackMaskableIconList.count();
   951         if ( count ) {
   952         if (count) {
   952             // for each item in fallbackMaskableIconList - decrement the reference count and
   953             // for each item in fallbackMaskableIconList - decrement the reference count and
   953             // remove the item in cache, dispose if needed.
   954             // remove the item in cache, dispose if needed.
   954             foreach ( HbMaskableIconImpl* impl, fallbackMaskableIconList ) {
   955             foreach(HbMaskableIconImpl * impl, fallbackMaskableIconList) {
   955                    impl->decrementRefCount();
   956                 impl->decrementRefCount();
   956                    if ( impl->refCount() == 0 && impl->isCreatedOnServer() ) {
   957                 if (impl->refCount() == 0 && impl->isCreatedOnServer()) {
   957                        loader->removeItemInCache( impl->iconImpl() );     
   958                     loader->removeItemInCache(impl->iconImpl());
   958                        impl->dispose();
   959                     impl->dispose();
   959                    } 
   960                 }
   960             }                                   
   961             }
   961             fallbackMaskableIconList.clear(); 
   962             fallbackMaskableIconList.clear();
   962         }
   963         }
   963     }
   964     }
   964     frameParts = 0;
   965     frameParts = 0;
   965 #endif
   966 #endif
   966 }
   967 }
  1004             id.append("_1");
  1005             id.append("_1");
  1005         } else {
  1006         } else {
  1006             id.append("_0");
  1007             id.append("_0");
  1007         }
  1008         }
  1008 
  1009 
  1009         for (int i = 0;i < 4; i++) { 
  1010         for (int i = 0; i < 4; i++) {
  1010             QString boundary;
  1011             QString boundary;
  1011             id.append("_");
  1012             id.append("_");
  1012             id.append(boundary.setNum(borderWidths[i]));
  1013             id.append(boundary.setNum(borderWidths[i]));
  1013         }
  1014         }
  1014     }
  1015     }
  1015 
  1016 
  1016     for (int i = 0; i < suffixList.count(); i++) {
  1017     for (int i = 0; i < suffixList.count(); i++) {
  1017         id.append( suffixList[i] );
  1018         id.append(suffixList[i]);
  1018     }
  1019     }
  1019 
  1020 
  1020     return id;
  1021     return id;
  1021 }
  1022 }
  1022 
  1023 
  1024 {
  1025 {
  1025     HbIconLoader *loader = HbIconLoader::global();
  1026     HbIconLoader *loader = HbIconLoader::global();
  1026     if (icon) {
  1027     if (icon) {
  1027         //If a consolidated (stitched) icon was created on the themeserver, then
  1028         //If a consolidated (stitched) icon was created on the themeserver, then
  1028         //HbIconLoader::unloadIcon() is used to unload it.
  1029         //HbIconLoader::unloadIcon() is used to unload it.
  1029         loader->unLoadIcon(icon->iconImpl(),unloadedByServer);
  1030         loader->unLoadIcon(icon->iconImpl(), unloadedByServer);
  1030         icon->dispose();
  1031         icon->dispose();
  1031         icon = 0;
  1032         icon = 0;
  1032     }
  1033     }
  1033 
  1034 
  1034     // get a vector of QVector<HbIconImpl*> from QVector<HbMaskableIconImpl*> for unloading.
  1035     // get a vector of QVector<HbIconImpl*> from QVector<HbMaskableIconImpl*> for unloading.
  1035     QVector<HbIconImpl *> fallbackIconList;
  1036     QVector<HbIconImpl *> fallbackIconList;
  1036     int count = fallbackMaskableIconList.count();
  1037     int count = fallbackMaskableIconList.count();
  1037     for (int i = 0; i < count ; i++) {
  1038     for (int i = 0; i < count ; i++) {
  1038         if ( fallbackMaskableIconList.at(i) ) {
  1039         if (fallbackMaskableIconList.at(i)) {
  1039             fallbackIconList.append(fallbackMaskableIconList.at(i)->iconImpl());
  1040             fallbackIconList.append(fallbackMaskableIconList.at(i)->iconImpl());
  1040         }
  1041         }
  1041     }
  1042     }
  1042     count = fallbackIconList.count();
  1043     count = fallbackIconList.count();
  1043     if (count > 0) {
  1044     if (count > 0) {
  1044         //If a consolidated (stitched) icon-creation on themeserver fails, unload-request for all individual
  1045         //If a consolidated (stitched) icon-creation on themeserver fails, unload-request for all individual
  1045         //frame-items are batched together in a single IPC, which is initiated in HbIconLoader::unLoadMultiIcon().
  1046         //frame-items are batched together in a single IPC, which is initiated in HbIconLoader::unLoadMultiIcon().
  1046         loader->unLoadMultiIcon(fallbackIconList);
  1047         loader->unLoadMultiIcon(fallbackIconList);
  1047         for (int i=0; i < count ; i++) {
  1048         for (int i = 0; i < count ; i++) {
  1048             if ( fallbackMaskableIconList.at(i) ) {
  1049             if (fallbackMaskableIconList.at(i)) {
  1049                 fallbackMaskableIconList.at(i)->dispose();
  1050                 fallbackMaskableIconList.at(i)->dispose();
  1050             }
  1051             }
  1051         }
  1052         }
  1052      }
  1053     }
  1053     fallbackIconList.clear();  // vector of HbIconImpl*
  1054     fallbackIconList.clear();  // vector of HbIconImpl*
  1054     fallbackMaskableIconList.clear(); // vector of HbMaskableIconImpl*
  1055     fallbackMaskableIconList.clear(); // vector of HbMaskableIconImpl*
  1055 }
  1056 }
  1056 
  1057 
  1057 void HbFrameDrawerPrivate::themeChange( const QStringList &updatedFiles)
  1058 void HbFrameDrawerPrivate::themeChange(const QStringList &updatedFiles)
  1058 {
  1059 {
  1059     bool unloadIcons = false;
  1060     bool unloadIcons = false;
  1060     if (updatedFiles.count() == 0 || (icon && updatedFiles.contains(icon->iconFileName()))) {
  1061     if (updatedFiles.count() == 0 || (icon && updatedFiles.contains(icon->iconFileName()))) {
  1061         unloadIcons = true;
  1062         unloadIcons = true;
  1062     } else {
  1063     } else {
  1063         HbMaskableIconImpl *fallbackIcon;
  1064         HbMaskableIconImpl *fallbackIcon;
  1064         foreach (fallbackIcon, fallbackMaskableIconList) {
  1065         foreach(fallbackIcon, fallbackMaskableIconList) {
  1065             if (fallbackIcon && updatedFiles.contains(fallbackIcon->iconFileName())) {
  1066             if (fallbackIcon && updatedFiles.contains(fallbackIcon->iconFileName())) {
  1066                 unloadIcons = true;
  1067                 unloadIcons = true;
  1067                 break;
  1068                 break;
  1068             }
  1069             }
  1069         }
  1070         }
  1077 /*! Constructs a new frame drawer item with the cacheFlag enabled  by default.
  1078 /*! Constructs a new frame drawer item with the cacheFlag enabled  by default.
  1078 */
  1079 */
  1079 HbFrameDrawer::HbFrameDrawer(bool cacheFlag)
  1080 HbFrameDrawer::HbFrameDrawer(bool cacheFlag)
  1080 {
  1081 {
  1081     d = new HbFrameDrawerPrivate();
  1082     d = new HbFrameDrawerPrivate();
  1082     if ( !cacheFlag ) {
  1083     if (!cacheFlag) {
  1083         d->flags &= HbFrameDrawerPrivate::DoNotCache;  
  1084         d->flags &= HbFrameDrawerPrivate::DoNotCache;
  1084     }
  1085     }
  1085 }
  1086 }
  1086 
  1087 
  1087 /*! Constructs a new frame drawer with the given \a frameGraphicsName and \a type  and cacheFlag is enabled.
  1088 /*! Constructs a new frame drawer with the given \a frameGraphicsName and \a type  and cacheFlag is enabled.
  1088 */
  1089 */
  1089 HbFrameDrawer::HbFrameDrawer(const QString &frameGraphicsName, FrameType type, bool cacheFlag)
  1090 HbFrameDrawer::HbFrameDrawer(const QString &frameGraphicsName, FrameType type, bool cacheFlag)
  1090 {
  1091 {
  1091     d = new HbFrameDrawerPrivate(frameGraphicsName, type);
  1092     d = new HbFrameDrawerPrivate(frameGraphicsName, type);
  1092     if ( !cacheFlag ) {
  1093     if (!cacheFlag) {
  1093         d->flags &= HbFrameDrawerPrivate::DoNotCache;
  1094         d->flags &= HbFrameDrawerPrivate::DoNotCache;
  1094     }  
  1095     }
  1095 }
  1096 }
  1096 
  1097 
  1097 /*!
  1098 /*!
  1098 * Copy constructs a new frame drawer using the \a other frame drawer.
  1099 * Copy constructs a new frame drawer using the \a other frame drawer.
  1099 * This is very fast.
  1100 * This is very fast.
  1100 * Copy-on-write semantics is used, so this only does a shallow copy. 
  1101 * Copy-on-write semantics is used, so this only does a shallow copy.
  1101 */
  1102 */
  1102 HbFrameDrawer::HbFrameDrawer(const HbFrameDrawer &other) :
  1103 HbFrameDrawer::HbFrameDrawer(const HbFrameDrawer &other) :
  1103     d(other.d)
  1104     d(other.d)
  1104 {
  1105 {
  1105 }
  1106 }
  1106 
  1107 
  1107 /*!
  1108 /*!
  1108 * Assigns the \a other frame drawer to this frame drawer and returns a reference to
  1109 * Assigns the \a other frame drawer to this frame drawer and returns a reference to
  1109 * this frame drawer. Copy-on-write semantics is used, so this only does a shallow copy. 
  1110 * this frame drawer. Copy-on-write semantics is used, so this only does a shallow copy.
  1110 */
  1111 */
  1111 HbFrameDrawer &HbFrameDrawer::operator=(const HbFrameDrawer &other)
  1112 HbFrameDrawer &HbFrameDrawer::operator=(const HbFrameDrawer &other)
  1112 {
  1113 {
  1113     if (&other != this) {
  1114     if (&other != this) {
  1114         d = other.d;
  1115         d = other.d;
  1150 void HbFrameDrawer::setFrameGraphicsName(const QString &frameGraphicsName)
  1151 void HbFrameDrawer::setFrameGraphicsName(const QString &frameGraphicsName)
  1151 {
  1152 {
  1152     // Remove possible file extension
  1153     // Remove possible file extension
  1153     QString nameWithoutExt = frameGraphicsName;
  1154     QString nameWithoutExt = frameGraphicsName;
  1154     int index = nameWithoutExt.lastIndexOf(QChar('.'));
  1155     int index = nameWithoutExt.lastIndexOf(QChar('.'));
  1155     if (index>0) {
  1156     if (index > 0) {
  1156         nameWithoutExt.resize(index);
  1157         nameWithoutExt.resize(index);
  1157     }
  1158     }
  1158 
  1159 
  1159     if (d->frameGraphicsName != nameWithoutExt) {
  1160     if (d->frameGraphicsName != nameWithoutExt) {
  1160         d->frameGraphicsName = nameWithoutExt;
  1161         d->frameGraphicsName = nameWithoutExt;
  1162         d->reset();
  1163         d->reset();
  1163         // Frame graphics changed, clear default frame mirroring information based on the automatic mirroring list
  1164         // Frame graphics changed, clear default frame mirroring information based on the automatic mirroring list
  1164         d->defaultMirroring = HbFrameDrawerPrivate::Unknown;
  1165         d->defaultMirroring = HbFrameDrawerPrivate::Unknown;
  1165 
  1166 
  1166         // if graphicsItem is set, request redraw
  1167         // if graphicsItem is set, request redraw
  1167         if ( d->graphicsItem ) {
  1168         if (d->graphicsItem) {
  1168             d->graphicsItem->update();
  1169             d->graphicsItem->update();
  1169         }
  1170         }
  1170     }
  1171     }
  1171 }
  1172 }
  1172 
  1173 
  1214 * Frame type \b ThreePiecesHorizontal:
  1215 * Frame type \b ThreePiecesHorizontal:
  1215 *
  1216 *
  1216 * - Left part width = (default size of the left part graphics scaled to the bounding rectangle).width
  1217 * - Left part width = (default size of the left part graphics scaled to the bounding rectangle).width
  1217 * - Right part width = (default size of the right part graphics scaled to the bounding rectangle).width
  1218 * - Right part width = (default size of the right part graphics scaled to the bounding rectangle).width
  1218 * - Center part width = remaining width
  1219 * - Center part width = remaining width
  1219 * 
  1220 *
  1220 * Frame type \b ThreePiecesVertical:
  1221 * Frame type \b ThreePiecesVertical:
  1221 *
  1222 *
  1222 * - Top part height = (default size of the top part graphics scaled to the bounding rectangle).height
  1223 * - Top part height = (default size of the top part graphics scaled to the bounding rectangle).height
  1223 * - Bottom part height = (default size of the bottom part graphics scaled to the bounding rectangle).height
  1224 * - Bottom part height = (default size of the bottom part graphics scaled to the bounding rectangle).height
  1224 * - Center part height = remaining height
  1225 * - Center part height = remaining height
  1230 *
  1231 *
  1231 * \sa HbFrameDrawer::borderWidths()
  1232 * \sa HbFrameDrawer::borderWidths()
  1232 */
  1233 */
  1233 void HbFrameDrawer::setBorderWidths(const qreal left, const qreal top, const qreal right, const qreal bottom)
  1234 void HbFrameDrawer::setBorderWidths(const qreal left, const qreal top, const qreal right, const qreal bottom)
  1234 {
  1235 {
  1235 	d->setBorderApiProtectionFlag(true);
  1236     d->setBorderApiProtectionFlag(true);
  1236     if ( left != d->borderWidths[0] || top != d->borderWidths[1] ||
  1237     if (left != d->borderWidths[0] || top != d->borderWidths[1] ||
  1237          right != d->borderWidths[2] || bottom != d->borderWidths[3] ) {
  1238             right != d->borderWidths[2] || bottom != d->borderWidths[3]) {
  1238         // Negative values are converted to zero.
  1239         // Negative values are converted to zero.
  1239         d->borderWidths[0] = qMax((qreal)0.0, left);
  1240         d->borderWidths[0] = qMax((qreal)0.0, left);
  1240         d->borderWidths[1] = qMax((qreal)0.0, top);
  1241         d->borderWidths[1] = qMax((qreal)0.0, top);
  1241         d->borderWidths[2] = qMax((qreal)0.0, right);
  1242         d->borderWidths[2] = qMax((qreal)0.0, right);
  1242         d->borderWidths[3] = qMax((qreal)0.0, bottom);
  1243         d->borderWidths[3] = qMax((qreal)0.0, bottom);
  1243         // borderWidths changed, clear frame icon
  1244         // borderWidths changed, clear frame icon
  1244         d->reset( false );
  1245         d->reset(false);
  1245     }
  1246     }
  1246 }
  1247 }
  1247 
  1248 
  1248 /*!
  1249 /*!
  1249 * This is a convenience method. Equals to:
  1250 * This is a convenience method. Equals to:
  1252 *
  1253 *
  1253 * \sa HbFrameDrawer::borderWidths()
  1254 * \sa HbFrameDrawer::borderWidths()
  1254 */
  1255 */
  1255 void HbFrameDrawer::setBorderWidths(const qreal horizontal, const qreal vertical)
  1256 void HbFrameDrawer::setBorderWidths(const qreal horizontal, const qreal vertical)
  1256 {
  1257 {
  1257     setBorderWidths( horizontal, vertical, horizontal, vertical );
  1258     setBorderWidths(horizontal, vertical, horizontal, vertical);
  1258 }
  1259 }
  1259 
  1260 
  1260 /*!
  1261 /*!
  1261 * This is a convenience method. Equals to:
  1262 * This is a convenience method. Equals to:
  1262 *
  1263 *
  1264 *
  1265 *
  1265 * \sa HbFrameDrawer::borderWidths()
  1266 * \sa HbFrameDrawer::borderWidths()
  1266 */
  1267 */
  1267 void HbFrameDrawer::setBorderWidth(const qreal width)
  1268 void HbFrameDrawer::setBorderWidth(const qreal width)
  1268 {
  1269 {
  1269     setBorderWidths( width, width, width, width );
  1270     setBorderWidths(width, width, width, width);
  1270 }
  1271 }
  1271 
  1272 
  1272 
  1273 
  1273 /*!
  1274 /*!
  1274 * Returns the bounding rectangle of the frame.
  1275 * Returns the bounding rectangle of the frame.
  1286 void HbFrameDrawer::setRect(const QRectF &rect)
  1287 void HbFrameDrawer::setRect(const QRectF &rect)
  1287 {
  1288 {
  1288     if (rect != d->rect) {
  1289     if (rect != d->rect) {
  1289         d->rect = rect;
  1290         d->rect = rect;
  1290         // Rect changed, clear frame icon
  1291         // Rect changed, clear frame icon
  1291         d->reset( false );
  1292         d->reset(false);
  1292     }
  1293     }
  1293 }
  1294 }
  1294 
  1295 
  1295 /*!
  1296 /*!
  1296 * Paints the frame with the given \a painter.
  1297 * Paints the frame with the given \a painter.
  1297 */
  1298 */
  1298 void HbFrameDrawer::paint(QPainter *painter, const QRectF &rect) const
  1299 void HbFrameDrawer::paint(QPainter *painter, const QRectF &rect) const
  1299 {
  1300 {
  1300     const_cast<HbFrameDrawer*>(this)->setRect( rect );
  1301     const_cast<HbFrameDrawer *>(this)->setRect(rect);
  1301 
  1302 
  1302     if (d->frameGraphicsName.isEmpty() || d->type == HbFrameDrawer::Undefined || d->rect.isEmpty()) {
  1303     if (d->frameGraphicsName.isEmpty() || d->type == HbFrameDrawer::Undefined || d->rect.isEmpty()) {
  1303         return;
  1304         return;
  1304     }
  1305     }
  1305 
  1306 
  1306     // Lazy graphics rasterizing is used.
  1307     // Lazy graphics rasterizing is used.
  1307     // Rasterize the frame parts now if that has not been done yet.
  1308     // Rasterize the frame parts now if that has not been done yet.
  1308     if (d->icon && (rect.toRect().size() !=  d->prevRect.size())) {
  1309     if (d->icon && (rect.toRect().size() !=  d->prevRect.size())) {
  1309         d->reset(); 
  1310         d->reset();
  1310     }    
  1311     }
  1311     
  1312 
  1312     // update the rendering mode
  1313     // update the rendering mode
  1313     HbIconLoader::global()->updateRenderingMode(painter->paintEngine()->type());    
  1314     QPaintEngine *paintEngine = painter->paintEngine();
       
  1315     if (paintEngine) {
       
  1316         HbIconLoader::global()->updateRenderingMode(paintEngine->type());
       
  1317     }
  1314     d->prepareFrameIcon();
  1318     d->prepareFrameIcon();
  1315     d->prevRect = rect.toRect();
  1319     d->prevRect = rect.toRect();
  1316     // Paint the frame
  1320     // Paint the frame
  1317     d->paint(painter);
  1321     d->paint(painter);
  1318 }
  1322 }
  1344 *
  1348 *
  1345 * \sa HbFrameDrawer::fillWholeRect()
  1349 * \sa HbFrameDrawer::fillWholeRect()
  1346 */
  1350 */
  1347 void HbFrameDrawer::setFillWholeRect(bool fill)
  1351 void HbFrameDrawer::setFillWholeRect(bool fill)
  1348 {
  1352 {
  1349     if ( (fill && !d->fillWholeRect()) || (!fill && d->fillWholeRect()) ) {
  1353     if ((fill && !d->fillWholeRect()) || (!fill && d->fillWholeRect())) {
  1350         if ( fill ) {
  1354         if (fill) {
  1351             d->flags |= HbFrameDrawerPrivate::FillWholeRect;
  1355             d->flags |= HbFrameDrawerPrivate::FillWholeRect;
  1352         } else {
  1356         } else {
  1353             d->flags &= ~HbFrameDrawerPrivate::FillWholeRect;
  1357             d->flags &= ~HbFrameDrawerPrivate::FillWholeRect;
  1354         }
  1358         }
  1355 
  1359 
  1356         // Fill mode changed, clear frame Icon
  1360         // Fill mode changed, clear frame Icon
  1357         d->reset( false );
  1361         d->reset(false);
  1358     }
  1362     }
  1359 }
  1363 }
  1360 
  1364 
  1361 /*! Returns the mirroring mode set for the frame drawer.
  1365 /*! Returns the mirroring mode set for the frame drawer.
  1362 * \sa HbFrameDrawer::setMirroringMode()
  1366 * \sa HbFrameDrawer::setMirroringMode()
  1372 void HbFrameDrawer::setMirroringMode(HbIcon::MirroringMode mode)
  1376 void HbFrameDrawer::setMirroringMode(HbIcon::MirroringMode mode)
  1373 {
  1377 {
  1374     if (mode != d->mirroring) {
  1378     if (mode != d->mirroring) {
  1375         d->mirroring = mode;
  1379         d->mirroring = mode;
  1376         // Mirroring changed, clear frame Icon
  1380         // Mirroring changed, clear frame Icon
  1377         d->reset( false );
  1381         d->reset(false);
  1378     }
  1382     }
  1379 }
  1383 }
  1380 
  1384 
  1381 /*! Returns the filename suffix list.
  1385 /*! Returns the filename suffix list.
  1382 * See the class level documentation for how frame part filenames are determined
  1386 * See the class level documentation for how frame part filenames are determined
  1442         // Frame part filename suffix list changed, clear frame parts count info and generated frame icon.
  1446         // Frame part filename suffix list changed, clear frame parts count info and generated frame icon.
  1443         d->reset();
  1447         d->reset();
  1444     }
  1448     }
  1445 }
  1449 }
  1446 
  1450 
  1447 /*! 
  1451 /*!
  1448 * Sets the mask to be applied with the the entire frame icon.
  1452 * Sets the mask to be applied with the entire frame icon.
  1449 * If the mask is also a frame item, use another frame drawer to draw it.
  1453 * If the mask is also a frame item, use another frame drawer to draw it.
  1450 * Mask should be of the same size as returned by frameSize().
  1454 * Mask should be of the same size as returned by frameSize().
  1451 * To unset the mask, set it to a null pixmap.
  1455 * To unset the mask, set it to a null pixmap.
  1452 * 
  1456 *
  1453 * \warning Currently this method makes use of pixmap() routine in case of NVG icons. 
  1457 * \warning Currently this method makes use of pixmap() routine in case of NVG icons.
  1454 * pixmap() slows down the hardware accelerated rendering.
  1458 * pixmap() slows down the hardware accelerated rendering.
  1455 * \sa frameSize(), mask()
  1459 * \sa frameSize(), mask()
  1456 */
  1460 */
  1457 void HbFrameDrawer::setMask(const QPixmap &mask)
  1461 void HbFrameDrawer::setMask(const QPixmap &mask)
  1458 {
  1462 {
  1459     d->mask = mask;
  1463     d->mask = mask;
  1460     d->maskChanged = true;
  1464     d->maskChanged = true;
  1461 }
  1465 }
  1462 
  1466 
  1463 /*! 
  1467 /*!
  1464 * Sets the \a clipPath to be applied with the entire frame icon.
  1468 * Sets the \a clipPath to be applied with the entire frame icon.
  1465 * 
  1469 *
  1466 */
  1470 */
  1467 void HbFrameDrawer::setClipPath(const QPainterPath &clipPath)
  1471 void HbFrameDrawer::setClipPath(const QPainterPath &clipPath)
  1468 {
  1472 {
  1469     d->clipPath = clipPath;
  1473     d->clipPath = clipPath;
  1470 }
  1474 }
  1471 
  1475 
  1472 /*!
  1476 /*!
  1473 * Returns the clippath set on the frame drawer.
  1477 * Returns the clippath set on the frame drawer.
  1474 * As default, returns a empty QPainterPath.
  1478 * By default, returns a empty QPainterPath.
  1475 * \sa setClipPath()
  1479 * \sa setClipPath()
  1476 */
  1480 */
  1477 
  1481 
  1478 QPainterPath HbFrameDrawer::clipPath() const
  1482 QPainterPath HbFrameDrawer::clipPath() const
  1479 {
  1483 {
  1480     return d->clipPath;
  1484     return d->clipPath;
  1481 }
  1485 }
  1482 
  1486 
  1483 /*! 
  1487 /*!
  1484 * Sets the mask to be applied with the the entire frame icon.
  1488 * Sets the mask to be applied with the entire frame icon.
  1485 * If the mask is also a frame item, use another frame drawer to draw it.
  1489 * If the mask is also a frame item, use another frame drawer to draw it.
  1486 * Mask should be of the same size as returned by frameSize().
  1490 * Mask should be of the same size as returned by frameSize().
  1487 * To unset the mask, set it to a null bitmap.
  1491 * To unset the mask, set it to a null bitmap.
  1488 *
  1492 *
  1489  \warning Currently this method makes use of pixmap() routine in case of NVG icons. 
  1493  \warning Currently this method makes use of pixmap() routine in case of NVG icons.
  1490 * pixmap() slows down the hardware accelerated rendering.
  1494 * pixmap() slows down the hardware accelerated rendering.
  1491 *
  1495 *
  1492 *\sa frameSize(), mask()
  1496 *\sa frameSize(), mask()
  1493 */
  1497 */
  1494 void HbFrameDrawer::setMask(const QBitmap &mask)
  1498 void HbFrameDrawer::setMask(const QBitmap &mask)
  1497     d->maskChanged = true;
  1501     d->maskChanged = true;
  1498 }
  1502 }
  1499 
  1503 
  1500 /*!
  1504 /*!
  1501 * Returns the mask set on the frame drawer.
  1505 * Returns the mask set on the frame drawer.
  1502 * As default, returns a null pixmap.
  1506 * By default, returns a null pixmap.
  1503 * \sa setMask()
  1507 * \sa setMask()
  1504 */
  1508 */
  1505 
  1509 
  1506 QPixmap HbFrameDrawer::mask() const
  1510 QPixmap HbFrameDrawer::mask() const
  1507 {
  1511 {
  1509 }
  1513 }
  1510 
  1514 
  1511 
  1515 
  1512 /*!
  1516 /*!
  1513 * Returns the mask set on the frame drawer.
  1517 * Returns the mask set on the frame drawer.
  1514 * As default, returns a null bitmap.
  1518 * By default, returns a null bitmap.
  1515 * \sa setMask()
  1519 * \sa setMask()
  1516 */
  1520 */
  1517 QBitmap HbFrameDrawer::maskBitmap() const
  1521 QBitmap HbFrameDrawer::maskBitmap() const
  1518 {
  1522 {
  1519     return d->mask;
  1523     return d->mask;
  1520 }
  1524 }
  1521 /*!
  1525 /*!
  1522  * Returns the size of the entire frame icon. 
  1526  * Returns the size of the entire frame icon.
  1523  * Use this method to retrieve the correct size for a mask pixmap that can be set with method setMask().
  1527  * Use this method to retrieve the correct size for a mask pixmap that can be set with method setMask().
  1524  * If the frame graphics name, bounding rectangle or frame type have not been set, this method returns
  1528  * If the frame graphics name, bounding rectangle or frame type have not been set, this method returns
  1525  * an empty size.
  1529  * an empty size.
  1526  */
  1530  */
  1527 QSize HbFrameDrawer::frameSize() const
  1531 QSize HbFrameDrawer::frameSize() const
  1562 /*!
  1566 /*!
  1563 * Sets the layout direction of the frame drawer.
  1567 * Sets the layout direction of the frame drawer.
  1564 *
  1568 *
  1565 * Valid only when the mirroring mode is HbIcon::LayoutDirection.
  1569 * Valid only when the mirroring mode is HbIcon::LayoutDirection.
  1566 */
  1570 */
  1567 void HbFrameDrawer::setLayoutDirection( Qt::LayoutDirection direction )
  1571 void HbFrameDrawer::setLayoutDirection(Qt::LayoutDirection direction)
  1568 {
  1572 {
  1569     d->flags |= HbFrameDrawerPrivate::LayoutDirectionSet;
  1573     d->flags |= HbFrameDrawerPrivate::LayoutDirectionSet;
  1570 
  1574 
  1571     if ( d->layoutDirection != direction ) {
  1575     if (d->layoutDirection != direction) {
  1572         d->layoutDirection = direction;
  1576         d->layoutDirection = direction;
  1573         
  1577 
  1574         if ( ( d->mirroring == HbIcon::Default 
  1578         if ((d->mirroring == HbIcon::Default
  1575                && d->defaultMirroring == HbFrameDrawerPrivate::Enabled ) ||
  1579                 && d->defaultMirroring == HbFrameDrawerPrivate::Enabled) ||
  1576             d->mirroring == HbIcon::LayoutDirection) {
  1580                 d->mirroring == HbIcon::LayoutDirection) {
  1577 
  1581 
  1578             d->reset( false );
  1582             d->reset(false);
  1579         }
  1583         }
  1580     }
  1584     }
  1581 }
  1585 }
  1582 
  1586 
  1583 /*!
  1587 /*!
  1584 * Sets the \a item which is needs to be redrawn when the frame drawer
  1588 * Sets the \a item which is needs to be redrawn when the frame drawer
  1585 * needs re-paint. 
  1589 * needs re-paint.
  1586 */
  1590 */
  1587 void HbFrameDrawer::setGraphicsItem( QGraphicsItem *item )
  1591 void HbFrameDrawer::setGraphicsItem(QGraphicsItem *item)
  1588 {
  1592 {
  1589     d->graphicsItem = item;
  1593     d->graphicsItem = item;
  1590 }
  1594 }
  1591 
  1595 
  1592 /*!
  1596 /*!