extras/calcsoft/inc/CalcCmdBtn.h
branchRCL_3
changeset 21 10c6e6d6e4d9
parent 0 3ee3dfdd8d69
equal deleted inserted replaced
20:41b775cdc0c8 21:10c6e6d6e4d9
       
     1 /*
       
     2 * Copyright (c) 2002 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:  The Function-Map's button class, CCalcCommandButton
       
    15 *                Derived from CEikCommandButtonBase
       
    16 *                The CCalcCommandButton is flat button.
       
    17 *                In making disable, it calls SetDimmed() function.
       
    18 *
       
    19 */
       
    20 
       
    21 
       
    22 #ifndef     CALCCMDBTN_H
       
    23 #define     CALCCMDBTN_H
       
    24 
       
    25 
       
    26 #include <coecntrl.h>
       
    27 #include <aknutils.h>
       
    28 
       
    29 //  CLASS DEFINITIONS 
       
    30 class CCalcFuncmapSubPane;
       
    31 
       
    32 /**
       
    33 CCalcCommandButton : The button class for FunctionMap of a calculator
       
    34 */
       
    35 
       
    36 class CCalcCommandButton 
       
    37       : public CCoeControl
       
    38     {
       
    39     public:
       
    40         enum TState  // Button state for bitmap.
       
    41             {
       
    42             ENormal,    // Button is normal.
       
    43             EPressed,   // Button is pushed.
       
    44             EDimmed     // Button is dimmed.
       
    45             };
       
    46 
       
    47     public: // Constructors and destructor 
       
    48         /**
       
    49         * Two-phased constructor.
       
    50         * @param aFuncmapSubPane : CCalcFuncmapSubPane pointer 
       
    51         * @param aUnpressedBmp : Bitmap for unpressed button
       
    52         * @param aPressedBmp : Bitmap for pressed button
       
    53         * @param aInactiveBmp : Bitmap for inactive button
       
    54         */
       
    55         static CCalcCommandButton* NewL(
       
    56             CCalcFuncmapSubPane* aFuncmapSubPane,
       
    57             const CGulIcon* aUnpressedBmp,
       
    58             const CGulIcon* aPressedBmp,
       
    59             const CGulIcon* aInactiveBmp); 
       
    60         
       
    61         /**
       
    62         * Destructor.
       
    63         */
       
    64         virtual ~CCalcCommandButton();
       
    65         
       
    66         
       
    67     public: // New functions
       
    68         /**
       
    69         * Button state is set and re-draw.
       
    70         * @param aState : State of a button (ENormal || EPressed || ESelected)
       
    71         */
       
    72         void SetStateAndRedraw(const TState& aState);
       
    73 
       
    74         /**
       
    75         * Set flag which button is selected or not, and redraw.
       
    76         * @param aIsSelected : Button is selected or not.
       
    77         */
       
    78         void SetIsSelectedAndRedraw(TBool aIsSelected);
       
    79 
       
    80         /**
       
    81         * Return Current state of a button.
       
    82         * @return Current state of a button (ENormal || EPressed || ESelected)
       
    83         */
       
    84         TState State() const;
       
    85 
       
    86 		/**
       
    87 		 *Sets iUnpressedButton, iPressedButton, iInactiveButton bitmap arrays to the current bitmaps.
       
    88 		 * @param aUnpressedButtonIcon: Icon for Unpressed button 
       
    89          * @param aPressedButtonIcon :  Icon for  pressed button
       
    90          * @param aInactiveButtonIcon : Icon for Inactive button        
       
    91 		*/
       
    92 		void SetBitmapIcons(CGulIcon* aUnpressedButtonIcon,
       
    93                     CGulIcon* aPressedButtonIcon,
       
    94                     CGulIcon* aInactiveButtonIcon);
       
    95         /**
       
    96         * Gets the button layout
       
    97         * Used for touch support.
       
    98         */
       
    99         TRect ButtonLayout();
       
   100     
       
   101     private: // New functions
       
   102         /**
       
   103         * C++ default constructor.
       
   104         */
       
   105         CCalcCommandButton();
       
   106        
       
   107         /**
       
   108         * Second-phase constructor.
       
   109         * @param aFuncmapSubPane : CCalcFuncmapSubPane pointer 
       
   110         * @param aUnpressedBmp : Bitmap for unpressed button
       
   111         * @param aPressedBmp : Bitmap for pressed button
       
   112         * @param aInactiveBmp : Bitmap for inactive button
       
   113         */
       
   114         void ConstructL(
       
   115                 CCalcFuncmapSubPane* aFuncmapSubPane,
       
   116                 const CGulIcon* aUnpressedBmp,
       
   117                 const CGulIcon* aPressedBmp,
       
   118                 const CGulIcon* aInactiveBmp); 
       
   119         
       
   120         
       
   121     private:  // Functions from base classes
       
   122         /**
       
   123         * From CCoeControl : Data of control is set.
       
   124         */
       
   125         void SizeChanged();
       
   126 
       
   127         /**
       
   128         * From CCoeControl : Draw a button
       
   129         * @param aRect : Size of a button
       
   130         */
       
   131         void Draw(const TRect& aRect) const;
       
   132 
       
   133         
       
   134     private:  // Data
       
   135         TState  iState;      // Current state of a button
       
   136         TBool   iIsSelected; // If Button selected TRUE
       
   137         const CGulIcon*   iUnpressedButton;   // Unpressed button bitmap
       
   138         const CGulIcon*   iPressedButton;     // Pressed button bitmap
       
   139         const CGulIcon*   iInactiveButton;    // Inactive button bitmap
       
   140         TAknLayoutRect    iLayoutRect;        // rectangle of button 
       
   141     };
       
   142 
       
   143 
       
   144 #endif      //  CALCCMDBTN_H
       
   145 
       
   146 // End of File