update dev300-m58
[ooovba.git] / canvas / source / java / aqua / WindowAdapter.java
blobc6974cf9871bc8457bbf67ef1685f34bb2dd75ad
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: WindowAdapter.java,v $
10 * $Revision: 1.3 $
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 // UNO
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;
38 // OOo AWT
39 import com.sun.star.awt.*;
41 // system-dependent stuff
42 import sun.awt.*;
44 //Apple specifics
45 import apple.awt.*;
48 public class WindowAdapter
49 // defacto implementing the interface, but not deriving from it, since
50 // we're no real XInterface here
51 // implements com.sun.star.awt.XWindow
53 public java.awt.Frame frame;
54 private boolean fullscreen;
56 public WindowAdapter( int windowHandle,
57 boolean _fullscreen )
59 fullscreen = false;
61 if( _fullscreen )
63 // create a normal Java frame, and set it into fullscreen mode
64 frame = new javax.swing.JFrame( "Presentation" );
65 frame.setUndecorated( true );
66 frame.setVisible( true );
68 java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics();
69 if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() )
71 CanvasUtils.printLog( "WindowAdapter(Aqua): entering fullscreen mode" );
72 graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( frame );
73 fullscreen = true;
75 else
77 CanvasUtils.printLog( "WindowAdapter(Aqua): fullscreen not supported" );
80 graphics.dispose();
82 else
84 // we're initialized with the operating system window handle
85 // as the parameter. We then generate a dummy Java frame with
86 // that window as the parent, to fake a root window for the
87 // Java implementation.
89 // now, we're getting slightly system dependent here.
90 String os = (String) System.getProperty("os.name");
92 // create the embedded frame
93 if( os.startsWith("Mac OS X") )
94 frame = new apple.awt.CEmbeddedFrame( windowHandle );
95 else
96 throw new com.sun.star.uno.RuntimeException();
99 // frame = new javax.swing.JFrame( "Test window" );
101 // // resize it according to the given bounds
102 // frame.setBounds( boundRect );
103 // frame.setVisible( true );
107 //----------------------------------------------------------------------------------
109 public void dispose()
111 if( fullscreen )
113 java.awt.Graphics2D graphics = (java.awt.Graphics2D)frame.getGraphics();
114 if( graphics.getDeviceConfiguration().getDevice().isFullScreenSupported() )
116 CanvasUtils.printLog( "WindowAdapter(Aqua): leaving fullscreen mode" );
117 graphics.getDeviceConfiguration().getDevice().setFullScreenWindow( null );
119 graphics.dispose();
122 if( frame != null )
123 frame.dispose();
126 //----------------------------------------------------------------------------------
129 // XWindow interface
130 // =================
132 public void setPosSize( int X, int Y, int Width, int Height, short Flags )
134 frame.setBounds( new java.awt.Rectangle( X, Y, Width, Height ) );
137 public com.sun.star.awt.Rectangle getPosSize( )
139 java.awt.Rectangle bounds = frame.getBounds();
141 return new com.sun.star.awt.Rectangle( bounds.x, bounds.y, bounds.width, bounds.height );
144 public void setVisible( boolean visible )
146 frame.setVisible( visible );
149 public void setEnable( boolean enable )
151 frame.setEnabled( enable );
154 public void setFocus()
158 public void addWindowListener( XWindowListener xListener )
162 public void removeWindowListener( XWindowListener xListener )
166 public void addFocusListener( XFocusListener xListener )
170 public void removeFocusListener( XFocusListener xListener )
174 public void addKeyListener( XKeyListener xListener )
178 public void removeKeyListener( XKeyListener xListener )
182 public void addMouseListener( XMouseListener xListener )
186 public void removeMouseListener( XMouseListener xListener )
190 public void addMouseMotionListener( XMouseMotionListener xListener )
194 public void removeMouseMotionListener( XMouseMotionListener xListener )
198 public void addPaintListener( XPaintListener xListener )
202 public void removePaintListener( XPaintListener xListener )