javauis/eswt_akn/org.eclipse.ercp.swt.s60/native/inc/swttablelistbox.h
branchRCL_3
changeset 19 04becd199f91
child 23 98ccebc37403
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 // SwtTableListBox.h
       
    12 
       
    13 #ifndef SWTTABLELISTBOX_H
       
    14 #define SWTTABLELISTBOX_H
       
    15 
       
    16 
       
    17 #include <eiklbo.h>
       
    18 #include <e32std.h>
       
    19 #include <eiktxlbx.h>
       
    20 #include "eswt.h"
       
    21 
       
    22 
       
    23 class MSwtScrollBar;
       
    24 class CSwtTableItemDrawer;
       
    25 class CSwtTable;
       
    26 class CSwtTableListBoxView;
       
    27 class MTouchFeedback;
       
    28 
       
    29 
       
    30 /**
       
    31  *  This class implements a listbox control that is utilised in Table as
       
    32  *  a component control.
       
    33  *  @lib eswt.dll
       
    34  */
       
    35 NONSHARABLE_CLASS(CSwtTableListBox)
       
    36         : public CEikTextListBox
       
    37         , public MEikListBoxObserver
       
    38 {
       
    39 public:
       
    40 
       
    41     /**
       
    42      * Two-phased constructor.
       
    43      * @param aDisplay  The display object.
       
    44      * @param aTable    The parent table.
       
    45      */
       
    46     static CSwtTableListBox* NewL(MSwtDisplay& aDisplay, CSwtTable &aTable);
       
    47 
       
    48     /**
       
    49     * Destructor.
       
    50     */
       
    51     virtual ~CSwtTableListBox();
       
    52 
       
    53     /**
       
    54      * A helper to deselect items at specified indices.
       
    55      * @param aIndices  An array of indices to deselect.
       
    56      * @param aCount    The number of indices in the array.
       
    57      */
       
    58     void DeselectItems(const TInt* aIndices, TInt aCount) const;
       
    59 
       
    60     /**
       
    61      * A helper to deselect a range of items.
       
    62      * @param aStart    The first index in range to deselect.
       
    63      * @param aEnd      The last index in range to deselect.
       
    64      */
       
    65     void DeselectRange(TInt aStart, TInt aEnd);
       
    66 
       
    67     /**
       
    68      * Returns the default font.
       
    69      * @return The default font.
       
    70      */
       
    71     const MSwtFont& GetDefaultFont() const;
       
    72 
       
    73     /**
       
    74      * Returns the bounding rectangle of the specified item.
       
    75      * @param aRowIndex The row index to get.
       
    76      * @return The bounding rectangle of the item.
       
    77      */
       
    78     TRect GetItemRect(TInt aRowIndex) const;
       
    79 
       
    80     /**
       
    81      * Returns the number of selected items.
       
    82      * @return The number of selected items.
       
    83      */
       
    84     TInt GetSelectionCount() const;
       
    85 
       
    86     /**
       
    87      * Selects an item.
       
    88      * @param aIndex    The index of the item to select.
       
    89      * @param aScroll   If the list should scroll to the selected item.
       
    90      */
       
    91     void SelectItemL(TInt aIndex, TBool aScroll) const;
       
    92 
       
    93     /**
       
    94      * A helper to select a range of items.
       
    95      * @param aStart    The first index in range to select.
       
    96      * @param aEnd      The last index in range to select.
       
    97      */
       
    98     void SelectRangeL(TInt aStart, TInt aEnd) const;
       
    99 
       
   100     /**
       
   101      * Select all the items.
       
   102      */
       
   103     void SelectAllL() const;
       
   104 
       
   105     /**
       
   106      * A helper to set the focus to the given index item.
       
   107      * @param aIndex    The index to focus.
       
   108      */
       
   109     void SetFocusIndex(TInt aIndex) const;
       
   110 
       
   111     /**
       
   112      * Scrolls to the first selected item.
       
   113      */
       
   114     void ShowSelection() const;
       
   115 
       
   116     /**
       
   117      * Handling of the key events.
       
   118      * @param aKeyEvent The key event to process.
       
   119      * @param aType     The event code.
       
   120      */
       
   121     void ProcessKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
       
   122 
       
   123     /**
       
   124      * Handles the situation where data size has changed. I.e. the size
       
   125      * of all the content including the data that fits to the view and
       
   126      * the data outside of it.
       
   127      */
       
   128     void HandleDataSizeChangeL();
       
   129 
       
   130     /**
       
   131      * Draws the grid lines.
       
   132      * @param aGc           The gc to use for drawing.
       
   133      * @param aClippingRect The clipping rectangle to use.
       
   134      */
       
   135     void DrawGrid(CWindowGc& aGc, const TRect& aClippingRect) const;
       
   136 
       
   137     /**
       
   138      * Leaving version of the HandleResourceChange.
       
   139      * @param aType The type parameter from HandleResourceChange.
       
   140      */
       
   141     void HandleResourceChangeL(TInt aType);
       
   142 
       
   143     /**
       
   144      * Returns the client rectangle for the listbox.
       
   145      */
       
   146     TRect ClientRect() const;
       
   147 
       
   148     /**
       
   149      * Sets the required height in number of items.
       
   150      * @param aRequiredHeightInNumOfItems The value to set.
       
   151      */
       
   152     void SetRequiredHeightInNumOfItems(const TInt& aRequiredHeightInNumOfItems);
       
   153 
       
   154     /**
       
   155      * Gets the item drawer for the listbox.
       
   156      * @return The item drawer.
       
   157      */
       
   158     CSwtTableItemDrawer* TableItemDrawer() const;
       
   159 
       
   160     /**
       
   161      * Gets the view for the listbox.
       
   162      * @return The view.
       
   163      */
       
   164     CSwtTableListBoxView* TableView() const;
       
   165 
       
   166     /**
       
   167      * A helper to set the default font to the one used by the item drawer.
       
   168      */
       
   169     void ResetDefaultFontFromItemDrawerL();
       
   170 
       
   171     /**
       
   172      * Gets the font for the currently active layout.
       
   173      * @return The font.
       
   174      */
       
   175     const CFont* LayoutFont();
       
   176 
       
   177     /**
       
   178      * Sets the scrollbar extents to invalid values to make sure it gets updated.
       
   179      */
       
   180     void InvalidateScrollBars();
       
   181 
       
   182     /**
       
   183      * Handles addition of an item in a way that doesn't cause a window server
       
   184      * redraw.
       
   185      */
       
   186     void HandleItemAdditionL();
       
   187 
       
   188     /**
       
   189      * Does the scrollbar update unless Redraw( false ) has been called.
       
   190      */
       
   191     void UpdateScrollBarsL();
       
   192 
       
   193     /**
       
   194      * Tactile feedback setter needed by the drawer.
       
   195      */
       
   196     void SetTouchFeedbackRect(const TRect& aRect) const;
       
   197 
       
   198 // From CCoeControl
       
   199 
       
   200     void MakeVisible(TBool aVisible);
       
   201     void SetDimmed(TBool aDimmed);
       
   202     void FocusChanged(TDrawNow aDrawNow);
       
   203     void HandlePointerEventL(const TPointerEvent& aPointerEvent);
       
   204 
       
   205 // From CEikListBox
       
   206 
       
   207     void HandleViewRectSizeChangeL();
       
   208     void SetItemHeightL(TInt aHeight);
       
   209     void SetTopItemIndex(TInt aItemIndex) const;
       
   210     void UpdateCurrentItem(TInt aItemIndex) const;
       
   211     void HandleScrollEventL(CEikScrollBar* aScrollBar, TEikScrollEvent aEventType);
       
   212 
       
   213 // From MEikListBoxObserver
       
   214 public:
       
   215     void HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType);
       
   216 
       
   217 protected:
       
   218 
       
   219     /**
       
   220      * Creates the scrollbar frame.
       
   221      * @return The scrollbar frame.
       
   222      */
       
   223     CEikScrollBarFrame* CreateScrollBarFrameL();
       
   224 
       
   225 // From CCoeControl
       
   226 
       
   227     void Draw(const TRect& aRect) const;
       
   228     void PositionChanged();
       
   229     void SizeChanged();
       
   230     void HandleResourceChange(TInt aType);
       
   231 
       
   232 // from base CEikTextListBox
       
   233 
       
   234     void CreateItemDrawerL();
       
   235 
       
   236 // from base CEikListBox
       
   237 
       
   238     CListBoxView* MakeViewClassInstanceL();
       
   239 
       
   240 private:
       
   241 
       
   242     /**
       
   243      * The constructor.
       
   244      * @param aDisplay  The display object.
       
   245      * @param aTable    The parent table.
       
   246      */
       
   247     CSwtTableListBox(MSwtDisplay& aDisplay, CSwtTable &aTable);
       
   248 
       
   249     /**
       
   250      * 2nd phase constructor.
       
   251      */
       
   252     void ConstructL();
       
   253 
       
   254     TInt HorizontalScrollPixelsPerArrowEvent();
       
   255     TInt HorizontalScrollPixelsPerPageEvent();
       
   256 
       
   257 private: // data
       
   258 
       
   259     /**
       
   260      * The default font.
       
   261      * Not own.
       
   262      */
       
   263     MSwtFont* iDefaultFont;
       
   264 
       
   265     /**
       
   266      * The Selection array before a key event, for multiselection only.
       
   267      * Own.
       
   268      */
       
   269     CArrayFix<TInt>* iOldSelectionArray;
       
   270 
       
   271     /**
       
   272      * The display object.
       
   273      */
       
   274     MSwtDisplay& iDisplay;
       
   275 
       
   276     /**
       
   277      * The parent table.
       
   278      */
       
   279     CSwtTable& iTable;
       
   280 
       
   281     /**
       
   282      * Feedback instance.
       
   283      * Not own.
       
   284      */
       
   285     MTouchFeedback* iFeedback;
       
   286 
       
   287     /**
       
   288      * Deliver all pointer event to the scrollbar when this on.
       
   289      */
       
   290     TBool iVScrollBarGrabsPointerEvents;
       
   291     TBool iHScrollBarGrabsPointerEvents;
       
   292 
       
   293     /**
       
   294      * Stores last known focus index. Use only during paint and key handlers.
       
   295      */
       
   296     TInt iPrevFocusIndex;
       
   297     
       
   298     /**
       
   299      * Used to implement horizontal panning.
       
   300      */
       
   301     TPoint iDragPos;
       
   302 };
       
   303 
       
   304 #endif // SWTTABLELISTBOX_H