From aad680b44458e67fdbad394aa81afec71e8f865b Mon Sep 17 00:00:00 2001 From: PanLi320 <854954082@qq.com> Date: Tue, 10 Jan 2017 20:02:20 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-576=20tab=E4=B8=ADbutton=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E8=87=AA=E5=8A=A8=E6=89=A9=E5=B1=95bug=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../designer/creator/XLayoutContainer.java | 23 ++++++++++++++-- .../creator/cardlayout/XCardSwitchButton.java | 26 ++++++++++++------- .../creator/cardlayout/XWCardLayout.java | 3 +-- .../creator/cardlayout/XWCardTagLayout.java | 12 --------- .../creator/cardlayout/XWTabFitLayout.java | 24 ++++++++++++++--- 5 files changed, 60 insertions(+), 28 deletions(-) diff --git a/designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java b/designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java index 47f4270a5e..254e9a9184 100644 --- a/designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java +++ b/designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java @@ -10,8 +10,6 @@ import com.fr.design.form.util.XCreatorConstants; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.widget.editors.PaddingMarginEditor; import com.fr.design.mainframe.widget.editors.WLayoutBorderStyleEditor; -import com.fr.design.mainframe.widget.renderer.LayoutBorderStyleRenderer; -import com.fr.design.mainframe.widget.renderer.PaddingMarginCellRenderer; import com.fr.design.parameter.ParameterBridge; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WLayout; @@ -81,6 +79,27 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme }; } + /** + * 控件名属性 + * @return + * @throws IntrospectionException + */ + public CRPropertyDescriptor createWidgetNameDescriptor() throws IntrospectionException { + return new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Inter + .getLocText("FR-Designer_Form-Widget_Name")); + } + + /** + * 边距属性 + * @return + * @throws IntrospectionException + */ + public CRPropertyDescriptor createMarginDescriptor() throws IntrospectionException { + return new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class) + .setI18NName(Inter.getLocText("FR-Designer_Layout-Padding")) + .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"); + } + /** * 返回对应的wlayout * @return wlayout控件 diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java index ca4f7f1f10..6baa740947 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java @@ -6,8 +6,7 @@ package com.fr.design.designer.creator.cardlayout; import java.awt.*; import java.awt.event.MouseEvent; import java.awt.geom.Rectangle2D; -import java.util.HashMap; -import java.util.Map; +import java.util.*; import javax.swing.*; @@ -58,6 +57,9 @@ public class XCardSwitchButton extends XButton { private static final int RIGHT_OFFSET = 15; private static final int TOP_OFFSET = 25; + //这边先不计算button的高度,涉及到layout那边的整体高度,先用之前的固定高度 + private static final int DEFAULT_BUTTON_HEIGHT = 36; + // tab按钮里的字体因为按钮内部的布局看起来比正常的要小,加个调整量 private static final int FONT_SIZE_ADJUST = 2; @@ -70,7 +72,6 @@ public class XCardSwitchButton extends XButton { private Background selectBackground; private boolean isCustomStyle; - private Icon closeIcon = MOUSE_COLSE; public XWCardTagLayout getTagLayout() { @@ -169,6 +170,7 @@ public class XCardSwitchButton extends XButton { editingMouseListener.startEditing(this, adapter.getDesignerEditor(), adapter); } + setTabsAndAdjust(); } //删除card,同时修改其他switchbutton和tabfit的index @@ -258,6 +260,7 @@ public class XCardSwitchButton extends XButton { public void paintComponent(Graphics g) { super.paintComponent(g); + setTabsAndAdjust(); Graphics2D g2d = (Graphics2D) g; drawBackgorund(); drawTitle(); @@ -359,22 +362,27 @@ public class XCardSwitchButton extends XButton { } public void adjustTabs(int tabLength, Map width, Map height) { + if (width == null) { + return; + } int tempX = 0; for (int i = 0; i < tabLength; i++) { - Rectangle rectangle = this.tagLayout.getComponent(i).getBounds(); + Rectangle rectangle = this.tagLayout.getComponent(i).getBounds(); Integer cardWidth = width.get(i) + SIDE_OFFSET; - Integer cardHeight = height.get(i) + HEIGHT_OFFSET; + //先用这边的固定高度 + Integer cardHeight = DEFAULT_BUTTON_HEIGHT; rectangle.setSize(cardWidth, cardHeight); rectangle.setBounds(tempX, 0, cardWidth, cardHeight); tempX += cardWidth; this.tagLayout.getComponent(i).setBounds(rectangle); Dimension dimension = new Dimension(); dimension.setSize(cardWidth, cardHeight); - this.getContentLabel().setSize(dimension); - this.setSize(dimension); XCardSwitchButton temp = (XCardSwitchButton) this.tagLayout.getComponent(i); - CardSwitchButton tempCard = (CardSwitchButton) temp.toData(); - tempCard.setDefaultWidth(cardWidth); + UILabel label = temp.getContentLabel(); + label.setSize(dimension); + temp.setContentLabel(label); + temp.setSize(dimension); + temp.setPreferredSize(new Dimension(cardWidth, cardHeight)); } } diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java index 4f2492ee9e..d008ccd521 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java @@ -198,8 +198,7 @@ public class XWCardLayout extends XLayoutContainer { firstBtn.setText(Inter.getLocText("FR-Designer_Title") + 0); firstBtn.setInitialBackground(ColorBackground.getInstance(Color.WHITE)); xTag.setCurrentCard(firstBtn); - XCardSwitchButton xFirstBtn = new XCardSwitchButton(firstBtn, new Dimension(CardSwitchButton.DEF_WIDTH, -1),this,xTag); - firstBtn.setCustomStyle(true); + XCardSwitchButton xFirstBtn = new XCardSwitchButton(firstBtn, new Dimension(CardSwitchButton.DEF_WIDTH, -1), this, xTag); xFirstBtn.setBackupParent(xTag); return xFirstBtn; diff --git a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java index e40a7ca871..82170bacc2 100644 --- a/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java +++ b/designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java @@ -163,18 +163,6 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout { * void */ public void adjustComponentWidth(){ - int btnNum = this.getComponentCount(); - int tagLayoutWidth = this.getWidth(); - int allBtnWidth = btnNum * CardSwitchButton.DEF_WIDTH + btnNum; - int size = CardSwitchButton.DEF_WIDTH; - if(tagLayoutWidth - allBtnWidth < CardSwitchButton.DEF_WIDTH){ - size = (tagLayoutWidth - CardSwitchButton.DEF_WIDTH - btnNum)/btnNum; - } - WCardTagLayout layout = (WCardTagLayout)this.toData(); - for(int i=0;i