feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
@@ -0,0 +1,431 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2014, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.security.AccessController;
|
||||
import sun.security.action.GetBooleanAction;
|
||||
|
||||
import java.util.*;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import javax.swing.*;
|
||||
|
||||
|
||||
|
||||
import sun.swing.UIClientPropertyKey;
|
||||
import com.sun.java.swing.plaf.windows.TMSchema.State;
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.State.*;
|
||||
import com.sun.java.swing.plaf.windows.TMSchema.Part;
|
||||
import com.sun.java.swing.plaf.windows.TMSchema.Prop;
|
||||
import com.sun.java.swing.plaf.windows.XPStyle.Skin;
|
||||
|
||||
import sun.awt.AppContext;
|
||||
|
||||
/**
|
||||
* A class to help mimic Vista theme animations. The only kind of
|
||||
* animation it handles for now is 'transition' animation (this seems
|
||||
* to be the only animation which Vista theme can do). This is when
|
||||
* one picture fadein over another one in some period of time.
|
||||
* According to
|
||||
* https://connect.microsoft.com/feedback/ViewFeedback.aspx?FeedbackID=86852&SiteID=4
|
||||
* The animations are all linear.
|
||||
*
|
||||
* This class has a number of responsibilities.
|
||||
* <ul>
|
||||
* <li> It trigger rapaint for the UI components involved in the animation
|
||||
* <li> It tracks the animation state for every UI component involved in the
|
||||
* animation and paints {@code Skin} in new {@code State} over the
|
||||
* {@code Skin} in last {@code State} using
|
||||
* {@code AlphaComposite.SrcOver.derive(alpha)} where {code alpha}
|
||||
* depends on the state of animation
|
||||
* </ul>
|
||||
*
|
||||
* @author Igor Kushnirskiy
|
||||
*/
|
||||
class AnimationController implements ActionListener, PropertyChangeListener {
|
||||
|
||||
private final static boolean VISTA_ANIMATION_DISABLED =
|
||||
AccessController.doPrivileged(new GetBooleanAction("swing.disablevistaanimation"));
|
||||
|
||||
|
||||
private final static Object ANIMATION_CONTROLLER_KEY =
|
||||
new StringBuilder("ANIMATION_CONTROLLER_KEY");
|
||||
|
||||
private final Map<JComponent, Map<Part, AnimationState>> animationStateMap =
|
||||
new WeakHashMap<JComponent, Map<Part, AnimationState>>();
|
||||
|
||||
//this timer is used to cause repaint on animated components
|
||||
//30 repaints per second should give smooth animation affect
|
||||
private final javax.swing.Timer timer =
|
||||
new javax.swing.Timer(1000/30, this);
|
||||
|
||||
private static synchronized AnimationController getAnimationController() {
|
||||
AppContext appContext = AppContext.getAppContext();
|
||||
Object obj = appContext.get(ANIMATION_CONTROLLER_KEY);
|
||||
if (obj == null) {
|
||||
obj = new AnimationController();
|
||||
appContext.put(ANIMATION_CONTROLLER_KEY, obj);
|
||||
}
|
||||
return (AnimationController) obj;
|
||||
}
|
||||
|
||||
private AnimationController() {
|
||||
timer.setRepeats(true);
|
||||
timer.setCoalesce(true);
|
||||
//we need to dispose the controller on l&f change
|
||||
UIManager.addPropertyChangeListener(this);
|
||||
}
|
||||
|
||||
private static void triggerAnimation(JComponent c,
|
||||
Part part, State newState) {
|
||||
if (c instanceof javax.swing.JTabbedPane
|
||||
|| part == Part.TP_BUTTON) {
|
||||
//idk: we can not handle tabs animation because
|
||||
//the same (component,part) is used to handle all the tabs
|
||||
//and we can not track the states
|
||||
//Vista theme might have transition duration for toolbar buttons
|
||||
//but native application does not seem to animate them
|
||||
return;
|
||||
}
|
||||
AnimationController controller =
|
||||
AnimationController.getAnimationController();
|
||||
State oldState = controller.getState(c, part);
|
||||
if (oldState != newState) {
|
||||
controller.putState(c, part, newState);
|
||||
if (newState == State.DEFAULTED) {
|
||||
// it seems for DEFAULTED button state Vista does animation from
|
||||
// HOT
|
||||
oldState = State.HOT;
|
||||
}
|
||||
if (oldState != null) {
|
||||
long duration;
|
||||
if (newState == State.DEFAULTED) {
|
||||
//Only button might have DEFAULTED state
|
||||
//idk: do not know how to get the value from Vista
|
||||
//one second seems plausible value
|
||||
duration = 1000;
|
||||
} else {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
duration = (xp != null)
|
||||
? xp.getThemeTransitionDuration(
|
||||
c, part,
|
||||
normalizeState(oldState),
|
||||
normalizeState(newState),
|
||||
Prop.TRANSITIONDURATIONS)
|
||||
: 1000;
|
||||
}
|
||||
controller.startAnimation(c, part, oldState, newState, duration);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// for scrollbar up, down, left and right button pictures are
|
||||
// defined by states. It seems that theme has duration defined
|
||||
// only for up button states thus we doing this translation here.
|
||||
private static State normalizeState(State state) {
|
||||
State rv;
|
||||
switch (state) {
|
||||
case DOWNPRESSED:
|
||||
/* falls through */
|
||||
case LEFTPRESSED:
|
||||
/* falls through */
|
||||
case RIGHTPRESSED:
|
||||
rv = UPPRESSED;
|
||||
break;
|
||||
|
||||
case DOWNDISABLED:
|
||||
/* falls through */
|
||||
case LEFTDISABLED:
|
||||
/* falls through */
|
||||
case RIGHTDISABLED:
|
||||
rv = UPDISABLED;
|
||||
break;
|
||||
|
||||
case DOWNHOT:
|
||||
/* falls through */
|
||||
case LEFTHOT:
|
||||
/* falls through */
|
||||
case RIGHTHOT:
|
||||
rv = UPHOT;
|
||||
break;
|
||||
|
||||
case DOWNNORMAL:
|
||||
/* falls through */
|
||||
case LEFTNORMAL:
|
||||
/* falls through */
|
||||
case RIGHTNORMAL:
|
||||
rv = UPNORMAL;
|
||||
break;
|
||||
|
||||
default :
|
||||
rv = state;
|
||||
break;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
private synchronized State getState(JComponent component, Part part) {
|
||||
State rv = null;
|
||||
Object tmpObject =
|
||||
component.getClientProperty(PartUIClientPropertyKey.getKey(part));
|
||||
if (tmpObject instanceof State) {
|
||||
rv = (State) tmpObject;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
private synchronized void putState(JComponent component, Part part,
|
||||
State state) {
|
||||
component.putClientProperty(PartUIClientPropertyKey.getKey(part),
|
||||
state);
|
||||
}
|
||||
|
||||
private synchronized void startAnimation(JComponent component,
|
||||
Part part,
|
||||
State startState,
|
||||
State endState,
|
||||
long millis) {
|
||||
boolean isForwardAndReverse = false;
|
||||
if (endState == State.DEFAULTED) {
|
||||
isForwardAndReverse = true;
|
||||
}
|
||||
Map<Part, AnimationState> map = animationStateMap.get(component);
|
||||
if (millis <= 0) {
|
||||
if (map != null) {
|
||||
map.remove(part);
|
||||
if (map.size() == 0) {
|
||||
animationStateMap.remove(component);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (map == null) {
|
||||
map = new EnumMap<Part, AnimationState>(Part.class);
|
||||
animationStateMap.put(component, map);
|
||||
}
|
||||
map.put(part,
|
||||
new AnimationState(startState, millis, isForwardAndReverse));
|
||||
if (! timer.isRunning()) {
|
||||
timer.start();
|
||||
}
|
||||
}
|
||||
|
||||
static void paintSkin(JComponent component, Skin skin,
|
||||
Graphics g, int dx, int dy, int dw, int dh, State state) {
|
||||
if (VISTA_ANIMATION_DISABLED) {
|
||||
skin.paintSkinRaw(g, dx, dy, dw, dh, state);
|
||||
return;
|
||||
}
|
||||
triggerAnimation(component, skin.part, state);
|
||||
AnimationController controller = getAnimationController();
|
||||
synchronized (controller) {
|
||||
AnimationState animationState = null;
|
||||
Map<Part, AnimationState> map =
|
||||
controller.animationStateMap.get(component);
|
||||
if (map != null) {
|
||||
animationState = map.get(skin.part);
|
||||
}
|
||||
if (animationState != null) {
|
||||
animationState.paintSkin(skin, g, dx, dy, dw, dh, state);
|
||||
} else {
|
||||
skin.paintSkinRaw(g, dx, dy, dw, dh, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void propertyChange(PropertyChangeEvent e) {
|
||||
if ("lookAndFeel" == e.getPropertyName()
|
||||
&& ! (e.getNewValue() instanceof WindowsLookAndFeel) ) {
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void actionPerformed(ActionEvent e) {
|
||||
java.util.List<JComponent> componentsToRemove = null;
|
||||
java.util.List<Part> partsToRemove = null;
|
||||
for (JComponent component : animationStateMap.keySet()) {
|
||||
component.repaint();
|
||||
if (partsToRemove != null) {
|
||||
partsToRemove.clear();
|
||||
}
|
||||
Map<Part, AnimationState> map = animationStateMap.get(component);
|
||||
if (! component.isShowing()
|
||||
|| map == null
|
||||
|| map.size() == 0) {
|
||||
if (componentsToRemove == null) {
|
||||
componentsToRemove = new ArrayList<JComponent>();
|
||||
}
|
||||
componentsToRemove.add(component);
|
||||
continue;
|
||||
}
|
||||
for (Part part : map.keySet()) {
|
||||
if (map.get(part).isDone()) {
|
||||
if (partsToRemove == null) {
|
||||
partsToRemove = new ArrayList<Part>();
|
||||
}
|
||||
partsToRemove.add(part);
|
||||
}
|
||||
}
|
||||
if (partsToRemove != null) {
|
||||
if (partsToRemove.size() == map.size()) {
|
||||
//animation is done for the component
|
||||
if (componentsToRemove == null) {
|
||||
componentsToRemove = new ArrayList<JComponent>();
|
||||
}
|
||||
componentsToRemove.add(component);
|
||||
} else {
|
||||
for (Part part : partsToRemove) {
|
||||
map.remove(part);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (componentsToRemove != null) {
|
||||
for (JComponent component : componentsToRemove) {
|
||||
animationStateMap.remove(component);
|
||||
}
|
||||
}
|
||||
if (animationStateMap.size() == 0) {
|
||||
timer.stop();
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void dispose() {
|
||||
timer.stop();
|
||||
UIManager.removePropertyChangeListener(this);
|
||||
synchronized (AnimationController.class) {
|
||||
AppContext.getAppContext()
|
||||
.put(ANIMATION_CONTROLLER_KEY, null);
|
||||
}
|
||||
}
|
||||
|
||||
private static class AnimationState {
|
||||
private final State startState;
|
||||
|
||||
//animation duration in nanoseconds
|
||||
private final long duration;
|
||||
|
||||
//animatin start time in nanoseconds
|
||||
private long startTime;
|
||||
|
||||
//direction the alpha value is changing
|
||||
//forward - from 0 to 1
|
||||
//!forward - from 1 to 0
|
||||
private boolean isForward = true;
|
||||
|
||||
//if isForwardAndReverse the animation continually goes
|
||||
//forward and reverse. alpha value is changing from 0 to 1 then
|
||||
//from 1 to 0 and so forth
|
||||
private boolean isForwardAndReverse;
|
||||
|
||||
private float progress;
|
||||
|
||||
AnimationState(final State startState,
|
||||
final long milliseconds,
|
||||
boolean isForwardAndReverse) {
|
||||
assert startState != null && milliseconds > 0;
|
||||
assert SwingUtilities.isEventDispatchThread();
|
||||
|
||||
this.startState = startState;
|
||||
this.duration = milliseconds * 1000000;
|
||||
this.startTime = System.nanoTime();
|
||||
this.isForwardAndReverse = isForwardAndReverse;
|
||||
progress = 0f;
|
||||
}
|
||||
private void updateProgress() {
|
||||
assert SwingUtilities.isEventDispatchThread();
|
||||
|
||||
if (isDone()) {
|
||||
return;
|
||||
}
|
||||
long currentTime = System.nanoTime();
|
||||
|
||||
progress = ((float) (currentTime - startTime))
|
||||
/ duration;
|
||||
progress = Math.max(progress, 0); //in case time was reset
|
||||
if (progress >= 1) {
|
||||
progress = 1;
|
||||
if (isForwardAndReverse) {
|
||||
startTime = currentTime;
|
||||
progress = 0;
|
||||
isForward = ! isForward;
|
||||
}
|
||||
}
|
||||
}
|
||||
void paintSkin(Skin skin, Graphics _g,
|
||||
int dx, int dy, int dw, int dh, State state) {
|
||||
assert SwingUtilities.isEventDispatchThread();
|
||||
|
||||
updateProgress();
|
||||
if (! isDone()) {
|
||||
Graphics2D g = (Graphics2D) _g.create();
|
||||
skin.paintSkinRaw(g, dx, dy, dw, dh, startState);
|
||||
float alpha;
|
||||
if (isForward) {
|
||||
alpha = progress;
|
||||
} else {
|
||||
alpha = 1 - progress;
|
||||
}
|
||||
g.setComposite(AlphaComposite.SrcOver.derive(alpha));
|
||||
skin.paintSkinRaw(g, dx, dy, dw, dh, state);
|
||||
g.dispose();
|
||||
} else {
|
||||
skin.paintSkinRaw(_g, dx, dy, dw, dh, state);
|
||||
}
|
||||
}
|
||||
boolean isDone() {
|
||||
assert SwingUtilities.isEventDispatchThread();
|
||||
|
||||
return progress >= 1;
|
||||
}
|
||||
}
|
||||
|
||||
private static class PartUIClientPropertyKey
|
||||
implements UIClientPropertyKey {
|
||||
|
||||
private static final Map<Part, PartUIClientPropertyKey> map =
|
||||
new EnumMap<Part, PartUIClientPropertyKey>(Part.class);
|
||||
|
||||
static synchronized PartUIClientPropertyKey getKey(Part part) {
|
||||
PartUIClientPropertyKey rv = map.get(part);
|
||||
if (rv == null) {
|
||||
rv = new PartUIClientPropertyKey(part);
|
||||
map.put(part, rv);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
private final Part part;
|
||||
private PartUIClientPropertyKey(Part part) {
|
||||
this.part = part;
|
||||
}
|
||||
public String toString() {
|
||||
return part.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
285
jdkSrc/jdk8/com/sun/java/swing/plaf/windows/DesktopProperty.java
Normal file
285
jdkSrc/jdk8/com/sun/java/swing/plaf/windows/DesktopProperty.java
Normal file
@@ -0,0 +1,285 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2009, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.beans.*;
|
||||
import java.lang.ref.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.*;
|
||||
|
||||
/**
|
||||
* Wrapper for a value from the desktop. The value is lazily looked up, and
|
||||
* can be accessed using the <code>UIManager.ActiveValue</code> method
|
||||
* <code>createValue</code>. If the underlying desktop property changes this
|
||||
* will force the UIs to update all known Frames. You can invoke
|
||||
* <code>invalidate</code> to force the value to be fetched again.
|
||||
*
|
||||
*/
|
||||
// NOTE: Don't rely on this class staying in this location. It is likely
|
||||
// to move to a different package in the future.
|
||||
public class DesktopProperty implements UIDefaults.ActiveValue {
|
||||
/**
|
||||
* Indicates if an updateUI call is pending.
|
||||
*/
|
||||
private static boolean updatePending;
|
||||
|
||||
/**
|
||||
* ReferenceQueue of unreferenced WeakPCLs.
|
||||
*/
|
||||
private static final ReferenceQueue<DesktopProperty> queue = new ReferenceQueue<DesktopProperty>();
|
||||
|
||||
/**
|
||||
* PropertyChangeListener attached to the Toolkit.
|
||||
*/
|
||||
private WeakPCL pcl;
|
||||
/**
|
||||
* Key used to lookup value from desktop.
|
||||
*/
|
||||
private final String key;
|
||||
/**
|
||||
* Value to return.
|
||||
*/
|
||||
private Object value;
|
||||
/**
|
||||
* Fallback value in case we get null from desktop.
|
||||
*/
|
||||
private final Object fallback;
|
||||
|
||||
|
||||
/**
|
||||
* Cleans up any lingering state held by unrefeernced
|
||||
* DesktopProperties.
|
||||
*/
|
||||
static void flushUnreferencedProperties() {
|
||||
WeakPCL pcl;
|
||||
|
||||
while ((pcl = (WeakPCL)queue.poll()) != null) {
|
||||
pcl.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets whether or not an updateUI call is pending.
|
||||
*/
|
||||
private static synchronized void setUpdatePending(boolean update) {
|
||||
updatePending = update;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a UI update is pending.
|
||||
*/
|
||||
private static synchronized boolean isUpdatePending() {
|
||||
return updatePending;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the UIs of all the known Frames.
|
||||
*/
|
||||
private static void updateAllUIs() {
|
||||
// Check if the current UI is WindowsLookAndfeel and flush the XP style map.
|
||||
// Note: Change the package test if this class is moved to a different package.
|
||||
Class uiClass = UIManager.getLookAndFeel().getClass();
|
||||
if (uiClass.getPackage().equals(DesktopProperty.class.getPackage())) {
|
||||
XPStyle.invalidateStyle();
|
||||
}
|
||||
Frame appFrames[] = Frame.getFrames();
|
||||
for (Frame appFrame : appFrames) {
|
||||
updateWindowUI(appFrame);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the UI of the passed in window and all its children.
|
||||
*/
|
||||
private static void updateWindowUI(Window window) {
|
||||
SwingUtilities.updateComponentTreeUI(window);
|
||||
Window ownedWins[] = window.getOwnedWindows();
|
||||
for (Window ownedWin : ownedWins) {
|
||||
updateWindowUI(ownedWin);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates a DesktopProperty.
|
||||
*
|
||||
* @param key Key used in looking up desktop value.
|
||||
* @param fallback Value used if desktop property is null.
|
||||
*/
|
||||
public DesktopProperty(String key, Object fallback) {
|
||||
this.key = key;
|
||||
this.fallback = fallback;
|
||||
// The only sure fire way to clear our references is to create a
|
||||
// Thread and wait for a reference to be added to the queue.
|
||||
// Because it is so rare that you will actually change the look
|
||||
// and feel, this stepped is forgoed and a middle ground of
|
||||
// flushing references from the constructor is instead done.
|
||||
// The implication is that once one DesktopProperty is created
|
||||
// there will most likely be n (number of DesktopProperties created
|
||||
// by the LookAndFeel) WeakPCLs around, but this number will not
|
||||
// grow past n.
|
||||
flushUnreferencedProperties();
|
||||
}
|
||||
|
||||
/**
|
||||
* UIManager.LazyValue method, returns the value from the desktop
|
||||
* or the fallback value if the desktop value is null.
|
||||
*/
|
||||
public Object createValue(UIDefaults table) {
|
||||
if (value == null) {
|
||||
value = configureValue(getValueFromDesktop());
|
||||
if (value == null) {
|
||||
value = configureValue(getDefaultValue());
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value from the desktop.
|
||||
*/
|
||||
protected Object getValueFromDesktop() {
|
||||
Toolkit toolkit = Toolkit.getDefaultToolkit();
|
||||
|
||||
if (pcl == null) {
|
||||
pcl = new WeakPCL(this, getKey(), UIManager.getLookAndFeel());
|
||||
toolkit.addPropertyChangeListener(getKey(), pcl);
|
||||
}
|
||||
|
||||
return toolkit.getDesktopProperty(getKey());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value to use if the desktop property is null.
|
||||
*/
|
||||
protected Object getDefaultValue() {
|
||||
return fallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidates the current value.
|
||||
*
|
||||
* @param laf the LookAndFeel this DesktopProperty was created with
|
||||
*/
|
||||
public void invalidate(LookAndFeel laf) {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalides the current value so that the next invocation of
|
||||
* <code>createValue</code> will ask for the property again.
|
||||
*/
|
||||
public void invalidate() {
|
||||
value = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Requests that all components in the GUI hierarchy be updated
|
||||
* to reflect dynamic changes in this look&feel. This update occurs
|
||||
* by uninstalling and re-installing the UI objects. Requests are
|
||||
* batched and collapsed into a single update pass because often
|
||||
* many desktop properties will change at once.
|
||||
*/
|
||||
protected void updateUI() {
|
||||
if (!isUpdatePending()) {
|
||||
setUpdatePending(true);
|
||||
Runnable uiUpdater = new Runnable() {
|
||||
public void run() {
|
||||
updateAllUIs();
|
||||
setUpdatePending(false);
|
||||
}
|
||||
};
|
||||
SwingUtilities.invokeLater(uiUpdater);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the value as appropriate for a defaults property in
|
||||
* the UIDefaults table.
|
||||
*/
|
||||
protected Object configureValue(Object value) {
|
||||
if (value != null) {
|
||||
if (value instanceof Color) {
|
||||
return new ColorUIResource((Color)value);
|
||||
}
|
||||
else if (value instanceof Font) {
|
||||
return new FontUIResource((Font)value);
|
||||
}
|
||||
else if (value instanceof UIDefaults.LazyValue) {
|
||||
value = ((UIDefaults.LazyValue)value).createValue(null);
|
||||
}
|
||||
else if (value instanceof UIDefaults.ActiveValue) {
|
||||
value = ((UIDefaults.ActiveValue)value).createValue(null);
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key used to lookup the desktop properties value.
|
||||
*/
|
||||
protected String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* As there is typically only one Toolkit, the PropertyChangeListener
|
||||
* is handled via a WeakReference so as not to pin down the
|
||||
* DesktopProperty.
|
||||
*/
|
||||
private static class WeakPCL extends WeakReference<DesktopProperty>
|
||||
implements PropertyChangeListener {
|
||||
private String key;
|
||||
private LookAndFeel laf;
|
||||
|
||||
WeakPCL(DesktopProperty target, String key, LookAndFeel laf) {
|
||||
super(target, queue);
|
||||
this.key = key;
|
||||
this.laf = laf;
|
||||
}
|
||||
|
||||
public void propertyChange(PropertyChangeEvent pce) {
|
||||
DesktopProperty property = get();
|
||||
|
||||
if (property == null || laf != UIManager.getLookAndFeel()) {
|
||||
// The property was GC'ed, we're no longer interested in
|
||||
// PropertyChanges, remove the listener.
|
||||
dispose();
|
||||
}
|
||||
else {
|
||||
property.invalidate(laf);
|
||||
property.updateUI();
|
||||
}
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
Toolkit.getDefaultToolkit().removePropertyChangeListener(key, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
565
jdkSrc/jdk8/com/sun/java/swing/plaf/windows/TMSchema.java
Normal file
565
jdkSrc/jdk8/com/sun/java/swing/plaf/windows/TMSchema.java
Normal file
@@ -0,0 +1,565 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* <p>These classes are designed to be used while the
|
||||
* corresponding <code>LookAndFeel</code> class has been installed
|
||||
* (<code>UIManager.setLookAndFeel(new <i>XXX</i>LookAndFeel())</code>).
|
||||
* Using them while a different <code>LookAndFeel</code> is installed
|
||||
* may produce unexpected results, including exceptions.
|
||||
* Additionally, changing the <code>LookAndFeel</code>
|
||||
* maintained by the <code>UIManager</code> without updating the
|
||||
* corresponding <code>ComponentUI</code> of any
|
||||
* <code>JComponent</code>s may also produce unexpected results,
|
||||
* such as the wrong colors showing up, and is generally not
|
||||
* encouraged.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
import sun.awt.windows.ThemeReader;
|
||||
|
||||
/**
|
||||
* Implements Windows Parts and their States and Properties for the Windows Look and Feel.
|
||||
*
|
||||
* See http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/userex/topics/partsandstates.asp
|
||||
* See tmschema.h (or vssym32.h & vsstyle.h for MS Vista)
|
||||
*
|
||||
* @author Leif Samuelsson
|
||||
*/
|
||||
class TMSchema {
|
||||
|
||||
/**
|
||||
* An enumeration of the various Windows controls (also known as
|
||||
* components, or top-level parts)
|
||||
*/
|
||||
public static enum Control {
|
||||
BUTTON,
|
||||
COMBOBOX,
|
||||
EDIT,
|
||||
HEADER,
|
||||
LISTBOX,
|
||||
LISTVIEW,
|
||||
MENU,
|
||||
PROGRESS,
|
||||
REBAR,
|
||||
SCROLLBAR,
|
||||
SPIN,
|
||||
TAB,
|
||||
TOOLBAR,
|
||||
TRACKBAR,
|
||||
TREEVIEW,
|
||||
WINDOW
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* An enumeration of the Windows compoent parts
|
||||
*/
|
||||
public static enum Part {
|
||||
MENU (Control.MENU, 0), // Special case, not in native
|
||||
MP_BARBACKGROUND (Control.MENU, 7),
|
||||
MP_BARITEM (Control.MENU, 8),
|
||||
MP_POPUPBACKGROUND (Control.MENU, 9),
|
||||
MP_POPUPBORDERS (Control.MENU, 10),
|
||||
MP_POPUPCHECK (Control.MENU, 11),
|
||||
MP_POPUPCHECKBACKGROUND (Control.MENU, 12),
|
||||
MP_POPUPGUTTER (Control.MENU, 13),
|
||||
MP_POPUPITEM (Control.MENU, 14),
|
||||
MP_POPUPSEPARATOR (Control.MENU, 15),
|
||||
MP_POPUPSUBMENU (Control.MENU, 16),
|
||||
|
||||
BP_PUSHBUTTON (Control.BUTTON, 1),
|
||||
BP_RADIOBUTTON(Control.BUTTON, 2),
|
||||
BP_CHECKBOX (Control.BUTTON, 3),
|
||||
BP_GROUPBOX (Control.BUTTON, 4),
|
||||
|
||||
CP_COMBOBOX (Control.COMBOBOX, 0),
|
||||
CP_DROPDOWNBUTTON(Control.COMBOBOX, 1),
|
||||
CP_BACKGROUND (Control.COMBOBOX, 2),
|
||||
CP_TRANSPARENTBACKGROUND (Control.COMBOBOX, 3),
|
||||
CP_BORDER (Control.COMBOBOX, 4),
|
||||
CP_READONLY (Control.COMBOBOX, 5),
|
||||
CP_DROPDOWNBUTTONRIGHT (Control.COMBOBOX, 6),
|
||||
CP_DROPDOWNBUTTONLEFT (Control.COMBOBOX, 7),
|
||||
CP_CUEBANNER (Control.COMBOBOX, 8),
|
||||
|
||||
|
||||
EP_EDIT (Control.EDIT, 0),
|
||||
EP_EDITTEXT(Control.EDIT, 1),
|
||||
|
||||
HP_HEADERITEM(Control.HEADER, 1),
|
||||
HP_HEADERSORTARROW(Control.HEADER, 4),
|
||||
|
||||
LBP_LISTBOX(Control.LISTBOX, 0),
|
||||
|
||||
LVP_LISTVIEW(Control.LISTVIEW, 0),
|
||||
|
||||
PP_PROGRESS (Control.PROGRESS, 0),
|
||||
PP_BAR (Control.PROGRESS, 1),
|
||||
PP_BARVERT (Control.PROGRESS, 2),
|
||||
PP_CHUNK (Control.PROGRESS, 3),
|
||||
PP_CHUNKVERT(Control.PROGRESS, 4),
|
||||
|
||||
RP_GRIPPER (Control.REBAR, 1),
|
||||
RP_GRIPPERVERT(Control.REBAR, 2),
|
||||
|
||||
SBP_SCROLLBAR (Control.SCROLLBAR, 0),
|
||||
SBP_ARROWBTN (Control.SCROLLBAR, 1),
|
||||
SBP_THUMBBTNHORZ (Control.SCROLLBAR, 2),
|
||||
SBP_THUMBBTNVERT (Control.SCROLLBAR, 3),
|
||||
SBP_LOWERTRACKHORZ(Control.SCROLLBAR, 4),
|
||||
SBP_UPPERTRACKHORZ(Control.SCROLLBAR, 5),
|
||||
SBP_LOWERTRACKVERT(Control.SCROLLBAR, 6),
|
||||
SBP_UPPERTRACKVERT(Control.SCROLLBAR, 7),
|
||||
SBP_GRIPPERHORZ (Control.SCROLLBAR, 8),
|
||||
SBP_GRIPPERVERT (Control.SCROLLBAR, 9),
|
||||
SBP_SIZEBOX (Control.SCROLLBAR, 10),
|
||||
|
||||
SPNP_UP (Control.SPIN, 1),
|
||||
SPNP_DOWN(Control.SPIN, 2),
|
||||
|
||||
TABP_TABITEM (Control.TAB, 1),
|
||||
TABP_TABITEMLEFTEDGE (Control.TAB, 2),
|
||||
TABP_TABITEMRIGHTEDGE(Control.TAB, 3),
|
||||
TABP_PANE (Control.TAB, 9),
|
||||
|
||||
TP_TOOLBAR (Control.TOOLBAR, 0),
|
||||
TP_BUTTON (Control.TOOLBAR, 1),
|
||||
TP_SEPARATOR (Control.TOOLBAR, 5),
|
||||
TP_SEPARATORVERT (Control.TOOLBAR, 6),
|
||||
|
||||
TKP_TRACK (Control.TRACKBAR, 1),
|
||||
TKP_TRACKVERT (Control.TRACKBAR, 2),
|
||||
TKP_THUMB (Control.TRACKBAR, 3),
|
||||
TKP_THUMBBOTTOM(Control.TRACKBAR, 4),
|
||||
TKP_THUMBTOP (Control.TRACKBAR, 5),
|
||||
TKP_THUMBVERT (Control.TRACKBAR, 6),
|
||||
TKP_THUMBLEFT (Control.TRACKBAR, 7),
|
||||
TKP_THUMBRIGHT (Control.TRACKBAR, 8),
|
||||
TKP_TICS (Control.TRACKBAR, 9),
|
||||
TKP_TICSVERT (Control.TRACKBAR, 10),
|
||||
|
||||
TVP_TREEVIEW(Control.TREEVIEW, 0),
|
||||
TVP_GLYPH (Control.TREEVIEW, 2),
|
||||
|
||||
WP_WINDOW (Control.WINDOW, 0),
|
||||
WP_CAPTION (Control.WINDOW, 1),
|
||||
WP_MINCAPTION (Control.WINDOW, 3),
|
||||
WP_MAXCAPTION (Control.WINDOW, 5),
|
||||
WP_FRAMELEFT (Control.WINDOW, 7),
|
||||
WP_FRAMERIGHT (Control.WINDOW, 8),
|
||||
WP_FRAMEBOTTOM (Control.WINDOW, 9),
|
||||
WP_SYSBUTTON (Control.WINDOW, 13),
|
||||
WP_MDISYSBUTTON (Control.WINDOW, 14),
|
||||
WP_MINBUTTON (Control.WINDOW, 15),
|
||||
WP_MDIMINBUTTON (Control.WINDOW, 16),
|
||||
WP_MAXBUTTON (Control.WINDOW, 17),
|
||||
WP_CLOSEBUTTON (Control.WINDOW, 18),
|
||||
WP_MDICLOSEBUTTON (Control.WINDOW, 20),
|
||||
WP_RESTOREBUTTON (Control.WINDOW, 21),
|
||||
WP_MDIRESTOREBUTTON(Control.WINDOW, 22);
|
||||
|
||||
private final Control control;
|
||||
private final int value;
|
||||
|
||||
private Part(Control control, int value) {
|
||||
this.control = control;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String getControlName(Component component) {
|
||||
String str = "";
|
||||
if (component instanceof JComponent) {
|
||||
JComponent c = (JComponent)component;
|
||||
String subAppName = (String)c.getClientProperty("XPStyle.subAppName");
|
||||
if (subAppName != null) {
|
||||
str = subAppName + "::";
|
||||
}
|
||||
}
|
||||
return str + control.toString();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return control.toString()+"."+name();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* An enumeration of the possible component states
|
||||
*/
|
||||
public static enum State {
|
||||
ACTIVE,
|
||||
ASSIST,
|
||||
BITMAP,
|
||||
CHECKED,
|
||||
CHECKEDDISABLED,
|
||||
CHECKEDHOT,
|
||||
CHECKEDNORMAL,
|
||||
CHECKEDPRESSED,
|
||||
CHECKMARKNORMAL,
|
||||
CHECKMARKDISABLED,
|
||||
BULLETNORMAL,
|
||||
BULLETDISABLED,
|
||||
CLOSED,
|
||||
DEFAULTED,
|
||||
DISABLED,
|
||||
DISABLEDHOT,
|
||||
DISABLEDPUSHED,
|
||||
DOWNDISABLED,
|
||||
DOWNHOT,
|
||||
DOWNNORMAL,
|
||||
DOWNPRESSED,
|
||||
FOCUSED,
|
||||
HOT,
|
||||
HOTCHECKED,
|
||||
ICONHOT,
|
||||
ICONNORMAL,
|
||||
ICONPRESSED,
|
||||
ICONSORTEDHOT,
|
||||
ICONSORTEDNORMAL,
|
||||
ICONSORTEDPRESSED,
|
||||
INACTIVE,
|
||||
INACTIVENORMAL, // See note 1
|
||||
INACTIVEHOT, // See note 1
|
||||
INACTIVEPUSHED, // See note 1
|
||||
INACTIVEDISABLED, // See note 1
|
||||
LEFTDISABLED,
|
||||
LEFTHOT,
|
||||
LEFTNORMAL,
|
||||
LEFTPRESSED,
|
||||
MIXEDDISABLED,
|
||||
MIXEDHOT,
|
||||
MIXEDNORMAL,
|
||||
MIXEDPRESSED,
|
||||
NORMAL,
|
||||
PRESSED,
|
||||
OPENED,
|
||||
PUSHED,
|
||||
READONLY,
|
||||
RIGHTDISABLED,
|
||||
RIGHTHOT,
|
||||
RIGHTNORMAL,
|
||||
RIGHTPRESSED,
|
||||
SELECTED,
|
||||
UNCHECKEDDISABLED,
|
||||
UNCHECKEDHOT,
|
||||
UNCHECKEDNORMAL,
|
||||
UNCHECKEDPRESSED,
|
||||
UPDISABLED,
|
||||
UPHOT,
|
||||
UPNORMAL,
|
||||
UPPRESSED,
|
||||
HOVER,
|
||||
UPHOVER,
|
||||
DOWNHOVER,
|
||||
LEFTHOVER,
|
||||
RIGHTHOVER,
|
||||
SORTEDDOWN,
|
||||
SORTEDHOT,
|
||||
SORTEDNORMAL,
|
||||
SORTEDPRESSED,
|
||||
SORTEDUP;
|
||||
|
||||
|
||||
/**
|
||||
* A map of allowed states for each Part
|
||||
*/
|
||||
private static EnumMap<Part, State[]> stateMap;
|
||||
|
||||
private static synchronized void initStates() {
|
||||
stateMap = new EnumMap<Part, State[]>(Part.class);
|
||||
|
||||
stateMap.put(Part.EP_EDITTEXT,
|
||||
new State[] {
|
||||
NORMAL, HOT, SELECTED, DISABLED, FOCUSED, READONLY, ASSIST
|
||||
});
|
||||
|
||||
stateMap.put(Part.BP_PUSHBUTTON,
|
||||
new State[] { NORMAL, HOT, PRESSED, DISABLED, DEFAULTED });
|
||||
|
||||
stateMap.put(Part.BP_RADIOBUTTON,
|
||||
new State[] {
|
||||
UNCHECKEDNORMAL, UNCHECKEDHOT, UNCHECKEDPRESSED, UNCHECKEDDISABLED,
|
||||
CHECKEDNORMAL, CHECKEDHOT, CHECKEDPRESSED, CHECKEDDISABLED
|
||||
});
|
||||
|
||||
stateMap.put(Part.BP_CHECKBOX,
|
||||
new State[] {
|
||||
UNCHECKEDNORMAL, UNCHECKEDHOT, UNCHECKEDPRESSED, UNCHECKEDDISABLED,
|
||||
CHECKEDNORMAL, CHECKEDHOT, CHECKEDPRESSED, CHECKEDDISABLED,
|
||||
MIXEDNORMAL, MIXEDHOT, MIXEDPRESSED, MIXEDDISABLED
|
||||
});
|
||||
|
||||
State[] comboBoxStates = new State[] { NORMAL, HOT, PRESSED, DISABLED };
|
||||
stateMap.put(Part.CP_COMBOBOX, comboBoxStates);
|
||||
stateMap.put(Part.CP_DROPDOWNBUTTON, comboBoxStates);
|
||||
stateMap.put(Part.CP_BACKGROUND, comboBoxStates);
|
||||
stateMap.put(Part.CP_TRANSPARENTBACKGROUND, comboBoxStates);
|
||||
stateMap.put(Part.CP_BORDER, comboBoxStates);
|
||||
stateMap.put(Part.CP_READONLY, comboBoxStates);
|
||||
stateMap.put(Part.CP_DROPDOWNBUTTONRIGHT, comboBoxStates);
|
||||
stateMap.put(Part.CP_DROPDOWNBUTTONLEFT, comboBoxStates);
|
||||
stateMap.put(Part.CP_CUEBANNER, comboBoxStates);
|
||||
|
||||
stateMap.put(Part.HP_HEADERITEM, new State[] { NORMAL, HOT, PRESSED,
|
||||
SORTEDNORMAL, SORTEDHOT, SORTEDPRESSED,
|
||||
ICONNORMAL, ICONHOT, ICONPRESSED,
|
||||
ICONSORTEDNORMAL, ICONSORTEDHOT, ICONSORTEDPRESSED });
|
||||
|
||||
stateMap.put(Part.HP_HEADERSORTARROW,
|
||||
new State[] {SORTEDDOWN, SORTEDUP});
|
||||
|
||||
State[] scrollBarStates = new State[] { NORMAL, HOT, PRESSED, DISABLED, HOVER };
|
||||
stateMap.put(Part.SBP_SCROLLBAR, scrollBarStates);
|
||||
stateMap.put(Part.SBP_THUMBBTNVERT, scrollBarStates);
|
||||
stateMap.put(Part.SBP_THUMBBTNHORZ, scrollBarStates);
|
||||
stateMap.put(Part.SBP_GRIPPERVERT, scrollBarStates);
|
||||
stateMap.put(Part.SBP_GRIPPERHORZ, scrollBarStates);
|
||||
|
||||
stateMap.put(Part.SBP_ARROWBTN,
|
||||
new State[] {
|
||||
UPNORMAL, UPHOT, UPPRESSED, UPDISABLED,
|
||||
DOWNNORMAL, DOWNHOT, DOWNPRESSED, DOWNDISABLED,
|
||||
LEFTNORMAL, LEFTHOT, LEFTPRESSED, LEFTDISABLED,
|
||||
RIGHTNORMAL, RIGHTHOT, RIGHTPRESSED, RIGHTDISABLED,
|
||||
UPHOVER, DOWNHOVER, LEFTHOVER, RIGHTHOVER
|
||||
});
|
||||
|
||||
|
||||
State[] spinnerStates = new State[] { NORMAL, HOT, PRESSED, DISABLED };
|
||||
stateMap.put(Part.SPNP_UP, spinnerStates);
|
||||
stateMap.put(Part.SPNP_DOWN, spinnerStates);
|
||||
|
||||
stateMap.put(Part.TVP_GLYPH, new State[] { CLOSED, OPENED });
|
||||
|
||||
State[] frameButtonStates = new State[] {
|
||||
NORMAL, HOT, PUSHED, DISABLED, // See note 1
|
||||
INACTIVENORMAL, INACTIVEHOT, INACTIVEPUSHED, INACTIVEDISABLED,
|
||||
};
|
||||
// Note 1: The INACTIVE frame button states apply when the frame
|
||||
// is inactive. They are not defined in tmschema.h
|
||||
|
||||
// Fix for 6316538: Vista has five frame button states
|
||||
if (ThemeReader.getInt(Control.WINDOW.toString(),
|
||||
Part.WP_CLOSEBUTTON.getValue(), 1,
|
||||
Prop.IMAGECOUNT.getValue()) == 10) {
|
||||
frameButtonStates = new State[] {
|
||||
NORMAL, HOT, PUSHED, DISABLED, null,
|
||||
INACTIVENORMAL, INACTIVEHOT, INACTIVEPUSHED, INACTIVEDISABLED, null
|
||||
};
|
||||
}
|
||||
|
||||
stateMap.put(Part.WP_MINBUTTON, frameButtonStates);
|
||||
stateMap.put(Part.WP_MAXBUTTON, frameButtonStates);
|
||||
stateMap.put(Part.WP_RESTOREBUTTON, frameButtonStates);
|
||||
stateMap.put(Part.WP_CLOSEBUTTON, frameButtonStates);
|
||||
|
||||
// States for Slider (trackbar)
|
||||
stateMap.put(Part.TKP_TRACK, new State[] { NORMAL });
|
||||
stateMap.put(Part.TKP_TRACKVERT, new State[] { NORMAL });
|
||||
|
||||
State[] sliderThumbStates =
|
||||
new State[] { NORMAL, HOT, PRESSED, FOCUSED, DISABLED };
|
||||
stateMap.put(Part.TKP_THUMB, sliderThumbStates);
|
||||
stateMap.put(Part.TKP_THUMBBOTTOM, sliderThumbStates);
|
||||
stateMap.put(Part.TKP_THUMBTOP, sliderThumbStates);
|
||||
stateMap.put(Part.TKP_THUMBVERT, sliderThumbStates);
|
||||
stateMap.put(Part.TKP_THUMBRIGHT, sliderThumbStates);
|
||||
|
||||
// States for Tabs
|
||||
State[] tabStates = new State[] { NORMAL, HOT, SELECTED, DISABLED, FOCUSED };
|
||||
stateMap.put(Part.TABP_TABITEM, tabStates);
|
||||
stateMap.put(Part.TABP_TABITEMLEFTEDGE, tabStates);
|
||||
stateMap.put(Part.TABP_TABITEMRIGHTEDGE, tabStates);
|
||||
|
||||
|
||||
stateMap.put(Part.TP_BUTTON,
|
||||
new State[] {
|
||||
NORMAL, HOT, PRESSED, DISABLED, CHECKED, HOTCHECKED
|
||||
});
|
||||
|
||||
State[] frameStates = new State[] { ACTIVE, INACTIVE };
|
||||
stateMap.put(Part.WP_WINDOW, frameStates);
|
||||
stateMap.put(Part.WP_FRAMELEFT, frameStates);
|
||||
stateMap.put(Part.WP_FRAMERIGHT, frameStates);
|
||||
stateMap.put(Part.WP_FRAMEBOTTOM, frameStates);
|
||||
|
||||
State[] captionStates = new State[] { ACTIVE, INACTIVE, DISABLED };
|
||||
stateMap.put(Part.WP_CAPTION, captionStates);
|
||||
stateMap.put(Part.WP_MINCAPTION, captionStates);
|
||||
stateMap.put(Part.WP_MAXCAPTION, captionStates);
|
||||
|
||||
stateMap.put(Part.MP_BARBACKGROUND,
|
||||
new State[] { ACTIVE, INACTIVE });
|
||||
stateMap.put(Part.MP_BARITEM,
|
||||
new State[] { NORMAL, HOT, PUSHED,
|
||||
DISABLED, DISABLEDHOT, DISABLEDPUSHED });
|
||||
stateMap.put(Part.MP_POPUPCHECK,
|
||||
new State[] { CHECKMARKNORMAL, CHECKMARKDISABLED,
|
||||
BULLETNORMAL, BULLETDISABLED });
|
||||
stateMap.put(Part.MP_POPUPCHECKBACKGROUND,
|
||||
new State[] { DISABLEDPUSHED, NORMAL, BITMAP });
|
||||
stateMap.put(Part.MP_POPUPITEM,
|
||||
new State[] { NORMAL, HOT, DISABLED, DISABLEDHOT });
|
||||
stateMap.put(Part.MP_POPUPSUBMENU,
|
||||
new State[] { NORMAL, DISABLED });
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static synchronized int getValue(Part part, State state) {
|
||||
if (stateMap == null) {
|
||||
initStates();
|
||||
}
|
||||
|
||||
Enum[] states = stateMap.get(part);
|
||||
if (states != null) {
|
||||
for (int i = 0; i < states.length; i++) {
|
||||
if (state == states[i]) {
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (state == null || state == State.NORMAL) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* An enumeration of the possible component attributes and the
|
||||
* corresponding value type
|
||||
*/
|
||||
public static enum Prop {
|
||||
COLOR(Color.class, 204),
|
||||
SIZE(Dimension.class, 207),
|
||||
|
||||
FLATMENUS(Boolean.class, 1001),
|
||||
|
||||
BORDERONLY(Boolean.class, 2203), // only draw the border area of the image
|
||||
|
||||
IMAGECOUNT(Integer.class, 2401), // the number of state images in an imagefile
|
||||
BORDERSIZE(Integer.class, 2403), // the size of the border line for bgtype=BorderFill
|
||||
|
||||
PROGRESSCHUNKSIZE(Integer.class, 2411), // size of progress control chunks
|
||||
PROGRESSSPACESIZE(Integer.class, 2412), // size of progress control spaces
|
||||
|
||||
TEXTSHADOWOFFSET(Point.class, 3402), // where char shadows are drawn, relative to orig. chars
|
||||
|
||||
NORMALSIZE(Dimension.class, 3409), // size of dest rect that exactly source
|
||||
|
||||
|
||||
SIZINGMARGINS ( Insets.class, 3601), // margins used for 9-grid sizing
|
||||
CONTENTMARGINS(Insets.class, 3602), // margins that define where content can be placed
|
||||
CAPTIONMARGINS(Insets.class, 3603), // margins that define where caption text can be placed
|
||||
|
||||
BORDERCOLOR(Color.class, 3801), // color of borders for BorderFill
|
||||
FILLCOLOR ( Color.class, 3802), // color of bg fill
|
||||
TEXTCOLOR ( Color.class, 3803), // color text is drawn in
|
||||
|
||||
TEXTSHADOWCOLOR(Color.class, 3818), // color of text shadow
|
||||
|
||||
BGTYPE(Integer.class, 4001), // basic drawing type for each part
|
||||
|
||||
TEXTSHADOWTYPE(Integer.class, 4010), // type of shadow to draw with text
|
||||
|
||||
TRANSITIONDURATIONS(Integer.class, 6000);
|
||||
|
||||
private final Class type;
|
||||
private final int value;
|
||||
|
||||
private Prop(Class type, int value) {
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return name()+"["+type.getName()+"] = "+value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* An enumeration of attribute values for some Props
|
||||
*/
|
||||
public static enum TypeEnum {
|
||||
BT_IMAGEFILE (Prop.BGTYPE, "imagefile", 0),
|
||||
BT_BORDERFILL(Prop.BGTYPE, "borderfill", 1),
|
||||
|
||||
TST_NONE(Prop.TEXTSHADOWTYPE, "none", 0),
|
||||
TST_SINGLE(Prop.TEXTSHADOWTYPE, "single", 1),
|
||||
TST_CONTINUOUS(Prop.TEXTSHADOWTYPE, "continuous", 2);
|
||||
|
||||
|
||||
private TypeEnum(Prop prop, String enumName, int value) {
|
||||
this.prop = prop;
|
||||
this.enumName = enumName;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
private final Prop prop;
|
||||
private final String enumName;
|
||||
private final int value;
|
||||
|
||||
public String toString() {
|
||||
return prop+"="+enumName+"="+value;
|
||||
}
|
||||
|
||||
String getName() {
|
||||
return enumName;
|
||||
}
|
||||
|
||||
|
||||
static TypeEnum getTypeEnum(Prop prop, int enumval) {
|
||||
for (TypeEnum e : TypeEnum.values()) {
|
||||
if (e.prop == prop && e.value == enumval) {
|
||||
return e;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
336
jdkSrc/jdk8/com/sun/java/swing/plaf/windows/WindowsBorders.java
Normal file
336
jdkSrc/jdk8/com/sun/java/swing/plaf/windows/WindowsBorders.java
Normal file
@@ -0,0 +1,336 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Insets;
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.*;
|
||||
import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
|
||||
|
||||
/**
|
||||
* Factory object that can vend Borders appropriate for the Windows 95 L & F.
|
||||
* @author Rich Schiavi
|
||||
*/
|
||||
|
||||
public class WindowsBorders {
|
||||
|
||||
/**
|
||||
* Returns a border instance for a Windows Progress Bar
|
||||
* @since 1.4
|
||||
*/
|
||||
public static Border getProgressBarBorder() {
|
||||
UIDefaults table = UIManager.getLookAndFeelDefaults();
|
||||
Border progressBarBorder = new BorderUIResource.CompoundBorderUIResource(
|
||||
new WindowsBorders.ProgressBarBorder(
|
||||
table.getColor("ProgressBar.shadow"),
|
||||
table.getColor("ProgressBar.highlight")),
|
||||
new EmptyBorder(1,1,1,1)
|
||||
);
|
||||
return progressBarBorder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a border instance for a Windows ToolBar
|
||||
*
|
||||
* @return a border used for the toolbar
|
||||
* @since 1.4
|
||||
*/
|
||||
public static Border getToolBarBorder() {
|
||||
UIDefaults table = UIManager.getLookAndFeelDefaults();
|
||||
Border toolBarBorder = new WindowsBorders.ToolBarBorder(
|
||||
table.getColor("ToolBar.shadow"),
|
||||
table.getColor("ToolBar.highlight"));
|
||||
return toolBarBorder;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an new instance of a border used to indicate which cell item
|
||||
* has focus.
|
||||
*
|
||||
* @return a border to indicate which cell item has focus
|
||||
* @since 1.4
|
||||
*/
|
||||
public static Border getFocusCellHighlightBorder() {
|
||||
return new ComplementDashedBorder();
|
||||
}
|
||||
|
||||
public static Border getTableHeaderBorder() {
|
||||
UIDefaults table = UIManager.getLookAndFeelDefaults();
|
||||
Border tableHeaderBorder = new BorderUIResource.CompoundBorderUIResource(
|
||||
new BasicBorders.ButtonBorder(
|
||||
table.getColor("Table.shadow"),
|
||||
table.getColor("Table.darkShadow"),
|
||||
table.getColor("Table.light"),
|
||||
table.getColor("Table.highlight")),
|
||||
new BasicBorders.MarginBorder());
|
||||
return tableHeaderBorder;
|
||||
}
|
||||
|
||||
public static Border getInternalFrameBorder() {
|
||||
UIDefaults table = UIManager.getLookAndFeelDefaults();
|
||||
Border internalFrameBorder = new
|
||||
BorderUIResource.CompoundBorderUIResource(
|
||||
BorderFactory.createBevelBorder(BevelBorder.RAISED,
|
||||
table.getColor("InternalFrame.borderColor"),
|
||||
table.getColor("InternalFrame.borderHighlight"),
|
||||
table.getColor("InternalFrame.borderDarkShadow"),
|
||||
table.getColor("InternalFrame.borderShadow")),
|
||||
new WindowsBorders.InternalFrameLineBorder(
|
||||
table.getColor("InternalFrame.activeBorderColor"),
|
||||
table.getColor("InternalFrame.inactiveBorderColor"),
|
||||
table.getInt("InternalFrame.borderWidth")));
|
||||
|
||||
return internalFrameBorder;
|
||||
}
|
||||
|
||||
public static class ProgressBarBorder extends AbstractBorder implements UIResource {
|
||||
protected Color shadow;
|
||||
protected Color highlight;
|
||||
|
||||
public ProgressBarBorder(Color shadow, Color highlight) {
|
||||
this.highlight = highlight;
|
||||
this.shadow = shadow;
|
||||
}
|
||||
|
||||
public void paintBorder(Component c, Graphics g, int x, int y,
|
||||
int width, int height) {
|
||||
g.setColor(shadow);
|
||||
g.drawLine(x,y, width-1,y); // draw top
|
||||
g.drawLine(x,y, x,height-1); // draw left
|
||||
g.setColor(highlight);
|
||||
g.drawLine(x,height-1, width-1,height-1); // draw bottom
|
||||
g.drawLine(width-1,y, width-1,height-1); // draw right
|
||||
}
|
||||
|
||||
public Insets getBorderInsets(Component c, Insets insets) {
|
||||
insets.set(1,1,1,1);
|
||||
return insets;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A border for the ToolBar. If the ToolBar is floatable then the handle grip is drawn
|
||||
* <p>
|
||||
* @since 1.4
|
||||
*/
|
||||
public static class ToolBarBorder extends AbstractBorder implements UIResource, SwingConstants {
|
||||
protected Color shadow;
|
||||
protected Color highlight;
|
||||
|
||||
public ToolBarBorder(Color shadow, Color highlight) {
|
||||
this.highlight = highlight;
|
||||
this.shadow = shadow;
|
||||
}
|
||||
|
||||
public void paintBorder(Component c, Graphics g, int x, int y,
|
||||
int width, int height) {
|
||||
if (!(c instanceof JToolBar)) {
|
||||
return;
|
||||
}
|
||||
g.translate(x, y);
|
||||
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
Border xpBorder = xp.getBorder(c, Part.TP_TOOLBAR);
|
||||
if (xpBorder != null) {
|
||||
xpBorder.paintBorder(c, g, 0, 0, width, height);
|
||||
}
|
||||
}
|
||||
if (((JToolBar)c).isFloatable()) {
|
||||
boolean vertical = ((JToolBar)c).getOrientation() == VERTICAL;
|
||||
|
||||
if (xp != null) {
|
||||
Part part = vertical ? Part.RP_GRIPPERVERT : Part.RP_GRIPPER;
|
||||
Skin skin = xp.getSkin(c, part);
|
||||
int dx, dy, dw, dh;
|
||||
if (vertical) {
|
||||
dx = 0;
|
||||
dy = 2;
|
||||
dw = width - 1;
|
||||
dh = skin.getHeight();
|
||||
} else {
|
||||
dw = skin.getWidth();
|
||||
dh = height - 1;
|
||||
dx = c.getComponentOrientation().isLeftToRight() ? 2 : (width-dw-2);
|
||||
dy = 0;
|
||||
}
|
||||
skin.paintSkin(g, dx, dy, dw, dh, State.NORMAL);
|
||||
|
||||
} else {
|
||||
|
||||
if (!vertical) {
|
||||
if (c.getComponentOrientation().isLeftToRight()) {
|
||||
g.setColor(shadow);
|
||||
g.drawLine(4, 3, 4, height - 4);
|
||||
g.drawLine(4, height - 4, 2, height - 4);
|
||||
|
||||
g.setColor(highlight);
|
||||
g.drawLine(2, 3, 3, 3);
|
||||
g.drawLine(2, 3, 2, height - 5);
|
||||
} else {
|
||||
g.setColor(shadow);
|
||||
g.drawLine(width - 3, 3, width - 3, height - 4);
|
||||
g.drawLine(width - 4, height - 4, width - 4, height - 4);
|
||||
|
||||
g.setColor(highlight);
|
||||
g.drawLine(width - 5, 3, width - 4, 3);
|
||||
g.drawLine(width - 5, 3, width - 5, height - 5);
|
||||
}
|
||||
} else { // Vertical
|
||||
g.setColor(shadow);
|
||||
g.drawLine(3, 4, width - 4, 4);
|
||||
g.drawLine(width - 4, 2, width - 4, 4);
|
||||
|
||||
g.setColor(highlight);
|
||||
g.drawLine(3, 2, width - 4, 2);
|
||||
g.drawLine(3, 2, 3, 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g.translate(-x, -y);
|
||||
}
|
||||
|
||||
public Insets getBorderInsets(Component c, Insets insets) {
|
||||
insets.set(1,1,1,1);
|
||||
if (!(c instanceof JToolBar)) {
|
||||
return insets;
|
||||
}
|
||||
if (((JToolBar)c).isFloatable()) {
|
||||
int gripInset = (XPStyle.getXP() != null) ? 12 : 9;
|
||||
if (((JToolBar)c).getOrientation() == HORIZONTAL) {
|
||||
if (c.getComponentOrientation().isLeftToRight()) {
|
||||
insets.left = gripInset;
|
||||
} else {
|
||||
insets.right = gripInset;
|
||||
}
|
||||
} else {
|
||||
insets.top = gripInset;
|
||||
}
|
||||
}
|
||||
return insets;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class is an implementation of a dashed border.
|
||||
* @since 1.4
|
||||
*/
|
||||
public static class DashedBorder extends LineBorder implements UIResource {
|
||||
public DashedBorder(Color color) {
|
||||
super(color);
|
||||
}
|
||||
|
||||
public DashedBorder(Color color, int thickness) {
|
||||
super(color, thickness);
|
||||
}
|
||||
|
||||
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
|
||||
Color oldColor = g.getColor();
|
||||
int i;
|
||||
|
||||
g.setColor(lineColor);
|
||||
for(i = 0; i < thickness; i++) {
|
||||
BasicGraphicsUtils.drawDashedRect(g, x+i, y+i, width-i-i, height-i-i);
|
||||
}
|
||||
g.setColor(oldColor);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A dashed border that paints itself in the complementary color
|
||||
* of the component's background color.
|
||||
*/
|
||||
static class ComplementDashedBorder extends LineBorder implements UIResource {
|
||||
private Color origColor;
|
||||
private Color paintColor;
|
||||
|
||||
public ComplementDashedBorder() {
|
||||
super(null);
|
||||
}
|
||||
|
||||
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
|
||||
Color color = c.getBackground();
|
||||
|
||||
if (origColor != color) {
|
||||
origColor = color;
|
||||
paintColor = new Color(~origColor.getRGB());
|
||||
}
|
||||
|
||||
g.setColor(paintColor);
|
||||
BasicGraphicsUtils.drawDashedRect(g, x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This class is an implementation of the InternalFrameLine border.
|
||||
* @since 1.4
|
||||
*/
|
||||
public static class InternalFrameLineBorder extends LineBorder implements
|
||||
UIResource {
|
||||
protected Color activeColor;
|
||||
protected Color inactiveColor;
|
||||
|
||||
public InternalFrameLineBorder(Color activeBorderColor,
|
||||
Color inactiveBorderColor,
|
||||
int thickness) {
|
||||
super(activeBorderColor, thickness);
|
||||
activeColor = activeBorderColor;
|
||||
inactiveColor = inactiveBorderColor;
|
||||
}
|
||||
|
||||
public void paintBorder(Component c, Graphics g, int x, int y,
|
||||
int width, int height) {
|
||||
|
||||
JInternalFrame jif = null;
|
||||
if (c instanceof JInternalFrame) {
|
||||
jif = (JInternalFrame)c;
|
||||
} else if (c instanceof JInternalFrame.JDesktopIcon) {
|
||||
jif = ((JInternalFrame.JDesktopIcon)c).getInternalFrame();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
if (jif.isSelected()) {
|
||||
// Set the line color so the line border gets the correct
|
||||
// color.
|
||||
lineColor = activeColor;
|
||||
super.paintBorder(c, g, x, y, width, height);
|
||||
} else {
|
||||
lineColor = inactiveColor;
|
||||
super.paintBorder(c, g, x, y, width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2006, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.beans.PropertyChangeEvent;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
|
||||
/**
|
||||
* Button Listener
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Rich Schiavi
|
||||
*/
|
||||
public class WindowsButtonListener extends BasicButtonListener {
|
||||
public WindowsButtonListener(AbstractButton b) {
|
||||
super(b);
|
||||
}
|
||||
/*
|
||||
This class is currently not used, but exists in case customers
|
||||
were subclassing it.
|
||||
*/
|
||||
}
|
||||
320
jdkSrc/jdk8/com/sun/java/swing/plaf/windows/WindowsButtonUI.java
Normal file
320
jdkSrc/jdk8/com/sun/java/swing/plaf/windows/WindowsButtonUI.java
Normal file
@@ -0,0 +1,320 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.*;
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.Part.*;
|
||||
import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
|
||||
import sun.awt.AppContext;
|
||||
|
||||
|
||||
/**
|
||||
* Windows button.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Jeff Dinkins
|
||||
*
|
||||
*/
|
||||
public class WindowsButtonUI extends BasicButtonUI
|
||||
{
|
||||
protected int dashedRectGapX;
|
||||
protected int dashedRectGapY;
|
||||
protected int dashedRectGapWidth;
|
||||
protected int dashedRectGapHeight;
|
||||
|
||||
protected Color focusColor;
|
||||
|
||||
private boolean defaults_initialized = false;
|
||||
|
||||
private static final Object WINDOWS_BUTTON_UI_KEY = new Object();
|
||||
|
||||
// ********************************
|
||||
// Create PLAF
|
||||
// ********************************
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
AppContext appContext = AppContext.getAppContext();
|
||||
WindowsButtonUI windowsButtonUI =
|
||||
(WindowsButtonUI) appContext.get(WINDOWS_BUTTON_UI_KEY);
|
||||
if (windowsButtonUI == null) {
|
||||
windowsButtonUI = new WindowsButtonUI();
|
||||
appContext.put(WINDOWS_BUTTON_UI_KEY, windowsButtonUI);
|
||||
}
|
||||
return windowsButtonUI;
|
||||
}
|
||||
|
||||
|
||||
// ********************************
|
||||
// Defaults
|
||||
// ********************************
|
||||
protected void installDefaults(AbstractButton b) {
|
||||
super.installDefaults(b);
|
||||
if(!defaults_initialized) {
|
||||
String pp = getPropertyPrefix();
|
||||
dashedRectGapX = UIManager.getInt(pp + "dashedRectGapX");
|
||||
dashedRectGapY = UIManager.getInt(pp + "dashedRectGapY");
|
||||
dashedRectGapWidth = UIManager.getInt(pp + "dashedRectGapWidth");
|
||||
dashedRectGapHeight = UIManager.getInt(pp + "dashedRectGapHeight");
|
||||
focusColor = UIManager.getColor(pp + "focus");
|
||||
defaults_initialized = true;
|
||||
}
|
||||
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
b.setBorder(xp.getBorder(b, getXPButtonType(b)));
|
||||
LookAndFeel.installProperty(b, "rolloverEnabled", Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
protected void uninstallDefaults(AbstractButton b) {
|
||||
super.uninstallDefaults(b);
|
||||
defaults_initialized = false;
|
||||
}
|
||||
|
||||
protected Color getFocusColor() {
|
||||
return focusColor;
|
||||
}
|
||||
|
||||
// ********************************
|
||||
// Paint Methods
|
||||
// ********************************
|
||||
|
||||
/**
|
||||
* Overridden method to render the text without the mnemonic
|
||||
*/
|
||||
protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) {
|
||||
WindowsGraphicsUtils.paintText(g, b, textRect, text, getTextShiftOffset());
|
||||
}
|
||||
|
||||
protected void paintFocus(Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect){
|
||||
|
||||
// focus painted same color as text on Basic??
|
||||
int width = b.getWidth();
|
||||
int height = b.getHeight();
|
||||
g.setColor(getFocusColor());
|
||||
BasicGraphicsUtils.drawDashedRect(g, dashedRectGapX, dashedRectGapY,
|
||||
width - dashedRectGapWidth, height - dashedRectGapHeight);
|
||||
}
|
||||
|
||||
protected void paintButtonPressed(Graphics g, AbstractButton b){
|
||||
setTextShiftOffset();
|
||||
}
|
||||
|
||||
// ********************************
|
||||
// Layout Methods
|
||||
// ********************************
|
||||
public Dimension getPreferredSize(JComponent c) {
|
||||
Dimension d = super.getPreferredSize(c);
|
||||
|
||||
/* Ensure that the width and height of the button is odd,
|
||||
* to allow for the focus line if focus is painted
|
||||
*/
|
||||
AbstractButton b = (AbstractButton)c;
|
||||
if (d != null && b.isFocusPainted()) {
|
||||
if(d.width % 2 == 0) { d.width += 1; }
|
||||
if(d.height % 2 == 0) { d.height += 1; }
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
|
||||
/* These rectangles/insets are allocated once for all
|
||||
* ButtonUI.paint() calls. Re-using rectangles rather than
|
||||
* allocating them in each paint call substantially reduced the time
|
||||
* it took paint to run. Obviously, this method can't be re-entered.
|
||||
*/
|
||||
private Rectangle viewRect = new Rectangle();
|
||||
|
||||
public void paint(Graphics g, JComponent c) {
|
||||
if (XPStyle.getXP() != null) {
|
||||
WindowsButtonUI.paintXPButtonBackground(g, c);
|
||||
}
|
||||
super.paint(g, c);
|
||||
}
|
||||
|
||||
static Part getXPButtonType(AbstractButton b) {
|
||||
if(b instanceof JCheckBox) {
|
||||
return Part.BP_CHECKBOX;
|
||||
}
|
||||
if(b instanceof JRadioButton) {
|
||||
return Part.BP_RADIOBUTTON;
|
||||
}
|
||||
boolean toolbar = (b.getParent() instanceof JToolBar);
|
||||
return toolbar ? Part.TP_BUTTON : Part.BP_PUSHBUTTON;
|
||||
}
|
||||
|
||||
static State getXPButtonState(AbstractButton b) {
|
||||
Part part = getXPButtonType(b);
|
||||
ButtonModel model = b.getModel();
|
||||
State state = State.NORMAL;
|
||||
switch (part) {
|
||||
case BP_RADIOBUTTON:
|
||||
/* falls through */
|
||||
case BP_CHECKBOX:
|
||||
if (! model.isEnabled()) {
|
||||
state = (model.isSelected()) ? State.CHECKEDDISABLED
|
||||
: State.UNCHECKEDDISABLED;
|
||||
} else if (model.isPressed() && model.isArmed()) {
|
||||
state = (model.isSelected()) ? State.CHECKEDPRESSED
|
||||
: State.UNCHECKEDPRESSED;
|
||||
} else if (model.isRollover()) {
|
||||
state = (model.isSelected()) ? State.CHECKEDHOT
|
||||
: State.UNCHECKEDHOT;
|
||||
} else {
|
||||
state = (model.isSelected()) ? State.CHECKEDNORMAL
|
||||
: State.UNCHECKEDNORMAL;
|
||||
}
|
||||
break;
|
||||
case BP_PUSHBUTTON:
|
||||
/* falls through */
|
||||
case TP_BUTTON:
|
||||
boolean toolbar = (b.getParent() instanceof JToolBar);
|
||||
if (toolbar) {
|
||||
if (model.isArmed() && model.isPressed()) {
|
||||
state = State.PRESSED;
|
||||
} else if (!model.isEnabled()) {
|
||||
state = State.DISABLED;
|
||||
} else if (model.isSelected() && model.isRollover()) {
|
||||
state = State.HOTCHECKED;
|
||||
} else if (model.isSelected()) {
|
||||
state = State.CHECKED;
|
||||
} else if (model.isRollover()) {
|
||||
state = State.HOT;
|
||||
} else if (b.hasFocus()) {
|
||||
state = State.HOT;
|
||||
}
|
||||
} else {
|
||||
if ((model.isArmed() && model.isPressed())
|
||||
|| model.isSelected()) {
|
||||
state = State.PRESSED;
|
||||
} else if (!model.isEnabled()) {
|
||||
state = State.DISABLED;
|
||||
} else if (model.isRollover() || model.isPressed()) {
|
||||
state = State.HOT;
|
||||
} else if (b instanceof JButton
|
||||
&& ((JButton)b).isDefaultButton()) {
|
||||
state = State.DEFAULTED;
|
||||
} else if (b.hasFocus()) {
|
||||
state = State.HOT;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default :
|
||||
state = State.NORMAL;
|
||||
}
|
||||
|
||||
return state;
|
||||
}
|
||||
|
||||
static void paintXPButtonBackground(Graphics g, JComponent c) {
|
||||
AbstractButton b = (AbstractButton)c;
|
||||
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
|
||||
Part part = getXPButtonType(b);
|
||||
|
||||
if (b.isContentAreaFilled() && xp != null) {
|
||||
|
||||
Skin skin = xp.getSkin(b, part);
|
||||
|
||||
State state = getXPButtonState(b);
|
||||
Dimension d = c.getSize();
|
||||
int dx = 0;
|
||||
int dy = 0;
|
||||
int dw = d.width;
|
||||
int dh = d.height;
|
||||
|
||||
Border border = c.getBorder();
|
||||
Insets insets;
|
||||
if (border != null) {
|
||||
// Note: The border may be compound, containing an outer
|
||||
// opaque border (supplied by the application), plus an
|
||||
// inner transparent margin border. We want to size the
|
||||
// background to fill the transparent part, but stay
|
||||
// inside the opaque part.
|
||||
insets = WindowsButtonUI.getOpaqueInsets(border, c);
|
||||
} else {
|
||||
insets = c.getInsets();
|
||||
}
|
||||
if (insets != null) {
|
||||
dx += insets.left;
|
||||
dy += insets.top;
|
||||
dw -= (insets.left + insets.right);
|
||||
dh -= (insets.top + insets.bottom);
|
||||
}
|
||||
skin.paintSkin(g, dx, dy, dw, dh, state);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns - b.getBorderInsets(c) if border is opaque
|
||||
* - null if border is completely non-opaque
|
||||
* - somewhere inbetween if border is compound and
|
||||
* outside border is opaque and inside isn't
|
||||
*/
|
||||
private static Insets getOpaqueInsets(Border b, Component c) {
|
||||
if (b == null) {
|
||||
return null;
|
||||
}
|
||||
if (b.isBorderOpaque()) {
|
||||
return b.getBorderInsets(c);
|
||||
} else if (b instanceof CompoundBorder) {
|
||||
CompoundBorder cb = (CompoundBorder)b;
|
||||
Insets iOut = getOpaqueInsets(cb.getOutsideBorder(), c);
|
||||
if (iOut != null && iOut.equals(cb.getOutsideBorder().getBorderInsets(c))) {
|
||||
// Outside border is opaque, keep looking
|
||||
Insets iIn = getOpaqueInsets(cb.getInsideBorder(), c);
|
||||
if (iIn == null) {
|
||||
// Inside is non-opaque, use outside insets
|
||||
return iOut;
|
||||
} else {
|
||||
// Found non-opaque somewhere in the inside (which is
|
||||
// also compound).
|
||||
return new Insets(iOut.top + iIn.top, iOut.left + iIn.left,
|
||||
iOut.bottom + iIn.bottom, iOut.right + iIn.right);
|
||||
}
|
||||
} else {
|
||||
// Outside is either all non-opaque or has non-opaque
|
||||
// border inside another compound border
|
||||
return iOut;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
|
||||
import com.sun.java.swing.plaf.windows.TMSchema.Part;
|
||||
import com.sun.java.swing.plaf.windows.TMSchema.State;
|
||||
|
||||
|
||||
/**
|
||||
* Windows check box menu item.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public class WindowsCheckBoxMenuItemUI extends BasicCheckBoxMenuItemUI {
|
||||
|
||||
final WindowsMenuItemUIAccessor accessor =
|
||||
new WindowsMenuItemUIAccessor() {
|
||||
|
||||
public JMenuItem getMenuItem() {
|
||||
return menuItem;
|
||||
}
|
||||
|
||||
public State getState(JMenuItem menuItem) {
|
||||
return WindowsMenuItemUI.getState(this, menuItem);
|
||||
}
|
||||
|
||||
public Part getPart(JMenuItem menuItem) {
|
||||
return WindowsMenuItemUI.getPart(this, menuItem);
|
||||
}
|
||||
};
|
||||
public static ComponentUI createUI(JComponent b) {
|
||||
return new WindowsCheckBoxMenuItemUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintBackground(Graphics g, JMenuItem menuItem,
|
||||
Color bgColor) {
|
||||
if (WindowsMenuItemUI.isVistaPainting()) {
|
||||
WindowsMenuItemUI.paintBackground(accessor, g, menuItem, bgColor);
|
||||
return;
|
||||
}
|
||||
super.paintBackground(g, menuItem, bgColor);
|
||||
}
|
||||
/**
|
||||
* Method which renders the text of the current menu item.
|
||||
* <p>
|
||||
* @param g Graphics context
|
||||
* @param menuItem Current menu item to render
|
||||
* @param textRect Bounding rectangle to render the text.
|
||||
* @param text String to render
|
||||
* @since 1.4
|
||||
*/
|
||||
protected void paintText(Graphics g, JMenuItem menuItem,
|
||||
Rectangle textRect, String text) {
|
||||
if (WindowsMenuItemUI.isVistaPainting()) {
|
||||
WindowsMenuItemUI.paintText(accessor, g, menuItem,
|
||||
textRect, text);
|
||||
return;
|
||||
}
|
||||
ButtonModel model = menuItem.getModel();
|
||||
Color oldColor = g.getColor();
|
||||
|
||||
if(model.isEnabled() && model.isArmed()) {
|
||||
g.setColor(selectionForeground); // Uses protected field.
|
||||
}
|
||||
|
||||
WindowsGraphicsUtils.paintText(g, menuItem, textRect, text, 0);
|
||||
|
||||
g.setColor(oldColor);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import sun.awt.AppContext;
|
||||
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.*;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Windows check box.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Jeff Dinkins
|
||||
*/
|
||||
public class WindowsCheckBoxUI extends WindowsRadioButtonUI
|
||||
{
|
||||
// NOTE: MetalCheckBoxUI inherts from MetalRadioButtonUI instead
|
||||
// of BasicCheckBoxUI because we want to pick up all the
|
||||
// painting changes made in MetalRadioButtonUI.
|
||||
|
||||
private static final Object WINDOWS_CHECK_BOX_UI_KEY = new Object();
|
||||
|
||||
private final static String propertyPrefix = "CheckBox" + ".";
|
||||
|
||||
private boolean defaults_initialized = false;
|
||||
|
||||
// ********************************
|
||||
// Create PLAF
|
||||
// ********************************
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
AppContext appContext = AppContext.getAppContext();
|
||||
WindowsCheckBoxUI windowsCheckBoxUI =
|
||||
(WindowsCheckBoxUI) appContext.get(WINDOWS_CHECK_BOX_UI_KEY);
|
||||
if (windowsCheckBoxUI == null) {
|
||||
windowsCheckBoxUI = new WindowsCheckBoxUI();
|
||||
appContext.put(WINDOWS_CHECK_BOX_UI_KEY, windowsCheckBoxUI);
|
||||
}
|
||||
return windowsCheckBoxUI;
|
||||
}
|
||||
|
||||
|
||||
public String getPropertyPrefix() {
|
||||
return propertyPrefix;
|
||||
}
|
||||
|
||||
// ********************************
|
||||
// Defaults
|
||||
// ********************************
|
||||
public void installDefaults(AbstractButton b) {
|
||||
super.installDefaults(b);
|
||||
if(!defaults_initialized) {
|
||||
icon = UIManager.getIcon(getPropertyPrefix() + "icon");
|
||||
defaults_initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void uninstallDefaults(AbstractButton b) {
|
||||
super.uninstallDefaults(b);
|
||||
defaults_initialized = false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2003, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
/**
|
||||
* Implements the Windows95/98/ME/NT/2000 Look and Feel.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public class WindowsClassicLookAndFeel extends WindowsLookAndFeel {
|
||||
public String getName() {
|
||||
return "Windows Classic";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,572 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.*;
|
||||
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.Part;
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.State;
|
||||
import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
|
||||
|
||||
import sun.swing.DefaultLookup;
|
||||
import sun.swing.StringUIClientPropertyKey;
|
||||
|
||||
|
||||
/**
|
||||
* Windows combo box.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Tom Santos
|
||||
* @author Igor Kushnirskiy
|
||||
*/
|
||||
|
||||
public class WindowsComboBoxUI extends BasicComboBoxUI {
|
||||
|
||||
private static final MouseListener rolloverListener =
|
||||
new MouseAdapter() {
|
||||
private void handleRollover(MouseEvent e, boolean isRollover) {
|
||||
JComboBox comboBox = getComboBox(e);
|
||||
WindowsComboBoxUI comboBoxUI = getWindowsComboBoxUI(e);
|
||||
if (comboBox == null || comboBoxUI == null) {
|
||||
return;
|
||||
}
|
||||
if (! comboBox.isEditable()) {
|
||||
//mouse over editable ComboBox does not switch rollover
|
||||
//for the arrow button
|
||||
ButtonModel m = null;
|
||||
if (comboBoxUI.arrowButton != null) {
|
||||
m = comboBoxUI.arrowButton.getModel();
|
||||
}
|
||||
if (m != null ) {
|
||||
m.setRollover(isRollover);
|
||||
}
|
||||
}
|
||||
comboBoxUI.isRollover = isRollover;
|
||||
comboBox.repaint();
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
handleRollover(e, true);
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent e) {
|
||||
handleRollover(e, false);
|
||||
}
|
||||
|
||||
private JComboBox getComboBox(MouseEvent event) {
|
||||
Object source = event.getSource();
|
||||
JComboBox rv = null;
|
||||
if (source instanceof JComboBox) {
|
||||
rv = (JComboBox) source;
|
||||
} else if (source instanceof XPComboBoxButton) {
|
||||
rv = ((XPComboBoxButton) source)
|
||||
.getWindowsComboBoxUI().comboBox;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
private WindowsComboBoxUI getWindowsComboBoxUI(MouseEvent event) {
|
||||
JComboBox comboBox = getComboBox(event);
|
||||
WindowsComboBoxUI rv = null;
|
||||
if (comboBox != null
|
||||
&& comboBox.getUI() instanceof WindowsComboBoxUI) {
|
||||
rv = (WindowsComboBoxUI) comboBox.getUI();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
};
|
||||
private boolean isRollover = false;
|
||||
|
||||
private static final PropertyChangeListener componentOrientationListener =
|
||||
new PropertyChangeListener() {
|
||||
public void propertyChange(PropertyChangeEvent e) {
|
||||
String propertyName = e.getPropertyName();
|
||||
Object source = null;
|
||||
if ("componentOrientation" == propertyName
|
||||
&& (source = e.getSource()) instanceof JComboBox
|
||||
&& ((JComboBox) source).getUI() instanceof
|
||||
WindowsComboBoxUI) {
|
||||
JComboBox comboBox = (JComboBox) source;
|
||||
WindowsComboBoxUI comboBoxUI = (WindowsComboBoxUI) comboBox.getUI();
|
||||
if (comboBoxUI.arrowButton instanceof XPComboBoxButton) {
|
||||
((XPComboBoxButton) comboBoxUI.arrowButton).setPart(
|
||||
(comboBox.getComponentOrientation() ==
|
||||
ComponentOrientation.RIGHT_TO_LEFT)
|
||||
? Part.CP_DROPDOWNBUTTONLEFT
|
||||
: Part.CP_DROPDOWNBUTTONRIGHT);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new WindowsComboBoxUI();
|
||||
}
|
||||
|
||||
public void installUI( JComponent c ) {
|
||||
super.installUI( c );
|
||||
isRollover = false;
|
||||
comboBox.setRequestFocusEnabled( true );
|
||||
if (XPStyle.getXP() != null && arrowButton != null) {
|
||||
//we can not do it in installListeners because arrowButton
|
||||
//is initialized after installListeners is invoked
|
||||
comboBox.addMouseListener(rolloverListener);
|
||||
arrowButton.addMouseListener(rolloverListener);
|
||||
}
|
||||
}
|
||||
|
||||
public void uninstallUI(JComponent c ) {
|
||||
comboBox.removeMouseListener(rolloverListener);
|
||||
if(arrowButton != null) {
|
||||
arrowButton.removeMouseListener(rolloverListener);
|
||||
}
|
||||
super.uninstallUI( c );
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 1.6
|
||||
*/
|
||||
@Override
|
||||
protected void installListeners() {
|
||||
super.installListeners();
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
//button glyph for LTR and RTL combobox might differ
|
||||
if (xp != null
|
||||
&& xp.isSkinDefined(comboBox, Part.CP_DROPDOWNBUTTONRIGHT)) {
|
||||
comboBox.addPropertyChangeListener("componentOrientation",
|
||||
componentOrientationListener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 1.6
|
||||
*/
|
||||
@Override
|
||||
protected void uninstallListeners() {
|
||||
super.uninstallListeners();
|
||||
comboBox.removePropertyChangeListener("componentOrientation",
|
||||
componentOrientationListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 1.6
|
||||
*/
|
||||
protected void configureEditor() {
|
||||
super.configureEditor();
|
||||
if (XPStyle.getXP() != null) {
|
||||
editor.addMouseListener(rolloverListener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 1.6
|
||||
*/
|
||||
protected void unconfigureEditor() {
|
||||
super.unconfigureEditor();
|
||||
editor.removeMouseListener(rolloverListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 1.6
|
||||
*/
|
||||
public void paint(Graphics g, JComponent c) {
|
||||
if (XPStyle.getXP() != null) {
|
||||
paintXPComboBoxBackground(g, c);
|
||||
}
|
||||
super.paint(g, c);
|
||||
}
|
||||
|
||||
State getXPComboBoxState(JComponent c) {
|
||||
State state = State.NORMAL;
|
||||
if (!c.isEnabled()) {
|
||||
state = State.DISABLED;
|
||||
} else if (isPopupVisible(comboBox)) {
|
||||
state = State.PRESSED;
|
||||
} else if (isRollover) {
|
||||
state = State.HOT;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
private void paintXPComboBoxBackground(Graphics g, JComponent c) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp == null) {
|
||||
return;
|
||||
}
|
||||
State state = getXPComboBoxState(c);
|
||||
Skin skin = null;
|
||||
if (! comboBox.isEditable()
|
||||
&& xp.isSkinDefined(c, Part.CP_READONLY)) {
|
||||
skin = xp.getSkin(c, Part.CP_READONLY);
|
||||
}
|
||||
if (skin == null) {
|
||||
skin = xp.getSkin(c, Part.CP_COMBOBOX);
|
||||
}
|
||||
skin.paintSkin(g, 0, 0, c.getWidth(), c.getHeight(), state);
|
||||
}
|
||||
|
||||
/**
|
||||
* If necessary paints the currently selected item.
|
||||
*
|
||||
* @param g Graphics to paint to
|
||||
* @param bounds Region to paint current value to
|
||||
* @param hasFocus whether or not the JComboBox has focus
|
||||
* @throws NullPointerException if any of the arguments are null.
|
||||
* @since 1.5
|
||||
*/
|
||||
public void paintCurrentValue(Graphics g, Rectangle bounds,
|
||||
boolean hasFocus) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if ( xp != null) {
|
||||
bounds.x += 2;
|
||||
bounds.y += 2;
|
||||
bounds.width -= 4;
|
||||
bounds.height -= 4;
|
||||
} else {
|
||||
bounds.x += 1;
|
||||
bounds.y += 1;
|
||||
bounds.width -= 2;
|
||||
bounds.height -= 2;
|
||||
}
|
||||
if (! comboBox.isEditable()
|
||||
&& xp != null
|
||||
&& xp.isSkinDefined(comboBox, Part.CP_READONLY)) {
|
||||
// On vista for READNLY ComboBox
|
||||
// color for currentValue is the same as for any other item
|
||||
|
||||
// mostly copied from javax.swing.plaf.basic.BasicComboBoxUI.paintCurrentValue
|
||||
ListCellRenderer renderer = comboBox.getRenderer();
|
||||
Component c;
|
||||
if ( hasFocus && !isPopupVisible(comboBox) ) {
|
||||
c = renderer.getListCellRendererComponent(
|
||||
listBox,
|
||||
comboBox.getSelectedItem(),
|
||||
-1,
|
||||
true,
|
||||
false );
|
||||
} else {
|
||||
c = renderer.getListCellRendererComponent(
|
||||
listBox,
|
||||
comboBox.getSelectedItem(),
|
||||
-1,
|
||||
false,
|
||||
false );
|
||||
}
|
||||
c.setFont(comboBox.getFont());
|
||||
if ( comboBox.isEnabled() ) {
|
||||
c.setForeground(comboBox.getForeground());
|
||||
c.setBackground(comboBox.getBackground());
|
||||
} else {
|
||||
c.setForeground(DefaultLookup.getColor(
|
||||
comboBox, this, "ComboBox.disabledForeground", null));
|
||||
c.setBackground(DefaultLookup.getColor(
|
||||
comboBox, this, "ComboBox.disabledBackground", null));
|
||||
}
|
||||
boolean shouldValidate = false;
|
||||
if (c instanceof JPanel) {
|
||||
shouldValidate = true;
|
||||
}
|
||||
currentValuePane.paintComponent(g, c, comboBox, bounds.x, bounds.y,
|
||||
bounds.width, bounds.height, shouldValidate);
|
||||
|
||||
} else {
|
||||
super.paintCurrentValue(g, bounds, hasFocus);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 1.6
|
||||
*/
|
||||
public void paintCurrentValueBackground(Graphics g, Rectangle bounds,
|
||||
boolean hasFocus) {
|
||||
if (XPStyle.getXP() == null) {
|
||||
super.paintCurrentValueBackground(g, bounds, hasFocus);
|
||||
}
|
||||
}
|
||||
|
||||
public Dimension getMinimumSize( JComponent c ) {
|
||||
Dimension d = super.getMinimumSize(c);
|
||||
if (XPStyle.getXP() != null) {
|
||||
d.width += 5;
|
||||
} else {
|
||||
d.width += 4;
|
||||
}
|
||||
d.height += 2;
|
||||
return d;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a layout manager for managing the components which make up the
|
||||
* combo box.
|
||||
*
|
||||
* @return an instance of a layout manager
|
||||
*/
|
||||
protected LayoutManager createLayoutManager() {
|
||||
return new BasicComboBoxUI.ComboBoxLayoutManager() {
|
||||
public void layoutContainer(Container parent) {
|
||||
super.layoutContainer(parent);
|
||||
|
||||
if (XPStyle.getXP() != null && arrowButton != null) {
|
||||
Dimension d = parent.getSize();
|
||||
Insets insets = getInsets();
|
||||
int buttonWidth = arrowButton.getPreferredSize().width;
|
||||
arrowButton.setBounds(WindowsGraphicsUtils.isLeftToRight((JComboBox)parent)
|
||||
? (d.width - insets.right - buttonWidth)
|
||||
: insets.left,
|
||||
insets.top,
|
||||
buttonWidth, d.height - insets.top - insets.bottom);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected void installKeyboardActions() {
|
||||
super.installKeyboardActions();
|
||||
}
|
||||
|
||||
protected ComboPopup createPopup() {
|
||||
return super.createPopup();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the default editor that will be used in editable combo boxes.
|
||||
* A default editor will be used only if an editor has not been
|
||||
* explicitly set with <code>setEditor</code>.
|
||||
*
|
||||
* @return a <code>ComboBoxEditor</code> used for the combo box
|
||||
* @see javax.swing.JComboBox#setEditor
|
||||
*/
|
||||
protected ComboBoxEditor createEditor() {
|
||||
return new WindowsComboBoxEditor();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 1.6
|
||||
*/
|
||||
@Override
|
||||
protected ListCellRenderer createRenderer() {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null && xp.isSkinDefined(comboBox, Part.CP_READONLY)) {
|
||||
return new WindowsComboBoxRenderer();
|
||||
} else {
|
||||
return super.createRenderer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an button which will be used as the control to show or hide
|
||||
* the popup portion of the combo box.
|
||||
*
|
||||
* @return a button which represents the popup control
|
||||
*/
|
||||
protected JButton createArrowButton() {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
return new XPComboBoxButton(xp);
|
||||
} else {
|
||||
return super.createArrowButton();
|
||||
}
|
||||
}
|
||||
|
||||
private class XPComboBoxButton extends XPStyle.GlyphButton {
|
||||
public XPComboBoxButton(XPStyle xp) {
|
||||
super(null,
|
||||
(! xp.isSkinDefined(comboBox, Part.CP_DROPDOWNBUTTONRIGHT))
|
||||
? Part.CP_DROPDOWNBUTTON
|
||||
: (comboBox.getComponentOrientation() == ComponentOrientation.RIGHT_TO_LEFT)
|
||||
? Part.CP_DROPDOWNBUTTONLEFT
|
||||
: Part.CP_DROPDOWNBUTTONRIGHT
|
||||
);
|
||||
setRequestFocusEnabled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected State getState() {
|
||||
State rv;
|
||||
rv = super.getState();
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (rv != State.DISABLED
|
||||
&& comboBox != null && ! comboBox.isEditable()
|
||||
&& xp != null && xp.isSkinDefined(comboBox,
|
||||
Part.CP_DROPDOWNBUTTONRIGHT)) {
|
||||
/*
|
||||
* for non editable ComboBoxes Vista seems to have the
|
||||
* same glyph for all non DISABLED states
|
||||
*/
|
||||
rv = State.NORMAL;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
return new Dimension(17, 21);
|
||||
}
|
||||
|
||||
void setPart(Part part) {
|
||||
setPart(comboBox, part);
|
||||
}
|
||||
|
||||
WindowsComboBoxUI getWindowsComboBoxUI() {
|
||||
return WindowsComboBoxUI.this;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Subclassed to add Windows specific Key Bindings.
|
||||
* This class is now obsolete and doesn't do anything.
|
||||
* Only included for backwards API compatibility.
|
||||
* Do not call or override.
|
||||
*
|
||||
* @deprecated As of Java 2 platform v1.4.
|
||||
*/
|
||||
@Deprecated
|
||||
protected class WindowsComboPopup extends BasicComboPopup {
|
||||
|
||||
public WindowsComboPopup( JComboBox cBox ) {
|
||||
super( cBox );
|
||||
}
|
||||
|
||||
protected KeyListener createKeyListener() {
|
||||
return new InvocationKeyHandler();
|
||||
}
|
||||
|
||||
protected class InvocationKeyHandler extends BasicComboPopup.InvocationKeyHandler {
|
||||
protected InvocationKeyHandler() {
|
||||
WindowsComboPopup.this.super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Subclassed to highlight selected item in an editable combo box.
|
||||
*/
|
||||
public static class WindowsComboBoxEditor
|
||||
extends BasicComboBoxEditor.UIResource {
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 1.6
|
||||
*/
|
||||
protected JTextField createEditorComponent() {
|
||||
JTextField editor = super.createEditorComponent();
|
||||
Border border = (Border)UIManager.get("ComboBox.editorBorder");
|
||||
if (border != null) {
|
||||
editor.setBorder(border);
|
||||
}
|
||||
editor.setOpaque(false);
|
||||
return editor;
|
||||
}
|
||||
|
||||
public void setItem(Object item) {
|
||||
super.setItem(item);
|
||||
Object focus = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
|
||||
if ((focus == editor) || (focus == editor.getParent())) {
|
||||
editor.selectAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Subclassed to set opacity {@code false} on the renderer
|
||||
* and to show border for focused cells.
|
||||
*/
|
||||
private static class WindowsComboBoxRenderer
|
||||
extends BasicComboBoxRenderer.UIResource {
|
||||
private static final Object BORDER_KEY
|
||||
= new StringUIClientPropertyKey("BORDER_KEY");
|
||||
private static final Border NULL_BORDER = new EmptyBorder(0, 0, 0, 0);
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public Component getListCellRendererComponent(
|
||||
JList list,
|
||||
Object value,
|
||||
int index,
|
||||
boolean isSelected,
|
||||
boolean cellHasFocus) {
|
||||
Component rv =
|
||||
super.getListCellRendererComponent(list, value, index,
|
||||
isSelected, cellHasFocus);
|
||||
if (rv instanceof JComponent) {
|
||||
JComponent component = (JComponent) rv;
|
||||
if (index == -1 && isSelected) {
|
||||
Border border = component.getBorder();
|
||||
Border dashedBorder =
|
||||
new WindowsBorders.DashedBorder(list.getForeground());
|
||||
component.setBorder(dashedBorder);
|
||||
//store current border in client property if needed
|
||||
if (component.getClientProperty(BORDER_KEY) == null) {
|
||||
component.putClientProperty(BORDER_KEY,
|
||||
(border == null) ? NULL_BORDER : border);
|
||||
}
|
||||
} else {
|
||||
if (component.getBorder() instanceof
|
||||
WindowsBorders.DashedBorder) {
|
||||
Object storedBorder = component.getClientProperty(BORDER_KEY);
|
||||
if (storedBorder instanceof Border) {
|
||||
component.setBorder(
|
||||
(storedBorder == NULL_BORDER) ? null
|
||||
: (Border) storedBorder);
|
||||
}
|
||||
component.putClientProperty(BORDER_KEY, null);
|
||||
}
|
||||
}
|
||||
if (index == -1) {
|
||||
component.setOpaque(false);
|
||||
component.setForeground(list.getForeground());
|
||||
} else {
|
||||
component.setOpaque(true);
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2004, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Windows icon for a minimized window on the desktop.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public class WindowsDesktopIconUI extends BasicDesktopIconUI {
|
||||
private int width;
|
||||
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new WindowsDesktopIconUI();
|
||||
}
|
||||
|
||||
public void installDefaults() {
|
||||
super.installDefaults();
|
||||
width = UIManager.getInt("DesktopIcon.width");
|
||||
}
|
||||
|
||||
public void installUI(JComponent c) {
|
||||
super.installUI(c);
|
||||
|
||||
c.setOpaque(XPStyle.getXP() == null);
|
||||
}
|
||||
|
||||
// Uninstall the listeners added by the WindowsInternalFrameTitlePane
|
||||
public void uninstallUI(JComponent c) {
|
||||
WindowsInternalFrameTitlePane thePane =
|
||||
(WindowsInternalFrameTitlePane)iconPane;
|
||||
super.uninstallUI(c);
|
||||
thePane.uninstallListeners();
|
||||
}
|
||||
|
||||
protected void installComponents() {
|
||||
iconPane = new WindowsInternalFrameTitlePane(frame);
|
||||
desktopIcon.setLayout(new BorderLayout());
|
||||
desktopIcon.add(iconPane, BorderLayout.CENTER);
|
||||
|
||||
if (XPStyle.getXP() != null) {
|
||||
desktopIcon.setBorder(null);
|
||||
}
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize(JComponent c) {
|
||||
// Windows desktop icons can not be resized. Therefore, we should
|
||||
// always return the minimum size of the desktop icon. See
|
||||
// getMinimumSize(JComponent c).
|
||||
return getMinimumSize(c);
|
||||
}
|
||||
|
||||
/**
|
||||
* Windows desktop icons are restricted to a width of 160 pixels by
|
||||
* default. This value is retrieved by the DesktopIcon.width property.
|
||||
*/
|
||||
public Dimension getMinimumSize(JComponent c) {
|
||||
Dimension dim = super.getMinimumSize(c);
|
||||
dim.width = width;
|
||||
return dim;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2008, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import javax.swing.DefaultDesktopManager;
|
||||
import javax.swing.JInternalFrame;
|
||||
import javax.swing.JLayeredPane;
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Dimension;
|
||||
import java.beans.PropertyVetoException;
|
||||
import java.util.Vector;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
/**
|
||||
* This class implements a DesktopManager which more closely follows
|
||||
* the MDI model than the DefaultDesktopManager. Unlike the
|
||||
* DefaultDesktopManager policy, MDI requires that the selected
|
||||
* and activated child frames are the same, and that that frame
|
||||
* always be the top-most window.
|
||||
* <p>
|
||||
* The maximized state is managed by the DesktopManager with MDI,
|
||||
* instead of just being a property of the individual child frame.
|
||||
* This means that if the currently selected window is maximized
|
||||
* and another window is selected, that new window will be maximized.
|
||||
*
|
||||
* @see javax.swing.DefaultDesktopManager
|
||||
* @author Thomas Ball
|
||||
*/
|
||||
public class WindowsDesktopManager extends DefaultDesktopManager
|
||||
implements java.io.Serializable, javax.swing.plaf.UIResource {
|
||||
|
||||
/* The frame which is currently selected/activated.
|
||||
* We store this value to enforce MDI's single-selection model.
|
||||
*/
|
||||
private WeakReference<JInternalFrame> currentFrameRef;
|
||||
|
||||
public void activateFrame(JInternalFrame f) {
|
||||
JInternalFrame currentFrame = currentFrameRef != null ?
|
||||
currentFrameRef.get() : null;
|
||||
try {
|
||||
super.activateFrame(f);
|
||||
if (currentFrame != null && f != currentFrame) {
|
||||
// If the current frame is maximized, transfer that
|
||||
// attribute to the frame being activated.
|
||||
if (currentFrame.isMaximum() &&
|
||||
(f.getClientProperty("JInternalFrame.frameType") !=
|
||||
"optionDialog") ) {
|
||||
//Special case. If key binding was used to select next
|
||||
//frame instead of minimizing the icon via the minimize
|
||||
//icon.
|
||||
if (!currentFrame.isIcon()) {
|
||||
currentFrame.setMaximum(false);
|
||||
if (f.isMaximizable()) {
|
||||
if (!f.isMaximum()) {
|
||||
f.setMaximum(true);
|
||||
} else if (f.isMaximum() && f.isIcon()) {
|
||||
f.setIcon(false);
|
||||
} else {
|
||||
f.setMaximum(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentFrame.isSelected()) {
|
||||
currentFrame.setSelected(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (!f.isSelected()) {
|
||||
f.setSelected(true);
|
||||
}
|
||||
} catch (PropertyVetoException e) {}
|
||||
if (f != currentFrame) {
|
||||
currentFrameRef = new WeakReference<JInternalFrame>(f);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import java.awt.event.*;
|
||||
|
||||
/**
|
||||
* Windows desktop pane.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author David Kloba
|
||||
*/
|
||||
public class WindowsDesktopPaneUI extends BasicDesktopPaneUI
|
||||
{
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new WindowsDesktopPaneUI();
|
||||
}
|
||||
|
||||
protected void installDesktopManager() {
|
||||
desktopManager = desktop.getDesktopManager();
|
||||
if(desktopManager == null) {
|
||||
desktopManager = new WindowsDesktopManager();
|
||||
desktop.setDesktopManager(desktopManager);
|
||||
}
|
||||
}
|
||||
|
||||
protected void installDefaults() {
|
||||
super.installDefaults();
|
||||
}
|
||||
|
||||
protected void installKeyboardActions() {
|
||||
super.installKeyboardActions();
|
||||
|
||||
// Request focus if it isn't set.
|
||||
if(!desktop.requestDefaultFocus()) {
|
||||
desktop.requestFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.Caret;
|
||||
|
||||
|
||||
/**
|
||||
* Windows rendition of the component.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public class WindowsEditorPaneUI extends BasicEditorPaneUI
|
||||
{
|
||||
|
||||
/**
|
||||
* Creates a UI for a JEditorPane.
|
||||
*
|
||||
* @param c the configurable text component
|
||||
* @return the UI
|
||||
*/
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new WindowsEditorPaneUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the object to use for a caret. By default an
|
||||
* instance of WindowsCaret is created. This method
|
||||
* can be redefined to provide something else that implements
|
||||
* the InputPosition interface or a subclass of DefaultCaret.
|
||||
*
|
||||
* @return the caret object
|
||||
*/
|
||||
protected Caret createCaret() {
|
||||
return new WindowsTextUI.WindowsCaret();
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2014, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import sun.swing.SwingUtilities2;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.UIResource;
|
||||
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.*;
|
||||
|
||||
/**
|
||||
* A collection of static utility methods used for rendering the Windows look
|
||||
* and feel.
|
||||
*
|
||||
* @author Mark Davidson
|
||||
* @since 1.4
|
||||
*/
|
||||
public class WindowsGraphicsUtils {
|
||||
|
||||
/**
|
||||
* Renders a text String in Windows without the mnemonic.
|
||||
* This is here because the WindowsUI hierarchy doesn't match the Component hierarchy. All
|
||||
* the overriden paintText methods of the ButtonUI delegates will call this static method.
|
||||
* <p>
|
||||
* @param g Graphics context
|
||||
* @param b Current button to render
|
||||
* @param textRect Bounding rectangle to render the text.
|
||||
* @param text String to render
|
||||
*/
|
||||
public static void paintText(Graphics g, AbstractButton b,
|
||||
Rectangle textRect, String text,
|
||||
int textShiftOffset) {
|
||||
FontMetrics fm = SwingUtilities2.getFontMetrics(b, g);
|
||||
|
||||
int mnemIndex = b.getDisplayedMnemonicIndex();
|
||||
// W2K Feature: Check to see if the Underscore should be rendered.
|
||||
if (WindowsLookAndFeel.isMnemonicHidden() == true) {
|
||||
mnemIndex = -1;
|
||||
}
|
||||
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null && !(b instanceof JMenuItem)) {
|
||||
paintXPText(b, g, textRect.x + textShiftOffset,
|
||||
textRect.y + fm.getAscent() + textShiftOffset,
|
||||
text, mnemIndex);
|
||||
} else {
|
||||
paintClassicText(b, g, textRect.x + textShiftOffset,
|
||||
textRect.y + fm.getAscent() + textShiftOffset,
|
||||
text, mnemIndex);
|
||||
}
|
||||
}
|
||||
|
||||
static void paintClassicText(AbstractButton b, Graphics g, int x, int y,
|
||||
String text, int mnemIndex) {
|
||||
ButtonModel model = b.getModel();
|
||||
|
||||
/* Draw the Text */
|
||||
Color color = b.getForeground();
|
||||
if(model.isEnabled()) {
|
||||
/*** paint the text normally */
|
||||
if(!(b instanceof JMenuItem && model.isArmed())
|
||||
&& !(b instanceof JMenu && (model.isSelected() || model.isRollover()))) {
|
||||
/* We shall not set foreground color for selected menu or
|
||||
* armed menuitem. Foreground must be set in appropriate
|
||||
* Windows* class because these colors passes from
|
||||
* BasicMenuItemUI as protected fields and we can't
|
||||
* reach them from this class */
|
||||
g.setColor(b.getForeground());
|
||||
}
|
||||
SwingUtilities2.drawStringUnderlineCharAt(b, g,text, mnemIndex, x, y);
|
||||
} else { /*** paint the text disabled ***/
|
||||
color = UIManager.getColor("Button.shadow");
|
||||
Color shadow = UIManager.getColor("Button.disabledShadow");
|
||||
if(model.isArmed()) {
|
||||
color = UIManager.getColor("Button.disabledForeground");
|
||||
} else {
|
||||
if (shadow == null) {
|
||||
shadow = b.getBackground().darker();
|
||||
}
|
||||
g.setColor(shadow);
|
||||
SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex,
|
||||
x + 1, y + 1);
|
||||
}
|
||||
if (color == null) {
|
||||
color = b.getBackground().brighter();
|
||||
}
|
||||
g.setColor(color);
|
||||
SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
static void paintXPText(AbstractButton b, Graphics g, int x, int y,
|
||||
String text, int mnemIndex) {
|
||||
Part part = WindowsButtonUI.getXPButtonType(b);
|
||||
State state = WindowsButtonUI.getXPButtonState(b);
|
||||
paintXPText(b, part, state, g, x, y, text, mnemIndex);
|
||||
}
|
||||
|
||||
static void paintXPText(AbstractButton b, Part part, State state,
|
||||
Graphics g, int x, int y, String text, int mnemIndex) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp == null) {
|
||||
return;
|
||||
}
|
||||
Color textColor = b.getForeground();
|
||||
|
||||
if (textColor instanceof UIResource) {
|
||||
textColor = xp.getColor(b, part, state, Prop.TEXTCOLOR, b.getForeground());
|
||||
// to work around an apparent bug in Windows, use the pushbutton
|
||||
// color for disabled toolbar buttons if the disabled color is the
|
||||
// same as the enabled color
|
||||
if (part == Part.TP_BUTTON && state == State.DISABLED) {
|
||||
Color enabledColor = xp.getColor(b, part, State.NORMAL,
|
||||
Prop.TEXTCOLOR, b.getForeground());
|
||||
if(textColor.equals(enabledColor)) {
|
||||
textColor = xp.getColor(b, Part.BP_PUSHBUTTON, state,
|
||||
Prop.TEXTCOLOR, textColor);
|
||||
}
|
||||
}
|
||||
// only draw shadow if developer hasn't changed the foreground color
|
||||
// and if the current style has text shadows.
|
||||
TypeEnum shadowType = xp.getTypeEnum(b, part,
|
||||
state, Prop.TEXTSHADOWTYPE);
|
||||
if (shadowType == TypeEnum.TST_SINGLE ||
|
||||
shadowType == TypeEnum.TST_CONTINUOUS) {
|
||||
Color shadowColor = xp.getColor(b, part, state,
|
||||
Prop.TEXTSHADOWCOLOR, Color.black);
|
||||
Point offset = xp.getPoint(b, part, state, Prop.TEXTSHADOWOFFSET);
|
||||
if (offset != null) {
|
||||
g.setColor(shadowColor);
|
||||
SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex,
|
||||
x + offset.x,
|
||||
y + offset.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
g.setColor(textColor);
|
||||
SwingUtilities2.drawStringUnderlineCharAt(b, g, text, mnemIndex, x, y);
|
||||
}
|
||||
|
||||
static boolean isLeftToRight(Component c) {
|
||||
return c.getComponentOrientation().isLeftToRight();
|
||||
}
|
||||
|
||||
/*
|
||||
* Repaints all the components with the mnemonics in the given window and
|
||||
* all its owned windows.
|
||||
*/
|
||||
static void repaintMnemonicsInWindow(Window w) {
|
||||
if(w == null || !w.isShowing()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Window[] ownedWindows = w.getOwnedWindows();
|
||||
for(int i=0;i<ownedWindows.length;i++) {
|
||||
repaintMnemonicsInWindow(ownedWindows[i]);
|
||||
}
|
||||
|
||||
repaintMnemonicsInContainer(w);
|
||||
}
|
||||
|
||||
/*
|
||||
* Repaints all the components with the mnemonics in container.
|
||||
* Recursively searches for all the subcomponents.
|
||||
*/
|
||||
static void repaintMnemonicsInContainer(Container cont) {
|
||||
Component c;
|
||||
for(int i=0; i<cont.getComponentCount(); i++) {
|
||||
c = cont.getComponent(i);
|
||||
if(c == null || !c.isVisible()) {
|
||||
continue;
|
||||
}
|
||||
if(c instanceof AbstractButton
|
||||
&& ((AbstractButton)c).getMnemonic() != '\0') {
|
||||
c.repaint();
|
||||
continue;
|
||||
} else if(c instanceof JLabel
|
||||
&& ((JLabel)c).getDisplayedMnemonic() != '\0') {
|
||||
c.repaint();
|
||||
continue;
|
||||
}
|
||||
if(c instanceof Container) {
|
||||
repaintMnemonicsInContainer((Container)c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,913 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ButtonUI;
|
||||
import javax.swing.plaf.UIResource;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.Serializable;
|
||||
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.*;
|
||||
import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
|
||||
|
||||
import sun.swing.MenuItemCheckIconFactory;
|
||||
|
||||
/**
|
||||
* Factory object that can vend Icons appropriate for the Windows L & F.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author David Kloba
|
||||
* @author Georges Saab
|
||||
* @author Rich Schiavi
|
||||
*/
|
||||
public class WindowsIconFactory implements Serializable
|
||||
{
|
||||
private static Icon frame_closeIcon;
|
||||
private static Icon frame_iconifyIcon;
|
||||
private static Icon frame_maxIcon;
|
||||
private static Icon frame_minIcon;
|
||||
private static Icon frame_resizeIcon;
|
||||
private static Icon checkBoxIcon;
|
||||
private static Icon radioButtonIcon;
|
||||
private static Icon checkBoxMenuItemIcon;
|
||||
private static Icon radioButtonMenuItemIcon;
|
||||
private static Icon menuItemCheckIcon;
|
||||
private static Icon menuItemArrowIcon;
|
||||
private static Icon menuArrowIcon;
|
||||
private static VistaMenuItemCheckIconFactory menuItemCheckIconFactory;
|
||||
|
||||
public static Icon getMenuItemCheckIcon() {
|
||||
if (menuItemCheckIcon == null) {
|
||||
menuItemCheckIcon = new MenuItemCheckIcon();
|
||||
}
|
||||
return menuItemCheckIcon;
|
||||
}
|
||||
|
||||
public static Icon getMenuItemArrowIcon() {
|
||||
if (menuItemArrowIcon == null) {
|
||||
menuItemArrowIcon = new MenuItemArrowIcon();
|
||||
}
|
||||
return menuItemArrowIcon;
|
||||
}
|
||||
|
||||
public static Icon getMenuArrowIcon() {
|
||||
if (menuArrowIcon == null) {
|
||||
menuArrowIcon = new MenuArrowIcon();
|
||||
}
|
||||
return menuArrowIcon;
|
||||
}
|
||||
|
||||
public static Icon getCheckBoxIcon() {
|
||||
if (checkBoxIcon == null) {
|
||||
checkBoxIcon = new CheckBoxIcon();
|
||||
}
|
||||
return checkBoxIcon;
|
||||
}
|
||||
|
||||
public static Icon getRadioButtonIcon() {
|
||||
if (radioButtonIcon == null) {
|
||||
radioButtonIcon = new RadioButtonIcon();
|
||||
}
|
||||
return radioButtonIcon;
|
||||
}
|
||||
|
||||
public static Icon getCheckBoxMenuItemIcon() {
|
||||
if (checkBoxMenuItemIcon == null) {
|
||||
checkBoxMenuItemIcon = new CheckBoxMenuItemIcon();
|
||||
}
|
||||
return checkBoxMenuItemIcon;
|
||||
}
|
||||
|
||||
public static Icon getRadioButtonMenuItemIcon() {
|
||||
if (radioButtonMenuItemIcon == null) {
|
||||
radioButtonMenuItemIcon = new RadioButtonMenuItemIcon();
|
||||
}
|
||||
return radioButtonMenuItemIcon;
|
||||
}
|
||||
|
||||
static
|
||||
synchronized VistaMenuItemCheckIconFactory getMenuItemCheckIconFactory() {
|
||||
if (menuItemCheckIconFactory == null) {
|
||||
menuItemCheckIconFactory =
|
||||
new VistaMenuItemCheckIconFactory();
|
||||
}
|
||||
return menuItemCheckIconFactory;
|
||||
}
|
||||
|
||||
public static Icon createFrameCloseIcon() {
|
||||
if (frame_closeIcon == null) {
|
||||
frame_closeIcon = new FrameButtonIcon(Part.WP_CLOSEBUTTON);
|
||||
}
|
||||
return frame_closeIcon;
|
||||
}
|
||||
|
||||
public static Icon createFrameIconifyIcon() {
|
||||
if (frame_iconifyIcon == null) {
|
||||
frame_iconifyIcon = new FrameButtonIcon(Part.WP_MINBUTTON);
|
||||
}
|
||||
return frame_iconifyIcon;
|
||||
}
|
||||
|
||||
public static Icon createFrameMaximizeIcon() {
|
||||
if (frame_maxIcon == null) {
|
||||
frame_maxIcon = new FrameButtonIcon(Part.WP_MAXBUTTON);
|
||||
}
|
||||
return frame_maxIcon;
|
||||
}
|
||||
|
||||
public static Icon createFrameMinimizeIcon() {
|
||||
if (frame_minIcon == null) {
|
||||
frame_minIcon = new FrameButtonIcon(Part.WP_RESTOREBUTTON);
|
||||
}
|
||||
return frame_minIcon;
|
||||
}
|
||||
|
||||
public static Icon createFrameResizeIcon() {
|
||||
if(frame_resizeIcon == null)
|
||||
frame_resizeIcon = new ResizeIcon();
|
||||
return frame_resizeIcon;
|
||||
}
|
||||
|
||||
|
||||
private static class FrameButtonIcon implements Icon, Serializable {
|
||||
private Part part;
|
||||
|
||||
private FrameButtonIcon(Part part) {
|
||||
this.part = part;
|
||||
}
|
||||
|
||||
public void paintIcon(Component c, Graphics g, int x0, int y0) {
|
||||
int width = getIconWidth();
|
||||
int height = getIconHeight();
|
||||
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
Skin skin = xp.getSkin(c, part);
|
||||
AbstractButton b = (AbstractButton)c;
|
||||
ButtonModel model = b.getModel();
|
||||
|
||||
// Find out if frame is inactive
|
||||
JInternalFrame jif = (JInternalFrame)SwingUtilities.
|
||||
getAncestorOfClass(JInternalFrame.class, b);
|
||||
boolean jifSelected = (jif != null && jif.isSelected());
|
||||
|
||||
State state;
|
||||
if (jifSelected) {
|
||||
if (!model.isEnabled()) {
|
||||
state = State.DISABLED;
|
||||
} else if (model.isArmed() && model.isPressed()) {
|
||||
state = State.PUSHED;
|
||||
} else if (model.isRollover()) {
|
||||
state = State.HOT;
|
||||
} else {
|
||||
state = State.NORMAL;
|
||||
}
|
||||
} else {
|
||||
if (!model.isEnabled()) {
|
||||
state = State.INACTIVEDISABLED;
|
||||
} else if (model.isArmed() && model.isPressed()) {
|
||||
state = State.INACTIVEPUSHED;
|
||||
} else if (model.isRollover()) {
|
||||
state = State.INACTIVEHOT;
|
||||
} else {
|
||||
state = State.INACTIVENORMAL;
|
||||
}
|
||||
}
|
||||
skin.paintSkin(g, 0, 0, width, height, state);
|
||||
} else {
|
||||
g.setColor(Color.black);
|
||||
int x = width / 12 + 2;
|
||||
int y = height / 5;
|
||||
int h = height - y * 2 - 1;
|
||||
int w = width * 3/4 -3;
|
||||
int thickness2 = Math.max(height / 8, 2);
|
||||
int thickness = Math.max(width / 15, 1);
|
||||
if (part == Part.WP_CLOSEBUTTON) {
|
||||
int lineWidth;
|
||||
if (width > 47) lineWidth = 6;
|
||||
else if (width > 37) lineWidth = 5;
|
||||
else if (width > 26) lineWidth = 4;
|
||||
else if (width > 16) lineWidth = 3;
|
||||
else if (width > 12) lineWidth = 2;
|
||||
else lineWidth = 1;
|
||||
y = height / 12 + 2;
|
||||
if (lineWidth == 1) {
|
||||
if (w % 2 == 1) { x++; w++; }
|
||||
g.drawLine(x, y, x+w-2, y+w-2);
|
||||
g.drawLine(x+w-2, y, x, y+w-2);
|
||||
} else if (lineWidth == 2) {
|
||||
if (w > 6) { x++; w--; }
|
||||
g.drawLine(x, y, x+w-2, y+w-2);
|
||||
g.drawLine(x+w-2, y, x, y+w-2);
|
||||
g.drawLine(x+1, y, x+w-1, y+w-2);
|
||||
g.drawLine(x+w-1, y, x+1, y+w-2);
|
||||
} else {
|
||||
x += 2; y++; w -= 2;
|
||||
g.drawLine(x, y, x+w-1, y+w-1);
|
||||
g.drawLine(x+w-1, y, x, y+w-1);
|
||||
g.drawLine(x+1, y, x+w-1, y+w-2);
|
||||
g.drawLine(x+w-2, y, x, y+w-2);
|
||||
g.drawLine(x, y+1, x+w-2, y+w-1);
|
||||
g.drawLine(x+w-1, y+1, x+1, y+w-1);
|
||||
for (int i = 4; i <= lineWidth; i++) {
|
||||
g.drawLine(x+i-2, y, x+w-1, y+w-i+1);
|
||||
g.drawLine(x, y+i-2, x+w-i+1, y+w-1);
|
||||
g.drawLine(x+w-i+1, y, x, y+w-i+1);
|
||||
g.drawLine(x+w-1, y+i-2, x+i-2, y+w-1);
|
||||
}
|
||||
}
|
||||
} else if (part == Part.WP_MINBUTTON) {
|
||||
g.fillRect(x, y+h-thickness2, w-w/3, thickness2);
|
||||
} else if (part == Part.WP_MAXBUTTON) {
|
||||
g.fillRect(x, y, w, thickness2);
|
||||
g.fillRect(x, y, thickness, h);
|
||||
g.fillRect(x+w-thickness, y, thickness, h);
|
||||
g.fillRect(x, y+h-thickness, w, thickness);
|
||||
} else if (part == Part.WP_RESTOREBUTTON) {
|
||||
g.fillRect(x+w/3, y, w-w/3, thickness2);
|
||||
g.fillRect(x+w/3, y, thickness, h/3);
|
||||
g.fillRect(x+w-thickness, y, thickness, h-h/3);
|
||||
g.fillRect(x+w-w/3, y+h-h/3-thickness, w/3, thickness);
|
||||
|
||||
g.fillRect(x, y+h/3, w-w/3, thickness2);
|
||||
g.fillRect(x, y+h/3, thickness, h-h/3);
|
||||
g.fillRect(x+w-w/3-thickness, y+h/3, thickness, h-h/3);
|
||||
g.fillRect(x, y+h-thickness, w-w/3, thickness);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getIconWidth() {
|
||||
int width;
|
||||
if (XPStyle.getXP() != null) {
|
||||
// Fix for XP bug where sometimes these sizes aren't updated properly
|
||||
// Assume for now that height is correct and derive width using the
|
||||
// ratio from the uxtheme part
|
||||
width = UIManager.getInt("InternalFrame.titleButtonHeight") -2;
|
||||
Dimension d = XPStyle.getPartSize(Part.WP_CLOSEBUTTON, State.NORMAL);
|
||||
if (d != null && d.width != 0 && d.height != 0) {
|
||||
width = (int) ((float) width * d.width / d.height);
|
||||
}
|
||||
} else {
|
||||
width = UIManager.getInt("InternalFrame.titleButtonWidth") -2;
|
||||
}
|
||||
if (XPStyle.getXP() != null) {
|
||||
width -= 2;
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getIconHeight() {
|
||||
int height = UIManager.getInt("InternalFrame.titleButtonHeight")-4;
|
||||
return height;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static class ResizeIcon implements Icon, Serializable {
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
g.setColor(UIManager.getColor("InternalFrame.resizeIconHighlight"));
|
||||
g.drawLine(0, 11, 11, 0);
|
||||
g.drawLine(4, 11, 11, 4);
|
||||
g.drawLine(8, 11, 11, 8);
|
||||
|
||||
g.setColor(UIManager.getColor("InternalFrame.resizeIconShadow"));
|
||||
g.drawLine(1, 11, 11, 1);
|
||||
g.drawLine(2, 11, 11, 2);
|
||||
g.drawLine(5, 11, 11, 5);
|
||||
g.drawLine(6, 11, 11, 6);
|
||||
g.drawLine(9, 11, 11, 9);
|
||||
g.drawLine(10, 11, 11, 10);
|
||||
}
|
||||
public int getIconWidth() { return 13; }
|
||||
public int getIconHeight() { return 13; }
|
||||
};
|
||||
|
||||
private static class CheckBoxIcon implements Icon, Serializable
|
||||
{
|
||||
final static int csize = 13;
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
JCheckBox cb = (JCheckBox) c;
|
||||
ButtonModel model = cb.getModel();
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
|
||||
if (xp != null) {
|
||||
State state;
|
||||
if (model.isSelected()) {
|
||||
state = State.CHECKEDNORMAL;
|
||||
if (!model.isEnabled()) {
|
||||
state = State.CHECKEDDISABLED;
|
||||
} else if (model.isPressed() && model.isArmed()) {
|
||||
state = State.CHECKEDPRESSED;
|
||||
} else if (model.isRollover()) {
|
||||
state = State.CHECKEDHOT;
|
||||
}
|
||||
} else {
|
||||
state = State.UNCHECKEDNORMAL;
|
||||
if (!model.isEnabled()) {
|
||||
state = State.UNCHECKEDDISABLED;
|
||||
} else if (model.isPressed() && model.isArmed()) {
|
||||
state = State.UNCHECKEDPRESSED;
|
||||
} else if (model.isRollover()) {
|
||||
state = State.UNCHECKEDHOT;
|
||||
}
|
||||
}
|
||||
Part part = Part.BP_CHECKBOX;
|
||||
xp.getSkin(c, part).paintSkin(g, x, y, state);
|
||||
} else {
|
||||
// outer bevel
|
||||
if(!cb.isBorderPaintedFlat()) {
|
||||
// Outer top/left
|
||||
g.setColor(UIManager.getColor("CheckBox.shadow"));
|
||||
g.drawLine(x, y, x+11, y);
|
||||
g.drawLine(x, y+1, x, y+11);
|
||||
|
||||
// Outer bottom/right
|
||||
g.setColor(UIManager.getColor("CheckBox.highlight"));
|
||||
g.drawLine(x+12, y, x+12, y+12);
|
||||
g.drawLine(x, y+12, x+11, y+12);
|
||||
|
||||
// Inner top.left
|
||||
g.setColor(UIManager.getColor("CheckBox.darkShadow"));
|
||||
g.drawLine(x+1, y+1, x+10, y+1);
|
||||
g.drawLine(x+1, y+2, x+1, y+10);
|
||||
|
||||
// Inner bottom/right
|
||||
g.setColor(UIManager.getColor("CheckBox.light"));
|
||||
g.drawLine(x+1, y+11, x+11, y+11);
|
||||
g.drawLine(x+11, y+1, x+11, y+10);
|
||||
|
||||
// inside box
|
||||
if((model.isPressed() && model.isArmed()) || !model.isEnabled()) {
|
||||
g.setColor(UIManager.getColor("CheckBox.background"));
|
||||
} else {
|
||||
g.setColor(UIManager.getColor("CheckBox.interiorBackground"));
|
||||
}
|
||||
g.fillRect(x+2, y+2, csize-4, csize-4);
|
||||
} else {
|
||||
g.setColor(UIManager.getColor("CheckBox.shadow"));
|
||||
g.drawRect(x+1, y+1, csize-3, csize-3);
|
||||
|
||||
if((model.isPressed() && model.isArmed()) || !model.isEnabled()) {
|
||||
g.setColor(UIManager.getColor("CheckBox.background"));
|
||||
} else {
|
||||
g.setColor(UIManager.getColor("CheckBox.interiorBackground"));
|
||||
}
|
||||
g.fillRect(x+2, y+2, csize-4, csize-4);
|
||||
}
|
||||
|
||||
if(model.isEnabled()) {
|
||||
g.setColor(UIManager.getColor("CheckBox.foreground"));
|
||||
} else {
|
||||
g.setColor(UIManager.getColor("CheckBox.shadow"));
|
||||
}
|
||||
|
||||
// paint check
|
||||
if (model.isSelected()) {
|
||||
g.drawLine(x+9, y+3, x+9, y+3);
|
||||
g.drawLine(x+8, y+4, x+9, y+4);
|
||||
g.drawLine(x+7, y+5, x+9, y+5);
|
||||
g.drawLine(x+6, y+6, x+8, y+6);
|
||||
g.drawLine(x+3, y+7, x+7, y+7);
|
||||
g.drawLine(x+4, y+8, x+6, y+8);
|
||||
g.drawLine(x+5, y+9, x+5, y+9);
|
||||
g.drawLine(x+3, y+5, x+3, y+5);
|
||||
g.drawLine(x+3, y+6, x+4, y+6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getIconWidth() {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
return xp.getSkin(null, Part.BP_CHECKBOX).getWidth();
|
||||
} else {
|
||||
return csize;
|
||||
}
|
||||
}
|
||||
|
||||
public int getIconHeight() {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
return xp.getSkin(null, Part.BP_CHECKBOX).getHeight();
|
||||
} else {
|
||||
return csize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class RadioButtonIcon implements Icon, UIResource, Serializable
|
||||
{
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
AbstractButton b = (AbstractButton) c;
|
||||
ButtonModel model = b.getModel();
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
|
||||
if (xp != null) {
|
||||
Part part = Part.BP_RADIOBUTTON;
|
||||
Skin skin = xp.getSkin(b, part);
|
||||
State state;
|
||||
int index = 0;
|
||||
if (model.isSelected()) {
|
||||
state = State.CHECKEDNORMAL;
|
||||
if (!model.isEnabled()) {
|
||||
state = State.CHECKEDDISABLED;
|
||||
} else if (model.isPressed() && model.isArmed()) {
|
||||
state = State.CHECKEDPRESSED;
|
||||
} else if (model.isRollover()) {
|
||||
state = State.CHECKEDHOT;
|
||||
}
|
||||
} else {
|
||||
state = State.UNCHECKEDNORMAL;
|
||||
if (!model.isEnabled()) {
|
||||
state = State.UNCHECKEDDISABLED;
|
||||
} else if (model.isPressed() && model.isArmed()) {
|
||||
state = State.UNCHECKEDPRESSED;
|
||||
} else if (model.isRollover()) {
|
||||
state = State.UNCHECKEDHOT;
|
||||
}
|
||||
}
|
||||
skin.paintSkin(g, x, y, state);
|
||||
} else {
|
||||
// fill interior
|
||||
if((model.isPressed() && model.isArmed()) || !model.isEnabled()) {
|
||||
g.setColor(UIManager.getColor("RadioButton.background"));
|
||||
} else {
|
||||
g.setColor(UIManager.getColor("RadioButton.interiorBackground"));
|
||||
}
|
||||
g.fillRect(x+2, y+2, 8, 8);
|
||||
|
||||
|
||||
// outter left arc
|
||||
g.setColor(UIManager.getColor("RadioButton.shadow"));
|
||||
g.drawLine(x+4, y+0, x+7, y+0);
|
||||
g.drawLine(x+2, y+1, x+3, y+1);
|
||||
g.drawLine(x+8, y+1, x+9, y+1);
|
||||
g.drawLine(x+1, y+2, x+1, y+3);
|
||||
g.drawLine(x+0, y+4, x+0, y+7);
|
||||
g.drawLine(x+1, y+8, x+1, y+9);
|
||||
|
||||
// outter right arc
|
||||
g.setColor(UIManager.getColor("RadioButton.highlight"));
|
||||
g.drawLine(x+2, y+10, x+3, y+10);
|
||||
g.drawLine(x+4, y+11, x+7, y+11);
|
||||
g.drawLine(x+8, y+10, x+9, y+10);
|
||||
g.drawLine(x+10, y+9, x+10, y+8);
|
||||
g.drawLine(x+11, y+7, x+11, y+4);
|
||||
g.drawLine(x+10, y+3, x+10, y+2);
|
||||
|
||||
|
||||
// inner left arc
|
||||
g.setColor(UIManager.getColor("RadioButton.darkShadow"));
|
||||
g.drawLine(x+4, y+1, x+7, y+1);
|
||||
g.drawLine(x+2, y+2, x+3, y+2);
|
||||
g.drawLine(x+8, y+2, x+9, y+2);
|
||||
g.drawLine(x+2, y+3, x+2, y+3);
|
||||
g.drawLine(x+1, y+4, x+1, y+7);
|
||||
g.drawLine(x+2, y+8, x+2, y+8);
|
||||
|
||||
|
||||
// inner right arc
|
||||
g.setColor(UIManager.getColor("RadioButton.light"));
|
||||
g.drawLine(x+2, y+9, x+3, y+9);
|
||||
g.drawLine(x+4, y+10, x+7, y+10);
|
||||
g.drawLine(x+8, y+9, x+9, y+9);
|
||||
g.drawLine(x+9, y+8, x+9, y+8);
|
||||
g.drawLine(x+10, y+7, x+10, y+4);
|
||||
g.drawLine(x+9, y+3, x+9, y+3);
|
||||
|
||||
|
||||
// indicate whether selected or not
|
||||
if (model.isSelected()) {
|
||||
if (model.isEnabled()) {
|
||||
g.setColor(UIManager.getColor("RadioButton.foreground"));
|
||||
} else {
|
||||
g.setColor(UIManager.getColor("RadioButton.shadow"));
|
||||
}
|
||||
g.fillRect(x+4, y+5, 4, 2);
|
||||
g.fillRect(x+5, y+4, 2, 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int getIconWidth() {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
return xp.getSkin(null, Part.BP_RADIOBUTTON).getWidth();
|
||||
} else {
|
||||
return 13;
|
||||
}
|
||||
}
|
||||
|
||||
public int getIconHeight() {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
return xp.getSkin(null, Part.BP_RADIOBUTTON).getHeight();
|
||||
} else {
|
||||
return 13;
|
||||
}
|
||||
}
|
||||
} // end class RadioButtonIcon
|
||||
|
||||
|
||||
private static class CheckBoxMenuItemIcon implements Icon, UIResource, Serializable
|
||||
{
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
AbstractButton b = (AbstractButton) c;
|
||||
ButtonModel model = b.getModel();
|
||||
boolean isSelected = model.isSelected();
|
||||
if (isSelected) {
|
||||
y = y - getIconHeight() / 2;
|
||||
g.drawLine(x+9, y+3, x+9, y+3);
|
||||
g.drawLine(x+8, y+4, x+9, y+4);
|
||||
g.drawLine(x+7, y+5, x+9, y+5);
|
||||
g.drawLine(x+6, y+6, x+8, y+6);
|
||||
g.drawLine(x+3, y+7, x+7, y+7);
|
||||
g.drawLine(x+4, y+8, x+6, y+8);
|
||||
g.drawLine(x+5, y+9, x+5, y+9);
|
||||
g.drawLine(x+3, y+5, x+3, y+5);
|
||||
g.drawLine(x+3, y+6, x+4, y+6);
|
||||
}
|
||||
}
|
||||
public int getIconWidth() { return 9; }
|
||||
public int getIconHeight() { return 9; }
|
||||
|
||||
} // End class CheckBoxMenuItemIcon
|
||||
|
||||
|
||||
private static class RadioButtonMenuItemIcon implements Icon, UIResource, Serializable
|
||||
{
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
AbstractButton b = (AbstractButton) c;
|
||||
ButtonModel model = b.getModel();
|
||||
if (b.isSelected() == true) {
|
||||
g.fillRoundRect(x+3,y+3, getIconWidth()-6, getIconHeight()-6,
|
||||
4, 4);
|
||||
}
|
||||
}
|
||||
public int getIconWidth() { return 12; }
|
||||
public int getIconHeight() { return 12; }
|
||||
|
||||
} // End class RadioButtonMenuItemIcon
|
||||
|
||||
|
||||
private static class MenuItemCheckIcon implements Icon, UIResource, Serializable{
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
/* For debugging:
|
||||
Color oldColor = g.getColor();
|
||||
g.setColor(Color.orange);
|
||||
g.fill3DRect(x,y,getIconWidth(), getIconHeight(), true);
|
||||
g.setColor(oldColor);
|
||||
*/
|
||||
}
|
||||
public int getIconWidth() { return 9; }
|
||||
public int getIconHeight() { return 9; }
|
||||
|
||||
} // End class MenuItemCheckIcon
|
||||
|
||||
private static class MenuItemArrowIcon implements Icon, UIResource, Serializable {
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
/* For debugging:
|
||||
Color oldColor = g.getColor();
|
||||
g.setColor(Color.green);
|
||||
g.fill3DRect(x,y,getIconWidth(), getIconHeight(), true);
|
||||
g.setColor(oldColor);
|
||||
*/
|
||||
}
|
||||
public int getIconWidth() { return 4; }
|
||||
public int getIconHeight() { return 8; }
|
||||
|
||||
} // End class MenuItemArrowIcon
|
||||
|
||||
private static class MenuArrowIcon implements Icon, UIResource, Serializable {
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (WindowsMenuItemUI.isVistaPainting(xp)) {
|
||||
State state = State.NORMAL;
|
||||
if (c instanceof JMenuItem) {
|
||||
state = ((JMenuItem) c).getModel().isEnabled()
|
||||
? State.NORMAL : State.DISABLED;
|
||||
}
|
||||
Skin skin = xp.getSkin(c, Part.MP_POPUPSUBMENU);
|
||||
if (WindowsGraphicsUtils.isLeftToRight(c)) {
|
||||
skin.paintSkin(g, x, y, state);
|
||||
} else {
|
||||
Graphics2D g2d = (Graphics2D)g.create();
|
||||
g2d.translate(x + skin.getWidth(), y);
|
||||
g2d.scale(-1, 1);
|
||||
skin.paintSkin(g2d, 0, 0, state);
|
||||
g2d.dispose();
|
||||
}
|
||||
} else {
|
||||
g.translate(x,y);
|
||||
if( WindowsGraphicsUtils.isLeftToRight(c) ) {
|
||||
g.drawLine( 0, 0, 0, 7 );
|
||||
g.drawLine( 1, 1, 1, 6 );
|
||||
g.drawLine( 2, 2, 2, 5 );
|
||||
g.drawLine( 3, 3, 3, 4 );
|
||||
} else {
|
||||
g.drawLine( 4, 0, 4, 7 );
|
||||
g.drawLine( 3, 1, 3, 6 );
|
||||
g.drawLine( 2, 2, 2, 5 );
|
||||
g.drawLine( 1, 3, 1, 4 );
|
||||
}
|
||||
g.translate(-x,-y);
|
||||
}
|
||||
}
|
||||
public int getIconWidth() {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (WindowsMenuItemUI.isVistaPainting(xp)) {
|
||||
Skin skin = xp.getSkin(null, Part.MP_POPUPSUBMENU);
|
||||
return skin.getWidth();
|
||||
} else {
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
public int getIconHeight() {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (WindowsMenuItemUI.isVistaPainting(xp)) {
|
||||
Skin skin = xp.getSkin(null, Part.MP_POPUPSUBMENU);
|
||||
return skin.getHeight();
|
||||
} else {
|
||||
return 8;
|
||||
}
|
||||
}
|
||||
} // End class MenuArrowIcon
|
||||
|
||||
static class VistaMenuItemCheckIconFactory
|
||||
implements MenuItemCheckIconFactory {
|
||||
private static final int OFFSET = 3;
|
||||
|
||||
public Icon getIcon(JMenuItem component) {
|
||||
return new VistaMenuItemCheckIcon(component);
|
||||
}
|
||||
|
||||
public boolean isCompatible(Object icon, String prefix) {
|
||||
return icon instanceof VistaMenuItemCheckIcon
|
||||
&& ((VistaMenuItemCheckIcon) icon).type == getType(prefix);
|
||||
}
|
||||
|
||||
public Icon getIcon(String type) {
|
||||
return new VistaMenuItemCheckIcon(type);
|
||||
}
|
||||
|
||||
static int getIconWidth() {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
return ((xp != null) ? xp.getSkin(null, Part.MP_POPUPCHECK).getWidth() : 16)
|
||||
+ 2 * OFFSET;
|
||||
}
|
||||
|
||||
private static Class<? extends JMenuItem> getType(Component c) {
|
||||
Class<? extends JMenuItem> rv = null;
|
||||
if (c instanceof JCheckBoxMenuItem) {
|
||||
rv = JCheckBoxMenuItem.class;
|
||||
} else if (c instanceof JRadioButtonMenuItem) {
|
||||
rv = JRadioButtonMenuItem.class;
|
||||
} else if (c instanceof JMenu) {
|
||||
rv = JMenu.class;
|
||||
} else if (c instanceof JMenuItem) {
|
||||
rv = JMenuItem.class;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
private static Class<? extends JMenuItem> getType(String type) {
|
||||
Class<? extends JMenuItem> rv = null;
|
||||
if (type == "CheckBoxMenuItem") {
|
||||
rv = JCheckBoxMenuItem.class;
|
||||
} else if (type == "RadioButtonMenuItem") {
|
||||
rv = JRadioButtonMenuItem.class;
|
||||
} else if (type == "Menu") {
|
||||
rv = JMenu.class;
|
||||
} else if (type == "MenuItem") {
|
||||
rv = JMenuItem.class;
|
||||
} else {
|
||||
// this should never happen
|
||||
rv = JMenuItem.class;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* CheckIcon for JMenuItem, JMenu, JCheckBoxMenuItem and
|
||||
* JRadioButtonMenuItem.
|
||||
* Note: to be used on Vista only.
|
||||
*/
|
||||
private static class VistaMenuItemCheckIcon
|
||||
implements Icon, UIResource, Serializable {
|
||||
|
||||
private final JMenuItem menuItem;
|
||||
private final Class<? extends JMenuItem> type;
|
||||
|
||||
VistaMenuItemCheckIcon(JMenuItem menuItem) {
|
||||
this.type = getType(menuItem);
|
||||
this.menuItem = menuItem;
|
||||
}
|
||||
VistaMenuItemCheckIcon(String type) {
|
||||
this.type = getType(type);
|
||||
this.menuItem = null;
|
||||
}
|
||||
|
||||
public int getIconHeight() {
|
||||
Icon lafIcon = getLaFIcon();
|
||||
if (lafIcon != null) {
|
||||
return lafIcon.getIconHeight();
|
||||
}
|
||||
Icon icon = getIcon();
|
||||
int height = 0;
|
||||
if (icon != null) {
|
||||
height = icon.getIconHeight();
|
||||
} else {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
Skin skin = xp.getSkin(null, Part.MP_POPUPCHECK);
|
||||
height = skin.getHeight();
|
||||
} else {
|
||||
height = 16;
|
||||
}
|
||||
}
|
||||
height += 2 * OFFSET;
|
||||
return height;
|
||||
}
|
||||
|
||||
public int getIconWidth() {
|
||||
Icon lafIcon = getLaFIcon();
|
||||
if (lafIcon != null) {
|
||||
return lafIcon.getIconWidth();
|
||||
}
|
||||
Icon icon = getIcon();
|
||||
int width = 0;
|
||||
if (icon != null) {
|
||||
width = icon.getIconWidth() + 2 * OFFSET;
|
||||
} else {
|
||||
width = VistaMenuItemCheckIconFactory.getIconWidth();
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
Icon lafIcon = getLaFIcon();
|
||||
if (lafIcon != null) {
|
||||
lafIcon.paintIcon(c, g, x, y);
|
||||
return;
|
||||
}
|
||||
assert menuItem == null || c == menuItem;
|
||||
Icon icon = getIcon();
|
||||
if (type == JCheckBoxMenuItem.class
|
||||
|| type == JRadioButtonMenuItem.class) {
|
||||
AbstractButton b = (AbstractButton) c;
|
||||
if (b.isSelected()) {
|
||||
Part backgroundPart = Part.MP_POPUPCHECKBACKGROUND;
|
||||
Part part = Part.MP_POPUPCHECK;
|
||||
State backgroundState;
|
||||
State state;
|
||||
if (isEnabled(c, null)) {
|
||||
backgroundState =
|
||||
(icon != null) ? State.BITMAP : State.NORMAL;
|
||||
state = (type == JRadioButtonMenuItem.class)
|
||||
? State.BULLETNORMAL
|
||||
: State.CHECKMARKNORMAL;
|
||||
} else {
|
||||
backgroundState = State.DISABLEDPUSHED;
|
||||
state =
|
||||
(type == JRadioButtonMenuItem.class)
|
||||
? State.BULLETDISABLED
|
||||
: State.CHECKMARKDISABLED;
|
||||
}
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
Skin skin;
|
||||
skin = xp.getSkin(c, backgroundPart);
|
||||
skin.paintSkin(g, x, y,
|
||||
getIconWidth(), getIconHeight(), backgroundState);
|
||||
if (icon == null) {
|
||||
skin = xp.getSkin(c, part);
|
||||
skin.paintSkin(g, x + OFFSET, y + OFFSET, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (icon != null) {
|
||||
icon.paintIcon(c, g, x + OFFSET, y + OFFSET);
|
||||
}
|
||||
}
|
||||
private static WindowsMenuItemUIAccessor getAccessor(
|
||||
JMenuItem menuItem) {
|
||||
WindowsMenuItemUIAccessor rv = null;
|
||||
ButtonUI uiObject = (menuItem != null) ? menuItem.getUI()
|
||||
: null;
|
||||
if (uiObject instanceof WindowsMenuItemUI) {
|
||||
rv = ((WindowsMenuItemUI) uiObject).accessor;
|
||||
} else if (uiObject instanceof WindowsMenuUI) {
|
||||
rv = ((WindowsMenuUI) uiObject).accessor;
|
||||
} else if (uiObject instanceof WindowsCheckBoxMenuItemUI) {
|
||||
rv = ((WindowsCheckBoxMenuItemUI) uiObject).accessor;
|
||||
} else if (uiObject instanceof WindowsRadioButtonMenuItemUI) {
|
||||
rv = ((WindowsRadioButtonMenuItemUI) uiObject).accessor;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
private static boolean isEnabled(Component c, State state) {
|
||||
if (state == null && c instanceof JMenuItem) {
|
||||
WindowsMenuItemUIAccessor accessor =
|
||||
getAccessor((JMenuItem) c);
|
||||
if (accessor != null) {
|
||||
state = accessor.getState((JMenuItem) c);
|
||||
}
|
||||
}
|
||||
if (state == null) {
|
||||
if (c != null) {
|
||||
return c.isEnabled();
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return (state != State.DISABLED)
|
||||
&& (state != State.DISABLEDHOT)
|
||||
&& (state != State.DISABLEDPUSHED);
|
||||
}
|
||||
}
|
||||
private Icon getIcon() {
|
||||
Icon rv = null;
|
||||
if (menuItem == null) {
|
||||
return rv;
|
||||
}
|
||||
WindowsMenuItemUIAccessor accessor =
|
||||
getAccessor(menuItem);
|
||||
State state = (accessor != null) ? accessor.getState(menuItem)
|
||||
: null;
|
||||
if (isEnabled(menuItem, null)) {
|
||||
if (state == State.PUSHED) {
|
||||
rv = menuItem.getPressedIcon();
|
||||
} else {
|
||||
rv = menuItem.getIcon();
|
||||
}
|
||||
} else {
|
||||
rv = menuItem.getDisabledIcon();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
/**
|
||||
* Check if developer changed icon in the UI table.
|
||||
*
|
||||
* @return the icon to use or {@code null} if the current one is to
|
||||
* be used
|
||||
*/
|
||||
private Icon getLaFIcon() {
|
||||
// use icon from the UI table if it does not match this one.
|
||||
Icon rv = (Icon) UIManager.getDefaults().get(typeToString(type));
|
||||
if (rv instanceof VistaMenuItemCheckIcon
|
||||
&& ((VistaMenuItemCheckIcon) rv).type == type) {
|
||||
rv = null;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
private static String typeToString(
|
||||
Class<? extends JMenuItem> type) {
|
||||
assert type == JMenuItem.class
|
||||
|| type == JMenu.class
|
||||
|| type == JCheckBoxMenuItem.class
|
||||
|| type == JRadioButtonMenuItem.class;
|
||||
StringBuilder sb = new StringBuilder(type.getName());
|
||||
// remove package name, dot and the first character
|
||||
sb.delete(0, sb.lastIndexOf("J") + 1);
|
||||
sb.append(".checkIcon");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
} // End class VistaMenuItemCheckIconFactory
|
||||
}
|
||||
@@ -0,0 +1,569 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2014, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import sun.swing.SwingUtilities2;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
import java.beans.PropertyVetoException;
|
||||
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.*;
|
||||
import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
|
||||
|
||||
public class WindowsInternalFrameTitlePane extends BasicInternalFrameTitlePane {
|
||||
private Color selectedTitleGradientColor;
|
||||
private Color notSelectedTitleGradientColor;
|
||||
private JPopupMenu systemPopupMenu;
|
||||
private JLabel systemLabel;
|
||||
|
||||
private Font titleFont;
|
||||
private int titlePaneHeight;
|
||||
private int buttonWidth, buttonHeight;
|
||||
private boolean hotTrackingOn;
|
||||
|
||||
public WindowsInternalFrameTitlePane(JInternalFrame f) {
|
||||
super(f);
|
||||
}
|
||||
|
||||
protected void addSubComponents() {
|
||||
add(systemLabel);
|
||||
add(iconButton);
|
||||
add(maxButton);
|
||||
add(closeButton);
|
||||
}
|
||||
|
||||
protected void installDefaults() {
|
||||
super.installDefaults();
|
||||
|
||||
titlePaneHeight = UIManager.getInt("InternalFrame.titlePaneHeight");
|
||||
buttonWidth = UIManager.getInt("InternalFrame.titleButtonWidth") - 4;
|
||||
buttonHeight = UIManager.getInt("InternalFrame.titleButtonHeight") - 4;
|
||||
|
||||
Object obj = UIManager.get("InternalFrame.titleButtonToolTipsOn");
|
||||
hotTrackingOn = (obj instanceof Boolean) ? (Boolean)obj : true;
|
||||
|
||||
|
||||
if (XPStyle.getXP() != null) {
|
||||
// Fix for XP bug where sometimes these sizes aren't updated properly
|
||||
// Assume for now that height is correct and derive width using the
|
||||
// ratio from the uxtheme part
|
||||
buttonWidth = buttonHeight;
|
||||
Dimension d = XPStyle.getPartSize(Part.WP_CLOSEBUTTON, State.NORMAL);
|
||||
if (d != null && d.width != 0 && d.height != 0) {
|
||||
buttonWidth = (int) ((float) buttonWidth * d.width / d.height);
|
||||
}
|
||||
} else {
|
||||
buttonWidth += 2;
|
||||
Color activeBorderColor =
|
||||
UIManager.getColor("InternalFrame.activeBorderColor");
|
||||
setBorder(BorderFactory.createLineBorder(activeBorderColor, 1));
|
||||
}
|
||||
// JDK-8039383: initialize these colors because getXP() may return null when theme is changed
|
||||
selectedTitleGradientColor =
|
||||
UIManager.getColor("InternalFrame.activeTitleGradient");
|
||||
notSelectedTitleGradientColor =
|
||||
UIManager.getColor("InternalFrame.inactiveTitleGradient");
|
||||
}
|
||||
|
||||
protected void uninstallListeners() {
|
||||
// Get around protected method in superclass
|
||||
super.uninstallListeners();
|
||||
}
|
||||
|
||||
protected void createButtons() {
|
||||
super.createButtons();
|
||||
if (XPStyle.getXP() != null) {
|
||||
iconButton.setContentAreaFilled(false);
|
||||
maxButton.setContentAreaFilled(false);
|
||||
closeButton.setContentAreaFilled(false);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setButtonIcons() {
|
||||
super.setButtonIcons();
|
||||
|
||||
if (!hotTrackingOn) {
|
||||
iconButton.setToolTipText(null);
|
||||
maxButton.setToolTipText(null);
|
||||
closeButton.setToolTipText(null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void paintComponent(Graphics g) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
|
||||
paintTitleBackground(g);
|
||||
|
||||
String title = frame.getTitle();
|
||||
if (title != null) {
|
||||
boolean isSelected = frame.isSelected();
|
||||
Font oldFont = g.getFont();
|
||||
Font newFont = (titleFont != null) ? titleFont : getFont();
|
||||
g.setFont(newFont);
|
||||
|
||||
// Center text vertically.
|
||||
FontMetrics fm = SwingUtilities2.getFontMetrics(frame, g, newFont);
|
||||
int baseline = (getHeight() + fm.getAscent() - fm.getLeading() -
|
||||
fm.getDescent()) / 2;
|
||||
|
||||
Rectangle lastIconBounds = new Rectangle(0, 0, 0, 0);
|
||||
if (frame.isIconifiable()) {
|
||||
lastIconBounds = iconButton.getBounds();
|
||||
} else if (frame.isMaximizable()) {
|
||||
lastIconBounds = maxButton.getBounds();
|
||||
} else if (frame.isClosable()) {
|
||||
lastIconBounds = closeButton.getBounds();
|
||||
}
|
||||
|
||||
int titleX;
|
||||
int titleW;
|
||||
int gap = 2;
|
||||
if (WindowsGraphicsUtils.isLeftToRight(frame)) {
|
||||
if (lastIconBounds.x == 0) { // There are no icons
|
||||
lastIconBounds.x = frame.getWidth() - frame.getInsets().right;
|
||||
}
|
||||
titleX = systemLabel.getX() + systemLabel.getWidth() + gap;
|
||||
if (xp != null) {
|
||||
titleX += 2;
|
||||
}
|
||||
titleW = lastIconBounds.x - titleX - gap;
|
||||
} else {
|
||||
if (lastIconBounds.x == 0) { // There are no icons
|
||||
lastIconBounds.x = frame.getInsets().left;
|
||||
}
|
||||
titleW = SwingUtilities2.stringWidth(frame, fm, title);
|
||||
int minTitleX = lastIconBounds.x + lastIconBounds.width + gap;
|
||||
if (xp != null) {
|
||||
minTitleX += 2;
|
||||
}
|
||||
int availableWidth = systemLabel.getX() - gap - minTitleX;
|
||||
if (availableWidth > titleW) {
|
||||
titleX = systemLabel.getX() - gap - titleW;
|
||||
} else {
|
||||
titleX = minTitleX;
|
||||
titleW = availableWidth;
|
||||
}
|
||||
}
|
||||
title = getTitle(frame.getTitle(), fm, titleW);
|
||||
|
||||
if (xp != null) {
|
||||
String shadowType = null;
|
||||
if (isSelected) {
|
||||
shadowType = xp.getString(this, Part.WP_CAPTION,
|
||||
State.ACTIVE, Prop.TEXTSHADOWTYPE);
|
||||
}
|
||||
if ("single".equalsIgnoreCase(shadowType)) {
|
||||
Point shadowOffset = xp.getPoint(this, Part.WP_WINDOW, State.ACTIVE,
|
||||
Prop.TEXTSHADOWOFFSET);
|
||||
Color shadowColor = xp.getColor(this, Part.WP_WINDOW, State.ACTIVE,
|
||||
Prop.TEXTSHADOWCOLOR, null);
|
||||
if (shadowOffset != null && shadowColor != null) {
|
||||
g.setColor(shadowColor);
|
||||
SwingUtilities2.drawString(frame, g, title,
|
||||
titleX + shadowOffset.x,
|
||||
baseline + shadowOffset.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
g.setColor(isSelected ? selectedTextColor : notSelectedTextColor);
|
||||
SwingUtilities2.drawString(frame, g, title, titleX, baseline);
|
||||
g.setFont(oldFont);
|
||||
}
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
return getMinimumSize();
|
||||
}
|
||||
|
||||
public Dimension getMinimumSize() {
|
||||
Dimension d = new Dimension(super.getMinimumSize());
|
||||
d.height = titlePaneHeight + 2;
|
||||
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
// Note: Don't know how to calculate height on XP,
|
||||
// the captionbarheight is 25 but native caption is 30 (maximized 26)
|
||||
if (frame.isMaximum()) {
|
||||
d.height -= 1;
|
||||
} else {
|
||||
d.height += 3;
|
||||
}
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
protected void paintTitleBackground(Graphics g) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
Part part = frame.isIcon() ? Part.WP_MINCAPTION
|
||||
: (frame.isMaximum() ? Part.WP_MAXCAPTION
|
||||
: Part.WP_CAPTION);
|
||||
State state = frame.isSelected() ? State.ACTIVE : State.INACTIVE;
|
||||
Skin skin = xp.getSkin(this, part);
|
||||
skin.paintSkin(g, 0, 0, getWidth(), getHeight(), state);
|
||||
} else {
|
||||
Boolean gradientsOn = (Boolean)LookAndFeel.getDesktopPropertyValue(
|
||||
"win.frame.captionGradientsOn", Boolean.valueOf(false));
|
||||
if (gradientsOn.booleanValue() && g instanceof Graphics2D) {
|
||||
Graphics2D g2 = (Graphics2D)g;
|
||||
Paint savePaint = g2.getPaint();
|
||||
|
||||
boolean isSelected = frame.isSelected();
|
||||
int w = getWidth();
|
||||
|
||||
if (isSelected) {
|
||||
GradientPaint titleGradient = new GradientPaint(0,0,
|
||||
selectedTitleColor,
|
||||
(int)(w*.75),0,
|
||||
selectedTitleGradientColor);
|
||||
g2.setPaint(titleGradient);
|
||||
} else {
|
||||
GradientPaint titleGradient = new GradientPaint(0,0,
|
||||
notSelectedTitleColor,
|
||||
(int)(w*.75),0,
|
||||
notSelectedTitleGradientColor);
|
||||
g2.setPaint(titleGradient);
|
||||
}
|
||||
g2.fillRect(0, 0, getWidth(), getHeight());
|
||||
g2.setPaint(savePaint);
|
||||
} else {
|
||||
super.paintTitleBackground(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void assembleSystemMenu() {
|
||||
systemPopupMenu = new JPopupMenu();
|
||||
addSystemMenuItems(systemPopupMenu);
|
||||
enableActions();
|
||||
systemLabel = new JLabel(frame.getFrameIcon()) {
|
||||
protected void paintComponent(Graphics g) {
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int w = getWidth();
|
||||
int h = getHeight();
|
||||
g = g.create(); // Create scratch graphics
|
||||
if (isOpaque()) {
|
||||
g.setColor(getBackground());
|
||||
g.fillRect(0, 0, w, h);
|
||||
}
|
||||
Icon icon = getIcon();
|
||||
int iconWidth;
|
||||
int iconHeight;
|
||||
if (icon != null &&
|
||||
(iconWidth = icon.getIconWidth()) > 0 &&
|
||||
(iconHeight = icon.getIconHeight()) > 0) {
|
||||
|
||||
// Set drawing scale to make icon scale to our desired size
|
||||
double drawScale;
|
||||
if (iconWidth > iconHeight) {
|
||||
// Center icon vertically
|
||||
y = (h - w*iconHeight/iconWidth) / 2;
|
||||
drawScale = w / (double)iconWidth;
|
||||
} else {
|
||||
// Center icon horizontally
|
||||
x = (w - h*iconWidth/iconHeight) / 2;
|
||||
drawScale = h / (double)iconHeight;
|
||||
}
|
||||
((Graphics2D)g).translate(x, y);
|
||||
((Graphics2D)g).scale(drawScale, drawScale);
|
||||
icon.paintIcon(this, g, 0, 0);
|
||||
}
|
||||
g.dispose();
|
||||
}
|
||||
};
|
||||
systemLabel.addMouseListener(new MouseAdapter() {
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.getClickCount() == 2 && frame.isClosable() &&
|
||||
!frame.isIcon()) {
|
||||
systemPopupMenu.setVisible(false);
|
||||
frame.doDefaultCloseAction();
|
||||
}
|
||||
else {
|
||||
super.mouseClicked(e);
|
||||
}
|
||||
}
|
||||
public void mousePressed(MouseEvent e) {
|
||||
try {
|
||||
frame.setSelected(true);
|
||||
} catch(PropertyVetoException pve) {
|
||||
}
|
||||
showSystemPopupMenu(e.getComponent());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void addSystemMenuItems(JPopupMenu menu) {
|
||||
JMenuItem mi = menu.add(restoreAction);
|
||||
mi.setMnemonic(getButtonMnemonic("restore"));
|
||||
mi = menu.add(moveAction);
|
||||
mi.setMnemonic(getButtonMnemonic("move"));
|
||||
mi = menu.add(sizeAction);
|
||||
mi.setMnemonic(getButtonMnemonic("size"));
|
||||
mi = menu.add(iconifyAction);
|
||||
mi.setMnemonic(getButtonMnemonic("minimize"));
|
||||
mi = menu.add(maximizeAction);
|
||||
mi.setMnemonic(getButtonMnemonic("maximize"));
|
||||
menu.add(new JSeparator());
|
||||
mi = menu.add(closeAction);
|
||||
mi.setMnemonic(getButtonMnemonic("close"));
|
||||
}
|
||||
|
||||
private static int getButtonMnemonic(String button) {
|
||||
try {
|
||||
return Integer.parseInt(UIManager.getString(
|
||||
"InternalFrameTitlePane." + button + "Button.mnemonic"));
|
||||
} catch (NumberFormatException e) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
protected void showSystemMenu(){
|
||||
showSystemPopupMenu(systemLabel);
|
||||
}
|
||||
|
||||
private void showSystemPopupMenu(Component invoker){
|
||||
Dimension dim = new Dimension();
|
||||
Border border = frame.getBorder();
|
||||
if (border != null) {
|
||||
dim.width += border.getBorderInsets(frame).left +
|
||||
border.getBorderInsets(frame).right;
|
||||
dim.height += border.getBorderInsets(frame).bottom +
|
||||
border.getBorderInsets(frame).top;
|
||||
}
|
||||
if (!frame.isIcon()) {
|
||||
systemPopupMenu.show(invoker,
|
||||
getX() - dim.width,
|
||||
getY() + getHeight() - dim.height);
|
||||
} else {
|
||||
systemPopupMenu.show(invoker,
|
||||
getX() - dim.width,
|
||||
getY() - systemPopupMenu.getPreferredSize().height -
|
||||
dim.height);
|
||||
}
|
||||
}
|
||||
|
||||
protected PropertyChangeListener createPropertyChangeListener() {
|
||||
return new WindowsPropertyChangeHandler();
|
||||
}
|
||||
|
||||
protected LayoutManager createLayout() {
|
||||
return new WindowsTitlePaneLayout();
|
||||
}
|
||||
|
||||
public class WindowsTitlePaneLayout extends BasicInternalFrameTitlePane.TitlePaneLayout {
|
||||
private Insets captionMargin = null;
|
||||
private Insets contentMargin = null;
|
||||
private XPStyle xp = XPStyle.getXP();
|
||||
|
||||
WindowsTitlePaneLayout() {
|
||||
if (xp != null) {
|
||||
Component c = WindowsInternalFrameTitlePane.this;
|
||||
captionMargin = xp.getMargin(c, Part.WP_CAPTION, null, Prop.CAPTIONMARGINS);
|
||||
contentMargin = xp.getMargin(c, Part.WP_CAPTION, null, Prop.CONTENTMARGINS);
|
||||
}
|
||||
if (captionMargin == null) {
|
||||
captionMargin = new Insets(0, 2, 0, 2);
|
||||
}
|
||||
if (contentMargin == null) {
|
||||
contentMargin = new Insets(0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private int layoutButton(JComponent button, Part part,
|
||||
int x, int y, int w, int h, int gap,
|
||||
boolean leftToRight) {
|
||||
if (!leftToRight) {
|
||||
x -= w;
|
||||
}
|
||||
button.setBounds(x, y, w, h);
|
||||
if (leftToRight) {
|
||||
x += w + 2;
|
||||
} else {
|
||||
x -= 2;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
public void layoutContainer(Container c) {
|
||||
boolean leftToRight = WindowsGraphicsUtils.isLeftToRight(frame);
|
||||
int x, y;
|
||||
int w = getWidth();
|
||||
int h = getHeight();
|
||||
|
||||
// System button
|
||||
// Note: this icon is square, but the buttons aren't always.
|
||||
int iconSize = (xp != null) ? (h-2)*6/10 : h-4;
|
||||
if (xp != null) {
|
||||
x = (leftToRight) ? captionMargin.left + 2 : w - captionMargin.right - 2;
|
||||
} else {
|
||||
x = (leftToRight) ? captionMargin.left : w - captionMargin.right;
|
||||
}
|
||||
y = (h - iconSize) / 2;
|
||||
layoutButton(systemLabel, Part.WP_SYSBUTTON,
|
||||
x, y, iconSize, iconSize, 0,
|
||||
leftToRight);
|
||||
|
||||
// Right hand buttons
|
||||
if (xp != null) {
|
||||
x = (leftToRight) ? w - captionMargin.right - 2 : captionMargin.left + 2;
|
||||
y = 1; // XP seems to ignore margins and offset here
|
||||
if (frame.isMaximum()) {
|
||||
y += 1;
|
||||
} else {
|
||||
y += 5;
|
||||
}
|
||||
} else {
|
||||
x = (leftToRight) ? w - captionMargin.right : captionMargin.left;
|
||||
y = (h - buttonHeight) / 2;
|
||||
}
|
||||
|
||||
if(frame.isClosable()) {
|
||||
x = layoutButton(closeButton, Part.WP_CLOSEBUTTON,
|
||||
x, y, buttonWidth, buttonHeight, 2,
|
||||
!leftToRight);
|
||||
}
|
||||
|
||||
if(frame.isMaximizable()) {
|
||||
x = layoutButton(maxButton, Part.WP_MAXBUTTON,
|
||||
x, y, buttonWidth, buttonHeight, (xp != null) ? 2 : 0,
|
||||
!leftToRight);
|
||||
}
|
||||
|
||||
if(frame.isIconifiable()) {
|
||||
layoutButton(iconButton, Part.WP_MINBUTTON,
|
||||
x, y, buttonWidth, buttonHeight, 0,
|
||||
!leftToRight);
|
||||
}
|
||||
}
|
||||
} // end WindowsTitlePaneLayout
|
||||
|
||||
public class WindowsPropertyChangeHandler extends PropertyChangeHandler {
|
||||
public void propertyChange(PropertyChangeEvent evt) {
|
||||
String prop = evt.getPropertyName();
|
||||
|
||||
// Update the internal frame icon for the system menu.
|
||||
if (JInternalFrame.FRAME_ICON_PROPERTY.equals(prop) &&
|
||||
systemLabel != null) {
|
||||
systemLabel.setIcon(frame.getFrameIcon());
|
||||
}
|
||||
|
||||
super.propertyChange(evt);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A versatile Icon implementation which can take an array of Icon
|
||||
* instances (typically <code>ImageIcon</code>s) and choose one that gives the best
|
||||
* quality for a given Graphics2D scale factor when painting.
|
||||
* <p>
|
||||
* The class is public so it can be instantiated by UIDefaults.ProxyLazyValue.
|
||||
* <p>
|
||||
* Note: We assume here that icons are square.
|
||||
*/
|
||||
public static class ScalableIconUIResource implements Icon, UIResource {
|
||||
// We can use an arbitrary size here because we scale to it in paintIcon()
|
||||
private static final int SIZE = 16;
|
||||
|
||||
private Icon[] icons;
|
||||
|
||||
/**
|
||||
* @params objects an array of Icon or UIDefaults.LazyValue
|
||||
* <p>
|
||||
* The constructor is public so it can be called by UIDefaults.ProxyLazyValue.
|
||||
*/
|
||||
public ScalableIconUIResource(Object[] objects) {
|
||||
this.icons = new Icon[objects.length];
|
||||
|
||||
for (int i = 0; i < objects.length; i++) {
|
||||
if (objects[i] instanceof UIDefaults.LazyValue) {
|
||||
icons[i] = (Icon)((UIDefaults.LazyValue)objects[i]).createValue(null);
|
||||
} else {
|
||||
icons[i] = (Icon)objects[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the <code>Icon</code> closest to the requested size
|
||||
*/
|
||||
protected Icon getBestIcon(int size) {
|
||||
if (icons != null && icons.length > 0) {
|
||||
int bestIndex = 0;
|
||||
int minDiff = Integer.MAX_VALUE;
|
||||
for (int i=0; i < icons.length; i++) {
|
||||
Icon icon = icons[i];
|
||||
int iconSize;
|
||||
if (icon != null && (iconSize = icon.getIconWidth()) > 0) {
|
||||
int diff = Math.abs(iconSize - size);
|
||||
if (diff < minDiff) {
|
||||
minDiff = diff;
|
||||
bestIndex = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return icons[bestIndex];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
Graphics2D g2d = (Graphics2D)g.create();
|
||||
// Calculate how big our drawing area is in pixels
|
||||
// Assume we are square
|
||||
int size = getIconWidth();
|
||||
double scale = g2d.getTransform().getScaleX();
|
||||
Icon icon = getBestIcon((int)(size * scale));
|
||||
int iconSize;
|
||||
if (icon != null && (iconSize = icon.getIconWidth()) > 0) {
|
||||
// Set drawing scale to make icon act true to our reported size
|
||||
double drawScale = size / (double)iconSize;
|
||||
g2d.translate(x, y);
|
||||
g2d.scale(drawScale, drawScale);
|
||||
icon.paintIcon(c, g2d, 0, 0);
|
||||
}
|
||||
g2d.dispose();
|
||||
}
|
||||
|
||||
public int getIconWidth() {
|
||||
return SIZE;
|
||||
}
|
||||
|
||||
public int getIconHeight() {
|
||||
return SIZE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2005, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.beans.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.*;
|
||||
import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
|
||||
|
||||
/**
|
||||
* Windows rendition of the component.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public class WindowsInternalFrameUI extends BasicInternalFrameUI
|
||||
{
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
|
||||
public void installDefaults() {
|
||||
super.installDefaults();
|
||||
|
||||
if (xp != null) {
|
||||
frame.setBorder(new XPBorder());
|
||||
} else {
|
||||
frame.setBorder(UIManager.getBorder("InternalFrame.border"));
|
||||
}
|
||||
}
|
||||
|
||||
public void installUI(JComponent c) {
|
||||
super.installUI(c);
|
||||
|
||||
LookAndFeel.installProperty(c, "opaque",
|
||||
xp == null? Boolean.TRUE : Boolean.FALSE);
|
||||
}
|
||||
|
||||
public void uninstallDefaults() {
|
||||
frame.setBorder(null);
|
||||
super.uninstallDefaults();
|
||||
}
|
||||
|
||||
public static ComponentUI createUI(JComponent b) {
|
||||
return new WindowsInternalFrameUI((JInternalFrame)b);
|
||||
}
|
||||
|
||||
public WindowsInternalFrameUI(JInternalFrame w){
|
||||
super(w);
|
||||
}
|
||||
|
||||
protected DesktopManager createDesktopManager(){
|
||||
return new WindowsDesktopManager();
|
||||
}
|
||||
|
||||
protected JComponent createNorthPane(JInternalFrame w) {
|
||||
titlePane = new WindowsInternalFrameTitlePane(w);
|
||||
return titlePane;
|
||||
}
|
||||
|
||||
private class XPBorder extends AbstractBorder {
|
||||
private Skin leftSkin = xp.getSkin(frame, Part.WP_FRAMELEFT);
|
||||
private Skin rightSkin = xp.getSkin(frame, Part.WP_FRAMERIGHT);
|
||||
private Skin bottomSkin = xp.getSkin(frame, Part.WP_FRAMEBOTTOM);
|
||||
|
||||
/**
|
||||
* @param x the x position of the painted border
|
||||
* @param y the y position of the painted border
|
||||
* @param width the width of the painted border
|
||||
* @param height the height of the painted border
|
||||
*/
|
||||
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
|
||||
State state = ((JInternalFrame)c).isSelected() ? State.ACTIVE : State.INACTIVE;
|
||||
int topBorderHeight = (titlePane != null) ? titlePane.getSize().height : 0;
|
||||
|
||||
bottomSkin.paintSkin(g, 0, height-bottomSkin.getHeight(),
|
||||
width, bottomSkin.getHeight(),
|
||||
state);
|
||||
|
||||
leftSkin.paintSkin(g, 0, topBorderHeight-1,
|
||||
leftSkin.getWidth(), height-topBorderHeight-bottomSkin.getHeight()+2,
|
||||
state);
|
||||
|
||||
rightSkin.paintSkin(g, width-rightSkin.getWidth(), topBorderHeight-1,
|
||||
rightSkin.getWidth(), height-topBorderHeight-bottomSkin.getHeight()+2,
|
||||
state);
|
||||
|
||||
}
|
||||
|
||||
public Insets getBorderInsets(Component c, Insets insets) {
|
||||
insets.top = 4;
|
||||
insets.left = leftSkin.getWidth();
|
||||
insets.right = rightSkin.getWidth();
|
||||
insets.bottom = bottomSkin.getHeight();
|
||||
|
||||
return insets;
|
||||
}
|
||||
|
||||
public boolean isBorderOpaque() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
112
jdkSrc/jdk8/com/sun/java/swing/plaf/windows/WindowsLabelUI.java
Normal file
112
jdkSrc/jdk8/com/sun/java/swing/plaf/windows/WindowsLabelUI.java
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2005, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import sun.swing.SwingUtilities2;
|
||||
import sun.awt.AppContext;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
|
||||
import javax.swing.plaf.basic.BasicLabelUI;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Windows rendition of the component.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public class WindowsLabelUI extends BasicLabelUI {
|
||||
|
||||
private static final Object WINDOWS_LABEL_UI_KEY = new Object();
|
||||
|
||||
// ********************************
|
||||
// Create PLAF
|
||||
// ********************************
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
AppContext appContext = AppContext.getAppContext();
|
||||
WindowsLabelUI windowsLabelUI =
|
||||
(WindowsLabelUI) appContext.get(WINDOWS_LABEL_UI_KEY);
|
||||
if (windowsLabelUI == null) {
|
||||
windowsLabelUI = new WindowsLabelUI();
|
||||
appContext.put(WINDOWS_LABEL_UI_KEY, windowsLabelUI);
|
||||
}
|
||||
return windowsLabelUI;
|
||||
}
|
||||
|
||||
protected void paintEnabledText(JLabel l, Graphics g, String s,
|
||||
int textX, int textY) {
|
||||
int mnemonicIndex = l.getDisplayedMnemonicIndex();
|
||||
// W2K Feature: Check to see if the Underscore should be rendered.
|
||||
if (WindowsLookAndFeel.isMnemonicHidden() == true) {
|
||||
mnemonicIndex = -1;
|
||||
}
|
||||
|
||||
g.setColor(l.getForeground());
|
||||
SwingUtilities2.drawStringUnderlineCharAt(l, g, s, mnemonicIndex,
|
||||
textX, textY);
|
||||
}
|
||||
|
||||
protected void paintDisabledText(JLabel l, Graphics g, String s,
|
||||
int textX, int textY) {
|
||||
int mnemonicIndex = l.getDisplayedMnemonicIndex();
|
||||
// W2K Feature: Check to see if the Underscore should be rendered.
|
||||
if (WindowsLookAndFeel.isMnemonicHidden() == true) {
|
||||
mnemonicIndex = -1;
|
||||
}
|
||||
if ( UIManager.getColor("Label.disabledForeground") instanceof Color &&
|
||||
UIManager.getColor("Label.disabledShadow") instanceof Color) {
|
||||
g.setColor( UIManager.getColor("Label.disabledShadow") );
|
||||
SwingUtilities2.drawStringUnderlineCharAt(l, g, s,
|
||||
mnemonicIndex,
|
||||
textX + 1, textY + 1);
|
||||
g.setColor( UIManager.getColor("Label.disabledForeground") );
|
||||
SwingUtilities2.drawStringUnderlineCharAt(l, g, s,
|
||||
mnemonicIndex,
|
||||
textX, textY);
|
||||
} else {
|
||||
Color background = l.getBackground();
|
||||
g.setColor(background.brighter());
|
||||
SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex,
|
||||
textX + 1, textY + 1);
|
||||
g.setColor(background.darker());
|
||||
SwingUtilities2.drawStringUnderlineCharAt(l,g, s, mnemonicIndex,
|
||||
textX, textY);
|
||||
}
|
||||
}
|
||||
}
|
||||
2639
jdkSrc/jdk8/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java
Normal file
2639
jdkSrc/jdk8/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,186 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ActionMapUIResource;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.HierarchyEvent;
|
||||
import java.awt.event.HierarchyListener;
|
||||
import java.awt.event.WindowAdapter;
|
||||
import java.awt.event.WindowEvent;
|
||||
import java.awt.event.WindowListener;
|
||||
import java.awt.event.WindowStateListener;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import com.sun.java.swing.plaf.windows.TMSchema.*;
|
||||
import com.sun.java.swing.plaf.windows.XPStyle.*;
|
||||
|
||||
/**
|
||||
* Windows rendition of the component.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public class WindowsMenuBarUI extends BasicMenuBarUI
|
||||
{
|
||||
/* to be accessed on the EDT only */
|
||||
private WindowListener windowListener = null;
|
||||
private HierarchyListener hierarchyListener = null;
|
||||
private Window window = null;
|
||||
|
||||
public static ComponentUI createUI(JComponent x) {
|
||||
return new WindowsMenuBarUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void uninstallListeners() {
|
||||
uninstallWindowListener();
|
||||
if (hierarchyListener != null) {
|
||||
menuBar.removeHierarchyListener(hierarchyListener);
|
||||
hierarchyListener = null;
|
||||
}
|
||||
super.uninstallListeners();
|
||||
}
|
||||
private void installWindowListener() {
|
||||
if (windowListener == null) {
|
||||
Component component = menuBar.getTopLevelAncestor();
|
||||
if (component instanceof Window) {
|
||||
window = (Window) component;
|
||||
windowListener = new WindowAdapter() {
|
||||
@Override
|
||||
public void windowActivated(WindowEvent e) {
|
||||
menuBar.repaint();
|
||||
}
|
||||
@Override
|
||||
public void windowDeactivated(WindowEvent e) {
|
||||
menuBar.repaint();
|
||||
}
|
||||
};
|
||||
((Window) component).addWindowListener(windowListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void uninstallWindowListener() {
|
||||
if (windowListener != null && window != null) {
|
||||
window.removeWindowListener(windowListener);
|
||||
}
|
||||
window = null;
|
||||
windowListener = null;
|
||||
}
|
||||
@Override
|
||||
protected void installListeners() {
|
||||
if (WindowsLookAndFeel.isOnVista()) {
|
||||
installWindowListener();
|
||||
hierarchyListener =
|
||||
new HierarchyListener() {
|
||||
public void hierarchyChanged(HierarchyEvent e) {
|
||||
if ((e.getChangeFlags()
|
||||
& HierarchyEvent.DISPLAYABILITY_CHANGED) != 0) {
|
||||
if (menuBar.isDisplayable()) {
|
||||
installWindowListener();
|
||||
} else {
|
||||
uninstallWindowListener();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
menuBar.addHierarchyListener(hierarchyListener);
|
||||
}
|
||||
super.installListeners();
|
||||
}
|
||||
|
||||
protected void installKeyboardActions() {
|
||||
super.installKeyboardActions();
|
||||
ActionMap map = SwingUtilities.getUIActionMap(menuBar);
|
||||
if (map == null) {
|
||||
map = new ActionMapUIResource();
|
||||
SwingUtilities.replaceUIActionMap(menuBar, map);
|
||||
}
|
||||
map.put("takeFocus", new TakeFocus());
|
||||
}
|
||||
|
||||
/**
|
||||
* Action that activates the menu (e.g. when F10 is pressed).
|
||||
* Unlike BasicMenuBarUI.TakeFocus, this Action will not show menu popup.
|
||||
*/
|
||||
private static class TakeFocus extends AbstractAction {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
JMenuBar menuBar = (JMenuBar)e.getSource();
|
||||
JMenu menu = menuBar.getMenu(0);
|
||||
if (menu != null) {
|
||||
MenuSelectionManager msm =
|
||||
MenuSelectionManager.defaultManager();
|
||||
MenuElement path[] = new MenuElement[2];
|
||||
path[0] = (MenuElement)menuBar;
|
||||
path[1] = (MenuElement)menu;
|
||||
msm.setSelectedPath(path);
|
||||
|
||||
// show mnemonics
|
||||
WindowsLookAndFeel.setMnemonicHidden(false);
|
||||
WindowsLookAndFeel.repaintRootPane(menuBar);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g, JComponent c) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (WindowsMenuItemUI.isVistaPainting(xp)) {
|
||||
Skin skin;
|
||||
skin = xp.getSkin(c, Part.MP_BARBACKGROUND);
|
||||
int width = c.getWidth();
|
||||
int height = c.getHeight();
|
||||
State state = isActive(c) ? State.ACTIVE : State.INACTIVE;
|
||||
skin.paintSkin(g, 0, 0, width, height, state);
|
||||
} else {
|
||||
super.paint(g, c);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if component belongs to an active window.
|
||||
* @param c component to check
|
||||
* @return true if component belongs to an active window
|
||||
*/
|
||||
static boolean isActive(JComponent c) {
|
||||
JRootPane rootPane = c.getRootPane();
|
||||
if (rootPane != null) {
|
||||
Component component = rootPane.getParent();
|
||||
if (component instanceof Window) {
|
||||
return ((Window) component).isActive();
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
|
||||
import sun.swing.SwingUtilities2;
|
||||
|
||||
import com.sun.java.swing.plaf.windows.TMSchema.*;
|
||||
import com.sun.java.swing.plaf.windows.XPStyle.*;
|
||||
|
||||
/**
|
||||
* Windows rendition of the component.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Igor Kushnirskiy
|
||||
*/
|
||||
|
||||
public class WindowsMenuItemUI extends BasicMenuItemUI {
|
||||
final WindowsMenuItemUIAccessor accessor =
|
||||
new WindowsMenuItemUIAccessor() {
|
||||
|
||||
public JMenuItem getMenuItem() {
|
||||
return menuItem;
|
||||
}
|
||||
|
||||
public State getState(JMenuItem menuItem) {
|
||||
return WindowsMenuItemUI.getState(this, menuItem);
|
||||
}
|
||||
|
||||
public Part getPart(JMenuItem menuItem) {
|
||||
return WindowsMenuItemUI.getPart(this, menuItem);
|
||||
}
|
||||
};
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new WindowsMenuItemUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which renders the text of the current menu item.
|
||||
* <p>
|
||||
* @param g Graphics context
|
||||
* @param menuItem Current menu item to render
|
||||
* @param textRect Bounding rectangle to render the text.
|
||||
* @param text String to render
|
||||
*/
|
||||
protected void paintText(Graphics g, JMenuItem menuItem,
|
||||
Rectangle textRect, String text) {
|
||||
if (WindowsMenuItemUI.isVistaPainting()) {
|
||||
WindowsMenuItemUI.paintText(accessor, g, menuItem, textRect, text);
|
||||
return;
|
||||
}
|
||||
ButtonModel model = menuItem.getModel();
|
||||
Color oldColor = g.getColor();
|
||||
|
||||
if(model.isEnabled() &&
|
||||
(model.isArmed() || (menuItem instanceof JMenu &&
|
||||
model.isSelected()))) {
|
||||
g.setColor(selectionForeground); // Uses protected field.
|
||||
}
|
||||
|
||||
WindowsGraphicsUtils.paintText(g, menuItem, textRect, text, 0);
|
||||
|
||||
g.setColor(oldColor);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintBackground(Graphics g, JMenuItem menuItem,
|
||||
Color bgColor) {
|
||||
if (WindowsMenuItemUI.isVistaPainting()) {
|
||||
WindowsMenuItemUI.paintBackground(accessor, g, menuItem, bgColor);
|
||||
return;
|
||||
}
|
||||
super.paintBackground(g, menuItem, bgColor);
|
||||
}
|
||||
|
||||
static void paintBackground(WindowsMenuItemUIAccessor menuItemUI,
|
||||
Graphics g, JMenuItem menuItem, Color bgColor) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
assert isVistaPainting(xp);
|
||||
if (isVistaPainting(xp)) {
|
||||
int menuWidth = menuItem.getWidth();
|
||||
int menuHeight = menuItem.getHeight();
|
||||
if (menuItem.isOpaque()) {
|
||||
Color oldColor = g.getColor();
|
||||
g.setColor(menuItem.getBackground());
|
||||
g.fillRect(0,0, menuWidth, menuHeight);
|
||||
g.setColor(oldColor);
|
||||
}
|
||||
Part part = menuItemUI.getPart(menuItem);
|
||||
Skin skin = xp.getSkin(menuItem, part);
|
||||
skin.paintSkin(g, 0 , 0,
|
||||
menuWidth,
|
||||
menuHeight,
|
||||
menuItemUI.getState(menuItem));
|
||||
}
|
||||
}
|
||||
|
||||
static void paintText(WindowsMenuItemUIAccessor menuItemUI, Graphics g,
|
||||
JMenuItem menuItem, Rectangle textRect,
|
||||
String text) {
|
||||
assert isVistaPainting();
|
||||
if (isVistaPainting()) {
|
||||
State state = menuItemUI.getState(menuItem);
|
||||
|
||||
/* part of it copied from WindowsGraphicsUtils.java */
|
||||
FontMetrics fm = SwingUtilities2.getFontMetrics(menuItem, g);
|
||||
int mnemIndex = menuItem.getDisplayedMnemonicIndex();
|
||||
// W2K Feature: Check to see if the Underscore should be rendered.
|
||||
if (WindowsLookAndFeel.isMnemonicHidden() == true) {
|
||||
mnemIndex = -1;
|
||||
}
|
||||
WindowsGraphicsUtils.paintXPText(menuItem,
|
||||
menuItemUI.getPart(menuItem), state,
|
||||
g, textRect.x,
|
||||
textRect.y + fm.getAscent(),
|
||||
text, mnemIndex);
|
||||
}
|
||||
}
|
||||
|
||||
static State getState(WindowsMenuItemUIAccessor menuItemUI, JMenuItem menuItem) {
|
||||
State state;
|
||||
ButtonModel model = menuItem.getModel();
|
||||
if (model.isArmed()) {
|
||||
state = (model.isEnabled()) ? State.HOT : State.DISABLEDHOT;
|
||||
} else {
|
||||
state = (model.isEnabled()) ? State.NORMAL : State.DISABLED;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
static Part getPart(WindowsMenuItemUIAccessor menuItemUI, JMenuItem menuItem) {
|
||||
return Part.MP_POPUPITEM;
|
||||
}
|
||||
|
||||
/*
|
||||
* TODO idk can we use XPStyle.isVista?
|
||||
* is it possible that in some theme some Vista parts are not defined while
|
||||
* others are?
|
||||
*/
|
||||
static boolean isVistaPainting(final XPStyle xp) {
|
||||
return xp != null && xp.isSkinDefined(null, Part.MP_POPUPITEM);
|
||||
}
|
||||
|
||||
static boolean isVistaPainting() {
|
||||
return isVistaPainting(XPStyle.getXP());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) 2006, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
|
||||
import javax.swing.JMenuItem;
|
||||
|
||||
import com.sun.java.swing.plaf.windows.TMSchema.Part;
|
||||
import com.sun.java.swing.plaf.windows.TMSchema.State;
|
||||
|
||||
/**
|
||||
* Accessor interface for WindowsMenuItemUI to allow for "multiple implementation
|
||||
* inheritance".
|
||||
*
|
||||
* @author Igor Kushnirskiy
|
||||
*/
|
||||
interface WindowsMenuItemUIAccessor {
|
||||
JMenuItem getMenuItem();
|
||||
State getState(JMenuItem menuItem);
|
||||
Part getPart(JMenuItem menuItem);
|
||||
}
|
||||
295
jdkSrc/jdk8/com/sun/java/swing/plaf/windows/WindowsMenuUI.java
Normal file
295
jdkSrc/jdk8/com/sun/java/swing/plaf/windows/WindowsMenuUI.java
Normal file
@@ -0,0 +1,295 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicMenuUI;
|
||||
import javax.swing.event.MouseInputListener;
|
||||
import javax.swing.*;
|
||||
|
||||
import com.sun.java.swing.plaf.windows.TMSchema.Part;
|
||||
import com.sun.java.swing.plaf.windows.TMSchema.State;
|
||||
|
||||
/**
|
||||
* Windows rendition of the component.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public class WindowsMenuUI extends BasicMenuUI {
|
||||
protected Integer menuBarHeight;
|
||||
protected boolean hotTrackingOn;
|
||||
|
||||
final WindowsMenuItemUIAccessor accessor =
|
||||
new WindowsMenuItemUIAccessor() {
|
||||
|
||||
public JMenuItem getMenuItem() {
|
||||
return menuItem;
|
||||
}
|
||||
|
||||
public State getState(JMenuItem menu) {
|
||||
State state = menu.isEnabled() ? State.NORMAL
|
||||
: State.DISABLED;
|
||||
ButtonModel model = menu.getModel();
|
||||
if (model.isArmed() || model.isSelected()) {
|
||||
state = (menu.isEnabled()) ? State.PUSHED
|
||||
: State.DISABLEDPUSHED;
|
||||
} else if (model.isRollover()
|
||||
&& ((JMenu) menu).isTopLevelMenu()) {
|
||||
/*
|
||||
* Only paint rollover if no other menu on menubar is
|
||||
* selected
|
||||
*/
|
||||
State stateTmp = state;
|
||||
state = (menu.isEnabled()) ? State.HOT
|
||||
: State.DISABLEDHOT;
|
||||
for (MenuElement menuElement :
|
||||
((JMenuBar) menu.getParent()).getSubElements()) {
|
||||
if (((JMenuItem) menuElement).isSelected()) {
|
||||
state = stateTmp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//non top level menus have HOT state instead of PUSHED
|
||||
if (!((JMenu) menu).isTopLevelMenu()) {
|
||||
if (state == State.PUSHED) {
|
||||
state = State.HOT;
|
||||
} else if (state == State.DISABLEDPUSHED) {
|
||||
state = State.DISABLEDHOT;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* on Vista top level menu for non active frame looks disabled
|
||||
*/
|
||||
if (((JMenu) menu).isTopLevelMenu() && WindowsMenuItemUI.isVistaPainting()) {
|
||||
if (! WindowsMenuBarUI.isActive(menu)) {
|
||||
state = State.DISABLED;
|
||||
}
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
public Part getPart(JMenuItem menuItem) {
|
||||
return ((JMenu) menuItem).isTopLevelMenu() ? Part.MP_BARITEM
|
||||
: Part.MP_POPUPITEM;
|
||||
}
|
||||
};
|
||||
public static ComponentUI createUI(JComponent x) {
|
||||
return new WindowsMenuUI();
|
||||
}
|
||||
|
||||
protected void installDefaults() {
|
||||
super.installDefaults();
|
||||
if (!WindowsLookAndFeel.isClassicWindows()) {
|
||||
menuItem.setRolloverEnabled(true);
|
||||
}
|
||||
|
||||
menuBarHeight = (Integer)UIManager.getInt("MenuBar.height");
|
||||
|
||||
Object obj = UIManager.get("MenuBar.rolloverEnabled");
|
||||
hotTrackingOn = (obj instanceof Boolean) ? (Boolean)obj : true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the background of the menu.
|
||||
* @since 1.4
|
||||
*/
|
||||
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
|
||||
if (WindowsMenuItemUI.isVistaPainting()) {
|
||||
WindowsMenuItemUI.paintBackground(accessor, g, menuItem, bgColor);
|
||||
return;
|
||||
}
|
||||
|
||||
JMenu menu = (JMenu)menuItem;
|
||||
ButtonModel model = menu.getModel();
|
||||
|
||||
// Use superclass method for the old Windows LAF,
|
||||
// for submenus, and for XP toplevel if selected or pressed
|
||||
if (WindowsLookAndFeel.isClassicWindows() ||
|
||||
!menu.isTopLevelMenu() ||
|
||||
(XPStyle.getXP() != null && (model.isArmed() || model.isSelected()))) {
|
||||
|
||||
super.paintBackground(g, menu, bgColor);
|
||||
return;
|
||||
}
|
||||
|
||||
Color oldColor = g.getColor();
|
||||
int menuWidth = menu.getWidth();
|
||||
int menuHeight = menu.getHeight();
|
||||
|
||||
UIDefaults table = UIManager.getLookAndFeelDefaults();
|
||||
Color highlight = table.getColor("controlLtHighlight");
|
||||
Color shadow = table.getColor("controlShadow");
|
||||
|
||||
g.setColor(menu.getBackground());
|
||||
g.fillRect(0,0, menuWidth, menuHeight);
|
||||
|
||||
if (menu.isOpaque()) {
|
||||
if (model.isArmed() || model.isSelected()) {
|
||||
// Draw a lowered bevel border
|
||||
g.setColor(shadow);
|
||||
g.drawLine(0,0, menuWidth - 1,0);
|
||||
g.drawLine(0,0, 0,menuHeight - 2);
|
||||
|
||||
g.setColor(highlight);
|
||||
g.drawLine(menuWidth - 1,0, menuWidth - 1,menuHeight - 2);
|
||||
g.drawLine(0,menuHeight - 2, menuWidth - 1,menuHeight - 2);
|
||||
} else if (model.isRollover() && model.isEnabled()) {
|
||||
// Only paint rollover if no other menu on menubar is selected
|
||||
boolean otherMenuSelected = false;
|
||||
MenuElement[] menus = ((JMenuBar)menu.getParent()).getSubElements();
|
||||
for (int i = 0; i < menus.length; i++) {
|
||||
if (((JMenuItem)menus[i]).isSelected()) {
|
||||
otherMenuSelected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!otherMenuSelected) {
|
||||
if (XPStyle.getXP() != null) {
|
||||
g.setColor(selectionBackground); // Uses protected field.
|
||||
g.fillRect(0, 0, menuWidth, menuHeight);
|
||||
} else {
|
||||
// Draw a raised bevel border
|
||||
g.setColor(highlight);
|
||||
g.drawLine(0,0, menuWidth - 1,0);
|
||||
g.drawLine(0,0, 0,menuHeight - 2);
|
||||
|
||||
g.setColor(shadow);
|
||||
g.drawLine(menuWidth - 1,0, menuWidth - 1,menuHeight - 2);
|
||||
g.drawLine(0,menuHeight - 2, menuWidth - 1,menuHeight - 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
g.setColor(oldColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which renders the text of the current menu item.
|
||||
* <p>
|
||||
* @param g Graphics context
|
||||
* @param menuItem Current menu item to render
|
||||
* @param textRect Bounding rectangle to render the text.
|
||||
* @param text String to render
|
||||
* @since 1.4
|
||||
*/
|
||||
protected void paintText(Graphics g, JMenuItem menuItem,
|
||||
Rectangle textRect, String text) {
|
||||
if (WindowsMenuItemUI.isVistaPainting()) {
|
||||
WindowsMenuItemUI.paintText(accessor, g, menuItem, textRect, text);
|
||||
return;
|
||||
}
|
||||
JMenu menu = (JMenu)menuItem;
|
||||
ButtonModel model = menuItem.getModel();
|
||||
Color oldColor = g.getColor();
|
||||
|
||||
// Only paint rollover if no other menu on menubar is selected
|
||||
boolean paintRollover = model.isRollover();
|
||||
if (paintRollover && menu.isTopLevelMenu()) {
|
||||
MenuElement[] menus = ((JMenuBar)menu.getParent()).getSubElements();
|
||||
for (int i = 0; i < menus.length; i++) {
|
||||
if (((JMenuItem)menus[i]).isSelected()) {
|
||||
paintRollover = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((model.isSelected() && (WindowsLookAndFeel.isClassicWindows() ||
|
||||
!menu.isTopLevelMenu())) ||
|
||||
(XPStyle.getXP() != null && (paintRollover ||
|
||||
model.isArmed() ||
|
||||
model.isSelected()))) {
|
||||
g.setColor(selectionForeground); // Uses protected field.
|
||||
}
|
||||
|
||||
WindowsGraphicsUtils.paintText(g, menuItem, textRect, text, 0);
|
||||
|
||||
g.setColor(oldColor);
|
||||
}
|
||||
|
||||
protected MouseInputListener createMouseInputListener(JComponent c) {
|
||||
return new WindowsMouseInputHandler();
|
||||
}
|
||||
|
||||
/**
|
||||
* This class implements a mouse handler that sets the rollover flag to
|
||||
* true when the mouse enters the menu and false when it exits.
|
||||
* @since 1.4
|
||||
*/
|
||||
protected class WindowsMouseInputHandler extends BasicMenuUI.MouseInputHandler {
|
||||
public void mouseEntered(MouseEvent evt) {
|
||||
super.mouseEntered(evt);
|
||||
|
||||
JMenu menu = (JMenu)evt.getSource();
|
||||
if (hotTrackingOn && menu.isTopLevelMenu() && menu.isRolloverEnabled()) {
|
||||
menu.getModel().setRollover(true);
|
||||
menuItem.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent evt) {
|
||||
super.mouseExited(evt);
|
||||
|
||||
JMenu menu = (JMenu)evt.getSource();
|
||||
ButtonModel model = menu.getModel();
|
||||
if (menu.isRolloverEnabled()) {
|
||||
model.setRollover(false);
|
||||
menuItem.repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected Dimension getPreferredMenuItemSize(JComponent c,
|
||||
Icon checkIcon,
|
||||
Icon arrowIcon,
|
||||
int defaultTextIconGap) {
|
||||
|
||||
Dimension d = super.getPreferredMenuItemSize(c, checkIcon, arrowIcon,
|
||||
defaultTextIconGap);
|
||||
|
||||
// Note: When toolbar containers (rebars) are implemented, only do
|
||||
// this if the JMenuBar is not in a rebar (i.e. ignore the desktop
|
||||
// property win.menu.height if in a rebar.)
|
||||
if (c instanceof JMenu && ((JMenu)c).isTopLevelMenu() &&
|
||||
menuBarHeight != null && d.height < menuBarHeight) {
|
||||
|
||||
d.height = menuBarHeight;
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2000, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.PropertyChangeListener;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Windows rendition of the component.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public class WindowsOptionPaneUI extends BasicOptionPaneUI {
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.Caret;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Windows rendition of the component.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public class WindowsPasswordFieldUI extends BasicPasswordFieldUI {
|
||||
|
||||
/**
|
||||
* Creates a UI for a JPasswordField
|
||||
*
|
||||
* @param c the password field
|
||||
* @return the UI
|
||||
*/
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new WindowsPasswordFieldUI();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates the object to use for a caret. By default an
|
||||
* instance of WindowsCaret is created. This method
|
||||
* can be redefined to provide something else that implements
|
||||
* the InputPosition interface or a subclass of DefaultCaret.
|
||||
*
|
||||
* @return the caret object
|
||||
*/
|
||||
protected Caret createCaret() {
|
||||
return new WindowsTextUI.WindowsCaret();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (c) 2004, 2014, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.basic.BasicPopupMenuSeparatorUI;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
|
||||
import com.sun.java.swing.plaf.windows.TMSchema.Part;
|
||||
import com.sun.java.swing.plaf.windows.TMSchema.State;
|
||||
import com.sun.java.swing.plaf.windows.XPStyle.Skin;
|
||||
|
||||
/**
|
||||
* Windows L&F implementation of PopupMenuSeparatorUI.
|
||||
*
|
||||
* @author Leif Samuelsson
|
||||
* @author Igor Kushnirskiy
|
||||
*/
|
||||
|
||||
public class WindowsPopupMenuSeparatorUI extends BasicPopupMenuSeparatorUI {
|
||||
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new WindowsPopupMenuSeparatorUI();
|
||||
}
|
||||
|
||||
public void paint(Graphics g, JComponent c) {
|
||||
Dimension s = c.getSize();
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (WindowsMenuItemUI.isVistaPainting(xp)) {
|
||||
int x = 1;
|
||||
Component parent = c.getParent();
|
||||
if (parent instanceof JComponent) {
|
||||
Object gutterOffsetObject =
|
||||
((JComponent) parent).getClientProperty(
|
||||
WindowsPopupMenuUI.GUTTER_OFFSET_KEY);
|
||||
if (gutterOffsetObject instanceof Integer) {
|
||||
/*
|
||||
* gutter offset is in parent's coordinates.
|
||||
* See comment in
|
||||
* WindowsPopupMenuUI.getTextOffset(JComponent)
|
||||
*/
|
||||
x = ((Integer) gutterOffsetObject).intValue() - c.getX();
|
||||
x += WindowsPopupMenuUI.getGutterWidth();
|
||||
}
|
||||
}
|
||||
Skin skin = xp.getSkin(c, Part.MP_POPUPSEPARATOR);
|
||||
int skinHeight = skin.getHeight();
|
||||
int y = (s.height - skinHeight) / 2;
|
||||
skin.paintSkin(g, x, y, s.width - x - 1, skinHeight, State.NORMAL);
|
||||
} else {
|
||||
int y = s.height / 2;
|
||||
g.setColor(c.getForeground());
|
||||
g.drawLine(1, y - 1, s.width - 2, y - 1);
|
||||
|
||||
g.setColor(c.getBackground());
|
||||
g.drawLine(1, y, s.width - 2, y);
|
||||
}
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize(JComponent c) {
|
||||
int fontHeight = 0;
|
||||
Font font = c.getFont();
|
||||
if (font != null) {
|
||||
fontHeight = c.getFontMetrics(font).getHeight();
|
||||
}
|
||||
|
||||
return new Dimension(0, fontHeight/2 + 2);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Insets;
|
||||
import java.awt.KeyEventPostProcessor;
|
||||
import java.awt.KeyboardFocusManager;
|
||||
import java.awt.Window;
|
||||
import java.awt.event.KeyEvent;
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
|
||||
import sun.swing.StringUIClientPropertyKey;
|
||||
|
||||
import com.sun.java.swing.plaf.windows.TMSchema.Part;
|
||||
import com.sun.java.swing.plaf.windows.TMSchema.State;
|
||||
import com.sun.java.swing.plaf.windows.XPStyle.Skin;
|
||||
import static sun.swing.SwingUtilities2.BASICMENUITEMUI_MAX_TEXT_OFFSET;
|
||||
|
||||
/**
|
||||
* Windows rendition of the component.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Igor Kushnirskiy
|
||||
*/
|
||||
public class WindowsPopupMenuUI extends BasicPopupMenuUI {
|
||||
|
||||
static MnemonicListener mnemonicListener = null;
|
||||
static final Object GUTTER_OFFSET_KEY =
|
||||
new StringUIClientPropertyKey("GUTTER_OFFSET_KEY");
|
||||
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new WindowsPopupMenuUI();
|
||||
}
|
||||
|
||||
public void installListeners() {
|
||||
super.installListeners();
|
||||
if (! UIManager.getBoolean("Button.showMnemonics") &&
|
||||
mnemonicListener == null) {
|
||||
|
||||
mnemonicListener = new MnemonicListener();
|
||||
MenuSelectionManager.defaultManager().
|
||||
addChangeListener(mnemonicListener);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <code>Popup</code> that will be responsible for
|
||||
* displaying the <code>JPopupMenu</code>.
|
||||
*
|
||||
* @param popupMenu JPopupMenu requesting Popup
|
||||
* @param x Screen x location Popup is to be shown at
|
||||
* @param y Screen y location Popup is to be shown at.
|
||||
* @return Popup that will show the JPopupMenu
|
||||
* @since 1.4
|
||||
*/
|
||||
public Popup getPopup(JPopupMenu popupMenu, int x, int y) {
|
||||
PopupFactory popupFactory = PopupFactory.getSharedInstance();
|
||||
return popupFactory.getPopup(popupMenu.getInvoker(), popupMenu, x, y);
|
||||
}
|
||||
|
||||
static class MnemonicListener implements ChangeListener {
|
||||
JRootPane repaintRoot = null;
|
||||
|
||||
public void stateChanged(ChangeEvent ev) {
|
||||
MenuSelectionManager msm = (MenuSelectionManager)ev.getSource();
|
||||
MenuElement[] path = msm.getSelectedPath();
|
||||
if (path.length == 0) {
|
||||
if(!WindowsLookAndFeel.isMnemonicHidden()) {
|
||||
// menu was canceled -- hide mnemonics
|
||||
WindowsLookAndFeel.setMnemonicHidden(true);
|
||||
if (repaintRoot != null) {
|
||||
Window win =
|
||||
SwingUtilities.getWindowAncestor(repaintRoot);
|
||||
WindowsGraphicsUtils.repaintMnemonicsInWindow(win);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Component c = (Component)path[0];
|
||||
if (c instanceof JPopupMenu) c = ((JPopupMenu)c).getInvoker();
|
||||
repaintRoot = SwingUtilities.getRootPane(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns offset for the text.
|
||||
* BasicMenuItemUI sets max text offset on the JPopupMenuUI.
|
||||
* @param c PopupMenu to return text offset for.
|
||||
* @return text offset for the component
|
||||
*/
|
||||
static int getTextOffset(JComponent c) {
|
||||
int rv = -1;
|
||||
Object maxTextOffset =
|
||||
c.getClientProperty(BASICMENUITEMUI_MAX_TEXT_OFFSET);
|
||||
if (maxTextOffset instanceof Integer) {
|
||||
/*
|
||||
* this is in JMenuItem coordinates.
|
||||
* Let's assume all the JMenuItem have the same offset along X.
|
||||
*/
|
||||
rv = (Integer) maxTextOffset;
|
||||
int menuItemOffset = 0;
|
||||
Component component = c.getComponent(0);
|
||||
if (component != null) {
|
||||
menuItemOffset = component.getX();
|
||||
}
|
||||
rv += menuItemOffset;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns span before gutter.
|
||||
* used only on Vista.
|
||||
* @return span before gutter
|
||||
*/
|
||||
static int getSpanBeforeGutter() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns span after gutter.
|
||||
* used only on Vista.
|
||||
* @return span after gutter
|
||||
*/
|
||||
static int getSpanAfterGutter() {
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns gutter width.
|
||||
* used only on Vista.
|
||||
* @return width of the gutter
|
||||
*/
|
||||
static int getGutterWidth() {
|
||||
int rv = 2;
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
Skin skin = xp.getSkin(null, Part.MP_POPUPGUTTER);
|
||||
rv = skin.getWidth();
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if PopupMenu is leftToRight
|
||||
* The orientation is derived from the children of the component.
|
||||
* It is leftToRight if all the children are leftToRight
|
||||
*
|
||||
* @param c component to return orientation for
|
||||
* @return true if all the children are leftToRight
|
||||
*/
|
||||
private static boolean isLeftToRight(JComponent c) {
|
||||
boolean leftToRight = true;
|
||||
for (int i = c.getComponentCount() - 1; i >=0 && leftToRight; i-- ) {
|
||||
leftToRight =
|
||||
c.getComponent(i).getComponentOrientation().isLeftToRight();
|
||||
}
|
||||
return leftToRight;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paint(Graphics g, JComponent c) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (WindowsMenuItemUI.isVistaPainting(xp)) {
|
||||
Skin skin = xp.getSkin(c, Part.MP_POPUPBACKGROUND);
|
||||
skin.paintSkin(g, 0, 0, c.getWidth(),c.getHeight(), State.NORMAL);
|
||||
int textOffset = getTextOffset(c);
|
||||
if (textOffset >= 0
|
||||
/* paint gutter only for leftToRight case */
|
||||
&& isLeftToRight(c)) {
|
||||
skin = xp.getSkin(c, Part.MP_POPUPGUTTER);
|
||||
int gutterWidth = getGutterWidth();
|
||||
int gutterOffset =
|
||||
textOffset - getSpanAfterGutter() - gutterWidth;
|
||||
c.putClientProperty(GUTTER_OFFSET_KEY,
|
||||
Integer.valueOf(gutterOffset));
|
||||
Insets insets = c.getInsets();
|
||||
skin.paintSkin(g, gutterOffset, insets.top,
|
||||
gutterWidth, c.getHeight() - insets.bottom - insets.top,
|
||||
State.NORMAL);
|
||||
} else {
|
||||
if (c.getClientProperty(GUTTER_OFFSET_KEY) != null) {
|
||||
c.putClientProperty(GUTTER_OFFSET_KEY, null);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
super.paint(g, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2002, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import javax.swing.JWindow;
|
||||
import java.awt.Window;
|
||||
import java.awt.Graphics;
|
||||
|
||||
/**
|
||||
* A class which tags a window with a particular semantic usage,
|
||||
* either tooltip, menu, sub-menu, popup-menu, or comobobox-popup.
|
||||
* This is used as a temporary solution for getting native AWT support
|
||||
* for transition effects in Windows 98 and Windows 2000. The native
|
||||
* code will interpret the windowType property and automatically
|
||||
* implement appropriate animation when the window is shown/hidden.
|
||||
* <p>
|
||||
* Note that support for transition effects may be supported with a
|
||||
* different mechanism in the future and so this class is
|
||||
* package-private and targeted for Swing implementation use only.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Amy Fowler
|
||||
*/
|
||||
class WindowsPopupWindow extends JWindow {
|
||||
|
||||
static final int UNDEFINED_WINDOW_TYPE = 0;
|
||||
static final int TOOLTIP_WINDOW_TYPE = 1;
|
||||
static final int MENU_WINDOW_TYPE = 2;
|
||||
static final int SUBMENU_WINDOW_TYPE = 3;
|
||||
static final int POPUPMENU_WINDOW_TYPE = 4;
|
||||
static final int COMBOBOX_POPUP_WINDOW_TYPE = 5;
|
||||
|
||||
private int windowType;
|
||||
|
||||
WindowsPopupWindow(Window parent) {
|
||||
super(parent);
|
||||
setFocusableWindowState(false);
|
||||
}
|
||||
|
||||
void setWindowType(int type) {
|
||||
windowType = type;
|
||||
}
|
||||
|
||||
int getWindowType() {
|
||||
return windowType;
|
||||
}
|
||||
|
||||
public void update(Graphics g) {
|
||||
paint(g);
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
super.hide();
|
||||
/** We need to call removeNotify() here because hide() does
|
||||
* something only if Component.visible is true. When the app
|
||||
* frame is miniaturized, the parent frame of this frame is
|
||||
* invisible, causing AWT to believe that this frame
|
||||
* is invisible and causing hide() to do nothing
|
||||
*/
|
||||
removeNotify();
|
||||
}
|
||||
|
||||
public void show() {
|
||||
super.show();
|
||||
this.pack();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,412 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.*;
|
||||
import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
|
||||
|
||||
|
||||
/**
|
||||
* Windows rendition of the component.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Michael C. Albers
|
||||
*/
|
||||
public class WindowsProgressBarUI extends BasicProgressBarUI
|
||||
{
|
||||
|
||||
private Rectangle previousFullBox;
|
||||
private Insets indeterminateInsets;
|
||||
|
||||
public static ComponentUI createUI(JComponent x) {
|
||||
return new WindowsProgressBarUI();
|
||||
}
|
||||
|
||||
|
||||
protected void installDefaults() {
|
||||
super.installDefaults();
|
||||
|
||||
if (XPStyle.getXP() != null) {
|
||||
LookAndFeel.installProperty(progressBar, "opaque", Boolean.FALSE);
|
||||
progressBar.setBorder(null);
|
||||
indeterminateInsets = UIManager.getInsets("ProgressBar.indeterminateInsets");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the baseline.
|
||||
*
|
||||
* @throws NullPointerException {@inheritDoc}
|
||||
* @throws IllegalArgumentException {@inheritDoc}
|
||||
* @see javax.swing.JComponent#getBaseline(int, int)
|
||||
* @since 1.6
|
||||
*/
|
||||
public int getBaseline(JComponent c, int width, int height) {
|
||||
int baseline = super.getBaseline(c, width, height);
|
||||
if (XPStyle.getXP() != null && progressBar.isStringPainted() &&
|
||||
progressBar.getOrientation() == JProgressBar.HORIZONTAL) {
|
||||
FontMetrics metrics = progressBar.
|
||||
getFontMetrics(progressBar.getFont());
|
||||
int y = progressBar.getInsets().top;
|
||||
if (progressBar.isIndeterminate()) {
|
||||
y = -1;
|
||||
height--;
|
||||
}
|
||||
else {
|
||||
y = 0;
|
||||
height -= 3;
|
||||
}
|
||||
baseline = y + (height + metrics.getAscent() -
|
||||
metrics.getLeading() -
|
||||
metrics.getDescent()) / 2;
|
||||
}
|
||||
return baseline;
|
||||
}
|
||||
|
||||
protected Dimension getPreferredInnerHorizontal() {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
Skin skin = xp.getSkin(progressBar, Part.PP_BAR);
|
||||
return new Dimension(
|
||||
(int)super.getPreferredInnerHorizontal().getWidth(),
|
||||
skin.getHeight());
|
||||
}
|
||||
return super.getPreferredInnerHorizontal();
|
||||
}
|
||||
|
||||
protected Dimension getPreferredInnerVertical() {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
Skin skin = xp.getSkin(progressBar, Part.PP_BARVERT);
|
||||
return new Dimension(
|
||||
skin.getWidth(),
|
||||
(int)super.getPreferredInnerVertical().getHeight());
|
||||
}
|
||||
return super.getPreferredInnerVertical();
|
||||
}
|
||||
|
||||
protected void paintDeterminate(Graphics g, JComponent c) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
boolean vertical = (progressBar.getOrientation() == JProgressBar.VERTICAL);
|
||||
boolean isLeftToRight = WindowsGraphicsUtils.isLeftToRight(c);
|
||||
int barRectWidth = progressBar.getWidth();
|
||||
int barRectHeight = progressBar.getHeight()-1;
|
||||
// amount of progress to draw
|
||||
int amountFull = getAmountFull(null, barRectWidth, barRectHeight);
|
||||
|
||||
paintXPBackground(g, vertical, barRectWidth, barRectHeight);
|
||||
// Paint progress
|
||||
if (progressBar.isStringPainted()) {
|
||||
// Do not paint the standard stripes from the skin, because they obscure
|
||||
// the text
|
||||
g.setColor(progressBar.getForeground());
|
||||
barRectHeight -= 2;
|
||||
barRectWidth -= 2;
|
||||
|
||||
if (barRectWidth <= 0 || barRectHeight <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Graphics2D g2 = (Graphics2D)g;
|
||||
g2.setStroke(new BasicStroke((float)(vertical ? barRectWidth : barRectHeight),
|
||||
BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
|
||||
if (!vertical) {
|
||||
if (isLeftToRight) {
|
||||
g2.drawLine(2, barRectHeight / 2 + 1,
|
||||
amountFull - 2, barRectHeight / 2 + 1);
|
||||
} else {
|
||||
g2.drawLine(2 + barRectWidth,
|
||||
barRectHeight / 2 + 1,
|
||||
2 + barRectWidth - (amountFull - 2),
|
||||
barRectHeight / 2 + 1);
|
||||
}
|
||||
paintString(g, 0, 0, barRectWidth, barRectHeight, amountFull, null);
|
||||
} else {
|
||||
g2.drawLine(barRectWidth/2 + 1, barRectHeight + 1,
|
||||
barRectWidth/2 + 1, barRectHeight + 1 - amountFull + 2);
|
||||
paintString(g, 2, 2, barRectWidth, barRectHeight, amountFull, null);
|
||||
}
|
||||
|
||||
} else {
|
||||
Skin skin = xp.getSkin(progressBar, vertical ? Part.PP_CHUNKVERT : Part.PP_CHUNK);
|
||||
int thickness;
|
||||
if (vertical) {
|
||||
thickness = barRectWidth - 5;
|
||||
} else {
|
||||
thickness = barRectHeight - 5;
|
||||
}
|
||||
|
||||
int chunkSize = xp.getInt(progressBar, Part.PP_PROGRESS, null, Prop.PROGRESSCHUNKSIZE, 2);
|
||||
int spaceSize = xp.getInt(progressBar, Part.PP_PROGRESS, null, Prop.PROGRESSSPACESIZE, 0);
|
||||
int nChunks = (amountFull-4) / (chunkSize + spaceSize);
|
||||
|
||||
// See if we can squeeze in an extra chunk without spacing after
|
||||
if (spaceSize > 0 && (nChunks * (chunkSize + spaceSize) + chunkSize) < (amountFull-4)) {
|
||||
nChunks++;
|
||||
}
|
||||
|
||||
for (int i = 0; i < nChunks; i++) {
|
||||
if (vertical) {
|
||||
skin.paintSkin(g,
|
||||
3, barRectHeight - i * (chunkSize + spaceSize) - chunkSize - 2,
|
||||
thickness, chunkSize, null);
|
||||
} else {
|
||||
if (isLeftToRight) {
|
||||
skin.paintSkin(g,
|
||||
4 + i * (chunkSize + spaceSize), 2,
|
||||
chunkSize, thickness, null);
|
||||
} else {
|
||||
skin.paintSkin(g,
|
||||
barRectWidth - (2 + (i+1) * (chunkSize + spaceSize)), 2,
|
||||
chunkSize, thickness, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
super.paintDeterminate(g, c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 1.6
|
||||
*/
|
||||
protected void setAnimationIndex(int newValue) {
|
||||
super.setAnimationIndex(newValue);
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
if (boxRect != null) {
|
||||
// get the full repaint area and add it the
|
||||
// previous one so we can erase it
|
||||
Rectangle chunk = getFullChunkBounds(boxRect);
|
||||
if (previousFullBox != null) {
|
||||
chunk.add(previousFullBox);
|
||||
}
|
||||
progressBar.repaint(chunk);
|
||||
} else {
|
||||
progressBar.repaint();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 1.6
|
||||
*/
|
||||
protected int getBoxLength(int availableLength, int otherDimension) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
return 6; // an apparently hard coded value in Windows
|
||||
}
|
||||
return super.getBoxLength(availableLength, otherDimension);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 1.6
|
||||
*/
|
||||
protected Rectangle getBox(Rectangle r) {
|
||||
Rectangle rect = super.getBox(r);
|
||||
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
boolean vertical = (progressBar.getOrientation()
|
||||
== JProgressBar.VERTICAL);
|
||||
Part part = vertical ? Part.PP_BARVERT : Part.PP_BAR;
|
||||
Insets ins = indeterminateInsets;
|
||||
|
||||
int currentFrame = getAnimationIndex();
|
||||
int framecount = getFrameCount()/2;
|
||||
|
||||
int gap = xp.getInt(progressBar, Part.PP_PROGRESS, null,
|
||||
Prop.PROGRESSSPACESIZE, 0);
|
||||
currentFrame = currentFrame % framecount;
|
||||
|
||||
// this code adjusts the chunk size to properly account for the
|
||||
// size and gap specified in the XP style. It also does it's own
|
||||
// box placement for the chunk animation. This is required because
|
||||
// the inherited algorithm from BasicProgressBarUI goes back and
|
||||
// forth whereas XP only goes in one direction. XP also has ghosted
|
||||
// trailing chunks to create the illusion of speed. This code
|
||||
// adjusts the pixel length of the animation to account for the
|
||||
// trails.
|
||||
if (!vertical) {
|
||||
rect.y = rect.y + ins.top;
|
||||
rect.height = progressBar.getHeight() - ins.top - ins.bottom;
|
||||
int len = progressBar.getWidth() - ins.left - ins.right;
|
||||
len += (rect.width+gap)*2; // add 2x for the trails
|
||||
double delta = (double)(len) / (double)framecount;
|
||||
rect.x = (int)(delta * currentFrame) + ins.left;
|
||||
} else {
|
||||
rect.x = rect.x + ins.left;
|
||||
rect.width = progressBar.getWidth() - ins.left - ins.right;
|
||||
int len = progressBar.getHeight() - ins.top - ins.bottom;
|
||||
len += (rect.height+gap)*2; // add 2x for the trails
|
||||
double delta = (double)(len) / (double)framecount;
|
||||
rect.y = (int)(delta * currentFrame) + ins.top;
|
||||
}
|
||||
}
|
||||
return rect;
|
||||
}
|
||||
|
||||
|
||||
protected void paintIndeterminate(Graphics g, JComponent c) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
boolean vertical = (progressBar.getOrientation()
|
||||
== JProgressBar.VERTICAL);
|
||||
int barRectWidth = progressBar.getWidth();
|
||||
int barRectHeight = progressBar.getHeight();
|
||||
paintXPBackground(g, vertical, barRectWidth, barRectHeight);
|
||||
|
||||
// Paint the bouncing box.
|
||||
boxRect = getBox(boxRect);
|
||||
if (boxRect != null) {
|
||||
g.setColor(progressBar.getForeground());
|
||||
if (!(g instanceof Graphics2D)) {
|
||||
return;
|
||||
}
|
||||
paintIndeterminateFrame(boxRect, (Graphics2D)g, vertical,
|
||||
barRectWidth, barRectHeight);
|
||||
if (progressBar.isStringPainted()) {
|
||||
if (!vertical) {
|
||||
paintString(g, -1, -1, barRectWidth, barRectHeight, 0, null);
|
||||
} else {
|
||||
paintString(g, 1, 1, barRectWidth, barRectHeight, 0, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
super.paintIndeterminate(g, c);
|
||||
}
|
||||
}
|
||||
|
||||
private Rectangle getFullChunkBounds(Rectangle box) {
|
||||
boolean vertical = (progressBar.getOrientation() == JProgressBar.VERTICAL);
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
int gap = (xp != null) ? xp.getInt(progressBar, Part.PP_PROGRESS,
|
||||
null, Prop.PROGRESSSPACESIZE, 0)
|
||||
: 0;
|
||||
|
||||
if (!vertical) {
|
||||
int chunksize = box.width+gap;
|
||||
return new Rectangle(box.x-chunksize*2, box.y, chunksize*3, box.height);
|
||||
} else {
|
||||
int chunksize = box.height+gap;
|
||||
return new Rectangle(box.x, box.y-chunksize*2, box.width, chunksize*3);
|
||||
}
|
||||
}
|
||||
|
||||
private void paintIndeterminateFrame(Rectangle box, Graphics2D g,
|
||||
boolean vertical,
|
||||
int bgwidth, int bgheight) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
// create a new graphics to keep drawing surface state
|
||||
Graphics2D gfx = (Graphics2D)g.create();
|
||||
|
||||
Part part = vertical ? Part.PP_BARVERT : Part.PP_BAR;
|
||||
Part chunk = vertical ? Part.PP_CHUNKVERT : Part.PP_CHUNK;
|
||||
|
||||
// calculate the chunk offsets
|
||||
int gap = xp.getInt(progressBar, Part.PP_PROGRESS, null,
|
||||
Prop.PROGRESSSPACESIZE, 0);
|
||||
int deltax = 0;
|
||||
int deltay = 0;
|
||||
if (!vertical) {
|
||||
deltax = -box.width - gap;
|
||||
deltay = 0;
|
||||
} else {
|
||||
deltax = 0;
|
||||
deltay = -box.height - gap;
|
||||
}
|
||||
|
||||
// Calculate the area of the chunks combined
|
||||
Rectangle fullBox = getFullChunkBounds(box);
|
||||
|
||||
// save this box for the next time
|
||||
previousFullBox = fullBox;
|
||||
|
||||
// this is the entire progress bar minus the track and borders
|
||||
Insets ins = indeterminateInsets;
|
||||
Rectangle progbarExtents = new Rectangle(ins.left, ins.top,
|
||||
bgwidth - ins.left - ins.right,
|
||||
bgheight - ins.top - ins.bottom);
|
||||
|
||||
// only paint where the chunks overlap with the progress bar drawing area
|
||||
Rectangle repaintArea = progbarExtents.intersection(fullBox);
|
||||
|
||||
// adjust the cliprect to chop the chunks when they go off the end
|
||||
gfx.clip(repaintArea);
|
||||
|
||||
// get the skin
|
||||
XPStyle.Skin skin = xp.getSkin(progressBar, chunk);
|
||||
|
||||
// do the drawing
|
||||
gfx.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.8f));
|
||||
skin.paintSkin(gfx, box.x, box.y, box.width, box.height, null);
|
||||
box.translate(deltax, deltay);
|
||||
gfx.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
|
||||
skin.paintSkin(gfx, box.x, box.y, box.width, box.height, null);
|
||||
box.translate(deltax, deltay);
|
||||
gfx.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f));
|
||||
skin.paintSkin(gfx, box.x, box.y, box.width, box.height, null);
|
||||
|
||||
// get rid of our clip and composite changes
|
||||
gfx.dispose();
|
||||
}
|
||||
|
||||
private void paintXPBackground(Graphics g, boolean vertical,
|
||||
int barRectWidth, int barRectHeight) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp == null) {
|
||||
return;
|
||||
}
|
||||
Part part = vertical ? Part.PP_BARVERT : Part.PP_BAR;
|
||||
Skin skin = xp.getSkin(progressBar, part);
|
||||
|
||||
// Paint background
|
||||
skin.paintSkin(g, 0, 0, barRectWidth, barRectHeight, null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
|
||||
import com.sun.java.swing.plaf.windows.TMSchema.Part;
|
||||
import com.sun.java.swing.plaf.windows.TMSchema.State;
|
||||
|
||||
/**
|
||||
* Windows rendition of the component.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public class WindowsRadioButtonMenuItemUI extends BasicRadioButtonMenuItemUI {
|
||||
|
||||
final WindowsMenuItemUIAccessor accessor =
|
||||
new WindowsMenuItemUIAccessor() {
|
||||
|
||||
public JMenuItem getMenuItem() {
|
||||
return menuItem;
|
||||
}
|
||||
|
||||
public State getState(JMenuItem menuItem) {
|
||||
return WindowsMenuItemUI.getState(this, menuItem);
|
||||
}
|
||||
|
||||
public Part getPart(JMenuItem menuItem) {
|
||||
return WindowsMenuItemUI.getPart(this, menuItem);
|
||||
}
|
||||
};
|
||||
public static ComponentUI createUI(JComponent b) {
|
||||
return new WindowsRadioButtonMenuItemUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void paintBackground(Graphics g, JMenuItem menuItem,
|
||||
Color bgColor) {
|
||||
if (WindowsMenuItemUI.isVistaPainting()) {
|
||||
WindowsMenuItemUI.paintBackground(accessor, g, menuItem, bgColor);
|
||||
return;
|
||||
}
|
||||
super.paintBackground(g, menuItem, bgColor);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method which renders the text of the current menu item.
|
||||
* <p>
|
||||
* @param g Graphics context
|
||||
* @param menuItem Current menu item to render
|
||||
* @param textRect Bounding rectangle to render the text.
|
||||
* @param text String to render
|
||||
* @since 1.4
|
||||
*/
|
||||
protected void paintText(Graphics g, JMenuItem menuItem,
|
||||
Rectangle textRect, String text) {
|
||||
if (WindowsMenuItemUI.isVistaPainting()) {
|
||||
WindowsMenuItemUI.paintText(accessor, g, menuItem, textRect, text);
|
||||
return;
|
||||
}
|
||||
ButtonModel model = menuItem.getModel();
|
||||
Color oldColor = g.getColor();
|
||||
|
||||
if(model.isEnabled() && model.isArmed()) {
|
||||
g.setColor(selectionForeground); // Uses protected field.
|
||||
}
|
||||
|
||||
WindowsGraphicsUtils.paintText(g, menuItem, textRect, text, 0);
|
||||
|
||||
g.setColor(oldColor);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import sun.awt.AppContext;
|
||||
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.*;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
|
||||
/**
|
||||
* Windows rendition of the component.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public class WindowsRadioButtonUI extends BasicRadioButtonUI
|
||||
{
|
||||
private static final Object WINDOWS_RADIO_BUTTON_UI_KEY = new Object();
|
||||
|
||||
protected int dashedRectGapX;
|
||||
protected int dashedRectGapY;
|
||||
protected int dashedRectGapWidth;
|
||||
protected int dashedRectGapHeight;
|
||||
|
||||
protected Color focusColor;
|
||||
|
||||
private boolean initialized = false;
|
||||
|
||||
// ********************************
|
||||
// Create PLAF
|
||||
// ********************************
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
AppContext appContext = AppContext.getAppContext();
|
||||
WindowsRadioButtonUI windowsRadioButtonUI =
|
||||
(WindowsRadioButtonUI) appContext.get(WINDOWS_RADIO_BUTTON_UI_KEY);
|
||||
if (windowsRadioButtonUI == null) {
|
||||
windowsRadioButtonUI = new WindowsRadioButtonUI();
|
||||
appContext.put(WINDOWS_RADIO_BUTTON_UI_KEY, windowsRadioButtonUI);
|
||||
}
|
||||
return windowsRadioButtonUI;
|
||||
}
|
||||
|
||||
// ********************************
|
||||
// Defaults
|
||||
// ********************************
|
||||
public void installDefaults(AbstractButton b) {
|
||||
super.installDefaults(b);
|
||||
if(!initialized) {
|
||||
dashedRectGapX = ((Integer)UIManager.get("Button.dashedRectGapX")).intValue();
|
||||
dashedRectGapY = ((Integer)UIManager.get("Button.dashedRectGapY")).intValue();
|
||||
dashedRectGapWidth = ((Integer)UIManager.get("Button.dashedRectGapWidth")).intValue();
|
||||
dashedRectGapHeight = ((Integer)UIManager.get("Button.dashedRectGapHeight")).intValue();
|
||||
focusColor = UIManager.getColor(getPropertyPrefix() + "focus");
|
||||
initialized = true;
|
||||
}
|
||||
if (XPStyle.getXP() != null) {
|
||||
LookAndFeel.installProperty(b, "rolloverEnabled", Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
protected void uninstallDefaults(AbstractButton b) {
|
||||
super.uninstallDefaults(b);
|
||||
initialized = false;
|
||||
}
|
||||
|
||||
protected Color getFocusColor() {
|
||||
return focusColor;
|
||||
}
|
||||
|
||||
// ********************************
|
||||
// Paint Methods
|
||||
// ********************************
|
||||
|
||||
/**
|
||||
* Overridden method to render the text without the mnemonic
|
||||
*/
|
||||
protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) {
|
||||
WindowsGraphicsUtils.paintText(g, b, textRect, text, getTextShiftOffset());
|
||||
}
|
||||
|
||||
|
||||
protected void paintFocus(Graphics g, Rectangle textRect, Dimension d){
|
||||
g.setColor(getFocusColor());
|
||||
BasicGraphicsUtils.drawDashedRect(g, textRect.x, textRect.y, textRect.width, textRect.height);
|
||||
}
|
||||
|
||||
// ********************************
|
||||
// Layout Methods
|
||||
// ********************************
|
||||
public Dimension getPreferredSize(JComponent c) {
|
||||
Dimension d = super.getPreferredSize(c);
|
||||
|
||||
/* Ensure that the width and height of the button is odd,
|
||||
* to allow for the focus line if focus is painted
|
||||
*/
|
||||
AbstractButton b = (AbstractButton)c;
|
||||
if (d != null && b.isFocusPainted()) {
|
||||
if(d.width % 2 == 0) { d.width += 1; }
|
||||
if(d.height % 2 == 0) { d.height += 1; }
|
||||
}
|
||||
return d;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.Component;
|
||||
import java.awt.Container;
|
||||
import java.awt.Event;
|
||||
import java.awt.KeyEventPostProcessor;
|
||||
import java.awt.Window;
|
||||
import java.awt.Toolkit;
|
||||
|
||||
import sun.awt.AWTAccessor;
|
||||
import sun.awt.SunToolkit;
|
||||
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
import javax.swing.AbstractAction;
|
||||
import javax.swing.ActionMap;
|
||||
import javax.swing.InputMap;
|
||||
import javax.swing.KeyStroke;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JRootPane;
|
||||
import javax.swing.SwingUtilities;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.AbstractButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JMenu;
|
||||
import javax.swing.JMenuBar;
|
||||
import javax.swing.MenuElement;
|
||||
import javax.swing.MenuSelectionManager;
|
||||
|
||||
import javax.swing.plaf.ActionMapUIResource;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.InputMapUIResource;
|
||||
|
||||
import javax.swing.plaf.basic.BasicRootPaneUI;
|
||||
import javax.swing.plaf.basic.ComboPopup;
|
||||
|
||||
/**
|
||||
* Windows implementation of RootPaneUI, there is one shared between all
|
||||
* JRootPane instances.
|
||||
*
|
||||
* @author Mark Davidson
|
||||
* @since 1.4
|
||||
*/
|
||||
public class WindowsRootPaneUI extends BasicRootPaneUI {
|
||||
|
||||
private final static WindowsRootPaneUI windowsRootPaneUI = new WindowsRootPaneUI();
|
||||
static final AltProcessor altProcessor = new AltProcessor();
|
||||
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return windowsRootPaneUI;
|
||||
}
|
||||
|
||||
static class AltProcessor implements KeyEventPostProcessor {
|
||||
static boolean altKeyPressed = false;
|
||||
static boolean menuCanceledOnPress = false;
|
||||
static JRootPane root = null;
|
||||
static Window winAncestor = null;
|
||||
|
||||
void altPressed(KeyEvent ev) {
|
||||
MenuSelectionManager msm =
|
||||
MenuSelectionManager.defaultManager();
|
||||
MenuElement[] path = msm.getSelectedPath();
|
||||
if (path.length > 0 && ! (path[0] instanceof ComboPopup)) {
|
||||
msm.clearSelectedPath();
|
||||
menuCanceledOnPress = true;
|
||||
ev.consume();
|
||||
} else if(path.length > 0) { // We are in ComboBox
|
||||
menuCanceledOnPress = false;
|
||||
WindowsLookAndFeel.setMnemonicHidden(false);
|
||||
WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
|
||||
ev.consume();
|
||||
} else {
|
||||
menuCanceledOnPress = false;
|
||||
WindowsLookAndFeel.setMnemonicHidden(false);
|
||||
WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
|
||||
JMenuBar mbar = root != null ? root.getJMenuBar() : null;
|
||||
if(mbar == null && winAncestor instanceof JFrame) {
|
||||
mbar = ((JFrame)winAncestor).getJMenuBar();
|
||||
}
|
||||
JMenu menu = mbar != null ? mbar.getMenu(0) : null;
|
||||
if(menu != null) {
|
||||
ev.consume();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void altReleased(KeyEvent ev) {
|
||||
if (menuCanceledOnPress) {
|
||||
WindowsLookAndFeel.setMnemonicHidden(true);
|
||||
WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
|
||||
return;
|
||||
}
|
||||
|
||||
MenuSelectionManager msm =
|
||||
MenuSelectionManager.defaultManager();
|
||||
if (msm.getSelectedPath().length == 0) {
|
||||
// if no menu is active, we try activating the menubar
|
||||
|
||||
JMenuBar mbar = root != null ? root.getJMenuBar() : null;
|
||||
if(mbar == null && winAncestor instanceof JFrame) {
|
||||
mbar = ((JFrame)winAncestor).getJMenuBar();
|
||||
}
|
||||
JMenu menu = mbar != null ? mbar.getMenu(0) : null;
|
||||
|
||||
// It might happen that the altRelease event is processed
|
||||
// with a reasonable delay since it has been generated.
|
||||
// Here we check the last deactivation time of the containing
|
||||
// window. If this time appears to be greater than the altRelease
|
||||
// event time the event is skipped to avoid unexpected menu
|
||||
// activation. See 7121442.
|
||||
// Also we must ensure that original source of key event belongs
|
||||
// to the same window object as winAncestor. See 8001633.
|
||||
boolean skip = false;
|
||||
Toolkit tk = Toolkit.getDefaultToolkit();
|
||||
if (tk instanceof SunToolkit) {
|
||||
Component originalSource = AWTAccessor.getKeyEventAccessor()
|
||||
.getOriginalSource(ev);
|
||||
skip = SunToolkit.getContainingWindow(originalSource) != winAncestor ||
|
||||
ev.getWhen() <= ((SunToolkit) tk).getWindowDeactivationTime(winAncestor);
|
||||
}
|
||||
|
||||
if (menu != null && !skip) {
|
||||
MenuElement[] path = new MenuElement[2];
|
||||
path[0] = mbar;
|
||||
path[1] = menu;
|
||||
msm.setSelectedPath(path);
|
||||
} else if(!WindowsLookAndFeel.isMnemonicHidden()) {
|
||||
WindowsLookAndFeel.setMnemonicHidden(true);
|
||||
WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
|
||||
}
|
||||
} else {
|
||||
if((msm.getSelectedPath())[0] instanceof ComboPopup) {
|
||||
WindowsLookAndFeel.setMnemonicHidden(true);
|
||||
WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public boolean postProcessKeyEvent(KeyEvent ev) {
|
||||
if(ev.isConsumed() && ev.getKeyCode() != KeyEvent.VK_ALT) {
|
||||
// mnemonic combination, it's consumed, but we need
|
||||
// set altKeyPressed to false, otherwise after selection
|
||||
// component by mnemonic combination a menu will be open
|
||||
altKeyPressed = false;
|
||||
return false;
|
||||
}
|
||||
if (ev.getKeyCode() == KeyEvent.VK_ALT) {
|
||||
root = SwingUtilities.getRootPane(ev.getComponent());
|
||||
winAncestor = (root == null ? null :
|
||||
SwingUtilities.getWindowAncestor(root));
|
||||
|
||||
if (ev.getID() == KeyEvent.KEY_PRESSED) {
|
||||
if (!altKeyPressed) {
|
||||
altPressed(ev);
|
||||
}
|
||||
altKeyPressed = true;
|
||||
return true;
|
||||
} else if (ev.getID() == KeyEvent.KEY_RELEASED) {
|
||||
if (altKeyPressed) {
|
||||
altReleased(ev);
|
||||
} else {
|
||||
MenuSelectionManager msm =
|
||||
MenuSelectionManager.defaultManager();
|
||||
MenuElement[] path = msm.getSelectedPath();
|
||||
if (path.length <= 0) {
|
||||
WindowsLookAndFeel.setMnemonicHidden(true);
|
||||
WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
|
||||
}
|
||||
}
|
||||
altKeyPressed = false;
|
||||
}
|
||||
root = null;
|
||||
winAncestor = null;
|
||||
} else {
|
||||
altKeyPressed = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,502 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.image.*;
|
||||
import java.lang.ref.*;
|
||||
import java.util.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.*;
|
||||
import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
|
||||
|
||||
|
||||
/**
|
||||
* Windows rendition of the component.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public class WindowsScrollBarUI extends BasicScrollBarUI {
|
||||
private Grid thumbGrid;
|
||||
private Grid highlightGrid;
|
||||
private Dimension horizontalThumbSize;
|
||||
private Dimension verticalThumbSize;
|
||||
|
||||
/**
|
||||
* Creates a UI for a JScrollBar.
|
||||
*
|
||||
* @param c the text field
|
||||
* @return the UI
|
||||
*/
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new WindowsScrollBarUI();
|
||||
}
|
||||
|
||||
protected void installDefaults() {
|
||||
super.installDefaults();
|
||||
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
scrollbar.setBorder(null);
|
||||
horizontalThumbSize = getSize(scrollbar, xp, Part.SBP_THUMBBTNHORZ);
|
||||
verticalThumbSize = getSize(scrollbar, xp, Part.SBP_THUMBBTNVERT);
|
||||
} else {
|
||||
horizontalThumbSize = null;
|
||||
verticalThumbSize = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Dimension getSize(Component component, XPStyle xp, Part part) {
|
||||
Skin skin = xp.getSkin(component, part);
|
||||
return new Dimension(skin.getWidth(), skin.getHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Dimension getMinimumThumbSize() {
|
||||
if ((horizontalThumbSize == null) || (verticalThumbSize == null)) {
|
||||
return super.getMinimumThumbSize();
|
||||
}
|
||||
return JScrollBar.HORIZONTAL == scrollbar.getOrientation()
|
||||
? horizontalThumbSize
|
||||
: verticalThumbSize;
|
||||
}
|
||||
|
||||
public void uninstallUI(JComponent c) {
|
||||
super.uninstallUI(c);
|
||||
thumbGrid = highlightGrid = null;
|
||||
}
|
||||
|
||||
protected void configureScrollBarColors() {
|
||||
super.configureScrollBarColors();
|
||||
Color color = UIManager.getColor("ScrollBar.trackForeground");
|
||||
if (color != null && trackColor != null) {
|
||||
thumbGrid = Grid.getGrid(color, trackColor);
|
||||
}
|
||||
|
||||
color = UIManager.getColor("ScrollBar.trackHighlightForeground");
|
||||
if (color != null && trackHighlightColor != null) {
|
||||
highlightGrid = Grid.getGrid(color, trackHighlightColor);
|
||||
}
|
||||
}
|
||||
|
||||
protected JButton createDecreaseButton(int orientation) {
|
||||
return new WindowsArrowButton(orientation,
|
||||
UIManager.getColor("ScrollBar.thumb"),
|
||||
UIManager.getColor("ScrollBar.thumbShadow"),
|
||||
UIManager.getColor("ScrollBar.thumbDarkShadow"),
|
||||
UIManager.getColor("ScrollBar.thumbHighlight"));
|
||||
}
|
||||
|
||||
protected JButton createIncreaseButton(int orientation) {
|
||||
return new WindowsArrowButton(orientation,
|
||||
UIManager.getColor("ScrollBar.thumb"),
|
||||
UIManager.getColor("ScrollBar.thumbShadow"),
|
||||
UIManager.getColor("ScrollBar.thumbDarkShadow"),
|
||||
UIManager.getColor("ScrollBar.thumbHighlight"));
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 1.6
|
||||
*/
|
||||
@Override
|
||||
protected ArrowButtonListener createArrowButtonListener(){
|
||||
// we need to repaint the entire scrollbar because state change for each
|
||||
// button causes a state change for the thumb and other button on Vista
|
||||
if(XPStyle.isVista()) {
|
||||
return new ArrowButtonListener() {
|
||||
public void mouseEntered(MouseEvent evt) {
|
||||
repaint();
|
||||
super.mouseEntered(evt);
|
||||
}
|
||||
public void mouseExited(MouseEvent evt) {
|
||||
repaint();
|
||||
super.mouseExited(evt);
|
||||
}
|
||||
private void repaint() {
|
||||
scrollbar.repaint();
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return super.createArrowButtonListener();
|
||||
}
|
||||
}
|
||||
|
||||
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds){
|
||||
boolean v = (scrollbar.getOrientation() == JScrollBar.VERTICAL);
|
||||
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
JScrollBar sb = (JScrollBar)c;
|
||||
State state = State.NORMAL;
|
||||
// Pending: Implement rollover (hot) and pressed
|
||||
if (!sb.isEnabled()) {
|
||||
state = State.DISABLED;
|
||||
}
|
||||
Part part = v ? Part.SBP_LOWERTRACKVERT : Part.SBP_LOWERTRACKHORZ;
|
||||
xp.getSkin(sb, part).paintSkin(g, trackBounds, state);
|
||||
} else if (thumbGrid == null) {
|
||||
super.paintTrack(g, c, trackBounds);
|
||||
}
|
||||
else {
|
||||
thumbGrid.paint(g, trackBounds.x, trackBounds.y, trackBounds.width,
|
||||
trackBounds.height);
|
||||
if (trackHighlight == DECREASE_HIGHLIGHT) {
|
||||
paintDecreaseHighlight(g);
|
||||
}
|
||||
else if (trackHighlight == INCREASE_HIGHLIGHT) {
|
||||
paintIncreaseHighlight(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
|
||||
boolean v = (scrollbar.getOrientation() == JScrollBar.VERTICAL);
|
||||
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
JScrollBar sb = (JScrollBar)c;
|
||||
State state = State.NORMAL;
|
||||
if (!sb.isEnabled()) {
|
||||
state = State.DISABLED;
|
||||
} else if (isDragging) {
|
||||
state = State.PRESSED;
|
||||
} else if (isThumbRollover()) {
|
||||
state = State.HOT;
|
||||
} else if (XPStyle.isVista()) {
|
||||
if ((incrButton != null && incrButton.getModel().isRollover()) ||
|
||||
(decrButton != null && decrButton.getModel().isRollover())) {
|
||||
state = State.HOVER;
|
||||
}
|
||||
}
|
||||
// Paint thumb
|
||||
Part thumbPart = v ? Part.SBP_THUMBBTNVERT : Part.SBP_THUMBBTNHORZ;
|
||||
xp.getSkin(sb, thumbPart).paintSkin(g, thumbBounds, state);
|
||||
// Paint gripper
|
||||
Part gripperPart = v ? Part.SBP_GRIPPERVERT : Part.SBP_GRIPPERHORZ;
|
||||
Skin skin = xp.getSkin(sb, gripperPart);
|
||||
Insets gripperInsets = xp.getMargin(c, thumbPart, null, Prop.CONTENTMARGINS);
|
||||
if (gripperInsets == null ||
|
||||
(v && (thumbBounds.height - gripperInsets.top -
|
||||
gripperInsets.bottom >= skin.getHeight())) ||
|
||||
(!v && (thumbBounds.width - gripperInsets.left -
|
||||
gripperInsets.right >= skin.getWidth()))) {
|
||||
skin.paintSkin(g,
|
||||
thumbBounds.x + (thumbBounds.width - skin.getWidth()) / 2,
|
||||
thumbBounds.y + (thumbBounds.height - skin.getHeight()) / 2,
|
||||
skin.getWidth(), skin.getHeight(), state);
|
||||
}
|
||||
} else {
|
||||
super.paintThumb(g, c, thumbBounds);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void paintDecreaseHighlight(Graphics g) {
|
||||
if (highlightGrid == null) {
|
||||
super.paintDecreaseHighlight(g);
|
||||
}
|
||||
else {
|
||||
Insets insets = scrollbar.getInsets();
|
||||
Rectangle thumbR = getThumbBounds();
|
||||
int x, y, w, h;
|
||||
|
||||
if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
|
||||
x = insets.left;
|
||||
y = decrButton.getY() + decrButton.getHeight();
|
||||
w = scrollbar.getWidth() - (insets.left + insets.right);
|
||||
h = thumbR.y - y;
|
||||
}
|
||||
else {
|
||||
x = decrButton.getX() + decrButton.getHeight();
|
||||
y = insets.top;
|
||||
w = thumbR.x - x;
|
||||
h = scrollbar.getHeight() - (insets.top + insets.bottom);
|
||||
}
|
||||
highlightGrid.paint(g, x, y, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void paintIncreaseHighlight(Graphics g) {
|
||||
if (highlightGrid == null) {
|
||||
super.paintDecreaseHighlight(g);
|
||||
}
|
||||
else {
|
||||
Insets insets = scrollbar.getInsets();
|
||||
Rectangle thumbR = getThumbBounds();
|
||||
int x, y, w, h;
|
||||
|
||||
if (scrollbar.getOrientation() == JScrollBar.VERTICAL) {
|
||||
x = insets.left;
|
||||
y = thumbR.y + thumbR.height;
|
||||
w = scrollbar.getWidth() - (insets.left + insets.right);
|
||||
h = incrButton.getY() - y;
|
||||
}
|
||||
else {
|
||||
x = thumbR.x + thumbR.width;
|
||||
y = insets.top;
|
||||
w = incrButton.getX() - x;
|
||||
h = scrollbar.getHeight() - (insets.top + insets.bottom);
|
||||
}
|
||||
highlightGrid.paint(g, x, y, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 1.6
|
||||
*/
|
||||
@Override
|
||||
protected void setThumbRollover(boolean active) {
|
||||
boolean old = isThumbRollover();
|
||||
super.setThumbRollover(active);
|
||||
// we need to repaint the entire scrollbar because state change for thumb
|
||||
// causes state change for incr and decr buttons on Vista
|
||||
if(XPStyle.isVista() && active != old) {
|
||||
scrollbar.repaint();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* WindowsArrowButton is used for the buttons to position the
|
||||
* document up/down. It differs from BasicArrowButton in that the
|
||||
* preferred size is always a square.
|
||||
*/
|
||||
private class WindowsArrowButton extends BasicArrowButton {
|
||||
|
||||
public WindowsArrowButton(int direction, Color background, Color shadow,
|
||||
Color darkShadow, Color highlight) {
|
||||
super(direction, background, shadow, darkShadow, highlight);
|
||||
}
|
||||
|
||||
public WindowsArrowButton(int direction) {
|
||||
super(direction);
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
ButtonModel model = getModel();
|
||||
Skin skin = xp.getSkin(this, Part.SBP_ARROWBTN);
|
||||
State state = null;
|
||||
|
||||
boolean jointRollover = XPStyle.isVista() && (isThumbRollover() ||
|
||||
(this == incrButton && decrButton.getModel().isRollover()) ||
|
||||
(this == decrButton && incrButton.getModel().isRollover()));
|
||||
|
||||
// normal, rollover, pressed, disabled
|
||||
if (model.isArmed() && model.isPressed()) {
|
||||
switch (direction) {
|
||||
case NORTH: state = State.UPPRESSED; break;
|
||||
case SOUTH: state = State.DOWNPRESSED; break;
|
||||
case WEST: state = State.LEFTPRESSED; break;
|
||||
case EAST: state = State.RIGHTPRESSED; break;
|
||||
}
|
||||
} else if (!model.isEnabled()) {
|
||||
switch (direction) {
|
||||
case NORTH: state = State.UPDISABLED; break;
|
||||
case SOUTH: state = State.DOWNDISABLED; break;
|
||||
case WEST: state = State.LEFTDISABLED; break;
|
||||
case EAST: state = State.RIGHTDISABLED; break;
|
||||
}
|
||||
} else if (model.isRollover() || model.isPressed()) {
|
||||
switch (direction) {
|
||||
case NORTH: state = State.UPHOT; break;
|
||||
case SOUTH: state = State.DOWNHOT; break;
|
||||
case WEST: state = State.LEFTHOT; break;
|
||||
case EAST: state = State.RIGHTHOT; break;
|
||||
}
|
||||
} else if (jointRollover) {
|
||||
switch (direction) {
|
||||
case NORTH: state = State.UPHOVER; break;
|
||||
case SOUTH: state = State.DOWNHOVER; break;
|
||||
case WEST: state = State.LEFTHOVER; break;
|
||||
case EAST: state = State.RIGHTHOVER; break;
|
||||
}
|
||||
} else {
|
||||
switch (direction) {
|
||||
case NORTH: state = State.UPNORMAL; break;
|
||||
case SOUTH: state = State.DOWNNORMAL; break;
|
||||
case WEST: state = State.LEFTNORMAL; break;
|
||||
case EAST: state = State.RIGHTNORMAL; break;
|
||||
}
|
||||
}
|
||||
|
||||
skin.paintSkin(g, 0, 0, getWidth(), getHeight(), state);
|
||||
} else {
|
||||
super.paint(g);
|
||||
}
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize() {
|
||||
int size = 16;
|
||||
if (scrollbar != null) {
|
||||
switch (scrollbar.getOrientation()) {
|
||||
case JScrollBar.VERTICAL:
|
||||
size = scrollbar.getWidth();
|
||||
break;
|
||||
case JScrollBar.HORIZONTAL:
|
||||
size = scrollbar.getHeight();
|
||||
break;
|
||||
}
|
||||
size = Math.max(size, 5);
|
||||
}
|
||||
return new Dimension(size, size);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This should be pulled out into its own class if more classes need to
|
||||
* use it.
|
||||
* <p>
|
||||
* Grid is used to draw the track for windows scrollbars. Grids
|
||||
* are cached in a HashMap, with the key being the rgb components
|
||||
* of the foreground/background colors. Further the Grid is held through
|
||||
* a WeakRef so that it can be freed when no longer needed. As the
|
||||
* Grid is rather expensive to draw, it is drawn in a BufferedImage.
|
||||
*/
|
||||
private static class Grid {
|
||||
private static final int BUFFER_SIZE = 64;
|
||||
private static HashMap<String, WeakReference<Grid>> map;
|
||||
|
||||
private BufferedImage image;
|
||||
|
||||
static {
|
||||
map = new HashMap<String, WeakReference<Grid>>();
|
||||
}
|
||||
|
||||
public static Grid getGrid(Color fg, Color bg) {
|
||||
String key = fg.getRGB() + " " + bg.getRGB();
|
||||
WeakReference<Grid> ref = map.get(key);
|
||||
Grid grid = (ref == null) ? null : ref.get();
|
||||
if (grid == null) {
|
||||
grid = new Grid(fg, bg);
|
||||
map.put(key, new WeakReference<Grid>(grid));
|
||||
}
|
||||
return grid;
|
||||
}
|
||||
|
||||
public Grid(Color fg, Color bg) {
|
||||
int cmap[] = { fg.getRGB(), bg.getRGB() };
|
||||
IndexColorModel icm = new IndexColorModel(8, 2, cmap, 0, false, -1,
|
||||
DataBuffer.TYPE_BYTE);
|
||||
image = new BufferedImage(BUFFER_SIZE, BUFFER_SIZE,
|
||||
BufferedImage.TYPE_BYTE_INDEXED, icm);
|
||||
Graphics g = image.getGraphics();
|
||||
try {
|
||||
g.setClip(0, 0, BUFFER_SIZE, BUFFER_SIZE);
|
||||
paintGrid(g, fg, bg);
|
||||
}
|
||||
finally {
|
||||
g.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints the grid into the specified Graphics at the specified
|
||||
* location.
|
||||
*/
|
||||
public void paint(Graphics g, int x, int y, int w, int h) {
|
||||
Rectangle clipRect = g.getClipBounds();
|
||||
int minX = Math.max(x, clipRect.x);
|
||||
int minY = Math.max(y, clipRect.y);
|
||||
int maxX = Math.min(clipRect.x + clipRect.width, x + w);
|
||||
int maxY = Math.min(clipRect.y + clipRect.height, y + h);
|
||||
|
||||
if (maxX <= minX || maxY <= minY) {
|
||||
return;
|
||||
}
|
||||
int xOffset = (minX - x) % 2;
|
||||
for (int xCounter = minX; xCounter < maxX;
|
||||
xCounter += BUFFER_SIZE) {
|
||||
int yOffset = (minY - y) % 2;
|
||||
int width = Math.min(BUFFER_SIZE - xOffset,
|
||||
maxX - xCounter);
|
||||
|
||||
for (int yCounter = minY; yCounter < maxY;
|
||||
yCounter += BUFFER_SIZE) {
|
||||
int height = Math.min(BUFFER_SIZE - yOffset,
|
||||
maxY - yCounter);
|
||||
|
||||
g.drawImage(image, xCounter, yCounter,
|
||||
xCounter + width, yCounter + height,
|
||||
xOffset, yOffset,
|
||||
xOffset + width, yOffset + height, null);
|
||||
if (yOffset != 0) {
|
||||
yCounter -= yOffset;
|
||||
yOffset = 0;
|
||||
}
|
||||
}
|
||||
if (xOffset != 0) {
|
||||
xCounter -= xOffset;
|
||||
xOffset = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Actually renders the grid into the Graphics <code>g</code>.
|
||||
*/
|
||||
private void paintGrid(Graphics g, Color fg, Color bg) {
|
||||
Rectangle clipRect = g.getClipBounds();
|
||||
g.setColor(bg);
|
||||
g.fillRect(clipRect.x, clipRect.y, clipRect.width,
|
||||
clipRect.height);
|
||||
g.setColor(fg);
|
||||
g.translate(clipRect.x, clipRect.y);
|
||||
int width = clipRect.width;
|
||||
int height = clipRect.height;
|
||||
int xCounter = clipRect.x % 2;
|
||||
for (int end = width - height; xCounter < end; xCounter += 2) {
|
||||
g.drawLine(xCounter, 0, xCounter + height, height);
|
||||
}
|
||||
for (int end = width; xCounter < end; xCounter += 2) {
|
||||
g.drawLine(xCounter, 0, width, width - xCounter);
|
||||
}
|
||||
|
||||
int yCounter = ((clipRect.x % 2) == 0) ? 2 : 1;
|
||||
for (int end = height - width; yCounter < end; yCounter += 2) {
|
||||
g.drawLine(0, yCounter, width, yCounter + width);
|
||||
}
|
||||
for (int end = height; yCounter < end; yCounter += 2) {
|
||||
g.drawLine(0, yCounter, height - yCounter, height);
|
||||
}
|
||||
g.translate(-clipRect.x, -clipRect.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.*;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Windows rendition of the component.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public class WindowsScrollPaneUI extends BasicScrollPaneUI
|
||||
{}
|
||||
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (c) 2002, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import javax.swing.plaf.basic.*;
|
||||
|
||||
/**
|
||||
* Windows Separator.
|
||||
* <p>
|
||||
*
|
||||
*/
|
||||
public class WindowsSeparatorUI extends BasicSeparatorUI { }
|
||||
233
jdkSrc/jdk8/com/sun/java/swing/plaf/windows/WindowsSliderUI.java
Normal file
233
jdkSrc/jdk8/com/sun/java/swing/plaf/windows/WindowsSliderUI.java
Normal file
@@ -0,0 +1,233 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.*;
|
||||
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.*;
|
||||
import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
|
||||
|
||||
|
||||
/**
|
||||
* Windows rendition of the component.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public class WindowsSliderUI extends BasicSliderUI
|
||||
{
|
||||
private boolean rollover = false;
|
||||
private boolean pressed = false;
|
||||
|
||||
public WindowsSliderUI(JSlider b){
|
||||
super(b);
|
||||
}
|
||||
|
||||
public static ComponentUI createUI(JComponent b) {
|
||||
return new WindowsSliderUI((JSlider)b);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Overrides to return a private track listener subclass which handles
|
||||
* the HOT, PRESSED, and FOCUSED states.
|
||||
* @since 1.6
|
||||
*/
|
||||
protected TrackListener createTrackListener(JSlider slider) {
|
||||
return new WindowsTrackListener();
|
||||
}
|
||||
|
||||
private class WindowsTrackListener extends TrackListener {
|
||||
|
||||
public void mouseMoved(MouseEvent e) {
|
||||
updateRollover(thumbRect.contains(e.getX(), e.getY()));
|
||||
super.mouseMoved(e);
|
||||
}
|
||||
|
||||
public void mouseEntered(MouseEvent e) {
|
||||
updateRollover(thumbRect.contains(e.getX(), e.getY()));
|
||||
super.mouseEntered(e);
|
||||
}
|
||||
|
||||
public void mouseExited(MouseEvent e) {
|
||||
updateRollover(false);
|
||||
super.mouseExited(e);
|
||||
}
|
||||
|
||||
public void mousePressed(MouseEvent e) {
|
||||
updatePressed(thumbRect.contains(e.getX(), e.getY()));
|
||||
super.mousePressed(e);
|
||||
}
|
||||
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
updatePressed(false);
|
||||
super.mouseReleased(e);
|
||||
}
|
||||
|
||||
public void updatePressed(boolean newPressed) {
|
||||
// You can't press a disabled slider
|
||||
if (!slider.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
if (pressed != newPressed) {
|
||||
pressed = newPressed;
|
||||
slider.repaint(thumbRect);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateRollover(boolean newRollover) {
|
||||
// You can't have a rollover on a disabled slider
|
||||
if (!slider.isEnabled()) {
|
||||
return;
|
||||
}
|
||||
if (rollover != newRollover) {
|
||||
rollover = newRollover;
|
||||
slider.repaint(thumbRect);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void paintTrack(Graphics g) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
boolean vertical = (slider.getOrientation() == JSlider.VERTICAL);
|
||||
Part part = vertical ? Part.TKP_TRACKVERT : Part.TKP_TRACK;
|
||||
Skin skin = xp.getSkin(slider, part);
|
||||
|
||||
if (vertical) {
|
||||
int x = (trackRect.width - skin.getWidth()) / 2;
|
||||
skin.paintSkin(g, trackRect.x + x, trackRect.y,
|
||||
skin.getWidth(), trackRect.height, null);
|
||||
} else {
|
||||
int y = (trackRect.height - skin.getHeight()) / 2;
|
||||
skin.paintSkin(g, trackRect.x, trackRect.y + y,
|
||||
trackRect.width, skin.getHeight(), null);
|
||||
}
|
||||
} else {
|
||||
super.paintTrack(g);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void paintMinorTickForHorizSlider( Graphics g, Rectangle tickBounds, int x ) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
g.setColor(xp.getColor(slider, Part.TKP_TICS, null, Prop.COLOR, Color.black));
|
||||
}
|
||||
super.paintMinorTickForHorizSlider(g, tickBounds, x);
|
||||
}
|
||||
|
||||
protected void paintMajorTickForHorizSlider( Graphics g, Rectangle tickBounds, int x ) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
g.setColor(xp.getColor(slider, Part.TKP_TICS, null, Prop.COLOR, Color.black));
|
||||
}
|
||||
super.paintMajorTickForHorizSlider(g, tickBounds, x);
|
||||
}
|
||||
|
||||
protected void paintMinorTickForVertSlider( Graphics g, Rectangle tickBounds, int y ) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
g.setColor(xp.getColor(slider, Part.TKP_TICSVERT, null, Prop.COLOR, Color.black));
|
||||
}
|
||||
super.paintMinorTickForVertSlider(g, tickBounds, y);
|
||||
}
|
||||
|
||||
protected void paintMajorTickForVertSlider( Graphics g, Rectangle tickBounds, int y ) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
g.setColor(xp.getColor(slider, Part.TKP_TICSVERT, null, Prop.COLOR, Color.black));
|
||||
}
|
||||
super.paintMajorTickForVertSlider(g, tickBounds, y);
|
||||
}
|
||||
|
||||
|
||||
public void paintThumb(Graphics g) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
Part part = getXPThumbPart();
|
||||
State state = State.NORMAL;
|
||||
|
||||
if (slider.hasFocus()) {
|
||||
state = State.FOCUSED;
|
||||
}
|
||||
if (rollover) {
|
||||
state = State.HOT;
|
||||
}
|
||||
if (pressed) {
|
||||
state = State.PRESSED;
|
||||
}
|
||||
if(!slider.isEnabled()) {
|
||||
state = State.DISABLED;
|
||||
}
|
||||
|
||||
xp.getSkin(slider, part).paintSkin(g, thumbRect.x, thumbRect.y, state);
|
||||
} else {
|
||||
super.paintThumb(g);
|
||||
}
|
||||
}
|
||||
|
||||
protected Dimension getThumbSize() {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
Dimension size = new Dimension();
|
||||
Skin s = xp.getSkin(slider, getXPThumbPart());
|
||||
size.width = s.getWidth();
|
||||
size.height = s.getHeight();
|
||||
return size;
|
||||
} else {
|
||||
return super.getThumbSize();
|
||||
}
|
||||
}
|
||||
|
||||
private Part getXPThumbPart() {
|
||||
Part part;
|
||||
boolean vertical = (slider.getOrientation() == JSlider.VERTICAL);
|
||||
boolean leftToRight = slider.getComponentOrientation().isLeftToRight();
|
||||
Boolean paintThumbArrowShape =
|
||||
(Boolean)slider.getClientProperty("Slider.paintThumbArrowShape");
|
||||
if ((!slider.getPaintTicks() && paintThumbArrowShape == null) ||
|
||||
paintThumbArrowShape == Boolean.FALSE) {
|
||||
part = vertical ? Part.TKP_THUMBVERT
|
||||
: Part.TKP_THUMB;
|
||||
} else {
|
||||
part = vertical ? (leftToRight ? Part.TKP_THUMBRIGHT : Part.TKP_THUMBLEFT)
|
||||
: Part.TKP_THUMBBOTTOM;
|
||||
}
|
||||
return part;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.*;
|
||||
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.Part;
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.State;
|
||||
import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
|
||||
|
||||
|
||||
public class WindowsSpinnerUI extends BasicSpinnerUI {
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new WindowsSpinnerUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 1.6
|
||||
*/
|
||||
public void paint(Graphics g, JComponent c) {
|
||||
if (XPStyle.getXP() != null) {
|
||||
paintXPBackground(g, c);
|
||||
}
|
||||
super.paint(g,c);
|
||||
}
|
||||
|
||||
private State getXPState(JComponent c) {
|
||||
State state = State.NORMAL;
|
||||
if (!c.isEnabled()) {
|
||||
state = State.DISABLED;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
private void paintXPBackground(Graphics g, JComponent c) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp == null) {
|
||||
return;
|
||||
}
|
||||
Skin skin = xp.getSkin(c, Part.EP_EDIT);
|
||||
State state = getXPState(c);
|
||||
skin.paintSkin(g, 0, 0, c.getWidth(), c.getHeight(), state);
|
||||
}
|
||||
|
||||
protected Component createPreviousButton() {
|
||||
if (XPStyle.getXP() != null) {
|
||||
JButton xpButton = new XPStyle.GlyphButton(spinner, Part.SPNP_DOWN);
|
||||
Dimension size = UIManager.getDimension("Spinner.arrowButtonSize");
|
||||
xpButton.setPreferredSize(size);
|
||||
xpButton.setRequestFocusEnabled(false);
|
||||
installPreviousButtonListeners(xpButton);
|
||||
return xpButton;
|
||||
}
|
||||
return super.createPreviousButton();
|
||||
}
|
||||
|
||||
protected Component createNextButton() {
|
||||
if (XPStyle.getXP() != null) {
|
||||
JButton xpButton = new XPStyle.GlyphButton(spinner, Part.SPNP_UP);
|
||||
Dimension size = UIManager.getDimension("Spinner.arrowButtonSize");
|
||||
xpButton.setPreferredSize(size);
|
||||
xpButton.setRequestFocusEnabled(false);
|
||||
installNextButtonListeners(xpButton);
|
||||
return xpButton;
|
||||
}
|
||||
return super.createNextButton();
|
||||
}
|
||||
|
||||
private UIResource getUIResource(Object[] listeners) {
|
||||
for (int counter = 0; counter < listeners.length; counter++) {
|
||||
if (listeners[counter] instanceof UIResource) {
|
||||
return (UIResource)listeners[counter];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Copyright (c) 1998, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import javax.swing.JSplitPane;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.plaf.basic.BasicSplitPaneUI;
|
||||
import javax.swing.plaf.basic.BasicSplitPaneDivider;
|
||||
|
||||
|
||||
/**
|
||||
* Divider used for Windows split pane.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Jeff Dinkins
|
||||
*/
|
||||
public class WindowsSplitPaneDivider extends BasicSplitPaneDivider
|
||||
{
|
||||
|
||||
/**
|
||||
* Creates a new Windows SplitPaneDivider
|
||||
*/
|
||||
public WindowsSplitPaneDivider(BasicSplitPaneUI ui) {
|
||||
super(ui);
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints the divider.
|
||||
*/
|
||||
public void paint(Graphics g) {
|
||||
Color bgColor = (splitPane.hasFocus()) ?
|
||||
UIManager.getColor("SplitPane.shadow") :
|
||||
getBackground();
|
||||
Dimension size = getSize();
|
||||
|
||||
if(bgColor != null) {
|
||||
g.setColor(bgColor);
|
||||
g.fillRect(0, 0, size.width, size.height);
|
||||
}
|
||||
super.paint(g);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.*;
|
||||
|
||||
import javax.swing.plaf.basic.BasicSplitPaneUI;
|
||||
import javax.swing.plaf.basic.BasicSplitPaneDivider;
|
||||
import javax.swing.plaf.*;
|
||||
|
||||
|
||||
/**
|
||||
* Windows rendition of the component.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public class WindowsSplitPaneUI extends BasicSplitPaneUI
|
||||
{
|
||||
|
||||
public WindowsSplitPaneUI() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new WindowsSplitPaneUI instance
|
||||
*/
|
||||
public static ComponentUI createUI(JComponent x) {
|
||||
return new WindowsSplitPaneUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the default divider.
|
||||
*/
|
||||
public BasicSplitPaneDivider createDefaultDivider() {
|
||||
return new WindowsSplitPaneDivider(this);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,227 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2008, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.*;
|
||||
import java.util.Set;
|
||||
import java.util.HashSet;
|
||||
import java.awt.event.*;
|
||||
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.*;
|
||||
import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
|
||||
|
||||
|
||||
/**
|
||||
* Windows rendition of the component.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public class WindowsTabbedPaneUI extends BasicTabbedPaneUI {
|
||||
/**
|
||||
* Keys to use for forward focus traversal when the JComponent is
|
||||
* managing focus.
|
||||
*/
|
||||
private static Set<KeyStroke> managingFocusForwardTraversalKeys;
|
||||
|
||||
/**
|
||||
* Keys to use for backward focus traversal when the JComponent is
|
||||
* managing focus.
|
||||
*/
|
||||
private static Set<KeyStroke> managingFocusBackwardTraversalKeys;
|
||||
|
||||
private boolean contentOpaque = true;
|
||||
|
||||
protected void installDefaults() {
|
||||
super.installDefaults();
|
||||
contentOpaque = UIManager.getBoolean("TabbedPane.contentOpaque");
|
||||
|
||||
// focus forward traversal key
|
||||
if (managingFocusForwardTraversalKeys==null) {
|
||||
managingFocusForwardTraversalKeys = new HashSet<KeyStroke>();
|
||||
managingFocusForwardTraversalKeys.add(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0));
|
||||
}
|
||||
tabPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, managingFocusForwardTraversalKeys);
|
||||
// focus backward traversal key
|
||||
if (managingFocusBackwardTraversalKeys==null) {
|
||||
managingFocusBackwardTraversalKeys = new HashSet<KeyStroke>();
|
||||
managingFocusBackwardTraversalKeys.add( KeyStroke.getKeyStroke(KeyEvent.VK_TAB, InputEvent.SHIFT_MASK));
|
||||
}
|
||||
tabPane.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, managingFocusBackwardTraversalKeys);
|
||||
}
|
||||
|
||||
protected void uninstallDefaults() {
|
||||
// sets the focus forward and backward traversal keys to null
|
||||
// to restore the defaults
|
||||
tabPane.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null);
|
||||
tabPane.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null);
|
||||
super.uninstallDefaults();
|
||||
}
|
||||
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new WindowsTabbedPaneUI();
|
||||
}
|
||||
|
||||
protected void setRolloverTab(int index) {
|
||||
// Rollover is only supported on XP
|
||||
if (XPStyle.getXP() != null) {
|
||||
int oldRolloverTab = getRolloverTab();
|
||||
super.setRolloverTab(index);
|
||||
Rectangle r1 = null;
|
||||
Rectangle r2 = null;
|
||||
if ( (oldRolloverTab >= 0) && (oldRolloverTab < tabPane.getTabCount()) ) {
|
||||
r1 = getTabBounds(tabPane, oldRolloverTab);
|
||||
}
|
||||
if (index >= 0) {
|
||||
r2 = getTabBounds(tabPane, index);
|
||||
}
|
||||
if (r1 != null) {
|
||||
if (r2 != null) {
|
||||
tabPane.repaint(r1.union(r2));
|
||||
} else {
|
||||
tabPane.repaint(r1);
|
||||
}
|
||||
} else if (r2 != null) {
|
||||
tabPane.repaint(r2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void paintContentBorder(Graphics g, int tabPlacement, int selectedIndex) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null && (contentOpaque || tabPane.isOpaque())) {
|
||||
Skin skin = xp.getSkin(tabPane, Part.TABP_PANE);
|
||||
if (skin != null) {
|
||||
Insets insets = tabPane.getInsets();
|
||||
// Note: don't call getTabAreaInsets(), because it causes rotation.
|
||||
// Make sure "TabbedPane.tabsOverlapBorder" is set to true in WindowsLookAndFeel
|
||||
Insets tabAreaInsets = UIManager.getInsets("TabbedPane.tabAreaInsets");
|
||||
int x = insets.left;
|
||||
int y = insets.top;
|
||||
int w = tabPane.getWidth() - insets.right - insets.left;
|
||||
int h = tabPane.getHeight() - insets.top - insets.bottom;
|
||||
|
||||
// Expand area by tabAreaInsets.bottom to allow tabs to overlap onto the border.
|
||||
if (tabPlacement == LEFT || tabPlacement == RIGHT) {
|
||||
int tabWidth = calculateTabAreaWidth(tabPlacement, runCount, maxTabWidth);
|
||||
if (tabPlacement == LEFT) {
|
||||
x += (tabWidth - tabAreaInsets.bottom);
|
||||
}
|
||||
w -= (tabWidth - tabAreaInsets.bottom);
|
||||
} else {
|
||||
int tabHeight = calculateTabAreaHeight(tabPlacement, runCount, maxTabHeight);
|
||||
if (tabPlacement == TOP) {
|
||||
y += (tabHeight - tabAreaInsets.bottom);
|
||||
}
|
||||
h -= (tabHeight - tabAreaInsets.bottom);
|
||||
}
|
||||
|
||||
paintRotatedSkin(g, skin, tabPlacement, x, y, w, h, null);
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.paintContentBorder(g, tabPlacement, selectedIndex);
|
||||
}
|
||||
|
||||
protected void paintTabBackground(Graphics g, int tabPlacement, int tabIndex,
|
||||
int x, int y, int w, int h, boolean isSelected ) {
|
||||
if (XPStyle.getXP() == null) {
|
||||
super.paintTabBackground(g, tabPlacement, tabIndex, x, y, w, h, isSelected);
|
||||
}
|
||||
}
|
||||
|
||||
protected void paintTabBorder(Graphics g, int tabPlacement, int tabIndex,
|
||||
int x, int y, int w, int h, boolean isSelected ) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
Part part;
|
||||
|
||||
int tabCount = tabPane.getTabCount();
|
||||
int tabRun = getRunForTab(tabCount, tabIndex);
|
||||
if (tabRuns[tabRun] == tabIndex) {
|
||||
part = Part.TABP_TABITEMLEFTEDGE;
|
||||
} else if (tabCount > 1 && lastTabInRun(tabCount, tabRun) == tabIndex) {
|
||||
part = Part.TABP_TABITEMRIGHTEDGE;
|
||||
if (isSelected) {
|
||||
// Align with right edge
|
||||
if (tabPlacement == TOP || tabPlacement == BOTTOM) {
|
||||
w++;
|
||||
} else {
|
||||
h++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
part = Part.TABP_TABITEM;
|
||||
}
|
||||
|
||||
State state = State.NORMAL;
|
||||
if (isSelected) {
|
||||
state = State.SELECTED;
|
||||
} else if (tabIndex == getRolloverTab()) {
|
||||
state = State.HOT;
|
||||
}
|
||||
|
||||
paintRotatedSkin(g, xp.getSkin(tabPane, part), tabPlacement, x, y, w, h, state);
|
||||
} else {
|
||||
super.paintTabBorder(g, tabPlacement, tabIndex, x, y, w, h, isSelected);
|
||||
}
|
||||
}
|
||||
|
||||
private void paintRotatedSkin(Graphics g, Skin skin, int tabPlacement,
|
||||
int x, int y, int w, int h, State state) {
|
||||
Graphics2D g2d = (Graphics2D)g.create();
|
||||
g2d.translate(x, y);
|
||||
switch (tabPlacement) {
|
||||
case RIGHT: g2d.translate(w, 0);
|
||||
g2d.rotate(Math.toRadians(90.0));
|
||||
skin.paintSkin(g2d, 0, 0, h, w, state);
|
||||
break;
|
||||
|
||||
case LEFT: g2d.scale(-1.0, 1.0);
|
||||
g2d.rotate(Math.toRadians(90.0));
|
||||
skin.paintSkin(g2d, 0, 0, h, w, state);
|
||||
break;
|
||||
|
||||
case BOTTOM: g2d.translate(0, h);
|
||||
g2d.scale(-1.0, 1.0);
|
||||
g2d.rotate(Math.toRadians(180.0));
|
||||
skin.paintSkin(g2d, 0, 0, w, h, state);
|
||||
break;
|
||||
|
||||
case TOP:
|
||||
default: skin.paintSkin(g2d, 0, 0, w, h, state);
|
||||
}
|
||||
g2d.dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,246 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2010, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.table.*;
|
||||
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.*;
|
||||
import static com.sun.java.swing.plaf.windows.XPStyle.*;
|
||||
import sun.swing.table.*;
|
||||
import sun.swing.SwingUtilities2;
|
||||
|
||||
|
||||
public class WindowsTableHeaderUI extends BasicTableHeaderUI {
|
||||
private TableCellRenderer originalHeaderRenderer;
|
||||
|
||||
public static ComponentUI createUI(JComponent h) {
|
||||
return new WindowsTableHeaderUI();
|
||||
}
|
||||
|
||||
public void installUI(JComponent c) {
|
||||
super.installUI(c);
|
||||
|
||||
if (XPStyle.getXP() != null) {
|
||||
originalHeaderRenderer = header.getDefaultRenderer();
|
||||
if (originalHeaderRenderer instanceof UIResource) {
|
||||
header.setDefaultRenderer(new XPDefaultRenderer());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void uninstallUI(JComponent c) {
|
||||
if (header.getDefaultRenderer() instanceof XPDefaultRenderer) {
|
||||
header.setDefaultRenderer(originalHeaderRenderer);
|
||||
}
|
||||
super.uninstallUI(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void rolloverColumnUpdated(int oldColumn, int newColumn) {
|
||||
if (XPStyle.getXP() != null) {
|
||||
header.repaint(header.getHeaderRect(oldColumn));
|
||||
header.repaint(header.getHeaderRect(newColumn));
|
||||
}
|
||||
}
|
||||
|
||||
private class XPDefaultRenderer extends DefaultTableCellHeaderRenderer {
|
||||
Skin skin;
|
||||
boolean isSelected, hasFocus, hasRollover;
|
||||
int column;
|
||||
|
||||
XPDefaultRenderer() {
|
||||
setHorizontalAlignment(LEADING);
|
||||
}
|
||||
|
||||
public Component getTableCellRendererComponent(JTable table, Object value,
|
||||
boolean isSelected, boolean hasFocus,
|
||||
int row, int column) {
|
||||
super.getTableCellRendererComponent(table, value, isSelected,
|
||||
hasFocus, row, column);
|
||||
this.isSelected = isSelected;
|
||||
this.hasFocus = hasFocus;
|
||||
this.column = column;
|
||||
this.hasRollover = (column == getRolloverColumn());
|
||||
if (skin == null) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
skin = (xp != null) ? xp.getSkin(header, Part.HP_HEADERITEM) : null;
|
||||
}
|
||||
Insets margins = (skin != null) ? skin.getContentMargin() : null;
|
||||
Border border = null;
|
||||
int contentTop = 0;
|
||||
int contentLeft = 0;
|
||||
int contentBottom = 0;
|
||||
int contentRight = 0;
|
||||
if (margins != null) {
|
||||
contentTop = margins.top;
|
||||
contentLeft = margins.left;
|
||||
contentBottom = margins.bottom;
|
||||
contentRight = margins.right;
|
||||
}
|
||||
/* idk:
|
||||
* Both on Vista and XP there is some offset to the
|
||||
* HP_HEADERITEM content. It does not seem to come from
|
||||
* Prop.CONTENTMARGINS. Do not know where it is defined.
|
||||
* using some hardcoded values.
|
||||
*/
|
||||
contentLeft += 5;
|
||||
contentBottom += 4;
|
||||
contentRight += 5;
|
||||
|
||||
/* On Vista sortIcon is painted above the header's text.
|
||||
* We use border to paint it.
|
||||
*/
|
||||
Icon sortIcon;
|
||||
if (WindowsLookAndFeel.isOnVista()
|
||||
&& ((sortIcon = getIcon()) instanceof javax.swing.plaf.UIResource
|
||||
|| sortIcon == null)) {
|
||||
contentTop += 1;
|
||||
setIcon(null);
|
||||
sortIcon = null;
|
||||
SortOrder sortOrder =
|
||||
getColumnSortOrder(table, column);
|
||||
if (sortOrder != null) {
|
||||
switch (sortOrder) {
|
||||
case ASCENDING:
|
||||
sortIcon =
|
||||
UIManager.getIcon("Table.ascendingSortIcon");
|
||||
break;
|
||||
case DESCENDING:
|
||||
sortIcon =
|
||||
UIManager.getIcon("Table.descendingSortIcon");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (sortIcon != null) {
|
||||
contentBottom = sortIcon.getIconHeight();
|
||||
border = new IconBorder(sortIcon, contentTop, contentLeft,
|
||||
contentBottom, contentRight);
|
||||
} else {
|
||||
sortIcon =
|
||||
UIManager.getIcon("Table.ascendingSortIcon");
|
||||
int sortIconHeight =
|
||||
(sortIcon != null) ? sortIcon.getIconHeight() : 0;
|
||||
if (sortIconHeight != 0) {
|
||||
contentBottom = sortIconHeight;
|
||||
}
|
||||
border =
|
||||
new EmptyBorder(
|
||||
sortIconHeight + contentTop, contentLeft,
|
||||
contentBottom, contentRight);
|
||||
}
|
||||
} else {
|
||||
contentTop += 3;
|
||||
border = new EmptyBorder(contentTop, contentLeft,
|
||||
contentBottom, contentRight);
|
||||
}
|
||||
setBorder(border);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void paint(Graphics g) {
|
||||
Dimension size = getSize();
|
||||
State state = State.NORMAL;
|
||||
TableColumn draggedColumn = header.getDraggedColumn();
|
||||
if (draggedColumn != null &&
|
||||
column == SwingUtilities2.convertColumnIndexToView(
|
||||
header.getColumnModel(), draggedColumn.getModelIndex())) {
|
||||
state = State.PRESSED;
|
||||
} else if (isSelected || hasFocus || hasRollover) {
|
||||
state = State.HOT;
|
||||
}
|
||||
/* on Vista there are more states for sorted columns */
|
||||
if (WindowsLookAndFeel.isOnVista()) {
|
||||
SortOrder sortOrder = getColumnSortOrder(header.getTable(), column);
|
||||
if (sortOrder != null) {
|
||||
switch(sortOrder) {
|
||||
case ASCENDING:
|
||||
/* falls through */
|
||||
case DESCENDING:
|
||||
switch (state) {
|
||||
case NORMAL:
|
||||
state = State.SORTEDNORMAL;
|
||||
break;
|
||||
case PRESSED:
|
||||
state = State.SORTEDPRESSED;
|
||||
break;
|
||||
case HOT:
|
||||
state = State.SORTEDHOT;
|
||||
break;
|
||||
default:
|
||||
/* do nothing */
|
||||
}
|
||||
default :
|
||||
/* do nothing */
|
||||
}
|
||||
}
|
||||
}
|
||||
skin.paintSkin(g, 0, 0, size.width-1, size.height-1, state);
|
||||
super.paint(g);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A border with an Icon at the middle of the top side.
|
||||
* Outer insets can be provided for this border.
|
||||
*/
|
||||
private static class IconBorder implements Border, UIResource{
|
||||
private final Icon icon;
|
||||
private final int top;
|
||||
private final int left;
|
||||
private final int bottom;
|
||||
private final int right;
|
||||
/**
|
||||
* Creates this border;
|
||||
* @param icon - icon to paint for this border
|
||||
* @param top, left, bottom, right - outer insets for this border
|
||||
*/
|
||||
public IconBorder(Icon icon, int top, int left,
|
||||
int bottom, int right) {
|
||||
this.icon = icon;
|
||||
this.top = top;
|
||||
this.left = left;
|
||||
this.bottom = bottom;
|
||||
this.right = right;
|
||||
}
|
||||
public Insets getBorderInsets(Component c) {
|
||||
return new Insets(icon.getIconHeight() + top, left, bottom, right);
|
||||
}
|
||||
public boolean isBorderOpaque() {
|
||||
return false;
|
||||
}
|
||||
public void paintBorder(Component c, Graphics g, int x, int y,
|
||||
int width, int height) {
|
||||
icon.paintIcon(c, g,
|
||||
x + left + (width - left - right - icon.getIconWidth()) / 2,
|
||||
y + top);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.Caret;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Windows rendition of the component.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public class WindowsTextAreaUI extends BasicTextAreaUI {
|
||||
/**
|
||||
* Creates the object to use for a caret. By default an
|
||||
* instance of WindowsCaret is created. This method
|
||||
* can be redefined to provide something else that implements
|
||||
* the InputPosition interface or a subclass of DefaultCaret.
|
||||
*
|
||||
* @return the caret object
|
||||
*/
|
||||
protected Caret createCaret() {
|
||||
return new WindowsTextUI.WindowsCaret();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a UI for a JTextField.
|
||||
*
|
||||
* @param c the text field
|
||||
* @return the UI
|
||||
*/
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new WindowsTextAreaUI();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.BasicTextFieldUI;
|
||||
import javax.swing.text.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.UIResource;
|
||||
import sun.swing.DefaultLookup;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Provides the Windows look and feel for a text field. This
|
||||
* is basically the following customizations to the default
|
||||
* look-and-feel.
|
||||
* <ul>
|
||||
* <li>The border is beveled (using the standard control color).
|
||||
* <li>The background is white by default.
|
||||
* <li>The highlight color is a dark color, blue by default.
|
||||
* <li>The foreground color is high contrast in the selected
|
||||
* area, white by default. The unselected foreground is black.
|
||||
* <li>The cursor blinks at about 1/2 second intervals.
|
||||
* <li>The entire value is selected when focus is gained.
|
||||
* <li>Shift-left-arrow and shift-right-arrow extend selection
|
||||
* <li>Ctrl-left-arrow and ctrl-right-arrow act like home and
|
||||
* end respectively.
|
||||
* </ul>
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Timothy Prinzing
|
||||
*/
|
||||
public class WindowsTextFieldUI extends BasicTextFieldUI
|
||||
{
|
||||
/**
|
||||
* Creates a UI for a JTextField.
|
||||
*
|
||||
* @param c the text field
|
||||
* @return the UI
|
||||
*/
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new WindowsTextFieldUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Paints a background for the view. This will only be
|
||||
* called if isOpaque() on the associated component is
|
||||
* true. The default is to paint the background color
|
||||
* of the component.
|
||||
*
|
||||
* @param g the graphics context
|
||||
*/
|
||||
protected void paintBackground(Graphics g) {
|
||||
super.paintBackground(g);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the caret for a field.
|
||||
*
|
||||
* @return the caret
|
||||
*/
|
||||
protected Caret createCaret() {
|
||||
return new WindowsFieldCaret();
|
||||
}
|
||||
|
||||
/**
|
||||
* WindowsFieldCaret has different scrolling behavior than
|
||||
* DefaultCaret.
|
||||
*/
|
||||
static class WindowsFieldCaret extends DefaultCaret implements UIResource {
|
||||
|
||||
public WindowsFieldCaret() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the visibility of the caret according to
|
||||
* the windows feel which seems to be to move the
|
||||
* caret out into the field by about a quarter of
|
||||
* a field length if not visible.
|
||||
*/
|
||||
protected void adjustVisibility(Rectangle r) {
|
||||
SwingUtilities.invokeLater(new SafeScroller(r));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the painter for the Highlighter.
|
||||
*
|
||||
* @return the painter
|
||||
*/
|
||||
protected Highlighter.HighlightPainter getSelectionPainter() {
|
||||
return WindowsTextUI.WindowsPainter;
|
||||
}
|
||||
|
||||
|
||||
private class SafeScroller implements Runnable {
|
||||
SafeScroller(Rectangle r) {
|
||||
this.r = r;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
JTextField field = (JTextField) getComponent();
|
||||
if (field != null) {
|
||||
TextUI ui = field.getUI();
|
||||
int dot = getDot();
|
||||
// PENDING: We need to expose the bias in DefaultCaret.
|
||||
Position.Bias bias = Position.Bias.Forward;
|
||||
Rectangle startRect = null;
|
||||
try {
|
||||
startRect = ui.modelToView(field, dot, bias);
|
||||
} catch (BadLocationException ble) {}
|
||||
|
||||
Insets i = field.getInsets();
|
||||
BoundedRangeModel vis = field.getHorizontalVisibility();
|
||||
int x = r.x + vis.getValue() - i.left;
|
||||
int quarterSpan = vis.getExtent() / 4;
|
||||
if (r.x < i.left) {
|
||||
vis.setValue(x - quarterSpan);
|
||||
} else if (r.x + r.width > i.left + vis.getExtent()) {
|
||||
vis.setValue(x - (3 * quarterSpan));
|
||||
}
|
||||
// If we scroll, our visual location will have changed,
|
||||
// but we won't have updated our internal location as
|
||||
// the model hasn't changed. This checks for the change,
|
||||
// and if necessary, resets the internal location.
|
||||
if (startRect != null) {
|
||||
try {
|
||||
Rectangle endRect;
|
||||
endRect = ui.modelToView(field, dot, bias);
|
||||
if (endRect != null && !endRect.equals(startRect)){
|
||||
damage(endRect);
|
||||
}
|
||||
} catch (BadLocationException ble) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Rectangle r;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1998, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.text.Caret;
|
||||
|
||||
|
||||
/**
|
||||
* Windows rendition of the component.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public class WindowsTextPaneUI extends BasicTextPaneUI
|
||||
{
|
||||
/**
|
||||
* Creates a UI for a JTextPane.
|
||||
*
|
||||
* @param c the styled text component
|
||||
* @return the UI
|
||||
*/
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new WindowsTextPaneUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the object to use for a caret. By default an
|
||||
* instance of WindowsCaret is created. This method
|
||||
* can be redefined to provide something else that implements
|
||||
* the InputPosition interface or a subclass of DefaultCaret.
|
||||
*
|
||||
* @return the caret object
|
||||
*/
|
||||
protected Caret createCaret() {
|
||||
return new WindowsTextUI.WindowsCaret();
|
||||
}
|
||||
}
|
||||
236
jdkSrc/jdk8/com/sun/java/swing/plaf/windows/WindowsTextUI.java
Normal file
236
jdkSrc/jdk8/com/sun/java/swing/plaf/windows/WindowsTextUI.java
Normal file
@@ -0,0 +1,236 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import java.awt.Rectangle;
|
||||
import java.awt.Shape;
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.TextUI;
|
||||
import javax.swing.plaf.UIResource;
|
||||
import javax.swing.text.*;
|
||||
|
||||
/**
|
||||
* Windows text rendering.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public abstract class WindowsTextUI extends BasicTextUI {
|
||||
/**
|
||||
* Creates the object to use for a caret. By default an
|
||||
* instance of WindowsCaret is created. This method
|
||||
* can be redefined to provide something else that implements
|
||||
* the InputPosition interface or a subclass of DefaultCaret.
|
||||
*
|
||||
* @return the caret object
|
||||
*/
|
||||
protected Caret createCaret() {
|
||||
return new WindowsCaret();
|
||||
}
|
||||
|
||||
/* public */
|
||||
static LayeredHighlighter.LayerPainter WindowsPainter = new WindowsHighlightPainter(null);
|
||||
|
||||
/* public */
|
||||
static class WindowsCaret extends DefaultCaret
|
||||
implements UIResource {
|
||||
/**
|
||||
* Gets the painter for the Highlighter.
|
||||
*
|
||||
* @return the painter
|
||||
*/
|
||||
protected Highlighter.HighlightPainter getSelectionPainter() {
|
||||
return WindowsTextUI.WindowsPainter;
|
||||
}
|
||||
}
|
||||
|
||||
/* public */
|
||||
static class WindowsHighlightPainter extends
|
||||
DefaultHighlighter.DefaultHighlightPainter {
|
||||
WindowsHighlightPainter(Color c) {
|
||||
super(c);
|
||||
}
|
||||
|
||||
// --- HighlightPainter methods ---------------------------------------
|
||||
|
||||
/**
|
||||
* Paints a highlight.
|
||||
*
|
||||
* @param g the graphics context
|
||||
* @param offs0 the starting model offset >= 0
|
||||
* @param offs1 the ending model offset >= offs1
|
||||
* @param bounds the bounding box for the highlight
|
||||
* @param c the editor
|
||||
*/
|
||||
public void paint(Graphics g, int offs0, int offs1, Shape bounds, JTextComponent c) {
|
||||
Rectangle alloc = bounds.getBounds();
|
||||
try {
|
||||
// --- determine locations ---
|
||||
TextUI mapper = c.getUI();
|
||||
Rectangle p0 = mapper.modelToView(c, offs0);
|
||||
Rectangle p1 = mapper.modelToView(c, offs1);
|
||||
|
||||
// --- render ---
|
||||
Color color = getColor();
|
||||
|
||||
if (color == null) {
|
||||
g.setColor(c.getSelectionColor());
|
||||
}
|
||||
else {
|
||||
g.setColor(color);
|
||||
}
|
||||
boolean firstIsDot = false;
|
||||
boolean secondIsDot = false;
|
||||
if (c.isEditable()) {
|
||||
int dot = c.getCaretPosition();
|
||||
firstIsDot = (offs0 == dot);
|
||||
secondIsDot = (offs1 == dot);
|
||||
}
|
||||
if (p0.y == p1.y) {
|
||||
// same line, render a rectangle
|
||||
Rectangle r = p0.union(p1);
|
||||
if (r.width > 0) {
|
||||
if (firstIsDot) {
|
||||
r.x++;
|
||||
r.width--;
|
||||
}
|
||||
else if (secondIsDot) {
|
||||
r.width--;
|
||||
}
|
||||
}
|
||||
g.fillRect(r.x, r.y, r.width, r.height);
|
||||
} else {
|
||||
// different lines
|
||||
int p0ToMarginWidth = alloc.x + alloc.width - p0.x;
|
||||
if (firstIsDot && p0ToMarginWidth > 0) {
|
||||
p0.x++;
|
||||
p0ToMarginWidth--;
|
||||
}
|
||||
g.fillRect(p0.x, p0.y, p0ToMarginWidth, p0.height);
|
||||
if ((p0.y + p0.height) != p1.y) {
|
||||
g.fillRect(alloc.x, p0.y + p0.height, alloc.width,
|
||||
p1.y - (p0.y + p0.height));
|
||||
}
|
||||
if (secondIsDot && p1.x > alloc.x) {
|
||||
p1.x--;
|
||||
}
|
||||
g.fillRect(alloc.x, p1.y, (p1.x - alloc.x), p1.height);
|
||||
}
|
||||
} catch (BadLocationException e) {
|
||||
// can't render
|
||||
}
|
||||
}
|
||||
|
||||
// --- LayerPainter methods ----------------------------
|
||||
/**
|
||||
* Paints a portion of a highlight.
|
||||
*
|
||||
* @param g the graphics context
|
||||
* @param offs0 the starting model offset >= 0
|
||||
* @param offs1 the ending model offset >= offs1
|
||||
* @param bounds the bounding box of the view, which is not
|
||||
* necessarily the region to paint.
|
||||
* @param c the editor
|
||||
* @param view View painting for
|
||||
* @return region drawing occurred in
|
||||
*/
|
||||
public Shape paintLayer(Graphics g, int offs0, int offs1,
|
||||
Shape bounds, JTextComponent c, View view) {
|
||||
Color color = getColor();
|
||||
|
||||
if (color == null) {
|
||||
g.setColor(c.getSelectionColor());
|
||||
}
|
||||
else {
|
||||
g.setColor(color);
|
||||
}
|
||||
boolean firstIsDot = false;
|
||||
boolean secondIsDot = false;
|
||||
if (c.isEditable()) {
|
||||
int dot = c.getCaretPosition();
|
||||
firstIsDot = (offs0 == dot);
|
||||
secondIsDot = (offs1 == dot);
|
||||
}
|
||||
if (offs0 == view.getStartOffset() &&
|
||||
offs1 == view.getEndOffset()) {
|
||||
// Contained in view, can just use bounds.
|
||||
Rectangle alloc;
|
||||
if (bounds instanceof Rectangle) {
|
||||
alloc = (Rectangle)bounds;
|
||||
}
|
||||
else {
|
||||
alloc = bounds.getBounds();
|
||||
}
|
||||
if (firstIsDot && alloc.width > 0) {
|
||||
g.fillRect(alloc.x + 1, alloc.y, alloc.width - 1,
|
||||
alloc.height);
|
||||
}
|
||||
else if (secondIsDot && alloc.width > 0) {
|
||||
g.fillRect(alloc.x, alloc.y, alloc.width - 1,
|
||||
alloc.height);
|
||||
}
|
||||
else {
|
||||
g.fillRect(alloc.x, alloc.y, alloc.width, alloc.height);
|
||||
}
|
||||
return alloc;
|
||||
}
|
||||
else {
|
||||
// Should only render part of View.
|
||||
try {
|
||||
// --- determine locations ---
|
||||
Shape shape = view.modelToView(offs0, Position.Bias.Forward,
|
||||
offs1,Position.Bias.Backward,
|
||||
bounds);
|
||||
Rectangle r = (shape instanceof Rectangle) ?
|
||||
(Rectangle)shape : shape.getBounds();
|
||||
if (firstIsDot && r.width > 0) {
|
||||
g.fillRect(r.x + 1, r.y, r.width - 1, r.height);
|
||||
}
|
||||
else if (secondIsDot && r.width > 0) {
|
||||
g.fillRect(r.x, r.y, r.width - 1, r.height);
|
||||
}
|
||||
else {
|
||||
g.fillRect(r.x, r.y, r.width, r.height);
|
||||
}
|
||||
return r;
|
||||
} catch (BadLocationException e) {
|
||||
// can't render
|
||||
}
|
||||
}
|
||||
// Only if exception
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import sun.awt.AppContext;
|
||||
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.*;
|
||||
|
||||
import java.awt.*;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A Windows toggle button.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Jeff Dinkins
|
||||
*/
|
||||
public class WindowsToggleButtonUI extends BasicToggleButtonUI
|
||||
{
|
||||
protected int dashedRectGapX;
|
||||
protected int dashedRectGapY;
|
||||
protected int dashedRectGapWidth;
|
||||
protected int dashedRectGapHeight;
|
||||
|
||||
protected Color focusColor;
|
||||
|
||||
private static final Object WINDOWS_TOGGLE_BUTTON_UI_KEY = new Object();
|
||||
|
||||
private boolean defaults_initialized = false;
|
||||
|
||||
public static ComponentUI createUI(JComponent b) {
|
||||
AppContext appContext = AppContext.getAppContext();
|
||||
WindowsToggleButtonUI windowsToggleButtonUI =
|
||||
(WindowsToggleButtonUI) appContext.get(WINDOWS_TOGGLE_BUTTON_UI_KEY);
|
||||
if (windowsToggleButtonUI == null) {
|
||||
windowsToggleButtonUI = new WindowsToggleButtonUI();
|
||||
appContext.put(WINDOWS_TOGGLE_BUTTON_UI_KEY, windowsToggleButtonUI);
|
||||
}
|
||||
return windowsToggleButtonUI;
|
||||
}
|
||||
|
||||
|
||||
// ********************************
|
||||
// Defaults
|
||||
// ********************************
|
||||
protected void installDefaults(AbstractButton b) {
|
||||
super.installDefaults(b);
|
||||
if(!defaults_initialized) {
|
||||
String pp = getPropertyPrefix();
|
||||
dashedRectGapX = ((Integer)UIManager.get("Button.dashedRectGapX")).intValue();
|
||||
dashedRectGapY = ((Integer)UIManager.get("Button.dashedRectGapY")).intValue();
|
||||
dashedRectGapWidth = ((Integer)UIManager.get("Button.dashedRectGapWidth")).intValue();
|
||||
dashedRectGapHeight = ((Integer)UIManager.get("Button.dashedRectGapHeight")).intValue();
|
||||
focusColor = UIManager.getColor(pp + "focus");
|
||||
defaults_initialized = true;
|
||||
}
|
||||
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
b.setBorder(xp.getBorder(b, WindowsButtonUI.getXPButtonType(b)));
|
||||
LookAndFeel.installProperty(b, "opaque", Boolean.FALSE);
|
||||
LookAndFeel.installProperty(b, "rolloverEnabled", Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
protected void uninstallDefaults(AbstractButton b) {
|
||||
super.uninstallDefaults(b);
|
||||
defaults_initialized = false;
|
||||
}
|
||||
|
||||
|
||||
protected Color getFocusColor() {
|
||||
return focusColor;
|
||||
}
|
||||
|
||||
|
||||
// ********************************
|
||||
// Paint Methods
|
||||
// ********************************
|
||||
|
||||
private transient Color cachedSelectedColor = null;
|
||||
private transient Color cachedBackgroundColor = null;
|
||||
private transient Color cachedHighlightColor = null;
|
||||
|
||||
protected void paintButtonPressed(Graphics g, AbstractButton b) {
|
||||
if (XPStyle.getXP() == null && b.isContentAreaFilled()) {
|
||||
Color oldColor = g.getColor();
|
||||
Color c1 = b.getBackground();
|
||||
Color c2 = UIManager.getColor("ToggleButton.highlight");
|
||||
if (c1 != cachedBackgroundColor || c2 != cachedHighlightColor) {
|
||||
int r1 = c1.getRed(), r2 = c2.getRed();
|
||||
int g1 = c1.getGreen(), g2 = c2.getGreen();
|
||||
int b1 = c1.getBlue(), b2 = c2.getBlue();
|
||||
cachedSelectedColor = new Color(
|
||||
Math.min(r1, r2) + Math.abs(r1 - r2) / 2,
|
||||
Math.min(g1, g2) + Math.abs(g1 - g2) / 2,
|
||||
Math.min(b1, b2) + Math.abs(b1 - b2) / 2
|
||||
);
|
||||
cachedBackgroundColor = c1;
|
||||
cachedHighlightColor = c2;
|
||||
}
|
||||
g.setColor(cachedSelectedColor);
|
||||
g.fillRect(0, 0, b.getWidth(), b.getHeight());
|
||||
g.setColor(oldColor);
|
||||
}
|
||||
}
|
||||
|
||||
public void paint(Graphics g, JComponent c) {
|
||||
if (XPStyle.getXP() != null) {
|
||||
WindowsButtonUI.paintXPButtonBackground(g, c);
|
||||
}
|
||||
super.paint(g, c);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Overridden method to render the text without the mnemonic
|
||||
*/
|
||||
protected void paintText(Graphics g, AbstractButton b, Rectangle textRect, String text) {
|
||||
WindowsGraphicsUtils.paintText(g, b, textRect, text, getTextShiftOffset());
|
||||
}
|
||||
|
||||
protected void paintFocus(Graphics g, AbstractButton b,
|
||||
Rectangle viewRect, Rectangle textRect, Rectangle iconRect) {
|
||||
g.setColor(getFocusColor());
|
||||
BasicGraphicsUtils.drawDashedRect(g, dashedRectGapX, dashedRectGapY,
|
||||
b.getWidth() - dashedRectGapWidth,
|
||||
b.getHeight() - dashedRectGapHeight);
|
||||
}
|
||||
|
||||
// ********************************
|
||||
// Layout Methods
|
||||
// ********************************
|
||||
public Dimension getPreferredSize(JComponent c) {
|
||||
Dimension d = super.getPreferredSize(c);
|
||||
|
||||
/* Ensure that the width and height of the button is odd,
|
||||
* to allow for the focus line if focus is painted
|
||||
*/
|
||||
AbstractButton b = (AbstractButton)c;
|
||||
if (d != null && b.isFocusPainted()) {
|
||||
if(d.width % 2 == 0) { d.width += 1; }
|
||||
if(d.height % 2 == 0) { d.height += 1; }
|
||||
}
|
||||
return d;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2005, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.*;
|
||||
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.Part;
|
||||
import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
|
||||
|
||||
|
||||
/**
|
||||
* Draws Windows toolbar separators.
|
||||
* <p>
|
||||
*
|
||||
* @author Mark Davidson
|
||||
*/
|
||||
public class WindowsToolBarSeparatorUI extends BasicToolBarSeparatorUI {
|
||||
|
||||
public static ComponentUI createUI( JComponent c ) {
|
||||
return new WindowsToolBarSeparatorUI();
|
||||
}
|
||||
|
||||
public Dimension getPreferredSize(JComponent c) {
|
||||
Dimension size = ((JToolBar.Separator)c).getSeparatorSize();
|
||||
|
||||
if (size != null) {
|
||||
size = size.getSize();
|
||||
} else {
|
||||
size = new Dimension(6, 6);
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
boolean vertical = ((JSeparator)c).getOrientation() == SwingConstants.VERTICAL;
|
||||
Part part = vertical ? Part.TP_SEPARATOR : Part.TP_SEPARATORVERT;
|
||||
Skin skin = xp.getSkin(c, part);
|
||||
size.width = skin.getWidth();
|
||||
size.height = skin.getHeight();
|
||||
}
|
||||
|
||||
if (((JSeparator)c).getOrientation() == SwingConstants.VERTICAL) {
|
||||
size.height = 0;
|
||||
} else {
|
||||
size.width = 0;
|
||||
}
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
public Dimension getMaximumSize(JComponent c) {
|
||||
Dimension pref = getPreferredSize(c);
|
||||
if (((JSeparator)c).getOrientation() == SwingConstants.VERTICAL) {
|
||||
return new Dimension(pref.width, Short.MAX_VALUE);
|
||||
} else {
|
||||
return new Dimension(Short.MAX_VALUE, pref.height);
|
||||
}
|
||||
}
|
||||
|
||||
public void paint( Graphics g, JComponent c ) {
|
||||
boolean vertical = ((JSeparator)c).getOrientation() == SwingConstants.VERTICAL;
|
||||
Dimension size = c.getSize();
|
||||
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
Part part = vertical ? Part.TP_SEPARATOR : Part.TP_SEPARATORVERT;
|
||||
Skin skin = xp.getSkin(c, part);
|
||||
|
||||
int dx = vertical ? (size.width - skin.getWidth()) / 2 : 0;
|
||||
int dy = vertical ? 0 : (size.height - skin.getHeight()) / 2;
|
||||
int dw = vertical ? skin.getWidth() : size.width;
|
||||
int dh = vertical ? size.height : skin.getHeight();
|
||||
skin.paintSkin(g, dx, dy, dw, dh, null);
|
||||
} else {
|
||||
|
||||
Color temp = g.getColor();
|
||||
|
||||
UIDefaults table = UIManager.getLookAndFeelDefaults();
|
||||
|
||||
Color shadow = table.getColor("ToolBar.shadow");
|
||||
Color highlight = table.getColor("ToolBar.highlight");
|
||||
|
||||
if (vertical) {
|
||||
int x = (size.width / 2) - 1;
|
||||
g.setColor(shadow);
|
||||
g.drawLine(x, 2, x, size.height - 2);
|
||||
|
||||
g.setColor(highlight);
|
||||
g.drawLine(x + 1, 2, x + 1, size.height - 2);
|
||||
} else {
|
||||
int y = (size.height / 2) - 1;
|
||||
g.setColor(shadow);
|
||||
g.drawLine(2, y, size.width - 2, y);
|
||||
g.setColor(highlight);
|
||||
g.drawLine(2, y + 1, size.width - 2, y + 1);
|
||||
}
|
||||
g.setColor(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
import javax.swing.AbstractButton;
|
||||
import javax.swing.JComponent;
|
||||
import javax.swing.JToggleButton;
|
||||
import javax.swing.UIDefaults;
|
||||
import javax.swing.UIManager;
|
||||
|
||||
import javax.swing.border.Border;
|
||||
import javax.swing.border.CompoundBorder;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import javax.swing.plaf.*;
|
||||
|
||||
import javax.swing.plaf.basic.BasicBorders;
|
||||
import javax.swing.plaf.basic.BasicToolBarUI;
|
||||
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.Part;
|
||||
|
||||
|
||||
public class WindowsToolBarUI extends BasicToolBarUI {
|
||||
|
||||
public static ComponentUI createUI(JComponent c) {
|
||||
return new WindowsToolBarUI();
|
||||
}
|
||||
|
||||
protected void installDefaults() {
|
||||
if (XPStyle.getXP() != null) {
|
||||
setRolloverBorders(true);
|
||||
}
|
||||
super.installDefaults();
|
||||
}
|
||||
|
||||
protected Border createRolloverBorder() {
|
||||
if (XPStyle.getXP() != null) {
|
||||
return new EmptyBorder(3, 3, 3, 3);
|
||||
} else {
|
||||
return super.createRolloverBorder();
|
||||
}
|
||||
}
|
||||
|
||||
protected Border createNonRolloverBorder() {
|
||||
if (XPStyle.getXP() != null) {
|
||||
return new EmptyBorder(3, 3, 3, 3);
|
||||
} else {
|
||||
return super.createNonRolloverBorder();
|
||||
}
|
||||
}
|
||||
|
||||
public void paint(Graphics g, JComponent c) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
xp.getSkin(c, Part.TP_TOOLBAR).paintSkin(g, 0, 0,
|
||||
c.getWidth(), c.getHeight(), null, true);
|
||||
} else {
|
||||
super.paint(g, c);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
* @since 1.6
|
||||
*/
|
||||
protected Border getRolloverBorder(AbstractButton b) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
if (xp != null) {
|
||||
return xp.getBorder(b, WindowsButtonUI.getXPButtonType(b));
|
||||
} else {
|
||||
return super.getRolloverBorder(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
242
jdkSrc/jdk8/com/sun/java/swing/plaf/windows/WindowsTreeUI.java
Normal file
242
jdkSrc/jdk8/com/sun/java/swing/plaf/windows/WindowsTreeUI.java
Normal file
@@ -0,0 +1,242 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.plaf.basic.*;
|
||||
import javax.swing.*;
|
||||
import javax.swing.plaf.*;
|
||||
|
||||
import javax.swing.tree.*;
|
||||
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.*;
|
||||
import static com.sun.java.swing.plaf.windows.XPStyle.Skin;
|
||||
|
||||
|
||||
/**
|
||||
* A Windows tree.
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*
|
||||
* @author Scott Violet
|
||||
*/
|
||||
public class WindowsTreeUI extends BasicTreeUI {
|
||||
|
||||
public static ComponentUI createUI( JComponent c )
|
||||
{
|
||||
return new WindowsTreeUI();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Ensures that the rows identified by beginRow through endRow are
|
||||
* visible.
|
||||
*/
|
||||
protected void ensureRowsAreVisible(int beginRow, int endRow) {
|
||||
if(tree != null && beginRow >= 0 && endRow < getRowCount(tree)) {
|
||||
Rectangle visRect = tree.getVisibleRect();
|
||||
if(beginRow == endRow) {
|
||||
Rectangle scrollBounds = getPathBounds(tree, getPathForRow
|
||||
(tree, beginRow));
|
||||
|
||||
if(scrollBounds != null) {
|
||||
scrollBounds.x = visRect.x;
|
||||
scrollBounds.width = visRect.width;
|
||||
tree.scrollRectToVisible(scrollBounds);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Rectangle beginRect = getPathBounds(tree, getPathForRow
|
||||
(tree, beginRow));
|
||||
if (beginRect != null) {
|
||||
Rectangle testRect = beginRect;
|
||||
int beginY = beginRect.y;
|
||||
int maxY = beginY + visRect.height;
|
||||
|
||||
for(int counter = beginRow + 1; counter <= endRow; counter++) {
|
||||
testRect = getPathBounds(tree,
|
||||
getPathForRow(tree, counter));
|
||||
if(testRect != null && (testRect.y + testRect.height) > maxY) {
|
||||
counter = endRow;
|
||||
}
|
||||
}
|
||||
|
||||
if (testRect == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
tree.scrollRectToVisible(new Rectangle(visRect.x, beginY, 1,
|
||||
testRect.y + testRect.height-
|
||||
beginY));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static protected final int HALF_SIZE = 4;
|
||||
static protected final int SIZE = 9;
|
||||
|
||||
/**
|
||||
* Returns the default cell renderer that is used to do the
|
||||
* stamping of each node.
|
||||
*/
|
||||
protected TreeCellRenderer createDefaultCellRenderer() {
|
||||
return new WindowsTreeCellRenderer();
|
||||
}
|
||||
|
||||
/**
|
||||
* The minus sign button icon
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public static class ExpandedIcon implements Icon, Serializable {
|
||||
|
||||
static public Icon createExpandedIcon() {
|
||||
return new ExpandedIcon();
|
||||
}
|
||||
|
||||
Skin getSkin(Component c) {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
return (xp != null) ? xp.getSkin(c, Part.TVP_GLYPH) : null;
|
||||
}
|
||||
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
Skin skin = getSkin(c);
|
||||
if (skin != null) {
|
||||
skin.paintSkin(g, x, y, State.OPENED);
|
||||
return;
|
||||
}
|
||||
|
||||
Color backgroundColor = c.getBackground();
|
||||
|
||||
if(backgroundColor != null)
|
||||
g.setColor(backgroundColor);
|
||||
else
|
||||
g.setColor(Color.white);
|
||||
g.fillRect(x, y, SIZE-1, SIZE-1);
|
||||
g.setColor(Color.gray);
|
||||
g.drawRect(x, y, SIZE-1, SIZE-1);
|
||||
g.setColor(Color.black);
|
||||
g.drawLine(x + 2, y + HALF_SIZE, x + (SIZE - 3), y + HALF_SIZE);
|
||||
}
|
||||
|
||||
public int getIconWidth() {
|
||||
Skin skin = getSkin(null);
|
||||
return (skin != null) ? skin.getWidth() : SIZE;
|
||||
}
|
||||
|
||||
public int getIconHeight() {
|
||||
Skin skin = getSkin(null);
|
||||
return (skin != null) ? skin.getHeight() : SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The plus sign button icon
|
||||
* <p>
|
||||
* <strong>Warning:</strong>
|
||||
* Serialized objects of this class will not be compatible with
|
||||
* future Swing releases. The current serialization support is appropriate
|
||||
* for short term storage or RMI between applications running the same
|
||||
* version of Swing. A future release of Swing will provide support for
|
||||
* long term persistence.
|
||||
*/
|
||||
public static class CollapsedIcon extends ExpandedIcon {
|
||||
static public Icon createCollapsedIcon() {
|
||||
return new CollapsedIcon();
|
||||
}
|
||||
|
||||
public void paintIcon(Component c, Graphics g, int x, int y) {
|
||||
Skin skin = getSkin(c);
|
||||
if (skin != null) {
|
||||
skin.paintSkin(g, x, y, State.CLOSED);
|
||||
} else {
|
||||
super.paintIcon(c, g, x, y);
|
||||
g.drawLine(x + HALF_SIZE, y + 2, x + HALF_SIZE, y + (SIZE - 3));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class WindowsTreeCellRenderer extends DefaultTreeCellRenderer {
|
||||
|
||||
/**
|
||||
* Configures the renderer based on the passed in components.
|
||||
* The value is set from messaging the tree with
|
||||
* <code>convertValueToText</code>, which ultimately invokes
|
||||
* <code>toString</code> on <code>value</code>.
|
||||
* The foreground color is set based on the selection and the icon
|
||||
* is set based on on leaf and expanded.
|
||||
*/
|
||||
public Component getTreeCellRendererComponent(JTree tree, Object value,
|
||||
boolean sel,
|
||||
boolean expanded,
|
||||
boolean leaf, int row,
|
||||
boolean hasFocus) {
|
||||
super.getTreeCellRendererComponent(tree, value, sel,
|
||||
expanded, leaf, row,
|
||||
hasFocus);
|
||||
// Windows displays the open icon when the tree item selected.
|
||||
if (!tree.isEnabled()) {
|
||||
setEnabled(false);
|
||||
if (leaf) {
|
||||
setDisabledIcon(getLeafIcon());
|
||||
} else if (sel) {
|
||||
setDisabledIcon(getOpenIcon());
|
||||
} else {
|
||||
setDisabledIcon(getClosedIcon());
|
||||
}
|
||||
}
|
||||
else {
|
||||
setEnabled(true);
|
||||
if (leaf) {
|
||||
setIcon(getLeafIcon());
|
||||
} else if (sel) {
|
||||
setIcon(getOpenIcon());
|
||||
} else {
|
||||
setIcon(getClosedIcon());
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
762
jdkSrc/jdk8/com/sun/java/swing/plaf/windows/XPStyle.java
Normal file
762
jdkSrc/jdk8/com/sun/java/swing/plaf/windows/XPStyle.java
Normal file
@@ -0,0 +1,762 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2007, Oracle and/or its affiliates. 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. 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* <p>These classes are designed to be used while the
|
||||
* corresponding <code>LookAndFeel</code> class has been installed
|
||||
* (<code>UIManager.setLookAndFeel(new <i>XXX</i>LookAndFeel())</code>).
|
||||
* Using them while a different <code>LookAndFeel</code> is installed
|
||||
* may produce unexpected results, including exceptions.
|
||||
* Additionally, changing the <code>LookAndFeel</code>
|
||||
* maintained by the <code>UIManager</code> without updating the
|
||||
* corresponding <code>ComponentUI</code> of any
|
||||
* <code>JComponent</code>s may also produce unexpected results,
|
||||
* such as the wrong colors showing up, and is generally not
|
||||
* encouraged.
|
||||
*
|
||||
*/
|
||||
|
||||
package com.sun.java.swing.plaf.windows;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.*;
|
||||
import java.security.AccessController;
|
||||
import java.util.*;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.*;
|
||||
import javax.swing.plaf.*;
|
||||
import javax.swing.text.JTextComponent;
|
||||
|
||||
import sun.awt.image.SunWritableRaster;
|
||||
import sun.awt.windows.ThemeReader;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
import sun.swing.CachedPainter;
|
||||
|
||||
import static com.sun.java.swing.plaf.windows.TMSchema.*;
|
||||
|
||||
|
||||
/**
|
||||
* Implements Windows XP Styles for the Windows Look and Feel.
|
||||
*
|
||||
* @author Leif Samuelsson
|
||||
*/
|
||||
class XPStyle {
|
||||
// Singleton instance of this class
|
||||
private static XPStyle xp;
|
||||
|
||||
// Singleton instance of SkinPainter
|
||||
private static SkinPainter skinPainter = new SkinPainter();
|
||||
|
||||
private static Boolean themeActive = null;
|
||||
|
||||
private HashMap<String, Border> borderMap;
|
||||
private HashMap<String, Color> colorMap;
|
||||
|
||||
private boolean flatMenus;
|
||||
|
||||
static {
|
||||
invalidateStyle();
|
||||
}
|
||||
|
||||
/** Static method for clearing the hashmap and loading the
|
||||
* current XP style and theme
|
||||
*/
|
||||
static synchronized void invalidateStyle() {
|
||||
xp = null;
|
||||
themeActive = null;
|
||||
skinPainter.flush();
|
||||
}
|
||||
|
||||
/** Get the singleton instance of this class
|
||||
*
|
||||
* @return the singleton instance of this class or null if XP styles
|
||||
* are not active or if this is not Windows XP
|
||||
*/
|
||||
static synchronized XPStyle getXP() {
|
||||
if (themeActive == null) {
|
||||
Toolkit toolkit = Toolkit.getDefaultToolkit();
|
||||
themeActive =
|
||||
(Boolean)toolkit.getDesktopProperty("win.xpstyle.themeActive");
|
||||
if (themeActive == null) {
|
||||
themeActive = Boolean.FALSE;
|
||||
}
|
||||
if (themeActive.booleanValue()) {
|
||||
GetPropertyAction propertyAction =
|
||||
new GetPropertyAction("swing.noxp");
|
||||
if (AccessController.doPrivileged(propertyAction) == null &&
|
||||
ThemeReader.isThemed() &&
|
||||
!(UIManager.getLookAndFeel()
|
||||
instanceof WindowsClassicLookAndFeel)) {
|
||||
|
||||
xp = new XPStyle();
|
||||
}
|
||||
}
|
||||
}
|
||||
return ThemeReader.isXPStyleEnabled() ? xp : null;
|
||||
}
|
||||
|
||||
static boolean isVista() {
|
||||
XPStyle xp = XPStyle.getXP();
|
||||
return (xp != null && xp.isSkinDefined(null, Part.CP_DROPDOWNBUTTONRIGHT));
|
||||
}
|
||||
|
||||
/** Get a named <code>String</code> value from the current style
|
||||
*
|
||||
* @param part a <code>Part</code>
|
||||
* @param state a <code>String</code>
|
||||
* @param attributeKey a <code>String</code>
|
||||
* @return a <code>String</code> or null if key is not found
|
||||
* in the current style
|
||||
*
|
||||
* This is currently only used by WindowsInternalFrameTitlePane for painting
|
||||
* title foregound and can be removed when no longer needed
|
||||
*/
|
||||
String getString(Component c, Part part, State state, Prop prop) {
|
||||
return getTypeEnumName(c, part, state, prop);
|
||||
}
|
||||
|
||||
TypeEnum getTypeEnum(Component c, Part part, State state, Prop prop) {
|
||||
int enumValue = ThemeReader.getEnum(part.getControlName(c), part.getValue(),
|
||||
State.getValue(part, state),
|
||||
prop.getValue());
|
||||
return TypeEnum.getTypeEnum(prop, enumValue);
|
||||
}
|
||||
|
||||
private static String getTypeEnumName(Component c, Part part, State state, Prop prop) {
|
||||
int enumValue = ThemeReader.getEnum(part.getControlName(c), part.getValue(),
|
||||
State.getValue(part, state),
|
||||
prop.getValue());
|
||||
if (enumValue == -1) {
|
||||
return null;
|
||||
}
|
||||
return TypeEnum.getTypeEnum(prop, enumValue).getName();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/** Get a named <code>int</code> value from the current style
|
||||
*
|
||||
* @param part a <code>Part</code>
|
||||
* @return an <code>int</code> or null if key is not found
|
||||
* in the current style
|
||||
*/
|
||||
int getInt(Component c, Part part, State state, Prop prop, int fallback) {
|
||||
return ThemeReader.getInt(part.getControlName(c), part.getValue(),
|
||||
State.getValue(part, state),
|
||||
prop.getValue());
|
||||
}
|
||||
|
||||
/** Get a named <code>Dimension</code> value from the current style
|
||||
*
|
||||
* @param key a <code>String</code>
|
||||
* @return a <code>Dimension</code> or null if key is not found
|
||||
* in the current style
|
||||
*
|
||||
* This is currently only used by WindowsProgressBarUI and the value
|
||||
* should probably be cached there instead of here.
|
||||
*/
|
||||
Dimension getDimension(Component c, Part part, State state, Prop prop) {
|
||||
Dimension d = ThemeReader.getPosition(part.getControlName(c), part.getValue(),
|
||||
State.getValue(part, state),
|
||||
prop.getValue());
|
||||
return (d != null) ? d : new Dimension();
|
||||
}
|
||||
|
||||
/** Get a named <code>Point</code> (e.g. a location or an offset) value
|
||||
* from the current style
|
||||
*
|
||||
* @param key a <code>String</code>
|
||||
* @return a <code>Point</code> or null if key is not found
|
||||
* in the current style
|
||||
*
|
||||
* This is currently only used by WindowsInternalFrameTitlePane for painting
|
||||
* title foregound and can be removed when no longer needed
|
||||
*/
|
||||
Point getPoint(Component c, Part part, State state, Prop prop) {
|
||||
Dimension d = ThemeReader.getPosition(part.getControlName(c), part.getValue(),
|
||||
State.getValue(part, state),
|
||||
prop.getValue());
|
||||
return (d != null) ? new Point(d.width, d.height) : new Point();
|
||||
}
|
||||
|
||||
/** Get a named <code>Insets</code> value from the current style
|
||||
*
|
||||
* @param key a <code>String</code>
|
||||
* @return an <code>Insets</code> object or null if key is not found
|
||||
* in the current style
|
||||
*
|
||||
* This is currently only used to create borders and by
|
||||
* WindowsInternalFrameTitlePane for painting title foregound.
|
||||
* The return value is already cached in those places.
|
||||
*/
|
||||
Insets getMargin(Component c, Part part, State state, Prop prop) {
|
||||
Insets insets = ThemeReader.getThemeMargins(part.getControlName(c), part.getValue(),
|
||||
State.getValue(part, state),
|
||||
prop.getValue());
|
||||
return (insets != null) ? insets : new Insets(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
/** Get a named <code>Color</code> value from the current style
|
||||
*
|
||||
* @param part a <code>Part</code>
|
||||
* @return a <code>Color</code> or null if key is not found
|
||||
* in the current style
|
||||
*/
|
||||
synchronized Color getColor(Skin skin, Prop prop, Color fallback) {
|
||||
String key = skin.toString() + "." + prop.name();
|
||||
Part part = skin.part;
|
||||
Color color = colorMap.get(key);
|
||||
if (color == null) {
|
||||
color = ThemeReader.getColor(part.getControlName(null), part.getValue(),
|
||||
State.getValue(part, skin.state),
|
||||
prop.getValue());
|
||||
if (color != null) {
|
||||
color = new ColorUIResource(color);
|
||||
colorMap.put(key, color);
|
||||
}
|
||||
}
|
||||
return (color != null) ? color : fallback;
|
||||
}
|
||||
|
||||
Color getColor(Component c, Part part, State state, Prop prop, Color fallback) {
|
||||
return getColor(new Skin(c, part, state), prop, fallback);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Get a named <code>Border</code> value from the current style
|
||||
*
|
||||
* @param part a <code>Part</code>
|
||||
* @return a <code>Border</code> or null if key is not found
|
||||
* in the current style or if the style for the particular
|
||||
* part is not defined as "borderfill".
|
||||
*/
|
||||
synchronized Border getBorder(Component c, Part part) {
|
||||
if (part == Part.MENU) {
|
||||
// Special case because XP has no skin for menus
|
||||
if (flatMenus) {
|
||||
// TODO: The classic border uses this color, but we should
|
||||
// create a new UI property called "PopupMenu.borderColor"
|
||||
// instead.
|
||||
return new XPFillBorder(UIManager.getColor("InternalFrame.borderShadow"),
|
||||
1);
|
||||
} else {
|
||||
return null; // Will cause L&F to use classic border
|
||||
}
|
||||
}
|
||||
Skin skin = new Skin(c, part, null);
|
||||
Border border = borderMap.get(skin.string);
|
||||
if (border == null) {
|
||||
String bgType = getTypeEnumName(c, part, null, Prop.BGTYPE);
|
||||
if ("borderfill".equalsIgnoreCase(bgType)) {
|
||||
int thickness = getInt(c, part, null, Prop.BORDERSIZE, 1);
|
||||
Color color = getColor(skin, Prop.BORDERCOLOR, Color.black);
|
||||
border = new XPFillBorder(color, thickness);
|
||||
if (part == Part.CP_COMBOBOX) {
|
||||
border = new XPStatefulFillBorder(color, thickness, part, Prop.BORDERCOLOR);
|
||||
}
|
||||
} else if ("imagefile".equalsIgnoreCase(bgType)) {
|
||||
Insets m = getMargin(c, part, null, Prop.SIZINGMARGINS);
|
||||
if (m != null) {
|
||||
if (getBoolean(c, part, null, Prop.BORDERONLY)) {
|
||||
border = new XPImageBorder(c, part);
|
||||
} else if (part == Part.CP_COMBOBOX) {
|
||||
border = new EmptyBorder(1, 1, 1, 1);
|
||||
} else {
|
||||
if(part == Part.TP_BUTTON) {
|
||||
border = new XPEmptyBorder(new Insets(3,3,3,3));
|
||||
} else {
|
||||
border = new XPEmptyBorder(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (border != null) {
|
||||
borderMap.put(skin.string, border);
|
||||
}
|
||||
}
|
||||
return border;
|
||||
}
|
||||
|
||||
private class XPFillBorder extends LineBorder implements UIResource {
|
||||
XPFillBorder(Color color, int thickness) {
|
||||
super(color, thickness);
|
||||
}
|
||||
|
||||
public Insets getBorderInsets(Component c, Insets insets) {
|
||||
Insets margin = null;
|
||||
//
|
||||
// Ideally we'd have an interface defined for classes which
|
||||
// support margins (to avoid this hackery), but we've
|
||||
// decided against it for simplicity
|
||||
//
|
||||
if (c instanceof AbstractButton) {
|
||||
margin = ((AbstractButton)c).getMargin();
|
||||
} else if (c instanceof JToolBar) {
|
||||
margin = ((JToolBar)c).getMargin();
|
||||
} else if (c instanceof JTextComponent) {
|
||||
margin = ((JTextComponent)c).getMargin();
|
||||
}
|
||||
insets.top = (margin != null? margin.top : 0) + thickness;
|
||||
insets.left = (margin != null? margin.left : 0) + thickness;
|
||||
insets.bottom = (margin != null? margin.bottom : 0) + thickness;
|
||||
insets.right = (margin != null? margin.right : 0) + thickness;
|
||||
|
||||
return insets;
|
||||
}
|
||||
}
|
||||
|
||||
private class XPStatefulFillBorder extends XPFillBorder {
|
||||
private final Part part;
|
||||
private final Prop prop;
|
||||
XPStatefulFillBorder(Color color, int thickness, Part part, Prop prop) {
|
||||
super(color, thickness);
|
||||
this.part = part;
|
||||
this.prop = prop;
|
||||
}
|
||||
|
||||
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
|
||||
State state = State.NORMAL;
|
||||
// special casing for comboboxes.
|
||||
// there may be more special cases in the future
|
||||
if(c instanceof JComboBox) {
|
||||
JComboBox cb = (JComboBox)c;
|
||||
// note. in the future this should be replaced with a call
|
||||
// to BasicLookAndFeel.getUIOfType()
|
||||
if(cb.getUI() instanceof WindowsComboBoxUI) {
|
||||
WindowsComboBoxUI wcb = (WindowsComboBoxUI)cb.getUI();
|
||||
state = wcb.getXPComboBoxState(cb);
|
||||
}
|
||||
}
|
||||
lineColor = getColor(c, part, state, prop, Color.black);
|
||||
super.paintBorder(c, g, x, y, width, height);
|
||||
}
|
||||
}
|
||||
|
||||
private class XPImageBorder extends AbstractBorder implements UIResource {
|
||||
Skin skin;
|
||||
|
||||
XPImageBorder(Component c, Part part) {
|
||||
this.skin = getSkin(c, part);
|
||||
}
|
||||
|
||||
public void paintBorder(Component c, Graphics g,
|
||||
int x, int y, int width, int height) {
|
||||
skin.paintSkin(g, x, y, width, height, null);
|
||||
}
|
||||
|
||||
public Insets getBorderInsets(Component c, Insets insets) {
|
||||
Insets margin = null;
|
||||
Insets borderInsets = skin.getContentMargin();
|
||||
if(borderInsets == null) {
|
||||
borderInsets = new Insets(0, 0, 0, 0);
|
||||
}
|
||||
//
|
||||
// Ideally we'd have an interface defined for classes which
|
||||
// support margins (to avoid this hackery), but we've
|
||||
// decided against it for simplicity
|
||||
//
|
||||
if (c instanceof AbstractButton) {
|
||||
margin = ((AbstractButton)c).getMargin();
|
||||
} else if (c instanceof JToolBar) {
|
||||
margin = ((JToolBar)c).getMargin();
|
||||
} else if (c instanceof JTextComponent) {
|
||||
margin = ((JTextComponent)c).getMargin();
|
||||
}
|
||||
insets.top = (margin != null? margin.top : 0) + borderInsets.top;
|
||||
insets.left = (margin != null? margin.left : 0) + borderInsets.left;
|
||||
insets.bottom = (margin != null? margin.bottom : 0) + borderInsets.bottom;
|
||||
insets.right = (margin != null? margin.right : 0) + borderInsets.right;
|
||||
|
||||
return insets;
|
||||
}
|
||||
}
|
||||
|
||||
private class XPEmptyBorder extends EmptyBorder implements UIResource {
|
||||
XPEmptyBorder(Insets m) {
|
||||
super(m.top+2, m.left+2, m.bottom+2, m.right+2);
|
||||
}
|
||||
|
||||
public Insets getBorderInsets(Component c, Insets insets) {
|
||||
insets = super.getBorderInsets(c, insets);
|
||||
|
||||
Insets margin = null;
|
||||
if (c instanceof AbstractButton) {
|
||||
Insets m = ((AbstractButton)c).getMargin();
|
||||
// if this is a toolbar button then ignore getMargin()
|
||||
// and subtract the padding added by the constructor
|
||||
if(c.getParent() instanceof JToolBar
|
||||
&& ! (c instanceof JRadioButton)
|
||||
&& ! (c instanceof JCheckBox)
|
||||
&& m instanceof InsetsUIResource) {
|
||||
insets.top -= 2;
|
||||
insets.left -= 2;
|
||||
insets.bottom -= 2;
|
||||
insets.right -= 2;
|
||||
} else {
|
||||
margin = m;
|
||||
}
|
||||
} else if (c instanceof JToolBar) {
|
||||
margin = ((JToolBar)c).getMargin();
|
||||
} else if (c instanceof JTextComponent) {
|
||||
margin = ((JTextComponent)c).getMargin();
|
||||
}
|
||||
if (margin != null) {
|
||||
insets.top = margin.top + 2;
|
||||
insets.left = margin.left + 2;
|
||||
insets.bottom = margin.bottom + 2;
|
||||
insets.right = margin.right + 2;
|
||||
}
|
||||
return insets;
|
||||
}
|
||||
}
|
||||
boolean isSkinDefined(Component c, Part part) {
|
||||
return (part.getValue() == 0)
|
||||
|| ThemeReader.isThemePartDefined(
|
||||
part.getControlName(c), part.getValue(), 0);
|
||||
}
|
||||
|
||||
|
||||
/** Get a <code>Skin</code> object from the current style
|
||||
* for a named part (component type)
|
||||
*
|
||||
* @param part a <code>Part</code>
|
||||
* @return a <code>Skin</code> object
|
||||
*/
|
||||
synchronized Skin getSkin(Component c, Part part) {
|
||||
assert isSkinDefined(c, part) : "part " + part + " is not defined";
|
||||
return new Skin(c, part, null);
|
||||
}
|
||||
|
||||
|
||||
long getThemeTransitionDuration(Component c, Part part, State stateFrom,
|
||||
State stateTo, Prop prop) {
|
||||
return ThemeReader.getThemeTransitionDuration(part.getControlName(c),
|
||||
part.getValue(),
|
||||
State.getValue(part, stateFrom),
|
||||
State.getValue(part, stateTo),
|
||||
(prop != null) ? prop.getValue() : 0);
|
||||
}
|
||||
|
||||
|
||||
/** A class which encapsulates attributes for a given part
|
||||
* (component type) and which provides methods for painting backgrounds
|
||||
* and glyphs
|
||||
*/
|
||||
static class Skin {
|
||||
final Component component;
|
||||
final Part part;
|
||||
final State state;
|
||||
|
||||
private final String string;
|
||||
private Dimension size = null;
|
||||
|
||||
Skin(Component component, Part part) {
|
||||
this(component, part, null);
|
||||
}
|
||||
|
||||
Skin(Part part, State state) {
|
||||
this(null, part, state);
|
||||
}
|
||||
|
||||
Skin(Component component, Part part, State state) {
|
||||
this.component = component;
|
||||
this.part = part;
|
||||
this.state = state;
|
||||
|
||||
String str = part.getControlName(component) +"." + part.name();
|
||||
if (state != null) {
|
||||
str += "("+state.name()+")";
|
||||
}
|
||||
string = str;
|
||||
}
|
||||
|
||||
Insets getContentMargin() {
|
||||
/* idk: it seems margins are the same for all 'big enough'
|
||||
* bounding rectangles.
|
||||
*/
|
||||
int boundingWidth = 100;
|
||||
int boundingHeight = 100;
|
||||
|
||||
Insets insets = ThemeReader.getThemeBackgroundContentMargins(
|
||||
part.getControlName(null), part.getValue(),
|
||||
0, boundingWidth, boundingHeight);
|
||||
return (insets != null) ? insets : new Insets(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
private int getWidth(State state) {
|
||||
if (size == null) {
|
||||
size = getPartSize(part, state);
|
||||
}
|
||||
return (size != null) ? size.width : 0;
|
||||
}
|
||||
|
||||
int getWidth() {
|
||||
return getWidth((state != null) ? state : State.NORMAL);
|
||||
}
|
||||
|
||||
private int getHeight(State state) {
|
||||
if (size == null) {
|
||||
size = getPartSize(part, state);
|
||||
}
|
||||
return (size != null) ? size.height : 0;
|
||||
}
|
||||
|
||||
int getHeight() {
|
||||
return getHeight((state != null) ? state : State.NORMAL);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return string;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
return (obj instanceof Skin && ((Skin)obj).string.equals(string));
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return string.hashCode();
|
||||
}
|
||||
|
||||
/** Paint a skin at x, y.
|
||||
*
|
||||
* @param g the graphics context to use for painting
|
||||
* @param dx the destination <i>x</i> coordinate
|
||||
* @param dy the destination <i>y</i> coordinate
|
||||
* @param state which state to paint
|
||||
*/
|
||||
void paintSkin(Graphics g, int dx, int dy, State state) {
|
||||
if (state == null) {
|
||||
state = this.state;
|
||||
}
|
||||
paintSkin(g, dx, dy, getWidth(state), getHeight(state), state);
|
||||
}
|
||||
|
||||
/** Paint a skin in an area defined by a rectangle.
|
||||
*
|
||||
* @param g the graphics context to use for painting
|
||||
* @param r a <code>Rectangle</code> defining the area to fill,
|
||||
* may cause the image to be stretched or tiled
|
||||
* @param state which state to paint
|
||||
*/
|
||||
void paintSkin(Graphics g, Rectangle r, State state) {
|
||||
paintSkin(g, r.x, r.y, r.width, r.height, state);
|
||||
}
|
||||
|
||||
/** Paint a skin at a defined position and size
|
||||
* This method supports animation.
|
||||
*
|
||||
* @param g the graphics context to use for painting
|
||||
* @param dx the destination <i>x</i> coordinate
|
||||
* @param dy the destination <i>y</i> coordinate
|
||||
* @param dw the width of the area to fill, may cause
|
||||
* the image to be stretched or tiled
|
||||
* @param dh the height of the area to fill, may cause
|
||||
* the image to be stretched or tiled
|
||||
* @param state which state to paint
|
||||
*/
|
||||
void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state) {
|
||||
if (XPStyle.getXP() == null) {
|
||||
return;
|
||||
}
|
||||
if (ThemeReader.isGetThemeTransitionDurationDefined()
|
||||
&& component instanceof JComponent
|
||||
&& SwingUtilities.getAncestorOfClass(CellRendererPane.class,
|
||||
component) == null) {
|
||||
AnimationController.paintSkin((JComponent) component, this,
|
||||
g, dx, dy, dw, dh, state);
|
||||
} else {
|
||||
paintSkinRaw(g, dx, dy, dw, dh, state);
|
||||
}
|
||||
}
|
||||
|
||||
/** Paint a skin at a defined position and size. This method
|
||||
* does not trigger animation. It is needed for the animation
|
||||
* support.
|
||||
*
|
||||
* @param g the graphics context to use for painting
|
||||
* @param dx the destination <i>x</i> coordinate.
|
||||
* @param dy the destination <i>y</i> coordinate.
|
||||
* @param dw the width of the area to fill, may cause
|
||||
* the image to be stretched or tiled
|
||||
* @param dh the height of the area to fill, may cause
|
||||
* the image to be stretched or tiled
|
||||
* @param state which state to paint
|
||||
*/
|
||||
void paintSkinRaw(Graphics g, int dx, int dy, int dw, int dh, State state) {
|
||||
if (XPStyle.getXP() == null) {
|
||||
return;
|
||||
}
|
||||
skinPainter.paint(null, g, dx, dy, dw, dh, this, state);
|
||||
}
|
||||
|
||||
/** Paint a skin at a defined position and size
|
||||
*
|
||||
* @param g the graphics context to use for painting
|
||||
* @param dx the destination <i>x</i> coordinate
|
||||
* @param dy the destination <i>y</i> coordinate
|
||||
* @param dw the width of the area to fill, may cause
|
||||
* the image to be stretched or tiled
|
||||
* @param dh the height of the area to fill, may cause
|
||||
* the image to be stretched or tiled
|
||||
* @param state which state to paint
|
||||
* @param borderFill should test if the component uses a border fill
|
||||
and skip painting if it is
|
||||
*/
|
||||
void paintSkin(Graphics g, int dx, int dy, int dw, int dh, State state,
|
||||
boolean borderFill) {
|
||||
if (XPStyle.getXP() == null) {
|
||||
return;
|
||||
}
|
||||
if(borderFill && "borderfill".equals(getTypeEnumName(component, part,
|
||||
state, Prop.BGTYPE))) {
|
||||
return;
|
||||
}
|
||||
skinPainter.paint(null, g, dx, dy, dw, dh, this, state);
|
||||
}
|
||||
}
|
||||
|
||||
private static class SkinPainter extends CachedPainter {
|
||||
SkinPainter() {
|
||||
super(30);
|
||||
flush();
|
||||
}
|
||||
|
||||
public void flush() {
|
||||
super.flush();
|
||||
}
|
||||
|
||||
protected void paintToImage(Component c, Image image, Graphics g,
|
||||
int w, int h, Object[] args) {
|
||||
boolean accEnabled = false;
|
||||
Skin skin = (Skin)args[0];
|
||||
Part part = skin.part;
|
||||
State state = (State)args[1];
|
||||
if (state == null) {
|
||||
state = skin.state;
|
||||
}
|
||||
if (c == null) {
|
||||
c = skin.component;
|
||||
}
|
||||
BufferedImage bi = (BufferedImage)image;
|
||||
|
||||
WritableRaster raster = bi.getRaster();
|
||||
DataBufferInt dbi = (DataBufferInt)raster.getDataBuffer();
|
||||
// Note that stealData() requires a markDirty() afterwards
|
||||
// since we modify the data in it.
|
||||
ThemeReader.paintBackground(SunWritableRaster.stealData(dbi, 0),
|
||||
part.getControlName(c), part.getValue(),
|
||||
State.getValue(part, state),
|
||||
0, 0, w, h, w);
|
||||
SunWritableRaster.markDirty(dbi);
|
||||
}
|
||||
|
||||
protected Image createImage(Component c, int w, int h,
|
||||
GraphicsConfiguration config, Object[] args) {
|
||||
return new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
|
||||
}
|
||||
}
|
||||
|
||||
static class GlyphButton extends JButton {
|
||||
private Skin skin;
|
||||
|
||||
public GlyphButton(Component parent, Part part) {
|
||||
XPStyle xp = getXP();
|
||||
skin = xp != null ? xp.getSkin(parent, part) : null;
|
||||
setBorder(null);
|
||||
setContentAreaFilled(false);
|
||||
setMinimumSize(new Dimension(5, 5));
|
||||
setPreferredSize(new Dimension(16, 16));
|
||||
setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE));
|
||||
}
|
||||
|
||||
public boolean isFocusTraversable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
protected State getState() {
|
||||
State state = State.NORMAL;
|
||||
if (!isEnabled()) {
|
||||
state = State.DISABLED;
|
||||
} else if (getModel().isPressed()) {
|
||||
state = State.PRESSED;
|
||||
} else if (getModel().isRollover()) {
|
||||
state = State.HOT;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
||||
public void paintComponent(Graphics g) {
|
||||
if (XPStyle.getXP() == null || skin == null) {
|
||||
return;
|
||||
}
|
||||
Dimension d = getSize();
|
||||
skin.paintSkin(g, 0, 0, d.width, d.height, getState());
|
||||
}
|
||||
|
||||
public void setPart(Component parent, Part part) {
|
||||
XPStyle xp = getXP();
|
||||
skin = xp != null ? xp.getSkin(parent, part) : null;
|
||||
revalidate();
|
||||
repaint();
|
||||
}
|
||||
|
||||
protected void paintBorder(Graphics g) {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Private constructor
|
||||
private XPStyle() {
|
||||
flatMenus = getSysBoolean(Prop.FLATMENUS);
|
||||
|
||||
colorMap = new HashMap<String, Color>();
|
||||
borderMap = new HashMap<String, Border>();
|
||||
// Note: All further access to the maps must be synchronized
|
||||
}
|
||||
|
||||
|
||||
private boolean getBoolean(Component c, Part part, State state, Prop prop) {
|
||||
return ThemeReader.getBoolean(part.getControlName(c), part.getValue(),
|
||||
State.getValue(part, state),
|
||||
prop.getValue());
|
||||
}
|
||||
|
||||
|
||||
|
||||
static Dimension getPartSize(Part part, State state) {
|
||||
return ThemeReader.getPartSize(part.getControlName(null), part.getValue(),
|
||||
State.getValue(part, state));
|
||||
}
|
||||
|
||||
private static boolean getSysBoolean(Prop prop) {
|
||||
// We can use any widget name here, I guess.
|
||||
return ThemeReader.getSysBoolean("window", prop.getValue());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.sun.java.swing.plaf.windows.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class windows extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "FileChooser.detailsViewActionLabel.textAndMnemonic", "Details" },
|
||||
{ "FileChooser.detailsViewButtonAccessibleName", "Details" },
|
||||
{ "FileChooser.detailsViewButtonToolTip.textAndMnemonic", "Details" },
|
||||
{ "FileChooser.fileAttrHeader.textAndMnemonic", "Attributes" },
|
||||
{ "FileChooser.fileDateHeader.textAndMnemonic", "Modified" },
|
||||
{ "FileChooser.fileNameHeader.textAndMnemonic", "Name" },
|
||||
{ "FileChooser.fileNameLabel.textAndMnemonic", "File &name:" },
|
||||
{ "FileChooser.fileSizeHeader.textAndMnemonic", "Size" },
|
||||
{ "FileChooser.fileTypeHeader.textAndMnemonic", "Type" },
|
||||
{ "FileChooser.filesOfTypeLabel.textAndMnemonic", "Files of &type:" },
|
||||
{ "FileChooser.folderNameLabel.textAndMnemonic", "Folder &name:" },
|
||||
{ "FileChooser.homeFolderAccessibleName", "Home" },
|
||||
{ "FileChooser.homeFolderToolTip.textAndMnemonic", "Home" },
|
||||
{ "FileChooser.listViewActionLabel.textAndMnemonic", "List" },
|
||||
{ "FileChooser.listViewButtonAccessibleName", "List" },
|
||||
{ "FileChooser.listViewButtonToolTip.textAndMnemonic", "List" },
|
||||
{ "FileChooser.lookInLabel.textAndMnemonic", "Look &in:" },
|
||||
{ "FileChooser.newFolderAccessibleName", "New Folder" },
|
||||
{ "FileChooser.newFolderActionLabel.textAndMnemonic", "New Folder" },
|
||||
{ "FileChooser.newFolderToolTip.textAndMnemonic", "Create New Folder" },
|
||||
{ "FileChooser.refreshActionLabel.textAndMnemonic", "Refresh" },
|
||||
{ "FileChooser.saveInLabel.textAndMnemonic", "Save in:" },
|
||||
{ "FileChooser.upFolderAccessibleName", "Up" },
|
||||
{ "FileChooser.upFolderToolTip.textAndMnemonic", "Up One Level" },
|
||||
{ "FileChooser.viewMenuButtonAccessibleName", "View Menu" },
|
||||
{ "FileChooser.viewMenuButtonToolTipText", "View Menu" },
|
||||
{ "FileChooser.viewMenuLabel.textAndMnemonic", "View" },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.sun.java.swing.plaf.windows.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class windows_de extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "FileChooser.detailsViewActionLabel.textAndMnemonic", "Details" },
|
||||
{ "FileChooser.detailsViewButtonAccessibleName", "Details" },
|
||||
{ "FileChooser.detailsViewButtonToolTip.textAndMnemonic", "Details" },
|
||||
{ "FileChooser.fileAttrHeader.textAndMnemonic", "Attribute" },
|
||||
{ "FileChooser.fileDateHeader.textAndMnemonic", "Ge\u00E4ndert" },
|
||||
{ "FileChooser.fileNameHeader.textAndMnemonic", "Name" },
|
||||
{ "FileChooser.fileNameLabel.textAndMnemonic", "&Dateiname:" },
|
||||
{ "FileChooser.fileSizeHeader.textAndMnemonic", "Gr\u00F6\u00DFe" },
|
||||
{ "FileChooser.fileTypeHeader.textAndMnemonic", "Typ" },
|
||||
{ "FileChooser.filesOfTypeLabel.textAndMnemonic", "Datei&typ:" },
|
||||
{ "FileChooser.folderNameLabel.textAndMnemonic", "Ordner&name:" },
|
||||
{ "FileChooser.homeFolderAccessibleName", "Home" },
|
||||
{ "FileChooser.homeFolderToolTip.textAndMnemonic", "Home" },
|
||||
{ "FileChooser.listViewActionLabel.textAndMnemonic", "Liste" },
|
||||
{ "FileChooser.listViewButtonAccessibleName", "Liste" },
|
||||
{ "FileChooser.listViewButtonToolTip.textAndMnemonic", "Liste" },
|
||||
{ "FileChooser.lookInLabel.textAndMnemonic", "Suchen &in:" },
|
||||
{ "FileChooser.newFolderAccessibleName", "Neuer Ordner" },
|
||||
{ "FileChooser.newFolderActionLabel.textAndMnemonic", "Neuer Ordner" },
|
||||
{ "FileChooser.newFolderToolTip.textAndMnemonic", "Neuen Ordner erstellen" },
|
||||
{ "FileChooser.refreshActionLabel.textAndMnemonic", "Aktualisieren" },
|
||||
{ "FileChooser.saveInLabel.textAndMnemonic", "Speichern in:" },
|
||||
{ "FileChooser.upFolderAccessibleName", "Nach oben" },
|
||||
{ "FileChooser.upFolderToolTip.textAndMnemonic", "Eine Ebene h\u00F6her" },
|
||||
{ "FileChooser.viewMenuButtonAccessibleName", "Ansichtsmen\u00FC" },
|
||||
{ "FileChooser.viewMenuButtonToolTipText", "Ansichtsmen\u00FC" },
|
||||
{ "FileChooser.viewMenuLabel.textAndMnemonic", "Ansicht" },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.sun.java.swing.plaf.windows.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class windows_es extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "FileChooser.detailsViewActionLabel.textAndMnemonic", "Detalles" },
|
||||
{ "FileChooser.detailsViewButtonAccessibleName", "Detalles" },
|
||||
{ "FileChooser.detailsViewButtonToolTip.textAndMnemonic", "Detalles" },
|
||||
{ "FileChooser.fileAttrHeader.textAndMnemonic", "Atributos" },
|
||||
{ "FileChooser.fileDateHeader.textAndMnemonic", "Modificado" },
|
||||
{ "FileChooser.fileNameHeader.textAndMnemonic", "Nombre" },
|
||||
{ "FileChooser.fileNameLabel.textAndMnemonic", "&Nombre de archivo:" },
|
||||
{ "FileChooser.fileSizeHeader.textAndMnemonic", "Tama\u00F1o" },
|
||||
{ "FileChooser.fileTypeHeader.textAndMnemonic", "Tipo" },
|
||||
{ "FileChooser.filesOfTypeLabel.textAndMnemonic", "Archivos de &tipo:" },
|
||||
{ "FileChooser.folderNameLabel.textAndMnemonic", "&Nombre de carpeta:" },
|
||||
{ "FileChooser.homeFolderAccessibleName", "Inicio" },
|
||||
{ "FileChooser.homeFolderToolTip.textAndMnemonic", "Inicio" },
|
||||
{ "FileChooser.listViewActionLabel.textAndMnemonic", "Lista" },
|
||||
{ "FileChooser.listViewButtonAccessibleName", "Lista" },
|
||||
{ "FileChooser.listViewButtonToolTip.textAndMnemonic", "Lista" },
|
||||
{ "FileChooser.lookInLabel.textAndMnemonic", "&Buscar en:" },
|
||||
{ "FileChooser.newFolderAccessibleName", "Nueva Carpeta" },
|
||||
{ "FileChooser.newFolderActionLabel.textAndMnemonic", "Nueva Carpeta" },
|
||||
{ "FileChooser.newFolderToolTip.textAndMnemonic", "Crear Nueva Carpeta" },
|
||||
{ "FileChooser.refreshActionLabel.textAndMnemonic", "Refrescar" },
|
||||
{ "FileChooser.saveInLabel.textAndMnemonic", "Guardar en:" },
|
||||
{ "FileChooser.upFolderAccessibleName", "Arriba" },
|
||||
{ "FileChooser.upFolderToolTip.textAndMnemonic", "Subir un Nivel" },
|
||||
{ "FileChooser.viewMenuButtonAccessibleName", "Men\u00FA Ver" },
|
||||
{ "FileChooser.viewMenuButtonToolTipText", "Men\u00FA Ver" },
|
||||
{ "FileChooser.viewMenuLabel.textAndMnemonic", "Ver" },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.sun.java.swing.plaf.windows.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class windows_fr extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "FileChooser.detailsViewActionLabel.textAndMnemonic", "D\u00E9tails" },
|
||||
{ "FileChooser.detailsViewButtonAccessibleName", "D\u00E9tails" },
|
||||
{ "FileChooser.detailsViewButtonToolTip.textAndMnemonic", "D\u00E9tails" },
|
||||
{ "FileChooser.fileAttrHeader.textAndMnemonic", "Attributs" },
|
||||
{ "FileChooser.fileDateHeader.textAndMnemonic", "Modifi\u00E9" },
|
||||
{ "FileChooser.fileNameHeader.textAndMnemonic", "Nom" },
|
||||
{ "FileChooser.fileNameLabel.textAndMnemonic", "&Nom du fichier :" },
|
||||
{ "FileChooser.fileSizeHeader.textAndMnemonic", "Taille" },
|
||||
{ "FileChooser.fileTypeHeader.textAndMnemonic", "Type" },
|
||||
{ "FileChooser.filesOfTypeLabel.textAndMnemonic", "&Type de fichier :" },
|
||||
{ "FileChooser.folderNameLabel.textAndMnemonic", "&Nom du dossier :" },
|
||||
{ "FileChooser.homeFolderAccessibleName", "R\u00E9pertoire de base" },
|
||||
{ "FileChooser.homeFolderToolTip.textAndMnemonic", "R\u00E9pertoire de base" },
|
||||
{ "FileChooser.listViewActionLabel.textAndMnemonic", "Liste" },
|
||||
{ "FileChooser.listViewButtonAccessibleName", "Liste" },
|
||||
{ "FileChooser.listViewButtonToolTip.textAndMnemonic", "Liste" },
|
||||
{ "FileChooser.lookInLabel.textAndMnemonic", "Rechercher &dans :" },
|
||||
{ "FileChooser.newFolderAccessibleName", "Nouveau dossier" },
|
||||
{ "FileChooser.newFolderActionLabel.textAndMnemonic", "Nouveau dossier" },
|
||||
{ "FileChooser.newFolderToolTip.textAndMnemonic", "Cr\u00E9e un dossier." },
|
||||
{ "FileChooser.refreshActionLabel.textAndMnemonic", "Actualiser" },
|
||||
{ "FileChooser.saveInLabel.textAndMnemonic", "Enregistrer dans :" },
|
||||
{ "FileChooser.upFolderAccessibleName", "Monter" },
|
||||
{ "FileChooser.upFolderToolTip.textAndMnemonic", "Remonte d'un niveau." },
|
||||
{ "FileChooser.viewMenuButtonAccessibleName", "Menu Affichage" },
|
||||
{ "FileChooser.viewMenuButtonToolTipText", "Menu Affichage" },
|
||||
{ "FileChooser.viewMenuLabel.textAndMnemonic", "Affichage" },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.sun.java.swing.plaf.windows.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class windows_it extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "FileChooser.detailsViewActionLabel.textAndMnemonic", "Dettagli" },
|
||||
{ "FileChooser.detailsViewButtonAccessibleName", "Dettagli" },
|
||||
{ "FileChooser.detailsViewButtonToolTip.textAndMnemonic", "Dettagli" },
|
||||
{ "FileChooser.fileAttrHeader.textAndMnemonic", "Attributi" },
|
||||
{ "FileChooser.fileDateHeader.textAndMnemonic", "Modificato" },
|
||||
{ "FileChooser.fileNameHeader.textAndMnemonic", "Nome" },
|
||||
{ "FileChooser.fileNameLabel.textAndMnemonic", "&Nome file:" },
|
||||
{ "FileChooser.fileSizeHeader.textAndMnemonic", "Dimensioni" },
|
||||
{ "FileChooser.fileTypeHeader.textAndMnemonic", "Tipo" },
|
||||
{ "FileChooser.filesOfTypeLabel.textAndMnemonic", "&Tipo file:" },
|
||||
{ "FileChooser.folderNameLabel.textAndMnemonic", "&Nome cartella:" },
|
||||
{ "FileChooser.homeFolderAccessibleName", "Home" },
|
||||
{ "FileChooser.homeFolderToolTip.textAndMnemonic", "Home" },
|
||||
{ "FileChooser.listViewActionLabel.textAndMnemonic", "Lista" },
|
||||
{ "FileChooser.listViewButtonAccessibleName", "Lista" },
|
||||
{ "FileChooser.listViewButtonToolTip.textAndMnemonic", "Lista" },
|
||||
{ "FileChooser.lookInLabel.textAndMnemonic", "Cerca &in:" },
|
||||
{ "FileChooser.newFolderAccessibleName", "Nuova cartella" },
|
||||
{ "FileChooser.newFolderActionLabel.textAndMnemonic", "Nuova cartella" },
|
||||
{ "FileChooser.newFolderToolTip.textAndMnemonic", "Crea nuova cartella" },
|
||||
{ "FileChooser.refreshActionLabel.textAndMnemonic", "Aggiorna" },
|
||||
{ "FileChooser.saveInLabel.textAndMnemonic", "Salva in:" },
|
||||
{ "FileChooser.upFolderAccessibleName", "Superiore" },
|
||||
{ "FileChooser.upFolderToolTip.textAndMnemonic", "Cartella superiore" },
|
||||
{ "FileChooser.viewMenuButtonAccessibleName", "Visualizza menu" },
|
||||
{ "FileChooser.viewMenuButtonToolTipText", "Visualizza menu" },
|
||||
{ "FileChooser.viewMenuLabel.textAndMnemonic", "Visualizza" },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.sun.java.swing.plaf.windows.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class windows_ja extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "FileChooser.detailsViewActionLabel.textAndMnemonic", "\u8A73\u7D30" },
|
||||
{ "FileChooser.detailsViewButtonAccessibleName", "\u8A73\u7D30" },
|
||||
{ "FileChooser.detailsViewButtonToolTip.textAndMnemonic", "\u8A73\u7D30" },
|
||||
{ "FileChooser.fileAttrHeader.textAndMnemonic", "\u5C5E\u6027" },
|
||||
{ "FileChooser.fileDateHeader.textAndMnemonic", "\u4FEE\u6B63\u65E5" },
|
||||
{ "FileChooser.fileNameHeader.textAndMnemonic", "\u540D\u524D" },
|
||||
{ "FileChooser.fileNameLabel.textAndMnemonic", "\u30D5\u30A1\u30A4\u30EB\u540D(&N):" },
|
||||
{ "FileChooser.fileSizeHeader.textAndMnemonic", "\u30B5\u30A4\u30BA" },
|
||||
{ "FileChooser.fileTypeHeader.textAndMnemonic", "\u30BF\u30A4\u30D7" },
|
||||
{ "FileChooser.filesOfTypeLabel.textAndMnemonic", "\u30D5\u30A1\u30A4\u30EB\u306E\u30BF\u30A4\u30D7(&T):" },
|
||||
{ "FileChooser.folderNameLabel.textAndMnemonic", "\u30D5\u30A9\u30EB\u30C0\u540D(&N):" },
|
||||
{ "FileChooser.homeFolderAccessibleName", "\u30DB\u30FC\u30E0" },
|
||||
{ "FileChooser.homeFolderToolTip.textAndMnemonic", "\u30DB\u30FC\u30E0" },
|
||||
{ "FileChooser.listViewActionLabel.textAndMnemonic", "\u30EA\u30B9\u30C8" },
|
||||
{ "FileChooser.listViewButtonAccessibleName", "\u30EA\u30B9\u30C8" },
|
||||
{ "FileChooser.listViewButtonToolTip.textAndMnemonic", "\u30EA\u30B9\u30C8" },
|
||||
{ "FileChooser.lookInLabel.textAndMnemonic", "\u30D5\u30A1\u30A4\u30EB\u306E\u5834\u6240(&I):" },
|
||||
{ "FileChooser.newFolderAccessibleName", "\u65B0\u898F\u30D5\u30A9\u30EB\u30C0" },
|
||||
{ "FileChooser.newFolderActionLabel.textAndMnemonic", "\u65B0\u898F\u30D5\u30A9\u30EB\u30C0" },
|
||||
{ "FileChooser.newFolderToolTip.textAndMnemonic", "\u65B0\u898F\u30D5\u30A9\u30EB\u30C0\u306E\u4F5C\u6210" },
|
||||
{ "FileChooser.refreshActionLabel.textAndMnemonic", "\u30EA\u30D5\u30EC\u30C3\u30B7\u30E5" },
|
||||
{ "FileChooser.saveInLabel.textAndMnemonic", "\u4FDD\u5B58:" },
|
||||
{ "FileChooser.upFolderAccessibleName", "\u4E0A\u3078" },
|
||||
{ "FileChooser.upFolderToolTip.textAndMnemonic", "1\u30EC\u30D9\u30EB\u4E0A\u3078" },
|
||||
{ "FileChooser.viewMenuButtonAccessibleName", "\u8868\u793A\u30E1\u30CB\u30E5\u30FC" },
|
||||
{ "FileChooser.viewMenuButtonToolTipText", "\u8868\u793A\u30E1\u30CB\u30E5\u30FC" },
|
||||
{ "FileChooser.viewMenuLabel.textAndMnemonic", "\u8868\u793A" },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.sun.java.swing.plaf.windows.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class windows_ko extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "FileChooser.detailsViewActionLabel.textAndMnemonic", "\uC138\uBD80\uC815\uBCF4" },
|
||||
{ "FileChooser.detailsViewButtonAccessibleName", "\uC138\uBD80\uC815\uBCF4" },
|
||||
{ "FileChooser.detailsViewButtonToolTip.textAndMnemonic", "\uC138\uBD80\uC815\uBCF4" },
|
||||
{ "FileChooser.fileAttrHeader.textAndMnemonic", "\uC18D\uC131" },
|
||||
{ "FileChooser.fileDateHeader.textAndMnemonic", "\uC218\uC815 \uB0A0\uC9DC" },
|
||||
{ "FileChooser.fileNameHeader.textAndMnemonic", "\uC774\uB984" },
|
||||
{ "FileChooser.fileNameLabel.textAndMnemonic", "\uD30C\uC77C \uC774\uB984(&N):" },
|
||||
{ "FileChooser.fileSizeHeader.textAndMnemonic", "\uD06C\uAE30" },
|
||||
{ "FileChooser.fileTypeHeader.textAndMnemonic", "\uC720\uD615" },
|
||||
{ "FileChooser.filesOfTypeLabel.textAndMnemonic", "\uD30C\uC77C \uC720\uD615(&T):" },
|
||||
{ "FileChooser.folderNameLabel.textAndMnemonic", "\uD3F4\uB354 \uC774\uB984(&N):" },
|
||||
{ "FileChooser.homeFolderAccessibleName", "\uD648" },
|
||||
{ "FileChooser.homeFolderToolTip.textAndMnemonic", "\uD648" },
|
||||
{ "FileChooser.listViewActionLabel.textAndMnemonic", "\uBAA9\uB85D" },
|
||||
{ "FileChooser.listViewButtonAccessibleName", "\uBAA9\uB85D" },
|
||||
{ "FileChooser.listViewButtonToolTip.textAndMnemonic", "\uBAA9\uB85D" },
|
||||
{ "FileChooser.lookInLabel.textAndMnemonic", "\uCC3E\uB294 \uC704\uCE58(&I):" },
|
||||
{ "FileChooser.newFolderAccessibleName", "\uC0C8 \uD3F4\uB354" },
|
||||
{ "FileChooser.newFolderActionLabel.textAndMnemonic", "\uC0C8 \uD3F4\uB354" },
|
||||
{ "FileChooser.newFolderToolTip.textAndMnemonic", "\uC0C8 \uD3F4\uB354 \uC0DD\uC131" },
|
||||
{ "FileChooser.refreshActionLabel.textAndMnemonic", "\uC0C8\uB85C\uACE0\uCE68" },
|
||||
{ "FileChooser.saveInLabel.textAndMnemonic", "\uC800\uC7A5 \uC704\uCE58:" },
|
||||
{ "FileChooser.upFolderAccessibleName", "\uC704\uB85C" },
|
||||
{ "FileChooser.upFolderToolTip.textAndMnemonic", "\uD55C \uB808\uBCA8 \uC704\uB85C" },
|
||||
{ "FileChooser.viewMenuButtonAccessibleName", "\uBCF4\uAE30 \uBA54\uB274" },
|
||||
{ "FileChooser.viewMenuButtonToolTipText", "\uBCF4\uAE30 \uBA54\uB274" },
|
||||
{ "FileChooser.viewMenuLabel.textAndMnemonic", "\uBCF4\uAE30" },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.sun.java.swing.plaf.windows.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class windows_pt_BR extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "FileChooser.detailsViewActionLabel.textAndMnemonic", "Detalhes" },
|
||||
{ "FileChooser.detailsViewButtonAccessibleName", "Detalhes" },
|
||||
{ "FileChooser.detailsViewButtonToolTip.textAndMnemonic", "Detalhes" },
|
||||
{ "FileChooser.fileAttrHeader.textAndMnemonic", "Atributos" },
|
||||
{ "FileChooser.fileDateHeader.textAndMnemonic", "Modificado" },
|
||||
{ "FileChooser.fileNameHeader.textAndMnemonic", "Nome" },
|
||||
{ "FileChooser.fileNameLabel.textAndMnemonic", "&Nome do arquivo:" },
|
||||
{ "FileChooser.fileSizeHeader.textAndMnemonic", "Tamanho" },
|
||||
{ "FileChooser.fileTypeHeader.textAndMnemonic", "Tipo" },
|
||||
{ "FileChooser.filesOfTypeLabel.textAndMnemonic", "Arquivos do &tipo:" },
|
||||
{ "FileChooser.folderNameLabel.textAndMnemonic", "&Nome da pasta:" },
|
||||
{ "FileChooser.homeFolderAccessibleName", "In\u00EDcio" },
|
||||
{ "FileChooser.homeFolderToolTip.textAndMnemonic", "In\u00EDcio" },
|
||||
{ "FileChooser.listViewActionLabel.textAndMnemonic", "Lista" },
|
||||
{ "FileChooser.listViewButtonAccessibleName", "Lista" },
|
||||
{ "FileChooser.listViewButtonToolTip.textAndMnemonic", "Lista" },
|
||||
{ "FileChooser.lookInLabel.textAndMnemonic", "Pesquisar &em:" },
|
||||
{ "FileChooser.newFolderAccessibleName", "Nova Pasta" },
|
||||
{ "FileChooser.newFolderActionLabel.textAndMnemonic", "Nova Pasta" },
|
||||
{ "FileChooser.newFolderToolTip.textAndMnemonic", "Criar Nova Pasta" },
|
||||
{ "FileChooser.refreshActionLabel.textAndMnemonic", "Atualizar" },
|
||||
{ "FileChooser.saveInLabel.textAndMnemonic", "Salvar em:" },
|
||||
{ "FileChooser.upFolderAccessibleName", "Acima" },
|
||||
{ "FileChooser.upFolderToolTip.textAndMnemonic", "Um N\u00EDvel Acima" },
|
||||
{ "FileChooser.viewMenuButtonAccessibleName", "Exibir Menu" },
|
||||
{ "FileChooser.viewMenuButtonToolTipText", "Exibir Menu" },
|
||||
{ "FileChooser.viewMenuLabel.textAndMnemonic", "Exibir" },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.sun.java.swing.plaf.windows.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class windows_sv extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "FileChooser.detailsViewActionLabel.textAndMnemonic", "Detaljer" },
|
||||
{ "FileChooser.detailsViewButtonAccessibleName", "Detaljer" },
|
||||
{ "FileChooser.detailsViewButtonToolTip.textAndMnemonic", "Detaljer" },
|
||||
{ "FileChooser.fileAttrHeader.textAndMnemonic", "Attribut" },
|
||||
{ "FileChooser.fileDateHeader.textAndMnemonic", "\u00C4ndrad" },
|
||||
{ "FileChooser.fileNameHeader.textAndMnemonic", "Namn" },
|
||||
{ "FileChooser.fileNameLabel.textAndMnemonic", "Fil&namn:" },
|
||||
{ "FileChooser.fileSizeHeader.textAndMnemonic", "Storlek" },
|
||||
{ "FileChooser.fileTypeHeader.textAndMnemonic", "Typ" },
|
||||
{ "FileChooser.filesOfTypeLabel.textAndMnemonic", "Filer av &typen:" },
|
||||
{ "FileChooser.folderNameLabel.textAndMnemonic", "Mapp&namn:" },
|
||||
{ "FileChooser.homeFolderAccessibleName", "Hem" },
|
||||
{ "FileChooser.homeFolderToolTip.textAndMnemonic", "Hem" },
|
||||
{ "FileChooser.listViewActionLabel.textAndMnemonic", "Lista" },
|
||||
{ "FileChooser.listViewButtonAccessibleName", "Lista" },
|
||||
{ "FileChooser.listViewButtonToolTip.textAndMnemonic", "Lista" },
|
||||
{ "FileChooser.lookInLabel.textAndMnemonic", "Leta &i:" },
|
||||
{ "FileChooser.newFolderAccessibleName", "Ny mapp" },
|
||||
{ "FileChooser.newFolderActionLabel.textAndMnemonic", "Ny mapp" },
|
||||
{ "FileChooser.newFolderToolTip.textAndMnemonic", "Skapa ny mapp" },
|
||||
{ "FileChooser.refreshActionLabel.textAndMnemonic", "F\u00F6rnya" },
|
||||
{ "FileChooser.saveInLabel.textAndMnemonic", "Spara i:" },
|
||||
{ "FileChooser.upFolderAccessibleName", "Upp" },
|
||||
{ "FileChooser.upFolderToolTip.textAndMnemonic", "Upp en niv\u00E5" },
|
||||
{ "FileChooser.viewMenuButtonAccessibleName", "Menyn Visa" },
|
||||
{ "FileChooser.viewMenuButtonToolTipText", "Menyn Visa" },
|
||||
{ "FileChooser.viewMenuLabel.textAndMnemonic", "Vy" },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.sun.java.swing.plaf.windows.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class windows_zh_CN extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "FileChooser.detailsViewActionLabel.textAndMnemonic", "\u8BE6\u7EC6\u4FE1\u606F" },
|
||||
{ "FileChooser.detailsViewButtonAccessibleName", "\u8BE6\u7EC6\u4FE1\u606F" },
|
||||
{ "FileChooser.detailsViewButtonToolTip.textAndMnemonic", "\u8BE6\u7EC6\u4FE1\u606F" },
|
||||
{ "FileChooser.fileAttrHeader.textAndMnemonic", "\u5C5E\u6027" },
|
||||
{ "FileChooser.fileDateHeader.textAndMnemonic", "\u4FEE\u6539\u65E5\u671F" },
|
||||
{ "FileChooser.fileNameHeader.textAndMnemonic", "\u540D\u79F0" },
|
||||
{ "FileChooser.fileNameLabel.textAndMnemonic", "\u6587\u4EF6\u540D(&N):" },
|
||||
{ "FileChooser.fileSizeHeader.textAndMnemonic", "\u5927\u5C0F" },
|
||||
{ "FileChooser.fileTypeHeader.textAndMnemonic", "\u7C7B\u578B" },
|
||||
{ "FileChooser.filesOfTypeLabel.textAndMnemonic", "\u6587\u4EF6\u7C7B\u578B(&T):" },
|
||||
{ "FileChooser.folderNameLabel.textAndMnemonic", "\u6587\u4EF6\u5939\u540D(&N):" },
|
||||
{ "FileChooser.homeFolderAccessibleName", "\u4E3B\u76EE\u5F55" },
|
||||
{ "FileChooser.homeFolderToolTip.textAndMnemonic", "\u4E3B\u76EE\u5F55" },
|
||||
{ "FileChooser.listViewActionLabel.textAndMnemonic", "\u5217\u8868" },
|
||||
{ "FileChooser.listViewButtonAccessibleName", "\u5217\u8868" },
|
||||
{ "FileChooser.listViewButtonToolTip.textAndMnemonic", "\u5217\u8868" },
|
||||
{ "FileChooser.lookInLabel.textAndMnemonic", "\u67E5\u627E(&I):" },
|
||||
{ "FileChooser.newFolderAccessibleName", "\u65B0\u5EFA\u6587\u4EF6\u5939" },
|
||||
{ "FileChooser.newFolderActionLabel.textAndMnemonic", "\u65B0\u5EFA\u6587\u4EF6\u5939" },
|
||||
{ "FileChooser.newFolderToolTip.textAndMnemonic", "\u521B\u5EFA\u65B0\u6587\u4EF6\u5939" },
|
||||
{ "FileChooser.refreshActionLabel.textAndMnemonic", "\u5237\u65B0" },
|
||||
{ "FileChooser.saveInLabel.textAndMnemonic", "\u4FDD\u5B58: " },
|
||||
{ "FileChooser.upFolderAccessibleName", "\u5411\u4E0A" },
|
||||
{ "FileChooser.upFolderToolTip.textAndMnemonic", "\u5411\u4E0A\u4E00\u7EA7" },
|
||||
{ "FileChooser.viewMenuButtonAccessibleName", "\u67E5\u770B\u83DC\u5355" },
|
||||
{ "FileChooser.viewMenuButtonToolTipText", "\u67E5\u770B\u83DC\u5355" },
|
||||
{ "FileChooser.viewMenuLabel.textAndMnemonic", "\u89C6\u56FE" },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.sun.java.swing.plaf.windows.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class windows_zh_HK extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "FileChooser.detailsViewActionLabel.textAndMnemonic", "\u8A73\u7D30\u8CC7\u8A0A" },
|
||||
{ "FileChooser.detailsViewButtonAccessibleName", "\u8A73\u7D30\u8CC7\u8A0A" },
|
||||
{ "FileChooser.detailsViewButtonToolTip.textAndMnemonic", "\u8A73\u7D30\u8CC7\u8A0A" },
|
||||
{ "FileChooser.fileAttrHeader.textAndMnemonic", "\u5C6C\u6027" },
|
||||
{ "FileChooser.fileDateHeader.textAndMnemonic", "\u4FEE\u6539\u65E5\u671F" },
|
||||
{ "FileChooser.fileNameHeader.textAndMnemonic", "\u540D\u7A31" },
|
||||
{ "FileChooser.fileNameLabel.textAndMnemonic", "\u6A94\u6848\u540D\u7A31(&N):" },
|
||||
{ "FileChooser.fileSizeHeader.textAndMnemonic", "\u5927\u5C0F" },
|
||||
{ "FileChooser.fileTypeHeader.textAndMnemonic", "\u985E\u578B" },
|
||||
{ "FileChooser.filesOfTypeLabel.textAndMnemonic", "\u6A94\u6848\u985E\u578B(&T):" },
|
||||
{ "FileChooser.folderNameLabel.textAndMnemonic", "\u8CC7\u6599\u593E\u540D\u7A31(&N):" },
|
||||
{ "FileChooser.homeFolderAccessibleName", "\u4E3B\u76EE\u9304" },
|
||||
{ "FileChooser.homeFolderToolTip.textAndMnemonic", "\u4E3B\u76EE\u9304" },
|
||||
{ "FileChooser.listViewActionLabel.textAndMnemonic", "\u6E05\u55AE" },
|
||||
{ "FileChooser.listViewButtonAccessibleName", "\u6E05\u55AE" },
|
||||
{ "FileChooser.listViewButtonToolTip.textAndMnemonic", "\u6E05\u55AE" },
|
||||
{ "FileChooser.lookInLabel.textAndMnemonic", "\u67E5\u8A62(&I):" },
|
||||
{ "FileChooser.newFolderAccessibleName", "\u65B0\u8CC7\u6599\u593E" },
|
||||
{ "FileChooser.newFolderActionLabel.textAndMnemonic", "\u65B0\u8CC7\u6599\u593E" },
|
||||
{ "FileChooser.newFolderToolTip.textAndMnemonic", "\u5EFA\u7ACB\u65B0\u8CC7\u6599\u593E" },
|
||||
{ "FileChooser.refreshActionLabel.textAndMnemonic", "\u91CD\u65B0\u6574\u7406" },
|
||||
{ "FileChooser.saveInLabel.textAndMnemonic", "\u5132\u5B58\u65BC: " },
|
||||
{ "FileChooser.upFolderAccessibleName", "\u5F80\u4E0A" },
|
||||
{ "FileChooser.upFolderToolTip.textAndMnemonic", "\u5F80\u4E0A\u4E00\u5C64" },
|
||||
{ "FileChooser.viewMenuButtonAccessibleName", "\u6AA2\u8996\u529F\u80FD\u8868" },
|
||||
{ "FileChooser.viewMenuButtonToolTipText", "\u6AA2\u8996\u529F\u80FD\u8868" },
|
||||
{ "FileChooser.viewMenuLabel.textAndMnemonic", "\u6AA2\u8996" },
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.sun.java.swing.plaf.windows.resources;
|
||||
|
||||
import java.util.ListResourceBundle;
|
||||
|
||||
public final class windows_zh_TW extends ListResourceBundle {
|
||||
protected final Object[][] getContents() {
|
||||
return new Object[][] {
|
||||
{ "FileChooser.detailsViewActionLabel.textAndMnemonic", "\u8A73\u7D30\u8CC7\u8A0A" },
|
||||
{ "FileChooser.detailsViewButtonAccessibleName", "\u8A73\u7D30\u8CC7\u8A0A" },
|
||||
{ "FileChooser.detailsViewButtonToolTip.textAndMnemonic", "\u8A73\u7D30\u8CC7\u8A0A" },
|
||||
{ "FileChooser.fileAttrHeader.textAndMnemonic", "\u5C6C\u6027" },
|
||||
{ "FileChooser.fileDateHeader.textAndMnemonic", "\u4FEE\u6539\u65E5\u671F" },
|
||||
{ "FileChooser.fileNameHeader.textAndMnemonic", "\u540D\u7A31" },
|
||||
{ "FileChooser.fileNameLabel.textAndMnemonic", "\u6A94\u6848\u540D\u7A31(&N):" },
|
||||
{ "FileChooser.fileSizeHeader.textAndMnemonic", "\u5927\u5C0F" },
|
||||
{ "FileChooser.fileTypeHeader.textAndMnemonic", "\u985E\u578B" },
|
||||
{ "FileChooser.filesOfTypeLabel.textAndMnemonic", "\u6A94\u6848\u985E\u578B(&T):" },
|
||||
{ "FileChooser.folderNameLabel.textAndMnemonic", "\u8CC7\u6599\u593E\u540D\u7A31(&N):" },
|
||||
{ "FileChooser.homeFolderAccessibleName", "\u4E3B\u76EE\u9304" },
|
||||
{ "FileChooser.homeFolderToolTip.textAndMnemonic", "\u4E3B\u76EE\u9304" },
|
||||
{ "FileChooser.listViewActionLabel.textAndMnemonic", "\u6E05\u55AE" },
|
||||
{ "FileChooser.listViewButtonAccessibleName", "\u6E05\u55AE" },
|
||||
{ "FileChooser.listViewButtonToolTip.textAndMnemonic", "\u6E05\u55AE" },
|
||||
{ "FileChooser.lookInLabel.textAndMnemonic", "\u67E5\u8A62(&I):" },
|
||||
{ "FileChooser.newFolderAccessibleName", "\u65B0\u8CC7\u6599\u593E" },
|
||||
{ "FileChooser.newFolderActionLabel.textAndMnemonic", "\u65B0\u8CC7\u6599\u593E" },
|
||||
{ "FileChooser.newFolderToolTip.textAndMnemonic", "\u5EFA\u7ACB\u65B0\u8CC7\u6599\u593E" },
|
||||
{ "FileChooser.refreshActionLabel.textAndMnemonic", "\u91CD\u65B0\u6574\u7406" },
|
||||
{ "FileChooser.saveInLabel.textAndMnemonic", "\u5132\u5B58\u65BC: " },
|
||||
{ "FileChooser.upFolderAccessibleName", "\u5F80\u4E0A" },
|
||||
{ "FileChooser.upFolderToolTip.textAndMnemonic", "\u5F80\u4E0A\u4E00\u5C64" },
|
||||
{ "FileChooser.viewMenuButtonAccessibleName", "\u6AA2\u8996\u529F\u80FD\u8868" },
|
||||
{ "FileChooser.viewMenuButtonToolTipText", "\u6AA2\u8996\u529F\u80FD\u8868" },
|
||||
{ "FileChooser.viewMenuLabel.textAndMnemonic", "\u6AA2\u8996" },
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user