|
1 /* |
|
2 * Copyright (c) 2004 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Implementation of class CRoapAppView. |
|
16 * |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 |
|
23 #include <barsread.h> |
|
24 #include <eiklabel.h> |
|
25 #include <avkon.rsg> |
|
26 #include <RoapApp.rsg> |
|
27 #include "RoapAppView.h" |
|
28 #include "RoapAppLogger.h" |
|
29 |
|
30 // ================= MEMBER FUNCTIONS ======================= |
|
31 |
|
32 // --------------------------------------------------------- |
|
33 // CRoapAppView::CRoapAppView() |
|
34 // --------------------------------------------------------- |
|
35 // |
|
36 CRoapAppView* CRoapAppView::NewL |
|
37 ( const TRect& aRect, MObjectProvider* aMopParent ) |
|
38 { |
|
39 CRoapAppView* view = new (ELeave) CRoapAppView( aMopParent ); |
|
40 CleanupStack::PushL( view ); |
|
41 view->ConstructL( aRect ); |
|
42 CleanupStack::Pop( view ); |
|
43 return view; |
|
44 } |
|
45 |
|
46 // --------------------------------------------------------- |
|
47 // CRoapAppView::~CRoapAppView() |
|
48 // --------------------------------------------------------- |
|
49 // |
|
50 CRoapAppView::~CRoapAppView() |
|
51 { |
|
52 delete iLabel; |
|
53 delete iBgContext; |
|
54 } |
|
55 |
|
56 //---------------------------------------------------------- |
|
57 // CRoapAppView::MopSupplyObject() |
|
58 //---------------------------------------------------------- |
|
59 // |
|
60 TTypeUid::Ptr CRoapAppView::MopSupplyObject(TTypeUid aId) |
|
61 { |
|
62 if (iBgContext ) |
|
63 { |
|
64 return MAknsControlContext::SupplyMopObject( aId, iBgContext ); |
|
65 } |
|
66 return CCoeControl::MopSupplyObject(aId); |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------- |
|
70 // CRoapAppView::SizeChanged() |
|
71 // --------------------------------------------------------- |
|
72 // |
|
73 void CRoapAppView::SizeChanged() |
|
74 { |
|
75 iLabel->SetRect( Rect() ); |
|
76 iLabel->DrawNow(); |
|
77 if(iBgContext) |
|
78 { |
|
79 iBgContext->SetRect(Rect()); |
|
80 if ( &Window() ) |
|
81 { |
|
82 iBgContext->SetParentPos( PositionRelativeToScreen() ); |
|
83 } |
|
84 } |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------- |
|
88 // CRoapAppView::CountComponentControls() |
|
89 // --------------------------------------------------------- |
|
90 // |
|
91 TInt CRoapAppView::CountComponentControls() const |
|
92 { |
|
93 return 1; |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------- |
|
97 // CRoapAppView::ComponentControl() |
|
98 // --------------------------------------------------------- |
|
99 // |
|
100 CCoeControl* CRoapAppView::ComponentControl( TInt aIndex ) const |
|
101 { |
|
102 if ( aIndex == 0 ) |
|
103 { |
|
104 return iLabel; |
|
105 } |
|
106 else |
|
107 { |
|
108 return NULL; |
|
109 } |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------- |
|
113 // CRoapAppView::OfferKeyEventL() |
|
114 // --------------------------------------------------------- |
|
115 // |
|
116 TKeyResponse CRoapAppView::OfferKeyEventL |
|
117 ( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
118 { |
|
119 return iLabel->OfferKeyEventL( aKeyEvent, aType ); |
|
120 } |
|
121 |
|
122 // --------------------------------------------------------- |
|
123 // CRoapAppView::Draw() |
|
124 // --------------------------------------------------------- |
|
125 // |
|
126 void CRoapAppView::Draw( const TRect& aRect ) const |
|
127 { |
|
128 // Get the standard graphics context |
|
129 CWindowGc& gc = SystemGc(); |
|
130 |
|
131 // Redraw the background using the default skin |
|
132 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
133 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
|
134 AknsDrawUtils::Background( skin, cc, this, gc, aRect ); |
|
135 |
|
136 gc.Clear( aRect ); |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------- |
|
140 // CRoapAppView::CRoapAppView() |
|
141 // --------------------------------------------------------- |
|
142 // |
|
143 CRoapAppView::CRoapAppView( MObjectProvider* aMopParent ) |
|
144 { |
|
145 SetMopParent( aMopParent ); |
|
146 } |
|
147 |
|
148 // --------------------------------------------------------- |
|
149 // CRoapAppView:ConstructL() |
|
150 // --------------------------------------------------------- |
|
151 // |
|
152 void CRoapAppView::ConstructL( const TRect& aRect ) |
|
153 { |
|
154 CreateWindowL(); |
|
155 iLabel = new (ELeave) CEikLabel; |
|
156 iLabel->SetContainerWindowL( *this ); |
|
157 TResourceReader rr; |
|
158 iBgContext = CAknsBasicBackgroundControlContext::NewL( KAknsIIDQsnBgAreaMain,aRect,ETrue); |
|
159 iCoeEnv->CreateResourceReaderLC( rr, R_ROAP_APP_LABEL ); |
|
160 iLabel->ConstructFromResourceL( rr ); |
|
161 CleanupStack::PopAndDestroy(); // rr |
|
162 iLabel->ActivateL(); |
|
163 SetRect( aRect ); |
|
164 ActivateL(); |
|
165 } |