Source code: gl4java/jau/awt/macintosh/MacHandleAccess.java
1 /*
2 * @(#) MacHandleAccess.java
3 */
4
5 package gl4java.jau.awt.macintosh;
6
7 import sun.awt.DrawingSurface;
8 import sun.awt.DrawingSurfaceInfo;
9 import sun.awt.MacDrawingSurface;
10
11 import java.awt.*;
12
13 /**
14 * This class has no user servicable parts inside. It is
15 * used internally by GLFrame and by our package spoofed
16 * sun.awt classes that give us internal access to window
17 * variables that we need to set up the OpenGL drawing
18 * context
19 *
20 *
21 * @see gl4java.jau.awt.WinHandleAccess
22 * @version 0.1, 7. JULY 1998
23 * @author Sven Goethel
24 * @author ported to Mac by gerard ziemski
25 *
26 */
27 public class MacHandleAccess implements gl4java.jau.awt.WinHandleAccess
28 {
29 protected DrawingSurface ds;
30 protected DrawingSurfaceInfo dsi;
31 protected MacDrawingSurface mds;
32 protected long window;
33 protected int depth;
34
35
36 protected void achieveData(java.awt.Component c, java.awt.Graphics g)
37 {
38 /* outta java3d */
39 dsi = null;
40 mds = null;
41 window = 0;
42 depth = 0;
43
44 ds = ((DrawingSurface)c.getPeer());
45 dsi = ds.getDrawingSurfaceInfo();
46
47 if (dsi != null)
48 {
49 dsi.lock();
50 mds = (MacDrawingSurface)dsi.getSurface();
51 dsi.unlock();
52 }
53
54 if (mds != null)
55 {
56 dsi.lock();
57
58 window = (long) mds.getPort();
59 depth = c.getColorModel().getPixelSize();
60
61 dsi.unlock();
62 }
63
64 if (mds == null)
65 {
66 System.out.println("MacHandleAccess:getWinHandle failed");
67 }
68 }
69
70 /**
71 *
72 * gets some structure for windows, and drawable on Mac
73 */
74 public long getWinHandle(java.awt.Component c, java.awt.Graphics g)
75 {
76 achieveData(c, g);
77 return window;
78 }
79
80 /**
81 *
82 * gets some structure for windows, and drawable on Mac
83 */
84 public int getWinDepth(java.awt.Component c, java.awt.Graphics g)
85 {
86 achieveData(c, g);
87 return depth;
88 }
89 }