Browse Source
Merge in DESIGN/design from ~TOMMY/design:release/10.0 to release/10.0 * commit '3f0db7cd7a138fce57817a6b04a8c19199022455': import 规范 MOBILE-27000 移动端控件自定义样式设计器开发feature/big-screen
Tommy
5 years ago
2 changed files with 183 additions and 17 deletions
@ -0,0 +1,99 @@ |
|||||||
|
package com.fr.design.mainframe.mobile.ui; |
||||||
|
|
||||||
|
import com.fr.base.BaseUtils; |
||||||
|
import com.fr.design.constants.LayoutConstants; |
||||||
|
import com.fr.design.gui.ibutton.UIToggleButton; |
||||||
|
import com.fr.design.gui.icombobox.UIComboBox; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
|
import com.fr.general.FRFont; |
||||||
|
import com.fr.stable.Constants; |
||||||
|
|
||||||
|
import javax.swing.JPanel; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Color; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.Dimension; |
||||||
|
import java.awt.FlowLayout; |
||||||
|
import java.awt.Font; |
||||||
|
import java.util.Vector; |
||||||
|
|
||||||
|
public class MobileStyleFontConfigPane extends JPanel { |
||||||
|
private static final int MAX_FONT_SIZE = 18; |
||||||
|
private static final int MIN_FONT_SIZE = 12; |
||||||
|
private static final Dimension BUTTON_SIZE = new Dimension(20, 18); |
||||||
|
|
||||||
|
public static Vector<Integer> getFontSizes() { |
||||||
|
Vector<Integer> FONT_SIZES = new Vector<Integer>(); |
||||||
|
for (int i = MIN_FONT_SIZE; i <= MAX_FONT_SIZE; i++) { |
||||||
|
FONT_SIZES.add(i); |
||||||
|
} |
||||||
|
return FONT_SIZES; |
||||||
|
} |
||||||
|
|
||||||
|
private UIComboBox fontSizeComboBox; |
||||||
|
private UIToggleButton underline; |
||||||
|
private UIToggleButton italic; |
||||||
|
private UIToggleButton bold; |
||||||
|
|
||||||
|
public MobileStyleFontConfigPane() { |
||||||
|
this.initComponent(); |
||||||
|
} |
||||||
|
|
||||||
|
private void initComponent() { |
||||||
|
|
||||||
|
fontSizeComboBox = new UIComboBox(getFontSizes()); |
||||||
|
fontSizeComboBox.setSelectedItem(16); |
||||||
|
fontSizeComboBox.setPreferredSize(new Dimension(60, 20)); |
||||||
|
fontSizeComboBox.setEditable(true); |
||||||
|
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")); |
||||||
|
bold = new UIToggleButton(BaseUtils.readIcon("/com/fr/design/images/m_format/cellstyle/bold.png")); |
||||||
|
|
||||||
|
this.setButtonsTips(); |
||||||
|
this.setButtonsSize(BUTTON_SIZE); |
||||||
|
|
||||||
|
Component[] components_font = new Component[]{ |
||||||
|
fontSizeComboBox, underline, italic, bold |
||||||
|
}; |
||||||
|
|
||||||
|
JPanel buttonPane = new JPanel(new BorderLayout()); |
||||||
|
buttonPane.add(GUICoreUtils.createFlowPane(components_font, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE)); |
||||||
|
|
||||||
|
this.setLayout(new BorderLayout(0,0)); |
||||||
|
this.add(buttonPane, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
private void setButtonsTips() { |
||||||
|
underline.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Underline")); |
||||||
|
italic.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Italic")); |
||||||
|
bold.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bold")); |
||||||
|
} |
||||||
|
|
||||||
|
private void setButtonsSize(Dimension size) { |
||||||
|
underline.setPreferredSize(size); |
||||||
|
italic.setPreferredSize(size); |
||||||
|
bold.setPreferredSize(size); |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
public void populateBean(FRFont frFont) { |
||||||
|
fontSizeComboBox.setSelectedItem(frFont.getSize()); |
||||||
|
bold.setSelected(frFont.isBold()); |
||||||
|
italic.setSelected(frFont.isItalic()); |
||||||
|
underline.setSelected(frFont.getUnderline() != Constants.LINE_NONE); |
||||||
|
} |
||||||
|
|
||||||
|
public FRFont updateBean() { |
||||||
|
int style = Font.PLAIN; |
||||||
|
style += this.bold.isSelected() ? Font.BOLD : Font.PLAIN; |
||||||
|
style += this.italic.isSelected() ? Font.ITALIC : Font.PLAIN; |
||||||
|
return FRFont.getInstance( |
||||||
|
FRFont.DEFAULT_FONTNAME, |
||||||
|
style, |
||||||
|
Float.parseFloat(fontSizeComboBox.getSelectedItem().toString()), |
||||||
|
Color.BLACK, |
||||||
|
underline.isSelected() ? Constants.LINE_THIN : Constants.LINE_NONE |
||||||
|
); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue