|
1 /* |
|
2 * Copyright (c) 2006-2007 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: Implementation of the CHuiDisplayCoeControl class. |
|
15 * CHuiDisplayCoeControl is a CCoeControl that has its own |
|
16 * CHuiDisplay instance attached to the control's RWindow. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 |
|
22 #include "uiacceltk/HuiDisplayCoeControl.h" // Class definition |
|
23 #include "uiacceltk/HuiEnv.h" |
|
24 #include "uiacceltk/HuiDisplay.h" |
|
25 #include "uiacceltk/HuiEvent.h" |
|
26 |
|
27 |
|
28 EXPORT_C CHuiDisplayCoeControl* |
|
29 CHuiDisplayCoeControl::NewL(CHuiEnv& aEnv, const TRect& aRect, TInt aFlags) |
|
30 { |
|
31 CHuiDisplayCoeControl* self = CHuiDisplayCoeControl::NewLC(aEnv, aRect, aFlags); |
|
32 CleanupStack::Pop(self); |
|
33 return self; |
|
34 } |
|
35 |
|
36 |
|
37 EXPORT_C CHuiDisplayCoeControl* |
|
38 CHuiDisplayCoeControl::NewLC(CHuiEnv& aEnv, const TRect& aRect, TInt aFlags) |
|
39 { |
|
40 CHuiDisplayCoeControl* self = new (ELeave) CHuiDisplayCoeControl(aEnv); |
|
41 CleanupStack::PushL(self); |
|
42 self->ConstructL(aRect, aFlags); |
|
43 return self; |
|
44 } |
|
45 |
|
46 |
|
47 EXPORT_C CHuiDisplayCoeControl::CHuiDisplayCoeControl(CHuiEnv& aEnv) |
|
48 : iEnv(aEnv) |
|
49 { |
|
50 } |
|
51 |
|
52 |
|
53 EXPORT_C void CHuiDisplayCoeControl::ConstructL(const TRect& aRect, TInt aFlags) |
|
54 { |
|
55 // The display has its own window. |
|
56 CreateWindowL(); |
|
57 #ifndef SYMBIAN_BUILD_GCE |
|
58 Window().EnableOSB(EFalse); |
|
59 #endif |
|
60 // Set the size of the control. |
|
61 SetRect(aRect); |
|
62 |
|
63 if(aFlags & CHuiEnv::ENewDisplayFullScreen) |
|
64 { |
|
65 SetExtentToWholeScreen(); |
|
66 } |
|
67 |
|
68 // Create a new CHuiDisplay for our window. We don't get ownership of |
|
69 // the display instance. |
|
70 iDisplay = &iEnv.NewDisplayL(Rect(), this, aFlags); |
|
71 |
|
72 // Since display creation went ok, we know that this rectangle size can be handled. |
|
73 iPrevRect = aRect; |
|
74 |
|
75 // The control is now ready to be drawn. |
|
76 ActivateL(); |
|
77 |
|
78 EnableDragEvents(); |
|
79 } |
|
80 |
|
81 |
|
82 EXPORT_C CHuiDisplayCoeControl::~CHuiDisplayCoeControl() |
|
83 { |
|
84 // if the environment has been destroyed, the display is |
|
85 // already been deleted |
|
86 if (CHuiEnv::Static()) |
|
87 { |
|
88 // The display is discarded. |
|
89 delete iDisplay; |
|
90 } |
|
91 } |
|
92 |
|
93 |
|
94 EXPORT_C CHuiEnv& CHuiDisplayCoeControl::Env() |
|
95 { |
|
96 return iEnv; |
|
97 } |
|
98 |
|
99 |
|
100 EXPORT_C CHuiDisplay& CHuiDisplayCoeControl::Display() |
|
101 { |
|
102 return *iDisplay; |
|
103 } |
|
104 |
|
105 |
|
106 EXPORT_C void CHuiDisplayCoeControl::SizeChanged() |
|
107 { |
|
108 if(iDisplay) |
|
109 { |
|
110 // Change the size of the display. |
|
111 TSize size = Rect().Size(); |
|
112 TRAPD(err, iDisplay->SetSizeL(size)); |
|
113 if(err != KErrNone) |
|
114 { |
|
115 // Switching to new size failed. Maintain old size. |
|
116 size = iPrevRect.Size(); |
|
117 } |
|
118 else |
|
119 { |
|
120 iPrevRect = Rect(); |
|
121 } |
|
122 |
|
123 // Redefine the portion of the drawing surface that is used by |
|
124 // the display. |
|
125 iDisplay->SetVisibleArea(TRect(TPoint(0, 0), size)); |
|
126 } |
|
127 } |
|
128 |
|
129 |
|
130 EXPORT_C TInt CHuiDisplayCoeControl::CountComponentControls() const |
|
131 { |
|
132 return 0; |
|
133 } |
|
134 |
|
135 |
|
136 EXPORT_C CCoeControl* CHuiDisplayCoeControl::ComponentControl(TInt /*aIndex*/) const |
|
137 { |
|
138 return NULL; |
|
139 } |
|
140 |
|
141 |
|
142 EXPORT_C void CHuiDisplayCoeControl::Draw(const TRect& /*aRect*/) const |
|
143 { |
|
144 // This is called when the application framework wants us to redraw |
|
145 // a certain portion of the screen. |
|
146 |
|
147 if(iDisplay) |
|
148 { |
|
149 /// @todo Use aRect as the dirty area to redraw. |
|
150 |
|
151 // Make sure refresh is going to happen. |
|
152 iDisplay->SetDirty(); |
|
153 } |
|
154 } |
|
155 |
|
156 |
|
157 EXPORT_C void CHuiDisplayCoeControl::HandleResourceChange(TInt aType) |
|
158 { |
|
159 CCoeControl::HandleResourceChange(aType); |
|
160 } |
|
161 |
|
162 |
|
163 EXPORT_C void CHuiDisplayCoeControl::HandleControlEventL(CCoeControl* /*aControl*/, |
|
164 TCoeEvent /*aEventType*/) |
|
165 { |
|
166 /** @todo What to do here? */ |
|
167 } |
|
168 |
|
169 |
|
170 EXPORT_C TKeyResponse CHuiDisplayCoeControl::OfferKeyEventL(const TKeyEvent& aKeyEvent, |
|
171 TEventCode aType) |
|
172 { |
|
173 THuiEvent event(iDisplay, aKeyEvent, aType); |
|
174 |
|
175 // Notify the environemnt. |
|
176 iEnv.NotifyInputReceivedL(event); |
|
177 |
|
178 if(iDisplay->Roster().HandleEventL(event)) |
|
179 { |
|
180 return EKeyWasConsumed; |
|
181 } |
|
182 return EKeyWasNotConsumed; |
|
183 } |
|
184 |
|
185 |
|
186 EXPORT_C void CHuiDisplayCoeControl::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
187 { |
|
188 THuiEvent event(iDisplay, aPointerEvent); |
|
189 |
|
190 // Notify the environment. |
|
191 iEnv.NotifyInputReceivedL(event); |
|
192 |
|
193 iDisplay->Roster().HandleEventL(event); |
|
194 } |
|
195 |
|
196 EXPORT_C void CHuiDisplayCoeControl::DisplayCoeCntrlExtension(const TUid& /*aExtensionUid*/, TAny** /*aExtensionParams*/) |
|
197 { |
|
198 } |
|
199 |
|
200 EXPORT_C void CHuiDisplayCoeControl::MakeVisible(TBool aVisible) |
|
201 { |
|
202 CCoeControl::MakeVisible(aVisible); |
|
203 } |
|
204 |
|
205 EXPORT_C void CHuiDisplayCoeControl::SetDimmed(TBool aDimmed) |
|
206 { |
|
207 CCoeControl::SetDimmed(aDimmed); |
|
208 } |
|
209 |
|
210 EXPORT_C void CHuiDisplayCoeControl::ConstructFromResourceL(TResourceReader& aReader) |
|
211 { |
|
212 CCoeControl::ConstructFromResourceL(aReader); |
|
213 } |
|
214 |
|
215 EXPORT_C void CHuiDisplayCoeControl::ActivateL() |
|
216 { |
|
217 Window().EnableAdvancedPointers(); |
|
218 CCoeControl::ActivateL(); |
|
219 } |
|
220 |
|
221 EXPORT_C void CHuiDisplayCoeControl::PrepareForFocusLossL() |
|
222 { |
|
223 CCoeControl::PrepareForFocusLossL(); |
|
224 } |
|
225 |
|
226 EXPORT_C void CHuiDisplayCoeControl::PrepareForFocusGainL() |
|
227 { |
|
228 CCoeControl::PrepareForFocusGainL(); |
|
229 } |
|
230 |
|
231 EXPORT_C TCoeInputCapabilities CHuiDisplayCoeControl::InputCapabilities() const |
|
232 { |
|
233 return CCoeControl::InputCapabilities(); |
|
234 } |
|
235 |
|
236 EXPORT_C void CHuiDisplayCoeControl::FocusChanged(TDrawNow aDrawNow) |
|
237 { |
|
238 CCoeControl::FocusChanged(aDrawNow); |
|
239 } |
|
240 |
|
241 EXPORT_C void CHuiDisplayCoeControl::PositionChanged() |
|
242 { |
|
243 CCoeControl::PositionChanged(); |
|
244 } |
|
245 |
|
246 EXPORT_C void CHuiDisplayCoeControl::SetContainerWindowL(const CCoeControl& aContainer) |
|
247 { |
|
248 CCoeControl::SetContainerWindowL(aContainer); |
|
249 } |
|
250 |