emailuis/emailui/inc/ncsheadercontainer.h
branchRCL_3
changeset 25 3533d4323edc
equal deleted inserted replaced
24:d189ee25cf9d 25:3533d4323edc
       
     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 email header
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef __NCSEMAILHEADERUI_H__
       
    21 #define __NCSEMAILHEADERUI_H__
       
    22 
       
    23 #include <aknlongtapdetector.h>
       
    24 #include <cpbkxremotecontactlookupserviceuicontext.h>
       
    25 
       
    26 #include "FreestyleEmailUi.hrh"
       
    27 #include "ncsaddressinputfield.h"
       
    28 #include "ncsfieldsizeobserver.h"
       
    29 #include "ncsconstants.h"
       
    30 
       
    31 
       
    32 class CFSMailBox;
       
    33 class CNcsAttachmentField;
       
    34 class CNcsEmailAddressObject;
       
    35 class CNcsPopupListBox;
       
    36 class CNcsSubjectField;
       
    37 class CAknPhysics;
       
    38 
       
    39 /**
       
    40 *  CNcsHeaderContainer
       
    41 */
       
    42 class CNcsHeaderContainer : public CCoeControl, public MNcsAddressPopupList
       
    43     {
       
    44 
       
    45 public:
       
    46 
       
    47     /** Initialisation flags. */
       
    48     enum TInitFlags
       
    49         {
       
    50         ECcFieldVisible  = 0x01,
       
    51         EBccFieldVisible = 0x02
       
    52         };
       
    53 
       
    54     /**
       
    55      * Two-phased constructor.
       
    56      * Create a CNcsHeaderContainer object, which will draw itself to aRect
       
    57      * @param aRect The rectangle this view will be drawn to.
       
    58      * @param aMailBox reference to current mailbox item
       
    59      * @param aFlags Initialisation flags.
       
    60      * @return a pointer to the created instance of CNcsHeaderContainer.
       
    61      */
       
    62     static CNcsHeaderContainer* NewL( CCoeControl& aParent,
       
    63         CFSMailBox& aMailBox, TInt aFlags = NULL, CAknPhysics* aPhysics = NULL );
       
    64 
       
    65     /**
       
    66      * ~CNcsHeaderContainer
       
    67      * Destructor
       
    68      */
       
    69     virtual ~CNcsHeaderContainer();
       
    70 
       
    71     void EnableKineticScrollingL(CAknPhysics*  aPhysics);
       
    72     
       
    73 private: // constructor/destructor
       
    74 
       
    75     /**
       
    76     * CNcsHeaderContainer
       
    77     * C++ constructor.
       
    78     * @param aParent Parent control.
       
    79     * @param aMailBox reference to current mailbox item
       
    80     */
       
    81 	CNcsHeaderContainer( CCoeControl& aParent, CFSMailBox& aMailBox, CAknPhysics* aPhysics );
       
    82 	
       
    83 	/**
       
    84 	* ConstructL
       
    85 	* 2nd phase constructor.
       
    86 	*/
       
    87 	void ConstructL( TInt aFlags );
       
    88 
       
    89 public: // function members
       
    90 	
       
    91 	/**
       
    92 	* GetToFieldAddressesL
       
    93 	* Get addresses in TO-field.
       
    94 	* @return Array of addresses.
       
    95 	*/
       
    96 	const RPointerArray<CNcsEmailAddressObject>& GetToFieldAddressesL( 
       
    97         TBool aParseNow = ETrue );
       
    98 
       
    99 	/**
       
   100 	* GetCcFieldAddressesL
       
   101 	* Get addresses in CC-field.
       
   102 	* @return Array of addresses.
       
   103 	*/
       
   104 	const RPointerArray<CNcsEmailAddressObject>& GetCcFieldAddressesL( 
       
   105         TBool aParseNow = ETrue );
       
   106 
       
   107 	/**
       
   108 	* GetBccFieldAddressesL
       
   109 	* Get addresses in BCC-field.
       
   110 	* @return Array of addresses.
       
   111 	*/
       
   112 	const RPointerArray<CNcsEmailAddressObject>& GetBccFieldAddressesL( 
       
   113         TBool aParseNow = ETrue );
       
   114 
       
   115 	/**
       
   116 	* GetSubjectLC
       
   117 	* Get text in SUBJECT-field.
       
   118 	* @return Subject text.
       
   119 	*/
       
   120 	HBufC* GetSubjectLC() const;
       
   121 
       
   122 	/**
       
   123 	* GetToFieldLength
       
   124 	* Get TO-field text length.
       
   125 	* @return Text length.
       
   126 	*/
       
   127 	TInt GetToFieldLength() const;
       
   128 
       
   129 	/**
       
   130 	* GetCcFieldLength
       
   131 	* Get CC-field text length.
       
   132 	* @return Text length.
       
   133 	*/
       
   134 	TInt GetCcFieldLength() const;
       
   135 
       
   136 	/**
       
   137 	* GetBccFieldLength
       
   138 	* Get BCC-field text length.
       
   139 	* @return Text length.
       
   140 	*/
       
   141 	TInt GetBccFieldLength() const;
       
   142 
       
   143 	/**
       
   144 	* GetSubjectFieldLength
       
   145 	* Get SUBJECT-field text length.
       
   146 	* @return Text length.
       
   147 	*/
       
   148 	TInt GetSubjectFieldLength() const;
       
   149 
       
   150 	/**
       
   151 	* GetAttachmentCount
       
   152 	* Get number of attachments.
       
   153 	* @return Attachment count.
       
   154 	*/
       
   155 	TInt GetAttachmentCount() const;
       
   156 
       
   157     /**
       
   158     * HasRemoteAttachments
       
   159     * Tells if the message has one or more remote attachments
       
   160     * @return ETrue if the message has at least one remote attachment.
       
   161     */
       
   162     TBool HasRemoteAttachments() const;
       
   163 
       
   164     /**
       
   165 	* GetToFieldSelectionLength
       
   166 	* Get selected text length in TO-field.
       
   167 	* @return Text length.
       
   168 	*/
       
   169 	TInt GetToFieldSelectionLength() const;
       
   170 
       
   171 	/**
       
   172 	* GetCcFieldSelectionLength
       
   173 	* Get selected text length in CC-field.
       
   174 	* @return Text length.
       
   175 	*/
       
   176 	TInt GetCcFieldSelectionLength() const;
       
   177 
       
   178 	/**
       
   179 	* GetBccFieldSelectionLength
       
   180 	* Get selected text length in BCC-field.
       
   181 	* @return Text length.
       
   182 	*/
       
   183 	TInt GetBccFieldSelectionLength() const;
       
   184 
       
   185 	/**
       
   186 	* GetLookupTextLC
       
   187 	* Get lookup text in focused AIF.
       
   188 	* @return Lookup text.
       
   189 	*/
       
   190 	HBufC* GetLookupTextLC() const;
       
   191 	
       
   192 	/**
       
   193 	* SetToFieldAddressesL
       
   194 	* Set addresses in TO-field.
       
   195 	* @param aAddress Address array.
       
   196 	*/
       
   197 	void SetToFieldAddressesL( 
       
   198         const RPointerArray<CNcsEmailAddressObject>& aAddress );
       
   199 
       
   200 	/**
       
   201 	* SetCcFieldAddressesL
       
   202 	* Set addresses in CC-field.
       
   203 	* @param aAddress Address array.
       
   204 	*/
       
   205 	void SetCcFieldAddressesL( 
       
   206         const RPointerArray<CNcsEmailAddressObject>& aAddress );
       
   207 
       
   208 	void SetBccFieldAddressesL( 
       
   209         const RPointerArray<CNcsEmailAddressObject>& aAddress );
       
   210 
       
   211 	void AppendToFieldAddressesL( 
       
   212         const RPointerArray<CNcsEmailAddressObject>& aAddress );
       
   213 	
       
   214 	void AppendCcFieldAddressesL( 
       
   215         const RPointerArray<CNcsEmailAddressObject>& aAddress );
       
   216 	
       
   217 	void AppendBccFieldAddressesL( 
       
   218         const RPointerArray<CNcsEmailAddressObject>& aAddress );
       
   219 	
       
   220 	void SetSubjectL( const TDesC& aSubject );
       
   221 	
       
   222 	void SetMenuBar( CEikButtonGroupContainer* aMenuBar );
       
   223 	
       
   224     void SetAttachmentLabelTextsLD( CDesCArray* aAttachmentNames, 
       
   225                                     CDesCArray* aAttachmentSizes );
       
   226     TInt FocusedAttachmentLabelIndex();
       
   227     void ShowAttachmentLabelL();
       
   228 	void HideAttachmentLabel();
       
   229 
       
   230 	void SetCcFieldVisibleL( 
       
   231         TBool aVisible, 
       
   232         TDrawNow aDrawNow = EDrawNow, 
       
   233         TBool aFocus = ETrue );
       
   234 
       
   235 	void SetBccFieldVisibleL( 
       
   236         TBool aVisible, 
       
   237         TDrawNow aDrawNow = EDrawNow, 
       
   238         TBool aFocus = ETrue );
       
   239 	
       
   240 	void FixSemicolonInAddressFieldsL();
       
   241 
       
   242 	TBool IsBccFieldVisible() const;
       
   243 
       
   244 	TBool IsCcFieldVisible() const;
       
   245 
       
   246 	TBool IsFocusAttachments() const;
       
   247 
       
   248 	TBool IsFocusTo() const;
       
   249 
       
   250 	TBool IsFocusCc() const;
       
   251 
       
   252 	TBool IsFocusBcc() const;
       
   253 
       
   254 	void IncludeAddressL();
       
   255 
       
   256 	void IncludeAddressL( const CNcsEmailAddressObject& eml );
       
   257 
       
   258 	// Update the field positions arround the anchor
       
   259     void UpdateFieldPosition( CCoeControl* aAnchor );
       
   260 
       
   261 	// Check if the AIF menu should be displayed
       
   262 	TBool NeedsAifMenu() const;
       
   263 
       
   264 	// Get the total number of scrollable lines to update the scroll bar
       
   265 	TInt ScrollableLines() const;
       
   266 
       
   267 	// Get the total line count of all the controls in this container.
       
   268 	TInt LineCount() const;
       
   269 	
       
   270 	// Get the current cursor position relative to the top of the container.
       
   271 	TInt CursorPosition() const;
       
   272 
       
   273     // Get the cursor line number.
       
   274     TInt CursorLineNumber() const;
       
   275 
       
   276 	void HandleControlArrayEventL(
       
   277 		CCoeControlArray::TEvent aEvent,
       
   278 		const CCoeControlArray *aArray,
       
   279 		CCoeControl *aControl,
       
   280 		TInt aControlId );
       
   281 
       
   282 	//Set Middlesoftkey
       
   283 	void SetMskL();
       
   284 	
       
   285 	void HandlePointerEventL( const TPointerEvent& aPointerEvent );
       
   286 	
       
   287 	void OpenPhonebookL();
       
   288 	
       
   289 	void HandleLongTap( const TPoint& aPenEventLocation, 
       
   290 						 const TPoint& aPenEventScreenLocation );
       
   291 
       
   292     TBool NeedsLongTapL( const TPoint& aPenEventLocation );
       
   293 	
       
   294 	// Process a key event
       
   295 	TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
       
   296 
       
   297 	// Delete the selected address from the current AIF
       
   298 	void DeleteSelectionL();
       
   299 	
       
   300 	TInt GetNumChars() const;
       
   301 
       
   302 	void SelectAllToFieldTextL();
       
   303 
       
   304 	void SelectAllCcFieldTextL();
       
   305 
       
   306 	void SelectAllBccFieldTextL();
       
   307 
       
   308 	void SelectAllSubjectFieldTextL();
       
   309 	
       
   310 	void FocusToField();
       
   311 
       
   312 	void FocusAttachmentField();
       
   313 
       
   314     void SetPriority( TMsgPriority aPriority );
       
   315 
       
   316     void SetFollowUp( TBool aFollowUp );
       
   317     
       
   318     TBool AreAddressFieldsEmpty() const;
       
   319     
       
   320     void DoPopupSelectL();
       
   321     
       
   322     TBool IsPopupActive() const;
       
   323 
       
   324 	void ClosePopupContactListL();
       
   325 	
       
   326 	void ShowPopupMenuBarL( TBool aShow );
       
   327 
       
   328 	TInt GetToLineHeight() const;
       
   329 	
       
   330 	TBool IsToFieldEmpty() const;
       
   331 
       
   332 	TBool IsCcFieldEmpty() const;
       
   333 
       
   334 	TBool IsBccFieldEmpty() const;
       
   335 
       
   336     TBool IsSubjectFieldEmpty() const;
       
   337 
       
   338     void HandleDynamicVariantSwitchL();
       
   339 
       
   340     void HandleSkinChangeL();
       
   341 
       
   342     // sets up iSwitchChangeMskOff falg 
       
   343     void SwitchChangeMskOff(TBool aTag);
       
   344     
       
   345     virtual TInt LayoutLineCount() const;
       
   346 
       
   347     TBool IsAddressInputField( const CCoeControl* aControl ) const;
       
   348 
       
   349     TBool IsRemoteSearchInprogress() const;
       
   350     
       
   351     /**
       
   352      * Shows/hides cursor.
       
   353      * 
       
   354      * @param aShow ETrue - shows, EFalse - hides cursor.
       
   355      */
       
   356     void ShowCursor( TBool aShow, TDrawNow aDrawNow = ENoDrawNow );
       
   357 
       
   358     void DoScroll();
       
   359     
       
   360     void SetPhysicsEmulationOngoing( TBool aPhysOngoing );
       
   361     
       
   362 private: // Function members
       
   363 
       
   364 	void FocusChanged(TDrawNow aDrawNow);
       
   365 
       
   366 	void UpdatePopupContactListL( const TDesC& aMatchString, TBool aListAll );
       
   367 
       
   368 	CCoeControl* FindFocused() const;
       
   369 
       
   370 	void Draw( const TRect& aRect ) const;
       
   371 
       
   372 	void DrawAttachmentFocusNow();
       
   373 
       
   374 	TKeyResponse ChangeFocusL( const TKeyEvent& aKeyEvent );
       
   375 
       
   376 	void SizeChanged();
       
   377 
       
   378 	void PositionChanged();
       
   379 
       
   380 	TInt GetTotalHeight() const;
       
   381 
       
   382 	void ChangePositions();
       
   383 
       
   384 	TTypeUid::Ptr MopSupplyObject( TTypeUid aId );
       
   385 
       
   386     TRect CalculatePopupRect();
       
   387 
       
   388     void HandleAttachmentsOpenCommand();
       
   389     
       
   390     /**
       
   391     * Execute Remote Lookup Search.
       
   392     *
       
   393     * @param aExitReason RCL exit reason.
       
   394     * @param aSearchText Search text.
       
   395     * @return Selected email address object.
       
   396     */
       
   397     CNcsEmailAddressObject* ExecuteRemoteSearchL(
       
   398         CPbkxRemoteContactLookupServiceUiContext::TResult::TExitReason& 
       
   399             aExitReason,
       
   400         const TDesC& aSearchText );
       
   401 
       
   402     void ChangeMskCommandL( TInt aLabelResourceId );
       
   403 
       
   404     void CommitFieldL( CCoeControl* aField );
       
   405 
       
   406 private:  //From MAknLongTapDetectorCallBack
       
   407     
       
   408     void HandleLongTapEventL( const TPoint& aPenEventLocation, 
       
   409             const TPoint& aPenEventScreenLocation );
       
   410     
       
   411 private: // Data members
       
   412 
       
   413     /*
       
   414     * Parent window
       
   415     * Not Own
       
   416     */
       
   417     CCoeControl& iParent;
       
   418 
       
   419     MNcsFieldSizeObserver& iFieldSizeObserver;
       
   420     
       
   421     CAknLongTapDetector*      iLongTapDetector;
       
   422 	
       
   423     CEikButtonGroupContainer* iMenuBar;
       
   424     
       
   425     CNcsAddressInputField* iToField;
       
   426 
       
   427     CNcsAddressInputField* iCcField;
       
   428 
       
   429     CNcsAddressInputField* iBccField;
       
   430 
       
   431     CNcsSubjectField* iSubjectField;
       
   432 
       
   433     CNcsAttachmentField* iAttachmentField;
       
   434 
       
   435 	// The attachments count
       
   436     TInt iAttachmentCount;
       
   437 
       
   438 	// Address popup data members
       
   439 	CNcsPopupListBox* iAacListBox;
       
   440 
       
   441 	CFSMailBox& iMailBox;
       
   442 	
       
   443     //flag which disables changes of MSK label if any popup dialog is open
       
   444     TBool iSwitchChangeMskOff;
       
   445 
       
   446     TBool iLongTapEventConsumed;
       
   447     TBool iRALInProgress;
       
   448     
       
   449     // Currently focused control
       
   450     CCoeControl* iFocused;
       
   451 
       
   452     // panning related
       
   453     CAknPhysics* iPhysics;
       
   454     };
       
   455 
       
   456 
       
   457 #endif