os/textandloc/fontservices/textshaperplugin/test/S60HindiDemo/src/HindiDemoappui.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
     1 /*
     2 * Copyright (c) 2005-2009 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: 
    15 * Series 60 version of Hindi Demo application
    16 * Implementation of CHindiDemoAppUi
    17 *
    18 */
    19 
    20 
    21 #include <e32std.h>
    22 
    23 #include "HindiDemo.hrh"
    24 #include "HindiDemoappui.h"
    25 #include "HindiDemoview.h"
    26 #include "MainViewview.h"
    27 
    28 // -----------------------------------------------------------------------
    29 // Method managed by IDE to construct views
    30 // Please do not edit this routine as its
    31 // contents are regenerated upon new view creation.
    32 // -----------------------------------------------------------------------
    33 void CHindiDemoAppUi::InitViewsL()
    34 {
    35   iHindiDemoView = CHindiDemoView::NewL();
    36   AddViewL( iHindiDemoView );
    37   iMainViewView = CMainViewView::NewL();
    38   AddViewL( iMainViewView );
    39 }
    40 
    41 
    42 // -----------------------------------------------------------------------
    43 // Constructs AppUI Object
    44 // -----------------------------------------------------------------------
    45 void CHindiDemoAppUi::ConstructL()
    46 {
    47   BaseConstructL();
    48   InitViewsL();
    49 
    50 #ifdef WITH_TAB_GROUP
    51   // -----------------------------------------------------------------------
    52   // Show tabs for main views from resources
    53   // -----------------------------------------------------------------------
    54   CEikStatusPane* sp = StatusPane();
    55   iNaviPane = (CAknNavigationControlContainer *)sp->ControlL(TUid::Uid(EEikStatusPaneUidNavi));
    56   sp->SetDimmed(ETrue);
    57 
    58   // -------------------------------------------------------------------------------
    59   // Tabgroup has been read from resource and it was pushed to the navi pane.
    60   // Get pointer to the navigation decorator with the ResourceDecorator() function.
    61   // Application owns the decorator and it has responsibility to delete the object.
    62   // -------------------------------------------------------------------------------
    63   iDecoratedTabGroup = iNaviPane->ResourceDecorator();
    64 
    65   if (iDecoratedTabGroup) 
    66   {
    67     iTabGroup = (CAknTabGroup*) iDecoratedTabGroup->DecoratedControl();
    68   }
    69 
    70   if (iTabGroup) 
    71   {
    72     ActivateLocalViewL(TUid::Uid(iTabGroup->ActiveTabId()));
    73   } 
    74 #else
    75   // -----------------------------------------------------------------------
    76   // Set default view
    77   // -----------------------------------------------------------------------
    78   SetDefaultViewL(*iMainViewView);
    79 #endif
    80 }
    81 
    82 
    83 // -----------------------------------------------------------------------
    84 // Cleanup of AppUI object
    85 // -----------------------------------------------------------------------
    86 CHindiDemoAppUi::~CHindiDemoAppUi()
    87 {
    88 #ifdef WITH_TAB_GROUP
    89   delete iDecoratedTabGroup;
    90 #endif
    91 }
    92 
    93 
    94 #ifdef WITH_TAB_GROUP
    95 // -----------------------------------------------------------------------
    96 // Key Event Handler - Primarily to automate navigation through tab groups
    97 // -----------------------------------------------------------------------
    98 TKeyResponse CHindiDemoAppUi::HandleKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
    99 {
   100   if (aType == EEventKey) 
   101   {
   102     if (iTabGroup == NULL)
   103     {
   104       return EKeyWasNotConsumed;
   105     } 
   106   }
   107 
   108   TInt active = iTabGroup->ActiveTabIndex();
   109   TInt count = iTabGroup->TabCount();
   110 
   111   switch (aKeyEvent.iCode) 
   112   {
   113     case EKeyLeftArrow:
   114       if (active > 0) 
   115       {
   116         // -----------------------------------------------------------------------
   117         // Change to usual layout
   118         // -----------------------------------------------------------------------
   119 	TRect cr = ClientRect();
   120 	if (cr.iTl.iY == Kqpn_height_status_pane_idle) 
   121         {
   122 	  StatusPane()->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL);
   123 	}
   124 
   125 	active--;
   126 	iTabGroup->SetActiveTabByIndex(active);
   127 	ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active)));
   128 	return EKeyWasConsumed;
   129       }
   130       break;
   131 
   132     case EKeyRightArrow:
   133       if((active + 1) < count) 
   134       {
   135         TRect cr = ClientRect();  
   136         if (cr.iTl.iY == Kqpn_height_status_pane_idle) 
   137         {
   138 	  StatusPane()->SwitchLayoutL(R_AVKON_STATUS_PANE_LAYOUT_USUAL);
   139         }
   140 
   141         active++;
   142         iTabGroup->SetActiveTabByIndex(active);
   143         ActivateLocalViewL(TUid::Uid(iTabGroup->TabIdFromIndex(active)));
   144         return EKeyWasConsumed;
   145       }
   146     break;
   147 
   148     default:
   149       break;
   150   }        
   151 
   152   return EKeyWasNotConsumed;
   153 }
   154 #endif
   155 
   156 
   157 // -----------------------------------------------------------------------
   158 // Default handler of Command Events
   159 // -----------------------------------------------------------------------
   160 void CHindiDemoAppUi::HandleCommandL(TInt aCommand)
   161 {
   162   if (DispatchAppUICommandEvents(aCommand)) 
   163     return;
   164 
   165   switch (aCommand) 
   166   {
   167  		case 1014:
   168    		case EEikCmdExit:
   169     	case EAknSoftkeyExit:
   170       		Exit();
   171       		break;
   172 
   173     	default:
   174       		break;
   175   		}
   176 	}
   177 
   178 
   179 // -----------------------------------------------------------------------
   180 // Here we dispatch to Command Event Handlers
   181 //
   182 // NOTE: This routine is managed by the C++Builder IDE - DO NOT MODIFY
   183 // -----------------------------------------------------------------------
   184 bool CHindiDemoAppUi::DispatchAppUICommandEvents(TInt aCommand)
   185 {
   186   return false;
   187 }
   188 
   189 
   190