提交 78db644c 编写于 作者: Y yan

6706121: makefile: unnecessary Motif classes compilation in JDK7

Summary: removed 80 obsolete .c and .java files, temporary modified some more
Reviewed-by: denis
上级 a0158dbd
......@@ -142,59 +142,59 @@ FILES_2D_c = \
# These files rely on motif to be built, and should not be included
# in a headless build.
FILES_MOTIF_c = \
awt_AWTEvent.c \
awt_Button.c \
awt_Canvas.c \
awt_Checkbox.c \
awt_Component.c \
awt_Cursor.c \
awt_DataTransferer.c \
awt_DrawingSurface.c \
awt_Event.c \
awt_FileDialog.c \
awt_GlobalCursorManager.c \
awt_GraphicsEnv.c \
awt_InputMethod.c \
awt_Insets.c \
awt_KeyboardFocusManager.c \
awt_Label.c \
awt_List.c \
awt_Menu.c \
awt_MenuBar.c \
awt_MenuComponent.c \
awt_MenuItem.c \
awt_motif.c \
awt_Plugin.c \
awt_PopupMenu.c \
awt_Robot.c \
awt_Scrollbar.c \
awt_ScrollPane.c \
awt_Selection.c \
awt_UNIXToolkit.c \
awt_TextArea.c \
awt_TextField.c \
awt_TopLevel.c \
awt_mgrsel.c \
awt_util.c \
awt_wm.c \
awt_XmDnD.c \
awt_dnd.c \
awt_dnd_ds.c \
awt_dnd_dt.c \
canvas.c \
cursor.c \
multi_font.c \
robot_common.c \
list.c \
multiVis.c \
XDrawingArea.c \
MouseInfo.c \
awt_xembed.c \
awt_xembed_server.c \
gtk2_interface.c \
swing_GTKEngine.c \
swing_GTKStyle.c
#FILES_MOTIF_c = \
#keep awt_AWTEvent.c \
# awt_Button.c \
# awt_Canvas.c \
# awt_Checkbox.c \
#keep .h awt_Component.c \
#keep .h awt_Cursor.c \
# awt_DataTransferer.c \
# awt_DrawingSurface.c \
# awt_Event.c \
# awt_FileDialog.c \
# awt_GlobalCursorManager.c \
# awt_GraphicsEnv.c \
# awt_InputMethod.c \
#keep awt_Insets.c \
# awt_KeyboardFocusManager.c \
# awt_Label.c \
# awt_List.c \
# awt_Menu.c \
# awt_MenuBar.c \
# awt_MenuComponent.c \
# awt_MenuItem.c \
# awt_motif.c \
# awt_Plugin.c \
# awt_PopupMenu.c \
# awt_Robot.c \
# awt_Scrollbar.c \
# awt_ScrollPane.c \
# awt_Selection.c \
# awt_UNIXToolkit.c \
# awt_TextArea.c \
# awt_TextField.c \
# awt_TopLevel.c \
# awt_mgrsel.c \
# awt_util.c \
# awt_wm.c \
# awt_XmDnD.c \
# awt_dnd.c \
# awt_dnd_ds.c \
# awt_dnd_dt.c \
# canvas.c \
# cursor.c \
# multi_font.c \
# robot_common.c \
# list.c \
# multiVis.c \
# XDrawingArea.c \
# MouseInfo.c \
# awt_xembed.c \
# awt_xembed_server.c \
# gtk2_interface.c \
# swing_GTKEngine.c \
# swing_GTKStyle.c
# These files are required to be built, with or without motif. Some of
......
......@@ -57,48 +57,15 @@ FILES_export = \
sun/awt/image/DataBufferNative.java \
\
sun/awt/motif/X11FontMetrics.java \
sun/awt/motif/X11Clipboard.java \
sun/awt/motif/X11Selection.java \
sun/awt/motif/X11SelectionHolder.java \
sun/awt/X11InputMethod.java \
sun/awt/motif/MInputMethod.java \
sun/awt/motif/MInputMethodControl.java \
sun/awt/motif/MCustomCursor.java \
sun/awt/motif/MFontConfiguration.java \
sun/awt/motif/MFontPeer.java \
sun/awt/motif/MToolkit.java \
sun/awt/motif/MComponentPeer.java \
sun/awt/motif/MButtonPeer.java \
sun/awt/motif/MCanvasPeer.java \
sun/awt/motif/MCheckboxPeer.java \
sun/awt/motif/MFileDialogPeer.java \
sun/awt/motif/MGlobalCursorManager.java \
sun/awt/motif/MTextFieldPeer.java \
sun/awt/motif/MLabelPeer.java \
sun/awt/motif/MListPeer.java \
sun/awt/motif/MWindowPeer.java \
sun/awt/motif/MMenuBarPeer.java \
sun/awt/motif/MMenuPeer.java \
sun/awt/motif/MPopupMenuPeer.java \
sun/awt/motif/MDialogPeer.java \
sun/awt/motif/MMenuItemPeer.java \
sun/awt/motif/MCheckboxMenuItemPeer.java \
sun/awt/motif/MChoicePeer.java \
sun/awt/motif/MTextAreaPeer.java \
sun/awt/motif/MScrollbarPeer.java \
sun/awt/motif/MScrollPanePeer.java \
sun/awt/motif/MFramePeer.java \
sun/awt/DebugSettings.java \
sun/awt/EmbeddedFrame.java \
sun/awt/motif/MEmbeddedFramePeer.java \
sun/awt/PlatformFont.java \
sun/awt/FontDescriptor.java \
sun/awt/NativeLibLoader.java \
sun/awt/motif/MDropTargetContextPeer.java \
sun/awt/motif/MDragSourceContextPeer.java \
sun/awt/motif/MRobotPeer.java \
sun/awt/motif/X11DragSourceContextPeer.java \
sun/awt/motif/X11DropTargetContextPeer.java \
sun/awt/X11GraphicsEnvironment.java \
sun/awt/X11GraphicsDevice.java \
sun/awt/X11GraphicsConfig.java \
......@@ -120,7 +87,6 @@ FILES_export = \
sun/java2d/cmm/ColorTransform.java \
sun/awt/datatransfer/DataTransferer.java \
sun/awt/dnd/SunDragSourceContextPeer.java \
sun/awt/motif/MDataTransferer.java \
sun/awt/motif/MToolkitThreadBlockedHandler.java \
sun/java2d/opengl/OGLBlitLoops.java \
sun/java2d/opengl/OGLContext.java \
......@@ -216,6 +182,5 @@ FILES_export2 = \
java/awt/event/NativeLibLoader.java \
java/awt/peer/ComponentPeer.java \
java/awt/dnd/DnDConstants.java \
sun/awt/CausedFocusEvent.java \
sun/awt/motif/MEmbedCanvasPeer.java
sun/awt/CausedFocusEvent.java
此差异已折叠。
此差异已折叠。
......@@ -28,14 +28,6 @@
#
INIT += $(LIB_LOCATION)
ifndef HEADLESS
ifeq ($(PLATFORM), linux)
ifeq ($(STATIC_MOTIF),false)
INIT += $(LIB_LOCATION)/libXm.so
endif
endif
endif
#
# Files
#
......@@ -52,13 +44,9 @@ include $(BUILDDIR)/sun/awt/FILES_export_unix.gmk
ifdef HEADLESS
FILES_c = $(FILES_NO_MOTIF_c)
else
FILES_c = $(FILES_MOTIF_c) $(FILES_NO_MOTIF_c)
ifeq ($(MOTIF_VERSION), 2)
FILES_c += awt_motif21.c
FILES_c += awt_Choice21.c
endif
# FILES_c = $(FILES_MOTIF_c) $(FILES_NO_MOTIF_c)
# XXX if in FILES_MOTIF_c there are unrelated to motif stuff, create a separate list!
FILES_c = $(FILES_NO_MOTIF_c)
endif
ifeq ($(PLATFORM), solaris)
......@@ -93,15 +81,6 @@ include $(BUILDDIR)/common/Library.gmk
$(LIB_LOCATION):
$(MKDIR) -p $@
ifeq ($(PLATFORM), linux)
ifeq ($(STATIC_MOTIF),false)
$(LIB_LOCATION)/libXm.so:
$(CP) $(MOTIF_LIB)/libXm.so $(LIB_LOCATION)/libXm.so
# Automounter problem makes the link fail on Redhat 6.1.
# $(LN) -s $(MOTIF_LIB)/libXm.so $(LIB_LOCATION)/libXm.so
endif
endif
clean::
#
......@@ -135,33 +114,49 @@ CFLAGS += -DHEADLESS=$(HEADLESS)
CPPFLAGS += -DHEADLESS=$(HEADLESS)
OTHER_LDLIBS =
else
CFLAGS += -DMOTIF_VERSION=$(MOTIF_VERSION)
ifeq ($(STATIC_MOTIF),true)
LIBXM = $(MOTIF_LIB)/libXm.a -lXp -lXmu
ifeq ($(PLATFORM), linux)
ifeq ($(ARCH_DATA_MODEL), 64)
LIBXT = -lXt
else
# Allows for builds on Debian GNU Linux, X11 is in a different place
LIBXT = $(firstword $(wildcard /usr/X11R6/lib/libXt.a) \
$(wildcard /usr/lib/libXt.a))
LIBSM = $(firstword $(wildcard /usr/X11R6/lib/libSM.a) \
$(wildcard /usr/lib/libSM.a))
LIBICE = $(firstword $(wildcard /usr/X11R6/lib/libICE.a) \
$(wildcard /usr/lib/libICE.a))
endif
endif
else
LIBXM = -L$(MOTIF_LIB) -lXm -lXp
ifeq ($(PLATFORM), linux)
LIBXT = -lXt
LIBSM =
LIBICE =
endif
endif
#CFLAGS += -DMOTIF_VERSION=$(MOTIF_VERSION)
#ifeq ($(STATIC_MOTIF),true)
# LIBXM = $(MOTIF_LIB)/libXm.a -lXp -lXmu
# ifeq ($(PLATFORM), linux)
# ifeq ($(ARCH_DATA_MODEL), 64)
# LIBXT = -lXt
# else
# # Allows for builds on Debian GNU Linux, X11 is in a different place
# LIBXT = $(firstword $(wildcard /usr/X11R6/lib/libXt.a) \
# $(wildcard /usr/lib/libXt.a))
# LIBSM = $(firstword $(wildcard /usr/X11R6/lib/libSM.a) \
# $(wildcard /usr/lib/libSM.a))
# LIBICE = $(firstword $(wildcard /usr/X11R6/lib/libICE.a) \
# $(wildcard /usr/lib/libICE.a))
# endif
# endif
#else
# LIBXM = -L$(MOTIF_LIB) -lXm -lXp
# ifeq ($(PLATFORM), linux)
# LIBXT = -lXt
# LIBSM =
# LIBICE =
# endif
#endif
LIBXTST = -lXtst
ifeq ($(PLATFORM), linux)
ifeq ($(ARCH_DATA_MODEL), 64)
# XXX what about the rest of them?
LIBXT = -lXt
else
# Allows for builds on Debian GNU Linux, X11 is in a different place
LIBXT = $(firstword $(wildcard /usr/X11R6/lib/libXt.a) \
$(wildcard /usr/lib/libXt.a))
LIBSM = $(firstword $(wildcard /usr/X11R6/lib/libSM.a) \
$(wildcard /usr/lib/libSM.a))
LIBICE = $(firstword $(wildcard /usr/X11R6/lib/libICE.a) \
$(wildcard /usr/lib/libICE.a))
LIBXTST = $(firstword $(wildcard /usr/X11R6/lib/libXtst.a) \
$(wildcard /usr/lib/libXtst.a))
endif
endif
# Use -lXmu for EditRes support
LIBXMU_DBG = -lXmu
......@@ -169,14 +164,14 @@ LIBXMU_OPT =
LIBXMU = $(LIBXMU_$(VARIANT))
ifeq ($(PLATFORM), solaris)
OTHER_LDLIBS = $(LIBXM) -lXt -lXext $(LIBXTST) $(LIBXMU) -lX11 -lXi
OTHER_LDLIBS = -lXt -lXext $(LIBXTST) $(LIBXMU) -lX11 -lXi
endif
ifeq ($(PLATFORM), linux)
OTHER_CFLAGS += -DMLIB_NO_LIBSUNMATH
OTHER_CFLAGS += -DMOTIF_VERSION=2
# XXX what is this define below? Isn't it motif-related?
OTHER_CFLAGS += -DXMSTRINGDEFINES=1
OTHER_LDLIBS = $(LIBXM) $(LIBXMU) $(LIBXTST) -lXext $(LIBXT) $(LIBSM) $(LIBICE) -lX11 -lXi
OTHER_LDLIBS = $(LIBXMU) $(LIBXTST) -lXext $(LIBXT) $(LIBSM) $(LIBICE) -lX11 -lXi
endif
endif
......@@ -199,9 +194,8 @@ endif
CPPFLAGS += -I$(CUPS_HEADERS_PATH)
ifndef HEADLESS
CPPFLAGS += -I$(MOTIF_DIR)/include \
-I$(OPENWIN_HOME)/include
LDFLAGS += -L$(MOTIF_LIB) -L$(OPENWIN_LIB)
CPPFLAGS += -I$(OPENWIN_HOME)/include
LDFLAGS += -L$(OPENWIN_LIB)
endif # !HEADLESS
......
......@@ -93,7 +93,6 @@ else # PLATFORM
# Other extra flags needed for compiling.
#
CPPFLAGS += -I$(OPENWIN_HOME)/include \
-I$(MOTIF_DIR)/include \
-I$(SHARE_SRC)/native/$(PKGDIR)/debug \
-I$(SHARE_SRC)/native/$(PKGDIR)/image \
-I$(SHARE_SRC)/native/$(PKGDIR)/image/cvutils \
......
/*
* Copyright 1995-2001 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.awt.motif;
import java.awt.*;
import java.awt.peer.*;
import java.awt.event.ActionEvent;
class MButtonPeer extends MComponentPeer implements ButtonPeer {
native void create(MComponentPeer peer);
public native void setLabel(String label);
MButtonPeer(Button target) {
super(target);
}
public Dimension getMinimumSize() {
FontMetrics fm = getFontMetrics(target.getFont());
String label = ((Button)target).getLabel();
if ( label == null ) {
label = "";
}
return new Dimension(fm.stringWidth(label) + 14,
fm.getHeight() + 8);
}
public boolean isFocusable() {
return true;
}
// NOTE: This method is called by privileged threads.
// DO NOT INVOKE CLIENT CODE ON THIS THREAD!
public void action(final long when, final int modifiers) {
MToolkit.executeOnEventHandlerThread(target, new Runnable() {
public void run() {
postEvent(new ActionEvent(target, ActionEvent.ACTION_PERFORMED,
((Button)target).getActionCommand(),
when, modifiers));
}
});
}
/*
* Print the native component by rendering the Motif look ourselves.
* ToDo(aim): needs to query native motif for more accurate size and
* color information.
*/
public void print(Graphics g) {
Button b = (Button)target;
Dimension d = b.size();
Color bg = b.getBackground();
Color fg = b.getForeground();
g.setColor(bg);
g.fillRect(2, 2, d.width - 3, d.height - 3);
draw3DRect(g, bg, 1, 1, d.width - 2, d.height - 2, true);
g.setColor(fg);
g.setFont(b.getFont());
FontMetrics fm = g.getFontMetrics();
String lbl = b.getLabel();
g.drawString(lbl, (d.width - fm.stringWidth(lbl)) / 2,
(d.height + fm.getMaxAscent() - fm.getMaxDescent()) / 2);
target.print(g);
}
/**
* DEPRECATED
*/
public Dimension minimumSize() {
return getMinimumSize();
}
}
/*
* Copyright 1995-2005 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.awt.motif;
import java.awt.*;
import java.awt.peer.*;
import sun.awt.DisplayChangedListener;
import sun.awt.X11GraphicsConfig;
import sun.awt.X11GraphicsDevice;
import sun.awt.X11GraphicsEnvironment;
class MCanvasPeer extends MComponentPeer implements CanvasPeer,
DisplayChangedListener {
native void create(MComponentPeer parent);
private static native void initIDs();
static {
initIDs();
}
MCanvasPeer() {}
MCanvasPeer(Component target) {
super(target);
}
MCanvasPeer(Component target, Object arg) {
super(target, arg);
}
/* --- DisplayChangedListener Stuff --- */
public void displayChanged() {}
public void paletteChanged() {}
native void resetTargetGC(Component target);
/*
* Called when the Window this
* Canvas is on is moved onto another Xinerama screen.
*
* Canvases can be created with a non-defulat GraphicsConfiguration. The
* GraphicsConfiguration needs to be changed to one on the new screen,
* preferably with the same visual ID.
*
* Up-called for other windows peer instances (WPanelPeer, WWindowPeer).
*
* Should only be called from the event thread.
*/
public void displayChanged(int screenNum) {
resetLocalGC(screenNum);
resetTargetGC(target); /* call Canvas.setGCFromPeer() via native */
}
/* Set graphicsConfig to a GraphicsConfig with the same visual on the new
* screen, which should be easy in Xinerama mode.
*
* Should only be called from displayChanged(), and therefore only from
* the event thread.
*/
void resetLocalGC(int screenNum) {
// Opt: Only need to do if we're not using the default GC
if (graphicsConfig != null) {
X11GraphicsConfig parentgc;
// save vis id of current gc
int visual = graphicsConfig.getVisual();
X11GraphicsDevice newDev = (X11GraphicsDevice) GraphicsEnvironment.
getLocalGraphicsEnvironment().
getScreenDevices()[screenNum];
for (int i = 0; i < newDev.getNumConfigs(screenNum); i++) {
if (visual == newDev.getConfigVisualId(i, screenNum)) {
// use that
graphicsConfig = (X11GraphicsConfig)newDev.getConfigurations()[i];
break;
}
}
// just in case...
if (graphicsConfig == null) {
graphicsConfig = (X11GraphicsConfig) GraphicsEnvironment.
getLocalGraphicsEnvironment().
getScreenDevices()[screenNum].
getDefaultConfiguration();
}
}
}
protected boolean shouldFocusOnClick() {
// Canvas should always be able to be focused by mouse clicks.
return true;
}
}
/*
* Copyright 1995-2005 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.awt.motif;
import java.awt.*;
import java.awt.event.*;
import java.awt.peer.*;
class MCheckboxMenuItemPeer extends MMenuItemPeer
implements CheckboxMenuItemPeer {
private boolean inUpCall=false;
private boolean inInit=false;
native void pSetState(boolean t);
native boolean getState();
void create(MMenuPeer parent) {
super.create(parent);
inInit=true;
setState(((CheckboxMenuItem)target).getState());
inInit=false;
}
MCheckboxMenuItemPeer(CheckboxMenuItem target) {
this.target = target;
isCheckbox = true;
MMenuPeer parent = (MMenuPeer) MToolkit.targetToPeer(getParent_NoClientCode(target));
create(parent);
}
public void setState(boolean t) {
if (!nativeCreated) {
return;
}
if (!inUpCall && (t != getState())) {
pSetState(t);
if (!inInit) {
// 4135725 : do not notify on programatic changes
// notifyStateChanged(t);
}
}
}
void notifyStateChanged(boolean state) {
CheckboxMenuItem cb = (CheckboxMenuItem)target;
ItemEvent e = new ItemEvent(cb,
ItemEvent.ITEM_STATE_CHANGED,
cb.getLabel(),
state ? ItemEvent.SELECTED : ItemEvent.DESELECTED);
postEvent(e);
}
// NOTE: This method may be called by privileged threads.
// DO NOT INVOKE CLIENT CODE ON THIS THREAD!
public void action(long when, int modifiers, boolean state) {
final CheckboxMenuItem cb = (CheckboxMenuItem)target;
final boolean newState = state;
MToolkit.executeOnEventHandlerThread(cb, new Runnable() {
public void run() {
cb.setState(newState);
notifyStateChanged(newState);
}
});
//Fix for 5005195: MAWT: CheckboxMenuItem fires action events
//super.action() is not invoked
} // action()
} // class MCheckboxMenuItemPeer
/*
* Copyright 1995-2000 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.awt.motif;
import java.awt.*;
import java.awt.peer.*;
import java.awt.event.*;
public class MCheckboxPeer extends MComponentPeer implements CheckboxPeer {
private boolean inUpCall = false;
private boolean inInit=false;
native void create(MComponentPeer parent);
native void pSetState(boolean state);
native boolean pGetState();
public native void setLabel(String label);
public native void setCheckboxGroup(CheckboxGroup g);
void initialize() {
Checkbox t = (Checkbox)target;
inInit=true;
setState(t.getState());
setCheckboxGroup(t.getCheckboxGroup());
super.initialize();
inInit=false;
}
public MCheckboxPeer(Checkbox target) {
super(target);
}
public boolean isFocusable() {
return true;
}
public void setState(boolean state) {
if (inInit) {
pSetState(state);
} else if (!inUpCall && (state != pGetState())) {
pSetState(state);
// 4135725 : do not notify on programatic changes
// notifyStateChanged(state);
}
}
private native int getIndicatorSize();
private native int getSpacing();
public Dimension getMinimumSize() {
String lbl = ((Checkbox)target).getLabel();
if (lbl == null) {
lbl = "";
}
FontMetrics fm = getFontMetrics(target.getFont());
/*
* Spacing (number of pixels between check mark and label text) is
* currently set to 0, but in case it ever changes we have to add
* it. 8 is a heuristic number. Indicator size depends on font
* height, so we don't need to include it in checkbox's height
* calculation.
*/
int wdth = fm.stringWidth(lbl) + getIndicatorSize() + getSpacing() + 8;
int hght = Math.max(fm.getHeight() + 8, 15);
return new Dimension(wdth, hght);
}
void notifyStateChanged(boolean state) {
Checkbox cb = (Checkbox) target;
ItemEvent e = new ItemEvent(cb,
ItemEvent.ITEM_STATE_CHANGED,
cb.getLabel(),
state ? ItemEvent.SELECTED : ItemEvent.DESELECTED);
postEvent(e);
}
// NOTE: This method is called by privileged threads.
// DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void action(boolean state) {
final Checkbox cb = (Checkbox)target;
final boolean newState = state;
MToolkit.executeOnEventHandlerThread(cb, new Runnable() {
public void run() {
CheckboxGroup cbg = cb.getCheckboxGroup();
/* Bugid 4039594. If this is the current Checkbox in
* a CheckboxGroup, then return to prevent deselection.
* Otherwise, it's logical state will be turned off,
* but it will appear on.
*/
if ((cbg != null) && (cbg.getSelectedCheckbox() == cb) &&
cb.getState()) {
inUpCall = false;
cb.setState(true);
return;
}
// All clear - set the new state
cb.setState(newState);
notifyStateChanged(newState);
} // run()
});
} // action()
static final int SIZE = 19;
static final int BORDER = 4;
static final int SIZ = SIZE - BORDER*2 - 1;
/*
* Print the native component by rendering the Motif look ourselves.
* ToDo(aim): needs to query native motif for more accurate size and
* color information; need to render check mark.
*/
public void print(Graphics g) {
Checkbox cb = (Checkbox)target;
Dimension d = cb.size();
Color bg = cb.getBackground();
Color fg = cb.getForeground();
Color shadow = bg.darker();
int x = BORDER;
int y = ((d.height - SIZE) / 2) + BORDER;
g.setColor(cb.getState()? shadow : bg);
if (cb.getCheckboxGroup() != null) {
g.fillOval(x, y, SIZ, SIZ);
draw3DOval(g, bg, x, y, SIZ, SIZ, !(cb.getState()));
if (cb.getState()) {
g.setColor(fg);
g.fillOval(x + 3, y + 3, SIZ - 6, SIZ - 6);
}
} else {
g.fillRect(x, y, SIZ, SIZ);
draw3DRect(g, bg, x, y, SIZ, SIZ, !(cb.getState()));
if (cb.getState()) {
g.setColor(fg);
g.drawLine(x+1, y+1, x+SIZ-1, y+SIZ-1);
g.drawLine(x+1, y+SIZ-1, x+SIZ-1, y+1);
}
}
g.setColor(fg);
String lbl = cb.getLabel();
if (lbl != null) {
// REMIND: align
g.setFont(cb.getFont());
FontMetrics fm = g.getFontMetrics();
g.drawString(lbl, SIZE,
(d.height + fm.getMaxAscent() - fm.getMaxDescent()) / 2);
}
target.print(g);
}
/**
* DEPRECATED
*/
public Dimension minimumSize() {
return getMinimumSize();
}
}
/*
* Copyright 1995-2003 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.awt.motif;
import java.awt.*;
import java.awt.peer.*;
import java.awt.event.ItemEvent;
class MChoicePeer extends MComponentPeer implements ChoicePeer {
boolean inUpCall=false;
native void create(MComponentPeer parent);
native void pReshape(int x, int y, int width, int height);
native void pSelect(int index, boolean init);
native void appendItems(String[] items);
void initialize() {
Choice opt = (Choice)target;
int itemCount = opt.countItems();
String[] items = new String[itemCount];
for (int i=0; i < itemCount; i++) {
items[i] = opt.getItem(i);
}
if (itemCount > 0) {
appendItems(items);
pSelect(opt.getSelectedIndex(), true);
}
super.initialize();
}
public MChoicePeer(Choice target) {
super(target);
}
public boolean isFocusable() {
return true;
}
public Dimension getMinimumSize() {
FontMetrics fm = getFontMetrics(target.getFont());
Choice c = (Choice)target;
int w = 0;
for (int i = c.countItems() ; i-- > 0 ;) {
w = Math.max(fm.stringWidth(c.getItem(i)), w);
}
return new Dimension(32 + w, Math.max(fm.getHeight() + 8, 15) + 5);
}
public native void setFont(Font f);
public void add(String item, int index) {
addItem(item, index);
// Adding an item can change the size of the Choice, so do
// a reshape, based on the font size.
Rectangle r = target.getBounds();
reshape(r.x, r.y, 0, 0);
}
public native void remove(int index);
public native void removeAll();
/**
* DEPRECATED, but for now, called by add(String, int).
*/
public native void addItem(String item, int index);
// public native void remove(int index);
public native void setBackground(Color c);
public native void setForeground(Color c);
public void select(int index) {
if (!inUpCall) {
pSelect(index, false);
}
}
void notifySelection(String item) {
Choice c = (Choice)target;
ItemEvent e = new ItemEvent(c, ItemEvent.ITEM_STATE_CHANGED,
item, ItemEvent.SELECTED);
postEvent(e);
}
// NOTE: This method is called by privileged threads.
// DO NOT INVOKE CLIENT CODE ON THIS THREAD!
void action(final int index) {
final Choice c = (Choice)target;
inUpCall = false; /* Used to prevent native selection. */
MToolkit.executeOnEventHandlerThread(c, new Runnable() {
public void run() {
String item;
synchronized(c) {
if (index >= c.getItemCount()) {
/* Nothing to do when the list is too short */
return;
}
inUpCall = true; /* Prevent native selection. */
c.select(index); /* set value in target */
item = c.getItem(index);
inUpCall = false;
}
notifySelection(item);
}
});
}
/*
* Print the native component by rendering the Motif look ourselves.
* ToDo(aim): needs to query native motif for more accurate size and
* color information.
*/
public void print(Graphics g) {
Choice ch = (Choice)target;
Dimension d = ch.size();
Color bg = ch.getBackground();
Color fg = ch.getForeground();
g.setColor(bg);
g.fillRect(2, 2, d.width-1, d.height-1);
draw3DRect(g, bg, 1, 1, d.width-2, d.height-2, true);
draw3DRect(g, bg, d.width - 18, (d.height / 2) - 3, 10, 6, true);
g.setColor(fg);
g.setFont(ch.getFont());
FontMetrics fm = g.getFontMetrics();
String lbl = ch.getSelectedItem();
if (lbl == null){
lbl = "";
}
if (lbl != ""){
g.drawString(lbl, 5, (d.height + fm.getMaxAscent()-fm.getMaxDescent())/2);
}
target.print(g);
}
/**
* DEPRECATED
*/
public Dimension minimumSize() {
return getMinimumSize();
}
protected void disposeImpl() {
freeNativeData();
super.disposeImpl();
}
private native void freeNativeData();
}
/*
* Copyright 2003 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.awt.motif;
import sun.awt.X11CustomCursor;
import sun.awt.CustomCursor;
import java.awt.*;
import java.awt.image.*;
import sun.awt.image.ImageRepresentation;
public class MCustomCursor extends X11CustomCursor {
public MCustomCursor(Image cursor, Point hotSpot, String name)
throws IndexOutOfBoundsException {
super(cursor, hotSpot, name);
}
/**
* Returns the supported cursor size
*/
public static Dimension getBestCursorSize(
int preferredWidth, int preferredHeight) {
// Fix for bug 4212593 The Toolkit.createCustomCursor does not
// check absence of the image of cursor
// We use XQueryBestCursor which accepts unsigned ints to obtain
// the largest cursor size that could be dislpayed
Dimension d = new Dimension(Math.abs(preferredWidth), Math.abs(preferredHeight));
queryBestCursor(d);
return d;
}
private static native void queryBestCursor(Dimension d);
protected native void createCursor(byte[] xorMask, byte[] andMask,
int width, int height,
int fcolor, int bcolor,
int xHotSpot, int yHotSpot);
static {
cacheInit();
}
private native static void cacheInit();
}
/*
* Copyright 2000-2004 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.awt.motif;
import java.awt.Image;
import java.awt.datatransfer.DataFlavor;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.WritableRaster;
import java.io.InputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import javax.imageio.ImageIO;
import javax.imageio.ImageTypeSpecifier;
import javax.imageio.ImageWriter;
import javax.imageio.spi.ImageWriterSpi;
import sun.awt.datatransfer.DataTransferer;
import sun.awt.datatransfer.ToolkitThreadBlockedHandler;
/**
* Platform-specific support for the data transfer subsystem.
*
* @author Roger Brinkley
* @author Danila Sinopalnikov
*
* @since 1.3.1
*/
public class MDataTransferer extends DataTransferer {
private static final long FILE_NAME_ATOM;
private static final long DT_NET_FILE_ATOM;
private static final long PNG_ATOM;
private static final long JFIF_ATOM;
static {
FILE_NAME_ATOM = getAtomForTarget("FILE_NAME");
DT_NET_FILE_ATOM = getAtomForTarget("_DT_NETFILE");
PNG_ATOM = getAtomForTarget("PNG");
JFIF_ATOM = getAtomForTarget("JFIF");
}
/**
* Singleton constructor
*/
private MDataTransferer() {
}
private static MDataTransferer transferer;
static MDataTransferer getInstanceImpl() {
if (transferer == null) {
synchronized (MDataTransferer.class) {
if (transferer == null) {
transferer = new MDataTransferer();
}
}
}
return transferer;
}
public String getDefaultUnicodeEncoding() {
return "iso-10646-ucs-2";
}
public boolean isLocaleDependentTextFormat(long format) {
return false;
}
public boolean isTextFormat(long format) {
return super.isTextFormat(format)
|| isMimeFormat(format, "text");
}
protected String getCharsetForTextFormat(Long lFormat) {
long format = lFormat.longValue();
if (isMimeFormat(format, "text")) {
String nat = getNativeForFormat(format);
DataFlavor df = new DataFlavor(nat, null);
// Ignore the charset parameter of the MIME type if the subtype
// doesn't support charset.
if (!DataTransferer.doesSubtypeSupportCharset(df)) {
return null;
}
String charset = df.getParameter("charset");
if (charset != null) {
return charset;
}
}
return super.getCharsetForTextFormat(lFormat);
}
public boolean isFileFormat(long format) {
return format == FILE_NAME_ATOM || format == DT_NET_FILE_ATOM;
}
public boolean isImageFormat(long format) {
return format == PNG_ATOM || format == JFIF_ATOM
|| isMimeFormat(format, "image");
}
protected Long getFormatForNativeAsLong(String str) {
// Just get the atom. If it has already been retrived
// once, we'll get a copy so this should be very fast.
long atom = getAtomForTarget(str);
if (atom <= 0) {
throw new InternalError("Cannot register a target");
}
return Long.valueOf(atom);
}
protected String getNativeForFormat(long format) {
return getTargetNameForAtom(format);
}
public ToolkitThreadBlockedHandler getToolkitThreadBlockedHandler() {
return MToolkitThreadBlockedHandler.getToolkitThreadBlockedHandler();
}
/**
* Gets an atom for a format name.
*/
static native long getAtomForTarget(String name);
/**
* Gets an format name for a given format (atom)
*/
private static native String getTargetNameForAtom(long atom);
protected byte[] imageToPlatformBytes(Image image, long format)
throws IOException {
String mimeType = null;
if (format == PNG_ATOM) {
mimeType = "image/png";
} else if (format == JFIF_ATOM) {
mimeType = "image/jpeg";
} else {
// Check if an image MIME format.
try {
String nat = getNativeForFormat(format);
DataFlavor df = new DataFlavor(nat);
String primaryType = df.getPrimaryType();
if ("image".equals(primaryType)) {
mimeType = df.getPrimaryType() + "/" + df.getSubType();
}
} catch (Exception e) {
// Not an image MIME format.
}
}
if (mimeType != null) {
return imageToStandardBytes(image, mimeType);
} else {
String nativeFormat = getNativeForFormat(format);
throw new IOException("Translation to " + nativeFormat +
" is not supported.");
}
}
/**
* Translates either a byte array or an input stream which contain
* platform-specific image data in the given format into an Image.
*/
protected Image platformImageBytesOrStreamToImage(InputStream inputStream,
byte[] bytes,
long format)
throws IOException {
String mimeType = null;
if (format == PNG_ATOM) {
mimeType = "image/png";
} else if (format == JFIF_ATOM) {
mimeType = "image/jpeg";
} else {
// Check if an image MIME format.
try {
String nat = getNativeForFormat(format);
DataFlavor df = new DataFlavor(nat);
String primaryType = df.getPrimaryType();
if ("image".equals(primaryType)) {
mimeType = df.getPrimaryType() + "/" + df.getSubType();
}
} catch (Exception e) {
// Not an image MIME format.
}
}
if (mimeType != null) {
return standardImageBytesOrStreamToImage(inputStream, bytes, mimeType);
} else {
String nativeFormat = getNativeForFormat(format);
throw new IOException("Translation from " + nativeFormat +
" is not supported.");
}
}
/**
* Returns true if and only if the name of the specified format Atom
* constitutes a valid MIME type with the specified primary type.
*/
private boolean isMimeFormat(long format, String primaryType) {
String nat = getNativeForFormat(format);
if (nat == null) {
return false;
}
try {
DataFlavor df = new DataFlavor(nat);
if (primaryType.equals(df.getPrimaryType())) {
return true;
}
} catch (Exception e) {
// Not a MIME format.
}
return false;
}
/*
* The XDnD protocol prescribes that the Atoms used as targets for data
* transfer should have string names that represent the corresponding MIME
* types.
* To meet this requirement we check if the passed native format constitutes
* a valid MIME and return a list of flavors to which the data in this MIME
* type can be translated by the Data Transfer subsystem.
*/
public List getPlatformMappingsForNative(String nat) {
List flavors = new ArrayList();
if (nat == null) {
return flavors;
}
DataFlavor df = null;
try {
df = new DataFlavor(nat);
} catch (Exception e) {
// The string doesn't constitute a valid MIME type.
return flavors;
}
Object value = df;
final String primaryType = df.getPrimaryType();
final String baseType = primaryType + "/" + df.getSubType();
// For text formats we map natives to MIME strings instead of data
// flavors to enable dynamic text native-to-flavor mapping generation.
// See SystemFlavorMap.getFlavorsForNative() for details.
if ("text".equals(primaryType)) {
value = primaryType + "/" + df.getSubType();
} else if ("image".equals(primaryType)) {
Iterator readers = ImageIO.getImageReadersByMIMEType(baseType);
if (readers.hasNext()) {
flavors.add(DataFlavor.imageFlavor);
}
}
flavors.add(value);
return flavors;
}
private static ImageTypeSpecifier defaultSpecifier = null;
private ImageTypeSpecifier getDefaultImageTypeSpecifier() {
if (defaultSpecifier == null) {
ColorModel model = ColorModel.getRGBdefault();
WritableRaster raster =
model.createCompatibleWritableRaster(10, 10);
BufferedImage bufferedImage =
new BufferedImage(model, raster, model.isAlphaPremultiplied(),
null);
defaultSpecifier = new ImageTypeSpecifier(bufferedImage);
}
return defaultSpecifier;
}
/*
* The XDnD protocol prescribes that the Atoms used as targets for data
* transfer should have string names that represent the corresponding MIME
* types.
* To meet this requirement we return a list of formats that represent
* MIME types to which the data in this flavor can be translated by the Data
* Transfer subsystem.
*/
public List getPlatformMappingsForFlavor(DataFlavor df) {
List natives = new ArrayList(1);
if (df == null) {
return natives;
}
String charset = df.getParameter("charset");
String baseType = df.getPrimaryType() + "/" + df.getSubType();
String mimeType = baseType;
if (charset != null && DataTransferer.isFlavorCharsetTextType(df)) {
mimeType += ";charset=" + charset;
}
// Add a mapping to the MIME native whenever the representation class
// doesn't require translation.
if (df.getRepresentationClass() != null &&
(df.isRepresentationClassInputStream() ||
df.isRepresentationClassByteBuffer() ||
byteArrayClass.equals(df.getRepresentationClass()))) {
natives.add(mimeType);
}
if (DataFlavor.imageFlavor.equals(df)) {
String[] mimeTypes = ImageIO.getWriterMIMETypes();
if (mimeTypes != null) {
for (int i = 0; i < mimeTypes.length; i++) {
Iterator writers =
ImageIO.getImageWritersByMIMEType(mimeTypes[i]);
while (writers.hasNext()) {
ImageWriter imageWriter = (ImageWriter)writers.next();
ImageWriterSpi writerSpi =
imageWriter.getOriginatingProvider();
if (writerSpi != null &&
writerSpi.canEncodeImage(getDefaultImageTypeSpecifier())) {
natives.add(mimeTypes[i]);
break;
}
}
}
}
} else if (DataTransferer.isFlavorCharsetTextType(df)) {
final Iterator iter = DataTransferer.standardEncodings();
// stringFlavor is semantically equivalent to the standard
// "text/plain" MIME type.
if (DataFlavor.stringFlavor.equals(df)) {
baseType = "text/plain";
}
while (iter.hasNext()) {
String encoding = (String)iter.next();
if (!encoding.equals(charset)) {
natives.add(baseType + ";charset=" + encoding);
}
}
// Add a MIME format without specified charset.
if (!natives.contains(baseType)) {
natives.add(baseType);
}
}
return natives;
}
protected native String[] dragQueryFile(byte[] bytes);
}
/*
* Copyright 1995-2007 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.awt.motif;
import java.util.Vector;
import java.awt.*;
import java.awt.peer.*;
import java.awt.event.*;
import sun.awt.motif.MInputMethodControl;
import sun.awt.im.*;
class MDialogPeer extends MWindowPeer implements DialogPeer, MInputMethodControl {
static Vector allDialogs = new Vector();
MDialogPeer(Dialog target) {
/* create MWindowPeer object */
super();
winAttr.nativeDecor = !target.isUndecorated();
winAttr.initialFocus = true;
winAttr.isResizable = target.isResizable();
winAttr.initialState = MWindowAttributes.NORMAL;
winAttr.title = target.getTitle();
winAttr.icon = null;
if (winAttr.nativeDecor) {
winAttr.decorations = winAttr.AWT_DECOR_ALL |
winAttr.AWT_DECOR_MINIMIZE |
winAttr.AWT_DECOR_MAXIMIZE;
} else {
winAttr.decorations = winAttr.AWT_DECOR_NONE;
}
/* create and init native component */
init(target);
allDialogs.addElement(this);
}
public void setTitle(String title) {
pSetTitle(title);
}
protected void disposeImpl() {
allDialogs.removeElement(this);
super.disposeImpl();
}
// NOTE: This method is called by privileged threads.
// DO NOT INVOKE CLIENT CODE ON THIS THREAD!
public void handleMoved(int x, int y) {
postEvent(new ComponentEvent(target, ComponentEvent.COMPONENT_MOVED));
}
public void show() {
pShowModal( ((Dialog)target).isModal() );
updateAlwaysOnTop(alwaysOnTop);
}
// NOTE: This method may be called by privileged threads.
// DO NOT INVOKE CLIENT CODE ON THIS THREAD!
public void handleIconify() {
// Note: These routines are necessary for Coaleseing of native implementations
// As Dialogs do not currently send Iconify/DeIconify messages but
// Windows/Frames do. If this should be made consistent...to do so
// uncomment the postEvent.
// postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_ICONIFIED));
}
// NOTE: This method may be called by privileged threads.
// DO NOT INVOKE CLIENT CODE ON THIS THREAD!
public void handleDeiconify() {
// Note: These routines are necessary for Coaleseing of native implementations
// As Dialogs do not currently send Iconify/DeIconify messages but
// Windows/Frames do. If this should be made consistent...to do so
// uncomment the postEvent.
// postEvent(new WindowEvent((Window)target, WindowEvent.WINDOW_DEICONIFIED));
}
public void blockWindows(java.util.List<Window> toBlock) {
// do nothing
}
@Override
final boolean isTargetUndecorated() {
return ((Dialog)target).isUndecorated();
}
}
/*
* Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.awt.motif;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Image;
import java.awt.Point;
import java.awt.datatransfer.Transferable;
import java.awt.dnd.DragSourceContext;
import java.awt.dnd.DragGestureEvent;
import java.awt.dnd.InvalidDnDOperationException;
import java.awt.event.InputEvent;
import java.awt.peer.ComponentPeer;
import java.awt.peer.LightweightPeer;
import java.util.Map;
import sun.awt.SunToolkit;
import sun.awt.dnd.SunDragSourceContextPeer;
/**
* <p>
* TBC
* </p>
*
* @since JDK1.2
*
*/
final class MDragSourceContextPeer extends SunDragSourceContextPeer {
private static final MDragSourceContextPeer theInstance =
new MDragSourceContextPeer(null);
/**
* construct a new MDragSourceContextPeer
*/
private MDragSourceContextPeer(DragGestureEvent dge) {
super(dge);
}
static MDragSourceContextPeer createDragSourceContextPeer(DragGestureEvent dge) throws InvalidDnDOperationException {
theInstance.setTrigger(dge);
return theInstance;
}
protected void startDrag(Transferable transferable,
long[] formats, Map formatMap) {
try {
long nativeCtxtLocal = startDrag(getTrigger().getComponent(),
transferable,
getTrigger().getTriggerEvent(),
getCursor(),
getCursor() == null ? 0 : getCursor().getType(),
getDragSourceContext().getSourceActions(),
formats,
formatMap);
setNativeContext(nativeCtxtLocal);
} catch (Exception e) {
throw new InvalidDnDOperationException("failed to create native peer: " + e);
}
if (getNativeContext() == 0) {
throw new InvalidDnDOperationException("failed to create native peer");
}
MDropTargetContextPeer.setCurrentJVMLocalSourceTransferable(transferable);
}
/**
* downcall into native code
*/
private native long startDrag(Component component,
Transferable transferable,
InputEvent nativeTrigger,
Cursor c, int ctype, int actions,
long[] formats, Map formatMap);
/**
* set cursor
*/
public void setCursor(Cursor c) throws InvalidDnDOperationException {
SunToolkit.awtLock();
super.setCursor(c);
SunToolkit.awtUnlock();
}
protected native void setNativeCursor(long nativeCtxt, Cursor c, int cType);
}
/*
* Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.awt.motif;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.awt.dnd.DnDConstants;
import java.awt.dnd.InvalidDnDOperationException;
import java.io.InputStream;
import java.util.Map;
import java.io.IOException;
import sun.awt.dnd.SunDropTargetContextPeer;
import sun.awt.SunToolkit;
/**
* <p>
* The MDropTargetContextPeer class is the class responsible for handling
* the interaction between the Motif DnD system and Java.
* </p>
*
* @since JDK1.2
*
*/
final class MDropTargetContextPeer extends SunDropTargetContextPeer {
private long nativeDropTransfer;
long nativeDataAvailable = 0;
Object nativeData = null;
/**
* create the peer
*/
static MDropTargetContextPeer createMDropTargetContextPeer() {
return new MDropTargetContextPeer();
}
/**
* create the peer
*/
private MDropTargetContextPeer() {
super();
}
protected Object getNativeData(long format) {
SunToolkit.awtLock();
if (nativeDropTransfer == 0) {
nativeDropTransfer = startTransfer(getNativeDragContext(),
format);
} else {
addTransfer (nativeDropTransfer, format);
}
for (nativeDataAvailable = 0;
format != nativeDataAvailable;) {
try {
SunToolkit.awtLockWait();
} catch (Throwable e) {
e.printStackTrace();
}
}
SunToolkit.awtUnlock();
return nativeData;
}
/**
* signal drop complete
*/
protected void doDropDone(boolean success, int dropAction,
boolean isLocal) {
dropDone(getNativeDragContext(), nativeDropTransfer, isLocal,
success, dropAction);
}
/**
* notify transfer complete
*/
private void newData(long format, String type, byte[] data) {
nativeDataAvailable = format;
nativeData = data;
SunToolkit.awtLockNotifyAll();
}
/**
* notify transfer failed
*/
private void transferFailed(long format) {
nativeDataAvailable = format;
nativeData = null;
SunToolkit.awtLockNotifyAll();
}
/**
* schedule a native DnD transfer
*/
private native long startTransfer(long nativeDragContext, long format);
/**
* schedule a native DnD data transfer
*/
private native void addTransfer(long nativeDropTransfer, long format);
/**
* signal that drop is completed
*/
private native void dropDone(long nativeDragContext, long nativeDropTransfer,
boolean localTx, boolean success, int dropAction);
}
/*
* Copyright 1996-2004 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.awt.motif;
import java.awt.Component;
import java.awt.peer.FramePeer;
import sun.awt.EmbeddedFrame;
import java.awt.peer.ComponentPeer;
import sun.awt.*;
import java.awt.*;
public class MEmbeddedFrame extends EmbeddedFrame {
/**
* Widget id of the shell widget
*/
long handle;
public enum IDKind {
WIDGET,
WINDOW
};
public MEmbeddedFrame() {
}
/**
* Backward-compatible implementation. This constructor takes widget which represents Frame's
* shell and uses it as top-level to build hierarchy of top-level widgets upon. It assumes that
* no XEmbed support is provided.
* @param widget a valid Xt widget pointer.
*/
public MEmbeddedFrame(long widget) {
this(widget, IDKind.WIDGET, false);
}
/**
* New constructor, gets X Window id and allows to specify whether XEmbed is supported by parent
* X window. Creates hierarchy of top-level widgets under supplied window ID.
* @param winid a valid X window
* @param supportsXEmbed whether the host application supports XEMBED protocol
*/
public MEmbeddedFrame(long winid, boolean supportsXEmbed) {
this(winid, IDKind.WINDOW, supportsXEmbed);
}
/**
* Creates embedded frame using ID as parent.
* @param ID parent ID
* @param supportsXEmbed whether the host application supports XEMBED protocol
* @param kind if WIDGET, ID represents a valid Xt widget pointer; if WINDOW, ID is a valid X Window
* ID
*/
public MEmbeddedFrame(long ID, IDKind kind, boolean supportsXEmbed) {
super(supportsXEmbed);
if (kind == IDKind.WIDGET) {
this.handle = ID;
} else {
this.handle = getWidget(ID);
}
MToolkit toolkit = (MToolkit)Toolkit.getDefaultToolkit();
setPeer(toolkit.createEmbeddedFrame(this));
/*
* addNotify() creates a LightweightDispatcher that propagates
* SunDropTargetEvents to subcomponents.
* NOTE: show() doesn't call addNotify() for embedded frames.
*/
addNotify();
show();
}
public void synthesizeWindowActivation(boolean b) {
MEmbeddedFramePeer peer = (MEmbeddedFramePeer)getPeer();
if (peer != null) {
if (peer.supportsXEmbed()) {
if (peer.isXEmbedActive()) {
// If XEmbed is active no synthetic focus events are allowed - everything
// should go through XEmbed
if (b) {
peer.requestXEmbedFocus();
}
}
} else {
peer.synthesizeFocusInOut(b);
}
}
}
public void show() {
if (handle != 0) {
mapWidget(handle);
}
super.show();
}
protected boolean traverseOut(boolean direction) {
MEmbeddedFramePeer xefp = (MEmbeddedFramePeer) getPeer();
xefp.traverseOut(direction);
return true;
}
// Native methods to handle widget <-> X Windows mapping
//
static native long getWidget(long winid);
static native int mapWidget(long widget);
public void registerAccelerator(AWTKeyStroke stroke) {
MEmbeddedFramePeer xefp = (MEmbeddedFramePeer) getPeer();
if (xefp != null) {
xefp.registerAccelerator(stroke);
}
}
public void unregisterAccelerator(AWTKeyStroke stroke) {
MEmbeddedFramePeer xefp = (MEmbeddedFramePeer) getPeer();
if (xefp != null) {
xefp.unregisterAccelerator(stroke);
}
}
}
/*
* Copyright 1996-2005 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Sun designates this
* particular file as subject to the "Classpath" exception as provided
* by Sun in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
* CA 95054 USA or visit www.sun.com if you need additional information or
* have any questions.
*/
package sun.awt.motif;
import sun.awt.EmbeddedFrame;
import java.util.logging.*;
import java.awt.Component;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Window;
import java.awt.AWTKeyStroke;
import java.awt.Component;
import java.awt.Container;
import sun.awt.SunToolkit;
import java.util.LinkedList;
import java.util.Iterator;
import sun.java2d.SurfaceData;
public class MEmbeddedFramePeer extends MFramePeer {
private static final Logger xembedLog = Logger.getLogger("sun.awt.motif.xembed.MEmbeddedFramePeer");
// A detail code is required for XEMBED_FOCUS_IN. The following values are valid:
/* Details for XEMBED_FOCUS_IN: */
final static int XEMBED_FOCUS_CURRENT = 0;
final static int XEMBED_FOCUS_FIRST = 1;
final static int XEMBED_FOCUS_LAST = 2;
LinkedList<AWTKeyStroke> strokes = new LinkedList<AWTKeyStroke>();
public MEmbeddedFramePeer(EmbeddedFrame target) {
super(target);
xembedLog.fine("Creating XEmbed-enabled motif embedded frame, frame supports XEmbed:" + supportsXEmbed());
}
void create(MComponentPeer parent) {
NEFcreate(parent, ((MEmbeddedFrame)target).handle);
}
native void NEFcreate(MComponentPeer parent, long handle);
native void pShowImpl();
void pShow() {
pShowImpl();
}
boolean supportsXEmbed() {
EmbeddedFrame frame = (EmbeddedFrame)target;
if (frame != null) {
return frame.supportsXEmbed();
} else {
return false;
}
}
public void setVisible(boolean vis) {
super.setVisible(vis);
xembedLog.fine("Peer made visible");
if (vis && !supportsXEmbed()) {
xembedLog.fine("Synthesizing FocusIn");
// Fix for 4878303 - generate WINDOW_GAINED_FOCUS and update if we were focused
// since noone will do it for us(WM does it for regular top-levels)
synthesizeFocusInOut(true);
}
}
public native void synthesizeFocusInOut(boolean b);
native boolean isXEmbedActive();
native boolean isXEmbedApplicationActive();
native void requestXEmbedFocus();
public boolean requestWindowFocus() {
xembedLog.fine("In requestWindowFocus");
// Should check for active state of host application
if (isXEmbedActive()) {
if (isXEmbedApplicationActive()) {
xembedLog.fine("Requesting focus from embedding host");
requestXEmbedFocus();
return true;
} else {
xembedLog.fine("Host application is not active");
return false;
}
} else {
xembedLog.fine("Requesting focus from X");
return super.requestWindowFocus();
}
}
void registerAccelerator(AWTKeyStroke stroke) {
// if (stroke == null) return;
// strokes.add(stroke);
// if (isXEmbedActive()) {
// nativeRegisterAccelerator(stroke, strokes.size()-1);
// }
}
void unregisterAccelerator(AWTKeyStroke stroke) {
// if (stroke == null) return;
// if (isXEmbedActive()) {
// int index = strokes.indexOf(stroke);
// nativeUnregisterAccelerator(index);
// }
}
void notifyStarted() {
// Register accelerators
// int i = 0;
// Iterator<AWTKeyStroke> iter = strokes.iterator();
// while (iter.hasNext()) {
// nativeRegisterAccelerator(iter.next(), i++);
// }
updateDropTarget();
}
native void traverseOut(boolean direction);
void handleFocusIn(int detail) {
xembedLog.log(Level.FINE, "handleFocusIn {0}", new Object[]{Integer.valueOf(detail)});
switch(detail) {
case XEMBED_FOCUS_CURRENT:
// Do nothing - just restore to the current value
break;
case XEMBED_FOCUS_FIRST:
SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
public void run() {
Component comp = ((Container)target).getFocusTraversalPolicy().getFirstComponent((Container)target);
if (comp != null) {
comp.requestFocusInWindow();
}
}});
break;
case XEMBED_FOCUS_LAST:
SunToolkit.executeOnEventHandlerThread(target, new Runnable() {
public void run() {
Component comp = ((Container)target).getFocusTraversalPolicy().getLastComponent((Container)target);
if (comp != null) {
comp.requestFocusInWindow();
}
}});
break;
}
}
public void handleWindowFocusIn() {
super.handleWindowFocusIn();
xembedLog.fine("windowFocusIn");
}
public void handleWindowFocusOut(Window oppositeWindow) {
super.handleWindowFocusOut(oppositeWindow);
xembedLog.fine("windowFocusOut, opposite is null?:" + (oppositeWindow==null));
}
native void pReshapePrivate(int x, int y, int w, int h);
public void setBoundsPrivate(int x, int y, int width, int height)
{
if (disposed)
{
return;
}
// Should set paintPending before reshape to prevent
// thread race between PaintEvent and setBounds
// This part of the 4267393 fix proved to be unstable under solaris,
// dissabled due to regressions 4418155, 4486762, 4490079
paintPending = false; //checkNativePaintOnSetBounds(width, height);
pReshapePrivate(x, y, width, height);
if ((width != oldWidth) || (height != oldHeight))
{
SurfaceData oldData = surfaceData;
if (oldData != null) {
surfaceData = graphicsConfig.createSurfaceData(this);
oldData.invalidate();
}
oldWidth = width;
oldHeight = height;
}
validateSurface(width, height);
serialNum++;
}
public native Rectangle getBoundsPrivate();
@Override
Rectangle constrainBounds(int x, int y, int width, int height) {
// We don't constrain the bounds of the EmbeddedFrames
return new Rectangle(x, y, width, height);
}
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -29,7 +29,7 @@
#include "awt_p.h"
#include "java_awt_Component.h"
#include "sun_awt_motif_MComponentPeer.h"
//#include "sun_awt_motif_MComponentPeer.h"
#include "awt_Component.h"
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册