1 | /* |
2 | * $Id: HMENU.java,v 1.2 2004/08/13 00:54:31 hastings Exp $ |
3 | * |
4 | * (c) Copyright, Moebius Solutions, Inc., 2004 |
5 | * |
6 | * All Rights Reserved |
7 | * |
8 | * This material may be reproduced by or for the U. S. Government |
9 | * pursuant to the copyright license under the clause at |
10 | * DFARS 252.227-7014 (OCT 2001). |
11 | */ |
12 | |
13 | package com.moesol.bindings.platform_sdk.windows_api; |
14 | |
15 | import java.nio.*; |
16 | |
17 | |
18 | public class HMENU extends HANDLE { |
19 | HMENU(long hmenu, boolean temporary) { |
20 | super(hmenu, temporary); |
21 | } |
22 | HMENU(long hmenu) { |
23 | super(hmenu); |
24 | } |
25 | public static HMENU createMenu() { |
26 | HMENU r = jni_createMenu(); |
27 | PlatformSDK.throwWin32OnFalse(r != null); |
28 | return r; |
29 | } |
30 | public static HMENU createPopupMenu() { |
31 | long r = jni_createPopupMenu(); |
32 | PlatformSDK.throwWin32OnFalse(r != 0); |
33 | return new HMENU(r); |
34 | } |
35 | public void destroyMenu() { |
36 | boolean r = jni_destroyMenu(_getHandle()); |
37 | PlatformSDK.throwWin32OnFalse(r); |
38 | detach(); |
39 | } |
40 | public void insertMenuItem(int item, boolean by_position, MENUITEMINFO mi) { |
41 | boolean r = jni_insertMenuItem(_getHandle(), item, by_position, mi.m_native_mii, mi.m_type_data); |
42 | PlatformSDK.throwWin32OnFalse(r); |
43 | } |
44 | public void getMenuItem(int item, boolean by_position, MENUITEMINFO mi) { |
45 | boolean r = jni_getMenuItem(_getHandle(), item, by_position, mi.m_native_mii, mi); |
46 | PlatformSDK.throwWin32OnFalse(r); |
47 | } |
48 | public void setMenuItem(int item, boolean by_position, MENUITEMINFO mi) { |
49 | boolean r = jni_setMenuItem(_getHandle(), item, by_position, mi.m_native_mii, mi.m_type_data); |
50 | PlatformSDK.throwWin32OnFalse(r); |
51 | } |
52 | public int getMenuItemCount() { |
53 | int r = jni_getMenuItemCount(_getHandle()); |
54 | PlatformSDK.throwWin32OnFalse(r >= 0); |
55 | return r; |
56 | } |
57 | public void removeMenuItem(int item, boolean by_position) { |
58 | boolean r = jni_removeMenuItem(_getHandle(), item, by_position); |
59 | PlatformSDK.throwWin32OnFalse(r); |
60 | } |
61 | public static final HMENU NULL = new HMENU(0); |
62 | |
63 | private static native HMENU jni_createMenu(); |
64 | private static native long jni_createPopupMenu(); |
65 | private static native boolean jni_destroyMenu(long handle); |
66 | private static native boolean jni_insertMenuItem(long handle, int item, boolean by_position, |
67 | ByteBuffer native_mii, String type_data); |
68 | private static native boolean jni_getMenuItem(long handle, int item, boolean by_position, |
69 | ByteBuffer native_mii, MENUITEMINFO mii); |
70 | private static native boolean jni_setMenuItem(long handle, int item, boolean by_position, |
71 | ByteBuffer native_mii, String type_data); |
72 | private static native int jni_getMenuItemCount(long handle); |
73 | private static native boolean jni_removeMenuItem(long handle, int item, boolean by_position); |
74 | } |