|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // header for client-side and server-side clock DLL's |
|
15 // $Workfile: CL_STD.H $ |
|
16 // $Revision: 1.7 $ |
|
17 // $Author: DougF $ |
|
18 // $Date: 07 Jul 1999 16:16:18 $ |
|
19 // |
|
20 // |
|
21 |
|
22 #if !defined(__CL_STD_H__) |
|
23 #define __CL_STD_H__ |
|
24 |
|
25 #if !defined(__E32STD_H__) |
|
26 #include <e32std.h> |
|
27 #endif |
|
28 |
|
29 #if !defined(__E32BASE_H__) |
|
30 #include <e32base.h> |
|
31 #endif |
|
32 |
|
33 #if !defined(__W32STD_H__) |
|
34 #include <w32std.h> |
|
35 #endif |
|
36 |
|
37 #if !defined(__W32ADLL_H__) |
|
38 #include <w32adll.h> |
|
39 #endif |
|
40 |
|
41 #if !defined(__CLOCK_H__) |
|
42 #include <clock.h> |
|
43 #endif |
|
44 |
|
45 // |
|
46 // build flags |
|
47 // |
|
48 |
|
49 #undef __SHOW_UPDATE_REGION__ |
|
50 #undef __SLOW_DIGITAL_REGION_CALCULATION__ |
|
51 |
|
52 // |
|
53 // miscellaneous constants |
|
54 // |
|
55 |
|
56 const TInt KCheckValueForEndOfTimeDeviceConstructionBuf=0x3af96b5e; // a random number |
|
57 const TInt KPanicClientFromServer=1; |
|
58 const TInt KIpcSlot=1; // must not be zero as this is reserved by the window server |
|
59 |
|
60 // |
|
61 // miscellaneous typedefs |
|
62 // |
|
63 |
|
64 typedef RRegionBuf<10> RRegionBuf10; |
|
65 |
|
66 // |
|
67 // miscellaneous enums |
|
68 // |
|
69 |
|
70 enum TClockClientPanic |
|
71 { |
|
72 EClockClientPanicAlreadyConstructed, |
|
73 EClockClientPanicAlreadyConstructedDigitalClock, |
|
74 EClockClientPanicAlreadyConstructedAnalogClock, |
|
75 EClockClientPanicNotYetConstructedDigitalClock, |
|
76 EClockClientPanicNotYetConstructedAnalogClock, |
|
77 EClockClientPanicNotYetFullyConstructed1, |
|
78 EClockClientPanicNotYetFullyConstructed2, |
|
79 EClockClientPanicNotYetFullyConstructed3, |
|
80 EClockClientPanicNotYetFullyConstructed4, |
|
81 EClockClientPanicNotYetFullyConstructed5, |
|
82 EClockClientPanicNotYetFullyConstructed6, |
|
83 EClockClientPanicNotYetFullyConstructed7, |
|
84 EClockClientPanicNotYetFullyConstructed8, |
|
85 EClockClientPanicNotYetFullyConstructed9, |
|
86 EClockClientPanicNotYetFullyConstructed10, |
|
87 EClockClientPanicNotYetFullyConstructed11, |
|
88 EClockClientPanicNotYetFullyConstructed12, |
|
89 EClockClientPanicIncorrectNumberOfAdditions1, |
|
90 EClockClientPanicIncorrectNumberOfAdditions2, |
|
91 EClockClientPanicNoConstructorBuf, |
|
92 EClockClientPanicBadSetNumAdditionsStillExpectedCall, |
|
93 EClockClientPanicTooFewTextSections, |
|
94 EClockClientPanicTooFewHands, |
|
95 EClockClientPanicTooFewHandFeatures, |
|
96 EClockClientPanicRectIsNotNormalized, |
|
97 EClockClientPanicUnexpectedError1, |
|
98 EClockClientPanicUnexpectedError2, |
|
99 EClockClientPanicUnexpectedError3, |
|
100 EClockClientPanicUnexpectedError4, |
|
101 EClockClientPanicUnexpectedError5, |
|
102 EClockClientPanicUnexpectedError6, |
|
103 EClockClientPanicUnexpectedError7, |
|
104 EClockClientPanicUnexpectedError8, |
|
105 EClockClientPanicUnexpectedError9, |
|
106 EClockClientPanicUnexpectedError10, |
|
107 EClockClientPanicUnexpectedError11, |
|
108 EClockClientPanicUnexpectedError12, |
|
109 // Setting the colors |
|
110 EClockClientPanicNotYetFullyConstructedDigitalTextColor, // When setting the text color for digital clock |
|
111 EClockClientPanicNotYetFullyConstructedAnalogPenColor, // When setting the pen color for analog clock |
|
112 EClockClientPanicNotYetFullyConstructedAnalogBrushColor, // When setting the brush color for analog clock |
|
113 EClockClientPanicNotYetFullyConstructedMsgWindowBackgroundColor, // When setting the background color for window message |
|
114 EClockClientPanicNotYetFullyConstructedMsgWindowTextColor, // When setting the text color for window message |
|
115 EClockClientPanicNotYetFullyConstructedMsgWindowBorderColor, // When setting the border color for window message |
|
116 EClockClientPanicNotYetFullyConstructedMsgWindowPlinthColor, // When setting the plinth color for window message |
|
117 EClockClientPanicUnexpectedErrorDigitalTextColor, // When setting the text color for digital clock |
|
118 EClockClientPanicUnexpectedErrorAnalogPenColor, // When setting the pen color for analog clock |
|
119 EClockClientPanicUnexpectedErrorAnalogBrushColor, // When setting the brush color for analog clock |
|
120 EClockClientPanicUnexpectedErrorMsgWindowBackgroundColor, // When setting the background color for window message |
|
121 EClockClientPanicUnexpectedErrorMsgWindowTextColor, // When setting the text color for window message |
|
122 EClockClientPanicUnexpectedErrorMsgWindowBorderColor, // When setting the border color for window message |
|
123 EClockClientPanicUnexpectedErrorMsgWindowPlinthColor, // When setting the plinth color for window message |
|
124 }; |
|
125 |
|
126 // |
|
127 |
|
128 enum TClockServerPanic |
|
129 { |
|
130 EClockServerPanicNotInitializedToNULL1, |
|
131 EClockServerPanicNotInitializedToNULL2, |
|
132 EClockServerPanicNotInitializedToNULL3, |
|
133 EClockServerPanicNotInitializedToNULL4, |
|
134 EClockServerPanicNotInitializedToNULL5, |
|
135 EClockServerPanicNotInitializedToNULL6, |
|
136 EClockServerPanicNotInitializedToNULL7, |
|
137 EClockServerPanicNotInitializedToNULL8, |
|
138 EClockServerPanicNotInitializedToNULL9, |
|
139 EClockServerPanicNotInitializedToZero1, |
|
140 EClockServerPanicNotInitializedToZero2, |
|
141 EClockServerPanicNotInitializedToZero3, |
|
142 EClockServerPanicNotInitializedToZero4, |
|
143 EClockServerPanicBadSync1, |
|
144 EClockServerPanicBadSync2, |
|
145 EClockServerPanicBadSync3, |
|
146 EClockServerPanicBadPolyLineState, |
|
147 EClockServerPanicInconsistentPointListLengths, |
|
148 EClockServerPanicBadEndOfConstructionBuf, |
|
149 EClockServerPanicUnexpectedError, |
|
150 EClockServerPanicAlreadyVisible, |
|
151 EClockServerPanicTimerIsActive, |
|
152 EClockServerPanicAnimatingNonFlashingMessageWindow, |
|
153 EClockServerPanicBadRect, |
|
154 EClockServerPanicBadMessageWindowTimerAction |
|
155 }; |
|
156 |
|
157 // |
|
158 |
|
159 enum TAnimType |
|
160 { |
|
161 EAnimClock, |
|
162 EAnimMessageWindow |
|
163 }; |
|
164 |
|
165 // |
|
166 // constructor argument structs |
|
167 // |
|
168 |
|
169 struct SDigitalDisplayConstructorArgs |
|
170 { |
|
171 TPoint iPosition; |
|
172 TSize iSize; |
|
173 TMargins iMargins; |
|
174 STimeDeviceShadow iShadow; |
|
175 TRgb iBackgroundColor; |
|
176 TInt iNumTextSections; |
|
177 }; |
|
178 |
|
179 // |
|
180 |
|
181 struct SDigitalDisplayTextSectionConstructorArgs |
|
182 { |
|
183 TInt iFontHandle; |
|
184 TRgb iTextColor; |
|
185 TDigitalDisplayHorizontalTextAlignment iHorizontalAlignment; |
|
186 TDigitalDisplayVerticalTextAlignment iVerticalAlignment; |
|
187 TInt iHorizontalMargin; |
|
188 TInt iVerticalMargin; |
|
189 TInt iFormatLength; |
|
190 }; |
|
191 |
|
192 // |
|
193 |
|
194 struct SAnalogDisplayConstructorArgs |
|
195 { |
|
196 TPoint iPosition; |
|
197 TSize iSize; |
|
198 TMargins iMargins; |
|
199 STimeDeviceShadow iShadow; |
|
200 TInt iFaceHandle; |
|
201 TInt iFaceMaskHandle; |
|
202 TInt iNumHands; |
|
203 TBool iHasAmPm; |
|
204 }; |
|
205 |
|
206 // |
|
207 |
|
208 struct SAnalogDisplayHandConstructorArgs |
|
209 { |
|
210 TAnalogDisplayHandType iType; |
|
211 TInt iNumFeatures; |
|
212 }; |
|
213 |
|
214 // |
|
215 |
|
216 struct SAnalogDisplayHandLineConstructorArgs |
|
217 { |
|
218 CGraphicsContext::TPenStyle iPenStyle; |
|
219 TRgb iPenColor; |
|
220 TSize iPenSize; |
|
221 TPoint iStartPoint; |
|
222 TPoint iEndPoint; |
|
223 }; |
|
224 |
|
225 // |
|
226 |
|
227 struct SAnalogDisplayHandPolyLineConstructorArgs |
|
228 { |
|
229 CGraphicsContext::TPenStyle iPenStyle; |
|
230 TRgb iPenColor; |
|
231 TSize iPenSize; |
|
232 CGraphicsContext::TBrushStyle iBrushStyle; |
|
233 TRgb iBrushColor; |
|
234 TBool iClosed; |
|
235 TInt iNumPoints; |
|
236 }; |
|
237 |
|
238 // |
|
239 |
|
240 struct SAnalogDisplayHandCircleConstructorArgs |
|
241 { |
|
242 CGraphicsContext::TPenStyle iPenStyle; |
|
243 TRgb iPenColor; |
|
244 TSize iPenSize; |
|
245 CGraphicsContext::TBrushStyle iBrushStyle; |
|
246 TRgb iBrushColor; |
|
247 TPoint iCircleCenter; |
|
248 TInt iRadius; |
|
249 }; |
|
250 |
|
251 // |
|
252 struct SAnalogDisplayHandFeaturesPenColorArgs |
|
253 { |
|
254 TRgb iPenColor; |
|
255 }; |
|
256 |
|
257 // |
|
258 struct SAnalogDisplayHandFeaturesBrushColorArgs |
|
259 { |
|
260 TRgb iBrushColor; |
|
261 }; |
|
262 |
|
263 // |
|
264 |
|
265 struct SClockConstructorArgs |
|
266 { |
|
267 TTimeIntervalSeconds iUniversalTimeOffset; |
|
268 }; |
|
269 |
|
270 // |
|
271 |
|
272 struct SMessageWindowConstructorArgs |
|
273 { |
|
274 TInt iBaselineOffset; |
|
275 TInt iFontHandle; |
|
276 TRgb iBackgroundColor; |
|
277 TRgb iTextColor; |
|
278 TRgb iBorderColor; |
|
279 }; |
|
280 |
|
281 // |
|
282 struct SMessageWindowBackgroundColorArgs |
|
283 { |
|
284 TRgb iBackgroundColor; |
|
285 }; |
|
286 // |
|
287 struct SMessageWindowTextColorArgs |
|
288 { |
|
289 TRgb iTextColor; |
|
290 }; |
|
291 // |
|
292 struct SMessageWindowBorderColorArgs |
|
293 { |
|
294 TRgb iBorderColor; |
|
295 }; |
|
296 |
|
297 struct SMessageWindowPlinthColorArgs |
|
298 { |
|
299 TRgb iTlColor; |
|
300 TRgb iBrColor; |
|
301 }; |
|
302 |
|
303 // |
|
304 // command opcodes and their argument structs |
|
305 // |
|
306 |
|
307 enum TTimeDeviceCommand |
|
308 { |
|
309 EClockCommand =0x1000, |
|
310 EDisplayCommand =0x2000, |
|
311 EDigitalDisplayCommand =0x4000|EDisplayCommand, |
|
312 EAnalogDisplayCommand =0x8000|EDisplayCommand, |
|
313 EClockCommandSetUniversalTimeOffset =EClockCommand|1, |
|
314 EDisplayCommandSetVisible =EDisplayCommand|1, |
|
315 EDisplayCommandSetPositionAndSize =EDisplayCommand|2, |
|
316 EDisplayCommandSetPosition =EDisplayCommand|3, |
|
317 EDisplayCommandSetSize =EDisplayCommand|4, |
|
318 EDisplayCommandUpdateDisplay =EDisplayCommand|5, |
|
319 EDisplayCommandDraw =EDisplayCommand|6, |
|
320 EDigitalDisplayCommandSetBackgroundColor =EDigitalDisplayCommand|1, |
|
321 //!< |
|
322 EDigitalDisplayCommandSetTextColor =EDigitalDisplayCommand|2, |
|
323 EAnalogDisplayCommandSetPenColor =EAnalogDisplayCommand|1, |
|
324 EAnalogDisplayCommandSetBrushColor =EAnalogDisplayCommand|2 |
|
325 //!> |
|
326 }; |
|
327 |
|
328 struct SClockCommandSetUniversalTimeOffsetArgs |
|
329 { |
|
330 TTimeIntervalSeconds iUniversalTimeOffset; |
|
331 }; |
|
332 |
|
333 struct SDisplayCommandSetVisibleArgs |
|
334 { |
|
335 TBool iVisible; |
|
336 }; |
|
337 |
|
338 struct SDisplayCommandSetPositionAndSizeArgs |
|
339 { |
|
340 TPoint iPosition; |
|
341 TSize iSize; |
|
342 }; |
|
343 |
|
344 struct SDisplayCommandSetPositionArgs |
|
345 { |
|
346 TPoint iPosition; |
|
347 }; |
|
348 |
|
349 struct SDisplayCommandSetSizeArgs |
|
350 { |
|
351 TSize iSize; |
|
352 }; |
|
353 |
|
354 struct SDigitalDisplayCommandSetBackgroundColorArgs |
|
355 { |
|
356 TRgb iBackgroundColor; |
|
357 TRgb iShadowColor; |
|
358 }; |
|
359 |
|
360 // |
|
361 struct SDigitalDisplayCommandSetTextColorArgs |
|
362 { |
|
363 TRgb iTextColor; |
|
364 }; |
|
365 |
|
366 enum TMessageWindowCommand |
|
367 { |
|
368 EMessageWindowCommandStartDisplay, |
|
369 EMessageWindowCommandCancelDisplay, |
|
370 EMessageWindowCommandGetBorders, |
|
371 EMessageWindowCommandSetBackgroundColor, |
|
372 EMessageWindowCommandSetTextColor, |
|
373 EMessageWindowCommandSetBorderColor, |
|
374 EMessageWindowCommandSetPlinthColor, |
|
375 }; |
|
376 |
|
377 struct SMessageWindowCommandStartDisplayArgs |
|
378 { |
|
379 enum |
|
380 { |
|
381 EIndefiniteDuration=-1 |
|
382 }; |
|
383 TBool iFlash; |
|
384 TTimeIntervalMicroSeconds32 iInitialDelay; |
|
385 TTimeIntervalMicroSeconds32 iDuration; |
|
386 TBuf<RMessageWindow::EMaxTextLength> iText; |
|
387 }; |
|
388 |
|
389 // |
|
390 // utility classes supporting the digital display class |
|
391 // |
|
392 |
|
393 class DDigitalDisplayTextSection : public CBase |
|
394 { |
|
395 public: |
|
396 DDigitalDisplayTextSection(MAnimGeneralFunctions& aFunctions, TRgb aTextColor, TDigitalDisplayHorizontalTextAlignment aHorizontalAlignment, |
|
397 TDigitalDisplayVerticalTextAlignment aVerticalAlignment, |
|
398 TInt aHorizontalMargin, TInt aVerticalMargin); |
|
399 void ConstructL(const TDesC& aFormat, TInt aFontHandle); |
|
400 void SetInitialTimeP(const TTime& aTime, TBool aLimitResolutionToMinutes); |
|
401 virtual ~DDigitalDisplayTextSection(); |
|
402 void DrawP(CAnimGc& aGc, const TRect& aRect, TBool aFlashStateOn, const TRgb* aOverridingColor=NULL) const; |
|
403 void UpdateDisplayDataP(const TRect& aRect, const STimeDeviceShadow& aShadow, const TTime& aTime, TBool aFlashStateIsChanging, TRegion* aRegion, TBool aLimitResolutionToMinutes); |
|
404 void SetTextColor(TRgb aTextColor); |
|
405 |
|
406 private: |
|
407 void FormatTruncatingIfNecessaryP(const TTime& aTime, TDes& aResult, TBool aLimitResolutionToMinutes) const; |
|
408 TRect UpdateRect(const TPoint& aPosition, const SCharWidth& aPixelWidth, TInt aAscentInPixels, TInt aHeightInPixels) const; |
|
409 TRect ExpandToIncludeShadows(const TRect& aRect, const STimeDeviceShadow& aShadow) const; |
|
410 #if defined(__SLOW_DIGITAL_REGION_CALCULATION__) |
|
411 void AddUpdateAreasToRegion(TRegion& aRegion, TInt aYPosition, const STimeDeviceShadow& aShadow, TInt aAscentInPixels, TInt aHeightInPixels, |
|
412 const TDesC& aOldText, TInt aOldXPosition, |
|
413 const TDesC& aNewText, TInt aNewXPosition) const; |
|
414 #endif |
|
415 void InitializeTextBlockIteratorP(const TRect& aRect, const TDesC& aText, TInt& aTextOffset, TInt& aTextLength, |
|
416 TInt& aXPosition, SCharWidth& aPixelWidth, TBool& aInFlashingBlock) const; |
|
417 TBool GetNextTextBlockP(const TDesC& aText, TInt& aTextOffset, TInt& aTextLength, |
|
418 TInt& aXPosition, SCharWidth& aPixelWidth, TBool& aInFlashingBlock) const; |
|
419 TInt XPositionP(const TRect& aRect, const TDesC& aText) const; |
|
420 TInt YPositionP(const TRect& aRect) const; |
|
421 void TextWidthInPixels(const TDesC& aText, SCharWidth& aPixelWidth) const; |
|
422 private: |
|
423 typedef TBuf<48> TDisplayText; |
|
424 private: |
|
425 MAnimGeneralFunctions& iFunctions; |
|
426 HBufC* iFormat; |
|
427 TDisplayText iDisplayText; |
|
428 CFbsFont* iFont; |
|
429 TRgb iTextColor; |
|
430 TDigitalDisplayHorizontalTextAlignment iHorizontalAlignment; |
|
431 TDigitalDisplayVerticalTextAlignment iVerticalAlignment; |
|
432 TInt iHorizontalMargin; |
|
433 TInt iVerticalMargin; |
|
434 HBufC* iTruncatedFormat; |
|
435 }; |
|
436 |
|
437 // |
|
438 // utility classes supporting the analog display class |
|
439 // |
|
440 |
|
441 class TFraction |
|
442 { |
|
443 public: |
|
444 TFraction(); |
|
445 TFraction(TInt aNumber, TInt aRightShift); |
|
446 TInt operator*(TInt aInt) const; |
|
447 private: |
|
448 TInt iNumber; |
|
449 TInt iRightShift; |
|
450 }; |
|
451 |
|
452 // |
|
453 |
|
454 class TTrig |
|
455 { |
|
456 public: |
|
457 static TFraction Sin(TInt aDegrees); |
|
458 static TFraction Cos(TInt aDegrees); |
|
459 private: |
|
460 enum |
|
461 { |
|
462 ERightShift=15, |
|
463 ENumStepsPer90Degrees=15, |
|
464 ENumInterpolations=90/ENumStepsPer90Degrees, |
|
465 ENumStored=ENumStepsPer90Degrees+2 |
|
466 }; |
|
467 private: |
|
468 static const TInt iStore[ENumStored]; |
|
469 }; |
|
470 |
|
471 // |
|
472 |
|
473 class DAnalogDisplayHandFeature : public CBase |
|
474 { |
|
475 public: |
|
476 DAnalogDisplayHandFeature(); |
|
477 virtual TRect BoundingRectP(const TFraction& aSin, const TFraction& aCos, const TPoint& aHandCenter) const=0; |
|
478 virtual void Draw(CAnimGc& aGc, const TFraction& aSin, const TFraction& aCos, const TPoint& aHandCenter, const TRgb* aOverridingColor) const=0; |
|
479 virtual void SetPenColor(TRgb aPenColor); |
|
480 virtual void SetBrushColor(TRgb aBrushColor); |
|
481 |
|
482 protected: |
|
483 TPoint Rotate(const TPoint& aPoint, const TFraction& aSin, const TFraction& aCos, const TPoint& aOffset) const; |
|
484 TRect AdjustRectForPenSizeP(const TRect& aRect, const TSize& aPenSize) const; |
|
485 }; |
|
486 |
|
487 // |
|
488 |
|
489 class DAnalogDisplayHandLine : public DAnalogDisplayHandFeature |
|
490 { |
|
491 public: |
|
492 DAnalogDisplayHandLine(CGraphicsContext::TPenStyle aPenStyle, TRgb aPenColor, const TSize& aPenSize, const TPoint& aStartPoint, const TPoint& aEndPoint); |
|
493 virtual TRect BoundingRectP(const TFraction& aSin, const TFraction& aCos, const TPoint& aHandCenter) const; |
|
494 virtual void Draw(CAnimGc& aGc, const TFraction& aSin, const TFraction& aCos, const TPoint& aHandCenter, const TRgb* aOverridingColor) const; |
|
495 void SetPenColor(TRgb aPenColor); |
|
496 |
|
497 private: |
|
498 CGraphicsContext::TPenStyle iPenStyle; |
|
499 TRgb iPenColor; |
|
500 TSize iPenSize; |
|
501 TPoint iStartPoint; |
|
502 TPoint iEndPoint; |
|
503 }; |
|
504 |
|
505 // |
|
506 |
|
507 class DAnalogDisplayHandPolyLine : public DAnalogDisplayHandFeature |
|
508 { |
|
509 public: |
|
510 DAnalogDisplayHandPolyLine(CGraphicsContext::TPenStyle aPenStyle, TRgb aPenColor, const TSize& aPenSize, |
|
511 CGraphicsContext::TBrushStyle aBrushStyle, TRgb aBrushColor, |
|
512 TBool aClosed, TInt aNumPoints); |
|
513 void AddPointLP(const TPoint& aPoint); |
|
514 virtual ~DAnalogDisplayHandPolyLine(); |
|
515 virtual TRect BoundingRectP(const TFraction& aSin, const TFraction& aCos, const TPoint& aHandCenter) const; |
|
516 virtual void Draw(CAnimGc& aGc, const TFraction& aSin, const TFraction& aCos, const TPoint& aHandCenter, const TRgb* aOverridingColor) const; |
|
517 void SetPenColor(TRgb aPenColor); |
|
518 void SetBrushColor(TRgb aBrushColor); |
|
519 |
|
520 private: |
|
521 struct SPointList |
|
522 { |
|
523 TInt16 iNumPoints; |
|
524 TInt16 iNumPointsAdded; |
|
525 TPoint* iPoints; |
|
526 }; |
|
527 private: |
|
528 void SetScratchPointList(const TFraction& aSin, const TFraction& aCos, const TPoint& aHandCenter) const; |
|
529 private: |
|
530 CGraphicsContext::TPenStyle iPenStyle; |
|
531 TRgb iPenColor; |
|
532 TSize iPenSize; |
|
533 CGraphicsContext::TBrushStyle iBrushStyle; |
|
534 TRgb iBrushColor; |
|
535 TBool iClosed; |
|
536 SPointList iPoints; |
|
537 CArrayFix<TPoint>* iScratchPointList; |
|
538 }; |
|
539 |
|
540 // |
|
541 |
|
542 class DAnalogDisplayHandCircle : public DAnalogDisplayHandFeature |
|
543 { |
|
544 public: |
|
545 DAnalogDisplayHandCircle(CGraphicsContext::TPenStyle aPenStyle, TRgb aPenColor, const TSize& aPenSize, |
|
546 CGraphicsContext::TBrushStyle aBrushStyle, TRgb aBrushColor, |
|
547 const TPoint& aCircleCenter, TInt aRadius); |
|
548 virtual TRect BoundingRectP(const TFraction& aSin, const TFraction& aCos, const TPoint& aHandCenter) const; |
|
549 virtual void Draw(CAnimGc& aGc, const TFraction& aSin, const TFraction& aCos, const TPoint& aHandCenter, const TRgb* aOverridingColor) const; |
|
550 void SetPenColor(TRgb aPenColor); |
|
551 void SetBrushColor(TRgb aBrushColor); |
|
552 |
|
553 private: |
|
554 TRect Rect(const TFraction& aSin, const TFraction& aCos, const TPoint& aHandCenter) const; |
|
555 private: |
|
556 CGraphicsContext::TPenStyle iPenStyle; |
|
557 TRgb iPenColor; |
|
558 TSize iPenSize; |
|
559 CGraphicsContext::TBrushStyle iBrushStyle; |
|
560 TRgb iBrushColor; |
|
561 TPoint iCircleCenter; |
|
562 TInt iRadius; |
|
563 }; |
|
564 |
|
565 // |
|
566 |
|
567 class DAnalogDisplayHand : public CBase |
|
568 { |
|
569 public: |
|
570 DAnalogDisplayHand(TAnalogDisplayHandType aType, TInt aNumFeatures); |
|
571 void AddFeatureLP(DAnalogDisplayHandFeature* aFeature); |
|
572 void SetInitialTimeP(const TTime& aTime); |
|
573 virtual ~DAnalogDisplayHand(); |
|
574 void DrawP(CAnimGc& aGc, const TPoint& aHandCenter, const TRgb* aOverridingColor=NULL) const; |
|
575 void UpdateDisplayDataP(const TTime& aTime, const TPoint& aHandCenter, const STimeDeviceShadow& aShadow, TRegion* aRegion); |
|
576 void SetPenColor(const TRgb aPenColor); |
|
577 void SetBrushColor(const TRgb aBrushColor); |
|
578 TAnalogDisplayHandType Type() const {return iType;}; |
|
579 |
|
580 private: |
|
581 TRect BoundingRectP(const TPoint& aHandCenter, const STimeDeviceShadow& aShadow) const; |
|
582 void SetDegreesOffUpright(TInt aDegreesOffUpright); |
|
583 TInt DegreesOffUprightP(const TTime& aTime) const; |
|
584 private: |
|
585 struct SFeatureList |
|
586 { |
|
587 TInt16 iNumFeatures; |
|
588 TInt16 iNumFeaturesAdded; |
|
589 DAnalogDisplayHandFeature** iFeatures; |
|
590 }; |
|
591 private: |
|
592 TAnalogDisplayHandType iType; |
|
593 SFeatureList iFeatures; |
|
594 TInt iDegreesOffUpright; |
|
595 TFraction iSin; |
|
596 TFraction iCos; |
|
597 }; |
|
598 |
|
599 // |
|
600 // utility class |
|
601 // |
|
602 |
|
603 // To give our animation the ability to animate itself independent |
|
604 // to WSERV calling Animate() make it a CFreeTimerWindowAnim |
|
605 class DAnimWithUtils : public CFreeTimerWindowAnim |
|
606 { |
|
607 public: |
|
608 struct TFunctions |
|
609 { |
|
610 inline TFunctions(MAnimGeneralFunctions& aFunctions,MAnimWindowFunctions& aWindowFunctions) |
|
611 :iFunctions(aFunctions),iWindowFunctions(aWindowFunctions) {} |
|
612 MAnimGeneralFunctions& iFunctions; |
|
613 MAnimWindowFunctions& iWindowFunctions; |
|
614 }; |
|
615 public: |
|
616 DAnimWithUtils(); |
|
617 virtual void ConstructL(TAny* aArgs, TBool aHasFocus); |
|
618 virtual TInt CommandReplyL(TInt aOpcode, TAny* aArgs); |
|
619 virtual void Command(TInt aOpcode, TAny* aArgs); |
|
620 virtual void Animate(TDateTime* aDateTime); |
|
621 virtual void Redraw(); |
|
622 virtual void FocusChanged(TBool aState); |
|
623 protected: |
|
624 virtual void ConstructLP(const TUint8* aBytePtr, TBool aHasFocus)=0; |
|
625 virtual TInt CommandReplyLP(TInt aOpcode, TAny* aArgs); |
|
626 virtual void CommandP(TInt aOpcode, TAny* aArgs); |
|
627 virtual void AnimateP(TDateTime* aDateTime)=0; |
|
628 virtual void RedrawP()=0; |
|
629 virtual void FocusChangedP(TBool aState); |
|
630 static TPtrC ReadText(const TUint8*& aBytePtr, TInt aTextLength); |
|
631 //Pure Virtual function from MEventHandler |
|
632 virtual TBool OfferRawEvent(const TRawEvent &aRawEvent); |
|
633 private: |
|
634 void HandleErrorIfErrorL(TInt aError); |
|
635 }; |
|
636 |
|
637 // CMinuteTick class definition here |
|
638 class CMinuteTick : public CTimer |
|
639 { |
|
640 public: |
|
641 class MObserver |
|
642 { |
|
643 public: |
|
644 virtual void MinuteTickCompleteL(const TTime& aNewUniversalTime)=0; |
|
645 }; |
|
646 public: |
|
647 static CMinuteTick* NewL(MObserver& aObserver); |
|
648 ~CMinuteTick(); |
|
649 |
|
650 void Start(); |
|
651 void Stop(); |
|
652 public: // From CActive (via CTimer) |
|
653 virtual void RunL(); |
|
654 private: |
|
655 CMinuteTick(MObserver& aObserver); |
|
656 void CalculateTimeAtNextMinute(); |
|
657 void ReQueueTimer(); |
|
658 private: |
|
659 MObserver& iObserver; |
|
660 TTime iHomeTimeAtNextMinute; |
|
661 }; |
|
662 |
|
663 // |
|
664 // time-device abstract class |
|
665 // |
|
666 |
|
667 class DDisplay; |
|
668 |
|
669 class DTimeDevice : public DAnimWithUtils, public CMinuteTick::MObserver |
|
670 { |
|
671 public: |
|
672 DTimeDevice(); |
|
673 virtual ~DTimeDevice(); |
|
674 public: // Overriding implementations from DAnimWithUtils |
|
675 virtual void FocusChanged(TBool aState); |
|
676 virtual void HandleNotification(const TWsEvent& aEvent); |
|
677 public: // from CMinuteTick::MObserver |
|
678 virtual void MinuteTickCompleteL(const TTime& aNewUniversalTime); |
|
679 protected: |
|
680 virtual void ConstructLP(const TUint8* aBytePtr, TBool aHasFocus); |
|
681 virtual TInt CommandReplyLP(TInt aOpcode, TAny* aArgs); |
|
682 virtual void CommandP(TInt aOpcode, TAny* aArgs); |
|
683 virtual void AnimateP(TDateTime* aDateTime); |
|
684 virtual void RedrawP(); |
|
685 TTime Time() const; |
|
686 static void StripOutCharacter(TDes& aText, TChar aCharacter); |
|
687 private: |
|
688 virtual void DoConstructL(const TUint8*& aBytePtr)=0; |
|
689 virtual TTime TimeGivenUniversalTime(const TTime& aUniversalTime) const=0; |
|
690 void DoAnimateP(); |
|
691 void CompleteAnimation(); |
|
692 void SwitchToMinuteTickIfNecessaryL(); |
|
693 static TInt FocusChangeCb(TAny* aThisPtr); |
|
694 protected: |
|
695 DDisplay* iDisplay; |
|
696 private: |
|
697 TTime iUniversalTime; |
|
698 TTimeIntervalSeconds iSecondsPerUpdate; |
|
699 CMinuteTick* iMinuteTick; |
|
700 TBool iDisplayIsAnalogue; |
|
701 TBool iAnimatingOnMinTick; |
|
702 TBool iVisible; |
|
703 CAsyncCallBack iFocusChangeCallback; |
|
704 }; |
|
705 |
|
706 // |
|
707 // time-device concrete classes |
|
708 // |
|
709 |
|
710 class DClock : public DTimeDevice |
|
711 { |
|
712 public: |
|
713 DClock(); |
|
714 protected: |
|
715 virtual TInt CommandReplyLP(TInt aOpcode, TAny* aArgs); |
|
716 virtual void DoConstructL(const TUint8*& aBytePtr); |
|
717 virtual TTime TimeGivenUniversalTime(const TTime& aUniversalTime) const; |
|
718 private: |
|
719 TTimeIntervalSeconds iUniversalTimeOffset; |
|
720 }; |
|
721 |
|
722 // |
|
723 // message-window class |
|
724 // |
|
725 |
|
726 class DMessageWindow : public DAnimWithUtils |
|
727 { |
|
728 public: |
|
729 DMessageWindow(); |
|
730 virtual ~DMessageWindow(); |
|
731 void StartDisplay(); |
|
732 void CancelDisplay(); |
|
733 private: |
|
734 virtual void ConstructLP(const TUint8* aBytePtr, TBool aHasFocus); |
|
735 virtual TInt CommandReplyLP(TInt aOpcode, TAny* aArgs); |
|
736 virtual void AnimateP(TDateTime* aDateTime); |
|
737 virtual void RedrawP(); |
|
738 TRect Rect() const; |
|
739 void DrawTextPortionOfDisplay(const TRect& aRect) const; |
|
740 private: |
|
741 class DMessageWindowTimer : public CTimer |
|
742 { |
|
743 public: |
|
744 enum TAction |
|
745 { |
|
746 EActionStartDisplay, |
|
747 EActionCancelDisplay |
|
748 }; |
|
749 private: |
|
750 DMessageWindowTimer(DMessageWindow& aOwner); |
|
751 public: |
|
752 static DMessageWindowTimer* NewL(DMessageWindow& aOwner); |
|
753 void SetAction(TAction aAction); |
|
754 private: |
|
755 // framework |
|
756 virtual void RunL(); |
|
757 private: |
|
758 DMessageWindow& iOwner; |
|
759 TAction iAction; |
|
760 }; |
|
761 enum |
|
762 { |
|
763 EFlagVisible =0x01, |
|
764 EFlagFlash =0x02, |
|
765 EFlagFlashStateOn =0x04 |
|
766 }; |
|
767 enum |
|
768 { |
|
769 EBorderWidthLeft=3, |
|
770 EBorderWidthRight=4, |
|
771 EBorderWidthTop=3, |
|
772 EBorderWidthBottom=4 |
|
773 }; |
|
774 private: |
|
775 TTimeIntervalMicroSeconds32 iDuration; |
|
776 TInt iBaselineOffset; |
|
777 CFbsFont* iFont; |
|
778 TRgb iBackgroundColor; |
|
779 TRgb iTextColor; |
|
780 TRgb iBorderColor; |
|
781 TRgb iPlinthTlColor; |
|
782 TRgb iPlinthBrColor; |
|
783 TUint iFlags; |
|
784 TBuf<RMessageWindow::EMaxTextLength> iText; |
|
785 DMessageWindowTimer* iTimer; |
|
786 }; |
|
787 |
|
788 // |
|
789 // display classes |
|
790 // |
|
791 |
|
792 class DDisplay : public CBase |
|
793 { |
|
794 public: |
|
795 DDisplay(const TPoint& aPosition, const TSize& aSize, const TMargins& aMargins, const STimeDeviceShadow& aShadow); |
|
796 virtual void SetInitialTimeP(const TTime& aTime)=0; |
|
797 void DrawP(MAnimWindowFunctions& aFunctions, CAnimGc& aGc) const; |
|
798 void UpdateLP(DAnimWithUtils::TFunctions& aFunctions, CAnimGc& aGc, const TTime& aTime); |
|
799 TRect RectDrawnTo() const; |
|
800 TRect RectToInvalidate() const; |
|
801 virtual void HandleCommandLP(DAnimWithUtils::TFunctions& aFunctions, CAnimGc& aGc, const TTime& aTime, TInt aOpcode, TAny* aArgs); |
|
802 virtual void PositionOrSizeHasChanged(); |
|
803 void SetPosition(const TPoint& aPosition); |
|
804 protected: |
|
805 void DrawClippedToDisplayRegionP(MAnimWindowFunctions& aFunctions, CAnimGc& aGc, TRegion* aRegion=NULL) const; |
|
806 virtual void DoDrawP(CAnimGc& aGc, TBool aFullDrawRequired, const TRect& aClippingRect) const=0; |
|
807 virtual void UpdateDisplayDataP(MAnimGeneralFunctions& aFunctions, const TTime& aTime, TRegion* aRegion)=0; |
|
808 void UpdateDisplayDataAndDrawClippedToDisplayRegionP(DAnimWithUtils::TFunctions& aFunctions, CAnimGc& aGc, const TTime& aTime, TRegion* aRegion); |
|
809 TBool IsVisibleAndNotHidden(MAnimWindowFunctions& aFunctions) const; |
|
810 protected: |
|
811 STimeDeviceShadow iShadow; |
|
812 private: |
|
813 TPoint iPosition; |
|
814 TSize iSize; |
|
815 TBool iVisible; |
|
816 TMargins iMargins; |
|
817 }; |
|
818 |
|
819 // |
|
820 |
|
821 class DDigitalDisplay : public DDisplay |
|
822 { |
|
823 public: |
|
824 DDigitalDisplay(const TPoint& aPosition, const TSize& aSize, const TMargins& aMargins, const STimeDeviceShadow& aShadow, TRgb aBackgroundColor, TInt aNumTextSections); |
|
825 void AddTextSectionLP(DDigitalDisplayTextSection* aTextSection); |
|
826 virtual void SetInitialTimeP(const TTime& aTime); |
|
827 virtual ~DDigitalDisplay(); |
|
828 virtual void HandleCommandLP(DAnimWithUtils::TFunctions& aFunctions, CAnimGc& aGc, const TTime& aTime, TInt aOpcode, TAny* aArgs); |
|
829 inline void LimitTimeResolutionToMinutes(TBool aLimitToMinutes); |
|
830 protected: |
|
831 virtual void DoDrawP(CAnimGc& aGc, TBool aFullDrawRequired, const TRect& aClippingRect) const; |
|
832 virtual void UpdateDisplayDataP(MAnimGeneralFunctions& aFunctions, const TTime& aTime, TRegion* aRegion); |
|
833 private: |
|
834 struct STextSectionList |
|
835 { |
|
836 TInt16 iNumTextSections; |
|
837 TInt16 iNumTextSectionsAdded; |
|
838 DDigitalDisplayTextSection** iTextSections; |
|
839 }; |
|
840 private: |
|
841 TRgb iBackgroundColor; |
|
842 STextSectionList iTextSections; |
|
843 TBool iFlashStateOn; |
|
844 TBool iTimeResolutionLimitedToMinutes; |
|
845 }; |
|
846 |
|
847 inline void DDigitalDisplay::LimitTimeResolutionToMinutes(TBool aLimitToMinutes) |
|
848 { |
|
849 iTimeResolutionLimitedToMinutes=aLimitToMinutes; |
|
850 } |
|
851 |
|
852 // |
|
853 |
|
854 class DAnalogDisplay : public DDisplay |
|
855 { |
|
856 public: |
|
857 enum THandsFlag |
|
858 { |
|
859 ESecondHand = 0x0001, |
|
860 EMinuteHand = 0x0002, |
|
861 EHourHand = 0x0004 |
|
862 }; |
|
863 public: |
|
864 DAnalogDisplay(const TPoint& aPosition, const TSize& aSize, const TMargins& aMargins, const STimeDeviceShadow& aShadow, TInt aNumHands); |
|
865 void ConstructL(MAnimGeneralFunctions& iFunctions, TInt aFaceHandle, TInt aFaceMaskHandle); |
|
866 void AddHandLP(DAnalogDisplayHand* aHand); |
|
867 void AddAmPmLP(MAnimGeneralFunctions& aFunctions, const TPoint& aPositionRelativeToFace, const TSize& aSize, const STimeDeviceShadow& aShadow, TRgb aBackgroundColor, TInt aFontHandle, TRgb aTextColor); |
|
868 virtual void SetInitialTimeP(const TTime& aTime); |
|
869 virtual ~DAnalogDisplay(); |
|
870 virtual void PositionOrSizeHasChanged(); |
|
871 TRect FaceRect() const; |
|
872 void DisableHands(TBool aHourHand, TBool aMinuteHand, TBool aSecondHand); |
|
873 void EnableHands(TBool aHourHand, TBool aMinuteHand, TBool aSecondHand); |
|
874 private: |
|
875 virtual void DoDrawP(CAnimGc& aGc, TBool aFullDrawRequired, const TRect& aClippingRect) const; |
|
876 virtual void UpdateDisplayDataP(MAnimGeneralFunctions& aFunctions, const TTime& aTime, TRegion* aRegion); |
|
877 TPoint HandCenter() const; |
|
878 TPoint AmPmPosition() const; |
|
879 virtual void HandleCommandLP(DAnimWithUtils::TFunctions& aFunctions, CAnimGc& aGc, const TTime& aTime, TInt aOpcode, TAny* aArgs); |
|
880 void DrawHands(CAnimGc& aGc, const TPoint& aCenter, const TRgb* aShadowColour=NULL) const; |
|
881 private: |
|
882 class DAmPmDisplay : public DDigitalDisplay |
|
883 { |
|
884 public: |
|
885 DAmPmDisplay(const TPoint& aPosition, const TSize& aSize, const TMargins& aMargins, const STimeDeviceShadow& aShadow, TRgb aBackgroundColor); |
|
886 void ConstructLP(MAnimGeneralFunctions& aFunctions, TRgb aTextColor, TInt aFontHandle); |
|
887 virtual void DoDrawP(CAnimGc& aGc, TBool aFullDrawRequired, const TRect& aClippingRect) const; |
|
888 virtual void UpdateDisplayDataP(MAnimGeneralFunctions& aFunctions, const TTime& aTime, TRegion* aRegion); |
|
889 }; |
|
890 struct SHandList |
|
891 { |
|
892 TInt16 iNumHands; |
|
893 TInt16 iNumHandsAdded; |
|
894 DAnalogDisplayHand** iHands; |
|
895 TInt iHandsDisabled; |
|
896 }; |
|
897 private: |
|
898 CFbsBitmap* iFace; |
|
899 CFbsBitmap* iFaceMask; |
|
900 SHandList iHands; |
|
901 DAmPmDisplay* iAmPm; |
|
902 TPoint iAmPmPositionRelativeToFace; |
|
903 }; |
|
904 |
|
905 // |
|
906 // clock DLL class |
|
907 // |
|
908 |
|
909 class DClockDll : public CAnimDll |
|
910 { |
|
911 public: |
|
912 DClockDll(); |
|
913 virtual CAnim* CreateInstanceL(TInt aType); |
|
914 }; |
|
915 |
|
916 // |
|
917 // global functions |
|
918 // |
|
919 |
|
920 GLREF_C void Panic(TClockServerPanic aReason); |
|
921 GLREF_C void PanicClientFromServer(); |
|
922 |
|
923 // |
|
924 |
|
925 #endif |
|
926 |