Source code: gl4java/jau/awt/windows/Win32HandleAccess.java
1 /*
2 * @(#) Win32HandleAccess.java
3 */
4
5 package gl4java.jau.awt.windows;
6
7 import sun.awt.DrawingSurface;
8 import sun.awt.Win32DrawingSurface;
9 import sun.awt.DrawingSurfaceInfo;
10
11 /**
12 * The ms-windows implementation for accessing the native window handle
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 * ontext
19 *
20 * @see gl4java.jau.awt.WinHandleAccess
21 * @version 0.1, 7. JULY 1998
22 * @author Sven Goethel
23 *
24 */
25 public class Win32HandleAccess
26 implements gl4java.jau.awt.WinHandleAccess
27 {
28
29 protected DrawingSurfaceInfo dsi;
30 protected Win32DrawingSurface wds;
31 protected long window;
32 protected int depth;
33
34 protected void achieveData(java.awt.Component c, java.awt.Graphics g)
35 {
36 /* outta java3d */
37 dsi=null;
38 wds=null;
39 window=0; depth=0;
40
41 dsi = ((DrawingSurface)(c.getPeer())).getDrawingSurfaceInfo();
42 if(dsi!=null)
43 {
44 dsi.lock();
45 wds = (Win32DrawingSurface)dsi.getSurface();
46 dsi.unlock();
47 }
48 if(wds!=null)
49 {
50 dsi.lock();
51 window = (long) wds.getHDC();
52 depth = wds.getDepth();
53 /*
54 System.out.println("wds ="+wds);
55 System.out.println("wds.Depth ="+wds.getDepth());
56 System.out.println("wds.HDC ="+wds.getHDC());
57 System.out.println("wds.HWnd ="+wds.getHWnd());
58 */
59 dsi.unlock();
60 }
61 if(wds==null)
62 System.out.println("Win32HandleAccess.getWinHandle failed, because the given Component is NOT a Window-Component\n");
63 }
64
65 /**
66 *
67 * gets some structure for windows, and drawable on Win32
68 */
69 public long getWinHandle(java.awt.Component c, java.awt.Graphics g)
70 {
71 achieveData(c, g);
72 return window;
73 }
74
75 /**
76 *
77 * gets some structure for windows, and drawable on Win32
78 */
79 public int getWinDepth(java.awt.Component c, java.awt.Graphics g)
80 {
81 achieveData(c, g);
82 return depth;
83 }
84 }
85