|
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( const TRect& aRect ) |
|
45 { |
|
46 CSimLockUIBackgroundControl* self = CSimLockUIBackgroundControl::NewLC( aRect ); |
|
47 CleanupStack::Pop( self ); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // CSimLockUIBackgroundControl::NewLC |
|
53 // --------------------------------------------------------------------------- |
|
54 CSimLockUIBackgroundControl* CSimLockUIBackgroundControl::NewLC( const TRect& aRect ) |
|
55 { |
|
56 CSimLockUIBackgroundControl* self = new ( ELeave ) CSimLockUIBackgroundControl; |
|
57 CleanupStack::PushL( self ); |
|
58 self->ConstructL( aRect ); |
|
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( const TRect& aRect ) |
|
87 { |
|
88 // Create a window for this application view |
|
89 CreateWindowL(); |
|
90 |
|
91 iBackgroundSkinContext = CAknsBasicBackgroundControlContext::NewL( |
|
92 KAknsIIDQsnBgAreaMain, aRect, EFalse ); |
|
93 |
|
94 // Set the windows size |
|
95 SetRect( aRect ); |
|
96 |
|
97 // Activate the window, which makes it ready to be drawn |
|
98 ActivateL(); |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CSimLockUIBackgroundControl::SizeChanged |
|
103 // --------------------------------------------------------------------------- |
|
104 void CSimLockUIBackgroundControl::SizeChanged() |
|
105 { |
|
106 // Background skin. |
|
107 iBackgroundSkinContext->SetRect( Rect() ); |
|
108 } |
|
109 |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // CSimLockUIBackgroundControl::Draw |
|
113 // --------------------------------------------------------------------------- |
|
114 void CSimLockUIBackgroundControl::Draw( const TRect& /*aRect*/ ) const |
|
115 { |
|
116 // Draw background skin |
|
117 CWindowGc& graphicsContext = SystemGc(); |
|
118 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
119 MAknsControlContext* controlContext = AknsDrawUtils::ControlContext( this ); |
|
120 AknsDrawUtils::Background( skin, controlContext, this, graphicsContext, Rect() ); |
|
121 |
|
122 // Draw background text |
|
123 DisplayText( graphicsContext ); |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // CSimLockUIBackgroundControl::MopSupplyObject |
|
128 // --------------------------------------------------------------------------- |
|
129 TTypeUid::Ptr CSimLockUIBackgroundControl::MopSupplyObject( TTypeUid aId ) |
|
130 { |
|
131 if ( aId.iUid == MAknsControlContext::ETypeId ) |
|
132 { |
|
133 // Return the background skin object |
|
134 return MAknsControlContext::SupplyMopObject( aId, iBackgroundSkinContext ); |
|
135 } |
|
136 |
|
137 return CCoeControl::MopSupplyObject( aId ); |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------------------------- |
|
141 // CSimLockUIBackgroundControl::DisplayText |
|
142 // --------------------------------------------------------------------------- |
|
143 void CSimLockUIBackgroundControl::DisplayText( CGraphicsContext& aGc ) const |
|
144 { |
|
145 if ( iDisplayText ) |
|
146 { |
|
147 // Set up text and layout |
|
148 TAknLayoutText line; |
|
149 TAknTextLineLayout layout = AknLayoutScalable_Avkon::main_pane_empty_t1( KSkinLayoutOption ).LayoutLine(); |
|
150 |
|
151 line.LayoutText( Rect(), layout ); |
|
152 |
|
153 // Get color from skin instance. |
|
154 TRgb color( line.Color() ); |
|
155 |
|
156 if ( AknsUtils::AvkonSkinEnabled() ) |
|
157 { |
|
158 TRgb skinColor; |
|
159 |
|
160 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
161 |
|
162 TInt err = AknsUtils::GetCachedColor( skin, |
|
163 skinColor, |
|
164 KAknsIIDQsnTextColors, |
|
165 EAknsCIQsnTextColorsCG6 ); |
|
166 if ( err == KErrNone ) |
|
167 { |
|
168 color = skinColor; |
|
169 } |
|
170 } |
|
171 |
|
172 // Actually display the text |
|
173 line.DrawText( aGc, *iDisplayText, ETrue, color ); |
|
174 } |
|
175 } |
|
176 |
|
177 // End of file. |
|
178 |