Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright 2010 JogAmp Community. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of JogAmp Community.
*/
package com.jogamp.nativewindow.swt;
import com.jogamp.common.os.Platform;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedAction;
import org.eclipse.swt.graphics.GCData;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Control;
import javax.media.nativewindow.AbstractGraphicsScreen;
import javax.media.nativewindow.NativeWindowException;
import javax.media.nativewindow.AbstractGraphicsDevice;
import javax.media.nativewindow.NativeWindowFactory;
import javax.media.nativewindow.VisualIDHolder;
import com.jogamp.common.util.ReflectionUtil;
import com.jogamp.common.util.VersionNumber;
import com.jogamp.nativewindow.macosx.MacOSXGraphicsDevice;
import com.jogamp.nativewindow.windows.WindowsGraphicsDevice;
import com.jogamp.nativewindow.x11.X11GraphicsDevice;
import jogamp.nativewindow.macosx.OSXUtil;
import jogamp.nativewindow.x11.X11Lib;
public class SWTAccessor {
private static final boolean DEBUG = true;
private static final Field swt_control_handle;
private static final boolean swt_uses_long_handles;
private static Object swt_osx_init = new Object();
private static Field swt_osx_control_view = null;
private static Field swt_osx_view_id = null;
private static final String nwt;
private static final boolean isOSX;
private static final boolean isWindows;
private static final boolean isX11;
private static final boolean isX11GTK;
// X11/GTK, Windows/GDI, ..
private static final String str_handle = "handle";
// OSX/Cocoa
private static final String str_osx_view = "view"; // OSX
private static final String str_osx_id = "id"; // OSX
// static final String str_NSView = "org.eclipse.swt.internal.cocoa.NSView";
private static final Method swt_control_internal_new_GC;
private static final Method swt_control_internal_dispose_GC;
private static final String str_internal_new_GC = "internal_new_GC";
private static final String str_internal_dispose_GC = "internal_dispose_GC";
private static final String str_OS_gtk_class = "org.eclipse.swt.internal.gtk.OS";
public static final Class> OS_gtk_class;
private static final String str_OS_gtk_version = "GTK_VERSION";
public static final VersionNumber OS_gtk_version;
private static final Method OS_gtk_widget_realize;
private static final Method OS_gtk_widget_unrealize; // optional (removed in SWT 4.3)
private static final Method OS_GTK_WIDGET_WINDOW;
private static final Method OS_gtk_widget_get_window;
private static final Method OS_gdk_x11_drawable_get_xdisplay;
private static final Method OS_gdk_x11_display_get_xdisplay;
private static final Method OS_gdk_window_get_display;
private static final Method OS_gdk_x11_drawable_get_xid;
private static final Method OS_gdk_x11_window_get_xid;
private static final Method OS_gdk_window_set_back_pixmap;
private static final String str_gtk_widget_realize = "gtk_widget_realize";
private static final String str_gtk_widget_unrealize = "gtk_widget_unrealize";
private static final String str_GTK_WIDGET_WINDOW = "GTK_WIDGET_WINDOW";
private static final String str_gtk_widget_get_window = "gtk_widget_get_window";
private static final String str_gdk_x11_drawable_get_xdisplay = "gdk_x11_drawable_get_xdisplay";
private static final String str_gdk_x11_display_get_xdisplay = "gdk_x11_display_get_xdisplay";
private static final String str_gdk_window_get_display = "gdk_window_get_display";
private static final String str_gdk_x11_drawable_get_xid = "gdk_x11_drawable_get_xid";
private static final String str_gdk_x11_window_get_xid = "gdk_x11_window_get_xid";
private static final String str_gdk_window_set_back_pixmap = "gdk_window_set_back_pixmap";
private static final VersionNumber GTK_VERSION_2_14_0 = new VersionNumber(2, 14, 0);
private static final VersionNumber GTK_VERSION_2_24_0 = new VersionNumber(2, 24, 0);
private static final VersionNumber GTK_VERSION_3_0_0 = new VersionNumber(3, 0, 0);
private static VersionNumber GTK_VERSION(int version) {
// return (major << 16) + (minor << 8) + micro;
final int micro = ( version ) & 0x0f;
final int minor = ( version >> 8 ) & 0x0f;
final int major = ( version >> 16 ) & 0x0f;
return new VersionNumber(major, minor, micro);
}
static {
AccessController.doPrivileged(new PrivilegedAction