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 CTruiShortcutsView |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <aknViewAppUi.h> |
|
20 #include <trui.rsg> |
|
21 #include <eikmenup.h> |
|
22 #include <akntoolbar.h> |
|
23 #include <aknnavide.h> |
|
24 #include <akntabgrp.h> |
|
25 |
|
26 #include "truishortcutsview.h" |
|
27 #include "truishortcutscontainer.h" |
|
28 #include "trui.hrh" |
|
29 #include "truiappui.h" |
|
30 #include "truishortcutedittextview.h" |
|
31 #include "truimainview.h" |
|
32 |
|
33 // ======== MEMBER FUNCTIONS ======== |
|
34 |
|
35 CTruiShortcutsView::CTruiShortcutsView() |
|
36 { |
|
37 } |
|
38 |
|
39 void CTruiShortcutsView::ConstructL() |
|
40 { |
|
41 BaseConstructL( R_TRUI_SHORTCUTSVIEW ); |
|
42 } |
|
43 |
|
44 CTruiShortcutsView* CTruiShortcutsView::NewL() |
|
45 { |
|
46 CTruiShortcutsView* self = CTruiShortcutsView::NewLC(); |
|
47 CleanupStack::Pop( self ); |
|
48 return self; |
|
49 } |
|
50 |
|
51 CTruiShortcutsView* CTruiShortcutsView::NewLC() |
|
52 { |
|
53 CTruiShortcutsView* self = new( ELeave ) CTruiShortcutsView; |
|
54 CleanupStack::PushL( self ); |
|
55 self->ConstructL(); |
|
56 return self; |
|
57 } |
|
58 |
|
59 CTruiShortcutsView::~CTruiShortcutsView() |
|
60 { |
|
61 } |
|
62 |
|
63 // --------------------------------------------------------------------------- |
|
64 // From class CAknView. |
|
65 // Returns views id. |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 TUid CTruiShortcutsView::Id() const |
|
69 { |
|
70 return KTruiShortcutsViewId; |
|
71 } |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // From class CAknView. |
|
75 // Command handling function. |
|
76 // --------------------------------------------------------------------------- |
|
77 // |
|
78 void CTruiShortcutsView::HandleCommandL( TInt aCommand ) |
|
79 { |
|
80 switch ( aCommand ) |
|
81 { |
|
82 case EShortcutViewCreate: |
|
83 { |
|
84 iContainer->AddShortcutL(); |
|
85 } |
|
86 break; |
|
87 case EShortcutViewEditText: |
|
88 { |
|
89 iContainer->EditShortcutL( ETrue ); |
|
90 break; |
|
91 } |
|
92 case EShortcutViewEditModel: |
|
93 { |
|
94 iContainer->EditShortcutL( EFalse ); |
|
95 } |
|
96 break; |
|
97 case EShortcutViewLinkToHandwritting: |
|
98 { |
|
99 // Set main view tab active |
|
100 CTruiAppUi* appui = static_cast<CTruiAppUi*>( AppUi() ); |
|
101 CAknNavigationDecorator* naviDecorator = appui->GetNaviDecorator(); |
|
102 CAknTabGroup* tabGroup = static_cast<CAknTabGroup*> |
|
103 ( naviDecorator->DecoratedControl() ); |
|
104 tabGroup->SetActiveTabById( ENavigationPaneMainViewTab ); |
|
105 // Switch to local view. |
|
106 appui->ActivateLocalViewL( KTruiMainViewId ); |
|
107 } |
|
108 break; |
|
109 case EShortcutViewMark: |
|
110 { |
|
111 iContainer->MarkShortcutL(); |
|
112 } |
|
113 break; |
|
114 case EShortcutViewUnmark: |
|
115 { |
|
116 iContainer->UnmarkShortcutL(); |
|
117 } |
|
118 break; |
|
119 case EShortcutViewResetInfoMessage: |
|
120 { |
|
121 iContainer->ResetIntroductionL(); |
|
122 } |
|
123 break; |
|
124 case EShortcutViewDelete: |
|
125 { |
|
126 iContainer->DeleteShortcutL(); |
|
127 } |
|
128 break; |
|
129 default: |
|
130 { |
|
131 AppUi()->HandleCommandL( aCommand ); |
|
132 } |
|
133 } |
|
134 } |
|
135 |
|
136 // --------------------------------------------------------------------------- |
|
137 // From class CAknView. |
|
138 // Carried out when View is activated |
|
139 // --------------------------------------------------------------------------- |
|
140 // |
|
141 void CTruiShortcutsView::DoActivateL( const TVwsViewId& /*aPrevViewId*/, |
|
142 TUid /*aCustomMessageId*/, |
|
143 const TDesC8& /*aCustomMessage*/ ) |
|
144 { |
|
145 // Set title pane |
|
146 CTruiAppUi* appui = static_cast<CTruiAppUi*>( AppUi() ); |
|
147 HBufC* titleText = iEikonEnv->AllocReadResourceLC |
|
148 ( R_TRUI_SHORTCUTSVIEW_TITLEPANE_TEXT ); |
|
149 appui->ShowTitlePaneL( *titleText ); |
|
150 CleanupStack::PopAndDestroy( titleText ); |
|
151 |
|
152 // Show navi pane |
|
153 appui->ShowNaviPaneL(); |
|
154 |
|
155 iContainer = CTruiShortcutsContainer::NewL( ClientRect() ); |
|
156 iContainer->SetMopParent( this ); |
|
157 AppUi()->AddToStackL( *this, iContainer ); |
|
158 iContainer->SetView( this ); |
|
159 |
|
160 // Set toolbar |
|
161 CAknToolbar* toolbar = Toolbar(); |
|
162 if ( toolbar ) |
|
163 { |
|
164 toolbar->SetToolbarObserver( this ); |
|
165 toolbar->SetToolbarVisibility( ETrue, EFalse ); |
|
166 } |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // From class CAknView. |
|
171 // Carried out when View is deactivated |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 void CTruiShortcutsView::DoDeactivate() |
|
175 { |
|
176 if ( iContainer ) |
|
177 { |
|
178 AppUi()->RemoveFromStack( iContainer ); |
|
179 delete iContainer; |
|
180 iContainer = NULL; |
|
181 } |
|
182 } |
|
183 |
|
184 |
|
185 // --------------------------------------------------------------------------- |
|
186 // From MEikMenuObserver |
|
187 // Dynamically initialises a menu pane. |
|
188 // --------------------------------------------------------------------------- |
|
189 // |
|
190 void CTruiShortcutsView::DynInitMenuPaneL( TInt aResourceId, |
|
191 CEikMenuPane* aMenuPane ) |
|
192 { |
|
193 // Prepare to display popup window when focus return to container |
|
194 iContainer->SetDisplayPopupWindow( ETrue ); |
|
195 |
|
196 if ( aResourceId == R_TRUI_SHORTCUTSVIEW_MENUPANE ) |
|
197 { |
|
198 // Check if "Edit" will be displayed when first item highlighted. |
|
199 // Check if "Delete" will be displayed when first item highlighted. |
|
200 // Check if "Mark" will be displayed when first item highlighted. |
|
201 // Check if "Unmark" will be displayed when first item highlighted. |
|
202 TInt currentIndex = iContainer->CurrentItemIndex(); |
|
203 if ( currentIndex != 0 ) |
|
204 { |
|
205 if ( iContainer->MarkCount() > 0 ) |
|
206 { |
|
207 // At least one marked, "Edit" won't be displayed |
|
208 aMenuPane->SetItemDimmed( EShortcutViewEditText, ETrue ); |
|
209 aMenuPane->SetItemDimmed( EShortcutViewEditModel, ETrue ); |
|
210 } |
|
211 else |
|
212 { |
|
213 // All unmark, "Edit" will be displayed. |
|
214 aMenuPane->SetItemDimmed( EShortcutViewEditText, EFalse ); |
|
215 aMenuPane->SetItemDimmed( EShortcutViewEditModel, EFalse ); |
|
216 } |
|
217 aMenuPane->SetItemDimmed( EShortcutViewDelete, EFalse ); |
|
218 aMenuPane->SetItemDimmed( EShortcutViewMark, EFalse ); |
|
219 aMenuPane->SetItemDimmed( EShortcutViewUnmark, EFalse ); |
|
220 if ( iContainer->IsMarked( currentIndex ) ) |
|
221 { |
|
222 // The currently selected item mark, display "Unmark" |
|
223 aMenuPane->SetItemDimmed( EShortcutViewMark, ETrue ); |
|
224 } |
|
225 else |
|
226 { |
|
227 // The currently selected item unmark, display "Mark" |
|
228 aMenuPane->SetItemDimmed( EShortcutViewUnmark, ETrue ); |
|
229 } |
|
230 |
|
231 // Hide Reset introduction |
|
232 aMenuPane->SetItemDimmed( EShortcutViewResetInfoMessage, ETrue ); |
|
233 } |
|
234 else |
|
235 { |
|
236 aMenuPane->SetItemDimmed( EShortcutViewEditText, ETrue ); |
|
237 aMenuPane->SetItemDimmed( EShortcutViewEditModel, ETrue ); |
|
238 aMenuPane->SetItemDimmed( EShortcutViewDelete, ETrue ); |
|
239 aMenuPane->SetItemDimmed( EShortcutViewMark, ETrue ); |
|
240 aMenuPane->SetItemDimmed( EShortcutViewUnmark, ETrue ); |
|
241 |
|
242 // Check value of setting of introduction |
|
243 TBool isDimReset = iContainer->IsResetIntroduction() ? EFalse : ETrue; |
|
244 aMenuPane->SetItemDimmed( EShortcutViewResetInfoMessage, isDimReset ); |
|
245 } |
|
246 } |
|
247 } |
|
248 |
|
249 // --------------------------------------------------------------------------- |
|
250 // From class MEikMenuObserver. |
|
251 // Dynamically initialises a menu bar. |
|
252 // --------------------------------------------------------------------------- |
|
253 // |
|
254 void CTruiShortcutsView::DynInitMenuBarL( TInt aResourceId, |
|
255 CEikMenuBar* /*aMenuBar*/ ) |
|
256 { |
|
257 if ( aResourceId == R_TRUI_SHORTCUTSVIEW_CONTEXT_MENUBAR ) |
|
258 { |
|
259 iContainer->SetDisplayPopupWindow( ETrue ); |
|
260 } |
|
261 } |
|
262 |
|
263 // --------------------------------------------------------------------------- |
|
264 // From class MAknToolbarObserver. |
|
265 // Handles toolbar events for a certain toolbar item. |
|
266 // --------------------------------------------------------------------------- |
|
267 // |
|
268 void CTruiShortcutsView::OfferToolbarEventL( TInt aCommand ) |
|
269 { |
|
270 switch ( aCommand ) |
|
271 { |
|
272 case EShortcutsViewButtonIdEditText: |
|
273 { |
|
274 // Open the text setting view |
|
275 iContainer->EditShortcutL( ETrue ); |
|
276 break; |
|
277 } |
|
278 case EShortcutsViewButtonIdEditModel: |
|
279 { |
|
280 // Open the shortcut edit view |
|
281 iContainer->EditShortcutL( EFalse ); |
|
282 break; |
|
283 } |
|
284 case EShortcutsViewButtonIdDelete: |
|
285 { |
|
286 iContainer->DeleteShortcutL(); |
|
287 break; |
|
288 } |
|
289 } |
|
290 } |
|
291 // --------------------------------------------------------------------------- |
|
292 // From CAknView. This function processes user commands. |
|
293 // --------------------------------------------------------------------------- |
|
294 // |
|
295 void CTruiShortcutsView::ProcessCommandL( TInt aCommand ) |
|
296 { |
|
297 if ( !iContainer ) |
|
298 { |
|
299 return; |
|
300 } |
|
301 CAknView::ProcessCommandL( aCommand ); |
|
302 } |
|