|
1 /* |
|
2 * Copyright (c) 2008 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: Screen class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "alfscreen.h" |
|
21 |
|
22 #include <aknenv.h> |
|
23 #include <AknsConstants.h> |
|
24 #include <s32mem.h> |
|
25 |
|
26 #include <uiacceltk/HuiEnv.h> |
|
27 #include <uiacceltk/HuiSkin.h> |
|
28 #include <uiacceltk/HuiDisplay.h> |
|
29 #include <uiacceltk/HuiControl.h> |
|
30 #include <uiacceltk/HuiControlGroup.h> |
|
31 #include <uiacceltk/HuiEvent.h> |
|
32 #include <uiacceltk/HuiDeckLayout.h> |
|
33 #include <uiacceltk/HuiImageVisual.h> |
|
34 #include <uiacceltk/HuiTransformation.h> |
|
35 #include <uiacceltk/HuiBorderBrush.h> |
|
36 #include <uiacceltk/HuiUtil.h> |
|
37 #include <uiacceltk/HuiTextVisual.h> |
|
38 #include <uiacceltk/HuiGradientBrush.h> |
|
39 #include <uiacceltk/HuiImageBrush.h> |
|
40 #include <uiacceltk/HuiCanvasVisual.h> |
|
41 |
|
42 #ifdef SYMBIAN_BUILD_GCE |
|
43 #include <bautils.h> |
|
44 #endif |
|
45 |
|
46 //_LIT8(KAlfSessionContainerControlTag, "Session container"); |
|
47 _LIT8(KAlfWindowFloatingSpriteContainerControlTag, "FSPRITE"); |
|
48 _LIT8(KAlfFullScreenEffectContainerControlTag, "EFFECT"); |
|
49 //_LIT8(KAlfWindowGroupTemporaryRemoveControlTag, "WGTEMP"); |
|
50 |
|
51 |
|
52 // ======== MEMBER FUNCTIONS ======== |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 CAlfScreen::CAlfScreen() |
|
58 { |
|
59 }; |
|
60 |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 void CAlfScreen::ConstructL(TInt aScreenNum, MHuiDisplayRefreshObserver& aObserver, CHuiEnv& aHuiEnv, CAlfSharedDisplayCoeControl* aSharedCoeControl) |
|
66 { |
|
67 iScreenNum = aScreenNum; |
|
68 |
|
69 CAlfSharedDisplayCoeControl* coeControl = aSharedCoeControl; |
|
70 if (!coeControl) |
|
71 { |
|
72 // Create own coe control |
|
73 |
|
74 // \todo: This works only if the screen is created to screen 0. Do *not* work |
|
75 // for external screens. |
|
76 iCoeControl = new (ELeave) CAlfSharedDisplayCoeControl(); |
|
77 iCoeControl->ConstructL(); |
|
78 iCoeControl->DrawableWindow()->EnableVisibilityChangeEvents(); |
|
79 iCoeControl->DrawableWindow()->SetPosition(TPoint(0, 0)); |
|
80 |
|
81 // This is not the main ALF native control, put it back |
|
82 iCoeControl->DrawableWindow()->SetOrdinalPosition(-2000); |
|
83 |
|
84 coeControl = iCoeControl; |
|
85 } |
|
86 |
|
87 // Resolve screen buffer uid |
|
88 // \todo currently only screen 0 and 1 are supported |
|
89 TUid screenBufferUid; |
|
90 switch(iScreenNum) |
|
91 { |
|
92 case 0: |
|
93 screenBufferUid = KHuiUidBackBufferScreen0; |
|
94 break; |
|
95 case 1: |
|
96 default: |
|
97 screenBufferUid = KHuiUidBackBufferScreen1; |
|
98 break; |
|
99 } |
|
100 |
|
101 // create display |
|
102 iDisplay = &aHuiEnv.NewDisplayL(coeControl->Rect(), coeControl, 0, NULL,CHuiDisplay::EDisplayNormal, screenBufferUid); |
|
103 CommonConstructL(aObserver, aHuiEnv); |
|
104 } |
|
105 |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // --------------------------------------------------------------------------- |
|
109 // |
|
110 void CAlfScreen::ConstructL(TInt aScreenNum, MHuiDisplayRefreshObserver& aObserver, CHuiEnv& aHuiEnv, RWindow* aWindow) |
|
111 { |
|
112 iScreenNum = aScreenNum; |
|
113 |
|
114 TUid screenBufferUid; |
|
115 switch(iScreenNum) |
|
116 { |
|
117 case 0: |
|
118 screenBufferUid = KHuiUidBackBufferScreen0; |
|
119 break; |
|
120 case 1: |
|
121 default: |
|
122 screenBufferUid = KHuiUidBackBufferScreen1; |
|
123 break; |
|
124 } |
|
125 |
|
126 // create display |
|
127 iDisplay = &aHuiEnv.NewDisplayL(aWindow, 0, NULL,CHuiDisplay::EDisplayNormal, screenBufferUid); |
|
128 CommonConstructL(aObserver, aHuiEnv); |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // --------------------------------------------------------------------------- |
|
133 // |
|
134 void CAlfScreen::CommonConstructL( MHuiDisplayRefreshObserver& aObserver, CHuiEnv& aHuiEnv) |
|
135 { |
|
136 |
|
137 iDisplay->iRefreshObservers.AppendL(aObserver); |
|
138 |
|
139 // Create special control group for floating sprites |
|
140 iFloatingSpriteControlGroup = &aHuiEnv.NewControlGroupL(0xDEADBEEF + iScreenNum); // TODO |
|
141 CHuiControl* cntrl = new (ELeave) CHuiControl(aHuiEnv); |
|
142 CleanupStack::PushL(cntrl); |
|
143 cntrl->ConstructL(); |
|
144 cntrl->SetRole(EAlfWindowFloatingSpriteContainer); |
|
145 iFloatingSpriteControlGroup->AppendL(cntrl); |
|
146 CleanupStack::Pop(cntrl); |
|
147 CHuiCanvasVisual* layout = CHuiCanvasVisual::AddNewL(*cntrl); |
|
148 layout->SetTagL(KAlfWindowFloatingSpriteContainerControlTag); |
|
149 |
|
150 // Create special control group for full screen effects |
|
151 iFullscreenEffectControlGroup = &aHuiEnv.NewControlGroupL(0xDEADBEEF + 10 + iScreenNum ); // TODO |
|
152 CHuiControl* effectCntrl = new (ELeave) CHuiControl(aHuiEnv); |
|
153 CleanupStack::PushL(effectCntrl); |
|
154 effectCntrl->ConstructL(); |
|
155 effectCntrl->SetRole(EAlfFullScreenEffectContainer); |
|
156 iFullscreenEffectControlGroup->AppendL(effectCntrl); |
|
157 CleanupStack::Pop(effectCntrl); |
|
158 CHuiCanvasVisual* effectLayout = CHuiCanvasVisual::AddNewL(*effectCntrl); |
|
159 effectLayout->SetTagL(KAlfFullScreenEffectContainerControlTag); |
|
160 |
|
161 #ifdef SYMBIAN_BUILD_GCE |
|
162 #ifndef __WINSCW__ |
|
163 _LIT(KRDSupport, "c:\\resource\\errrd" ); |
|
164 if (CHuiStatic::FsSession().Handle() && BaflUtils::FileExists( CHuiStatic::FsSession(), KRDSupport )) |
|
165 { |
|
166 // FPS Counter with hitchcock drawing |
|
167 iFPSText = CHuiTextVisual::AddNewL(*effectCntrl, effectLayout); |
|
168 iFPSText->SetColor(KRgbBlue); |
|
169 iFPSText->SetFlag(EHuiVisualFlagManualLayout); |
|
170 iFPSText->SetPos(THuiRealPoint(300,20)); // could be adjusted |
|
171 iFPSText->SetSize(THuiRealSize(50,50)); |
|
172 } |
|
173 #endif |
|
174 #endif |
|
175 } |
|
176 |
|
177 |
|
178 // --------------------------------------------------------------------------- |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 TSize CAlfScreen::Size() const |
|
182 { |
|
183 return iDisplay->VisibleArea().Size(); |
|
184 } |
|
185 |
|
186 // --------------------------------------------------------------------------- |
|
187 // --------------------------------------------------------------------------- |
|
188 // |
|
189 CAlfScreen::~CAlfScreen() |
|
190 { |
|
191 // this deletes also control and layout |
|
192 delete iFullscreenEffectControlGroup; |
|
193 |
|
194 // this deletes also control and layout |
|
195 delete iFloatingSpriteControlGroup; |
|
196 |
|
197 delete iDisplay; |
|
198 iControlGroups.Close(); |
|
199 |
|
200 delete iCoeControl; |
|
201 |
|
202 delete iSwRenderingTarget; |
|
203 }; |
|
204 |
|
205 // --------------------------------------------------------------------------- |
|
206 // --------------------------------------------------------------------------- |
|
207 // |
|
208 void CAlfScreen::SetVisualTreeVisibilityChanged(TBool aChanged) |
|
209 { |
|
210 if (aChanged && iDisplay) |
|
211 { |
|
212 iDisplay->SetDirty(); |
|
213 } |
|
214 iVisualTreeVisibilityChanged = aChanged; |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------------------------- |
|
218 // --------------------------------------------------------------------------- |
|
219 // |
|
220 TBool CAlfScreen::IsVisualTreeVisibilityChanged() |
|
221 { |
|
222 return iVisualTreeVisibilityChanged; |
|
223 } |
|
224 |