AquaInternalFrameUI.java revision 4725
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle 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 Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/**
* From AquaInternalFrameUI
*
* InternalFrame implementation for Aqua LAF
*
* We want to inherit most of the inner classes, but not the base class,
* so be very careful about subclassing so you know you get what you want
*
*/
// Instance variables
protected Color fSelectedTextColor;
protected Color fNotSelectedTextColor;
// for button tracking
boolean fMouseOverPressedButton;
int fWhichButtonPressed = -1;
boolean fRollover = false;
boolean fDocumentEdited = false; // to indicate whether we should use the dirty document red dot.
boolean fIsPallet;
public int getWhichButtonPressed() {
return fWhichButtonPressed;
}
public boolean getMouseOverPressedButton() {
return fMouseOverPressedButton;
}
public boolean getRollover() {
return fRollover;
}
// ComponentUI Interface Implementation methods
return new AquaInternalFrameUI((JInternalFrame)b);
}
public AquaInternalFrameUI(final JInternalFrame b) {
super(b);
}
/// Inherit (but be careful to check everything they call):
public void installUI(final JComponent c) {
// super.installUI(c); // Swing 1.1.1 has a bug in installUI - it doesn't check for null northPane
frame = (JInternalFrame)c;
if (paletteProp != null) {
} else {
if (paletteProp != null) {
} else {
}
}
// We only have a southPane, for grow box room, created in setFrameType
c.setBorder(new CompoundUIBorder(fIsPallet ? paletteWindowShadow.get() : documentWindowShadow.get(), c.getBorder()));
}
protected void installDefaults() {
super.installDefaults();
}
public void setSouthPane(final JComponent c) {
}
if (c != null) {
}
southPane = c;
}
protected Icon getInstance() {
}
};
public static Icon exportCloseIcon() {
}
protected Icon getInstance() {
}
};
public static Icon exportMinimizeIcon() {
return minimizeIcon.get();
}
protected Icon getInstance() {
}
};
public static Icon exportZoomIcon() {
}
}
super.paintIcon(c, g, x, y);
}
}
public int getIconWidth() {
return 19;
}
public int getIconHeight() {
return 19;
}
}
protected void installKeyboardActions() {
} //$ Not Mac-ish - should we support?
protected void installComponents() {
}
}
/// Inherit all the listeners - that's the main reason we subclass Basic!
protected void installListeners() {
fPropertyListener = new PropertyListener();
super.installListeners();
}
// uninstallDefaults
// uninstallComponents
protected void uninstallListeners() {
super.uninstallListeners();
}
protected void uninstallKeyboardActions() {
}
// Called when a DesktopIcon replaces an InternalFrame & vice versa
//protected void replacePane(JComponent currentPane, JComponent newPane) {}
protected void installMouseHandlers(final JComponent c) {
}
protected void deinstallMouseHandlers(final JComponent c) {
}
// add action for the system menu
// Set the ActionMap's parent to the Auditory Feedback Action Map
return map;
}
}
}
return preferredSize;
}
public void setNorthPane(final JComponent c) {
replacePane(northPane, c);
northPane = c;
}
/**
* Installs necessary mouse handlers on <code>newPane</code>
* and adds it to the frame.
* Reverse process for the <code>currentPane</code>.
*/
if (currentPane != null) {
}
}
}
// Our "Border" listener is shared by the AquaDesktopIcon
return new AquaBorderListener();
}
/**
* Mac-specific stuff begins here
*/
// Basic sets the background of the contentPane to null so it can inherit JInternalFrame.setBackground
// but if *that's* null, we get the JDesktop, which makes ours look invisible!
// So JInternalFrame has to have a background color
// See Sun bugs 4268949 & 4320889
boolean isPalette = false;
isPalette = true;
} else {
}
// We don't get the borders from UIManager, in case someone changes them - this class will not work with
// different borders. If they want different ones, they have to make their own InternalFrameUI class
}
public void setPalette(final boolean isPalette) {
}
public boolean isDocumentEdited() {
return fDocumentEdited;
}
public void setDocumentEdited(final boolean flag) {
}
/*
// helpful debug drawing, shows component and content bounds
public void paint(final Graphics g, final JComponent c) {
super.paint(g, c);
g.setColor(Color.green);
g.drawRect(0, 0, frame.getWidth() - 1, frame.getHeight() - 1);
final Insets insets = frame.getInsets();
g.setColor(Color.orange);
g.drawRect(insets.left - 2, insets.top - 2, frame.getWidth() - insets.left - insets.right + 4, frame.getHeight() - insets.top - insets.bottom + 4);
}
*/
// Border Listener Class
/**
* Listens for border adjustments.
*/
protected class AquaBorderListener extends MouseInputAdapter {
// _x & _y are the mousePressed location in absolute coordinate system
// __x & __y are the mousePressed location in source view's coordinate system
boolean fDraggingFrame;
int resizeDir;
protected final int RESIZE_NONE = 0;
private boolean discardRelease = false;
public void mouseClicked(final MouseEvent e) {
if (didForwardEvent(e)) return;
try {
} catch(final PropertyVetoException e2) {}
} else if (frame.isMaximizable()) {
frame.setMaximum(true);
} catch(final PropertyVetoException e2) {}
else try {
frame.setMaximum(false);
} catch(final PropertyVetoException e3) {}
}
}
public void updateRollover(final MouseEvent e) {
final boolean oldRollover = fRollover;
fRollover = (isTitleBarDraggableArea(e) && fAquaBorder.getWithinRolloverArea(i, e.getX(), e.getY()));
if (fRollover != oldRollover) {
}
}
public void repaintButtons() {
}
public void mouseReleased(final MouseEvent e) {
if (didForwardEvent(e)) return;
fDraggingFrame = false;
if (fWhichButtonPressed != -1) {
final int buttonPresed = fWhichButtonPressed;
fWhichButtonPressed = -1;
fMouseOverPressedButton = false;
if (buttonPresed == newButton) {
fMouseOverPressedButton = false;
fRollover = false; // not sure if this is needed?
}
updateRollover(e);
return;
}
if (discardRelease) {
discardRelease = false;
return;
}
else {
if (c instanceof JFrame) {
((JFrame)frame.getTopLevelAncestor()).getGlassPane().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
} else if (c instanceof JApplet) {
} else if (c instanceof JWindow) {
} else if (c instanceof JDialog) {
}
}
_x = 0;
_y = 0;
__x = 0;
__y = 0;
}
public void mousePressed(final MouseEvent e) {
if (didForwardEvent(e)) return;
_x = p.x;
_y = p.y;
if (updatePressed(e)) { return; }
if (!frame.isSelected()) {
try {
frame.setSelected(true);
} catch(final PropertyVetoException e1) {}
}
if (isTitleBarDraggableArea(e)) {
fDraggingFrame = true;
return;
}
if (e.getSource() == getNorthPane()) {
return;
}
if (!frame.isResizable()) { return; }
discardRelease = true;
return;
}
}
// returns true if we have handled the pressed
public boolean updatePressed(final MouseEvent e) {
// get the component.
fMouseOverPressedButton = true;
return (fWhichButtonPressed >= 0);
// e.getX(), e.getY()
}
public int getButtonHit(final MouseEvent e) {
}
public boolean isTitleBarDraggableArea(final MouseEvent e) {
return true;
}
public void mouseDragged(final MouseEvent e) {
// do not forward drags
// if (didForwardEvent(e)) return;
if (startingBounds == null) {
// (STEVE) Yucky work around for bug ID 4106552
return;
}
if (fWhichButtonPressed != -1) {
// track the button we started on.
final int newButton = getButtonHit(e);
return;
}
// Handle a MOVE
if (frame.isMaximum() || ((e.getModifiers() & InputEvent.BUTTON1_MASK) != InputEvent.BUTTON1_MASK)) {
// don't allow moving of frames if maximixed or left mouse
// button was not used.
return;
}
// Make sure we stay in-bounds
return;
}
public void mouseMoved(final MouseEvent e) {
if (didForwardEvent(e)) return;
updateRollover(e);
}
// guards against accidental infinite recursion
boolean isTryingToForwardEvent = false;
boolean didForwardEvent(final MouseEvent e) {
if (isTryingToForwardEvent) return true; // we didn't actually...but we wound up back where we started.
isTryingToForwardEvent = true;
final boolean didForwardEvent = didForwardEventInternal(e);
isTryingToForwardEvent = false;
return didForwardEvent;
}
boolean didForwardEventInternal(final MouseEvent e) {
if (fDraggingFrame) return false;
if (!isEventInWindowShadow(originalPoint)) return false;
if (!(parent instanceof JDesktopPane)) return false;
/* // debug drawing
Graphics g = parent.getGraphics();
g.setColor(Color.red);
g.drawLine(parentPoint.x, parentPoint.y, parentPoint.x, parentPoint.y);
*/
hitComponent.dispatchEvent(new MouseEvent(hitComponent, e.getID(), e.getWhen(), e.getModifiers(), hitComponentPoint.x, hitComponentPoint.y, e.getClickCount(), e.isPopupTrigger(), e.getButton()));
return true;
}
boolean foundSelf = false;
for (final JInternalFrame f : allFrames) {
if (!foundSelf) continue;
}
return pane;
}
return false;
}
}
}
} else if (c instanceof Container) {
}
}
}
}
class PropertyListener implements PropertyChangeListener {
public void propertyChange(final PropertyChangeEvent e) {
if (e.getNewValue() instanceof String) {
}
if (e.getNewValue() != null) {
} else {
setPalette(false);
}
// TODO: CPlatformWindow?
} else if ("windowModified".equals(name) || CPlatformWindow.WINDOW_DOCUMENT_MODIFIED.equals(name)) {
// repaint title bar
} else if ("resizable".equals(name) || "state".equals(name) || "iconable".equals(name) || "maximizable".equals(name) || "closable".equals(name)) {
frame.revalidate();
}
frame.revalidate();
}
}
} // end class PaletteListener
}
}, new Painter() {
}
},
0, 7, 1.1f, 1.0f, 24, 51, 51, 25, 25, 25, 25);
}
}
}, new Painter() {
}
},
0, 0, 3.0f, 1.0f, 10, 51, 51, 25, 25, 25, 25);
}
};
}
}, null,
0, 3, 1.0f, 1.0f, 10, 25, 25, 12, 12, 12, 12);
}
return getForegroundShadowBorder();
}
};
}
abstract Border getForegroundShadowBorder();
abstract Border getBackgroundShadowBorder();
protected Border getInstance() {
return new Border() {
return fgShadow.getBorderInsets(c);
}
public boolean isBorderOpaque() {
return false;
}
public void paintBorder(final Component c, final Graphics g, final int x, final int y, final int w, final int h) {
if (((JInternalFrame)c).isSelected()) {
fgShadow.paintBorder(c, g, x, y, w, h);
} else {
bgShadow.paintBorder(c, g, x, y, w, h);
}
}
};
}
}
protected Icon getInstance() {
}
};
}
};
class ResizeBox extends JLabel implements MouseListener, MouseMotionListener, MouseWheelListener, ComponentListener, PropertyChangeListener, UIResource {
final JLayeredPane layeredPane;
super(RESIZE_ICON.get());
this.layeredPane = layeredPane;
addMouseListener(this);
addMouseMotionListener(this);
addMouseWheelListener(this);
}
void addListeners() {
}
void removeListeners() {
}
void repositionResizeBox() {
}
if (!(parent instanceof JDesktopPane)) return;
}
}
}
}
}
boolean testGrowboxPoint(final int x, final int y, final int w, final int h) {
return (w - x) + (h - y) < 12;
}
void forwardEventToFrame(final MouseEvent e) {
if (c == null) return;
c.dispatchEvent(new MouseEvent(c, e.getID(), e.getWhen(), e.getModifiers(), pt.x, pt.y, e.getClickCount(), e.isPopupTrigger(), e.getButton()));
}
return c;
}
public void mouseClicked(final MouseEvent e) {
}
public void mouseEntered(final MouseEvent e) { }
public void mouseExited(final MouseEvent e) { }
public void mousePressed(final MouseEvent e) {
if (frame.isResizable() && !frame.isMaximum() && testGrowboxPoint(e.getX(), e.getY(), getWidth(), getHeight())) {
return;
}
}
public void mouseReleased(final MouseEvent e) {
if (originalLocation != null) {
resizeInternalFrame(e.getPoint());
return;
}
}
public void mouseDragged(final MouseEvent e) {
resizeInternalFrame(e.getPoint());
}
public void mouseMoved(final MouseEvent e) { }
public void mouseWheelMoved(final MouseWheelEvent e) {
if (c == null) return;
c.dispatchEvent(new MouseWheelEvent(c, e.getID(), e.getWhen(), e.getModifiers(), pt.x, pt.y, e.getClickCount(), e.isPopupTrigger(), e.getScrollType(), e.getScrollAmount(), e.getWheelRotation()));
}
public void componentResized(final ComponentEvent e) {
}
public void componentShown(final ComponentEvent e) {
}
public void componentMoved(final ComponentEvent e) {
}
public void componentHidden(final ComponentEvent e) { }
}
}
}