javauis/lcdui_akn/lcdui/inc/CMIDChoiceGroupItem.h
branchRCL_3
changeset 19 04becd199f91
child 77 7cee158cb8cd
equal deleted inserted replaced
16:f5050f1da672 19:04becd199f91
       
     1 /*
       
     2 * Copyright (c) 2003-2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  CMIDChoiceGroupItem implements the MID Form ChoiceGroup item
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef CMIDCHOICEGROUPITEM_H
       
    19 #define CMIDCHOICEGROUPITEM_H
       
    20 
       
    21 #include <eiktxlbx.h>
       
    22 #include <eiktxlbm.h>
       
    23 #include <eikclb.h>
       
    24 #include <gulicon.h>
       
    25 
       
    26 #include <aknlists.h>
       
    27 
       
    28 #include "CMIDForm.h"
       
    29 #include "CMIDCommand.h"
       
    30 #include "CMIDControlItem.h"
       
    31 // for MMIDChoiceGroupControlObserver interface in class declaration
       
    32 #include "CMIDChoiceGroupControl.h"
       
    33 
       
    34 
       
    35 // Class CMIDChoiceGroupItem
       
    36 NONSHARABLE_CLASS(CMIDChoiceGroupItem) :
       
    37         public CMIDControlItem,
       
    38         public MMIDChoiceGroup,
       
    39         public MMIDChoiceGroupControlObserver
       
    40 {
       
    41 public:
       
    42     /**
       
    43      * Double ctor
       
    44      * @param aMIDEnv Environment
       
    45      * @return CMIDChoiceGroupItem instance
       
    46      *
       
    47      * @since s60
       
    48      */
       
    49     static CMIDChoiceGroupItem* NewL(
       
    50         MMIDEnv& aMIDEnv, const TDesC& aLabel, TInt aType,
       
    51         RArray<TPtrC>& aStringArray, RArray<MMIDImage*>& aImageArray, CMIDUIManager* aUIManager);
       
    52 
       
    53     ~CMIDChoiceGroupItem();
       
    54 
       
    55 private:
       
    56     CMIDChoiceGroupItem(
       
    57         MMIDEnv& aMIDEnv,
       
    58         TInt aType,
       
    59         RArray<TPtrC>& aStringArray,
       
    60         RArray<MMIDImage*>& aImageArray,
       
    61         CMIDUIManager* aUIManager);
       
    62 
       
    63     void ConstructL(const TDesC& aLabel);
       
    64 
       
    65 public:
       
    66 //    void Draw(const TRect& aRect) const;
       
    67     void UpdateCommands();
       
    68 
       
    69 public: // from MMIDChoiceGroup
       
    70     void InsertElementL(TInt aIndex, const TDesC& aText, MMIDImage* aImage);
       
    71     void DeleteElementL(TInt aIndex);
       
    72     void DeleteAllL();
       
    73     void SetElementL(TInt aIndex, const TDesC& aText, MMIDImage* aImage);
       
    74     void SelectElementL(TInt aIndex, TBool aSelected);
       
    75     TBool IsSelected(TInt aIndex);
       
    76     void SetFontL(TInt aIndex, MMIDFont* aFont);
       
    77     void SetFitPolicyL(TInt aFitPolicy);
       
    78 
       
    79 public: // from MMIDItem
       
    80     void SetLabelL(const TDesC& aLabel);
       
    81     void SetLayoutL(TLayout aLayout);
       
    82     void SetPreferredSizeL(const TSize& aSize);
       
    83     TSize PreferredSize() const;
       
    84     TSize MinimumSize() const;
       
    85     void AddCommandL(MMIDCommand* aCommand);
       
    86     void RemoveCommand(MMIDCommand* aCommand);
       
    87     TBool IsSelectable() const
       
    88     {
       
    89         return ETrue;
       
    90     }
       
    91     void SetDefaultCommand(MMIDCommand* aCommand);
       
    92     TBool ProcessCommandL(CMIDCommand* aCommand);
       
    93     void HandleCurrentL(TBool aCurrent);
       
    94 
       
    95 public: // from MMIDComponent
       
    96     void Dispose();
       
    97     inline TType Type() const
       
    98     {
       
    99         return EChoiceGroup;
       
   100     }
       
   101 
       
   102 public: // from CCoeControl
       
   103     void SetContainerWindowL(const CCoeControl& aContainer);
       
   104     TInt CountComponentControls() const;
       
   105     CCoeControl* ComponentControl(TInt aIndex) const;
       
   106     void SizeChanged();
       
   107     TSize MinimumSize();
       
   108     TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType);
       
   109     // Responds to focus change.
       
   110     void FocusChanged(TDrawNow aDrawNow);
       
   111 
       
   112 #ifdef RD_SCALABLE_UI_V2
       
   113     void HandlePointerEventL(const TPointerEvent& aPointerEvent);
       
   114 #endif
       
   115 
       
   116 public: // from CMIDControlItem
       
   117     // Returns a rect that should be partially visible for an Item to have focus
       
   118     virtual TRect FocusableRect();
       
   119     void ResolutionChange(TInt aType);
       
   120     void ColorChange(TInt aType);
       
   121     void RestoreInnerFocus();
       
   122 
       
   123 public: // from MMIDChoiceGroupControlObserver
       
   124     virtual void HandleChoiceGroupControlEventL(
       
   125         CMIDChoiceGroupControl* aControl,
       
   126         TChoiceGroupControlEvent aEvent,
       
   127         TAny* aParam);
       
   128 
       
   129 public: // From CMIDItem
       
   130     // Returns the item's preferred height without the label part
       
   131     TInt ItemPreferredHeightWithoutLabel();
       
   132 
       
   133     // Overridden, because the choice listbox needs to be created
       
   134     // only when adding the item to a form (the listbox very much
       
   135     // likes to have a parent window when created)
       
   136     void ItemAddedToFormL();
       
   137     void ItemRemovedFromForm();
       
   138     void NotifyScrollingCompleted();
       
   139 
       
   140     // from CMIDControlItem
       
   141     void PostFocusTransferEvent(TBool aFocus,CMIDForm::TDirection aDirection);
       
   142 
       
   143 public: // New stuff (for control use mainly)
       
   144     // Retrieves the rect of the form where this item is
       
   145     TRect FormRect();
       
   146     void PostItemStateChangedEventL();
       
   147 
       
   148 #ifdef RD_JAVA_S60_RELEASE_9_2
       
   149 public:
       
   150     void PostPendingUpEventL();
       
   151     TBool LongTapDetected();
       
   152 #endif // RD_JAVA_S60_RELEASE_9_2
       
   153 
       
   154 private:
       
   155     void SafeDrawNow();
       
   156     void CreateChoiceGroupControlL(CCoeControl* aParent);
       
   157     void CalcChildSizes(
       
   158         const TRect& aItemRect,
       
   159         TRect& aLabelRect,
       
   160         TRect& aChoiceRect);
       
   161 
       
   162 private:
       
   163     // Saved parameters
       
   164     MMIDChoiceGroup::TChoiceType iChoiceType;
       
   165     MMIDChoiceGroup::TFitPolicy iFitPolicy;
       
   166 
       
   167     MMIDEnv& iMIDEnv;
       
   168 
       
   169     // The actual control used in this item
       
   170     CMIDChoiceGroupControl* iChoiceGroupControl;
       
   171 
       
   172     CMIDCommand* iSelectCommand;
       
   173     CMIDCommand* iMarkCommand;
       
   174     CMIDCommand* iUnmarkCommand;
       
   175 
       
   176     // Saved initialization array pointers
       
   177     RArray<TPtrC>& iStringArray;
       
   178     RArray<MMIDImage*>& iImageArray;
       
   179 
       
   180 #ifdef RD_JAVA_S60_RELEASE_9_2
       
   181     TBool           iLongTapDetected;
       
   182     TPointerEvent   iPendingUpEvent;
       
   183 #endif // RD_JAVA_S60_RELEASE_9_2
       
   184 };
       
   185 
       
   186 #endif // CMIDCHOICEGROUPITEM_H