aboutsummaryrefslogtreecommitdiffstats
path: root/gl4java/jau/awt/windows/MSWin32HandleAccess.java
blob: 1dd4d93960cff1054368bd4a23ca806b1017cc54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
 * @(#) MSWin32HandleAccess.java
 */

package gl4java.jau.awt.windows;

import java.awt.Component;
import com.ms.awt.GraphicsX;

/**
 * The ms-windows implementation for accessing the native window handle
 *
 * This class has no user servicable parts inside.  It is
 * used internally by GLFrame and by our package spoofed
 * sun.awt classes that give us internal access to window
 * variables that we need to set up the OpenGL drawing
 * ontext 
 *
 * @see WinHandleAccess
 * @version     0.1, 3. JULY 1999
 * @author      Ron Cemer
 * 
 */
public class MSWin32HandleAccess 
	implements gl4java.jau.awt.WinHandleAccess
{
    protected int window, depth;

    /**
     * @dll.import("USER32",auto)
     */
    private static native int WindowFromDC(int hdc);

    protected void achieveData(java.awt.Component c, java.awt.Graphics g)
    {
        window = WindowFromDC(((GraphicsX)g).gdc.pGetDC());
        depth = c.getColorModel().getPixelSize();
    }

    /**
     *
     * get the window handle
     */
    public int getWinHandle(java.awt.Component c, java.awt.Graphics g)
    {
        achieveData(c, g);
        return window;
    }

    /**
     *
     * get the color depth
     */
    public int getWinDepth(java.awt.Component c, java.awt.Graphics g)
    {
        achieveData(c, g);
        return depth;
    }
}