|
1 /* |
|
2 * Copyright (c) 2002-2008 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: Tab control for the status pane's navigation pane. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef AKNTABGRP_H |
|
20 #define AKNTABGRP_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <AknControl.h> |
|
24 #include <coeccntx.h> |
|
25 #include <coecobs.h> |
|
26 #include <AknNaviDecoratorObserver.h> |
|
27 #include "aknconsts.h" |
|
28 #include "AknUtils.h" |
|
29 |
|
30 #include <avkon.mbg> |
|
31 |
|
32 |
|
33 // FORWARD DECLARATIONS |
|
34 |
|
35 class CEikLabel; |
|
36 class CEikImage; |
|
37 class CAknTabGroup; |
|
38 class CAknTabGroupExtension; |
|
39 class MAknTabObserver; |
|
40 class MAknNaviDecoratorObserver; |
|
41 class TAknWindowLineLayout; |
|
42 class CAknTabExtension; |
|
43 |
|
44 /** |
|
45 * Tab item control used inside a tab group. |
|
46 * |
|
47 * @lib avkon.lib |
|
48 * @since 0.9 |
|
49 */ |
|
50 NONSHARABLE_CLASS( CAknTab ) : public CAknControl |
|
51 { |
|
52 friend class CAknTabGroup; |
|
53 |
|
54 public: |
|
55 |
|
56 /** |
|
57 * Indicates a tab title's type |
|
58 */ |
|
59 enum TAknTabDataType |
|
60 { |
|
61 /** Tab title is empty.*/ |
|
62 EAknTabNone, |
|
63 /** Tab title has only text. */ |
|
64 EAknTabText, |
|
65 /** Tab title has only icon */ |
|
66 EAknTabIcon, |
|
67 /** Tab title has both text and icon. */ |
|
68 EAknTabTextAndIcon |
|
69 }; |
|
70 |
|
71 public: |
|
72 |
|
73 /** |
|
74 * Destructor |
|
75 */ |
|
76 ~CAknTab(); |
|
77 |
|
78 /** |
|
79 * Two-phased constructor. |
|
80 * |
|
81 * @param aParent Reference to parent control. |
|
82 * @param aReader Reference to resource reader. |
|
83 * |
|
84 * @return A pointer to constructed @c CAknTab object. |
|
85 */ |
|
86 static CAknTab* NewL( const CCoeControl& aParent, |
|
87 TResourceReader& aReader ); |
|
88 |
|
89 /** |
|
90 * Two-phased constructor. |
|
91 * |
|
92 * @param aParent Reference to parent control. |
|
93 * @param aReader Reference to resource reader. |
|
94 * |
|
95 * @return A pointer to constructed @c CAknTab object. |
|
96 */ |
|
97 static CAknTab* NewLC( const CCoeControl& aParent, |
|
98 TResourceReader& aReader ); |
|
99 |
|
100 /** |
|
101 * Two-phased constructor. |
|
102 * |
|
103 * @param aId Tab ID. |
|
104 * @param aParent Reference to parent control. |
|
105 * @param aTabText Reference to title text. |
|
106 * |
|
107 * @return A pointer to constructed @c CAknTab object. |
|
108 */ |
|
109 static CAknTab* NewL( TInt aId, |
|
110 const CCoeControl& aParent, |
|
111 const TDesC& aTabText ); |
|
112 |
|
113 /** |
|
114 * Two-phased constructor. |
|
115 * |
|
116 * @param aId Tab ID. |
|
117 * @param aParent Reference to parent control. |
|
118 * @param aTabText Reference to title text. |
|
119 * |
|
120 * @return A pointer to constructed @c CAknTab object. |
|
121 */ |
|
122 static CAknTab* NewLC( TInt aId, |
|
123 const CCoeControl& aParent, |
|
124 const TDesC& aTabText ); |
|
125 |
|
126 /** |
|
127 * Two-phased constructor. |
|
128 * |
|
129 * @param aId Tab ID. |
|
130 * @param aParent Reference to parent control. |
|
131 * @param aTabText Reference to title text. |
|
132 * @param aTabBitmap Bitmap for the tab. Ownership of the bitmap is taken. |
|
133 * @param aMask Bitmap's mask. Ownership of the mask is taken. |
|
134 * |
|
135 * @return A pointer to constructed @c CAknTab object. |
|
136 */ |
|
137 static CAknTab* NewL( TInt aId, |
|
138 const CCoeControl& aParent, |
|
139 const TDesC& aTabText, |
|
140 const CFbsBitmap* aTabBitmap, |
|
141 const CFbsBitmap* aMask = NULL ); |
|
142 |
|
143 /** |
|
144 * Two-phased constructor. |
|
145 * |
|
146 * @param aId Tab ID. |
|
147 * @param aParent Reference to parent control. |
|
148 * @param aTabText Reference to title text. |
|
149 * @param aTabBitmap Bitmap for the tab. Ownership of the bitmap is taken. |
|
150 * @param aMask Bitmap's mask. Ownership of the mask is taken. |
|
151 * |
|
152 * @return A pointer to constructed @c CAknTab object. |
|
153 */ |
|
154 static CAknTab* NewLC( TInt aId, |
|
155 const CCoeControl& aParent, |
|
156 const TDesC& aTabText, |
|
157 const CFbsBitmap* aTabBitmap, |
|
158 const CFbsBitmap* aMask = NULL ); |
|
159 |
|
160 /** |
|
161 * Two-phased constructor. |
|
162 * |
|
163 * @param aId Tab ID. |
|
164 * @param aParent Reference to parent control. |
|
165 * @param aTabBitmap Bitmap for the tab. Ownership of the bitmap is taken. |
|
166 * @param aMask Bitmap's mask. Ownership of the mask is taken. |
|
167 * |
|
168 * @return A pointer to constructed @c CAknTab object. |
|
169 */ |
|
170 static CAknTab* NewL( TInt aId, |
|
171 const CCoeControl& aParent, |
|
172 const CFbsBitmap* aTabBitmap, |
|
173 const CFbsBitmap* aMask = NULL ); |
|
174 |
|
175 /** |
|
176 * Two-phased constructor. |
|
177 * |
|
178 * @param aId Tab ID. |
|
179 * @param aParent Reference to parent control. |
|
180 * @param aTabBitmap Bitmap for the tab. Ownership of the bitmap is taken. |
|
181 * @param aMask Bitmap's mask. Ownership of the mask is taken. |
|
182 * |
|
183 * @return A pointer to constructed @c CAknTab object. |
|
184 */ |
|
185 static CAknTab* NewLC( TInt aId, |
|
186 const CCoeControl& aParent, |
|
187 const CFbsBitmap* aTabBitmap, |
|
188 const CFbsBitmap* aMask = NULL ); |
|
189 |
|
190 /** |
|
191 * Replace the tab title. |
|
192 * |
|
193 * @param aTabText New title text. |
|
194 */ |
|
195 void ReplaceTextL( const TDesC& aTabText ); |
|
196 |
|
197 /** |
|
198 * Activate or deactive this tab. |
|
199 * |
|
200 * @param aActive @c ETrue for activation, @c EFalse for deactivation. |
|
201 * @param aDrawNow Indicates whether control need to be redrawn. |
|
202 */ |
|
203 void SetActive( TBool aActive, TDrawNow aDrawNow ); |
|
204 |
|
205 /** |
|
206 * Determines whether this tab is active. |
|
207 * |
|
208 * @return @c ETrue if a tab is active, @c EFalse if not. |
|
209 */ |
|
210 TBool Active() const; |
|
211 |
|
212 /** |
|
213 * Gets tab's ID. |
|
214 * |
|
215 * @return Tabs' ID. |
|
216 */ |
|
217 TInt Id() const; |
|
218 |
|
219 /** |
|
220 * Gets this tab's type. |
|
221 * |
|
222 * @return Tab's type. |
|
223 */ |
|
224 enum TAknTabDataType TabType() const; |
|
225 |
|
226 |
|
227 /** |
|
228 * Sets the total amount of tabs in the tabgroup where this tab belongs to. |
|
229 */ |
|
230 void SetTotalAmountOfTabs( TInt aAmount ); |
|
231 |
|
232 /** |
|
233 * Sets the narrow tab layout. |
|
234 * @internal Used by the UI framework. |
|
235 * Applications can set the narrow layout using @c CAknNaviDecorator class. |
|
236 */ |
|
237 void SetNarrowTabLayout( TBool aNarrow ); |
|
238 |
|
239 /** |
|
240 * Sets the flag indicating whether or not this tab contains |
|
241 * a multi-colored title icon. |
|
242 * |
|
243 * The multi-color mode should be used with color icons, |
|
244 * otherwise the tab icon is drawn using a color |
|
245 * defined in the current skin. |
|
246 * |
|
247 * @param aMultiColor @c ETrue to set the multi-color mode on, |
|
248 * @c EFalse to turn it off. |
|
249 */ |
|
250 void SetMultiColorMode( TBool aMultiColor ); |
|
251 |
|
252 /** |
|
253 * Checks whether or not this tab is drawn using multi-color mode or not. |
|
254 * |
|
255 * @return @c ETrue if this tab contains a multi-color icon, |
|
256 * @c EFalse otherwise. |
|
257 */ |
|
258 TBool MultiColorMode() const; |
|
259 |
|
260 /** |
|
261 * Sets the long tab layout. |
|
262 * @internal Used by the UI framework. |
|
263 */ |
|
264 void SetLongTabLayout( TBool aLongTab ); |
|
265 |
|
266 public: // From base class @c CCoeControl. |
|
267 |
|
268 /** |
|
269 * Gets the minimum size of the tab. |
|
270 * |
|
271 * @return Minimum size of the tab. |
|
272 */ |
|
273 virtual TSize MinimumSize(); |
|
274 |
|
275 /** |
|
276 * Sets the tab dimmed. |
|
277 * |
|
278 * @param aDimmed @c ETrue to dim the control, |
|
279 * @c EFalse to set the control as not dimmed. |
|
280 */ |
|
281 virtual void SetDimmed( TBool aDimmed ); |
|
282 |
|
283 /** |
|
284 * Gets the list of logical colors employed |
|
285 * in the drawing of the control, paired with an explanation of how |
|
286 * they are used. Appends the list into @c aColorUseList. |
|
287 * |
|
288 * @param[in,out] aColorUseList The color list. |
|
289 */ |
|
290 virtual void GetColorUseListL( |
|
291 CArrayFix<TCoeColorUse>& aColorUseList ) const; |
|
292 |
|
293 protected: // From base class @c CCoeControl. |
|
294 |
|
295 /** |
|
296 * Responds to size changes events to sets the size and |
|
297 * position of the contents of this control. |
|
298 */ |
|
299 virtual void SizeChanged(); |
|
300 |
|
301 /** |
|
302 * Gets the number of controls contained in a compound control. |
|
303 * |
|
304 * @return The number of component controls contained by this control. |
|
305 */ |
|
306 virtual TInt CountComponentControls() const; |
|
307 |
|
308 /** |
|
309 * Gets the specified component of a compound control. |
|
310 * |
|
311 * @param aIndex The index of the control to get. |
|
312 * |
|
313 * @return The component control with an index of @c aIndex. |
|
314 |
|
315 */ |
|
316 virtual CCoeControl* ComponentControl( TInt aIndex ) const; |
|
317 |
|
318 /** |
|
319 * Handles pointer events. |
|
320 * This function is called by framework whenever a pointer event |
|
321 * occurs in the control. |
|
322 * |
|
323 * @param aPointerEvent The pointer event. |
|
324 */ |
|
325 virtual void HandlePointerEventL( const TPointerEvent& aPointerEvent ); |
|
326 |
|
327 private: // From base class @c CAknControl. |
|
328 |
|
329 IMPORT_C void* ExtensionInterface( TUid aInterface ); |
|
330 |
|
331 private: // From base class @c CCoeControl. |
|
332 |
|
333 virtual void Draw( const TRect& aRect ) const; |
|
334 |
|
335 private: |
|
336 |
|
337 CAknTab( TInt aId ); |
|
338 |
|
339 void ConstructFromResourceL( TResourceReader& aReader ); |
|
340 |
|
341 void ConstructL( const TDesC& aTabText ); |
|
342 |
|
343 void ConstructL( const CFbsBitmap* aTabBitmap, |
|
344 const CFbsBitmap* aMask = NULL ); |
|
345 |
|
346 void LoadColorBitmapL(); |
|
347 |
|
348 /** |
|
349 * Handles a change to the control's resources. |
|
350 * |
|
351 * @param aType The event type. |
|
352 */ |
|
353 void HandleResourceChange( TInt aType ); |
|
354 |
|
355 void SizeChangedInNormalLayout(); |
|
356 void SizeChangedInFlatLayout(); |
|
357 void SizeChangedInNarrowLayout(); |
|
358 |
|
359 private: |
|
360 |
|
361 CEikLabel* iLabel; |
|
362 TInt iId; |
|
363 TBool iActive; |
|
364 |
|
365 const CFbsBitmap* iBitmap; |
|
366 const CFbsBitmap* iBitmapMask; |
|
367 TAknLayoutRect iBitmapRect; |
|
368 |
|
369 CAknTabExtension* iExtension; |
|
370 |
|
371 typedef CArrayPtrFlat<CFbsBitmap> CAknTabColorBitmapArray; |
|
372 CAknTabColorBitmapArray* iColorBitmaps; |
|
373 }; |
|
374 |
|
375 |
|
376 /** |
|
377 * Tab group functionality for navigation pane. |
|
378 * |
|
379 * @lib avkon.lib |
|
380 * @since 0.9 |
|
381 */ |
|
382 class CAknTabGroup : public CAknControl, |
|
383 public MCoeControlObserver, |
|
384 public MCoeControlContext, |
|
385 public MAknNaviDecoratorObserver |
|
386 { |
|
387 public: |
|
388 /** |
|
389 * Destructor. |
|
390 */ |
|
391 IMPORT_C ~CAknTabGroup(); |
|
392 |
|
393 /** |
|
394 * Creates new tab group. |
|
395 * |
|
396 * @param aParent Parent control. |
|
397 */ |
|
398 IMPORT_C static CAknTabGroup* NewL( const CCoeControl& aParent ); |
|
399 |
|
400 /** |
|
401 * Creates new tab group and pushes it to the clean up stack. |
|
402 * |
|
403 * @param aParent Parent control. |
|
404 */ |
|
405 IMPORT_C static CAknTabGroup* NewLC( const CCoeControl& aParent ); |
|
406 |
|
407 public: |
|
408 |
|
409 /** |
|
410 * Add a tab to the tab group from resources. |
|
411 * |
|
412 * @param aReader Resource reader. |
|
413 * |
|
414 * @return ID of the added tab. |
|
415 */ |
|
416 IMPORT_C TInt AddTabL( TResourceReader& aReader ); |
|
417 |
|
418 /** |
|
419 * Add a tab to the tab group. |
|
420 * |
|
421 * @param aTabId ID of the tab to be added. |
|
422 * @param aTabText Text for the tab. |
|
423 */ |
|
424 IMPORT_C void AddTabL( TInt aTabId, const TDesC& aText ); |
|
425 |
|
426 /** |
|
427 * Add a tab to the tab group. |
|
428 * |
|
429 * @param aTabId ID of the tab. |
|
430 * @param aTabText Text for the tab. |
|
431 * @param aTabBitmap Bitmap for the tab. Ownership of the bitmap is taken. |
|
432 * @param aMask Bitmap's mask. Ownership of the mask is taken. |
|
433 */ |
|
434 IMPORT_C void AddTabL( TInt aTabId, |
|
435 const TDesC& aText, |
|
436 const CFbsBitmap* aTabBitmap, |
|
437 const CFbsBitmap* aMask = NULL ); |
|
438 |
|
439 /** |
|
440 * Add a tab to the tab group. |
|
441 * |
|
442 * @param aTabId ID of the tab. |
|
443 * @param aTabBitmap Bitmap for the tab. Ownership of the bitmap is taken. |
|
444 * @param aMask Bitmap's mask. Ownership of the mask is taken. |
|
445 */ |
|
446 IMPORT_C void AddTabL( TInt aTabId, |
|
447 const CFbsBitmap* aTabBitmap, |
|
448 const CFbsBitmap* aMask = NULL ); |
|
449 /** |
|
450 * Replaces a tab with a new one from resources. |
|
451 * Tab with same ID is replaced. |
|
452 * |
|
453 * @param aReader Resource reader. |
|
454 */ |
|
455 IMPORT_C void ReplaceTabL( TResourceReader& aReader ); |
|
456 |
|
457 /** |
|
458 * Replaces a tab with a new one. |
|
459 * |
|
460 * @param aTabId ID of the tab to be replaced. |
|
461 * @param aTabText Text for the new tab. |
|
462 */ |
|
463 IMPORT_C void ReplaceTabL( TInt aTabId, const TDesC& aText ); |
|
464 |
|
465 /** |
|
466 * Replaces a tab with a new one. |
|
467 * |
|
468 * @param aTabId ID of the tab to be replaced. |
|
469 * @param aTabText Text for the new tab. |
|
470 * @param aTabBitmap Bitmap for the tab. Ownership of the bitmap is taken. |
|
471 * @param aMask Bitmap's mask. Ownership of the mask is taken. |
|
472 */ |
|
473 IMPORT_C void ReplaceTabL( TInt aTabId, |
|
474 const TDesC& aText, |
|
475 const CFbsBitmap* aTabBitmap, |
|
476 const CFbsBitmap* aMask = NULL ); |
|
477 |
|
478 /** |
|
479 * Replaces a tab with a new one. |
|
480 * |
|
481 * @param aTabId ID of the tab to be replaced. |
|
482 * @param aTabBitmap Bitmap for the tab. Ownership of the bitmap is taken. |
|
483 * @param aMask Bitmap's mask. Ownership of the mask is taken. |
|
484 */ |
|
485 IMPORT_C void ReplaceTabL( TInt aTabId, |
|
486 const CFbsBitmap* aTabBitmap, |
|
487 const CFbsBitmap* aMask = NULL ); |
|
488 |
|
489 /** |
|
490 * Replaces a tab text with a new one. |
|
491 * |
|
492 * @param aTabId ID of the tab containing the text to be replaced. |
|
493 * @param aTabText New tab text. |
|
494 */ |
|
495 IMPORT_C void ReplaceTabTextL( TInt aTabId, const TDesC& aTabText ); |
|
496 |
|
497 /** |
|
498 * Delete a tab from the tab group. |
|
499 * |
|
500 * @param aTabId ID of the tab to be deleted. |
|
501 */ |
|
502 IMPORT_C void DeleteTabL( TInt aTabId ); |
|
503 |
|
504 /** |
|
505 * Activate (highlight) a tab. |
|
506 * |
|
507 * @param aTabId ID of the tab to be highlighted. |
|
508 */ |
|
509 IMPORT_C void SetActiveTabById( TInt aTabId ); |
|
510 |
|
511 /** |
|
512 * Activate (highlight) a tab. |
|
513 * |
|
514 * @param aTabIndex Index of the tab to be highlighted. |
|
515 */ |
|
516 IMPORT_C void SetActiveTabByIndex( TInt aTabIndex ); |
|
517 |
|
518 /** |
|
519 * Returns the ID of the currently active (highlighted) tab. |
|
520 * |
|
521 * @return ID of the highlighted tab. |
|
522 */ |
|
523 IMPORT_C TInt ActiveTabId() const; |
|
524 |
|
525 /** |
|
526 * Returns the index of the currently active (highlighted) tab. |
|
527 * |
|
528 * @return Index of the highlighted tab. |
|
529 */ |
|
530 IMPORT_C TInt ActiveTabIndex() const; |
|
531 |
|
532 /** |
|
533 * Set width of each tab. |
|
534 * This width determines what tab layout is used. |
|
535 * To get a specific tab layout, use the following constants: |
|
536 * - KTabWidthWithOneTab One tab layout |
|
537 * - KTabWidthWithTwoTabs Two tabs layout |
|
538 * - KTabWidthWithThreeTabs Three tabs layout |
|
539 * - KTabWidthWithFourTabs Four tabs layout |
|
540 * - KTabWidthWithTwoLongTabs Two long tabs layout |
|
541 * - KTabWidthWithThreeLongTabs Three long tabs layout |
|
542 * |
|
543 * @param aWidth Width of each tab, @see aknconsts.h. |
|
544 */ |
|
545 IMPORT_C void SetTabFixedWidthL( TInt aWidth ); |
|
546 |
|
547 /** |
|
548 * Sets a tab dimmed/not dimmed. |
|
549 * |
|
550 * @param aTabId ID of the tab. |
|
551 * @param aDimmed @c ETrue to set the tab dimmed, |
|
552 * @c EFalse otherwise. |
|
553 */ |
|
554 IMPORT_C void DimTab( TInt aTabId, TBool aDimmed ); |
|
555 |
|
556 /** |
|
557 * Used to check whether or not a tab is dimmed. |
|
558 * |
|
559 * @param aTabId ID of the tab. |
|
560 * |
|
561 * @return @c ETrue if the tab is dimmed, @c EFalse otherwise. |
|
562 */ |
|
563 IMPORT_C virtual TBool IsTabDimmed( TInt aTabId ) const; |
|
564 |
|
565 /** |
|
566 * Returns the index of a tab. |
|
567 * |
|
568 * @param aTabId ID of a tab. |
|
569 * |
|
570 * @return Index of the tab. |
|
571 */ |
|
572 IMPORT_C virtual TInt TabIndexFromId( TInt aTabId ) const; |
|
573 |
|
574 /** |
|
575 * Returns the ID of a tab. |
|
576 * |
|
577 * @param aTabIndex Index of a tab. |
|
578 * |
|
579 * @return ID of the tab. |
|
580 */ |
|
581 IMPORT_C virtual TInt TabIdFromIndex( TInt aTabIndex ) const; |
|
582 |
|
583 /** |
|
584 * Number of tabs in the tab group. |
|
585 * |
|
586 * @return Number of tabs in the tab group. |
|
587 */ |
|
588 IMPORT_C virtual TInt TabCount() const; |
|
589 |
|
590 /** |
|
591 * Sets the tab observer for this tab group. |
|
592 * |
|
593 * @param aObserver Tab observer to set. |
|
594 */ |
|
595 IMPORT_C void SetObserver( MAknTabObserver* aObserver ); |
|
596 |
|
597 public: // From base class @c CCoeControl. |
|
598 |
|
599 /** |
|
600 * Return minimum size of the control. |
|
601 * |
|
602 * @return Minimum size of the control. |
|
603 */ |
|
604 IMPORT_C virtual TSize MinimumSize(); |
|
605 |
|
606 /** |
|
607 * Handles key events. |
|
608 * |
|
609 * @param aKeyEvent The key event. |
|
610 * @param aType The type of the event. |
|
611 * |
|
612 * @return Indicates whether or not the key event was used by this control. |
|
613 */ |
|
614 IMPORT_C virtual TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
615 TEventCode aType ); |
|
616 |
|
617 /** |
|
618 * Gets the list of logical colors employed in the drawing of the control, |
|
619 * paired with an explanation of how they are used. |
|
620 * Appends the list into @c aColorUseList. |
|
621 * |
|
622 * @param[in,out] aColorUseList The color list. |
|
623 */ |
|
624 IMPORT_C virtual void GetColorUseListL( |
|
625 CArrayFix<TCoeColorUse>& aColorUseList ) const; |
|
626 |
|
627 /** |
|
628 * Handles a change to the control's resources. |
|
629 * |
|
630 * @param aType The type of resource change. |
|
631 */ |
|
632 void HandleResourceChange( TInt aType ); |
|
633 |
|
634 /** |
|
635 * Handles pointer events in tabs. |
|
636 * |
|
637 * @param aPointerEvent Pointer event to be handled. |
|
638 */ |
|
639 IMPORT_C void HandlePointerEventL( const TPointerEvent& aPointerEvent ); |
|
640 |
|
641 public: // From base class @c MCoeControlObserver. |
|
642 |
|
643 /** |
|
644 * Handles an event from an observed control. |
|
645 * |
|
646 * @param aControl Control that caused the event. |
|
647 * @param aEventType Type of the event. |
|
648 */ |
|
649 IMPORT_C virtual void HandleControlEventL( CCoeControl* aControl, |
|
650 TCoeEvent aEventType ); |
|
651 |
|
652 public: // From base class @c MCoeControlContext. |
|
653 |
|
654 /** |
|
655 * Allows to modify graphics context before Draw. |
|
656 * |
|
657 * @param aGc Graphics context to be modified. |
|
658 */ |
|
659 IMPORT_C virtual void PrepareContext( CWindowGc& aGc ) const; |
|
660 |
|
661 public: // From base class @c MAknNaviDecoratorObserver. |
|
662 |
|
663 /* |
|
664 * Handles events from navi decorator parent control. |
|
665 * |
|
666 * @param aEventID ID of event to be handled. |
|
667 */ |
|
668 IMPORT_C virtual void HandleNaviDecoratorEventL( TInt aEventID ); |
|
669 |
|
670 protected: // From base class @c CCoeControl. |
|
671 |
|
672 /** |
|
673 * Handles the size change events. |
|
674 */ |
|
675 IMPORT_C virtual void SizeChanged(); |
|
676 |
|
677 /** |
|
678 * Returns number of controls inside this control. |
|
679 * |
|
680 * @return Number of component controls. |
|
681 */ |
|
682 IMPORT_C virtual TInt CountComponentControls() const; |
|
683 |
|
684 /** |
|
685 * Returns a component control determined by control index. |
|
686 * |
|
687 * @param aIndex Index of a control to be returned. |
|
688 * |
|
689 * @return Pointer to the control. |
|
690 */ |
|
691 IMPORT_C virtual CCoeControl* ComponentControl( TInt aIndex ) const; |
|
692 |
|
693 /** |
|
694 * This is called when the focus is changed. |
|
695 * |
|
696 * @param aDrawNow Whether or not to draw the control. |
|
697 */ |
|
698 IMPORT_C virtual void FocusChanged( TDrawNow aDrawNow ); |
|
699 |
|
700 /** |
|
701 * Reverse the order of tabs in tab array. |
|
702 */ |
|
703 void ReverseTabOrderL(); |
|
704 |
|
705 private: |
|
706 |
|
707 /* |
|
708 * Reserved |
|
709 */ |
|
710 IMPORT_C virtual void Reserved1(); |
|
711 |
|
712 /* |
|
713 * Reserved |
|
714 */ |
|
715 IMPORT_C virtual void Reserved2(); |
|
716 |
|
717 /* |
|
718 * Reserved |
|
719 */ |
|
720 IMPORT_C virtual void Reserved3(); |
|
721 |
|
722 |
|
723 private: |
|
724 IMPORT_C CAknTabGroup(); |
|
725 |
|
726 /** |
|
727 * Tab groups can be mirrored depending on current locale. To client |
|
728 * application everything always seems like tabs are not mirrored but |
|
729 * the internal order of tabs in tab group may or may not be mirrored. |
|
730 * If mirroring is off then this function just returns given |
|
731 * parameter as it is. If mirroring is on then this function returns |
|
732 * unmirrored index if given index was mirrord and vice versa. Two |
|
733 * nested calls to this function cancels its effect |
|
734 * (ConvertTabIndex(ConvertTabIndex(aIndex)) == aIndex). |
|
735 * |
|
736 * @param aIndex Index to be converted. |
|
737 * @return Converted index. |
|
738 */ |
|
739 TInt ConvertTabIndex(TInt aIndex) const; |
|
740 |
|
741 private: // From base class @c CCoeControl. |
|
742 |
|
743 IMPORT_C virtual void Draw( const TRect& aRect ) const; |
|
744 |
|
745 private: // From base class @c CAknControl. |
|
746 |
|
747 IMPORT_C void* ExtensionInterface( TUid aInterface ); |
|
748 |
|
749 public: // New methods |
|
750 |
|
751 /** |
|
752 * Sets the multi-color drawing mode of a tab. |
|
753 * This should be called after adding a tab to the tab group |
|
754 * if the icon in the tab should be drawn as multi-colored. |
|
755 * The tab icon will be drawn using a color specified in the |
|
756 * active skin if multi-color mode is not defined. |
|
757 * |
|
758 * This function should be called right after a tab containing |
|
759 * a multi-color icon is added to the tab group. |
|
760 * |
|
761 * @param aTabId ID of the tab. |
|
762 * @param aMultiColor @c ETrue to set the multi-color mode on, |
|
763 * @c EFalse to turn it off. |
|
764 */ |
|
765 IMPORT_C void SetTabMultiColorMode( TInt aTabId, TBool aMultiColor ); |
|
766 |
|
767 /** Directions in which the tab group focus can be moved. */ |
|
768 enum TDirection |
|
769 { |
|
770 ELeft, |
|
771 ERight |
|
772 }; |
|
773 |
|
774 private: |
|
775 void ConstructL(); |
|
776 void CommonAddTabL(CAknTab* aTab); |
|
777 void CommonReplaceTabL(CAknTab* aTab); |
|
778 void HandleTabStateChanged(CCoeControl* aControl); |
|
779 TInt Index(TInt aTabId) const; |
|
780 TBool CycleFocus(TDirection aDirection,TDrawNow aDrawNow); |
|
781 TInt LeftMostTabIndex() const; |
|
782 TInt RightMostTabIndex() const; |
|
783 void DrawLowerBorder(TDrawNow aDrawNow) const; |
|
784 void DoDrawLowerBorder() const; |
|
785 void ReportNavigationEvent(); |
|
786 void LoadTabBitmapsL(TInt aNumberOfTabsShown, TBool aLongTabs); |
|
787 TBool TabsVisibleInCurrentLayout() const; |
|
788 void CurrentLayout( TAknWindowLineLayout& aLayout ) const; |
|
789 void InitTabGroupGraphicsL(); |
|
790 |
|
791 void InitTabAnimationEventTimer(); |
|
792 void CancelTabAnimationEventTimer(); |
|
793 static TInt TabAnimationEvent(TAny * aPtr); |
|
794 void DoTabAnimationEvent(); |
|
795 |
|
796 TBool NarrowTabLayoutNext(); |
|
797 TBool NarrowTabLayout(); |
|
798 |
|
799 public: |
|
800 |
|
801 /** |
|
802 * Sets the navigation decorator layout so that it corresponds |
|
803 * the current tab group layout. |
|
804 * |
|
805 * @param aNarrow @c ETrue if narrow tab group layout is used, |
|
806 * @c EFalse if normal layout is used. |
|
807 */ |
|
808 void SetDecoratorLayout( TBool aNarrow ); |
|
809 |
|
810 private: |
|
811 |
|
812 void SizeChangedInNormalLayout(); |
|
813 void SizeChangedInFlatLayout(); |
|
814 void SizeChangedInNarrowLayout(); |
|
815 void InitTabAnimationL(); |
|
816 |
|
817 |
|
818 /** |
|
819 * Gets the rectangle for the tab group. |
|
820 * If the tab arrows are not shown, then the tab group gets a wider |
|
821 * rectangle. |
|
822 * |
|
823 * @param aArrowsUsed @c ETrue if tab arrows are shown, |
|
824 * @c EFalse otherwise. |
|
825 */ |
|
826 static TRect ParentRect( TBool aArrowsUsed ); |
|
827 |
|
828 /** |
|
829 * @internal Used by the UI framework. |
|
830 * |
|
831 * Starts the animation shown when tab focus is cycled. |
|
832 * Note that this starts the animation only when required, i.e. |
|
833 * when layout that needs cycle animation is used and when the first |
|
834 * shown tab in the tab group changes. |
|
835 * |
|
836 * @param aDirection Direction which the focus in cycled to. |
|
837 * @param aNewTab Index of the tab that receives the focus. |
|
838 */ |
|
839 void StartCycleAnimationL( TDirection aDirection, TInt aNewTab ); |
|
840 |
|
841 /** |
|
842 * Called on the dynamic layout switch event, switches the current tab |
|
843 * layout to a corresponding one that is usable in the new layout. |
|
844 */ |
|
845 void SwitchTabLayoutL(); |
|
846 |
|
847 public: |
|
848 |
|
849 /** |
|
850 * @internal Used by the UI framework. |
|
851 * Applications can set the narrow layout using @c CAknNaviDecorator class. |
|
852 */ |
|
853 void SetNarrowTabLayoutL( TBool aNarrow, TBool aUseAnimation = EFalse ); |
|
854 |
|
855 /** |
|
856 * @internal Used by the UI framework. |
|
857 * |
|
858 * Sets the tab arrows' visibility. |
|
859 * |
|
860 * @param aVisible @c ETrue to set the arrows visible, |
|
861 * @c EFalse to hide them. |
|
862 */ |
|
863 void SetNaviArrowsVisible( TBool aVisible ); |
|
864 |
|
865 private: |
|
866 CArrayPtr<CAknTab>* iTabArray; |
|
867 TInt iActiveTab; |
|
868 TRect iSpareRect; |
|
869 |
|
870 TInt iTabFixedWidth; |
|
871 TBool iLongTabs; |
|
872 TInt iNumberOfTabsShown; |
|
873 TInt iFirstShownTab; |
|
874 |
|
875 CFbsBitmap* iTabBitmaps[KTabNumberOfTabBitmaps]; |
|
876 CFbsBitmap* iTabMaskBitmaps[KTabNumberOfTabBitmaps]; |
|
877 |
|
878 TInt iBitmapNames[KTabNumberOfTabBitmaps]; |
|
879 TInt iBitmapMaskNames[KTabNumberOfTabBitmaps]; |
|
880 CAknTabGroupExtension* iExtension; |
|
881 |
|
882 MAknTabObserver* iTabObserver; |
|
883 TBool iMirrored; |
|
884 }; |
|
885 |
|
886 #endif // AKNTABGRP_H |