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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #if !defined(__CLOCK_H__)
19 #if !defined(__E32STD_H__)
23 #if !defined(__E32BASE_H__)
27 #if !defined(__W32STD_H__)
32 // miscellaneous typedefs
34 /** @internalComponent */
35 typedef TBuf8<1024> TConstructorBuf8; // implementation class
38 // miscellaneous enums
41 /** @internalComponent */
42 enum TDisplayType // implementation class
48 /** @internalComponent */
49 enum TAnalogDisplayHandFeatureType // implementation class
51 EAnalogDisplayHandFeatureLine,
52 EAnalogDisplayHandFeaturePolyLine,
53 EAnalogDisplayHandFeatureCircle
56 /** Horizontal alignment options for text in a digital clock's display.
58 @see TDigitalDisplayTextSection
61 enum TDigitalDisplayHorizontalTextAlignment
63 /** Left align text. */
64 EDigitalDisplayHorizontalTextAlignmentLeft,
65 /** Centre align text. */
66 EDigitalDisplayHorizontalTextAlignmentCenter,
67 /** Right align text. */
68 EDigitalDisplayHorizontalTextAlignmentRight
71 /** Vertical alignment options for text in a digital clock's display.
73 @see TDigitalDisplayTextSection
76 enum TDigitalDisplayVerticalTextAlignment
78 /** Top align text. */
79 EDigitalDisplayVerticalTextAlignmentTop,
80 /** Centre align text, including the character descent. */
81 EDigitalDisplayVerticalTextAlignmentCenterInclDescent,
82 /** Centre align text, excluding the character descent. */
83 EDigitalDisplayVerticalTextAlignmentCenterExclDescent,
84 /** Bottom align text, including the character descent. */
85 EDigitalDisplayVerticalTextAlignmentBottomInclDescent,
86 /** Bottom align text, excluding the character descent. */
87 EDigitalDisplayVerticalTextAlignmentBottomExclDescent
90 /** Special characters that can be used in a digital clock display.
92 @see TDigitalDisplayTextSection
95 enum TDigitalDisplayLayoutChar
97 /** A flashing block to delimit different sections of the display.
99 /** A flashing block to delimit different sections of the display. */
100 EDigitalDisplayLayoutCharFlashingBlockDelimiter=1
104 /** Different types of hand for an analogue clock.
108 enum TAnalogDisplayHandType
110 /** A hand that performs one revolution every 12 hours. */
111 EAnalogDisplayHandOneRevPer12Hours,
112 /** A hand that performs one revolution every hour. */
113 EAnalogDisplayHandOneRevPerHour,
114 /** A hand that performs one revolution every minute. */
115 EAnalogDisplayHandOneRevPerMinute
119 // miscellaneous structs
122 struct STimeDeviceShadow
123 /** Determines how shadows are added to the clock display.
128 /** True if shadows should be displayed, else false. */
130 /** Colour of the shadows. */
132 /** Offset of shadows from foreground. */
136 struct SAnalogDisplayAmPm
137 /** Defines the display parameters of the AM/PM display for an analogue clock.
143 /** Position relative to the clock face. */
144 TPoint iPositionRelativeToFace;
147 /** Shadow settings. */
148 STimeDeviceShadow iShadow;
149 /** Background colour. */
150 TRgb iBackgroundColor;
151 /** Handle to the font to use. This can be obtained using CFbsFont::Handle().
153 @see CFbsFont::Handle() */
155 /** Colour for text. */
160 // display-addition classes
164 class TDisplayAddition
165 /** This class is used in the derivation of TAnalogDisplayHand and TDigitalDisplayTextSection.
167 @internalComponent */
170 const TDesC8& Buf() const;
172 TConstructorBuf8 iBuf;
177 class TDigitalDisplayTextSection : public TDisplayAddition
178 /** A text section for a digital clock.
185 IMPORT_C TDigitalDisplayTextSection(TInt aFontHandle, TRgb aTextColor, TDigitalDisplayHorizontalTextAlignment aHorizontalAlignment,
186 TDigitalDisplayVerticalTextAlignment aVerticalAlignment,
187 TInt aHorizontalMargin, TInt aVerticalMargin, const TDesC& aFormat);
188 // N.B. the font passed in to aFontHandle cannot be destroyed until the
189 // RDigitalClock has been completely constructed, including all necessary
190 // calls to RDigitalClock::AddTextSectionL()
195 class TAnalogDisplayHand : public TDisplayAddition
196 /** A hand for an analogue clock.
198 A hand is a vector drawing made from a number of features (lines, circles,
199 polylines). These are specified with the hand assumed to be in the 12 o'clock
200 position, with TPoint(0,0) being the center of the clock.
207 IMPORT_C TAnalogDisplayHand(TAnalogDisplayHandType aType);
208 IMPORT_C void AddLine(CGraphicsContext::TPenStyle aPenStyle, TRgb aPenColor, const TSize& aPenSize,
209 const TPoint& aStartPoint, const TPoint& aEndPoint);
210 IMPORT_C void AddPolyLine(CGraphicsContext::TPenStyle aPenStyle, TRgb aPenColor, const TSize& aPenSize,
211 CGraphicsContext::TBrushStyle aBrushStyle, TRgb aBrushColor,
212 TBool aClosed, const CArrayFix<TPoint>* aPointList); // aPointList is not destroyed
213 IMPORT_C void AddCircle(CGraphicsContext::TPenStyle aPenStyle, TRgb aPenColor, const TSize& aPenSize,
214 CGraphicsContext::TBrushStyle aBrushStyle, TRgb aBrushColor,
215 const TPoint& aCircleCenter, TInt aRadius);
216 inline TInt NumFeatures() const
217 /** Gets the number of features added to the hand. */
218 {return *iNumFeaturesPtr;}
220 void AppendType(TAnalogDisplayHandFeatureType aType);
222 TInt* iNumFeaturesPtr;
229 class RAnimWithUtils : public RAnim
230 /** Utility class to support clock animation.
237 RAnimWithUtils(RAnimDll& aAnimDll, const RWindowBase& aWindow);
238 void AppendToConstructorBufL(const TDesC8& aData);
239 void SendConstructorBufIfCompleteL(TInt aAnimatedObjectType);
240 void SendConstructorBufL(TInt aAnimatedObjectType);
241 TBool ConstructorBufExists() const;
242 TBool ConstructorBufAlreadySent() const;
243 TConstructorBuf8& ConstructorBuf() const;
244 void SetNumAdditionsStillExpected(TInt aNumAdditionsStillExpected);
246 IMPORT_C virtual void Close();
248 TConstructorBuf8* iConstructorBuf; // on the heap as it is only required for construction
249 TBool iConstructorBufAlreadySent;
250 const RWindowBase& iWindow;
251 TInt iNumAdditionsStillExpected;
255 // time-device abstract classes
259 class RTimeDevice : public RAnimWithUtils
260 /** Sets display parameters for clocks.
267 RTimeDevice(RAnimDll& aAnimDll, const RWindowBase& aWindow);
268 void AppendDisplayTypeL(TDisplayType aType);
269 void AppendDigitalDisplayConstructorArgsL(const TPoint& aPosition, const TSize& aSize, const TMargins& aMargins, const STimeDeviceShadow& aShadow,
270 TRgb aBackgroundColor, TInt aNumTextSections);
271 void AppendAnalogDisplayConstructorArgsL(const TPoint& aPosition, const TSize& aSize, const TMargins& aMargins, const STimeDeviceShadow& aShadow,
272 TInt aFaceHandle, TInt aFaceMaskHandle, TInt aNumHands, const SAnalogDisplayAmPm* aAmPm);
274 IMPORT_C void SetVisible(TBool aVisible); // can only be called after full construction - by default clocks are invisible
275 IMPORT_C void SetPositionAndSize(const TPoint& aPosition, const TSize& aSize); // can only be called after full construction
276 IMPORT_C void SetPosition(const TPoint& aPosition); // can only be called after full construction
277 IMPORT_C void SetSize(const TSize& aSize); // can only be called after full construction
278 IMPORT_C void UpdateDisplay(); // can only be called after full construction
279 IMPORT_C void Draw(); // can only be called after full construction
284 class RClock : public RTimeDevice
285 /** Sets the time for clocks.
291 RClock(RAnimDll& aAnimDll, const RWindowBase& aWindow);
292 void AppendClockConstructorArgsL(TTimeIntervalSeconds aUniversalTimeOffset);
294 IMPORT_C void SetUniversalTimeOffset(TTimeIntervalSeconds aUniversalTimeOffset); // can only be called after full construction
298 // time-device concrete classes
301 class RDigitalClock : public RClock
304 A digital clock is composed of one or more text sections, which define
305 how the time information is displayed.
311 IMPORT_C RDigitalClock(RAnimDll& aAnimDll, const RWindowBase& aWindow);
312 IMPORT_C void ConstructL(TTimeIntervalSeconds aUniversalTimeOffset, const TPoint& aPosition, const TSize& aSize, const TMargins& aMargins,
313 const STimeDeviceShadow& aShadow, TRgb aBackgroundColor, TInt aNumTextSections);
314 IMPORT_C void AddTextSectionL(const TDigitalDisplayTextSection& aTextSection);
315 IMPORT_C void SetBackgroundColor(TRgb aBackgroundColor, TRgb aShadowColor); // can only be called after full construction
316 IMPORT_C void SetTextColor(TRgb aTextColor);
323 class RAnalogClock : public RClock
324 /** An analogue clock.
326 @see CFbsBitmap::Handle()
332 IMPORT_C RAnalogClock(RAnimDll& aAnimDll, const RWindowBase& aWindow);
333 IMPORT_C void ConstructL(TTimeIntervalSeconds aUniversalTimeOffset, const TPoint& aPosition, const TSize& aSize, const TMargins& aMargins,
334 const STimeDeviceShadow& aShadow, TInt aFaceHandle, TInt aFaceMaskHandle, TInt aNumHands, const SAnalogDisplayAmPm* aAmPm=NULL);
335 // N.B. the bitmap(s) passed in to aFaceHandle and aFaceMaskHandle in these
336 // ConstructL functions cannot be destroyed until the RAnalogClock has been
337 // completely constructed, including all necessary calls to
338 // RAnalogClock::AddHandL() - aFaceMaskHandle may be 0
339 IMPORT_C void AddHandL(const TAnalogDisplayHand& aHand);
340 IMPORT_C void SetBackgroundColor(TRgb aBackgroundColor, TRgb aShadowColor); // can only be called after full construction
341 IMPORT_C void SetTextColor(TRgb aTextColor);
342 IMPORT_C void SetPenColor(const TRgb aPenColor);
343 IMPORT_C void SetBrushColor(const TRgb aBrushColor);
347 // message-window class
351 class RMessageWindow : public RAnimWithUtils
352 /** A configurable window that appears for a brief time to display a message to
353 the user and then disappears.
355 This is the basic class that is used by classes such as CEikonEnv and CEikMsgWin
356 to provide information and message windows. Such higher-level classes would
357 normally be used by client applications rather than RMessageWindow. This class
358 can be used though to implement specialist new classes.
360 Note that this class is in the same library as the Clock API for implementation
369 /** Defines the maximum length of text in the message. */
372 /** Maximum length of text in the message. */
376 IMPORT_C RMessageWindow(RAnimDll& aAnimDll, const RWindowBase& aWindow);
377 IMPORT_C void ConstructL(TInt aBaselineOffset, TInt aFontHandle, TRgb aBackgroundColor, TRgb aTextColor);
378 IMPORT_C void ConstructL(TInt aBaselineOffset, TInt aFontHandle, TRgb aBackgroundColor, TRgb aTextColor, TRgb aBorderColor);
379 IMPORT_C void StartDisplay(TBool aFlash, TTimeIntervalMicroSeconds32 aInitialDelay, const TDesC& aText);
380 IMPORT_C void StartDisplay(TBool aFlash, TTimeIntervalMicroSeconds32 aInitialDelay, TTimeIntervalMicroSeconds32 aDuration, const TDesC& aText);
381 IMPORT_C void CancelDisplay();
382 IMPORT_C void GetBorders(TMargins& aBorders);
383 IMPORT_C void SetBackgroundColor(TRgb aBackgroundColor);
384 IMPORT_C void SetTextColor(TRgb aTextColor);
385 IMPORT_C void SetBorderColor(TRgb aBorderColor);
386 IMPORT_C void SetPlinthColors(TRgb aTl,TRgb aBr);