|
|
|
@ -69,6 +69,19 @@ public class XWTitleLayout extends DedicateLayoutContainer {
|
|
|
|
|
setBackground4Painting(null, 0.0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Insets getInsets() { |
|
|
|
|
if (getComponentCount() > 1) { |
|
|
|
|
XCreator bodyCreator = getBodyCreator(); |
|
|
|
|
if (bodyCreator instanceof XBorderStyleWidgetCreator) { |
|
|
|
|
XBorderStyleWidgetCreator styleBodyCreator = (XBorderStyleWidgetCreator) bodyCreator; |
|
|
|
|
setPaddingInsets4Painting(styleBodyCreator.toData().getMargin()); |
|
|
|
|
return getPaddingInsets4Painting(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return super.getInsets(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected void initXCreatorProperties() { |
|
|
|
|
super.initXCreatorProperties(); |
|
|
|
@ -187,30 +200,37 @@ public class XWTitleLayout extends DedicateLayoutContainer {
|
|
|
|
|
Composite oldComposite = g2d.getComposite(); |
|
|
|
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, (float) this.titleBackgroundOpacity4Painting)); |
|
|
|
|
XCreator titleCreator = getTitleCreator(); |
|
|
|
|
int titleHeight = titleCreator != null ? titleCreator.getHeight() : 0; |
|
|
|
|
if (titleCreator != null) { |
|
|
|
|
int height = titleCreator.getHeight(); |
|
|
|
|
Insets paddingInsets = getInsets(); |
|
|
|
|
|
|
|
|
|
Shape shape = new Rectangle2D.Double(0, 0, getWidth(), titleHeight); |
|
|
|
|
Shape shape = new Rectangle2D.Double(0, 0, getWidth(), height + paddingInsets.top); |
|
|
|
|
titleBackground4Painting.paint(g2d, shape); |
|
|
|
|
|
|
|
|
|
g2d.setComposite(oldComposite); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void paintBodyBackground(Graphics2D g2d) { |
|
|
|
|
if (bodyBackground4Painting != null) { |
|
|
|
|
Composite oldComposite = g2d.getComposite(); |
|
|
|
|
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, (float) this.bodyBackgroundOpacity4Painting)); |
|
|
|
|
|
|
|
|
|
XCreator titleCreator = getTitleCreator(); |
|
|
|
|
int titleHeight = titleCreator != null ? titleCreator.getHeight() : 0; |
|
|
|
|
// 兼容性考虑,组件样式背景不作用在标题范围内,只作用在控件整体,但同时不能遮挡作用于整体的边框图片
|
|
|
|
|
// 所以考虑样式背景与边框图片都由XWTitleLayout绘制,但样式背景要向下偏移标题栏的高度
|
|
|
|
|
Shape shape = new Rectangle2D.Double(0, titleHeight, getWidth(), getHeight() - titleHeight); |
|
|
|
|
XCreator bodyCreator = getBodyCreator(); |
|
|
|
|
|
|
|
|
|
if (bodyCreator != null) { |
|
|
|
|
int y = bodyCreator.getY(); |
|
|
|
|
int height = bodyCreator.getHeight(); |
|
|
|
|
Insets paddingInsets = getInsets(); |
|
|
|
|
|
|
|
|
|
Shape shape = new Rectangle2D.Double(0, y, getWidth(), height + paddingInsets.bottom); |
|
|
|
|
bodyBackground4Painting.paint(g2d, shape); |
|
|
|
|
|
|
|
|
|
g2d.setComposite(oldComposite); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 将WLayout转换为XLayoutContainer |
|
|
|
|