00001 /* 00002 Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. 00003 00004 Redistribution and use in source and binary forms, with or without 00005 modification, are permitted provided that the following conditions are met: 00006 00007 * Redistributions of source code must retain the above copyright notice, this 00008 list of conditions and the following disclaimer. 00009 * Redistributions in binary form must reproduce the above copyright notice, 00010 this list of conditions and the following disclaimer in the documentation 00011 and/or other materials provided with the distribution. 00012 * Neither the name of Nokia Corporation nor the names of its contributors 00013 may be used to endorse or promote products derived from this software 00014 without specific prior written permission. 00015 00016 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00017 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00018 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00019 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00020 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00021 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00022 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00023 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00024 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00025 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 00027 Description: 00028 */ 00029 00030 00031 00032 #include "Minimal.h" 00033 00034 const TUid KUidMinimal = { 0xE800008B }; 00035 00036 00037 // Called by the UI framework to get the application's UID 00038 TUid CExampleApplication::AppDllUid() const 00039 { 00040 return KUidMinimal; 00041 } 00042 00043 // Called by the UI framework at application start-up to 00044 // create an instance of the document class. 00045 CApaDocument* CExampleApplication::CreateDocumentL() 00046 { 00047 return new (ELeave) CExampleDocument(*this); 00048 } 00049 00050 // Called by the UI framework to get the name of the resource file. 00051 // This returns an empty filename as there is no resource file. 00052 TFileName CExampleApplication::ResourceFileName() const 00053 { 00054 return TFileName(); 00055 } 00056 00057 CExampleDocument::CExampleDocument(CEikApplication& aApp) 00058 : CEikDocument(aApp) 00059 {} 00060 00061 // Called by the UI framework to construct 00062 // the application UI class. Note that the app UI's 00063 // ConstructL() is called by the UI framework. 00064 CEikAppUi* CExampleDocument::CreateAppUiL() 00065 { 00066 return new(ELeave) CExampleAppUi; 00067 } 00068 00069 // Second phase constructor of the application UI class. 00070 // It creates and owns a single view. 00071 void CExampleAppUi::ConstructL() 00072 { 00073 BaseConstructL(ENoAppResourceFile | ENoScreenFurniture); 00074 iAppView = CExampleAppView::NewL(ClientRect()); 00075 } 00076 00077 // The application UI class owns one view, and is responsible 00078 // for destroying it. 00079 CExampleAppUi::~CExampleAppUi() 00080 { 00081 delete iAppView; 00082 } 00083 00084 // Called by the UI framework when a command has been issued. 00085 // Minimally needs to handle the exit command. 00086 void CExampleAppUi::HandleCommandL(TInt aCommand) 00087 { 00088 switch (aCommand) 00089 { 00090 // Exit the application. 00091 case EEikCmdExit: 00092 Exit(); 00093 break; 00094 } 00095 } 00096 00097 CExampleAppView::CExampleAppView() 00098 { 00099 } 00100 00101 // Static function wraps up two-phase construction for the view. 00102 CExampleAppView* CExampleAppView::NewL(const TRect& aRect) 00103 { 00104 CExampleAppView* self = new(ELeave) CExampleAppView(); 00105 CleanupStack::PushL(self); 00106 self->ConstructL(aRect); 00107 CleanupStack::Pop(); 00108 return self; 00109 } 00110 00111 CExampleAppView::~CExampleAppView() 00112 { 00113 } 00114 00115 // Standard initialisation for a window-owning control. 00116 void CExampleAppView::ConstructL(const TRect& aRect) 00117 { 00118 // Create the window owned by the view. 00119 CreateWindowL(); 00120 // Set the view's size and position. 00121 SetRect(aRect); 00122 // Activate the view. 00123 ActivateL(); 00124 } 00125 00126 // Draws the view with a simple outline rectangle and then 00127 // draws the welcome text centred. 00128 void CExampleAppView::Draw(const TRect& /*aRect*/) const 00129 { 00130 // Use drawing parameters from the system graphics context. 00131 CWindowGc& gc = SystemGc(); 00132 TRect drawRect = Rect(); 00133 const CFont* fontUsed; 00134 gc.Clear(); 00135 drawRect.Shrink(10,10); 00136 gc.DrawRect(drawRect); 00137 fontUsed = iEikonEnv->TitleFont(); 00138 gc.UseFont(fontUsed); 00139 TInt baselineOffset=(drawRect.Height())/2; 00140 _LIT(KText,"Welcome to the minimal application example"); 00141 gc.DrawText(KText,drawRect,baselineOffset,CGraphicsContext::ECenter, 0); 00142 gc.DiscardFont(); 00143 } 00144