appfw/apparchitecture/tef/tnotifydrivesapp/tnotifydrivesapp.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @test
       
    19  @internalComponent - Internal Symbian test code
       
    20 */
       
    21 
       
    22 #include <eikstart.h>
       
    23 #include "tnotifydrivesapp.h"
       
    24 
       
    25 const TUid KNotifyDrivesAppUid = { 0xA0003376 };
       
    26 
       
    27 
       
    28 //
       
    29 //
       
    30 // Implementation of the application class - CExampleApplication
       
    31 //
       
    32 //
       
    33 
       
    34 TUid CExampleApplication::AppDllUid() const
       
    35 	{
       
    36 	return KNotifyDrivesAppUid;
       
    37 	}
       
    38 
       
    39 CApaDocument* CExampleApplication::CreateDocumentL()
       
    40 	{
       
    41 	return new (ELeave) CExampleDocument(*this);
       
    42 	}
       
    43 	
       
    44 
       
    45 //
       
    46 //
       
    47 // Implementation of the appui class - CExampleAppUi
       
    48 //
       
    49 //
       
    50 
       
    51 void CExampleAppUi::ConstructL()
       
    52     {
       
    53     BaseConstructL();
       
    54 	iAppView = CExampleAppView::NewL(ClientRect());
       
    55 	}
       
    56 
       
    57 CExampleAppUi::~CExampleAppUi()
       
    58 	{
       
    59 	delete iAppView;
       
    60 	}
       
    61 
       
    62 void CExampleAppUi::HandleCommandL(TInt aCommand)
       
    63 	{
       
    64 	switch (aCommand)
       
    65 		{
       
    66 		case EEikCmdExit: 
       
    67 			Exit();
       
    68 			break;
       
    69 		}
       
    70 	}
       
    71 
       
    72 
       
    73 
       
    74 //
       
    75 //
       
    76 // Implementation of the view class - CExampleAppView
       
    77 //
       
    78 //
       
    79 
       
    80 CExampleAppView::CExampleAppView()
       
    81 	{
       
    82 	}
       
    83 
       
    84 CExampleAppView* CExampleAppView::NewL(const TRect& aRect)
       
    85 	{
       
    86 	CExampleAppView* self = new(ELeave) CExampleAppView();
       
    87 	CleanupStack::PushL(self);
       
    88 	self->ConstructL(aRect);
       
    89 	CleanupStack::Pop();
       
    90 	return self;
       
    91 	}
       
    92 
       
    93 CExampleAppView::~CExampleAppView()
       
    94 	{
       
    95 	
       
    96 	}
       
    97 
       
    98 void CExampleAppView::ConstructL(const TRect& aRect)
       
    99     {
       
   100    	// Fetch the text from the resource file.
       
   101 	
       
   102 
       
   103     // Control is a window owning control
       
   104 	CreateWindowL();
       
   105 
       
   106    // Extent of the control. This is
       
   107    // the whole rectangle available to application.
       
   108    // The rectangle is passed to us from the application UI.
       
   109 	SetRect(aRect);
       
   110 
       
   111    // At this stage, the control is ready to draw so
       
   112    // we tell the UI framework by activating it.
       
   113 	ActivateL();
       
   114 	}
       
   115 
       
   116 
       
   117 void CExampleAppView::Draw(const TRect& /*aRect*/) const
       
   118 	{
       
   119 	CWindowGc& gc = SystemGc();			// Window graphics context
       
   120 	TRect      drawRect = Rect();		// Area in which we shall draw	
       
   121 	const CFont*     fontUsed;			// Font used for drawing text
       
   122 	
       
   123 	// Start with a clear screen
       
   124 	gc.Clear();
       
   125 	
       
   126 	// Draw an outline rectangle (the default pen and brush styles ensure this) slightly smaller than the drawing area.
       
   127 	drawRect.Shrink(10,10);		   	
       
   128 	gc.DrawRect(drawRect);
       
   129     
       
   130     // Use the title font supplied by the UI
       
   131 	fontUsed = iEikonEnv->TitleFont();
       
   132 	gc.UseFont(fontUsed);
       
   133 	
       
   134 	// Draw the text in the middle of the rectangle.
       
   135 	TInt   baselineOffset=(drawRect.Height() - fontUsed->HeightInPixels())/2; 
       
   136 	
       
   137     
       
   138     // Finished using the font
       
   139 	gc.DiscardFont();
       
   140 	}
       
   141 
       
   142 
       
   143 
       
   144 //
       
   145 //
       
   146 // Implementation of the document class - CExampleDocument
       
   147 //
       
   148 //
       
   149 
       
   150 CExampleDocument::CExampleDocument(CEikApplication& aApp)
       
   151 		: CEikDocument(aApp)
       
   152 	{
       
   153 	}
       
   154 
       
   155 CEikAppUi* CExampleDocument::CreateAppUiL()
       
   156 	{
       
   157     return new(ELeave) CExampleAppUi;
       
   158 	}
       
   159 
       
   160 
       
   161 LOCAL_C CApaApplication* NewApplication()
       
   162 	{
       
   163 	return new CExampleApplication;
       
   164 	}
       
   165 	
       
   166 GLDEF_C TInt E32Main()
       
   167 	{
       
   168 	return EikStart::RunApplication(NewApplication);
       
   169 	}
       
   170