1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: WindowAdapter.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 import com
.sun
.star
.awt
.*;
34 public class WindowAdapter
35 // defacto implementing the interface, but not deriving from it, since
36 // we're no real XInterface here
37 // implements com.sun.star.awt.XWindow
39 // the frame object we're generating. TODO: Remove public access.
40 public java
.awt
.Frame frame
;
41 private boolean fullscreen
;
43 public WindowAdapter( int windowHandle
,
46 CanvasUtils
.printLog( "WindowAdapter(X11): constructor called" );
51 // create a normal Java frame, and set it into fullscreen mode
52 frame
= new javax
.swing
.JFrame( "Presentation" );
53 frame
.setUndecorated( true );
54 frame
.setVisible( true );
56 java
.awt
.Graphics2D graphics
= (java
.awt
.Graphics2D
)frame
.getGraphics();
57 if( graphics
.getDeviceConfiguration().getDevice().isFullScreenSupported() )
59 CanvasUtils
.printLog( "WindowAdapter(X11): entering fullscreen mode" );
60 graphics
.getDeviceConfiguration().getDevice().setFullScreenWindow( frame
);
65 CanvasUtils
.printLog( "WindowAdapter(X11): fullscreen not supported" );
72 // we're initialized with the operating system window handle
73 // as the parameter. We then generate a dummy Java frame with
74 // that window as the parent, to fake a root window for the
75 // Java implementation.
77 // now, we're getting slightly system dependent here.
78 String os
= (String
) System
.getProperty("os.name");
80 System
.err
.println("WindowAdapter created");
82 // create the embedded frame
83 if( os
.startsWith("Linux") )
85 // create a java frame from that
86 // TODO: Maybe that's the reason why we crash on Linux 1.5beta
87 // immediately: Try XAWT here, or naked X: sun.awt.X11.XEmbeddedFrame
90 //frame = new sun.awt.motif.MEmbeddedFrame( windowHandle ); // Crashes 1.5, because class is unknown
91 //frame = new sun.awt.X11.XEmbeddedFrame( windowHandle ); // cannot currently compile, because class is not in 1.4.
92 CanvasUtils
.printLog( "WindowAdapter(X11): no frame created for now" );
93 frame
= null; // disabled for now
97 throw new com
.sun
.star
.uno
.RuntimeException();
102 //----------------------------------------------------------------------------------
104 public void dispose()
108 java
.awt
.Graphics2D graphics
= (java
.awt
.Graphics2D
)frame
.getGraphics();
109 if( graphics
.getDeviceConfiguration().getDevice().isFullScreenSupported() )
111 CanvasUtils
.printLog( "WindowAdapter(X11): leaving fullscreen mode" );
112 graphics
.getDeviceConfiguration().getDevice().setFullScreenWindow( null );
121 //----------------------------------------------------------------------------------
127 public void setPosSize( int X
, int Y
, int Width
, int Height
, short Flags
)
129 frame
.setBounds( new java
.awt
.Rectangle( X
, Y
, Width
, Height
) );
132 public com
.sun
.star
.awt
.Rectangle
getPosSize( )
134 java
.awt
.Rectangle bounds
= frame
.getBounds();
136 return new com
.sun
.star
.awt
.Rectangle( bounds
.x
, bounds
.y
, bounds
.width
, bounds
.height
);
139 public void setVisible( boolean visible
)
141 frame
.setVisible( visible
);
144 public void setEnable( boolean enable
)
146 frame
.setEnabled( enable
);
149 public void setFocus()
153 public void addWindowListener( XWindowListener xListener
)
157 public void removeWindowListener( XWindowListener xListener
)
161 public void addFocusListener( XFocusListener xListener
)
165 public void removeFocusListener( XFocusListener xListener
)
169 public void addKeyListener( XKeyListener xListener
)
173 public void removeKeyListener( XKeyListener xListener
)
177 public void addMouseListener( XMouseListener xListener
)
181 public void removeMouseListener( XMouseListener xListener
)
185 public void addMouseMotionListener( XMouseMotionListener xListener
)
189 public void removeMouseMotionListener( XMouseMotionListener xListener
)
193 public void addPaintListener( XPaintListener xListener
)
197 public void removePaintListener( XPaintListener xListener
)