uifw/EikStd/coctlinc/AknDoubleSpanScrollIndicator.h
changeset 0 2f259fa3e83a
child 4 8ca85d2f0db7
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     1 /*
       
     2 * Copyright (c) 1997-1999 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: Indicator for double span scroll bar.
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __AKNDOUBLESPANSCROLLINDICATOR_H
       
    19 #define __AKNDOUBLESPANSCROLLINDICATOR_H
       
    20 
       
    21 #include <coecntrl.h>
       
    22 #include "eikscrlb.h"
       
    23 
       
    24 #include "AknDoubleSpanScrollIndicatorItem.h"
       
    25 
       
    26 class CAknDoubleSpanScrollIndicatorBGExtension;
       
    27 
       
    28 NONSHARABLE_CLASS( TBitmapFx )
       
    29     {
       
    30 public:    
       
    31     struct TRGB
       
    32         {
       
    33         TInt iR;
       
    34         TInt iG;
       
    35         TInt iB;
       
    36         };
       
    37     struct THSL
       
    38         {
       
    39         TInt iH;
       
    40         TInt iS;
       
    41         TInt iL;
       
    42         };
       
    43     
       
    44     static void PixelEffect( TUint16* aPixelData );
       
    45     static TInt HueToRGB( TInt v1, TInt v2, TInt aH );
       
    46     };
       
    47 
       
    48 NONSHARABLE_CLASS(CAknDoubleSpanScrollIndicator) : public CCoeControl
       
    49     {            
       
    50 public: // public construction and destruction methods
       
    51    
       
    52    /**
       
    53     * Two-phased constructor.
       
    54     *
       
    55     * @since    2.6
       
    56     * @return   Newly constructed object.
       
    57     */
       
    58     static CAknDoubleSpanScrollIndicator* NewL(CEikScrollBar::TOrientation aOrientation);
       
    59 
       
    60    /**
       
    61     * Destructor.
       
    62     *
       
    63     * @since    2.6
       
    64     */
       
    65     ~CAknDoubleSpanScrollIndicator(); 
       
    66 
       
    67 public: // new methods
       
    68 
       
    69    /**
       
    70     * Sets values for the indicator.
       
    71     *
       
    72     * @since    2.6
       
    73     * @param    aScrollSpan       Size of the scrolled list.
       
    74     * @param    aFocusPosition    Position of the current field in the list.
       
    75     * @param    aWindowSize       Size of the visible part of the list.
       
    76     * @param    aFieldPosition    Size of the current field. (Optional double span)
       
    77     * @param    aFieldSize        Position inside the current field. (Optional double span)  
       
    78     *
       
    79     */
       
    80     void SetIndicatorValues(TInt aScrollSpan, TInt aFocusPosition, TInt aWindowSize, TInt aFieldPosition, TInt aFieldSize);
       
    81     
       
    82    /**
       
    83     * Gets a value from the indicator.
       
    84     *
       
    85     * @since    2.6
       
    86     * @return   Size of the scrolled list. 
       
    87     *
       
    88     */
       
    89     TInt ScrollSpan();
       
    90 
       
    91    /**
       
    92     * Gets a value from the indicator.
       
    93     *
       
    94     * @since    2.6
       
    95     * @return   Position of the current field in the list. 
       
    96     *
       
    97     */
       
    98     TInt FocusPosition();
       
    99 
       
   100    /**
       
   101     * Gets a value from the indicator.
       
   102     *
       
   103     * @since    2.6
       
   104     * @return   Size of the visible part of the list. 
       
   105     *
       
   106     */
       
   107     TInt WindowSize();
       
   108 
       
   109    /**
       
   110     * Gets a value from the indicator.
       
   111     *
       
   112     * @since    2.6
       
   113     * @return   Size of the current field. (Optional double span) 
       
   114     *
       
   115     */
       
   116     TInt FieldPosition();
       
   117     
       
   118    /**
       
   119     * Gets a value from the indicator.
       
   120     *
       
   121     * @since    2.6
       
   122     * @return   Position inside the current field. (Optional double span) 
       
   123     *
       
   124     */
       
   125     TInt FieldSize();
       
   126 
       
   127    /**
       
   128     * Sets flag which tells wheter indicator should assume transparent background
       
   129     * instead of drawing a background from skin system.
       
   130     * 
       
   131     * @since    2.6
       
   132     * @param    aTransparentBackground   If ETrue, then indicator does not try to 
       
   133     *                                    draw background. Otherwise background is
       
   134     *                                    drawn normally.
       
   135     */
       
   136     void SetTransparentBackground(TBool aTransparentBackground);    
       
   137 
       
   138    /**
       
   139     * Gets flag which tells wheter indicator should assume transparent background
       
   140     * instead of drawing a background from skin system.
       
   141     * 
       
   142     * @since    2.6
       
   143     * @retrun   If ETrue, then indicator does not try to 
       
   144     *           draw background. Otherwise background is drawn normally.
       
   145     */
       
   146     TBool TransparentBackground();    
       
   147 
       
   148    /**
       
   149     * Gets the width of the indicator graphics.
       
   150     *
       
   151     * @since    2.8
       
   152     * @return   Width of the indicator.  
       
   153     *
       
   154     */
       
   155     TInt IndicatorWidth();
       
   156 
       
   157     /**
       
   158      * @since 3.1
       
   159      * TInt aOwnsWindow is zero if non-window, else window owning
       
   160      */
       
   161     void SetAsWindowOwning(TBool aOwnsWindow);
       
   162 
       
   163 private: // methods from CCoeControl
       
   164     void Draw(const TRect& aRect) const; 
       
   165        void SizeChanged();                  
       
   166 public:
       
   167     void HandleResourceChange(TInt aType);
       
   168     
       
   169     /**
       
   170     * Is the scrollbar drawing its background from background context
       
   171     * or are the scrollbar graphics drawn on top of current graphics on display
       
   172     *
       
   173     * @since    3.0
       
   174     * @return   The background drawing state 
       
   175     *
       
   176     */    
       
   177     TBool DrawBackgroundState();
       
   178     
       
   179     /**
       
   180     * Set the background drawing of the scrollbar. If ETrue, scrollbar draws 
       
   181     * background from background context.
       
   182     *
       
   183     * @since    3.0
       
   184     * @param    aDraw If ETrue, background is drawn, otherwise drawing is skipped
       
   185     */
       
   186     void SetDrawBackgroundState(TBool aDraw);            
       
   187 
       
   188     /**
       
   189     * Get the current calculated thumb (handle) span in pixels.
       
   190     *
       
   191     * @since    5.0
       
   192     * @return   The thumb span in pixels
       
   193     */
       
   194     TInt GetCurrentThumbSpanInPixels();
       
   195     
       
   196     /**
       
   197     * Get the current calculated thumb (handle) position in pixels
       
   198     * relative to the iTl of the scrollbar's shaft.
       
   199     *
       
   200     * @since    5.0
       
   201     * @return   The thumb position in pixels
       
   202     */
       
   203     TInt GetCurrentThumbPositionInPixels();
       
   204 
       
   205     /**
       
   206     * Sets the handle drag highlight.
       
   207     *
       
   208     * @since    5.0
       
   209     * @param    aHandleHighlight If ETrue, turn the handle highlight on.
       
   210     */
       
   211     void SetHandleHighlight( TBool aHandleHighlight );
       
   212     
       
   213     /**
       
   214     * Gets the status of the handle drag highlight.
       
   215     *
       
   216     * @since    5.0
       
   217     * @return   ETrue, if the handle highlight is on.
       
   218     */
       
   219     TBool HandleHighlight() const;
       
   220     
       
   221     /**
       
   222     * Sets the touch area control.
       
   223     *
       
   224     * @since    5.0
       
   225     * @param    aTouchAreaControl A pointer to the control which is drawn
       
   226     *           along with this indicator.
       
   227     */
       
   228     void SetTouchAreaControl( CCoeControl* aTouchAreaControl );
       
   229     
       
   230     /**
       
   231     * Sets the background drag highlight.
       
   232     *
       
   233     * @since    5.0
       
   234     * @param    aHandleHighlight If ETrue, turn the handle highlight on.
       
   235     */
       
   236     void SetBackgroudHighlight( TBool aBackgroudHighlight );
       
   237     
       
   238     /**
       
   239     * Gets the status of the background drag highlight.
       
   240     *
       
   241     * @since    5.0
       
   242     * @return   ETrue, if the handle highlight is on.
       
   243     */
       
   244     TBool BackgroudHighlight() const;
       
   245     
       
   246 private: // new methods
       
   247 
       
   248    /**
       
   249     * C++ default constructor.
       
   250     *
       
   251     * @since    2.6
       
   252     */
       
   253     CAknDoubleSpanScrollIndicator();
       
   254     
       
   255    /**
       
   256     * By default Symbian 2nd phase constructor is private.
       
   257     *
       
   258     * @since    2.6
       
   259     */
       
   260     void ConstructL(CEikScrollBar::TOrientation aOrientation);
       
   261 
       
   262    /**
       
   263     * Checks and if needed modifies values for drawing.
       
   264     *
       
   265     * @since    2.6
       
   266     * @param    aScrollSpan       Size of the scrolled list.
       
   267     * @param    aFocusPosition    Position of the current field in the list.
       
   268     * @param    aWindowSize       Size of the visible part of the list.
       
   269     * @param    aFieldPosition    Size of the current field. (Optional double span)
       
   270     * @param    aFieldSize        Position inside the current field. (Optional double span)  
       
   271     *
       
   272     */
       
   273     void CheckValues(TInt& aScrollSpan, TInt& aFocusPosition, TInt& aWindowSize, TInt& aFieldPosition, TInt& aFieldSize) const;
       
   274         
       
   275    /**
       
   276     * Calculates rects for different indicator parts to be used in drawing phase.
       
   277     *
       
   278     * @since    2.6
       
   279     */
       
   280     void CalculateRects();    
       
   281     
       
   282    /**
       
   283     * Creates items (that contain the bitmaps) for the scrollbar.
       
   284     *
       
   285     * @since    2.6
       
   286     */
       
   287     void CreateScrollBarItemsL();    
       
   288 
       
   289     TInt ScrollHandleMaxVisibleSizeInPixels();
       
   290     TInt HandleBackgroundMinSizeInPixels();
       
   291     TInt HandleMinSizeInPixels();
       
   292 
       
   293     /**
       
   294     * Handles background drawing
       
   295     * 
       
   296     * @since    3.1
       
   297     *
       
   298     */
       
   299     void DrawBackground() const;
       
   300     
       
   301     /**
       
   302     * Handles background bitmap creation for window owning scrollbar
       
   303     * 
       
   304     * @since    3.1
       
   305     *
       
   306     */
       
   307     void CreateBackgroundBitmapL();
       
   308     
       
   309     /**
       
   310     * Layout scrollbar handle
       
   311     * 
       
   312     * @since    3.1
       
   313     *
       
   314     */
       
   315     void LayoutHandleGraphics();
       
   316     
       
   317     /**
       
   318     * Used for highlighting handle skin graphics. Takes a bitmap, creates 
       
   319     * a copy and optionally applies an effect for the pixels in the
       
   320     * bitmap. Returns the new bitmap, so caller must take ownership.
       
   321     * Note that the effect only works for EColor64K bitmaps.
       
   322     *
       
   323     * @since    5.0
       
   324     * @param    aSource The source bitmap.
       
   325     * @param    aCopyOnly If ETrue, doesn't apply effect.
       
   326     * @return   The new bitmap.
       
   327     */
       
   328     CFbsBitmap* CopyAndApplyEffectL( const CFbsBitmap* aSource, TBool aCopyOnly = EFalse );
       
   329     
       
   330     CAknDoubleSpanScrollIndicatorItem* LoadScrollIndicatorItemL(
       
   331             const TAknsItemID &aTopId,
       
   332             const TAknsItemID &aMidId,
       
   333             const TAknsItemID &aBottomId);
       
   334 
       
   335     void DrawTiled(
       
   336             CWindowGc& aGc, const TRect& aRect, 
       
   337             CAknDoubleSpanScrollIndicatorItem *aIndicatorItem) const;
       
   338     
       
   339     void UpdateScrollBarLayout();
       
   340     
       
   341 private: // data
       
   342     TInt iScrollSpan;           // Size of the scrolled list.
       
   343     TInt iFocusPosition;        // Position of the current field in the list.
       
   344     TInt iWindowSize;           // Size of the visible part of the list. 
       
   345     TInt iFieldPosition;        // Size of the current field. (Optional double span)
       
   346     TInt iFieldSize;            // Position inside the current field. (Optional double span)
       
   347     TBool iOwnsWindow;            // Is window owning
       
   348     TInt iSpare;
       
   349 
       
   350     TRect iBackgroundRect;       // Rect for scrollbar background.
       
   351     TRect iHandleBackgroundRect; // Rect for scrollbar handle background.
       
   352     TRect iHandleRect;           // Rect for scrollbar handle. 
       
   353     
       
   354     TBool iTransparentBackground;  // A flag which tells if we have transparent bg
       
   355     TBool iDrawBackground; // do  we draw any background
       
   356     
       
   357     TBool iHandleHighlight; // is handle drag highlight on?
       
   358     
       
   359     TBool iBackgroundHighlight; //is background highlight on?
       
   360    
       
   361     
       
   362     mutable TBool iDrawBackgroundBitmap; // do we draw the background to the background bitmap before it is drawn
       
   363     TRect iOldRect; // the old scb retangle, to optimize unneccessary resizing
       
   364 
       
   365     CEikScrollBar::TOrientation iOrientation;    // Vertical or horizontal scrollbar
       
   366     
       
   367     CAknDoubleSpanScrollIndicatorItem* iBackgroundBar;
       
   368     CAknDoubleSpanScrollIndicatorItem* iHighlightBackgroundBar;
       
   369     CAknDoubleSpanScrollIndicatorItem* iHandleBar;
       
   370     CAknDoubleSpanScrollIndicatorItem* iHighlightHandleBar;
       
   371  
       
   372     
       
   373     TInt iHeadItemSize;
       
   374     TInt iMidItemSize;
       
   375     TInt iTailItemSize;
       
   376     
       
   377     CCoeControl* iTouchAreaControl; // Not own.
       
   378     };
       
   379 
       
   380 #endif
       
   381