photosgallery/viewframework/uiutilities/inc/glxscrollbar.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:    Scrollbar
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef C_GLXSCROLLBAR_H
       
    22 #define C_GLXSCROLLBAR_H
       
    23 
       
    24 #include <e32base.h>
       
    25 
       
    26 class MGlxScrollbarObserver;
       
    27 class CAlfControl;
       
    28 class CAlfLayout;
       
    29 class CAlfAnchorLayout;
       
    30 class CGlxTextureManager;
       
    31 
       
    32 /**
       
    33  * CGlxScrollbar
       
    34  *
       
    35  * Class to handle controlling/drawing of scrollbar
       
    36  *
       
    37  * Example: Scrollbar required for list with 10 items, with 3 visible items
       
    38  * The first visible row is at position 0.
       
    39  * The position is always from 0 to (full length - 1).
       
    40  *
       
    41  * Client calls:
       
    42  *
       
    43  * SetFullLength(10)
       
    44  * SetVisibleLength(3)
       
    45  * SetPosition(0)
       
    46  *
       
    47  * @lib glxuiutilities.lib
       
    48  *
       
    49  * @author Michael Yip
       
    50  */
       
    51 class CGlxScrollbar : public CBase
       
    52     {
       
    53 public:
       
    54     /**
       
    55      * Two phase constructor
       
    56      *
       
    57      * @param aControl The Alf control
       
    58      * @param aParentLayout The Alf layout that owns this scrollbar
       
    59      */
       
    60     IMPORT_C static CGlxScrollbar* NewL(CAlfControl& aControl, CAlfLayout& aParentLayout);
       
    61 
       
    62     /**
       
    63      * Two phase constructor
       
    64      *
       
    65      * @param aControl The Alf control
       
    66      * @param aParentLayout The Alf layout that owns this scrollbar
       
    67      */
       
    68     IMPORT_C static CGlxScrollbar* NewLC(CAlfControl& aControl, CAlfLayout& aParentLayout);
       
    69 
       
    70     /**
       
    71      * Add an observer to observe scrollbar
       
    72      * Observers are notified if the scrollbar is scrollable
       
    73      *
       
    74      * @param aObserver The observer
       
    75      */
       
    76     IMPORT_C void AddObserverL(MGlxScrollbarObserver* aObserver);
       
    77 
       
    78     /**
       
    79      * Remove an observer
       
    80      *
       
    81      * @param aObserver The observer
       
    82      */
       
    83     IMPORT_C void RemoveObserver(MGlxScrollbarObserver* aObserver);
       
    84 
       
    85     /**
       
    86      * Sets the visible length of the scrollbar
       
    87      *
       
    88      * @param aVisibleLength The visible length
       
    89      */
       
    90     IMPORT_C void SetVisibleLength(TUint aVisibleLength);
       
    91 
       
    92     /**
       
    93      * Sets the full length of the scrollbar
       
    94      *
       
    95      * @param aFullLength The full length
       
    96      * @param aTransitionTime The transition time in milliseconds if any animation is required
       
    97      */
       
    98     IMPORT_C void SetFullLength(TUint aFullLength, TUint aTransitionTime = 0);
       
    99 
       
   100     /**
       
   101      * Sets the position of the first visible row in the full length
       
   102      *
       
   103      * @param aPosition The position
       
   104      * @param aTransitionTime The transition time in milliseconds if any animation is required
       
   105      */
       
   106     IMPORT_C void SetPosition(TUint aPosition, TUint aTransitionTime = 0);
       
   107 
       
   108     /**
       
   109      * Destructor
       
   110      */
       
   111     ~CGlxScrollbar();
       
   112 
       
   113 private:
       
   114     /**
       
   115      * Constructor
       
   116      */
       
   117     CGlxScrollbar();
       
   118 
       
   119     /**
       
   120      * Two phase constructor
       
   121      *
       
   122      * @param aControl The Alf control
       
   123      * @param aParentLayout The Alf layout that owns this scrollbar
       
   124      */
       
   125     void ConstructL(CAlfControl& aControl, CAlfLayout& aParentLayout);
       
   126 
       
   127     /**
       
   128      * Set the textures for the visuals
       
   129      */
       
   130     void SetTexturesL();
       
   131 
       
   132     /**
       
   133      * Set the textures for the visuals in the background layout
       
   134      *
       
   135      * @param aTextureManager The texture manager for creating textures
       
   136      */
       
   137     void SetBackgroundTexturesL(CGlxTextureManager& aTextureManager);
       
   138 
       
   139     /**
       
   140      * Set the textures for the visuals in the thumb layout
       
   141      *
       
   142      * @param aTextureManager The texture manager for creating textures
       
   143      */
       
   144     void SetThumbTexturesL(CGlxTextureManager& aTextureManager);
       
   145 
       
   146     /**
       
   147      * Set the background or thumb layout anchors
       
   148      *
       
   149      * @param aLayout The anchor layout to set the anchors for
       
   150      */
       
   151     void SetAnchors(CAlfAnchorLayout& aLayout);
       
   152 
       
   153     /**
       
   154      * Update the scrollbar
       
   155      *
       
   156      * @param aTransitionTime The transition time in milliseconds if any animation is required
       
   157      */
       
   158     void Update(TUint aTransitionTime = 0);
       
   159 
       
   160     /**
       
   161      * Notify observers if the scrollbar is scrollable
       
   162      */
       
   163     void NotifyObservers();
       
   164 
       
   165 private:
       
   166     /// The Alf layout for the scrollbar
       
   167     /// Ownership passed to parent layout
       
   168     CAlfLayout* iLayout;
       
   169 
       
   170     /// The visible length of the scrollbar
       
   171     TUint iVisibleLength;
       
   172 
       
   173     /// The full length of the scrollbar
       
   174     TUint iFullLength;
       
   175 
       
   176     /// The position of the first visible row in the full length
       
   177     TUint iPosition;
       
   178 
       
   179     /// Observers of the scrollbar
       
   180     RPointerArray<MGlxScrollbarObserver> iObservers;
       
   181     };
       
   182 
       
   183 #endif // C_GLXSCROLLBAR_H