|
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 #include "CMIDToolkit.h" |
|
20 #include "javax_microedition_lcdui_Device.h" |
|
21 |
|
22 const TInt KAlphaLevels = 256; |
|
23 |
|
24 LOCAL_C TInt GetDeviceAttribs(CMIDToolkit* aToolkit, jint* aAttribArray, jint aArrayLength) |
|
25 { |
|
26 if (aArrayLength < javax_microedition_lcdui_Device_ATTRIB_COUNT) |
|
27 { |
|
28 return KErrOverflow; |
|
29 } |
|
30 |
|
31 MMIDUtils& utils = *aToolkit->Utils(); |
|
32 MMIDGraphicsFactory& factory = aToolkit->GraphicsFactory(); |
|
33 |
|
34 jint caps = 0; |
|
35 |
|
36 if (factory.DoubleBuffer()) |
|
37 { |
|
38 caps |= javax_microedition_lcdui_Device_CAPS_DOUBLE_BUFFERED; |
|
39 } |
|
40 if (utils.HasPointerEvents()) |
|
41 { |
|
42 caps |= javax_microedition_lcdui_Device_CAPS_POINTER_EVENTS; |
|
43 } |
|
44 if (utils.HasPointerMotionEvents()) |
|
45 { |
|
46 caps |= javax_microedition_lcdui_Device_CAPS_POINTER_MOTION_EVENTS; |
|
47 } |
|
48 if (utils.HasRepeatEvents()) |
|
49 { |
|
50 caps |= javax_microedition_lcdui_Device_CAPS_KEY_REPEAT_EVENTS; |
|
51 } |
|
52 |
|
53 |
|
54 |
|
55 TDisplayMode frameBufferMode = factory.DisplayMode(); |
|
56 if (frameBufferMode > EGray256) |
|
57 { |
|
58 caps |= javax_microedition_lcdui_Device_CAPS_COLOR; |
|
59 } |
|
60 |
|
61 CCoeEnv* controlEnv = CCoeEnv::Static(); |
|
62 CWsScreenDevice* screenDevice = controlEnv->ScreenDevice(); |
|
63 |
|
64 TSize screenSize = screenDevice->SizeInPixels(); |
|
65 |
|
66 aAttribArray[ javax_microedition_lcdui_Device_ATTRIB_CAPABILITIES ] = caps; |
|
67 aAttribArray[ javax_microedition_lcdui_Device_ATTRIB_NUM_COLORS ] = TDisplayModeUtils::NumDisplayModeColors(frameBufferMode); |
|
68 aAttribArray[ javax_microedition_lcdui_Device_ATTRIB_NUM_ALPHAS ] = KAlphaLevels; |
|
69 aAttribArray[ javax_microedition_lcdui_Device_ATTRIB_SCREEN_WIDTH ] = screenSize.iWidth; |
|
70 aAttribArray[ javax_microedition_lcdui_Device_ATTRIB_SCREEN_HEIGHT] = screenSize.iHeight; |
|
71 |
|
72 return KErrNone; |
|
73 } |
|
74 |
|
75 JNIEXPORT jint JNICALL Java_javax_microedition_lcdui_Device__1getAttribs(JNIEnv* aJni, jobject, jint aToolkit, jintArray aAttribArray) |
|
76 { |
|
77 CMIDToolkit* toolkit = JavaUnhand<CMIDToolkit>(aToolkit); |
|
78 |
|
79 if (aJni->GetArrayLength(aAttribArray) != javax_microedition_lcdui_Device_ATTRIB_COUNT) |
|
80 { |
|
81 return KErrArgument; |
|
82 } |
|
83 |
|
84 jint attribArray[javax_microedition_lcdui_Device_ATTRIB_COUNT]; |
|
85 jint attribCount = javax_microedition_lcdui_Device_ATTRIB_COUNT; |
|
86 jint err; |
|
87 |
|
88 err = toolkit->Execute(&GetDeviceAttribs, toolkit, &attribArray[0], attribCount); |
|
89 if (KErrNone == err) |
|
90 { |
|
91 aJni->SetIntArrayRegion(aAttribArray, 0, attribCount, &attribArray[0]); |
|
92 } |
|
93 |
|
94 return err; |
|
95 } |
|
96 |
|
97 LOCAL_C void InvokeCanvasSizeWithoutKeypad(MMIDDisplayable* aDisplayable, jint* aSizeArray) |
|
98 { |
|
99 TRect onScreenKeypadRect = aDisplayable->GetCanvasRectFromLaf(); |
|
100 aSizeArray[0] = onScreenKeypadRect.Width(); |
|
101 aSizeArray[1] = onScreenKeypadRect.Height(); |
|
102 } |
|
103 |
|
104 JNIEXPORT void JNICALL Java_javax_microedition_lcdui_Device__1getCanvasSizeWithoutKeypad |
|
105 (JNIEnv* aEnv,jobject, jint aToolkit, jint aDisplayable, jintArray aSize) |
|
106 { |
|
107 MMIDDisplayable* displayable = MIDUnhandObject<MMIDDisplayable>(aDisplayable); |
|
108 CMIDToolkit* toolkit = JavaUnhand<CMIDToolkit>(aToolkit); |
|
109 jint sizeArray[2]; |
|
110 toolkit->Execute(&InvokeCanvasSizeWithoutKeypad, displayable, sizeArray); |
|
111 aEnv->SetIntArrayRegion(aSize, 0, 2, sizeArray); |
|
112 } |