|
1 /* |
|
2 * Copyright (c) 2006-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: Control for xuikon's skinnable clock. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef _XNCLOCKCONTROL_H |
|
20 #define _XNCLOCKCONTROL_H |
|
21 |
|
22 // INCLUDES |
|
23 |
|
24 // FORWARD DECLARATIONS |
|
25 class CWindowGc; |
|
26 class CXnClockAdapter; |
|
27 class CXnClockChangeHandler; |
|
28 class CXnClockFace; |
|
29 |
|
30 // CLASS DECLARATION |
|
31 /** |
|
32 * @ingroup group_xnclockfactory |
|
33 * @lib xnclockfactory.lib |
|
34 * @since S60 |
|
35 */ |
|
36 class CXnClockControl : public CBase |
|
37 { |
|
38 public: // Constructors and destructor |
|
39 |
|
40 /** |
|
41 * Two-phased constructor. |
|
42 * |
|
43 * @since S60 5.1 |
|
44 * |
|
45 * @param aContainerWindow Container window for the clock component. |
|
46 * |
|
47 * @param aFormatFromLocale Boolean flag to indicate whether the clock |
|
48 * format should be updated from the locale. |
|
49 * |
|
50 * @param aContextPaneClock Boolean flag that indicates whether the |
|
51 * clock is in the context pane. |
|
52 * |
|
53 * @return Newly constructed object. |
|
54 */ |
|
55 static CXnClockControl* NewL( CXnClockAdapter* aAdapter, |
|
56 const TBool aFormatFromLocale, |
|
57 const TClockFormat aFormat ); |
|
58 |
|
59 |
|
60 /** |
|
61 * Destructor. |
|
62 */ |
|
63 virtual ~CXnClockControl(); |
|
64 |
|
65 public: // New functions |
|
66 |
|
67 /** |
|
68 * Updates the double buffer and redraws the clock. |
|
69 */ |
|
70 void UpdateDisplay(); |
|
71 |
|
72 /** |
|
73 * Sets the format of the clock. |
|
74 * |
|
75 * @param aFormatFromLocale Wheter clock is getting format from locale |
|
76 * @param aFormat New clock format. |
|
77 */ |
|
78 void SetFormatL( const TBool aFormatFromLocale, |
|
79 const TClockFormat aFormat ); |
|
80 |
|
81 /** |
|
82 * Gets the clock format |
|
83 * |
|
84 * @return Clock format. |
|
85 */ |
|
86 TClockFormat Format() const; |
|
87 |
|
88 /** |
|
89 * Updates time and locale state of the clock. |
|
90 */ |
|
91 void TimeOrLocaleChanged(); |
|
92 |
|
93 /** |
|
94 * Draws the clock |
|
95 * |
|
96 * @param aGc Context where to draw |
|
97 * @param aRect Rect Clock rect |
|
98 */ |
|
99 void Draw( CWindowGc& aGc, const TRect& aRect ) const; |
|
100 |
|
101 /** |
|
102 * Starts the clock timer. |
|
103 * Used when the clock gains visibility. |
|
104 */ |
|
105 void StartTimer(); |
|
106 |
|
107 /** |
|
108 * Stops the clock timer. |
|
109 * Used when the clock loses visibility. |
|
110 */ |
|
111 void StopTimer(); |
|
112 |
|
113 private: // New functions |
|
114 |
|
115 /** |
|
116 * Timer callback for clock updates |
|
117 * |
|
118 * @param aThis Pointer to the skinnable clock instance. |
|
119 * |
|
120 * @return Always returns @c KErrNone. |
|
121 */ |
|
122 static TInt TimerCallback( TAny* aThis ); |
|
123 |
|
124 private: |
|
125 |
|
126 /** |
|
127 * C++ default constructor. |
|
128 */ |
|
129 CXnClockControl( CXnClockAdapter* aAdapter, |
|
130 const TBool aFormatFromLocale, |
|
131 const TClockFormat aFormat ); |
|
132 |
|
133 /** |
|
134 * By default Symbian 2nd phase constructor is private. |
|
135 */ |
|
136 void ConstructL(); |
|
137 |
|
138 private: // data |
|
139 |
|
140 // Timer, owned |
|
141 CPeriodic* iTimer; |
|
142 // Clock face, owned |
|
143 CXnClockFace* iFace; |
|
144 // Clock change handler, owned |
|
145 CXnClockChangeHandler* iHandler; |
|
146 // Clock adapter, not owned |
|
147 CXnClockAdapter* iAdapter; |
|
148 // Clock format |
|
149 TClockFormat iClockFormat; |
|
150 // Flag indicating whetger format clock from locale |
|
151 TBool iFormatFromLocale; |
|
152 }; |
|
153 |
|
154 #endif // _XNCLOCKCONTROL_H |
|
155 |
|
156 // End of File |