classicui_plat/skinnable_clock_api/inc/AknSkinnableClock.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 2006-2008 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:  Control for AVKON's skinnable clock.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_AKNSKINNABLECLOCK_H
       
    20 #define C_AKNSKINNABLECLOCK_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <coecntrl.h>
       
    24 #include <e32property.h>
       
    25 #include <hwrmlight.h>
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class CFbsBitmap;
       
    29 class CFbsBitmapDevice;
       
    30 class CFbsBitGc;
       
    31 class CAknSkinnableClockChangeHandler;
       
    32 class CAknSkinnableClockFace;
       
    33 class CAknSkinnableClock;
       
    34 
       
    35 /**
       
    36  * Clock control that displays analogue or digital clock with skinning.
       
    37  *
       
    38  * This is a public (non-SDK) class visible outside the library.
       
    39  * This class is not intended for further derivation.
       
    40  *
       
    41  * @since 2.0
       
    42  *
       
    43  * @internal
       
    44  */
       
    45 NONSHARABLE_CLASS( CAknSkinnableClock ) : public CCoeControl,
       
    46                                           public MCoeControlHitTest,
       
    47                                           public MCoeMessageMonitorObserver, 
       
    48                                           public MHWRMLightObserver
       
    49     {
       
    50 public: // Constructors and destructor
       
    51 
       
    52     /**
       
    53     * Two-phased constructor.
       
    54     *
       
    55     * @since 2.0
       
    56     *
       
    57     * @param  aContainerWindow   Container window for the clock component.
       
    58     *
       
    59     * @param  aFormatFromLocale  Boolean flag to indicate whether the clock
       
    60     *                            format should be updated from the locale.
       
    61     *
       
    62     * @param  aContextPaneClock  Boolean flag that indicates whether the
       
    63     *                            clock is in the context pane.
       
    64     *
       
    65     * @return Newly constructed object.
       
    66     */
       
    67     IMPORT_C static CAknSkinnableClock* NewL( CCoeControl* aContainerWindow,
       
    68                                               const TBool aFormatFromLocale,
       
    69                                               const TBool aContextPaneClock );
       
    70 
       
    71     /**
       
    72     * Destructor.
       
    73     */
       
    74     IMPORT_C virtual ~CAknSkinnableClock();
       
    75 
       
    76 public: // New functions
       
    77 
       
    78     /**
       
    79     * Updates the double buffer and redraws the clock.
       
    80     */
       
    81     IMPORT_C void UpdateDisplay();
       
    82 
       
    83     /**
       
    84     * Sets the format of the clock.
       
    85     *
       
    86     * @param  aFormat  New clock format.
       
    87     */
       
    88     IMPORT_C void SetFormatL( const TClockFormat aFormat );
       
    89 
       
    90 
       
    91     /**
       
    92     * Updates time and locale state of the clock.
       
    93     */
       
    94     void TimeOrLocaleChanged();
       
    95 
       
    96 private: // New functions
       
    97 
       
    98 
       
    99     /**
       
   100     * Timer callback for clock updates
       
   101     *
       
   102     * @param  aThis  Pointer to the skinnable clock instance.
       
   103     *
       
   104     * @return Always returns @c KErrNone.
       
   105     */
       
   106     static TInt TimerCallback( TAny* aThis );
       
   107 
       
   108     /**
       
   109     * Gets the display mode for the buffer.
       
   110     *
       
   111     * @return Display mode suitable for the buffer.
       
   112     */
       
   113     TDisplayMode BufferDisplayMode();
       
   114 
       
   115     /**
       
   116     * Checks whether the clock is currently in the context pane.
       
   117     *
       
   118     * @return @c ETrue if the clock is visible in context pane,
       
   119     *         @c EFalse otherwise.
       
   120     */
       
   121     TBool IsVisibleInContextPane() const;
       
   122 
       
   123     /**
       
   124     * Starts the clock timer.
       
   125     * Used when the clock gains visibility.
       
   126     */
       
   127     void StartTimer();
       
   128 
       
   129     /**
       
   130     * Stops the clock timer.
       
   131     * Used when the clock loses visibility.
       
   132     */
       
   133     void StopTimer();
       
   134 
       
   135     /**
       
   136     * Called when the clock control gains foreground.
       
   137     */
       
   138     void ForegroundGainedL();
       
   139 
       
   140 public: // From base class @c CCoeControl.
       
   141 
       
   142     /**
       
   143     * Handles the resource change events.
       
   144     *
       
   145     * @param  aType  Resource change type.
       
   146     */
       
   147     void HandleResourceChange( TInt aType );
       
   148 
       
   149     /**
       
   150     * Check if pointer event should be handled or not,
       
   151     * If in idle - then handle.
       
   152     *
       
   153     * @param  aPoint    The position to test.
       
   154     * @param  aControl  Control.
       
   155     *
       
   156     * @return @c ETrue if pointer event should be handled, @c EFalse if not.
       
   157     */
       
   158     TBool HitRegionContains( const TPoint &aPoint,
       
   159                              const CCoeControl &aControl ) const;
       
   160 
       
   161     /**
       
   162     * Responds to changes in the position of the control.
       
   163     */
       
   164     IMPORT_C virtual void PositionChanged();
       
   165 
       
   166 public: // From base class @c MCoeMessageMonitorObserver.
       
   167 
       
   168     /**
       
   169     * Used to receive event from window server
       
   170     * when the visibility of the window changes.
       
   171     *
       
   172     * @param  aEvent  The window server event.
       
   173     */
       
   174     void MonitorWsMessage( const TWsEvent& aEvent );
       
   175 
       
   176 private: // From base class @c CCoeControl.
       
   177 
       
   178     /**
       
   179     * Draws the clock.
       
   180     *
       
   181     * @param  aRect  The rectangle to be drawn.
       
   182     */
       
   183     void Draw( const TRect& aRect ) const;
       
   184 
       
   185 private:
       
   186 
       
   187     /**
       
   188     * C++ default constructor.
       
   189     *
       
   190     * @param  aFormatFromLocale  Boolean flag to indicate whether the clock
       
   191     *                            format should be updated from the locale.
       
   192     *
       
   193     * @param  aContextPaneClock  Boolean flag that indicates whether the
       
   194     *                            clock is in the context pane.
       
   195     */
       
   196     CAknSkinnableClock( const TBool aFormatFromLocale,
       
   197                         const TBool aContextPaneClock );
       
   198 
       
   199     /**
       
   200     * Second-phase constructor.
       
   201     * By default Symbian 2nd phase constructor is private.
       
   202     */
       
   203     void ConstructL();
       
   204 
       
   205 public: // From base class @c CCoeControl.
       
   206 
       
   207     /**
       
   208     * Handles pointer events by launching the clock application.
       
   209     *
       
   210     * @param  aPointerEvent  Pointer event to be handled.
       
   211     */
       
   212     IMPORT_C void HandlePointerEventL( const TPointerEvent& aPointerEvent );
       
   213 
       
   214     /**
       
   215     * Changes the control visibility.
       
   216     *
       
   217     * @param  aVisible  @c ETrue to make the control visible,
       
   218     *                   @c EFalse otherwise.
       
   219     */
       
   220     virtual void MakeVisible( TBool aVisible );
       
   221 
       
   222 protected: // From base class @c CCoeControl.
       
   223 
       
   224     /**
       
   225     * Handles size change events.
       
   226     */
       
   227     void SizeChanged();
       
   228 
       
   229 private:
       
   230 
       
   231     /**
       
   232      * From MHWRMLightObserver
       
   233      * @since Series 60 3.1
       
   234      */
       
   235     void LightStatusChanged(TInt aTarget, CHWRMLight::TLightStatus aStatus);
       
   236 
       
   237 private: // Member data
       
   238 
       
   239     /**
       
   240     * Clock timer.
       
   241     * Own.
       
   242     */
       
   243     CPeriodic* iTimer;
       
   244 
       
   245     /**
       
   246     * Change handler to monitor changes in system time or locale.
       
   247     * Own.
       
   248     */
       
   249     CAknSkinnableClockChangeHandler* iHandler;
       
   250 
       
   251     /**
       
   252     * Double buffer to which the clock graphics are drawn.
       
   253     * Own.
       
   254     */
       
   255     CFbsBitmap* iDoubleBuffer;
       
   256 
       
   257     /**
       
   258     * The graphics device into which the double buffer is drawn.
       
   259     * Own.
       
   260     */
       
   261     CFbsBitmapDevice* iDoubleBufferDev;
       
   262 
       
   263     /**
       
   264     * Graphics context for the double buffer.
       
   265     * Own.
       
   266     */
       
   267     CFbsBitGc* iDoubleBufferGc;
       
   268 
       
   269     /** Current display format of the clock. */
       
   270     TClockFormat iClockFormat;
       
   271 
       
   272     /** Defines whether or not the clock format is updated from the locale. */
       
   273     TBool iFormatFromLocale;
       
   274 
       
   275     /** Defines whether or not the clock control is in the status pane. */
       
   276     TBool iContextPaneClock;
       
   277 
       
   278     /**
       
   279     * Pointer to the class which draws the time graphics to the double buffer.
       
   280     * Own.
       
   281     */
       
   282     CAknSkinnableClockFace* iFace;
       
   283 
       
   284     /**
       
   285     * Defines whether or not the clock control has full or
       
   286     * partial foreground.
       
   287     */
       
   288     TBool iInForeground;
       
   289 
       
   290     /** Contains the time currently drawn to the bitmap. */
       
   291     TDateTime iTimeInBitmap;
       
   292 
       
   293     /** For registering MHWRMLightObserver. */
       
   294     CHWRMLight* iLight;
       
   295     };
       
   296 
       
   297 #endif // C_AKNSKINNABLECLOCK_H
       
   298 
       
   299 // End of File