javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/inc/swtscrollablebase.h
branchRCL_3
changeset 19 04becd199f91
child 60 6c158198356e
equal deleted inserted replaced
16:f5050f1da672 19: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 SWTSCROLLABLEBASE_H
       
    14 #define SWTSCROLLABLEBASE_H
       
    15 
       
    16 
       
    17 #include <eikscrlb.h>
       
    18 #include <eiksbobs.h>
       
    19 #include <swtlaffacade.h>
       
    20 #include "swtcontrolbase.h"
       
    21 
       
    22 
       
    23 class CSwtScrollBar;
       
    24 
       
    25 
       
    26 /**
       
    27  * ASwtScrollableBase
       
    28  * Base (abstract) class of all scrollable controls
       
    29  * @lib eswt
       
    30  */
       
    31 NONSHARABLE_CLASS(ASwtScrollableBase)
       
    32         : public ASwtControlBase
       
    33         , public MSwtScrollable
       
    34         , public MEikScrollBarObserver
       
    35 {
       
    36 // Own methods
       
    37 protected:
       
    38     /**
       
    39      * Default constructor
       
    40      * @param aDisplay parent display
       
    41      * @param aPeer java peer of this class
       
    42      * @param aParent composite parent
       
    43      * @param aStyle control style
       
    44      */
       
    45     inline ASwtScrollableBase(MSwtDisplay& aDisplay, TSwtPeer aPeer,
       
    46     MSwtComposite* aParent, TInt aStyle);
       
    47 
       
    48     /**
       
    49      * Destructor
       
    50      */
       
    51     inline ~ASwtScrollableBase();
       
    52 
       
    53     /**
       
    54      * Scrollbar frame getter
       
    55      * @return pointer to frame
       
    56      */
       
    57     virtual CEikScrollBarFrame* SbFrame() const =0;
       
    58 
       
    59     /**
       
    60      * Default scrollbar model getter
       
    61      * @return model
       
    62      */
       
    63     inline static TEikScrollBarModel DefaultSbModel(TInt aStyle);
       
    64 
       
    65     /**
       
    66      * Compute the inner rectangle of a scrollbar frame
       
    67      * @param aRect scrollbar frame container rectangle
       
    68      * @return rectangle contained within the scrollbar frame
       
    69      */
       
    70     TRect SbInnerRect(const TRect& aRect) const;
       
    71 
       
    72     /**
       
    73      * Compute the outer rectangle of a scrollbar frame
       
    74      * @param aRect rectangle contained within the scrollbar frame
       
    75      * @return scrollbar frame container rectangle
       
    76      */
       
    77     TRect SbOuterRect(const TRect& aRect) const;
       
    78 
       
    79 // From MSwtScrollable
       
    80 public:
       
    81     MSwtControl* Control();
       
    82     MSwtScrollBar* CreateScrollBarL(TSwtPeer aPeer, TInt aStyle);
       
    83     virtual void SetVisibleScrollBar(TInt aStyle, TBool aVisible);
       
    84     virtual void ScrollBarDestroyed(const MSwtScrollBar* aScrollbar);
       
    85     void ComputeTrim(TRect& aRect) const;
       
    86     TBool HasScrollBars() const;
       
    87 
       
    88 // From ASwtControlBase
       
    89 public:
       
    90     virtual TRect ClientRect() const;
       
    91 
       
    92 // From MEikScrollBarObserver
       
    93 public:
       
    94     virtual void HandleScrollEventL(CEikScrollBar* aScrollBar,
       
    95                                     TEikScrollEvent aEventType);
       
    96 
       
    97 // Data
       
    98 protected:
       
    99     /**
       
   100      * Horizontal scrollbar, may be NULL.
       
   101      * Not own.
       
   102      */
       
   103     CSwtScrollBar* iHScroll;
       
   104 
       
   105     /**
       
   106      * Vertical scrollbar, may be NULL.
       
   107      * Not own.
       
   108      */
       
   109     CSwtScrollBar* iVScroll;
       
   110 };
       
   111 
       
   112 inline ASwtScrollableBase::ASwtScrollableBase(
       
   113     MSwtDisplay& aDisplay,
       
   114     TSwtPeer aPeer,
       
   115     MSwtComposite* aParent,
       
   116     TInt aStyle)
       
   117         : ASwtControlBase(aDisplay, aPeer, aParent, aStyle)
       
   118 {
       
   119 }
       
   120 
       
   121 inline ASwtScrollableBase::~ASwtScrollableBase()
       
   122 {
       
   123     iHScroll = NULL;
       
   124     iVScroll = NULL;
       
   125 }
       
   126 
       
   127 inline TEikScrollBarModel ASwtScrollableBase::DefaultSbModel(TInt aStyle)
       
   128 {
       
   129     TInt thumbPos(CSwtLafFacade::KSwtDefaultScrollBarModelThumbposition);
       
   130 
       
   131     if ((aStyle & KSwtStyleHScroll) && AknLayoutUtils::LayoutMirrored())
       
   132     {
       
   133         thumbPos = Max((CSwtLafFacade::KSwtDefaultScrollBarModelScrollSpan
       
   134                         - CSwtLafFacade::KSwtDefaultScrollBarModelThumbposition
       
   135                         - CSwtLafFacade::KSwtDefaultScrollBarModelThumbSpan), 0);
       
   136     }
       
   137 
       
   138 
       
   139     return TEikScrollBarModel(CSwtLafFacade::KSwtDefaultScrollBarModelScrollSpan,
       
   140                               CSwtLafFacade::KSwtDefaultScrollBarModelThumbSpan,
       
   141                               thumbPos);
       
   142 }
       
   143 
       
   144 #endif // SWTSCROLLABLEBASE_H