37 // CXnClockControl::CXnClockControl |
37 // CXnClockControl::CXnClockControl |
38 // C++ default constructor can NOT contain any code, that |
38 // C++ default constructor can NOT contain any code, that |
39 // might leave. |
39 // might leave. |
40 // ----------------------------------------------------------------------------- |
40 // ----------------------------------------------------------------------------- |
41 // |
41 // |
42 CXnClockControl::CXnClockControl( CXnClockAdapter* aAdapter, |
42 CXnClockControl::CXnClockControl( CXnClockAdapter& aAdapter, |
43 const TBool aFormatFromLocale, |
43 const TBool aFormatFromLocale, |
44 const TClockFormat aFormat ) |
44 const TClockFormat aFormat ) |
45 : iAdapter( aAdapter ), |
45 : iAdapter( aAdapter ), |
46 iClockFormat( aFormat ), |
46 iClockFormat( aFormat ), |
47 iFormatFromLocale ( aFormatFromLocale ) |
47 iFormatFromLocale ( aFormatFromLocale ) |
48 { |
48 { |
49 } |
49 } |
50 |
50 |
51 // ----------------------------------------------------------------------------- |
51 // ----------------------------------------------------------------------------- |
52 // CXnClockControl::ConstructL |
52 // CXnClockControl::ConstructL |
54 // ----------------------------------------------------------------------------- |
54 // ----------------------------------------------------------------------------- |
55 // |
55 // |
56 void CXnClockControl::ConstructL() |
56 void CXnClockControl::ConstructL() |
57 { |
57 { |
58 iTimer = CPeriodic::NewL( CActive::EPriorityHigh ); |
58 iTimer = CPeriodic::NewL( CActive::EPriorityHigh ); |
59 |
59 iTimeFormat = TLocale().TimeFormat(); |
60 SetFormatL( iFormatFromLocale, iClockFormat ); |
60 SetFormatL( iFormatFromLocale, iClockFormat ); |
61 } |
61 } |
62 |
62 |
63 // ----------------------------------------------------------------------------- |
63 // ----------------------------------------------------------------------------- |
64 // CXnClockControl::NewL |
64 // CXnClockControl::NewL |
65 // Two-phased constructor. |
65 // Two-phased constructor. |
66 // ----------------------------------------------------------------------------- |
66 // ----------------------------------------------------------------------------- |
67 // |
67 // |
68 CXnClockControl* CXnClockControl::NewL( CXnClockAdapter* aAdapter, |
68 CXnClockControl* CXnClockControl::NewL( CXnClockAdapter& aAdapter, |
69 const TBool aFormatFromLocale, |
69 const TBool aFormatFromLocale, |
70 const TClockFormat aFormat ) |
70 const TClockFormat aFormat ) |
71 { |
71 { |
72 CXnClockControl* self = |
72 CXnClockControl* self = |
73 new (ELeave) CXnClockControl( aAdapter, aFormatFromLocale, aFormat ); |
73 new (ELeave) CXnClockControl( aAdapter, aFormatFromLocale, aFormat ); |
74 |
|
75 CleanupStack::PushL( self ); |
74 CleanupStack::PushL( self ); |
76 self->ConstructL(); |
75 self->ConstructL(); |
77 |
|
78 CleanupStack::Pop( self ); |
76 CleanupStack::Pop( self ); |
79 |
|
80 return self; |
77 return self; |
81 } |
78 } |
82 |
79 |
83 // ----------------------------------------------------------------------------- |
80 // ----------------------------------------------------------------------------- |
84 // Destructor |
81 // Destructor |
85 // |
|
86 // ----------------------------------------------------------------------------- |
82 // ----------------------------------------------------------------------------- |
87 // |
83 // |
88 CXnClockControl::~CXnClockControl() |
84 CXnClockControl::~CXnClockControl() |
89 { |
85 { |
90 delete iTimer; |
86 delete iTimer; |
91 delete iFace; |
87 delete iFace; |
92 } |
88 } |
93 |
89 |
94 // ----------------------------------------------------------------------------- |
90 // ----------------------------------------------------------------------------- |
95 // CXnClockControl::UpdateDisplay |
91 // CXnClockControl::UpdateDisplay |
96 // (other items were commented in a header). |
|
97 // ----------------------------------------------------------------------------- |
92 // ----------------------------------------------------------------------------- |
98 // |
93 // |
99 void CXnClockControl::UpdateDisplay() |
94 void CXnClockControl::UpdateDisplay() |
100 { |
95 { |
101 if( !iFace ) |
96 if( !iFace ) |
102 { |
97 { |
103 return; |
98 return; |
104 } |
99 } |
105 |
100 |
106 iAdapter->UpdateDisplay(); |
101 iAdapter.UpdateDisplay(); |
107 } |
102 } |
108 |
103 |
109 // ----------------------------------------------------------------------------- |
104 // ----------------------------------------------------------------------------- |
110 // CXnClockControl::SetFormatL |
105 // CXnClockControl::SetFormatL |
111 // (other items were commented in a header). |
|
112 // ----------------------------------------------------------------------------- |
106 // ----------------------------------------------------------------------------- |
113 // |
107 // |
114 void CXnClockControl::SetFormatL( const TBool aFormatFromLocale, |
108 void CXnClockControl::SetFormatL( const TBool aFormatFromLocale, |
115 const TClockFormat aFormat ) |
109 const TClockFormat aFormat ) |
116 { |
110 { |
139 iFace = CXnClockFaceAnalog::NewL(); |
136 iFace = CXnClockFaceAnalog::NewL(); |
140 } |
137 } |
141 else if( format == EClockDigital ) |
138 else if( format == EClockDigital ) |
142 { |
139 { |
143 iFace = CXnClockFaceDigital::NewL(); |
140 iFace = CXnClockFaceDigital::NewL(); |
144 } |
141 } |
|
142 |
|
143 iAdapter.SetClockFormatL( format ); |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // CXnClockControl::CheckClockFormatL |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 void CXnClockControl::CheckClockFormatL() |
|
151 { |
|
152 SetFormatL( iFormatFromLocale, iClockFormat ); |
145 } |
153 } |
146 |
154 |
147 // ----------------------------------------------------------------------------- |
155 // ----------------------------------------------------------------------------- |
148 // CXnClockControl::Format |
156 // CXnClockControl::Format |
149 // (other items were commented in a header). |
|
150 // ----------------------------------------------------------------------------- |
157 // ----------------------------------------------------------------------------- |
151 // |
158 // |
152 TClockFormat CXnClockControl::Format() const |
159 TClockFormat CXnClockControl::Format() const |
153 { |
160 { |
154 return iClockFormat; |
161 return iClockFormat; |
155 } |
162 } |
156 |
163 |
157 // ----------------------------------------------------------------------------- |
164 // ----------------------------------------------------------------------------- |
158 // CXnClockControl::Draw |
165 // CXnClockControl::Draw |
159 // (other items were commented in a header). |
|
160 // ----------------------------------------------------------------------------- |
166 // ----------------------------------------------------------------------------- |
161 // |
167 // |
162 void CXnClockControl::Draw( CWindowGc& aGc, const TRect& aRect ) |
168 void CXnClockControl::Draw( CWindowGc& aGc, CXnNodePluginIf* aNode, |
163 { |
169 CXnNodePluginIf* aAmpm ) |
164 // Ensure correct appearance |
170 { |
165 TRAP_IGNORE( SetFormatL( iFormatFromLocale, iClockFormat ) ); |
171 if ( !aNode ) |
166 |
172 { |
167 if( iFace && !aRect.IsEmpty() ) |
173 return; |
|
174 } |
|
175 |
|
176 if( iFace && !aNode->Rect().IsEmpty() ) |
168 { |
177 { |
169 __PRINT( __DBG_FORMAT( "CXnClockControl::Draw: 0x%X" ), this ); |
178 __PRINT( __DBG_FORMAT( "CXnClockControl::Draw: 0x%X" ), this ); |
170 |
179 |
171 TTime homeTime; |
180 TTime homeTime; |
172 homeTime.HomeTime(); |
181 homeTime.HomeTime(); |
173 |
182 |
174 TRAP_IGNORE( iFace->DrawL( *iAdapter, aGc, aRect, homeTime ) ); |
183 TRAP_IGNORE( iFace->DrawL( iAdapter, aGc, *aNode, homeTime, aAmpm ) ); |
175 } |
184 } |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // CXnClockControl::ResetFont |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 void CXnClockControl::ResetFont() |
|
192 { |
|
193 iFace->ResetFont(); |
176 } |
194 } |
177 |
195 |
178 // ----------------------------------------------------------------------------- |
196 // ----------------------------------------------------------------------------- |
179 // CXnClockControl::TimerCallback |
197 // CXnClockControl::TimerCallback |
180 // (other items were commented in a header). |
|
181 // ----------------------------------------------------------------------------- |
198 // ----------------------------------------------------------------------------- |
182 // |
199 // |
183 TInt CXnClockControl::TimerCallback( TAny* aThis ) |
200 TInt CXnClockControl::TimerCallback( TAny* aThis ) |
184 { |
201 { |
185 __PRINT( __DBG_FORMAT( "CXnClockControl::TimerCallback: 0x%X" ), aThis ); |
202 __PRINT( __DBG_FORMAT( "CXnClockControl::TimerCallback: 0x%X" ), aThis ); |