|
1 /* |
|
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <eikcapc.h> |
|
20 #include <coemain.h> |
|
21 #include <barsread.h> |
|
22 #include <eikenv.h> |
|
23 #include <eikon.hrh> |
|
24 #include <eikbctrl.h> |
|
25 #include <eiksfont.h> |
|
26 #include <gulcolor.h> |
|
27 #include <eikimage.h> |
|
28 #include <eikappui.h> |
|
29 #include <eikbtgpc.h> |
|
30 |
|
31 #include <eikedwin.h> |
|
32 #include <frmtlay.h> |
|
33 |
|
34 #include <eikdialg.pan> |
|
35 #include <AknUtils.h> // Avkon drawing utilities |
|
36 #include <aknenv.h> |
|
37 #include <AknDef.h> |
|
38 #include <aknconsts.h> |
|
39 #include <avkon.hrh> |
|
40 #include <avkon.rsg> |
|
41 #include <AknPopupFieldText.h> |
|
42 #include <aknslider.h> |
|
43 #include <eikseced.h> |
|
44 #include <eikdpage.h> |
|
45 #include <eikdialogext.h> |
|
46 #include <eikcapca.h> |
|
47 #include <eikmfne.h> |
|
48 #include <eikform.pan> |
|
49 #include <eikdpobs.h> |
|
50 #include <eikdpsel.h> |
|
51 #include <gulicon.h> |
|
52 #include <gdi.h> // for CEikCapCLabel |
|
53 #include <biditext.h> // for TDirectionality |
|
54 #include <AknBidiTextUtils.h> |
|
55 #include <AknIconUtils.h> |
|
56 #include <AknPanic.h> |
|
57 #include <touchfeedback.h> |
|
58 |
|
59 #include <AknTasHook.h> // for testability hooks |
|
60 //<SKIN> |
|
61 #include <AknsDrawUtils.h> |
|
62 #include <AknsUtils.h> |
|
63 #include <AknsListBoxBackgroundControlContext.h> |
|
64 #include <AknsFrameBackgroundControlContext.h> |
|
65 #include <skinlayout.cdl.h> |
|
66 #include <aknappui.h> |
|
67 |
|
68 #include <aknlayoutscalable_avkon.cdl.h> |
|
69 #include <aknextendedinputcapabilities.h> |
|
70 #include "EIKFANIM.H" |
|
71 |
|
72 //#define BLACKBACKGROUND // useful when debugging form layout. |
|
73 |
|
74 |
|
75 #if defined( RD_SCALABLE_UI_V2) |
|
76 //class CAknButton is available from week 20 version 5.0 onwards |
|
77 #include "aknbutton.h" |
|
78 #include <avkon.mbg> |
|
79 // For MAknMfneCommandObserver |
|
80 #include <aknmfnecommandobserver.h> |
|
81 #endif //if defined( RD_SCALABLE_UI_V2) |
|
82 |
|
83 |
|
84 |
|
85 GLREF_C void Panic(TEikDialogPanic aPanic); |
|
86 |
|
87 const TInt KViewHighlightColor = 244 ; |
|
88 // const TInt KViewHighlightShadowColor = 222 ; |
|
89 // const TInt KNormalBackgroundColor = 0 ; |
|
90 |
|
91 |
|
92 // Do not reference these directly... Use MaximumNumberOfControlLinesOnVisiblePage() |
|
93 // const TInt KMaxControlLinesOnPageSingleLineFormat =6; |
|
94 // const TInt KMaxControlLinesOnPageDoubleLineFormat =5; |
|
95 |
|
96 enum |
|
97 {// must carry on from TSpaceSharingFlags |
|
98 EUsesEars =0x10, |
|
99 ELeftEarDown =0x20, |
|
100 ERightEarDown =0x40, |
|
101 ELeftEarGrab =0x80, |
|
102 ERightEarGrab =0x100, |
|
103 ECurrent =0x200, |
|
104 ESeparatorAfter =0x400, |
|
105 EExtraAscent =0x800, |
|
106 ELatent =0x1000, |
|
107 ELglf =0x2000, |
|
108 ETakesEnterKey =0x4000, |
|
109 EOfferAllHotKeys=0x8000, |
|
110 ETrailerAfterEar=0x10000, |
|
111 ENoBorder = 0x20000 |
|
112 }; |
|
113 |
|
114 const TInt KDynamicEarMask=(ELeftEarDown|ERightEarDown|ELeftEarGrab|ERightEarGrab); |
|
115 |
|
116 const TInt KCapCDefaultHorzEdgeSpacing=0; |
|
117 const TInt KCapCDefaultVertEdgeSpacing=0; |
|
118 const TInt KCapCCenterSpacing=0; |
|
119 const TInt KControlTrailerSpacing=0; |
|
120 // const TInt KCapCEarHeightTopHalf=0; |
|
121 // const TInt KCapCEarHeightBottomHalf=0; |
|
122 // const TInt KCapCEarHeight=KCapCEarHeightTopHalf+KCapCEarHeightBottomHalf; |
|
123 const TInt KCapCEarWidth=0; |
|
124 const TInt KCapCEarSpacing=0; |
|
125 const TInt KCapCVertCaptionOffset=0; |
|
126 const TInt KCapCExtraAscent=KCapCVertCaptionOffset+0; |
|
127 const TInt KTrailCVertCaptionOffset=0; |
|
128 const TInt KCapCSeparatorAfterSpace=0; |
|
129 |
|
130 const TInt KCapCInitialEarRepeat=600000; // 6 tenths of a second |
|
131 const TInt KCapCEarRepeat=100000; // one tenth of a second |
|
132 |
|
133 /* |
|
134 * The following set of static functions return value which have been hard coded from the Series 60 Skins LAF v2.0 |
|
135 * If a layout DLL becomes available the hard-coded values may be replaced with equivalent Macros. |
|
136 * NOTE THAT THERE ARE COPIES OF SOME OF THESE FUNCTIONS IN EIKDPAGE.CPP |
|
137 */ |
|
138 |
|
139 /* |
|
140 * Note, that table numbers have changed, 5.24 is 5.26 in current (3.1) laf, |
|
141 * and 5.17 seems to be 5.16 |
|
142 * Also, these original hard coded values mostly ignore l & t fields, as |
|
143 * code only wants to know W & H, and it will break if l & t are used |
|
144 * comments indicate overriden values |
|
145 */ |
|
146 |
|
147 LOCAL_D TRect EditFrameTopLeftRect( const TRect& aParentRect ) |
|
148 {// Skins LAF table 5.24 Line 2 |
|
149 TAknLayoutRect topLeft ; |
|
150 topLeft.LayoutRect( aParentRect, SkinLayout::Input_field_skin_placing__general__Line_2() ); |
|
151 TRect rectTopLeft( topLeft.Rect() ); |
|
152 return rectTopLeft; |
|
153 } |
|
154 |
|
155 LOCAL_D TRect EditFrameTopRightRect( const TRect& aParentRect ) |
|
156 {// Skins LAF table 5.24 Line 3 |
|
157 TAknLayoutRect topRight ; |
|
158 TAknWindowLineLayout l( SkinLayout::Input_field_skin_placing__general__Line_3() ); |
|
159 // l field should be w - 3 |
|
160 TAknLayoutRect layoutRect; |
|
161 layoutRect.LayoutRect( aParentRect, l ); |
|
162 TRect rectLayout( layoutRect.Rect() ); |
|
163 |
|
164 // COMPLETELY BROKEN -- SHOULD NEVER INVENT OWN COORDINATES FOR LAYOUTRECT(). |
|
165 //topRight.LayoutRect( aParentRect, ELayoutEmpty, ELayoutEmpty, 0, 0, ELayoutEmpty, rectLayout.Width(), rectLayout.Height() ) ; |
|
166 //TRect rectTopRight( topRight.Rect() ); |
|
167 |
|
168 return rectLayout /*rectTopRight*/; |
|
169 } |
|
170 |
|
171 LOCAL_D TRect EditFrameBottomLeftRect( const TRect& aParentRect ) |
|
172 {// Skins LAF table 5.24 Line 4 |
|
173 TAknLayoutRect bottomLeft ; |
|
174 TAknWindowLineLayout l( SkinLayout::Input_field_skin_placing__general__Line_4() ); |
|
175 // t should be h-3 |
|
176 TAknLayoutRect layoutRect; |
|
177 layoutRect.LayoutRect( aParentRect, l ); |
|
178 TRect rectLayout( layoutRect.Rect() ); |
|
179 |
|
180 // COMPLETELY BROKEN -- SHOULD NEVER INVENT OWN COORDINATES FOR LAYOUTRECT(). |
|
181 //bottomLeft.LayoutRect( aParentRect, ELayoutEmpty, 0, ELayoutEmpty, ELayoutEmpty, 0, rectLayout.Width(), rectLayout.Height() ) ; |
|
182 //TRect rectBottomLeft( bottomLeft.Rect() ); |
|
183 |
|
184 return rectLayout /*rectBottomLeft*/; |
|
185 } |
|
186 |
|
187 LOCAL_D TRect EditFrameBottomRightRect( const TRect& aParentRect ) |
|
188 {// Skins LAF table 5.24 Line 5 |
|
189 TAknLayoutRect bottomRight ; |
|
190 TAknWindowLineLayout l( SkinLayout::Input_field_skin_placing__general__Line_5() ); |
|
191 // l should be w-3, t should be h-3 |
|
192 TAknLayoutRect layoutRect; |
|
193 layoutRect.LayoutRect( aParentRect, l ); |
|
194 TRect rectLayout( layoutRect.Rect() ); |
|
195 |
|
196 // COMPLETELY BROKEN -- SHOULD NEVER INVENT OWN COORDINATES FOR LAYOUTRECT(). |
|
197 //bottomRight.LayoutRect( aParentRect, ELayoutEmpty, ELayoutEmpty, ELayoutEmpty, 0, 0, rectLayout.Width(), rectLayout.Height() ) ; |
|
198 //TRect rectBottomRight( bottomRight.Rect() ); |
|
199 |
|
200 return rectLayout /*rectBottomRight*/; |
|
201 } |
|
202 |
|
203 LOCAL_D TRect EditFrameTopRect( const TRect& aParentRect ) |
|
204 {// Skins LAF table 5.24 Line 6 |
|
205 TAknLayoutRect top ; |
|
206 TAknWindowLineLayout l (SkinLayout::Input_field_skin_placing__general__Line_6() ); |
|
207 TAknLayoutRect layoutRect; |
|
208 layoutRect.LayoutRect( aParentRect, l ); |
|
209 TRect rectLayout( layoutRect.Rect() ); |
|
210 |
|
211 // COMPLETELY BROKEN -- SHOULD NEVER INVENT OWN COORDINATES FOR LAYOUTRECT(). |
|
212 //top.LayoutRect( aParentRect, ELayoutEmpty, rectLayout.iTl.iX, rectLayout.iTl.iY, ELayoutEmpty, ELayoutEmpty, aParentRect.Width()+rectLayout.Width(), rectLayout.Height() ) ; |
|
213 //TRect rectTop( top.Rect() ); |
|
214 |
|
215 return rectLayout /*rectTop*/; |
|
216 } |
|
217 |
|
218 LOCAL_D TRect EditFrameBottomRect( const TRect& aParentRect ) |
|
219 {// Skins LAF table 5.24 Line 7 |
|
220 TAknLayoutRect bottom ; |
|
221 TAknWindowLineLayout l (SkinLayout::Input_field_skin_placing__general__Line_7() ); |
|
222 TAknLayoutRect layoutRect; |
|
223 layoutRect.LayoutRect( aParentRect, l ); |
|
224 TRect rectLayout( layoutRect.Rect() ); |
|
225 |
|
226 // COMPLETELY BROKEN -- SHOULD NEVER INVENT OWN COORDINATES FOR LAYOUTRECT(). |
|
227 //bottom.LayoutRect( aParentRect, ELayoutEmpty, rectLayout.iTl.iX, 0, aParentRect.Height()+rectLayout.iTl.iY, ELayoutEmpty, aParentRect.Width()+rectLayout.Width(), rectLayout.Height() ) ; |
|
228 //TRect rectBottom( bottom.Rect() ); |
|
229 |
|
230 return rectLayout /*rectBottom*/; |
|
231 } |
|
232 |
|
233 |
|
234 LOCAL_D TRect ViewFrameTopLeftRect( const TRect& aParentRect ) |
|
235 {// Skins LAF table 5.17 line 2 |
|
236 TAknLayoutRect topLeft ; |
|
237 topLeft.LayoutRect( aParentRect, SkinLayout::List_highlight_skin_placing__general__Line_2() ); |
|
238 TRect rectTopLeft( topLeft.Rect() ); |
|
239 |
|
240 return rectTopLeft; |
|
241 } |
|
242 |
|
243 LOCAL_D TRect ViewFrameBottomRightRect( const TRect& aParentRect ) |
|
244 {// Skins LAF table 5.17 line 5 |
|
245 TAknLayoutRect bottomRight ; |
|
246 TAknWindowLineLayout l ( SkinLayout::List_highlight_skin_placing__general__Line_5() ); |
|
247 TAknLayoutRect layoutRect; |
|
248 layoutRect.LayoutRect( aParentRect, l ); |
|
249 TRect rectLayout( layoutRect.Rect() ); |
|
250 |
|
251 // COMPLETELY BROKEN -- SHOULD NEVER INVENT OWN COORDINATES FOR LAYOUTRECT(). |
|
252 //bottomRight.LayoutRect( aParentRect, ELayoutEmpty, ELayoutEmpty, ELayoutEmpty, 0, 0, rectLayout.Width(), rectLayout.Height() ) ; |
|
253 //TRect rectBottomRight( bottomRight.Rect() ); |
|
254 |
|
255 return rectLayout; |
|
256 } |
|
257 |
|
258 |
|
259 LOCAL_D TInt ScaledSubLength(TInt aScaledTotal, TInt aSubLength, TInt aTotal) |
|
260 { |
|
261 if(aTotal) |
|
262 return ((aSubLength*aScaledTotal)+(aTotal/2))/aTotal; |
|
263 else |
|
264 return aScaledTotal; |
|
265 } |
|
266 |
|
267 LOCAL_D TBool IsPopupField(const CEikCaptionedControl* aCC) |
|
268 { |
|
269 TInt ctrlType = aCC->iControlType; |
|
270 if (ctrlType == EAknCtPopupField || ctrlType == EAknCtPopupFieldText) |
|
271 { |
|
272 CAknPopupField *field = (CAknPopupField*)aCC->iControl; |
|
273 if (field->SelectionMode() != CAknPopupField::EAknPopupFieldLabelMode) |
|
274 return ETrue; |
|
275 return EFalse; |
|
276 } |
|
277 return EFalse; |
|
278 } |
|
279 |
|
280 class CIdleCallbackData; |
|
281 /** |
|
282 * |
|
283 * Extension class for additional data members. |
|
284 * |
|
285 */ |
|
286 NONSHARABLE_CLASS( CEikCapCExtension ): public MEikFormAnimObserver |
|
287 { |
|
288 friend class CEikCaptionedControl ; |
|
289 |
|
290 private: |
|
291 CEikCapCExtension(); |
|
292 ~CEikCapCExtension(); |
|
293 |
|
294 TBool IsHighlightAnimated() const; |
|
295 void SkinChanged(); |
|
296 void HandleLayoutSwitch( const TSize& aSize ); |
|
297 |
|
298 // Implementation of MEikFormAnimObserver |
|
299 void AnimFrameReady(); |
|
300 TBool AnimDrawHighlightBackground( CFbsBitGc& aGc ); |
|
301 |
|
302 /** |
|
303 * Simulates pointer event to control if required. |
|
304 * |
|
305 * @param aPointerEvent Received pointer event. |
|
306 */ |
|
307 void SimulatePointerEventToControlL( const TPointerEvent& aPointerEvent ); |
|
308 |
|
309 /** |
|
310 * Returns ETrue if control launches a virtual input when tapped. |
|
311 * |
|
312 * @return ETrue if virtual input should be launched. |
|
313 */ |
|
314 TBool LaunchInputType() const; |
|
315 |
|
316 private: //Data members. None owned. |
|
317 CEikCaptionedControl* iSelf ; // pointer to full class |
|
318 CAknsFrameBackgroundControlContext* iEditModeHighlightControlContext ; |
|
319 CAknsFrameBackgroundControlContext* iViewModeHighlightControlContext ; |
|
320 CAknsFrameBackgroundControlContext* iEditModeHighlightControlContextPressed; |
|
321 CAknsFrameBackgroundControlContext* iViewModeHighlightControlContextPressed ; |
|
322 TRect iPreviousRect ; |
|
323 TBool iPreviousState ; // Editable state |
|
324 TBool iPressDownEffect; //Press Down Effect |
|
325 // Offset necessary because LAF instructs use of List Layout for Forms but the parent panes have different origins. |
|
326 TInt iXOffsetForDataPaneInEditMode ; |
|
327 TInt iYOffsetForDataPaneInEditMode ; |
|
328 |
|
329 TBool iDrawNoWhiteBackground; |
|
330 |
|
331 CEikFormAnim* iAnimation; |
|
332 |
|
333 CEikImage* iIndicator; |
|
334 CEikImage* iIndicator2; |
|
335 |
|
336 MPointerEventObserver *iObserver; |
|
337 |
|
338 /** |
|
339 * ETrue if to control is sent simulated down event. |
|
340 */ |
|
341 TBool iSimulatedDownEvent; |
|
342 |
|
343 /** |
|
344 * Tactile feedback provider. |
|
345 * Not own. |
|
346 */ |
|
347 MTouchFeedback* iFeedback; |
|
348 |
|
349 public: // needs to be public because idle callback uses these members. |
|
350 CIdle *iIdle; |
|
351 CIdleCallbackData *iIdleData; |
|
352 /** iPartiallyVisible is used as a protection from changing subcontrol positions of |
|
353 * partially-visible controls in PositionFormComponents(). This is needed only for |
|
354 * dynamic screen size change. |
|
355 */ |
|
356 TBool iPartiallyVisible; |
|
357 |
|
358 /** |
|
359 * Boolean used to check if application is single touch compatible. |
|
360 */ |
|
361 TBool iUsesSingleClick; |
|
362 |
|
363 private: |
|
364 |
|
365 } ; |
|
366 |
|
367 NONSHARABLE_CLASS(CIdleCallbackData) : public CBase |
|
368 { |
|
369 public: |
|
370 CEikCaptionedControl *iCtrl; |
|
371 CEikCapCExtension *iExt; |
|
372 }; |
|
373 |
|
374 |
|
375 CEikCapCExtension::CEikCapCExtension() : |
|
376 // Member initialisaction list - all values to NULL/0 |
|
377 iSelf( NULL ), |
|
378 iEditModeHighlightControlContext ( NULL ) , |
|
379 iViewModeHighlightControlContext ( NULL ) , |
|
380 iEditModeHighlightControlContextPressed( NULL ), |
|
381 iViewModeHighlightControlContextPressed( NULL ), |
|
382 iPreviousRect( TPoint(0, 0), TSize(0, 0) ) , |
|
383 iPreviousState( EFalse ) , |
|
384 iPressDownEffect( EFalse ), |
|
385 iXOffsetForDataPaneInEditMode( ELayoutEmpty ) , |
|
386 iYOffsetForDataPaneInEditMode( ELayoutEmpty ) , |
|
387 iDrawNoWhiteBackground( EFalse ), |
|
388 iAnimation( NULL ) |
|
389 , iIndicator(NULL), |
|
390 iIndicator2(NULL), |
|
391 iObserver(NULL), |
|
392 iFeedback( MTouchFeedback::Instance() ), |
|
393 iIdle(NULL), |
|
394 iIdleData(NULL), |
|
395 iPartiallyVisible( EFalse ) |
|
396 { |
|
397 if ( iAvkonAppUi ) |
|
398 { |
|
399 iUsesSingleClick = iAvkonAppUi->IsSingleClickCompatible(); |
|
400 } |
|
401 }; |
|
402 |
|
403 CEikCapCExtension::~CEikCapCExtension() |
|
404 { |
|
405 // Remember to unacquire animation |
|
406 if( iAnimation && iSelf ) |
|
407 { |
|
408 if( iSelf->iDialogPage ) |
|
409 iSelf->iDialogPage->AcquireAnim( EFalse, this ); |
|
410 } |
|
411 } |
|
412 |
|
413 TBool CEikCapCExtension::IsHighlightAnimated() const |
|
414 { |
|
415 if( iAnimation ) |
|
416 { |
|
417 if( iAnimation->Animation() ) |
|
418 return ETrue; |
|
419 } |
|
420 |
|
421 // No animation available at all... |
|
422 return EFalse; |
|
423 } |
|
424 |
|
425 void CEikCapCExtension::SkinChanged() |
|
426 { |
|
427 iAnimation = NULL; |
|
428 if( iSelf->iDialogPage ) |
|
429 iAnimation = iSelf->iDialogPage->AcquireAnim( ETrue, this ); |
|
430 |
|
431 if( iAnimation ) |
|
432 { |
|
433 iAnimation->SetHighlightSize( iSelf->Rect().Size() ); |
|
434 } |
|
435 } |
|
436 |
|
437 void CEikCapCExtension::HandleLayoutSwitch( const TSize& aSize ) |
|
438 { |
|
439 if( iAnimation ) |
|
440 { |
|
441 if( iAnimation->Size() == aSize ) |
|
442 { |
|
443 // No need to resize, just change the background used |
|
444 // as animation input. |
|
445 iAnimation->ChangeHighlightBackground(); |
|
446 } |
|
447 else |
|
448 { |
|
449 iAnimation->SetHighlightSize( aSize ); |
|
450 } |
|
451 } |
|
452 } |
|
453 |
|
454 void CEikCapCExtension::AnimFrameReady() |
|
455 { |
|
456 if( iSelf ) |
|
457 iSelf->DrawNow(); |
|
458 } |
|
459 |
|
460 TBool CEikCapCExtension::AnimDrawHighlightBackground( CFbsBitGc& aGc ) |
|
461 { |
|
462 if( !iSelf->iDialogPage ) |
|
463 return EFalse; |
|
464 |
|
465 // Draw the background under the current highlight. This simplified |
|
466 // drawing, we only grab a piece from the list background bitmap. |
|
467 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
468 MAknsControlContext* cc = AknsDrawUtils::ControlContext( iSelf->iDialogPage ); |
|
469 |
|
470 return AknsDrawUtils::DrawBackground( skin, cc, iSelf->iDialogPage, aGc, TPoint(0,0), |
|
471 iSelf->ViewRect(), KAknsDrawParamRGBOnly ); |
|
472 } |
|
473 |
|
474 |
|
475 void CEikCapCExtension::SimulatePointerEventToControlL( |
|
476 const TPointerEvent& aPointerEvent ) |
|
477 { |
|
478 // Extend form item touch area to whole item area |
|
479 if ( iSelf->iIsEditable |
|
480 && ( aPointerEvent.iType == TPointerEvent::EButton1Down |
|
481 || aPointerEvent.iType == TPointerEvent::EButton1Up ) ) |
|
482 { |
|
483 |
|
484 // Check control type |
|
485 TBool edwinControl( LaunchInputType() ); |
|
486 TBool simulate = EFalse; |
|
487 if ( aPointerEvent.iType == TPointerEvent::EButton1Down |
|
488 && iSelf->Rect().Contains( aPointerEvent.iPosition ) |
|
489 && !iSelf->iControl->Rect().Contains( |
|
490 aPointerEvent.iPosition ) ) |
|
491 { |
|
492 iSimulatedDownEvent = ETrue; |
|
493 if ( !edwinControl ) |
|
494 { |
|
495 simulate = ETrue; |
|
496 } |
|
497 } |
|
498 else if ( aPointerEvent.iType == TPointerEvent::EButton1Up |
|
499 && iSimulatedDownEvent ) |
|
500 { |
|
501 simulate = ETrue; |
|
502 } |
|
503 |
|
504 // Simulate pointer event to control |
|
505 if ( simulate && !edwinControl ) |
|
506 { |
|
507 TPointerEvent controlEvent( aPointerEvent ); |
|
508 controlEvent.iPosition = |
|
509 iSelf->iControl->Rect().iTl + TPoint( 1, 1 ); |
|
510 iSelf->iControl->HandlePointerEventL( controlEvent ); |
|
511 } |
|
512 |
|
513 // With edwin do action directly (due to cursor problems) |
|
514 else if ( edwinControl && simulate |
|
515 && aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
516 { |
|
517 CAknExtendedInputCapabilities* input( NULL ); |
|
518 iSelf->iControl->InputCapabilities().ObjectProvider( |
|
519 )->MopGetObjectNoChaining( input ); |
|
520 if ( input ) |
|
521 { |
|
522 iFeedback->InstantFeedback( |
|
523 iSelf->iControl, ETouchFeedbackEdit, |
|
524 ETouchFeedbackVibra, aPointerEvent ); |
|
525 input->ReportEventL( |
|
526 CAknExtendedInputCapabilities::\ |
|
527 MAknEventObserver::EActivatePenInputRequest, |
|
528 NULL ); |
|
529 } |
|
530 } |
|
531 if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
532 { |
|
533 iSimulatedDownEvent = EFalse; |
|
534 } |
|
535 } |
|
536 } |
|
537 |
|
538 |
|
539 TBool CEikCapCExtension::LaunchInputType() const |
|
540 { |
|
541 TBool launchInput( EFalse ); |
|
542 |
|
543 switch( iSelf->iControlType ) |
|
544 { |
|
545 case EEikCtEdwin: |
|
546 case EEikCtGlobalTextEditor: |
|
547 case EEikCtRichTextEditor: |
|
548 case EAknCtIntegerEdwin: |
|
549 case EEikCtFlPtEd: |
|
550 case EEikCtFxPtEd: |
|
551 { |
|
552 launchInput = ETrue; |
|
553 break; |
|
554 } |
|
555 default: |
|
556 { |
|
557 break; |
|
558 } |
|
559 } |
|
560 |
|
561 return launchInput || iSelf->ControlIsASecretEditor( iSelf->iControlType ); |
|
562 } |
|
563 |
|
564 |
|
565 NONSHARABLE_CLASS(CEikCaptionedControlFormHighlightLine) : public CCoeControl |
|
566 { |
|
567 public: |
|
568 enum TTopOrBottom |
|
569 { |
|
570 EUnset, |
|
571 ETop, |
|
572 EBottom |
|
573 }; |
|
574 CEikCaptionedControlFormHighlightLine( const CEikCaptionedControl& aParent ) : iCapCtl( aParent ) |
|
575 { iTopOrBottom=EUnset; }; |
|
576 void ConstructL() ; |
|
577 void Draw(const TRect& aRect) const; |
|
578 void SetTopOrBottom(TTopOrBottom aTopOrBottom) {iTopOrBottom=aTopOrBottom;}; |
|
579 TInt HeightOfHighlight(TTopOrBottom aTopOrBottom) const; |
|
580 private: |
|
581 TBool DrawingSkins() const ; |
|
582 const CEikCaptionedControl& iCapCtl ; // pointer to parent class |
|
583 TTopOrBottom iTopOrBottom; |
|
584 }; |
|
585 |
|
586 /** |
|
587 * This draws the form highlight line |
|
588 * |
|
589 */ |
|
590 void CEikCaptionedControlFormHighlightLine::Draw(const TRect& /*aRect*/) const |
|
591 { |
|
592 CWindowGc& gc=SystemGc(); |
|
593 TBool drawn = EFalse; |
|
594 |
|
595 if ( IsVisible() && DrawingSkins() ) |
|
596 { |
|
597 //<SKIN> |
|
598 MAknsSkinInstance* skin = AknsUtils::SkinInstance() ; |
|
599 |
|
600 // Drawn as three parts |
|
601 if (iTopOrBottom == ETop) |
|
602 { |
|
603 AknsDrawUtils::DrawFramePart( skin, gc, EditFrameTopRect( Rect() ), KAknsIIDQsnFrInput, EAknsFrameIndexT ) ; |
|
604 AknsDrawUtils::DrawFramePart( skin, gc, EditFrameTopLeftRect( Rect() ), KAknsIIDQsnFrInput, EAknsFrameIndexTl ); |
|
605 AknsDrawUtils::DrawFramePart( skin, gc, EditFrameTopRightRect( Rect() ), KAknsIIDQsnFrInput, EAknsFrameIndexTr ); |
|
606 } |
|
607 else if (iTopOrBottom == EBottom) |
|
608 { |
|
609 AknsDrawUtils::DrawFramePart( skin, gc, EditFrameBottomLeftRect( Rect() ), KAknsIIDQsnFrInput, EAknsFrameIndexBl ); |
|
610 AknsDrawUtils::DrawFramePart( skin, gc, EditFrameBottomRightRect( Rect() ), KAknsIIDQsnFrInput, EAknsFrameIndexBr ); |
|
611 AknsDrawUtils::DrawFramePart( skin, gc, EditFrameBottomRect( Rect() ), KAknsIIDQsnFrInput, EAknsFrameIndexB ); |
|
612 } |
|
613 |
|
614 drawn = ETrue ; |
|
615 } |
|
616 |
|
617 if ( IsVisible() && !drawn ) // old, non-skin, drawing code |
|
618 { |
|
619 if (!iTopOrBottom==EUnset) |
|
620 { |
|
621 // Assert control is the correct height. |
|
622 __ASSERT_DEBUG(Rect().Height()==HeightOfHighlight(iTopOrBottom), Panic(EEikDialogPanicFocusableLineWithIdZero)); |
|
623 // numbers used to just get data on how the line looks in terms of color. |
|
624 TRect someArbitraryRect=TRect(TPoint(0,0),TPoint(11,22)); |
|
625 TInt someArbitraryNumber=0; |
|
626 TAknLayoutRect line2Rect; |
|
627 line2Rect.LayoutRect |
|
628 (someArbitraryRect, |
|
629 AKN_LAYOUT_WINDOW_Form_data_field_elements_Line_2 |
|
630 ); |
|
631 TAknLayoutRect line3Rect; |
|
632 line3Rect.LayoutRect |
|
633 (someArbitraryRect, |
|
634 AKN_LAYOUT_WINDOW_Form_data_field_elements_Line_3 |
|
635 ( someArbitraryNumber) |
|
636 ); |
|
637 gc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
638 gc.SetBrushStyle( CGraphicsContext::ENullBrush) ; |
|
639 |
|
640 if (iTopOrBottom == ETop) |
|
641 { |
|
642 // Draw solid black 2 pixel rectangle |
|
643 TRect rectToDraw=Rect(); |
|
644 gc.SetPenColor( line3Rect.Color() ) ; // black line; |
|
645 gc.DrawRect(rectToDraw); |
|
646 // Draw grey line, over black |
|
647 rectToDraw.iTl.iY++; |
|
648 rectToDraw.Shrink(1,0); |
|
649 gc.SetPenColor( line2Rect.Color() ) ; // Greyline; |
|
650 gc.DrawRect(rectToDraw); |
|
651 } |
|
652 else if (iTopOrBottom == EBottom) |
|
653 { |
|
654 // Draw solid black 1 pixel rectangle (i.e. a line :-) |
|
655 TRect rectToDraw=Rect(); |
|
656 gc.SetPenColor( line3Rect.Color() ) ; // black line; |
|
657 gc.DrawRect(rectToDraw); |
|
658 } |
|
659 } |
|
660 } |
|
661 }; |
|
662 |
|
663 |
|
664 TInt CEikCaptionedControlFormHighlightLine::HeightOfHighlight(TTopOrBottom aTopOrBottom) const |
|
665 { |
|
666 if ( DrawingSkins() ) |
|
667 { |
|
668 // Also, what it skins is enabled, but this part has not skinning... |
|
669 switch (aTopOrBottom) |
|
670 { |
|
671 case ETop : |
|
672 return EditFrameTopRect( Rect().Size() ).Height(); |
|
673 case EBottom : |
|
674 return EditFrameBottomRect( Rect().Size() ).Height(); |
|
675 default: |
|
676 return 0; |
|
677 } |
|
678 } |
|
679 else // no skin - old code |
|
680 { |
|
681 switch (aTopOrBottom) |
|
682 { |
|
683 case ETop: |
|
684 return 2; |
|
685 case EBottom: |
|
686 return 1; |
|
687 default: |
|
688 return 0; |
|
689 }; |
|
690 } |
|
691 } |
|
692 |
|
693 void CEikCaptionedControlFormHighlightLine::ConstructL() |
|
694 { |
|
695 SetContainerWindowL( iCapCtl ) ; |
|
696 } |
|
697 |
|
698 |
|
699 TBool CEikCaptionedControlFormHighlightLine::DrawingSkins() const |
|
700 { |
|
701 TBool drawingSkins = EFalse; |
|
702 if ( AknsUtils::AvkonSkinEnabled() ) |
|
703 { |
|
704 MAknsSkinInstance* skin = AknsUtils::SkinInstance() ; |
|
705 MAknsControlContext* cc = AknsDrawUtils::ControlContext( &iCapCtl ) ; |
|
706 CWindowGc& gc = SystemGc(); |
|
707 drawingSkins = AknsDrawUtils::Background( skin, cc, this, gc, Rect(), KAknsDrawParamPrepareOnly ); |
|
708 } |
|
709 return drawingSkins; |
|
710 } |
|
711 |
|
712 EXPORT_C CEikCaptionedControl::CEikCaptionedControl() : iHasAppendedEditIndicator(EFalse) |
|
713 { |
|
714 iNumberOfLines = 1 ; // default starting value |
|
715 AKNTASHOOK_ADD( this, "CEikCaptionedControl" ); |
|
716 } |
|
717 |
|
718 EXPORT_C CEikCaptionedControl::~CEikCaptionedControl() |
|
719 { |
|
720 AKNTASHOOK_REMOVE(); |
|
721 AknsUtils::DeregisterControlPosition(this); |
|
722 AknsUtils::DeregisterControlPosition(iBitmap); |
|
723 AknsUtils::DeregisterControlPosition(iCaption); |
|
724 AknsUtils::DeregisterControlPosition(iControl); |
|
725 AknsUtils::DeregisterControlPosition(iTrailer); |
|
726 AknsUtils::DeregisterControlPosition(iHighlightControl); |
|
727 if ( ControlIsAnEdwin( iControlType ) ) |
|
728 { |
|
729 static_cast<CEikEdwin*>( iControl )->SetEdwinObserver( NULL ); |
|
730 } |
|
731 if (iIsFormControl && iControl) |
|
732 iControl->SetFocus( EFalse); |
|
733 delete iControl; |
|
734 delete iCaptionText; |
|
735 delete iCaption; |
|
736 delete iTrailer; |
|
737 delete iToolTipText ; |
|
738 delete iBitmap ; |
|
739 delete iHighlightControl ; |
|
740 if ( iExtension ) |
|
741 { |
|
742 delete iExtension->iIdle; |
|
743 delete iExtension->iIdleData; |
|
744 delete iExtension->iEditModeHighlightControlContext ; |
|
745 delete iExtension->iViewModeHighlightControlContext ; |
|
746 delete iExtension->iEditModeHighlightControlContextPressed; |
|
747 delete iExtension->iViewModeHighlightControlContextPressed; |
|
748 delete iExtension->iIndicator; |
|
749 delete iExtension->iIndicator2; |
|
750 } |
|
751 delete iExtension ; |
|
752 } |
|
753 |
|
754 EXPORT_C void CEikCaptionedControl::SetPointerEventObserver(MPointerEventObserver *aObserver) |
|
755 { |
|
756 if (iExtension) |
|
757 iExtension->iObserver = aObserver; |
|
758 } |
|
759 |
|
760 MPointerEventObserver *CEikCaptionedControl::PointerEventObserver() const |
|
761 { |
|
762 if (iExtension) |
|
763 return iExtension->iObserver; |
|
764 return NULL; |
|
765 } |
|
766 |
|
767 EXPORT_C void CEikCaptionedControl::SetUsesEars() |
|
768 { |
|
769 iCapCFlags&=(~EUsesEars) ; // switch them off to make sure |
|
770 } |
|
771 |
|
772 EXPORT_C void CEikCaptionedControl::SetExtraAscent() |
|
773 { |
|
774 iCapCFlags|=EExtraAscent; |
|
775 } |
|
776 |
|
777 void CEikCaptionedControl::SetPictographCallBack() |
|
778 { |
|
779 if ( ControlIsAnEdwin( iControlType ) ) |
|
780 { |
|
781 TCallBack cb( PictographAnimationCallBack, this ); |
|
782 static_cast<CEikEdwin*>( iControl )->SetPictographAnimationCallBack( cb ); |
|
783 } |
|
784 } |
|
785 |
|
786 TInt CEikCaptionedControl::PictographAnimationCallBack( TAny* aPtr ) |
|
787 { |
|
788 CEikCaptionedControl* me = static_cast<CEikCaptionedControl*>( aPtr ); |
|
789 me->iHighlightControl->DrawNow(); |
|
790 return KErrNone; |
|
791 } |
|
792 |
|
793 EXPORT_C TSize CEikCaptionedControl::MinimumSize() |
|
794 { |
|
795 // NTBD Add an extra line for those with the label on a separate |
|
796 if ( iIsFormControl ) |
|
797 { |
|
798 if (iControl->IsDimmed()) |
|
799 { |
|
800 iSize = TSize( 0, 0) ; |
|
801 return iSize; |
|
802 } |
|
803 // We can get the minimum size from the resource - and the size of the editor (EditorControlSize() in lines) |
|
804 CalculateNumberOfLinesForControl( ENotSupplied ); |
|
805 |
|
806 // temporary hack |
|
807 TBool fixedNumOfLines(EFalse); |
|
808 if (ControlIsAnEdwin(iControlType) && iNumberOfLines == 0) |
|
809 { |
|
810 iNumberOfLines = 1; |
|
811 fixedNumOfLines = ETrue; |
|
812 } |
|
813 // --------------- |
|
814 |
|
815 |
|
816 // TInt heightExpectedForNumberOfLines=0; (NOT USED) |
|
817 TRect layout = TRect(0,0,0,0); |
|
818 TRect mainPaneRect; |
|
819 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
820 TAknLayoutRect l; |
|
821 l.LayoutRect(mainPaneRect, AknLayoutScalable_Avkon::listscroll_form_pane().LayoutLine()); |
|
822 l.LayoutRect(l.Rect(), AknLayoutScalable_Avkon::list_form_gen_pane().LayoutLine()); |
|
823 TRect parentRect = l.Rect(); |
|
824 |
|
825 if ( iNumberOfLines > 0 ) |
|
826 { |
|
827 if ( iNumberOfLines > MaximumNumberOfControlLinesOnVisiblePage() ) // MAX LINES |
|
828 Panic( EEikDialogPanicControlIsBiggerThanPage ) ; |
|
829 |
|
830 switch ( FormLayout() ) |
|
831 { |
|
832 case CEikDialogPage::ESingle : |
|
833 { |
|
834 TAknWindowLineLayout l; |
|
835 if (IsPopupField(this)) |
|
836 l = AknLayoutScalable_Avkon::form_field_popup_pane(iNumberOfLines - 1).LayoutLine(); |
|
837 else |
|
838 l = AknLayoutScalable_Avkon::form_field_data_pane(iNumberOfLines - 1).LayoutLine(); |
|
839 |
|
840 TAknLayoutRect layoutRect; |
|
841 |
|
842 layoutRect.LayoutRect( parentRect, l ); |
|
843 TRect rectSingle( layoutRect.Rect() ); |
|
844 layout = layoutRect.Rect(); |
|
845 //heightExpectedForNumberOfLines = rectSingle.Height(); |
|
846 } |
|
847 break ; |
|
848 case CEikDialogPage::EDouble : |
|
849 { |
|
850 TAknWindowLineLayout l; |
|
851 if (IsPopupField(this)) |
|
852 l = AknLayoutScalable_Avkon::form_field_popup_wide_pane(iNumberOfLines - 1).LayoutLine(); |
|
853 else |
|
854 l = AknLayoutScalable_Avkon::form_field_data_wide_pane(iNumberOfLines - 1).LayoutLine(); |
|
855 TAknLayoutRect layoutRect; |
|
856 |
|
857 layoutRect.LayoutRect( parentRect, l ); |
|
858 TRect rectDouble( layoutRect.Rect() ); |
|
859 layout = layoutRect.Rect(); |
|
860 //heightExpectedForNumberOfLines = rectDouble.Height(); |
|
861 } |
|
862 break ; |
|
863 default : |
|
864 break ; |
|
865 } |
|
866 } |
|
867 // temporary hack continues |
|
868 if (fixedNumOfLines) |
|
869 { |
|
870 iNumberOfLines = 0; |
|
871 } |
|
872 // ------------------------ |
|
873 |
|
874 iSize = layout.Size(); |
|
875 return ( iSize ) ; |
|
876 } |
|
877 else |
|
878 { |
|
879 TSize size=iControl->MinimumSize(); |
|
880 TPoint ctlTl = iControl->Rect().iTl; |
|
881 TPoint ownTl = Rect().iTl; |
|
882 TRect mainPaneRect; |
|
883 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
884 |
|
885 if (ctlTl.iX > ownTl.iX || ctlTl.iY > ownTl.iY) |
|
886 { |
|
887 size = size + (ctlTl - ownTl); |
|
888 |
|
889 if ( size.iHeight > mainPaneRect.Size().iHeight && iDialogPage && |
|
890 !( iDialogPage->PageContainer()->PageSelector()->Dialg()-> |
|
891 DialogFlags() & EEikDialogFlagFillScreen ) && |
|
892 !iDialogPage->PageContainer()->PageSelector()->Dialg()-> |
|
893 Extension()->iPublicFlags.IsSet( CEikDialogExtension::EUseVirtualInput ) ) |
|
894 { |
|
895 size.iHeight = mainPaneRect.Size().iHeight; |
|
896 } |
|
897 |
|
898 } |
|
899 |
|
900 if ( !iIsFormControl && iCaption && !(iCaption->Text()->Length()) ) |
|
901 // Non form controls mustn't have empty captions. |
|
902 { |
|
903 delete iCaption ; |
|
904 iCaption = NULL ; |
|
905 ResetMinimumSizes() ; |
|
906 } |
|
907 |
|
908 if (iCaption) |
|
909 { |
|
910 if (iCapCFlags&EExtraAscent) |
|
911 size.iHeight+=KCapCExtraAscent; |
|
912 TSize capSize=iCaption->MinimumSize(); |
|
913 capSize.iHeight+=KCapCVertCaptionOffset; |
|
914 if (capSize.iHeight>size.iHeight) |
|
915 size.iHeight=capSize.iHeight; |
|
916 iCaptionWidth=capSize.iWidth+KCapCCenterSpacing; |
|
917 } |
|
918 if (iTrailer) |
|
919 { |
|
920 TSize trailSize=iTrailer->MinimumSize(); |
|
921 trailSize.iHeight+=KTrailCVertCaptionOffset; |
|
922 if (trailSize.iHeight>size.iHeight) |
|
923 size.iHeight=trailSize.iHeight; |
|
924 size.iWidth+=trailSize.iWidth+KControlTrailerSpacing; |
|
925 } |
|
926 if ( iBitmap ) |
|
927 { |
|
928 // Decisions... decisions... |
|
929 // Do we use the bitmap as is, or do we resize it? |
|
930 // Do we need some border spacing values added? |
|
931 TSize bitmapSize = iBitmap->MinimumSize() ; |
|
932 if ( bitmapSize.iHeight > size.iHeight ) |
|
933 size.iHeight = bitmapSize.iHeight ; |
|
934 //T: size.iWidth += bitmapSize.iWidth ; |
|
935 iCaptionWidth += bitmapSize.iWidth ; // Include the bitmap in the caption |
|
936 } |
|
937 if (iCapCFlags&EUsesEars) |
|
938 { |
|
939 size.iWidth+=KCapCEarWidth+KCapCEarSpacing; |
|
940 iCaptionWidth+=KCapCEarWidth+KCapCEarSpacing; |
|
941 } |
|
942 size.iHeight+=2*iVertEdgeSpacing; |
|
943 size.iWidth+=iCaptionWidth+2*iHorzEdgeSpacing; |
|
944 if (iCapCFlags&ESeparatorAfter) |
|
945 size.iHeight+=KCapCSeparatorAfterSpace; |
|
946 iMinSize=size; |
|
947 |
|
948 if ( iDoNotDisplay ) |
|
949 // This flag is set if the control is not to be shown - so set it's height to zero |
|
950 iMinSize.iHeight = 0 ; |
|
951 return(size); |
|
952 } |
|
953 } |
|
954 /** |
|
955 * This routine should always called when any state affecting layout changed, including |
|
956 * dynamically notified changes to the environment. |
|
957 * |
|
958 * This is also called from Cone as a matter of course when SetRect is called on the object. |
|
959 */ |
|
960 EXPORT_C void CEikCaptionedControl::SizeChanged() |
|
961 { |
|
962 // Resize the animation |
|
963 if( iIsFormControl && iExtension->iAnimation ) |
|
964 { |
|
965 iExtension->iAnimation->SetHighlightSize( Rect().Size() ); |
|
966 } |
|
967 |
|
968 // If the size hasn't changed from the last time this was called we might be able to save a load of processing |
|
969 #if ENABLE_BAD_OPTIMIZATION |
|
970 if ( iExtension->iPreviousRect != Rect() || iExtension->iPreviousState != iIsEditable || |
|
971 iDialogPage && iDialogPage->GetFormFlags() & CEikDialogPage::EFormForceEdwinResizeFlag ) |
|
972 { |
|
973 iExtension->iPreviousRect = Rect() ; |
|
974 iExtension->iPreviousState = iIsEditable ; |
|
975 } |
|
976 else |
|
977 { |
|
978 return ; |
|
979 } |
|
980 #endif |
|
981 // Routine is strictly in two parts. This part for Form layout. |
|
982 if (iIsFormControl) |
|
983 { |
|
984 // If Offset values have not been set up to adjust Layout for parent pane do so now |
|
985 if ( iExtension->iXOffsetForDataPaneInEditMode == ELayoutEmpty || iExtension->iYOffsetForDataPaneInEditMode == ELayoutEmpty ) |
|
986 { |
|
987 TRect mainPaneRect; |
|
988 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
989 |
|
990 TAknLayoutRect formPaneRect ; |
|
991 // RWindow origin is same as mainPainRect origin, so move mainPaneRect to 0,0 |
|
992 TAknWindowLineLayout dataPane = TAknWindowComponentLayout::Compose( |
|
993 AknLayoutScalable_Avkon::listscroll_form_pane(), |
|
994 AknLayoutScalable_Avkon::list_form_gen_pane()).LayoutLine(); |
|
995 formPaneRect.LayoutRect( TRect( TPoint(0 ,0 ), mainPaneRect.Size() ), dataPane ) ; |
|
996 |
|
997 iExtension->iXOffsetForDataPaneInEditMode = formPaneRect.Rect().iTl.iX ; |
|
998 iExtension->iYOffsetForDataPaneInEditMode = formPaneRect.Rect().iTl.iY ; |
|
999 } |
|
1000 PositionFormComponents() ; |
|
1001 LayoutSkinControlContexts(); |
|
1002 |
|
1003 |
|
1004 if (iIsEditable) |
|
1005 { |
|
1006 if (iBitmap && iBitmap->Bitmap()) |
|
1007 { |
|
1008 TAknWindowLineLayout l = AknLayoutScalable_Avkon::form_field_data_wide_pane_g1().LayoutLine(); |
|
1009 TAknLayoutRect layoutRect; |
|
1010 TRect parentRect = Rect(); |
|
1011 layoutRect.LayoutRect( parentRect, l ); |
|
1012 TRect rectElements( layoutRect.Rect() ); |
|
1013 |
|
1014 AknIconUtils::SetSize(CONST_CAST(CFbsBitmap*, iBitmap->Bitmap()), |
|
1015 rectElements.Size() ); |
|
1016 } |
|
1017 } |
|
1018 else |
|
1019 { |
|
1020 if (iBitmap && iBitmap->Bitmap()) |
|
1021 { |
|
1022 TAknWindowLineLayout l = AknLayout::List_pane_elements__single_graphic_heading__Line_1(); |
|
1023 TAknLayoutRect layoutRect; |
|
1024 TRect parentRect = Rect(); |
|
1025 layoutRect.LayoutRect( parentRect, l ); |
|
1026 TRect rectElements( layoutRect.Rect() ); |
|
1027 |
|
1028 AknIconUtils::SetSize(CONST_CAST(CFbsBitmap*, iBitmap->Bitmap()), |
|
1029 rectElements.Size() ); |
|
1030 } |
|
1031 } |
|
1032 } |
|
1033 else |
|
1034 { |
|
1035 TRect rect=Rect(); |
|
1036 if(rect.Width()<MinimumSize().iWidth) |
|
1037 { |
|
1038 SquashComponents(); |
|
1039 } |
|
1040 else |
|
1041 { |
|
1042 StretchComponents(); |
|
1043 } |
|
1044 |
|
1045 if (iBitmap && iBitmap->Bitmap()) |
|
1046 { |
|
1047 TAknWindowLineLayout l = AknLayout::List_pane_elements__single_graphic_heading__Line_1(); |
|
1048 TAknLayoutRect layoutRect; |
|
1049 TRect parentRect = Rect(); |
|
1050 layoutRect.LayoutRect( parentRect, l ); |
|
1051 TRect rectElements( layoutRect.Rect() ); |
|
1052 |
|
1053 AknIconUtils::SetSize(CONST_CAST(CFbsBitmap*, iBitmap->Bitmap()), |
|
1054 rectElements.Size() ); |
|
1055 } |
|
1056 } |
|
1057 |
|
1058 // This flag is also set in ConstructFromResourceL() but has to be re-visited once iIsFormControl has been set |
|
1059 if ( !(iCapCFlags & ENoBorder) && iIsFormControl ) |
|
1060 { |
|
1061 ((CEikBorderedControl*)iControl)->SetBorder( TGulBorder::ENone ) ; |
|
1062 SetExtraAscent() ; |
|
1063 iCapCFlags |= ENoBorder ; |
|
1064 } |
|
1065 |
|
1066 if (iCaption) |
|
1067 { |
|
1068 TRAP_IGNORE(iCaption->SetTextL(*iCaptionText)); |
|
1069 iCaption->CropText(); |
|
1070 } |
|
1071 |
|
1072 if (iExtension && iExtension->iIndicator) |
|
1073 { |
|
1074 TInt variety = 0; |
|
1075 if (iExtension->iIndicator2) |
|
1076 variety = 1; |
|
1077 AknLayoutUtils::LayoutImage(iExtension->iIndicator, Rect(), AknLayoutScalable_Avkon::form_field_data_wide_pane_g2(variety).LayoutLine()); |
|
1078 } |
|
1079 if (iExtension && iExtension->iIndicator2) |
|
1080 { |
|
1081 AknLayoutUtils::LayoutImage(iExtension->iIndicator2, Rect(), AknLayoutScalable_Avkon::form_field_data_wide_pane_g3(1).LayoutLine()); |
|
1082 } |
|
1083 |
|
1084 |
|
1085 // Deregister control positions. Registering new positions here |
|
1086 // would cause undesired WS flush. |
|
1087 // So, they are registered later in CEikDialogPage::SetDataPosition. |
|
1088 |
|
1089 AknsUtils::DeregisterControlPosition(this); |
|
1090 AknsUtils::DeregisterControlPosition(iBitmap); |
|
1091 if (iExtension) |
|
1092 { |
|
1093 AknsUtils::DeregisterControlPosition(iExtension->iIndicator); |
|
1094 AknsUtils::DeregisterControlPosition(iExtension->iIndicator2); |
|
1095 } |
|
1096 AknsUtils::DeregisterControlPosition(iCaption); |
|
1097 AknsUtils::DeregisterControlPosition(iControl); |
|
1098 AknsUtils::DeregisterControlPosition(iTrailer); |
|
1099 AknsUtils::DeregisterControlPosition(iHighlightControl); |
|
1100 |
|
1101 if ( iIsFormControl && iDialogPage ) |
|
1102 { |
|
1103 CEikEdwin* edwin = NULL; |
|
1104 CEikMfne* mfne = NULL; |
|
1105 |
|
1106 if ( ControlIsAnEdwin( iControlType ) ) |
|
1107 { |
|
1108 edwin = static_cast<CEikEdwin*>( iControl ); |
|
1109 edwin->SetSuppressBackgroundDrawing( ETrue ); |
|
1110 } |
|
1111 else if ( ControlIsAMfne( iControlType ) ) |
|
1112 { |
|
1113 mfne = static_cast<CEikMfne*>( iControl ); |
|
1114 mfne->SetSuppressBackgroundDrawing( ETrue ); |
|
1115 } |
|
1116 |
|
1117 iDialogPage->UpdateLineInCache( this ); |
|
1118 |
|
1119 if ( edwin ) |
|
1120 { |
|
1121 edwin->SetSuppressBackgroundDrawing( EFalse ); |
|
1122 } |
|
1123 else if ( mfne ) |
|
1124 { |
|
1125 mfne->SetSuppressBackgroundDrawing( EFalse ); |
|
1126 } |
|
1127 } |
|
1128 } |
|
1129 |
|
1130 |
|
1131 void CEikCaptionedControl::StretchComponents() |
|
1132 { |
|
1133 if (iCapCFlags&EIfTooSmallDontStrech) |
|
1134 return; |
|
1135 |
|
1136 TRect rect=Rect(); |
|
1137 rect.Shrink(iHorzEdgeSpacing,iVertEdgeSpacing); |
|
1138 if (iCapCFlags&ESeparatorAfter) |
|
1139 rect.iBr.iY-=KCapCSeparatorAfterSpace; |
|
1140 |
|
1141 const CFont* editorFont = AknLayoutUtils::FontFromId( iEditorFontId ) ; |
|
1142 |
|
1143 TInt normalEditorHeight = editorFont->HeightInPixels() + editorFont->DescentInPixels() + ( 2 * iVertEdgeSpacing ) ; |
|
1144 if ( normalEditorHeight > rect.Height() ) |
|
1145 normalEditorHeight = rect.Height() ; |
|
1146 |
|
1147 // Insert Bitmap before caption |
|
1148 // Note, if position of caption & bitmap is to be configurable this routine will have to be re structured |
|
1149 if ( iBitmap ) |
|
1150 { |
|
1151 TPoint bitmapTl = rect.iTl ; |
|
1152 TSize bitmapSize = iBitmap->MinimumSize() ; |
|
1153 if ( bitmapSize.iHeight > normalEditorHeight ) |
|
1154 { |
|
1155 // reduce the size of the bitmap whilst retaining proportion. (will clip the bitmap methinks) |
|
1156 TReal ratio = normalEditorHeight/bitmapSize.iHeight ; |
|
1157 bitmapSize = TSize( TInt(bitmapSize.iWidth * ratio) , TInt(bitmapSize.iHeight * ratio) ) ; |
|
1158 } |
|
1159 //else |
|
1160 // bitmapTl.iY += ( normalEditorHeight - bitmapSize.iHeight ) ; |
|
1161 iBitmap->SetExtent( bitmapTl, bitmapSize ) ; |
|
1162 } |
|
1163 if (iCaption) |
|
1164 { |
|
1165 TPoint capPos=rect.iTl; |
|
1166 TSize capSize=iCaption->MinimumSize(); |
|
1167 // For SERIES60 the caption is aligned to the the right if the available space |
|
1168 if ( iCaptionWidth > capSize.iWidth ) // & it should be! |
|
1169 capPos.iX += ( iCaptionWidth - capSize.iWidth - KCapCCenterSpacing ) ; |
|
1170 |
|
1171 if ( capSize.iHeight > normalEditorHeight ) |
|
1172 capSize.iHeight = normalEditorHeight ; |
|
1173 //capPos.iY += ( normalEditorHeight - capSize.iHeight /*- KCapCVertCaptionOffset*/ ) ; |
|
1174 |
|
1175 iCaption->SetExtent(capPos,capSize); |
|
1176 if (iCapCFlags&EExtraAscent) |
|
1177 rect.iTl.iY+=KCapCExtraAscent; |
|
1178 } |
|
1179 rect.iTl.iX+=iCaptionWidth; |
|
1180 |
|
1181 if ((iCapCFlags&EUsesEars) && !(iCapCFlags&ETrailerAfterEar)) |
|
1182 rect.iBr.iX-=(KCapCEarWidth+KCapCEarSpacing); |
|
1183 |
|
1184 if (iTrailer) |
|
1185 { |
|
1186 TSize trailSize=iTrailer->MinimumSize(); |
|
1187 TInt trailPosX=rect.iBr.iX-trailSize.iWidth; |
|
1188 TInt trailPosY=rect.iTl.iY+KTrailCVertCaptionOffset; |
|
1189 if(trailSize.iHeight+trailPosY>Rect().iBr.iY) |
|
1190 trailSize.iHeight=Rect().iBr.iY-trailPosY; |
|
1191 iTrailer->SetExtent(TPoint(trailPosX,trailPosY),trailSize); |
|
1192 rect.iBr.iX=trailPosX-KControlTrailerSpacing; |
|
1193 } |
|
1194 if ((iCapCFlags&EUsesEars) && (iCapCFlags&ETrailerAfterEar)) |
|
1195 rect.iBr.iX-=(KCapCEarWidth+KCapCEarSpacing); |
|
1196 |
|
1197 if(iCapCFlags&EIfTooBigCtlStaysMinHeight && rect.Height()>iControl->MinimumSize().iHeight) |
|
1198 rect.iBr.iY=rect.iTl.iY+iControl->MinimumSize().iHeight; |
|
1199 if(iCapCFlags&EIfTooBigCtlStaysMinWidth && rect.Width()>iControl->MinimumSize().iWidth) |
|
1200 rect.iBr.iX=rect.iTl.iX+iControl->MinimumSize().iWidth; |
|
1201 iControl->SetRect(rect); |
|
1202 |
|
1203 } |
|
1204 |
|
1205 |
|
1206 TInt CEikCaptionedControl::WidthForEars(TInt aWidthRemaining) const |
|
1207 { |
|
1208 TInt earWidth=0; |
|
1209 if(iCapCFlags&EUsesEars) |
|
1210 { |
|
1211 const TInt earAndMarginWidth=KCapCEarWidth+KCapCEarSpacing; |
|
1212 if(iTrailer || iCaption) |
|
1213 { |
|
1214 if(aWidthRemaining>(2+(iTrailer?1:0)+(iCaption?1:0))*earAndMarginWidth) |
|
1215 earWidth=earAndMarginWidth; |
|
1216 else if(aWidthRemaining>(2+(iTrailer?1:0)+(iCaption?1:0))*KCapCEarWidth) |
|
1217 earWidth=KCapCEarWidth; |
|
1218 } |
|
1219 else |
|
1220 earWidth=Min(aWidthRemaining/2,earAndMarginWidth); |
|
1221 } |
|
1222 return earWidth; |
|
1223 } |
|
1224 |
|
1225 |
|
1226 void CEikCaptionedControl::SquashComponents() |
|
1227 { |
|
1228 TRect rect=Rect(); |
|
1229 // Shrink for Separator |
|
1230 if (iCapCFlags&ESeparatorAfter) |
|
1231 rect.iBr.iY-=KCapCSeparatorAfterSpace; |
|
1232 |
|
1233 // Space required before the left of the control rect |
|
1234 TInt desiredLeft=iHorzEdgeSpacing; |
|
1235 if(iCaption) |
|
1236 desiredLeft+=iCaption->MinimumSize().iWidth+KCapCCenterSpacing; |
|
1237 if ( iBitmap ) |
|
1238 desiredLeft += iBitmap->MinimumSize().iWidth ; // + additional separation? |
|
1239 |
|
1240 // Space required after the right of the control rect |
|
1241 TInt desiredRight=iHorzEdgeSpacing; |
|
1242 if(iTrailer) |
|
1243 desiredRight+=iTrailer->MinimumSize().iWidth+KControlTrailerSpacing; |
|
1244 |
|
1245 // Decide on space for the control rect. |
|
1246 TInt controlWidth=0; |
|
1247 TInt desiredControl=0; |
|
1248 TInt widthRemaining=rect.Width(); |
|
1249 if(iControl) |
|
1250 { |
|
1251 desiredControl=iControl->MinimumSize().iWidth; |
|
1252 if(iCapCFlags&EIfTooSmallCtlGetsWidthFirst) |
|
1253 controlWidth=Min(desiredControl,widthRemaining); |
|
1254 else if(iCapCFlags&EIfTooSmallCtlGetsEqualShareOfWidth) |
|
1255 controlWidth=ScaledSubLength(widthRemaining,desiredControl,MinimumSize().iWidth); |
|
1256 else |
|
1257 controlWidth=Max(0,widthRemaining-(desiredLeft+desiredRight+2*(KCapCEarWidth+KCapCEarSpacing))); |
|
1258 widthRemaining-=controlWidth; |
|
1259 } |
|
1260 |
|
1261 // Decide if there is space for ears with margins, ears only, or no ears. |
|
1262 TInt earWidth=WidthForEars(widthRemaining); |
|
1263 widthRemaining-=2*earWidth; |
|
1264 |
|
1265 // Space assigned for before the left of the control rect |
|
1266 TInt actualLeft=0; |
|
1267 actualLeft=ScaledSubLength(widthRemaining,desiredLeft,desiredLeft+desiredRight); |
|
1268 // Space assigned for after the right of the control rect |
|
1269 TInt actualRight=widthRemaining-actualLeft; |
|
1270 TInt actualCaption = actualLeft; |
|
1271 |
|
1272 // Check in debug builds that actualRight is the same (+/-1) to what would be calculated |
|
1273 __ASSERT_DEBUG(((desiredRight==0)||(ScaledSubLength(widthRemaining,desiredRight,desiredLeft+desiredRight)<actualRight+2 |
|
1274 || ScaledSubLength(widthRemaining,desiredRight,desiredLeft+desiredRight)>actualRight-2)), |
|
1275 User::Invariant()); // check our calculations! |
|
1276 |
|
1277 // Decide if there is room in actualLeft for caption only, or caption with margins. |
|
1278 if ( iBitmap ) |
|
1279 { |
|
1280 // slip the bitmap in before the caption. |
|
1281 TPoint bitmapTl = rect.iTl ; |
|
1282 // Offset from top of rectangle in here ( bitmapTl.iY += vertical offset ) |
|
1283 TSize bitmapSize = iBitmap->MinimumSize() ; |
|
1284 if ( (bitmapSize.iHeight + bitmapTl.iY) > Rect().iBr.iY ) |
|
1285 bitmapSize.iHeight = (Rect().iBr.iY - bitmapTl.iY ) ; |
|
1286 iBitmap->SetExtent( bitmapTl, bitmapSize ) ; |
|
1287 actualCaption = Max(0, actualLeft-bitmapSize.iWidth); |
|
1288 } |
|
1289 |
|
1290 if(iCaption) |
|
1291 { |
|
1292 TRect captionRect=rect; |
|
1293 captionRect.iTl.iY+=KCapCVertCaptionOffset; |
|
1294 captionRect.iTl.iX+=actualLeft-actualCaption; |
|
1295 captionRect.iBr.iX=captionRect.iTl.iX+actualCaption; |
|
1296 if (iCapCFlags&EExtraAscent) |
|
1297 rect.iTl.iY+=KCapCExtraAscent; |
|
1298 |
|
1299 if(actualLeft>2*(KCapCCenterSpacing+iHorzEdgeSpacing)) |
|
1300 { |
|
1301 captionRect.iTl.iX+=iHorzEdgeSpacing; |
|
1302 captionRect.iBr.iX-=KCapCCenterSpacing; |
|
1303 } |
|
1304 const TSize capMin=iCaption->MinimumSize(); |
|
1305 iCaption->SetExtent(captionRect.iTl,TSize(Min(captionRect.Width(),capMin.iWidth) |
|
1306 ,Min(captionRect.Height(),iCaption->MinimumSize().iHeight))); |
|
1307 } |
|
1308 |
|
1309 // Decide if there is room in actualRight for trailer only, or trailer with margins. |
|
1310 if(iTrailer) |
|
1311 { |
|
1312 TInt leftAdjust=0; |
|
1313 TInt rightAdjust=0; |
|
1314 TRect trailerRect=rect; |
|
1315 trailerRect.iTl.iX+=actualLeft+controlWidth+(iCapCFlags&EUsesEars ? earWidth : 0); |
|
1316 trailerRect.iTl.iY+=KTrailCVertCaptionOffset; |
|
1317 |
|
1318 if(actualRight>2*(iHorzEdgeSpacing+KControlTrailerSpacing)) |
|
1319 { |
|
1320 if(iCapCFlags&ETrailerAfterEar) |
|
1321 { |
|
1322 leftAdjust=KControlTrailerSpacing+earWidth; |
|
1323 rightAdjust=iHorzEdgeSpacing; |
|
1324 } |
|
1325 else |
|
1326 { |
|
1327 rightAdjust=earWidth+iHorzEdgeSpacing; |
|
1328 leftAdjust=KControlTrailerSpacing; |
|
1329 } |
|
1330 } |
|
1331 else |
|
1332 { |
|
1333 if(iCapCFlags&ETrailerAfterEar) |
|
1334 leftAdjust=earWidth; |
|
1335 else |
|
1336 rightAdjust=earWidth; |
|
1337 } |
|
1338 trailerRect.iTl.iX+=leftAdjust; |
|
1339 trailerRect.iBr.iX-=rightAdjust; |
|
1340 iTrailer->SetExtent(trailerRect.iTl,TSize(trailerRect.Width(), |
|
1341 Min(trailerRect.Height(),iTrailer->MinimumSize().iHeight))); |
|
1342 } |
|
1343 // Position and set the controls space |
|
1344 TRect controlRect=rect; |
|
1345 controlRect.iTl.iX+=actualLeft+earWidth; |
|
1346 controlRect.iBr.iX-=(actualRight+earWidth); |
|
1347 if(iCapCFlags&EIfTooBigCtlStaysMinHeight && controlRect.Height()>iControl->MinimumSize().iHeight) |
|
1348 controlRect.iBr.iY=controlRect.iTl.iY+iControl->MinimumSize().iHeight; |
|
1349 iControl->SetRect(controlRect); |
|
1350 |
|
1351 } |
|
1352 |
|
1353 |
|
1354 |
|
1355 /** |
|
1356 * Sets the flags, aFlags, (see TSpaceSharingFlags), which determine |
|
1357 * the way space is distributed if the captioned control is given too |
|
1358 * much or too little space, relative to its minimum size. |
|
1359 * |
|
1360 */ |
|
1361 EXPORT_C void CEikCaptionedControl::SetSpaceSharingFlags(TInt aFlags) |
|
1362 { |
|
1363 iCapCFlags|=aFlags; |
|
1364 } |
|
1365 |
|
1366 |
|
1367 static TInt IdleCallback(TAny *aAny) |
|
1368 { |
|
1369 CIdleCallbackData *data = (CIdleCallbackData*)aAny; |
|
1370 CEikCapCExtension *ext = data->iExt; |
|
1371 CEikCaptionedControl *ctrl = data->iCtrl; |
|
1372 |
|
1373 CEikEdwin *edwin = (CEikEdwin*)ctrl->iControl; |
|
1374 ctrl->DrawNow(); |
|
1375 TInt textLength = edwin->TextLength(); |
|
1376 TRAP_IGNORE ( edwin->SetCursorPosL( (textLength>=0 ? textLength : 0), EFalse) ); |
|
1377 delete ext->iIdle; |
|
1378 ext->iIdle = NULL; |
|
1379 delete data; |
|
1380 ext->iIdleData = NULL; |
|
1381 return EFalse; |
|
1382 } |
|
1383 |
|
1384 void CEikCaptionedControl::ScrollBackEditor() |
|
1385 { |
|
1386 // |
|
1387 // For long single-line edwin, scroll horizontally to show beginning of the edwin |
|
1388 // when focus changes away from the edwin. |
|
1389 // |
|
1390 if ( iIsEditable && ControlIsAnEdwin(iControlType) ) |
|
1391 { |
|
1392 delete iExtension->iIdle; |
|
1393 delete iExtension->iIdleData; |
|
1394 iExtension->iIdleData = new (ELeave) CIdleCallbackData; |
|
1395 iExtension->iIdleData->iCtrl = this; |
|
1396 iExtension->iIdleData->iExt = iExtension; |
|
1397 iExtension->iIdle = CIdle::NewL(0); |
|
1398 iExtension->iIdle->Start(TCallBack(&IdleCallback, iExtension->iIdleData)); |
|
1399 } |
|
1400 } |
|
1401 |
|
1402 EXPORT_C void CEikCaptionedControl::FocusChanged(TDrawNow aDrawNow) |
|
1403 { |
|
1404 // Only form controls need to adapt animation to focus changes. |
|
1405 if( iExtension->iAnimation && iIsFormControl ) |
|
1406 { |
|
1407 // Pause animation when losing focus (other states ignored) |
|
1408 if( !IsFocused() ) |
|
1409 { |
|
1410 iExtension->iAnimation->Pause(); |
|
1411 } |
|
1412 else if( iIsCurrentLine && !iIsEditable ) // Current and in view mode |
|
1413 { |
|
1414 CAknAppUi* aui = static_cast<CAknAppUi*>(CEikonEnv::Static()->AppUi()); |
|
1415 if( aui->IsForeground() ) |
|
1416 { |
|
1417 iExtension->iAnimation->Play(); |
|
1418 } |
|
1419 } |
|
1420 } |
|
1421 |
|
1422 TBool focused=IsFocused(); |
|
1423 |
|
1424 if ( iIsFormControl ) |
|
1425 { |
|
1426 // this bit can't be done in Draw() because that is a const function. |
|
1427 // It shouldn't be done here either because it can leave but... |
|
1428 TRgb brushColor; |
|
1429 TRgb textColor; |
|
1430 |
|
1431 if ( iIsCurrentLine && !iIsEditable) |
|
1432 { |
|
1433 brushColor = AKN_LAF_COLOR( KViewHighlightColor ) ; |
|
1434 } |
|
1435 else |
|
1436 { |
|
1437 brushColor = ( iEikonEnv->ControlColor( EColorWindowBackground, *this ) ) ; |
|
1438 } |
|
1439 TRAP_IGNORE( |
|
1440 { |
|
1441 SetElementBrushColorsL( brushColor ); |
|
1442 SetElementTextColorsL( textColor ); |
|
1443 }) |
|
1444 |
|
1445 // as focused has changed, need to layout the contained controls |
|
1446 // all over again, to ensure that the highlight text colours are correct |
|
1447 // Anyway, don't do this unless activated |
|
1448 if (IsReadyToDraw()) |
|
1449 PositionFormComponents(); |
|
1450 |
|
1451 if (iIsEditable) |
|
1452 { |
|
1453 SetPressedDownState( EFalse ); |
|
1454 |
|
1455 #if defined( RD_SCALABLE_UI_V2) |
|
1456 if( AknLayoutUtils::PenEnabled() ) |
|
1457 { |
|
1458 if(focused && ControlIsAMfne(iControlType)) |
|
1459 { |
|
1460 CEikMfne* mfne = static_cast<CEikMfne*>(iControl); |
|
1461 mfne->SetFeature( CEikMfne::EFingerSupport, CEikMfne::EnableWithAllHighlight ); |
|
1462 } |
|
1463 } |
|
1464 #endif //if defined( RD_SCALABLE_UI_V2) |
|
1465 iControl->SetFocus(focused,aDrawNow); |
|
1466 } |
|
1467 |
|
1468 } |
|
1469 else |
|
1470 { |
|
1471 iControl->SetFocus(focused,aDrawNow); |
|
1472 if (iCaption) |
|
1473 { |
|
1474 CEikLabel::TTextEmphasis emphasis=CEikLabel::EFullEmphasis; |
|
1475 if (!focused) |
|
1476 emphasis=(iCapCFlags&ECurrent? CEikLabel::EPartialEmphasis: CEikLabel::ENoEmphasis); |
|
1477 iCaption->SetEmphasis(emphasis); |
|
1478 } |
|
1479 } |
|
1480 |
|
1481 |
|
1482 if (aDrawNow && iCapCFlags&EUsesEars && IsReadyToDraw()) |
|
1483 DrawEarsNow(EBothEars); |
|
1484 } |
|
1485 |
|
1486 |
|
1487 |
|
1488 void CEikCaptionedControl::DrawEarsNow(TWhichEars aEar) const |
|
1489 { |
|
1490 ActivateGc(); |
|
1491 DrawEars(aEar); |
|
1492 DeactivateGc(); |
|
1493 } |
|
1494 |
|
1495 void CEikCaptionedControl::DrawEars(TWhichEars aEar) const |
|
1496 { |
|
1497 if (aEar&ELeftEar) |
|
1498 DrawSingleEar(ELeftEar,iCapCFlags&ELeftEarDown); |
|
1499 if (aEar&ERightEar) |
|
1500 DrawSingleEar(ERightEar,iCapCFlags&ERightEarDown); |
|
1501 } |
|
1502 |
|
1503 void CEikCaptionedControl::DrawSingleEar(TWhichEars /*aEar*/,TBool /*aPressed*/) const |
|
1504 { |
|
1505 // not needed in S60 |
|
1506 } |
|
1507 |
|
1508 TRect CEikCaptionedControl::EarRect(TWhichEars /*aEar*/) const |
|
1509 { |
|
1510 return(TRect(0,0,0,0)); // not needed in S60 |
|
1511 } |
|
1512 |
|
1513 EXPORT_C TInt CEikCaptionedControl::CountComponentControls() const |
|
1514 { |
|
1515 CCoeControl* controls[] = |
|
1516 { |
|
1517 iBitmap, |
|
1518 iCaption, |
|
1519 iControl, |
|
1520 iTrailer, |
|
1521 iHighlightControl, |
|
1522 iExtension->iIndicator, |
|
1523 iExtension->iIndicator2 |
|
1524 }; |
|
1525 |
|
1526 TInt count = 0; |
|
1527 for (TUint ii=0; ii<sizeof(controls)/sizeof(CCoeControl*); ii++) |
|
1528 { |
|
1529 if (controls[ii]) |
|
1530 { |
|
1531 count++; |
|
1532 } |
|
1533 } |
|
1534 return count; |
|
1535 } |
|
1536 |
|
1537 |
|
1538 EXPORT_C CCoeControl* CEikCaptionedControl::ComponentControl(TInt aIndex) const |
|
1539 { |
|
1540 CCoeControl* controls[] = |
|
1541 { |
|
1542 iBitmap, |
|
1543 iCaption, |
|
1544 iControl, |
|
1545 iTrailer, |
|
1546 iHighlightControl, |
|
1547 iExtension->iIndicator, |
|
1548 iExtension->iIndicator2 |
|
1549 }; |
|
1550 |
|
1551 for (TUint ii=0; ii<sizeof(controls)/sizeof(CCoeControl*); ii++) |
|
1552 if (controls[ii] && aIndex-- == 0) |
|
1553 return controls[ii]; |
|
1554 return NULL; |
|
1555 } |
|
1556 |
|
1557 |
|
1558 EXPORT_C void CEikCaptionedControl::Draw(const TRect& aRect) const |
|
1559 { |
|
1560 if (iIsFormControl ) |
|
1561 DrawAsForm( aRect ); |
|
1562 else |
|
1563 DrawAsEikonDialog( aRect ); |
|
1564 } |
|
1565 |
|
1566 void CEikCaptionedControl::DrawAsForm( const TRect& aRect ) const |
|
1567 { |
|
1568 |
|
1569 CWindowGc& gc=SystemGc(); |
|
1570 |
|
1571 gc.SetPenStyle(CGraphicsContext::ENullPen); |
|
1572 if ( iRefresh ) |
|
1573 { |
|
1574 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ) ; |
|
1575 gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) ) ; |
|
1576 } |
|
1577 |
|
1578 if ( iCaption ) |
|
1579 { |
|
1580 // Draw ':' for edit indicator. ( Skin independant ) |
|
1581 if ( iIsEditable && iIsCurrentLine ) |
|
1582 iCaption->EnableColon( ETrue ) ; |
|
1583 else |
|
1584 iCaption->EnableColon( EFalse ) ; |
|
1585 } |
|
1586 |
|
1587 if (iHighlightControl) |
|
1588 STATIC_CAST(CEikCaptionedControlFormHighlightLine*,iHighlightControl)->SetTopOrBottom(CEikCaptionedControlFormHighlightLine::EUnset); |
|
1589 |
|
1590 // assumed that CalculateNumberOfLinesForControl has been called |
|
1591 if (!iNumberOfLines) |
|
1592 return; |
|
1593 |
|
1594 if( ControlIsASecretEditor(iControlType) && iIsCurrentLine ) |
|
1595 { |
|
1596 CEikSecretEditor* edwin=(CEikSecretEditor*)iControl; |
|
1597 edwin->EnableCursor( ETrue ); |
|
1598 } |
|
1599 |
|
1600 if ( DrawingSkins() || iExtension->iAnimation ) |
|
1601 { |
|
1602 DrawAsSkinnedForm(gc, aRect); |
|
1603 return; |
|
1604 } |
|
1605 |
|
1606 if (iIsEditable && iIsCurrentLine ) |
|
1607 DrawAsFormInEditMode( aRect ); |
|
1608 else if (!iIsEditable && iIsCurrentLine ) |
|
1609 DrawAsFormInViewMode( aRect ); |
|
1610 else |
|
1611 DrawAsFormUnFocusedLine( aRect ); |
|
1612 } |
|
1613 |
|
1614 void CEikCaptionedControl::DrawAsFormInEditMode( const TRect& /*aRect*/ ) const |
|
1615 { |
|
1616 CWindowGc& gc=SystemGc(); |
|
1617 |
|
1618 gc.SetPenStyle(CGraphicsContext::ENullPen); |
|
1619 |
|
1620 if ( iRefresh ) |
|
1621 { |
|
1622 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ) ; |
|
1623 gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) ) ; |
|
1624 } |
|
1625 |
|
1626 if (iDialogPage&& iHighlightControl) |
|
1627 { |
|
1628 TInt height(Rect().Height()); |
|
1629 TBool top = iDialogPage->VisibleSizeOnPage(height,iControl); |
|
1630 if (height<Rect().Height()) |
|
1631 { |
|
1632 CEikCaptionedControlFormHighlightLine::TTopOrBottom topOrBottom = (top) ? CEikCaptionedControlFormHighlightLine::ETop : CEikCaptionedControlFormHighlightLine::EBottom; |
|
1633 TInt heightOfHighlight = STATIC_CAST(CEikCaptionedControlFormHighlightLine*,iHighlightControl)->HeightOfHighlight(topOrBottom); |
|
1634 // is off page, and needs a line drawing. |
|
1635 TRect controlRect = (top) |
|
1636 ? TRect |
|
1637 ( |
|
1638 TPoint(Rect().iTl.iX,Rect().iBr.iY-height), |
|
1639 TPoint(Rect().iBr.iX,Rect().iBr.iY-(height-heightOfHighlight)) |
|
1640 ) |
|
1641 : TRect |
|
1642 ( |
|
1643 TPoint(Rect().iTl.iX,Rect().iTl.iY+(height-heightOfHighlight)), |
|
1644 TPoint(Rect().iBr.iX,Rect().iTl.iY+height) |
|
1645 ); |
|
1646 iHighlightControl->SetRect(controlRect); |
|
1647 STATIC_CAST(CEikCaptionedControlFormHighlightLine*,iHighlightControl)->SetTopOrBottom(topOrBottom); |
|
1648 iHighlightControl->MakeVisible( ETrue ) ; |
|
1649 } |
|
1650 else // control rect is not visible |
|
1651 iHighlightControl->MakeVisible( EFalse ) ; |
|
1652 } |
|
1653 |
|
1654 TInt noLinesToDraw =iNumberOfLines-1; |
|
1655 if ( FormLayout() == CEikDialogPage::EDouble ) |
|
1656 ++noLinesToDraw; |
|
1657 TAknLayoutRect line3Rect; |
|
1658 line3Rect.LayoutRect |
|
1659 (Rect(), |
|
1660 AKN_LAYOUT_WINDOW_Form_data_field_elements_Line_3 |
|
1661 ( noLinesToDraw ) |
|
1662 ); |
|
1663 gc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
1664 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ) ; |
|
1665 gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) ) ; |
|
1666 gc.SetPenColor( line3Rect.Color() ) ; |
|
1667 gc.DrawRect(line3Rect.Rect()); |
|
1668 TAknLayoutRect line1Rect; |
|
1669 line1Rect.LayoutRect |
|
1670 (Rect(), |
|
1671 AKN_LAYOUT_WINDOW_Form_data_field_elements_Line_1 |
|
1672 ( noLinesToDraw ) |
|
1673 ); |
|
1674 gc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
1675 gc.SetBrushStyle( CGraphicsContext::ENullBrush ) ; |
|
1676 gc.SetPenColor( line1Rect.Color() ) ; |
|
1677 gc.DrawRect(line1Rect.Rect()); |
|
1678 TAknLayoutRect line2Rect; |
|
1679 line2Rect.LayoutRect |
|
1680 (Rect(), |
|
1681 AKN_LAYOUT_WINDOW_Form_data_field_elements_Line_2 |
|
1682 ); |
|
1683 gc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
1684 gc.SetBrushStyle( CGraphicsContext::ENullBrush ) ; |
|
1685 gc.SetPenColor( line2Rect.Color() ) ; |
|
1686 gc.DrawRect(line2Rect.Rect()); |
|
1687 } |
|
1688 |
|
1689 |
|
1690 void CEikCaptionedControl::DrawAsFormInViewMode( const TRect& /*aRect*/ ) const |
|
1691 { |
|
1692 CWindowGc& gc=SystemGc(); |
|
1693 |
|
1694 gc.SetPenStyle(CGraphicsContext::ENullPen); |
|
1695 |
|
1696 if ( iRefresh ) |
|
1697 { |
|
1698 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ) ; |
|
1699 gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) ) ; |
|
1700 } |
|
1701 |
|
1702 // This gives the correct Rect for using the Layout functions |
|
1703 TRect viewRect=ViewRect(); |
|
1704 |
|
1705 TAknLayoutRect line1Rect; |
|
1706 line1Rect.LayoutRect( viewRect, AKN_LAYOUT_WINDOW_List_pane_highlight_graphics__various__Line_1 (viewRect) ); |
|
1707 |
|
1708 /* This is in view mode, and is the current line |
|
1709 Do not clear the bit which will be recoloured in the next |
|
1710 draw, Instead, alter the GC drawing region to prevent this |
|
1711 */ |
|
1712 TRegionFix<4> region(Rect()); |
|
1713 region.SubRect(line1Rect.Rect()); |
|
1714 for (TInt i=0;i< region.Count();i++) |
|
1715 gc.Clear(region[i]); |
|
1716 |
|
1717 gc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
1718 gc.SetPenColor(line1Rect.Color()); |
|
1719 gc.SetBrushStyle( CGraphicsContext::ENullBrush ) ; |
|
1720 TRect rect=line1Rect.Rect(); |
|
1721 gc.DrawRect(rect); |
|
1722 |
|
1723 TAknLayoutRect line2Rect; |
|
1724 line2Rect.LayoutRect |
|
1725 ( |
|
1726 viewRect, |
|
1727 AKN_LAYOUT_WINDOW_List_pane_highlight_graphics__various__Line_2 (viewRect) |
|
1728 ); |
|
1729 line2Rect.DrawRect(gc); |
|
1730 |
|
1731 gc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
1732 gc.SetPenColor(iEikonEnv->ControlColor(EColorDialogText,*this)); |
|
1733 gc.SetBrushStyle( CGraphicsContext::ENullBrush ) ; |
|
1734 |
|
1735 TAknLayoutId layout; |
|
1736 iAvkonEnv->GetCurrentLayoutId( layout ); |
|
1737 |
|
1738 if ( layout == EAknLayoutIdAPAC ) |
|
1739 { |
|
1740 gc.DrawLine(TPoint(iVerticalLineXPosition,Rect().iTl.iY), |
|
1741 TPoint(iVerticalLineXPosition,Rect().iTl.iY+1)); |
|
1742 } |
|
1743 |
|
1744 else // ELAF |
|
1745 { |
|
1746 gc.DrawLine(TPoint(iVerticalLineXPosition,Rect().iTl.iY), |
|
1747 TPoint(iVerticalLineXPosition,Rect().iTl.iY+2)); |
|
1748 } |
|
1749 |
|
1750 gc.DrawLine(TPoint(iVerticalLineXPosition,Rect().iBr.iY-1), |
|
1751 TPoint(iVerticalLineXPosition,Rect().iBr.iY+1)); |
|
1752 } |
|
1753 |
|
1754 void CEikCaptionedControl::DrawAsFormUnFocusedLine( const TRect& /*aRect*/ ) const |
|
1755 { |
|
1756 CWindowGc& gc=SystemGc(); |
|
1757 |
|
1758 gc.SetPenStyle(CGraphicsContext::ENullPen); |
|
1759 |
|
1760 if ( iRefresh ) |
|
1761 { |
|
1762 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ) ; |
|
1763 gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) ) ; |
|
1764 } |
|
1765 |
|
1766 gc.SetPenStyle(CGraphicsContext::ENullPen); |
|
1767 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ) ; |
|
1768 gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) ) ; |
|
1769 |
|
1770 gc.DrawRect(Rect()); // clear region |
|
1771 |
|
1772 //list_single_heading_pane |
|
1773 /* |
|
1774 offset of datapane is 1,7. I'm afraid some mathematics here is unavoidable |
|
1775 In fact I will hard code this until later. |
|
1776 */ |
|
1777 // from LAF, color 210, position 50 - iXOffsetForDataPaneInEditMode |
|
1778 gc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
1779 gc.SetPenColor(iEikonEnv->ControlColor(EColorDialogText,*this)); |
|
1780 gc.SetBrushStyle( CGraphicsContext::ENullBrush ) ; |
|
1781 gc.DrawLine(TPoint(iVerticalLineXPosition,Rect().iTl.iY), |
|
1782 TPoint(iVerticalLineXPosition,Rect().iBr.iY+1)); |
|
1783 // CEikCaptionedControl* visibleBelow=0; (NOT USED) |
|
1784 |
|
1785 if (iDialogPage) |
|
1786 { |
|
1787 // visibleBelow=iDialogPage->FindNextControlOnPageWithHeight(EFalse,this); |
|
1788 |
|
1789 //draw separator line unless This control is at or off the top of the page. |
|
1790 TBool atTopOfPage = (iDialogPage && iDialogPage->IsAtOrOffTopOfPage(iControl) ); |
|
1791 if (HasSeparator() && !atTopOfPage) |
|
1792 DrawFormSeparator( gc ); |
|
1793 } |
|
1794 } |
|
1795 |
|
1796 |
|
1797 // --------------------------------------------------------------------------- |
|
1798 // CEikCaptionedControl::TextColorIndex |
|
1799 // --------------------------------------------------------------------------- |
|
1800 // |
|
1801 TAknsQsnTextColorsIndex CEikCaptionedControl::TextColorIndex() const |
|
1802 { |
|
1803 TAknsQsnTextColorsIndex colorIndex = EAknsCIQsnTextColorsCG8; |
|
1804 |
|
1805 // Note control doesn't use highlight text color |
|
1806 if ( iControlType != EAknCtNote ) |
|
1807 { |
|
1808 if ( iIsCurrentLine && iDialogPage->HighlightVisible() ) |
|
1809 { |
|
1810 colorIndex = EAknsCIQsnTextColorsCG10; |
|
1811 } |
|
1812 } |
|
1813 |
|
1814 return colorIndex; |
|
1815 } |
|
1816 |
|
1817 |
|
1818 void CEikCaptionedControl::DrawAsEikonDialog( const TRect& aRect ) const |
|
1819 { |
|
1820 CWindowGc& gc=SystemGc(); |
|
1821 gc.SetPenStyle(CGraphicsContext::ENullPen); |
|
1822 |
|
1823 if (iHighlightControl) |
|
1824 STATIC_CAST(CEikCaptionedControlFormHighlightLine*,iHighlightControl)->SetTopOrBottom(CEikCaptionedControlFormHighlightLine::EUnset); |
|
1825 |
|
1826 if ( iRefresh ) |
|
1827 { |
|
1828 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ) ; |
|
1829 gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) ) ; |
|
1830 } |
|
1831 |
|
1832 |
|
1833 TRect redrawRect=Rect(); |
|
1834 redrawRect.Intersection(aRect); |
|
1835 |
|
1836 /* |
|
1837 * |
|
1838 * FIX TSW JTON-6HGAND - see also eikdpage.cpp |
|
1839 * |
|
1840 *if (!iExtension->iDrawNoWhiteBackground) |
|
1841 * gc.DrawRect(redrawRect); |
|
1842 * |
|
1843 * Most likely other places using gc.Clear() ( or gc.DrawRect() as 'clear' |
|
1844 * should be fixed also. |
|
1845 */ |
|
1846 |
|
1847 if (iCapCFlags&ESeparatorAfter) |
|
1848 { |
|
1849 TRect rect(Rect()); |
|
1850 TPoint separatorStartPt(rect.iTl.iX+iHorzEdgeSpacing/2,rect.iBr.iY-1); |
|
1851 TPoint separatorEndPt(separatorStartPt.iX+(iFullWidth-iHorzEdgeSpacing), separatorStartPt.iY); |
|
1852 gc.SetPenStyle(CGraphicsContext::ESolidPen); |
|
1853 gc.SetPenColor(iEikonEnv->ControlColor(EColorWindowText, *this)); |
|
1854 gc.DrawLine(separatorStartPt, separatorEndPt); |
|
1855 }; |
|
1856 |
|
1857 if (iCapCFlags&EUsesEars) |
|
1858 DrawEars(EBothEars); |
|
1859 } |
|
1860 |
|
1861 /* |
|
1862 * Method to return T/F whether this CEikCaptionedControl has a separator. |
|
1863 */ |
|
1864 TBool CEikCaptionedControl::HasSeparator() const |
|
1865 { |
|
1866 return iCapCFlags & ESeparatorAfter; |
|
1867 } |
|
1868 |
|
1869 |
|
1870 EXPORT_C TKeyResponse CEikCaptionedControl::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
1871 { |
|
1872 if ( !iIsFormControl) |
|
1873 return iControl->OfferKeyEventL(aKeyEvent,aType); |
|
1874 else if ( iIsFormControl && iIsEditable ) |
|
1875 { |
|
1876 TKeyResponse retVal ; |
|
1877 retVal = iControl->OfferKeyEventL( aKeyEvent, aType ) ; |
|
1878 return retVal ; |
|
1879 } |
|
1880 else |
|
1881 return EKeyWasNotConsumed ; |
|
1882 } |
|
1883 |
|
1884 EXPORT_C TCoeInputCapabilities CEikCaptionedControl::InputCapabilities() const |
|
1885 { |
|
1886 return TCoeInputCapabilities(TCoeInputCapabilities::ENone, NULL, CONST_CAST(CEikCaptionedControl*, this)); |
|
1887 } |
|
1888 |
|
1889 EXPORT_C void CEikCaptionedControl::SetDimmed(TBool aDimmed) |
|
1890 { |
|
1891 CCoeControl::SetDimmed(aDimmed); |
|
1892 if (iControl && iControl->IsVisible()) |
|
1893 { |
|
1894 iControl->SetDimmed(aDimmed); |
|
1895 } |
|
1896 if (iCaption) |
|
1897 { |
|
1898 iCaption->SetDimmed(aDimmed); |
|
1899 } |
|
1900 if (iTrailer) |
|
1901 { |
|
1902 iTrailer->SetDimmed(aDimmed); |
|
1903 } |
|
1904 } |
|
1905 |
|
1906 EXPORT_C void* CEikCaptionedControl::ExtensionInterface( TUid /*aInterface*/ ) |
|
1907 { |
|
1908 return NULL; |
|
1909 } |
|
1910 |
|
1911 EXPORT_C void CEikCaptionedControl::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
1912 { |
|
1913 if (!IsNonFocusing()) |
|
1914 { |
|
1915 TWhichEars ear=ENoEar; |
|
1916 if (aPointerEvent.iType!=TPointerEvent::EButton1Down) |
|
1917 { |
|
1918 if (iCapCFlags&ELeftEarGrab) |
|
1919 ear=ELeftEar; |
|
1920 else if (iCapCFlags&ERightEarGrab) |
|
1921 ear=ERightEar; |
|
1922 if (ear) |
|
1923 { |
|
1924 TInt oldDrawFlags=iCapCFlags&(ELeftEarDown|ERightEarDown); |
|
1925 if (aPointerEvent.iType==TPointerEvent::EButton1Up) |
|
1926 iCapCFlags&=(~KDynamicEarMask); |
|
1927 else |
|
1928 { |
|
1929 iCapCFlags&=(~(ELeftEarDown|ERightEarDown)); |
|
1930 if (EarRect(ear).Contains(aPointerEvent.iPosition)) |
|
1931 { |
|
1932 FireEarL(ear, KCapCEarRepeat); |
|
1933 return; |
|
1934 } |
|
1935 } |
|
1936 if (oldDrawFlags!=(iCapCFlags&(ELeftEarDown|ERightEarDown))) |
|
1937 DrawEarsNow(ear); |
|
1938 return; |
|
1939 } |
|
1940 } |
|
1941 else if (iCapCFlags&EUsesEars) |
|
1942 { |
|
1943 iCapCFlags&=(~KDynamicEarMask); |
|
1944 if (EarRect(ELeftEar).Contains(aPointerEvent.iPosition)) |
|
1945 ear=ELeftEar; |
|
1946 else if (EarRect(ERightEar).Contains(aPointerEvent.iPosition)) |
|
1947 ear=ERightEar; |
|
1948 if (ear) |
|
1949 { |
|
1950 FireEarL(ear, KCapCInitialEarRepeat); |
|
1951 return; |
|
1952 } |
|
1953 } |
|
1954 } |
|
1955 if (iIsFormControl) |
|
1956 { |
|
1957 if ( PressedDownState()&& |
|
1958 aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
1959 { |
|
1960 SetPressedDownState( ETrue ); |
|
1961 DrawDeferred(); |
|
1962 } |
|
1963 else if(aPointerEvent.iType == TPointerEvent::EButton1Up) |
|
1964 { |
|
1965 SetPressedDownState( EFalse ); |
|
1966 DrawDeferred(); |
|
1967 } |
|
1968 } |
|
1969 |
|
1970 if ( !iIsEditable && (ControlIsAnEdwin(iControlType) || ControlIsAMfne(iControlType)) |
|
1971 &&( iDialogPage && CEikDialogPage::EDouble == iDialogPage->FormLayout() )) |
|
1972 { |
|
1973 return; |
|
1974 } |
|
1975 |
|
1976 CCoeControl::HandlePointerEventL(aPointerEvent); |
|
1977 |
|
1978 if ( iExtension ) |
|
1979 { |
|
1980 iExtension->SimulatePointerEventToControlL( aPointerEvent ); |
|
1981 } |
|
1982 } |
|
1983 |
|
1984 void CEikCaptionedControl::FireEarL(TWhichEars aEar, TInt aEarRepeat) |
|
1985 { |
|
1986 Window().RequestPointerRepeatEvent(aEarRepeat, EarRect(aEar)); |
|
1987 TKeyEvent key; |
|
1988 key.iModifiers=0; |
|
1989 if (aEar==ELeftEar) |
|
1990 { |
|
1991 key.iCode=EKeyLeftArrow; |
|
1992 iCapCFlags|=ELeftEarDown|ELeftEarGrab; |
|
1993 } |
|
1994 else |
|
1995 { |
|
1996 key.iCode=EKeyRightArrow; |
|
1997 iCapCFlags|=ERightEarDown|ERightEarGrab; |
|
1998 } |
|
1999 DrawEarsNow(aEar); |
|
2000 iControl->OfferKeyEventL(key,EEventKey); |
|
2001 } |
|
2002 |
|
2003 EXPORT_C void CEikCaptionedControl::SetCaptionL(const TDesC& aText) |
|
2004 { |
|
2005 ConstructExtensionL() ; // One of several places where this is made |
|
2006 if (!iCaption) |
|
2007 { |
|
2008 // Retain a zero sized caption for formatting forms |
|
2009 iCaption=new(ELeave) CEikCapCLabel; |
|
2010 iCaption->SetNonFocusing(); |
|
2011 iCaption->SetFont( AknLayoutUtils::FontFromId( iCaptionFontId ) ) ; |
|
2012 delete iCaptionText; // get rid of old iCaptionText |
|
2013 iCaptionText=0; |
|
2014 iCaptionText = aText.AllocL(); |
|
2015 } |
|
2016 |
|
2017 if (iCaption->DrawableWindow() == NULL) |
|
2018 { |
|
2019 iCaption->SetContainerWindowL(*this); |
|
2020 iCaption->CopyControlContextFrom(this); |
|
2021 } |
|
2022 /* |
|
2023 Forms have truncated labels with elipses. |
|
2024 iCaption should reflect this data |
|
2025 iCaptionText should contain the whoel string. |
|
2026 */ |
|
2027 if (iIsFormControl) |
|
2028 DoFormCaptionSettingsL(aText); |
|
2029 else |
|
2030 iCaption->SetTextL(aText); |
|
2031 } |
|
2032 |
|
2033 EXPORT_C void CEikCaptionedControl::SetDrawNoWhiteBackground(TBool aEnabled) |
|
2034 { |
|
2035 iExtension->iDrawNoWhiteBackground = aEnabled; |
|
2036 } |
|
2037 |
|
2038 EXPORT_C void CEikCaptionedControl::SetTrailerL(const TDesC& aText) |
|
2039 { |
|
2040 if (!aText.Length()) |
|
2041 return; |
|
2042 if (!iTrailer) |
|
2043 { |
|
2044 iTrailer=new(ELeave) CEikLabel; |
|
2045 iTrailer->SetFont( AknLayoutUtils::FontFromId( iCaptionFontId ) ) ; |
|
2046 iTrailer->SetContainerWindowL(*this); |
|
2047 iTrailer->CopyControlContextFrom(this); |
|
2048 iTrailer->SetAllMarginsTo(1); |
|
2049 iTrailer->SetNonFocusing(); |
|
2050 } |
|
2051 iTrailer->SetTextL(aText); |
|
2052 } |
|
2053 |
|
2054 EXPORT_C void CEikCaptionedControl::SetCurrent(TBool aSelected) |
|
2055 { |
|
2056 SetCurrent( aSelected, ETrue ); |
|
2057 } |
|
2058 |
|
2059 EXPORT_C void CEikCaptionedControl::ConstructFromResourceL(TResourceReader& aReader) |
|
2060 { |
|
2061 TPtrC capTextTPtrC = aReader.ReadTPtrC(); |
|
2062 iCaptionText = capTextTPtrC.AllocL(); |
|
2063 SetCaptionL(capTextTPtrC); |
|
2064 iId=aReader.ReadInt16(); |
|
2065 TInt itemFlags=aReader.ReadInt32(); |
|
2066 TInt divider=itemFlags&EEikDlgItemSeparatorMask; |
|
2067 if (divider==EEikDlgItemSeparatorAfter) |
|
2068 { |
|
2069 iCapCFlags|=ESeparatorAfter; |
|
2070 SetCanDrawOutsideRect(); |
|
2071 } |
|
2072 iControl->CopyControlContextFrom(this); |
|
2073 iControl->ConstructFromResourceL(aReader); |
|
2074 |
|
2075 // For form items in SERIES60 the default is NOT to show the border |
|
2076 // Unfortunately we can't tell at this point whether that is the case so |
|
2077 // for the moment just remove the border completely |
|
2078 if ( itemFlags&EEikDlgItemNoBorder ) |
|
2079 { |
|
2080 ((CEikBorderedControl*)iControl)->SetBorder(TGulBorder::ENone); |
|
2081 SetExtraAscent(); |
|
2082 iCapCFlags|=ENoBorder ; |
|
2083 } |
|
2084 if (itemFlags&EEikDlgItemNonFocusing) |
|
2085 { |
|
2086 SetNonFocusing(); |
|
2087 iControl->SetNonFocusing(); |
|
2088 iCapCFlags&=(~EUsesEars); |
|
2089 } |
|
2090 else |
|
2091 { |
|
2092 __ASSERT_DEBUG(iId!=0, Panic(EEikDialogPanicFocusableLineWithIdZero)); |
|
2093 } |
|
2094 SetTrailerL(aReader.ReadTPtrC()); |
|
2095 if (itemFlags&EEikDlgItemLatent) |
|
2096 SetLatent(ETrue); |
|
2097 if (itemFlags&EEikDlgItemLglf) |
|
2098 iCapCFlags|=ELglf; |
|
2099 if (itemFlags&EEikDlgItemTakesEnterKey) |
|
2100 iCapCFlags|=ETakesEnterKey; |
|
2101 if (itemFlags&EEikDlgItemOfferAllHotKeys) |
|
2102 iCapCFlags|=EOfferAllHotKeys; |
|
2103 if (itemFlags&EEikDlgItemTrailerAfterEar) |
|
2104 iCapCFlags|=ETrailerAfterEar; |
|
2105 if(itemFlags&EEikDlgItemCtlMinHeightOrLess) |
|
2106 iCapCFlags|=EIfTooBigCtlStaysMinHeight; |
|
2107 if(itemFlags&EEikDlgItemCtlMinWidthOrLess) |
|
2108 iCapCFlags|=EIfTooBigCtlStaysMinWidth; |
|
2109 if(itemFlags&EEikDlgItemCtlGetsWidthFirst) |
|
2110 iCapCFlags|=EIfTooSmallCtlGetsWidthFirst; |
|
2111 else if(itemFlags&EEikDlgItemCtlSharesWidth) |
|
2112 iCapCFlags|=EIfTooSmallCtlGetsEqualShareOfWidth; |
|
2113 if (itemFlags&EEikDlgItemCtlRefusesStrecth) |
|
2114 iCapCFlags|=EIfTooSmallDontStrech; |
|
2115 |
|
2116 // Process bmpfile, bmpid, bmpmask from Resource File. |
|
2117 TPtrC16 bitmapFileName = aReader.ReadTPtrC() ; |
|
2118 TInt16 bitmapId = TInt16(aReader.ReadInt16()) ; |
|
2119 TInt16 bitmapMaskId = TInt16(aReader.ReadInt16()) ; |
|
2120 if ( bitmapFileName.Length() != 0 ) |
|
2121 SetBitmapFromFileL( bitmapFileName, bitmapId, bitmapMaskId ) ; |
|
2122 |
|
2123 // Process ToolTip |
|
2124 TPtrC16 toolTip = aReader.ReadTPtrC() ; |
|
2125 SetToolTipTextL( toolTip ) ; |
|
2126 |
|
2127 // Set the border spacing to the default value |
|
2128 SetVertEdgeSpacing( KCapCDefaultVertEdgeSpacing ) ; |
|
2129 SetHorzEdgeSpacing( KCapCDefaultHorzEdgeSpacing ) ; |
|
2130 |
|
2131 //Added to create new form box closer for edwins in forms. |
|
2132 if (!iHighlightControl) |
|
2133 { |
|
2134 iHighlightControl = new(ELeave) CEikCaptionedControlFormHighlightLine( *this ) ; |
|
2135 STATIC_CAST(CEikCaptionedControlFormHighlightLine*,iHighlightControl)->ConstructL() ; |
|
2136 } |
|
2137 ConstructExtensionL() ; |
|
2138 } |
|
2139 |
|
2140 |
|
2141 EXPORT_C void CEikCaptionedControl::SetBitmapFromFileL( const TDesC& aFilename,TInt aMainId,TInt aMaskId /*=-1*/ ) |
|
2142 { |
|
2143 if ( iBitmap ) |
|
2144 delete iBitmap; |
|
2145 iBitmap = 0; |
|
2146 |
|
2147 iBitmap = new ( ELeave ) CEikImage(); |
|
2148 iBitmap->CreatePictureFromFileL( aFilename, aMainId, aMaskId ); |
|
2149 |
|
2150 if (iBitmap && iBitmap->Bitmap()) |
|
2151 SetIconSizeL( CONST_CAST( CFbsBitmap*, iBitmap->Bitmap() ) ); |
|
2152 |
|
2153 iBitmap->SetContainerWindowL(*this); |
|
2154 iBitmap->CopyControlContextFrom(this); |
|
2155 iBitmap->SetNonFocusing(); |
|
2156 iBitmap->SetBrushStyle(CGraphicsContext::ENullBrush ); |
|
2157 } |
|
2158 |
|
2159 EXPORT_C void CEikCaptionedControl::CheckDimmedDisplayState() |
|
2160 { |
|
2161 TBool lineDimmed=(iControl->IsDimmed()); |
|
2162 SetDimmed(lineDimmed); |
|
2163 if (iCaption) |
|
2164 { |
|
2165 iCaption->SetDimmed(lineDimmed); |
|
2166 iCaption->DrawNow(); |
|
2167 } |
|
2168 if (iTrailer) |
|
2169 { |
|
2170 TBool controlVisible=iControl->IsVisible(); |
|
2171 if (iTrailer->IsVisible()!=controlVisible) |
|
2172 iTrailer->MakeVisible(controlVisible); |
|
2173 iTrailer->SetDimmed(lineDimmed); |
|
2174 iTrailer->DrawNow(); |
|
2175 } |
|
2176 } |
|
2177 |
|
2178 EXPORT_C void CEikCaptionedControl::ResetMinimumSizes() |
|
2179 { |
|
2180 iMinSize.iWidth=0; |
|
2181 iCaptionWidth=0; |
|
2182 iFullWidth=0; |
|
2183 } |
|
2184 |
|
2185 EXPORT_C TBool CEikCaptionedControl::IsLatent() const |
|
2186 { |
|
2187 return(iCapCFlags&ELatent); |
|
2188 } |
|
2189 |
|
2190 EXPORT_C void CEikCaptionedControl::SetLatent(TBool aLatent) |
|
2191 { |
|
2192 TBool visible=ETrue; |
|
2193 iCapCFlags&=(~ELatent); |
|
2194 if (aLatent) |
|
2195 { |
|
2196 iCapCFlags|=ELatent; |
|
2197 visible=EFalse; |
|
2198 } |
|
2199 iControl->MakeVisible(visible); |
|
2200 if (iCaption) |
|
2201 iCaption->MakeVisible(visible); |
|
2202 if (iTrailer) |
|
2203 iTrailer->MakeVisible(visible); |
|
2204 MakeVisible(visible); |
|
2205 } |
|
2206 |
|
2207 EXPORT_C TBool CEikCaptionedControl::LatentGroupLineFollows() const |
|
2208 { |
|
2209 return(iCapCFlags&ELglf); |
|
2210 } |
|
2211 |
|
2212 EXPORT_C void CEikCaptionedControl::SetLatentGroupLineFollows(TBool aLglf) |
|
2213 { |
|
2214 if (aLglf) |
|
2215 iCapCFlags|=ELglf; |
|
2216 else |
|
2217 iCapCFlags&=(~ELglf); |
|
2218 } |
|
2219 |
|
2220 EXPORT_C TBool CEikCaptionedControl::DividerAfter() const |
|
2221 { |
|
2222 return(iCapCFlags&ESeparatorAfter); |
|
2223 } |
|
2224 |
|
2225 EXPORT_C void CEikCaptionedControl::SetDividerAfter(TBool aDividerAfter) |
|
2226 { |
|
2227 if (aDividerAfter) |
|
2228 iCapCFlags|=ESeparatorAfter; |
|
2229 else |
|
2230 iCapCFlags&=(~ESeparatorAfter); |
|
2231 } |
|
2232 |
|
2233 EXPORT_C TBool CEikCaptionedControl::TakesEnterKey() const |
|
2234 { |
|
2235 return(iCapCFlags&ETakesEnterKey); |
|
2236 } |
|
2237 |
|
2238 EXPORT_C void CEikCaptionedControl::SetTakesEnterKey(TBool aTakesEnter) |
|
2239 { |
|
2240 if (aTakesEnter) |
|
2241 iCapCFlags|=ETakesEnterKey; |
|
2242 else |
|
2243 iCapCFlags&=(~ETakesEnterKey); |
|
2244 } |
|
2245 |
|
2246 EXPORT_C TBool CEikCaptionedControl::OfferHotKeys() const |
|
2247 { |
|
2248 return iCapCFlags&EOfferAllHotKeys; |
|
2249 } |
|
2250 |
|
2251 EXPORT_C void CEikCaptionedControl::SetOfferHotKeys(TBool aOffer) |
|
2252 { |
|
2253 if (aOffer) |
|
2254 iCapCFlags|=EOfferAllHotKeys; |
|
2255 else |
|
2256 iCapCFlags&=~EOfferAllHotKeys; |
|
2257 } |
|
2258 |
|
2259 /** |
|
2260 * Gets the list of logical colors employed in the drawing of the control, |
|
2261 * paired with an explanation of how they are used. Appends the list to aColorUseList. |
|
2262 * |
|
2263 * @since ER5U |
|
2264 */ |
|
2265 EXPORT_C void CEikCaptionedControl::GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const |
|
2266 { |
|
2267 CCoeControl::GetColorUseListL(aColorUseList); |
|
2268 |
|
2269 TCoeColorUse colorUse; |
|
2270 colorUse.SetLogicalColor(EColorWindowText); |
|
2271 colorUse.SetUse(TCoeColorUse::EFore|TCoeColorUse::EActive|TCoeColorUse::ESurrounds|TCoeColorUse::ENormal|TCoeColorUse::ENeutral); |
|
2272 aColorUseList.AppendL(colorUse); |
|
2273 |
|
2274 const TInt count=CountComponentControls(); |
|
2275 for(TInt ii=0;ii<count;ii++) |
|
2276 ComponentControl(ii)->GetColorUseListL(aColorUseList); |
|
2277 } |
|
2278 |
|
2279 /** |
|
2280 * Handles a change to the control's resources of type aType |
|
2281 * which are shared across the environment, e.g. colors or fonts. |
|
2282 * |
|
2283 * @since ER5U |
|
2284 */ |
|
2285 EXPORT_C void CEikCaptionedControl::HandleResourceChange(TInt aType) |
|
2286 { |
|
2287 CCoeControl::HandleResourceChange(aType); |
|
2288 |
|
2289 // Animation is skin dependent, whenever skin changes animation changes |
|
2290 // too. |
|
2291 if( KAknsMessageSkinChange == aType ) |
|
2292 { |
|
2293 TRAP_IGNORE( SetElementTextColorsL(TRgb())); |
|
2294 |
|
2295 if( iIsCurrentLine ) |
|
2296 { |
|
2297 iExtension->SkinChanged(); |
|
2298 } |
|
2299 } |
|
2300 else if( KEikDynamicLayoutVariantSwitch == aType && iIsFormControl ) |
|
2301 { |
|
2302 SizeChanged(); |
|
2303 CalculateNumberOfLinesForControl( ENotSupplied ); |
|
2304 if( iIsCurrentLine ) |
|
2305 { |
|
2306 iExtension->HandleLayoutSwitch( Rect().Size() ); |
|
2307 } |
|
2308 DrawDeferred(); |
|
2309 } |
|
2310 } |
|
2311 |
|
2312 |
|
2313 /* Deactivated as requested in AISA-595AEZ |
|
2314 */ |
|
2315 |
|
2316 EXPORT_C void CEikCaptionedControl::SetToolTipTextL( const TDesC& /*aText*/ ) |
|
2317 { |
|
2318 } |
|
2319 |
|
2320 EXPORT_C const TDesC* CEikCaptionedControl::ToolTipText() const |
|
2321 { |
|
2322 if ( iToolTipText ) |
|
2323 return iToolTipText ; |
|
2324 else |
|
2325 return NULL ; |
|
2326 } |
|
2327 |
|
2328 /** |
|
2329 * Writes the internal state of the control and its components to aStream. |
|
2330 * Does nothing in release mode. |
|
2331 * Designed to be overidden and base called by subclasses. |
|
2332 * |
|
2333 * @internal |
|
2334 * @since App-Framework_6.1 |
|
2335 */ |
|
2336 #ifndef _DEBUG |
|
2337 EXPORT_C void CEikCaptionedControl::WriteInternalStateL(RWriteStream&) const |
|
2338 {} |
|
2339 #else |
|
2340 EXPORT_C void CEikCaptionedControl::WriteInternalStateL(RWriteStream& aWriteStream) const |
|
2341 { |
|
2342 CCoeControl::WriteInternalStateL(aWriteStream); |
|
2343 } |
|
2344 #endif |
|
2345 |
|
2346 EXPORT_C void CEikCaptionedControl::Reserved_2() |
|
2347 {} |
|
2348 |
|
2349 EXPORT_C void CEikCaptionedControl::GetCaptionForFep(TDes& aCaption) const |
|
2350 { |
|
2351 if (iCaption==NULL) |
|
2352 { |
|
2353 aCaption=KNullDesC; |
|
2354 } |
|
2355 else |
|
2356 { |
|
2357 const TDesC* caption=iCaption->Text(); |
|
2358 if (caption==NULL) |
|
2359 { |
|
2360 aCaption=KNullDesC; |
|
2361 } |
|
2362 else |
|
2363 { |
|
2364 const TInt maximumLength=aCaption.MaxLength(); |
|
2365 if (caption->Length()>maximumLength) |
|
2366 { |
|
2367 aCaption=caption->Left(maximumLength); |
|
2368 } |
|
2369 else |
|
2370 { |
|
2371 aCaption=*caption; |
|
2372 } |
|
2373 } |
|
2374 } |
|
2375 } |
|
2376 |
|
2377 EXPORT_C void CEikCaptionedControl::MCoeCaptionRetrieverForFep_Reserved_1() |
|
2378 {} |
|
2379 |
|
2380 EXPORT_C void CEikCaptionedControl::MCoeCaptionRetrieverForFep_Reserved_2() |
|
2381 {} |
|
2382 |
|
2383 EXPORT_C void CEikCaptionedControl::SetEditableL( TBool aEditable, TBool /*aShowEmptyFields*/ ) |
|
2384 { |
|
2385 // Construct extension object if needed |
|
2386 ConstructExtensionL() ; |
|
2387 |
|
2388 // Animation is not run when editing |
|
2389 if( iIsFormControl && iExtension->iAnimation && aEditable ) |
|
2390 { |
|
2391 iExtension->iAnimation->Pause(); |
|
2392 } |
|
2393 |
|
2394 // Ensure that iHighlightControl gets created |
|
2395 if (!iHighlightControl) |
|
2396 { |
|
2397 iHighlightControl=new(ELeave) CEikCaptionedControlFormHighlightLine ( *this ) ; |
|
2398 STATIC_CAST(CEikCaptionedControlFormHighlightLine*,iHighlightControl)->ConstructL() ; |
|
2399 } |
|
2400 if (iIsFormControl && iIsEditable && iIsCurrentLine&& !aEditable) |
|
2401 { |
|
2402 iControl->SetFocus( EFalse) ; |
|
2403 } |
|
2404 if ( iIsFormControl ) |
|
2405 { |
|
2406 iIsEditable = aEditable ; |
|
2407 SetFocusing( ETrue ) ; // Might be modified later on |
|
2408 |
|
2409 iControl->SetFocusing( aEditable ) ; |
|
2410 |
|
2411 if ( !ControlIsAPopfield(iControlType) ) |
|
2412 { |
|
2413 if( aEditable ) |
|
2414 iControl->HandleResourceChange(KEikMessageCaptionedControlEditableStateChange); |
|
2415 else |
|
2416 iControl->HandleResourceChange(KEikMessageCaptionedControlNotEditableStateChange); |
|
2417 } |
|
2418 else |
|
2419 { // so popupfield derived |
|
2420 TBool isSingleLineLayout = ( FormLayout() == CEikDialogPage::ESingle); |
|
2421 TBool hasBitmaps = ShowBitmap(); |
|
2422 if( isSingleLineLayout ) |
|
2423 { |
|
2424 if( aEditable ) |
|
2425 iControl->HandleResourceChange(KEikMessageCaptionedControlEditableStateChange); |
|
2426 else |
|
2427 iControl->HandleResourceChange(KEikMessageCaptionedControlNotEditableStateChange); |
|
2428 } |
|
2429 else |
|
2430 { // double line layout |
|
2431 if( hasBitmaps ) |
|
2432 { // wide with graphic |
|
2433 if( aEditable ) |
|
2434 iControl->HandleResourceChange(KEikMessageCaptionedControlEditableStateChangeWideWithGraphic); |
|
2435 else |
|
2436 iControl->HandleResourceChange(KEikMessageCaptionedControlNotEditableStateChangeWideWithGraphic); |
|
2437 } |
|
2438 else |
|
2439 { // wide without graphic |
|
2440 if( aEditable ) |
|
2441 iControl->HandleResourceChange(KEikMessageCaptionedControlEditableStateChangeWideWithoutGraphic); |
|
2442 else |
|
2443 iControl->HandleResourceChange(KEikMessageCaptionedControlNotEditableStateChangeWideWithoutGraphic); |
|
2444 } |
|
2445 } |
|
2446 } |
|
2447 |
|
2448 if ( iCaption ) |
|
2449 iCaption->SetFocusing( !aEditable ) ; |
|
2450 |
|
2451 CalculateNumberOfLinesForControl( ENotSupplied ) ; |
|
2452 |
|
2453 // Force the layout |
|
2454 ResetMinimumSizes() ; |
|
2455 LayoutSkinControlContexts(); |
|
2456 if (IsReadyToDraw()) |
|
2457 SizeChanged(); // needed because layout lines change when editable flag is switched. |
|
2458 } |
|
2459 } |
|
2460 |
|
2461 void CEikCaptionedControl::SetVertEdgeSpacing( TInt aVertEdgeSpacing ) |
|
2462 { |
|
2463 iVertEdgeSpacing = aVertEdgeSpacing ; |
|
2464 } |
|
2465 |
|
2466 void CEikCaptionedControl::SetHorzEdgeSpacing( TInt aHorzEdgeSpacing ) |
|
2467 { |
|
2468 iHorzEdgeSpacing = aHorzEdgeSpacing ; |
|
2469 } |
|
2470 |
|
2471 /** |
|
2472 * Avkon component positioning for Forms |
|
2473 */ |
|
2474 |
|
2475 void CEikCaptionedControl::PositionFormComponents() |
|
2476 { |
|
2477 if( iExtension->iPartiallyVisible ) |
|
2478 return; |
|
2479 TBool isFocused = iIsCurrentLine; |
|
2480 TBool isSingleLineLayout = ( FormLayout() == CEikDialogPage::ESingle); |
|
2481 MinimumSize() ; |
|
2482 TBool hasBitmaps = ShowBitmap(); |
|
2483 |
|
2484 /* |
|
2485 if control has no height, return now (no point laying out) |
|
2486 */ |
|
2487 if (!Rect().Height()) |
|
2488 return; |
|
2489 |
|
2490 TAknWindowLineLayout verticalLine = AKN_LAYOUT_WINDOW_List_pane_elements__single_heading__Line_1 ; |
|
2491 |
|
2492 // If double line layout update verticalLine |
|
2493 if ( !isSingleLineLayout ) |
|
2494 { |
|
2495 if (iDialogPage) |
|
2496 { // use form flags from dialog |
|
2497 if (iDialogPage->GetFormFlags()&EEikFormShowBitmaps) |
|
2498 { |
|
2499 verticalLine = AKN_LAYOUT_WINDOW_List_pane_elements__double_graphic__Line_1; |
|
2500 } |
|
2501 else |
|
2502 { |
|
2503 verticalLine = AKN_LAYOUT_WINDOW_List_pane_lines__A_column__Line_1(0); |
|
2504 } |
|
2505 } |
|
2506 else |
|
2507 { // use local form flags |
|
2508 if (iFlags&EEikFormShowBitmaps) |
|
2509 { |
|
2510 verticalLine = AKN_LAYOUT_WINDOW_List_pane_elements__double_graphic__Line_1; |
|
2511 } |
|
2512 else |
|
2513 { |
|
2514 verticalLine = AKN_LAYOUT_WINDOW_List_pane_lines__A_column__Line_1(0); |
|
2515 } |
|
2516 } |
|
2517 } |
|
2518 TRect parentRect = Rect(); |
|
2519 TAknLayoutRect layoutRect; |
|
2520 layoutRect.LayoutRect( parentRect, verticalLine ); |
|
2521 TRect rectVerticalLine( layoutRect.Rect() ); |
|
2522 |
|
2523 |
|
2524 // set vertical line position. |
|
2525 if ( AknLayoutUtils::LayoutMirrored() ) |
|
2526 { |
|
2527 iVerticalLineXPosition = Rect().Width() - rectVerticalLine.iBr.iX; |
|
2528 } |
|
2529 else |
|
2530 { |
|
2531 iVerticalLineXPosition = rectVerticalLine.iTl.iX - iExtension->iXOffsetForDataPaneInEditMode; |
|
2532 } |
|
2533 |
|
2534 MEikDialogPageObserver::TFormControlTypes typeOfControlToLayout = MEikDialogPageObserver::EUnknownType; |
|
2535 if (ControlIsAnEdwin(iControlType)) |
|
2536 typeOfControlToLayout=MEikDialogPageObserver::EEdwinDerived; |
|
2537 else if (ControlIsAMfne(iControlType)) |
|
2538 typeOfControlToLayout=MEikDialogPageObserver::EMfneDerived; |
|
2539 else if (ControlIsAPopfield(iControlType)) |
|
2540 typeOfControlToLayout=MEikDialogPageObserver::EPopfieldDerived; |
|
2541 else if (ControlIsASecretEditor(iControlType)) |
|
2542 typeOfControlToLayout=MEikDialogPageObserver::ESecretEditorDerived; |
|
2543 else if (ControlIsASlider(iControlType)) |
|
2544 typeOfControlToLayout=MEikDialogPageObserver::ESliderDerived; |
|
2545 else |
|
2546 { |
|
2547 /* |
|
2548 Each control type checks to see if it a user-defined control type is of that type, using the |
|
2549 ConvertCustomControlTypeToBaseControlType mechanism so if the code gets here, the control is |
|
2550 "none of the above". |
|
2551 */ |
|
2552 Panic(EEikFormPanicUnknownControlType); |
|
2553 }; |
|
2554 |
|
2555 //TRect layoutRectOfDataPane =(iIsEditable)? EditRect() : ViewRect(); |
|
2556 |
|
2557 //view and edit data pane rect should be the same |
|
2558 TRect layoutRectOfDataPane = ViewRect(); |
|
2559 |
|
2560 if ( hasBitmaps ) |
|
2561 { |
|
2562 if (iBitmap) |
|
2563 FormLayoutControlBitmap |
|
2564 ( |
|
2565 iBitmap, |
|
2566 layoutRectOfDataPane, |
|
2567 iIsEditable, |
|
2568 isSingleLineLayout, |
|
2569 iNumberOfLines |
|
2570 ); |
|
2571 } |
|
2572 if (iCaption) |
|
2573 { |
|
2574 TInt numOfIcons = 0; |
|
2575 if (iExtension && iExtension->iIndicator) numOfIcons = 1; |
|
2576 if (iExtension && iExtension->iIndicator2) numOfIcons = 2; |
|
2577 |
|
2578 FormLayoutControlLabel |
|
2579 ( |
|
2580 iCaption, |
|
2581 layoutRectOfDataPane, |
|
2582 iIsEditable, |
|
2583 isSingleLineLayout, |
|
2584 iNumberOfLines, |
|
2585 hasBitmaps, |
|
2586 isFocused, |
|
2587 numOfIcons |
|
2588 ); |
|
2589 } |
|
2590 |
|
2591 switch (typeOfControlToLayout) |
|
2592 { |
|
2593 case MEikDialogPageObserver::EEdwinDerived: |
|
2594 { |
|
2595 #ifdef _DEBUG |
|
2596 TInt numberOfLines=iNumberOfLines; |
|
2597 #endif // _DEBUG |
|
2598 |
|
2599 /* WARNING... The following is done to prevent edwin resize events. The flag |
|
2600 iIgnoreFurtherEdwinResizeEvents should only be set for the shortest time possible and only |
|
2601 when resizing an edwin. |
|
2602 */ |
|
2603 CEikEdwin* edwinPtr=STATIC_CAST(CEikEdwin*, iControl); |
|
2604 CEikEdwin* previousVal=iDialogPage->iIgnoreFurtherEdwinResizeEvents; |
|
2605 |
|
2606 #ifdef _DEBUG |
|
2607 if (previousVal) |
|
2608 { |
|
2609 RDebug::Print(_L("Warning - Editor has changed number of lines post-layout.")); |
|
2610 } |
|
2611 #endif // _DEBUG |
|
2612 iDialogPage->iIgnoreFurtherEdwinResizeEvents=edwinPtr; |
|
2613 FormLayoutControlEdwin |
|
2614 ( |
|
2615 edwinPtr, |
|
2616 layoutRectOfDataPane, |
|
2617 iIsEditable, |
|
2618 isSingleLineLayout, |
|
2619 iNumberOfLines, |
|
2620 hasBitmaps, |
|
2621 isFocused |
|
2622 ); |
|
2623 iDialogPage->iIgnoreFurtherEdwinResizeEvents=previousVal; |
|
2624 |
|
2625 #ifdef _DEBUG |
|
2626 if (numberOfLines!=iNumberOfLines) |
|
2627 { |
|
2628 /* |
|
2629 Due to some rather sneaky code which lays out the editors on mode change, initially |
|
2630 the number of lines should be correct (may be incorrect if the editor had a different |
|
2631 width before the layout to after the layout). |
|
2632 |
|
2633 This will warn if this has not worked. |
|
2634 */ |
|
2635 RDebug::Print(_L("Warning - Editor has changed number of lines post-layout.")); |
|
2636 RDebug::Print(_L("pre-layout phase must have used a different format.")); |
|
2637 } |
|
2638 #endif // _DEBUG |
|
2639 break; |
|
2640 } |
|
2641 case MEikDialogPageObserver::EMfneDerived: |
|
2642 { |
|
2643 FormLayoutControlMfne |
|
2644 ( |
|
2645 STATIC_CAST(CEikMfne*, iControl), |
|
2646 layoutRectOfDataPane, |
|
2647 iIsEditable, |
|
2648 isSingleLineLayout, |
|
2649 iNumberOfLines, |
|
2650 hasBitmaps, |
|
2651 isFocused |
|
2652 ); |
|
2653 break; |
|
2654 } |
|
2655 case MEikDialogPageObserver::EPopfieldDerived: |
|
2656 { |
|
2657 FormLayoutControlPopfield |
|
2658 ( |
|
2659 STATIC_CAST(CAknPopupField*, iControl), |
|
2660 layoutRectOfDataPane, |
|
2661 iIsEditable, |
|
2662 isSingleLineLayout, |
|
2663 iNumberOfLines, |
|
2664 hasBitmaps, |
|
2665 isFocused |
|
2666 ); |
|
2667 break; |
|
2668 } |
|
2669 case MEikDialogPageObserver::ESecretEditorDerived: |
|
2670 { |
|
2671 FormLayoutControlSecretEditor |
|
2672 ( |
|
2673 STATIC_CAST(CEikSecretEditor*, iControl), |
|
2674 layoutRectOfDataPane, |
|
2675 iIsEditable, |
|
2676 isSingleLineLayout, |
|
2677 iNumberOfLines, |
|
2678 hasBitmaps, |
|
2679 isFocused |
|
2680 ); |
|
2681 break; |
|
2682 } |
|
2683 case MEikDialogPageObserver::ESliderDerived: |
|
2684 { |
|
2685 FormLayoutControlSlider |
|
2686 ( |
|
2687 STATIC_CAST(CAknSlider*, iControl), |
|
2688 layoutRectOfDataPane, |
|
2689 iIsEditable, |
|
2690 isSingleLineLayout, |
|
2691 iNumberOfLines, |
|
2692 hasBitmaps |
|
2693 ); |
|
2694 break; |
|
2695 } |
|
2696 default: |
|
2697 Panic(EEikFormPanicLayoutErrorUnknownControlType); |
|
2698 } |
|
2699 |
|
2700 TRAP_IGNORE( SetElementTextColorsL(TRgb())); |
|
2701 } |
|
2702 |
|
2703 TBool CEikCaptionedControl::ShowBitmap() const |
|
2704 { |
|
2705 return (iFlags & EEikFormShowBitmaps); |
|
2706 } |
|
2707 |
|
2708 void CEikCaptionedControl::LayoutBitmap(const TRect& aRect) |
|
2709 { |
|
2710 if ( ShowBitmap() && iBitmap ) |
|
2711 { |
|
2712 iBitmap->SetAllMarginsTo(0); |
|
2713 AknLayoutUtils::LayoutControl( iBitmap, aRect, R_AVKON_FORM_ICON ) ; |
|
2714 } |
|
2715 } |
|
2716 |
|
2717 void CEikCaptionedControl::LayoutCaption(const TRect& aRect) |
|
2718 { |
|
2719 if ( iCaption ) |
|
2720 { |
|
2721 if ( ShowBitmap() ) |
|
2722 { |
|
2723 AknLayoutUtils::LayoutLabel( iCaption, aRect, R_AVKON_FORM_LABEL_WITH_ICON ) ; |
|
2724 } |
|
2725 else |
|
2726 { |
|
2727 AknLayoutUtils::LayoutLabel( iCaption, aRect, R_AVKON_FORM_LABEL_NO_ICON ) ; |
|
2728 } |
|
2729 } |
|
2730 } |
|
2731 |
|
2732 TSize CEikCaptionedControl::EditorControlSize() const |
|
2733 { |
|
2734 return iEditorControlSize ; |
|
2735 } |
|
2736 |
|
2737 TInt CEikCaptionedControl::NumberOfLines() const |
|
2738 { |
|
2739 return iNumberOfLines; |
|
2740 } |
|
2741 |
|
2742 TInt CEikCaptionedControl::NumberOfLinesForScrollBar() const |
|
2743 { |
|
2744 if ( FormLayout() == CEikDialogPage::ESingle ) return NumberOfLines(); |
|
2745 return NumberOfLines()+1; |
|
2746 } |
|
2747 |
|
2748 /** |
|
2749 * Recalculates the number of required lines for a control. |
|
2750 */ |
|
2751 void CEikCaptionedControl::CalculateNumberOfLinesForControl( TInt aLines ) |
|
2752 { |
|
2753 // NB if new control types are added, ones which should be invisible in view mode |
|
2754 // should be also added to IsDisplayable(). |
|
2755 if ( aLines == ENotSupplied ) |
|
2756 { |
|
2757 // Function has to be aware of edit/view state. |
|
2758 if ( iIsEditable ) |
|
2759 { |
|
2760 if (ControlIsAnEdwin(iControlType)) |
|
2761 { |
|
2762 CEikEdwin* edwin = STATIC_CAST( CEikEdwin*, iControl ); |
|
2763 if (iIsFormControl) |
|
2764 edwin->SetMaximumHeightInLines(MaximumNumberOfControlLinesOnVisiblePage()); |
|
2765 |
|
2766 TInt limitForView = edwin->MaximumHeightInLines(); |
|
2767 TInt noLinesInTotal=0; |
|
2768 if (edwin->TextLayout()) |
|
2769 noLinesInTotal= edwin->TextLayout()->NumFormattedLines() ; |
|
2770 aLines = ((limitForView < noLinesInTotal) && limitForView) |
|
2771 ? limitForView : noLinesInTotal ; |
|
2772 } |
|
2773 else |
|
2774 { |
|
2775 switch ( iControlType ) |
|
2776 { |
|
2777 case EAknCtPopupField: |
|
2778 case EAknCtPopupFieldText : |
|
2779 { |
|
2780 CAknPopupField* popupField = static_cast<CAknPopupField*>(iControl); |
|
2781 popupField->SetMaxNumberOfLinesPermitted(MaximumNumberOfControlLinesOnVisiblePage()); |
|
2782 aLines = popupField->NumLines(); |
|
2783 } |
|
2784 break; |
|
2785 case EAknCtSlider : |
|
2786 aLines = STATIC_CAST(CAknSlider*, iControl )->NumberOfLines(); |
|
2787 break; |
|
2788 default : |
|
2789 aLines = 1 ; |
|
2790 break ; |
|
2791 } |
|
2792 } |
|
2793 } |
|
2794 else // not editable |
|
2795 { |
|
2796 if ( iFlags & EEikFormHideEmptyFields |
|
2797 && ControlIsAnEdwin(iControlType) |
|
2798 && STATIC_CAST( CEikEdwin*, iControl )->TextLength() == 0 ) |
|
2799 { |
|
2800 SetFocusing( EFalse ) ; // don't want the focus on invisible control! |
|
2801 aLines = 0 ; |
|
2802 } |
|
2803 else |
|
2804 aLines=1; |
|
2805 } |
|
2806 } |
|
2807 iNumberOfLines = aLines ; |
|
2808 } |
|
2809 |
|
2810 EXPORT_C void CEikCaptionedControl::SetFormFlags( TInt aFlags ) |
|
2811 { |
|
2812 iFlags = aFlags ; |
|
2813 } |
|
2814 |
|
2815 /* |
|
2816 * Set the background colours of iBitmap, iCaption and iControl |
|
2817 */ |
|
2818 void CEikCaptionedControl::SetElementBrushColorsL( TRgb aColor ) |
|
2819 { |
|
2820 AknLayoutUtils::OverrideControlColorL(*this, EColorControlBackground, aColor ) ; |
|
2821 } |
|
2822 |
|
2823 /* |
|
2824 * Set the foreground colours of iBitmap, iCaption and iControl |
|
2825 */ |
|
2826 void CEikCaptionedControl::SetElementTextColorsL( TRgb aColor ) |
|
2827 { |
|
2828 TRgb textColor = aColor; |
|
2829 { |
|
2830 if ( AknsUtils::AvkonSkinEnabled() ) |
|
2831 { |
|
2832 // extended skin support |
|
2833 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
2834 |
|
2835 // sets the color according the skin LAF |
|
2836 TAknsQsnTextColorsIndex colorIndex = TextColorIndex(); |
|
2837 AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnTextColors, colorIndex ); |
|
2838 } |
|
2839 } |
|
2840 AknLayoutUtils::OverrideControlColorL(*this, EColorLabelText, textColor ); |
|
2841 |
|
2842 if(ControlIsAnEdwin(iControlType)) |
|
2843 { |
|
2844 AknLayoutUtils::OverrideControlColorL(*this, EColorControlText, textColor ); |
|
2845 } |
|
2846 |
|
2847 } |
|
2848 |
|
2849 /** |
|
2850 * Retrieves the Series 60 European LAF layout values from avkon.rh |
|
2851 * |
|
2852 */ |
|
2853 void CEikCaptionedControl::GetAknLayoutValuesL() |
|
2854 { |
|
2855 TAknWindowLineLayout l = AknLayoutScalable_Avkon::form_field_data_pane(0).LayoutLine(); |
|
2856 TRect parentRect = iAvkonAppUi->ClientRect(); |
|
2857 TAknLayoutRect layoutRect; |
|
2858 layoutRect.LayoutRect( parentRect, l ); |
|
2859 TRect rectDataPane( layoutRect.Rect() ); |
|
2860 |
|
2861 iAknFormControlWidth = rectDataPane.Width(); |
|
2862 iAknFormControlHeight = rectDataPane.Height(); |
|
2863 } |
|
2864 |
|
2865 |
|
2866 |
|
2867 TBool CEikCaptionedControl::IsDisplayable() const |
|
2868 { |
|
2869 /* |
|
2870 Added to provide whether the control should be displayed without calls to minimumsize. |
|
2871 */ |
|
2872 |
|
2873 // If new control types are added which can be invisible in view mode |
|
2874 // with the appropriate flag (EEikFormHideEmptyFields), they should be added here. |
|
2875 if (iIsFormControl && (!iIsEditable) &&(iFlags & EEikFormHideEmptyFields )) |
|
2876 { |
|
2877 if (ControlIsAnEdwin(iControlType)&& |
|
2878 STATIC_CAST( CEikEdwin*, iControl )->TextLength() == 0 ) |
|
2879 return EFalse; |
|
2880 } |
|
2881 return ETrue; |
|
2882 } |
|
2883 |
|
2884 TInt CEikCaptionedControl::ControlType() const |
|
2885 { |
|
2886 return iControlType; |
|
2887 } |
|
2888 |
|
2889 TBool CEikCaptionedControl::ControlIsAnEdwin(TInt aControlType) const |
|
2890 { |
|
2891 // function used to return which controls are editors (i.e. derived from Edwin) |
|
2892 // The idea is to leave this as expandable as possible. |
|
2893 switch (aControlType) |
|
2894 { |
|
2895 case EEikCtEdwin: |
|
2896 case EEikCtGlobalTextEditor: |
|
2897 case EEikCtRichTextEditor: |
|
2898 case EAknCtIntegerEdwin: |
|
2899 case EEikCtFlPtEd: |
|
2900 case EEikCtFxPtEd: |
|
2901 return ETrue; |
|
2902 } |
|
2903 /* |
|
2904 See if the control is an Edwin via the Edwin->Derived route |
|
2905 */ |
|
2906 if (iDialogPage) |
|
2907 { |
|
2908 TInt typeOfControlToLayout=iDialogPage->PageContainer()->PageSelector()->Dialg()->ConvertCustomControlTypeToBaseControlType(iControlType); |
|
2909 if (typeOfControlToLayout==MEikDialogPageObserver::EEdwinDerived) |
|
2910 return ETrue; |
|
2911 } |
|
2912 return EFalse; |
|
2913 } |
|
2914 |
|
2915 TBool CEikCaptionedControl::ControlIsAMfne(TInt aControlType) const |
|
2916 { |
|
2917 // function used to return which controls are mfnes (i.e. derived from CEikmfne) |
|
2918 // The idea is to leave this as expandable as possible. |
|
2919 switch (aControlType) |
|
2920 { |
|
2921 case EEikCtRangeEditor: |
|
2922 case EEikCtTimeEditor: |
|
2923 case EEikCtDateEditor: |
|
2924 case EEikCtTimeAndDateEditor: |
|
2925 case EEikCtDurationEditor: |
|
2926 case EEikCtTimeOffsetEditor: |
|
2927 case EEikCtNumberEditor: |
|
2928 case EAknCtLocationEditor: |
|
2929 case EAknCtUnitEditor: |
|
2930 return ETrue; |
|
2931 } |
|
2932 TInt typeOfControlToLayout=iDialogPage->PageContainer()->PageSelector()->Dialg()->ConvertCustomControlTypeToBaseControlType(iControlType); |
|
2933 if (typeOfControlToLayout==MEikDialogPageObserver::EMfneDerived) |
|
2934 return ETrue; |
|
2935 return EFalse; |
|
2936 } |
|
2937 |
|
2938 TBool CEikCaptionedControl::ControlIsAPopfield(TInt aControlType) const |
|
2939 { |
|
2940 // function used to return which controls are mfnes (i.e. derived from CEikmfne) |
|
2941 // The idea is to leave this as expandable as possible. |
|
2942 switch (aControlType) |
|
2943 { |
|
2944 case EAknCtPopupField : |
|
2945 case EAknCtPopupFieldText : |
|
2946 return ETrue; |
|
2947 } |
|
2948 if (iDialogPage) |
|
2949 { |
|
2950 TInt typeOfControlToLayout=iDialogPage->PageContainer()->PageSelector()->Dialg()->ConvertCustomControlTypeToBaseControlType(iControlType); |
|
2951 if (typeOfControlToLayout==MEikDialogPageObserver::EPopfieldDerived) |
|
2952 return ETrue; |
|
2953 } |
|
2954 return EFalse; |
|
2955 } |
|
2956 |
|
2957 TBool CEikCaptionedControl::ControlIsASecretEditor(TInt aControlType) const |
|
2958 { |
|
2959 // function used to return which controls are mfnes (i.e. derived from CEikmfne) |
|
2960 // The idea is to leave this as expandable as possible. |
|
2961 switch (aControlType) |
|
2962 { |
|
2963 case EEikCtSecretEd: |
|
2964 case EAknCtNumericSecretEditor: |
|
2965 return ETrue; |
|
2966 } |
|
2967 TInt typeOfControlToLayout=iDialogPage->PageContainer()->PageSelector()->Dialg()->ConvertCustomControlTypeToBaseControlType(iControlType); |
|
2968 if (typeOfControlToLayout==MEikDialogPageObserver::ESecretEditorDerived) |
|
2969 return ETrue; |
|
2970 return EFalse; |
|
2971 } |
|
2972 |
|
2973 TBool CEikCaptionedControl::ControlIsASlider(TInt aControlType) const |
|
2974 { |
|
2975 // function used to return which controls are sliders |
|
2976 // The idea is to leave this as expandable as possible. |
|
2977 switch (aControlType) |
|
2978 { |
|
2979 case EAknCtSlider : |
|
2980 return ETrue; |
|
2981 } |
|
2982 TInt typeOfControlToLayout=iDialogPage->PageContainer()->PageSelector()->Dialg()->ConvertCustomControlTypeToBaseControlType(iControlType); |
|
2983 if (typeOfControlToLayout==MEikDialogPageObserver::ESliderDerived) |
|
2984 return ETrue; |
|
2985 return EFalse; |
|
2986 } |
|
2987 |
|
2988 //------------------------------------------------------------------------ |
|
2989 // CEikCaptionedControl::ControlIsAColourSelGrid |
|
2990 // Returns true if control is colourselection grid or nonefield . |
|
2991 //------------------------------------------------------------------------ |
|
2992 TBool CEikCaptionedControl::ControlIsAColourSelGrid(TInt aControlType) const |
|
2993 { |
|
2994 // function used to return which controls are ColourSelectionGrids |
|
2995 // The idea is to leave this as expandable as possible. |
|
2996 switch (aControlType) |
|
2997 { |
|
2998 case EAknCtColourSelectionDialogGrid : // Deprecated |
|
2999 case EAknCtColourSelectionGridDialog : |
|
3000 case EAknCtColourSelectionDialogNoneField: |
|
3001 return ETrue; |
|
3002 } |
|
3003 TInt typeOfControlToLayout=iDialogPage->PageContainer()->PageSelector()->Dialg()->ConvertCustomControlTypeToBaseControlType(iControlType); |
|
3004 if (typeOfControlToLayout==MEikDialogPageObserver::EColourSelectionGridDerived) |
|
3005 return ETrue; |
|
3006 return EFalse; |
|
3007 } |
|
3008 |
|
3009 void CEikCaptionedControl::DoFormCaptionSettingsL(const TDesC& aText) |
|
3010 { |
|
3011 delete iCaptionText; // get rid of old iCaptionText |
|
3012 iCaptionText=0; |
|
3013 iCaptionText = aText.AllocL(); |
|
3014 iCaption->SetTextL(aText); |
|
3015 iCaption->CropText(); |
|
3016 } |
|
3017 |
|
3018 |
|
3019 EXPORT_C const TPtrC CEikCaptionedControl::GetFullCaptionText() const |
|
3020 { |
|
3021 return *iCaptionText; |
|
3022 }; |
|
3023 |
|
3024 void CEikCaptionedControl::RegisterPageWithCaptionControl(CEikDialogPage* aPage) |
|
3025 { |
|
3026 iDialogPage=aPage; |
|
3027 }; |
|
3028 |
|
3029 TInt CEikCaptionedControl::MaximumNumberOfControlLinesOnVisiblePage() const |
|
3030 { |
|
3031 TInt maxItems = 0; |
|
3032 TAknLayoutScalableParameterLimits paneLimits; |
|
3033 if (IsPopupField(this)) |
|
3034 { |
|
3035 if (iDialogPage&& CEikDialogPage::EDouble == iDialogPage->FormLayout()) |
|
3036 paneLimits = AknLayoutScalable_Avkon::form_field_popup_wide_pane_ParamLimits(); |
|
3037 else |
|
3038 paneLimits = AknLayoutScalable_Avkon::form_field_popup_pane_ParamLimits(); |
|
3039 } |
|
3040 else |
|
3041 { |
|
3042 if (iDialogPage&& CEikDialogPage::EDouble == iDialogPage->FormLayout()) |
|
3043 paneLimits = AknLayoutScalable_Avkon::form_field_data_wide_pane_ParamLimits(); |
|
3044 else |
|
3045 paneLimits = AknLayoutScalable_Avkon::form_field_data_pane_ParamLimits(); |
|
3046 } |
|
3047 maxItems = paneLimits.LastVariety() + 1; // last variety is a zero based index, we need num items which is 1 based |
|
3048 |
|
3049 TInt maxItems2 = maxItems; |
|
3050 if (!IsPopupField(this)) |
|
3051 { |
|
3052 paneLimits = AknLayoutScalable_Avkon::data_form_wide_pane_t1_ParamLimits(); |
|
3053 maxItems2 = paneLimits.LastRow()+1; |
|
3054 } |
|
3055 else |
|
3056 { |
|
3057 if (iDialogPage&& CEikDialogPage::EDouble == iDialogPage->FormLayout()) |
|
3058 paneLimits = AknLayoutScalable_Avkon::list_form_graphic_pane_cp_ParamLimits(); |
|
3059 else |
|
3060 paneLimits = AknLayoutScalable_Avkon::list_form_graphic_pane_ParamLimits(); |
|
3061 maxItems2 = paneLimits.LastRow()+1; |
|
3062 } |
|
3063 |
|
3064 if (maxItems2 < maxItems) maxItems = maxItems2; |
|
3065 |
|
3066 if ( ControlIsAnEdwin( iControlType ) ) |
|
3067 { |
|
3068 TInt defineHeight = static_cast<CEikEdwin*>( iControl )->MaximumHeightInLines(); |
|
3069 if ( defineHeight && defineHeight < maxItems ) |
|
3070 return defineHeight; |
|
3071 } |
|
3072 //maxItems -= 1; // TODO: this is a temporary workaround for layout data being incorrect, it has too many options available |
|
3073 return maxItems; |
|
3074 }; |
|
3075 |
|
3076 |
|
3077 TRect CEikCaptionedControl::ViewRect() const |
|
3078 |
|
3079 { |
|
3080 /* |
|
3081 The Rect that the view mode is expecting is: |
|
3082 176 across |
|
3083 21 high |
|
3084 set from 0,0 |
|
3085 |
|
3086 We are |
|
3087 174 across |
|
3088 23 high |
|
3089 set from (1,1) relative to viewwin. |
|
3090 |
|
3091 To convert we must: |
|
3092 * Shrink(-1,1) to make Y cord and size equal, and X coord equal. |
|
3093 * add 1 to the BR X coord. to make X size equal. |
|
3094 */ |
|
3095 TRect viewRectConversion(EditRect()); |
|
3096 viewRectConversion.Shrink(0,1); |
|
3097 return viewRectConversion; |
|
3098 } |
|
3099 |
|
3100 TRect CEikCaptionedControl::EditRect() const |
|
3101 { |
|
3102 //The Rect provided by Rect() is fine |
|
3103 return Rect(); |
|
3104 } |
|
3105 |
|
3106 void CEikCaptionedControl::FormLayoutControlBitmap(CEikImage* aBitmap, const TRect& aParent, TBool aIsEditable, TBool aSingleLayout, TInt aNumberOfLines) |
|
3107 { |
|
3108 if (!aNumberOfLines) |
|
3109 return; |
|
3110 aBitmap->SetAllMarginsTo(0); |
|
3111 if (aSingleLayout) |
|
3112 { |
|
3113 if (aIsEditable) |
|
3114 { |
|
3115 AknLayoutUtils::LayoutControl |
|
3116 ( |
|
3117 aBitmap, |
|
3118 aParent, |
|
3119 AKN_LAYOUT_WINDOW_Form_data_field_elements_Line_4 |
|
3120 ); |
|
3121 } |
|
3122 else |
|
3123 { |
|
3124 AknLayoutUtils::LayoutImage |
|
3125 ( |
|
3126 aBitmap, |
|
3127 aParent, |
|
3128 AKN_LAYOUT_WINDOW_List_pane_elements__single_graphic_heading__Line_1 |
|
3129 ); |
|
3130 } |
|
3131 } |
|
3132 else |
|
3133 { |
|
3134 if (aIsEditable) |
|
3135 { |
|
3136 AknLayoutUtils::LayoutControl |
|
3137 ( |
|
3138 aBitmap, |
|
3139 aParent, |
|
3140 AKN_LAYOUT_WINDOW_Form_data_wide_field_elements_Line_4 |
|
3141 ); |
|
3142 } |
|
3143 else |
|
3144 { |
|
3145 AknLayoutUtils::LayoutControl |
|
3146 ( |
|
3147 aBitmap, |
|
3148 aParent, |
|
3149 AKN_LAYOUT_WINDOW_List_pane_elements__single_graphic_heading__Line_1 |
|
3150 ); |
|
3151 } |
|
3152 } |
|
3153 } |
|
3154 |
|
3155 static TRect LineRect(TRect aParentRect, TInt aLine, TAknTextLineLayout aLayout) |
|
3156 { |
|
3157 TAknLayoutText text; |
|
3158 text.LayoutText(aParentRect, aLayout); |
|
3159 TRect rect = text.TextRect(); |
|
3160 rect.iTl.iY += aLayout.iBaselineSkip * aLine; |
|
3161 rect.iBr.iY += aLayout.iBaselineSkip * aLine; |
|
3162 return rect; |
|
3163 } |
|
3164 |
|
3165 static void SetScrollRect(CEikEdwin *aEdwin, TRect aParentRect, TAknTextLineLayout aLayout, TInt aNumberOfLines) |
|
3166 { |
|
3167 TRect top = LineRect(aParentRect, 1, aLayout); |
|
3168 TRect bottom = LineRect(aParentRect, aNumberOfLines-2, aLayout); |
|
3169 TRect area = TRect(top.iTl, bottom.iBr); |
|
3170 aEdwin->SetScrollRect(area); |
|
3171 } |
|
3172 |
|
3173 // Edit fields |
|
3174 void CEikCaptionedControl::FormLayoutControlEdwin( |
|
3175 CEikEdwin* aEdwin, const TRect& aParentRect, TBool aIsEditable, |
|
3176 TBool aSingleLayout, TInt aNumberOfLines, TBool aBitmapPresent, |
|
3177 TBool /*aIsFocused*/ ) |
|
3178 { |
|
3179 if (!aNumberOfLines) |
|
3180 return; |
|
3181 // Create a standard text layout object with scope at this level |
|
3182 TRect layoutRect = aParentRect; |
|
3183 TAknTextLineLayout textLayout ( |
|
3184 AKN_LAYOUT_TEXT_List_pane_texts__single_graphic_heading__Line_2(0) ); |
|
3185 |
|
3186 if (aSingleLayout) |
|
3187 { |
|
3188 if (aIsEditable) |
|
3189 { |
|
3190 TAknTextLineLayout specificLayout( |
|
3191 AKN_LAYOUT_MULTILINE_TEXT_Form_data_field_texts_Line_2(aNumberOfLines) ); |
|
3192 textLayout = specificLayout; |
|
3193 } |
|
3194 else |
|
3195 { |
|
3196 // should assert only 1 line |
|
3197 TAknTextLineLayout specificLayout( |
|
3198 AKN_LAYOUT_TEXT_List_pane_texts__single_graphic_heading__Line_2(0) ); |
|
3199 textLayout = specificLayout; |
|
3200 } |
|
3201 } |
|
3202 else |
|
3203 { |
|
3204 // Not currently specified, so making temporary alterations here. |
|
3205 if (aIsEditable) |
|
3206 { |
|
3207 if (aBitmapPresent) |
|
3208 { |
|
3209 TAknTextLineLayout specificLayout( |
|
3210 AKN_LAYOUT_MULTILINE_TEXT_Form_data_wide_graphic_field_texts_Line_2(aNumberOfLines) ); |
|
3211 textLayout = specificLayout; |
|
3212 } |
|
3213 else |
|
3214 { |
|
3215 TAknTextLineLayout specificLayout( |
|
3216 AKN_LAYOUT_MULTILINE_TEXT_Form_data_wide_field_texts_Line_2(aNumberOfLines) ); |
|
3217 |
|
3218 textLayout = specificLayout; |
|
3219 } |
|
3220 } |
|
3221 else |
|
3222 { |
|
3223 if (aBitmapPresent) |
|
3224 { |
|
3225 TAknTextLineLayout specificLayout( |
|
3226 AKN_LAYOUT_TEXT_List_pane_texts__large_single_heading_graphic__Line_2 ); |
|
3227 textLayout = specificLayout; |
|
3228 } |
|
3229 else |
|
3230 { |
|
3231 TAknTextLineLayout specificLayout( |
|
3232 AKN_LAYOUT_TEXT_List_pane_texts__large_single_heading__Line_2 ); |
|
3233 |
|
3234 textLayout = specificLayout; |
|
3235 } |
|
3236 } |
|
3237 } |
|
3238 |
|
3239 if( aEdwin->TextLayout() ) |
|
3240 { |
|
3241 aEdwin->TextLayout()->RestrictScrollToTopsOfLines(EFalse); |
|
3242 |
|
3243 if (AknLayoutUtils::LayoutMirrored() && textLayout.iJ == ELayoutAlignRight && aIsEditable) |
|
3244 { |
|
3245 textLayout.iJ = ELayoutAlignBidi; |
|
3246 } |
|
3247 |
|
3248 TAknsQsnTextColorsIndex colorIndex = TextColorIndex(); |
|
3249 AknLayoutUtils::LayoutEdwin( aEdwin, layoutRect, textLayout, |
|
3250 colorIndex, 0, ETrue ); |
|
3251 SetScrollRect(aEdwin, layoutRect, textLayout, aNumberOfLines); |
|
3252 } |
|
3253 |
|
3254 TBool isviewmode = !aIsEditable; |
|
3255 aEdwin->SetSuppressBackgroundDrawing(isviewmode); |
|
3256 } |
|
3257 |
|
3258 |
|
3259 // Labels |
|
3260 void CEikCaptionedControl::FormLayoutControlLabel( |
|
3261 CEikLabel* aLabel, const TRect& aParent, TBool aIsEditable, |
|
3262 TBool aSingleLayout, TInt aNumberOfLines, TBool aBitmapPresent, |
|
3263 TBool /*aIsFocused*/, TInt aIconCount) |
|
3264 { |
|
3265 if (!aNumberOfLines) |
|
3266 return; |
|
3267 TInt bitmap = (aBitmapPresent)?1:0; |
|
3268 TRect layoutRect = aParent; |
|
3269 |
|
3270 TInt numOfIcons = aIconCount; |
|
3271 |
|
3272 // Put a layout object at this level of scope |
|
3273 TAknTextLineLayout textLayout( AKN_LAYOUT_TEXT_Form_data_field_texts_Line_1(bitmap,0) ); |
|
3274 |
|
3275 // Layout the label for the single line format |
|
3276 if (aSingleLayout) |
|
3277 { |
|
3278 if (aIsEditable) |
|
3279 { |
|
3280 // Do nothing; this is the default used |
|
3281 } |
|
3282 else |
|
3283 { |
|
3284 // This layout is dy |
|
3285 if (aBitmapPresent) |
|
3286 { |
|
3287 TAknTextLineLayout anotherTextLayout(AKN_LAYOUT_TEXT_List_pane_texts__single_graphic_heading__Line_1(0) ); |
|
3288 textLayout = anotherTextLayout; |
|
3289 } |
|
3290 else |
|
3291 { |
|
3292 textLayout = AknLayoutScalable_Avkon::form_field_data_pane_t1(0).LayoutLine(); |
|
3293 }; |
|
3294 } |
|
3295 } |
|
3296 else |
|
3297 // Double line format |
|
3298 { |
|
3299 if (aIsEditable) |
|
3300 { |
|
3301 if (aBitmapPresent) |
|
3302 { |
|
3303 TAknTextLineLayout anotherTextLayout( AknLayoutScalable_Avkon::form_field_data_wide_pane_t1(1+numOfIcons).LayoutLine() ) ; |
|
3304 textLayout = anotherTextLayout; |
|
3305 } |
|
3306 else |
|
3307 { |
|
3308 TAknTextLineLayout anotherTextLayout( AknLayoutScalable_Avkon::form_field_data_wide_pane_t1(numOfIcons ? numOfIcons+1 : 0).LayoutLine() ) ; |
|
3309 textLayout = anotherTextLayout; |
|
3310 |
|
3311 } |
|
3312 } |
|
3313 else |
|
3314 { |
|
3315 if (aBitmapPresent) |
|
3316 { |
|
3317 TAknTextLineLayout anotherTextLayout( |
|
3318 AKN_LAYOUT_TEXT_List_pane_texts__large_single_heading_graphic__Line_1(numOfIcons) ); |
|
3319 textLayout = anotherTextLayout; |
|
3320 } |
|
3321 else |
|
3322 { |
|
3323 TAknTextLineLayout anotherTextLayout( |
|
3324 AknLayoutScalable_Avkon::list_double_heading_pane_t1(numOfIcons).LayoutLine() ); |
|
3325 textLayout = anotherTextLayout; |
|
3326 } |
|
3327 } |
|
3328 |
|
3329 } |
|
3330 |
|
3331 // Finally, lay out the label |
|
3332 AknLayoutUtils::LayoutLabel( aLabel, layoutRect, textLayout); |
|
3333 |
|
3334 aLabel->SetFont( AknLayoutUtils::FontFromId( textLayout.FontId() ) ) ; |
|
3335 TRgb textColor; |
|
3336 |
|
3337 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
3338 |
|
3339 if (skin) |
|
3340 { |
|
3341 TAknsQsnTextColorsIndex colorIndex = TextColorIndex(); |
|
3342 TInt error = AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnTextColors, colorIndex ); |
|
3343 if (error == KErrNone ) |
|
3344 { |
|
3345 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( *aLabel, EColorLabelText, textColor ) ); |
|
3346 } |
|
3347 } |
|
3348 } |
|
3349 |
|
3350 |
|
3351 // Number editors |
|
3352 void CEikCaptionedControl::FormLayoutControlMfne( |
|
3353 CEikMfne* aMfne, const TRect& aParent, TBool aIsEditable, |
|
3354 TBool aSingleLayout, TInt aNumberOfLines, TBool aBitmapPresent, |
|
3355 TBool /*aIsFocused*/ ) |
|
3356 { |
|
3357 if (!aNumberOfLines) |
|
3358 return; |
|
3359 TAknTextLineLayout layoutMFNE(AKN_LAYOUT_MULTILINE_TEXT_Form_data_field_texts_Line_2(0)); |
|
3360 TRect finalRect(aParent); |
|
3361 if (aSingleLayout) |
|
3362 { |
|
3363 if (aIsEditable) |
|
3364 { |
|
3365 layoutMFNE = AKN_LAYOUT_MULTILINE_TEXT_Form_data_field_texts_Line_2(0); |
|
3366 } |
|
3367 else |
|
3368 { |
|
3369 layoutMFNE =AKN_LAYOUT_TEXT_List_pane_texts__single_graphic_heading__Line_2(0); |
|
3370 } |
|
3371 } |
|
3372 else |
|
3373 { |
|
3374 if (aIsEditable) |
|
3375 { |
|
3376 if (aBitmapPresent) |
|
3377 { |
|
3378 TAknTextLineLayout specificLayout( |
|
3379 AKN_LAYOUT_MULTILINE_TEXT_Form_data_wide_graphic_field_texts_Line_2(aNumberOfLines) ); |
|
3380 layoutMFNE = specificLayout; |
|
3381 } |
|
3382 else |
|
3383 { |
|
3384 TAknTextLineLayout specificLayout( |
|
3385 AKN_LAYOUT_MULTILINE_TEXT_Form_data_wide_field_texts_Line_2(aNumberOfLines) ); |
|
3386 layoutMFNE = specificLayout; |
|
3387 } |
|
3388 } |
|
3389 else |
|
3390 { |
|
3391 if (aBitmapPresent) |
|
3392 { |
|
3393 TAknTextLineLayout specificLayout( |
|
3394 AKN_LAYOUT_TEXT_List_pane_texts__large_single_heading_graphic__Line_2 ); |
|
3395 layoutMFNE = specificLayout; |
|
3396 } |
|
3397 else |
|
3398 { |
|
3399 TAknTextLineLayout specificLayout( |
|
3400 AKN_LAYOUT_TEXT_List_pane_texts__large_single_heading__Line_2 ); |
|
3401 layoutMFNE = specificLayout; |
|
3402 } |
|
3403 |
|
3404 } |
|
3405 } |
|
3406 AknLayoutUtils::LayoutMfne |
|
3407 ( |
|
3408 aMfne, |
|
3409 finalRect, |
|
3410 layoutMFNE |
|
3411 ); |
|
3412 |
|
3413 TRAP_IGNORE( aMfne->SetSkinTextColorL( TextColorIndex() ) ); |
|
3414 |
|
3415 TBool isviewmode = !aIsEditable; |
|
3416 aMfne->SetSuppressBackgroundDrawing(isviewmode); |
|
3417 } |
|
3418 |
|
3419 // Pop-fields |
|
3420 void CEikCaptionedControl::FormLayoutControlPopfield( |
|
3421 CAknPopupField* aPopfield, const TRect& aParent, TBool aIsEditable, |
|
3422 TBool aSingleLayout, TInt aNumberOfLines, TBool aBitmapPresent, |
|
3423 TBool /*aIsFocused*/) |
|
3424 { |
|
3425 TRect layoutRect = aParent; |
|
3426 TAknWindowLineLayout layoutData(AKN_LAYOUT_WINDOW_list_form_pane(aNumberOfLines-1)); |
|
3427 TAknTextLineLayout labelLayout(AknLayout::Form_data_field_texts_Line_2(0)); |
|
3428 if (!aNumberOfLines) |
|
3429 return; |
|
3430 |
|
3431 if (aPopfield->FormMode() == CAknPopupField::EAknFormModeEdit || aPopfield->FormMode() == CAknPopupField::EAknFormModeView) |
|
3432 { |
|
3433 labelLayout = AknLayout::Form_data_field_texts_Line_2(0); |
|
3434 } |
|
3435 else if ( aPopfield->FormMode()==CAknPopupField::EAknFormModeEditWideWithoutGraphic || aPopfield->FormMode()==CAknPopupField::EAknFormModeViewWideWithoutGraphic ) |
|
3436 { |
|
3437 labelLayout = AknLayout::Form_data_wide_field_texts_Line_2(0); |
|
3438 } |
|
3439 else // wide with bitmap for now use wide style |
|
3440 { |
|
3441 labelLayout = AknLayout::Form_data_wide_graphic_field_texts_Line_2(0); |
|
3442 } |
|
3443 TBool isText = EFalse; |
|
3444 if (aPopfield->SelectionMode() == CAknPopupField::EAknPopupFieldLabelMode) |
|
3445 { |
|
3446 isText = ETrue; |
|
3447 } |
|
3448 |
|
3449 if (aSingleLayout) |
|
3450 { |
|
3451 if (aIsEditable) |
|
3452 { |
|
3453 layoutData=AKN_LAYOUT_WINDOW_list_form_pane(aNumberOfLines-1); |
|
3454 } |
|
3455 else |
|
3456 { |
|
3457 /* |
|
3458 popupfields not specified in lists. |
|
3459 Have to convert aParent to form equivalent and use that layout. |
|
3460 */ |
|
3461 ConvertViewRectToEditRect(layoutRect); |
|
3462 layoutData=AKN_LAYOUT_WINDOW_list_form_pane(aNumberOfLines-1); |
|
3463 } |
|
3464 } |
|
3465 else // double layout |
|
3466 { |
|
3467 TInt newpar = ( aBitmapPresent ? 1 : 0 ) ; |
|
3468 if (!aBitmapPresent) |
|
3469 { |
|
3470 if (aIsEditable) |
|
3471 { |
|
3472 layoutData=AKN_LAYOUT_WINDOW_list_form_wide_pane(newpar, aNumberOfLines-1); |
|
3473 } |
|
3474 else |
|
3475 { |
|
3476 // have to convert Rect before doing this. |
|
3477 ConvertViewRectToEditRect(layoutRect); |
|
3478 layoutData=AKN_LAYOUT_WINDOW_list_form_wide_pane(newpar, aNumberOfLines-1); |
|
3479 } |
|
3480 } |
|
3481 else //AKN_LAYOUT_WINDOW_list_form_graphic_wide_pane |
|
3482 { |
|
3483 if (aIsEditable) |
|
3484 { |
|
3485 layoutData=AKN_LAYOUT_WINDOW_list_form_wide_pane(newpar, aNumberOfLines-1); |
|
3486 } |
|
3487 else |
|
3488 { |
|
3489 // have to convert Rect before doing this. |
|
3490 ConvertViewRectToEditRect(layoutRect); |
|
3491 layoutData=AKN_LAYOUT_WINDOW_list_form_wide_pane(newpar, aNumberOfLines-1); |
|
3492 //move bitmap's width for display second line text |
|
3493 TAknWindowLineLayout l = AknLayout::List_pane_elements__single_graphic_heading__Line_1(); |
|
3494 TAknLayoutRect bmpRect; |
|
3495 TRect tempRect; |
|
3496 bmpRect.LayoutRect( tempRect, l ); |
|
3497 layoutRect.iTl.iX += bmpRect.Rect().Width(); |
|
3498 } |
|
3499 } |
|
3500 }; |
|
3501 aPopfield->SetFormFieldRect(layoutRect); |
|
3502 if (isText) |
|
3503 { // popup field will be same size as text element |
|
3504 TAknLayoutText r; |
|
3505 r.LayoutText(layoutRect, labelLayout); |
|
3506 TRect resultRect = r.TextRect(); |
|
3507 aPopfield->SetRect(resultRect); |
|
3508 } |
|
3509 else |
|
3510 { // popup field will be same size as list_pane |
|
3511 AknLayoutUtils::LayoutControl |
|
3512 ( |
|
3513 aPopfield, |
|
3514 layoutRect, |
|
3515 layoutData |
|
3516 ); |
|
3517 } |
|
3518 |
|
3519 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
3520 |
|
3521 if (skin) |
|
3522 { |
|
3523 TRgb textColor; |
|
3524 TAknsQsnTextColorsIndex colorIndex = TextColorIndex(); |
|
3525 TInt error = AknsUtils::GetCachedColor( skin, textColor, KAknsIIDQsnTextColors, colorIndex ); |
|
3526 if (error == KErrNone ) |
|
3527 { |
|
3528 TRAP_IGNORE( AknLayoutUtils::OverrideControlColorL( *aPopfield, EColorLabelText, textColor ) ); |
|
3529 } |
|
3530 } |
|
3531 |
|
3532 } |
|
3533 |
|
3534 // Password editor |
|
3535 void CEikCaptionedControl::FormLayoutControlSecretEditor( |
|
3536 CEikSecretEditor* aSecretEd, const TRect& aParent, TBool aIsEditable, |
|
3537 TBool aSingleLayout, TInt aNumberOfLines, TBool aBitmapPresent, |
|
3538 TBool /*aIsFocused*/) |
|
3539 { |
|
3540 if (!aNumberOfLines) |
|
3541 return; |
|
3542 TAknTextLineLayout layoutSecEd(AKN_LAYOUT_MULTILINE_TEXT_Form_data_field_texts_Line_2(0)); |
|
3543 |
|
3544 if (aSingleLayout) |
|
3545 { |
|
3546 if (aIsEditable) |
|
3547 { |
|
3548 layoutSecEd=AKN_LAYOUT_MULTILINE_TEXT_Form_data_field_texts_Line_2(1); |
|
3549 } |
|
3550 else |
|
3551 { |
|
3552 layoutSecEd = AKN_LAYOUT_TEXT_List_pane_texts__single_graphic_heading__Line_2(0); |
|
3553 } |
|
3554 } |
|
3555 else |
|
3556 { |
|
3557 if (aIsEditable) |
|
3558 { |
|
3559 if (aBitmapPresent) |
|
3560 { |
|
3561 TAknTextLineLayout specificLayout( |
|
3562 AKN_LAYOUT_MULTILINE_TEXT_Form_data_wide_graphic_field_texts_Line_2(aNumberOfLines) ); |
|
3563 layoutSecEd = specificLayout; |
|
3564 } |
|
3565 else |
|
3566 { |
|
3567 TAknTextLineLayout specificLayout( |
|
3568 AKN_LAYOUT_MULTILINE_TEXT_Form_data_wide_field_texts_Line_2(aNumberOfLines) ); |
|
3569 layoutSecEd = specificLayout; |
|
3570 } |
|
3571 } |
|
3572 else |
|
3573 { |
|
3574 if (aBitmapPresent) |
|
3575 { |
|
3576 TAknTextLineLayout specificLayout( |
|
3577 AKN_LAYOUT_TEXT_List_pane_texts__large_single_heading_graphic__Line_2 ); |
|
3578 layoutSecEd = specificLayout; |
|
3579 } |
|
3580 else |
|
3581 { |
|
3582 TAknTextLineLayout specificLayout( |
|
3583 AKN_LAYOUT_TEXT_List_pane_texts__large_single_heading__Line_2 ); |
|
3584 layoutSecEd = specificLayout; |
|
3585 } |
|
3586 } |
|
3587 } |
|
3588 AknLayoutUtils::LayoutSecretEditor |
|
3589 ( |
|
3590 aSecretEd, |
|
3591 aParent, |
|
3592 layoutSecEd |
|
3593 ); |
|
3594 |
|
3595 TRAP_IGNORE( aSecretEd->SetSkinTextColorL( TextColorIndex() ) ); |
|
3596 } |
|
3597 |
|
3598 // Slider control |
|
3599 void CEikCaptionedControl::FormLayoutControlSlider(CAknSlider* aSlider, const TRect& aParent, TBool aIsEditable, TBool aSingleLayout, TInt aNumberOfLines, TBool /*aBitmapPresent*/) |
|
3600 { |
|
3601 if (!aNumberOfLines) |
|
3602 return; |
|
3603 if (aSingleLayout) |
|
3604 { |
|
3605 if (aIsEditable) |
|
3606 { |
|
3607 aSlider->SetRect(aParent); |
|
3608 } |
|
3609 else |
|
3610 { |
|
3611 /* |
|
3612 sliders not specified in lists. |
|
3613 Have to convert aParent to form equivalent and use that layout. |
|
3614 */ |
|
3615 TRect conversionRect(aParent); |
|
3616 ConvertViewRectToEditRect(conversionRect); |
|
3617 aSlider->SetRect(conversionRect); |
|
3618 } |
|
3619 } |
|
3620 else |
|
3621 { |
|
3622 // Not currently specified, so making temporary alterations here. |
|
3623 TInt baselineSkip= AKN_LAYOUT_MULTILINE_TEXT_Form_data_field_texts_Line_2(1).BaselineSkip(); |
|
3624 TRect newParentRect(aParent); |
|
3625 //Only move the rect will cover a part or next dialogline, so decrease height of rect form iTl. |
|
3626 if( !aIsEditable ) |
|
3627 { |
|
3628 newParentRect.iTl.iX += baselineSkip; |
|
3629 } |
|
3630 newParentRect.iTl.iY += baselineSkip; |
|
3631 |
|
3632 if (aIsEditable) |
|
3633 { |
|
3634 aSlider->SetRect(newParentRect); |
|
3635 } |
|
3636 else |
|
3637 { |
|
3638 TRect conversionRect(newParentRect); |
|
3639 ConvertViewRectToEditRect(conversionRect); |
|
3640 aSlider->SetRect(conversionRect); |
|
3641 } |
|
3642 } |
|
3643 |
|
3644 // Exteded skin support for sliders coded in slider file: \s60\AvKon\src\Aknslider.cpp |
|
3645 } |
|
3646 |
|
3647 void CEikCaptionedControl::ConvertViewRectToEditRect(TRect& aRect) |
|
3648 { |
|
3649 aRect.Grow(-1,1); |
|
3650 aRect.iBr.iX--; |
|
3651 } |
|
3652 |
|
3653 void CEikCaptionedControl::ConvertEditRectToViewRect(TRect& aRect) |
|
3654 { |
|
3655 aRect.Shrink(-1,1); |
|
3656 aRect.iBr.iX++; |
|
3657 } |
|
3658 |
|
3659 // Standard access method for the form layout from within captioned control |
|
3660 CEikDialogPage::TFormLayoutSelection CEikCaptionedControl::FormLayout() const |
|
3661 { |
|
3662 // There is no undefined style, but initialize to single... |
|
3663 CEikDialogPage::TFormLayoutSelection ret = CEikDialogPage::ESingle; |
|
3664 if ( iDialogPage ) |
|
3665 ret = iDialogPage->FormLayout(); |
|
3666 |
|
3667 if (!iDialogPage) |
|
3668 { |
|
3669 if (iFlags & EEikFormUseDoubleSpacedFormat) // similar to CEikDialogPage::ConstructFormFromResourceL() |
|
3670 ret = CEikDialogPage::EDouble; |
|
3671 } |
|
3672 return ret; |
|
3673 } |
|
3674 |
|
3675 void CEikCaptionedControl::DrawFormSeparator( CWindowGc& gc ) const |
|
3676 { |
|
3677 TAknLayoutRect sepLineRect; |
|
3678 if ( FormLayout() == CEikDialogPage::ESingle ) |
|
3679 { |
|
3680 sepLineRect.LayoutRect |
|
3681 ( |
|
3682 ViewRect(), |
|
3683 AKN_LAYOUT_WINDOW_List_pane_elements__single_heading__Line_2 |
|
3684 ); |
|
3685 sepLineRect.DrawRect(gc); |
|
3686 |
|
3687 } |
|
3688 // else |
|
3689 // { |
|
3690 // Currently no LAF specification for separator in double mode |
|
3691 // sepLineRect.LayoutRect |
|
3692 // ( |
|
3693 // ViewRect(), |
|
3694 // AKN_LAYOUT_WINDOW_List_pane_elements__double_graphic__Line_?? |
|
3695 // ); |
|
3696 // sepLineRect.DrawRect(gc); |
|
3697 // |
|
3698 // } |
|
3699 } |
|
3700 |
|
3701 void CEikCaptionedControl::DrawClosingLine() const |
|
3702 { |
|
3703 if (iHighlightControl) |
|
3704 iHighlightControl->DrawDeferred(); |
|
3705 }; |
|
3706 |
|
3707 /** |
|
3708 * Ensure that iExtension is constructed (there is no BaseConstructL() in which to place this stuff) |
|
3709 * |
|
3710 */ |
|
3711 void CEikCaptionedControl::ConstructExtensionL() |
|
3712 { |
|
3713 if ( !iExtension ) |
|
3714 { |
|
3715 iExtension = new (ELeave) CEikCapCExtension ; |
|
3716 iExtension->iSelf = this ; |
|
3717 SetPressedDownState( EFalse ); |
|
3718 |
|
3719 if ( iIsFormControl ) |
|
3720 { |
|
3721 TRect innerRect, outerRect ; // Place holder rectangles |
|
3722 iExtension->iEditModeHighlightControlContext = CAknsFrameBackgroundControlContext::NewL( |
|
3723 KAknsIIDQsnFrInput, outerRect, innerRect, EFalse /*parent absolute*/ ) ; |
|
3724 iExtension->iEditModeHighlightControlContextPressed = CAknsFrameBackgroundControlContext::NewL( |
|
3725 KAknsIIDQsnFrListPressed, outerRect, innerRect, EFalse /*parent absolute*/ ) ; |
|
3726 iExtension->iViewModeHighlightControlContext = CAknsFrameBackgroundControlContext::NewL( |
|
3727 KAknsIIDQsnFrList, outerRect, innerRect, EFalse /*parent absolute*/ ) ; |
|
3728 iExtension->iViewModeHighlightControlContextPressed = CAknsFrameBackgroundControlContext::NewL( |
|
3729 KAknsIIDQsnFrListPressed, outerRect, innerRect, EFalse /*parent absolute*/ ) ; |
|
3730 } |
|
3731 } |
|
3732 } |
|
3733 |
|
3734 EXPORT_C TTypeUid::Ptr CEikCaptionedControl::MopSupplyObject(TTypeUid aId) |
|
3735 { |
|
3736 if ( aId.iUid == MAknsControlContext::ETypeId && iIsFormControl ) |
|
3737 { |
|
3738 if ( iIsFormControl && iIsCurrentLine && iExtension ) |
|
3739 { |
|
3740 // The highlighted field in Forms has its own context. Otherwise take that of the MOP Parent. |
|
3741 if ( iIsEditable ) |
|
3742 if ( PressedDownState() ) |
|
3743 { |
|
3744 return ( MAknsControlContext::SupplyMopObject( aId, iExtension->iEditModeHighlightControlContextPressed ) ) ; |
|
3745 } |
|
3746 else |
|
3747 { |
|
3748 return ( MAknsControlContext::SupplyMopObject( aId, iExtension->iEditModeHighlightControlContext ) ) ; |
|
3749 } |
|
3750 else |
|
3751 if ( PressedDownState() ) |
|
3752 { |
|
3753 return ( MAknsControlContext::SupplyMopObject( aId, iExtension->iViewModeHighlightControlContextPressed ) ) ; |
|
3754 } |
|
3755 else |
|
3756 { |
|
3757 return ( MAknsControlContext::SupplyMopObject( aId, iExtension->iViewModeHighlightControlContext ) ) ; |
|
3758 } |
|
3759 } |
|
3760 } |
|
3761 // Otherwise, do a base call to immediate parent class |
|
3762 return CCoeControl::MopSupplyObject( aId ) ; |
|
3763 } |
|
3764 |
|
3765 void CEikCaptionedControl::LayoutSkinControlContexts() |
|
3766 { |
|
3767 TRect outerRect( Rect() ); |
|
3768 TRect innerRect( outerRect ); |
|
3769 |
|
3770 // Only lay out the "current" context |
|
3771 if ( iIsEditable ) |
|
3772 { |
|
3773 innerRect.iTl = EditFrameTopLeftRect( outerRect ).iBr ; |
|
3774 innerRect.iBr = EditFrameBottomRightRect( outerRect ).iTl ; |
|
3775 iExtension->iEditModeHighlightControlContext->SetFrameRects( outerRect, innerRect); |
|
3776 iExtension->iEditModeHighlightControlContext->SetParentContext( |
|
3777 GetDialogControlContext( iDialogPage ) ); |
|
3778 iExtension->iEditModeHighlightControlContextPressed->SetFrameRects( outerRect, innerRect); |
|
3779 iExtension->iEditModeHighlightControlContextPressed->SetParentContext( |
|
3780 GetDialogControlContext( iDialogPage ) ); |
|
3781 } |
|
3782 else |
|
3783 { |
|
3784 outerRect = ViewRect() ; |
|
3785 innerRect = outerRect ; |
|
3786 innerRect.iTl = ViewFrameTopLeftRect( outerRect ).iBr ; |
|
3787 innerRect.iBr = ViewFrameBottomRightRect( outerRect ).iTl ; |
|
3788 iExtension->iViewModeHighlightControlContext->SetFrameRects( outerRect, innerRect ); |
|
3789 iExtension->iViewModeHighlightControlContext->SetParentContext( |
|
3790 GetDialogControlContext( iDialogPage ) ); |
|
3791 iExtension->iViewModeHighlightControlContextPressed->SetFrameRects( outerRect, innerRect); |
|
3792 iExtension->iViewModeHighlightControlContextPressed->SetParentContext( |
|
3793 GetDialogControlContext( iDialogPage ) ); |
|
3794 } |
|
3795 } |
|
3796 |
|
3797 TBool CEikCaptionedControl::PressedDownState() const |
|
3798 { |
|
3799 return iExtension->iPressDownEffect; |
|
3800 } |
|
3801 |
|
3802 void CEikCaptionedControl::SetPressedDownState( TBool aPressed ) |
|
3803 { |
|
3804 // there's no pressed down highlight in single click UI |
|
3805 if ( !iExtension->iUsesSingleClick ) |
|
3806 { |
|
3807 iExtension->iPressDownEffect = aPressed; |
|
3808 } |
|
3809 } |
|
3810 |
|
3811 void CEikCaptionedControl::DrawAsSkinnedForm( CWindowGc& aGc, const TRect& /*aRect*/ ) const |
|
3812 { |
|
3813 MAknsSkinInstance* skin = AknsUtils::SkinInstance() ; |
|
3814 |
|
3815 if ( !iIsCurrentLine ) |
|
3816 { |
|
3817 aGc.SetBrushStyle( CGraphicsContext::ENullBrush ) ; |
|
3818 } |
|
3819 else // Highlight Skinning. Requires Frame |
|
3820 { |
|
3821 if ( iIsEditable ) |
|
3822 { |
|
3823 TRect innerRect( EditRect() ) ; |
|
3824 innerRect.iTl = EditFrameTopLeftRect( Rect() ).iBr ; |
|
3825 innerRect.iBr = EditFrameBottomRightRect( Rect() ).iTl ; |
|
3826 |
|
3827 MAknsControlContext* parentCc = GetDialogControlContext( iDialogPage ) ; |
|
3828 AknsDrawUtils::Background( skin, parentCc, this, aGc, Rect() ) ; |
|
3829 |
|
3830 // Set the rectangle(s) for the Frame context |
|
3831 iExtension->iEditModeHighlightControlContext->SetFrameRects( EditRect(), innerRect ) ; |
|
3832 iExtension->iEditModeHighlightControlContextPressed->SetFrameRects( EditRect(), innerRect ) ; |
|
3833 |
|
3834 AknsDrawUtils::DrawFrame( skin, aGc, EditRect(), innerRect, |
|
3835 PressedDownState() ? |
|
3836 KAknsIIDQsnFrListPressed : KAknsIIDQsnFrInput, KAknsIIDDefault ); |
|
3837 } |
|
3838 else // View Mode highlight |
|
3839 { |
|
3840 TBool drawOk = EFalse; |
|
3841 if( iExtension->IsHighlightAnimated() ) // Draw animated highlight |
|
3842 { |
|
3843 CAknsEffectAnim* anim = iExtension->iAnimation->Animation(); |
|
3844 |
|
3845 // TODO: Background is drawn first to prevent white stripes |
|
3846 // appearing above and below the highlight. Wasting resources |
|
3847 // here, you could create animation that is a tad bigger and |
|
3848 // remove background drawing from here. |
|
3849 TRect viewRect = ViewRect() ; |
|
3850 TRect innerRect( viewRect ) ; |
|
3851 innerRect.iTl = ViewFrameTopLeftRect( viewRect ).iBr ; |
|
3852 innerRect.iTl.iX-- ; innerRect.iTl.iY-- ; // not sure why this adjustment is required here and not above. |
|
3853 innerRect.iBr = ViewFrameBottomRightRect( viewRect ).iTl ; |
|
3854 |
|
3855 // The bit around the outside must use the parent's control context |
|
3856 MAknsControlContext* parentCc = GetDialogControlContext( iDialogPage ) ; |
|
3857 AknsDrawUtils::BackgroundBetweenRects( skin, parentCc, this, aGc, Rect() , innerRect ) ; |
|
3858 |
|
3859 // Draw the animation itself |
|
3860 if( anim ) |
|
3861 { |
|
3862 drawOk = anim->Render( aGc, ViewRect() ); |
|
3863 } |
|
3864 } |
|
3865 |
|
3866 if( !drawOk ) |
|
3867 { |
|
3868 // Code for skinning Highlight ( Using AVKON LAF highlight in place of |
|
3869 // Skins LAF to establish highlight outer rect ) |
|
3870 TRect viewRect = ViewRect() ; |
|
3871 TRect innerRect( viewRect ) ; |
|
3872 innerRect.iTl = ViewFrameTopLeftRect( viewRect ).iBr ; |
|
3873 innerRect.iTl.iX-- ; innerRect.iTl.iY-- ; // not sure why this adjustment is required here and not above. |
|
3874 innerRect.iBr = ViewFrameBottomRightRect( viewRect ).iTl ; |
|
3875 |
|
3876 // The bit around the outside must use the parent's control context |
|
3877 MAknsControlContext* parentCc = GetDialogControlContext( iDialogPage ) ; |
|
3878 AknsDrawUtils::BackgroundBetweenRects( skin, parentCc, this, aGc, Rect() , innerRect ) ; |
|
3879 |
|
3880 // Set the rectangle(s) for the Frame context |
|
3881 iExtension->iViewModeHighlightControlContext->SetFrameRects( viewRect, innerRect ) ; |
|
3882 iExtension->iViewModeHighlightControlContextPressed->SetFrameRects( viewRect, innerRect ) ; |
|
3883 |
|
3884 AknsDrawUtils::DrawFrame( skin, aGc, viewRect, innerRect, |
|
3885 PressedDownState() ? |
|
3886 KAknsIIDQsnFrListPressed : KAknsIIDQsnFrList, KAknsIIDDefault ); |
|
3887 } |
|
3888 } |
|
3889 } |
|
3890 |
|
3891 // Enable/disable the control line as required. (Hide first, show if necessary) |
|
3892 TBool showHighlightControl = EFalse ; |
|
3893 |
|
3894 if (iDialogPage&& iHighlightControl && iIsCurrentLine ) |
|
3895 { |
|
3896 TInt height(Rect().Height()); |
|
3897 TBool top = iDialogPage->VisibleSizeOnPage(height,iControl); |
|
3898 if (height<Rect().Height()) |
|
3899 { |
|
3900 CEikCaptionedControlFormHighlightLine::TTopOrBottom topOrBottom = (top) ? CEikCaptionedControlFormHighlightLine::ETop : CEikCaptionedControlFormHighlightLine::EBottom; |
|
3901 TInt heightOfHighlight = STATIC_CAST(CEikCaptionedControlFormHighlightLine*,iHighlightControl)->HeightOfHighlight(topOrBottom); |
|
3902 // is off page, and needs a line drawing. |
|
3903 TRect controlRect = (top) |
|
3904 ? TRect |
|
3905 ( |
|
3906 TPoint(Rect().iTl.iX,Rect().iBr.iY-height), |
|
3907 TPoint(Rect().iBr.iX,Rect().iBr.iY-(height-heightOfHighlight)) |
|
3908 ) |
|
3909 : TRect |
|
3910 ( |
|
3911 TPoint(Rect().iTl.iX,Rect().iTl.iY+(height-heightOfHighlight)), |
|
3912 TPoint(Rect().iBr.iX,Rect().iTl.iY+height) |
|
3913 ); |
|
3914 iHighlightControl->SetRect(controlRect); |
|
3915 STATIC_CAST(CEikCaptionedControlFormHighlightLine*,iHighlightControl)->SetTopOrBottom(topOrBottom); |
|
3916 showHighlightControl = ETrue ; |
|
3917 } |
|
3918 } |
|
3919 if (iHighlightControl) |
|
3920 { |
|
3921 iHighlightControl->MakeVisible( showHighlightControl ); |
|
3922 } |
|
3923 } |
|
3924 |
|
3925 TBool CEikCaptionedControl::DrawingSkins() const |
|
3926 { |
|
3927 TBool drawingSkins = EFalse; |
|
3928 if ( AknsUtils::AvkonSkinEnabled() ) |
|
3929 { |
|
3930 MAknsSkinInstance* skin = AknsUtils::SkinInstance() ; |
|
3931 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ) ; |
|
3932 CWindowGc& gc = SystemGc(); |
|
3933 drawingSkins = AknsDrawUtils::Background( skin, cc, this, gc, Rect(), KAknsDrawParamPrepareOnly ); |
|
3934 } |
|
3935 return drawingSkins; |
|
3936 } |
|
3937 |
|
3938 EXPORT_C void CEikCaptionedControl::SetIconL( CFbsBitmap* aBitmap, CFbsBitmap* aMask ) |
|
3939 { |
|
3940 SetIconSizeL(aBitmap); |
|
3941 |
|
3942 if ( iBitmap ) |
|
3943 delete iBitmap; |
|
3944 iBitmap = 0; |
|
3945 iBitmap = new ( ELeave ) CEikImage(); |
|
3946 iBitmap->SetPicture(aBitmap, aMask); |
|
3947 } |
|
3948 |
|
3949 EXPORT_C void CEikCaptionedControl::SetIndicatorIconL( TInt aIcon, CFbsBitmap *aBitmap, CFbsBitmap *aMask ) |
|
3950 { |
|
3951 if (aIcon == 0) |
|
3952 { |
|
3953 if (iExtension) |
|
3954 { |
|
3955 if (aBitmap == NULL) |
|
3956 { |
|
3957 delete iExtension->iIndicator; |
|
3958 iExtension->iIndicator = 0; |
|
3959 } |
|
3960 else |
|
3961 { |
|
3962 if (!iExtension->iIndicator) |
|
3963 { |
|
3964 iExtension->iIndicator = new(ELeave) CEikImage(); |
|
3965 iExtension->iIndicator->SetContainerWindowL(*this); |
|
3966 iExtension->iIndicator->CopyControlContextFrom(this); |
|
3967 iExtension->iIndicator->SetNonFocusing(); |
|
3968 iExtension->iIndicator->SetBrushStyle(CGraphicsContext::ENullBrush ); |
|
3969 } |
|
3970 iExtension->iIndicator->SetPicture(aBitmap, aMask); |
|
3971 } |
|
3972 } |
|
3973 } |
|
3974 else if (aIcon == 1) |
|
3975 { |
|
3976 if (iExtension) |
|
3977 { |
|
3978 if (aBitmap == NULL) |
|
3979 { |
|
3980 delete iExtension->iIndicator2; |
|
3981 iExtension->iIndicator2 = 0; |
|
3982 } |
|
3983 else |
|
3984 { |
|
3985 if (!iExtension->iIndicator2) |
|
3986 { |
|
3987 iExtension->iIndicator2 = new(ELeave) CEikImage(); |
|
3988 iExtension->iIndicator2->SetContainerWindowL(*this); |
|
3989 iExtension->iIndicator2->CopyControlContextFrom(this); |
|
3990 iExtension->iIndicator2->SetNonFocusing(); |
|
3991 iExtension->iIndicator2->SetBrushStyle(CGraphicsContext::ENullBrush ); |
|
3992 } |
|
3993 iExtension->iIndicator2->SetPicture(aBitmap, aMask); |
|
3994 |
|
3995 } |
|
3996 } |
|
3997 } |
|
3998 } |
|
3999 |
|
4000 void CEikCaptionedControl::SetIconSizeL(CFbsBitmap* aBitmap) |
|
4001 { |
|
4002 if (iIsFormControl && iIsEditable) |
|
4003 { |
|
4004 TAknWindowLineLayout l = AknLayout::Form_data_field_elements_Line_4(); |
|
4005 TAknLayoutRect layoutRect; |
|
4006 TRect parentRect = Rect(); |
|
4007 layoutRect.LayoutRect( parentRect, l ); |
|
4008 TRect rectElements( layoutRect.Rect() ); |
|
4009 |
|
4010 User::LeaveIfError(AknIconUtils::SetSize(aBitmap, |
|
4011 rectElements.Size() )); |
|
4012 } |
|
4013 else |
|
4014 { |
|
4015 TAknWindowLineLayout l = AknLayout::List_pane_elements__single_graphic_heading__Line_1(); |
|
4016 TAknLayoutRect layoutRect; |
|
4017 TRect parentRect = Rect(); |
|
4018 layoutRect.LayoutRect( parentRect, l ); |
|
4019 TRect rectElements( layoutRect.Rect() ); |
|
4020 |
|
4021 User::LeaveIfError(AknIconUtils::SetSize(aBitmap, |
|
4022 rectElements.Size() )); |
|
4023 } |
|
4024 /* |
|
4025 |
|
4026 if (iIsFormControl) |
|
4027 { |
|
4028 if (iIsEditable) |
|
4029 { |
|
4030 if (iBitmap && iBitmap->Bitmap()) |
|
4031 { |
|
4032 AknIconUtils::SetSize(CONST_CAST(CFbsBitmap*, iBitmap->Bitmap()), |
|
4033 TSize(AKN_LAYOUT_WINDOW_Form_data_field_elements_Line_4.iW, |
|
4034 AKN_LAYOUT_WINDOW_Form_data_field_elements_Line_4.iH)); |
|
4035 } |
|
4036 } |
|
4037 else |
|
4038 { |
|
4039 if (iBitmap && iBitmap->Bitmap()) |
|
4040 { |
|
4041 AknIconUtils::SetSize(CONST_CAST(CFbsBitmap*, iBitmap->Bitmap()), |
|
4042 TSize(AKN_LAYOUT_WINDOW_List_pane_elements__single_graphic_heading__Line_1.iW, |
|
4043 AKN_LAYOUT_WINDOW_List_pane_elements__single_graphic_heading__Line_1.iH)); |
|
4044 } |
|
4045 } |
|
4046 } |
|
4047 else |
|
4048 { |
|
4049 if (iBitmap && iBitmap->Bitmap()) |
|
4050 { |
|
4051 AknIconUtils::SetSize(CONST_CAST(CFbsBitmap*, iBitmap->Bitmap()), |
|
4052 TSize(AKN_LAYOUT_WINDOW_List_pane_elements__single_graphic_heading__Line_1.iW, |
|
4053 AKN_LAYOUT_WINDOW_List_pane_elements__single_graphic_heading__Line_1.iH)); |
|
4054 } |
|
4055 } */ |
|
4056 } |
|
4057 |
|
4058 |
|
4059 |
|
4060 // ----------------------------------------------------------------------------- |
|
4061 // CEikCaptionedControl::HandleControlEventL |
|
4062 // Implementation of MCoeControlObserver observer interface for observing touch button |
|
4063 // events used with MFNE editors. |
|
4064 // ----------------------------------------------------------------------------- |
|
4065 // |
|
4066 EXPORT_C void CEikCaptionedControl::HandleControlEventL(CCoeControl* /*aControl*/, |
|
4067 MCoeControlObserver::TCoeEvent /*aEventType*/) |
|
4068 { |
|
4069 } |
|
4070 |
|
4071 MAknsControlContext* CEikCaptionedControl::GetDialogControlContext(const CCoeControl* aDialog) const |
|
4072 { |
|
4073 MAknsControlContext* parentCc = AknsDrawUtils::ControlContext(aDialog); |
|
4074 if (!parentCc) |
|
4075 { |
|
4076 // try to find a window owning parent control |
|
4077 const CCoeControl* parent = WindowOwningParent(); |
|
4078 parentCc = AknsDrawUtils::ControlContext(parent); |
|
4079 } |
|
4080 return parentCc; |
|
4081 } |
|
4082 |
|
4083 const CCoeControl* CEikCaptionedControl::WindowOwningParent() const |
|
4084 { |
|
4085 const CCoeControl* parent = this; |
|
4086 |
|
4087 while ( parent && !parent->OwnsWindow() ) |
|
4088 { |
|
4089 parent = parent->Parent(); |
|
4090 } |
|
4091 |
|
4092 return parent; |
|
4093 } |
|
4094 |
|
4095 void CEikCaptionedControl::SetCurrent(TBool aSelected, TBool aRedraw) |
|
4096 { |
|
4097 if (aSelected) |
|
4098 iCapCFlags|=ECurrent; |
|
4099 else |
|
4100 iCapCFlags&=(~ECurrent); |
|
4101 iIsCurrentLine=aSelected; |
|
4102 |
|
4103 // Only form controls need to play animation |
|
4104 if( iDialogPage && iIsFormControl ) |
|
4105 { |
|
4106 if( !aSelected ) |
|
4107 { |
|
4108 // Deselected -> unacquire animation |
|
4109 if( iExtension->iAnimation ) |
|
4110 { |
|
4111 iExtension->iAnimation->Pause(); |
|
4112 iExtension->iAnimation = iDialogPage->AcquireAnim( EFalse, iExtension ); |
|
4113 } |
|
4114 } |
|
4115 else |
|
4116 { |
|
4117 // Acquire highlight animation |
|
4118 if( !iIsEditable ) |
|
4119 { |
|
4120 iExtension->iAnimation = iDialogPage->AcquireAnim( ETrue, iExtension ); |
|
4121 |
|
4122 if( iExtension->iAnimation ) |
|
4123 { |
|
4124 // We need to apply the size because different lines can be |
|
4125 // of different size (at least in theory). |
|
4126 if( iExtension->iAnimation->Size() == Rect().Size() ) |
|
4127 { |
|
4128 // No need to resize, just change the background used |
|
4129 // as animation input. |
|
4130 iExtension->iAnimation->ChangeHighlightBackground(); |
|
4131 } |
|
4132 else |
|
4133 { |
|
4134 iExtension->iAnimation->SetHighlightSize( Rect().Size() ); |
|
4135 } |
|
4136 |
|
4137 // Animation playing is not started here (it is done when |
|
4138 // focus is received). |
|
4139 } |
|
4140 } |
|
4141 } |
|
4142 } |
|
4143 |
|
4144 if ( iIsFormControl || !aRedraw ) |
|
4145 SetFocus(aSelected,ENoDrawNow); |
|
4146 else |
|
4147 SetFocus(aSelected,EDrawNow); |
|
4148 } |
|
4149 |
|
4150 |
|
4151 void CEikCaptionedControl::SetPartiallyVisible( TBool aPVisible ) |
|
4152 { |
|
4153 iExtension->iPartiallyVisible = aPVisible; |
|
4154 } |
|
4155 |
|
4156 /* |
|
4157 * Special Label Class which appends colon to label text |
|
4158 */ |
|
4159 |
|
4160 CEikCapCLabel::CEikCapCLabel() : iIsColonEnabled( EFalse ) |
|
4161 { |
|
4162 } |
|
4163 |
|
4164 CEikCapCLabel::~CEikCapCLabel() |
|
4165 { |
|
4166 } |
|
4167 |
|
4168 void CEikCapCLabel::Draw( const TRect& aRect ) const |
|
4169 { |
|
4170 |
|
4171 // <SKIN> // Make the caption label transparent. Has to be done here as other labels (eg popupfield) rely on opaque labels. |
|
4172 CWindowGc& gc = SystemGc() ; |
|
4173 gc.SetBrushStyle( CGraphicsContext::ENullBrush ) ; |
|
4174 |
|
4175 if ( ColonEnabled() ) |
|
4176 { |
|
4177 TRAPD( err, const_cast<CEikCapCLabel*>(this)->DrawL( aRect ) ) ; // const_cast and TRAP required to call DrawL() function |
|
4178 if ( err != KErrNone ) |
|
4179 CEikLabel::Draw( aRect ) ; |
|
4180 } |
|
4181 else |
|
4182 CEikLabel::Draw( aRect ) ; |
|
4183 } |
|
4184 |
|
4185 |
|
4186 //static const TInt KUnicodeLeftToRightMark = 0x200E; |
|
4187 //static const TInt KUnicodeRightToLeftMark = 0x200F; |
|
4188 |
|
4189 |
|
4190 void CEikCapCLabel::DrawL( const TRect& /*aRect*/ ) |
|
4191 { |
|
4192 // It might be necessary to expand the label to accommodate the colon without reducing the space available for text. |
|
4193 // Store the original size so that it can be restored. |
|
4194 TRect originalRect( Rect() ); |
|
4195 TRect modifiedRect( originalRect ); |
|
4196 |
|
4197 // Store a pointer to the existing text |
|
4198 HBufC* storedText = iText; |
|
4199 // Create a local copy to modify, +1 is for colon |
|
4200 HBufC* labelText = HBufC::NewLC( |
|
4201 storedText->Length() + KAknBidiExtraSpacePerLine + 1 ); |
|
4202 |
|
4203 *labelText = *storedText; |
|
4204 TPtr ptr = labelText->Des(); |
|
4205 |
|
4206 AknBidiTextUtils::TParagraphDirectionality directionality = |
|
4207 AknLayoutUtils::LayoutMirrored() ? |
|
4208 AknBidiTextUtils::ERightToLeft : |
|
4209 AknBidiTextUtils::ELeftToRight; |
|
4210 |
|
4211 AknBidiTextUtils::ConvertToVisualAndClipL( |
|
4212 ptr, |
|
4213 *Font(), |
|
4214 Size().iWidth, |
|
4215 Size().iWidth, |
|
4216 directionality ); |
|
4217 |
|
4218 // Increase the size of the control to ensure that the colon can be fitted in. |
|
4219 TInt colonWidthInPixels = Font()->CharWidthInPixels( ':' ); |
|
4220 |
|
4221 if ( AknLayoutUtils::LayoutMirrored() ) |
|
4222 { |
|
4223 modifiedRect.iTl.iX -= colonWidthInPixels ; |
|
4224 } |
|
4225 else |
|
4226 { |
|
4227 modifiedRect.iBr.iX += colonWidthInPixels ; |
|
4228 } |
|
4229 SetRect( modifiedRect ) ; |
|
4230 |
|
4231 // Insert colon (in the beginning or in the end of the visual line) |
|
4232 |
|
4233 _LIT( KColon, ":" ); |
|
4234 |
|
4235 if ( AknLayoutUtils::LayoutMirrored() ) |
|
4236 { |
|
4237 ptr.Insert( 0, KColon ); |
|
4238 } |
|
4239 else |
|
4240 { |
|
4241 ptr.Append( KColon ); |
|
4242 } |
|
4243 |
|
4244 // Switch the adjusted text in, draw it, and then restore the original text and dimensions |
|
4245 iText = labelText ; |
|
4246 |
|
4247 TBool normalState = |
|
4248 LogicalToVisualConversionUsed(); |
|
4249 |
|
4250 // Disable logical-to-visual conversion in CEikLabel |
|
4251 // because we have done it already |
|
4252 UseLogicalToVisualConversion( EFalse ); |
|
4253 CEikLabel::Draw( modifiedRect ) ; |
|
4254 |
|
4255 UseLogicalToVisualConversion( normalState ); |
|
4256 iText = storedText ; |
|
4257 SetRect( originalRect ) ; |
|
4258 |
|
4259 CleanupStack::PopAndDestroy() ; // labelText |
|
4260 } |
|
4261 |
|
4262 TBool CEikCapCLabel::ColonEnabled() const |
|
4263 { |
|
4264 return ( iIsColonEnabled ) ; |
|
4265 } |
|
4266 |
|
4267 void CEikCapCLabel::EnableColon( TBool aEnable ) |
|
4268 { |
|
4269 iIsColonEnabled = aEnable ; |
|
4270 } |
|
4271 |
|
4272 |