emailuis/emailui/inc/ncsaddressinputfield.h
changeset 0 8466d47a6819
child 17 8592a65ad3fb
equal deleted inserted replaced
-1:000000000000 0:8466d47a6819
       
     1 /*
       
     2 * Copyright (c) 2007 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:  Container class for compose view
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CNCSADDRESSINPUTFIELD_H
       
    21 #define CNCSADDRESSINPUTFIELD_H
       
    22 
       
    23 
       
    24 // INCLUDES
       
    25 #include <aknview.h>
       
    26 #include <AknDef.h>
       
    27 //<cmail>
       
    28 #include <eikedwob.h>
       
    29 //</cmail>
       
    30 #include "ncscontrol.h"
       
    31 
       
    32 //<cmail>  Temporary hardcoded layout values
       
    33 //Horizontal values
       
    34 const TInt KButtonXa = 5;
       
    35 const TInt KButtonXb = 80;
       
    36 const TInt KTxtFieldXa = KButtonXb + 7;
       
    37 const TInt KTxtFieldXb = 445;
       
    38 
       
    39 //To-field
       
    40 const TInt KToAy = 5;
       
    41 const TInt KToBy = KToAy + 45;
       
    42 const TInt KToFieldAy = 5;
       
    43 const TInt KToFieldBy = KToFieldAy + 45;
       
    44 
       
    45 //Cc-field
       
    46 const TInt KCcAy = KToBy + 7;
       
    47 const TInt KCcBy = KCcAy + 45;
       
    48 const TInt KCcFieldAy = KToFieldBy + 7;
       
    49 const TInt KCcFieldBy = KCcFieldAy + 45;
       
    50 
       
    51 //Bcc-field
       
    52 const TInt KBccAy = KCcBy + 7;
       
    53 const TInt KBccBy = KBccAy + 45;
       
    54 const TInt KBccFieldAy = KCcFieldBy + 7;
       
    55 const TInt KBccFieldBy = KBccFieldAy + 45;
       
    56 
       
    57 //Subject field
       
    58 const TInt KSubjectLblRectAy = KBccBy + 7;
       
    59 const TInt KSubjectLblRectBy = KSubjectLblRectAy + 45;
       
    60 const TInt KSubjectFieldRectAy = KBccFieldBy + 7;
       
    61 const TInt KSubjectFieldRectBy = KSubjectFieldRectAy + 45;
       
    62 
       
    63 //A konst for empty return values
       
    64 _LIT( KEmptyReturnValue, "" );
       
    65 //</cmail>
       
    66 
       
    67 class CEikImage;
       
    68 class CAknButton;
       
    69 class CNcsAifEditor;
       
    70 class CNcsEmailAddressObject;
       
    71 class CNcsHeaderContainer;
       
    72 
       
    73 
       
    74 /**
       
    75 *  CNcsAddressInputField container control class.
       
    76 */
       
    77 class MNcsAddressPopupList
       
    78     {
       
    79 public:
       
    80     virtual void UpdatePopupContactListL( const TDesC& aMatchString, TBool iListAll ) = 0;
       
    81 	virtual void ClosePopupContactListL() = 0;
       
    82     };
       
    83 
       
    84 
       
    85 /**
       
    86 *  CNcsAddressInputField container control class.
       
    87 */
       
    88 class CNcsAddressInputField: public CCoeControl, public MEikEdwinSizeObserver,
       
    89                              public MNcsControl, public MCoeControlObserver
       
    90     {
       
    91 public: // enum
       
    92     
       
    93     enum TNcsInputFieldType
       
    94         {
       
    95         EInputFieldTo,
       
    96         EInputFieldCc,
       
    97         EInputFieldBcc
       
    98         };
       
    99     
       
   100 public: // Constructors and destructor
       
   101 
       
   102         /**
       
   103         * NewL
       
   104         * Create a CNcsAddressInputField object, which will draw itself to aRect
       
   105         */
       
   106     static CNcsAddressInputField* NewL( 
       
   107         TInt aLabelId,
       
   108         TNcsInputFieldType aFieldType,
       
   109         MNcsFieldSizeObserver* aSizeObserver,
       
   110         MNcsAddressPopupList* aAddressPopupList,
       
   111         CNcsHeaderContainer* aParentControl );
       
   112         
       
   113     /**
       
   114     * ~CNcsAddressInputField
       
   115     * Destructor
       
   116     */
       
   117     virtual ~CNcsAddressInputField();
       
   118 
       
   119 public: // new functions
       
   120     
       
   121     TInt MinimumHeight() const;
       
   122         
       
   123     void SetAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddress );
       
   124         
       
   125     const RPointerArray<CNcsEmailAddressObject>& GetAddressesL( TBool aParseNow=ETrue );
       
   126         
       
   127     void GetLineRectL( TRect& aLineRect ) const;
       
   128         
       
   129     void SetMaxLabelLength( TInt aMaxLength );
       
   130         
       
   131     TInt GetMinLabelLength() const;
       
   132         
       
   133     void AddAddressL( const CNcsEmailAddressObject& aAddress ); 
       
   134         
       
   135     void AddAddressL( const TDesC& aDisplayName, const TDesC& aEmail );   
       
   136                     
       
   137     void AddAddressL( const TDesC& aEmail );
       
   138         
       
   139     void AppendAddressesL( const RPointerArray<CNcsEmailAddressObject>& aAddress );
       
   140         
       
   141     CEikEdwin* TextEditor() const;
       
   142 
       
   143     HBufC* GetLookupTextLC() const;
       
   144 
       
   145     const CNcsEmailAddressObject* EmailAddressObjectBySelection() const;
       
   146 		
       
   147     void SelectAllTextL();
       
   148 		
       
   149     void SetTextColorL( TLogicalRgb aColor );
       
   150 
       
   151     CNcsEditor* Editor() const;
       
   152         
       
   153     TBool IsEmpty() const;
       
   154 
       
   155 // <cmail> S60 Skin support
       
   156     void SetLabelTextColorL (TRgb aColor);
       
   157     
       
   158     void FixSemicolonAtTheEndL();
       
   159 // </cmail>
       
   160 
       
   161 public: // from CoeControl
       
   162     
       
   163     /**
       
   164     * SetContainerWinowL
       
   165     * Set the cotainer window this control should raw in
       
   166     * @since S60 v3.0
       
   167     * @param aContainer The window continer that owns this control
       
   168     */
       
   169     void SetContainerWindowL(const CCoeControl& aContainer);
       
   170     
       
   171     /**
       
   172     * Draw
       
   173     * Draw this CNcsAddressInputField to the screen.
       
   174     * @since S60 v3.0
       
   175     * @param aRect the rectangle of this view that needs updating
       
   176     */
       
   177     void Draw( const TRect& aRect ) const;
       
   178         
       
   179     void SizeChanged();
       
   180     
       
   181 	void PositionChanged();
       
   182 
       
   183     //<cmail>
       
   184     void HandlePointerEventL( const TPointerEvent& aPointerEvent );
       
   185     //</cmail>
       
   186     
       
   187     TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
       
   188         
       
   189     void FocusChanged(TDrawNow aDrawNow);
       
   190 
       
   191     void HandleResourceChange( TInt aType );
       
   192         
       
   193 public: // from MEikEdwinSizeObserver
       
   194         
       
   195     TBool HandleEdwinSizeEventL( CEikEdwin* aEdwin, TEdwinSizeEvent aEventType, TSize aDesirableEdwinSize );
       
   196         
       
   197 public: // from MNcsControl
       
   198 
       
   199     virtual TInt LineCount() const;
       
   200 
       
   201     virtual TInt ScrollableLines() const;
       
   202 
       
   203     virtual TInt GetNumChars() const;
       
   204 
       
   205     virtual TInt CursorLineNumber() const;
       
   206 
       
   207     virtual TInt CursorPosition() const;
       
   208 
       
   209     virtual void Reposition(TPoint& aPt, TInt aWidth);
       
   210 
       
   211     virtual const TDesC& GetLabelText() const;
       
   212 
       
   213     // <cmail> Platform layout change       
       
   214     TInt LayoutLineCount() const;
       
   215     // </cmail> Platform layout change
       
   216 
       
   217 //<cmail>
       
   218 private:
       
   219     
       
   220     void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType );
       
   221 //</cmail>
       
   222 private: // methods
       
   223     
       
   224     CNcsAddressInputField( 
       
   225         TNcsInputFieldType aFieldType,
       
   226         MNcsFieldSizeObserver* aSizeObserver,
       
   227         MNcsAddressPopupList* aAddressPopupList,
       
   228         CNcsHeaderContainer* aParentControl );
       
   229         
       
   230     void ConstructL( TInt aLabelTextId );
       
   231     
       
   232     void UpdateFontSize();
       
   233     
       
   234     //<cmail>
       
   235     void CreateControlsL( const TDesC& aControlText );
       
   236     
       
   237     void LayoutTouch();
       
   238     
       
   239     void LayoutNonTouch();  
       
   240     //</cmail>
       
   241 
       
   242 private: // data
       
   243     	
       
   244     CNcsHeaderContainer* iParentControl; // not owned
       
   245     
       
   246     MNcsAddressPopupList* iAddressPopupList;
       
   247     
       
   248     /*
       
   249     * text field
       
   250     * Own
       
   251     */
       
   252     CNcsLabel* iLabel;
       
   253     
       
   254 // <cmail> Platform layout changes
       
   255     const CFont* iFont; // not owned, needs to be released in the end
       
   256     
       
   257     CAknButton* iButton;
       
   258 // </cmail> Platform layout changes   
       
   259     /*
       
   260     * text field
       
   261     * Own
       
   262     */
       
   263     CNcsAifEditor* iTextEditor;
       
   264         
       
   265     TNcsInputFieldType iFieldType;
       
   266         
       
   267     TBool iFocusChanged;
       
   268         
       
   269     TInt iEditorMinimumHeight;
       
   270     
       
   271 // <cmail> Platform layout changes
       
   272     TInt iEditorLineCount;
       
   273 // </cmail> Platform layout changes
       
   274        
       
   275     TInt iMaximumLabelLength;
       
   276         
       
   277     RTimer iPopupTimer;
       
   278         
       
   279     TRgb iBorderColor;
       
   280     
       
   281     TRgb iBgColor;
       
   282     
       
   283     // for keeping buttons in view while scrolling
       
   284     TPoint iOriginalFieldPos;
       
   285     TPoint iOriginalButtonPos;
       
   286     };
       
   287 	
       
   288 #endif // CNCSADDRESSINPUTFIELD_H