epoc32/include/clock.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 0 061f57f2323e
permissions -rw-r--r--
Final list of Symbian^2 public API header files
     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".
     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 //
    32 // miscellaneous typedefs
    33 //
    34 /** @internalComponent */
    35 typedef TBuf8<1024> TConstructorBuf8; // implementation class
    36 
    37 //
    38 // miscellaneous enums
    39 //
    40 
    41 /** @internalComponent */
    42 enum TDisplayType // implementation class
    43 	{
    44 	EDisplayDigital,
    45 	EDisplayAnalog
    46 	};
    47 
    48 /** @internalComponent */
    49 enum TAnalogDisplayHandFeatureType // implementation class
    50 	{
    51 	EAnalogDisplayHandFeatureLine,
    52 	EAnalogDisplayHandFeaturePolyLine,
    53 	EAnalogDisplayHandFeatureCircle
    54 	};
    55 
    56 /** Horizontal alignment options for text in a digital clock's display.
    57 
    58 @see TDigitalDisplayTextSection 
    59 @publishedAll
    60 @released */
    61 enum TDigitalDisplayHorizontalTextAlignment
    62 	{
    63 	/** Left align text. */
    64 	EDigitalDisplayHorizontalTextAlignmentLeft,
    65 	/** Centre align text. */
    66 	EDigitalDisplayHorizontalTextAlignmentCenter,
    67 	/** Right align text. */
    68 	EDigitalDisplayHorizontalTextAlignmentRight
    69 	};
    70 
    71 /** Vertical alignment options for text in a digital clock's display.
    72 
    73 @see TDigitalDisplayTextSection 
    74 @publishedAll
    75 @released */
    76 enum TDigitalDisplayVerticalTextAlignment
    77 	{
    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
    88 	};
    89 
    90 /** Special characters that can be used in a digital clock display.
    91 
    92 @see TDigitalDisplayTextSection 
    93 @publishedAll
    94 @released */
    95 enum TDigitalDisplayLayoutChar
    96 	{
    97 	/** A flashing block to delimit different sections of the display.
    98 	 */
    99 	/** A flashing block to delimit different sections of the display. */
   100 	EDigitalDisplayLayoutCharFlashingBlockDelimiter=1
   101 	};
   102 
   103 //
   104 /** Different types of hand for an analogue clock. 
   105 
   106 @publishedAll
   107 @released */
   108 enum TAnalogDisplayHandType
   109 	{
   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
   116 	};
   117 
   118 //
   119 // miscellaneous structs
   120 //
   121 
   122 struct STimeDeviceShadow
   123 /** Determines how shadows are added to the clock display. 
   124 
   125 @publishedAll
   126 @released */
   127 	{
   128 	/** True if shadows should be displayed, else false. */
   129 	TBool iIsOn;
   130 	/** Colour of the shadows. */
   131 	TRgb iColor;
   132 	/** Offset of shadows from foreground. */
   133 	TPoint iOffset;
   134 	};
   135 
   136 struct SAnalogDisplayAmPm
   137 /** Defines the display parameters of the AM/PM display for an analogue clock.
   138 
   139 @see RAnalogClock 
   140 @publishedAll
   141 @released */
   142 	{
   143 	/** Position relative to the clock face. */
   144 	TPoint iPositionRelativeToFace;
   145 	/** Size. */
   146 	TSize iSize;
   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().
   152 	
   153 	@see CFbsFont::Handle() */
   154 	TInt iFontHandle;
   155 	/** Colour for text. */
   156 	TRgb iTextColor;
   157 	};
   158 
   159 //
   160 // display-addition classes
   161 //
   162 
   163 
   164 class TDisplayAddition
   165 /** This class is used in the derivation of TAnalogDisplayHand and TDigitalDisplayTextSection. 
   166 
   167 @internalComponent */
   168 	{
   169 public:
   170 	const TDesC8& Buf() const;
   171 protected:
   172 	TConstructorBuf8 iBuf;
   173 	};
   174 
   175 //
   176 
   177 class TDigitalDisplayTextSection : public TDisplayAddition
   178 /** A text section for a digital clock.
   179 
   180 @see RDigitalClock 
   181 @publishedAll 
   182 @released */
   183 	{
   184 public:
   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()
   191 	};
   192 
   193 //
   194 
   195 class TAnalogDisplayHand : public TDisplayAddition
   196 /** A hand for an analogue clock.
   197 
   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.
   201 
   202 @see RAnalogClock 
   203 @publishedAll 
   204 @released */
   205 	{
   206 public:
   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;}
   219 private:
   220 	void AppendType(TAnalogDisplayHandFeatureType aType);
   221 private:
   222 	TInt* iNumFeaturesPtr;
   223 	};
   224 
   225 //
   226 // utility class
   227 //
   228 
   229 class RAnimWithUtils : public RAnim
   230 /** Utility class to support clock animation. 
   231 
   232 @publishedAll
   233 @released
   234 */
   235 	{
   236 protected:
   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);
   245 public:
   246 	IMPORT_C virtual void Close();
   247 private:
   248 	TConstructorBuf8* iConstructorBuf; // on the heap as it is only required for construction
   249 	TBool iConstructorBufAlreadySent;
   250 	const RWindowBase& iWindow;
   251 	TInt iNumAdditionsStillExpected;
   252 	};
   253 
   254 //
   255 // time-device abstract classes
   256 //
   257 
   258 
   259 class RTimeDevice : public RAnimWithUtils
   260 /** Sets display parameters for clocks.
   261  
   262 @publishedAll
   263 @released
   264 */
   265 	{
   266 protected:
   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);
   273 public:
   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
   280 	};
   281 
   282 //
   283 
   284 class RClock : public RTimeDevice
   285 /** Sets the time for clocks.
   286 
   287 @publishedAll
   288 @released */
   289 	{
   290 protected:
   291 	RClock(RAnimDll& aAnimDll, const RWindowBase& aWindow);
   292 	void AppendClockConstructorArgsL(TTimeIntervalSeconds aUniversalTimeOffset);
   293 public:
   294 	IMPORT_C void SetUniversalTimeOffset(TTimeIntervalSeconds aUniversalTimeOffset); // can only be called after full construction
   295 	};
   296 
   297 //
   298 // time-device concrete classes
   299 //
   300 
   301 class RDigitalClock : public RClock
   302 /** A digital clock.
   303 
   304 A digital clock is composed of one or more text sections, which define
   305 how the time information is displayed.
   306 
   307 @publishedAll 
   308 @released */
   309 	{
   310 public:
   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);
   317 
   318 	};
   319 
   320 //
   321 
   322 
   323 class RAnalogClock : public RClock
   324 /** An analogue clock.
   325 
   326 @see CFbsBitmap::Handle() 
   327 @publishedAll 
   328 @released */
   329 
   330 	{
   331 public:
   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);
   344 	};
   345 
   346 //
   347 // message-window class
   348 //
   349 
   350 
   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.
   354 
   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. 
   359 
   360 Note that this class is in the same library as the Clock API for implementation 
   361 reasons only.
   362 
   363 @see CEikMsgWin
   364 @see CEikonEnv 
   365 @publishedAll 
   366 @released */
   367 	{
   368 public:
   369 	/** Defines the maximum length of text in the message. */
   370 	enum
   371 		{
   372 		/** Maximum length of text in the message. */
   373 		EMaxTextLength=80
   374 		};
   375 public:
   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);
   387 	};
   388 
   389 #endif