author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 15 Sep 2010 12:05:25 +0300 | |
branch | RCL_3 |
changeset 77 | 7cee158cb8cd |
parent 66 | 2455ef1f5bbc |
child 83 | 26b2b12093af |
permissions | -rw-r--r-- |
66 | 1 |
/* |
2 |
* Copyright (c) 2002 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: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#ifndef CMIDENV_H |
|
20 |
#define CMIDENV_H |
|
21 |
||
22 |
#include <e32def.h> |
|
23 |
#include <lcdui.h> |
|
24 |
||
25 |
class CMIDKeyTranslator; |
|
26 |
class CMIDToolkit; |
|
27 |
class CMIDToLcduiObserver; |
|
28 |
||
29 |
||
30 |
/** |
|
31 |
* |
|
32 |
* A MIDlet environment, one per MIDlet, providing utility methods for the |
|
33 |
* MIDP implementation |
|
34 |
* |
|
35 |
*/ |
|
36 |
class CMIDEnv : public CBase, public MMIDEnv |
|
37 |
{ |
|
38 |
public: |
|
39 |
CMIDEnv(CMIDToolkit* aToolkit, const TSize& aSize); |
|
40 |
void ConstructL(); |
|
41 |
~CMIDEnv(); |
|
42 |
||
43 |
void SetUtils(MMIDUtils* aUtils); |
|
44 |
||
45 |
public: |
|
46 |
virtual TBool PostJavaEvent(MMIDComponent& aSource,TSourceType aSourceType,TEventType aEventType,TInt aEventData,TInt aEventData1,TInt aEventData2); |
|
47 |
virtual TBool PostJavaEvent(MMIDComponent& aSource,TSourceType aSourceType,TEventType aEventType=ENoType,TInt aEventData=0); |
|
48 |
virtual TBool PostJavaEvent(MMIDComponent& aSource,TSourceType aSourceType,TInt aEventData); |
|
49 |
virtual TBool PostMidletEvent(TEventType aEventType); |
|
50 |
||
51 |
virtual MMIDNotifyEvent* NewNotifyL(MMIDComponent& aSource); |
|
52 |
virtual TBool PostJavaNotify(MMIDNotifyEvent* aNotify); |
|
53 |
||
54 |
virtual TBool TranslateKeyL(TMIDKeyEvent& aEvent, const TKeyEvent&, TEventCode aType); |
|
55 |
virtual TBool PostKeyEvent(MMIDComponent& aSource, TMIDKeyEvent& aEvent); |
|
56 |
virtual void ResetKeys(); |
|
57 |
||
58 |
virtual MMIDDisplayable* Current(); |
|
59 |
virtual TPtrC MidletName() const; |
|
60 |
virtual TUid MidletUid() const; |
|
61 |
virtual TPtrC MidletHome() const; |
|
62 |
virtual void DisplayableIsDestructed(const MMIDDisplayable* displayable); |
|
63 |
const MMIDDisplayable* LastFullscreenDisplayable() const; |
|
64 |
||
65 |
#ifdef RD_SCALABLE_UI_V2 |
|
66 |
// This function can be moved out from RD_SCALABLE_UI_V2 flag if needed. |
|
67 |
// It is behind this flag because currently it is used only by Touch. |
|
68 |
/** |
|
69 |
* Returns MIDlet Suite uid that is parsed from the MIDlet home path. |
|
70 |
* In practise this function assumes that the midlet home path includes |
|
71 |
* Midlet suite uid inside the brackets, for example: |
|
72 |
* "e:\epoc32\winscw\c\private\102033E6\MIDlets\[101e0a27]" |
|
73 |
* |
|
74 |
* Note: |
|
75 |
* MIDlet suite uid could be retrieved from the Java registry based on |
|
76 |
* the midlet uid. But that operation is very time consuming because it |
|
77 |
* requires lot of file accessing, especially when there are many midlets |
|
78 |
* installed in the device. |
|
79 |
* @since S60 5.0 |
|
80 |
* @return TUid iMidletSuiteUid or |
|
81 |
* KNullUidValue if midlet suite uid not found or error occured. |
|
82 |
*/ |
|
83 |
TUid MidletSuiteUid(); |
|
84 |
#endif //RD_SCALABLE_UI_V2 |
|
85 |
||
86 |
virtual TInt NumColors(); |
|
87 |
virtual TDisplayMode DisplayMode(); |
|
88 |
||
89 |
virtual void SetCanvasZoomSize(const TSize& aSize); |
|
90 |
virtual TSize CanvasZoomSize(); |
|
91 |
virtual TSize CanvasAssumedSize(); |
|
92 |
virtual TInt MidletAttribute(const TDesC& aAttributeName, TPtrC& aAttributeValue); |
|
93 |
||
94 |
/** |
|
95 |
* @see MMIDEnv#MidletAttributeIsSetToVal() |
|
96 |
*/ |
|
97 |
virtual TBool MidletAttributeIsSetToVal(const TDesC& aAttributeName, const TDesC& aAttributeValue); |
|
98 |
||
99 |
/** |
|
100 |
* @see MMIDEnv#MidletAttributeContainsVal() |
|
101 |
*/ |
|
102 |
virtual TBool MidletAttributeContainsVal(const TDesC& aAttributeName, const TDesC& aAttributeValue); |
|
103 |
||
104 |
virtual void SetCanvasAssumedSize(const TSize& aSize); |
|
105 |
||
106 |
// |
|
107 |
virtual void AddObserverL(MMIDEnvObserver& aObserver); |
|
108 |
virtual void RemoveObserver(MMIDEnvObserver& aObserver); |
|
109 |
// |
|
110 |
void HandleSwitchOnL(TBool aSwitchOn); |
|
111 |
void HandleForegroundL(TBool aForeground); |
|
112 |
void HandleResourceChangeL(TInt aType); |
|
113 |
||
114 |
/** |
|
115 |
* @see MMIDEnv#ReserveCanvasFrameBuffer() |
|
116 |
*/ |
|
117 |
virtual CFbsBitmap* ReserveCanvasFrameBufferL(MMIDCanvas& aCanvas, const TSize& aSz); |
|
118 |
||
119 |
/** |
|
120 |
* @see MMIDEnv#ReleaseCanvasFrameBuffer() |
|
121 |
*/ |
|
122 |
virtual void ReleaseCanvasFrameBuffer(MMIDCanvas& aCanvas, CFbsBitmap*& aFrameBuffer); |
|
123 |
||
124 |
/** |
|
125 |
* @see MMIDEnv#CanvasHasBackground() |
|
126 |
*/ |
|
127 |
virtual TBool CanvasHasBackground(const MMIDCanvas& aCanvas) const; |
|
128 |
||
129 |
/** |
|
130 |
* Maps low level key event |
|
131 |
* @param aMidKeyEvent key event output data |
|
132 |
* @param aEvent key event input data |
|
133 |
* @see virtual void MMIDEnv::MappingDataForKey( TKeyEvent& aEvent ); |
|
134 |
*/ |
|
135 |
virtual void MappingDataForKey(TKeyEvent& aEvent, TEventCode aType); |
|
136 |
||
137 |
/** |
|
138 |
* Set last key event |
|
139 |
* @param aEvent key event input data |
|
140 |
* @see virtual void MMIDEnv::SetLastKeyEvent( const TKeyEvent& aEvent ); |
|
141 |
*/ |
|
142 |
virtual void SetLastKeyEvent(const TKeyEvent& aEvent); |
|
143 |
||
144 |
/** |
|
145 |
* From MMIDEnv. |
|
146 |
* Gets an instance of ToLcduiObserver. |
|
147 |
* |
|
148 |
* @since S60 5.0 |
|
149 |
* @return Pointer to ToLcduiObserver instance |
|
150 |
* @see iToLcduiObserver |
|
151 |
*/ |
|
152 |
virtual MMIDToLcduiObserver& ToLcduiObserver(); |
|
153 |
||
77
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
154 |
/** |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
155 |
* @see MMIDEnv#VideoOverlayEnabled() |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
156 |
*/ |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
157 |
virtual TBool VideoOverlayEnabled() const; |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
158 |
|
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
159 |
/** |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
160 |
* @see MMIDEnv#GetMMAPILock() |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
161 |
*/ |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
162 |
RCriticalSection& GetMMAPILock(); |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
163 |
|
66 | 164 |
#ifdef RD_JAVA_NGA_ENABLED |
165 |
/** |
|
166 |
* @see MMIDEnv#IsHardwareAccelerated() |
|
167 |
*/ |
|
168 |
virtual TBool IsHardwareAcceleratedL( |
|
169 |
MMIDEnv::THardwareType aHardwareType = MMIDEnv::EHardware3D); |
|
170 |
||
171 |
/** |
|
172 |
* @see MMIDEnv#HandleFullOrPartialForegroundL() |
|
173 |
*/ |
|
174 |
virtual void HandleFullOrPartialForegroundL(TBool aFullOrPartialFg); |
|
175 |
||
176 |
/** |
|
177 |
* @see MMIDEnv#HandleFreeGraphicsMemory() |
|
178 |
*/ |
|
179 |
virtual void HandleFreeGraphicsMemory(); |
|
180 |
||
181 |
/** |
|
182 |
* @see MMIDEnv#HasFullOrPartialForeground() |
|
183 |
*/ |
|
184 |
virtual TBool HasFullOrPartialForeground() const; |
|
185 |
private: |
|
186 |
/** |
|
187 |
* Checks and initializes 2D & 3D harware status |
|
188 |
* @return Hardware status @see MMIDEnv::THardwareType |
|
189 |
* @since S60 9.2 |
|
190 |
*/ |
|
191 |
TInt InitHardwareStatusL(); |
|
192 |
||
193 |
#endif // RD_JAVA_NGA_ENABLED |
|
194 |
||
195 |
||
196 |
private: |
|
197 |
/** |
|
198 |
* Encapsulated canvas (frame buffer) data |
|
199 |
*/ |
|
200 |
struct TCanvasData |
|
201 |
{ |
|
202 |
||
203 |
/** |
|
204 |
* Ctor |
|
205 |
*/ |
|
206 |
TCanvasData() |
|
207 |
: iRefCount(0), iFrameBuffer(NULL), iHasBackground(EFalse) |
|
208 |
{ |
|
209 |
} |
|
210 |
||
211 |
/** |
|
212 |
* Reset frame buffer data |
|
213 |
*/ |
|
214 |
inline void Reset() |
|
215 |
{ |
|
216 |
delete iFrameBuffer; |
|
217 |
iFrameBuffer = NULL; |
|
218 |
iRefCount = 0; |
|
219 |
} |
|
220 |
TUint iRefCount; |
|
221 |
CFbsBitmap* iFrameBuffer; |
|
222 |
TBool iHasBackground; |
|
223 |
RMutex iLock; |
|
224 |
}; |
|
225 |
||
226 |
/** |
|
227 |
* Autolocker class. |
|
228 |
*/ |
|
229 |
class TMutexAutoLock |
|
230 |
{ |
|
231 |
public: |
|
232 |
/** |
|
233 |
* Ctor |
|
234 |
* @param aLock Syncronization primitive that is locked during construction |
|
235 |
*/ |
|
236 |
TMutexAutoLock(RMutex* aLock) : iLock(aLock) |
|
237 |
{ |
|
238 |
iLock->Wait(); |
|
239 |
} |
|
240 |
||
241 |
/** |
|
242 |
* Dtor. Signals the synchronization primitive |
|
243 |
*/ |
|
244 |
~TMutexAutoLock() |
|
245 |
{ |
|
246 |
iLock->Signal(); |
|
247 |
} |
|
248 |
private: |
|
249 |
RMutex* iLock; |
|
250 |
}; |
|
251 |
||
252 |
||
253 |
/** |
|
254 |
* Create a frame buffer for a <code>MMIDCanvas</code> instance. |
|
255 |
* @param aCanvas Target canvas |
|
256 |
* @param aWsBitmap If <code>ETrue</code> then the type of the frame buffer |
|
257 |
* will be <code>WsBitmap</code> instead of a <code>CFbsBitmap</code>. |
|
258 |
* @param aSz Frame buffer size |
|
259 |
* @return Frame buffer instance |
|
260 |
* @since S60 5.0 |
|
261 |
*/ |
|
262 |
CFbsBitmap* CreateCanvasFrameBufferL( |
|
263 |
MMIDCanvas& aCanvas, TBool aWsBitmap, const TSize& aSz); |
|
264 |
||
265 |
private: |
|
266 |
enum {EGranularity = 4}; |
|
267 |
||
268 |
private: |
|
269 |
CMIDToolkit* iToolkit; |
|
270 |
RArray<MMIDEnvObserver*> iObservers; |
|
271 |
CMIDKeyTranslator* iKeyTranslator; |
|
272 |
TSize iCanvasAssumedSize; |
|
273 |
TSize iCanvasZoomSize; |
|
274 |
TCanvasData iCanvasData; |
|
275 |
||
276 |
#ifdef RD_SCALABLE_UI_V2 |
|
277 |
// MIDlet suite uid |
|
278 |
TUid iMidletSuiteUid; |
|
279 |
#endif //RD_SCALABLE_UI_V2 |
|
280 |
||
281 |
/** |
|
282 |
* Provides possibility to make calls from non-LCDUI threads |
|
283 |
* to LCDUI ES thread. |
|
284 |
* Own. |
|
285 |
*/ |
|
286 |
CMIDToLcduiObserver* iToLcduiObserver; |
|
287 |
||
77
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
288 |
TBool iVideoOverlayEnabled; |
7cee158cb8cd
Revision: v2.2.13
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
289 |
RCriticalSection iMMAPILock; |
66 | 290 |
#ifdef RD_JAVA_NGA_ENABLED |
291 |
TInt iHardwareStatus; |
|
292 |
TBool iFullOrPartialFg; |
|
293 |
#endif // RD_JAVA_NGA_ENABLED |
|
294 |
}; |
|
295 |
||
296 |
#endif // CMIDENV_H |