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 ************************************************************************/
32 import com
.sun
.star
.uno
.UnoRuntime
;
33 import com
.sun
.star
.uno
.XComponentContext
;
34 import com
.sun
.star
.uno
.AnyConverter
;
35 import com
.sun
.star
.lang
.XInitialization
;
36 import com
.sun
.star
.lib
.uno
.helper
.WeakBase
;
39 import com
.sun
.star
.awt
.*;
41 // system-dependent stuff
45 public class WindowAdapter
46 // defacto implementing the interface, but not deriving from it, since
47 // we're no real XInterface here
48 // implements com.sun.star.awt.XWindow
50 public java
.awt
.Frame frame
;
51 private boolean fullscreen
;
53 public WindowAdapter( int windowHandle
,
60 // create a normal Java frame, and set it into fullscreen mode
61 frame
= new javax
.swing
.JFrame( "Presentation" );
62 frame
.setUndecorated( true );
63 frame
.setVisible( true );
65 java
.awt
.Graphics2D graphics
= (java
.awt
.Graphics2D
)frame
.getGraphics();
66 if( graphics
.getDeviceConfiguration().getDevice().isFullScreenSupported() )
68 CanvasUtils
.printLog( "WindowAdapter(Win32): entering fullscreen mode" );
69 graphics
.getDeviceConfiguration().getDevice().setFullScreenWindow( frame
);
74 CanvasUtils
.printLog( "WindowAdapter(Win32): fullscreen not supported" );
81 // we're initialized with the operating system window handle
82 // as the parameter. We then generate a dummy Java frame with
83 // that window as the parent, to fake a root window for the
84 // Java implementation.
86 // now, we're getting slightly system dependent here.
87 String os
= (String
) System
.getProperty("os.name");
89 // create the embedded frame
90 if( os
.startsWith("Windows") )
91 frame
= new sun
.awt
.windows
.WEmbeddedFrame( windowHandle
);
93 throw new com
.sun
.star
.uno
.RuntimeException();
96 // frame = new javax.swing.JFrame( "Test window" );
98 // // resize it according to the given bounds
99 // frame.setBounds( boundRect );
100 // frame.setVisible( true );
104 //----------------------------------------------------------------------------------
106 public void dispose()
110 java
.awt
.Graphics2D graphics
= (java
.awt
.Graphics2D
)frame
.getGraphics();
111 if( graphics
.getDeviceConfiguration().getDevice().isFullScreenSupported() )
113 CanvasUtils
.printLog( "WindowAdapter(Win32): leaving fullscreen mode" );
114 graphics
.getDeviceConfiguration().getDevice().setFullScreenWindow( null );
123 //----------------------------------------------------------------------------------
129 public void setPosSize( int X
, int Y
, int Width
, int Height
, short Flags
)
131 frame
.setBounds( new java
.awt
.Rectangle( X
, Y
, Width
, Height
) );
134 public com
.sun
.star
.awt
.Rectangle
getPosSize( )
136 java
.awt
.Rectangle bounds
= frame
.getBounds();
138 return new com
.sun
.star
.awt
.Rectangle( bounds
.x
, bounds
.y
, bounds
.width
, bounds
.height
);
141 public void setVisible( boolean visible
)
143 frame
.setVisible( visible
);
146 public void setEnable( boolean enable
)
148 frame
.setEnabled( enable
);
151 public void setFocus()
155 public void addWindowListener( XWindowListener xListener
)
159 public void removeWindowListener( XWindowListener xListener
)
163 public void addFocusListener( XFocusListener xListener
)
167 public void removeFocusListener( XFocusListener xListener
)
171 public void addKeyListener( XKeyListener xListener
)
175 public void removeKeyListener( XKeyListener xListener
)
179 public void addMouseListener( XMouseListener xListener
)
183 public void removeMouseListener( XMouseListener xListener
)
187 public void addMouseMotionListener( XMouseMotionListener xListener
)
191 public void removeMouseMotionListener( XMouseMotionListener xListener
)
195 public void addPaintListener( XPaintListener xListener
)
199 public void removePaintListener( XPaintListener xListener
)