src/hbcore/image/hbframedrawer.cpp
branchGCC_SURGE
changeset 15 f378acbc9cfb
parent 6 c3690ec91ef8
child 28 b7da29130b0e
child 34 ed14f46c0e55
equal deleted inserted replaced
9:730c025d4b77 15:f378acbc9cfb
    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 #include <hbthemeutils_p.h>
    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     if (HbThemeUtils::isLogicalName(frameGraphicsName)) {
   204     int index = this->frameGraphicsName.lastIndexOf(QChar('.'));
   205         // Remove possible file extension
   205     if (index>0) {
   206         int index = this->frameGraphicsName.lastIndexOf(QChar('.'));
   206         this->frameGraphicsName.resize(index);
   207         if (index>0) {
   207     }
   208             this->frameGraphicsName.resize(index);
       
   209         }
       
   210     }
       
   211 
   208     //Register the HbFrameDrawerPrivate Instance to HbIconLoader
   212     //Register the HbFrameDrawerPrivate Instance to HbIconLoader
   209     HbIconLoader::global()->storeFrameDrawerInfo(this);
   213     HbIconLoader::global()->storeFrameDrawerInfo(this);
   210 }
   214 }
   211 
   215 
   212 /*!
   216 /*!
   219     rect(other.rect),
   223     rect(other.rect),
   220     mask(QPixmap()),
   224     mask(QPixmap()),
   221     frameParts(other.frameParts),
   225     frameParts(other.frameParts),
   222     mirroring(other.mirroring),
   226     mirroring(other.mirroring),
   223     defaultMirroring(other.defaultMirroring),
   227     defaultMirroring(other.defaultMirroring),
   224     flags( other.flags ),
   228     flags(other.flags),
   225     layoutDirection( other.layoutDirection ),
   229     layoutDirection(other.layoutDirection),
   226     graphicsItem( other.graphicsItem ),
   230     graphicsItem(other.graphicsItem),
   227     color(other.color),
   231     color(other.color),
   228     icon(0),
   232     icon(0),
   229     maskChanged(false),
   233     maskChanged(false),
   230     clipPath(QPainterPath())
   234     clipPath(QPainterPath())
   231 {
   235 {
   232     borderWidths[0]=other.borderWidths[0];
   236     borderWidths[0] = other.borderWidths[0];
   233     borderWidths[1]=other.borderWidths[1];
   237     borderWidths[1] = other.borderWidths[1];
   234     borderWidths[2]=other.borderWidths[2];
   238     borderWidths[2] = other.borderWidths[2];
   235     borderWidths[3]=other.borderWidths[3];
   239     borderWidths[3] = other.borderWidths[3];
   236     //Register the HbFrameDrawerPrivate Instance to HbIconLoader
   240     //Register the HbFrameDrawerPrivate Instance to HbIconLoader
   237     HbIconLoader::global()->storeFrameDrawerInfo(this);
   241     HbIconLoader::global()->storeFrameDrawerInfo(this);
   238 }
   242 }
   239 
   243 
   240 /*!
   244 /*!
   253 void HbFrameDrawerPrivate::prepareFrameIcon()
   257 void HbFrameDrawerPrivate::prepareFrameIcon()
   254 {
   258 {
   255     if (!frameParts) {
   259     if (!frameParts) {
   256         checkFrameParts();
   260         checkFrameParts();
   257     }
   261     }
   258     if ((!icon ) && (!fallbackMaskableIconList.count()) ) {
   262     if ((!icon) && (!fallbackMaskableIconList.count())) {
   259         createFrameIcon();
   263         createFrameIcon();
   260     }
   264     }
   261 }
   265 }
   262 
   266 
   263 /*!
   267 /*!
   265 *
   269 *
   266 * \sa HbFrameDrawerPrivate::setBorderApiProtectionFlag()
   270 * \sa HbFrameDrawerPrivate::setBorderApiProtectionFlag()
   267 */
   271 */
   268 bool HbFrameDrawerPrivate::testBorderApiProtectionFlag() const
   272 bool HbFrameDrawerPrivate::testBorderApiProtectionFlag() const
   269 {
   273 {
   270 	return flags & HbFrameDrawerPrivate::BorderWidthSetByApi;
   274     return flags & HbFrameDrawerPrivate::BorderWidthSetByApi;
   271 }
   275 }
   272 
   276 
   273 /*!
   277 /*!
   274 * Clears the flag denoting that the border widths have been set by API.
   278 * 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.
   279 * This will cause control of border widths to return to the CSS system.
   276 *
   280 *
   277 * \sa HbFrameDrawerPrivate::testBorderApiProtectionFlag()
   281 * \sa HbFrameDrawerPrivate::testBorderApiProtectionFlag()
   278 */
   282 */
   279 void HbFrameDrawerPrivate::setBorderApiProtectionFlag(bool on)
   283 void HbFrameDrawerPrivate::setBorderApiProtectionFlag(bool on)
   280 {
   284 {
   281 	if(on){
   285     if (on) {
   282 		flags |= HbFrameDrawerPrivate::BorderWidthSetByApi;
   286         flags |= HbFrameDrawerPrivate::BorderWidthSetByApi;
   283 	}else{
   287     } else {
   284 		flags &= ~HbFrameDrawerPrivate::BorderWidthSetByApi;
   288         flags &= ~HbFrameDrawerPrivate::BorderWidthSetByApi;
   285 	}
   289     }
   286 }
   290 }
   287 
   291 
   288 /*!
   292 /*!
   289 * Checks whether all the frame parts are available for the given frame type.
   293 * Checks whether all the frame parts are available for the given frame type.
   290 * Fallback is 1-part frame rendering.
   294 * Fallback is 1-part frame rendering.
   312 QStringList HbFrameDrawerPrivate::fileNameSuffixList() const
   316 QStringList HbFrameDrawerPrivate::fileNameSuffixList() const
   313 {
   317 {
   314     // If the suffix list has been set explicitly, return that if it contains enough suffixes.
   318     // If the suffix list has been set explicitly, return that if it contains enough suffixes.
   315     if (!suffixList.isEmpty()) {
   319     if (!suffixList.isEmpty()) {
   316         switch (type) {
   320         switch (type) {
   317             case HbFrameDrawer::ThreePiecesHorizontal: // fall through
   321         case HbFrameDrawer::ThreePiecesHorizontal: // fall through
   318             case HbFrameDrawer::ThreePiecesVertical:
   322         case HbFrameDrawer::ThreePiecesVertical:
   319                 if (suffixList.count() >= 3) {
   323             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;
   324                 return suffixList;
   332         }
   325             }
   333     } 
   326             break;
       
   327 
       
   328         case HbFrameDrawer::NinePieces:
       
   329             if (suffixList.count() >= 9) {
       
   330                 return suffixList;
       
   331             }
       
   332             break;
       
   333 
       
   334         default:
       
   335             return suffixList;
       
   336         }
       
   337     }
   334 
   338 
   335     // Otherwise, return default suffix list.
   339     // Otherwise, return default suffix list.
   336     QStringList list;
   340     QStringList list;
   337 
   341 
   338     switch (type) {
   342     switch (type) {
   339         case HbFrameDrawer::ThreePiecesHorizontal:
   343     case HbFrameDrawer::ThreePiecesHorizontal:
   340             list << "_l" << "_c" << "_r";
   344         list << "_l" << "_c" << "_r";
   341             break;
   345         break;
   342         case HbFrameDrawer::ThreePiecesVertical:
   346     case HbFrameDrawer::ThreePiecesVertical:
   343             list << "_t" << "_c" << "_b";
   347         list << "_t" << "_c" << "_b";
   344             break;
   348         break;
   345         case HbFrameDrawer::NinePieces:
   349     case HbFrameDrawer::NinePieces:
   346             list << "_tl" << "_t" << "_tr" << "_l" << "_c" << "_r" << "_bl" << "_b" << "_br";
   350         list << "_tl" << "_t" << "_tr" << "_l" << "_c" << "_r" << "_bl" << "_b" << "_br";
   347             break;
   351         break;
   348         default:
   352     default:
   349             break;
   353         break;
   350     }
   354     }
   351 
   355 
   352     return list;
   356     return list;
   353 }
   357 }
   354 
   358 
   355 /*!
   359 /*!
   356 * Creates a consolidated HbIconImpl (Icon) with the available piece information 
   360 * Creates a consolidated HbIconImpl (Icon) with the available piece information
   357 * If failed to create the same, then creates HbIconImpls for the pieces.
   361 * If failed to create the same, then creates HbIconImpls for the pieces.
   358 * \internal
   362 * \internal
   359 */
   363 */
   360 void HbFrameDrawerPrivate::createFrameIcon()
   364 void HbFrameDrawerPrivate::createFrameIcon()
   361 {
   365 {
   365     data.multiPartIconId = multiPartIconId();
   369     data.multiPartIconId = multiPartIconId();
   366     multiPartSizeData = data;
   370     multiPartSizeData = data;
   367 
   371 
   368     // Create the frame icon and add it in the icon cache
   372     // Create the frame icon and add it in the icon cache
   369     HbIconLoader *loader = HbIconLoader::global();
   373     HbIconLoader *loader = HbIconLoader::global();
   370     
   374 
   371     //If it's one-piece frame-item, it's loaded using HbIconLoader::loadIcon()
   375     //If it's one-piece frame-item, it's loaded using HbIconLoader::loadIcon()
   372     if (frameParts == 1) {
   376     if (frameParts == 1) {
   373         HbIconImpl * iconImpl =  loader->loadIcon(frameGraphicsName, HbIconLoader::AnyType,
   377         HbIconImpl *iconImpl =  loader->loadIcon(frameGraphicsName, HbIconLoader::AnyType,
   374                                  HbIconLoader::AnyPurpose,
   378                                 HbIconLoader::AnyPurpose,
   375                                  frameIconSize,
   379                                 frameIconSize,
   376                                  Qt::IgnoreAspectRatio,
   380                                 Qt::IgnoreAspectRatio,
   377                                  QIcon::Normal,
   381                                 QIcon::Normal,
   378                                  iconLoaderOptions());
   382                                 iconLoaderOptions());
   379         if (iconImpl) {
   383         if (iconImpl) {
   380             icon = new HbMaskableIconImpl(iconImpl);
   384             icon = new HbMaskableIconImpl(iconImpl);
   381         }
   385         }
   382 
   386 
   383     } else {
   387     } else {
   384         QStringList multiPieceFileNames;
   388         QStringList multiPieceFileNames = resolveMultiPieceFileNames();
   385         QStringList list = fileNameSuffixList();
   389         
   386         int nameListCount = list.count();
   390         for (int i = 0; i < frameParts; i++) {
   387         for (int i = 0; i < nameListCount; i++) {
       
   388             multiPieceFileNames.append(frameGraphicsName + list[i]);
       
   389             if (data.pixmapSizes[i].isEmpty()) {
   391             if (data.pixmapSizes[i].isEmpty()) {
   390                 data.pixmapSizes[i] = QSize(0,0);
   392                 data.pixmapSizes[i] = QSize(0, 0);
   391             }
   393             }
   392         }
   394         }
   393 
   395 
   394         QVector<HbIconImpl *> listOfIcons;
   396         QVector<HbIconImpl *> listOfIcons;
   395         
   397 
   396         //For multi-piece frame-items, HbIocnLoader::loadMultipieceIcon is used
   398         //For multi-piece frame-items, HbIocnLoader::loadMultipieceIcon is used
   397         //This function returns the consolidate (stitched) icon created on the themeserver.
   399         //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
   400         //If the consolidated icon-creation on themeserver fails, then server returns a list
   399         //of individual frame-items.
   401         //of individual frame-items.
   400         HbIconImpl * iconImpl = loader->loadMultiPieceIcon(multiPieceFileNames, data, frameIconSize,
   402         HbIconImpl *iconImpl = loader->loadMultiPieceIcon(multiPieceFileNames, data, frameIconSize,
   401                                           Qt::IgnoreAspectRatio, QIcon::Normal, iconLoaderOptions(),
   403                                Qt::IgnoreAspectRatio, QIcon::Normal, iconLoaderOptions(),
   402                                           listOfIcons, color);
   404                                listOfIcons, color);
   403 
   405 
   404         if (iconImpl) {
   406         if (iconImpl) {
   405             icon = new HbMaskableIconImpl(iconImpl);
   407             icon = new HbMaskableIconImpl(iconImpl);
   406         } else {
   408         } else {
   407             int implCount = listOfIcons.count();
   409             int implCount = listOfIcons.count();
   408             for (int i = 0; i < implCount; i++) {
   410             for (int i = 0; i < implCount; i++) {
   409                 fallbackMaskableIconList.append(new HbMaskableIconImpl(listOfIcons[i]));
   411                 fallbackMaskableIconList.append(new HbMaskableIconImpl(listOfIcons[i]));
   410             }
   412             }
   411         }
   413         }
   412  
   414 
   413     }
   415     }
       
   416 }
       
   417 
       
   418 QStringList HbFrameDrawerPrivate::resolveMultiPieceFileNames()
       
   419 {
       
   420     QStringList multiPieceFileNames;
       
   421 
       
   422     bool logicalName = HbThemeUtils::isLogicalName(frameGraphicsName);
       
   423 
       
   424     int suffixIndex = frameGraphicsName.length();
       
   425     if (!logicalName) {
       
   426         // If it is an absolute icon path, the suffix is inserted before the file extension
       
   427         int index = frameGraphicsName.lastIndexOf(QChar('.'));
       
   428         if (index > 0) {
       
   429             suffixIndex = index;
       
   430         }
       
   431     }
       
   432 
       
   433     QStringList list = fileNameSuffixList();
       
   434     int count = list.count();
       
   435     for (int i = 0; i < count; i++) {
       
   436         QString nameWithSuffix = frameGraphicsName;
       
   437         nameWithSuffix.insert(suffixIndex, list.at(i));
       
   438         multiPieceFileNames.append(nameWithSuffix);
       
   439     }
       
   440 
       
   441     return multiPieceFileNames;
   414 }
   442 }
   415 
   443 
   416 /*!
   444 /*!
   417 \internal
   445 \internal
   418 */
   446 */
   434             centeredRect.setHeight(size.height());
   462             centeredRect.setHeight(size.height());
   435         }
   463         }
   436 
   464 
   437         if (!mask.isNull() && maskChanged) {
   465         if (!mask.isNull() && maskChanged) {
   438             icon->setMask(mask);
   466             icon->setMask(mask);
   439         } 
   467         }
   440         //paint the stitched icon
   468         //paint the stitched icon
   441         icon->paint(painter, centeredRect, Qt::AlignHCenter, clipPath);
   469         icon->paint(painter, centeredRect, Qt::AlignHCenter, clipPath);
   442         if ( icon->isCreatedOnServer() ) {
   470         if (icon->isCreatedOnServer()) {
   443             iconType = icon->iconImpl()->iconData().type;
   471             iconType = icon->iconImpl()->iconData().type;
   444         }
   472         }
   445 
   473 
   446         #ifdef HB_FRAME_DRAWER_TRACES
   474 #ifdef HB_FRAME_DRAWER_TRACES
   447         qDebug() << "FRAMENAME: " << frameGraphicsName << "Drawn at: "
   475         qDebug() << "FRAMENAME: " << frameGraphicsName << "Drawn at: "
   448         << centeredRect.topLeft().x() << "," << centeredRect.topLeft().y() << " | "
   476                  << centeredRect.topLeft().x() << "," << centeredRect.topLeft().y() << " | "
   449         << centeredRect.bottomRight().x() << "," << centeredRect.bottomRight().y();
   477                  << centeredRect.bottomRight().x() << "," << centeredRect.bottomRight().y();
   450         #endif
   478 #endif
   451     } else {
   479     } else {
   452         for (int i = 0; i < fileNameSuffixList().count(); i++) {
   480         for (int i = 0; i < fileNameSuffixList().count(); i++) {
   453             if (i < fallbackMaskableIconList.count() && fallbackMaskableIconList[i]) {
   481             if (i < fallbackMaskableIconList.count() && fallbackMaskableIconList[i]) {
   454                 QPoint position = multiPartSizeData.targets[i].topLeft();
   482                 QPoint position = multiPartSizeData.targets[i].topLeft();
   455                 if (isMirrored()) {
   483                 if (isMirrored()) {
   467                     pieceMask = mask.copy(maskRect);
   495                     pieceMask = mask.copy(maskRect);
   468                     fallbackMaskableIconList[i]->setMask(pieceMask);
   496                     fallbackMaskableIconList[i]->setMask(pieceMask);
   469                 }
   497                 }
   470                 if (!multiPartSizeData.targets[i].isEmpty()) {
   498                 if (!multiPartSizeData.targets[i].isEmpty()) {
   471                     fallbackMaskableIconList[i]->paint(painter,
   499                     fallbackMaskableIconList[i]->paint(painter,
   472                             QRect(position, multiPartSizeData.pixmapSizes[i]),
   500                                                        QRect(position, multiPartSizeData.pixmapSizes[i]),
   473                             Qt::AlignHCenter, clipPath);
   501                                                        Qt::AlignHCenter, clipPath);
   474                 }
   502                 }
   475             }
   503             }
   476         }
   504         }
   477         if ( fallbackMaskableIconList[0]->iconImpl()
   505         if ( fallbackMaskableIconList.count() && fallbackMaskableIconList[0]->iconImpl()
   478              && fallbackMaskableIconList[0]->iconImpl()->isCreatedOnServer() ) {
   506              && fallbackMaskableIconList[0]->iconImpl()->isCreatedOnServer() ) {
   479             if ( fallbackMaskableIconList[0]->iconImpl()->iconData().type != INVALID_FORMAT ) {
   507             if ( fallbackMaskableIconList[0]->iconImpl()->iconData().type != INVALID_FORMAT ) {
   480                 // store the icon type
   508                 // store the icon type
   481                 iconType = fallbackMaskableIconList[0]->iconImpl()->iconData().type;
   509                 iconType = fallbackMaskableIconList[0]->iconImpl()->iconData().type;
   482             }
   510             }
   486 }
   514 }
   487 
   515 
   488 /*!
   516 /*!
   489 \internal
   517 \internal
   490 */
   518 */
   491 bool HbFrameDrawerPrivate::fillWholeRect() const 
   519 bool HbFrameDrawerPrivate::fillWholeRect() const
   492 {
   520 {
   493     return flags & HbFrameDrawerPrivate::FillWholeRect;
   521     return flags & HbFrameDrawerPrivate::FillWholeRect;
   494 }
   522 }
   495 
   523 
   496 /*!
   524 /*!
   497 * Calculates frame part rectangles and icon sizes based on the following information.
   525 * Calculates frame part rectangles and icon sizes based on the following information.
   498 * - frame bounding rectangle
   526 * - frame bounding rectangle
   499 * - frame inner rectangle (optional)
   527 * - frame inner rectangle (optional)
   500 * - default sizes of the frame corner (9-piece) or side (3-piece) graphics.
   528 * - default sizes of the frame corner (9-piece) or side (3-piece) graphics.
   501 * 
   529 *
   502 * Note! Integer pixel sizes are used in this function to avoid one pixel gaps between the frame parts.
   530 * Note! Integer pixel sizes are used in this function to avoid one pixel gaps between the frame parts.
   503 * \internal
   531 * \internal
   504 */
   532 */
   505 QSize HbFrameDrawerPrivate::divideSpace(HbMultiPartSizeData &data)
   533 QSize HbFrameDrawerPrivate::divideSpace(HbMultiPartSizeData &data)
   506 {
   534 {
   535         int rightWidth;
   563         int rightWidth;
   536 
   564 
   537         if (borderWidths[0] == 0 && borderWidths[2] == 0) {
   565         if (borderWidths[0] == 0 && borderWidths[2] == 0) {
   538             QSizeF leftSize = defaultSize(suffixList.at(0)); // index 0 is leftmost frame part
   566             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
   567             QSizeF rightSize = defaultSize(suffixList.at(2)); // index 2 is rightmost frame part
   540             
   568 
   541             if (fillWholeRect()) {
   569             if (fillWholeRect()) {
   542                 leftSize.scale(rect.size(), Qt::KeepAspectRatio);
   570                 leftSize.scale(rect.size(), Qt::KeepAspectRatio);
   543                 rightSize.scale(rect.size(), Qt::KeepAspectRatio);
   571                 rightSize.scale(rect.size(), Qt::KeepAspectRatio);
   544             } else {
   572             } else {
   545                 int leftHeight = leftSize.toSize().height();
   573                 int leftHeight = leftSize.toSize().height();
   571 
   599 
   572         // Do all 3 pieces fit?
   600         // Do all 3 pieces fit?
   573         if (fullWidth >= leftWidth + rightWidth) {
   601         if (fullWidth >= leftWidth + rightWidth) {
   574             data.targets[0] = QRect(0, 0, leftWidth, fullHeight);
   602             data.targets[0] = QRect(0, 0, leftWidth, fullHeight);
   575             data.targets[1] = QRect(leftWidth, 0, centerWidth, fullHeight);
   603             data.targets[1] = QRect(leftWidth, 0, centerWidth, fullHeight);
   576             data.targets[2] = QRect(fullWidth-rightWidth, 0, rightWidth, fullHeight);
   604             data.targets[2] = QRect(fullWidth - rightWidth, 0, rightWidth, fullHeight);
   577 
   605 
   578             data.pixmapSizes[0] = QSize(leftWidth, fullHeight);
   606             data.pixmapSizes[0] = QSize(leftWidth, fullHeight);
   579             data.pixmapSizes[1] = QSize(centerWidth, fullHeight);
   607             data.pixmapSizes[1] = QSize(centerWidth, fullHeight);
   580             data.pixmapSizes[2] = QSize(rightWidth, fullHeight);
   608             data.pixmapSizes[2] = QSize(rightWidth, fullHeight);
   581 
   609 
   582             data.sources[0] = QRect(QPoint(0,0), data.pixmapSizes[0]);
   610             data.sources[0] = QRect(QPoint(0, 0), data.pixmapSizes[0]);
   583             data.sources[1] = QRect(QPoint(0,0), data.pixmapSizes[1]);
   611             data.sources[1] = QRect(QPoint(0, 0), data.pixmapSizes[1]);
   584             data.sources[2] = QRect(QPoint(0,0), data.pixmapSizes[2]);
   612             data.sources[2] = QRect(QPoint(0, 0), data.pixmapSizes[2]);
   585         } else {
   613         } else {
   586             // Only sides fit
   614             // Only sides fit
   587             int totalSideWidth = leftWidth + rightWidth;
   615             int totalSideWidth = leftWidth + rightWidth;
   588             data.targets[0] = QRect(0, 0, leftWidth * fullWidth / totalSideWidth, fullHeight);
   616             data.targets[0] = QRect(0, 0, leftWidth * fullWidth / totalSideWidth, fullHeight);
   589             data.targets[1] = QRect();
   617             data.targets[1] = QRect();
   604         int bottomHeight;
   632         int bottomHeight;
   605 
   633 
   606         if (borderWidths[1] == 0 && borderWidths[3] == 0) {
   634         if (borderWidths[1] == 0 && borderWidths[3] == 0) {
   607             QSizeF topSize = defaultSize(suffixList.at(0)); // index 0 is top frame part
   635             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
   636             QSizeF bottomSize = defaultSize(suffixList.at(2)); // index 2 is bottom frame part
   609             
   637 
   610             if (fillWholeRect()) {
   638             if (fillWholeRect()) {
   611                 topSize.scale(rect.size(), Qt::KeepAspectRatio);
   639                 topSize.scale(rect.size(), Qt::KeepAspectRatio);
   612                 bottomSize.scale(rect.size(), Qt::KeepAspectRatio);
   640                 bottomSize.scale(rect.size(), Qt::KeepAspectRatio);
   613             } else {
   641             } else {
   614                 int topWidth = topSize.toSize().width();
   642                 int topWidth = topSize.toSize().width();
   645 
   673 
   646             data.pixmapSizes[0] = QSize(fullWidth, topHeight);
   674             data.pixmapSizes[0] = QSize(fullWidth, topHeight);
   647             data.pixmapSizes[1] = QSize(fullWidth, centerHeight);
   675             data.pixmapSizes[1] = QSize(fullWidth, centerHeight);
   648             data.pixmapSizes[2] = QSize(fullWidth, bottomHeight);
   676             data.pixmapSizes[2] = QSize(fullWidth, bottomHeight);
   649 
   677 
   650             data.sources[0] = QRect(QPoint(0,0), data.pixmapSizes[0]);
   678             data.sources[0] = QRect(QPoint(0, 0), data.pixmapSizes[0]);
   651             data.sources[1] = QRect(QPoint(0,0), data.pixmapSizes[1]);
   679             data.sources[1] = QRect(QPoint(0, 0), data.pixmapSizes[1]);
   652             data.sources[2] = QRect(QPoint(0,0), data.pixmapSizes[2]);
   680             data.sources[2] = QRect(QPoint(0, 0), data.pixmapSizes[2]);
   653         } else {
   681         } else {
   654             // Only sides fit
   682             // Only sides fit
   655             int totalSideHeight = topHeight + bottomHeight;
   683             int totalSideHeight = topHeight + bottomHeight;
   656             data.targets[0] = QRect(0, 0, fullWidth, topHeight * fullHeight / totalSideHeight);
   684             data.targets[0] = QRect(0, 0, fullWidth, topHeight * fullHeight / totalSideHeight);
   657             data.targets[1] = QRect();
   685             data.targets[1] = QRect();
   658             data.targets[2] = QRect(0, data.targets[0].height(), fullWidth, fullHeight - data.targets[0].height());
   686             data.targets[2] = QRect(0, data.targets[0].height(), fullWidth, fullHeight - data.targets[0].height());
   659 
   687 
   660             data.pixmapSizes[0] = QSize(fullWidth,data.targets[0].height());
   688             data.pixmapSizes[0] = QSize(fullWidth, data.targets[0].height());
   661             data.pixmapSizes[1] = QSize();
   689             data.pixmapSizes[1] = QSize();
   662             data.pixmapSizes[2] = QSize(fullWidth,data.targets[2].height());
   690             data.pixmapSizes[2] = QSize(fullWidth, data.targets[2].height());
   663 
   691 
   664             data.sources[0] = data.targets[0];
   692             data.sources[0] = data.targets[0];
   665             data.sources[1] = QRect();
   693             data.sources[1] = QRect();
   666             data.sources[2] = data.targets[2];
   694             data.sources[2] = data.targets[2];
   667             data.sources[2].moveTop(data.pixmapSizes[2].height() - data.targets[2].height());
   695             data.sources[2].moveTop(data.pixmapSizes[2].height() - data.targets[2].height());
   679             brSize = QSizeF(borderWidths[2], borderWidths[3]).toSize();
   707             brSize = QSizeF(borderWidths[2], borderWidths[3]).toSize();
   680         }
   708         }
   681 
   709 
   682         // Do all 9 pieces fit?
   710         // Do all 9 pieces fit?
   683         if (fullWidth >= tlSize.width() + brSize.width() &&
   711         if (fullWidth >= tlSize.width() + brSize.width() &&
   684             fullHeight >= tlSize.height() + brSize.height()) {
   712                 fullHeight >= tlSize.height() + brSize.height()) {
   685 
   713 
   686             int centerWidth = fullWidth - tlSize.width() - brSize.width();
   714             int centerWidth = fullWidth - tlSize.width() - brSize.width();
   687             int centerHeight = fullHeight - tlSize.height() - brSize.height();
   715             int centerHeight = fullHeight - tlSize.height() - brSize.height();
   688 
   716 
   689             data.targets[0] = QRect(0, 0, tlSize.width(), tlSize.height());
   717             data.targets[0] = QRect(0, 0, tlSize.width(), tlSize.height());
   704             data.pixmapSizes[5] = data.targets[5].size();
   732             data.pixmapSizes[5] = data.targets[5].size();
   705             data.pixmapSizes[6] = data.targets[6].size();
   733             data.pixmapSizes[6] = data.targets[6].size();
   706             data.pixmapSizes[7] = data.targets[7].size();
   734             data.pixmapSizes[7] = data.targets[7].size();
   707             data.pixmapSizes[8] = data.targets[8].size();
   735             data.pixmapSizes[8] = data.targets[8].size();
   708 
   736 
   709             data.sources[0] = QRect(QPoint(0,0), data.pixmapSizes[0]);
   737             data.sources[0] = QRect(QPoint(0, 0), data.pixmapSizes[0]);
   710             data.sources[1] = QRect(QPoint(0,0), data.pixmapSizes[1]);
   738             data.sources[1] = QRect(QPoint(0, 0), data.pixmapSizes[1]);
   711             data.sources[2] = QRect(QPoint(0,0), data.pixmapSizes[2]);
   739             data.sources[2] = QRect(QPoint(0, 0), data.pixmapSizes[2]);
   712             data.sources[3] = QRect(QPoint(0,0), data.pixmapSizes[3]);
   740             data.sources[3] = QRect(QPoint(0, 0), data.pixmapSizes[3]);
   713             data.sources[4] = QRect(QPoint(0,0), data.pixmapSizes[4]);
   741             data.sources[4] = QRect(QPoint(0, 0), data.pixmapSizes[4]);
   714             data.sources[5] = QRect(QPoint(0,0), data.pixmapSizes[5]);
   742             data.sources[5] = QRect(QPoint(0, 0), data.pixmapSizes[5]);
   715             data.sources[6] = QRect(QPoint(0,0), data.pixmapSizes[6]);
   743             data.sources[6] = QRect(QPoint(0, 0), data.pixmapSizes[6]);
   716             data.sources[7] = QRect(QPoint(0,0), data.pixmapSizes[7]);
   744             data.sources[7] = QRect(QPoint(0, 0), data.pixmapSizes[7]);
   717             data.sources[8] = QRect(QPoint(0,0), data.pixmapSizes[8]);
   745             data.sources[8] = QRect(QPoint(0, 0), data.pixmapSizes[8]);
   718 
   746 
   719         } else {
   747         } else {
   720             // All 9 pieces do not fit.
   748             // 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.
   749             // 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();
   750             int totalCornerWidth = tlSize.width() + brSize.width();
   733             if (totalCornerHeight > fullHeight) {
   761             if (totalCornerHeight > fullHeight) {
   734                 splitPointY = tlSize.height() * fullHeight / totalCornerHeight;
   762                 splitPointY = tlSize.height() * fullHeight / totalCornerHeight;
   735             }
   763             }
   736 
   764 
   737             calculateShrinkedNinePieceCorners(
   765             calculateShrinkedNinePieceCorners(
   738                     data, tlSize, brSize,
   766                 data, tlSize, brSize,
   739                     QSize(fullWidth, fullHeight), QPoint(splitPointX, splitPointY));
   767                 QSize(fullWidth, fullHeight), QPoint(splitPointX, splitPointY));
   740 
   768 
   741             // Left and right get drawn if corners height does not cover the total height
   769             // Left and right get drawn if corners height does not cover the total height
   742             if (!splitPointY) {
   770             if (!splitPointY) {
   743                 data.targets[3] = QRect(0, data.targets[0].height(), data.targets[0].width(), fullHeight - tlSize.height() - brSize.height());
   771                 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());
   772                 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();
   796             data.pixmapSizes[6] = data.targets[6].size();
   769             data.pixmapSizes[7] = data.targets[7].size();
   797             data.pixmapSizes[7] = data.targets[7].size();
   770             data.pixmapSizes[8] = data.targets[8].size();
   798             data.pixmapSizes[8] = data.targets[8].size();
   771 
   799 
   772             data.sources[0] = data.targets[0];
   800             data.sources[0] = data.targets[0];
   773             data.sources[1] = QRect(QPoint(0,0), data.pixmapSizes[1]);
   801             data.sources[1] = QRect(QPoint(0, 0), data.pixmapSizes[1]);
   774             data.sources[2] = QRect(QPoint(0,0), data.pixmapSizes[2]);
   802             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));
   803             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]);
   804             data.sources[3] = QRect(QPoint(0, 0), data.pixmapSizes[3]);
   777             data.sources[4] = QRect(); // center is always empty
   805             data.sources[4] = QRect(); // center is always empty
   778             data.sources[5] = QRect(QPoint(0,0), data.pixmapSizes[5]);
   806             data.sources[5] = QRect(QPoint(0, 0), data.pixmapSizes[5]);
   779             data.sources[6] = QRect(QPoint(0,0), data.pixmapSizes[6]);
   807             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()));
   808             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]);
   809             data.sources[7] = QRect(QPoint(0, 0), data.pixmapSizes[7]);
   782             data.sources[8] = QRect(QPoint(0,0), data.pixmapSizes[8]);
   810             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()));
   811             data.sources[8].setTopLeft(QPoint(data.pixmapSizes[8].width() - data.targets[8].width(), data.pixmapSizes[8].height() - data.targets[8].height()));
   784         }
   812         }
   785     }
   813     }
   786 
   814 
   787 #ifdef HB_FRAME_DRAWER_TRACES
   815 #ifdef HB_FRAME_DRAWER_TRACES
   794 
   822 
   795 /*!
   823 /*!
   796 \internal
   824 \internal
   797 */
   825 */
   798 void HbFrameDrawerPrivate::calculateShrinkedNinePieceCorners(
   826 void HbFrameDrawerPrivate::calculateShrinkedNinePieceCorners(
   799         HbMultiPartSizeData &data,
   827     HbMultiPartSizeData &data,
   800         const QSize& tlSize, const QSize& brSize,
   828     const QSize &tlSize, const QSize &brSize,
   801         const QSize& fullSize, const QPoint& splitPoint)
   829     const QSize &fullSize, const QPoint &splitPoint)
   802 {
   830 {
   803     // Make sure that corner sizes don't exceed frames full size
   831     // Make sure that corner sizes don't exceed frames full size
   804 
   832 
   805     // Top-left corner
   833     // Top-left corner
   806     int topLeftWidth = splitPoint.x() ? splitPoint.x() : tlSize.width();
   834     int topLeftWidth = splitPoint.x() ? splitPoint.x() : tlSize.width();
   807     int topLeftHeight = splitPoint.y() ? splitPoint.y() : tlSize.height();
   835     int topLeftHeight = splitPoint.y() ? splitPoint.y() : tlSize.height();
   808     data.targets[0] = QRect(
   836     data.targets[0] = QRect(
   809         0,
   837                           0,
   810         0,
   838                           0,
   811         topLeftWidth < fullSize.width() ? topLeftWidth : fullSize.width(),
   839                           topLeftWidth < fullSize.width() ? topLeftWidth : fullSize.width(),
   812         topLeftHeight < fullSize.height() ? topLeftHeight : fullSize.height());
   840                           topLeftHeight < fullSize.height() ? topLeftHeight : fullSize.height());
   813 
   841 
   814     // Top-right corner
   842     // Top-right corner
   815     int topRightX = splitPoint.x() ? splitPoint.x() : fullSize.width() - brSize.width();
   843     int topRightX = splitPoint.x() ? splitPoint.x() : fullSize.width() - brSize.width();
   816     int topRightWidth = splitPoint.x() ? fullSize.width() - splitPoint.x() : brSize.width();
   844     int topRightWidth = splitPoint.x() ? fullSize.width() - splitPoint.x() : brSize.width();
   817     if (topRightWidth > fullSize.width()) {
   845     if (topRightWidth > fullSize.width()) {
   848     int bottomRightHeight = splitPoint.y() ? fullSize.height() - splitPoint.y() : brSize.height();
   876     int bottomRightHeight = splitPoint.y() ? fullSize.height() - splitPoint.y() : brSize.height();
   849     if (bottomRightHeight > fullSize.height()) {
   877     if (bottomRightHeight > fullSize.height()) {
   850         bottomRightHeight = fullSize.height();
   878         bottomRightHeight = fullSize.height();
   851         bottomRightY = 0;
   879         bottomRightY = 0;
   852     }
   880     }
   853     data.targets[8] = QRect( bottomRightX, bottomRightY, bottomRightWidth, bottomRightHeight);
   881     data.targets[8] = QRect(bottomRightX, bottomRightY, bottomRightWidth, bottomRightHeight);
   854 }
   882 }
   855 
   883 
   856 /*!
   884 /*!
   857 \internal
   885 \internal
   858 */
   886 */
   859 QSizeF HbFrameDrawerPrivate::defaultSize(const QString &framePartSuffix)
   887 QSizeF HbFrameDrawerPrivate::defaultSize(const QString &framePartSuffix)
   860 {
   888 {
   861     HbIconLoader *loader = HbIconLoader::global();
   889     HbIconLoader *loader = HbIconLoader::global();
   862     return loader->defaultSize(frameGraphicsName + framePartSuffix).toSize();
   890     
       
   891     QString nameWithSuffix = frameGraphicsName;
       
   892     if (HbThemeUtils::isLogicalName(frameGraphicsName)) {
       
   893         // Logical icon name, append suffix in the end
       
   894         nameWithSuffix.append(framePartSuffix);
       
   895     } else {
       
   896         // Absolute icon path, insert suffix before file extension
       
   897         int index = this->frameGraphicsName.lastIndexOf(QChar('.'));
       
   898         if (index > 0) {
       
   899             nameWithSuffix.insert(index, framePartSuffix);
       
   900         }
       
   901     }
       
   902 
       
   903     return loader->defaultSize(nameWithSuffix).toSize();
   863 }
   904 }
   864 
   905 
   865 bool HbFrameDrawerPrivate::isMirrored()
   906 bool HbFrameDrawerPrivate::isMirrored()
   866 {
   907 {
   867     // If mirroring mode is default, check automatic mirroring from loader.
   908     // If mirroring mode is default, check automatic mirroring from loader.
   878         if (defaultMirroring == Enabled) {
   919         if (defaultMirroring == Enabled) {
   879             basedOnLayoutDir = true;
   920             basedOnLayoutDir = true;
   880         } else if (defaultMirroring == Disabled) {
   921         } else if (defaultMirroring == Disabled) {
   881             return false;
   922             return false;
   882         }
   923         }
   883     // Forced
   924         // Forced
   884     } else if (mirroring == HbIcon::Forced) {
   925     } else if (mirroring == HbIcon::Forced) {
   885         return true;
   926         return true;
   886     // Prevented
   927         // Prevented
   887     } else if (mirroring == HbIcon::Prevented) {
   928     } else if (mirroring == HbIcon::Prevented) {
   888         return false;
   929         return false;
   889     // LayoutDirection
   930         // LayoutDirection
   890     } else if (mirroring == HbIcon::LayoutDirection) {
   931     } else if (mirroring == HbIcon::LayoutDirection) {
   891         basedOnLayoutDir = true;
   932         basedOnLayoutDir = true;
   892     }
   933     }
   893 
   934 
   894     if (basedOnLayoutDir) {
   935     if (basedOnLayoutDir) {
   895         Qt::LayoutDirection usedDirection = Qt::LeftToRight; // default;
   936         Qt::LayoutDirection usedDirection = Qt::LeftToRight; // default;
   896         if ( flags&HbFrameDrawerPrivate::LayoutDirectionSet ) {
   937         if (flags & HbFrameDrawerPrivate::LayoutDirectionSet) {
   897             usedDirection = layoutDirection;
   938             usedDirection = layoutDirection;
   898         } else {
   939         } else {
   899 			usedDirection = QApplication::layoutDirection();
   940             usedDirection = QApplication::layoutDirection();
   900         }
   941         }
   901 
   942 
   902         return usedDirection == Qt::LeftToRight ? false : true;
   943         return usedDirection == Qt::LeftToRight ? false : true;
   903     }
   944     }
   904 
   945 
   912 \internal
   953 \internal
   913 */
   954 */
   914 bool HbFrameDrawerPrivate::hasBorderWidths() const
   955 bool HbFrameDrawerPrivate::hasBorderWidths() const
   915 {
   956 {
   916     return borderWidths[1] > 0
   957     return borderWidths[1] > 0
   917         || borderWidths[2] > 0
   958            || borderWidths[2] > 0
   918         || borderWidths[2] > 0
   959            || borderWidths[2] > 0
   919         || borderWidths[3] > 0;
   960            || borderWidths[3] > 0;
   920 }
   961 }
   921 
   962 
   922 /*!
   963 /*!
   923 \internal
   964 \internal
   924 */
   965 */
   925 void HbFrameDrawerPrivate::reset(bool resetFrameCount, bool unloadedByServer)
   966 void HbFrameDrawerPrivate::reset(bool resetFrameCount, bool unloadedByServer)
   926 {
   967 {
   927     unLoadIcon(unloadedByServer);
   968     unLoadIcon(unloadedByServer);
   928     if ( resetFrameCount ) {
   969     if (resetFrameCount) {
   929         frameParts = 0;
   970         frameParts = 0;
   930     }
   971     }
   931 }
   972 }
   932 
   973 
   933 /*!
   974 /*!
   934 *	Resets the MaskableIcon 
   975 *   Resets the MaskableIcon
   935 */
   976 */
   936 void HbFrameDrawerPrivate::resetMaskableIcon()
   977 void HbFrameDrawerPrivate::resetMaskableIcon()
   937 {
   978 {
   938 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON)    
   979 #if defined(HB_SGIMAGE_ICON) || defined(HB_NVG_CS_ICON)
   939     HbIconLoader *loader = HbIconLoader::global();
   980     HbIconLoader *loader = HbIconLoader::global();
   940     if ( icon ) {  
   981     if (icon) {
   941       //consolidated icon case 
   982         //consolidated icon case
   942       icon->decrementRefCount();    
   983         icon->decrementRefCount();
   943       if ( icon->refCount() == 0 && icon->isCreatedOnServer() ) {
   984         if (icon->refCount() == 0 && icon->isCreatedOnServer()) {
   944           // remove the item from cache and delete the icon
   985             // remove the item from cache and delete the icon
   945           loader->removeItemInCache( icon->iconImpl() );
   986             loader->removeItemInCache(icon->iconImpl());
   946           icon->dispose();
   987             icon->dispose();
   947       }
   988         }
   948       icon = 0;              
   989         icon = 0;
   949     } else {            
   990     } else {
   950         int count = fallbackMaskableIconList.count();
   991         int count = fallbackMaskableIconList.count();
   951         if ( count ) {
   992         if (count) {
   952             // for each item in fallbackMaskableIconList - decrement the reference count and
   993             // for each item in fallbackMaskableIconList - decrement the reference count and
   953             // remove the item in cache, dispose if needed.
   994             // remove the item in cache, dispose if needed.
   954             foreach ( HbMaskableIconImpl* impl, fallbackMaskableIconList ) {
   995             foreach(HbMaskableIconImpl * impl, fallbackMaskableIconList) {
   955                    impl->decrementRefCount();
   996                 impl->decrementRefCount();
   956                    if ( impl->refCount() == 0 && impl->isCreatedOnServer() ) {
   997                 if (impl->refCount() == 0 && impl->isCreatedOnServer()) {
   957                        loader->removeItemInCache( impl->iconImpl() );     
   998                     loader->removeItemInCache(impl->iconImpl());
   958                        impl->dispose();
   999                     impl->dispose();
   959                    } 
  1000                 }
   960             }                                   
  1001             }
   961             fallbackMaskableIconList.clear(); 
  1002             fallbackMaskableIconList.clear();
   962         }
  1003         }
   963     }
  1004     }
   964     frameParts = 0;
  1005     frameParts = 0;
   965 #endif
  1006 #endif
   966 }
  1007 }
  1004             id.append("_1");
  1045             id.append("_1");
  1005         } else {
  1046         } else {
  1006             id.append("_0");
  1047             id.append("_0");
  1007         }
  1048         }
  1008 
  1049 
  1009         for (int i = 0;i < 4; i++) { 
  1050         for (int i = 0; i < 4; i++) {
  1010             QString boundary;
  1051             QString boundary;
  1011             id.append("_");
  1052             id.append("_");
  1012             id.append(boundary.setNum(borderWidths[i]));
  1053             id.append(boundary.setNum(borderWidths[i]));
  1013         }
  1054         }
  1014     }
  1055     }
  1015 
  1056 
  1016     for (int i = 0; i < suffixList.count(); i++) {
  1057     for (int i = 0; i < suffixList.count(); i++) {
  1017         id.append( suffixList[i] );
  1058         id.append(suffixList[i]);
  1018     }
  1059     }
  1019 
  1060 
  1020     return id;
  1061     return id;
  1021 }
  1062 }
  1022 
  1063 
  1024 {
  1065 {
  1025     HbIconLoader *loader = HbIconLoader::global();
  1066     HbIconLoader *loader = HbIconLoader::global();
  1026     if (icon) {
  1067     if (icon) {
  1027         //If a consolidated (stitched) icon was created on the themeserver, then
  1068         //If a consolidated (stitched) icon was created on the themeserver, then
  1028         //HbIconLoader::unloadIcon() is used to unload it.
  1069         //HbIconLoader::unloadIcon() is used to unload it.
  1029         loader->unLoadIcon(icon->iconImpl(),unloadedByServer);
  1070         loader->unLoadIcon(icon->iconImpl(), unloadedByServer);
  1030         icon->dispose();
  1071         icon->dispose();
  1031         icon = 0;
  1072         icon = 0;
  1032     }
  1073     }
  1033 
  1074 
  1034     // get a vector of QVector<HbIconImpl*> from QVector<HbMaskableIconImpl*> for unloading.
  1075     // get a vector of QVector<HbIconImpl*> from QVector<HbMaskableIconImpl*> for unloading.
  1035     QVector<HbIconImpl *> fallbackIconList;
  1076     QVector<HbIconImpl *> fallbackIconList;
  1036     int count = fallbackMaskableIconList.count();
  1077     int count = fallbackMaskableIconList.count();
  1037     for (int i = 0; i < count ; i++) {
  1078     for (int i = 0; i < count ; i++) {
  1038         if ( fallbackMaskableIconList.at(i) ) {
  1079         if (fallbackMaskableIconList.at(i)) {
  1039             fallbackIconList.append(fallbackMaskableIconList.at(i)->iconImpl());
  1080             fallbackIconList.append(fallbackMaskableIconList.at(i)->iconImpl());
  1040         }
  1081         }
  1041     }
  1082     }
  1042     count = fallbackIconList.count();
  1083     count = fallbackIconList.count();
  1043     if (count > 0) {
  1084     if (count > 0) {
  1044         //If a consolidated (stitched) icon-creation on themeserver fails, unload-request for all individual
  1085         //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().
  1086         //frame-items are batched together in a single IPC, which is initiated in HbIconLoader::unLoadMultiIcon().
  1046         loader->unLoadMultiIcon(fallbackIconList);
  1087         loader->unLoadMultiIcon(fallbackIconList);
  1047         for (int i=0; i < count ; i++) {
  1088         for (int i = 0; i < count ; i++) {
  1048             if ( fallbackMaskableIconList.at(i) ) {
  1089             if (fallbackMaskableIconList.at(i)) {
  1049                 fallbackMaskableIconList.at(i)->dispose();
  1090                 fallbackMaskableIconList.at(i)->dispose();
  1050             }
  1091             }
  1051         }
  1092         }
  1052      }
  1093     }
  1053     fallbackIconList.clear();  // vector of HbIconImpl*
  1094     fallbackIconList.clear();  // vector of HbIconImpl*
  1054     fallbackMaskableIconList.clear(); // vector of HbMaskableIconImpl*
  1095     fallbackMaskableIconList.clear(); // vector of HbMaskableIconImpl*
  1055 }
  1096 }
  1056 
  1097 
  1057 void HbFrameDrawerPrivate::themeChange( const QStringList &updatedFiles)
  1098 void HbFrameDrawerPrivate::themeChange(const QStringList &updatedFiles)
  1058 {
  1099 {
  1059     bool unloadIcons = false;
  1100     bool unloadIcons = false;
  1060     if (updatedFiles.count() == 0 || (icon && updatedFiles.contains(icon->iconFileName()))) {
  1101     if (updatedFiles.count() == 0 || (icon && updatedFiles.contains(icon->iconFileName()))) {
  1061         unloadIcons = true;
  1102         unloadIcons = true;
  1062     } else {
  1103     } else {
  1063         HbMaskableIconImpl *fallbackIcon;
  1104         HbMaskableIconImpl *fallbackIcon;
  1064         foreach (fallbackIcon, fallbackMaskableIconList) {
  1105         foreach(fallbackIcon, fallbackMaskableIconList) {
  1065             if (fallbackIcon && updatedFiles.contains(fallbackIcon->iconFileName())) {
  1106             if (fallbackIcon && updatedFiles.contains(fallbackIcon->iconFileName())) {
  1066                 unloadIcons = true;
  1107                 unloadIcons = true;
  1067                 break;
  1108                 break;
  1068             }
  1109             }
  1069         }
  1110         }
  1077 /*! Constructs a new frame drawer item with the cacheFlag enabled  by default.
  1118 /*! Constructs a new frame drawer item with the cacheFlag enabled  by default.
  1078 */
  1119 */
  1079 HbFrameDrawer::HbFrameDrawer(bool cacheFlag)
  1120 HbFrameDrawer::HbFrameDrawer(bool cacheFlag)
  1080 {
  1121 {
  1081     d = new HbFrameDrawerPrivate();
  1122     d = new HbFrameDrawerPrivate();
  1082     if ( !cacheFlag ) {
  1123     if (!cacheFlag) {
  1083         d->flags &= HbFrameDrawerPrivate::DoNotCache;  
  1124         d->flags &= HbFrameDrawerPrivate::DoNotCache;
  1084     }
  1125     }
  1085 }
  1126 }
  1086 
  1127 
  1087 /*! Constructs a new frame drawer with the given \a frameGraphicsName and \a type  and cacheFlag is enabled.
  1128 /*! Constructs a new frame drawer with the given \a frameGraphicsName and \a type  and cacheFlag is enabled.
  1088 */
  1129 */
  1089 HbFrameDrawer::HbFrameDrawer(const QString &frameGraphicsName, FrameType type, bool cacheFlag)
  1130 HbFrameDrawer::HbFrameDrawer(const QString &frameGraphicsName, FrameType type, bool cacheFlag)
  1090 {
  1131 {
  1091     d = new HbFrameDrawerPrivate(frameGraphicsName, type);
  1132     d = new HbFrameDrawerPrivate(frameGraphicsName, type);
  1092     if ( !cacheFlag ) {
  1133     if (!cacheFlag) {
  1093         d->flags &= HbFrameDrawerPrivate::DoNotCache;
  1134         d->flags &= HbFrameDrawerPrivate::DoNotCache;
  1094     }  
  1135     }
  1095 }
  1136 }
  1096 
  1137 
  1097 /*!
  1138 /*!
  1098 * Copy constructs a new frame drawer using the \a other frame drawer.
  1139 * Copy constructs a new frame drawer using the \a other frame drawer.
  1099 * This is very fast.
  1140 * This is very fast.
  1100 * Copy-on-write semantics is used, so this only does a shallow copy. 
  1141 * Copy-on-write semantics is used, so this only does a shallow copy.
  1101 */
  1142 */
  1102 HbFrameDrawer::HbFrameDrawer(const HbFrameDrawer &other) :
  1143 HbFrameDrawer::HbFrameDrawer(const HbFrameDrawer &other) :
  1103     d(other.d)
  1144     d(other.d)
  1104 {
  1145 {
  1105 }
  1146 }
  1106 
  1147 
  1107 /*!
  1148 /*!
  1108 * Assigns the \a other frame drawer to this frame drawer and returns a reference to
  1149 * 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. 
  1150 * this frame drawer. Copy-on-write semantics is used, so this only does a shallow copy.
  1110 */
  1151 */
  1111 HbFrameDrawer &HbFrameDrawer::operator=(const HbFrameDrawer &other)
  1152 HbFrameDrawer &HbFrameDrawer::operator=(const HbFrameDrawer &other)
  1112 {
  1153 {
  1113     if (&other != this) {
  1154     if (&other != this) {
  1114         d = other.d;
  1155         d = other.d;
  1144 }
  1185 }
  1145 
  1186 
  1146 /*!
  1187 /*!
  1147 * Sets the frame graphics name. See the class description for the file name convention for different frame parts.
  1188 * Sets the frame graphics name. See the class description for the file name convention for different frame parts.
  1148 * \sa HbFrameDrawer::frameGraphicsName()
  1189 * \sa HbFrameDrawer::frameGraphicsName()
       
  1190 * \note Logical frame names that define a themable frame should not include filename extension, whereas absolute filenames
       
  1191 * must include full path and filename extension.
  1149 */
  1192 */
  1150 void HbFrameDrawer::setFrameGraphicsName(const QString &frameGraphicsName)
  1193 void HbFrameDrawer::setFrameGraphicsName(const QString &frameGraphicsName)
  1151 {
  1194 {
  1152     // Remove possible file extension
       
  1153     QString nameWithoutExt = frameGraphicsName;
  1195     QString nameWithoutExt = frameGraphicsName;
  1154     int index = nameWithoutExt.lastIndexOf(QChar('.'));
  1196 
  1155     if (index>0) {
  1197     if (HbThemeUtils::isLogicalName(frameGraphicsName)) {
  1156         nameWithoutExt.resize(index);
  1198         // Remove possible file extension
       
  1199         int index = nameWithoutExt.lastIndexOf(QChar('.'));
       
  1200         if (index>0) {
       
  1201             nameWithoutExt.resize(index);
       
  1202         }
  1157     }
  1203     }
  1158 
  1204 
  1159     if (d->frameGraphicsName != nameWithoutExt) {
  1205     if (d->frameGraphicsName != nameWithoutExt) {
  1160         d->frameGraphicsName = nameWithoutExt;
  1206         d->frameGraphicsName = nameWithoutExt;
  1161         // Frame graphics changed, clear frame icon
  1207         // Frame graphics changed, clear frame icon
  1162         d->reset();
  1208         d->reset();
  1163         // Frame graphics changed, clear default frame mirroring information based on the automatic mirroring list
  1209         // Frame graphics changed, clear default frame mirroring information based on the automatic mirroring list
  1164         d->defaultMirroring = HbFrameDrawerPrivate::Unknown;
  1210         d->defaultMirroring = HbFrameDrawerPrivate::Unknown;
  1165 
  1211 
  1166         // if graphicsItem is set, request redraw
  1212         // if graphicsItem is set, request redraw
  1167         if ( d->graphicsItem ) {
  1213         if (d->graphicsItem) {
  1168             d->graphicsItem->update();
  1214             d->graphicsItem->update();
  1169         }
  1215         }
  1170     }
  1216     }
  1171 }
  1217 }
  1172 
  1218 
  1214 * Frame type \b ThreePiecesHorizontal:
  1260 * Frame type \b ThreePiecesHorizontal:
  1215 *
  1261 *
  1216 * - Left part width = (default size of the left part graphics scaled to the bounding rectangle).width
  1262 * - 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
  1263 * - Right part width = (default size of the right part graphics scaled to the bounding rectangle).width
  1218 * - Center part width = remaining width
  1264 * - Center part width = remaining width
  1219 * 
  1265 *
  1220 * Frame type \b ThreePiecesVertical:
  1266 * Frame type \b ThreePiecesVertical:
  1221 *
  1267 *
  1222 * - Top part height = (default size of the top part graphics scaled to the bounding rectangle).height
  1268 * - 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
  1269 * - Bottom part height = (default size of the bottom part graphics scaled to the bounding rectangle).height
  1224 * - Center part height = remaining height
  1270 * - Center part height = remaining height
  1230 *
  1276 *
  1231 * \sa HbFrameDrawer::borderWidths()
  1277 * \sa HbFrameDrawer::borderWidths()
  1232 */
  1278 */
  1233 void HbFrameDrawer::setBorderWidths(const qreal left, const qreal top, const qreal right, const qreal bottom)
  1279 void HbFrameDrawer::setBorderWidths(const qreal left, const qreal top, const qreal right, const qreal bottom)
  1234 {
  1280 {
  1235 	d->setBorderApiProtectionFlag(true);
  1281     d->setBorderApiProtectionFlag(true);
  1236     if ( left != d->borderWidths[0] || top != d->borderWidths[1] ||
  1282     if (left != d->borderWidths[0] || top != d->borderWidths[1] ||
  1237          right != d->borderWidths[2] || bottom != d->borderWidths[3] ) {
  1283             right != d->borderWidths[2] || bottom != d->borderWidths[3]) {
  1238         // Negative values are converted to zero.
  1284         // Negative values are converted to zero.
  1239         d->borderWidths[0] = qMax((qreal)0.0, left);
  1285         d->borderWidths[0] = qMax((qreal)0.0, left);
  1240         d->borderWidths[1] = qMax((qreal)0.0, top);
  1286         d->borderWidths[1] = qMax((qreal)0.0, top);
  1241         d->borderWidths[2] = qMax((qreal)0.0, right);
  1287         d->borderWidths[2] = qMax((qreal)0.0, right);
  1242         d->borderWidths[3] = qMax((qreal)0.0, bottom);
  1288         d->borderWidths[3] = qMax((qreal)0.0, bottom);
  1243         // borderWidths changed, clear frame icon
  1289         // borderWidths changed, clear frame icon
  1244         d->reset( false );
  1290         d->reset(false);
  1245     }
  1291     }
  1246 }
  1292 }
  1247 
  1293 
  1248 /*!
  1294 /*!
  1249 * This is a convenience method. Equals to:
  1295 * This is a convenience method. Equals to:
  1252 *
  1298 *
  1253 * \sa HbFrameDrawer::borderWidths()
  1299 * \sa HbFrameDrawer::borderWidths()
  1254 */
  1300 */
  1255 void HbFrameDrawer::setBorderWidths(const qreal horizontal, const qreal vertical)
  1301 void HbFrameDrawer::setBorderWidths(const qreal horizontal, const qreal vertical)
  1256 {
  1302 {
  1257     setBorderWidths( horizontal, vertical, horizontal, vertical );
  1303     setBorderWidths(horizontal, vertical, horizontal, vertical);
  1258 }
  1304 }
  1259 
  1305 
  1260 /*!
  1306 /*!
  1261 * This is a convenience method. Equals to:
  1307 * This is a convenience method. Equals to:
  1262 *
  1308 *
  1264 *
  1310 *
  1265 * \sa HbFrameDrawer::borderWidths()
  1311 * \sa HbFrameDrawer::borderWidths()
  1266 */
  1312 */
  1267 void HbFrameDrawer::setBorderWidth(const qreal width)
  1313 void HbFrameDrawer::setBorderWidth(const qreal width)
  1268 {
  1314 {
  1269     setBorderWidths( width, width, width, width );
  1315     setBorderWidths(width, width, width, width);
  1270 }
  1316 }
  1271 
  1317 
  1272 
  1318 
  1273 /*!
  1319 /*!
  1274 * Returns the bounding rectangle of the frame.
  1320 * Returns the bounding rectangle of the frame.
  1286 void HbFrameDrawer::setRect(const QRectF &rect)
  1332 void HbFrameDrawer::setRect(const QRectF &rect)
  1287 {
  1333 {
  1288     if (rect != d->rect) {
  1334     if (rect != d->rect) {
  1289         d->rect = rect;
  1335         d->rect = rect;
  1290         // Rect changed, clear frame icon
  1336         // Rect changed, clear frame icon
  1291         d->reset( false );
  1337         d->reset(false);
  1292     }
  1338     }
  1293 }
  1339 }
  1294 
  1340 
  1295 /*!
  1341 /*!
  1296 * Paints the frame with the given \a painter.
  1342 * Paints the frame with the given \a painter.
  1297 */
  1343 */
  1298 void HbFrameDrawer::paint(QPainter *painter, const QRectF &rect) const
  1344 void HbFrameDrawer::paint(QPainter *painter, const QRectF &rect) const
  1299 {
  1345 {
  1300     const_cast<HbFrameDrawer*>(this)->setRect( rect );
  1346     const_cast<HbFrameDrawer *>(this)->setRect(rect);
  1301 
  1347 
  1302     if (d->frameGraphicsName.isEmpty() || d->type == HbFrameDrawer::Undefined || d->rect.isEmpty()) {
  1348     if (d->frameGraphicsName.isEmpty() || d->type == HbFrameDrawer::Undefined || d->rect.isEmpty()) {
  1303         return;
  1349         return;
  1304     }
  1350     }
  1305 
  1351 
  1306     // Lazy graphics rasterizing is used.
  1352     // Lazy graphics rasterizing is used.
  1307     // Rasterize the frame parts now if that has not been done yet.
  1353     // Rasterize the frame parts now if that has not been done yet.
  1308     if (d->icon && (rect.toRect().size() !=  d->prevRect.size())) {
  1354     if (d->icon && (rect.toRect().size() !=  d->prevRect.size())) {
  1309         d->reset(); 
  1355         d->reset();
  1310     }    
  1356     }
  1311     
  1357 
  1312     // update the rendering mode
  1358     // update the rendering mode
  1313     HbIconLoader::global()->updateRenderingMode(painter->paintEngine()->type());    
  1359     QPaintEngine *paintEngine = painter->paintEngine();
       
  1360     if (paintEngine) {
       
  1361         HbIconLoader::global()->updateRenderingMode(paintEngine->type());
       
  1362     }
  1314     d->prepareFrameIcon();
  1363     d->prepareFrameIcon();
  1315     d->prevRect = rect.toRect();
  1364     d->prevRect = rect.toRect();
  1316     // Paint the frame
  1365     // Paint the frame
  1317     d->paint(painter);
  1366     d->paint(painter);
  1318 }
  1367 }
  1344 *
  1393 *
  1345 * \sa HbFrameDrawer::fillWholeRect()
  1394 * \sa HbFrameDrawer::fillWholeRect()
  1346 */
  1395 */
  1347 void HbFrameDrawer::setFillWholeRect(bool fill)
  1396 void HbFrameDrawer::setFillWholeRect(bool fill)
  1348 {
  1397 {
  1349     if ( (fill && !d->fillWholeRect()) || (!fill && d->fillWholeRect()) ) {
  1398     if ((fill && !d->fillWholeRect()) || (!fill && d->fillWholeRect())) {
  1350         if ( fill ) {
  1399         if (fill) {
  1351             d->flags |= HbFrameDrawerPrivate::FillWholeRect;
  1400             d->flags |= HbFrameDrawerPrivate::FillWholeRect;
  1352         } else {
  1401         } else {
  1353             d->flags &= ~HbFrameDrawerPrivate::FillWholeRect;
  1402             d->flags &= ~HbFrameDrawerPrivate::FillWholeRect;
  1354         }
  1403         }
  1355 
  1404 
  1356         // Fill mode changed, clear frame Icon
  1405         // Fill mode changed, clear frame Icon
  1357         d->reset( false );
  1406         d->reset(false);
  1358     }
  1407     }
  1359 }
  1408 }
  1360 
  1409 
  1361 /*! Returns the mirroring mode set for the frame drawer.
  1410 /*! Returns the mirroring mode set for the frame drawer.
  1362 * \sa HbFrameDrawer::setMirroringMode()
  1411 * \sa HbFrameDrawer::setMirroringMode()
  1372 void HbFrameDrawer::setMirroringMode(HbIcon::MirroringMode mode)
  1421 void HbFrameDrawer::setMirroringMode(HbIcon::MirroringMode mode)
  1373 {
  1422 {
  1374     if (mode != d->mirroring) {
  1423     if (mode != d->mirroring) {
  1375         d->mirroring = mode;
  1424         d->mirroring = mode;
  1376         // Mirroring changed, clear frame Icon
  1425         // Mirroring changed, clear frame Icon
  1377         d->reset( false );
  1426         d->reset(false);
  1378     }
  1427     }
  1379 }
  1428 }
  1380 
  1429 
  1381 /*! Returns the filename suffix list.
  1430 /*! Returns the filename suffix list.
  1382 * See the class level documentation for how frame part filenames are determined
  1431 * 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.
  1491         // Frame part filename suffix list changed, clear frame parts count info and generated frame icon.
  1443         d->reset();
  1492         d->reset();
  1444     }
  1493     }
  1445 }
  1494 }
  1446 
  1495 
  1447 /*! 
  1496 /*!
  1448 * Sets the mask to be applied with the the entire frame icon.
  1497 * 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.
  1498 * 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().
  1499 * Mask should be of the same size as returned by frameSize().
  1451 * To unset the mask, set it to a null pixmap.
  1500 * To unset the mask, set it to a null pixmap.
  1452 * 
  1501 *
  1453 * \warning Currently this method makes use of pixmap() routine in case of NVG icons. 
  1502 * \warning Currently this method makes use of pixmap() routine in case of NVG icons.
  1454 * pixmap() slows down the hardware accelerated rendering.
  1503 * pixmap() slows down the hardware accelerated rendering.
  1455 * \sa frameSize(), mask()
  1504 * \sa frameSize(), mask()
  1456 */
  1505 */
  1457 void HbFrameDrawer::setMask(const QPixmap &mask)
  1506 void HbFrameDrawer::setMask(const QPixmap &mask)
  1458 {
  1507 {
  1459     d->mask = mask;
  1508     d->mask = mask;
  1460     d->maskChanged = true;
  1509     d->maskChanged = true;
  1461 }
  1510 }
  1462 
  1511 
  1463 /*! 
  1512 /*!
  1464 * Sets the \a clipPath to be applied with the entire frame icon.
  1513 * Sets the \a clipPath to be applied with the entire frame icon.
  1465 * 
  1514 *
  1466 */
  1515 */
  1467 void HbFrameDrawer::setClipPath(const QPainterPath &clipPath)
  1516 void HbFrameDrawer::setClipPath(const QPainterPath &clipPath)
  1468 {
  1517 {
  1469     d->clipPath = clipPath;
  1518     d->clipPath = clipPath;
  1470 }
  1519 }
  1471 
  1520 
  1472 /*!
  1521 /*!
  1473 * Returns the clippath set on the frame drawer.
  1522 * Returns the clippath set on the frame drawer.
  1474 * As default, returns a empty QPainterPath.
  1523 * By default, returns a empty QPainterPath.
  1475 * \sa setClipPath()
  1524 * \sa setClipPath()
  1476 */
  1525 */
  1477 
  1526 
  1478 QPainterPath HbFrameDrawer::clipPath() const
  1527 QPainterPath HbFrameDrawer::clipPath() const
  1479 {
  1528 {
  1480     return d->clipPath;
  1529     return d->clipPath;
  1481 }
  1530 }
  1482 
  1531 
  1483 /*! 
  1532 /*!
  1484 * Sets the mask to be applied with the the entire frame icon.
  1533 * 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.
  1534 * 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().
  1535 * Mask should be of the same size as returned by frameSize().
  1487 * To unset the mask, set it to a null bitmap.
  1536 * To unset the mask, set it to a null bitmap.
  1488 *
  1537 *
  1489  \warning Currently this method makes use of pixmap() routine in case of NVG icons. 
  1538  \warning Currently this method makes use of pixmap() routine in case of NVG icons.
  1490 * pixmap() slows down the hardware accelerated rendering.
  1539 * pixmap() slows down the hardware accelerated rendering.
  1491 *
  1540 *
  1492 *\sa frameSize(), mask()
  1541 *\sa frameSize(), mask()
  1493 */
  1542 */
  1494 void HbFrameDrawer::setMask(const QBitmap &mask)
  1543 void HbFrameDrawer::setMask(const QBitmap &mask)
  1497     d->maskChanged = true;
  1546     d->maskChanged = true;
  1498 }
  1547 }
  1499 
  1548 
  1500 /*!
  1549 /*!
  1501 * Returns the mask set on the frame drawer.
  1550 * Returns the mask set on the frame drawer.
  1502 * As default, returns a null pixmap.
  1551 * By default, returns a null pixmap.
  1503 * \sa setMask()
  1552 * \sa setMask()
  1504 */
  1553 */
  1505 
  1554 
  1506 QPixmap HbFrameDrawer::mask() const
  1555 QPixmap HbFrameDrawer::mask() const
  1507 {
  1556 {
  1509 }
  1558 }
  1510 
  1559 
  1511 
  1560 
  1512 /*!
  1561 /*!
  1513 * Returns the mask set on the frame drawer.
  1562 * Returns the mask set on the frame drawer.
  1514 * As default, returns a null bitmap.
  1563 * By default, returns a null bitmap.
  1515 * \sa setMask()
  1564 * \sa setMask()
  1516 */
  1565 */
  1517 QBitmap HbFrameDrawer::maskBitmap() const
  1566 QBitmap HbFrameDrawer::maskBitmap() const
  1518 {
  1567 {
  1519     return d->mask;
  1568     return d->mask;
  1520 }
  1569 }
  1521 /*!
  1570 /*!
  1522  * Returns the size of the entire frame icon. 
  1571  * 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().
  1572  * 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
  1573  * If the frame graphics name, bounding rectangle or frame type have not been set, this method returns
  1525  * an empty size.
  1574  * an empty size.
  1526  */
  1575  */
  1527 QSize HbFrameDrawer::frameSize() const
  1576 QSize HbFrameDrawer::frameSize() const
  1562 /*!
  1611 /*!
  1563 * Sets the layout direction of the frame drawer.
  1612 * Sets the layout direction of the frame drawer.
  1564 *
  1613 *
  1565 * Valid only when the mirroring mode is HbIcon::LayoutDirection.
  1614 * Valid only when the mirroring mode is HbIcon::LayoutDirection.
  1566 */
  1615 */
  1567 void HbFrameDrawer::setLayoutDirection( Qt::LayoutDirection direction )
  1616 void HbFrameDrawer::setLayoutDirection(Qt::LayoutDirection direction)
  1568 {
  1617 {
  1569     d->flags |= HbFrameDrawerPrivate::LayoutDirectionSet;
  1618     d->flags |= HbFrameDrawerPrivate::LayoutDirectionSet;
  1570 
  1619 
  1571     if ( d->layoutDirection != direction ) {
  1620     if (d->layoutDirection != direction) {
  1572         d->layoutDirection = direction;
  1621         d->layoutDirection = direction;
  1573         
  1622 
  1574         if ( ( d->mirroring == HbIcon::Default 
  1623         if ((d->mirroring == HbIcon::Default
  1575                && d->defaultMirroring == HbFrameDrawerPrivate::Enabled ) ||
  1624                 && d->defaultMirroring == HbFrameDrawerPrivate::Enabled) ||
  1576             d->mirroring == HbIcon::LayoutDirection) {
  1625                 d->mirroring == HbIcon::LayoutDirection) {
  1577 
  1626 
  1578             d->reset( false );
  1627             d->reset(false);
  1579         }
  1628         }
  1580     }
  1629     }
  1581 }
  1630 }
  1582 
  1631 
  1583 /*!
  1632 /*!
  1584 * Sets the \a item which is needs to be redrawn when the frame drawer
  1633 * Sets the \a item which is needs to be redrawn when the frame drawer
  1585 * needs re-paint. 
  1634 * needs re-paint.
  1586 */
  1635 */
  1587 void HbFrameDrawer::setGraphicsItem( QGraphicsItem *item )
  1636 void HbFrameDrawer::setGraphicsItem(QGraphicsItem *item)
  1588 {
  1637 {
  1589     d->graphicsItem = item;
  1638     d->graphicsItem = item;
  1590 }
  1639 }
  1591 
  1640 
  1592 /*!
  1641 /*!