aboutsummaryrefslogtreecommitdiffstats
path: root/gl4java/jau/awt/macintosh/MacHandleAccess.java
blob: 853662d1f113ad8d94e0a5d45b832d4d0728dc15 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
 * @(#) MacHandleAccess.java
 */

package gl4java.jau.awt.macintosh;

import sun.awt.DrawingSurface;  
import sun.awt.DrawingSurfaceInfo;  
import sun.awt.MacDrawingSurface;

import java.awt.*;

/**
 * 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
 * context
 * 
 *
 * @see WinHandleAccess
 * @version 	0.1, 7. JULY 1998
 * @author      Sven Goethel
 * @author      ported to Mac by gerard ziemski
 * 
 */
public class MacHandleAccess implements gl4java.jau.awt.WinHandleAccess
{
	protected DrawingSurface		ds;
	protected DrawingSurfaceInfo	dsi;
	protected MacDrawingSurface		mds;
	protected long		window;
	protected int		depth;
	
	
	protected void achieveData(java.awt.Component c, java.awt.Graphics g)
	{
		/* outta java3d */
		dsi			= null;
		mds			= null;
		window		= 0;
		depth		= 0;
		
		ds = ((DrawingSurface)c.getPeer());
		dsi = ds.getDrawingSurfaceInfo();
		
		if (dsi != null)
		{
			dsi.lock();
			mds = (MacDrawingSurface)dsi.getSurface();  
			dsi.unlock();
		}
		
		if (mds != null)
		{
			dsi.lock();
			
			window = (long) mds.getPort();
			depth = c.getColorModel().getPixelSize();
					
			dsi.unlock();
		}
		
		if (mds == null)
		{
			System.out.println("MacHandleAccess:getWinHandle failed");
		}
  	}

/**
 *
 * gets some structure for windows, and drawable on Mac
 */
	public long getWinHandle(java.awt.Component c, java.awt.Graphics g)
	{
		achieveData(c, g);
		return window;
	}

/**
 *
 * gets some structure for windows, and drawable on Mac
 */
	public int getWinDepth(java.awt.Component c, java.awt.Graphics g)
	{
		achieveData(c, g);
		return depth;
	}
}