tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / embeddedobj / test / Container1 / nativelib / nativeview.c
bloba58ce54ef58764042d8ac1367aa061704f750941
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifdef _WIN32
22 #if !defined WIN32_LEAN_AND_MEAN
23 # define WIN32_LEAN_AND_MEAN
24 #endif
25 #include <windows.h>
26 // property name to register own window procedure on hwnd
27 #define OLD_PROC_KEY "oldwindowproc"
28 // signature of this window procedure
29 static LRESULT APIENTRY NativeViewWndProc( HWND , UINT , WPARAM , LPARAM );
31 #endif
33 #include "jawt.h"
34 #include "jawt_md.h"
35 #include "NativeView.h"
37 #define MY_ASSERT(X,S) if (!X) { fprintf(stderr,"%s\n",S); return 0;}
39 #define SYSTEM_WIN32 1
40 #define SYSTEM_WIN16 2
41 #define SYSTEM_JAVA 3
42 #define SYSTEM_MAC 5
43 #define SYSTEM_XWINDOW 6
45 /*****************************************************************************
47 * Class : NativeView
48 * Method : getNativeWindowSystemType
49 * Signature : ()I
50 * Description: returns an identifier for the current operating system
52 JNIEXPORT jint JNICALL Java_embeddedobj_test_NativeView_getNativeWindowSystemType
53 (JNIEnv * env, jobject obj_this)
55 return SYSTEM_WIN32;
58 /*****************************************************************************
60 * Class : NativeView
61 * Method : getNativeWindow
62 * Signature : ()J
63 * Description: returns the native systemw window handle of this object
65 JNIEXPORT jlong JNICALL Java_embeddedobj_test_NativeView_getNativeWindow
66 (JNIEnv * env, jobject obj_this)
68 jboolean result ;
69 jint lock ;
70 JAWT awt ;
71 JAWT_DrawingSurface* ds ;
72 JAWT_DrawingSurfaceInfo* dsi ;
73 #ifdef _WIN32
74 JAWT_Win32DrawingSurfaceInfo* dsi_win ;
75 #else
76 // FIXME: Where is dsi_x11 defined?
77 // Added below because I'm guessing this test breaks
79 // JAWT_X11DrawingSurfaceInfo*dsi_x11 ;
80 #endif
81 jlong drawable;
83 /* Get the AWT */
84 awt.version = JAWT_VERSION_1_3;
85 result = JAWT_GetAWT(env, &awt);
86 MY_ASSERT(result!=JNI_FALSE,"wrong jawt version");
88 /* Get the drawing surface */
89 if ((ds = awt.GetDrawingSurface(env, obj_this)) == NULL)
90 return 0;
92 /* Lock the drawing surface */
93 lock = ds->Lock(ds);
94 MY_ASSERT((lock & JAWT_LOCK_ERROR)==0,"can't lock the drawing surface");
96 /* Get the drawing surface info */
97 dsi = ds->GetDrawingSurfaceInfo(ds);
99 /* Get the platform-specific drawing info */
100 #ifdef _WIN32
101 dsi_win = (JAWT_Win32DrawingSurfaceInfo*)dsi->platformInfo;
102 drawable = (jlong)dsi_win->hwnd;
103 #else
104 dsi_x11 = (JAWT_X11DrawingSurfaceInfo*)dsi->platformInfo;
105 drawable = (jlong)dsi_x11->drawable;
106 #endif
108 /* Free the drawing surface info */
109 ds->FreeDrawingSurfaceInfo(dsi);
110 /* Unlock the drawing surface */
111 ds->Unlock(ds);
112 /* Free the drawing surface */
113 awt.FreeDrawingSurface(ds);
115 return drawable;
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */