Nokia N97 SDK
Example Applications Guide

guiengineappui.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : guiengineappui.cpp
00004 *  Part of     : GuiEngine
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 <eiktbar.h>
00018 #include <eikenv.h>
00019 #include <w32adll.h>
00020 #include <avkon.hrh>
00021 
00022 #include "GuiEngine.pan"
00023 #include "GuiEngineDocument.h"
00024 #include "GuiEngineAppUi.h"
00025 #include "GuiEngineAppView.h"
00026 #include "GuiEngine.hrh"
00027 
00028 
00029 // ========================= MEMBER FUNCTIONS ==================================
00030 
00031 // -----------------------------------------------------------------------------
00032 // CGuiEngineAppUi::CGuiEngineAppUi()
00033 // C++ default constructor can NOT contain any code, that might leave.
00034 // -----------------------------------------------------------------------------
00035 //
00036 CGuiEngineAppUi::CGuiEngineAppUi( CGuiEngineDocument* aDocument )
00037 : iDocument( aDocument )
00038     {
00039     //  No implementation required
00040     }
00041 
00042 // -----------------------------------------------------------------------------
00043 // CGuiEngineAppUi::ConstructL()
00044 // Symbian 2nd phase constructor can leave.
00045 // -----------------------------------------------------------------------------
00046 //
00047 void CGuiEngineAppUi::ConstructL()
00048     {
00049 
00050     // Initialise app UI with standard value.
00051     BaseConstructL( EAknEnableSkin );
00052 
00053     iAppView = CGuiEngineAppView::NewL(ClientRect(), iDocument);
00054 
00055     // Enable the virtual cursor
00056     iEikonEnv->VirtualCursor().SetCursorStateL( TEikVirtualCursor::EOn,*iEikonEnv );
00057 
00058     AddToStackL( iAppView );
00059 
00060     }
00061 
00062 // -----------------------------------------------------------------------------
00063 // CGuiEngineAppUi::~CGuiEngineAppUi()
00064 // Destructor.
00065 // -----------------------------------------------------------------------------
00066 //
00067 CGuiEngineAppUi::~CGuiEngineAppUi()
00068     {
00069     if ( iAppView )
00070         {
00071         iEikonEnv->RemoveFromStack( iAppView );
00072         delete iAppView;
00073         iAppView = NULL;
00074         }
00075 
00076     }
00077 
00078 // -----------------------------------------------------------------------------
00079 // CGuiEngineAppUi::HandleCommandL()
00080 // Handles the commands.
00081 // -----------------------------------------------------------------------------
00082 //
00083 void CGuiEngineAppUi::HandleCommandL( TInt aCommand )
00084     {
00085 
00086     switch ( aCommand )
00087         {
00088         case EEikCmdExit:
00089         case EAknSoftkeyExit:
00090             SaveL();
00091             Exit();
00092             break;
00093 
00094         case KClear:
00095             iAppView->Clear();
00096             break;
00097 
00098         case KSelectBrushCircle:
00099             iAppView->SetBrushShapeType( CGuiEngineAppView::ECircle );
00100             break;
00101 
00102         case KSelectBrushRectangle:
00103             iAppView->SetBrushShapeType( CGuiEngineAppView::ERectangle );
00104             break;
00105 
00106         default:
00107             break;
00108         }
00109 
00110     }
00111 
00112 // -----------------------------------------------------------------------------
00113 // CGuiEngineAppUi::HandleModelChangeL()
00114 // Handles Model Changes
00115 // -----------------------------------------------------------------------------
00116 //
00117 void CGuiEngineAppUi::HandleModelChangeL()
00118     {
00119     // Redraw the application view based on the new model.
00120     iAppView->DrawNow();
00121 
00122     // Update the file name in the task list to show the current file.
00123     iEikonEnv->UpdateTaskNameL();
00124     }
00125 
00126 // -----------------------------------------------------------------------------
00127 // CGuiEngineAppUi::StoreL()
00128 // Stores to a stream
00129 // -----------------------------------------------------------------------------
00130 //
00131 TStreamId CGuiEngineAppUi::StoreL( CStreamStore& aStore ) const
00132     {
00133     RStoreWriteStream stream;
00134     TStreamId id = stream.CreateLC( aStore );
00135 
00136     // Write the data to the stream
00137     iAppView->ExternalizeL( stream );
00138     stream.CommitL();
00139     CleanupStack::PopAndDestroy();
00140 
00141     // Return the stream ID
00142     return id;
00143     }
00144 
00145 // -----------------------------------------------------------------------------
00146 // CGuiEngineAppUi::RestoreL()
00147 // Restore from a stream
00148 // -----------------------------------------------------------------------------
00149 //
00150 void CGuiEngineAppUi::RestoreL( const CStreamStore& aStore,
00151                                 TStreamId aStreamId )
00152     {
00153     RStoreReadStream stream;
00154     stream.OpenLC( aStore,aStreamId );
00155 
00156     //  Read in the data
00157     iAppView->InternalizeL( stream );
00158 
00159     CleanupStack::PopAndDestroy();
00160     }
00161 
00162 
00163 // End of File

© Nokia 2009

Back to top