Skip to content

Commit c115301

Browse files
authored
Fix Shell.print() on macOS to render child controls
The macOS implementation was just returning false without printing children, similar to a previously fixed Windows issue. Now it properly iterates through child controls and prints them with correct coordinate transformations using NSAffineTransform and NSGraphicsContext state management.
1 parent a972e2e commit c115301

File tree

1 file changed

+17
-1
lines changed
  • bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets

1 file changed

+17
-1
lines changed

bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Shell.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1404,7 +1404,23 @@ public boolean print (GC gc) {
14041404
checkWidget ();
14051405
if (gc == null) error (SWT.ERROR_NULL_ARGUMENT);
14061406
if (gc.isDisposed ()) error (SWT.ERROR_INVALID_ARGUMENT);
1407-
return false;
1407+
// Print only the client area (children) without shell decorations
1408+
Control [] children = _getChildren ();
1409+
for (Control child : children) {
1410+
Rectangle bounds = child.getBounds();
1411+
// Save the graphics state before transforming
1412+
NSGraphicsContext.static_saveGraphicsState();
1413+
NSGraphicsContext.setCurrentContext(gc.handle);
1414+
// Create and apply translation transform for child's position
1415+
NSAffineTransform transform = NSAffineTransform.transform();
1416+
transform.translateXBy(bounds.x, bounds.y);
1417+
transform.concat();
1418+
// Print the child control
1419+
child.print(gc);
1420+
// Restore the graphics state
1421+
NSGraphicsContext.static_restoreGraphicsState();
1422+
}
1423+
return true;
14081424
}
14091425

14101426
@Override

0 commit comments

Comments
 (0)