idlehomescreen/nativeuicontroller/src/aitoolbarbutton.cpp
changeset 0 f72a12da539e
equal deleted inserted replaced
-1:000000000000 0:f72a12da539e
       
     1 /*
       
     2 * Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Touch Toolbar button
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <aknbutton.h>
       
    20 #include <gulicon.h>
       
    21 
       
    22 #include "aitoolbarbutton.h"
       
    23 
       
    24 using namespace AiNativeUiController;
       
    25 
       
    26 CAiToolbarButton* CAiToolbarButton::NewL()
       
    27     {
       
    28     CAiToolbarButton* self = new (ELeave) CAiToolbarButton;
       
    29     CleanupStack::PushL( self );
       
    30     self->ConstructL();
       
    31     CleanupStack::Pop( self );
       
    32     return self;
       
    33     }
       
    34 
       
    35 void CAiToolbarButton::ConstructL()
       
    36     {
       
    37     iIconNotOwned = EFalse;
       
    38     iTooltip = KNullDesC().AllocL();
       
    39     }
       
    40 
       
    41 CAiToolbarButton::~CAiToolbarButton()
       
    42     {
       
    43 
       
    44     if ( !iIconNotOwned )
       
    45         {
       
    46         delete iIcon;
       
    47         iIcon = NULL;
       
    48         }
       
    49     delete iTooltip;
       
    50     iTooltip = NULL;
       
    51     }
       
    52 
       
    53 CAiToolbarButton::CAiToolbarButton()
       
    54     {
       
    55     // no implementation
       
    56     }
       
    57 
       
    58 void CAiToolbarButton::SetShortcutId( TInt aId )
       
    59     {
       
    60     iShortcutId = aId;
       
    61     }
       
    62 
       
    63 TInt CAiToolbarButton::ShortcutId()
       
    64     {
       
    65     return iShortcutId;
       
    66     }
       
    67 
       
    68 TDesC& CAiToolbarButton::Tooltip()
       
    69     {
       
    70     return *iTooltip;
       
    71     }
       
    72 
       
    73 
       
    74 CGulIcon* CAiToolbarButton::Icon( TBool aTransferOwnership )
       
    75     {
       
    76     iIconNotOwned = aTransferOwnership;
       
    77     CGulIcon* icon = iIcon;
       
    78     if(iIconNotOwned)
       
    79         {
       
    80         iIcon = NULL;
       
    81         }
       
    82 
       
    83     return icon;
       
    84     }
       
    85 
       
    86 void CAiToolbarButton::SetTooltipL( const TDesC& aTooltip )
       
    87     {
       
    88     HBufC *temp = aTooltip.AllocL();
       
    89     delete iTooltip;
       
    90     iTooltip = temp;
       
    91     }
       
    92 
       
    93 void CAiToolbarButton::SetIcon( CGulIcon *aIcon, TBool aTransferOwnership )
       
    94     {
       
    95     if ( !iIconNotOwned )
       
    96         {
       
    97         delete iIcon;
       
    98         iIcon = NULL;
       
    99         }
       
   100     iIconNotOwned = aTransferOwnership;
       
   101     iIcon = aIcon;
       
   102     }
       
   103 
       
   104 void CAiToolbarButton::SetIconExternallyOwned( TBool aValue )
       
   105     {
       
   106     iIconNotOwned = aValue;
       
   107     }
       
   108 
       
   109 CAknButton* CAiToolbarButton::ButtonL()
       
   110     {
       
   111     // Icon ownership transferred to CAknButton
       
   112     return CAknButton::NewL( Icon( ETrue ),
       
   113                              NULL,
       
   114                              NULL,
       
   115                              NULL,
       
   116                              KNullDesC,
       
   117                              Tooltip(),
       
   118                              KAknButtonSizeFitText | KAknButtonReportOnLongPress,
       
   119                              0 );
       
   120     }
       
   121