mirror of
https://github.com/HMCL-dev/HMCL.git
synced 2025-09-13 05:46:59 -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);
|
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));
|
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;
|
return toolbar ? Part.TP_BUTTON : Part.BP_PUSHBUTTON;
|
||||||
}
|
}
|
||||||
|
|
||||||
static State getXPButtonState(AbstractButton b) {
|
public static State getXPButtonState(AbstractButton b) {
|
||||||
Part part = getXPButtonType(b);
|
Part part = getXPButtonType(b);
|
||||||
ButtonModel model = b.getModel();
|
ButtonModel model = b.getModel();
|
||||||
State state = State.NORMAL;
|
State state = State.NORMAL;
|
||||||
@ -276,13 +250,13 @@ public class BEButtonUI extends BasicButtonUI implements Skin {
|
|||||||
else if (!model.isEnabled())
|
else if (!model.isEnabled())
|
||||||
state = State.DISABLED;
|
state = State.DISABLED;
|
||||||
else if (model.isSelected() && model.isRollover())
|
else if (model.isSelected() && model.isRollover())
|
||||||
state = State.HOTCHECKED;
|
state = State.ROLLOVERCHECKED;
|
||||||
else if (model.isSelected())
|
else if (model.isSelected())
|
||||||
state = State.CHECKED;
|
state = State.CHECKED;
|
||||||
else if (model.isRollover())
|
else if (model.isRollover())
|
||||||
state = State.HOT;
|
state = State.ROLLOVER;
|
||||||
else if (b.hasFocus())
|
else if (b.hasFocus())
|
||||||
state = State.HOT;
|
state = State.ROLLOVER;
|
||||||
} else
|
} else
|
||||||
if ((model.isArmed() && model.isPressed())
|
if ((model.isArmed() && model.isPressed())
|
||||||
|| model.isSelected())
|
|| model.isSelected())
|
||||||
@ -290,7 +264,7 @@ public class BEButtonUI extends BasicButtonUI implements Skin {
|
|||||||
else if (!model.isEnabled())
|
else if (!model.isEnabled())
|
||||||
state = State.DISABLED;
|
state = State.DISABLED;
|
||||||
else if (model.isRollover() || model.isPressed())
|
else if (model.isRollover() || model.isPressed())
|
||||||
state = State.HOT;
|
state = State.ROLLOVER;
|
||||||
else if (b instanceof JButton
|
else if (b instanceof JButton
|
||||||
&& ((JButton) b).isDefaultButton())
|
&& ((JButton) b).isDefaultButton())
|
||||||
state = State.DEFAULTED;
|
state = State.DEFAULTED;
|
||||||
@ -304,27 +278,7 @@ public class BEButtonUI extends BasicButtonUI implements Skin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paintSkinRaw(Graphics g, int dx, int dy, int dw, int dh, TMSchema.State state) {
|
public void paintSkinRaw(Graphics g, int dx, int dy, int dw, int dh, TMSchema.State state) {
|
||||||
String key;
|
ICON_9.get(state.toString()).draw((Graphics2D) g, dx, dy, dw, dh);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -183,7 +183,7 @@ public class BEComboBoxUI extends BasicComboBoxUI
|
|||||||
} else if (isPopupVisible(comboBox)) {
|
} else if (isPopupVisible(comboBox)) {
|
||||||
state = State.PRESSED;
|
state = State.PRESSED;
|
||||||
} else if (mouseInside) {
|
} else if (mouseInside) {
|
||||||
state = State.HOT;
|
state = State.ROLLOVER;
|
||||||
}
|
}
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
@ -198,7 +198,7 @@ public class BEComboBoxUI extends BasicComboBoxUI
|
|||||||
case DISABLED:
|
case DISABLED:
|
||||||
key = "disabled";
|
key = "disabled";
|
||||||
break;
|
break;
|
||||||
case HOT:
|
case ROLLOVER:
|
||||||
key = "rollover";
|
key = "rollover";
|
||||||
break;
|
break;
|
||||||
case NORMAL:
|
case NORMAL:
|
||||||
|
@ -24,8 +24,13 @@ import javax.swing.UIManager;
|
|||||||
import javax.swing.plaf.ComponentUI;
|
import javax.swing.plaf.ComponentUI;
|
||||||
import javax.swing.plaf.basic.BasicArrowButton;
|
import javax.swing.plaf.basic.BasicArrowButton;
|
||||||
import javax.swing.plaf.basic.BasicScrollBarUI;
|
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.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;
|
import org.jackhuang.hmcl.util.ui.GraphicsUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,7 +42,7 @@ import org.jackhuang.hmcl.util.ui.GraphicsUtils;
|
|||||||
* @version 1.0
|
* @version 1.0
|
||||||
* @see com.sun.java.swing.plaf.windows.WindowsScrollBarUI
|
* @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");
|
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
|
* up/down. It differs from BasicArrowButton in that the preferred size is
|
||||||
* always a square.
|
* always a square.
|
||||||
*/
|
*/
|
||||||
protected class BEArrowButton extends BasicArrowButton {
|
protected class BEArrowButton extends BasicArrowButton implements Skin {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new windows arrow button.
|
* Instantiates a new windows arrow button.
|
||||||
@ -91,7 +96,6 @@ public class BEScrollBarUI extends BasicScrollBarUI {
|
|||||||
@Override
|
@Override
|
||||||
public void paint(Graphics g) {
|
public void paint(Graphics g) {
|
||||||
Graphics2D g2 = (Graphics2D) g;
|
Graphics2D g2 = (Graphics2D) g;
|
||||||
String id = "arrow";
|
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case NORTH:
|
case NORTH:
|
||||||
break;
|
break;
|
||||||
@ -108,8 +112,7 @@ public class BEScrollBarUI extends BasicScrollBarUI {
|
|||||||
g2.rotate(Math.PI / 2);
|
g2.rotate(Math.PI / 2);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ICON_9.getWithScrollState(id, getModel().isPressed(), getModel().isRollover())
|
AnimationController.paintSkin(this, this, g, 0, 0, getWidth(), getHeight(), BEButtonUI.getXPButtonState(this));
|
||||||
.draw(g2, 0, 0, getWidth(), getHeight());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -128,6 +131,16 @@ public class BEScrollBarUI extends BasicScrollBarUI {
|
|||||||
}
|
}
|
||||||
return new Dimension(size, size);
|
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
|
//----------------------------------------------------------------------------------- END
|
||||||
|
|
||||||
@ -148,10 +161,21 @@ public class BEScrollBarUI extends BasicScrollBarUI {
|
|||||||
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
|
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
|
||||||
if (thumbBounds.isEmpty() || !scrollbar.isEnabled())
|
if (thumbBounds.isEmpty() || !scrollbar.isEnabled())
|
||||||
return;
|
return;
|
||||||
Color color = GraphicsUtils.getWebColor(isDragging ? "#616161" : isThumbRollover() ? "#919191" : "#C2C2C2");
|
AnimationController.paintSkin(c, this, g, thumbBounds.x, thumbBounds.y, thumbBounds.width, thumbBounds.height, isDragging ? State.PRESSED : isThumbRollover() ? State.ROLLOVER : State.NORMAL);
|
||||||
g.setColor(color);
|
|
||||||
g.fillRect(thumbBounds.x, thumbBounds.y, thumbBounds.width, thumbBounds.height);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
//----------------------------------------------------------------------------------- END
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -101,7 +101,7 @@ public class AnimationController implements ActionListener, PropertyChangeListen
|
|||||||
if (newState == State.DEFAULTED)
|
if (newState == State.DEFAULTED)
|
||||||
// it seems for DEFAULTED button state Vista does animation from
|
// it seems for DEFAULTED button state Vista does animation from
|
||||||
// HOT
|
// HOT
|
||||||
oldState = State.HOT;
|
oldState = State.ROLLOVER;
|
||||||
if (oldState != null) {
|
if (oldState != null) {
|
||||||
long duration;
|
long duration;
|
||||||
//if (newState == State.DEFAULTED) {
|
//if (newState == State.DEFAULTED) {
|
||||||
|
@ -136,7 +136,7 @@ public class Icon9Factory extends RawCache<NinePatch> {
|
|||||||
put("toggle_button", "selected", "toggle_button_selected");
|
put("toggle_button", "selected", "toggle_button_selected");
|
||||||
put("toggle_button", "rollover", "toggle_button_rover");
|
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_rollover", "arrow_rover");
|
||||||
put("scroll_bar", "arrow_pressed", "arrow_pressed");
|
put("scroll_bar", "arrow_pressed", "arrow_pressed");
|
||||||
put("scroll_bar", "scroll_pane_border", "scroll_pane_bg1");
|
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/}.
|
* along with this program. If not, see {http://www.gnu.org/licenses/}.
|
||||||
*/
|
*/
|
||||||
package org.jackhuang.hmcl.laf.utils;
|
package org.jackhuang.hmcl.laf.utils;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||||
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
|
||||||
@ -55,7 +56,6 @@ package org.jackhuang.hmcl.laf.utils;
|
|||||||
* encouraged.
|
* encouraged.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@ -94,7 +94,6 @@ public class TMSchema {
|
|||||||
WINDOW
|
WINDOW
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An enumeration of the Windows compoent parts
|
* An enumeration of the Windows compoent parts
|
||||||
*/
|
*/
|
||||||
@ -110,12 +109,10 @@ public class TMSchema {
|
|||||||
MP_POPUPITEM(Control.MENU, 14),
|
MP_POPUPITEM(Control.MENU, 14),
|
||||||
MP_POPUPSEPARATOR(Control.MENU, 15),
|
MP_POPUPSEPARATOR(Control.MENU, 15),
|
||||||
MP_POPUPSUBMENU(Control.MENU, 16),
|
MP_POPUPSUBMENU(Control.MENU, 16),
|
||||||
|
|
||||||
BP_PUSHBUTTON(Control.BUTTON, 1),
|
BP_PUSHBUTTON(Control.BUTTON, 1),
|
||||||
BP_RADIOBUTTON(Control.BUTTON, 2),
|
BP_RADIOBUTTON(Control.BUTTON, 2),
|
||||||
BP_CHECKBOX(Control.BUTTON, 3),
|
BP_CHECKBOX(Control.BUTTON, 3),
|
||||||
BP_GROUPBOX(Control.BUTTON, 4),
|
BP_GROUPBOX(Control.BUTTON, 4),
|
||||||
|
|
||||||
CP_COMBOBOX(Control.COMBOBOX, 0),
|
CP_COMBOBOX(Control.COMBOBOX, 0),
|
||||||
CP_DROPDOWNBUTTON(Control.COMBOBOX, 1),
|
CP_DROPDOWNBUTTON(Control.COMBOBOX, 1),
|
||||||
CP_BACKGROUND(Control.COMBOBOX, 2),
|
CP_BACKGROUND(Control.COMBOBOX, 2),
|
||||||
@ -125,27 +122,19 @@ public class TMSchema {
|
|||||||
CP_DROPDOWNBUTTONRIGHT(Control.COMBOBOX, 6),
|
CP_DROPDOWNBUTTONRIGHT(Control.COMBOBOX, 6),
|
||||||
CP_DROPDOWNBUTTONLEFT(Control.COMBOBOX, 7),
|
CP_DROPDOWNBUTTONLEFT(Control.COMBOBOX, 7),
|
||||||
CP_CUEBANNER(Control.COMBOBOX, 8),
|
CP_CUEBANNER(Control.COMBOBOX, 8),
|
||||||
|
|
||||||
|
|
||||||
EP_EDIT(Control.EDIT, 0),
|
EP_EDIT(Control.EDIT, 0),
|
||||||
EP_EDITTEXT(Control.EDIT, 1),
|
EP_EDITTEXT(Control.EDIT, 1),
|
||||||
|
|
||||||
HP_HEADERITEM(Control.HEADER, 1),
|
HP_HEADERITEM(Control.HEADER, 1),
|
||||||
HP_HEADERSORTARROW(Control.HEADER, 4),
|
HP_HEADERSORTARROW(Control.HEADER, 4),
|
||||||
|
|
||||||
LBP_LISTBOX(Control.LISTBOX, 0),
|
LBP_LISTBOX(Control.LISTBOX, 0),
|
||||||
|
|
||||||
LVP_LISTVIEW(Control.LISTVIEW, 0),
|
LVP_LISTVIEW(Control.LISTVIEW, 0),
|
||||||
|
|
||||||
PP_PROGRESS(Control.PROGRESS, 0),
|
PP_PROGRESS(Control.PROGRESS, 0),
|
||||||
PP_BAR(Control.PROGRESS, 1),
|
PP_BAR(Control.PROGRESS, 1),
|
||||||
PP_BARVERT(Control.PROGRESS, 2),
|
PP_BARVERT(Control.PROGRESS, 2),
|
||||||
PP_CHUNK(Control.PROGRESS, 3),
|
PP_CHUNK(Control.PROGRESS, 3),
|
||||||
PP_CHUNKVERT(Control.PROGRESS, 4),
|
PP_CHUNKVERT(Control.PROGRESS, 4),
|
||||||
|
|
||||||
RP_GRIPPER(Control.REBAR, 1),
|
RP_GRIPPER(Control.REBAR, 1),
|
||||||
RP_GRIPPERVERT(Control.REBAR, 2),
|
RP_GRIPPERVERT(Control.REBAR, 2),
|
||||||
|
|
||||||
SBP_SCROLLBAR(Control.SCROLLBAR, 0),
|
SBP_SCROLLBAR(Control.SCROLLBAR, 0),
|
||||||
SBP_ARROWBTN(Control.SCROLLBAR, 1),
|
SBP_ARROWBTN(Control.SCROLLBAR, 1),
|
||||||
SBP_THUMBBTNHORZ(Control.SCROLLBAR, 2),
|
SBP_THUMBBTNHORZ(Control.SCROLLBAR, 2),
|
||||||
@ -157,20 +146,16 @@ public class TMSchema {
|
|||||||
SBP_GRIPPERHORZ(Control.SCROLLBAR, 8),
|
SBP_GRIPPERHORZ(Control.SCROLLBAR, 8),
|
||||||
SBP_GRIPPERVERT(Control.SCROLLBAR, 9),
|
SBP_GRIPPERVERT(Control.SCROLLBAR, 9),
|
||||||
SBP_SIZEBOX(Control.SCROLLBAR, 10),
|
SBP_SIZEBOX(Control.SCROLLBAR, 10),
|
||||||
|
|
||||||
SPNP_UP(Control.SPIN, 1),
|
SPNP_UP(Control.SPIN, 1),
|
||||||
SPNP_DOWN(Control.SPIN, 2),
|
SPNP_DOWN(Control.SPIN, 2),
|
||||||
|
|
||||||
TABP_TABITEM(Control.TAB, 1),
|
TABP_TABITEM(Control.TAB, 1),
|
||||||
TABP_TABITEMLEFTEDGE(Control.TAB, 2),
|
TABP_TABITEMLEFTEDGE(Control.TAB, 2),
|
||||||
TABP_TABITEMRIGHTEDGE(Control.TAB, 3),
|
TABP_TABITEMRIGHTEDGE(Control.TAB, 3),
|
||||||
TABP_PANE(Control.TAB, 9),
|
TABP_PANE(Control.TAB, 9),
|
||||||
|
|
||||||
TP_TOOLBAR(Control.TOOLBAR, 0),
|
TP_TOOLBAR(Control.TOOLBAR, 0),
|
||||||
TP_BUTTON(Control.TOOLBAR, 1),
|
TP_BUTTON(Control.TOOLBAR, 1),
|
||||||
TP_SEPARATOR(Control.TOOLBAR, 5),
|
TP_SEPARATOR(Control.TOOLBAR, 5),
|
||||||
TP_SEPARATORVERT(Control.TOOLBAR, 6),
|
TP_SEPARATORVERT(Control.TOOLBAR, 6),
|
||||||
|
|
||||||
TKP_TRACK(Control.TRACKBAR, 1),
|
TKP_TRACK(Control.TRACKBAR, 1),
|
||||||
TKP_TRACKVERT(Control.TRACKBAR, 2),
|
TKP_TRACKVERT(Control.TRACKBAR, 2),
|
||||||
TKP_THUMB(Control.TRACKBAR, 3),
|
TKP_THUMB(Control.TRACKBAR, 3),
|
||||||
@ -181,10 +166,8 @@ public class TMSchema {
|
|||||||
TKP_THUMBRIGHT(Control.TRACKBAR, 8),
|
TKP_THUMBRIGHT(Control.TRACKBAR, 8),
|
||||||
TKP_TICS(Control.TRACKBAR, 9),
|
TKP_TICS(Control.TRACKBAR, 9),
|
||||||
TKP_TICSVERT(Control.TRACKBAR, 10),
|
TKP_TICSVERT(Control.TRACKBAR, 10),
|
||||||
|
|
||||||
TVP_TREEVIEW(Control.TREEVIEW, 0),
|
TVP_TREEVIEW(Control.TREEVIEW, 0),
|
||||||
TVP_GLYPH(Control.TREEVIEW, 2),
|
TVP_GLYPH(Control.TREEVIEW, 2),
|
||||||
|
|
||||||
WP_WINDOW(Control.WINDOW, 0),
|
WP_WINDOW(Control.WINDOW, 0),
|
||||||
WP_CAPTION(Control.WINDOW, 1),
|
WP_CAPTION(Control.WINDOW, 1),
|
||||||
WP_MINCAPTION(Control.WINDOW, 3),
|
WP_MINCAPTION(Control.WINDOW, 3),
|
||||||
@ -219,10 +202,9 @@ public class TMSchema {
|
|||||||
if (component instanceof JComponent) {
|
if (component instanceof JComponent) {
|
||||||
JComponent c = (JComponent) component;
|
JComponent c = (JComponent) component;
|
||||||
String subAppName = (String) c.getClientProperty("XPStyle.subAppName");
|
String subAppName = (String) c.getClientProperty("XPStyle.subAppName");
|
||||||
if (subAppName != null) {
|
if (subAppName != null)
|
||||||
str = subAppName + "::";
|
str = subAppName + "::";
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return str + control.toString();
|
return str + control.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,7 +213,6 @@ public class TMSchema {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An enumeration of the possible component states
|
* An enumeration of the possible component states
|
||||||
*/
|
*/
|
||||||
@ -258,8 +239,8 @@ public class TMSchema {
|
|||||||
DOWNNORMAL,
|
DOWNNORMAL,
|
||||||
DOWNPRESSED,
|
DOWNPRESSED,
|
||||||
FOCUSED,
|
FOCUSED,
|
||||||
HOT,
|
ROLLOVER,
|
||||||
HOTCHECKED,
|
ROLLOVERCHECKED,
|
||||||
ICONHOT,
|
ICONHOT,
|
||||||
ICONNORMAL,
|
ICONNORMAL,
|
||||||
ICONPRESSED,
|
ICONPRESSED,
|
||||||
@ -308,7 +289,6 @@ public class TMSchema {
|
|||||||
SORTEDPRESSED,
|
SORTEDPRESSED,
|
||||||
SORTEDUP;
|
SORTEDUP;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A map of allowed states for each Part
|
* A map of allowed states for each Part
|
||||||
*/
|
*/
|
||||||
@ -319,11 +299,11 @@ public class TMSchema {
|
|||||||
|
|
||||||
stateMap.put(Part.EP_EDITTEXT,
|
stateMap.put(Part.EP_EDITTEXT,
|
||||||
new State[] {
|
new State[] {
|
||||||
NORMAL, HOT, SELECTED, DISABLED, FOCUSED, READONLY, ASSIST
|
NORMAL, ROLLOVER, SELECTED, DISABLED, FOCUSED, READONLY, ASSIST
|
||||||
});
|
});
|
||||||
|
|
||||||
stateMap.put(Part.BP_PUSHBUTTON,
|
stateMap.put(Part.BP_PUSHBUTTON,
|
||||||
new State[] { NORMAL, HOT, PRESSED, DISABLED, DEFAULTED });
|
new State[] { NORMAL, ROLLOVER, PRESSED, DISABLED, DEFAULTED });
|
||||||
|
|
||||||
stateMap.put(Part.BP_RADIOBUTTON,
|
stateMap.put(Part.BP_RADIOBUTTON,
|
||||||
new State[] {
|
new State[] {
|
||||||
@ -338,7 +318,7 @@ public class TMSchema {
|
|||||||
MIXEDNORMAL, MIXEDHOT, MIXEDPRESSED, MIXEDDISABLED
|
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_COMBOBOX, comboBoxStates);
|
||||||
stateMap.put(Part.CP_DROPDOWNBUTTON, comboBoxStates);
|
stateMap.put(Part.CP_DROPDOWNBUTTON, comboBoxStates);
|
||||||
stateMap.put(Part.CP_BACKGROUND, comboBoxStates);
|
stateMap.put(Part.CP_BACKGROUND, comboBoxStates);
|
||||||
@ -349,7 +329,7 @@ public class TMSchema {
|
|||||||
stateMap.put(Part.CP_DROPDOWNBUTTONLEFT, comboBoxStates);
|
stateMap.put(Part.CP_DROPDOWNBUTTONLEFT, comboBoxStates);
|
||||||
stateMap.put(Part.CP_CUEBANNER, comboBoxStates);
|
stateMap.put(Part.CP_CUEBANNER, comboBoxStates);
|
||||||
|
|
||||||
stateMap.put(Part.HP_HEADERITEM, new State[] { NORMAL, HOT, PRESSED,
|
stateMap.put(Part.HP_HEADERITEM, new State[] { NORMAL, ROLLOVER, PRESSED,
|
||||||
SORTEDNORMAL, SORTEDHOT, SORTEDPRESSED,
|
SORTEDNORMAL, SORTEDHOT, SORTEDPRESSED,
|
||||||
ICONNORMAL, ICONHOT, ICONPRESSED,
|
ICONNORMAL, ICONHOT, ICONPRESSED,
|
||||||
ICONSORTEDNORMAL, ICONSORTEDHOT, ICONSORTEDPRESSED });
|
ICONSORTEDNORMAL, ICONSORTEDHOT, ICONSORTEDPRESSED });
|
||||||
@ -357,7 +337,7 @@ public class TMSchema {
|
|||||||
stateMap.put(Part.HP_HEADERSORTARROW,
|
stateMap.put(Part.HP_HEADERSORTARROW,
|
||||||
new State[] { SORTEDDOWN, SORTEDUP });
|
new State[] { SORTEDDOWN, SORTEDUP });
|
||||||
|
|
||||||
State[] scrollBarStates = new State[] { NORMAL, HOT, PRESSED, DISABLED, HOVER };
|
State[] scrollBarStates = new State[] { NORMAL, ROLLOVER, PRESSED, DISABLED, HOVER };
|
||||||
stateMap.put(Part.SBP_SCROLLBAR, scrollBarStates);
|
stateMap.put(Part.SBP_SCROLLBAR, scrollBarStates);
|
||||||
stateMap.put(Part.SBP_THUMBBTNVERT, scrollBarStates);
|
stateMap.put(Part.SBP_THUMBBTNVERT, scrollBarStates);
|
||||||
stateMap.put(Part.SBP_THUMBBTNHORZ, scrollBarStates);
|
stateMap.put(Part.SBP_THUMBBTNHORZ, scrollBarStates);
|
||||||
@ -373,17 +353,15 @@ public class TMSchema {
|
|||||||
UPHOVER, DOWNHOVER, LEFTHOVER, RIGHTHOVER
|
UPHOVER, DOWNHOVER, LEFTHOVER, RIGHTHOVER
|
||||||
});
|
});
|
||||||
|
|
||||||
|
State[] spinnerStates = new State[] { NORMAL, ROLLOVER, PRESSED, DISABLED };
|
||||||
State[] spinnerStates = new State[] { NORMAL, HOT, PRESSED, DISABLED };
|
|
||||||
stateMap.put(Part.SPNP_UP, spinnerStates);
|
stateMap.put(Part.SPNP_UP, spinnerStates);
|
||||||
stateMap.put(Part.SPNP_DOWN, spinnerStates);
|
stateMap.put(Part.SPNP_DOWN, spinnerStates);
|
||||||
|
|
||||||
stateMap.put(Part.TVP_GLYPH, new State[] { CLOSED, OPENED });
|
stateMap.put(Part.TVP_GLYPH, new State[] { CLOSED, OPENED });
|
||||||
|
|
||||||
State[] frameButtonStates = new State[] {
|
State[] frameButtonStates = new State[] {
|
||||||
NORMAL, HOT, PUSHED, DISABLED, // See note 1
|
NORMAL, ROLLOVER, PUSHED, DISABLED, // See note 1
|
||||||
INACTIVENORMAL, INACTIVEHOT, INACTIVEPUSHED, INACTIVEDISABLED,
|
INACTIVENORMAL, INACTIVEHOT, INACTIVEPUSHED, INACTIVEDISABLED, };
|
||||||
};
|
|
||||||
// Note 1: The INACTIVE frame button states apply when the frame
|
// Note 1: The INACTIVE frame button states apply when the frame
|
||||||
// is inactive. They are not defined in tmschema.h
|
// is inactive. They are not defined in tmschema.h
|
||||||
|
|
||||||
@ -396,7 +374,6 @@ public class TMSchema {
|
|||||||
INACTIVENORMAL, INACTIVEHOT, INACTIVEPUSHED, INACTIVEDISABLED, null
|
INACTIVENORMAL, INACTIVEHOT, INACTIVEPUSHED, INACTIVEDISABLED, null
|
||||||
};
|
};
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
stateMap.put(Part.WP_MINBUTTON, frameButtonStates);
|
stateMap.put(Part.WP_MINBUTTON, frameButtonStates);
|
||||||
stateMap.put(Part.WP_MAXBUTTON, frameButtonStates);
|
stateMap.put(Part.WP_MAXBUTTON, frameButtonStates);
|
||||||
stateMap.put(Part.WP_RESTOREBUTTON, frameButtonStates);
|
stateMap.put(Part.WP_RESTOREBUTTON, frameButtonStates);
|
||||||
@ -406,8 +383,8 @@ public class TMSchema {
|
|||||||
stateMap.put(Part.TKP_TRACK, new State[] { NORMAL });
|
stateMap.put(Part.TKP_TRACK, new State[] { NORMAL });
|
||||||
stateMap.put(Part.TKP_TRACKVERT, new State[] { NORMAL });
|
stateMap.put(Part.TKP_TRACKVERT, new State[] { NORMAL });
|
||||||
|
|
||||||
State[] sliderThumbStates =
|
State[] sliderThumbStates
|
||||||
new State[] { NORMAL, HOT, PRESSED, FOCUSED, DISABLED };
|
= new State[] { NORMAL, ROLLOVER, PRESSED, FOCUSED, DISABLED };
|
||||||
stateMap.put(Part.TKP_THUMB, sliderThumbStates);
|
stateMap.put(Part.TKP_THUMB, sliderThumbStates);
|
||||||
stateMap.put(Part.TKP_THUMBBOTTOM, sliderThumbStates);
|
stateMap.put(Part.TKP_THUMBBOTTOM, sliderThumbStates);
|
||||||
stateMap.put(Part.TKP_THUMBTOP, sliderThumbStates);
|
stateMap.put(Part.TKP_THUMBTOP, sliderThumbStates);
|
||||||
@ -415,15 +392,14 @@ public class TMSchema {
|
|||||||
stateMap.put(Part.TKP_THUMBRIGHT, sliderThumbStates);
|
stateMap.put(Part.TKP_THUMBRIGHT, sliderThumbStates);
|
||||||
|
|
||||||
// States for Tabs
|
// States for Tabs
|
||||||
State[] tabStates = new State[] { NORMAL, HOT, SELECTED, DISABLED, FOCUSED };
|
State[] tabStates = new State[] { NORMAL, ROLLOVER, SELECTED, DISABLED, FOCUSED };
|
||||||
stateMap.put(Part.TABP_TABITEM, tabStates);
|
stateMap.put(Part.TABP_TABITEM, tabStates);
|
||||||
stateMap.put(Part.TABP_TABITEMLEFTEDGE, tabStates);
|
stateMap.put(Part.TABP_TABITEMLEFTEDGE, tabStates);
|
||||||
stateMap.put(Part.TABP_TABITEMRIGHTEDGE, tabStates);
|
stateMap.put(Part.TABP_TABITEMRIGHTEDGE, tabStates);
|
||||||
|
|
||||||
|
|
||||||
stateMap.put(Part.TP_BUTTON,
|
stateMap.put(Part.TP_BUTTON,
|
||||||
new State[] {
|
new State[] {
|
||||||
NORMAL, HOT, PRESSED, DISABLED, CHECKED, HOTCHECKED
|
NORMAL, ROLLOVER, PRESSED, DISABLED, CHECKED, ROLLOVERCHECKED
|
||||||
});
|
});
|
||||||
|
|
||||||
State[] frameStates = new State[] { ACTIVE, INACTIVE };
|
State[] frameStates = new State[] { ACTIVE, INACTIVE };
|
||||||
@ -440,7 +416,7 @@ public class TMSchema {
|
|||||||
stateMap.put(Part.MP_BARBACKGROUND,
|
stateMap.put(Part.MP_BARBACKGROUND,
|
||||||
new State[] { ACTIVE, INACTIVE });
|
new State[] { ACTIVE, INACTIVE });
|
||||||
stateMap.put(Part.MP_BARITEM,
|
stateMap.put(Part.MP_BARITEM,
|
||||||
new State[] { NORMAL, HOT, PUSHED,
|
new State[] { NORMAL, ROLLOVER, PUSHED,
|
||||||
DISABLED, DISABLEDHOT, DISABLEDPUSHED });
|
DISABLED, DISABLEDHOT, DISABLEDPUSHED });
|
||||||
stateMap.put(Part.MP_POPUPCHECK,
|
stateMap.put(Part.MP_POPUPCHECK,
|
||||||
new State[] { CHECKMARKNORMAL, CHECKMARKDISABLED,
|
new State[] { CHECKMARKNORMAL, CHECKMARKDISABLED,
|
||||||
@ -448,36 +424,34 @@ public class TMSchema {
|
|||||||
stateMap.put(Part.MP_POPUPCHECKBACKGROUND,
|
stateMap.put(Part.MP_POPUPCHECKBACKGROUND,
|
||||||
new State[] { DISABLEDPUSHED, NORMAL, BITMAP });
|
new State[] { DISABLEDPUSHED, NORMAL, BITMAP });
|
||||||
stateMap.put(Part.MP_POPUPITEM,
|
stateMap.put(Part.MP_POPUPITEM,
|
||||||
new State[] { NORMAL, HOT, DISABLED, DISABLEDHOT });
|
new State[] { NORMAL, ROLLOVER, DISABLED, DISABLEDHOT });
|
||||||
stateMap.put(Part.MP_POPUPSUBMENU,
|
stateMap.put(Part.MP_POPUPSUBMENU,
|
||||||
new State[] { NORMAL, DISABLED });
|
new State[] { NORMAL, DISABLED });
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static synchronized int getValue(Part part, State state) {
|
public static synchronized int getValue(Part part, State state) {
|
||||||
if (stateMap == null) {
|
if (stateMap == null)
|
||||||
initStates();
|
initStates();
|
||||||
}
|
|
||||||
|
|
||||||
Enum[] states = stateMap.get(part);
|
Enum[] states = stateMap.get(part);
|
||||||
if (states != null) {
|
if (states != null)
|
||||||
for (int i = 0; i < states.length; i++) {
|
for (int i = 0; i < states.length; i++)
|
||||||
if (state == states[i]) {
|
if (state == states[i])
|
||||||
return i + 1;
|
return i + 1;
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state == null || state == State.NORMAL) {
|
if (state == null || state == State.NORMAL)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return name().toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An enumeration of the possible component attributes and the
|
* An enumeration of the possible component attributes and the
|
||||||
@ -486,9 +460,7 @@ public class TMSchema {
|
|||||||
public static enum Prop {
|
public static enum Prop {
|
||||||
COLOR(Color.class, 204),
|
COLOR(Color.class, 204),
|
||||||
SIZE(Dimension.class, 207),
|
SIZE(Dimension.class, 207),
|
||||||
|
|
||||||
FLATMENUS(Boolean.class, 1001),
|
FLATMENUS(Boolean.class, 1001),
|
||||||
|
|
||||||
BORDERONLY(Boolean.class, 2203), // only draw the border area of the image
|
BORDERONLY(Boolean.class, 2203), // only draw the border area of the image
|
||||||
|
|
||||||
IMAGECOUNT(Integer.class, 2401), // the number of state images in an imagefile
|
IMAGECOUNT(Integer.class, 2401), // the number of state images in an imagefile
|
||||||
@ -501,7 +473,6 @@ public class TMSchema {
|
|||||||
|
|
||||||
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
|
SIZINGMARGINS(Insets.class, 3601), // margins used for 9-grid sizing
|
||||||
CONTENTMARGINS(Insets.class, 3602), // margins that define where content can be placed
|
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
|
CAPTIONMARGINS(Insets.class, 3603), // margins that define where caption text can be placed
|
||||||
@ -535,19 +506,16 @@ public class TMSchema {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An enumeration of attribute values for some Props
|
* An enumeration of attribute values for some Props
|
||||||
*/
|
*/
|
||||||
public static enum TypeEnum {
|
public static enum TypeEnum {
|
||||||
BT_IMAGEFILE(Prop.BGTYPE, "imagefile", 0),
|
BT_IMAGEFILE(Prop.BGTYPE, "imagefile", 0),
|
||||||
BT_BORDERFILL(Prop.BGTYPE, "borderfill", 1),
|
BT_BORDERFILL(Prop.BGTYPE, "borderfill", 1),
|
||||||
|
|
||||||
TST_NONE(Prop.TEXTSHADOWTYPE, "none", 0),
|
TST_NONE(Prop.TEXTSHADOWTYPE, "none", 0),
|
||||||
TST_SINGLE(Prop.TEXTSHADOWTYPE, "single", 1),
|
TST_SINGLE(Prop.TEXTSHADOWTYPE, "single", 1),
|
||||||
TST_CONTINUOUS(Prop.TEXTSHADOWTYPE, "continuous", 2);
|
TST_CONTINUOUS(Prop.TEXTSHADOWTYPE, "continuous", 2);
|
||||||
|
|
||||||
|
|
||||||
private TypeEnum(Prop prop, String enumName, int value) {
|
private TypeEnum(Prop prop, String enumName, int value) {
|
||||||
this.prop = prop;
|
this.prop = prop;
|
||||||
this.enumName = enumName;
|
this.enumName = enumName;
|
||||||
@ -566,15 +534,11 @@ public class TMSchema {
|
|||||||
return enumName;
|
return enumName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static TypeEnum getTypeEnum(Prop prop, int enumval) {
|
static TypeEnum getTypeEnum(Prop prop, int enumval) {
|
||||||
for (TypeEnum e : TypeEnum.values()) {
|
for (TypeEnum e : TypeEnum.values())
|
||||||
if (e.prop == prop && e.value == enumval) {
|
if (e.prop == prop && e.value == enumval)
|
||||||
return e;
|
return e;
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user