coreapplicationuis/powersaveutilities/batterypopupcontrol/inc/batterypopupcontrol.h
changeset 56 11a052f4b02e
parent 49 76883296a0d5
child 65 8a530a83576a
equal deleted inserted replaced
49:76883296a0d5 56:11a052f4b02e
     1 /*
       
     2 * Copyright (c) 2007-2010 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:  Content for preview pop-up.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CBATTERYPOPUPCONTROL_H
       
    20 #define CBATTERYPOPUPCONTROL_H
       
    21 
       
    22 //#include <akncontrol.h>
       
    23 //#include <aknutils.h>
       
    24 //#include <aknpreviewpopupcontroller.h> // Controlling the preview pop-up component
       
    25 #include<coecobs.h>
       
    26 class MEikCommandObserver; 
       
    27 class CEikLabel;
       
    28 class CGulIcon;
       
    29 
       
    30 
       
    31 /**
       
    32 *  Class defining stylus activated pop-up content.
       
    33 *  
       
    34 *  This content is intended to be used in connection with preview pop-up
       
    35 *  component. Content shows an icon, text and
       
    36 *  an optional stylus tappable function link. If using link, the user gives link text and
       
    37 *  corresponding ID for link in construction. The user must also set
       
    38 *  itself as an observer for this content when using function links. This
       
    39 *  way the user gets callbacks (with ID) for its ProcessCommandL() function
       
    40 *  when the link is tapped.  
       
    41 *
       
    42 *  @lib BatteryPopupControl.lib
       
    43 *  @since S60 5.0
       
    44 */
       
    45 NONSHARABLE_CLASS( CBatteryPopupControl ) :public MCoeControlObserver
       
    46    // public CAknControl,
       
    47        // public MAknPreviewPopUpObserver
       
    48     {
       
    49 public:
       
    50     
       
    51     /** Preview popup command ids */
       
    52     enum TLinkCommandID
       
    53         {
       
    54         ELinkNone = 0,
       
    55         ELinkFirst = 1
       
    56         };
       
    57         
       
    58     /**
       
    59      * Two-phased constructor. Constructs the content
       
    60      * with text and function link.
       
    61      *
       
    62      * @since S60 5.0
       
    63      * @param aContentText Text for the popup. Mandatory.
       
    64      * @param aLinkText    Link text.
       
    65      * @return Pointer to the created content object.
       
    66      */
       
    67                            
       
    68     IMPORT_C static CBatteryPopupControl* NewL( const TDesC& aContentText,
       
    69                                                 const TDesC& aLinkText );
       
    70 
       
    71     /**
       
    72      * Destructor.
       
    73      */
       
    74     IMPORT_C ~CBatteryPopupControl();
       
    75        
       
    76     /**
       
    77      * Sets the command observer of the preview pop-up content. When
       
    78      * link that is set to the content is pressed, the command
       
    79      * observer's ProcessCommandL() method is called with the command ID
       
    80      * of the pressed component.
       
    81      *
       
    82      * @since S60 5.0
       
    83      * @param aCommandObserver Command observer.
       
    84      */
       
    85     IMPORT_C void SetCommandObserver( MEikCommandObserver& aCommandObserver );
       
    86     
       
    87     /**
       
    88      * Shows preview popup
       
    89      * 
       
    90      * @since S60 5.0    
       
    91      */ 
       
    92     IMPORT_C void ShowPopUpL();
       
    93 
       
    94 private:   
       
    95 // from base class CCoeControl
       
    96         
       
    97 	  /**
       
    98 	   * Handles a change to the control's resources of type aType which are
       
    99 	   * shared across the environment.
       
   100 	   *
       
   101 	   * @param aType The type of resource that have changed.
       
   102 	   */
       
   103     void HandleResourceChange( TInt aType );
       
   104 	
       
   105     /**
       
   106      * Sets container window.
       
   107      *
       
   108      * @param aContainer Container.
       
   109      */
       
   110     void SetContainerWindowL( const CCoeControl& aContainer );
       
   111 
       
   112     /**
       
   113      * Handles pointer events
       
   114      *
       
   115      * @param aPointerEvent information about the pointer event.
       
   116      */
       
   117     void HandlePointerEventL( const TPointerEvent& aPointerEvent );
       
   118 
       
   119 
       
   120 // from base class MCoeControlObserver
       
   121     
       
   122     /**
       
   123      * Handles an event from an observed control.
       
   124      *
       
   125      * @param aControl The control that sent the event.
       
   126      * @param aEventType The event type.
       
   127      */
       
   128     void HandleControlEventL( CCoeControl *aControl,
       
   129                                            TCoeEvent aEventType );
       
   130     
       
   131 // From MAknPreviewPopUpObserver
       
   132    
       
   133     /**
       
   134      * @see MAknPreviewPopUpObserver
       
   135      */
       
   136  //   void HandlePreviewPopUpEventL( CAknPreviewPopUpController* aController,
       
   137  //                                  TPreviewPopUpEvent aEvent );     
       
   138 
       
   139     /**
       
   140      * Default constructor.
       
   141      */
       
   142     CBatteryPopupControl();
       
   143     
       
   144     /**
       
   145      * Symbian 2nd phase constructor.
       
   146      *
       
   147      * @since S60 5.0
       
   148      * @param aContentText Text for the popup.
       
   149      * @param aLinkText    Link text.
       
   150      */
       
   151     void ConstructL( const TDesC& aContentText,                    
       
   152                      const TDesC& aLinkText );
       
   153 
       
   154     /**
       
   155      * Gets rect from layout data.
       
   156      *
       
   157      * @since S60 5.0
       
   158      * @param aParent Parent rect.
       
   159      * @param aComponentLayout Layout data.
       
   160      */
       
   161  //   TRect RectFromLayout( const TRect& aParent,
       
   162  //       const TAknWindowComponentLayout& aComponentLayout ) const;
       
   163 
       
   164     /**
       
   165      * Gets rect from layout data.
       
   166      *
       
   167      * @since S60 5.0
       
   168      * @param aComponentLayout Layout data.
       
   169      */
       
   170  //   TRect PopUpWindowRectFromLayout( const TAknWindowComponentLayout&
       
   171  //       aComponentLayout ) const;
       
   172     
       
   173     /**
       
   174      * Creates CGulIcon.
       
   175      *
       
   176      * @since S60 5.0
       
   177      */
       
   178     void CreateIconL( );
       
   179    
       
   180 // from base class CCoeControl
       
   181 
       
   182     /**
       
   183      * Returns a control determined by control index.
       
   184      *
       
   185      * @param aIndex Index of a control to be returned.
       
   186      * @return Pointer to control.
       
   187      */
       
   188     CCoeControl* ComponentControl( TInt aIndex ) const;
       
   189 
       
   190     /**
       
   191      * Returns the number of controls inside the control.
       
   192      *
       
   193      * @return The number of component controls.
       
   194      */
       
   195     TInt CountComponentControls() const;
       
   196     
       
   197     /**
       
   198      * Draws the control.
       
   199      *
       
   200      * @param aRect The control's area.
       
   201      */
       
   202     void Draw( const TRect& aRect ) const;
       
   203 
       
   204     /**
       
   205      * Returns the control's minimum required size.
       
   206      *
       
   207      * @return The minimum size required by the control.
       
   208      */
       
   209     TSize MinimumSize();
       
   210 
       
   211     /**
       
   212      * Responds to size changes to set the size and position for 
       
   213      * the contents of this control.
       
   214      */
       
   215     void SizeChanged();
       
   216    
       
   217 private: // data
       
   218     /** Variant ids */
       
   219     enum TVariantID
       
   220         {
       
   221         EVariantIconText = 0,
       
   222         EVariantIconTextLink = 1
       
   223         };
       
   224         
       
   225     /**
       
   226      * Label for informative text.
       
   227      * Own.
       
   228      */
       
   229     CEikLabel* iText;
       
   230 
       
   231     /**
       
   232      * Link text.
       
   233      * Own.
       
   234      */    
       
   235     HBufC* iLinkText;
       
   236 
       
   237     /**
       
   238      * Command observer.
       
   239      * Not own.
       
   240      */
       
   241     MEikCommandObserver* iCommandObserver;
       
   242 
       
   243     /**
       
   244      * Font
       
   245      * Not own
       
   246      */
       
   247     const CFont* iFont;
       
   248     
       
   249     /**
       
   250      * Status of highlighted item.  
       
   251      */
       
   252     TBool iHighlightedItem;
       
   253     
       
   254     /**
       
   255      * Id for icon bitmap    
       
   256      */ 
       
   257     TInt iIconId;
       
   258         
       
   259     /**
       
   260      * Id for icon mask    
       
   261      */ 
       
   262     TInt iMaskId;
       
   263     
       
   264     /**
       
   265      * Icon.
       
   266      * Own.  
       
   267      */ 
       
   268     CGulIcon* iIcon;
       
   269         
       
   270     /**
       
   271      * Layout for icon  
       
   272      */
       
   273   //  TAknLayoutRect iBitmapLayout;  
       
   274 
       
   275     /**
       
   276      * Variant, 
       
   277      * 0 = icon and text
       
   278      * 1 = icon, text and function link
       
   279      */
       
   280     TInt iVariant;
       
   281     
       
   282     /**
       
   283      * Popup controller
       
   284      * Own.  
       
   285      */    
       
   286   //  CAknPreviewPopUpController* iController;
       
   287     
       
   288     /**
       
   289      * Rect for link  
       
   290      */     
       
   291     TRect iLinkRect;
       
   292     };
       
   293     
       
   294     
       
   295 #endif // CBATTERYPOPUPCONTROL_H
       
   296