notepad/notepad1/AppSrc/NpdAppUi.cpp
changeset 0 f979ecb2b13e
equal deleted inserted replaced
-1:000000000000 0:f979ecb2b13e
       
     1 /*
       
     2 * Copyright (c) 2002 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:  Implementation of Notepad Application UI class.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <avkon.hrh>
       
    22 #include <NpdLib.rsg>
       
    23 #include <NpdApi.h>
       
    24 #include "NpdListDialog.h"
       
    25 #include "NpdAppUi.h"
       
    26 
       
    27 //UID of PinbMdl
       
    28 const TInt KUidApaMessagePinboardValue(0x1000590C);
       
    29 
       
    30 // ============================ MEMBER FUNCTIONS ===============================
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CNotepadAppUi::ConstructL
       
    34 // Initialize iApi and iDialog.
       
    35 // non-waiting CNotepadListDialog starts.
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 void CNotepadAppUi::ConstructL()
       
    39     {
       
    40 
       
    41     BaseConstructL(EAknEnableSkin | EAknEnableMSK | EAknSingleClickCompatible);
       
    42 
       
    43     iApi = CNotepadApi::NewL();
       
    44 
       
    45     iDialog = CNotepadListDialog::NewL(R_NOTEPAD_LIST_DIALOG,
       
    46         REINTERPRET_CAST( CEikDialog**, &iDialog ) );
       
    47     iDialog->SetMopParent(this);
       
    48     iDialog->ExecuteLD(); // non waiting    
       
    49     }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CNotepadAppUi::~CNotepadAppUi
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 CNotepadAppUi::~CNotepadAppUi()
       
    56     {
       
    57     delete iDialog;
       
    58     delete iApi;
       
    59     }
       
    60 
       
    61 // -----------------------------------------------------------------------------
       
    62 // CNotepadAppUi::HandleCommandL
       
    63 // -----------------------------------------------------------------------------
       
    64 //
       
    65 void CNotepadAppUi::HandleCommandL(TInt aCommand)
       
    66     {
       
    67     if ( aCommand == EEikCmdExit )
       
    68         {
       
    69         TRAPD( err, iDialog->SaveL(); );
       
    70         if ( err )
       
    71             {
       
    72             iEikonEnv->HandleError(err);
       
    73             }
       
    74         Exit();
       
    75         }
       
    76     else
       
    77         {
       
    78         CAknAppUi::HandleCommandL( aCommand );
       
    79         }
       
    80     }
       
    81 
       
    82 // -----------------------------------------------------------------------------
       
    83 // CNotepadAppUi::ProcessCommandParametersL
       
    84 // From CEikAppUi
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 TBool CNotepadAppUi::ProcessCommandParametersL(
       
    88     TApaCommand aCommand,
       
    89     TFileName& aDocumentName,
       
    90     const TDesC8& aTail )
       
    91     {
       
    92     if ( aTail.Length() )
       
    93         {
       
    94         TLex8 lex(aTail);
       
    95         TInt key;
       
    96         if ( iDialog && lex.Val(key) == KErrNone)
       
    97             {
       
    98             // force change to edit mode
       
    99             iDialog->EditByKeyL(key);
       
   100             }
       
   101         }
       
   102     return CEikAppUi::ProcessCommandParametersL(aCommand, aDocumentName, 
       
   103         aTail);
       
   104     }
       
   105 
       
   106 // -----------------------------------------------------------------------------
       
   107 // CNotepadAppUi::HandleMessageL
       
   108 // from MCoeMessageObserver
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 MCoeMessageObserver::TMessageResponse CNotepadAppUi::HandleMessageL(
       
   112     TUint32 aClientHandleOfTargetWindowGroup, 
       
   113     TUid aMessageUid, 
       
   114     const TDesC8& aMessageParameters )
       
   115     {
       
   116     MCoeMessageObserver::TMessageResponse messageResponse(EMessageHandled);
       
   117     if ( aMessageUid.iUid  == KUidApaMessagePinboardValue )
       
   118         {
       
   119         TLex8 lex(aMessageParameters);
       
   120         TInt key;
       
   121         if (lex.Val(key) == KErrNone)
       
   122             {
       
   123             iDialog->EditByKeyL(key);
       
   124             }
       
   125         }
       
   126     else
       
   127         {
       
   128         messageResponse = CAknAppUi::HandleMessageL(
       
   129             aClientHandleOfTargetWindowGroup, 
       
   130             aMessageUid,
       
   131             aMessageParameters);
       
   132         }
       
   133     return messageResponse;
       
   134     }
       
   135 
       
   136 // -----------------------------------------------------------------------------
       
   137 // CNotepadAppUi::PrepareToExit()
       
   138 // from CCoeAppUiBase
       
   139 // -----------------------------------------------------------------------------
       
   140 //
       
   141 void CNotepadAppUi::PrepareToExit()
       
   142     {
       
   143     delete iDialog;
       
   144     iDialog = NULL;
       
   145     CAknAppUi::PrepareToExit();
       
   146     }
       
   147 
       
   148 // End of File