22
|
1 |
/*
|
|
2 |
* ============================================================================
|
|
3 |
* Name : SimLockUIBackgroundControl.cpp
|
|
4 |
* Part of : Sim Lock UI Application
|
|
5 |
* Description : Implementation of Sim Lock UI Background
|
|
6 |
* Version :
|
|
7 |
*
|
|
8 |
* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
9 |
* All rights reserved.
|
|
10 |
* This component and the accompanying materials are made available
|
|
11 |
* under the terms of "Eclipse Public License v1.0"
|
|
12 |
* which accompanies this distribution, and is available
|
|
13 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
14 |
*
|
|
15 |
* Initial Contributors:
|
|
16 |
* Nokia Corporation - initial contribution.
|
|
17 |
*
|
|
18 |
* Contributors:
|
|
19 |
*
|
|
20 |
* Description: Build info file for Ado domain appinstall
|
|
21 |
* ============================================================================
|
|
22 |
*/
|
|
23 |
|
|
24 |
|
|
25 |
// System Includes
|
|
26 |
#include <coemain.h>
|
|
27 |
#include <AknsDrawUtils.h> // AknsDrawUtils
|
|
28 |
#include <AknsSkinInstance.h> // MAknsSkinInstance
|
|
29 |
#include <AknsControlContext.h> // MAknsControlContext
|
|
30 |
#include <AknsBasicBackgroundControlContext.h> // CAknsBasicBackgroundControlContext
|
|
31 |
#include <aknlayoutscalable_avkon.cdl.h> // AknLayoutScalable_Avkon
|
|
32 |
#include <AknUtils.h> // AknsUtils
|
|
33 |
|
|
34 |
// User Includes
|
|
35 |
#include "simlockuibackgroundcontrol.h"
|
|
36 |
#include "simlockisaserverdefinitions.h"
|
|
37 |
#include <simlockui.rsg>
|
|
38 |
|
|
39 |
static const TInt KSkinLayoutOption = 2;
|
|
40 |
|
|
41 |
// ---------------------------------------------------------------------------
|
|
42 |
// CSimLockUIBackgroundControl::NewL
|
|
43 |
// ---------------------------------------------------------------------------
|
|
44 |
CSimLockUIBackgroundControl* CSimLockUIBackgroundControl::NewL()
|
|
45 |
{
|
|
46 |
CSimLockUIBackgroundControl* self = CSimLockUIBackgroundControl::NewLC();
|
|
47 |
CleanupStack::Pop( self );
|
|
48 |
return self;
|
|
49 |
}
|
|
50 |
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
// CSimLockUIBackgroundControl::NewLC
|
|
53 |
// ---------------------------------------------------------------------------
|
|
54 |
CSimLockUIBackgroundControl* CSimLockUIBackgroundControl::NewLC()
|
|
55 |
{
|
|
56 |
CSimLockUIBackgroundControl* self = new ( ELeave ) CSimLockUIBackgroundControl;
|
|
57 |
CleanupStack::PushL( self );
|
|
58 |
self->ConstructL();
|
|
59 |
return self;
|
|
60 |
}
|
|
61 |
|
|
62 |
// ---------------------------------------------------------------------------
|
|
63 |
// CSimLockUIBackgroundControl::~CSimLockUIBackgroundControl
|
|
64 |
// ---------------------------------------------------------------------------
|
|
65 |
CSimLockUIBackgroundControl::~CSimLockUIBackgroundControl()
|
|
66 |
{
|
|
67 |
delete iBackgroundSkinContext;
|
|
68 |
delete iDisplayText;
|
|
69 |
}
|
|
70 |
|
|
71 |
// ---------------------------------------------------------------------------
|
|
72 |
// CSimLockUIBackgroundControl::SetBackgroundText
|
|
73 |
// ---------------------------------------------------------------------------
|
|
74 |
void CSimLockUIBackgroundControl::SetBackgroundText( HBufC* aText )
|
|
75 |
{
|
|
76 |
delete iDisplayText;
|
|
77 |
|
|
78 |
iDisplayText = aText;
|
|
79 |
|
|
80 |
DrawDeferred();
|
|
81 |
}
|
|
82 |
|
|
83 |
// ---------------------------------------------------------------------------
|
|
84 |
// CSimLockUIBackgroundControl::ConstructL
|
|
85 |
// ---------------------------------------------------------------------------
|
|
86 |
void CSimLockUIBackgroundControl::ConstructL()
|
|
87 |
{
|
|
88 |
// Create a window for this application view
|
|
89 |
CreateWindowL();
|
|
90 |
SetExtentToWholeScreen();
|
|
91 |
|
|
92 |
iBackgroundSkinContext = CAknsBasicBackgroundControlContext::NewL(
|
|
93 |
KAknsIIDQsnBgAreaMain, Rect(), EFalse );
|
|
94 |
|
|
95 |
// Activate the window, which makes it ready to be drawn
|
|
96 |
ActivateL();
|
|
97 |
}
|
|
98 |
|
|
99 |
// ---------------------------------------------------------------------------
|
|
100 |
// CSimLockUIBackgroundControl::SizeChanged
|
|
101 |
// ---------------------------------------------------------------------------
|
|
102 |
void CSimLockUIBackgroundControl::SizeChanged()
|
|
103 |
{
|
|
104 |
// Background skin.
|
|
105 |
if ( iBackgroundSkinContext )
|
|
106 |
iBackgroundSkinContext->SetRect( Rect() );
|
|
107 |
}
|
|
108 |
|
|
109 |
// ---------------------------------------------------------------------------
|
|
110 |
// CSimLockUIBackgroundControl::HandleResourceChange()
|
|
111 |
// ---------------------------------------------------------------------------
|
|
112 |
//
|
|
113 |
void CSimLockUIBackgroundControl::HandleResourceChange( TInt aType )
|
|
114 |
{
|
|
115 |
CCoeControl::HandleResourceChange( aType );
|
|
116 |
|
|
117 |
if ( aType == KEikDynamicLayoutVariantSwitch )
|
|
118 |
{
|
|
119 |
SetExtentToWholeScreen();
|
|
120 |
}
|
|
121 |
}
|
|
122 |
|
|
123 |
|
|
124 |
// ---------------------------------------------------------------------------
|
|
125 |
// CSimLockUIBackgroundControl::Draw
|
|
126 |
// ---------------------------------------------------------------------------
|
|
127 |
void CSimLockUIBackgroundControl::Draw( const TRect& /*aRect*/ ) const
|
|
128 |
{
|
|
129 |
// Draw background skin
|
|
130 |
CWindowGc& graphicsContext = SystemGc();
|
|
131 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
|
|
132 |
MAknsControlContext* controlContext = AknsDrawUtils::ControlContext( this );
|
|
133 |
AknsDrawUtils::Background( skin, controlContext, this, graphicsContext, Rect() );
|
|
134 |
|
|
135 |
// Draw background text
|
|
136 |
DisplayText( graphicsContext );
|
|
137 |
}
|
|
138 |
|
|
139 |
// ---------------------------------------------------------------------------
|
|
140 |
// CSimLockUIBackgroundControl::MopSupplyObject
|
|
141 |
// ---------------------------------------------------------------------------
|
|
142 |
TTypeUid::Ptr CSimLockUIBackgroundControl::MopSupplyObject( TTypeUid aId )
|
|
143 |
{
|
|
144 |
if ( aId.iUid == MAknsControlContext::ETypeId )
|
|
145 |
{
|
|
146 |
// Return the background skin object
|
|
147 |
return MAknsControlContext::SupplyMopObject( aId, iBackgroundSkinContext );
|
|
148 |
}
|
|
149 |
|
|
150 |
return CCoeControl::MopSupplyObject( aId );
|
|
151 |
}
|
|
152 |
|
|
153 |
// ---------------------------------------------------------------------------
|
|
154 |
// CSimLockUIBackgroundControl::DisplayText
|
|
155 |
// ---------------------------------------------------------------------------
|
|
156 |
void CSimLockUIBackgroundControl::DisplayText( CGraphicsContext& aGc ) const
|
|
157 |
{
|
|
158 |
if ( iDisplayText )
|
|
159 |
{
|
|
160 |
// Set up text and layout
|
|
161 |
TAknLayoutText line;
|
|
162 |
TAknTextLineLayout layout = AknLayoutScalable_Avkon::main_pane_empty_t1( KSkinLayoutOption ).LayoutLine();
|
|
163 |
|
|
164 |
line.LayoutText( Rect(), layout );
|
|
165 |
|
|
166 |
// Get color from skin instance.
|
|
167 |
TRgb color( line.Color() );
|
|
168 |
|
|
169 |
if ( AknsUtils::AvkonSkinEnabled() )
|
|
170 |
{
|
|
171 |
TRgb skinColor;
|
|
172 |
|
|
173 |
MAknsSkinInstance* skin = AknsUtils::SkinInstance();
|
|
174 |
|
|
175 |
TInt err = AknsUtils::GetCachedColor( skin,
|
|
176 |
skinColor,
|
|
177 |
KAknsIIDQsnTextColors,
|
|
178 |
EAknsCIQsnTextColorsCG6 );
|
|
179 |
if ( err == KErrNone )
|
|
180 |
{
|
|
181 |
color = skinColor;
|
|
182 |
}
|
|
183 |
}
|
|
184 |
|
|
185 |
// Actually display the text
|
|
186 |
line.DrawText( aGc, *iDisplayText, ETrue, color );
|
|
187 |
}
|
|
188 |
}
|
|
189 |
|
|
190 |
// End of file.
|
|
191 |
|