|
1 /* |
|
2 * Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: MsgBaseControl implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // ========== INCLUDE FILES ================================ |
|
21 |
|
22 #include <eikenv.h> // for CEikonEnv |
|
23 #include <AknUtils.h> // for AknUtils |
|
24 #include <aknenv.h> // for CAknEnv |
|
25 |
|
26 #include <applayout.cdl.h> |
|
27 |
|
28 #include "MsgEditorCommon.h" // |
|
29 #include "MsgBaseControl.h" // for CMsgBaseControl |
|
30 #include "MsgBaseControlObserver.h" // for MMsgBaseControlObserver |
|
31 #include "MsgEditorPanic.h" // for CMsgEditor panics |
|
32 |
|
33 // ========== EXTERNAL DATA STRUCTURES ===================== |
|
34 |
|
35 // ========== EXTERNAL FUNCTION PROTOTYPES ================= |
|
36 |
|
37 // ========== CONSTANTS ==================================== |
|
38 |
|
39 // ========== MACROS ======================================= |
|
40 |
|
41 // ========== LOCAL CONSTANTS AND MACROS =================== |
|
42 |
|
43 // ========== MODULE DATA STRUCTURES ======================= |
|
44 |
|
45 // ========== LOCAL FUNCTION PROTOTYPES ==================== |
|
46 |
|
47 // ========== LOCAL FUNCTIONS ============================== |
|
48 |
|
49 // ========== MEMBER FUNCTIONS ============================= |
|
50 |
|
51 // --------------------------------------------------------- |
|
52 // CMsgBaseControl::CMsgBaseControl |
|
53 // |
|
54 // Constructor. |
|
55 // --------------------------------------------------------- |
|
56 // |
|
57 EXPORT_C CMsgBaseControl::CMsgBaseControl( MMsgBaseControlObserver& aBaseControlObserver ) : |
|
58 iBaseControlObserver( &aBaseControlObserver ), |
|
59 iLineHeight( MsgEditorCommons::MsgBaseLineDelta() ), |
|
60 iMaxBodyHeight( MsgEditorCommons::MaxBodyHeight() ) |
|
61 { |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------- |
|
65 // CMsgBaseControl::CMsgBaseControl |
|
66 // |
|
67 // Constructor. |
|
68 // --------------------------------------------------------- |
|
69 // |
|
70 EXPORT_C CMsgBaseControl::CMsgBaseControl() : |
|
71 iLineHeight( MsgEditorCommons::MsgBaseLineDelta() ), |
|
72 iMaxBodyHeight( MsgEditorCommons::MaxBodyHeight() ) |
|
73 { |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------- |
|
77 // CMsgBaseControl::~CMsgBaseControl |
|
78 // |
|
79 // Destructor. |
|
80 // --------------------------------------------------------- |
|
81 // |
|
82 EXPORT_C CMsgBaseControl::~CMsgBaseControl() |
|
83 { |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------- |
|
87 // CMsgBaseControl::ConstructFromResourceL |
|
88 // |
|
89 // nop |
|
90 // --------------------------------------------------------- |
|
91 // |
|
92 EXPORT_C void CMsgBaseControl::ConstructFromResourceL( TInt /*aResourceId*/ ) |
|
93 { |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------- |
|
97 // CMsgBaseControl::NotifyViewEvent |
|
98 // |
|
99 // nop |
|
100 // --------------------------------------------------------- |
|
101 // |
|
102 EXPORT_C void CMsgBaseControl::NotifyViewEvent( TMsgViewEvent /*aEvent*/, |
|
103 TInt /*aParam*/ ) |
|
104 { |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------- |
|
108 // CMsgBaseControl::Reset |
|
109 // |
|
110 // nop |
|
111 // --------------------------------------------------------- |
|
112 // |
|
113 EXPORT_C void CMsgBaseControl::Reset() |
|
114 { |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------- |
|
118 // CMsgBaseControl::SetModified |
|
119 // |
|
120 // Sets the modified flag of the control. |
|
121 // --------------------------------------------------------- |
|
122 // |
|
123 EXPORT_C void CMsgBaseControl::SetModified( TBool aModified ) |
|
124 { |
|
125 if ( aModified ) |
|
126 { |
|
127 iControlModeFlags |= EMsgControlModeModified; |
|
128 } |
|
129 else |
|
130 { |
|
131 iControlModeFlags &= ~EMsgControlModeModified; |
|
132 } |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------- |
|
136 // CMsgBaseControl::IsModified |
|
137 // |
|
138 // Return ETrue if contents of control has been modified. |
|
139 // --------------------------------------------------------- |
|
140 // |
|
141 EXPORT_C TBool CMsgBaseControl::IsModified() const |
|
142 { |
|
143 return iControlModeFlags & EMsgControlModeModified; |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------- |
|
147 // CMsgBaseControl::SetReadOnly |
|
148 // |
|
149 // Sets the control read only or not. Before setting the read only flag on or |
|
150 // off, calls virtual PrepareForReadOnly function. |
|
151 // --------------------------------------------------------- |
|
152 // |
|
153 EXPORT_C void CMsgBaseControl::SetReadOnly( TBool aReadOnly ) |
|
154 { |
|
155 PrepareForReadOnly( aReadOnly ); |
|
156 |
|
157 if ( aReadOnly ) |
|
158 { |
|
159 iControlModeFlags |= EMsgControlModeReadOnly; |
|
160 } |
|
161 else |
|
162 { |
|
163 iControlModeFlags &= ~EMsgControlModeReadOnly; |
|
164 } |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------- |
|
168 // CMsgBaseControl::IsReadOnly |
|
169 // |
|
170 // Returns the read only status of the control. |
|
171 // --------------------------------------------------------- |
|
172 // |
|
173 EXPORT_C TBool CMsgBaseControl::IsReadOnly() const |
|
174 { |
|
175 return iControlModeFlags & EMsgControlModeReadOnly; |
|
176 } |
|
177 |
|
178 // --------------------------------------------------------- |
|
179 // CMsgBaseControl::ControlId |
|
180 // |
|
181 // Returns the control id. |
|
182 // --------------------------------------------------------- |
|
183 // |
|
184 EXPORT_C TInt CMsgBaseControl::ControlId() const |
|
185 { |
|
186 return iControlId; |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------- |
|
190 // CMsgBaseControl::SetControlId |
|
191 // |
|
192 // Sets the control id. |
|
193 // --------------------------------------------------------- |
|
194 // |
|
195 EXPORT_C void CMsgBaseControl::SetControlId( TInt aControlId ) |
|
196 { |
|
197 iControlId = aControlId; |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------- |
|
201 // CMsgBaseControl::DistanceFromComponentAbove |
|
202 // |
|
203 // Returns a distance from above to this control in pixels. |
|
204 // --------------------------------------------------------- |
|
205 // |
|
206 EXPORT_C TInt CMsgBaseControl::DistanceFromComponentAbove() const |
|
207 { |
|
208 return iDistanceFromComponentAbove; |
|
209 } |
|
210 |
|
211 // --------------------------------------------------------- |
|
212 // CMsgBaseControl::SetDistanceFromComponentAbove |
|
213 // |
|
214 // Sets a distance from above control in pixels. |
|
215 // --------------------------------------------------------- |
|
216 // |
|
217 EXPORT_C void CMsgBaseControl::SetDistanceFromComponentAbove( TInt aDistance ) |
|
218 { |
|
219 iDistanceFromComponentAbove = aDistance; |
|
220 } |
|
221 |
|
222 // --------------------------------------------------------- |
|
223 // CMsgBaseControl::Margins |
|
224 // |
|
225 // Returns the margins of the control. |
|
226 // --------------------------------------------------------- |
|
227 // |
|
228 EXPORT_C TMargins CMsgBaseControl::Margins() const |
|
229 { |
|
230 return iMargins; |
|
231 } |
|
232 |
|
233 // --------------------------------------------------------- |
|
234 // CMsgBaseControl::SetMargins |
|
235 // |
|
236 // Sets margins for the control. |
|
237 // --------------------------------------------------------- |
|
238 // |
|
239 EXPORT_C void CMsgBaseControl::SetMargins( const TMargins& aMargins ) |
|
240 { |
|
241 iMargins = aMargins; |
|
242 } |
|
243 |
|
244 // --------------------------------------------------------- |
|
245 // CMsgBaseControl::SetBaseControlObserver |
|
246 // |
|
247 // Sets base control observer. |
|
248 // --------------------------------------------------------- |
|
249 // |
|
250 EXPORT_C void CMsgBaseControl::SetBaseControlObserver( |
|
251 MMsgBaseControlObserver& aBaseControlObserver ) |
|
252 { |
|
253 iBaseControlObserver = &aBaseControlObserver; |
|
254 } |
|
255 |
|
256 // --------------------------------------------------------- |
|
257 // CMsgBaseControl::VirtualHeight |
|
258 // |
|
259 // Returns approximate height of the control. |
|
260 // --------------------------------------------------------- |
|
261 // |
|
262 EXPORT_C TInt CMsgBaseControl::VirtualHeight() |
|
263 { |
|
264 return iSize.iHeight; |
|
265 } |
|
266 |
|
267 // --------------------------------------------------------- |
|
268 // CMsgBaseControl::VirtualVisibleTop |
|
269 // |
|
270 // Returns a topmost visible text position. |
|
271 // --------------------------------------------------------- |
|
272 // |
|
273 EXPORT_C TInt CMsgBaseControl::VirtualVisibleTop() |
|
274 { |
|
275 return 0; |
|
276 } |
|
277 |
|
278 // --------------------------------------------------------- |
|
279 // CMsgBaseControl::BaseConstructL |
|
280 // |
|
281 // Sets default margins for the control. |
|
282 // --------------------------------------------------------- |
|
283 // |
|
284 EXPORT_C void CMsgBaseControl::BaseConstructL() |
|
285 { |
|
286 iMargins.iLeft = 0; |
|
287 iMargins.iRight = 0; |
|
288 iMargins.iTop = 0; |
|
289 iMargins.iBottom = 0; |
|
290 } |
|
291 |
|
292 // --------------------------------------------------------- |
|
293 // CMsgBaseControl::NormalTextFontL |
|
294 // |
|
295 // Returns a pointer to the normal text font. |
|
296 // --------------------------------------------------------- |
|
297 // |
|
298 EXPORT_C const CFont* CMsgBaseControl::NormalTextFontL() const |
|
299 { |
|
300 //TODO: Should this be read from LAF? |
|
301 const CFont* font = iEikonEnv->NormalFont(); |
|
302 return font; |
|
303 } |
|
304 |
|
305 // --------------------------------------------------------- |
|
306 // CMsgBaseControl::LabelFontL |
|
307 // |
|
308 // Returns a pointer to the normal label font. |
|
309 // --------------------------------------------------------- |
|
310 // |
|
311 EXPORT_C const CFont* CMsgBaseControl::LabelFontL() const |
|
312 { |
|
313 TRect msgPane = MsgEditorCommons::MsgMainPane(); |
|
314 TAknLayoutText labelLayout; |
|
315 labelLayout.LayoutText( |
|
316 msgPane, |
|
317 AppLayout::Message_writing_texts_Line_1( 0 ) ); |
|
318 return labelLayout.Font(); |
|
319 } |
|
320 |
|
321 // --------------------------------------------------------- |
|
322 // CMsgBaseControl::CountComponentControls |
|
323 // |
|
324 // Returns a number of controls. |
|
325 // --------------------------------------------------------- |
|
326 // |
|
327 EXPORT_C TInt CMsgBaseControl::CountComponentControls() const |
|
328 { |
|
329 __ASSERT_DEBUG( EFalse, Panic( EMsgInheritedFunctionIsMissing ) ); |
|
330 return 0; |
|
331 } |
|
332 |
|
333 // --------------------------------------------------------- |
|
334 // CMsgBaseControl::ComponentControl |
|
335 // |
|
336 // Returns a control of index aIndex. |
|
337 // --------------------------------------------------------- |
|
338 // |
|
339 EXPORT_C CCoeControl* CMsgBaseControl::ComponentControl( TInt /*aIndex*/ ) const |
|
340 { |
|
341 __ASSERT_DEBUG( EFalse, Panic( EMsgInheritedFunctionIsMissing ) ); |
|
342 return NULL; |
|
343 } |
|
344 |
|
345 // --------------------------------------------------------- |
|
346 // CMsgBaseControl::SizeChanged |
|
347 // |
|
348 // nop |
|
349 // --------------------------------------------------------- |
|
350 // |
|
351 EXPORT_C void CMsgBaseControl::SizeChanged() |
|
352 { |
|
353 __ASSERT_DEBUG( EFalse, Panic( EMsgInheritedFunctionIsMissing ) ); |
|
354 } |
|
355 |
|
356 // --------------------------------------------------------- |
|
357 // CMsgBaseControl::FocusChanged |
|
358 // |
|
359 // nop |
|
360 // --------------------------------------------------------- |
|
361 // |
|
362 EXPORT_C void CMsgBaseControl::FocusChanged( TDrawNow /*aDrawNow*/ ) |
|
363 { |
|
364 __ASSERT_DEBUG( EFalse, Panic( EMsgInheritedFunctionIsMissing ) ); |
|
365 } |
|
366 |
|
367 // --------------------------------------------------------- |
|
368 // CMsgBaseControl::ItemFinder |
|
369 // |
|
370 // nop |
|
371 // --------------------------------------------------------- |
|
372 // |
|
373 EXPORT_C CItemFinder* CMsgBaseControl::ItemFinder() |
|
374 { |
|
375 return NULL; |
|
376 } |
|
377 |
|
378 // --------------------------------------------------------- |
|
379 // CMsgBaseControl::SetupAutomaticFindAfterFocusChangeL |
|
380 // |
|
381 // nop |
|
382 // --------------------------------------------------------- |
|
383 // |
|
384 EXPORT_C void CMsgBaseControl::SetupAutomaticFindAfterFocusChangeL( TBool /*aBeginning */ ) |
|
385 { |
|
386 } |
|
387 |
|
388 // --------------------------------------------------------- |
|
389 // CMsgBaseControl::ScrollL |
|
390 // |
|
391 // nop |
|
392 // --------------------------------------------------------- |
|
393 // |
|
394 EXPORT_C TInt CMsgBaseControl::ScrollL( TInt /*aPixelsToScroll*/, |
|
395 TMsgScrollDirection /*aDirection*/ ) |
|
396 { |
|
397 return 0; |
|
398 } |
|
399 |
|
400 // --------------------------------------------------------- |
|
401 // CMsgBaseControl::HandleResourceChange |
|
402 // |
|
403 // nop |
|
404 // --------------------------------------------------------- |
|
405 // |
|
406 EXPORT_C void CMsgBaseControl::HandleResourceChange( TInt aType ) |
|
407 { |
|
408 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
409 { |
|
410 iLineHeight = MsgEditorCommons::MsgBaseLineDelta(); |
|
411 iMaxBodyHeight = MsgEditorCommons::MaxBodyHeight(); |
|
412 } |
|
413 |
|
414 CCoeControl::HandleResourceChange( aType ); |
|
415 } |
|
416 |
|
417 // End of File |