javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/src/swtbutton.cpp
changeset 21 2a9601315dfc
child 23 98ccebc37403
equal deleted inserted replaced
18:e8e63152f320 21:2a9601315dfc
       
     1 /*******************************************************************************
       
     2  * Copyright (c) 2005, 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved. This program and the accompanying materials
       
     4  * are made available under the terms of the Eclipse Public License v1.0
       
     5  * which accompanies this distribution, and is available at
       
     6  * http://www.eclipse.org/legal/epl-v10.html
       
     7  *
       
     8  * Contributors:
       
     9  *     Nokia Corporation - S60 implementation
       
    10  *******************************************************************************/
       
    11 
       
    12 
       
    13 #include <gulicon.h>
       
    14 #include <AknsUtils.h>
       
    15 #include <aknconsts.h>
       
    16 #include <avkon.mbg>
       
    17 #include <swtlaffacade.h>
       
    18 #include "swtcontrolhelper.h"
       
    19 #include "eswtmobileextensions.h"
       
    20 #include "swtbutton.h"
       
    21 #include "swtbuttonproxy.h"
       
    22 #include "swtfont.h"
       
    23 #ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK
       
    24 #include <touchfeedback.h>
       
    25 #endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK
       
    26 
       
    27 // ======== MEMBER FUNCTIONS ========
       
    28 
       
    29 
       
    30 // ---------------------------------------------------------------------------
       
    31 // CSwtButton::NewL
       
    32 // ---------------------------------------------------------------------------
       
    33 //
       
    34 CSwtButton* CSwtButton::NewL(
       
    35     MSwtDisplay& aDisplay,
       
    36     TSwtPeer aPeer,
       
    37     MSwtComposite& aParent,
       
    38     TInt aStyle)
       
    39 {
       
    40     CSwtButton* self = new(ELeave) CSwtButton(
       
    41         aDisplay,
       
    42         aPeer,
       
    43         aParent,
       
    44         aStyle);
       
    45     CleanupStack::PushL(self);
       
    46     self->ConstructL();
       
    47     self->InitControlBaseL();
       
    48     CleanupStack::Pop(self);
       
    49     return self;
       
    50 }
       
    51 
       
    52 // ---------------------------------------------------------------------------
       
    53 // CSwtButton::CSwtButton
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 CSwtButton::CSwtButton(
       
    57     MSwtDisplay& aDisplay,
       
    58     TSwtPeer aPeer,
       
    59     MSwtComposite& aParent,
       
    60     TInt aStyle)
       
    61         : ASwtControlBase(aDisplay, aPeer, &aParent, aStyle)
       
    62 {
       
    63 }
       
    64 
       
    65 // ---------------------------------------------------------------------------
       
    66 // CSwtButton::~CSwtButton
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 CSwtButton::~CSwtButton()
       
    70 {
       
    71     delete iButton;
       
    72 
       
    73     if (iDefaultFont)
       
    74     {
       
    75         iDefaultFont->RemoveRef();
       
    76     }
       
    77 
       
    78     if (iImage != NULL)
       
    79     {
       
    80         iImage->RemoveRef();
       
    81     }
       
    82 
       
    83     if (iDupFont)
       
    84     {
       
    85         iDupFont->RemoveRef();
       
    86     }
       
    87 
       
    88 #ifdef _lint
       
    89     iDefaultFont = NULL;
       
    90     iImage = NULL;
       
    91     iCustomIcon = NULL;
       
    92     iDupFont = NULL;
       
    93 #endif
       
    94 }
       
    95 
       
    96 // ---------------------------------------------------------------------------
       
    97 // CSwtButton::ConstructL
       
    98 // ---------------------------------------------------------------------------
       
    99 //
       
   100 void CSwtButton::ConstructL()
       
   101 {
       
   102     CCoeControl& coeParent = iParent->Control()->CoeControl();
       
   103     SetContainerWindowL(coeParent);
       
   104 
       
   105     CreateButtonL(KNullDesC);
       
   106     RetrieveDefaultFontL();
       
   107 
       
   108     CCoeControl::MakeVisible(coeParent.IsVisible());
       
   109     CCoeControl::SetDimmed(coeParent.IsDimmed());
       
   110     SetAlignment(iStyle & KSwtAlignmentMask);
       
   111 
       
   112     SetComponentsToInheritVisibility(ETrue);
       
   113 
       
   114 #ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK
       
   115     iFeedback = MTouchFeedback::Instance();
       
   116     // Disabling feedback for CSwtButton.
       
   117     // When enabled - first tap on combo creates extra feedback,
       
   118     // that is not needed.
       
   119     if (iFeedback)
       
   120     {
       
   121         iFeedback->EnableFeedbackForControl(this, EFalse);
       
   122     }
       
   123 #endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK
       
   124 
       
   125     ActivateL();
       
   126 }
       
   127 
       
   128 // ---------------------------------------------------------------------------
       
   129 // CSwtButton::RetrieveDefaultFontL
       
   130 // ---------------------------------------------------------------------------
       
   131 //
       
   132 void CSwtButton::RetrieveDefaultFontL()
       
   133 {
       
   134     if (iDefaultFont)
       
   135     {
       
   136         iDefaultFont->RemoveRef();
       
   137         iDefaultFont = NULL;
       
   138     }
       
   139 
       
   140     // Same as Label's
       
   141     iDefaultFont = CSwtFont::NewL(iDisplay.Device(), iDisplay.Device().GetSystemFont()->Font());
       
   142     if (!iFont)
       
   143     {
       
   144         ProcessFontUpdate();
       
   145     }
       
   146 }
       
   147 // ---------------------------------------------------------------------------------------------
       
   148 // CSwtButton::ProcessFontUpdate
       
   149 // ---------------------------------------------------------------------------------------------
       
   150 //
       
   151 void CSwtButton::ProcessFontUpdate()
       
   152 {
       
   153     const MSwtFont* swtFont=GetFont();
       
   154     ASSERT(swtFont);
       
   155     const CFont* font = &(swtFont->Font());
       
   156 
       
   157     // Workaround for that the custom font on window server side is changed unexpectedly
       
   158     if (iFont)
       
   159     {
       
   160         if (!iDupFont)
       
   161         {
       
   162             // duplicate
       
   163             TRAP_IGNORE(iDupFont = CSwtFont::NewL(iDisplay.Device(), swtFont->Font()));
       
   164         }
       
   165 
       
   166         if (iDupFont)
       
   167         {
       
   168             // duplicated font will pass to the button to avoid custom font being changed
       
   169             font = &(iDupFont->Font());
       
   170         }
       
   171     }
       
   172 
       
   173     iButton->SetTextFont(font);
       
   174 }
       
   175 
       
   176 
       
   177 // ---------------------------------------------------------------------------
       
   178 // CSwtButton::CreateButtonL
       
   179 // ---------------------------------------------------------------------------
       
   180 //
       
   181 void CSwtButton::CreateButtonL(const TDesC& aText)
       
   182 {
       
   183     ASSERT(iButton == NULL);
       
   184 
       
   185     if (iStyle & (KSwtStyleCheck | KSwtStyleRadio))
       
   186     {
       
   187         CGulIcon* icon = CreateCheckOrRadioIconL(iSelected, iStyle);
       
   188         CleanupStack::PushL(icon);
       
   189 
       
   190         iButton = CSwtButtonProxy::NewL(this, icon, aText,
       
   191                                         KAknButtonSizeFitText | KAknButtonNoFrame | KAknButtonPressedDownFrame);
       
   192 
       
   193         CleanupStack::Pop(icon);
       
   194 
       
   195         iCustomIcon = icon;
       
   196 
       
   197         TSize iconSize(TSize::EUninitialized);
       
   198         GetSizeOfCheckOrRadioIcon(iconSize);
       
   199         SetIconSize(iCustomIcon, iconSize);
       
   200         iButton->SetIconSize(iconSize);
       
   201     }
       
   202     else // KSwtStyleToggle, KSwtStylePush, KSwtStyleFlat
       
   203     {
       
   204         // Do not use KAknButtonTextInsideFrame. It clips the icons when text is present.
       
   205         iButton = CSwtButtonProxy::NewL(this, NULL, aText, KAknButtonSizeFitText);
       
   206     }
       
   207 
       
   208     iButton->SetObserver(this);
       
   209     iButton->MakeVisible(ETrue);
       
   210     iButton->SetFocusing(ETrue);
       
   211     iButton->SetIconScaleMode(EAspectRatioPreserved);
       
   212 
       
   213     iButton->SetBackground(this);   // Back will be drawn by ASwtControlBase::Draw
       
   214 
       
   215     // Set default color
       
   216     TRgb color;
       
   217     AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
       
   218                               color,
       
   219                               KAknsIIDQsnTextColors,
       
   220                               EAknsCIQsnTextColorsCG63); // Messaging touch buttons
       
   221     iButton->OverrideColorL(EColorButtonText, color);
       
   222 }
       
   223 
       
   224 // ---------------------------------------------------------------------------
       
   225 // CSwtButton::ChangeStateL
       
   226 // ---------------------------------------------------------------------------
       
   227 //
       
   228 void CSwtButton::ChangeStateL(TBool aState)
       
   229 {
       
   230     ASSERT(iButton);
       
   231 
       
   232     if (iStyle & KSwtStyleToggle)
       
   233     {
       
   234         if (aState)
       
   235         {
       
   236             iButton->SetFlags(iButton->Flags() | KAknButtonStateHasLatchedFrame);
       
   237         }
       
   238         else
       
   239         {
       
   240             iButton->SetFlags(iButton->Flags() & ~KAknButtonStateHasLatchedFrame);
       
   241         }
       
   242     }
       
   243     else if (iStyle & (KSwtStyleCheck | KSwtStyleRadio))
       
   244     {
       
   245         ChangeCheckOrRadioIconL(aState);
       
   246     }
       
   247 }
       
   248 
       
   249 // ---------------------------------------------------------------------------
       
   250 // CSwtButton::CreateCheckOrRadioIconL
       
   251 // ---------------------------------------------------------------------------
       
   252 //
       
   253 CGulIcon* CSwtButton::CreateCheckOrRadioIconL(
       
   254     TBool aState, TInt aStyle) const
       
   255 {
       
   256     ASSERT(aStyle & (KSwtStyleCheck | KSwtStyleRadio));
       
   257 
       
   258     TInt bmpId(0);
       
   259     TInt maskId(0);
       
   260     TAknsItemID skinItemId;
       
   261 
       
   262     if (aStyle & KSwtStyleCheck)
       
   263     {
       
   264         if (aState)
       
   265         {
       
   266             skinItemId.Set(KAknsIIDQgnPropCheckboxOn);
       
   267             bmpId = EMbmAvkonQgn_prop_checkbox_on;
       
   268             maskId = EMbmAvkonQgn_prop_checkbox_on_mask;
       
   269         }
       
   270         else
       
   271         {
       
   272             skinItemId.Set(KAknsIIDQgnPropCheckboxOff);
       
   273             bmpId = EMbmAvkonQgn_prop_checkbox_off;
       
   274             maskId = EMbmAvkonQgn_prop_checkbox_off_mask;
       
   275         }
       
   276     }
       
   277     else // KSwtStyleRadio
       
   278     {
       
   279         if (aState)
       
   280         {
       
   281             skinItemId.Set(KAknsIIDQgnPropRadiobuttOn);
       
   282             bmpId = EMbmAvkonQgn_prop_radiobutt_on;
       
   283             maskId = EMbmAvkonQgn_prop_radiobutt_on_mask;
       
   284         }
       
   285         else
       
   286         {
       
   287             skinItemId.Set(KAknsIIDQgnPropRadiobuttOff);
       
   288             bmpId = EMbmAvkonQgn_prop_radiobutt_off;
       
   289             maskId = EMbmAvkonQgn_prop_radiobutt_off_mask;
       
   290         }
       
   291     }
       
   292 
       
   293     return AknsUtils::CreateGulIconL(
       
   294                AknsUtils::SkinInstance(),
       
   295                skinItemId,
       
   296                AknIconUtils::AvkonIconFileName(),
       
   297                bmpId,
       
   298                maskId);
       
   299 }
       
   300 
       
   301 // ---------------------------------------------------------------------------
       
   302 // CSwtButton::ChangeCheckOrRadioIconL
       
   303 // ---------------------------------------------------------------------------
       
   304 //
       
   305 void CSwtButton::ChangeCheckOrRadioIconL(TBool aState)
       
   306 {
       
   307     ASSERT(iStyle & (KSwtStyleCheck | KSwtStyleRadio));
       
   308 
       
   309     CGulIcon* icon = CreateCheckOrRadioIconL(aState, iStyle);
       
   310     if (iButton)
       
   311     {
       
   312         iButton->SetIcon(icon);
       
   313     }
       
   314     iCustomIcon = icon;
       
   315 
       
   316     TSize iconSize(TSize::EUninitialized);
       
   317     GetSizeOfCheckOrRadioIcon(iconSize);
       
   318     SetIconSize(iCustomIcon, iconSize);
       
   319     iButton->SetIconSize(iconSize);
       
   320 }
       
   321 
       
   322 // ---------------------------------------------------------------------------
       
   323 // CSwtButton::SetIconSize
       
   324 // ---------------------------------------------------------------------------
       
   325 //
       
   326 void CSwtButton::SetIconSize(const CGulIcon* aIcon, const TSize& aSize,
       
   327                              TScaleMode aScaleMode) const
       
   328 {
       
   329     if (aIcon)
       
   330     {
       
   331         if (aIcon->Bitmap())
       
   332         {
       
   333             AknIconUtils::SetSize(aIcon->Bitmap(), aSize, aScaleMode);
       
   334         }
       
   335         if (aIcon->Mask())
       
   336         {
       
   337             AknIconUtils::SetSize(aIcon->Mask(), aSize, aScaleMode);
       
   338         }
       
   339     }
       
   340 }
       
   341 
       
   342 // ---------------------------------------------------------------------------
       
   343 // CSwtButton::GetSizeOfCheckOrRadioIcon
       
   344 // ---------------------------------------------------------------------------
       
   345 //
       
   346 void CSwtButton::GetSizeOfCheckOrRadioIcon(TSize& aSize) const
       
   347 {
       
   348     aSize = TSize(0, 0);
       
   349 
       
   350     if (iStyle & (KSwtStyleCheck | KSwtStyleRadio))
       
   351     {
       
   352         TInt variety((iStyle & KSwtStyleRadio) ? 1 : 0);
       
   353 
       
   354         aSize = CSwtLafFacade::GetLayoutRect(
       
   355                     CSwtLafFacade::EControlButtonPaneG2, TRect(), variety).Rect().Size();
       
   356     }
       
   357 }
       
   358 
       
   359 // ---------------------------------------------------------------------------
       
   360 // CSwtButton::UpdateControlSize
       
   361 // ---------------------------------------------------------------------------
       
   362 //
       
   363 void CSwtButton::UpdateControlSize()
       
   364 {
       
   365     if (iButton)
       
   366     {
       
   367         iButton->SetSize(iSize);
       
   368     }
       
   369 
       
   370     if (iStyle & (KSwtStyleCheck | KSwtStyleRadio))
       
   371     {
       
   372         // Update check/radio icon to match the new size of the control
       
   373         TRAP_IGNORE(ChangeCheckOrRadioIconL(iSelected));
       
   374     }
       
   375 
       
   376     if (iButton)
       
   377     {
       
   378         iButton->SetHighlightRect(Rect());
       
   379     }
       
   380 }
       
   381 
       
   382 // ---------------------------------------------------------------------------
       
   383 // CSwtButton::SwtHandleResourceChangeL
       
   384 // ---------------------------------------------------------------------------
       
   385 //
       
   386 void CSwtButton::SwtHandleResourceChangeL(TInt aType)
       
   387 {
       
   388     CCoeControl::HandleResourceChange(aType);
       
   389     if (aType == KAknsMessageSkinChange || aType == KEikDynamicLayoutVariantSwitch)
       
   390     {
       
   391         if (!iFont)
       
   392         {
       
   393             RetrieveDefaultFontL();
       
   394         }
       
   395         else
       
   396         {
       
   397             // Workaround: the custom font (iDupFont) that was passed to button
       
   398             // can be changed by switching resolutions. Here, delete the duplicated
       
   399             // font and a new will be created in ProcessFontUpdate
       
   400             if (iDupFont)
       
   401             {
       
   402                 // delete duplicated font (by removing reference to it)
       
   403                 iDupFont->RemoveRef();
       
   404                 iDupFont = NULL;
       
   405             }
       
   406             ProcessFontUpdate();
       
   407         }
       
   408         if (aType == KAknsMessageSkinChange)
       
   409         {
       
   410             // Refresh radio or check image
       
   411             if (iStyle & (KSwtStyleCheck | KSwtStyleRadio))
       
   412             {
       
   413                 ChangeCheckOrRadioIconL(iSelected);
       
   414             }
       
   415         }
       
   416     }
       
   417 }
       
   418 
       
   419 // ---------------------------------------------------------------------------
       
   420 // CSwtButton::IsFeedbackOnTouchDown
       
   421 // ---------------------------------------------------------------------------
       
   422 //
       
   423 #ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK
       
   424 TBool CSwtButton::IsFeedbackOnTouchDownNeeded(const TPointerEvent& aPointerEvent) const
       
   425 {
       
   426     if (aPointerEvent.iType != TPointerEvent::EButton1Down)
       
   427     {
       
   428         return EFalse;
       
   429     }
       
   430 
       
   431     return ETrue;
       
   432 }
       
   433 #endif
       
   434 
       
   435 // ---------------------------------------------------------------------------
       
   436 // CSwtButton::IsFeedbackOnTouchRelease
       
   437 // ---------------------------------------------------------------------------
       
   438 //
       
   439 #ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK
       
   440 TBool CSwtButton::IsFeedbackOnTouchReleaseNeeded(const TPointerEvent& aPointerEvent) const
       
   441 {
       
   442     if (aPointerEvent.iType != TPointerEvent::EButton1Up)
       
   443     {
       
   444         return EFalse;
       
   445     }
       
   446 
       
   447     // When pointer was dragged out of the visible area of the control,
       
   448     // ther should be no feedback.
       
   449     return VisibleRect(ETrue).Contains(aPointerEvent.iPosition);
       
   450 }
       
   451 #endif
       
   452 
       
   453 // ---------------------------------------------------------------------------
       
   454 // CSwtButton::ComponentControl
       
   455 // From CCoeControl
       
   456 // ---------------------------------------------------------------------------
       
   457 //
       
   458 CCoeControl* CSwtButton::ComponentControl(TInt /*aIndex*/) const
       
   459 {
       
   460     return iButton;
       
   461 }
       
   462 
       
   463 // ---------------------------------------------------------------------------
       
   464 // CSwtButton::CountComponentControls
       
   465 // From CCoeControl
       
   466 // ---------------------------------------------------------------------------
       
   467 //
       
   468 TInt CSwtButton::CountComponentControls() const
       
   469 {
       
   470     return (iButton) ? 1 : 0;
       
   471 }
       
   472 
       
   473 // ---------------------------------------------------------------------------
       
   474 // CSwtButton::MakeVisible
       
   475 // From CCoeControl
       
   476 // ---------------------------------------------------------------------------
       
   477 //
       
   478 void CSwtButton::MakeVisible(TBool aVisible)
       
   479 {
       
   480     CCoeControl::MakeVisible(aVisible);
       
   481     FocusabilityChanged();
       
   482 }
       
   483 
       
   484 // ---------------------------------------------------------------------------
       
   485 // CSwtButton::SetDimmed
       
   486 // From CCoeControl
       
   487 // ---------------------------------------------------------------------------
       
   488 //
       
   489 void CSwtButton::SetDimmed(TBool aDimmed)
       
   490 {
       
   491     ASSERT(iButton);
       
   492 
       
   493     CCoeControl::SetDimmed(aDimmed);
       
   494 
       
   495     if (iButton)
       
   496     {
       
   497         iButton->SetDimmed(aDimmed);
       
   498     }
       
   499 
       
   500     FocusabilityChanged();
       
   501 }
       
   502 
       
   503 // ---------------------------------------------------------------------------
       
   504 // CSwtButton::OfferKeyEventL
       
   505 // From CCoeControl
       
   506 // ---------------------------------------------------------------------------
       
   507 //
       
   508 TKeyResponse CSwtButton::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType)
       
   509 {
       
   510     TBool traversalDoIt = ETrue;
       
   511 
       
   512     // Enter key is used to traverse_return the Shell, which means a default
       
   513     // button can get selected. Only the Selection key is a sure thing.
       
   514     if (aKeyEvent.iCode == EKeyOK)
       
   515     {
       
   516         traversalDoIt = EFalse;
       
   517     }
       
   518 
       
   519     return HandleKeyL(aKeyEvent, aType, traversalDoIt);
       
   520 }
       
   521 
       
   522 // ---------------------------------------------------------------------------
       
   523 // CSwtButton::HandleResourceChange
       
   524 // From CCoeControl
       
   525 // ---------------------------------------------------------------------------
       
   526 //
       
   527 void CSwtButton::HandleResourceChange(TInt aType)
       
   528 {
       
   529     TRAP_IGNORE(SwtHandleResourceChangeL(aType));
       
   530 }
       
   531 
       
   532 // ---------------------------------------------------------------------------
       
   533 // CSwtButton::PositionChanged
       
   534 // From CCoeControl
       
   535 // ---------------------------------------------------------------------------
       
   536 //
       
   537 void CSwtButton::PositionChanged()
       
   538 {
       
   539     if (iButton)
       
   540     {
       
   541         iButton->SetPosition(iPosition);
       
   542         iButton->SetHighlightRect(Rect());
       
   543     }
       
   544     HandlePositionChanged();
       
   545 }
       
   546 
       
   547 // ---------------------------------------------------------------------------
       
   548 // CSwtButton::SizeChanged
       
   549 // From CCoeControl
       
   550 // ---------------------------------------------------------------------------
       
   551 //
       
   552 void CSwtButton::SizeChanged()
       
   553 {
       
   554     UpdateControlSize();
       
   555     HandleSizeChanged();
       
   556 }
       
   557 
       
   558 // ---------------------------------------------------------------------------
       
   559 // CSwtButton::FocusChanged
       
   560 // From CCoeControl
       
   561 // ---------------------------------------------------------------------------
       
   562 //
       
   563 void CSwtButton::FocusChanged(TDrawNow aDrawNow)
       
   564 {
       
   565     TBool isFocused = IsFocusControl();
       
   566     if (iButton)
       
   567     {
       
   568         if (iDisplay.UiUtils().NaviKeyInput())
       
   569         {
       
   570             iButton->SetFocus(isFocused, aDrawNow);
       
   571         }
       
   572         else
       
   573         {
       
   574             // This is to eliminate the key focus highlight indication.
       
   575             if (iButton->IsFocused())
       
   576                 iButton->SetFocus(EFalse, aDrawNow);
       
   577         }
       
   578     }
       
   579     HandleFocusChanged(aDrawNow);
       
   580 }
       
   581 
       
   582 // ---------------------------------------------------------------------------
       
   583 // CSwtButton::MopSupplyObject
       
   584 // From CCoeControl
       
   585 // ---------------------------------------------------------------------------
       
   586 //
       
   587 TTypeUid::Ptr CSwtButton::MopSupplyObject(TTypeUid aId)
       
   588 {
       
   589     TTypeUid::Ptr id = ASwtControlBase::SwtMopSupplyObject(aId);
       
   590 
       
   591     if (id.Pointer() == NULL)
       
   592     {
       
   593         return CCoeControl::MopSupplyObject(aId);
       
   594     }
       
   595     else
       
   596     {
       
   597         return id;
       
   598     }
       
   599 }
       
   600 
       
   601 // ---------------------------------------------------------------------------
       
   602 // CSwtButton::SetFontL
       
   603 // From ASwtControlbase
       
   604 // ---------------------------------------------------------------------------
       
   605 //
       
   606 void CSwtButton::SetFontL(const MSwtFont* aFont)
       
   607 {
       
   608     ASwtControlBase::DoSetFontL(aFont);
       
   609 
       
   610     // Workaround: the custom font (iDupFont) that was passed to button can be changed by switching resolutions.
       
   611     // So, we don't directly pass iFont to button. Instead, we pass a duplicate font, iDupFont, to button.
       
   612     if (iDupFont)
       
   613     {
       
   614         // delete the old duplicated font (by removing reference to it) and
       
   615         // a new one will be duplicated in ProcessFontUpdate
       
   616         iDupFont->RemoveRef();
       
   617         iDupFont = NULL;
       
   618     }
       
   619 
       
   620     if (iButton)
       
   621     {
       
   622         ProcessFontUpdate();
       
   623     }
       
   624 
       
   625     Redraw();
       
   626 }
       
   627 
       
   628 // ---------------------------------------------------------------------------
       
   629 // CSwtButton::SetForegroundL
       
   630 // From ASwtControlbase
       
   631 // ---------------------------------------------------------------------------
       
   632 //
       
   633 void CSwtButton::SetForegroundL(const MSwtColor* aColor)
       
   634 {
       
   635     TRgb color;
       
   636 
       
   637     if (aColor)
       
   638     {
       
   639         color = aColor->RgbValue();
       
   640     }
       
   641     else
       
   642     {
       
   643         // Reset to default color
       
   644         AknsUtils::GetCachedColor(AknsUtils::SkinInstance(),
       
   645                                   color,
       
   646                                   KAknsIIDQsnTextColors,
       
   647                                   EAknsCIQsnTextColorsCG63); // Messaging touch buttons
       
   648     }
       
   649 
       
   650     if (iButton)
       
   651     {
       
   652         iButton->OverrideColorL(EColorButtonText, color);
       
   653     }
       
   654 
       
   655     ASwtControlBase::DoSetForegroundL(aColor);
       
   656     Redraw();
       
   657 }
       
   658 
       
   659 // ---------------------------------------------------------------------------
       
   660 // CSwtButton::DefaultFont
       
   661 // From ASwtControlbase
       
   662 // ---------------------------------------------------------------------------
       
   663 //
       
   664 const MSwtFont& CSwtButton::DefaultFont() const
       
   665 {
       
   666     ASSERT(iDefaultFont!=NULL);
       
   667     return *iDefaultFont;
       
   668 }
       
   669 
       
   670 // ---------------------------------------------------------------------------
       
   671 // CSwtButton::CoeControl
       
   672 // From MSwtControl
       
   673 // ---------------------------------------------------------------------------
       
   674 //
       
   675 CCoeControl& CSwtButton::CoeControl()
       
   676 {
       
   677     return *this;
       
   678 }
       
   679 
       
   680 // ---------------------------------------------------------------------------
       
   681 // CSwtButton::CoeControl
       
   682 // From MSwtControl
       
   683 // ---------------------------------------------------------------------------
       
   684 //
       
   685 const CCoeControl& CSwtButton::CoeControl() const
       
   686 {
       
   687     return *this;
       
   688 }
       
   689 
       
   690 // ---------------------------------------------------------------------------
       
   691 // CSwtButton::ProcessKeyEventL
       
   692 // From MSwtControl
       
   693 // ---------------------------------------------------------------------------
       
   694 //
       
   695 void CSwtButton::ProcessKeyEventL(const TKeyEvent& aKeyEvent,
       
   696                                   TEventCode aType)
       
   697 {
       
   698     // Do not pass SKs to CAknButton as it will activate.
       
   699     if (iButton && (aKeyEvent.iScanCode != EStdKeyDevice0 && aKeyEvent.iScanCode != EStdKeyDevice1))
       
   700     {        
       
   701         TBool forward(EFalse);
       
   702         if ((iStyle & KSwtStyleRadio)
       
   703                 && (GetParent()->Control()->CaptionedControlInterface() == NULL)
       
   704                 && ((GetParent()->Control()->Style() & KSwtStyleNoRadioGroup) == 0))
       
   705         {
       
   706             if (!GetSelection())
       
   707             {
       
   708                 forward = ETrue;
       
   709             }
       
   710         }
       
   711         else
       
   712         {
       
   713             forward = ETrue;
       
   714         }
       
   715         
       
   716         if (forward)
       
   717         {
       
   718             if (aKeyEvent.iScanCode == EStdKeyNkpEnter) {
       
   719                 // Workaround for CAknButton's inability to handle EKeyEnter correctly
       
   720                 TKeyEvent ev;
       
   721                 ev.iCode = aKeyEvent.iCode;
       
   722                 ev.iModifiers = aKeyEvent.iModifiers;
       
   723                 ev.iRepeats = aKeyEvent.iRepeats;
       
   724                 ev.iScanCode = EStdKeyEnter;
       
   725                 iButton->OfferKeyEventL(ev, aType);
       
   726             }
       
   727             else
       
   728             {
       
   729                 iButton->OfferKeyEventL(aKeyEvent, aType);
       
   730             }
       
   731         }
       
   732     }
       
   733 }
       
   734 
       
   735 // ---------------------------------------------------------------------------
       
   736 // CSwtButton::IsKeyUsed
       
   737 // From MSwtControl
       
   738 // ---------------------------------------------------------------------------
       
   739 //
       
   740 TBool CSwtButton::IsKeyUsed(TUint aKeyCode) const
       
   741 {
       
   742     if (aKeyCode == EKeyBackspace)
       
   743     {
       
   744         return EFalse;
       
   745     }
       
   746     else if (aKeyCode == EKeyOK)
       
   747     {
       
   748         return ETrue;
       
   749     }
       
   750     return EFalse;
       
   751 }
       
   752 
       
   753 // ---------------------------------------------------------------------------
       
   754 // CSwtButton::ComputeSizeL
       
   755 // From MSwtControl
       
   756 // ---------------------------------------------------------------------------
       
   757 //
       
   758 TSize CSwtButton::ComputeSizeL(TInt aWHint, TInt aHHint)
       
   759 {
       
   760     if (aWHint != KSwtDefault && aHHint != KSwtDefault)
       
   761     {
       
   762         return TSize(aWHint, aHHint);
       
   763     }
       
   764 
       
   765     ASSERT(iButton);
       
   766 
       
   767     // Icon size
       
   768     const CGulIcon* icon = iButton->Icon();
       
   769     TSize iconSize(0, 0);
       
   770     if (icon)
       
   771     {
       
   772         if (icon->Bitmap())
       
   773         {
       
   774             iconSize = icon->Bitmap()->SizeInPixels();
       
   775         }
       
   776     }
       
   777     else if (iStyle & (KSwtStyleCheck | KSwtStyleRadio))
       
   778     {
       
   779         GetSizeOfCheckOrRadioIcon(iconSize);
       
   780     }
       
   781 
       
   782     // Text size
       
   783     const MSwtFont* font = GetFont();
       
   784     ASSERT(font);
       
   785     TSize textSize(0, font->Font().FontMaxHeight());
       
   786     if (font == &DefaultFont())
       
   787     {
       
   788         textSize.iHeight = Max(iDisplay.UiUtils().InlineReferenceFontHeight(), textSize.iHeight);
       
   789     }
       
   790     if (iButton->Text().Length())
       
   791     {
       
   792         textSize.iWidth += font->TextWidthInPixels(iButton->Text());
       
   793     }
       
   794 
       
   795     // Icon & text size
       
   796     TSize res(iDisplay.UiUtils().InlineReferencePadding().SizeDelta());
       
   797     res.iWidth += iconSize.iWidth + textSize.iWidth;
       
   798     res.iHeight += Max(iconSize.iHeight, textSize.iHeight);
       
   799     res += BorderSizeDelta();
       
   800 
       
   801     if (aWHint != KSwtDefault)
       
   802     {
       
   803         res.iWidth = aWHint;
       
   804     }
       
   805     if (aHHint != KSwtDefault)
       
   806     {
       
   807         res.iHeight = aHHint;
       
   808     }
       
   809 
       
   810     return res;
       
   811 }
       
   812 
       
   813 // ---------------------------------------------------------------------------
       
   814 // CSwtButton::ButtonInterface
       
   815 // From MSwtControl
       
   816 // ---------------------------------------------------------------------------
       
   817 //
       
   818 MSwtButton* CSwtButton::ButtonInterface()
       
   819 {
       
   820     return this;
       
   821 }
       
   822 
       
   823 // ---------------------------------------------------------------------------
       
   824 // CSwtButton::FocusBackgroundPolicy
       
   825 // From MSwtControl
       
   826 // ---------------------------------------------------------------------------
       
   827 //
       
   828 TInt CSwtButton::FocusBackgroundPolicy() const
       
   829 {
       
   830     return EEmbeddedFocusBackground;
       
   831 };
       
   832 
       
   833 // ---------------------------------------------------------------------------
       
   834 // CSwtButton::Control
       
   835 // From MSwtButton
       
   836 // ---------------------------------------------------------------------------
       
   837 //
       
   838 MSwtControl* CSwtButton::Control()
       
   839 {
       
   840     return this;
       
   841 }
       
   842 
       
   843 // ---------------------------------------------------------------------------
       
   844 // CSwtButton::GetSelection
       
   845 // From MSwtButton
       
   846 // ---------------------------------------------------------------------------
       
   847 //
       
   848 TBool CSwtButton::GetSelection() const
       
   849 {
       
   850     return iSelected;
       
   851 }
       
   852 
       
   853 // ---------------------------------------------------------------------------
       
   854 // CSwtButton::SetSelection
       
   855 // From MSwtButton
       
   856 // ---------------------------------------------------------------------------
       
   857 //
       
   858 void CSwtButton::SetSelection(TBool aState)
       
   859 {
       
   860     if (iSelected != aState)
       
   861     {
       
   862         if (!(iStyle & KSwtStylePush))
       
   863         {
       
   864             iSelected = aState;
       
   865 
       
   866             TRAP_IGNORE(ChangeStateL(aState));
       
   867 
       
   868             Redraw();
       
   869         }
       
   870 
       
   871         if (iSelected
       
   872                 && (iStyle & KSwtStyleRadio)
       
   873                 && (GetParent()->Control()->CaptionedControlInterface() == NULL)
       
   874                 && ((GetParent()->Control()->Style() & KSwtStyleNoRadioGroup) == 0))
       
   875         {
       
   876             GetParent()->NotifyRadioGroup(this);
       
   877         }
       
   878     }
       
   879     //MSK label update needed.
       
   880     if (AknLayoutUtils::MSKEnabled() && ((iStyle & KSwtStyleRadio) || (iStyle & KSwtStyleCheck)))
       
   881     {
       
   882         MSwtCommandArranger* commandArranger = iDisplay.CommandArranger();
       
   883         if (commandArranger)
       
   884         {
       
   885             TRAP_IGNORE(commandArranger->UpdateMSKLabelL()) ;
       
   886         }
       
   887     }
       
   888 
       
   889 }
       
   890 
       
   891 // ---------------------------------------------------------------------------
       
   892 // CSwtButton::GetAlignment
       
   893 // From MSwtButton
       
   894 // ---------------------------------------------------------------------------
       
   895 //
       
   896 TInt CSwtButton::GetAlignment() const
       
   897 {
       
   898     return iStyle & KSwtAlignmentMask;
       
   899 }
       
   900 
       
   901 // ---------------------------------------------------------------------------
       
   902 // CSwtButton::SetAlignment
       
   903 // From MSwtButton
       
   904 // ---------------------------------------------------------------------------
       
   905 //
       
   906 void CSwtButton::SetAlignment(TInt aAlignment)
       
   907 {
       
   908     CGraphicsContext::TTextAlign aHorizontalAlignment;
       
   909     CSwtButtonProxy::TAlignment aIconAlignment;
       
   910 
       
   911     iStyle &= ~KSwtAlignmentMask;
       
   912     iStyle |= (aAlignment & KSwtAlignmentMask);
       
   913 
       
   914     if (aAlignment == KSwtStyleCenter)         // Center
       
   915     {
       
   916         aHorizontalAlignment = CGraphicsContext::ECenter;
       
   917         aIconAlignment = CSwtButtonProxy::ECenter;
       
   918     }
       
   919     else if (aAlignment == KSwtStyleTrail)     // Trail
       
   920     {
       
   921         if ((iStyle & KSwtOrientationMask) == KSwtStyleRightToLeft
       
   922                 || AknLayoutUtils::LayoutMirrored())
       
   923         {
       
   924             aHorizontalAlignment = CGraphicsContext::ELeft;
       
   925             aIconAlignment = CSwtButtonProxy::ELeft;
       
   926         }
       
   927         else
       
   928         {
       
   929             aHorizontalAlignment = CGraphicsContext::ERight;
       
   930             aIconAlignment = CSwtButtonProxy::ERight;
       
   931         }
       
   932     }
       
   933     else                                    // Lead ( default )
       
   934     {
       
   935         ASSERT(aAlignment==KSwtStyleLead);
       
   936         if ((iStyle & KSwtOrientationMask) == KSwtStyleRightToLeft
       
   937                 || AknLayoutUtils::LayoutMirrored())
       
   938         {
       
   939             aHorizontalAlignment = CGraphicsContext::ERight;
       
   940             aIconAlignment = CSwtButtonProxy::ERight;
       
   941         }
       
   942         else
       
   943         {
       
   944             aHorizontalAlignment = CGraphicsContext::ELeft;
       
   945             aIconAlignment = CSwtButtonProxy::ELeft;
       
   946         }
       
   947     }
       
   948 
       
   949     if (iButton)
       
   950     {
       
   951         iButton->SetTextHorizontalAlignment(aHorizontalAlignment);
       
   952         iButton->SetIconHorizontalAlignment(aIconAlignment);
       
   953     }
       
   954 
       
   955     Redraw();
       
   956 }
       
   957 
       
   958 // ---------------------------------------------------------------------------
       
   959 // CSwtButton::SetImageL
       
   960 // From MSwtButton
       
   961 // ---------------------------------------------------------------------------
       
   962 //
       
   963 void CSwtButton::SetImageL(const MSwtImage* aImage)
       
   964 {
       
   965     if (iStyle & (KSwtStylePush | KSwtStyleToggle))
       
   966     {
       
   967         if (iImage != NULL)
       
   968         {
       
   969             iImage->RemoveRef();
       
   970         }
       
   971 
       
   972         iImage = NULL;
       
   973         CGulIcon* img = NULL;
       
   974         if (aImage != NULL)
       
   975         {
       
   976             CFbsBitmap* bmp = SwtControlHelper::GetCopyOfBitmapLC(
       
   977                                   &aImage->Bitmap());
       
   978             ASSERT(bmp != NULL);
       
   979             CFbsBitmap* mask   = SwtControlHelper::GetInvertedCopyOfMonoBitmapLC(
       
   980                                      aImage->MaskBitmap());
       
   981             img = CGulIcon::NewL(bmp, mask);
       
   982             if (mask)
       
   983             {
       
   984                 CleanupStack::Pop(mask);
       
   985             }
       
   986             CleanupStack::Pop(bmp);
       
   987 
       
   988             iImage = aImage;
       
   989             iImage->AddRef();
       
   990         }
       
   991 
       
   992         if (iButton)
       
   993         {
       
   994             iButton->SetIcon(img);
       
   995         }
       
   996         Redraw();
       
   997     }
       
   998 }
       
   999 
       
  1000 // ---------------------------------------------------------------------------
       
  1001 // CSwtButton::SetTextL
       
  1002 // From MSwtButton
       
  1003 // ---------------------------------------------------------------------------
       
  1004 //
       
  1005 void CSwtButton::SetTextL(const TDesC& aText)
       
  1006 {
       
  1007     if (iButton)
       
  1008     {
       
  1009         iButton->SetTextL(aText);
       
  1010     }
       
  1011     Redraw();
       
  1012 }
       
  1013 
       
  1014 // ---------------------------------------------------------------------------
       
  1015 // CSwtButton::SetDefault
       
  1016 // From MSwtButton
       
  1017 // ---------------------------------------------------------------------------
       
  1018 //
       
  1019 void CSwtButton::SetDefault(TBool aDefault)
       
  1020 {
       
  1021     ASSERT(iStyle & KSwtStylePush);
       
  1022 
       
  1023     if (iIsDefault != aDefault)
       
  1024     {
       
  1025         iIsDefault = aDefault;
       
  1026 
       
  1027         if (iButton)
       
  1028         {
       
  1029             iButton->SetTextUnderlineStyle(iIsDefault ? EUnderlineOn : EUnderlineOff);
       
  1030         }
       
  1031 
       
  1032         Redraw();
       
  1033     }
       
  1034 }
       
  1035 
       
  1036 // ---------------------------------------------------------------------------
       
  1037 // CSwtButton::IsDefault
       
  1038 // From MSwtButton
       
  1039 // ---------------------------------------------------------------------------
       
  1040 //
       
  1041 TBool CSwtButton::IsDefault() const
       
  1042 {
       
  1043     return iIsDefault;
       
  1044 }
       
  1045 
       
  1046 // ---------------------------------------------------------------------------
       
  1047 // CSwtButton::ClickL
       
  1048 // From MSwtButton
       
  1049 // ---------------------------------------------------------------------------
       
  1050 //
       
  1051 void CSwtButton::ClickL()
       
  1052 {
       
  1053     SetSwtFocus(KSwtFocusByForce);
       
  1054     TKeyEvent ev;
       
  1055     ev.iScanCode = EStdKeyEnter;
       
  1056     ev.iCode = 0;
       
  1057     ev.iRepeats = 0;
       
  1058     ev.iModifiers = 0;
       
  1059     iButton->OfferKeyEventL(ev, EEventKeyDown);
       
  1060     iButton->OfferKeyEventL(ev, EEventKey);
       
  1061     iButton->OfferKeyEventL(ev, EEventKeyUp);
       
  1062 }
       
  1063 
       
  1064 // ---------------------------------------------------------------------------
       
  1065 // CSwtButton::HandleControlEventL
       
  1066 // From MCoeControlObserver
       
  1067 // ---------------------------------------------------------------------------
       
  1068 //
       
  1069 void CSwtButton::HandleControlEventL(CCoeControl* aControl, TCoeEvent aEventType)
       
  1070 {
       
  1071     if (aEventType == MCoeControlObserver::EEventStateChanged && aControl == iButton)
       
  1072     {
       
  1073 #ifdef RD_SCALABLE_UI_V2
       
  1074         if (!iDisplay.RevertPointerEvent())
       
  1075         {
       
  1076             SetSelection(!GetSelection());
       
  1077             // Notify the Selection
       
  1078             TRAP_IGNORE(iDisplay.PostSelectionEventL(iPeer));
       
  1079         }
       
  1080 #else
       
  1081         SetSelection(!GetSelection());
       
  1082         // Notify the Selection
       
  1083         TRAP_IGNORE(iDisplay.PostSelectionEventL(iPeer));
       
  1084 #endif //RD_SCALABLE_UI_V2
       
  1085     }
       
  1086 }
       
  1087 
       
  1088 #ifdef RD_SCALABLE_UI_V2
       
  1089 void CSwtButton::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
  1090 {
       
  1091     if (!iButton)
       
  1092         return;
       
  1093 
       
  1094     // This is to eliminate the key focus highlight indication.
       
  1095     if (iButton->IsFocused())
       
  1096         iButton->SetFocus(EFalse, ENoDrawNow);
       
  1097 
       
  1098     if ((iStyle & KSwtStyleRadio)
       
  1099             && (GetParent()->Control()->CaptionedControlInterface() == NULL)
       
  1100             && ((GetParent()->Control()->Style() & KSwtStyleNoRadioGroup) == 0))
       
  1101     {
       
  1102         if (!GetSelection())
       
  1103         {
       
  1104 #ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK
       
  1105             //Because native button supports only one feedback, we
       
  1106             //have to do it by ourselves here. To avoid double feedback,
       
  1107             //native button has feedback disabled
       
  1108             //(see CSwtButtonProxy::HandlePointerEventL).
       
  1109             if (IsFeedbackOnTouchDownNeeded(aPointerEvent) ||
       
  1110                     IsFeedbackOnTouchReleaseNeeded(aPointerEvent))
       
  1111             {
       
  1112                 //The same feedback for RADIO button is given
       
  1113                 //on touch down and release
       
  1114                 iFeedback->InstantFeedback(ETouchFeedbackBasicButton);
       
  1115             }
       
  1116 #endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK
       
  1117             iButton->HandlePointerEventL(aPointerEvent);
       
  1118         }
       
  1119     }
       
  1120     else
       
  1121     {
       
  1122 #ifdef RD_JAVA_ADVANCED_TACTILE_FEEDBACK
       
  1123         //Do feedback for other styles
       
  1124         if (iStyle & KSwtStylePush)
       
  1125         {
       
  1126             if (IsFeedbackOnTouchDownNeeded(aPointerEvent))
       
  1127             {
       
  1128                 iFeedback->InstantFeedback(ETouchFeedbackBasicButton);
       
  1129             }
       
  1130             if (IsFeedbackOnTouchReleaseNeeded(aPointerEvent))
       
  1131             {
       
  1132                 iFeedback->EnableFeedbackForControl(this, ETrue, EFalse);
       
  1133                 iFeedback->InstantFeedback(this, ETouchFeedbackBasicButton);
       
  1134                 iFeedback->EnableFeedbackForControl(this, EFalse);
       
  1135             }
       
  1136         }
       
  1137         else if (iStyle & KSwtStyleCheck)
       
  1138         {
       
  1139             //Feedabck for CHECK button
       
  1140             if (IsFeedbackOnTouchDownNeeded(aPointerEvent))
       
  1141             {
       
  1142                 iFeedback->InstantFeedback(ETouchFeedbackSensitiveButton);
       
  1143             }
       
  1144             if (IsFeedbackOnTouchReleaseNeeded(aPointerEvent))
       
  1145             {
       
  1146                 iFeedback->InstantFeedback(ETouchFeedbackCheckbox);
       
  1147             }
       
  1148         }
       
  1149         else if (iStyle && KSwtStyleToggle)
       
  1150         {
       
  1151             //Feedback for TOGGLE button
       
  1152             CSwtButtonStateProxy* state = iButton->State();
       
  1153             if (state)
       
  1154             {
       
  1155                 //first we need to check if button is toggled (latched)
       
  1156                 TInt flags = state->Flags();
       
  1157                 if (flags & KAknButtonStateHasLatchedFrame)
       
  1158                 {
       
  1159                     //latched
       
  1160                     if (IsFeedbackOnTouchDownNeeded(aPointerEvent))
       
  1161                     {
       
  1162                         iFeedback->InstantFeedback(ETouchFeedbackSensitiveButton);
       
  1163                     }
       
  1164                     if (IsFeedbackOnTouchReleaseNeeded(aPointerEvent))
       
  1165                     {
       
  1166                         iFeedback->InstantFeedback(ETouchFeedbackBasicButton);
       
  1167                     }
       
  1168                 }
       
  1169                 else
       
  1170                 {
       
  1171                     //unlatched
       
  1172                     if (IsFeedbackOnTouchDownNeeded(aPointerEvent))
       
  1173                     {
       
  1174                         //If button is not latched, only feedback on touch down
       
  1175                         //is given.
       
  1176                         iFeedback->InstantFeedback(ETouchFeedbackBasicButton);
       
  1177                     }
       
  1178                 }
       
  1179             }
       
  1180         }
       
  1181 #endif //RD_JAVA_ADVANCED_TACTILE_FEEDBACK
       
  1182         iButton->HandlePointerEventL(aPointerEvent);
       
  1183     }
       
  1184 }
       
  1185 #endif // RD_SCALABLE_UI_V2
       
  1186 
       
  1187 // ---------------------------------------------------------------------------
       
  1188 // CSwtButton::MSKLabelL
       
  1189 // From ASwtControlBase
       
  1190 // ---------------------------------------------------------------------------
       
  1191 //
       
  1192 HBufC* CSwtButton::MSKLabelL() const
       
  1193 {
       
  1194     HBufC* label = NULL;
       
  1195     if ((iStyle & KSwtStylePush))
       
  1196     {
       
  1197         label = iEikonEnv->AllocReadResourceL(R_QTN_MSK_SELECT);
       
  1198     }
       
  1199     else if (iStyle & KSwtStyleToggle)
       
  1200     {
       
  1201         label = iEikonEnv->AllocReadResourceL(R_QTN_MSK_CHANGE);
       
  1202     }
       
  1203     else if (iStyle & KSwtStyleCheck)
       
  1204     {
       
  1205         label = iSelected ? iEikonEnv->AllocReadResourceL(R_QTN_MSK_UNMARK) : iEikonEnv->AllocReadResourceL(R_QTN_MSK_MARK);
       
  1206     }
       
  1207     else if ((iStyle & KSwtStyleRadio))
       
  1208     {
       
  1209         if (GetSelection())
       
  1210         {
       
  1211             return ASwtControlBase::MSKLabelL();
       
  1212         }
       
  1213         label = iEikonEnv->AllocReadResourceL(R_QTN_MSK_SELECT);
       
  1214     }
       
  1215 
       
  1216     ASSERT(label);
       
  1217     return label;
       
  1218 }