diff -r 89d6a7a84779 -r 25a17d01db0c Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/_minimal_8cpp-source.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/_minimal_8cpp-source.html Fri Jan 22 18:26:19 2010 +0000 @@ -0,0 +1,141 @@ + +
+00001 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +00002 // All rights reserved. +00003 // This component and the accompanying materials are made available +00004 // under the terms of "Eclipse Public License v1.0" +00005 // which accompanies this distribution, and is available +00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html". +00007 // +00008 // Initial Contributors: +00009 // Nokia Corporation - initial contribution. +00010 // +00011 // Contributors: +00012 // +00013 // Description: +00014 // +00015 +00016 +00017 #include "Minimal.h" +00018 +00019 const TUid KUidMinimal = { 0xE800008B }; +00020 +00021 +00022 // Called by the UI framework to get the application's UID +00023 TUid CExampleApplication::AppDllUid() const +00024 { +00025 return KUidMinimal; +00026 } +00027 +00028 // Called by the UI framework at application start-up to +00029 // create an instance of the document class. +00030 CApaDocument* CExampleApplication::CreateDocumentL() +00031 { +00032 return new (ELeave) CExampleDocument(*this); +00033 } +00034 +00035 // Called by the UI framework to get the name of the resource file. +00036 // This returns an empty filename as there is no resource file. +00037 TFileName CExampleApplication::ResourceFileName() const +00038 { +00039 return TFileName(); +00040 } +00041 +00042 CExampleDocument::CExampleDocument(CEikApplication& aApp) +00043 : CEikDocument(aApp) +00044 {} +00045 +00046 // Called by the UI framework to construct +00047 // the application UI class. Note that the app UI's +00048 // ConstructL() is called by the UI framework. +00049 CEikAppUi* CExampleDocument::CreateAppUiL() +00050 { +00051 return new(ELeave) CExampleAppUi; +00052 } +00053 +00054 // Second phase constructor of the application UI class. +00055 // It creates and owns a single view. +00056 void CExampleAppUi::ConstructL() +00057 { +00058 BaseConstructL(ENoAppResourceFile | ENoScreenFurniture); +00059 iAppView = CExampleAppView::NewL(ClientRect()); +00060 } +00061 +00062 // The application UI class owns one view, and is responsible +00063 // for destroying it. +00064 CExampleAppUi::~CExampleAppUi() +00065 { +00066 delete iAppView; +00067 } +00068 +00069 // Called by the UI framework when a command has been issued. +00070 // Minimally needs to handle the exit command. +00071 void CExampleAppUi::HandleCommandL(TInt aCommand) +00072 { +00073 switch (aCommand) +00074 { +00075 // Exit the application. +00076 case EEikCmdExit: +00077 Exit(); +00078 break; +00079 } +00080 } +00081 +00082 CExampleAppView::CExampleAppView() +00083 { +00084 } +00085 +00086 // Static function wraps up two-phase construction for the view. +00087 CExampleAppView* CExampleAppView::NewL(const TRect& aRect) +00088 { +00089 CExampleAppView* self = new(ELeave) CExampleAppView(); +00090 CleanupStack::PushL(self); +00091 self->ConstructL(aRect); +00092 CleanupStack::Pop(); +00093 return self; +00094 } +00095 +00096 CExampleAppView::~CExampleAppView() +00097 { +00098 } +00099 +00100 // Standard initialisation for a window-owning control. +00101 void CExampleAppView::ConstructL(const TRect& aRect) +00102 { +00103 // Create the window owned by the view. +00104 CreateWindowL(); +00105 // Set the view's size and position. +00106 SetRect(aRect); +00107 // Activate the view. +00108 ActivateL(); +00109 } +00110 +00111 // Draws the view with a simple outline rectangle and then +00112 // draws the welcome text centred. +00113 void CExampleAppView::Draw(const TRect& /*aRect*/) const +00114 { +00115 // Use drawing parameters from the system graphics context. +00116 CWindowGc& gc = SystemGc(); +00117 TRect drawRect = Rect(); +00118 const CFont* fontUsed; +00119 gc.Clear(); +00120 drawRect.Shrink(10,10); +00121 gc.DrawRect(drawRect); +00122 fontUsed = iEikonEnv->TitleFont(); +00123 gc.UseFont(fontUsed); +00124 TInt baselineOffset=(drawRect.Height())/2; +00125 _LIT(KText,"Welcome to the minimal application example"); +00126 gc.DrawText(KText,drawRect,baselineOffset,CGraphicsContext::ECenter, 0); +00127 gc.DiscardFont(); +00128 } +00129 +