author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 15 Sep 2010 12:09:15 +0300 | |
branch | RCL_3 |
changeset 38 | ac48f0cc9f9c |
parent 33 | bc78a40cd63c |
child 41 | 755f0370535b |
permissions | -rw-r--r-- |
33 | 1 |
/* |
2 |
* Copyright (c) 2005 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 "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: The MUS application's UI class. |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
#include "musuibackgroundviewcontainer.h" |
|
19 |
#include "musuiappui.h" |
|
20 |
#include "muslogger.h" // debug logging |
|
38
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
21 |
#include "musuieventcontroller.h" |
33 | 22 |
|
23 |
#include <AknsControlContext.h> |
|
24 |
#include <AknsBasicBackgroundControlContext.h> |
|
25 |
#include <AknsDrawUtils.h> |
|
26 |
#include <StringLoader.h> // StringLoader |
|
27 |
#include <aknnotewrappers.h> |
|
28 |
#include <AknWaitDialog.h> |
|
29 |
#include <AknGlobalNote.h> |
|
30 |
#include <AknDef.h> |
|
31 |
||
32 |
||
33 |
// Hidden window group. magic number 32 hiddens window |
|
34 |
_LIT( KMusUiBackgroundWindowGroupName,"32MusUiBackground" ); |
|
35 |
||
36 |
||
37 |
// ----------------------------------------------------------------------------- |
|
38 |
// |
|
39 |
// ----------------------------------------------------------------------------- |
|
40 |
// |
|
41 |
CMusUiBackgroundViewContainer* CMusUiBackgroundViewContainer::NewL( |
|
42 |
const TRect& aRect, |
|
43 |
TInt aOrdinalPosition ) |
|
44 |
{ |
|
45 |
CMusUiBackgroundViewContainer* self = |
|
46 |
new( ELeave )CMusUiBackgroundViewContainer( aOrdinalPosition ); |
|
47 |
CleanupStack::PushL( self ); |
|
48 |
self->ConstructL( aRect ); |
|
49 |
CleanupStack::Pop( self ); |
|
50 |
return self; |
|
51 |
} |
|
52 |
||
53 |
// ----------------------------------------------------------------------------- |
|
54 |
// |
|
55 |
// ----------------------------------------------------------------------------- |
|
56 |
// |
|
57 |
CMusUiBackgroundViewContainer::CMusUiBackgroundViewContainer( |
|
38
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
58 |
TInt aOrdinalPosition ) : iOrdinalPosition( aOrdinalPosition ), |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
59 |
iController( NULL ) |
33 | 60 |
{ |
61 |
} |
|
62 |
||
63 |
// ----------------------------------------------------------------------------- |
|
64 |
// |
|
65 |
// ----------------------------------------------------------------------------- |
|
66 |
// |
|
67 |
void CMusUiBackgroundViewContainer::ConstructL( const TRect& aRect ) |
|
68 |
{ |
|
69 |
MUS_LOG( "mus: [MUSUI ] -> CMusUiBackgroundViewContainer::ConstructL()" ); |
|
70 |
||
71 |
RWindowGroup iMyWindowGroup = RWindowGroup( iCoeEnv->WsSession() ); |
|
72 |
User::LeaveIfError( iMyWindowGroup.Construct( ( TUint32 )&iMyWindowGroup) ); |
|
73 |
||
74 |
iMyWindowGroup.SetName( KMusUiBackgroundWindowGroupName ); |
|
75 |
iMyWindowGroup.SetOrdinalPosition( iOrdinalPosition, ECoeWinPriorityNormal ); |
|
76 |
iMyWindowGroup.EnableReceiptOfFocus( EFalse ); |
|
77 |
iMyWindowGroup.AutoForeground( EFalse ); |
|
78 |
iMyWindowGroup.SetNonFading( ETrue ); |
|
79 |
||
80 |
CreateWindowL(&iMyWindowGroup); |
|
81 |
||
82 |
iGroupIdentifier = iMyWindowGroup.Identifier(); |
|
83 |
||
84 |
iBackGround = CAknsBasicBackgroundControlContext::NewL( |
|
85 |
KAknsIIDQsnBgAreaMain, |
|
86 |
aRect, |
|
87 |
EFalse ); |
|
88 |
||
89 |
SetRect( aRect ); |
|
90 |
||
91 |
ActivateL(); |
|
92 |
||
93 |
MUS_LOG( "mus: [MUSUI ] <- CMusUiBackgroundViewContainer::ConstructL()" ); |
|
94 |
} |
|
95 |
||
96 |
// ----------------------------------------------------------------------------- |
|
97 |
// |
|
98 |
// ----------------------------------------------------------------------------- |
|
99 |
// |
|
100 |
CMusUiBackgroundViewContainer::~CMusUiBackgroundViewContainer() |
|
101 |
{ |
|
102 |
MUS_LOG( "mus: [MUSUI ] -> CMusUiBackgroundViewContainer::~CMusUiBackgroundViewContainer()" ); |
|
103 |
delete iBackGround; |
|
104 |
MUS_LOG( "mus: [MUSUI ] <- CMusUiBackgroundViewContainer::~CMusUiBackgroundViewContainer()" ); |
|
105 |
} |
|
106 |
||
107 |
// ----------------------------------------------------------------------------- |
|
108 |
// |
|
109 |
// ----------------------------------------------------------------------------- |
|
110 |
// |
|
111 |
void CMusUiBackgroundViewContainer::RefreshView() |
|
112 |
{ |
|
113 |
MUS_LOG( "mus: [MUSUI ] -> CMusUiBackgroundViewContainer::RefreshView()" ); |
|
114 |
||
115 |
DrawNow(); |
|
116 |
||
117 |
MUS_LOG( "mus: [MUSUI ] <- CMusUiBackgroundViewContainer::RefreshView()" ); |
|
118 |
} |
|
119 |
||
120 |
||
121 |
// ----------------------------------------------------------------------------- |
|
122 |
// Set's this group right ordinal position |
|
123 |
// ----------------------------------------------------------------------------- |
|
124 |
// |
|
125 |
void CMusUiBackgroundViewContainer::SetOrdinalPosition() |
|
126 |
{ |
|
127 |
MUS_LOG1( "mus: [MUSUI ] -> CMusUiBackgroundViewContainer::SetOrdinalPosition(): %d", |
|
128 |
iOrdinalPosition ); |
|
129 |
MakeVisible( ETrue ); |
|
130 |
||
131 |
iCoeEnv->WsSession().SetWindowGroupOrdinalPosition( iGroupIdentifier, |
|
132 |
iOrdinalPosition ); |
|
133 |
||
134 |
DrawNow(); |
|
135 |
MUS_LOG( "mus: [MUSUI ] <- CMusUiBackgroundViewContainer::SetOrdinalPosition()" ); |
|
136 |
} |
|
137 |
||
138 |
// ----------------------------------------------------------------------------- |
|
139 |
// Set's this group right ordinal position |
|
140 |
// ----------------------------------------------------------------------------- |
|
141 |
// |
|
142 |
void CMusUiBackgroundViewContainer::SetOrdinalPosition( TInt aOrdianlPosition) |
|
143 |
{ |
|
144 |
MUS_LOG1( "mus: [MUSUI ] -> CMusUiBackgroundViewContainer::SetOrdinalPosition(): %d", |
|
145 |
aOrdianlPosition ); |
|
146 |
MakeVisible( ETrue ); |
|
147 |
||
148 |
iCoeEnv->WsSession().SetWindowGroupOrdinalPosition( iGroupIdentifier, |
|
149 |
aOrdianlPosition ); |
|
150 |
||
151 |
DrawNow(); |
|
152 |
MUS_LOG( "mus: [MUSUI ] <- CMusUiBackgroundViewContainer::SetOrdinalPosition()" ); |
|
153 |
} |
|
154 |
||
155 |
// ----------------------------------------------------------------------------- |
|
156 |
// |
|
157 |
// ----------------------------------------------------------------------------- |
|
158 |
// |
|
159 |
void CMusUiBackgroundViewContainer::UpdateOrdinalPositionValue( TBool aUp ) |
|
160 |
{ |
|
161 |
MUS_LOG1( "mus: [MUSUI ] -> CMusUiBackgroundViewContainer::UpdateOrdinalPositionValue(): %d", |
|
162 |
aUp ); |
|
163 |
if ( aUp ) |
|
164 |
{ |
|
165 |
++iOrdinalPosition; |
|
166 |
} |
|
167 |
else |
|
168 |
{ |
|
169 |
--iOrdinalPosition; |
|
170 |
} |
|
171 |
SetOrdinalPosition(); |
|
172 |
MUS_LOG( "mus: [MUSUI ] <- CMusUiBackgroundViewContainer::UpdateOrdinalPositionValue()" ); |
|
173 |
} |
|
174 |
||
175 |
||
176 |
// ----------------------------------------------------------------------------- |
|
38
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
177 |
// Sets the event controller |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
178 |
// ----------------------------------------------------------------------------- |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
179 |
// |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
180 |
void CMusUiBackgroundViewContainer::SetUiEventController( CMusUiEventController* aController ) |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
181 |
{ |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
182 |
iController = aController; |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
183 |
} |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
184 |
|
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
185 |
|
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
186 |
// ----------------------------------------------------------------------------- |
33 | 187 |
// Called by framework when the view size is changed |
188 |
// ----------------------------------------------------------------------------- |
|
189 |
// |
|
190 |
void CMusUiBackgroundViewContainer::SizeChanged() |
|
191 |
{ |
|
192 |
MUS_LOG( "mus: [MUSUI ] -> CMusUiBackgroundViewContainer::SizeChanged()" ); |
|
193 |
TRect parentRect(Rect()); |
|
194 |
if (iBackGround) |
|
195 |
{ |
|
196 |
(static_cast<CAknsBasicBackgroundControlContext*>(iBackGround))->SetRect(parentRect); |
|
197 |
} |
|
198 |
||
199 |
SetOrdinalPosition(); |
|
200 |
//MakeVisible( EFalse ); |
|
201 |
MUS_LOG( "mus: [MUSUI ] <- CMusUiBackgroundViewContainer::SizeChanged()" ); |
|
202 |
} |
|
203 |
||
204 |
||
205 |
// ----------------------------------------------------------------------------- |
|
38
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
206 |
// From base class CCoeControl. Handles a change to the application's |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
207 |
// resources which are shared across the environment. |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
208 |
// ----------------------------------------------------------------------------- |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
209 |
// |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
210 |
void CMusUiBackgroundViewContainer::HandleResourceChange( TInt aType ) |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
211 |
{ |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
212 |
MUS_LOG( "mus: [MUSUI ] -> CMusUiBackgroundViewContainer::HandleResourceChange" ); |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
213 |
CCoeControl::HandleResourceChange( aType ); |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
214 |
|
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
215 |
TBool displayEnabled( EFalse ); |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
216 |
if ( iController ) |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
217 |
{ |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
218 |
TRAP_IGNORE( displayEnabled = iController->IsDisplayEnabledL() ) |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
219 |
} |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
220 |
|
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
221 |
if ( aType == KEikDynamicLayoutVariantSwitch && !displayEnabled ) |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
222 |
{ |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
223 |
TRect mainPaneRect; |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
224 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
225 |
mainPaneRect ); |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
226 |
SetRect( mainPaneRect ); |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
227 |
} |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
228 |
MUS_LOG( "mus: [MUSUI ] <- CMusUiBackgroundViewContainer::HandleResourceChange" ); |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
229 |
} |
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
230 |
|
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
231 |
|
ac48f0cc9f9c
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
232 |
// ----------------------------------------------------------------------------- |
33 | 233 |
// Called by framework when to retrieve the no. of controls. |
234 |
// ----------------------------------------------------------------------------- |
|
235 |
// |
|
236 |
TInt CMusUiBackgroundViewContainer::CountComponentControls() const |
|
237 |
{ |
|
238 |
return 0; // return nbr of controls inside this container |
|
239 |
} |
|
240 |
||
241 |
||
242 |
// ----------------------------------------------------------------------------- |
|
243 |
// Called by framework to retrieve the control specified by index. |
|
244 |
// ----------------------------------------------------------------------------- |
|
245 |
// |
|
246 |
CCoeControl* CMusUiBackgroundViewContainer::ComponentControl( TInt /*aIndex*/ ) const |
|
247 |
{ |
|
248 |
return NULL; |
|
249 |
} |
|
250 |
||
251 |
||
252 |
// ----------------------------------------------------------------------------- |
|
253 |
// Called by framework to redraw the screen area. |
|
254 |
// ----------------------------------------------------------------------------- |
|
255 |
// |
|
256 |
void CMusUiBackgroundViewContainer::Draw( const TRect& aRect ) const |
|
257 |
{ |
|
258 |
MUS_LOG( "mus: [MUSUI ] -> CMusUiBackgroundViewContainer::Draw()" ); |
|
259 |
||
260 |
CWindowGc& gc = SystemGc(); |
|
261 |
||
262 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
263 |
MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
|
264 |
if(!AknsDrawUtils::Background( skin, cc,this,gc,aRect,KAknsDrawParamDefault )) |
|
265 |
{ |
|
266 |
MUS_LOG( "mus: [MUSUI ] Skin not valid or not found" ); |
|
267 |
gc.SetBrushColor( iEikonEnv->ControlColor( EColorWindowBackground, *this ) ); |
|
268 |
gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
269 |
gc.Clear( aRect ); |
|
270 |
} |
|
271 |
||
272 |
MUS_LOG( "mus: [MUSUI ] <- CMusUiBackgroundViewContainer::Draw()" ); |
|
273 |
} |
|
274 |
||
275 |
// ----------------------------------------------------------------------------- |
|
276 |
// |
|
277 |
// ----------------------------------------------------------------------------- |
|
278 |
// |
|
279 |
void CMusUiBackgroundViewContainer::HandleControlEventL( |
|
280 |
CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/) |
|
281 |
{ |
|
282 |
// TODO: Add your control event handler code here |
|
283 |
} |
|
284 |
||
285 |
||
286 |
// ----------------------------------------------------------------------------- |
|
287 |
// Called by framework to act on key events if required. |
|
288 |
// ----------------------------------------------------------------------------- |
|
289 |
// |
|
290 |
TKeyResponse CMusUiBackgroundViewContainer::OfferKeyEventL( |
|
291 |
const TKeyEvent& /*aKeyEvent*/, |
|
292 |
TEventCode /*aType*/ ) |
|
293 |
{ |
|
294 |
return EKeyWasNotConsumed; |
|
295 |
} |
|
296 |
||
297 |
||
298 |
// ----------------------------------------------------------------------------- |
|
299 |
// Supply the Mob Object for background skin drawing |
|
300 |
// ----------------------------------------------------------------------------- |
|
301 |
// |
|
302 |
TTypeUid::Ptr CMusUiBackgroundViewContainer::MopSupplyObject( TTypeUid aId ) |
|
303 |
{ |
|
304 |
if (aId.iUid == MAknsControlContext::ETypeId && iBackGround ) |
|
305 |
{ |
|
306 |
return MAknsControlContext::SupplyMopObject( aId, iBackGround ); |
|
307 |
} |
|
308 |
return CCoeControl::MopSupplyObject( aId ); |
|
309 |
} |
|
310 |
||
311 |
||
312 |
||
313 |
// end of file |