photosgallery/commonui/inc/glxresolutionutility.h
changeset 0 4e91876724a2
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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:    Utility class for managing the screen size
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __CGLXRESOLUTIONUTILITY_H__
       
    22 #define __CGLXRESOLUTIONUTILITY_H__
       
    23 
       
    24 #include <e32cmn.h>                 // for RPointerArray
       
    25 #include <e32base.h>
       
    26 
       
    27 // forward declarations
       
    28 class MGlxResolutionChangeObserver;
       
    29 class MGlxResolutionSize;
       
    30 
       
    31 
       
    32 /**
       
    33  * Class Description
       
    34  * Singleton containing resolution utility methods
       
    35  * @author Loughlin
       
    36  */        
       
    37 NONSHARABLE_CLASS (CGlxResolutionUtility) : public CBase
       
    38     {
       
    39 public:    
       
    40 	/**
       
    41 	 * Construction of singleton
       
    42 	 * @return A pointer to the single instance of CGlxResolutionUtility 
       
    43 	 */
       
    44     IMPORT_C static CGlxResolutionUtility* InstanceL();
       
    45     
       
    46     /**
       
    47 	 * Destroys the renderer instance of CGlxResolutionUtility when the 
       
    48 	 * reference count is zero
       
    49      */	
       
    50     IMPORT_C void Close();
       
    51 
       
    52     /**
       
    53 	 * Get the screen size
       
    54 	 * @return The screen size in POSS
       
    55      */	
       
    56     IMPORT_C TSize ScreenSize() const;
       
    57 
       
    58     /**
       
    59      * Get the lenght of in POSS
       
    60      * @param The lenght in pixels which is to be converted to POSS
       
    61      * @return The converted lenght & width in POSS
       
    62      */
       
    63     IMPORT_C TReal32 PixelsToPoss( const TReal32& aLenPixels ) const;
       
    64 
       
    65     /**
       
    66      * Get the lenght of in pixels
       
    67      * @param The length in POSS which is to be converted to pixels
       
    68      * @return The converted size in pixels
       
    69      */
       
    70     IMPORT_C TReal32 PossToPixels( const TReal32& aSzPoss ) const;
       
    71 
       
    72     /**
       
    73      * Add a resolution change observer
       
    74      * @param The observer that will recieve notification on resolution 
       
    75      *           change
       
    76      */
       
    77     IMPORT_C void AddObserverL( MGlxResolutionChangeObserver& aObserver );
       
    78 
       
    79     /**
       
    80      * Remove a resolution change observer
       
    81      * @param The observer that will no longer recieve notification on 
       
    82      *           resolution change
       
    83      */
       
    84     IMPORT_C void RemoveObserver( MGlxResolutionChangeObserver& aObserver );
       
    85    
       
    86 public: // not exported
       
    87 
       
    88     /**
       
    89      * Receives notification of a change in the screen size
       
    90      * All resolution observers are notified of the resolution change
       
    91      * @param aScreenSize the new screen size
       
    92      */
       
    93     void SetScreenSizeL( TSize aScreenSize );
       
    94     
       
    95 private: 
       
    96 
       
    97     /**
       
    98      * Symbian constructor - used by SingletonStore to create instance
       
    99      */
       
   100     static CGlxResolutionUtility* NewL();
       
   101     
       
   102     /**
       
   103      * C++ constructor
       
   104      */
       
   105     CGlxResolutionUtility();
       
   106     
       
   107     /**
       
   108      * 2 Phase ctor
       
   109      */
       
   110     void ConstructL();
       
   111     /**
       
   112      * Destructor
       
   113      */
       
   114     ~CGlxResolutionUtility();
       
   115  
       
   116 private: // class member variables
       
   117  
       
   118     // Size of the screen
       
   119     TSize iScreenSize;
       
   120     // Screen Size aspect ratio - POSS is a unit of measurement 
       
   121     // where 1 == the longest screen axis
       
   122     TReal32 iOnePossToPixelRatio;
       
   123     // The ratio of pixels to poss - stored to save on division 
       
   124     TReal32 iPixelToPossRatio;
       
   125     // Own: The container for the event observers
       
   126 	RPointerArray < MGlxResolutionChangeObserver > iObserverList;
       
   127     };
       
   128 
       
   129 #endif //__CGLXRESOLUTIONUTILITY_H__