mobilemessaging/postcard/postcardinc/PostcardTextDialog.h
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2005 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: PostcardTextDialog  declaration
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef POSTCARDTEXTDIALOG_H 
       
    21 #define POSTCARDTEXTDIALOG_H
       
    22 
       
    23 // INCLUDES
       
    24 #include <AknForm.h>        // for CAknDialog
       
    25 #include <ConeResLoader.h>
       
    26 #include <aknnavide.h>
       
    27 #include <eikrted.h>
       
    28 #include <txtrich.h>
       
    29 #include <eikedwob.h>
       
    30 #include <coecobs.h>
       
    31 
       
    32 #include "Postcard.hrh"
       
    33 
       
    34 // FORWARD DECLARATIONS
       
    35 class CPostcardTextDialogCustomDraw;
       
    36 class CPostcardAppUi;
       
    37 class CPostcardDocument;
       
    38 struct TKeyEvent;
       
    39 
       
    40 // CLASS DECLARATION
       
    41 /**
       
    42 * CPostcardTextDialog dialog class
       
    43 *   The dialog will be automatically destroyed by ExecuteLD.
       
    44 */
       
    45 class CPostcardTextDialog :     public CAknDialog, 
       
    46                                 public MEikEdwinObserver
       
    47     {
       
    48 
       
    49     public: // Constructors and destructor
       
    50 
       
    51         /**
       
    52         * Two-phased constructor.
       
    53         * @return pointer to created CPostcardTextDialog
       
    54         */
       
    55         static CPostcardTextDialog* NewL( 	CPostcardAppUi& aAppUi, 
       
    56         									CPostcardDocument& aDocument,
       
    57         									CPlainText& aText, 
       
    58         									TInt& aRetValue,
       
    59         									TKeyEvent aKeyEvent = TKeyEvent() );
       
    60 
       
    61         /**
       
    62         * Destructor.
       
    63         * Removes the dialog from EikonEnv Stack. Closes
       
    64         * the resource loader. Changes the title back to
       
    65         * the original. Deletes presentation controller
       
    66         * and wrapper.
       
    67         */
       
    68         ~CPostcardTextDialog();
       
    69         
       
    70     public:
       
    71 
       
    72         /**  
       
    73         * @return CAknDialog::RunLD()
       
    74         */
       
    75         TInt ExecLD( );
       
    76 
       
    77         /**
       
    78         * UpdateNavipaneL
       
    79         */
       
    80         void UpdateNavipaneL( TBool aForce );
       
    81 
       
    82         /**
       
    83         * SetCharParaFormat Set character and paragraph formats
       
    84         */
       
    85         void SetCharParaFormat();
       
    86 
       
    87     public: // Functions from base classes
       
    88 
       
    89         /**
       
    90         * From MEikCommandObserver Prosesses menucommands
       
    91         * @param aCommandId - id of the command
       
    92         */
       
    93         void ProcessCommandL( TInt aCommandId );
       
    94 
       
    95         /**
       
    96         * From CCoeControl Handles key events
       
    97         * @param aKeyEvent  - keyevent to be handled
       
    98         * @param aType      - keyeventtype to be handled
       
    99         */
       
   100         TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, 
       
   101                TEventCode aType );
       
   102 
       
   103         /**
       
   104         * HandleResourceChange
       
   105         * If aType is dynamic layout change -> rereads the size of the text field from LAF
       
   106         */ 
       
   107         void HandleResourceChange(TInt aType);
       
   108 
       
   109         /**
       
   110         * from CEikDialog
       
   111         * Constructs Text Editor.
       
   112         * Reads the font from LAF.
       
   113         * Creates scrollbar and updates navipane.
       
   114         */
       
   115         void PreLayoutDynInitL();
       
   116 
       
   117         /**
       
   118         * from CEikDialog
       
   119         * Sets the position of the cursor in the end of the text.
       
   120         * Set the editor as readonly if necessary.
       
   121         */
       
   122         void PostLayoutDynInitL();
       
   123 
       
   124         /**
       
   125          * from MCoeControlObserver
       
   126          */
       
   127         void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEventType);
       
   128 
       
   129     protected:  // Functions from base classes
       
   130 
       
   131         /** 
       
   132         * From CCoeControl
       
   133         */
       
   134         void FocusChanged(TDrawNow aDrawNow);
       
   135 
       
   136         /**
       
   137         * From MEikMenuObserver Initializes items on the menu
       
   138         *
       
   139         * @param aMenuId    Current menu's resource Id
       
   140         * @param aMenuPane  Pointer to menupane
       
   141         */
       
   142         void DynInitMenuPaneL(TInt aMenuId, CEikMenuPane* aMenuPane);
       
   143 
       
   144         /**
       
   145         * From CEikDialog 
       
   146         * Checks if it ok to exit with aButtonId
       
   147         * If it is, takes the text from the text editor
       
   148         * and passes it to AppUi object.
       
   149         * @param aButtonId Id of the 'pressed' button
       
   150         * @return   ETrue if it's OK to exit
       
   151         *           EFalse otherwise
       
   152         */
       
   153         TBool OkToExitL( TInt aButtonId );
       
   154 
       
   155         /** 
       
   156         * From CCoeControl
       
   157         * Draws skin background if available or just clears the background.
       
   158         */
       
   159 		void Draw(const TRect &aRect) const;
       
   160 
       
   161         /** 
       
   162         * If aEventType is EEventTextUpdate, checks the length of the text field
       
   163         * and updates navipane.
       
   164         */
       
   165 		void HandleEdwinEventL(CEikEdwin* aEdwin,TEdwinEvent aEventType);
       
   166 
       
   167     protected:  // New functions
       
   168 
       
   169         /**
       
   170         * DynInitMainMenuL Initializes items on the menu
       
   171         * @param aMenuPane  Pointer to menupane
       
   172         */
       
   173         void DynInitMainMenuL(CEikMenuPane* aMenuPane);
       
   174 
       
   175         /**
       
   176         * DynInitInsertSubMenuL Initializes items on the menu
       
   177         * @param aMenuPane  Pointer to menupane
       
   178         */
       
   179         void DynInitInsertSubMenuL(CEikMenuPane* aMenuPane);
       
   180 
       
   181         /**
       
   182         * DynInitContextMenuL Initializes items on the menu
       
   183         * @param aMenuPane  Pointer to menupane
       
   184         */
       
   185         void DynInitContextMenuL(CEikMenuPane* aMenuPane);
       
   186 
       
   187         /**
       
   188         * IsMainMenuOptionInvisible
       
   189         * Returns true if menuoption aMenuOptionId is invisible in Mainmenu
       
   190         * @param aMenuOptionId  menu option to be checked
       
   191         * @return TBool         True if option is invisible
       
   192         */
       
   193         TBool IsMainMenuOptionInvisible( TInt aMenuOptionId );
       
   194 
       
   195         /**
       
   196         * LaunchHelpL
       
   197         * Calls AppUi object's LaunchHelpL with right context id.
       
   198         */
       
   199         void LaunchHelpL( );
       
   200 
       
   201         
       
   202     private:
       
   203 
       
   204         /**
       
   205         * Default C++ constructor.
       
   206         */
       
   207         CPostcardTextDialog( 	CPostcardAppUi& aAppUi, 
       
   208         						CPostcardDocument& aDocument, 
       
   209         						CPlainText& aText, 
       
   210         						TInt& aRetValue, 
       
   211         						TKeyEvent aKeyEvent  );
       
   212 
       
   213         /**
       
   214         * EPOC constructor
       
   215         */
       
   216         void ConstructL();
       
   217 
       
   218         /**
       
   219         * Focuses itself. Sets cursor visible if necessary.
       
   220         * Adds edwin observer. Activates base class (CCoeControl).
       
   221         * Sets the position of the cursor in the end of the text.
       
   222         * Updates navipane. Simulates a keyevent if such an event
       
   223         * was passed as a parameter in the construction phase.
       
   224         */
       
   225         void ActivateL();
       
   226 
       
   227         /**
       
   228         * From CoeControl.
       
   229         * Returns 1 or 2.
       
   230         */
       
   231         TInt CountComponentControls() const;
       
   232 
       
   233        /**
       
   234         * From CCoeControl.
       
   235         * 1 is text editor.
       
   236         * 2 is possible scrollbar.
       
   237         */
       
   238         CCoeControl* ComponentControl(TInt aIndex) const;
       
   239 
       
   240 
       
   241     private: //New functions
       
   242 
       
   243         /**
       
   244         *    Panic
       
   245         * @param aReason - the reason of the panic
       
   246         */
       
   247         void Panic(TInt aReason);
       
   248 
       
   249         /**
       
   250         * Sets the return parameter iRetValue as Send 
       
   251         * and tries to exit the dialog.
       
   252         */
       
   253 		void SendL( );
       
   254 		
       
   255         /**
       
   256          * Sets the return parameter iRetValue as Forward
       
   257          * and tries to exit the dialog.
       
   258          */
       
   259         void ForwardMessageL( );
       
   260 		
       
   261         /**
       
   262         * Updates the current TMsvEntry and
       
   263         * calls AppUi object's ShowMessageInfoL method.
       
   264         */
       
   265 		void MessageInfoL( );
       
   266 		
       
   267         /**
       
   268         * Calls NotePad's Fetch-API to fetch a note or template and inserts 
       
   269         * it in the position of the cursor. If there's currently
       
   270         * highlighted text, inserts the text in the place of the text.
       
   271         * @param aNote - If ETrue, fetches note, if EFalse, fetches template
       
   272         */
       
   273 		void InsertFromL( TBool aNote );
       
   274 		
       
   275         /**
       
   276         * Checks if the text is exceeded by 1 or more characters
       
   277         * and shows an information note.
       
   278         */
       
   279 		void CheckTextExceedingL( );
       
   280 
       
   281         /**
       
   282         * Sets middle softkey either to empty or to context menu. Empty in viewer
       
   283         * mode and when maximum amount characters inserted.
       
   284         */
       
   285         void SetMiddleSoftkeyL();
       
   286 
       
   287     private: //data
       
   288 
       
   289 		enum PostcardTextFlags 
       
   290 			{
       
   291 			EPostcardTextHelpSupported = 1,
       
   292 			EPostcardTextExceeded = 2
       
   293 			};
       
   294 
       
   295 		CPostcardAppUi& 	iAppUi;
       
   296 		CPostcardDocument& 	iDocument;
       
   297 		CPlainText& 		iOrigText;
       
   298 
       
   299         CEikRichTextEditor*	iTextEditor;    // Richtext editor
       
   300         CPostcardTextDialogCustomDraw* iCustomDraw;  // For drawing lines to editor
       
   301         CAknNavigationDecorator*    iNaviDecorator;
       
   302 
       
   303 		TKeyEvent			iKeyEvent;
       
   304 		
       
   305 		TInt&				iRetValue;
       
   306         TInt            	iTextFlags;
       
   307         TInt				iMaxLen;
       
   308         
       
   309         TInt                iMskResource;
       
   310 
       
   311     };
       
   312 
       
   313 #endif  // POSTCARDTEXTDIALOG_H
       
   314 
       
   315 // End of File