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