Browse Source

MOBILE-27000 移动端控件图标支持自定义颜色

feature/big-screen
kuangshuai 5 years ago
parent
commit
ef832d90a1
  1. 16
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java
  2. 29
      designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java

16
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleDefinePane.java

@ -48,6 +48,7 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
private LineComboBox borderType; private LineComboBox borderType;
private NewColorSelectBox borderColor; private NewColorSelectBox borderColor;
private UISpinner borderRadius; private UISpinner borderRadius;
private NewColorSelectBox iconColor;
private MobileStyleFontConfigPane fontConfigPane; private MobileStyleFontConfigPane fontConfigPane;
MobileStyleDefinePane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customBeanPaneClass, MobileStyleDefinePane(Widget widget, Class<? extends MobileStyleCustomDefinePane> customBeanPaneClass,
@ -69,6 +70,9 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
borderColor.setSelectObject(ob.getBorderColor()); borderColor.setSelectObject(ob.getBorderColor());
} }
borderRadius.setValue(ob.getBorderRadius()); borderRadius.setValue(ob.getBorderRadius());
if (ob.getIconColor() != null) {
iconColor.setSelectObject(ob.getIconColor());
}
if (ob.getFont() != null) { if (ob.getFont() != null) {
fontConfigPane.populateBean(ob.getFont()); fontConfigPane.populateBean(ob.getFont());
} }
@ -83,6 +87,7 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
mobileStyle.setBorderType(borderType.getSelectedLineStyle()); mobileStyle.setBorderType(borderType.getSelectedLineStyle());
mobileStyle.setBorderColor(borderColor.getSelectObject()); mobileStyle.setBorderColor(borderColor.getSelectObject());
mobileStyle.setBorderRadius(borderRadius.getValue()); mobileStyle.setBorderRadius(borderRadius.getValue());
mobileStyle.setIconColor(iconColor.getSelectObject());
mobileStyle.setFont(fontConfigPane.updateBean()); mobileStyle.setFont(fontConfigPane.updateBean());
return mobileStyle; return mobileStyle;
} }
@ -123,6 +128,7 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
createBackgroundPane(); createBackgroundPane();
createBorderPane(); createBorderPane();
createIconSettingPane();
createFontPane(); createFontPane();
} }
@ -155,6 +161,16 @@ public class MobileStyleDefinePane extends BasicBeanPane<MobileStyle> {
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderRadius")), borderRadius)); commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_BorderRadius")), borderRadius));
} }
private void createIconSettingPane() {
iconColor = new NewColorSelectBox(NORMAL_COMBO_WIDTH);
iconColor.addSelectChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
}
});
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Icon_Color")), iconColor));
}
private void createFontPane() { private void createFontPane() {
fontConfigPane = new MobileStyleFontConfigPane(); fontConfigPane = new MobileStyleFontConfigPane();
commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Font")), fontConfigPane)); commomPane.add(createLeftRightComponentsPane(createConfigLabel(Toolkit.i18nText("Fine-Design_Mobile_Widget_Font")), fontConfigPane));

29
designer-base/src/main/java/com/fr/design/mainframe/mobile/ui/MobileStyleFontConfigPane.java

@ -4,11 +4,15 @@ import com.fr.base.BaseUtils;
import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.LayoutConstants;
import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.FRFont; import com.fr.general.FRFont;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel; import javax.swing.JPanel;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
@ -19,12 +23,14 @@ import java.awt.Font;
import java.util.Vector; import java.util.Vector;
public class MobileStyleFontConfigPane extends JPanel { public class MobileStyleFontConfigPane extends JPanel {
public static final int FONT_NONE = 0;
private static final int MAX_FONT_SIZE = 18; private static final int MAX_FONT_SIZE = 18;
private static final int MIN_FONT_SIZE = 12; private static final int MIN_FONT_SIZE = 12;
private static final Dimension BUTTON_SIZE = new Dimension(20, 18); private static final Dimension BUTTON_SIZE = new Dimension(20, 18);
public static Vector<Integer> getFontSizes() { public static Vector<Integer> getFontSizes() {
Vector<Integer> FONT_SIZES = new Vector<Integer>(); Vector<Integer> FONT_SIZES = new Vector<Integer>();
FONT_SIZES.add(FONT_NONE);
for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++) { for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++) {
FONT_SIZES.add(i); FONT_SIZES.add(i);
} }
@ -42,10 +48,11 @@ public class MobileStyleFontConfigPane extends JPanel {
private void initComponent() { private void initComponent() {
fontSizeComboBox = new UIComboBox(getFontSizes()); fontSizeComboBox = new UIComboBox();
fontSizeComboBox.setSelectedItem(16); fontSizeComboBox.setSelectedItem(0);
fontSizeComboBox.setModel(new DefaultComboBoxModel(getFontSizes()));
fontSizeComboBox.setPreferredSize(new Dimension(60, 20)); fontSizeComboBox.setPreferredSize(new Dimension(60, 20));
fontSizeComboBox.setEditable(true); fontSizeComboBox.setRenderer(new LineCellRenderer());
underline = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png")); underline = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/underline.png"));
italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png")); italic = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/italic.png"));
bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png"));
@ -96,4 +103,20 @@ public class MobileStyleFontConfigPane extends JPanel {
underline.isSelected() ? Constants.LINE_THIN : Constants.LINE_NONE underline.isSelected() ? Constants.LINE_THIN : Constants.LINE_NONE
); );
} }
private class LineCellRenderer extends UIComboBoxRenderer {
public LineCellRenderer() {
super();
}
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel renderer =(JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
int currentValue = ((Integer) value).intValue();
if (currentValue == MobileStyleFontConfigPane.FONT_NONE) {
renderer.setText(" " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_None"));
}
return renderer;
}
}
} }

Loading…
Cancel
Save