|
1 /* |
|
2 * Copyright (c) 1999-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 #include "CMIDToolkit.h" |
|
20 #include "MIDUtils.h" |
|
21 #include "javax_microedition_lcdui_Displayable.h" |
|
22 |
|
23 LOCAL_C void CreateContainerL(CMIDToolkit* aToolkit, jweak aRef, jint* aHandle) |
|
24 { |
|
25 MMIDDisplayable* displayable = aToolkit->ComponentFactory()->CreateDisplayableL(); |
|
26 CleanupDisposePushL(displayable); |
|
27 *aHandle = aToolkit->RegisterComponentL(displayable, aRef); |
|
28 CleanupPopComponent(displayable); |
|
29 } |
|
30 |
|
31 JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_Displayable__1createContainer |
|
32 ( |
|
33 JNIEnv* aJni, |
|
34 jobject aDisplayable, |
|
35 jint aToolkit |
|
36 ) |
|
37 { |
|
38 jint err = KErrNoMemory; |
|
39 jint handle = 0; |
|
40 jweak ref = aJni->NewWeakGlobalRef(aDisplayable); |
|
41 if (ref != 0) |
|
42 { |
|
43 CMIDToolkit* toolkit = JavaUnhand<CMIDToolkit>(aToolkit); |
|
44 err = toolkit->ExecuteTrap(CreateContainerL, toolkit, ref, &handle); |
|
45 if (err!=KErrNone) |
|
46 { |
|
47 aJni->DeleteWeakGlobalRef(ref); |
|
48 return err; |
|
49 } |
|
50 } |
|
51 return handle; |
|
52 } |
|
53 |
|
54 LOCAL_C void InvokeAddCommandL(jint aDisplayable, jint aCommand) |
|
55 { |
|
56 MMIDDisplayable* displayable = MIDUnhandObject<MMIDDisplayable>(aDisplayable); |
|
57 MMIDCommand* command = MIDUnhandObject<MMIDCommand>(aCommand); |
|
58 displayable->AddCommandL(command); |
|
59 } |
|
60 |
|
61 JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_Displayable__1addCommand |
|
62 (JNIEnv*,jobject,jint aDisplayable,jint aToolkit, jint aCommand) |
|
63 { |
|
64 CMIDToolkit* toolkit = JavaUnhand<CMIDToolkit>(aToolkit); |
|
65 return toolkit->ExecuteTrap(&InvokeAddCommandL, aDisplayable,aCommand); |
|
66 } |
|
67 |
|
68 LOCAL_C void InvokeRemoveCommand(jint aDisplayable,jint aCommand) |
|
69 { |
|
70 MMIDDisplayable* displayable = MIDUnhandObject<MMIDDisplayable>(aDisplayable); |
|
71 MMIDCommand* command = MIDUnhandObject<MMIDCommand>(aCommand); |
|
72 displayable->RemoveCommand(command); |
|
73 } |
|
74 |
|
75 JNIEXPORT void JNICALL Java_javax_microedition_lcdui_Displayable__1removeCommand |
|
76 (JNIEnv*,jobject,jint aToolkit,jint aDisplayable, jint aCommand) |
|
77 { |
|
78 CMIDToolkit* toolkit = JavaUnhand<CMIDToolkit>(aToolkit); |
|
79 toolkit->ExecuteTrap(&InvokeRemoveCommand,aDisplayable, aCommand); |
|
80 } |
|
81 |
|
82 LOCAL_C void InvokeSetTitleL(jint aDisplayable, const TDesC* aTitle) |
|
83 { |
|
84 MMIDDisplayable* displayable = MIDUnhandObject<MMIDDisplayable>(aDisplayable); |
|
85 displayable->SetTitleL(aTitle); |
|
86 } |
|
87 |
|
88 JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_Displayable__1setTitle |
|
89 (JNIEnv* aEnv,jobject,jint aDisplayable,jint aToolkit,jstring aString) |
|
90 { |
|
91 const RJString titleDes(*aEnv, aString); |
|
92 const TDesC* pTitle = NULL; |
|
93 if (NULL != aString) |
|
94 { |
|
95 pTitle = &titleDes; |
|
96 } |
|
97 return JavaUnhand<CMIDToolkit>(aToolkit)->ExecuteTrap(&InvokeSetTitleL, aDisplayable, pTitle); |
|
98 } |
|
99 |
|
100 LOCAL_C void InvokeSetTickerL(jint aDisplayable,jint aTicker) |
|
101 { |
|
102 MMIDDisplayable* displayable = MIDUnhandObject<MMIDDisplayable>(aDisplayable); |
|
103 MMIDTicker* ticker = MIDUnhandObject<MMIDTicker>(aTicker); |
|
104 displayable->SetTickerL(ticker); |
|
105 } |
|
106 |
|
107 JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_Displayable__1setTicker |
|
108 (JNIEnv*,jobject,jint aDisplayable,jint aToolkit,jint aTicker) |
|
109 { |
|
110 return JavaUnhand<CMIDToolkit>(aToolkit)->ExecuteTrap(&InvokeSetTickerL,aDisplayable,aTicker); |
|
111 } |
|
112 |
|
113 LOCAL_C void InvokeContentSize(jint aDisplayable,TSize* aSize) |
|
114 { |
|
115 MMIDDisplayable* displayable = MIDUnhandObject<MMIDDisplayable>(aDisplayable); |
|
116 *aSize = displayable->ContentSize(); |
|
117 } |
|
118 |
|
119 JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_Displayable__1getContentSize |
|
120 (JNIEnv*,jobject,jint aDisplayable,jint aToolkit) |
|
121 { |
|
122 TSize size; |
|
123 JavaUnhand<CMIDToolkit>(aToolkit)->ExecuteV(&InvokeContentSize, aDisplayable, &size); |
|
124 return (size.iWidth << 16) | (size.iHeight & 0x0000ffff); |
|
125 } |
|
126 |
|
127 LOCAL_C void InvokeSetCommandListenerExistence(jint aDisplayable, jboolean aExistence) |
|
128 { |
|
129 MMIDDisplayable* displayable = MIDUnhandObject<MMIDDisplayable>(aDisplayable); |
|
130 displayable->SetCommandListenerExistence(aExistence); |
|
131 } |
|
132 |
|
133 JNIEXPORT void JNICALL Java_javax_microedition_lcdui_Displayable__1setCommandListenerExistence |
|
134 (JNIEnv*, jobject, jint aDisplayable, jint aToolkit, jboolean aExistence) |
|
135 { |
|
136 CMIDToolkit* toolkit = JavaUnhand<CMIDToolkit>(aToolkit); |
|
137 toolkit->ExecuteV(&InvokeSetCommandListenerExistence, aDisplayable, aExistence); |
|
138 } |
|
139 |
|
140 LOCAL_C jboolean InvokeSoftKeyLabelLocation(MMIDDisplayable* aDisplayable, |
|
141 jint softKeyId, |
|
142 jint* aPositionArray, |
|
143 jint* aSizeArray) |
|
144 { |
|
145 TSize size; |
|
146 TPoint position; |
|
147 TBool softkeyExists = aDisplayable->SoftKeyLabelLocation(softKeyId, position, size); |
|
148 aPositionArray[0] = position.iX; |
|
149 aPositionArray[1] = position.iY; |
|
150 aSizeArray[0] = size.iWidth; |
|
151 aSizeArray[1] = size.iHeight; |
|
152 return softkeyExists; |
|
153 } |
|
154 |
|
155 JNIEXPORT jboolean JNICALL Java_javax_microedition_lcdui_Displayable__1getSoftKeyLabelLocation |
|
156 (JNIEnv* aEnv,jobject, jint aToolkit, jint aDisplayable, jint softKeyId, jintArray aPosition, jintArray aSize) |
|
157 { |
|
158 CMIDToolkit* toolkit = JavaUnhand<CMIDToolkit>(aToolkit); |
|
159 MMIDDisplayable* displayable = MIDUnhand<MMIDDisplayable>(aDisplayable); |
|
160 jint positionArray[2]; |
|
161 jint sizeArray[2]; |
|
162 jboolean softkeyExists = toolkit->Execute(&InvokeSoftKeyLabelLocation, |
|
163 displayable, |
|
164 softKeyId, |
|
165 positionArray, |
|
166 sizeArray); |
|
167 |
|
168 aEnv->SetIntArrayRegion(aPosition, 0, 2, positionArray); |
|
169 aEnv->SetIntArrayRegion(aSize, 0, 2, sizeArray); |
|
170 return softkeyExists; |
|
171 } |
|
172 |
|
173 LOCAL_C jint InvokeSoftKeyLabelAnchor(MMIDDisplayable* aDisplayable, jint softKeyId) |
|
174 { |
|
175 return aDisplayable->SoftKeyLabelAnchor(softKeyId); |
|
176 } |
|
177 |
|
178 JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_Displayable__1getSoftKeyLabelAnchor |
|
179 (JNIEnv*,jobject, jint aToolkit, jint aDisplayable, jint softKeyId) |
|
180 { |
|
181 CMIDToolkit* toolkit = JavaUnhand<CMIDToolkit>(aToolkit); |
|
182 MMIDDisplayable* displayable = MIDUnhand<MMIDDisplayable>(aDisplayable); |
|
183 |
|
184 return toolkit->Execute(&InvokeSoftKeyLabelAnchor, displayable, softKeyId); |
|
185 } |
|
186 |
|
187 LOCAL_C void GetKeyboardTypeName(MMIDUtils *aUtils, TDes* aText) |
|
188 { |
|
189 aUtils->GetKeyboardTypeName(aText); |
|
190 } |
|
191 |
|
192 JNIEXPORT |
|
193 jstring JNICALL Java_javax_microedition_lcdui_Displayable__1getKeyboardTypeName |
|
194 (JNIEnv* aEnv, jclass, jint aToolkit) |
|
195 { |
|
196 TBuf<KMaxName> keyboardTypeName; |
|
197 CMIDToolkit* toolkit = JavaUnhand<CMIDToolkit>(aToolkit); |
|
198 toolkit->ExecuteV(&GetKeyboardTypeName, |
|
199 toolkit->Utils(), (TDes*)&keyboardTypeName); |
|
200 jstring str = CreateJavaString(*aEnv, keyboardTypeName); |
|
201 return str; |
|
202 } |
|
203 |
|
204 LOCAL_C TInt GetKeyScanCode(MMIDUtils *aUtils) |
|
205 { |
|
206 return aUtils->GetKeyScanCode(); |
|
207 } |
|
208 |
|
209 JNIEXPORT |
|
210 jint JNICALL Java_javax_microedition_lcdui_Displayable__1getKeyScanCode |
|
211 (JNIEnv* /*aEnv*/, jclass, jint aToolkit) |
|
212 { |
|
213 CMIDToolkit* toolkit = JavaUnhand<CMIDToolkit>(aToolkit); |
|
214 return toolkit->Execute(&GetKeyScanCode, toolkit->Utils()); |
|
215 } |
|
216 |
|
217 LOCAL_C TInt GetKeyModifier(MMIDUtils *aUtils) |
|
218 { |
|
219 return aUtils->GetKeyModifier(); |
|
220 } |
|
221 |
|
222 JNIEXPORT |
|
223 jint JNICALL Java_javax_microedition_lcdui_Displayable__1getKeyModifier |
|
224 (JNIEnv* /*aEnv*/, jclass, jint aToolkit) |
|
225 { |
|
226 CMIDToolkit* toolkit = JavaUnhand<CMIDToolkit>(aToolkit); |
|
227 return toolkit->Execute(&GetKeyModifier, toolkit->Utils()); |
|
228 } |