vtuis/videotelui/src/CVtUiNaviPaneControl.cpp
changeset 0 ed9695c8bcbe
child 8 07d1685f0cd4
equal deleted inserted replaced
-1:000000000000 0:ed9695c8bcbe
       
     1 /*
       
     2 * Copyright (c) 2004, 2005 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:  Implementation of the CVtUiNaviPaneControl control class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include    "CVtUiNaviPaneControl.h"
       
    22 #include    "CVtUiNaviPane.h"
       
    23 #include    "VtUiLayout.h"
       
    24 #include    <aknsutils.h>
       
    25 #include    <aknsdrawutils.h>
       
    26 
       
    27 // CONSTANTS
       
    28 
       
    29 // There are sixty seconds in one minute.
       
    30 const TInt KVtUiOneMinuteInSeconds = 60;
       
    31 
       
    32 // There are sixty minutes in one hour.
       
    33 const TInt KVtUiOneHourInSeconds = 3600;
       
    34 
       
    35 // Maximum duration is 99:59:59.
       
    36 const TInt KVtUiMaxDurationInSeconds = 
       
    37     99*KVtUiOneHourInSeconds + 
       
    38     59*KVtUiOneMinuteInSeconds +
       
    39     59;
       
    40 
       
    41 // Amount of digits.
       
    42 const TInt KVtUiDigits = 10;
       
    43 
       
    44 // Index of time separator.
       
    45 const TInt KVtUiSeparatorTime = 0;
       
    46 
       
    47 // Index of hour separator.
       
    48 const TInt KVtUiSeparatorHour = 1;
       
    49 
       
    50 // Index of minute separator.
       
    51 const TInt KVtUiSeparatorMinute = 2;
       
    52 
       
    53 // Index of second separator.
       
    54 const TInt KVtUiSeparatorSecond = 3;
       
    55 
       
    56 // ============================ MEMBER FUNCTIONS ===============================
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CVtUiNaviPaneControl::CVtUiNaviPaneControl
       
    60 // C++ constructor can NOT contain any code, that
       
    61 // might leave.
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 CVtUiNaviPaneControl::CVtUiNaviPaneControl( CVtUiNaviPane& aNaviPane )
       
    65     : iNaviPane ( aNaviPane )
       
    66     {
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CVtUiNaviPaneControl::ConstructL
       
    71 // Symbian 2nd phase constructor.
       
    72 // -----------------------------------------------------------------------------
       
    73 //
       
    74 void CVtUiNaviPaneControl::ConstructL()
       
    75     {
       
    76     }
       
    77 
       
    78 // -----------------------------------------------------------------------------
       
    79 // CVtUiNaviPaneControl::~CVtUiNaviPaneControl
       
    80 // Destructor.
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 CVtUiNaviPaneControl::~CVtUiNaviPaneControl()
       
    84     {
       
    85     AknsUtils::DeregisterControlPosition( this );
       
    86     }
       
    87     
       
    88 // -----------------------------------------------------------------------------
       
    89 // CVtUiNaviPaneControl::SetCallDuration
       
    90 // -----------------------------------------------------------------------------
       
    91 //
       
    92 void CVtUiNaviPaneControl::SetCallDuration( 
       
    93         const TTimeIntervalSeconds& aDuration,
       
    94         const TBool aEnabled )
       
    95     {
       
    96     iCallDurationEnabled = aEnabled;
       
    97     iCallDuration = aDuration;
       
    98     }
       
    99 
       
   100 // -----------------------------------------------------------------------------
       
   101 // CVtUiNaviPaneControl::CommitL
       
   102 // -----------------------------------------------------------------------------
       
   103 //
       
   104 void CVtUiNaviPaneControl::CommitL()
       
   105     {
       
   106     ReportEventL( MCoeControlObserver::EEventStateChanged ); 
       
   107     }
       
   108     
       
   109 // -----------------------------------------------------------------------------
       
   110 // CVtUiNaviPaneControl::Draw
       
   111 // -----------------------------------------------------------------------------
       
   112 //
       
   113 void CVtUiNaviPaneControl::Draw( const TRect& /*aRect*/ ) const
       
   114     {
       
   115     CWindowGc& gc = SystemGc();
       
   116     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   117     
       
   118     const TDesC& callDurationText = GetCallDurationText();
       
   119     if ( callDurationText.Length() )
       
   120         {
       
   121         TRgb color = iCallDurationLayout.Color();
       
   122         // Color is not updated if it not found from the skin
       
   123         AknsUtils::GetCachedColor(
       
   124             skin,
       
   125             color,
       
   126             KAknsIIDQsnTextColors,
       
   127             EAknsCIQsnTextColorsCG2 );
       
   128         iCallDurationLayout.DrawText( gc, callDurationText, EFalse, color );
       
   129         }
       
   130     }
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CVtUiNaviPaneControl::SizeChanged
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 void CVtUiNaviPaneControl::SizeChanged()
       
   137     {
       
   138     AknsUtils::RegisterControlPosition( this );
       
   139     TAknWindowLineLayout rect;
       
   140     TRect parent( Rect() );
       
   141     if ( parent.IsEmpty() )
       
   142         {
       
   143         return;
       
   144         }
       
   145 
       
   146     TAknTextLineLayout text;
       
   147     VtUiLayout::GetCallDurationTextLayout( text );
       
   148     iCallDurationLayout.LayoutText( parent, text );
       
   149     }
       
   150 
       
   151 // -----------------------------------------------------------------------------
       
   152 // CVtUiNaviPaneControl::PositionChanged
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 void CVtUiNaviPaneControl::PositionChanged()
       
   156     {
       
   157     AknsUtils::RegisterControlPosition( this );
       
   158     }
       
   159 
       
   160 // -----------------------------------------------------------------------------
       
   161 // CVtUiNaviPaneControl::GetCallDurationText
       
   162 // -----------------------------------------------------------------------------
       
   163 //
       
   164 const TDesC& CVtUiNaviPaneControl::GetCallDurationText() const
       
   165     {
       
   166     iCallDurationBuffer.Zero();
       
   167 
       
   168     if ( iCallDurationEnabled )
       
   169         {
       
   170         TLocale locale;
       
   171     
       
   172         TInt durationInseconds = iCallDuration.Int();
       
   173         if ( durationInseconds > KVtUiMaxDurationInSeconds )
       
   174             {
       
   175             durationInseconds = KVtUiMaxDurationInSeconds;
       
   176             }
       
   177 
       
   178         const TInt hours = durationInseconds / KVtUiOneHourInSeconds;
       
   179         const TInt secondsLeft = 
       
   180             durationInseconds - ( hours * KVtUiOneHourInSeconds );
       
   181 
       
   182         const TInt minutes = secondsLeft / KVtUiOneMinuteInSeconds;
       
   183         const TInt seconds = 
       
   184             secondsLeft - ( minutes * KVtUiOneMinuteInSeconds );
       
   185 
       
   186         AppendChar( 
       
   187             iCallDurationBuffer, 
       
   188             locale.TimeSeparator( KVtUiSeparatorTime ) );
       
   189 
       
   190         AppendNum( 
       
   191             iCallDurationBuffer,
       
   192             hours );
       
   193     
       
   194         AppendChar( 
       
   195             iCallDurationBuffer, 
       
   196             locale.TimeSeparator( KVtUiSeparatorHour ) );
       
   197     
       
   198         AppendNum( 
       
   199             iCallDurationBuffer, 
       
   200             minutes );
       
   201 
       
   202         AppendChar( 
       
   203             iCallDurationBuffer, 
       
   204             locale.TimeSeparator( KVtUiSeparatorMinute ) );
       
   205 
       
   206         AppendNum( 
       
   207             iCallDurationBuffer, 
       
   208             seconds );
       
   209 
       
   210         AppendChar( 
       
   211             iCallDurationBuffer, 
       
   212             locale.TimeSeparator( KVtUiSeparatorSecond ) );
       
   213 
       
   214         // Convert numbers to display language.
       
   215         AknTextUtils::DisplayTextLanguageSpecificNumberConversion( 
       
   216             iCallDurationBuffer );
       
   217         }
       
   218 
       
   219     return iCallDurationBuffer;
       
   220     }
       
   221 
       
   222 // -----------------------------------------------------------------------------
       
   223 // CVtUiNaviPaneControl::AppendChar
       
   224 // -----------------------------------------------------------------------------
       
   225 //
       
   226 void CVtUiNaviPaneControl::AppendChar( 
       
   227         TDes& aBuffer,
       
   228         const TChar& aChar )
       
   229     {
       
   230     if ( aChar )
       
   231         {
       
   232         aBuffer.Append( aChar );
       
   233         }
       
   234     }
       
   235 
       
   236 // -----------------------------------------------------------------------------
       
   237 // CVtUiNaviPaneControl::AppendNum
       
   238 // -----------------------------------------------------------------------------
       
   239 //
       
   240 void CVtUiNaviPaneControl::AppendNum(
       
   241         TDes& aBuffer,
       
   242         TInt aNumber )
       
   243     {
       
   244     if ( aNumber < 0 )
       
   245         {
       
   246         aNumber = 0;
       
   247         }
       
   248 
       
   249     const TInt firstDigit = ( aNumber / KVtUiDigits ) % KVtUiDigits;
       
   250     const TInt secondDigit = ( aNumber % KVtUiDigits );
       
   251 
       
   252     aBuffer.AppendNum( firstDigit );
       
   253     aBuffer.AppendNum( secondDigit );
       
   254     }
       
   255 
       
   256 //  End of File