examples/AppFramework/Apparc/EmbApp/embedded.cpp

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 #include "embedded.h"
00032 
00033 const TUid KAppEmbeddable       = { 0xE800008F };
00034 
00035 CExampleAppView::CExampleAppView()
00036         {}
00037 
00038 // Static function wraps up two-phase construction for the view.
00039 CExampleAppView* CExampleAppView::NewL(const TRect& aRect)
00040         {
00041         CExampleAppView* self = new(ELeave) CExampleAppView();
00042         CleanupStack::PushL(self);
00043         self->ConstructL(aRect);
00044         CleanupStack::Pop();
00045         return self;
00046         }
00047 
00048 CExampleAppView::~CExampleAppView()
00049         {
00050         delete iExampleText;
00051         }
00052 
00053 // Standard initialisation for a window-owning control.
00054 void CExampleAppView::ConstructL(const TRect& aRect)
00055     {
00056         TPtrC ptr(KExampleText);
00057         iExampleText = ptr.AllocL();
00058         CreateWindowL();
00059         SetRect(aRect);
00060         ActivateL();
00061         }
00062 
00063 // Draws the view with a simple outline rectangle and then
00064 // draws the welcome text centred.
00065 void CExampleAppView::Draw(const TRect& /*aRect*/) const
00066         {
00067         CWindowGc& gc = SystemGc();
00068         TRect      drawRect = Rect();
00069         const CFont*     fontUsed;
00070 
00071         gc.Clear();
00072         fontUsed = iEikonEnv->TitleFont();
00073         gc.UseFont(fontUsed);
00074         TInt   baselineOffset=(drawRect.Height() - fontUsed->HeightInPixels())/2;
00075         gc.DrawText(*iExampleText,drawRect,baselineOffset,CGraphicsContext::ECenter, 0);
00076         gc.DiscardFont();
00077         }
00078 
00079 // Second phase constructor of the application UI class.
00080 // It creates and owns a single view.
00081 void CExampleAppUi::ConstructL()
00082     {
00083     BaseConstructL(ENoAppResourceFile | ENoScreenFurniture);
00084         iAppView = CExampleAppView::NewL(ClientRect());
00085         }
00086 
00087 // The application UI class owns one view, and is responsible
00088 // for destroying it.
00089 CExampleAppUi::~CExampleAppUi()
00090         {
00091         delete iAppView;
00092         }
00093 
00094 // Called by the UI framework when a command has been issued.
00095 // Minimally needs to handle the exit command.
00096 void CExampleAppUi::HandleCommandL(TInt aCommand)
00097         {
00098         switch (aCommand)
00099                 {
00100         case EEikCmdExit:
00101                 Exit();
00102                 break;
00103                 }
00104         }
00105 
00106 CExampleDocument::CExampleDocument(CEikApplication& aApp)
00107                 : CEikDocument(aApp)
00108         {}
00109 
00110 // Called by the UI framework to construct
00111 // the application UI class. Note that the app UI's
00112 // ConstructL() is called by the UI framework.
00113 CEikAppUi* CExampleDocument::CreateAppUiL()
00114         {
00115     return new(ELeave) CExampleAppUi;
00116         }
00117 
00118 // Called by the UI framework at application start-up to
00119 // create an instance of the document class.
00120 CApaDocument* CExampleApplication::CreateDocumentL()
00121         {
00122         return new (ELeave) CExampleDocument(*this);
00123         }
00124 
00125 // Called by the UI framework to get the application's UID
00126 TUid CExampleApplication::AppDllUid() const
00127         {
00128         return KAppEmbeddable;
00129         }
00130 
00131 // Called by the UI framework to get the name of the resource file.
00132 // This returns an empty filename as there is no resource file.
00133 TFileName CExampleApplication::ResourceFileName() const
00134 {
00135         return TFileName();
00136 }
00137 

Generated by  doxygen 1.6.2