|
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 // |
|
15 |
|
16 #if !defined(__CLOCK_H__) |
|
17 #define __CLOCK_H__ |
|
18 |
|
19 #if !defined(__E32STD_H__) |
|
20 #include <e32std.h> |
|
21 #endif |
|
22 |
|
23 #if !defined(__E32BASE_H__) |
|
24 #include <e32base.h> |
|
25 #endif |
|
26 |
|
27 #if !defined(__W32STD_H__) |
|
28 #include <w32std.h> |
|
29 #endif |
|
30 |
|
31 //exported due to dependancies |
|
32 #include <graphics/clock/displayaddition.h> |
|
33 |
|
34 /** |
|
35 @file |
|
36 @publishedAll |
|
37 */ |
|
38 |
|
39 /** Horizontal alignment options for text in a digital clock's display. |
|
40 |
|
41 @see TDigitalDisplayTextSection |
|
42 @publishedAll |
|
43 @released */ |
|
44 enum TDigitalDisplayHorizontalTextAlignment |
|
45 { |
|
46 /** Left align text. */ |
|
47 EDigitalDisplayHorizontalTextAlignmentLeft, |
|
48 /** Centre align text. */ |
|
49 EDigitalDisplayHorizontalTextAlignmentCenter, |
|
50 /** Right align text. */ |
|
51 EDigitalDisplayHorizontalTextAlignmentRight |
|
52 }; |
|
53 |
|
54 /** Vertical alignment options for text in a digital clock's display. |
|
55 |
|
56 @see TDigitalDisplayTextSection |
|
57 @publishedAll |
|
58 @released */ |
|
59 enum TDigitalDisplayVerticalTextAlignment |
|
60 { |
|
61 /** Top align text. */ |
|
62 EDigitalDisplayVerticalTextAlignmentTop, |
|
63 /** Centre align text, including the character descent. */ |
|
64 EDigitalDisplayVerticalTextAlignmentCenterInclDescent, |
|
65 /** Centre align text, excluding the character descent. */ |
|
66 EDigitalDisplayVerticalTextAlignmentCenterExclDescent, |
|
67 /** Bottom align text, including the character descent. */ |
|
68 EDigitalDisplayVerticalTextAlignmentBottomInclDescent, |
|
69 /** Bottom align text, excluding the character descent. */ |
|
70 EDigitalDisplayVerticalTextAlignmentBottomExclDescent |
|
71 }; |
|
72 |
|
73 /** Special characters that can be used in a digital clock display. |
|
74 |
|
75 @see TDigitalDisplayTextSection |
|
76 @publishedAll |
|
77 @released */ |
|
78 enum TDigitalDisplayLayoutChar |
|
79 { |
|
80 /** A flashing block to delimit different sections of the display. |
|
81 */ |
|
82 /** A flashing block to delimit different sections of the display. */ |
|
83 EDigitalDisplayLayoutCharFlashingBlockDelimiter=1 |
|
84 }; |
|
85 |
|
86 // |
|
87 /** Different types of hand for an analogue clock. |
|
88 |
|
89 @publishedAll |
|
90 @released */ |
|
91 enum TAnalogDisplayHandType |
|
92 { |
|
93 /** A hand that performs one revolution every 12 hours. */ |
|
94 EAnalogDisplayHandOneRevPer12Hours, |
|
95 /** A hand that performs one revolution every hour. */ |
|
96 EAnalogDisplayHandOneRevPerHour, |
|
97 /** A hand that performs one revolution every minute. */ |
|
98 EAnalogDisplayHandOneRevPerMinute |
|
99 }; |
|
100 |
|
101 // |
|
102 // miscellaneous structs |
|
103 // |
|
104 |
|
105 |
|
106 /** Determines how shadows are added to the clock display. |
|
107 |
|
108 @publishedAll |
|
109 @released */ |
|
110 struct STimeDeviceShadow |
|
111 { |
|
112 /** True if shadows should be displayed, else false. */ |
|
113 TBool iIsOn; |
|
114 /** Colour of the shadows. */ |
|
115 TRgb iColor; |
|
116 /** Offset of shadows from foreground. */ |
|
117 TPoint iOffset; |
|
118 }; |
|
119 |
|
120 |
|
121 /** Defines the display parameters of the AM/PM display for an analogue clock. |
|
122 |
|
123 @see RAnalogClock |
|
124 @publishedAll |
|
125 @released */ |
|
126 struct SAnalogDisplayAmPm |
|
127 { |
|
128 /** Position relative to the clock face. */ |
|
129 TPoint iPositionRelativeToFace; |
|
130 /** Size. */ |
|
131 TSize iSize; |
|
132 /** Shadow settings. */ |
|
133 STimeDeviceShadow iShadow; |
|
134 /** Background colour. */ |
|
135 TRgb iBackgroundColor; |
|
136 /** Handle to the font to use. This can be obtained using CFbsFont::Handle(). |
|
137 |
|
138 @see CFbsFont::Handle() */ |
|
139 TInt iFontHandle; |
|
140 /** Colour for text. */ |
|
141 TRgb iTextColor; |
|
142 }; |
|
143 |
|
144 // |
|
145 // display-addition classes |
|
146 // |
|
147 |
|
148 |
|
149 /** A text section for a digital clock. |
|
150 |
|
151 @see RDigitalClock |
|
152 @publishedAll |
|
153 @released */ |
|
154 class TDigitalDisplayTextSection : public TDisplayAddition |
|
155 { |
|
156 public: |
|
157 IMPORT_C TDigitalDisplayTextSection(TInt aFontHandle, TRgb aTextColor, TDigitalDisplayHorizontalTextAlignment aHorizontalAlignment, |
|
158 TDigitalDisplayVerticalTextAlignment aVerticalAlignment, |
|
159 TInt aHorizontalMargin, TInt aVerticalMargin, const TDesC& aFormat); |
|
160 // N.B. the font passed in to aFontHandle cannot be destroyed until the |
|
161 // RDigitalClock has been completely constructed, including all necessary |
|
162 // calls to RDigitalClock::AddTextSectionL() |
|
163 }; |
|
164 |
|
165 // |
|
166 |
|
167 |
|
168 /** A hand for an analogue clock. |
|
169 |
|
170 A hand is a vector drawing made from a number of features (lines, circles, |
|
171 polylines). These are specified with the hand assumed to be in the 12 o'clock |
|
172 position, with TPoint(0,0) being the center of the clock. |
|
173 |
|
174 @see RAnalogClock |
|
175 @publishedAll |
|
176 @released */ |
|
177 class TAnalogDisplayHand : public TDisplayAddition |
|
178 { |
|
179 public: |
|
180 IMPORT_C TAnalogDisplayHand(TAnalogDisplayHandType aType); |
|
181 IMPORT_C void AddLine(CGraphicsContext::TPenStyle aPenStyle, TRgb aPenColor, const TSize& aPenSize, |
|
182 const TPoint& aStartPoint, const TPoint& aEndPoint); |
|
183 IMPORT_C void AddPolyLine(CGraphicsContext::TPenStyle aPenStyle, TRgb aPenColor, const TSize& aPenSize, |
|
184 CGraphicsContext::TBrushStyle aBrushStyle, TRgb aBrushColor, |
|
185 TBool aClosed, const CArrayFix<TPoint>* aPointList); // aPointList is not destroyed |
|
186 IMPORT_C void AddCircle(CGraphicsContext::TPenStyle aPenStyle, TRgb aPenColor, const TSize& aPenSize, |
|
187 CGraphicsContext::TBrushStyle aBrushStyle, TRgb aBrushColor, |
|
188 const TPoint& aCircleCenter, TInt aRadius); |
|
189 inline TInt NumFeatures() const |
|
190 /** Gets the number of features added to the hand. */ |
|
191 {return *iNumFeaturesPtr;} |
|
192 private: |
|
193 void AppendType(TAnalogDisplayHandFeatureType aType); |
|
194 private: |
|
195 TInt* iNumFeaturesPtr; |
|
196 }; |
|
197 |
|
198 // |
|
199 // utility class |
|
200 // |
|
201 |
|
202 |
|
203 /** Utility class to support clock animation. |
|
204 |
|
205 @publishedAll |
|
206 @released |
|
207 */ |
|
208 class RAnimWithUtils : public RAnim |
|
209 { |
|
210 protected: |
|
211 RAnimWithUtils(RAnimDll& aAnimDll, const RWindowBase& aWindow); |
|
212 void AppendToConstructorBufL(const TDesC8& aData); |
|
213 void SendConstructorBufIfCompleteL(TInt aAnimatedObjectType); |
|
214 void SendConstructorBufL(TInt aAnimatedObjectType); |
|
215 TBool ConstructorBufExists() const; |
|
216 TBool ConstructorBufAlreadySent() const; |
|
217 TConstructorBuf8& ConstructorBuf() const; |
|
218 void SetNumAdditionsStillExpected(TInt aNumAdditionsStillExpected); |
|
219 public: |
|
220 IMPORT_C virtual void Close(); |
|
221 private: |
|
222 TConstructorBuf8* iConstructorBuf; // on the heap as it is only required for construction |
|
223 TBool iConstructorBufAlreadySent; |
|
224 const RWindowBase& iWindow; |
|
225 TInt iNumAdditionsStillExpected; |
|
226 }; |
|
227 |
|
228 // |
|
229 // time-device abstract classes |
|
230 // |
|
231 |
|
232 |
|
233 |
|
234 /** Sets display parameters for clocks. |
|
235 |
|
236 @publishedAll |
|
237 @released |
|
238 */ |
|
239 class RTimeDevice : public RAnimWithUtils |
|
240 { |
|
241 protected: |
|
242 RTimeDevice(RAnimDll& aAnimDll, const RWindowBase& aWindow); |
|
243 void AppendDisplayTypeL(TDisplayType aType); |
|
244 void AppendDigitalDisplayConstructorArgsL(const TPoint& aPosition, const TSize& aSize, const TMargins& aMargins, const STimeDeviceShadow& aShadow, |
|
245 TRgb aBackgroundColor, TInt aNumTextSections); |
|
246 void AppendAnalogDisplayConstructorArgsL(const TPoint& aPosition, const TSize& aSize, const TMargins& aMargins, const STimeDeviceShadow& aShadow, |
|
247 TInt aFaceHandle, TInt aFaceMaskHandle, TInt aNumHands, const SAnalogDisplayAmPm* aAmPm); |
|
248 public: |
|
249 IMPORT_C void SetVisible(TBool aVisible); // can only be called after full construction - by default clocks are invisible |
|
250 IMPORT_C void SetPositionAndSize(const TPoint& aPosition, const TSize& aSize); // can only be called after full construction |
|
251 IMPORT_C void SetPosition(const TPoint& aPosition); // can only be called after full construction |
|
252 IMPORT_C void SetSize(const TSize& aSize); // can only be called after full construction |
|
253 IMPORT_C void UpdateDisplay(); // can only be called after full construction |
|
254 IMPORT_C void Draw(); // can only be called after full construction |
|
255 }; |
|
256 |
|
257 // |
|
258 |
|
259 |
|
260 /** Sets the time for clocks. |
|
261 |
|
262 @publishedAll |
|
263 @released */ |
|
264 class RClock : public RTimeDevice |
|
265 { |
|
266 protected: |
|
267 RClock(RAnimDll& aAnimDll, const RWindowBase& aWindow); |
|
268 void AppendClockConstructorArgsL(TTimeIntervalSeconds aUniversalTimeOffset); |
|
269 public: |
|
270 IMPORT_C void SetUniversalTimeOffset(TTimeIntervalSeconds aUniversalTimeOffset); // can only be called after full construction |
|
271 }; |
|
272 |
|
273 // |
|
274 // time-device concrete classes |
|
275 // |
|
276 |
|
277 |
|
278 /** A digital clock. |
|
279 |
|
280 A digital clock is composed of one or more text sections, which define |
|
281 how the time information is displayed. |
|
282 |
|
283 @publishedAll |
|
284 @released */ |
|
285 class RDigitalClock : public RClock |
|
286 { |
|
287 public: |
|
288 IMPORT_C RDigitalClock(RAnimDll& aAnimDll, const RWindowBase& aWindow); |
|
289 IMPORT_C void ConstructL(TTimeIntervalSeconds aUniversalTimeOffset, const TPoint& aPosition, const TSize& aSize, const TMargins& aMargins, |
|
290 const STimeDeviceShadow& aShadow, TRgb aBackgroundColor, TInt aNumTextSections); |
|
291 IMPORT_C void AddTextSectionL(const TDigitalDisplayTextSection& aTextSection); |
|
292 IMPORT_C void SetBackgroundColor(TRgb aBackgroundColor, TRgb aShadowColor); // can only be called after full construction |
|
293 IMPORT_C void SetTextColor(TRgb aTextColor); |
|
294 |
|
295 }; |
|
296 |
|
297 // |
|
298 |
|
299 |
|
300 |
|
301 /** An analogue clock. |
|
302 |
|
303 @see CFbsBitmap::Handle() |
|
304 @publishedAll |
|
305 @released */ |
|
306 class RAnalogClock : public RClock |
|
307 { |
|
308 public: |
|
309 IMPORT_C RAnalogClock(RAnimDll& aAnimDll, const RWindowBase& aWindow); |
|
310 IMPORT_C void ConstructL(TTimeIntervalSeconds aUniversalTimeOffset, const TPoint& aPosition, const TSize& aSize, const TMargins& aMargins, |
|
311 const STimeDeviceShadow& aShadow, TInt aFaceHandle, TInt aFaceMaskHandle, TInt aNumHands, const SAnalogDisplayAmPm* aAmPm=NULL); |
|
312 // N.B. the bitmap(s) passed in to aFaceHandle and aFaceMaskHandle in these |
|
313 // ConstructL functions cannot be destroyed until the RAnalogClock has been |
|
314 // completely constructed, including all necessary calls to |
|
315 // RAnalogClock::AddHandL() - aFaceMaskHandle may be 0 |
|
316 IMPORT_C void AddHandL(const TAnalogDisplayHand& aHand); |
|
317 IMPORT_C void SetBackgroundColor(TRgb aBackgroundColor, TRgb aShadowColor); // can only be called after full construction |
|
318 IMPORT_C void SetTextColor(TRgb aTextColor); |
|
319 IMPORT_C void SetPenColor(const TRgb aPenColor); |
|
320 IMPORT_C void SetBrushColor(const TRgb aBrushColor); |
|
321 }; |
|
322 |
|
323 // |
|
324 // message-window class |
|
325 // |
|
326 |
|
327 |
|
328 |
|
329 /** A configurable window that appears for a brief time to display a message to |
|
330 the user and then disappears. |
|
331 |
|
332 This is the basic class that is used by classes such as CEikonEnv and CEikMsgWin |
|
333 to provide information and message windows. Such higher-level classes would |
|
334 normally be used by client applications rather than RMessageWindow. This class |
|
335 can be used though to implement specialist new classes. |
|
336 |
|
337 Note that this class is in the same library as the Clock API for implementation |
|
338 reasons only. |
|
339 |
|
340 @see CEikMsgWin |
|
341 @see CEikonEnv |
|
342 @publishedAll |
|
343 @released */ |
|
344 class RMessageWindow : public RAnimWithUtils |
|
345 { |
|
346 public: |
|
347 /** Defines the maximum length of text in the message. */ |
|
348 enum |
|
349 { |
|
350 /** Maximum length of text in the message. */ |
|
351 EMaxTextLength=80 |
|
352 }; |
|
353 public: |
|
354 IMPORT_C RMessageWindow(RAnimDll& aAnimDll, const RWindowBase& aWindow); |
|
355 IMPORT_C void ConstructL(TInt aBaselineOffset, TInt aFontHandle, TRgb aBackgroundColor, TRgb aTextColor); |
|
356 IMPORT_C void ConstructL(TInt aBaselineOffset, TInt aFontHandle, TRgb aBackgroundColor, TRgb aTextColor, TRgb aBorderColor); |
|
357 IMPORT_C void StartDisplay(TBool aFlash, TTimeIntervalMicroSeconds32 aInitialDelay, const TDesC& aText); |
|
358 IMPORT_C void StartDisplay(TBool aFlash, TTimeIntervalMicroSeconds32 aInitialDelay, TTimeIntervalMicroSeconds32 aDuration, const TDesC& aText); |
|
359 IMPORT_C void CancelDisplay(); |
|
360 IMPORT_C void GetBorders(TMargins& aBorders); |
|
361 IMPORT_C void SetBackgroundColor(TRgb aBackgroundColor); |
|
362 IMPORT_C void SetTextColor(TRgb aTextColor); |
|
363 IMPORT_C void SetBorderColor(TRgb aBorderColor); |
|
364 IMPORT_C void SetPlinthColors(TRgb aTl,TRgb aBr); |
|
365 }; |
|
366 |
|
367 #endif |
|
368 |