×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    Jan 2005
    Location
    India
    Posts
    6

    Post Listbox creation

    Can anyone let me know the procedure for creating a Simple text list box in UIQ2.1.source code is preferred..

  2. #2
    Super Contributor
    Join Date
    Mar 2004
    Location
    Czech Republic
    Posts
    2,037
    Hi,
    it is very simple and additionally if it will be good programmed it could be used on both UIQ and Avkon ( and Crystal possible:). Remember that the UIQ additionally needs processing pointer events - but is is much nore simply than keyboard.

    You must do 3 steps
    a) provide model - means implement mixin MListBoxModel
    b) programm drawer - derived from CListItemDrawer
    c) program listbox class - derived from CEikListBox

    It is really simply, I cannot put source code here, so look at least on this header file and implement all methods:



    // ---------------------------------------------------------
    // MODEL
    // Encapsulates the data items for the listbox
    // It just wraps access to the view's list of objects
    // ---------------------------------------------------------
    class CExampleListBoxModel: public MListBoxModel
    {
    public:

    ///
    /// C++ constructor.
    ///
    CExampleListBoxModel();

    ///
    /// Destructor.
    ///
    ~CExampleListBoxModel();

    ///
    /// 2nd stage constructor.
    ///
    void ConstructL();

    ///
    /// MListBoxModel - Gets the number of items in the list box.
    ///
    TInt NumberOfItems() const;

    ///
    /// MListBoxModel - Gets an array of strings used by the list box
    ///
    const MDesCArray* MatchableTextArray() const;

    ///
    /// MListBoxModel - Returns pointer to text item array from model
    ///
    MDesCArray* ItemTextArray() const;

    ///
    /// set new MListBoxModel
    ///
    void SetItemTextArrayL( MDesCArray* aItems );
    private:

    ///
    /// Defined as pure virtual for future use - must have blank
    /// implementation...
    ///
    virtual TAny* Reserved_1() { return NULL; };

    private:

    /// text description storage
    CDesCArray* iTexts;
    };

    // ---------------------------------------------------------
    // DRAWER
    // draws images in listbox
    // ---------------------------------------------------------
    class CExampleListBoxItemDrawer: public CListItemDrawer
    {
    public:
    ///
    /// C++ constructor.
    ///
    CExampleListBoxItemDrawer();

    ///
    /// Destructor.
    ///
    ~CExampleListBoxItemDrawer();

    ///
    /// 2nd stage constructor.
    ///
    void ConstructL(const CEikListBox& aOwner);

    ///
    /// CListItemDrawer Draws individual list box items.
    ///
    void DrawActualItem(TInt aItemIndex, const TRect& aActualItemRect,
    TBool aItemIsCurrent, TBool aViewIsEmphasized,
    TBool aViewIsDimmed, TBool aItemIsSelected) const;
    ///
    /// Returns pointer to icon array.
    ///
    CArrayPtr<CGulIcon>* IconArray() const;

    ///
    /// Set icons.
    ///
    void SetIconArrayL(CArrayPtr<CGulIcon>* aIcons);

    ///
    /// Set model.
    ///
    void SetModel(CExampleListBoxModel* aModel);

    private:

    /// icons storage
    CArrayPtr<CGulIcon>* iIcons;

    /// text color
    TRgb iTextColor;

    /// highlight text color
    TRgb iHighlightedTextColor;

    /// highlight background
    TRgb iHighligtedBackground;

    /// model with texts to draw
    CExampleListBoxModel* iModel;

    /// small font
    const CFont* iFont;

    // owner
    const CEikListBox* iOwner;
    };

    // ---------------------------------------------------------
    // LISTBOX
    // ---------------------------------------------------------
    class CExampleListBox: public CEikListBox
    {
    public:

    ///
    /// Epoc way...
    ///
    static CExampleListBox* NewL(const CCoeControl& aParent);

    ///
    /// Returns pointer to item drawer.
    ///
    CExampleListBoxItemDrawer* ItemDrawer() const;

    ///
    /// Returns pointer to model
    ///
    CExampleListBoxModel* Model() const;

    protected:

    ///
    ///
    ///
    virtual void SizeChanged();

    private:

    ///
    /// object construction methods
    ///
    CExampleListBox();

    ///
    /// 2nd constructor.
    ///
    void ConstructL(const CCoeControl& aParent);

    private:

    /// List box has a model (the data)
    CExampleListBoxModel* iGraphicsListBoxModel;

    /// Drawer that does the actual drawing of items.
    CExampleListBoxItemDrawer* iGraphicsListItemDrawer;
    };
    Bye
    STeN

  3. #3
    Registered User
    Join Date
    Jan 2005
    Location
    India
    Posts
    6

    thanx

    Thank you for ur reply..
    Ill try ur method and post my feedback

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×