Integration of OCCT 6.5.0 from SVN
[occt.git] / samples / java / java / util / win32 / WinHandleAccess.java
1
2 //Title:        Geological editor
3 //Version:      
4 //Copyright:    Copyright (c) 1998
5 //Author:       User Interface Group (Nizhny Novgorod)
6 //Company:      EQCC
7 //Description:  Prototype of BRGM project
8
9
10 package util.win32;
11
12 import sun.awt.DrawingSurface;
13 import sun.awt.Win32DrawingSurface;
14 import sun.awt.DrawingSurfaceInfo;
15 import java.awt.peer.ComponentPeer;
16 import java.awt.Component;
17
18
19 public class WinHandleAccess implements util.handleAccess
20 {
21
22   protected DrawingSurfaceInfo dsi;
23   protected Win32DrawingSurface wds;
24   protected int window, depth;
25
26   protected void achieveData(java.awt.Component c, java.awt.Graphics g)
27   {
28 //    System.out.println(">>> achieveData: Start...");
29 //    System.out.println(">>> achieveData: Component = " + c);
30 //    System.out.println(">>> achieveData: Graphics = " + g);
31
32     dsi=null;
33     wds=null;
34     window=0; depth=0;
35
36     ComponentPeer peer = c.getPeer();
37 //    System.out.println(">>> achieveData: Peer = " + peer);
38
39     DrawingSurface ds = (DrawingSurface) peer;
40 //    System.out.println(">>> achieveData: DrawingSurface = " + ds);
41
42     dsi = ds.getDrawingSurfaceInfo();
43 //    System.out.println(">>> achieveData: DrawingSurface = " + dsi);
44
45     if(dsi!=null)
46     {
47       dsi.lock();
48       wds = (Win32DrawingSurface)dsi.getSurface();
49       dsi.unlock();
50     }
51 //    System.out.println(">>> achieveData: Win32DrawingSurface = " + wds);
52
53     if(wds!=null)
54     {
55       dsi.lock();
56
57       //window = wds.getHDC();
58       window = wds.getHWnd();
59       depth = wds.getDepth();
60
61 /*
62       System.out.println("WinHandleAccess:");
63       System.out.println("\t wds = " + wds);
64       System.out.println("\t wds.Depth = " + wds.getDepth());
65       System.out.println("\t wds.HDC = " + wds.getHDC());
66       System.out.println("\t wds.HWnd = " + wds.getHWnd());
67 */
68
69       dsi.unlock();
70     }
71
72     if (wds==null)
73       System.out.println("Win32HandleAccess.getWinHandle failed, because the given Component is NOT a Window-Component\n");
74   }
75
76   public int getWinHandle(java.awt.Component c, java.awt.Graphics g)
77   {
78     achieveData(c, g);
79     return window;
80   }
81
82   public int getWinDepth(java.awt.Component c, java.awt.Graphics g)
83   {
84     achieveData(c, g);
85     return depth;
86   }
87
88   public int getVisualId(java.awt.GraphicsConfiguration gc)
89   {
90     return -1;
91   } // Not avalaible under Windows
92
93   public WinHandleAccess()
94   {
95   }
96
97 }