Browse Source

REPORT-576 tab中button内容自动扩展bug修复

master
PanLi320 8 years ago
parent
commit
8d9ddb0502
  1. 24
      designer_form/src/com/fr/design/designer/creator/cardlayout/XCardSwitchButton.java
  2. 1
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  3. 12
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java
  4. 13
      designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java

24
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.*;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.geom.Rectangle2D; import java.awt.geom.Rectangle2D;
import java.util.HashMap; import java.util.*;
import java.util.Map;
import javax.swing.*; import javax.swing.*;
@ -58,6 +57,9 @@ public class XCardSwitchButton extends XButton {
private static final int RIGHT_OFFSET = 15; private static final int RIGHT_OFFSET = 15;
private static final int TOP_OFFSET = 25; private static final int TOP_OFFSET = 25;
//这边先不计算button的高度,涉及到layout那边的整体高度,先用之前的固定高度
private static final int DEFAULT_BUTTON_HEIGHT = 36;
// tab按钮里的字体因为按钮内部的布局看起来比正常的要小,加个调整量 // tab按钮里的字体因为按钮内部的布局看起来比正常的要小,加个调整量
private static final int FONT_SIZE_ADJUST = 2; private static final int FONT_SIZE_ADJUST = 2;
@ -166,7 +168,7 @@ public class XCardSwitchButton extends XButton {
editingMouseListener.startEditing(this, editingMouseListener.startEditing(this,
adapter.getDesignerEditor(), adapter); adapter.getDesignerEditor(), adapter);
} }
setTabsAndAdjust();
} }
//删除card,同时修改其他switchbutton和tabfit的index //删除card,同时修改其他switchbutton和tabfit的index
@ -256,6 +258,7 @@ public class XCardSwitchButton extends XButton {
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
setTabsAndAdjust();
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
drawBackgorund(); drawBackgorund();
drawTitle(); drawTitle();
@ -357,22 +360,27 @@ public class XCardSwitchButton extends XButton {
} }
public void adjustTabs(int tabLength, Map<Integer, Integer> width, Map<Integer, Integer> height) { public void adjustTabs(int tabLength, Map<Integer, Integer> width, Map<Integer, Integer> height) {
if (width == null) {
return;
}
int tempX = 0; int tempX = 0;
for (int i = 0; i < tabLength; i++) { 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 cardWidth = width.get(i) + SIDE_OFFSET;
Integer cardHeight = height.get(i) + HEIGHT_OFFSET; //先用这边的固定高度
Integer cardHeight = DEFAULT_BUTTON_HEIGHT;
rectangle.setSize(cardWidth, cardHeight); rectangle.setSize(cardWidth, cardHeight);
rectangle.setBounds(tempX, 0, cardWidth, cardHeight); rectangle.setBounds(tempX, 0, cardWidth, cardHeight);
tempX += cardWidth; tempX += cardWidth;
this.tagLayout.getComponent(i).setBounds(rectangle); this.tagLayout.getComponent(i).setBounds(rectangle);
Dimension dimension = new Dimension(); Dimension dimension = new Dimension();
dimension.setSize(cardWidth, cardHeight); dimension.setSize(cardWidth, cardHeight);
this.getContentLabel().setSize(dimension);
this.setSize(dimension);
XCardSwitchButton temp = (XCardSwitchButton) this.tagLayout.getComponent(i); XCardSwitchButton temp = (XCardSwitchButton) this.tagLayout.getComponent(i);
CardSwitchButton tempCard = (CardSwitchButton) temp.toData(); UILabel label = temp.getContentLabel();
tempCard.setDefaultWidth(cardWidth); label.setSize(dimension);
temp.setContentLabel(label);
temp.setSize(dimension);
temp.setPreferredSize(new Dimension(cardWidth, cardHeight));
} }
} }

1
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardLayout.java

@ -199,7 +199,6 @@ public class XWCardLayout extends XLayoutContainer {
firstBtn.setInitialBackground(ColorBackground.getInstance(Color.WHITE)); firstBtn.setInitialBackground(ColorBackground.getInstance(Color.WHITE));
xTag.setCurrentCard(firstBtn); xTag.setCurrentCard(firstBtn);
XCardSwitchButton xFirstBtn = new XCardSwitchButton(firstBtn, new Dimension(CardSwitchButton.DEF_WIDTH, -1), this, xTag); XCardSwitchButton xFirstBtn = new XCardSwitchButton(firstBtn, new Dimension(CardSwitchButton.DEF_WIDTH, -1), this, xTag);
firstBtn.setCustomStyle(true);
xFirstBtn.setBackupParent(xTag); xFirstBtn.setBackupParent(xTag);
return xFirstBtn; return xFirstBtn;

12
designer_form/src/com/fr/design/designer/creator/cardlayout/XWCardTagLayout.java

@ -163,18 +163,6 @@ public class XWCardTagLayout extends XWHorizontalBoxLayout {
* void * void
*/ */
public void adjustComponentWidth(){ 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<btnNum;i++){
CardSwitchButton button = layout.getSwitchButton(i);
layout.setWidthAtWidget(button, size);
}
} }

13
designer_form/src/com/fr/design/designer/creator/cardlayout/XWTabFitLayout.java

@ -27,6 +27,7 @@ import com.fr.form.ui.container.WAbsoluteLayout.BoundsWidget;
import com.fr.form.ui.container.cardlayout.WCardTagLayout; import com.fr.form.ui.container.cardlayout.WCardTagLayout;
import com.fr.form.ui.container.cardlayout.WTabFitLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout;
import com.fr.general.Background; import com.fr.general.Background;
import com.fr.general.FRFont;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
@ -41,11 +42,12 @@ public class XWTabFitLayout extends XWFitLayout {
private static final int MIN_SIZE = 1; private static final int MIN_SIZE = 1;
// tab布局在拖拽导致的缩放里(含间隔时),如果拖拽宽高大于组件宽高,会导致调整的时候找不到原来的组件 // tab布局在拖拽导致的缩放里(含间隔时),如果拖拽宽高大于组件宽高,会导致调整的时候找不到原来的组件
// 这里先将拖拽之前的宽高先做备份 // 这里先将拖拽之前的宽高先做备份
public static final Color NORMAL_GRAL = new Color(236,236,236); private static final Color NORMAL_GRAL = new Color(236,236,236);
private Dimension referDim; private Dimension referDim;
private Background initialBackground; private Background initialBackground;
private Background overBackground; private Background overBackground;
private Background clickBackground; private Background clickBackground;
private FRFont font;
private XCardSwitchButton xCardSwitchButton; private XCardSwitchButton xCardSwitchButton;
public Dimension getReferDim() { public Dimension getReferDim() {
@ -80,6 +82,15 @@ public class XWTabFitLayout extends XWFitLayout {
this.clickBackground = clickBackground; this.clickBackground = clickBackground;
} }
@Override
public FRFont getFont() {
return font;
}
public void setFont(FRFont font) {
this.font = font;
}
public XCardSwitchButton getxCardSwitchButton() { public XCardSwitchButton getxCardSwitchButton() {
return xCardSwitchButton; return xCardSwitchButton;
} }

Loading…
Cancel
Save