examples/S60CppExamples/ClientServerAsync/client/src/csasyncappui.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : csasyncappui.cpp
00004 *  Part of     : CSAsync
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 
00017 // INCLUDE FILES
00018 #include <eikmenup.h>
00019 #include <avkon.hrh>
00020 #include <CSAsync.rsg>
00021 
00022 #include "CSAsync.pan"
00023 #include "CSAsyncAppUi.h"
00024 #include "CSAsyncAppView.h"
00025 #include "CSAsyncDocument.h"
00026 #include "CSAsync.hrh"
00027 
00028 // ========================= MEMBER FUNCTIONS ==================================
00029 
00030 // -----------------------------------------------------------------------------
00031 // CCSAsyncAppUi::CCSAsyncAppUi()
00032 // C++ default constructor can NOT contain any code, that might leave.
00033 // -----------------------------------------------------------------------------
00034 //
00035 CCSAsyncAppUi::CCSAsyncAppUi()
00036     {
00037     // No implementation required
00038     }
00039 
00040 // -----------------------------------------------------------------------------
00041 // CCSAsyncAppUi::ConstructL()
00042 // Symbian 2nd phase constructor can leave.
00043 // -----------------------------------------------------------------------------
00044 //
00045 void CCSAsyncAppUi::ConstructL()
00046     {
00047     BaseConstructL();
00048 
00049     iAppView = CCSAsyncAppView::NewL( ClientRect(), *AsyncDocument() );
00050 
00051     AddToStackL( iAppView );
00052     }
00053 
00054 // -----------------------------------------------------------------------------
00055 // CCSAsyncAppUi::~CCSAsyncAppUi()
00056 // Destructor.
00057 // -----------------------------------------------------------------------------
00058 //
00059 CCSAsyncAppUi::~CCSAsyncAppUi()
00060     {
00061     if ( iAppView )
00062         {
00063         iEikonEnv->RemoveFromStack( iAppView );
00064         delete iAppView;
00065         iAppView = NULL;
00066         }
00067     }
00068 
00069 // -----------------------------------------------------------------------------
00070 // CCSAsyncAppUi::AsyncDocument() const
00071 // Casts iDocument member from CAknAppUi to CCSAsyncDocument.
00072 // -----------------------------------------------------------------------------
00073 //
00074 CCSAsyncDocument* CCSAsyncAppUi::AsyncDocument() const
00075     {
00076     return ( static_cast<CCSAsyncDocument*>( iDocument ) );
00077     }
00078 
00079 // -----------------------------------------------------------------------------
00080 // CCSAsyncAppUi::HandleCommandL( TInt aCommand )
00081 // Handles user menu selections.
00082 // -----------------------------------------------------------------------------
00083 //
00084 void CCSAsyncAppUi::HandleCommandL( TInt aCommand )
00085     {
00086     switch( aCommand )
00087         {
00088         case EEikCmdExit:
00089         case EAknSoftkeyExit:
00090             Exit();
00091             break;
00092 
00093         case EStartClock:
00094             AsyncDocument()->UpdateTime();
00095             break;
00096 
00097         case EStopClock:
00098             AsyncDocument()->StopClock();
00099             break;
00100 
00101         default:
00102             break;
00103         }
00104     }
00105 
00106 // -----------------------------------------------------------------------------
00107 // CCSAsyncAppUi::HandleTimeUpdate()
00108 // Updates view
00109 // -----------------------------------------------------------------------------
00110 //
00111 void CCSAsyncAppUi::HandleTimeUpdate()
00112     {
00113     __ASSERT_ALWAYS( iAppView, User::Panic ( KCSAsyncClient, 
00114                                              ECSAsyncProgram ) );
00115     iAppView->DrawNow();
00116     }
00117 
00118 // -----------------------------------------------------------------------------
00119 // CCSAsyncAppUi::DynInitMenuPaneL( TInt aResourceId, CEikMenuPane* aMenuPane )
00120 // Prepares the menu prior to display.
00121 // -----------------------------------------------------------------------------
00122 //
00123 void CCSAsyncAppUi::DynInitMenuPaneL( TInt aResourceId, 
00124                                       CEikMenuPane* aMenuPane )
00125     {
00126     if ( aResourceId == R_CSASYNC_MENU )
00127         {
00128         if ( AsyncDocument()->ClockActive() )
00129             {
00130             aMenuPane->SetItemDimmed( EStartClock, ETrue );
00131             aMenuPane->SetItemDimmed( EStopClock, EFalse );
00132             }
00133         else
00134             {
00135             aMenuPane->SetItemDimmed( EStartClock, EFalse );
00136             aMenuPane->SetItemDimmed( EStopClock, ETrue );
00137             }
00138         }
00139     }
00140 
00141 // -----------------------------------------------------------------------------
00142 // CCSAsyncAppUi::HandleResourceChangeL( TInt aType )
00143 // Called by framework when layout is changed.
00144 // -----------------------------------------------------------------------------
00145 //
00146 void CCSAsyncAppUi::HandleResourceChangeL( TInt aType )
00147     {
00148     CAknAppUi::HandleResourceChangeL( aType );
00149 
00150     if ( aType==KEikDynamicLayoutVariantSwitch )
00151         {
00152         iAppView->SetRect( ClientRect() );
00153         }
00154     //Controls derived from CCoeControl, handled in container class
00155     iAppView->HandleResourceChange( aType );
00156     }
00157 
00158 // End of File

Generated by  doxygen 1.6.2