|
|
@ -727,8 +727,9 @@ public class WindowsTitlePane extends CustomTitlePane { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Dimension getPreferredSize() { |
|
|
|
public Dimension getPreferredSize() { |
|
|
|
if (hideTitleBar()) return new Dimension(0, 0); |
|
|
|
if (hideTitleBar()) return new Dimension(0, 0); |
|
|
|
int size = computeHeight(); |
|
|
|
int height = computeHeight(); |
|
|
|
return new Dimension(size + 1, size + 1); |
|
|
|
int width = computeWidth(); |
|
|
|
|
|
|
|
return new Dimension(width, height + 1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private int computeHeight() { |
|
|
|
private int computeHeight() { |
|
|
@ -741,6 +742,35 @@ public class WindowsTitlePane extends CustomTitlePane { |
|
|
|
return Math.max(BAR_HEIGHT, height); |
|
|
|
return Math.max(BAR_HEIGHT, height); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private int computeWidth() { |
|
|
|
|
|
|
|
int width = 0; |
|
|
|
|
|
|
|
Icon windowIcon = windowIconButton.getIcon(); |
|
|
|
|
|
|
|
if (windowIcon != null) { |
|
|
|
|
|
|
|
width += Math.min(ICON_WIDTH, Math.max(windowIcon.getIconHeight(), windowIcon.getIconWidth())); |
|
|
|
|
|
|
|
width += 2 * PAD; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (menuBar != null) { |
|
|
|
|
|
|
|
width += getPreferredMenuSize().width; |
|
|
|
|
|
|
|
width += PAD; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
boolean frame = getDecorationStyle() == JRootPane.FRAME; |
|
|
|
|
|
|
|
boolean undecorated = getDecorationStyle() == JRootPane.NONE; |
|
|
|
|
|
|
|
if (!undecorated) { |
|
|
|
|
|
|
|
width += BUTTON_WIDTH; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (frame) { |
|
|
|
|
|
|
|
width += BUTTON_WIDTH; |
|
|
|
|
|
|
|
if (Toolkit.getDefaultToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH)) { |
|
|
|
|
|
|
|
width += BUTTON_WIDTH; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (!titleLabel.getText().isEmpty()) { |
|
|
|
|
|
|
|
width += titleLabel.getPreferredSize().width; |
|
|
|
|
|
|
|
width += PAD; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return width; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected void updateDragArea(final GraphicsConfiguration gc) { |
|
|
|
protected void updateDragArea(final GraphicsConfiguration gc) { |
|
|
|
JNIDecorationsWindows.updateValues(windowHandle, |
|
|
|
JNIDecorationsWindows.updateValues(windowHandle, |
|
|
|
(int) Scale.scaleWidth(left, gc), |
|
|
|
(int) Scale.scaleWidth(left, gc), |
|
|
@ -748,6 +778,15 @@ public class WindowsTitlePane extends CustomTitlePane { |
|
|
|
(int) Scale.scaleHeight(height, gc)); |
|
|
|
(int) Scale.scaleHeight(height, gc)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Dimension getPreferredMenuSize() { |
|
|
|
|
|
|
|
LayoutManager menuBarLayout = menuBar.getLayout(); |
|
|
|
|
|
|
|
Dimension size = null; |
|
|
|
|
|
|
|
if (menuBarLayout != null) { |
|
|
|
|
|
|
|
size = menuBarLayout.preferredLayoutSize(menuBar); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return (size != null) ? size : menuBar.getPreferredSize(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private class TitlePaneLayout implements LayoutManager { |
|
|
|
private class TitlePaneLayout implements LayoutManager { |
|
|
|
public void addLayoutComponent(final String name, final Component c) {} |
|
|
|
public void addLayoutComponent(final String name, final Component c) {} |
|
|
|
|
|
|
|
|
|
|
@ -781,12 +820,9 @@ public class WindowsTitlePane extends CustomTitlePane { |
|
|
|
left = 0; |
|
|
|
left = 0; |
|
|
|
right = 0; |
|
|
|
right = 0; |
|
|
|
|
|
|
|
|
|
|
|
if (windowIconButton.getIcon() != null) { |
|
|
|
Icon windowIcon = windowIconButton.getIcon(); |
|
|
|
int windowButtonWidth = windowIconButton.getIcon() != null ? Math.max(windowIconButton.getIcon() |
|
|
|
if (windowIcon != null) { |
|
|
|
.getIconHeight(), |
|
|
|
int windowButtonWidth = Math.max(windowIcon.getIconHeight(), windowIcon.getIconWidth()); |
|
|
|
windowIconButton.getIcon() |
|
|
|
|
|
|
|
.getIconWidth()) |
|
|
|
|
|
|
|
: ICON_WIDTH; |
|
|
|
|
|
|
|
windowButtonWidth = Math.min(ICON_WIDTH, windowButtonWidth); |
|
|
|
windowButtonWidth = Math.min(ICON_WIDTH, windowButtonWidth); |
|
|
|
windowIconButton.setBounds(start + PAD, y, windowButtonWidth, height); |
|
|
|
windowIconButton.setBounds(start + PAD, y, windowButtonWidth, height); |
|
|
|
start += windowButtonWidth + 2 * PAD; |
|
|
|
start += windowButtonWidth + 2 * PAD; |
|
|
@ -815,9 +851,18 @@ public class WindowsTitlePane extends CustomTitlePane { |
|
|
|
x -= BUTTON_WIDTH; |
|
|
|
x -= BUTTON_WIDTH; |
|
|
|
right += BUTTON_WIDTH; |
|
|
|
right += BUTTON_WIDTH; |
|
|
|
minimizeButton.setBounds(x, y, BUTTON_WIDTH, height); |
|
|
|
minimizeButton.setBounds(x, y, BUTTON_WIDTH, height); |
|
|
|
|
|
|
|
x -= PAD; |
|
|
|
} |
|
|
|
} |
|
|
|
start = Math.max(start, PAD); |
|
|
|
start = Math.max(start, PAD); |
|
|
|
titleLabel.setBounds(start, 0, x - start, height); |
|
|
|
x = Math.min(getWidth() - PAD, x); |
|
|
|
|
|
|
|
int labelWidth = x - start; |
|
|
|
|
|
|
|
int prefLabelWidth = titleLabel.getPreferredSize().width; |
|
|
|
|
|
|
|
if (prefLabelWidth > labelWidth) { |
|
|
|
|
|
|
|
int extra = Math.min(prefLabelWidth - labelWidth, 2 * PAD); |
|
|
|
|
|
|
|
start -= extra / 2; |
|
|
|
|
|
|
|
labelWidth += extra; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
titleLabel.setBounds(start, 0, labelWidth, height); |
|
|
|
|
|
|
|
|
|
|
|
if (!leftToRight) { |
|
|
|
if (!leftToRight) { |
|
|
|
mirror(windowIconButton, w); |
|
|
|
mirror(windowIconButton, w); |
|
|
@ -840,15 +885,6 @@ public class WindowsTitlePane extends CustomTitlePane { |
|
|
|
component.getY()); |
|
|
|
component.getY()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private Dimension getPreferredMenuSize() { |
|
|
|
|
|
|
|
LayoutManager menuBarLayout = menuBar.getLayout(); |
|
|
|
|
|
|
|
Dimension size = null; |
|
|
|
|
|
|
|
if (menuBarLayout != null) { |
|
|
|
|
|
|
|
size = menuBarLayout.preferredLayoutSize(menuBar); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return (size != null) ? size : menuBar.getPreferredSize(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected class WindowPropertyChangeListener implements PropertyChangeListener { |
|
|
|
protected class WindowPropertyChangeListener implements PropertyChangeListener { |
|
|
|