williamr@2: /* williamr@2: * Copyright (c) 1997-2006 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: #if !defined(__EIKSCRLB_H__) williamr@2: #define __EIKSCRLB_H__ williamr@2: williamr@2: #if !defined(__EIKBCTRL_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #if !defined(__EIKSBOBS_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #if !defined(__AKNSCBUT_H__) williamr@2: #include williamr@2: #endif williamr@2: williamr@2: #include williamr@2: williamr@2: class CEikCba; williamr@2: class CAknDoubleSpanScrollIndicator; williamr@2: class CEikScrollBarExtensionImpl; williamr@2: class CEikScrollBarExtension; williamr@2: class CAknDoubleSpanScrollBarExtension; williamr@2: williamr@2: const TInt KEikScrollEventFromVBar=0; williamr@2: const TInt KEikScrollEventFromHBar=0x01; williamr@2: const TInt KEikScrollEventBarMask=0x01; williamr@2: williamr@2: // sets all bits in EButtonsXxx range williamr@2: const TInt KButtonPositionMask=KLafScrollBarButtonPositionMask; williamr@2: williamr@2: // sets all bits in determining which components exist williamr@2: const TInt KDisplayComponentsMask=0x1f; williamr@2: williamr@2: williamr@2: /** williamr@2: * Scroll bar models encapsulate the range of integers which a scroll bar can williamr@2: * represent, from zero to n, and the current position of the scroll bar thumb williamr@2: * within that range. williamr@2: * williamr@2: * Supported from Symbian 5.0. williamr@2: */ williamr@2: class TEikScrollBarModel williamr@2: { williamr@2: williamr@2: public: williamr@2: williamr@2: /** williamr@2: * C++ default constructor. Creates, allocates and initialises a new @c williamr@2: * TEikScrollBarModel. williamr@2: */ williamr@2: inline TEikScrollBarModel(); williamr@2: williamr@2: /** williamr@2: * Constructor. Creates, allocates and initialises a new @c williamr@2: * TEikScrollBarModel. williamr@2: * williamr@2: * @param aScrollSpan The span of this model, numbered from zero. williamr@2: * @param aThumbSpan Number of positions spanned by the thumb.In default williamr@2: * this is zero. williamr@2: * @param aThumbPosition Position of the thumb within the model span. In williamr@2: * default this is zero. williamr@2: */ williamr@2: IMPORT_C TEikScrollBarModel(TInt aScrollSpan, williamr@2: TInt aThumbSpan=0, williamr@2: TInt aThumbPosition=0); williamr@2: williamr@2: /** williamr@2: * Tests two models for equality. The two models are the current model and williamr@2: * the model specified by @c aModel. williamr@2: * williamr@2: * @param The model against which the current model is tested. williamr@2: * williamr@2: * @return @c ETrue if the two models are equal. williamr@2: */ williamr@2: IMPORT_C TBool operator==(const TEikScrollBarModel aModel) const; williamr@2: williamr@2: /** williamr@2: * Tests two models for inequality. The two models are the current model williamr@2: * and the model specified by @c aModel. williamr@2: * williamr@2: * @param The model against which the current model is tested. williamr@2: * @return @c ETrue if the two models are not equal. williamr@2: */ williamr@2: inline TBool operator!=(const TEikScrollBarModel aModel) const; williamr@2: williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Tests whether the scroll bar model is useful. Scroll bar models are only williamr@2: * useful if their thumb span is smaller than their entire span. williamr@2: * williamr@2: * @return Whether this scroll bar can be used. williamr@2: */ williamr@2: IMPORT_C TBool ScrollBarUseful() const; williamr@2: williamr@2: /** williamr@2: * Gets the maximum position possible for the low edge of the thumb within williamr@2: * the total span. williamr@2: * williamr@2: * @return Maximum value possible for @c iThumbPosition. williamr@2: */ williamr@2: IMPORT_C TInt MaxThumbPos() const; williamr@2: williamr@2: /** williamr@2: * Ensures that the thumb position remains within its valid range by williamr@2: * altering it if necessary. williamr@2: */ williamr@2: IMPORT_C void CheckBounds(); williamr@2: williamr@2: /** williamr@2: * Type of scroll bar model. The different models store the scrolling williamr@2: * information in different way, so correct model must be used with correct williamr@2: * scrollbar type. williamr@2: */ williamr@2: enum TEikScrollBarModelType williamr@2: { williamr@2: williamr@2: /** This model type is for storing data for the arrowhead scrollbar. */ williamr@2: EEikScrollBarModel = 0x00000000, williamr@2: williamr@2: /** This model type is for storing data for the spanned scrollbar. */ williamr@2: EAknDoubleSpanScrollBarModel = 0x80000000 williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Gets type of scroll bar model which is one of the enum values from @c williamr@2: * TEikScrollBarModelType enum. williamr@2: */ williamr@2: TEikScrollBarModel::TEikScrollBarModelType ScrollBarModelType() const; williamr@2: williamr@2: public: williamr@2: williamr@2: /** Entire range of integers for this model. */ williamr@2: TInt iScrollSpan; williamr@2: williamr@2: /** Range spanned by the thumb. */ williamr@2: TInt iThumbSpan; williamr@2: williamr@2: /** Position of the low edge of the thumb within 0...@c iScrollSpan. */ williamr@2: TInt iThumbPosition; williamr@2: }; williamr@2: williamr@2: inline TEikScrollBarModel::TEikScrollBarModel() {} williamr@2: inline TBool TEikScrollBarModel::operator!=(const TEikScrollBarModel aModel) const { return !(*this==aModel); } williamr@2: williamr@2: williamr@2: // williamr@2: // TAknDoubleSpanScrollBarModel class williamr@2: // williamr@2: // This class is binary compatible with TEikScrollBarModel and can williamr@2: // be used in places where TEikScrollBarModel is used but few restrictions exist: williamr@2: // williamr@2: // - Base class (TEikScrollBarModel) public members must NOT be accessed directly. williamr@2: // - Base class (TEikScrollBarModel) public methods must NOT be called. williamr@2: // williamr@2: // If this model is not supported by the scrollbar system, then values are stored williamr@2: // as in the base class for compatibility resons. See ModelIsSupported()-method williamr@2: // documentation for more information. williamr@2: // williamr@2: class TAknDoubleSpanScrollBarModel : public TEikScrollBarModel williamr@2: { williamr@2: williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Default constructor. williamr@2: */ williamr@2: IMPORT_C TAknDoubleSpanScrollBarModel(); williamr@2: williamr@2: /** williamr@2: * Constructor which converts TEikScrollBarModel into TAknDoubleSpanScrollBarModel. williamr@2: * williamr@2: * @since 2.6 williamr@2: * @param aEikModel a model that will be converted. williamr@2: * williamr@2: * Allowed range for TEikScrollBarModel values is from 0x1FFF7FFF to -0x1FFF7FFF. williamr@2: * Values outside the allowed range will be truncated to max or min value. williamr@2: * Value will be internally stored with 15 bit accuracy, this means williamr@2: * that the actual stored value may differ from the value given as parameter. williamr@2: * williamr@2: * Values will be converted as: williamr@2: * williamr@2: * TEikScrollBarModel TAknDoubleSpanScrollBarModel williamr@2: * ------------------ ---------------------------- williamr@2: * iScrollSpan -> ScrollSpan williamr@2: * iThumbPosition -> FocusPosition williamr@2: * iThumbSpan -> WindowSize williamr@2: * 0 -> FieldPosition williamr@2: * 0 -> FieldSize williamr@2: * williamr@2: * williamr@2: * Values will be internally stored with 15 bit accuracy, this means that the williamr@2: * actual stored value may differ from the value given inside parameter. williamr@2: * williamr@2: */ williamr@2: IMPORT_C TAknDoubleSpanScrollBarModel(const TEikScrollBarModel& aEikModel); williamr@2: williamr@2: williamr@2: /** williamr@2: * Set methods for model attributes. These MUST be used instead of setting williamr@2: * base class model values directly. williamr@2: * williamr@2: * @since 2.6 williamr@2: * @param aValue Value to be stored. Allowed range 0x1FFF7FFF to -0x1FFF7FFF. williamr@2: * Value outside the allowed range will be truncated to max williamr@2: * or min value. Value will be internally stored with williamr@2: * 15 bit accuracy, this means that the actual stored value williamr@2: * may differ from the value given as parameter. williamr@2: * williamr@2: * This inaccuracy means that e.g. following can happen: williamr@2: * TInt value1 = 23456789; williamr@2: * TInt value2 = 0; williamr@2: * williamr@2: * model.SetScrollSpan(value1); williamr@2: * value2 = model.ScrollSpan(); williamr@2: * if (value1 != value2) williamr@2: * { williamr@2: * // we can end up here !!!! williamr@2: * } williamr@2: * williamr@2: */ williamr@2: IMPORT_C void SetScrollSpan(TInt aValue); // Size of the scrolled list. williamr@2: IMPORT_C void SetFocusPosition(TInt aValue); // Position of the current field in the list. williamr@2: IMPORT_C void SetWindowSize(TInt aValue); // Size of the visible part of the list. williamr@2: IMPORT_C void SetFieldSize(TInt aValue); // Size of the current field. (Optional double span) williamr@2: IMPORT_C void SetFieldPosition(TInt aValue); // Position inside the current field. (Optional double span) williamr@2: williamr@2: williamr@2: /** williamr@2: * Get methods for model attributes. These MUST be used instead of getting williamr@2: * base class model values directly. williamr@2: * williamr@2: * @since 2.6 williamr@2: * @return Values from range 0x1FFF7FFF to -0x1FFF7FFF. williamr@2: * Values are internally stored with 15 bit accuracy, this means that williamr@2: * the returned value may differ from the value which was set using the williamr@2: * corresponding set method. Difference can be about 0x3FFF in the high williamr@2: * end of the range. williamr@2: * williamr@2: */ williamr@2: IMPORT_C TInt ScrollSpan() const; // Size of the scrolled list. williamr@2: IMPORT_C TInt FocusPosition() const; // Position of the current field in the list. williamr@2: IMPORT_C TInt WindowSize() const; // Size of the visible part of the list. williamr@2: IMPORT_C TInt FieldSize() const; // Size of the current field. (Optional double span) williamr@2: IMPORT_C TInt FieldPosition() const; // Position inside the current field. (Optional double span) williamr@2: williamr@2: williamr@2: /** williamr@2: * This method can be used to query if this model type is supported by the device. If model williamr@2: * is not supported then this model and the behaviour of ALL methods defaults to TEikScrollBarModel williamr@2: * behaviour with following rules: williamr@2: * williamr@2: * TAknDoubleSpanScrollBarModel TEikScrollBarModel williamr@2: * ---------------------------- ------------------ williamr@2: * ScrollSpan methods -> iScrollSpan williamr@2: * FocusPosition methods -> iThumbPosition williamr@2: * WindowSize methods -> iThumbSize williamr@2: * FieldPosition methods -> N/A williamr@2: * FieldSize methods -> N/A williamr@2: * williamr@2: * @since 2.6 williamr@2: * @return ETrue if this model is supported by the devices scrollbar system. Otherwise EFalse is williamr@2: * returned. williamr@2: * williamr@2: */ williamr@2: static TBool ModelIsSupported(); williamr@2: williamr@2: private: williamr@2: /** williamr@2: * Gets the internal scale value. williamr@2: * williamr@2: * @since 2.6 williamr@2: * @return Internal scaling value. williamr@2: * williamr@2: */ williamr@2: TUint16 Scale() const; williamr@2: williamr@2: /** williamr@2: * Sets the internal scale value. williamr@2: * williamr@2: * @since 2.6 williamr@2: * @param aScale New internal scaling value. williamr@2: * williamr@2: */ williamr@2: void SetScale(TUint16 aScale); williamr@2: williamr@2: private: williamr@2: /** williamr@2: * Get methods for model attributes values without scaling. williamr@2: * williamr@2: * @since 2.6 williamr@2: * @return Stored value without scaling. williamr@2: * williamr@2: */ williamr@2: TInt16 ScrollSpanValue() const; williamr@2: TInt16 FocusPositionValue() const; williamr@2: TInt16 FieldPositionValue() const; williamr@2: TInt16 FieldSizeValue() const; williamr@2: TInt16 WindowSizeValue() const; williamr@2: williamr@2: /** williamr@2: * Set methods for model attributes values without scaling. williamr@2: * williamr@2: * @since 2.6 williamr@2: * @param aValue Value without scaling to be stored. williamr@2: * williamr@2: */ williamr@2: void SetScrollSpanValue(TInt16 aValue); williamr@2: void SetFocusPositionValue(TInt16 aValue); williamr@2: void SetFieldPositionValue(TInt16 aValue); williamr@2: void SetFieldSizeValue(TInt16 aValue); williamr@2: void SetWindowSizeValue(TInt16 aValue); williamr@2: williamr@2: /** williamr@2: * Gets two lowest bytes from TInt and constructs TInt16 from those. williamr@2: * williamr@2: * @since 2.6 williamr@2: * @param aInt Value from which the lowest bytes are extracted. williamr@2: * @return TInt16 constructed from two lowest bytes. williamr@2: */ williamr@2: TInt16 LowBytes(TInt aInt) const; williamr@2: williamr@2: /** williamr@2: * Gets two highest bytes from TInt and constructs TInt16 from those. williamr@2: * williamr@2: * @since 2.6 williamr@2: * @param aInt Value from which the highest bytes are extracted. williamr@2: * @return TInt16 constructed from two highest bytes. williamr@2: */ williamr@2: TInt16 HighBytes(TInt aInt) const; williamr@2: williamr@2: williamr@2: /** williamr@2: * Sets two lowest bytes of TInt. williamr@2: * williamr@2: * @since 2.6 williamr@2: * @param aInt TInt of which the lowest bytes are set. williamr@2: * @param aValue Value for the lowest bytes. williamr@2: */ williamr@2: void SetLowBytes(TInt& aInt, TInt16 aValue); williamr@2: williamr@2: /** williamr@2: * Sets two highest bytes of TInt. williamr@2: * williamr@2: * @since 2.6 williamr@2: * @param aInt TInt of which the highest bytes are set. williamr@2: * @param aValue Value for the highest bytes. williamr@2: */ williamr@2: void SetHighBytes(TInt& aInt, TInt16 aValue); williamr@2: williamr@2: williamr@2: /** williamr@2: * Constructs a scaled TInt16 value from given TInt value. Changes williamr@2: * internal member variable values using ReScale()-method if needed. williamr@2: * williamr@2: * @since 2.6 williamr@2: * @param aNonScaledValue Value which will be changed to scaled one. williamr@2: * @return Scaled value. williamr@2: */ williamr@2: TInt16 PrepareScaledValue(TInt aNonScaledValue); williamr@2: williamr@2: /** williamr@2: * Changes the used scale value and updates all stored attribute values williamr@2: * if needed. williamr@2: * williamr@2: * @since 2.6 williamr@2: * @param aNewScale New value to be used scaling. williamr@2: * williamr@2: */ williamr@2: void ReScale(TUint16 aNewScale); williamr@2: williamr@2: /** williamr@2: * Sets the scrollbar type. williamr@2: * williamr@2: * @since 2.6 williamr@2: * @param aModelType Scrollbar type. Supported types are williamr@2: * EEikScrollBarModel and EAknDoubleSpanScrollBarModel. williamr@2: * williamr@2: */ williamr@2: void SetScrollBarModelType(TEikScrollBarModelType aModelType); williamr@2: williamr@2: /** williamr@2: * Checks if given parameter is between internal min and max values. williamr@2: * williamr@2: * @since 2.6 williamr@2: * @param aValue Value to be checked. williamr@2: * @return Checked value which will be between internal min williamr@2: * and max values. williamr@2: * williamr@2: */ williamr@2: TInt CheckMinMaxValue(TInt aValue); williamr@2: }; williamr@2: williamr@2: williamr@2: // williamr@2: // CEikScrollBar williamr@2: // williamr@2: williamr@2: class CEikScrollThumb; williamr@2: class CEikScrollBarFrame; williamr@2: williamr@2: /** williamr@2: * The CEikScrollBar class implements a scroll bar. Scroll bars are used when williamr@2: * the contents of a view require a greater area than can be physically williamr@2: * displayed. Scroll bars allow a user to move different parts of the content williamr@2: * into the view and to indicate what proportion of the total contents are williamr@2: * visible at any one time. williamr@2: */ williamr@2: class CEikScrollBar : public CEikBorderedControl, public MCoeControlObserver williamr@2: { williamr@2: friend class CEikScrollBarExtension; williamr@2: friend class CAknDoubleSpanScrollBarExtension; williamr@2: williamr@2: public: williamr@2: williamr@2: /** Scroll bar orientation. */ williamr@2: enum TOrientation williamr@2: { williamr@2: /** Scroll bar is oriented vertically. */ williamr@2: EVertical = SLafScrollBar::EVertical, williamr@2: williamr@2: /** Scroll bar is oriented horizontally. */ williamr@2: EHorizontal = SLafScrollBar::EHorizontal williamr@2: }; williamr@2: williamr@2: /** Type of the scroll bar.*/ williamr@2: enum TScrollBarType williamr@2: { williamr@2: /** Normal scrollbar. */ williamr@2: ENormalScrollBar =0x0, williamr@2: williamr@2: /** Used scrollbar type is an old one. (arrows in the CBA-area) */ williamr@2: EArrowHead =0x200, williamr@2: williamr@2: /** williamr@2: * The created scrollbar is the current and commonly used in Series 60 williamr@2: * platform, spanned scrollbar. (scrollable bar on the right side of williamr@2: * the control, like in windows etc.). williamr@2: */ williamr@2: EDoubleSpan =0x400 williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Scroll bar initialisation flags. The default is for the scroll bar williamr@2: * to have both a shaft and a thumb. williamr@2: */ williamr@2: enum TEikScrollBarFlags williamr@2: { williamr@2: /** */ williamr@2: EEikScrollBarDefaultBehaviour = williamr@2: SLafScrollBar::EEikScrollBarDefaultBehaviour, williamr@2: williamr@2: /** Does not display nudge buttons.*/ williamr@2: EEikScrollBarNoNudgeButtons = williamr@2: SLafScrollBar::EEikScrollBarNoNudgeButtons, williamr@2: williamr@2: /** Has buttons which move it a page at a time. */ williamr@2: EEikScrollBarHasPageButtons = williamr@2: SLafScrollBar::EEikScrollBarHasPageButtons, williamr@2: williamr@2: /** Has buttons which move it its entire extent. */ williamr@2: EEikScrollBarHasHomeEndButtons = williamr@2: SLafScrollBar::EEikScrollBarHasHomeEndButtons, williamr@2: williamr@2: /** Central area is empty. */ williamr@2: EEikScrollBarNoShaftOrThumb = williamr@2: SLafScrollBar::EEikScrollBarNoShaftOrThumb, williamr@2: williamr@2: /** Central area has no scroll thumb. */ williamr@2: EEikScrollBarShaftButNoThumb = williamr@2: SLafScrollBar::EEikScrollBarShaftButNoThumb, williamr@2: williamr@2: /** Buttons are placed at the start of the bar. */ williamr@2: EButtonsAtStartOfShaft = williamr@2: SLafScrollBar::EButtonsAtStartOfShaft, williamr@2: williamr@2: /** Buttons are placed at the end of the bar. */ williamr@2: EButtonsAtEndOfShaft = williamr@2: SLafScrollBar::EButtonsAtEndOfShaft, williamr@2: williamr@2: /** williamr@2: * Buttons are placed at either end of the bar @c williamr@2: * (EButtonsAtStartOfShaft | @c EButtonsAtEndOfShaft). williamr@2: */ williamr@2: EButtonsEitherSideOfShaft = williamr@2: SLafScrollBar::EButtonsEitherSideOfShaft, williamr@2: williamr@2: /** williamr@2: * Buttons do not automatically dim when scroll bar is at its maximum williamr@2: * extent. williamr@2: */ williamr@2: ENoAutoDimming = williamr@2: SLafScrollBar::ENoAutoDimming, williamr@2: williamr@2: /** Enable the nudge buttons. */ williamr@2: EEnableNudgeButtons = 0x0200, williamr@2: williamr@2: /** Disable the expanded touch area. */ williamr@2: EDisableExpandedTouchArea = 0x0400 williamr@2: }; williamr@2: williamr@2: /** Type of the scroll extension area.*/ williamr@2: enum TScrollBarExtensionAreaType williamr@2: { williamr@2: /** Normal scrollbar extension area. */ williamr@2: ENormalExpandedTouchArea, williamr@2: williamr@2: /** Scale scrollbar extension area. */ williamr@2: EScaleExpandedTouchArea, williamr@2: williamr@2: /** none scrollbar extension area. */ williamr@2: ENoExpandedTouchArea williamr@2: }; williamr@2: williamr@2: typedef TEikScrollBarFlags TAknScrollBarFlags; williamr@2: williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Destructor. williamr@2: */ williamr@2: IMPORT_C ~CEikScrollBar(); williamr@2: williamr@2: /** williamr@2: * C++ default constructor. williamr@2: */ williamr@2: IMPORT_C CEikScrollBar(); williamr@2: williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Second phase constructor of the scroll bar. williamr@2: * williamr@2: * @param aScrollBarObserver The scroll bar observer which is to be williamr@2: * informed of scroll events by this scroll bar. williamr@2: * @param aParent Parent control for this new scroll bar. williamr@2: * @param aOrientation Orientation of the new scroll bar. williamr@2: * @param aLength Not used. williamr@2: * @param aScrollBarFlags Not used. williamr@2: */ williamr@2: IMPORT_C virtual void ConstructL( williamr@2: MEikScrollBarObserver* aScrollBarObserver, williamr@2: const CCoeControl* aParent, williamr@2: TOrientation aOrientation, williamr@2: TInt aLength, williamr@2: TInt aScrollBarFlags=EEikScrollBarDefaultBehaviour); williamr@2: williamr@2: /** williamr@2: * Not implemented. williamr@2: * williamr@2: * @param aLength Not used. williamr@2: */ williamr@2: IMPORT_C void SetLengthL(TInt aLength); williamr@2: williamr@2: /** williamr@2: * Change the scrollbar model. williamr@2: * williamr@2: * @param aModel The new model to use. williamr@2: */ williamr@2: IMPORT_C void SetModelL(const TEikScrollBarModel* aModel); williamr@2: williamr@2: /** williamr@2: * Change the scrollbar model. williamr@2: * williamr@2: * @param aModel The new model to use. williamr@2: */ williamr@2: IMPORT_C void SetModel(const TEikScrollBarModel* aModel); williamr@2: williamr@2: /** williamr@2: * Change the model at once to avoid a double update of the scroll bar. williamr@2: * williamr@2: * @param aLength Not used. williamr@2: * @param aModel New scroll bar model. williamr@2: */ williamr@2: IMPORT_C void SetLengthAndModelL(TInt aLength, williamr@2: const TEikScrollBarModel* aModel); williamr@2: williamr@2: /** williamr@2: * Not implemented. williamr@2: * williamr@2: * @param aThumbPos Not used. williamr@2: */ williamr@2: IMPORT_C void SetModelThumbPosition(TInt aThumbPos); williamr@2: williamr@2: /** williamr@2: * Not implemented. williamr@2: * williamr@2: * @param aFocusPosition Not used. williamr@2: */ williamr@2: IMPORT_C void SetFocusPosToThumbPos(TInt aFocusPosition); williamr@2: williamr@2: /** williamr@2: * Gets the default width of the scroll bar. williamr@2: * williamr@2: * @return Default scroll bar breadth. williamr@2: */ williamr@2: IMPORT_C static TInt DefaultScrollBarBreadth(); williamr@2: williamr@2: /** williamr@2: * Allows scroll bar observer to be changed also after the construction. williamr@2: * This function is not exported, but the applications can use it via williamr@2: * @c CEikScrollBarFrame::SetScrollBarFrameObserver function. williamr@2: * williamr@2: * @param aScrollBarObserver New observer replacing the previous (if any). williamr@2: */ williamr@2: void SetScrollBarObserver(MEikScrollBarObserver* aScrollBarObserver); williamr@2: williamr@2: /** williamr@2: * Gets the scroll bar model used by this scroll bar. williamr@2: */ williamr@2: inline const TEikScrollBarModel* Model() const; williamr@2: williamr@2: /** williamr@2: * Gets the position within the scroll bar model. This function would williamr@2: * normally be called by an @c MEikScrollBarObserver implementation in williamr@2: * response to a scroll bar event. williamr@2: * williamr@2: * @return Current position within the scroll bar model’s range. williamr@2: */ williamr@2: IMPORT_C TInt ThumbPosition() const; williamr@2: williamr@2: /** williamr@2: * Gets the height of a horizontal scrollbar or width of a vertical williamr@2: * scrollbar. williamr@2: * williamr@2: * @return Scroll bar breadth. williamr@2: */ williamr@2: IMPORT_C TInt ScrollBarBreadth() const; williamr@2: williamr@2: /** williamr@2: * Not implemented. williamr@2: * williamr@2: * @param aScrollBarFlags Not used. williamr@2: * williamr@2: * @return Zero. williamr@2: */ williamr@2: IMPORT_C static TInt MinVisibleLength(const TInt aScrollBarFlags); williamr@2: williamr@2: /** williamr@2: * Not implemented. williamr@2: * williamr@2: * @param aDimmed Not used. williamr@2: */ williamr@2: IMPORT_C void SetDecreaseButtonsDimmed(TBool aDimmed); williamr@2: williamr@2: /** williamr@2: * Not implemented. williamr@2: * williamr@2: * @param aDimmed Not used. williamr@2: */ williamr@2: IMPORT_C void SetIncreaseButtonsDimmed(TBool aDimmed); williamr@2: williamr@2: /** williamr@2: * Not implemented. williamr@2: * williamr@2: * @param aDimmed Not used. williamr@2: */ williamr@2: IMPORT_C void SetAllButtonsDimmed(TBool aDimmed); williamr@2: williamr@2: /** williamr@2: * Gets handle to the controls that draw arrows in the both ends of spanned williamr@2: * scrollbar. These arrows are for pen support to enable exact moving of williamr@2: * the scrollbar with pen. The arrow is tapped with the pen to move the williamr@2: * scrollbar with one step. williamr@2: * williamr@2: * @return Pointer to the increace button. williamr@2: */ williamr@2: inline CAknScrollButton* IncreaseNudgeButton() const; williamr@2: williamr@2: /** williamr@2: * Gets handle to the controls that draw arrows in the both ends of spanned williamr@2: * scrollbar. These arrows are for pen support to enable exact moving of williamr@2: * the scrollbar with pen. The arrow is tapped with the pen to move the williamr@2: * scrollbar with one step. williamr@2: * williamr@2: * @return Pointer to the decreace button. williamr@2: */ williamr@2: inline CAknScrollButton* DecreaseNudgeButton() const; williamr@2: williamr@2: // This function should only be used by CEikCba williamr@2: /** williamr@2: * Sets command button area. This function should only be used by @c williamr@2: * CEikCba. williamr@2: * williamr@2: * @param aCba Command button area. williamr@2: * @panic EEikPanicScrollBarExtensionNotCreated Extension of williamr@2: * the scroll bar not created. williamr@2: */ williamr@2: IMPORT_C void SetContainingCba(CEikCba* aCba); williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl. williamr@2: * williamr@2: * Sets this control as visible or invisible. williamr@2: * williamr@2: * If @c MakeVisible() is used to make a component visible, and the control williamr@2: * captures the pointer (see @c CapturesPointer()), @c MakeVisible() throws williamr@2: * away any pending pointer events for that control. williamr@2: * williamr@2: * @param aVisible @c ETrue to make the control visible, @c EFalse to make williamr@2: * it invisible. williamr@2: */ williamr@2: IMPORT_C void MakeVisible(TBool aVisible); williamr@2: williamr@2: // williamr@2: /** williamr@2: * From @c CCoeControl williamr@2: * williamr@2: * Called by the framework to handle pointer events. williamr@2: * williamr@2: * @param aPointerEvent A pointer event. williamr@2: */ williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: williamr@2: /** williamr@2: * Not implemented. williamr@2: * williamr@2: * @param aType The extension area to use. williamr@2: */ williamr@2: williamr@2: IMPORT_C void SetExtensionAreaType(TScrollBarExtensionAreaType aType); williamr@2: protected: williamr@2: williamr@2: /** williamr@2: * From @c CCoeControl williamr@2: * williamr@2: * Gets the specified scrollbar component. Each component control is williamr@2: * identified by an index, where the index depends on the order the williamr@2: * controls were added: the first is given an index of 0, the next an index williamr@2: * of 1. williamr@2: * williamr@2: * @param aIndex The index of the control to get. williamr@2: * williamr@2: * @return The component control with an index of aIndex. williamr@2: */ williamr@2: IMPORT_C CCoeControl* ComponentControl(TInt aIndex) const; williamr@2: williamr@2: /** williamr@2: * From @cCCoeControl. williamr@2: * williamr@2: * Gets the number of controls contained in this scrollbar. williamr@2: * williamr@2: * @return The number of component controls contained by this scrollbar. williamr@2: */ williamr@2: IMPORT_C TInt CountComponentControls() const; williamr@2: williamr@2: private: // from MCoeControlObserver williamr@2: IMPORT_C virtual void HandleControlEventL(CCoeControl* aControl, williamr@2: TCoeEvent aEventType); williamr@2: private: // virtual - reserved from CCoeControl williamr@2: IMPORT_C virtual void Reserved_2(); williamr@2: private: williamr@2: /** williamr@2: * From CAknControl williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: williamr@2: protected: williamr@2: williamr@2: /** williamr@2: * The scroll bar frame is a control assemblage manager that relates a williamr@2: * control, or control body, to two scroll bars and a corner window. A williamr@2: * corner window is that part of the screen that is common to both the williamr@2: * horizontal, and the vertical elements of a scroll bar. williamr@2: * williamr@2: * This class helps with access to, and set up of, scroll bars and also williamr@2: * with the layout of the scrolled control or control body. A scroll bar williamr@2: * frame is not a control, but it does implement the standard control williamr@2: * composite pattern to manage the assemblage. williamr@2: */ williamr@2: friend class CEikScrollBarFrame; williamr@2: williamr@2: // enums williamr@2: /** williamr@2: * Flags to determine whether there are visible components and whether to williamr@2: * dim the increase, or decrease, buttons. williamr@2: */ williamr@2: enum TPrivateScrollBarFlags williamr@2: { williamr@2: williamr@2: /** There are no visible components in the scroll bar. */ williamr@2: ENoComponentsToDisplay =0x10000, williamr@2: williamr@2: /** Dim the increase buttons. */ williamr@2: EIncreaseButtonsDimmed =0x20000, williamr@2: williamr@2: /** Dim the decrease buttons. */ williamr@2: EDecreaseButtonsDimmed =0x40000 williamr@2: }; williamr@2: williamr@2: /** Determines where on a scroll bar a pointer down event occurred. */ williamr@2: enum TPointerDownOn williamr@2: { williamr@2: /** No pointer down event occurred on the scroll bar. */ williamr@2: ENone, williamr@2: williamr@2: /** A pointer down event occurred on the home button. */ williamr@2: EHomeButton, williamr@2: williamr@2: /** A pointer down event occurred on the decrease page button. */ williamr@2: EDecreasePageButton, williamr@2: williamr@2: /** A pointer down event occurred on the decrease nudge button. */ williamr@2: EDecreaseNudgeButton, williamr@2: williamr@2: /** A pointer down event occurred on the decrease shaft button. */ williamr@2: EDecreaseShaft, williamr@2: williamr@2: /** A pointer down event occurred on the scroll bar thumb. */ williamr@2: EThumb, williamr@2: williamr@2: /** A pointer down event occurred on the increase shaft button. */ williamr@2: EIncreaseShaft, williamr@2: williamr@2: /** A pointer down event occurred on the increase nudge button. */ williamr@2: EIncreaseNudgeButton, williamr@2: williamr@2: /** A pointer down event occurred on the increase page button. */ williamr@2: EIncreasePageButton, williamr@2: williamr@2: /** A pointer down event occurred on the end button. */ williamr@2: EEndButton williamr@2: }; williamr@2: williamr@2: /** Determines whether to redraw the scroll bar shaft. */ williamr@2: enum TShaftRedrawRequired williamr@2: { williamr@2: /** Do not redraw the scroll bar shaft. */ williamr@2: ENoRedrawRequired, williamr@2: williamr@2: /** Redraw the scroll bar shaft. */ williamr@2: ERedrawShaft williamr@2: }; williamr@2: williamr@2: /** Determines which buttons are displayed. */ williamr@2: enum TWhichButtons williamr@2: { williamr@2: /** Display the increase buttons only. */ williamr@2: EIncreaseOnly, williamr@2: williamr@2: /** Display the decrease buttons only. */ williamr@2: EDecreaseOnly, williamr@2: williamr@2: /** Display all buttons. */ williamr@2: EAll williamr@2: }; williamr@2: williamr@2: /** williamr@2: * Encapsulates pointers to the scroll bar buttons. A maximum of three williamr@2: * pairs of buttons are available, you may choose to use only one pair or williamr@2: * two pairs. williamr@2: */ williamr@2: struct SEikScrollBarButtons williamr@2: { williamr@2: /** Pointer to the decrease nudge button. */ williamr@2: CAknScrollButton* iDecreaseNudge; williamr@2: williamr@2: /** Pointer to the increase nudge button. */ williamr@2: CAknScrollButton* iIncreaseNudge; williamr@2: }; williamr@2: williamr@2: williamr@2: private: williamr@2: // construction/destruction williamr@2: IMPORT_C virtual void CreateButtonL(CAknScrollButton*& aButton, williamr@2: CAknScrollButton::TType aType); williamr@2: williamr@2: void SizeChanged(); williamr@2: williamr@2: // set state functions williamr@2: void DoSetModel(const TEikScrollBarModel* aModel); williamr@2: williamr@2: CEikCba* Cba() const; williamr@2: williamr@2: // These functions are for use only be CEikScrollBarFrame (a friend class) williamr@2: void AddExternalFrameL(CEikScrollBarFrame* aFrame); williamr@2: void RemoveExternalFrame(CEikScrollBarFrame* aFrame); williamr@2: williamr@2: void DisconnectExternalFrames(); williamr@2: williamr@2: protected: williamr@2: williamr@2: /** williamr@2: * Allocates and constructs all the required components of the scrollbar. williamr@2: */ williamr@2: void CreateRequiredComponentsL(); williamr@2: williamr@2: /** williamr@2: * Destroys a button. williamr@2: * williamr@2: * @param aButton A button that will be destroyed. williamr@2: */ williamr@2: void DestroyButton(CAknScrollButton*& aButton); williamr@2: williamr@2: /** williamr@2: * Not implemented williamr@2: * williamr@2: * @param aButton Not used. williamr@2: */ williamr@2: IMPORT_C virtual void SetButtonPositionL(CAknScrollButton* aButton); williamr@2: williamr@2: public: williamr@2: williamr@2: /** williamr@2: * Gets the scroll bar type. williamr@2: * williamr@2: * @return Value of the enum @c TScrollBarType. williamr@2: */ williamr@2: TScrollBarType ScrollBarType(); williamr@2: williamr@2: public: williamr@2: williamr@2: /** Not used, but cannot be removed due binary compatibility issues. */ williamr@2: TDblQueLink iSBLink; williamr@2: williamr@2: protected: williamr@2: williamr@2: /** Scroll bar buttons struct. */ williamr@2: SEikScrollBarButtons iButtons; williamr@2: williamr@2: /** Scroll bar orientation. */ williamr@2: TOrientation iOrientation; williamr@2: williamr@2: private: williamr@2: TEikScrollBarModel iModel; williamr@2: williamr@2: protected: williamr@2: williamr@2: /** A pointer to @c CEikScrollBarExtensionImpl class. */ williamr@2: CEikScrollBarExtensionImpl* iExtension; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: * The CEikArrowHeadScrollBar class is a scroll bar which uses only williamr@2: * two small nudge button arrows to scroll up and down. It has no shaft. williamr@2: * It therefore takes up very little space. williamr@2: * williamr@2: * @since ER5U williamr@2: * @ internal williamr@2: * Internal to Symbian williamr@2: * williamr@2: */ williamr@2: class CEikArrowHeadScrollBar : public CEikScrollBar williamr@2: { williamr@2: public: williamr@2: IMPORT_C CEikArrowHeadScrollBar(CCoeControl* aParentWindow); williamr@2: IMPORT_C ~CEikArrowHeadScrollBar(); williamr@2: public: // from CEikScrollBar williamr@2: IMPORT_C void ConstructL(MEikScrollBarObserver* aScrollBarObserver,const CCoeControl* aParent, williamr@2: TOrientation aOrientation,TInt aLength,TInt aScrollBarFlags=EEikScrollBarDefaultBehaviour); williamr@2: public: // From CCoeControl williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: private: // from CEikScrollBar williamr@2: void CreateButtonL(CAknScrollButton*& aButton,CAknScrollButton::TType aType); williamr@2: void SetButtonPositionL(CAknScrollButton* aButton); williamr@2: private: williamr@2: private: williamr@2: /** williamr@2: * From CAknControl williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: private: williamr@2: CCoeControl* iParentControl; williamr@2: TInt iSpare; williamr@2: }; williamr@2: williamr@2: williamr@2: /** williamr@2: * The CAknDoubleSpanScrollBar class is a scroll bar without buttons, williamr@2: * but it has a shaft. Additionally it has in its shaft a double williamr@2: * span feature which means that there can be another thumb inside the thumb williamr@2: * if needed. williamr@2: * williamr@2: * This class uses TAknDoubleSpanScrollBarModel instead of TEikScrollBarModel williamr@2: * as its internal scrollbar model. TAknDoubleSpanScrollBarModel in binary williamr@2: * compatible with TEikScrollBarModel. User must take care that TAknDoubleSpanScrollBarModel williamr@2: * is really used in API calls in places where TEikScrollBarModel is declared. williamr@2: * williamr@2: * @since 2.6 williamr@2: * williamr@2: */ williamr@2: class CAknDoubleSpanScrollBar : public CEikScrollBar williamr@2: { williamr@2: public: williamr@2: IMPORT_C CAknDoubleSpanScrollBar(CCoeControl* aParentWindow); williamr@2: IMPORT_C ~CAknDoubleSpanScrollBar(); williamr@2: williamr@2: /** williamr@2: * Sets fixed layout to scrollbar. If set, then scrollbar size williamr@2: * changes done by the CEikScrollBarFrame class are disabled. williamr@2: * williamr@2: * @since 2.6 williamr@2: * @param aScrollBarRect Scrollbar rectangle. williamr@2: * williamr@2: */ williamr@2: IMPORT_C void SetFixedLayoutRect(TRect aScrollBarRect); williamr@2: williamr@2: /** williamr@2: * Method for constructing the object. williamr@2: * williamr@2: * @since 2.6 williamr@2: * @param aWindowOwning True if scrollbar is to be a window owning control. williamr@2: * @param aScrollBarObserver Same as in CEikScrollBar::ConstructL() williamr@2: * @param aParent Same as in CEikScrollBar::ConstructL() williamr@2: * @param aOrientation Same as in CEikScrollBar::ConstructL() williamr@2: * @param aLength Same as in CEikScrollBar::ConstructL() williamr@2: * @param aScrollBarFlags Same as in CEikScrollBar::ConstructL() williamr@2: * williamr@2: */ williamr@2: IMPORT_C void ConstructL(TBool aWindowOwning, MEikScrollBarObserver* aScrollBarObserver,const CCoeControl* aParent, williamr@2: TOrientation aOrientation,TInt aLength,TInt aScrollBarFlags=EEikScrollBarDefaultBehaviour); williamr@2: williamr@2: /** williamr@2: * Sets scroll popup info text to be shown while dragging with stylus. williamr@2: * Popup is shown until next pointer up event. williamr@2: * KNullDesC parameter can be used to hide popup earlier. williamr@2: * williamr@2: * @since 3.2 williamr@2: * @param aText Text to be shown williamr@2: * williamr@2: */ williamr@2: IMPORT_C void SetScrollPopupInfoTextL( const TDesC& aText ); williamr@2: williamr@2: /** williamr@2: * Gets the fixed layoutrect of the scrollbar. williamr@2: * @since 2.6 williamr@2: * @return Scrollbar rectangle. williamr@2: * williamr@2: */ williamr@2: TRect FixedLayoutRect(); williamr@2: williamr@2: public: // from CEikScrollBar williamr@2: IMPORT_C void ConstructL(MEikScrollBarObserver* aScrollBarObserver,const CCoeControl* aParent, williamr@2: TOrientation aOrientation,TInt aLength,TInt aScrollBarFlags=EEikScrollBarDefaultBehaviour); williamr@2: IMPORT_C void MakeVisible(TBool aVisible); williamr@2: williamr@2: public: // from CCoeControl williamr@2: IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent); williamr@2: williamr@2: protected: // from CCoeControl williamr@2: IMPORT_C CCoeControl* ComponentControl(TInt aIndex) const; williamr@2: IMPORT_C TInt CountComponentControls() const; williamr@2: williamr@2: private: // from CCoeControl williamr@2: IMPORT_C void SizeChanged(); williamr@2: williamr@2: public: williamr@2: williamr@2: TBool DrawBackgroundState(); williamr@2: williamr@2: void DrawBackground(TBool aDrawHorizontal); williamr@2: williamr@4: /** williamr@4: * Resets pressed down highlight so that default highlight is used when williamr@4: * the scrollbar is drawn. williamr@4: * williamr@4: * @since S60 5.2 williamr@4: */ williamr@4: void ResetPressedDownHighlight(); williamr@4: williamr@2: private: williamr@2: /** williamr@2: * From CAknControl williamr@2: */ williamr@2: IMPORT_C void* ExtensionInterface( TUid aInterface ); williamr@2: private: // from CEikScrollBar williamr@2: void CreateButtonL(CAknScrollButton*& aButton,CAknScrollButton::TType aType); williamr@2: void SetButtonPositionL(CAknScrollButton* aButton); williamr@2: williamr@2: /** williamr@2: * Sets scrollbar background transparency as given in the parameter. williamr@2: * williamr@2: * @param aTransparentBackground If ETrue then scrollbar will have transparent background. williamr@2: * @since 2.6 williamr@2: * williamr@2: */ williamr@2: void SetTransparentBackground(TBool aTransparentBackground); williamr@2: williamr@2: /** williamr@2: * Calculates scrollbar's extension area relative to its own position. williamr@2: */ williamr@2: TRect ExtensionArea() const; williamr@2: private: williamr@2: CCoeControl* iParentControl; williamr@2: TInt iSpare; williamr@2: }; williamr@2: williamr@2: williamr@2: // williamr@2: // Inlines williamr@2: // williamr@2: williamr@2: williamr@2: inline const TEikScrollBarModel* CEikScrollBar::Model() const williamr@2: { return &iModel; } williamr@2: williamr@2: inline CAknScrollButton* CEikScrollBar::IncreaseNudgeButton() const williamr@2: { return iButtons.iIncreaseNudge; } williamr@2: williamr@2: inline CAknScrollButton* CEikScrollBar::DecreaseNudgeButton() const williamr@2: { return iButtons.iDecreaseNudge; } williamr@2: williamr@2: williamr@2: #endif