Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / embeddedobj / test / Container1 / nativelib / nativeview.c
blob6952fe9e96ec4e4d92f3f0b5a70eaed8887f200f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 *************************************************************************/
29 #ifdef WNT
31 #include <windows.h>
32 // property name to register own window procedure on hwnd
33 #define OLD_PROC_KEY "oldwindowproc"
34 // signature of this window procedure
35 static LRESULT APIENTRY NativeViewWndProc( HWND , UINT , WPARAM , LPARAM );
37 #endif
39 #include "jawt.h"
40 #include "jawt_md.h"
41 #include "NativeView.h"
43 #define MY_ASSERT(X,S) if (!X) { fprintf(stderr,"%s\n",S); return 0L;}
45 #define SYSTEM_WIN32 1
46 #define SYSTEM_WIN16 2
47 #define SYSTEM_JAVA 3
48 #define SYSTEM_MAC 5
49 #define SYSTEM_XWINDOW 6
51 /*****************************************************************************
53 * Class : NativeView
54 * Method : getNativeWindowSystemType
55 * Signature : ()I
56 * Description: returns an identifier for the current operating system
58 JNIEXPORT jint JNICALL Java_embeddedobj_test_NativeView_getNativeWindowSystemType
59 (JNIEnv * env, jobject obj_this)
61 return (SYSTEM_WIN32);
64 /*****************************************************************************
66 * Class : NativeView
67 * Method : getNativeWindow
68 * Signature : ()J
69 * Description: returns the native systemw window handle of this object
71 JNIEXPORT jlong JNICALL Java_embeddedobj_test_NativeView_getNativeWindow
72 (JNIEnv * env, jobject obj_this)
74 jboolean result ;
75 jint lock ;
76 JAWT awt ;
77 JAWT_DrawingSurface* ds ;
78 JAWT_DrawingSurfaceInfo* dsi ;
79 JAWT_Win32DrawingSurfaceInfo* dsi_win ;
80 jlong drawable;
82 /* Get the AWT */
83 awt.version = JAWT_VERSION_1_3;
84 result = JAWT_GetAWT(env, &awt);
85 MY_ASSERT(result!=JNI_FALSE,"wrong jawt version");
87 /* Get the drawing surface */
88 if ((ds = awt.GetDrawingSurface(env, obj_this)) == NULL)
89 return 0L;
91 /* Lock the drawing surface */
92 lock = ds->Lock(ds);
93 MY_ASSERT((lock & JAWT_LOCK_ERROR)==0,"can't lock the drawing surface");
95 /* Get the drawing surface info */
96 dsi = ds->GetDrawingSurfaceInfo(ds);
98 /* Get the platform-specific drawing info */
99 #ifdef WNT
100 dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
101 drawable = (jlong)dsi_win->hwnd;
102 #else
103 dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
104 drawable = (jlong)dsi_x11->drawable;
105 #endif
107 /* Free the drawing surface info */
108 ds->FreeDrawingSurfaceInfo(dsi);
109 /* Unlock the drawing surface */
110 ds->Unlock(ds);
111 /* Free the drawing surface */
112 awt.FreeDrawingSurface(ds);
114 return drawable;
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */