javauis/lcdui_akn/lcdui/inc/CMIDChoiceGroupListBox.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 15 Sep 2010 12:05:25 +0300
branchRCL_3
changeset 77 7cee158cb8cd
parent 66 2455ef1f5bbc
child 83 26b2b12093af
permissions -rw-r--r--
Revision: v2.2.13 Kit: 201036

/*
* Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:  The CMIDChoiceGroup listbox
*
*/

#ifndef CMIDCHOICEGROUPLISTBOX_H
#define CMIDCHOICEGROUPLISTBOX_H

#include <lcdui.h>
#include <eikclb.h>
// using CMIDChoiceGroupModel as parameter of ConstructL function
#include "CMIDChoiceGroupModel.h"
// CAknColumnListBox inheritance in declaration
// using API in CMIDChoiceGroupControl
#include <aknlists.h>


#ifdef RD_TACTILE_FEEDBACK
#include <touchfeedback.h>
#endif //RD_TACTILE_FEEDBACK


class CAknsFrameBackgroundControlContext;
class CMIDChoiceGroupControl;

// Shallow frosting around the CAknColumnListBox cake
NONSHARABLE_CLASS(CMIDChoiceGroupListBox) : public CAknColumnListBox
{
public:
    // c'tor
    CMIDChoiceGroupListBox(CMIDChoiceGroupControl* aChoiceControl);

    // d'tor
    ~CMIDChoiceGroupListBox();

    // Construct with model from outside. Just sets the model
    // and calls CAknColumnListBox::ContructL()
    void ConstructL(
        const CCoeControl* aParent,
        TInt aFlags,
        CMIDChoiceGroupModel* aModel);

public:  // from CCoeControl
    // Overridden, because CEikListBox returns EKeyWasConsumed when
    // up is pressed on the first item, or down on last. We need to
    // return not consumed in order to make the form move focus
    // to other items
    TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);

    void SizeChanged();
    void PositionChanged();
    void Draw(const TRect& aRect) const;

    TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
    void HandleResourceChange(TInt aType);

#ifdef RD_SCALABLE_UI_V2
    void HandlePointerEventL(const TPointerEvent& aPointerEvent);
#endif

#ifdef RD_JAVA_S60_RELEASE_9_2
    /**
     * Returns index of ChoiceGroup element, which is the first
     * visible element in ChoiceGroup from top of Form.
     */
    TInt TopVisibleItemIndex();

    /**
     * Fuction sets ESingleClickDisabledHighlight - item drawer flags
     * and reports current highlight element change event
     */
    void SingleClickDisableHighlightL(TBool aDisable);
    void SetHighlight(TBool aVisible);
    TBool GetHighlight();

    void UpdateColors();

#endif // RD_JAVA_S60_RELEASE_9_2

#ifdef RD_TACTILE_FEEDBACK
private:
    MTouchFeedback* iFeedback;
#endif

protected:
    // Overridden to use the CMIDChoiceGroupModel instead of the
    // normal listbox model. Note that this model is owned outside
    // the listbox, and must not be deleted by the box
    virtual void CreateModelL();

private:
    void SetTextColors();

    /**
     * Checks if highlight is needed
     * @param aCurrentSelected - currently selected item
     * @param aKeyEvent
     * @return EFalse when highlight is not needed
     */
    TBool IsHighlightNeeded(TInt aCurrentSelected, const TKeyEvent& aKeyEvent);

#ifdef RD_JAVA_S60_RELEASE_9_2
    /**
     * Fuction calculates index of element, which is the first
     * visible element in ChoiceGroup from top of Form.
     */
    void UpdateTopVisibleItemIndex();

#endif // RD_JAVA_S60_RELEASE_9_2

private:
    CMIDChoiceGroupControl* iChoiceControl;

#ifdef RD_JAVA_S60_RELEASE_9_2
    TBool iUpEventSent;
    TBool iHighlight;
    TInt iTopVisibleItemIndex;
#endif // RD_JAVA_S60_RELEASE_9_2
};


#endif // CMIDCHOICEGROUPLISTBOX_H