textinput/peninputhwrtrui/src/truiappui.cpp
changeset 27 694fa80c203c
parent 24 fc42a86c98e3
child 35 0f326f2e628e
equal deleted inserted replaced
24:fc42a86c98e3 27:694fa80c203c
     1 /*
       
     2 * Copyright (c) 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:  Implement of class CTruiAppUi
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <avkon.hrh>
       
    20 #include <aknnavide.h>
       
    21 #include <barsread.h>
       
    22 #include <akntabgrp.h>
       
    23 #include <trui.rsg>
       
    24 #include <akntitle.h> 
       
    25 #include <hlplch.h>
       
    26 #include <AknsUtils.h>
       
    27 
       
    28 #include "trui.hrh"
       
    29 #include "truiappui.h"
       
    30 #include "truimainview.h"
       
    31 #include "truishortcutsview.h"
       
    32 #include "truishortcuteditview.h"
       
    33 #include "truishortcutedittextview.h"
       
    34 #include "truiinfomessageview.h"
       
    35 #include "truiengine.h"
       
    36 
       
    37 // ======== MEMBER FUNCTIONS ========
       
    38 
       
    39 // ---------------------------------------------------------------------------
       
    40 // ConstructL is called by the application framework
       
    41 // ---------------------------------------------------------------------------
       
    42 //
       
    43 void CTruiAppUi::ConstructL()
       
    44     {
       
    45     BaseConstructL();    
       
    46     //Create HWR engine
       
    47     iEngine = CTruiEngine::NewL( iEikonEnv );
       
    48 
       
    49     //Create view
       
    50     iMainView = CTruiMainView::NewL();
       
    51     AddViewL( iMainView );    
       
    52  
       
    53     iShortcutsView = CTruiShortcutsView::NewL();   
       
    54     AddViewL( iShortcutsView );
       
    55     
       
    56     iShortcutEditView = CTruiShortcutEditView::NewL();   
       
    57     AddViewL( iShortcutEditView );
       
    58     
       
    59     iShortcutEditTextView = CTruiShortcutEditTextView::NewL();   
       
    60     AddViewL( iShortcutEditTextView );   
       
    61     
       
    62     iInfoMessageView = CTruiInfoMessageView::NewL();   
       
    63     AddViewL( iInfoMessageView );      
       
    64 
       
    65     SetDefaultViewL( *iMainView );
       
    66   
       
    67     iNaviDecorator = CreateNavigationTabL( R_NAVIGATIONPANE_TABGROUP, 0 );
       
    68     
       
    69     // Create empty navi pane
       
    70     // Get status pane from AppUi
       
    71     CEikStatusPane* statusPane = StatusPane();
       
    72     CEikStatusPaneBase::TPaneCapabilities naviPaneCapability =
       
    73         statusPane->PaneCapabilities( TUid::Uid( EEikStatusPaneUidNavi ) );        
       
    74     // if the navigation pane can be used
       
    75     if ( naviPaneCapability.IsPresent() && naviPaneCapability.IsAppOwned() )
       
    76         {
       
    77         CAknNavigationControlContainer* naviPane = 
       
    78             static_cast<CAknNavigationControlContainer*>
       
    79             ( statusPane->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
    80         // if the navigation pane can be used
       
    81         if ( naviPaneCapability.IsPresent() && naviPaneCapability.IsAppOwned() )
       
    82             {
       
    83             iEmptyNaviDecorator = naviPane->CreateNavigationLabelL();
       
    84             }        
       
    85         }   
       
    86     AknsUtils::SetAvkonSkinEnabledL( ETrue );    
       
    87     }
       
    88 
       
    89 // ---------------------------------------------------------------------------
       
    90 // Constructor
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 CTruiAppUi::CTruiAppUi()                              
       
    94     {
       
    95     }
       
    96 
       
    97 // ---------------------------------------------------------------------------
       
    98 // Destructor
       
    99 // ---------------------------------------------------------------------------
       
   100 //
       
   101 CTruiAppUi::~CTruiAppUi()
       
   102     {
       
   103     if ( iNaviDecorator )
       
   104         {
       
   105         delete iNaviDecorator;        
       
   106         }
       
   107     if ( iEmptyNaviDecorator )
       
   108         {
       
   109         delete iEmptyNaviDecorator;        
       
   110         }
       
   111     if ( iEngine )
       
   112         {
       
   113         delete iEngine;        
       
   114         }    
       
   115     }
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 // handle any menu commands
       
   119 // ---------------------------------------------------------------------------
       
   120 //
       
   121 void CTruiAppUi::HandleCommandL( TInt aCommand )
       
   122     {
       
   123     switch( aCommand )
       
   124         {
       
   125         case EEikCmdExit:
       
   126         case EAknSoftkeyExit:
       
   127             {
       
   128             PrepareToExit();
       
   129             Exit();
       
   130             break;
       
   131             }
       
   132         case EMainViewHelp:
       
   133         case EShortcutViewHelp:
       
   134             {
       
   135             CArrayFix<TCoeHelpContext>* buf = CCoeAppUi::AppHelpContextL();
       
   136             HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), 
       
   137                                                  buf );
       
   138             break;
       
   139             }
       
   140         default:
       
   141             break;
       
   142         }
       
   143     }    
       
   144     
       
   145 // ---------------------------------------------------------------------------
       
   146 // Create navigation pane
       
   147 // ---------------------------------------------------------------------------
       
   148 //
       
   149 CAknNavigationDecorator* CTruiAppUi::CreateNavigationTabL
       
   150                                      ( const TInt aResourceId, 
       
   151                                        const TInt aDefaultActive )
       
   152     {    
       
   153     // Get status pane from AppUi
       
   154     CEikStatusPane* statusPane = StatusPane();
       
   155     CEikStatusPaneBase::TPaneCapabilities naviPaneCapability =
       
   156         statusPane->PaneCapabilities( TUid::Uid( EEikStatusPaneUidNavi ) );
       
   157     
       
   158     CAknNavigationDecorator* naviDecorator = NULL;
       
   159     // if the navigation pane can be used
       
   160     if ( naviPaneCapability.IsPresent() && naviPaneCapability.IsAppOwned() )
       
   161         {
       
   162         // Get the navigation pane from status pane.
       
   163         CAknNavigationControlContainer* naviPane = 
       
   164             static_cast<CAknNavigationControlContainer*>
       
   165             ( statusPane->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
   166         TResourceReader reader;
       
   167         iEikonEnv->CreateResourceReaderLC( reader, aResourceId );
       
   168         
       
   169         // Create the navigation pane tab group
       
   170         naviDecorator = naviPane->CreateTabGroupL( reader, this );
       
   171         CleanupStack::PushL( naviDecorator );
       
   172         
       
   173         // Set tab text
       
   174         CAknTabGroup* tabGroup = static_cast<CAknTabGroup*>
       
   175                                  ( naviDecorator->DecoratedControl() );    
       
   176         tabGroup->SetActiveTabByIndex( aDefaultActive );
       
   177          
       
   178         // Push and show the navigation pane
       
   179         naviPane->PushL( *naviDecorator );
       
   180         CleanupStack::Pop( naviDecorator );
       
   181         CleanupStack::PopAndDestroy(); // reader
       
   182         }
       
   183     return naviDecorator;
       
   184     }
       
   185 
       
   186 // ---------------------------------------------------------------------------
       
   187 // return pointer of hand writing engine
       
   188 // ---------------------------------------------------------------------------
       
   189 //
       
   190 CTruiEngine* CTruiAppUi::HwrEngine() const
       
   191     {
       
   192     return iEngine;
       
   193     }
       
   194 
       
   195 // ---------------------------------------------------------------------------
       
   196 // Return a pointer to navigation pane.
       
   197 // ---------------------------------------------------------------------------
       
   198 //
       
   199 CAknNavigationDecorator* CTruiAppUi::GetNaviDecorator() const
       
   200     {
       
   201     return iNaviDecorator;
       
   202     }
       
   203 
       
   204 // ---------------------------------------------------------------------------
       
   205 // Close the navi pane
       
   206 // ---------------------------------------------------------------------------
       
   207 //
       
   208 void CTruiAppUi::CloseNaviPaneL()
       
   209     {
       
   210     // Get status pane from AppUi
       
   211     CEikStatusPane* statusPane = StatusPane();
       
   212 
       
   213     CEikStatusPaneBase::TPaneCapabilities naviPaneCapability =
       
   214         statusPane->PaneCapabilities( TUid::Uid( EEikStatusPaneUidNavi ) );   
       
   215     // if the navigation pane can be used
       
   216     if ( naviPaneCapability.IsPresent() && naviPaneCapability.IsAppOwned() )
       
   217         {
       
   218         // Get the navigation pane from status pane.
       
   219         CAknNavigationControlContainer* naviPane =
       
   220              static_cast<CAknNavigationControlContainer*>
       
   221              ( statusPane->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );        
       
   222         // Pop and hide the navigation pane
       
   223         naviPane->PushL( *iEmptyNaviDecorator );
       
   224         }
       
   225     }
       
   226 
       
   227 // ---------------------------------------------------------------------------
       
   228 // Show the navi pane
       
   229 // ---------------------------------------------------------------------------
       
   230 //
       
   231 void CTruiAppUi::ShowNaviPaneL()
       
   232     {
       
   233     CEikStatusPane* statusPane = StatusPane();
       
   234 
       
   235     CEikStatusPaneBase::TPaneCapabilities naviPaneCapability =
       
   236         statusPane->PaneCapabilities( TUid::Uid( EEikStatusPaneUidNavi ) );  
       
   237     // if the navigation pane can be used
       
   238     if ( naviPaneCapability.IsPresent() && naviPaneCapability.IsAppOwned() )
       
   239         {
       
   240         CAknNavigationControlContainer* naviPane =
       
   241               static_cast<CAknNavigationControlContainer*>
       
   242               ( statusPane->ControlL( TUid::Uid( EEikStatusPaneUidNavi ) ) );
       
   243         // Push and show the navigation pane
       
   244         naviPane->PushL( *iNaviDecorator );
       
   245         }
       
   246     }
       
   247 
       
   248 // ---------------------------------------------------------------------------
       
   249 // Handle active tab changed
       
   250 // ---------------------------------------------------------------------------
       
   251 //
       
   252 void CTruiAppUi::TabChangedL( TInt aIndex )
       
   253     {
       
   254     if ( aIndex == 0 )
       
   255         {
       
   256         // Switch to mainview
       
   257         ActivateLocalViewL( KTruiMainViewId );        
       
   258         }
       
   259     else
       
   260         {
       
   261         // Switch to shortcuts view
       
   262         ActivateLocalViewL( KTruiShortcutsViewId );
       
   263         }
       
   264     }
       
   265     
       
   266 // ---------------------------------------------------------------------------
       
   267 // Show the title pane
       
   268 // ---------------------------------------------------------------------------
       
   269 //    
       
   270 void CTruiAppUi::ShowTitlePaneL( const TDesC& aTitle )
       
   271     {
       
   272     CEikStatusPane* statusPane = StatusPane();
       
   273     CEikStatusPaneBase::TPaneCapabilities titlePaneCapability =
       
   274         statusPane->PaneCapabilities( TUid::Uid( EEikStatusPaneUidTitle ) );
       
   275     if ( titlePaneCapability.IsPresent() && titlePaneCapability.IsAppOwned() )
       
   276         {
       
   277         CAknTitlePane* titlePane = static_cast<CAknTitlePane*>
       
   278             ( statusPane->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
       
   279         titlePane->SetTextL( aTitle );
       
   280         }
       
   281     }
       
   282 
       
   283 
       
   284 
       
   285 
       
   286