mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-12 13:26:53 -04:00
Animations on Scroll Bar
This commit is contained in:
parent
61afad30c8
commit
f4303a0480
@ -203,32 +203,6 @@ public class BEButtonUI extends BasicButtonUI implements Skin {
|
||||
dh -= (insets.top + insets.bottom);
|
||||
}
|
||||
|
||||
/*if (toolbar)
|
||||
//此状态下JToggleButton和JButton使用各自的背景实现,2012-10-16前无论是不是JToggleButton都是使用该种实是不太合理的
|
||||
if (model.isRollover() || model.isPressed())
|
||||
if (c instanceof JToggleButton)
|
||||
BEToggleButtonUI.ICON_9.get("rollover").draw((Graphics2D) g, dx, dy, dw, dh);
|
||||
else
|
||||
ICON_9.get("pressed").draw((Graphics2D) g, dx, dy, dw, dh);
|
||||
else if (model.isSelected())
|
||||
BEToggleButtonUI.ICON_9.get("selected").draw((Graphics2D) g, dx, dy, dw, dh);
|
||||
else {
|
||||
//TODO 其它状态下的按钮背景样式需要完善,要不然看起来太硬!
|
||||
// skin.paintSkin(g, dx, dy, dw, dh, state);
|
||||
}
|
||||
else {
|
||||
//TODO 其它状态下的按钮背景样式需要完善,要不然看起来太硬!
|
||||
String key;
|
||||
if (model.isArmed() && model.isPressed() || model.isSelected())
|
||||
key = "pressed";
|
||||
else if (!model.isEnabled())
|
||||
key = "disabled";
|
||||
else if (model.isRollover())
|
||||
key = "rollover";
|
||||
else
|
||||
key = "normal";
|
||||
ICON_9.get(key).draw((Graphics2D) g, dx, dy, dw, dh);
|
||||
}*/
|
||||
AnimationController.paintSkin(c, INSTANCE, g, dx, dy, dw, dh, getXPButtonState(b));
|
||||
}
|
||||
}
|
||||
@ -247,7 +221,7 @@ public class BEButtonUI extends BasicButtonUI implements Skin {
|
||||
return toolbar ? Part.TP_BUTTON : Part.BP_PUSHBUTTON;
|
||||
}
|
||||
|
||||
static State getXPButtonState(AbstractButton b) {
|
||||
public static State getXPButtonState(AbstractButton b) {
|
||||
Part part = getXPButtonType(b);
|
||||
ButtonModel model = b.getModel();
|
||||
State state = State.NORMAL;
|
||||
@ -276,13 +250,13 @@ public class BEButtonUI extends BasicButtonUI implements Skin {
|
||||
else if (!model.isEnabled())
|
||||
state = State.DISABLED;
|
||||
else if (model.isSelected() && model.isRollover())
|
||||
state = State.HOTCHECKED;
|
||||
state = State.ROLLOVERCHECKED;
|
||||
else if (model.isSelected())
|
||||
state = State.CHECKED;
|
||||
else if (model.isRollover())
|
||||
state = State.HOT;
|
||||
state = State.ROLLOVER;
|
||||
else if (b.hasFocus())
|
||||
state = State.HOT;
|
||||
state = State.ROLLOVER;
|
||||
} else
|
||||
if ((model.isArmed() && model.isPressed())
|
||||
|| model.isSelected())
|
||||
@ -290,7 +264,7 @@ public class BEButtonUI extends BasicButtonUI implements Skin {
|
||||
else if (!model.isEnabled())
|
||||
state = State.DISABLED;
|
||||
else if (model.isRollover() || model.isPressed())
|
||||
state = State.HOT;
|
||||
state = State.ROLLOVER;
|
||||
else if (b instanceof JButton
|
||||
&& ((JButton) b).isDefaultButton())
|
||||
state = State.DEFAULTED;
|
||||
@ -304,27 +278,7 @@ public class BEButtonUI extends BasicButtonUI implements Skin {
|
||||
|
||||
@Override
|
||||
public void paintSkinRaw(Graphics g, int dx, int dy, int dw, int dh, TMSchema.State state) {
|
||||
String key;
|
||||
switch (state) {
|
||||
case SELECTED:
|
||||
key = "selected";
|
||||
break;
|
||||
case PRESSED:
|
||||
key = "pressed";
|
||||
break;
|
||||
case DISABLED:
|
||||
key = "disabled";
|
||||
break;
|
||||
case HOT:
|
||||
key = "rollover";
|
||||
break;
|
||||
case NORMAL:
|
||||
key = "normal";
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
ICON_9.get(key).draw((Graphics2D) g, dx, dy, dw, dh);
|
||||
ICON_9.get(state.toString()).draw((Graphics2D) g, dx, dy, dw, dh);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -183,7 +183,7 @@ public class BEComboBoxUI extends BasicComboBoxUI
|
||||
} else if (isPopupVisible(comboBox)) {
|
||||
state = State.PRESSED;
|
||||
} else if (mouseInside) {
|
||||
state = State.HOT;
|
||||
state = State.ROLLOVER;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
@ -198,7 +198,7 @@ public class BEComboBoxUI extends BasicComboBoxUI
|
||||
case DISABLED:
|
||||
key = "disabled";
|
||||
break;
|
||||
case HOT:
|
||||
case ROLLOVER:
|
||||
key = "rollover";
|
||||
break;
|
||||
case NORMAL:
|
||||
|
@ -24,8 +24,13 @@ import javax.swing.UIManager;
|
||||
import javax.swing.plaf.ComponentUI;
|
||||
import javax.swing.plaf.basic.BasicArrowButton;
|
||||
import javax.swing.plaf.basic.BasicScrollBarUI;
|
||||
import org.jackhuang.hmcl.laf.button.BEButtonUI;
|
||||
import org.jackhuang.hmcl.laf.utils.AnimationController;
|
||||
|
||||
import org.jackhuang.hmcl.laf.utils.Icon9Factory;
|
||||
import org.jackhuang.hmcl.laf.utils.Skin;
|
||||
import org.jackhuang.hmcl.laf.utils.TMSchema;
|
||||
import org.jackhuang.hmcl.laf.utils.TMSchema.State;
|
||||
import org.jackhuang.hmcl.util.ui.GraphicsUtils;
|
||||
|
||||
/**
|
||||
@ -37,7 +42,7 @@ import org.jackhuang.hmcl.util.ui.GraphicsUtils;
|
||||
* @version 1.0
|
||||
* @see com.sun.java.swing.plaf.windows.WindowsScrollBarUI
|
||||
*/
|
||||
public class BEScrollBarUI extends BasicScrollBarUI {
|
||||
public class BEScrollBarUI extends BasicScrollBarUI implements Skin {
|
||||
|
||||
public static final Icon9Factory ICON_9 = new Icon9Factory("scroll_bar");
|
||||
|
||||
@ -68,7 +73,7 @@ public class BEScrollBarUI extends BasicScrollBarUI {
|
||||
* up/down. It differs from BasicArrowButton in that the preferred size is
|
||||
* always a square.
|
||||
*/
|
||||
protected class BEArrowButton extends BasicArrowButton {
|
||||
protected class BEArrowButton extends BasicArrowButton implements Skin {
|
||||
|
||||
/**
|
||||
* Instantiates a new windows arrow button.
|
||||
@ -91,7 +96,6 @@ public class BEScrollBarUI extends BasicScrollBarUI {
|
||||
@Override
|
||||
public void paint(Graphics g) {
|
||||
Graphics2D g2 = (Graphics2D) g;
|
||||
String id = "arrow";
|
||||
switch (direction) {
|
||||
case NORTH:
|
||||
break;
|
||||
@ -108,8 +112,7 @@ public class BEScrollBarUI extends BasicScrollBarUI {
|
||||
g2.rotate(Math.PI / 2);
|
||||
break;
|
||||
}
|
||||
ICON_9.getWithScrollState(id, getModel().isPressed(), getModel().isRollover())
|
||||
.draw(g2, 0, 0, getWidth(), getHeight());
|
||||
AnimationController.paintSkin(this, this, g, 0, 0, getWidth(), getHeight(), BEButtonUI.getXPButtonState(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -128,6 +131,16 @@ public class BEScrollBarUI extends BasicScrollBarUI {
|
||||
}
|
||||
return new Dimension(size, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintSkinRaw(Graphics g, int x, int y, int w, int h, TMSchema.State state) {
|
||||
ICON_9.get("arrow", state.toString()).draw((Graphics2D) g, x, y, w, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TMSchema.Part getPart(JComponent c) {
|
||||
return TMSchema.Part.SBP_ARROWBTN;
|
||||
}
|
||||
}
|
||||
//----------------------------------------------------------------------------------- END
|
||||
|
||||
@ -148,10 +161,21 @@ public class BEScrollBarUI extends BasicScrollBarUI {
|
||||
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
|
||||
if (thumbBounds.isEmpty() || !scrollbar.isEnabled())
|
||||
return;
|
||||
Color color = GraphicsUtils.getWebColor(isDragging ? "#616161" : isThumbRollover() ? "#919191" : "#C2C2C2");
|
||||
g.setColor(color);
|
||||
g.fillRect(thumbBounds.x, thumbBounds.y, thumbBounds.width, thumbBounds.height);
|
||||
AnimationController.paintSkin(c, this, g, thumbBounds.x, thumbBounds.y, thumbBounds.width, thumbBounds.height, isDragging ? State.PRESSED : isThumbRollover() ? State.ROLLOVER : State.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintSkinRaw(Graphics g, int x, int y, int w, int h, State state) {
|
||||
Color color = GraphicsUtils.getWebColor(state == State.PRESSED ? "#616161" : state == State.ROLLOVER ? "#919191" : "#C2C2C2");
|
||||
g.setColor(color);
|
||||
g.fillRect(x, y, w, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TMSchema.Part getPart(JComponent c) {
|
||||
return TMSchema.Part.SBP_THUMBBTNHORZ;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------- END
|
||||
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ public class AnimationController implements ActionListener, PropertyChangeListen
|
||||
if (newState == State.DEFAULTED)
|
||||
// it seems for DEFAULTED button state Vista does animation from
|
||||
// HOT
|
||||
oldState = State.HOT;
|
||||
oldState = State.ROLLOVER;
|
||||
if (oldState != null) {
|
||||
long duration;
|
||||
//if (newState == State.DEFAULTED) {
|
||||
|
@ -136,7 +136,7 @@ public class Icon9Factory extends RawCache<NinePatch> {
|
||||
put("toggle_button", "selected", "toggle_button_selected");
|
||||
put("toggle_button", "rollover", "toggle_button_rover");
|
||||
|
||||
put("scroll_bar", "arrow", "arrow");
|
||||
put("scroll_bar", "arrow_normal", "arrow");
|
||||
put("scroll_bar", "arrow_rollover", "arrow_rover");
|
||||
put("scroll_bar", "arrow_pressed", "arrow_pressed");
|
||||
put("scroll_bar", "scroll_pane_border", "scroll_pane_bg1");
|
||||
|
@ -16,6 +16,7 @@
|
||||
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||
*/
|
||||
package org.jackhuang.hmcl.laf.utils;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
||||
@ -41,7 +42,7 @@ package org.jackhuang.hmcl.laf.utils;
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* <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>).
|
||||
@ -55,7 +56,6 @@ package org.jackhuang.hmcl.laf.utils;
|
||||
* encouraged.
|
||||
*
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.*;
|
||||
|
||||
@ -94,112 +94,95 @@ public class TMSchema {
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
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_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_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_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),
|
||||
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_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),
|
||||
|
||||
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),
|
||||
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;
|
||||
@ -217,21 +200,19 @@ public class TMSchema {
|
||||
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) {
|
||||
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();
|
||||
return control.toString() + "." + name();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* An enumeration of the possible component states
|
||||
*/
|
||||
@ -258,8 +239,8 @@ public class TMSchema {
|
||||
DOWNNORMAL,
|
||||
DOWNPRESSED,
|
||||
FOCUSED,
|
||||
HOT,
|
||||
HOTCHECKED,
|
||||
ROLLOVER,
|
||||
ROLLOVERCHECKED,
|
||||
ICONHOT,
|
||||
ICONNORMAL,
|
||||
ICONPRESSED,
|
||||
@ -267,10 +248,10 @@ public class TMSchema {
|
||||
ICONSORTEDNORMAL,
|
||||
ICONSORTEDPRESSED,
|
||||
INACTIVE,
|
||||
INACTIVENORMAL, // See note 1
|
||||
INACTIVEHOT, // See note 1
|
||||
INACTIVEPUSHED, // See note 1
|
||||
INACTIVEDISABLED, // See note 1
|
||||
INACTIVENORMAL, // See note 1
|
||||
INACTIVEHOT, // See note 1
|
||||
INACTIVEPUSHED, // See note 1
|
||||
INACTIVEDISABLED, // See note 1
|
||||
LEFTDISABLED,
|
||||
LEFTHOT,
|
||||
LEFTNORMAL,
|
||||
@ -308,7 +289,6 @@ public class TMSchema {
|
||||
SORTEDPRESSED,
|
||||
SORTEDUP;
|
||||
|
||||
|
||||
/**
|
||||
* A map of allowed states for each Part
|
||||
*/
|
||||
@ -318,27 +298,27 @@ public class TMSchema {
|
||||
stateMap = new EnumMap<Part, State[]>(Part.class);
|
||||
|
||||
stateMap.put(Part.EP_EDITTEXT,
|
||||
new State[] {
|
||||
NORMAL, HOT, SELECTED, DISABLED, FOCUSED, READONLY, ASSIST
|
||||
});
|
||||
new State[] {
|
||||
NORMAL, ROLLOVER, SELECTED, DISABLED, FOCUSED, READONLY, ASSIST
|
||||
});
|
||||
|
||||
stateMap.put(Part.BP_PUSHBUTTON,
|
||||
new State[] { NORMAL, HOT, PRESSED, DISABLED, DEFAULTED });
|
||||
new State[] { NORMAL, ROLLOVER, PRESSED, DISABLED, DEFAULTED });
|
||||
|
||||
stateMap.put(Part.BP_RADIOBUTTON,
|
||||
new State[] {
|
||||
new State[] {
|
||||
UNCHECKEDNORMAL, UNCHECKEDHOT, UNCHECKEDPRESSED, UNCHECKEDDISABLED,
|
||||
CHECKEDNORMAL, CHECKEDHOT, CHECKEDPRESSED, CHECKEDDISABLED
|
||||
});
|
||||
CHECKEDNORMAL, CHECKEDHOT, CHECKEDPRESSED, CHECKEDDISABLED
|
||||
});
|
||||
|
||||
stateMap.put(Part.BP_CHECKBOX,
|
||||
new State[] {
|
||||
new State[] {
|
||||
UNCHECKEDNORMAL, UNCHECKEDHOT, UNCHECKEDPRESSED, UNCHECKEDDISABLED,
|
||||
CHECKEDNORMAL, CHECKEDHOT, CHECKEDPRESSED, CHECKEDDISABLED,
|
||||
MIXEDNORMAL, MIXEDHOT, MIXEDPRESSED, MIXEDDISABLED
|
||||
});
|
||||
CHECKEDNORMAL, CHECKEDHOT, CHECKEDPRESSED, CHECKEDDISABLED,
|
||||
MIXEDNORMAL, MIXEDHOT, MIXEDPRESSED, MIXEDDISABLED
|
||||
});
|
||||
|
||||
State[] comboBoxStates = new State[] { NORMAL, HOT, PRESSED, DISABLED };
|
||||
State[] comboBoxStates = new State[] { NORMAL, ROLLOVER, PRESSED, DISABLED };
|
||||
stateMap.put(Part.CP_COMBOBOX, comboBoxStates);
|
||||
stateMap.put(Part.CP_DROPDOWNBUTTON, comboBoxStates);
|
||||
stateMap.put(Part.CP_BACKGROUND, comboBoxStates);
|
||||
@ -349,41 +329,39 @@ public class TMSchema {
|
||||
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_HEADERITEM, new State[] { NORMAL, ROLLOVER, PRESSED,
|
||||
SORTEDNORMAL, SORTEDHOT, SORTEDPRESSED,
|
||||
ICONNORMAL, ICONHOT, ICONPRESSED,
|
||||
ICONSORTEDNORMAL, ICONSORTEDHOT, ICONSORTEDPRESSED });
|
||||
|
||||
stateMap.put(Part.HP_HEADERSORTARROW,
|
||||
new State[] {SORTEDDOWN, SORTEDUP});
|
||||
new State[] { SORTEDDOWN, SORTEDUP });
|
||||
|
||||
State[] scrollBarStates = new State[] { NORMAL, HOT, PRESSED, DISABLED, HOVER };
|
||||
stateMap.put(Part.SBP_SCROLLBAR, scrollBarStates);
|
||||
State[] scrollBarStates = new State[] { NORMAL, ROLLOVER, 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_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
|
||||
});
|
||||
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);
|
||||
State[] spinnerStates = new State[] { NORMAL, ROLLOVER, 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,
|
||||
};
|
||||
NORMAL, ROLLOVER, 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
|
||||
|
||||
@ -396,125 +374,118 @@ public class TMSchema {
|
||||
INACTIVENORMAL, INACTIVEHOT, INACTIVEPUSHED, INACTIVEDISABLED, null
|
||||
};
|
||||
}*/
|
||||
|
||||
stateMap.put(Part.WP_MINBUTTON, frameButtonStates);
|
||||
stateMap.put(Part.WP_MAXBUTTON, frameButtonStates);
|
||||
stateMap.put(Part.WP_MINBUTTON, frameButtonStates);
|
||||
stateMap.put(Part.WP_MAXBUTTON, frameButtonStates);
|
||||
stateMap.put(Part.WP_RESTOREBUTTON, frameButtonStates);
|
||||
stateMap.put(Part.WP_CLOSEBUTTON, frameButtonStates);
|
||||
stateMap.put(Part.WP_CLOSEBUTTON, frameButtonStates);
|
||||
|
||||
// States for Slider (trackbar)
|
||||
stateMap.put(Part.TKP_TRACK, new State[] { NORMAL });
|
||||
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);
|
||||
State[] sliderThumbStates
|
||||
= new State[] { NORMAL, ROLLOVER, 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);
|
||||
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);
|
||||
State[] tabStates = new State[] { NORMAL, ROLLOVER, 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
|
||||
});
|
||||
new State[] {
|
||||
NORMAL, ROLLOVER, PRESSED, DISABLED, CHECKED, ROLLOVERCHECKED
|
||||
});
|
||||
|
||||
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_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_CAPTION, captionStates);
|
||||
stateMap.put(Part.WP_MINCAPTION, captionStates);
|
||||
stateMap.put(Part.WP_MAXCAPTION, captionStates);
|
||||
|
||||
stateMap.put(Part.MP_BARBACKGROUND,
|
||||
new State[] { ACTIVE, INACTIVE });
|
||||
new State[] { ACTIVE, INACTIVE });
|
||||
stateMap.put(Part.MP_BARITEM,
|
||||
new State[] { NORMAL, HOT, PUSHED,
|
||||
DISABLED, DISABLEDHOT, DISABLEDPUSHED });
|
||||
new State[] { NORMAL, ROLLOVER, PUSHED,
|
||||
DISABLED, DISABLEDHOT, DISABLEDPUSHED });
|
||||
stateMap.put(Part.MP_POPUPCHECK,
|
||||
new State[] { CHECKMARKNORMAL, CHECKMARKDISABLED,
|
||||
BULLETNORMAL, BULLETDISABLED });
|
||||
new State[] { CHECKMARKNORMAL, CHECKMARKDISABLED,
|
||||
BULLETNORMAL, BULLETDISABLED });
|
||||
stateMap.put(Part.MP_POPUPCHECKBACKGROUND,
|
||||
new State[] { DISABLEDPUSHED, NORMAL, BITMAP });
|
||||
new State[] { DISABLEDPUSHED, NORMAL, BITMAP });
|
||||
stateMap.put(Part.MP_POPUPITEM,
|
||||
new State[] { NORMAL, HOT, DISABLED, DISABLEDHOT });
|
||||
new State[] { NORMAL, ROLLOVER, DISABLED, DISABLEDHOT });
|
||||
stateMap.put(Part.MP_POPUPSUBMENU,
|
||||
new State[] { NORMAL, DISABLED });
|
||||
new State[] { NORMAL, DISABLED });
|
||||
|
||||
}
|
||||
|
||||
|
||||
public static synchronized int getValue(Part part, State state) {
|
||||
if (stateMap == null) {
|
||||
if (stateMap == null)
|
||||
initStates();
|
||||
}
|
||||
|
||||
Enum[] states = stateMap.get(part);
|
||||
if (states != null) {
|
||||
for (int i = 0; i < states.length; i++) {
|
||||
if (state == states[i]) {
|
||||
if (states != null)
|
||||
for (int i = 0; i < states.length; i++)
|
||||
if (state == states[i])
|
||||
return i + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (state == null || state == State.NORMAL) {
|
||||
if (state == null || state == State.NORMAL)
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return name().toLowerCase();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* An enumeration of the possible component attributes and the
|
||||
* corresponding value type
|
||||
*/
|
||||
public static enum Prop {
|
||||
COLOR(Color.class, 204),
|
||||
SIZE(Dimension.class, 207),
|
||||
COLOR(Color.class, 204),
|
||||
SIZE(Dimension.class, 207),
|
||||
FLATMENUS(Boolean.class, 1001),
|
||||
BORDERONLY(Boolean.class, 2203), // only draw the border area of the image
|
||||
|
||||
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
|
||||
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
|
||||
TEXTSHADOWOFFSET(Point.class, 3402), // where char shadows are drawn, relative to orig. chars
|
||||
|
||||
NORMALSIZE(Dimension.class, 3409), // size of dest rect that exactly source
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
TEXTSHADOWCOLOR(Color.class, 3818), // color of text shadow
|
||||
BGTYPE(Integer.class, 4001), // basic drawing type for each part
|
||||
|
||||
BGTYPE(Integer.class, 4001), // basic drawing type for each part
|
||||
|
||||
TEXTSHADOWTYPE(Integer.class, 4010), // type of shadow to draw with text
|
||||
TEXTSHADOWTYPE(Integer.class, 4010), // type of shadow to draw with text
|
||||
|
||||
TRANSITIONDURATIONS(Integer.class, 6000);
|
||||
|
||||
@ -522,8 +493,8 @@ public class TMSchema {
|
||||
private final int value;
|
||||
|
||||
private Prop(Class type, int value) {
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public int getValue() {
|
||||
@ -531,23 +502,20 @@ public class TMSchema {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return name()+"["+type.getName()+"] = "+value;
|
||||
return name() + "[" + type.getName() + "] = " + value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* An enumeration of attribute values for some Props
|
||||
*/
|
||||
public static enum TypeEnum {
|
||||
BT_IMAGEFILE (Prop.BGTYPE, "imagefile", 0),
|
||||
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;
|
||||
@ -559,22 +527,18 @@ public class TMSchema {
|
||||
private final int value;
|
||||
|
||||
public String toString() {
|
||||
return prop+"="+enumName+"="+value;
|
||||
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) {
|
||||
for (TypeEnum e : TypeEnum.values())
|
||||
if (e.prop == prop && e.value == enumval)
|
||||
return e;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user