eiklbx.h

Go to the documentation of this file.
00001 // EIKLBX.H
00002 //
00003 // Copyright (c) 1997-1999 Symbian Ltd.  All rights reserved.
00004 //
00005    
00006 #if !defined(__EIKLBX_H__)
00007 #define __EIKLBX_H__
00008 
00009 //  INCLUDES 
00010 #if !defined(__GDI_H__)
00011 #include <gdi.h>
00012 #endif
00013 
00014 #if !defined(__EIKBCTRL_H__)
00015 #include <eikbctrl.h>
00016 #endif
00017 
00018 #if !defined(__EIKLBO_H__)
00019 #include <eiklbo.h>
00020 #endif
00021 
00022 #if !defined(__EIKSBFRM_H__)
00023 #include <eiksbfrm.h>
00024 #endif
00025 
00026 #if !defined(__EIKLBM_H__)
00027 #include <eiklbm.h>
00028 #endif
00029 
00030 #if !defined(__EIKLBV_H__)
00031 #include <eiklbv.h>
00032 #endif
00033 
00034 #if !defined(__GULBORDR_H__)
00035 #include <gulbordr.h>
00036 #endif
00037 
00038 #if !defined(__EIKLBED_H__)
00039 #include <eiklbed.h>
00040 #endif
00041 
00042 #if !defined(__GULUTIL_H__)
00043 #include <gulutil.h>
00044 #endif
00045 
00046 #if !defined(__LAFPUBLC_H__)
00047 #include <lafpublc.h>
00048 #endif
00049 
00050 //  FORWARD DECLARATIONS
00051 enum TKeyCode;
00052 class RIncrMatcherBase;
00053 class CListItemDrawer;
00054 class CEikScrollBarFrame;
00055 class CEikButtonBase;
00056 class CMatchBuffer;
00057 class CListBoxExt;
00058 class CEikListBox;
00059 
00060 //  CLASS DECLARATION
00061 
00070 class MListBoxItemChangeObserver
00071     {
00072     public:
00078         virtual void ListBoxItemsChanged(CEikListBox* aListBox) = 0;
00079     };
00080 
00081 
00090 class MListBoxSelectionObserver
00091     {
00092     public:
00100         virtual void SelectionModeChanged(CEikListBox* aListBox, TBool aSelectionModeEnabled) = 0;
00101     };
00102 
00103 
00104 // CLASS DECLARATION
00105     
00127 class CEikListBox : public CEikBorderedControl, public MEikScrollBarObserver
00128     {
00129 
00130 public:
00131 
00132     friend class CListBoxExt;
00133 
00134 public:
00135 
00139     enum TFlags
00140         {
00141         
00146         EMultipleSelection          = SLafListBox::EMultipleSelection,
00147         
00153         ENoExtendedSelection        = SLafListBox::ENoExtendedSelection,
00154         
00159         EIncrementalMatching        = SLafListBox::EIncrementalMatching,
00160         
00165         EPopout                     = SLafListBox::EPopout,
00166 
00171         ELeftDownInViewRect         = SLafListBox::ELeftDownInViewRect,
00172         
00177         EItemDoubleClicked          = SLafListBox::EItemDoubleClicked,
00178                 
00184         EKeepModel                  = SLafListBox::EKeepModel,
00185         
00191         EScrollBarSizeExcluded      = SLafListBox::EScrollBarSizeExcluded,
00192 
00196         EStateChanged               = SLafListBox::EStateChanged,
00197 
00202         ECreateOwnWindow            = SLafListBox::ECreateOwnWindow,
00203 
00207         ENoFirstLetterMatching      = SLafListBox::ENoFirstLetterMatching,
00208 
00212         EPaintedSelection           = SLafListBox::EPaintedSelection ,
00213 
00218         ELoopScrolling = 0x1000,
00219 
00223         EEnterMarks = 0x2000,       // Avkon multiselection list
00224 
00229         EShiftEnterMarks = 0x4000,  // Avkon markable list
00230 
00235         EViewerFlag = 0x8000,       // combined the two flags to fit to WORD.
00236 
00241         EPageAtOnceScrolling = 0x8000, // Avkon viewers
00242 
00246         EDisableHighlight = 0x8000,  // Avkon viewers       
00247 
00252         ES60StyleMultiselection     = SLafListBox::ES60StyleMultiselection,   
00253         
00257         ES60StyleMarkable           = SLafListBox::ES60StyleMarkable
00258         };
00259     enum {KEikMaxMatchingBufferLength = 2};
00260 
00264     enum TScrollBarOwnerShip
00265         {
00269         ENotOwnedExternally=0x0000,
00273         EOwnedExternally   =0x0001
00274         };
00275 
00276 protected:
00277 
00281     enum TReasonForFocusLost
00282         { 
00286         EFocusLostToExternalControl, 
00290         EFocusLostToInternalEditor 
00291         };
00292 
00293 public:
00297     IMPORT_C ~CEikListBox();
00298 
00302     IMPORT_C CEikListBox();
00315     IMPORT_C void ConstructL(MListBoxModel* aListBoxModel,
00316                              CListItemDrawer* aListItemDrawer,
00317                              const CCoeControl* aParent,
00318                              TInt aFlags = 0);
00319     
00335     IMPORT_C void ConstructL(MListBoxModel* aListBoxModel,
00336                              CListItemDrawer* aListItemDrawer,
00337                              const CCoeControl* aParent, 
00338                              TGulBorder aBorder, 
00339                              TInt aFlags = 0);
00349     IMPORT_C virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,
00350                                                  TEventCode aType);
00351     
00358     IMPORT_C virtual void HandlePointerEventL(
00359                             const TPointerEvent& aPointerEvent);
00360     
00367     IMPORT_C virtual void SetContainerWindowL(const CCoeControl& aContainer);
00368     
00374     IMPORT_C virtual TSize MinimumSize();
00375     
00382     IMPORT_C virtual void SetDimmed(TBool aDimmed);
00383 
00390     IMPORT_C virtual void HandleScrollEventL(CEikScrollBar* aScrollBar, 
00391                                              TEikScrollEvent aEventType);
00392 
00393     // model/view access functions 
00399     IMPORT_C MListBoxModel* Model() const;
00400 
00406     IMPORT_C CListBoxView* View() const;
00407 
00408     // functions for accessing top/current/bottom item index
00414     IMPORT_C TInt TopItemIndex() const;
00415     
00421     IMPORT_C virtual void SetTopItemIndex(TInt aItemIndex) const;
00422     
00428     IMPORT_C TInt BottomItemIndex() const;
00429     
00435     IMPORT_C TInt CurrentItemIndex() const;   
00436     
00444     IMPORT_C void SetCurrentItemIndex(TInt aItemIndex) const;
00445     
00452     IMPORT_C void SetCurrentItemIndexAndDraw(TInt aItemIndex) const;
00453 
00454     // functions for dealing with the selection state
00460     IMPORT_C const CListBoxView::CSelectionIndexArray* SelectionIndexes() const;
00461     
00468     IMPORT_C void SetSelectionIndexesL(
00469                 CListBoxView::CSelectionIndexArray* aArrayOfSelectionIndexes);
00470     
00474     IMPORT_C void ClearSelection(); 
00475 
00476     // Functions for updating a list box's internal state after its model has
00477     // been updated, all of them will emit item change event to item change
00478     // observers.
00482     IMPORT_C void HandleItemAdditionL();
00483     
00487     IMPORT_C void HandleItemRemovalL();
00488 
00498     IMPORT_C void HandleItemAdditionL(
00499                     CArrayFix<TInt> &aArrayOfNewIndexesAfterAddition);
00500     
00510     IMPORT_C void HandleItemRemovalL(
00511                     CArrayFix<TInt> &aArrayOfOldIndexesBeforeRemoval);
00512     
00516     IMPORT_C void Reset();
00517 
00525     IMPORT_C void AddItemChangeObserverL( MListBoxItemChangeObserver* aObserver );
00534     IMPORT_C TBool RemoveItemChangeObserver( MListBoxItemChangeObserver* aObserver );
00535 
00536     // functions for accessing the item height
00542     IMPORT_C virtual void SetItemHeightL(TInt aHeight);
00543     
00549     IMPORT_C TInt ItemHeight() const;
00550 
00551     // functions for scrollbars
00559     IMPORT_C CEikScrollBarFrame* CreateScrollBarFrameL(TBool aPreAlloc=EFalse);
00560 
00568     IMPORT_C void SetScrollBarFrame(CEikScrollBarFrame* aScrollBarFrame, TScrollBarOwnerShip aOwnerShip);
00569 
00575     IMPORT_C CEikScrollBarFrame* const ScrollBarFrame();
00576 
00580     IMPORT_C virtual void UpdateScrollBarsL();
00581 
00582     // construction support functions
00592     IMPORT_C void CalculatePopoutRect( TInt aTargetItemIndex,
00593                                        TInt aTargetYPos,
00594                                        TRect& aListBoxRect,
00595                                        TInt aMinHeightInNumOfItems = 1 );
00609     IMPORT_C TSize CalcSizeInPixels(TInt aWidthAsNumOfChars, 
00610                                     TInt aHeightAsNumOfItems) const;
00611 
00622     IMPORT_C TInt CalcWidthBasedOnNumOfChars(TInt aNumOfChars) const;
00623     
00633     IMPORT_C TInt CalcHeightBasedOnNumOfItems(TInt aNumOfItems) const;
00634     
00646     IMPORT_C TInt CalcWidthBasedOnRequiredItemWidth(
00647                                 TInt aTextWidthInPixels) const;
00648 
00649     // drawing/scrolling functions
00657     IMPORT_C void DrawItem(TInt aItemIndex) const;
00658 
00664     IMPORT_C void ScrollToMakeItemVisible(TInt aItemIndex) const;
00665 
00671     IMPORT_C void RedrawItem( TInt aItemIndex );
00672 
00673     // observer support
00679     IMPORT_C void SetListBoxObserver(MEikListBoxObserver* aObserver);
00680 
00681     
00688     IMPORT_C TInt VerticalInterItemGap() const;
00689 
00690     // popouts only
00697     IMPORT_C void SetLaunchingButton(CEikButtonBase* aButton);
00698 
00699     // Editing support
00705     IMPORT_C void SetItemEditor(MEikListBoxEditor* aEditor);
00706     
00710     IMPORT_C void ResetItemEditor();
00716     IMPORT_C MEikListBoxEditor* ItemEditor();
00717     
00729     IMPORT_C virtual void EditItemL(TInt aMaxLength);
00730     
00739     IMPORT_C void StopEditingL(TBool aUpdateModel);
00740 
00741     // functions needed for Avkon shortcuts, 
00742     // passing information from one list to another
00743 
00749     IMPORT_C virtual TInt ShortcutValueForNextList();
00750     
00756     IMPORT_C virtual void SetShortcutValueFromPrevList(TInt aValue);
00757 
00758     // pop-up positioning support
00765     IMPORT_C TRect HighlightRect() const;
00766 
00767 public: // from CCoeControl
00768 
00779     IMPORT_C virtual void GetColorUseListL(
00780                         CArrayFix<TCoeColorUse>& aColorUseList) const; 
00781                         // not available before Release 005u
00782     
00792     IMPORT_C virtual void HandleResourceChange(TInt aType);         
00793                 // not available before Release 005u
00794     
00832     IMPORT_C virtual void ActivateL();
00833     
00841     IMPORT_C TCoeInputCapabilities InputCapabilities() const;
00842 
00843 private:
00847     IMPORT_C void* ExtensionInterface( TUid aInterface );
00848 
00849 protected:
00850     // Shortcuts need access to Incremental matching
00851     // The shortcuts will be used inside OfferkeyEventL().
00852     friend class AknListBoxShortCutsImplementation;
00853     // Avkon layout uses SetVerticalMargin, which is protected.
00854     friend class AknListBoxLayouts;
00855 
00870     IMPORT_C virtual void FocusChanged(TDrawNow aDrawNow);
00871     
00890     IMPORT_C virtual void SizeChanged();
00891 
00896     IMPORT_C virtual void HandleViewRectSizeChangeL();
00897     
00907     IMPORT_C virtual TInt CountComponentControls() const;
00908     
00924     IMPORT_C virtual CCoeControl* ComponentControl(TInt aIndex) const;
00925 
00926     // functions that implement first letter and incremental matching
00930     IMPORT_C void CreateMatchBufferL();  
00931 
00935     IMPORT_C void ClearMatchBuffer() const;
00936 
00942     IMPORT_C void MatchTypedCharL(TUint aCode);
00943 
00948     IMPORT_C void UndoLastChar();
00954     IMPORT_C TBool LastCharMatched() const;
00955 
00956     // functions needed for supporting scrollbars
00961     IMPORT_C virtual void UpdateScrollBarThumbs() const;
00962     
00970     IMPORT_C virtual TInt HorizScrollGranularityInPixels() const;
00971     
00980     IMPORT_C virtual TInt HorizontalNudgeValue() const;
00981     
00989     IMPORT_C virtual void AdjustTopItemIndex() const;
00990 
00991     // navigation support functions
01002     IMPORT_C void SimulateArrowKeyEventL(TKeyCode aKeyCode);
01003     
01012     IMPORT_C virtual void HandleLeftArrowKeyL(CListBoxView::TSelectionMode aSelectionMode);
01013     
01022     IMPORT_C virtual void HandleRightArrowKeyL(CListBoxView::TSelectionMode aSelectionMode);
01023 
01024     // construction support functions
01032     IMPORT_C void RestoreCommonListBoxPropertiesL(TResourceReader& aReader); 
01033 
01044     IMPORT_C virtual void ConstructL(const CCoeControl* aParent, TInt aFlags = 0);
01045     
01053     IMPORT_C virtual void CreateViewL();
01054     
01065     IMPORT_C virtual CListBoxView* MakeViewClassInstanceL();
01066     
01073     IMPORT_C void SetViewRectFromClientRect(const TRect& aClientRect);
01074     
01086     IMPORT_C virtual void RestoreClientRectFromViewRect( TRect& aClientRect) const;
01087 
01095     IMPORT_C virtual TInt AdjustRectHeightToWholeNumberOfItems( TRect& aRect) const;
01096 
01097     // accessor for Laf members
01103     IMPORT_C TMargins8 ListBoxMargins() const;
01104 
01105     // various accessors for private data members
01114     IMPORT_C TInt HorizontalMargin() const;
01115     
01125     IMPORT_C TInt VerticalMargin() const;
01126     
01132     IMPORT_C void SetHorizontalMargin(TInt aMargin);
01133     
01139     IMPORT_C void SetVerticalMargin(TInt aMargin);
01140     
01147     IMPORT_C RIncrMatcherBase* MatchBuffer() const;
01148     
01158     IMPORT_C TInt ViewRectHeightAdjustment() const;
01159     
01165     IMPORT_C TRgb BackColor() const;
01166     
01172     IMPORT_C void SetViewRectHeightAdjustment(TInt aAdjustment);
01173 
01174     // misc functions
01175     
01182     IMPORT_C virtual void ReportListBoxEventL( MEikListBoxObserver::TListBoxEvent aEvent );
01183     
01190     IMPORT_C virtual void Draw(const TRect& aRect) const;
01191     
01196     IMPORT_C void ClearMargins() const;
01197     
01205     IMPORT_C virtual void UpdateCurrentItem(TInt aItemIndex) const;
01206     
01216     IMPORT_C virtual void HandleDragEventL(TPoint aPointerPos);
01217     
01224     IMPORT_C TBool ItemExists(TInt aItemIndex) const;
01225     
01241     IMPORT_C void DrawMatcherCursor() const;
01242 
01248     IMPORT_C static TInt InterItemGap();
01249 
01254     IMPORT_C void UpdateViewColors();
01255 
01260     IMPORT_C void UpdateItemDrawerColors();
01261 
01269     IMPORT_C void FireItemChange();
01270 
01271 
01272 protected:      // functions which deal with extension
01281     IMPORT_C void SetReasonForFocusLostL( TReasonForFocusLost aReasonForFocusLost );
01282 
01288     IMPORT_C TReasonForFocusLost ReasonForFocusLostL();
01289 
01296     IMPORT_C TBool IsMatchBuffer() const;
01297 
01303     void CheckCreateExtensionL();
01304 
01314     TBool CheckCreateExtension();
01315 
01320     void CheckCreateBufferL();
01321 
01327     CMatchBuffer* Buffer() const;
01328 
01329 protected:
01335     IMPORT_C void CreateScrollBarFrameLayout(TEikScrollBarFrameLayout& aLayout) const;
01336     
01341     void UpdateMarkUnmarkMSKL() const;
01342 
01343 public:
01347     IMPORT_C TInt EventModifiers();
01348 
01349     /* 
01350     * Returns ETrue if list has ES60StyleMultiselection flag. 
01351     */
01352     IMPORT_C TBool IsMultiselection();
01353 
01366     IMPORT_C CEikScrollBarFrame* CreateScrollBarFrameL(TBool aPreAlloc, TBool aRemote);
01367         
01383     IMPORT_C CEikScrollBarFrame* CreateScrollBarFrameL(TBool aPreAlloc, TBool aRemote, TBool aWindowOwning);
01384 
01395     IMPORT_C void EnableMSKObserver(TBool aEnable);
01396     
01402     void DoShiftMSKMarkingL();
01403 
01410     void InformMSKButtonGroupDeletion();
01411     
01419     IMPORT_C void AddSelectionObserverL( MListBoxSelectionObserver* aObserver );
01420     
01427     IMPORT_C void RemoveSelectionObserver( MListBoxSelectionObserver* aObserver );
01428 
01436     void ChangeSelectionMode(TBool aEnable);
01437     
01438 private:
01439     IMPORT_C virtual void CEikListBox_Reserved(); // listbox use only
01440     void HorizontalScroll(TInt aScrollAmountInPixels);
01441     void DrawItemInView(TInt aItemIndex) const;
01442     void ClearMargins(CWindowGc& aGc) const;
01443     TKeyResponse DoOfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
01444     void UpdateScrollBarColors(CEikScrollBar* aScrollBar);
01445     void UpdateScrollBarsColors();
01446 
01447     void HandleItemRemovalWithoutSelectionsL();
01448  
01449 protected:
01451     TInt iListBoxFlags;
01452     
01454     CListBoxView* iView;
01455     
01457     CListItemDrawer* iItemDrawer;
01458     
01460     MListBoxModel* iModel;
01461     
01463     TInt iItemHeight;   
01464     
01466     CEikScrollBarFrame* iSBFrame;
01467     
01469     TScrollBarOwnerShip iSBFrameOwned;
01470     
01474     TInt iRequiredHeightInNumOfItems;
01475     
01479     CEikButtonBase* iLaunchingButton; // only used by popouts
01480     
01482     MEikListBoxObserver* iListBoxObserver;
01483 
01484 private:
01485 
01486     TRgb iBackColor;
01487 //  TInt iHorizontalMargin;
01488 //  TInt iVerticalMargin;
01489     TMargins8 iMargins ;
01490     CListBoxExt* iListBoxExt;
01491     TInt iViewRectHeightAdjustment;
01492     MEikListBoxEditor* iItemEditor;
01493     TBool* iLbxDestroyed;
01494     TBool iLastCharMatched;
01495     TInt iSpare;
01496     };
01497 
01498 
01499 
01514 class CEikSnakingListBox : public CEikListBox  
01515     {
01516 public:
01520     IMPORT_C CEikSnakingListBox();
01521     
01525     IMPORT_C ~CEikSnakingListBox();
01526     
01539     IMPORT_C virtual CListBoxView* MakeViewClassInstanceL();
01540     
01546     IMPORT_C virtual void SetTopItemIndex(TInt aItemIndex) const;
01547     
01553     IMPORT_C TInt ColumnWidth() const;
01554     
01560     IMPORT_C void SetColumnWidth(TInt aColumnWidth);
01561 
01562 public: //from CCoeControl
01563     
01571     IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
01572 
01573 protected:
01574     
01583     IMPORT_C virtual void HandleViewRectSizeChangeL();
01584 
01593     IMPORT_C virtual void HandleLeftArrowKeyL(
01594                             CListBoxView::TSelectionMode aSelectionMode);
01595     
01604     IMPORT_C virtual void HandleRightArrowKeyL(
01605                             CListBoxView::TSelectionMode aSelectionMode);
01606     
01616     IMPORT_C virtual TInt HorizontalNudgeValue() const;
01617 
01626     IMPORT_C virtual TInt HorizScrollGranularityInPixels() const;
01627 
01635     IMPORT_C virtual void AdjustTopItemIndex() const;
01636 
01646     IMPORT_C virtual void HandleDragEventL(TPoint aPointerPos);
01647 
01659     IMPORT_C virtual void RestoreClientRectFromViewRect(
01660                                                     TRect& aClientRect) const;
01661 
01669     IMPORT_C virtual TInt AdjustRectHeightToWholeNumberOfItems(
01670                                                         TRect& aRect) const;
01671 
01677     IMPORT_C void MoveToNextOrPreviousItemL(TPoint aPoint);
01678 
01679 protected: //from CCoeControl
01680 
01687     IMPORT_C virtual void SizeChanged();
01688     
01699     IMPORT_C virtual void GetColorUseListL(
01700                     CArrayFix<TCoeColorUse>& aColorUseList) const; 
01701                     // not available before Release 005u
01711     IMPORT_C virtual void HandleResourceChange(TInt aType);         
01712                     // not available before Release 005u
01713 
01714 private: // from CCoeControl
01715     IMPORT_C void Reserved_1();
01716     
01717     IMPORT_C void Reserved_2();
01718 
01719 private:
01723     IMPORT_C void* ExtensionInterface( TUid aInterface );
01724 
01725 private:
01726     IMPORT_C virtual void CEikListBox_Reserved(); // listbox use only
01727     };
01728 
01729 // __EIKLBX_H__
01730 #endif

Copyright © Nokia Corporation 2001-2008
Back to top