javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/src/swttasktip.cpp
changeset 23 98ccebc37403
parent 21 2a9601315dfc
child 26 dc7c549001d5
child 32 8ba170b5d5e1
equal deleted inserted replaced
21:2a9601315dfc 23:98ccebc37403
     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 <swtlaffacade.h>
       
    14 #include "swttasktip.h"
       
    15 
       
    16 
       
    17 const TInt KVariationFullScreen = 3;
       
    18 const TInt KVariationWindow = 0;
       
    19 const TInt KVariationWindowBarOrTextOnly = 1;
       
    20 const TInt KVariationBar = 0;
       
    21 const TInt KVariationBarOnly = 1;
       
    22 const TInt KVariationLabel = 0;
       
    23 const TInt KVariationLabelOnly = 1;
       
    24 
       
    25 
       
    26 // ======== MEMBER FUNCTIONS ========
       
    27 
       
    28 
       
    29 // ---------------------------------------------------------------------------
       
    30 // CSwtTaskTip::NewL
       
    31 // ---------------------------------------------------------------------------
       
    32 //
       
    33 CSwtTaskTip* CSwtTaskTip::NewL(MSwtDisplay& aDisplay, TSwtPeer aPeer, TInt aStyle)
       
    34 {
       
    35     CSwtTaskTip* self = new(ELeave) CSwtTaskTip(aDisplay, aPeer, aStyle);
       
    36     CleanupStack::PushL(self);
       
    37     self->ConstructL();
       
    38     CleanupStack::Pop(self);
       
    39     return self;
       
    40 }
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 // CSwtTaskTip::Dispose
       
    44 // From MSwtTaskTip
       
    45 // ---------------------------------------------------------------------------
       
    46 //
       
    47 TSwtPeer CSwtTaskTip::Dispose()
       
    48 {
       
    49     TSwtPeer peer(JavaPeer());
       
    50     delete this;
       
    51     return peer;
       
    52 }
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // CSwtTaskTip::JavaPeer
       
    56 // From MSwtTaskTip
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 TSwtPeer CSwtTaskTip::JavaPeer() const
       
    60 {
       
    61     return iPeer;
       
    62 }
       
    63 
       
    64 // ---------------------------------------------------------------------------
       
    65 // CSwtTaskTip::GetBarDefaultBounds
       
    66 // From MSwtTaskTip
       
    67 // ---------------------------------------------------------------------------
       
    68 //
       
    69 TRect CSwtTaskTip::GetBarDefaultBounds(TBool aHasText) const
       
    70 {
       
    71     if (aHasText
       
    72             && (((iStyle & KSwtStyleIndeterminate) != 0)
       
    73                 || ((iStyle & KSwtStyleSmooth) != 0)))
       
    74     {
       
    75         return iRectBar;
       
    76     }
       
    77     else
       
    78     {
       
    79         return iRectBarOnly;
       
    80     }
       
    81 }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // CSwtTaskTip::GetLabelDefaultBounds
       
    85 // From MSwtTaskTip
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 TRect CSwtTaskTip::GetLabelDefaultBounds(TBool aHasText) const
       
    89 {
       
    90     if (aHasText
       
    91             && (((iStyle & KSwtStyleIndeterminate) != 0)
       
    92                 || ((iStyle & KSwtStyleSmooth) != 0)))
       
    93     {
       
    94         return iRectLabel;
       
    95     }
       
    96     else
       
    97     {
       
    98         return iRectLabelOnly;
       
    99     }
       
   100 }
       
   101 
       
   102 // ---------------------------------------------------------------------------
       
   103 // CSwtTaskTip::GetShellDefaultBounds
       
   104 // From MSwtTaskTip
       
   105 // ---------------------------------------------------------------------------
       
   106 //
       
   107 TRect CSwtTaskTip::GetShellDefaultBounds(TBool aHasText) const
       
   108 {
       
   109     if (aHasText
       
   110             && (((iStyle & KSwtStyleIndeterminate) != 0)
       
   111                 || ((iStyle & KSwtStyleSmooth) != 0)))
       
   112     {
       
   113         return iRectShell;
       
   114     }
       
   115     else
       
   116     {
       
   117         return iRectShellBarOrLabelOnly;
       
   118     }
       
   119 }
       
   120 
       
   121 // ---------------------------------------------------------------------------
       
   122 // CSwtTaskTip::OfferResourceChangeL
       
   123 // From MSwtResourceChangeObserver
       
   124 // ---------------------------------------------------------------------------
       
   125 //
       
   126 void CSwtTaskTip::OfferResourceChangeL(TInt aType)
       
   127 {
       
   128     if (aType == KEikDynamicLayoutVariantSwitch)
       
   129     {
       
   130         UpdateLayout();
       
   131     }
       
   132 }
       
   133 
       
   134 // ---------------------------------------------------------------------------
       
   135 // CSwtTaskTip::CSwtTaskTip
       
   136 // ---------------------------------------------------------------------------
       
   137 //
       
   138 CSwtTaskTip::CSwtTaskTip(MSwtDisplay& aDisplay, TSwtPeer aPeer, TInt aStyle)
       
   139         : iDisplay(aDisplay)
       
   140         , iPeer(aPeer)
       
   141         , iStyle(aStyle)
       
   142 {
       
   143     iRectShell = TRect(TRect::EUninitialized);
       
   144     iRectShellBarOrLabelOnly = TRect(TRect::EUninitialized);
       
   145     iRectLabel = TRect(TRect::EUninitialized);
       
   146     iRectLabelOnly = TRect(TRect::EUninitialized);
       
   147     iRectBar = TRect(TRect::EUninitialized);
       
   148     iRectBarOnly = TRect(TRect::EUninitialized);
       
   149 }
       
   150 
       
   151 // ---------------------------------------------------------------------------
       
   152 // CSwtTaskTip::CSwtTaskTip
       
   153 // ---------------------------------------------------------------------------
       
   154 //
       
   155 CSwtTaskTip::~CSwtTaskTip()
       
   156 {
       
   157     iDisplay.RemoveResourceChangeObserver(this);
       
   158 }
       
   159 
       
   160 // ---------------------------------------------------------------------------
       
   161 // CSwtTaskTip::ConstructL
       
   162 // ---------------------------------------------------------------------------
       
   163 //
       
   164 void CSwtTaskTip::ConstructL()
       
   165 {
       
   166     iDisplay.AddResourceChangeObserverL(this);
       
   167     UpdateLayout();
       
   168 }
       
   169 
       
   170 // ---------------------------------------------------------------------------
       
   171 // CSwtTaskTip::UpdateLayout
       
   172 // ---------------------------------------------------------------------------
       
   173 //
       
   174 void CSwtTaskTip::UpdateLayout()
       
   175 {
       
   176     TRect screenRect;
       
   177     AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, screenRect);
       
   178     TAknLayoutRect layoutMainPane = CSwtLafFacade::GetLayoutRect(
       
   179                                         CSwtLafFacade::EMainEswtPane,
       
   180                                         screenRect,
       
   181                                         KVariationFullScreen);
       
   182     TRect mainPaneRect = layoutMainPane.Rect();
       
   183 
       
   184     // Shell bounds
       
   185     TAknLayoutRect layoutShell = CSwtLafFacade::GetLayoutRect(
       
   186                                      CSwtLafFacade::EPopupEswtTasktipWindow,
       
   187                                      mainPaneRect,
       
   188                                      KVariationWindow);
       
   189     iRectShell = layoutShell.Rect();
       
   190     layoutShell = CSwtLafFacade::GetLayoutRect(
       
   191                       CSwtLafFacade::EPopupEswtTasktipWindow,
       
   192                       mainPaneRect,
       
   193                       KVariationWindowBarOrTextOnly);
       
   194     iRectShellBarOrLabelOnly = layoutShell.Rect();
       
   195 
       
   196     // Label bounds
       
   197     TAknLayoutText layoutLabel = CSwtLafFacade::GetLayoutText(
       
   198                                      CSwtLafFacade::EPopupEswtTasktipWindowT1,
       
   199                                      iRectShell,
       
   200                                      KVariationLabel);
       
   201     iRectLabel = layoutLabel.TextRect();
       
   202     layoutLabel = CSwtLafFacade::GetLayoutText(
       
   203                       CSwtLafFacade::EPopupEswtTasktipWindowT1,
       
   204                       iRectShellBarOrLabelOnly,
       
   205                       KVariationLabelOnly);
       
   206     iRectLabelOnly = layoutLabel.TextRect();
       
   207 
       
   208     // Progress bar bounds
       
   209     if (((iStyle & KSwtStyleIndeterminate) != 0)
       
   210             || ((iStyle & KSwtStyleSmooth) != 0))
       
   211     {
       
   212         TAknLayoutRect layoutBar = CSwtLafFacade::GetLayoutRect(
       
   213                                        CSwtLafFacade::EWaitBarPaneCp71,
       
   214                                        iRectShell,
       
   215                                        KVariationBar);
       
   216         iRectBar = layoutBar.Rect();
       
   217         layoutBar = CSwtLafFacade::GetLayoutRect(
       
   218                         CSwtLafFacade::EWaitBarPaneCp71,
       
   219                         iRectShellBarOrLabelOnly,
       
   220                         KVariationBarOnly);
       
   221         iRectBarOnly = layoutBar.Rect();
       
   222     }
       
   223 }