|
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 |
|
24 |
|
25 #include "tupgradeiconapp.h" |
|
26 |
|
27 const TUid KUidUpgradeIconApp = { 0xA0003195 }; |
|
28 |
|
29 |
|
30 // |
|
31 // |
|
32 // Implementation of the application class - CExampleApplication |
|
33 // |
|
34 // |
|
35 |
|
36 TUid CExampleApplication::AppDllUid() const |
|
37 { |
|
38 return KUidUpgradeIconApp; |
|
39 } |
|
40 |
|
41 CApaDocument* CExampleApplication::CreateDocumentL() |
|
42 { |
|
43 return new (ELeave) CExampleDocument(*this); |
|
44 } |
|
45 |
|
46 |
|
47 // |
|
48 // |
|
49 // Implementation of the appui class - CExampleAppUi |
|
50 // |
|
51 // |
|
52 |
|
53 void CExampleAppUi::ConstructL() |
|
54 { |
|
55 BaseConstructL(); |
|
56 iAppView = CExampleAppView::NewL(ClientRect()); |
|
57 } |
|
58 |
|
59 CExampleAppUi::~CExampleAppUi() |
|
60 { |
|
61 delete iAppView; |
|
62 } |
|
63 |
|
64 void CExampleAppUi::HandleCommandL(TInt aCommand) |
|
65 { |
|
66 switch (aCommand) |
|
67 { |
|
68 case EEikCmdExit: |
|
69 Exit(); |
|
70 break; |
|
71 } |
|
72 } |
|
73 |
|
74 |
|
75 |
|
76 // |
|
77 // |
|
78 // Implementation of the view class - CExampleAppView |
|
79 // |
|
80 // |
|
81 |
|
82 CExampleAppView::CExampleAppView() |
|
83 { |
|
84 } |
|
85 |
|
86 CExampleAppView* CExampleAppView::NewL(const TRect& aRect) |
|
87 { |
|
88 CExampleAppView* self = new(ELeave) CExampleAppView(); |
|
89 CleanupStack::PushL(self); |
|
90 self->ConstructL(aRect); |
|
91 CleanupStack::Pop(); |
|
92 return self; |
|
93 } |
|
94 |
|
95 CExampleAppView::~CExampleAppView() |
|
96 { |
|
97 delete iExampleText; |
|
98 } |
|
99 |
|
100 void CExampleAppView::ConstructL(const TRect& aRect) |
|
101 { |
|
102 // Fetch the text from the resource file. |
|
103 iExampleText = iEikonEnv->AllocReadResourceL(R_UPGRADEICONAPP_TEXT_TESTAPP); |
|
104 |
|
105 // Control is a window owning control |
|
106 CreateWindowL(); |
|
107 |
|
108 // Extent of the control. This is |
|
109 // the whole rectangle available to application. |
|
110 // The rectangle is passed to us from the application UI. |
|
111 SetRect(aRect); |
|
112 |
|
113 // At this stage, the control is ready to draw so |
|
114 // we tell the UI framework by activating it. |
|
115 ActivateL(); |
|
116 } |
|
117 |
|
118 |
|
119 void CExampleAppView::Draw(const TRect& /*aRect*/) const |
|
120 { |
|
121 CWindowGc& gc = SystemGc(); // Window graphics context |
|
122 TRect drawRect = Rect(); // Area in which we shall draw |
|
123 const CFont* fontUsed; // Font used for drawing text |
|
124 |
|
125 // Start with a clear screen |
|
126 gc.Clear(); |
|
127 |
|
128 // Draw an outline rectangle (the default pen and brush styles ensure this) slightly smaller than the drawing area. |
|
129 drawRect.Shrink(10,10); |
|
130 gc.DrawRect(drawRect); |
|
131 |
|
132 // Use the title font supplied by the UI |
|
133 fontUsed = iEikonEnv->TitleFont(); |
|
134 gc.UseFont(fontUsed); |
|
135 |
|
136 // Draw the text in the middle of the rectangle. |
|
137 TInt baselineOffset=(drawRect.Height() - fontUsed->HeightInPixels())/2; |
|
138 gc.DrawText(*iExampleText,drawRect,baselineOffset,CGraphicsContext::ECenter, 0); |
|
139 |
|
140 // Finished using the font |
|
141 gc.DiscardFont(); |
|
142 } |
|
143 |
|
144 |
|
145 |
|
146 // |
|
147 // |
|
148 // Implementation of the document class - CExampleDocument |
|
149 // |
|
150 // |
|
151 |
|
152 CExampleDocument::CExampleDocument(CEikApplication& aApp) |
|
153 : CEikDocument(aApp) |
|
154 { |
|
155 } |
|
156 |
|
157 CEikAppUi* CExampleDocument::CreateAppUiL() |
|
158 { |
|
159 return new(ELeave) CExampleAppUi; |
|
160 } |
|
161 |
|
162 |
|
163 LOCAL_C CApaApplication* NewApplication() |
|
164 { |
|
165 return new CExampleApplication; |
|
166 } |
|
167 |
|
168 GLDEF_C TInt E32Main() |
|
169 { |
|
170 return EikStart::RunApplication(NewApplication); |
|
171 } |
|
172 |