Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras7
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSWindow.java12
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java1
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java2
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java90
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java152
-rw-r--r--bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java132
-rw-r--r--examples/org.eclipse.swt.examples/META-INF/MANIFEST.MF2
-rw-r--r--examples/org.eclipse.swt.examples/pom.xml2
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ShellTab.java2
12 files changed, 372 insertions, 32 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
index ddcbeecee5..03617127fc 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/AppKitFull.bridgesupport.extras
@@ -3984,6 +3984,9 @@
<arg swt_gen="true"></arg>
<retval swt_gen="true"></retval>
</method>
+ <method selector="maxSize" swt_gen="true">
+ <retval swt_gen="true"></retval>
+ </method>
<method class_method="true" selector="minFrameWidthWithTitle:styleMask:" swt_gen="true">
<arg swt_gen="true"></arg>
<arg swt_gen="true"></arg>
@@ -4088,6 +4091,10 @@
<arg swt_gen="true"></arg>
<retval swt_gen="true"></retval>
</method>
+ <method selector="setMaxSize:" swt_gen="true">
+ <arg swt_gen="true"></arg>
+ <retval swt_gen="true"></retval>
+ </method>
<method selector="setMinSize:" swt_gen="true">
<arg swt_gen="true"></arg>
<retval swt_gen="true"></retval>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSWindow.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSWindow.java
index 72acf7cfa1..964eef4407 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSWindow.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/NSWindow.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2019 IBM Corporation and others.
+ * Copyright (c) 2000, 2021 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
@@ -201,6 +201,12 @@ public void makeKeyAndOrderFront(id sender) {
OS.objc_msgSend(this.id, OS.sel_makeKeyAndOrderFront_, sender != null ? sender.id : 0);
}
+public NSSize maxSize() {
+ NSSize result = new NSSize();
+ OS.objc_msgSend_stret(result, this.id, OS.sel_maxSize);
+ return result;
+}
+
public static double minFrameWidthWithTitle(NSString aTitle, long aStyle) {
return OS.objc_msgSend_fpret(OS.class_NSWindow, OS.sel_minFrameWidthWithTitle_styleMask_, aTitle != null ? aTitle.id : 0, aStyle);
}
@@ -311,6 +317,10 @@ public void setLevel(long level) {
OS.objc_msgSend(this.id, OS.sel_setLevel_, level);
}
+public void setMaxSize(NSSize maxSize) {
+ OS.objc_msgSend(this.id, OS.sel_setMaxSize_, maxSize);
+}
+
public void setMinSize(NSSize minSize) {
OS.objc_msgSend(this.id, OS.sel_setMinSize_, minSize);
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
index 3f599c17a2..08a90047c1 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/OS.java
@@ -1379,6 +1379,7 @@ public static final long sel_makeFirstResponder_ = Selector.sel_makeFirstRespond
public static final long sel_makeKeyAndOrderFront_ = Selector.sel_makeKeyAndOrderFront_.value;
public static final long sel_markedRange = Selector.sel_markedRange.value;
public static final long sel_markedTextAttributes = Selector.sel_markedTextAttributes.value;
+public static final long sel_maxSize = Selector.sel_maxSize.value;
public static final long sel_maxValue = Selector.sel_maxValue.value;
public static final long sel_menu = Selector.sel_menu.value;
public static final long sel_menu_willHighlightItem_ = Selector.sel_menu_willHighlightItem_.value;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java
index 258e28dd4f..3625842269 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/cocoa/org/eclipse/swt/internal/cocoa/Selector.java
@@ -651,6 +651,7 @@ public enum Selector {
, sel_makeKeyAndOrderFront_("makeKeyAndOrderFront:")
, sel_markedRange("markedRange")
, sel_markedTextAttributes("markedTextAttributes")
+ , sel_maxSize("maxSize")
, sel_maxValue("maxValue")
, sel_menu("menu")
, sel_menu_willHighlightItem_("menu:willHighlightItem:")
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java
index 5da54185c1..92082c0a03 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/gtk/org/eclipse/swt/internal/gtk/GDK.java
@@ -102,6 +102,7 @@ public class GDK extends OS {
public static final int GDK_GRAVITY_NORTH_WEST = 1;
public static final int GDK_Help = 0xFF6A;
public static final int GDK_HINT_MIN_SIZE = 1 << 1;
+ public static final int GDK_HINT_MAX_SIZE = 1 << 2;
public static final int GDK_Home = 0xff50;
public static final int GDK_INPUT_ONLY = 1;
public static final int GDK_INTERP_BILINEAR = 0x2;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
index 57763eeff5..6eea334e64 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT PI/win32/org/eclipse/swt/internal/win32/OS.java
@@ -1206,6 +1206,8 @@ public class OS extends C {
public static final int SM_CYMENU = 0xf;
public static final int SM_CXMINTRACK = 34;
public static final int SM_CYMINTRACK = 35;
+ public static final int SM_CXMAXTRACK = 59;
+ public static final int SM_CYMAXTRACK = 60;
public static final int SM_CMOUSEBUTTONS = 43;
public static final int SM_CYSCREEN = 0x1;
public static final int SM_CYVSCROLL = 0x14;
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java
index 95b21008bc..bde295c49c 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java
@@ -1109,6 +1109,28 @@ public boolean getMinimized () {
}
/**
+ * Returns a point describing the maximum receiver's size. The
+ * x coordinate of the result is the maximum width of the receiver.
+ * The y coordinate of the result is the maximum height of the
+ * receiver.
+ *
+ * @return the receiver's size
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.116
+ */
+public Point getMaximumSize () {
+ checkWidget();
+ if (window == null) return new Point(0, 0);
+ NSSize size = window.maxSize();
+ return new Point((int)size.width, (int)size.height);
+}
+
+/**
* Returns a point describing the minimum receiver's size. The
* x coordinate of the result is the minimum width of the receiver.
* The y coordinate of the result is the minimum height of the
@@ -1722,8 +1744,9 @@ public void setEnabled (boolean enabled) {
* to either the maximized or normal states.
* <p>
* Note: The result of intermixing calls to <code>setFullScreen(true)</code>,
- * <code>setMaximized(true)</code> and <code>setMinimized(true)</code> will
- * vary by platform. Typically, the behavior will match the platform user's
+ * <code>setMaximized(true)</code>, <code>setMinimized(true)</code> and
+ * <code>setMaximumSize</code> will vary by platform.
+ * Typically, the behavior will match the platform user's
* expectations, but not always. This should be avoided if possible.
* </p>
*
@@ -1818,6 +1841,69 @@ public void setMaximized (boolean maximized) {
window.zoom (null);
}
+/**
+ * Sets the receiver's maximum size to the size specified by the arguments.
+ * If the new maximum size is smaller than the current size of the receiver,
+ * the receiver is resized to the new maximum size.
+ * <p>
+ * Note: The result of intermixing calls to <code>setMaximumSize</code> and
+ * <code>setFullScreen(true)</code> will vary by platform.
+ * Typically, the behavior will match the platform user's
+ * expectations, but not always. This should be avoided if possible.
+ * </p>
+ * @param width the new maximum width for the receiver
+ * @param height the new maximum height for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.116
+ */
+public void setMaximumSize (int width, int height) {
+ checkWidget();
+ if (window == null) return;
+ NSSize size = new NSSize();
+ size.width = width;
+ size.height = height;
+ window.setMaxSize(size);
+ NSRect frame = window.frame();
+ if (width < frame.width || height < frame.height) {
+ width = (int)(width < frame.width ? width : frame.width);
+ height = (int)(height < frame.height ? height : frame.height);
+ setBounds(0, 0, width, height, false, true);
+ }
+}
+
+/**
+ * Sets the receiver's maximum size to the size specified by the argument.
+ * If the new maximum size is smaller than the current size of the receiver,
+ * the receiver is resized to the new maximum size.
+ * <p>
+ * Note: The result of intermixing calls to <code>setMaximumSize</code> and
+ * <code>setFullScreen(true)</code> will vary by platform.
+ * Typically, the behavior will match the platform user's
+ * expectations, but not always. This should be avoided if possible.
+ * </p>
+ * @param size the new maximum size for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.116
+ */
+public void setMaximumSize (Point size) {
+ checkWidget();
+ if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setMaximumSize (size.x, size.y);
+}
+
@Override
public void setMinimized (boolean minimized) {
checkWidget();
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
index b786bb1bf7..5dc3c02798 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Shell.java
@@ -125,7 +125,7 @@ public class Shell extends Decorations {
long shellHandle, tooltipsHandle, tooltipWindow, group, modalGroup;
boolean mapped, moved, resized, opened, fullScreen, showWithParent, modified, center;
int oldX, oldY, oldWidth, oldHeight;
- int minWidth, minHeight;
+ GdkGeometry geometry;
Control lastActive;
ToolTip [] toolTips;
boolean ignoreFocusOut, ignoreFocusIn;
@@ -286,6 +286,7 @@ Shell (Display display, Shell parent, int style, long handle, boolean embedded)
state |= FOREIGN_HANDLE;
}
}
+ this.geometry = new GdkGeometry();
reskinWidget();
createWidget (0);
}
@@ -1272,8 +1273,36 @@ public Point getMinimumSize () {
Point getMinimumSizeInPixels () {
checkWidget ();
- int width = Math.max (1, minWidth + trimWidth ());
- int height = Math.max (1, minHeight + trimHeight ());
+ int width = Math.max (1, geometry.min_width + trimWidth ());
+ int height = Math.max (1, geometry.min_height + trimHeight ());
+ return new Point (width, height);
+}
+
+/**
+ * Returns a point describing the maximum receiver's size. The
+ * x coordinate of the result is the maximum width of the receiver.
+ * The y coordinate of the result is the maximum height of the
+ * receiver.
+ *
+ * @return the receiver's size
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.116
+ */
+public Point getMaximumSize () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown (getMaximumSizeInPixels ());
+}
+
+Point getMaximumSizeInPixels () {
+ checkWidget ();
+
+ int width = Math.min (Integer.MAX_VALUE, geometry.max_width + trimWidth ());
+ int height = Math.min (Integer.MAX_VALUE, geometry.max_height + trimHeight ());
return new Point (width, height);
}
@@ -1654,8 +1683,8 @@ long gtk_motion_notify_event (long widget, long event) {
int y = display.resizeBoundsY;
int width = display.resizeBoundsWidth;
int height = display.resizeBoundsHeight;
- int newWidth = Math.max(width - dx, Math.max(minWidth, border + border));
- int newHeight = Math.max(height - dy, Math.max(minHeight, border + border));
+ int newWidth = Math.max(width - dx, Math.max(geometry.min_width, border + border));
+ int newHeight = Math.max(height - dy, Math.max(geometry.min_height, border + border));
switch (display.resizeMode) {
case SWT.CURSOR_SIZEW:
x += width - newWidth;
@@ -1672,24 +1701,24 @@ long gtk_motion_notify_event (long widget, long event) {
height = newHeight;
break;
case SWT.CURSOR_SIZENE:
- width = Math.max(width + dx, Math.max(minWidth, border + border));
+ width = Math.max(width + dx, Math.max(geometry.min_width, border + border));
y += height - newHeight;
height = newHeight;
break;
case SWT.CURSOR_SIZEE:
- width = Math.max(width + dx, Math.max(minWidth, border + border));
+ width = Math.max(width + dx, Math.max(geometry.min_width, border + border));
break;
case SWT.CURSOR_SIZESE:
- width = Math.max(width + dx, Math.max(minWidth, border + border));
- height = Math.max(height + dy, Math.max(minHeight, border + border));
+ width = Math.max(width + dx, Math.max(geometry.min_width, border + border));
+ height = Math.max(height + dy, Math.max(geometry.min_height, border + border));
break;
case SWT.CURSOR_SIZES:
- height = Math.max(height + dy, Math.max(minHeight, border + border));
+ height = Math.max(height + dy, Math.max(geometry.min_height, border + border));
break;
case SWT.CURSOR_SIZESW:
x += width - newWidth;
width = newWidth;
- height = Math.max(height + dy, Math.max(minHeight, border + border));
+ height = Math.max(height + dy, Math.max(geometry.min_height, border + border));
break;
}
if (x != display.resizeBoundsX || y != display.resizeBoundsY) {
@@ -2267,13 +2296,19 @@ int setBounds (int x, int y, int width, int height, boolean move, boolean resize
}
}
if (resize) {
- width = Math.max (1, Math.max (minWidth, width - trimWidth ()));
- height = Math.max (1, Math.max (minHeight, height - trimHeight ()));
+ width = Math.max (1, Math.max (geometry.min_width, width - trimWidth ()));
+ if (geometry.max_width > 0) {
+ width = Math.min( width, geometry.max_width);
+ }
+ height = Math.max (1, Math.max (geometry.min_height, height - trimHeight ()));
+ if (geometry.max_height > 0) {
+ height = Math.min(height, geometry.max_height);
+ }
/*
* If the shell is created without a RESIZE style bit, and the
- * minWidth/minHeight has been set, allow the resize.
+ * minWidth/minHeight/maxWidth/maxHeight have been set, allow the resize.
*/
- if ((style & SWT.RESIZE) != 0 || (minHeight != 0 || minWidth != 0)) {
+ if ((style & SWT.RESIZE) != 0 || (geometry.min_height != 0 || geometry.min_width != 0 || geometry.max_height != 0 || geometry.max_width != 0)) {
if (GTK.GTK4) {
GTK.gtk_window_set_default_size(shellHandle, width, height);
} else {
@@ -2389,8 +2424,9 @@ public void setEnabled (boolean enabled) {
* to either the maximized or normal states.
* <p>
* Note: The result of intermixing calls to <code>setFullScreen(true)</code>,
- * <code>setMaximized(true)</code> and <code>setMinimized(true)</code> will
- * vary by platform. Typically, the behavior will match the platform user's
+ * <code>setMaximized(true)</code>, <code>setMinimized(true)</code> and
+ * <code>setMaximumSize</code> will vary by platform.
+ * Typically, the behavior will match the platform user's
* expectations, but not always. This should be avoided if possible.
* </p>
*
@@ -2580,10 +2616,13 @@ public void setMinimumSize (int width, int height) {
void setMinimumSizeInPixels (int width, int height) {
checkWidget ();
- GdkGeometry geometry = new GdkGeometry ();
- minWidth = geometry.min_width = Math.max (width, trimWidth ()) - trimWidth ();
- minHeight = geometry.min_height = Math.max (height, trimHeight ()) - trimHeight ();
- GTK.gtk_window_set_geometry_hints (shellHandle, 0, geometry, GDK.GDK_HINT_MIN_SIZE);
+ geometry.min_width = Math.max (width, trimWidth ()) - trimWidth ();
+ geometry.min_height = Math.max (height, trimHeight ()) - trimHeight ();
+ int hint = GDK.GDK_HINT_MIN_SIZE;
+ if (geometry.max_height > 0 || geometry.max_width > 0) {
+ hint = hint | GDK.GDK_HINT_MAX_SIZE;
+ }
+ GTK.gtk_window_set_geometry_hints (shellHandle, 0, geometry, hint);
}
/**
@@ -2615,6 +2654,75 @@ void setMinimumSizeInPixels (Point size) {
}
/**
+ * Sets the receiver's maximum size to the size specified by the arguments.
+ * If the new maximum size is smaller than the current size of the receiver,
+ * the receiver is resized to the new maximum size.
+ * <p>
+ * Note: The result of intermixing calls to <code>setMaximumSize</code> and
+ * <code>setFullScreen(true)</code> will vary by platform.
+ * Typically, the behavior will match the platform user's
+ * expectations, but not always. This should be avoided if possible.
+ * </p>
+ * @param width the new maximum width for the receiver
+ * @param height the new maximum height for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.116
+ */
+public void setMaximumSize (int width, int height) {
+ checkWidget ();
+ setMaximumSize (new Point (width, height));
+}
+
+/**
+ * Sets the receiver's maximum size to the size specified by the argument.
+ * If the new maximum size is smaller than the current size of the receiver,
+ * the receiver is resized to the new maximum size.
+ * <p>
+ * Note: The result of intermixing calls to <code>setMaximumSize</code> and
+ * <code>setFullScreen(true)</code> will vary by platform.
+ * Typically, the behavior will match the platform user's
+ * expectations, but not always. This should be avoided if possible.
+ * </p>
+ * @param size the new maximum size for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.116
+ */
+public void setMaximumSize (Point size) {
+ checkWidget ();
+ setMaximumSizeInPixels (DPIUtil.autoScaleUp (size));
+}
+
+void setMaximumSizeInPixels (Point size) {
+ checkWidget ();
+ if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
+ setMaximumSizeInPixels (size.x, size.y);
+}
+
+void setMaximumSizeInPixels (int width, int height) {
+ checkWidget ();
+ geometry.max_width = Math.max (width, trimWidth ()) - trimWidth ();
+ geometry.max_height = Math.max (height, trimHeight ()) - trimHeight ();
+ int hint = GDK.GDK_HINT_MAX_SIZE;
+ if (geometry.min_width > 0 || geometry.min_height > 0) {
+ hint = hint | GDK.GDK_HINT_MIN_SIZE;
+ }
+ GTK.gtk_window_set_geometry_hints (shellHandle, 0, geometry, hint);
+}
+
+/**
* Sets the receiver's modified state as specified by the argument.
*
* @param modified the new modified state for the receiver
@@ -2809,7 +2917,7 @@ public void setVisible (boolean visible) {
if (enableSurface != 0) {
int width = GDK.gdk_surface_get_width(enableSurface);
int height = GDK.gdk_surface_get_height(enableSurface);
- long layout = GDK.gdk_toplevel_layout_new(minWidth, minHeight);
+ long layout = GDK.gdk_toplevel_layout_new(geometry.min_width, geometry.min_height);
GDK.gdk_toplevel_present(enableSurface, width, height, layout);
}
} else {
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
index 1fd56f1a3a..6d67201746 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Shell.java
@@ -124,7 +124,7 @@ public class Shell extends Decorations {
Menu activeMenu;
ToolTip [] toolTips;
long hwndMDIClient, lpstrTip, toolTipHandle, balloonTipHandle, menuItemToolTipHandle;
- int minWidth = SWT.DEFAULT, minHeight = SWT.DEFAULT;
+ int minWidth = SWT.DEFAULT, minHeight = SWT.DEFAULT, maxWidth = SWT.DEFAULT, maxHeight = SWT.DEFAULT;
long [] brushes;
boolean showWithParent, fullScreen, wasMaximized, modified, center;
String toolTitle, balloonTitle;
@@ -1010,6 +1010,47 @@ public boolean getMaximized () {
}
/**
+ * Returns a point describing the maximum receiver's size. The
+ * x coordinate of the result is the maximum width of the receiver.
+ * The y coordinate of the result is the maximum height of the
+ * receiver.
+ *
+ * @return the receiver's size
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.116
+ */
+public Point getMaximumSize () {
+ checkWidget ();
+ return DPIUtil.autoScaleDown(getMaximumSizeInPixels());
+}
+
+Point getMaximumSizeInPixels () {
+ int width = Math.min (Integer.MAX_VALUE, maxWidth);
+ int trim = SWT.TITLE | SWT.CLOSE | SWT.MIN | SWT.MAX;
+ if ((style & SWT.NO_TRIM) == 0 && (style & trim) != 0) {
+ width = Math.min (width, OS.GetSystemMetrics (OS.SM_CXMAXTRACK));
+ }
+ int height = Math.min (Integer.MAX_VALUE, maxHeight);
+ if ((style & SWT.NO_TRIM) == 0 && (style & trim) != 0) {
+ if ((style & SWT.RESIZE) != 0) {
+ height = Math.min (height, OS.GetSystemMetrics (OS.SM_CYMAXTRACK));
+ } else {
+ RECT rect = new RECT ();
+ int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
+ OS.AdjustWindowRectEx (rect, bits1, false, bits2);
+ height = Math.min (height, rect.bottom - rect.top);
+ }
+ }
+ return new Point (width, height);
+}
+
+/**
* Returns a point describing the minimum receiver's size. The
* x coordinate of the result is the minimum width of the receiver.
* The y coordinate of the result is the minimum height of the
@@ -1539,8 +1580,9 @@ public void setEnabled (boolean enabled) {
* to either the maximized or normal states.
* <p>
* Note: The result of intermixing calls to <code>setFullScreen(true)</code>,
- * <code>setMaximized(true)</code> and <code>setMinimized(true)</code> will
- * vary by platform. Typically, the behavior will match the platform user's
+ * <code>setMaximized(true)</code>, <code>setMinimized(true)</code> and
+ * <code>setMaximumSize</code> will vary by platform.
+ * Typically, the behavior will match the platform user's
* expectations, but not always. This should be avoided if possible.
* </p>
*
@@ -1647,6 +1689,85 @@ public void setImeInputMode (int mode) {
}
/**
+ * Sets the receiver's maximum size to the size specified by the arguments.
+ * If the new maximum size is smaller than the current size of the receiver,
+ * the receiver is resized to the new maximum size.
+ * <p>
+ * Note: The result of intermixing calls to <code>setMaximumSize</code> and
+ * <code>setFullScreen(true)</code> will vary by platform.
+ * Typically, the behavior will match the platform user's
+ * expectations, but not always. This should be avoided if possible.
+ * </p>
+ * @param width the new maximum width for the receiver
+ * @param height the new maximum height for the receiver
+ *
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.116
+ */
+public void setMaximumSize (int width, int height) {
+ checkWidget ();
+ setMaximumSizeInPixels(DPIUtil.autoScaleUp(width), DPIUtil.autoScaleUp(height));
+}
+
+/**
+ * Sets the receiver's maximum size to the size specified by the argument.
+ * If the new maximum size is smaller than the current size of the receiver,
+ * the receiver is resized to the new maximum size.
+ * <p>
+ * Note: The result of intermixing calls to <code>setMaximumSize</code> and
+ * <code>setFullScreen(true)</code> will vary by platform.
+ * Typically, the behavior will match the platform user's
+ * expectations, but not always. This should be avoided if possible.
+ * </p>
+ * @param size the new maximum size for the receiver
+ *
+ * @exception IllegalArgumentException <ul>
+ * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
+ * </ul>
+ * @exception SWTException <ul>
+ * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
+ * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
+ * </ul>
+ *
+ * @since 3.116
+ */
+public void setMaximumSize (Point size) {
+ checkWidget ();
+ if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
+ size = DPIUtil.autoScaleUp(size);
+ setMaximumSizeInPixels(size.x, size.y);
+}
+
+void setMaximumSizeInPixels (int width, int height) {
+ int widthLimit = 0, heightLimit = 0;
+ int trim = SWT.TITLE | SWT.CLOSE | SWT.MIN | SWT.MAX;
+ if ((style & SWT.NO_TRIM) == 0 && (style & trim) != 0) {
+ widthLimit = OS.GetSystemMetrics (OS.SM_CXMAXTRACK);
+ if ((style & SWT.RESIZE) != 0) {
+ heightLimit = OS.GetSystemMetrics (OS.SM_CYMAXTRACK);
+ } else {
+ RECT rect = new RECT ();
+ int bits1 = OS.GetWindowLong (handle, OS.GWL_STYLE);
+ int bits2 = OS.GetWindowLong (handle, OS.GWL_EXSTYLE);
+ OS.AdjustWindowRectEx (rect, bits1, false, bits2);
+ heightLimit = rect.bottom - rect.top;
+ }
+ }
+ maxWidth = Math.min (widthLimit, width);
+ maxHeight = Math.min (heightLimit, height);
+ Point size = getSizeInPixels ();
+ int newWidth = Math.min (size.x, maxWidth);
+ int newHeight = Math.min (size.y, maxHeight);
+ if (maxWidth >= widthLimit) maxWidth = SWT.DEFAULT;
+ if (maxHeight >= heightLimit) maxHeight = SWT.DEFAULT;
+ if (newWidth != size.x || newHeight != size.y) setSizeInPixels (newWidth, newHeight);
+}
+
+/**
* Sets the receiver's minimum size to the size specified by the arguments.
* If the new minimum size is larger than the current size of the receiver,
* the receiver is resized to the new minimum size.
@@ -2227,11 +2348,14 @@ LRESULT WM_ENTERIDLE (long wParam, long lParam) {
LRESULT WM_GETMINMAXINFO (long wParam, long lParam) {
LRESULT result = super.WM_GETMINMAXINFO (wParam, lParam);
if (result != null) return result;
- if (minWidth != SWT.DEFAULT || minHeight != SWT.DEFAULT) {
+ if (minWidth != SWT.DEFAULT || minHeight != SWT.DEFAULT
+ || maxWidth != SWT.DEFAULT || maxHeight != SWT.DEFAULT) {
MINMAXINFO info = new MINMAXINFO ();
OS.MoveMemory (info, lParam, MINMAXINFO.sizeof);
if (minWidth != SWT.DEFAULT) info.ptMinTrackSize_x = minWidth;
if (minHeight != SWT.DEFAULT) info.ptMinTrackSize_y = minHeight;
+ if (maxWidth != SWT.DEFAULT) info.ptMaxTrackSize_x = maxWidth;
+ if (maxHeight != SWT.DEFAULT) info.ptMaxTrackSize_y = maxHeight;
OS.MoveMemory (lParam, info, MINMAXINFO.sizeof);
return LRESULT.ZERO;
}
diff --git a/examples/org.eclipse.swt.examples/META-INF/MANIFEST.MF b/examples/org.eclipse.swt.examples/META-INF/MANIFEST.MF
index b435f0c6a0..c2bed06b1b 100644
--- a/examples/org.eclipse.swt.examples/META-INF/MANIFEST.MF
+++ b/examples/org.eclipse.swt.examples/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %plugin.SWTStandaloneExampleSet.name
Bundle-SymbolicName: org.eclipse.swt.examples; singleton:=true
-Bundle-Version: 3.106.1100.qualifier
+Bundle-Version: 3.106.1200.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/examples/org.eclipse.swt.examples/pom.xml b/examples/org.eclipse.swt.examples/pom.xml
index 1630418824..cce56adca4 100644
--- a/examples/org.eclipse.swt.examples/pom.xml
+++ b/examples/org.eclipse.swt.examples/pom.xml
@@ -19,6 +19,6 @@
</parent>
<groupId>org.eclipse.swt</groupId>
<artifactId>org.eclipse.swt.examples</artifactId>
- <version>3.106.1100-SNAPSHOT</version>
+ <version>3.106.1200-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ShellTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ShellTab.java
index b878a2cfb9..18a2b71c27 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ShellTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ShellTab.java
@@ -341,7 +341,7 @@ class ShellTab extends Tab {
@Override
String[] getMethodNames() {
- return new String[] {"Alpha", "Bounds", "MinimumSize", "Modified", "Text"};
+ return new String[] {"Alpha", "Bounds", "MinimumSize", "MaximumSize", "Modified", "Text"};
}
@Override

Back to the top