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

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

Generated by  doxygen 1.6.2