Nokia N97 SDK
Example Applications Guide

aknexnoteview.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : aknexnoteview.cpp
00004 *  Part of     : Note example
00005 *  Interface   :
00006 *  Description :
00007 *  Version     :
00008 *
00009 *  Copyright (c) 2004 - 2006 Nokia Corporation.
00010 *  This material, including documentation and any related
00011 *  computer programs, is protected by copyright controlled by
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 // INCLUDE FILES
00017 #include <aknviewappui.h>
00018 #include <akntitle.h>
00019 #include <avkon.hrh>
00020 #include <AknExNote.rsg>
00021 #include <AVKON.RSG>
00022 
00023 #include "AknExNoteView.h"
00024 #include "AknExNoteContainer.h"
00025 #include "aknexnote.hrh"
00026 
00027 
00028 // CONSTANTS
00029 #include "Aknexnoteconstants.h"
00030 
00031 
00032 // ========================= MEMBER FUNCTIONS ===================================
00033 
00034 // ------------------------------------------------------------------------------
00035 // CAknExNoteView::CAknExNoteView()
00036 // C++ default constructor can NOT contain any code, that might leave.
00037 // ------------------------------------------------------------------------------
00038 //
00039 CAknExNoteView::CAknExNoteView()
00040 : iContainer( NULL ),iCurrentOutline( EAknExNoteCmdEmptyOutline )
00041     {
00042     // No implementation required
00043     }
00044 
00045 // ------------------------------------------------------------------------------
00046 // CAknExNoteView::~CAknExNoteView()
00047 // Destructor.
00048 // ------------------------------------------------------------------------------
00049 //
00050 CAknExNoteView::~CAknExNoteView()
00051     {
00052     delete iContainer;
00053     }
00054 
00055 // ------------------------------------------------------------------------------
00056 // CAknExNoteView::ConstructL()
00057 // Symbian 2nd phase constructor can leave.
00058 // ------------------------------------------------------------------------------
00059 //
00060 void CAknExNoteView::ConstructL()
00061     {
00062     BaseConstructL( R_AKNEXNOTE_VIEW );
00063     }
00064 
00065 // ------------------------------------------------------------------------------
00066 // CAknExNoteView::DisplayNextOutLineL()
00067 // Displays Next Outline
00068 // ------------------------------------------------------------------------------
00069 //
00070 void CAknExNoteView::DisplayNextOutlineL()
00071     {
00072     switch ( iCurrentOutline )
00073         {
00074         case EAknExNoteCmdEmptyOutline:
00075             HandleCommandL( EAknExNoteCmdOutline01 );
00076             break;
00077 
00078         case EAknExNoteCmdOutline01: 
00079             HandleCommandL( EAknExNoteCmdOutline05 );
00080             break;
00081 
00082         case EAknExNoteCmdOutline05:
00083             HandleCommandL( EAknExNoteCmdOutline08 );
00084             break;
00085 
00086         case EAknExNoteCmdOutline08:
00087             HandleCommandL( EAknExNoteCmdOutline35 );
00088             break;
00089 
00090         case EAknExNoteCmdOutline35:
00091             HandleCommandL( EAknExNoteCmdOutline53 );
00092             break;
00093 
00094         case EAknExNoteCmdOutline53:
00095         default:
00096             HandleCommandL( EAknExNoteCmdEmptyOutline );
00097             break;
00098         }
00099     }
00100 
00101 // -----------------------------------------------------------------------------
00102 // CAknExNoteView::Id()
00103 // Returns ID of view.
00104 // -----------------------------------------------------------------------------
00105 //
00106 TUid CAknExNoteView::Id() const
00107     {
00108     return KViewId;
00109     }
00110 
00111 // -----------------------------------------------------------------------------
00112 // CAknExNoteView::HandleCommandL()
00113 // Handles the commands.
00114 // -----------------------------------------------------------------------------
00115 //
00116 void CAknExNoteView::HandleCommandL( TInt aCommand )
00117     {
00118     switch ( aCommand )
00119         {
00120         // Soft Back
00121         case EAknSoftkeyBack:
00122             AppUi()->ProcessCommandL( EAknCmdExit );
00123             break;
00124 
00125         // Exit
00126         case EAknCmdExit:
00127             AppUi()->HandleCommandL( EAknCmdExit );
00128             break;
00129 
00130         case EAknExNoteCmdEmptyOutline:
00131             iCurrentOutline = aCommand;
00132             iContainer->SetTextToLabelL( R_AKNEXNOTE_TEXT_LABEL_TITLE );
00133             IndicateTitlePaneTextL( aCommand );
00134             break;
00135         
00136         // Error Note
00137         case EAknExNoteCmdOutline01: 
00138             iCurrentOutline = aCommand;
00139             iContainer->SetTextToLabelL( R_AKNEXNOTE_TEXT_LABEL_OPERATION );
00140             IndicateTitlePaneTextL( aCommand );
00141             iContainer->ShowGeneralNoteL( R_AKNEXNOTE_ERROR_NOTE,
00142                                           CAknNoteDialog::ELongTimeout,
00143                                           CAknNoteDialog::EErrorTone );
00144             break;
00145 
00146         // Wait Note
00147         case EAknExNoteCmdOutline05:
00148             iCurrentOutline = aCommand;
00149             iContainer->SetTextToLabelL( R_AKNEXNOTE_TEXT_LABEL_OPERATION );
00150             IndicateTitlePaneTextL( aCommand );
00151             iContainer->ShowWaitNoteL(R_AKNEXNOTE_WAIT_NOTE_SOFTKEY_CANCEL,
00152                                       EAknExNoteCtrlIdWaitNote);
00153             break;
00154          
00155         // Dynamic text
00156         case EAknExNoteCmdOutline08:
00157             iCurrentOutline = aCommand;
00158             iContainer->SetTextToLabelL( R_AKNEXNOTE_TEXT_LABEL_OPERATION );
00159             IndicateTitlePaneTextL( aCommand );
00160             iContainer->ShowDynamicNumberNoteL();
00161             break;
00162         
00163         // Progress note 
00164         case EAknExNoteCmdOutline35: 
00165             iCurrentOutline = aCommand;
00166             iContainer->SetTextToLabelL( R_AKNEXNOTE_TEXT_LABEL_OPERATION );
00167             IndicateTitlePaneTextL( aCommand );
00168             iContainer->ShowProgressNoteUnderSingleProcessL( 
00169                                             R_AKNEXNOTE_PROGRESS_NOTE,
00170                                             EAknExNoteCtrlIdProgressNote );
00171             break;
00172         
00173         // EAknGlobalConfirmationNote
00174         case EAknExNoteCmdOutline53:
00175             iCurrentOutline = aCommand;
00176             iContainer->SetTextToLabelL( R_AKNEXNOTE_TEXT_LABEL_OPERATION );
00177             IndicateTitlePaneTextL( aCommand );
00178             iContainer->ShowShowNoteL(
00179                         EAknGlobalConfirmationNote,
00180                         R_AKNEXNOTE_SHOWNOTEL_GLOBALCONFIRMATIONNOTE_TEXT );
00181             break;
00182         
00183         // Next one
00184         case EAknExNoteCbaCmdNext:
00185             DisplayNextOutlineL();
00186             break;
00187         default:
00188             break;
00189         }
00190     }
00191 
00192 // -----------------------------------------------------------------------------
00193 // CAknExNoteView::IndicateTitlePaneTextL()
00194 // Set title text to status-pane
00195 // -----------------------------------------------------------------------------
00196 //
00197 void CAknExNoteView::IndicateTitlePaneTextL( TInt aCommand )
00198     {
00199 
00200     TBool useDefaultText( EFalse );
00201     TInt resourceId( KAknExNoteInitializeResourceId );
00202 
00203     switch ( aCommand )
00204         {
00205         case EAknExNoteCmdEmptyOutline:
00206             useDefaultText = ETrue;
00207             break;
00208 
00209         case EAknExNoteCmdOutline01:
00210             resourceId = R_AKNEXNOTE_TEXT_STATUS_PANE_TITLE01;
00211             break;
00212 
00213         case EAknExNoteCmdOutline05:
00214             resourceId = R_AKNEXNOTE_TEXT_STATUS_PANE_TITLE05;
00215             break;
00216 
00217         case EAknExNoteCmdOutline08:
00218             resourceId = R_AKNEXNOTE_TEXT_STATUS_PANE_TITLE08;
00219             break;
00220 
00221         case EAknExNoteCmdOutline35:
00222             resourceId = R_AKNEXNOTE_TEXT_STATUS_PANE_TITLE35;
00223             break;
00224 
00225         case EAknExNoteCmdOutline53:
00226             resourceId = R_AKNEXNOTE_TEXT_STATUS_PANE_TITLE53;
00227             break;
00228 
00229         default:
00230             break;
00231         }
00232 
00233     CAknTitlePane* titlePane = static_cast<CAknTitlePane*> 
00234                                ( StatusPane()->ControlL( TUid::Uid
00235                                ( EEikStatusPaneUidTitle ) ) );
00236     
00237     if ( useDefaultText )
00238         {
00239         titlePane->SetTextToDefaultL();
00240         }
00241     else
00242         {
00243         
00244         //Allocate TBuf with constant length.
00245         TBuf<KAknExNoteTitleBufLength> titleText( NULL );
00246         
00247          // Reads a resource into a descriptor.
00248         iEikonEnv->ReadResource( titleText, resourceId );
00249         
00250         // Set the text for TitlePane
00251         titlePane->SetTextL( titleText );
00252         }
00253     }
00254 
00255 // -----------------------------------------------------------------------------
00256 // CAknExNoteView::HandleViewRectChange()
00257 // Handles the size of the clientrect.
00258 // -----------------------------------------------------------------------------
00259 //
00260 void CAknExNoteView::HandleViewRectChange()
00261     {
00262     if ( iContainer )
00263         {
00264         iContainer->SetRect( ClientRect() );
00265         }
00266     }
00267 
00268 // -----------------------------------------------------------------------------
00269 // CAknExNoteView::DoActivateL()
00270 // Creates container class object.
00271 // -----------------------------------------------------------------------------
00272 //
00273 void CAknExNoteView::DoActivateL( const TVwsViewId& /*aPrevViewId*/,
00274                                   TUid /*aCustomMessageId*/,
00275                                   const TDesC8& /*aCustomMessage*/ )
00276     {
00277 
00278     // Creates container object
00279     if ( !iContainer )
00280         {
00281         iContainer = new ( ELeave ) CAknExNoteContainer( this );
00282         iContainer->ConstructL( ClientRect() );
00283         iContainer->SetMopParent( this );
00284         }
00285 
00286     // Adds container to view control stack.
00287     AppUi()->AddToStackL( *this, iContainer );
00288     iContainer->MakeVisible( ETrue );
00289     }
00290 
00291 // -----------------------------------------------------------------------------
00292 // CAknExNoteView::DoDeactivate()
00293 // Deletes container class object.
00294 // -----------------------------------------------------------------------------
00295 //
00296 void CAknExNoteView::DoDeactivate()
00297     {
00298     // Deletes the container class object.
00299     if ( iContainer )
00300         {
00301         iContainer->MakeVisible( EFalse );
00302         // Removes container from view control stack.
00303         AppUi()->RemoveFromStack( iContainer );
00304         }
00305     }
00306 
00307 // End of File

© Nokia 2009

Back to top