|
1 /* |
|
2 * Copyright (c) 2002-2010 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: Icon Selector Dialog Class Implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <uikon.hrh> |
|
20 #include <e32std.h> |
|
21 #include <eikcapc.h> |
|
22 #include <aknlayoutscalable_avkon.cdl.h> |
|
23 #include <layoutmetadata.cdl.h> |
|
24 #include <aknborders.h> |
|
25 #include <aknconsts.h> |
|
26 #include <AknUtils.h> |
|
27 #include <aknPopupHeadingPane.h> |
|
28 #include <AknSettingCache.h> |
|
29 #include <AknLayout.lag> |
|
30 #include <e32property.h> |
|
31 |
|
32 #include <lmkui.rsg> |
|
33 |
|
34 #include "landmarks.hrh" |
|
35 #include "lmkicondialog.h" |
|
36 #include "lmkiconmap.h" |
|
37 |
|
38 // ============================ MEMBER FUNCTIONS =============================== |
|
39 |
|
40 // ---------------------------------------------------------------------------- |
|
41 // CLmkIconMapDialog class |
|
42 // CLmkIconMapDialog() - constructor |
|
43 // ---------------------------------------------------------------------------- |
|
44 // |
|
45 CLmkIconMapDialog::CLmkIconMapDialog(TInt& aIconIndex) : |
|
46 iIconIndex(&aIconIndex) |
|
47 { |
|
48 CEikDialog::SetBorder(AknBorderId::EAknBorderNotePopup); |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CLmkIconMapDialog::~CLmkIconMapDialog() |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CLmkIconMapDialog::~CLmkIconMapDialog() |
|
56 { |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CLmkIconMapDialog::HandleResourceChange() |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 void CLmkIconMapDialog::HandleResourceChange(TInt aType) |
|
64 { |
|
65 CAknDialog::HandleResourceChange(aType); |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CLmkIconMapDialog::OkToExitL() |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 TBool CLmkIconMapDialog::OkToExitL(TInt aButtonId) |
|
73 { |
|
74 CLmkIconMap* iconmapControl = |
|
75 STATIC_CAST(CLmkIconMap*, Control(ELmkIconMapContentId)); |
|
76 // Selection key / select softkey adds a iconacter only if 5-key was not used |
|
77 // to select multiple icons before. |
|
78 if (aButtonId == EAknSoftkeyOk || aButtonId == EAknSoftkeySelect |
|
79 || aButtonId == EKeyEnter || aButtonId == EStdKeyEnter) |
|
80 { |
|
81 TKeyEvent key; |
|
82 key.iCode = EKeyOK; |
|
83 key.iModifiers = 0; |
|
84 iconmapControl->OfferKeyEventL(key, EEventKey); |
|
85 } |
|
86 return (ETrue); |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CLmkIconMapDialog::PreLayoutDynInitL() |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 void CLmkIconMapDialog::PreLayoutDynInitL() |
|
94 { |
|
95 CLmkIconMap* iconmapControl = |
|
96 STATIC_CAST(CLmkIconMap*, Control(ELmkIconMapContentId)); |
|
97 CAknPopupHeadingPane |
|
98 * headingPane = |
|
99 STATIC_CAST(CAknPopupHeadingPane*, Control(EAknSCTQueryHeadingId)); |
|
100 |
|
101 iconmapControl->SetIndex(*iIconIndex); |
|
102 |
|
103 SetLineNonFocusing(EAknSCTQueryHeadingId); |
|
104 |
|
105 // add title |
|
106 |
|
107 HBufC* title = iEikonEnv->AllocReadResourceL(R_LMK_ICON_SELECTOR_TITLE); |
|
108 CleanupStack::PushL(title); |
|
109 headingPane->SetTextL(*title); |
|
110 CleanupStack::PopAndDestroy(title); //title |
|
111 title = NULL; |
|
112 #ifdef RD_SCALABLE_UI_V2 |
|
113 iconmapControl->SetObserver(this); |
|
114 #endif //RD_SCALABLE_UI_V2 |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CLmkIconMapDialog::PostLayoutDynInitL() |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 void CLmkIconMapDialog::PostLayoutDynInitL() |
|
122 { |
|
123 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
124 cba->SetCommandSetL(R_LMK_ICON_SOFTKEYS_SELECT_CANCEL_SELECT); |
|
125 cba->MakeCommandVisibleByPosition( |
|
126 CEikButtonGroupContainer::ELeftSoftkeyPosition, EFalse); |
|
127 cba->DrawDeferred(); |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CLmkIconMapDialog::SetSizeAndPosition() |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 void CLmkIconMapDialog::SetSizeAndPosition(const TSize& aSize) |
|
135 { |
|
136 SetBorder(TGulBorder::ENone); // No Dialog borders in SCT. |
|
137 CAknDialog::SetSizeAndPosition(aSize); |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CLmkIconMapDialog::OfferKeyEventL() |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 TKeyResponse CLmkIconMapDialog::OfferKeyEventL(const TKeyEvent& aKeyEvent, |
|
145 TEventCode aModifiers) |
|
146 { |
|
147 if (aModifiers == EEventKey) |
|
148 { |
|
149 TUint code = aKeyEvent.iCode; |
|
150 CLmkIconMap* iconmapControl = |
|
151 STATIC_CAST(CLmkIconMap*, Control(ELmkIconMapContentId)); |
|
152 |
|
153 switch (code) |
|
154 { |
|
155 case EKeyLeftArrow: |
|
156 case EKeyRightArrow: |
|
157 case EKeyUpArrow: |
|
158 case EKeyDownArrow: |
|
159 { |
|
160 TKeyResponse res(iconmapControl->OfferKeyEventL(aKeyEvent, |
|
161 aModifiers)); |
|
162 return res; |
|
163 } |
|
164 case EKeyEnter: |
|
165 // change fro EKeyEnter to EKeyOK |
|
166 { |
|
167 TKeyEvent keyEvent; |
|
168 keyEvent.iCode = EKeyOK; |
|
169 keyEvent.iScanCode = aKeyEvent.iScanCode; |
|
170 keyEvent.iModifiers = aKeyEvent.iModifiers; |
|
171 keyEvent.iRepeats = aKeyEvent.iRepeats; |
|
172 return CEikDialog::OfferKeyEventL(keyEvent, aModifiers); |
|
173 } |
|
174 default: |
|
175 break; |
|
176 } |
|
177 } |
|
178 return CEikDialog::OfferKeyEventL(aKeyEvent, aModifiers); |
|
179 } |
|
180 |
|
181 // ----------------------------------------------------------------------------- |
|
182 // CLmkIconMapDialog::ExecuteLD() |
|
183 // ----------------------------------------------------------------------------- |
|
184 // |
|
185 TInt CLmkIconMapDialog::ExecuteLD(TInt aResourceId) |
|
186 { |
|
187 // Prepare real icon map |
|
188 CEikDialog::PrepareLC(aResourceId); |
|
189 return (RunLD()); |
|
190 } |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
|
193 // CLmkIconMapDialog::CEikDialog_Reserved_1() |
|
194 // ----------------------------------------------------------------------------- |
|
195 // |
|
196 void CLmkIconMapDialog::CEikDialog_Reserved_1() |
|
197 { |
|
198 } |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // CLmkIconMapDialog::CEikDialog_Reserved_2() |
|
202 // ----------------------------------------------------------------------------- |
|
203 // |
|
204 void CLmkIconMapDialog::CEikDialog_Reserved_2() |
|
205 { |
|
206 } |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // CLmkIconMapDialog::CLmkIconMapDialog_Reserved() |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 void CLmkIconMapDialog::CAknIconMapDialog_Reserved() |
|
213 { |
|
214 } |
|
215 |
|
216 // ----------------------------------------------------------------------------- |
|
217 // CLmkIconMapDialog::DoLayout() |
|
218 // Doing all the Layout calculations |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 void CLmkIconMapDialog::DoLayout() |
|
222 { |
|
223 /* |
|
224 TAknLayoutRect dialogLayRect; |
|
225 |
|
226 CLmkIconMap* iconmapControl = |
|
227 STATIC_CAST(CLmkIconMap*, Control(ELmkIconMapContentId)); |
|
228 |
|
229 // Number of icon rows in the icon table |
|
230 TInt rows = iconmapControl->HeightInRows(); |
|
231 |
|
232 // Main pane without softkeys |
|
233 TRect mainPaneRect; |
|
234 if(!AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect)) |
|
235 { |
|
236 mainPaneRect = iAvkonAppUi->ClientRect(); |
|
237 } |
|
238 |
|
239 // Layout the dialog size |
|
240 dialogLayRect.LayoutRect( mainPaneRect,AknLayoutScalable_Avkon::popup_grid_graphic_window(3)); |
|
241 |
|
242 // Set the retangle for dialog and eventually to CLmkIconMap |
|
243 SetRect(dialogLayRect.Rect()); |
|
244 |
|
245 // Need to update popup heading's skin IDs to zero to draw background |
|
246 |
|
247 // Offscreen background for picto table. |
|
248 iconmapControl->DrawOffscreenBackgroundIfRequired(); |
|
249 */ |
|
250 } |
|
251 |
|
252 // ----------------------------------------------------------------------------- |
|
253 // CLmkIconMapDialog::CreateCustomControlL() |
|
254 // Virtual function override from the base class to implement the custom control |
|
255 // ----------------------------------------------------------------------------- |
|
256 // |
|
257 SEikControlInfo CLmkIconMapDialog::CreateCustomControlL(TInt aControlType) |
|
258 { |
|
259 CLmkIconMap *control = NULL; |
|
260 if (aControlType == ELmkCtIconMap) |
|
261 { |
|
262 control = CLmkIconMap::NewL(); |
|
263 } |
|
264 SEikControlInfo info; |
|
265 info.iControl = control; |
|
266 info.iFlags = 0; |
|
267 info.iTrailerTextId = 0; |
|
268 return info; |
|
269 } |
|
270 |
|
271 #ifdef RD_SCALABLE_UI_V2 |
|
272 // ----------------------------------------------------------------------------- |
|
273 // CLmkIconMapDialog::HandleControlEventL |
|
274 // Handles the event. |
|
275 // ----------------------------------------------------------------------------- |
|
276 // |
|
277 void CLmkIconMapDialog::HandleControlEventL(CCoeControl* /*aControl*/, |
|
278 TCoeEvent aEventType) |
|
279 { |
|
280 if (aEventType == EEventStateChanged) |
|
281 { |
|
282 iConSelected = ETrue; |
|
283 TryExitL(EAknSoftkeyOk); |
|
284 } |
|
285 } |
|
286 |
|
287 // ----------------------------------------------------------------------------- |
|
288 // CLmkIconMapDialog::HandleDialogPageEventL |
|
289 // Handles the event. |
|
290 // ----------------------------------------------------------------------------- |
|
291 // |
|
292 void CLmkIconMapDialog::HandleDialogPageEventL(TInt aEventID) |
|
293 { |
|
294 if (AknLayoutUtils::PenEnabled() && (aEventID |
|
295 == MEikDialogPageObserver::EDialogPageTapped && iConSelected)) |
|
296 { |
|
297 TryExitL(EAknSoftkeyOk); |
|
298 } |
|
299 } |
|
300 |
|
301 //-------------------------------------------------------------------------- |
|
302 // void CLmkIconMapDialog::HandlePointerEventL() |
|
303 //-------------------------------------------------------------------------- |
|
304 void CLmkIconMapDialog::HandlePointerEventL( |
|
305 const TPointerEvent& aPointerEvent) |
|
306 { |
|
307 if (AknLayoutUtils::PenEnabled()) |
|
308 { |
|
309 if (aPointerEvent.iPosition.iY <= 0 && aPointerEvent.iType |
|
310 == TPointerEvent::EButton1Down) |
|
311 { |
|
312 TryExitL(EAknSoftkeyCancel); |
|
313 } |
|
314 else |
|
315 { |
|
316 CLmkIconMap* iconmapControl = |
|
317 STATIC_CAST(CLmkIconMap*, Control(ELmkIconMapContentId)); |
|
318 iconmapControl->HandlePointerEventL(aPointerEvent); |
|
319 } |
|
320 } |
|
321 } |
|
322 #endif //RD_SCALABLE_UI_V2 |
|
323 // End of File |
|
324 |