|
1 /* |
|
2 * Copyright (c) 2006 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 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "AknAdaptiveSearchGrid.h" |
|
21 #include <AknsDrawUtils.h> |
|
22 #include <layoutmetadata.cdl.h> |
|
23 #include <aknlayoutscalable_apps.cdl.h> |
|
24 #include <aknlayoutscalable_avkon.cdl.h> |
|
25 |
|
26 #include <AknsListBoxBackgroundControlContext.h> |
|
27 #include <AknsBasicBackgroundControlContext.h> |
|
28 #include <AknsFrameBackgroundControlContext.h> |
|
29 #include <numberconversion.h> // For page indicator |
|
30 |
|
31 #include <eikedwin.h> |
|
32 #include <akninfrm.h> // CAknInputFrame |
|
33 #include <avkon.mbg> // Bitmaps for "dummy" find pane |
|
34 #include <aknconsts.h> // KAvkonBitmapFile |
|
35 #include <featmgr.h> // FeatureManager |
|
36 #include <aknViewAppUi.h> // CAknViewAppUi |
|
37 #include <akntoolbar.h> |
|
38 |
|
39 #include "aknSfldIndicatorFactory.h" |
|
40 #include "aknsfldIndicator.h" |
|
41 #include <aknEditStateIndicator.h> |
|
42 #include <eikbtgpc.h> |
|
43 #include <aknsfld.h> //for TSearchFieldStyle |
|
44 |
|
45 #include <touchfeedback.h> |
|
46 |
|
47 #include "akntrace.h" |
|
48 // CONSTANTS |
|
49 const TInt KPortraitMaxSize = 0; |
|
50 const TInt KLandscapeMaxSize = 1; |
|
51 |
|
52 const TInt KPortraitMultiPage = 0; |
|
53 const TInt KLandscapeMultiPage = 1; |
|
54 const TInt KPortraitSinglePage = 2; |
|
55 const TInt KLandscapeSinglePage = 3; |
|
56 |
|
57 const TInt KPortraitToolbarMaxSize = 18; |
|
58 |
|
59 |
|
60 _LIT( KSlashOfPageIndicator, "/" ); |
|
61 _LIT( KSpaceCharacter, " " ); |
|
62 const TInt KCloseAndClearButtonCount = 2; |
|
63 |
|
64 // ============================ MEMBER FUNCTIONS =============================== |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CAknAdaptiveSearchGrid::NewL() |
|
68 // Two-phased constructor. |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 CAknAdaptiveSearchGrid* |
|
72 CAknAdaptiveSearchGrid::NewL( const TInt aTextLimit, TInt aFieldStyle ) |
|
73 { |
|
74 CAknAdaptiveSearchGrid* self = CAknAdaptiveSearchGrid::NewLC( aTextLimit, |
|
75 aFieldStyle ); |
|
76 CleanupStack::Pop( self ); |
|
77 return self; |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CAknAdaptiveSearchGrid::NewLC() |
|
82 // Two-phased constructor. |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 CAknAdaptiveSearchGrid* |
|
86 CAknAdaptiveSearchGrid::NewLC( const TInt aTextLimit, TInt aFieldStyle ) |
|
87 { |
|
88 CAknAdaptiveSearchGrid* self = new ( ELeave ) CAknAdaptiveSearchGrid ( aTextLimit ); |
|
89 CleanupStack::PushL( self ); |
|
90 self->ConstructL( aFieldStyle ); |
|
91 return self; |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CAknAdaptiveSearchGrid::CAknAdaptiveSearchGrid() |
|
96 // C++ default constructor. |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 CAknAdaptiveSearchGrid::CAknAdaptiveSearchGrid( const TInt aTextLimit ) |
|
100 : iCloseButton( NULL ), |
|
101 iDeleteButton( NULL ), |
|
102 iPrevButton( NULL ), |
|
103 iNextButton( NULL ), |
|
104 iLastFocusedButton( NULL ), |
|
105 iTextLimit( aTextLimit ), |
|
106 iShown( EFalse ), |
|
107 iNumOfPages( 1 ), |
|
108 iGridChars( NULL ), |
|
109 iAppUi( iAvkonAppUi ), |
|
110 iAdaptiveSearchGridObserver( NULL ), |
|
111 iLayoutChanged(EFalse), |
|
112 iPopupFindpane(EFalse) |
|
113 { |
|
114 __ASSERT_DEBUG( iAppUi, User::Invariant() ); |
|
115 SetMopParent( iAppUi ); |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CAknAdaptiveSearchGrid::~CAknAdaptiveSearchGrid() |
|
120 // Destructor. |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 CAknAdaptiveSearchGrid::~CAknAdaptiveSearchGrid() |
|
124 { |
|
125 _AKNTRACE_FUNC_ENTER; |
|
126 CEikonEnv::Static()->EikAppUi()->RemoveFromStack( this ); |
|
127 delete iBgContextOfFindPane; |
|
128 delete iBgContextOfControlPane; |
|
129 delete iSkinContextOfFindPane; |
|
130 delete iInputFrame; |
|
131 |
|
132 // Clear current region of AS |
|
133 iCurrentRegion.Clear(); |
|
134 iButtonArray.ResetAndDestroy(); |
|
135 |
|
136 if ( iEditor ) |
|
137 { |
|
138 TRAP_IGNORE(iEditor->TextView()->SetCursorVisibilityL( |
|
139 TCursor::EFCursorInvisible, TCursor::EFCursorInvisible )); |
|
140 delete iEditor; |
|
141 } |
|
142 if( iGridChars ) |
|
143 { |
|
144 delete iGridChars; |
|
145 iGridChars = NULL; |
|
146 } |
|
147 if( iCloseButton ) |
|
148 { |
|
149 delete iCloseButton; |
|
150 iCloseButton = NULL; |
|
151 } |
|
152 if( iDeleteButton ) |
|
153 { |
|
154 delete iDeleteButton; |
|
155 iDeleteButton = NULL; |
|
156 } |
|
157 if( iPrevButton ) |
|
158 { |
|
159 delete iPrevButton; |
|
160 iPrevButton = NULL; |
|
161 } |
|
162 if( iNextButton ) |
|
163 { |
|
164 delete iNextButton; |
|
165 iNextButton = NULL; |
|
166 } |
|
167 if( iPageIndicator ) |
|
168 { |
|
169 delete iPageIndicator; |
|
170 iPageIndicator = NULL; |
|
171 } |
|
172 |
|
173 CAknWsEventMonitor* eventMonitor = iAppUi->EventMonitor(); |
|
174 eventMonitor->Enable( EFalse ); |
|
175 eventMonitor->RemoveObserver( this ); |
|
176 _AKNTRACE_FUNC_EXIT; |
|
177 } |
|
178 |
|
179 // ----------------------------------------------------------------------------- |
|
180 // CAknAdaptiveSearchGrid::ConstructL() |
|
181 // Symbian 2nd phase constructor. |
|
182 // ----------------------------------------------------------------------------- |
|
183 // |
|
184 void CAknAdaptiveSearchGrid::ConstructL( TInt aFieldStyle ) |
|
185 { |
|
186 _AKNTRACE_FUNC_ENTER; |
|
187 |
|
188 _AKNTRACE( "[%s][%s] Search Field Style : %d", "CAknAdaptiveSearchGrid", __FUNCTION__, aFieldStyle ); |
|
189 CreateWindowL(); |
|
190 |
|
191 if( CAknEnv::Static()->TransparencyEnabled() ) |
|
192 { |
|
193 Window().SetRequiredDisplayMode( EColor16MA ); |
|
194 TInt err = Window().SetTransparencyAlphaChannel(); |
|
195 if ( err == KErrNone ) |
|
196 { |
|
197 Window().SetBackgroundColor(~0); |
|
198 } |
|
199 } |
|
200 |
|
201 CAknWsEventMonitor* eventMonitor = iAppUi->EventMonitor(); |
|
202 eventMonitor->AddObserverL( this ); |
|
203 eventMonitor->Enable(); |
|
204 |
|
205 iSkinContextOfFindPane = CAknsListBoxBackgroundControlContext::NewL( KAknsIIDQsnBgAreaControlPopup, |
|
206 TRect(0,0,0,0), |
|
207 EFalse, |
|
208 KAknsIIDNone, |
|
209 TRect(0,0,0,0) ); |
|
210 iBgContextOfFindPane = CAknsFrameBackgroundControlContext::NewL( KAknsIIDQsnFrInput, |
|
211 TRect(0,0,0,0), |
|
212 TRect(0,0,0,0), |
|
213 EFalse ); |
|
214 iBgContextOfControlPane = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQgnGrafAdaptSearchPageBg, |
|
215 TRect(0,0,0,0), EFalse ); |
|
216 // Init components |
|
217 InitControlsL( aFieldStyle ); |
|
218 InitGrid(); |
|
219 _AKNTRACE_FUNC_EXIT; |
|
220 } |
|
221 |
|
222 // --------------------------------------------------------------------------- |
|
223 // CAknAdaptiveSearchGrid::InitControls() |
|
224 // Initiates find pane and page indicator. |
|
225 // Create control buttons: close, delete, next page, prev page |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 void CAknAdaptiveSearchGrid::InitControlsL( TInt aFieldStyle ) |
|
229 { |
|
230 CGulIcon* gulIcon = NULL; |
|
231 |
|
232 gulIcon = GetColorIconL( 0 ); |
|
233 iCloseButton = CAknButton::NewL( gulIcon, NULL, NULL, NULL, KNullDesC, |
|
234 KNullDesC, 0, 0 ); |
|
235 iCloseButton->SetBackgroundIds( KAknsIIDQsnFrFunctionButtonNormal, |
|
236 KAknsIIDQsnFrFunctionButtonPressed, KAknsIIDQsnFrFunctionButtonInactive, |
|
237 KAknsIIDQsnFrFunctionButtonPressed, KAknsIIDQsnFrFunctionButtonInactive ); |
|
238 iCloseButton->SetObserver( this ); |
|
239 iCloseButton->SetContainerWindowL( *this ); |
|
240 |
|
241 gulIcon = GetColorIconL( 1 ); |
|
242 iDeleteButton = CAknButton::NewL( gulIcon, NULL, NULL, NULL, KNullDesC, |
|
243 KNullDesC, KAknButtonKeyRepeat, 0 ); |
|
244 iDeleteButton->SetBackgroundIds( KAknsIIDQsnFrFunctionButtonNormal, |
|
245 KAknsIIDQsnFrFunctionButtonPressed, KAknsIIDQsnFrFunctionButtonInactive, |
|
246 KAknsIIDQsnFrFunctionButtonPressed, KAknsIIDQsnFrFunctionButtonInactive ); |
|
247 iDeleteButton->SetObserver( this ); |
|
248 iDeleteButton->SetContainerWindowL( *this ); |
|
249 |
|
250 gulIcon = GetColorIconL( 2 ); |
|
251 iPrevButton = CAknButton::NewL( gulIcon, NULL, NULL, NULL, KNullDesC, |
|
252 KNullDesC, KAknButtonKeyRepeat, 0 ); |
|
253 iPrevButton->SetBackgroundIds( KAknsIIDQsnFrFunctionButtonNormal, |
|
254 KAknsIIDQsnFrFunctionButtonPressed, KAknsIIDQsnFrFunctionButtonInactive, |
|
255 KAknsIIDQsnFrFunctionButtonPressed, KAknsIIDQsnFrFunctionButtonInactive ); |
|
256 iPrevButton->SetObserver( this ); |
|
257 iPrevButton->SetContainerWindowL( *this ); |
|
258 |
|
259 gulIcon = GetColorIconL( 3 ); |
|
260 iNextButton = CAknButton::NewL( gulIcon, NULL, NULL, NULL, KNullDesC, |
|
261 KNullDesC, KAknButtonKeyRepeat, 0 ); |
|
262 iNextButton->SetBackgroundIds( KAknsIIDQsnFrFunctionButtonNormal, |
|
263 KAknsIIDQsnFrFunctionButtonPressed, KAknsIIDQsnFrFunctionButtonInactive, |
|
264 KAknsIIDQsnFrFunctionButtonPressed, KAknsIIDQsnFrFunctionButtonInactive ); |
|
265 iNextButton->SetObserver( this ); |
|
266 iNextButton->SetContainerWindowL( *this ); |
|
267 |
|
268 TUint flags = 0; |
|
269 switch ( aFieldStyle ) |
|
270 { |
|
271 case CAknSearchField::EPopupAdaptiveSearch: |
|
272 flags |= CAknInputFrame::EPopupLayout; |
|
273 iPopupFindpane = ETrue; |
|
274 break; |
|
275 case CAknSearchField::EPopupAdaptiveSearchWindow: |
|
276 flags |= CAknInputFrame::EPopupWindowLayout; |
|
277 flags |= CAknInputFrame::EFixedFindWithoutLine; |
|
278 break; |
|
279 } |
|
280 iEditor = new (ELeave) CEikEdwin; |
|
281 |
|
282 iInputFrame = CAknInputFrame::NewL( iEditor, |
|
283 EFalse, |
|
284 KAvkonBitmapFile, |
|
285 EMbmAvkonQgn_indi_find_glass, |
|
286 EMbmAvkonQgn_indi_find_glass_mask, |
|
287 flags ); |
|
288 |
|
289 iEditor->SetContainerWindowL( *this ); |
|
290 iInputFrame->SetContainerWindowL( *this ); |
|
291 |
|
292 AknEditUtils::ConstructEditingL( iEditor, |
|
293 iTextLimit, |
|
294 1, |
|
295 EAknEditorCharactersLowerCase, |
|
296 EAknEditorAlignLeft, |
|
297 EFalse, |
|
298 ETrue, |
|
299 EFalse ); |
|
300 iEditor->SetObserver( this ); |
|
301 iEditor->SetBorder( TGulBorder::ENone ); |
|
302 iEditor->SetAknEditorInputMode( EAknEditorTextInputMode ); |
|
303 iEditor->SetAknEditorAllowedInputModes( EAknEditorTextInputMode | |
|
304 EAknEditorNumericInputMode ); |
|
305 iEditor->AddFlagToUserFlags( CEikEdwin::EAvkonDisableVKB ); |
|
306 |
|
307 if ( FeatureManager::FeatureSupported( KFeatureIdJapanese ) ) |
|
308 { |
|
309 iEditor->SetAknEditorPermittedCaseModes( EAknEditorCharactersLowerCase ); |
|
310 } |
|
311 |
|
312 TInt editorFlags = EAknEditorFlagNoT9 | |
|
313 EAknEditorFlagNoLRNavigation | |
|
314 EAknEditorFlagForceTransparentFepModes | |
|
315 EAknEditorFlagNoEditIndicators | |
|
316 EAknEditorFlagFindPane; |
|
317 |
|
318 iEditor->SetAknEditorFlags( editorFlags ); |
|
319 iEditor->CreateTextViewL(); |
|
320 |
|
321 iInputFrame->SetInputContext( iBgContextOfFindPane ); |
|
322 iEditor->SetSkinBackgroundControlContextL( iBgContextOfFindPane ); |
|
323 |
|
324 TRgb textColor = KRgbBlack; |
|
325 TInt error = AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), |
|
326 textColor, |
|
327 KAknsIIDQsnTextColors, |
|
328 EAknsCIQsnTextColorsCG19); |
|
329 if( !error ) |
|
330 { |
|
331 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL(*iEditor, EColorLabelText, textColor) ); |
|
332 } |
|
333 |
|
334 // Create label for page indicator |
|
335 iPageIndicator = new (ELeave) CEikLabel; |
|
336 iPageIndicator->SetObserver( this ); |
|
337 iPageIndicator->SetContainerWindowL( *this ); |
|
338 iPageIndicator->SetTextL( KNullDesC ); |
|
339 } |
|
340 |
|
341 CGulIcon* CAknAdaptiveSearchGrid::GetColorIconL( TInt aIndex ) |
|
342 { |
|
343 // order: Close, Backspace, Previous, Next |
|
344 _AKNTRACE( "[%s][%s] color icon index : %d", "CAknAdaptiveSearchGrid", __FUNCTION__, aIndex ); |
|
345 TAknsItemID skinIdArray[] = |
|
346 { |
|
347 KAknsIIDQgnIndiSctClose, |
|
348 KAknsIIDQgnIndiAdaptSearchBackspace, |
|
349 KAknsIIDQgnIndiSctPagePrev, |
|
350 KAknsIIDQgnIndiSctPageNext, |
|
351 KAknsIIDQgnIndiKeypadSpace |
|
352 }; |
|
353 TInt bitmapIds [] = |
|
354 { |
|
355 EMbmAvkonQgn_indi_sct_close, |
|
356 EMbmAvkonQgn_indi_adapt_search_backspace, |
|
357 EMbmAvkonQgn_indi_sct_page_prev, |
|
358 EMbmAvkonQgn_indi_sct_page_next, |
|
359 EMbmAvkonQgn_indi_keypad_space |
|
360 }; |
|
361 TInt maskIds [] = |
|
362 { |
|
363 EMbmAvkonQgn_indi_sct_close_mask, |
|
364 EMbmAvkonQgn_indi_adapt_search_backspace_mask, |
|
365 EMbmAvkonQgn_indi_sct_page_prev_mask, |
|
366 EMbmAvkonQgn_indi_sct_page_next_mask, |
|
367 EMbmAvkonQgn_indi_keypad_space_mask |
|
368 }; |
|
369 |
|
370 CFbsBitmap *icon = NULL; |
|
371 CFbsBitmap *mask = NULL; |
|
372 |
|
373 TAknsItemID colorGroup = KAknsIIDQsnIconColors; |
|
374 TInt textColorIndex = EAknsCIQsnIconColorsCG30; |
|
375 // space belong to another color group |
|
376 if( aIndex == 4 ) |
|
377 { |
|
378 colorGroup = KAknsIIDQsnTextColors; |
|
379 textColorIndex = EAknsCIQsnTextColorsCG65; |
|
380 } |
|
381 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
382 if( aIndex == 0 ) |
|
383 { |
|
384 AknsUtils::CreateIconL( skin, skinIdArray[aIndex], |
|
385 icon, mask, KAvkonBitmapFile, |
|
386 bitmapIds[aIndex], maskIds[aIndex] ); |
|
387 } |
|
388 else |
|
389 { |
|
390 AknsUtils::CreateColorIconL( skin, skinIdArray[aIndex], |
|
391 colorGroup, |
|
392 textColorIndex, |
|
393 icon, mask, |
|
394 KAvkonBitmapFile, |
|
395 bitmapIds[aIndex], |
|
396 maskIds[aIndex], |
|
397 KRgbBlack ); |
|
398 } |
|
399 |
|
400 CGulIcon* gulIcon = CGulIcon::NewL( icon, mask ); |
|
401 return gulIcon; |
|
402 } |
|
403 |
|
404 // ----------------------------------------------------------------------------- |
|
405 // CAknAdaptiveSearchGrid::UpdateLayoutVariant() |
|
406 // Update layout variant. This should be done when |
|
407 // KEikDynamicLayoutVariantSwitch message recieved. |
|
408 // ----------------------------------------------------------------------------- |
|
409 // |
|
410 void CAknAdaptiveSearchGrid::UpdateLayoutVariant() |
|
411 { |
|
412 _AKNTRACE_FUNC_ENTER; |
|
413 InitGrid(); |
|
414 UpdatePageAndRowCount(); |
|
415 if( IsShown() ) |
|
416 { |
|
417 ControlsPositions(); |
|
418 TRAP_IGNORE( UpdateVisibleButtonsL() ); |
|
419 ShowControls(); |
|
420 } |
|
421 _AKNTRACE_FUNC_EXIT; |
|
422 } |
|
423 |
|
424 // ----------------------------------------------------------------------------- |
|
425 // CAknAdaptiveSearchGrid::UpdateSkinL() |
|
426 // Update adaptive search grid skin. This should be done when |
|
427 // KAknsMessageSkinChange message recieved. |
|
428 // ----------------------------------------------------------------------------- |
|
429 // |
|
430 void CAknAdaptiveSearchGrid::UpdateSkinL() |
|
431 { |
|
432 CGulIcon* gulIcon = NULL; |
|
433 gulIcon = GetColorIconL( 0 ); |
|
434 iCloseButton->State()->SetIcon( gulIcon ); |
|
435 CGulIcon* gulIcon1 = NULL; |
|
436 gulIcon1 = GetColorIconL( 1 ); |
|
437 iDeleteButton->State()->SetIcon( gulIcon1 ); |
|
438 CGulIcon* gulIcon2 = NULL; |
|
439 gulIcon2 = GetColorIconL( 2 ); |
|
440 iPrevButton->State()->SetIcon( gulIcon2 ); |
|
441 CGulIcon* gulIcon3 = NULL; |
|
442 gulIcon3 = GetColorIconL( 3 ); |
|
443 iNextButton->State()->SetIcon( gulIcon3 ); |
|
444 |
|
445 UpdateVisibleButtonsL(); |
|
446 |
|
447 if( iNumOfPages > 1 ) |
|
448 { |
|
449 // Page pane & page indicator |
|
450 TRect page_pane = RectFromLayout( Rect(), AknLayoutScalable_Apps::afind_page_pane( iLayoutOption) ); |
|
451 if( AknsUtils::AvkonSkinEnabled() ) |
|
452 { |
|
453 TRgb textColor = KRgbBlack; |
|
454 TInt error = AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), |
|
455 textColor, |
|
456 KAknsIIDQsnTextColors, |
|
457 EAknsCIQsnTextColorsCG19); |
|
458 if( !error ) |
|
459 AknLayoutUtils::OverrideControlColorL(*iPageIndicator, EColorLabelText, textColor); |
|
460 } |
|
461 iBgContextOfControlPane->SetRect( page_pane ); |
|
462 } |
|
463 } |
|
464 // CAknAdaptiveSearchGrid::InitGridButtons() |
|
465 // Initiates buttons array of the adaptive search grid. |
|
466 // iTotalGridButtons should be calculated in advance by caling InitGrid() |
|
467 // ----------------------------------------------------------------------------- |
|
468 // |
|
469 void CAknAdaptiveSearchGrid::InitGridButtons() |
|
470 { |
|
471 iButtonArray.ResetAndDestroy(); |
|
472 //EKKG-7LZB4U. When SizeChanged() is invoked, maybe iLastFocusedButton keeps invaild point. |
|
473 iLastFocusedButton = NULL; |
|
474 for ( TInt i = 0; i < iTotalGridButtons; i++ ) |
|
475 { |
|
476 TRAP_IGNORE( iButtonArray.Append( CreateButtonL() ) ); |
|
477 } |
|
478 } |
|
479 |
|
480 // ----------------------------------------------------------------------------- |
|
481 // CAknAdaptiveSearchGrid::CreateButtonL |
|
482 // Create a button from Text or Resource. |
|
483 // Set to button observer and container window |
|
484 // ----------------------------------------------------------------------------- |
|
485 // |
|
486 CAknButton* CAknAdaptiveSearchGrid::CreateButtonL() |
|
487 { |
|
488 CAknButton* button = CAknButton::NewL( NULL, NULL, NULL, NULL, |
|
489 KNullDesC, KNullDesC , KAknButtonSizeFitText, 0 ); |
|
490 |
|
491 if ( button ) |
|
492 { |
|
493 button->SetObserver( this ); |
|
494 button->SetContainerWindowL( *this ); |
|
495 button->SetBackground(this); |
|
496 button->SetTextColorIds( KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG65 ); |
|
497 button->ActivateL(); |
|
498 return button; |
|
499 } |
|
500 else |
|
501 { |
|
502 CleanupStack::PopAndDestroy( button ); |
|
503 User::LeaveNoMemory(); |
|
504 return NULL; |
|
505 } |
|
506 } |
|
507 |
|
508 // ----------------------------------------------------------------------------- |
|
509 // CAknAdaptiveSearchGrid::RectFromLayout |
|
510 // ----------------------------------------------------------------------------- |
|
511 // |
|
512 TRect CAknAdaptiveSearchGrid::RectFromLayout( const TRect& aParent, |
|
513 const TAknWindowComponentLayout& aComponentLayout ) const |
|
514 { |
|
515 TAknWindowLineLayout lineLayout = aComponentLayout.LayoutLine(); |
|
516 TAknLayoutRect layoutRect; |
|
517 layoutRect.LayoutRect( aParent, lineLayout ); |
|
518 return layoutRect.Rect(); |
|
519 } |
|
520 |
|
521 // ----------------------------------------------------------------------------- |
|
522 // CAknAdaptiveSearchGrid::InitGrid |
|
523 // Calculate max grid size and total amount of buttons for initialisation |
|
524 // ----------------------------------------------------------------------------- |
|
525 // |
|
526 void CAknAdaptiveSearchGrid::InitGrid() |
|
527 { |
|
528 TInt layout_option; |
|
529 |
|
530 if( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
531 { |
|
532 iLayoutOption = KLandscapeSinglePage; |
|
533 layout_option = KLandscapeMaxSize; |
|
534 iToolbarShown = EFalse; |
|
535 } |
|
536 else |
|
537 { |
|
538 CAknToolbar* toolbar = iAppUi->CurrentFixedToolbar(); |
|
539 iLayoutOption = KPortraitSinglePage; |
|
540 |
|
541 if ( toolbar && toolbar->IsShown() ) |
|
542 { |
|
543 iToolbarShown = ETrue; |
|
544 layout_option = KPortraitToolbarMaxSize; |
|
545 } |
|
546 else |
|
547 { |
|
548 iToolbarShown = EFalse; |
|
549 layout_option = KPortraitMaxSize; |
|
550 } |
|
551 } |
|
552 |
|
553 TRect appWindow; |
|
554 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow, appWindow ); |
|
555 TRect currentWindowRect = RectFromLayout( appWindow, AknLayoutScalable_Apps::popup_adpt_find_window(layout_option) ); |
|
556 |
|
557 // TODO: Remove this once the layout is fixed so that the adaptive search |
|
558 // grid doesn't go over the control pane area in BSK landscape layout. |
|
559 if ( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
560 { |
|
561 TRect controlPaneRect; |
|
562 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EControlPane, |
|
563 controlPaneRect ); |
|
564 currentWindowRect.iBr.iY = controlPaneRect.iTl.iY; |
|
565 |
|
566 TRect mainPaneRect; |
|
567 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, |
|
568 mainPaneRect ); |
|
569 |
|
570 if ( 0 != iFindpaneRect.Size().iWidth |
|
571 && iFindpaneRect.Size().iWidth <= mainPaneRect.Size().iWidth ) |
|
572 { |
|
573 currentWindowRect.iBr.iX = currentWindowRect.iTl.iX |
|
574 + iFindpaneRect.Size().iWidth; |
|
575 } |
|
576 else |
|
577 { |
|
578 currentWindowRect.iBr.iX = currentWindowRect.iTl.iX |
|
579 + mainPaneRect.Size().iWidth; |
|
580 } |
|
581 } |
|
582 |
|
583 TRect grid_pane = RectFromLayout( currentWindowRect, AknLayoutScalable_Apps::grid_afind_pane( iLayoutOption ) ); |
|
584 TRect button_rect = RectFromLayout( grid_pane, AknLayoutScalable_Apps::cell_afind_pane( iLayoutOption, 0, 0 ) ); |
|
585 TSize button_rect_size = button_rect.Size(); |
|
586 TSize grid_pane_size = grid_pane.Size(); |
|
587 |
|
588 iNumOfCols = grid_pane_size.iWidth/button_rect_size.iWidth; |
|
589 iNumOfRows = grid_pane_size.iHeight/button_rect_size.iHeight; |
|
590 iTotalGridButtons = iNumOfCols*iNumOfRows; |
|
591 |
|
592 //For ELJG-7VC8Q2, calculate the length of overlap section |
|
593 TRect popup_find_pane = RectFromLayout( Rect(), AknLayoutScalable_Avkon::popup_find_window() ); |
|
594 TRect find_pane = RectFromLayout( Rect(), AknLayoutScalable_Apps::find_pane_cp01( iLayoutOption ) ); |
|
595 iOverlapLength = (find_pane.iTl.iY - popup_find_pane.iTl.iY)/iNumOfRows + 1; |
|
596 |
|
597 |
|
598 // max amount of char buttons on the one page |
|
599 iMaxAmountOfButtons = iTotalGridButtons - KCloseAndClearButtonCount; |
|
600 |
|
601 SetRect( currentWindowRect ); |
|
602 } |
|
603 |
|
604 // ----------------------------------------------------------------------------- |
|
605 // CAknAdaptiveSearchGrid::Draw |
|
606 // From MCoeControlBackground |
|
607 // Draw the background for a given control. |
|
608 // The text drawer that shall be used to draw text on the specific background |
|
609 // can be fetched through the GetTextDrawer() method. |
|
610 // ----------------------------------------------------------------------------- |
|
611 // |
|
612 void CAknAdaptiveSearchGrid::Draw( CWindowGc& aGc, const CCoeControl& /*aControl*/, |
|
613 const TRect& aRect ) const |
|
614 { |
|
615 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
616 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
|
617 aGc.SetBrushColor( KRgbWhite ); |
|
618 aGc.SetPenColor( KRgbBlack ); |
|
619 aGc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
620 aGc.DrawRect( aRect ); |
|
621 } |
|
622 |
|
623 // ----------------------------------------------------------------------------- |
|
624 // CAknAdaptiveSearchGrid::Draw() |
|
625 // Draws the display. |
|
626 // ----------------------------------------------------------------------------- |
|
627 // |
|
628 |
|
629 void CAknAdaptiveSearchGrid::Draw( const TRect& /*aRect*/ ) const |
|
630 { |
|
631 if( iNumOfPages > 1 ) |
|
632 { |
|
633 // Page pane |
|
634 TRect page_pane; |
|
635 CWindowGc& gc = SystemGc(); |
|
636 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
637 page_pane = RectFromLayout( Rect(), AknLayoutScalable_Apps::afind_page_pane(iLayoutOption) ); |
|
638 |
|
639 AknsDrawUtils::Background( skin, iBgContextOfControlPane, gc, page_pane ); |
|
640 } |
|
641 } |
|
642 |
|
643 // ----------------------------------------------------------------------------- |
|
644 // CAknAdaptiveSearchGrid::SizeChanged() |
|
645 // Called by framework when the view size is changed. |
|
646 // ----------------------------------------------------------------------------- |
|
647 // |
|
648 void CAknAdaptiveSearchGrid::SizeChanged() |
|
649 { |
|
650 InitGridButtons(); |
|
651 GridButtonsPositions(); |
|
652 } |
|
653 |
|
654 // ----------------------------------------------------------------------------- |
|
655 // CAknAdaptiveSearchGrid::MopSupplyObject |
|
656 // Retrieves an object of the same type as that encapsulated in aId. |
|
657 // ----------------------------------------------------------------------------- |
|
658 // |
|
659 TTypeUid::Ptr CAknAdaptiveSearchGrid::MopSupplyObject( TTypeUid aId ) |
|
660 { |
|
661 if ( aId.iUid == MAknsControlContext::ETypeId && iSkinContextOfFindPane ) |
|
662 { |
|
663 return MAknsControlContext::SupplyMopObject( aId, iSkinContextOfFindPane ); |
|
664 } |
|
665 return MAknsControlContext::SupplyMopObject( aId, NULL ); |
|
666 } |
|
667 |
|
668 // ----------------------------------------------------------------------------- |
|
669 // CAknAdaptiveSearchGrid::CountComponentControls |
|
670 // Gets the number of controls contained in a compound control. |
|
671 // ----------------------------------------------------------------------------- |
|
672 // |
|
673 TInt CAknAdaptiveSearchGrid::CountComponentControls() const |
|
674 { |
|
675 // buttons + controls + search field ( editor, input frame ) |
|
676 return iButtonArray.Count()+5+2; |
|
677 } |
|
678 |
|
679 // ----------------------------------------------------------------------------- |
|
680 // Sets text into search field. |
|
681 // Gets one parameters: |
|
682 // const TDesC& aSearchTxt - Reference to the text buffer. |
|
683 // ----------------------------------------------------------------------------- |
|
684 // |
|
685 void CAknAdaptiveSearchGrid::SetSearchTextToFindPane( const TDesC& aSearchTxt ) |
|
686 { |
|
687 _AKNDEBUG( |
|
688 _LIT( KClassName, "CAknAdaptiveSearchGrid" ); |
|
689 _LIT( KFunctionName, "SetSearchTextToFindPane" ); |
|
690 _LIT( KFormat, "[%S][%S] search text is: %S"); |
|
691 _AKNTRACE( KFormat, |
|
692 &KClassName, &KFunctionName, &aSearchTxt ); |
|
693 ); |
|
694 |
|
695 TRAP_IGNORE( iEditor->SetTextL( &aSearchTxt ) ); |
|
696 if ( iShown ) |
|
697 { |
|
698 TRAP_IGNORE(iEditor->TextView()->SetCursorVisibilityL( TCursor::EFCursorFlashing, |
|
699 TCursor::EFCursorFlashing )); |
|
700 } |
|
701 TInt curPos = iEditor->TextLength(); |
|
702 //This set selection all off |
|
703 TRAP_IGNORE( iEditor->SetSelectionL( curPos, curPos ) ); |
|
704 iEditor->DrawNow(); |
|
705 } |
|
706 |
|
707 // ----------------------------------------------------------------------------- |
|
708 // CAknAdaptiveSearchGrid::ComponentControlh |
|
709 // Gets the specified component of a compound control. |
|
710 // ----------------------------------------------------------------------------- |
|
711 // |
|
712 CCoeControl* CAknAdaptiveSearchGrid::ComponentControl( TInt aIndex ) const |
|
713 { |
|
714 if(aIndex < iButtonArray.Count() && aIndex >= 0) |
|
715 { |
|
716 return iButtonArray[aIndex]; |
|
717 } |
|
718 else |
|
719 { |
|
720 switch(aIndex - iButtonArray.Count() ) |
|
721 { |
|
722 case 0: |
|
723 return iNextButton; |
|
724 case 1: |
|
725 return iPrevButton; |
|
726 case 2: |
|
727 return iCloseButton; |
|
728 case 3: |
|
729 return iDeleteButton; |
|
730 case 4: |
|
731 return iPageIndicator; |
|
732 case 5: |
|
733 return iInputFrame; |
|
734 case 6: |
|
735 return iEditor; |
|
736 default: |
|
737 return NULL; |
|
738 } |
|
739 } |
|
740 } |
|
741 |
|
742 // ----------------------------------------------------------------------------- |
|
743 // CAknAdaptiveSearchGrid::SetAdaptiveSearchGridVisibility |
|
744 // Shows or hides grid. |
|
745 // The position of the top left corner should be set in advance. |
|
746 // ----------------------------------------------------------------------------- |
|
747 // |
|
748 void CAknAdaptiveSearchGrid::SetVisibilityL( TBool aVisible, TBool aSelectAll ) |
|
749 { |
|
750 _AKNTRACE( "[%s][%s] Visible : %d", "CAknAdaptiveSearchGrid", __FUNCTION__, aVisible ); |
|
751 if ( aVisible ) |
|
752 { |
|
753 SetFocus( ETrue); |
|
754 iCurrentPage = 1; |
|
755 ShowL(); |
|
756 if ( iEditor ) |
|
757 { |
|
758 iEditor->SetFocus( ETrue ); |
|
759 TInt curPos = iEditor->TextLength(); |
|
760 iEditor->SetCursorPosL( curPos, EFalse ); |
|
761 if ( aSelectAll) |
|
762 { |
|
763 iEditor->SelectAllL(); |
|
764 } |
|
765 } |
|
766 } |
|
767 else |
|
768 { |
|
769 HideL(); |
|
770 } |
|
771 } |
|
772 |
|
773 // ----------------------------------------------------------------------------- |
|
774 // CAknAdaptiveSearchGrid::SetButtonGridChars |
|
775 // |
|
776 // ----------------------------------------------------------------------------- |
|
777 // |
|
778 void CAknAdaptiveSearchGrid::SetButtonGridChars( const TDesC& aGridChars ) |
|
779 { |
|
780 _AKNDEBUG( |
|
781 _LIT( KClassName, "CAknAdaptiveSearchGrid" ); |
|
782 _LIT( KFunctionName, "SetButtonGridChars" ); |
|
783 _LIT( KFormat, "[%S][%S] grid char is: %S"); |
|
784 _AKNTRACE( KFormat, |
|
785 &KClassName, &KFunctionName, &aGridChars ); |
|
786 ); |
|
787 |
|
788 if( iGridChars ) |
|
789 { |
|
790 delete iGridChars; |
|
791 iGridChars = NULL; |
|
792 } |
|
793 |
|
794 TRAPD( error, iGridChars = HBufC::NewL( aGridChars.Length() ) ); |
|
795 if ( error == KErrNone ) |
|
796 { |
|
797 iGridChars->Des().Copy( aGridChars ); |
|
798 } |
|
799 |
|
800 UpdatePageAndRowCount(); |
|
801 if( IsShown() ) |
|
802 { |
|
803 ControlsPositions(); |
|
804 TRAP_IGNORE( UpdateVisibleButtonsL() ); |
|
805 ShowControls(); |
|
806 DrawNow(); |
|
807 } |
|
808 } |
|
809 |
|
810 // ----------------------------------------------------------------------------- |
|
811 // CAknAdaptiveSearchGrid::GridButtonsPositions |
|
812 // Calculates position of the adaptive search grid buttons. |
|
813 // iButtonArray should be initialized with buttons in advance |
|
814 // ----------------------------------------------------------------------------- |
|
815 // |
|
816 void CAknAdaptiveSearchGrid::GridButtonsPositions() |
|
817 { |
|
818 if( ( iButtonArray.Count() == 0) || (iNumOfPages < 1 ) ) |
|
819 return; |
|
820 |
|
821 TRect grid_pane = RectFromLayout( Rect(), AknLayoutScalable_Apps::grid_afind_pane(iLayoutOption) ); |
|
822 TRect cell_pane; |
|
823 |
|
824 TInt temp = 0; |
|
825 for ( TInt j = 0; j < iNumOfRows; j++ ) |
|
826 { |
|
827 for ( TInt i = 0; i < iNumOfCols; i++ ) |
|
828 { |
|
829 cell_pane = RectFromLayout( grid_pane, AknLayoutScalable_Apps::cell_afind_pane( iLayoutOption, i, j ) ); |
|
830 iButtonArray[temp]->SetRect( cell_pane ); |
|
831 temp++; |
|
832 } |
|
833 } |
|
834 TInt variety = 1; |
|
835 if( iNumOfPages > 1 ) |
|
836 variety = 0; |
|
837 |
|
838 iButtonIconSize = RectFromLayout( cell_pane, AknLayoutScalable_Apps::cell_afind_pane_g1( variety, 0, 0 ) ).Size(); |
|
839 } |
|
840 |
|
841 |
|
842 // ----------------------------------------------------------------------------- |
|
843 // CAknAdaptiveSearchGrid::ControlsPositions |
|
844 // Calculates position of the adaptive search gridcontrols. |
|
845 // ----------------------------------------------------------------------------- |
|
846 // |
|
847 void CAknAdaptiveSearchGrid::ControlsPositions() |
|
848 { |
|
849 TRect cell_pane; |
|
850 |
|
851 TRect grid_pane = RectFromLayout( Rect(), AknLayoutScalable_Apps::grid_afind_pane( iLayoutOption ) ); |
|
852 TRect find_pane; |
|
853 |
|
854 if(iPopupFindpane) |
|
855 { |
|
856 find_pane = RectFromLayout( Rect(), AknLayoutScalable_Avkon::popup_find_window() ); |
|
857 } |
|
858 else |
|
859 { |
|
860 find_pane = RectFromLayout( Rect(), AknLayoutScalable_Apps::find_pane_cp01( iLayoutOption ) ); |
|
861 } |
|
862 _AKNTRACE( "[%s][%s] rect of find pane is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, |
|
863 find_pane.iTl.iX, find_pane.iTl.iY, find_pane.iBr.iX, find_pane.iBr.iY ); |
|
864 iInputFrame->SetRect( find_pane ); |
|
865 iSkinContextOfFindPane->SetRect( find_pane ); |
|
866 |
|
867 // Backspace and close buttons |
|
868 cell_pane = RectFromLayout( grid_pane, AknLayoutScalable_Apps::cell_afind_pane(iLayoutOption, iNumOfCols-2, iNumOfRows-1) ); |
|
869 |
|
870 // For ELJG-7VC8Q2, move delete button up |
|
871 if(iPopupFindpane && ( iLayoutOption == KPortraitSinglePage ||iLayoutOption == KLandscapeSinglePage)) |
|
872 { |
|
873 cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*iNumOfRows; |
|
874 cell_pane.iTl.iY = cell_pane.iTl.iY - iOverlapLength*(iNumOfRows-1); |
|
875 } |
|
876 _AKNTRACE( "[%s][%s] rect of delete button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, |
|
877 cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY ); |
|
878 iDeleteButton->SetRect( cell_pane ); |
|
879 cell_pane = RectFromLayout( grid_pane, AknLayoutScalable_Apps::cell_afind_pane(iLayoutOption, iNumOfCols-1, iNumOfRows-1) ); |
|
880 |
|
881 // For ELJG-7VC8Q2, move close button up |
|
882 if(iPopupFindpane && ( iLayoutOption == KPortraitSinglePage ||iLayoutOption == KLandscapeSinglePage)) |
|
883 { |
|
884 cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*iNumOfRows; |
|
885 cell_pane.iTl.iY = cell_pane.iTl.iY - iOverlapLength*(iNumOfRows-1); |
|
886 } |
|
887 |
|
888 _AKNTRACE( "[%s][%s] rect of close button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, |
|
889 cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY ); |
|
890 iCloseButton->SetRect( cell_pane ); |
|
891 |
|
892 // For ELJG-7VC8Q2, Move all the buttons up when there is only one page |
|
893 if(iPopupFindpane) |
|
894 { |
|
895 TInt temp = 0; |
|
896 for ( TInt j = 0; j < iNumOfRows; j++ ) |
|
897 { |
|
898 for ( TInt i = 0; i < iNumOfCols; i++ ) |
|
899 { |
|
900 cell_pane = RectFromLayout( grid_pane, AknLayoutScalable_Apps::cell_afind_pane( iLayoutOption, i, j ) ); |
|
901 if(iLayoutOption == KPortraitSinglePage ||iLayoutOption == KLandscapeSinglePage ) |
|
902 { |
|
903 cell_pane.iTl.iY -=iOverlapLength*j; |
|
904 cell_pane.iBr.iY -=iOverlapLength*(j+1); |
|
905 } |
|
906 iButtonArray[temp]->SetRect( cell_pane ); |
|
907 temp++; |
|
908 } |
|
909 } |
|
910 } |
|
911 |
|
912 |
|
913 if ( Layout_Meta_Data::IsLandscapeOrientation() && AknLayoutUtils::LayoutMirrored() ) |
|
914 { |
|
915 SetCornerAndSize( EHLeftVTop, Rect().Size()); |
|
916 } |
|
917 |
|
918 if( iNumOfPages > 1 ) |
|
919 { |
|
920 if( iLayoutOption == KLandscapeMultiPage ) |
|
921 { |
|
922 TRect cont_pane = RectFromLayout( Rect(), AknLayoutScalable_Apps::grid_afind_control_pane(iLayoutOption) ); |
|
923 cell_pane = RectFromLayout( cont_pane, AknLayoutScalable_Apps::cell_afind_grid_control_pane(0,0) ); |
|
924 |
|
925 // For ELJG-7VC8Q2, Move delete button up |
|
926 if(iPopupFindpane) |
|
927 { |
|
928 cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*(iNumOfRows+1); |
|
929 } |
|
930 |
|
931 _AKNTRACE( "[%s][%s] rect of delete button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, |
|
932 cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY ); |
|
933 iDeleteButton->SetRect( cell_pane ); |
|
934 cell_pane = RectFromLayout( cont_pane, AknLayoutScalable_Apps::cell_afind_grid_control_pane(0,1) ); |
|
935 |
|
936 // For ELJG-7VC8Q2, Move close button up |
|
937 if(iPopupFindpane) |
|
938 { |
|
939 cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*(iNumOfRows+1); |
|
940 } |
|
941 |
|
942 _AKNTRACE( "[%s][%s] rect of close button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, |
|
943 cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY ); |
|
944 iCloseButton->SetRect( cell_pane ); |
|
945 } |
|
946 // Page pane |
|
947 TRect page_pane; |
|
948 page_pane = RectFromLayout( Rect(), AknLayoutScalable_Apps::afind_page_pane( iLayoutOption) ); |
|
949 _AKNTRACE( "[%s][%s] rect of page pane is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, |
|
950 page_pane.iTl.iX, page_pane.iTl.iY, page_pane.iBr.iX, page_pane.iBr.iY ); |
|
951 AknLayoutUtils::LayoutLabel( iPageIndicator, Rect(), |
|
952 TAknWindowComponentLayout::ComposeText( AknLayoutScalable_Apps::afind_page_pane( iLayoutOption ), |
|
953 AknLayoutScalable_Apps::afind_page_pane_t1() ).LayoutLine() ); |
|
954 |
|
955 // Next and previous buttons |
|
956 if ( !AknLayoutUtils::LayoutMirrored() ) |
|
957 { |
|
958 cell_pane = RectFromLayout( page_pane, AknLayoutScalable_Apps::afind_page_pane_g2( iLayoutOption) ); |
|
959 |
|
960 // For ELJG-7VC8Q2, Move prev button up |
|
961 if(iPopupFindpane) |
|
962 { |
|
963 cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*(iNumOfRows+1); |
|
964 } |
|
965 _AKNTRACE( "[%s][%s] rect of pre page button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, |
|
966 cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY ); |
|
967 iPrevButton->SetRect( cell_pane ); |
|
968 cell_pane = RectFromLayout( page_pane, AknLayoutScalable_Apps::afind_page_pane_g3( iLayoutOption) ); |
|
969 |
|
970 // For ELJG-7VC8Q2, Move next button up |
|
971 if(iPopupFindpane) |
|
972 { |
|
973 cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*(iNumOfRows+1); |
|
974 } |
|
975 _AKNTRACE( "[%s][%s] rect of next page button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, |
|
976 cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY ); |
|
977 iNextButton->SetRect( cell_pane ); |
|
978 } |
|
979 else |
|
980 { |
|
981 cell_pane = RectFromLayout( page_pane, AknLayoutScalable_Apps::afind_page_pane_g2( iLayoutOption) ); |
|
982 |
|
983 // For ELJG-7VC8Q2, Move next button up |
|
984 if(iPopupFindpane) |
|
985 { |
|
986 cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*(iNumOfRows+1); |
|
987 } |
|
988 _AKNTRACE( "[%s][%s] rect of next page button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, |
|
989 cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY ); |
|
990 iNextButton->SetRect( cell_pane ); |
|
991 cell_pane = RectFromLayout( page_pane, AknLayoutScalable_Apps::afind_page_pane_g3( iLayoutOption) ); |
|
992 |
|
993 // For ELJG-7VC8Q2, Move pre button up |
|
994 if(iPopupFindpane) |
|
995 { |
|
996 cell_pane.iBr.iY = cell_pane.iBr.iY - iOverlapLength*(iNumOfRows+1); |
|
997 } |
|
998 |
|
999 _AKNTRACE( "[%s][%s] rect of pre page button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, |
|
1000 cell_pane.iTl.iX, cell_pane.iTl.iY, cell_pane.iBr.iX, cell_pane.iBr.iY ); |
|
1001 iPrevButton->SetRect( cell_pane ); |
|
1002 } |
|
1003 |
|
1004 if( AknsUtils::AvkonSkinEnabled() ) |
|
1005 { |
|
1006 TRgb textColor = KRgbWhite; |
|
1007 TInt error = AknsUtils::GetCachedColor( AknsUtils::SkinInstance(), |
|
1008 textColor, |
|
1009 KAknsIIDQsnTextColors, |
|
1010 EAknsCIQsnTextColorsCG19); |
|
1011 if( !error ) |
|
1012 { |
|
1013 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL(*iPageIndicator, EColorLabelText, textColor) ); |
|
1014 } |
|
1015 } |
|
1016 iBgContextOfControlPane->SetRect( page_pane ); |
|
1017 } |
|
1018 } |
|
1019 |
|
1020 // ----------------------------------------------------------------------------- |
|
1021 // CAknAdaptiveSearchGrid::NextPage() |
|
1022 // Show next page of adaptive search grid and activate it. |
|
1023 // ----------------------------------------------------------------------------- |
|
1024 // |
|
1025 void CAknAdaptiveSearchGrid::NextPage() |
|
1026 { |
|
1027 if( iNumOfPages == 1 ) |
|
1028 { |
|
1029 return; |
|
1030 } |
|
1031 else |
|
1032 { |
|
1033 if( iCurrentPage == iNumOfPages ) |
|
1034 { |
|
1035 iCurrentPage = 1; |
|
1036 } |
|
1037 else |
|
1038 { |
|
1039 iCurrentPage++; |
|
1040 } |
|
1041 _AKNTRACE( "[%s][%s] current page is : %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, iCurrentPage ); |
|
1042 TRAP_IGNORE( UpdateVisibleButtonsL() ); |
|
1043 TRAP_IGNORE( UpdatePageIndicatorL() ); |
|
1044 DrawNow(); |
|
1045 } |
|
1046 } |
|
1047 |
|
1048 // ----------------------------------------------------------------------------- |
|
1049 // CAknAdaptiveSearchGrid::PrevPage() |
|
1050 // Show previous page of adaptive search grid and activates it. |
|
1051 // ----------------------------------------------------------------------------- |
|
1052 // |
|
1053 void CAknAdaptiveSearchGrid::PrevPage() |
|
1054 { |
|
1055 if(iNumOfPages == 1) |
|
1056 { |
|
1057 return; |
|
1058 } |
|
1059 else |
|
1060 { |
|
1061 if( iCurrentPage == 1 ) |
|
1062 { |
|
1063 iCurrentPage = iNumOfPages; |
|
1064 } |
|
1065 else |
|
1066 { |
|
1067 iCurrentPage--; |
|
1068 } |
|
1069 _AKNTRACE( "[%s][%s] current page is : %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, iCurrentPage ); |
|
1070 TRAP_IGNORE( UpdateVisibleButtonsL() ); |
|
1071 TRAP_IGNORE( UpdatePageIndicatorL() ); |
|
1072 DrawNow(); |
|
1073 } |
|
1074 } |
|
1075 |
|
1076 |
|
1077 // ----------------------------------------------------------------------------- |
|
1078 // CAknAdaptiveSearchGrid::UpdatePageIndicatorL() |
|
1079 // ----------------------------------------------------------------------------- |
|
1080 // |
|
1081 void CAknAdaptiveSearchGrid::UpdatePageIndicatorL() |
|
1082 { |
|
1083 // Create text buffer for page indicator |
|
1084 // 10 is a length of page indicator |
|
1085 HBufC* textPageIndicator = HBufC::NewL( 10 ); |
|
1086 HBufC* temp_text = NULL; |
|
1087 TRAPD( err, temp_text = HBufC::NewL(10) ); |
|
1088 if( err ) |
|
1089 { |
|
1090 TRAP_IGNORE( iPageIndicator->SetTextL( KSlashOfPageIndicator ) ); |
|
1091 return; |
|
1092 } |
|
1093 TPtr ptr_temp_text = temp_text->Des(); |
|
1094 TPtr ptr_page_number = textPageIndicator->Des(); |
|
1095 |
|
1096 NumberConversion::FormatNumber( ptr_page_number, iCurrentPage, AknTextUtils::NumericEditorDigitType() ); |
|
1097 ptr_page_number.Append( KSlashOfPageIndicator ); |
|
1098 NumberConversion::FormatNumber( ptr_temp_text, iNumOfPages, AknTextUtils::NumericEditorDigitType() ); |
|
1099 ptr_page_number.Append( ptr_temp_text ); |
|
1100 |
|
1101 TRAP_IGNORE( iPageIndicator->SetTextL( ptr_page_number ) ); |
|
1102 delete temp_text; |
|
1103 if ( textPageIndicator ) |
|
1104 { |
|
1105 delete textPageIndicator; |
|
1106 textPageIndicator = NULL; |
|
1107 } |
|
1108 } |
|
1109 |
|
1110 // ----------------------------------------------------------------------------- |
|
1111 // CAknAdaptiveSearchGrid::ShowControls() |
|
1112 // Show and hide controls of adaptive search grid. |
|
1113 // ----------------------------------------------------------------------------- |
|
1114 // |
|
1115 void CAknAdaptiveSearchGrid::ShowControls() |
|
1116 { |
|
1117 if( iNumOfPages == 1 ) |
|
1118 { |
|
1119 iNextButton->MakeVisible( EFalse ); |
|
1120 iPrevButton->MakeVisible( EFalse ); |
|
1121 iPageIndicator->MakeVisible( EFalse ); |
|
1122 } |
|
1123 else |
|
1124 { |
|
1125 iNextButton->MakeVisible( ETrue ); |
|
1126 iPrevButton->MakeVisible( ETrue ); |
|
1127 iPageIndicator->MakeVisible( ETrue ); |
|
1128 } |
|
1129 iCloseButton->MakeVisible( ETrue ); |
|
1130 iDeleteButton->MakeVisible( ETrue ); |
|
1131 iInputFrame->MakeVisible( ETrue ); |
|
1132 iEditor->MakeVisible( ETrue ); |
|
1133 } |
|
1134 |
|
1135 // ----------------------------------------------------------------------------- |
|
1136 // CAknAdaptiveSearchGrid::AdaptiveSearchGridShowL() |
|
1137 // Makes adaptive search grid visible and activates it. |
|
1138 // ----------------------------------------------------------------------------- |
|
1139 // |
|
1140 void CAknAdaptiveSearchGrid::ShowL() |
|
1141 { |
|
1142 _AKNTRACE_FUNC_ENTER; |
|
1143 if( (iButtonArray.Count() == 0) || (iNumOfPages < 1 ) ) |
|
1144 { |
|
1145 SetShown( EFalse ); |
|
1146 return; |
|
1147 } |
|
1148 |
|
1149 DrawableWindow()->SetOrdinalPosition( 0, ECoeWinPriorityNormal ); |
|
1150 CEikonEnv::Static()->EikAppUi()->AddToStackL( this ); |
|
1151 |
|
1152 if( Window().IsFaded() ) |
|
1153 { |
|
1154 Window().SetNonFading( ETrue ); |
|
1155 } |
|
1156 |
|
1157 CAknToolbar* toolbar = iAppUi->CurrentFixedToolbar(); |
|
1158 TBool needRelayout = EFalse; |
|
1159 if( Layout_Meta_Data::IsLandscapeOrientation()) |
|
1160 { |
|
1161 if ( iLayoutOption == KPortraitMultiPage |
|
1162 || iLayoutOption == KPortraitSinglePage |
|
1163 || iFindPaneSizeChanged ) |
|
1164 { |
|
1165 needRelayout = ETrue; |
|
1166 iFindPaneSizeChanged = EFalse; |
|
1167 } |
|
1168 } |
|
1169 else if ( iLayoutOption == KLandscapeMultiPage || iLayoutOption == KLandscapeSinglePage ) |
|
1170 { |
|
1171 needRelayout = ETrue; |
|
1172 } |
|
1173 else if ( toolbar && toolbar->IsShown() && iToolbarShown == EFalse ) |
|
1174 { |
|
1175 needRelayout = ETrue; |
|
1176 } |
|
1177 |
|
1178 if( iLayoutChanged ) |
|
1179 { |
|
1180 needRelayout = ETrue; |
|
1181 iLayoutChanged = EFalse; |
|
1182 } |
|
1183 |
|
1184 if ( needRelayout ) |
|
1185 { |
|
1186 InitGrid(); |
|
1187 UpdatePageAndRowCount(); |
|
1188 } |
|
1189 |
|
1190 |
|
1191 CAknWsEventMonitor* eventMonitor = iAppUi->EventMonitor(); |
|
1192 if ( !eventMonitor->IsEnabled() ) |
|
1193 { |
|
1194 eventMonitor->AddObserverL( this ); |
|
1195 eventMonitor->Enable(); |
|
1196 } |
|
1197 |
|
1198 ControlsPositions(); |
|
1199 UpdateVisibleButtonsL(); |
|
1200 ShowControls(); |
|
1201 |
|
1202 // Make grid visible |
|
1203 SetShown( ETrue ); |
|
1204 |
|
1205 // Notify observer, that adaptive search grid was shown |
|
1206 if ( Observer() ) |
|
1207 { |
|
1208 Observer()->HandleControlEventL( this, MCoeControlObserver::EEventStateChanged ); |
|
1209 } |
|
1210 |
|
1211 ActivateL(); |
|
1212 DrawNow(); |
|
1213 _AKNTRACE_FUNC_EXIT; |
|
1214 } |
|
1215 |
|
1216 // ----------------------------------------------------------------------------- |
|
1217 // CAknAdaptiveSearchGrid::SetShown |
|
1218 // Sets the flag on or off. |
|
1219 // ----------------------------------------------------------------------------- |
|
1220 // |
|
1221 void CAknAdaptiveSearchGrid::SetShown( const TBool aShown ) |
|
1222 { |
|
1223 iShown = aShown; |
|
1224 _AKNTRACE( "[%s][%s] set show : %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, aShown ); |
|
1225 CCoeControl::MakeVisible( aShown ); |
|
1226 } |
|
1227 |
|
1228 // ----------------------------------------------------------------------------- |
|
1229 // CAknAdaptiveSearchGrid::HideAdaptiveSearchGrid() |
|
1230 // Disactivate adaptive search grid and hides it. |
|
1231 // ----------------------------------------------------------------------------- |
|
1232 // |
|
1233 void CAknAdaptiveSearchGrid::HideL() |
|
1234 { |
|
1235 _AKNTRACE_FUNC_ENTER; |
|
1236 if ( !iShown ) // nothing to hide |
|
1237 { |
|
1238 return; |
|
1239 } |
|
1240 |
|
1241 iEditor->TextView()->SetCursorVisibilityL( |
|
1242 TCursor::EFCursorInvisible, TCursor::EFCursorInvisible); |
|
1243 |
|
1244 SetFocus( EFalse ); |
|
1245 //fix for TSW error EKDN-7KW9P2 |
|
1246 SetShown( EFalse ); |
|
1247 |
|
1248 if( iAdaptiveSearchGridObserver ) |
|
1249 { |
|
1250 iAdaptiveSearchGridObserver->ProcessCommandL( CAknAdaptiveSearchGrid::ECloseGridPressed ); |
|
1251 } |
|
1252 CEikonEnv::Static()->EikAppUi()->RemoveFromStack(this); |
|
1253 DrawableWindow()->SetOrdinalPosition( 0, ECoeWinPriorityNeverAtFront ); |
|
1254 _AKNTRACE_FUNC_EXIT; |
|
1255 } |
|
1256 |
|
1257 // ----------------------------------------------------------------------------- |
|
1258 // CAknAdaptiveSearchGrid::FocusChanged |
|
1259 // This function is called whenever a control gains or loses focus. |
|
1260 // ----------------------------------------------------------------------------- |
|
1261 // |
|
1262 void CAknAdaptiveSearchGrid::FocusChanged( TDrawNow aDrawNow ) |
|
1263 { |
|
1264 if ( !iShown || IsNonFocusing() ) |
|
1265 { |
|
1266 return; // nothing should be done in this case |
|
1267 } |
|
1268 if ( !IsFocused() && iLastFocusedButton ) |
|
1269 iLastFocusedButton->ResetState(); |
|
1270 |
|
1271 iInputFrame->SetFocus( IsFocused(), aDrawNow ); |
|
1272 } |
|
1273 |
|
1274 |
|
1275 // ----------------------------------------------------------------------------- |
|
1276 // CAknAdaptiveSearchGrid::HandleWsEventL |
|
1277 // Handles window server events. |
|
1278 // ----------------------------------------------------------------------------- |
|
1279 // |
|
1280 void CAknAdaptiveSearchGrid::HandleWsEventL( const TWsEvent& aEvent, CCoeControl* aDestination ) |
|
1281 { |
|
1282 _AKNTRACE( "[%s][%s] Ws Event Type : %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, aEvent.Type() ); |
|
1283 if ( !iShown ) |
|
1284 { |
|
1285 return; // nothing should be done in this case |
|
1286 } |
|
1287 |
|
1288 if ( aEvent.Type() == EEventKeyDown && aEvent.Key()->iScanCode != EStdKeyApplication10 ) |
|
1289 { |
|
1290 HideL(); |
|
1291 return; |
|
1292 } |
|
1293 |
|
1294 if( aEvent.Type() == EEventPointer ) |
|
1295 { |
|
1296 TPointerEvent& pointerEvent = *aEvent.Pointer(); |
|
1297 |
|
1298 if( pointerEvent.iType == TPointerEvent::EButton1Down ) |
|
1299 { |
|
1300 if( iInputFrame->Rect().Contains(pointerEvent.iPosition) || |
|
1301 aDestination != this ) |
|
1302 { |
|
1303 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
1304 |
|
1305 // according to Touch UI spec tapping on input frame should cause feedback, |
|
1306 // even if action is to cancel dialog.. |
|
1307 if ( feedback ) |
|
1308 { |
|
1309 feedback->InstantFeedback( this, ETouchFeedbackBasic ); |
|
1310 } |
|
1311 |
|
1312 HideL(); |
|
1313 return; |
|
1314 } |
|
1315 } |
|
1316 } |
|
1317 } |
|
1318 |
|
1319 |
|
1320 // ----------------------------------------------------------------------------- |
|
1321 // CAknAdaptiveSearchGrid::HandleControlEventL |
|
1322 // Handles an event from an observed adaptive search grid item. |
|
1323 // ----------------------------------------------------------------------------- |
|
1324 // |
|
1325 void CAknAdaptiveSearchGrid::HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType ) |
|
1326 { |
|
1327 _AKNTRACE_FUNC_ENTER; |
|
1328 _AKNTRACE( "[%s][%s] Control Event Type : %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, aEventType ); |
|
1329 switch ( aEventType ) |
|
1330 { |
|
1331 case MCoeControlObserver::EEventRequestExit: |
|
1332 { |
|
1333 HideL(); |
|
1334 break; |
|
1335 } |
|
1336 case EEventRequestFocus: |
|
1337 FocusChanged( EDrawNow ); |
|
1338 break; |
|
1339 case MCoeControlObserver::EEventStateChanged: |
|
1340 { |
|
1341 if( iNumOfPages > 1 && aControl == iPrevButton) |
|
1342 { |
|
1343 iLastFocusedButton = iPrevButton; |
|
1344 PrevPage(); |
|
1345 break; |
|
1346 } |
|
1347 if( iNumOfPages > 1 && aControl == iNextButton ) |
|
1348 { |
|
1349 iLastFocusedButton = iNextButton; |
|
1350 NextPage(); |
|
1351 break; |
|
1352 } |
|
1353 if( aControl == iCloseButton ) |
|
1354 { |
|
1355 iLastFocusedButton = iCloseButton; |
|
1356 HideL(); |
|
1357 if(iAdaptiveSearchGridObserver) |
|
1358 iAdaptiveSearchGridObserver->ProcessCommandL( CAknAdaptiveSearchGrid::ECloseGridPressed); |
|
1359 |
|
1360 break; |
|
1361 } |
|
1362 if( aControl == iDeleteButton ) |
|
1363 { |
|
1364 iLastFocusedButton = iDeleteButton; |
|
1365 if( iAdaptiveSearchGridObserver ) |
|
1366 iAdaptiveSearchGridObserver->ProcessCommandL( CAknAdaptiveSearchGrid::EDeleteLastCharPressed ); |
|
1367 break; |
|
1368 } |
|
1369 if( iAdaptiveSearchGridObserver ) |
|
1370 { |
|
1371 // index of pressed button = index of pressed char |
|
1372 TInt button_index = iButtonArray.Find( static_cast<CAknButton*>( aControl) ); |
|
1373 if( button_index != KErrNotFound ) |
|
1374 { |
|
1375 CAknButton* button = static_cast<CAknButton*>(iButtonArray[button_index]); |
|
1376 iLastFocusedButton = button; |
|
1377 CAknButtonState* bState = button->State(); |
|
1378 TInt char_position = iGridChars->Find( bState->Text() ); |
|
1379 if( iAdaptiveSearchGridObserver ) |
|
1380 iAdaptiveSearchGridObserver->ProcessCommandL( char_position ); |
|
1381 } |
|
1382 } |
|
1383 break; |
|
1384 } |
|
1385 default: |
|
1386 { |
|
1387 break; |
|
1388 } |
|
1389 } |
|
1390 _AKNTRACE_FUNC_EXIT; |
|
1391 } |
|
1392 |
|
1393 // ----------------------------------------------------------------------------- |
|
1394 // CAknAdaptiveSearchGrid::UpdateVisibleButtonsL() |
|
1395 // ----------------------------------------------------------------------------- |
|
1396 // |
|
1397 void CAknAdaptiveSearchGrid::UpdateVisibleButtonsL() |
|
1398 { |
|
1399 _AKNTRACE_FUNC_ENTER; |
|
1400 if ( iGridChars ) |
|
1401 { |
|
1402 // Clear current region of AS |
|
1403 iCurrentRegion.Clear(); |
|
1404 |
|
1405 TPtr ptr = iGridChars->Des(); |
|
1406 TInt numOfChars = ptr.Length(); |
|
1407 CAknButton* button = NULL; |
|
1408 CAknButtonState* bState = NULL; |
|
1409 TRect button_rect; |
|
1410 CGulIcon* icon = NULL; |
|
1411 TBool IsIndic = EFalse; |
|
1412 TInt shift_Ind = 0; |
|
1413 |
|
1414 // If Devanagari ( halant character is present ) |
|
1415 if ( KErrNotFound != ptr.Locate(0x094D) ) |
|
1416 { |
|
1417 IsIndic = ETrue; |
|
1418 } |
|
1419 |
|
1420 // Hide all the buttons at the beginning for now. |
|
1421 CAknButton* tmpButton = NULL; |
|
1422 for( TInt i = 0; i < iButtonArray.Count(); i++ ) |
|
1423 { |
|
1424 tmpButton = static_cast<CAknButton*>( iButtonArray[i] ); |
|
1425 tmpButton->MakeVisible( EFalse ); |
|
1426 } |
|
1427 |
|
1428 TInt tempTotalGridButtons = iTotalGridButtons - KCloseAndClearButtonCount; |
|
1429 if( iNumOfPages == 1 ) |
|
1430 { |
|
1431 for ( TInt i = 0; i < tempTotalGridButtons; i++ ) |
|
1432 { |
|
1433 button = static_cast<CAknButton*>( iButtonArray[tempTotalGridButtons-i-1] ); |
|
1434 TInt charPosition = numOfChars-i-1-shift_Ind; |
|
1435 if ( charPosition >= 0 ) |
|
1436 { |
|
1437 bState = button->State(); |
|
1438 if ( ptr.Mid(charPosition, 1) == KSpaceCharacter ) |
|
1439 { |
|
1440 // Create icon for space button |
|
1441 icon = GetColorIconL( 4 ); |
|
1442 AknIconUtils::SetSize( icon->Bitmap(), iButtonIconSize ); |
|
1443 |
|
1444 bState->SetTextL( KNullDesC ); |
|
1445 bState->SetIcon( icon ); |
|
1446 button->SetIconSize( iButtonIconSize ); |
|
1447 } |
|
1448 else |
|
1449 { |
|
1450 if( bState->Icon() ) |
|
1451 { |
|
1452 bState->SetIcon( NULL ); |
|
1453 } |
|
1454 // If Devanagari |
|
1455 if ( IsIndic && charPosition >= 2 |
|
1456 && ptr[charPosition-1] == 0x094D ) |
|
1457 { |
|
1458 bState->SetTextL( ptr.Mid(charPosition-2, 3) ); |
|
1459 shift_Ind+=2; |
|
1460 } |
|
1461 else |
|
1462 { |
|
1463 bState->SetTextL( ptr.Mid(charPosition, 1) ); |
|
1464 } |
|
1465 } |
|
1466 button_rect = button->Rect(); |
|
1467 _AKNTRACE( "[%s][%s] rect of button %s is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, bState->Text().Ptr(), |
|
1468 button_rect.iTl.iX, button_rect.iTl.iY, button_rect.iBr.iX, button_rect.iBr.iY ); |
|
1469 iCurrentRegion.AddRect( button_rect ); |
|
1470 button->MakeVisible( ETrue ); |
|
1471 } |
|
1472 else |
|
1473 { |
|
1474 button->MakeVisible( EFalse ); |
|
1475 } |
|
1476 } |
|
1477 } |
|
1478 else |
|
1479 { |
|
1480 if( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
1481 { |
|
1482 tempTotalGridButtons = iTotalGridButtons - iNumOfCols; |
|
1483 } |
|
1484 UpdatePageIndicatorL(); |
|
1485 TInt numOfCharsInPrevPages = (iCurrentPage-1)*(tempTotalGridButtons); |
|
1486 shift_Ind = 0; |
|
1487 if ( IsIndic ) |
|
1488 { |
|
1489 for (TInt tempItr = 0; tempItr < numOfCharsInPrevPages; ++tempItr) |
|
1490 { |
|
1491 if ( numOfChars-tempItr >= 3 && 0x094D == ptr[tempItr+1] ) |
|
1492 { |
|
1493 numOfCharsInPrevPages+=2; |
|
1494 tempItr+=2; |
|
1495 } |
|
1496 } |
|
1497 } |
|
1498 |
|
1499 if( iCurrentPage == iNumOfPages ) |
|
1500 { |
|
1501 // last page |
|
1502 TInt charsOnLastPage = numOfChars - numOfCharsInPrevPages; |
|
1503 TInt offset = tempTotalGridButtons - charsOnLastPage; |
|
1504 |
|
1505 for ( TInt i = tempTotalGridButtons-1 ; i >= 0 ; --i ) |
|
1506 { |
|
1507 button = static_cast<CAknButton*>(iButtonArray[i+shift_Ind]); |
|
1508 if( i < offset ) |
|
1509 { |
|
1510 button->MakeVisible( EFalse ); |
|
1511 } |
|
1512 else |
|
1513 { |
|
1514 bState = button->State(); |
|
1515 TInt CharPosition = numOfCharsInPrevPages + i - offset; |
|
1516 if( ptr.Mid(CharPosition, 1) == KSpaceCharacter ) |
|
1517 { |
|
1518 // Create icon for space button |
|
1519 icon = GetColorIconL( 4 ); |
|
1520 AknIconUtils::SetSize( icon->Bitmap(), iButtonIconSize ); |
|
1521 |
|
1522 bState->SetTextL( KNullDesC ); |
|
1523 bState->SetIcon( icon ); |
|
1524 button->SetIconSize( iButtonIconSize ); |
|
1525 } |
|
1526 else |
|
1527 { |
|
1528 if( bState->Icon() ) |
|
1529 { |
|
1530 bState->SetIcon( NULL ); |
|
1531 } |
|
1532 // If Devanagari |
|
1533 if ( IsIndic && CharPosition >= 2 |
|
1534 && (ptr[CharPosition-1] == 0x094D) ) |
|
1535 { |
|
1536 bState->SetTextL( ptr.Mid(CharPosition-2, 3) ); |
|
1537 //i-=2; |
|
1538 //shift_Ind+=2; |
|
1539 offset+=2; |
|
1540 } |
|
1541 else |
|
1542 { |
|
1543 bState->SetTextL( ptr.Mid(CharPosition, 1)); |
|
1544 } |
|
1545 } |
|
1546 button_rect = button->Rect(); |
|
1547 _AKNTRACE( "[%s][%s] rect of button %s is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, bState->Text().Ptr(), |
|
1548 button_rect.iTl.iX, button_rect.iTl.iY, button_rect.iBr.iX, button_rect.iBr.iY ); |
|
1549 iCurrentRegion.AddRect( button_rect ); |
|
1550 button->MakeVisible( ETrue ); |
|
1551 } |
|
1552 } |
|
1553 } |
|
1554 else |
|
1555 { |
|
1556 TInt start = numOfCharsInPrevPages; |
|
1557 TInt end = start + tempTotalGridButtons; |
|
1558 //reset shift_Ind |
|
1559 shift_Ind = 0; |
|
1560 |
|
1561 for ( TInt i = 0; i < numOfChars; i++ ) |
|
1562 { |
|
1563 if ( ( i >= start) && (i < end) ) |
|
1564 { |
|
1565 button = static_cast<CAknButton*>(iButtonArray[i-start-shift_Ind]); |
|
1566 bState = button->State(); |
|
1567 if( ptr.Mid(i, 1) == KSpaceCharacter ) |
|
1568 { |
|
1569 // Create icon for space button |
|
1570 icon = GetColorIconL( 4 ); |
|
1571 AknIconUtils::SetSize( icon->Bitmap(), iButtonIconSize ); |
|
1572 |
|
1573 bState->SetTextL( KNullDesC ); |
|
1574 bState->SetIcon( icon ); |
|
1575 button->SetIconSize( iButtonIconSize ); |
|
1576 } |
|
1577 else |
|
1578 { |
|
1579 if( bState->Icon() ) |
|
1580 { |
|
1581 bState->SetIcon( NULL ); |
|
1582 } |
|
1583 //If Devanagari |
|
1584 if ( IsIndic && (numOfChars-i)>=3 |
|
1585 && (ptr[i+1] == 0x094D) ) |
|
1586 { |
|
1587 bState->SetTextL( ptr.Mid(i, 3) ); |
|
1588 shift_Ind+=2; |
|
1589 i+=2; |
|
1590 if ( numOfChars - end > 2 ) |
|
1591 { |
|
1592 end+=2; |
|
1593 } |
|
1594 else |
|
1595 { |
|
1596 end = numOfChars; |
|
1597 } |
|
1598 } |
|
1599 else |
|
1600 { |
|
1601 bState->SetTextL( ptr.Mid(i, 1) ); |
|
1602 } |
|
1603 } |
|
1604 button_rect = button->Rect(); |
|
1605 _AKNTRACE( "[%s][%s] rect of button %s is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, bState->Text().Ptr(), |
|
1606 button_rect.iTl.iX, button_rect.iTl.iY, button_rect.iBr.iX, button_rect.iBr.iY ); |
|
1607 iCurrentRegion.AddRect( button_rect ); |
|
1608 button->MakeVisible( ETrue ); |
|
1609 |
|
1610 } |
|
1611 } |
|
1612 if( !Layout_Meta_Data::IsLandscapeOrientation() ) |
|
1613 { |
|
1614 tempTotalGridButtons = iTotalGridButtons; |
|
1615 } |
|
1616 for ( TInt i = tempTotalGridButtons; i < tempTotalGridButtons+iNumOfCols; i++ ) |
|
1617 { |
|
1618 button = static_cast<CAknButton*>(iButtonArray[i]); |
|
1619 button->MakeVisible( EFalse ); |
|
1620 } |
|
1621 } |
|
1622 } |
|
1623 button_rect = iDeleteButton->Rect(); |
|
1624 _AKNTRACE( "[%s][%s] rect of delete button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, |
|
1625 button_rect.iTl.iX, button_rect.iTl.iY, button_rect.iBr.iX, button_rect.iBr.iY ); |
|
1626 iCurrentRegion.AddRect( button_rect ); |
|
1627 button_rect = iCloseButton->Rect(); |
|
1628 _AKNTRACE( "[%s][%s] rect of close button is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, |
|
1629 button_rect.iTl.iX, button_rect.iTl.iY, button_rect.iBr.iX, button_rect.iBr.iY ); |
|
1630 iCurrentRegion.AddRect( button_rect ); |
|
1631 button_rect = iInputFrame->Rect(); |
|
1632 _AKNTRACE( "[%s][%s] rect of Input Frame is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, |
|
1633 button_rect.iTl.iX, button_rect.iTl.iY, button_rect.iBr.iX, button_rect.iBr.iY ); |
|
1634 iCurrentRegion.AddRect( button_rect ); |
|
1635 if( iNumOfPages > 1 ) |
|
1636 { |
|
1637 TRect page_pane; |
|
1638 page_pane = RectFromLayout( Rect(), AknLayoutScalable_Apps::afind_page_pane(iLayoutOption) ); |
|
1639 _AKNTRACE( "[%s][%s] rect of page pane is %d %d %d %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, |
|
1640 page_pane.iTl.iX, page_pane.iTl.iY, page_pane.iBr.iX, page_pane.iBr.iY ); |
|
1641 iCurrentRegion.AddRect( page_pane ); |
|
1642 } |
|
1643 } |
|
1644 Window().SetShape( iCurrentRegion ); |
|
1645 _AKNTRACE_FUNC_EXIT; |
|
1646 } |
|
1647 |
|
1648 // ----------------------------------------------------------------------------- |
|
1649 // CAknAdaptiveSearchGrid::UpdatePageAndRowCount |
|
1650 // ----------------------------------------------------------------------------- |
|
1651 // |
|
1652 void CAknAdaptiveSearchGrid::UpdatePageAndRowCount() |
|
1653 { |
|
1654 _AKNTRACE_FUNC_ENTER; |
|
1655 if ( iGridChars ) |
|
1656 { |
|
1657 TPtr ptr = iGridChars->Des(); |
|
1658 TInt numOfChars = ptr.Length(); |
|
1659 |
|
1660 // If Devanagari ( halant character is present ) |
|
1661 TInt numOfIndicCharsNotShown(0); |
|
1662 for ( TInt i = 0; i < numOfChars; ++i ) |
|
1663 { |
|
1664 if ( (*iGridChars)[i] == 0x094D ) |
|
1665 numOfIndicCharsNotShown+=2; |
|
1666 } |
|
1667 numOfChars -=numOfIndicCharsNotShown; |
|
1668 |
|
1669 // the row update is not needed as the layout change goes through init |
|
1670 if(( numOfChars <= iTotalGridButtons - KCloseAndClearButtonCount) || ( numOfChars == iMaxAmountOfButtons )) |
|
1671 { |
|
1672 //one page |
|
1673 iCurrentPage = 1; |
|
1674 iNumOfPages = 1; |
|
1675 |
|
1676 if( iLayoutOption == KPortraitMultiPage ) |
|
1677 { |
|
1678 iNumOfRows = iNumOfRows + 1; // one row for the page pane |
|
1679 iTotalGridButtons = iNumOfCols*iNumOfRows; // update new max number of buttons |
|
1680 } |
|
1681 |
|
1682 TInt lastLayoutOption = iLayoutOption; |
|
1683 iLayoutOption = Layout_Meta_Data::IsLandscapeOrientation() ? |
|
1684 KLandscapeSinglePage : KPortraitSinglePage; |
|
1685 if( lastLayoutOption != iLayoutOption ) |
|
1686 { |
|
1687 iLayoutChanged = ETrue; |
|
1688 } |
|
1689 } |
|
1690 else |
|
1691 { |
|
1692 if( iLayoutOption == KPortraitSinglePage ) |
|
1693 { |
|
1694 iNumOfRows = iNumOfRows - 1; // one row for the page pane |
|
1695 iTotalGridButtons = iNumOfCols*iNumOfRows; // update new max number of buttons |
|
1696 } |
|
1697 |
|
1698 TInt tempTotalGridButtons = iTotalGridButtons; |
|
1699 |
|
1700 if( !Layout_Meta_Data::IsLandscapeOrientation() ) |
|
1701 { |
|
1702 iLayoutOption = KPortraitMultiPage; |
|
1703 tempTotalGridButtons = tempTotalGridButtons - KCloseAndClearButtonCount; |
|
1704 } |
|
1705 else |
|
1706 { |
|
1707 iLayoutOption = KLandscapeMultiPage; |
|
1708 tempTotalGridButtons = tempTotalGridButtons - iNumOfCols; |
|
1709 } |
|
1710 |
|
1711 iCurrentPage = 1; |
|
1712 iNumOfPages = numOfChars/tempTotalGridButtons; |
|
1713 |
|
1714 // the last page |
|
1715 if( numOfChars > iNumOfPages*(tempTotalGridButtons) ) |
|
1716 iNumOfPages++; |
|
1717 } |
|
1718 } |
|
1719 _AKNTRACE( "[%s][%s] number of page is : %d current page is : %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, iNumOfPages, iCurrentPage ); |
|
1720 _AKNTRACE( "[%s][%s] number of row is : %d number of total grid button is : %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, iNumOfRows, iTotalGridButtons ); |
|
1721 _AKNTRACE( "[%s][%s] Adaptive search grid layout option is : %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, iLayoutOption ); |
|
1722 _AKNTRACE_FUNC_EXIT; |
|
1723 } |
|
1724 |
|
1725 // ----------------------------------------------------------------------------- |
|
1726 // CAknAdaptiveSearchGrid::HandleResourceChange |
|
1727 // Handles a change to the control's resources. |
|
1728 // ----------------------------------------------------------------------------- |
|
1729 // |
|
1730 void CAknAdaptiveSearchGrid::HandleResourceChange( TInt aType ) |
|
1731 { |
|
1732 _AKNTRACE_FUNC_ENTER; |
|
1733 _AKNTRACE( "[%s][%s] Event Type : %d ", "CAknAdaptiveSearchGrid", __FUNCTION__, aType ); |
|
1734 switch( aType ) |
|
1735 { |
|
1736 case KEikDynamicLayoutVariantSwitch: |
|
1737 { |
|
1738 UpdateLayoutVariant(); |
|
1739 break; |
|
1740 } |
|
1741 case KAknsMessageSkinChange: |
|
1742 { |
|
1743 TRAP_IGNORE( UpdateSkinL() ); |
|
1744 break; |
|
1745 } |
|
1746 default: |
|
1747 { |
|
1748 break; |
|
1749 } |
|
1750 } |
|
1751 |
|
1752 CAknControl::HandleResourceChange( aType ); |
|
1753 _AKNTRACE_FUNC_EXIT; |
|
1754 } |
|
1755 |
|
1756 // ----------------------------------------------------------------------------- |
|
1757 // CAknAdaptiveSearchGrid::IsShown |
|
1758 // Returns adaptive search grid visibility at this moment |
|
1759 // ----------------------------------------------------------------------------- |
|
1760 // |
|
1761 TBool CAknAdaptiveSearchGrid::IsShown() const |
|
1762 { |
|
1763 return iShown; |
|
1764 } |
|
1765 |
|
1766 // ----------------------------------------------------------------------------- |
|
1767 // CAknAdaptiveSearchGrid::SetAdaptiveSearchGridObserver |
|
1768 // Sets the observer for the adaptive search grid |
|
1769 // ----------------------------------------------------------------------------- |
|
1770 // |
|
1771 void CAknAdaptiveSearchGrid::SetAdaptiveSearchGridObserver( |
|
1772 MAknAdaptiveSearchGridObserver* aObserver ) |
|
1773 { |
|
1774 iAdaptiveSearchGridObserver = aObserver; |
|
1775 } |
|
1776 |
|
1777 // ----------------------------------------------------------------------------- |
|
1778 // CAknAdaptiveSearchGrid::AdaptiveSearchGridObserver |
|
1779 // Returns a pointer to the adaptive search grid observer. |
|
1780 // ----------------------------------------------------------------------------- |
|
1781 // |
|
1782 MAknAdaptiveSearchGridObserver* CAknAdaptiveSearchGrid::AdaptiveSearchGridObserver() |
|
1783 { |
|
1784 return iAdaptiveSearchGridObserver; |
|
1785 } |
|
1786 |
|
1787 |
|
1788 // ----------------------------------------------------------------------------- |
|
1789 // CCAknAdaptiveSearch::SaveFindPaneRect() |
|
1790 // When the rect of find pane is set, this functions will be notified |
|
1791 // to record the size of it. |
|
1792 // ----------------------------------------------------------------------------- |
|
1793 // |
|
1794 void CAknAdaptiveSearchGrid::SaveFindPaneRect( const TRect &aRect ) |
|
1795 { |
|
1796 //Now we just deal with the landscape conditions |
|
1797 if ( !Layout_Meta_Data::IsLandscapeOrientation() ) |
|
1798 return; |
|
1799 |
|
1800 //When width is zero, no need to deal with. |
|
1801 if ( 0 == aRect.Size().iWidth ) |
|
1802 return; |
|
1803 |
|
1804 //The same size already is set. No need to do further process. |
|
1805 if ( aRect.Size().iWidth == iFindpaneRect.Size().iWidth ) |
|
1806 return; |
|
1807 |
|
1808 iFindpaneRect = aRect; |
|
1809 iFindPaneSizeChanged = ETrue; |
|
1810 } |
|
1811 |
|
1812 // End of File |
|
1813 |