javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/inc/swtprogressbar.h
branchRCL_3
changeset 14 04becd199f91
equal deleted inserted replaced
13:f5050f1da672 14:04becd199f91
       
     1 /*******************************************************************************
       
     2  * Copyright (c) 2005, 2010 Nokia Corporation and/or its subsidiary(-ies).
       
     3  * All rights reserved. This program and the accompanying materials
       
     4  * are made available under the terms of the Eclipse Public License v1.0
       
     5  * which accompanies this distribution, and is available at
       
     6  * http://www.eclipse.org/legal/epl-v10.html
       
     7  *
       
     8  * Contributors:
       
     9  *     Nokia Corporation - S60 implementation
       
    10  *******************************************************************************/
       
    11 
       
    12 
       
    13 #ifndef SWTPROGRESSBAR_H
       
    14 #define SWTPROGRESSBAR_H
       
    15 
       
    16 
       
    17 #include "swtcontrolbase.h"
       
    18 
       
    19 
       
    20 class CAORotateImage;
       
    21 
       
    22 
       
    23 /**
       
    24  * CSwtProgressBar
       
    25  * @lib eswt.dll
       
    26  */
       
    27 NONSHARABLE_CLASS(CSwtProgressBar)
       
    28         : public CAknControl
       
    29         , public ASwtControlBase
       
    30         , public MSwtProgressBar
       
    31 {
       
    32 public:
       
    33     /**
       
    34      * The 1st and 2nd phase constructor wrapper.
       
    35      * @param aDisplay The Display to associate with.
       
    36      * @param aPeer The peer to its java counterpart.
       
    37      * @param aParent Parent composite.
       
    38      * @param aStyle The control's style.
       
    39      * @return CSwtProgressBar*  A pointer to the  created CSwtProgressBar object.
       
    40      */
       
    41     static CSwtProgressBar* NewL(MSwtDisplay& aDisplay, TSwtPeer aPeer,
       
    42     MSwtComposite& aParent, TInt aStyle);
       
    43 
       
    44 private:
       
    45     /**
       
    46      * Contructor.
       
    47      * @param aDisplay The Display to associate with
       
    48      * @param aPeer The peer to its java counterpart
       
    49      * @param aParent Parent composite
       
    50      * @param aStyle The style
       
    51      */
       
    52     CSwtProgressBar(MSwtDisplay& aDisplay, TSwtPeer aPeer,
       
    53                     MSwtComposite& aParent, TInt aStyle);
       
    54 
       
    55     /**
       
    56      * Destructor.
       
    57      */
       
    58     ~CSwtProgressBar();
       
    59 
       
    60     /**
       
    61      * Second phase constructor
       
    62      */
       
    63     void ConstructL();
       
    64 
       
    65 private:
       
    66     /**
       
    67      * Load all needed images
       
    68      */
       
    69     void LoadImagesL();
       
    70 
       
    71     /**
       
    72      * Delete all images.
       
    73      * This method delete all images contained by iImagesToDelete,
       
    74      * and reset iBarImages and iBarMasks arrays.
       
    75      */
       
    76     void DeleteImages();
       
    77 
       
    78     /**
       
    79      * Adjust the current selection value with the maximun, minimun values.
       
    80      */
       
    81     void UpdateSelection();
       
    82 
       
    83     /**
       
    84      * Drawing the background on the empty area, which are relative
       
    85      * with the current selection. This method is used by the SMOOTH styles.
       
    86      */
       
    87     void DrawEmptyArea(CWindowGc& aGc) const;
       
    88 
       
    89     /**
       
    90      * Add a image to the "rotator".
       
    91      * @param aBitmap The bitmap to rotate.
       
    92      */
       
    93     void AddBitmapToRotator(CFbsBitmap*& aBitmap);
       
    94 
       
    95     /**
       
    96      * Add all images to the "rotator".
       
    97      */
       
    98     void AddAllImagesToRotate();
       
    99 
       
   100     /**
       
   101      * Draw the progressBar images.
       
   102      * @param aGC    The graphic context where the image will be drawing.
       
   103      * @param aRect  The progress bar rectangle.
       
   104      */
       
   105     void DrawProgressBar(CWindowGc& gc, TRect targetRect) const;
       
   106 
       
   107     /**
       
   108      * Draw the progressBar frame.
       
   109      * @param aGC    The graphic context where the image will be drawing.
       
   110      * @param aRect  The progress bar rectangle.
       
   111      */
       
   112     void DrawFrame(CWindowGc& gc, const TRect& targetRect) const;
       
   113 
       
   114     /**
       
   115      * Get the prefered size of the ProgressBar from the layout.
       
   116      * @return The prefered size of the ProgressBar from the layout.
       
   117      */
       
   118     TSize LayoutPreferedSizeSize() const;
       
   119 
       
   120     void SetImagesSize(const TSize& aImageSize);
       
   121 
       
   122     /**
       
   123      * Resource change leaving helper
       
   124      */
       
   125     void SwtHandleResourceChangeL(TInt aType);
       
   126 
       
   127     /**
       
   128      * Returns ETrue when bitmap needs to be converted to plain bitmap.
       
   129      * @param aBitmap Bitmap to be tested.
       
   130      * @return ETrue when bitmap needs to be converted.
       
   131      */
       
   132     TBool IsBitmapConversionNeeded(CFbsBitmap* aBitmap) const;
       
   133 
       
   134     /**
       
   135      * Creates new bitmap which is neither compressed, nor extentended.
       
   136      * Ownership of the new bitmap is passed to the caller.
       
   137      * Source bitmap is not destroyed.
       
   138      * @param aSrcBitmap Bitmap to be converted
       
   139      * @return New un-compressed, non-extended bitmap.
       
   140      */
       
   141     CFbsBitmap* CreatePlainBitmapL(CFbsBitmap* aSrcBitmap) const;
       
   142 
       
   143 
       
   144 // Some private methods related to the KSwtStyleIndeterminate mode
       
   145 private:
       
   146     void StartAnimation();
       
   147     void StopAnimation();
       
   148     static TInt AnimationCallBack(TAny* aPtr);
       
   149 
       
   150 // From CCoeControl
       
   151 public:
       
   152     TSize           MinimumSize();
       
   153     void            HandleResourceChange(TInt aType);
       
   154     void            SetDimmed(TBool aDimmed);
       
   155     void            MakeVisible(TBool aVisible);
       
   156     TKeyResponse    OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
       
   157 protected:
       
   158     void            FocusChanged(TDrawNow aDrawNow);
       
   159     void            SizeChanged();
       
   160     void            PositionChanged();
       
   161     void            Draw(const TRect& aRect) const;
       
   162     TTypeUid::Ptr   MopSupplyObject(TTypeUid aId);
       
   163 
       
   164 // From MSwtControl
       
   165 public:
       
   166     CCoeControl&        CoeControl();
       
   167     const CCoeControl&  CoeControl() const;
       
   168     TBool               IsFocusable(TInt aReason = KSwtFocusByApi) const;
       
   169     void                ProcessKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
       
   170     TSize               ComputeSizeL(TInt aWHint, TInt aHHint);
       
   171 
       
   172 // From MSwtProgressBar
       
   173 public:
       
   174     MSwtControl*    Control();
       
   175     TInt            GetMaximum() const;
       
   176     TInt            GetMinimum() const;
       
   177     TInt            GetSelection() const;
       
   178     void            SetMaximum(TInt aValue);
       
   179     void            SetMinimum(TInt aValue);
       
   180     void            SetSelection(TInt aValue);
       
   181 
       
   182 // Data
       
   183 private:
       
   184     /**
       
   185      *  The minimum value for the Slider.
       
   186      */
       
   187     TInt iMinimum;
       
   188 
       
   189     /**
       
   190      *  The maximum value for the ProgressBar.
       
   191      */
       
   192     TInt iMaximum;
       
   193 
       
   194     /**
       
   195      *  The current selection on the ProgressBar.
       
   196      */
       
   197     TInt iSelection;
       
   198 
       
   199     /**
       
   200      *  The active object which rotate the VERTICAL ProgressBar images.
       
   201      */
       
   202     CAORotateImage* iImagesRotator;
       
   203 
       
   204     /**
       
   205      *  Array which contains all images to delete.
       
   206      */
       
   207     RArray<CFbsBitmap*>     iImagesToDelete;
       
   208 
       
   209     TInt                    iImageIndex;            // Actual displayed frame of the animation.
       
   210     RArray<CFbsBitmap*>     iBarImages;             // Bitmaps for the waiting animation.
       
   211     RArray<CFbsBitmap*>     iBarMasks;              // Mask for the waiting animation.
       
   212     CFbsBitmap*             iBarFrameLeftImage;     // Bitmap of the progress bar frame image.
       
   213     CFbsBitmap*             iBarFrameLeftMask;      // Bitmap of the progress bar frame mask.
       
   214     CFbsBitmap*             iBarFrameRightImage;    // Bitmap of the progress bar frame image.
       
   215     CFbsBitmap*             iBarFrameRightMask;     // Bitmap of the progress bar frame mask.
       
   216     CFbsBitmap*             iBarFrameCenterImage;   // Bitmap of the progress bar frame image.
       
   217     CFbsBitmap*             iBarFrameCenterMask;    // Bitmap of the progress bar frame mask.
       
   218     CPeriodic*              iAnimationPeriodic;     // Asyncronous periodic caller for the animation.
       
   219     TInt                    iFrameIntervalInMilliSeconds;
       
   220 };
       
   221 
       
   222 #endif // SWTPROGRESSBAR_H
       
   223 
       
   224 
       
   225