installationservices/swi/test/testexes/interpretsis_testcase/interpretsis_testcase_AppView.cpp
branchRCL_3
changeset 25 7333d7932ef7
equal deleted inserted replaced
24:5cc91383ab1e 25:7333d7932ef7
       
     1 // Copyright (c) 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 // HelloWorld_CExampleAppView.cpp
       
    15 // Source file for the implementation of the 
       
    16 // application view class - CExampleAppView
       
    17 //
       
    18 
       
    19 #include "interpretsis_testcase.h"
       
    20 
       
    21 //
       
    22 //             Constructor for the view.
       
    23 //
       
    24 CExampleAppView::CExampleAppView()
       
    25 	{
       
    26 	}
       
    27 
       
    28 
       
    29 //             Static NewL() function to start the standard two
       
    30 //             phase construction.
       
    31 //
       
    32 CExampleAppView* CExampleAppView::NewL(const TRect& aRect)
       
    33 	{
       
    34 	CExampleAppView* self = new(ELeave) CExampleAppView();
       
    35 	CleanupStack::PushL(self);
       
    36 	self->ConstructL(aRect);
       
    37 	CleanupStack::Pop();
       
    38 	return self;
       
    39 	}
       
    40 
       
    41 
       
    42 //
       
    43 //             Destructor for the view.
       
    44 //
       
    45 CExampleAppView::~CExampleAppView()
       
    46 	{
       
    47 	delete iExampleText;
       
    48 	}
       
    49 
       
    50 
       
    51 //             Second phase construction.
       
    52 //
       
    53 void CExampleAppView::ConstructL(const TRect& aRect)
       
    54     {
       
    55 			   // Fetch the text from the resource file.
       
    56 	//iExampleText = iEikonEnv->AllocReadResourceL(R_EXAMPLE_TEXT_HELLO);
       
    57 	           // Control is a window owning control
       
    58 	CreateWindowL();
       
    59 	           // Extent of the control. This is
       
    60 	           // the whole rectangle available to application.
       
    61 	           // The rectangle is passed to us from the application UI.
       
    62 	SetRect(aRect);
       
    63 			   // At this stage, the control is ready to draw so
       
    64 	           // we tell the UI framework by activating it.
       
    65 	ActivateL();
       
    66 	}
       
    67 
       
    68 
       
    69 //             Drawing the view - in this example, 
       
    70 //             consists of drawing a simple outline rectangle
       
    71 //             and then drawing the text in the middle.
       
    72 //             We use the Normal font supplied by the UI.
       
    73 //
       
    74 //             In this example, we don't use the redraw
       
    75 //             region because it's easier to redraw to
       
    76 //             the whole client area.
       
    77 //
       
    78 void CExampleAppView::Draw(const TRect& /*aRect*/) const
       
    79 	{
       
    80                // Window graphics context
       
    81 	CWindowGc& gc = SystemGc();
       
    82 	           // Area in which we shall draw
       
    83 	TRect      drawRect = Rect();
       
    84 			   // Font used for drawing text
       
    85 	const CFont*     fontUsed;
       
    86 	
       
    87 	           // Start with a clear screen
       
    88 	gc.Clear();
       
    89 			   // Draw an outline rectangle (the default pen
       
    90 	           // and brush styles ensure this) slightly
       
    91 	           // smaller than the drawing area.
       
    92 	drawRect.Shrink(10,10);		   	
       
    93 	gc.DrawRect(drawRect);
       
    94                // Use the title font supplied by the UI
       
    95 	fontUsed = iEikonEnv->TitleFont();
       
    96 	gc.UseFont(fontUsed);
       
    97 			   // Draw the text in the middle of the rectangle.
       
    98 	TInt   baselineOffset=(drawRect.Height() - fontUsed->HeightInPixels())/2; 
       
    99 	gc.DrawText(*iExampleText,drawRect,baselineOffset,CGraphicsContext::ECenter, 0);
       
   100                // Finished using the font
       
   101 	gc.DiscardFont();
       
   102 	}
       
   103 
       
   104 
       
   105