Mercurial > projects > dwt-mac
diff dwt/widgets/Group.d @ 45:d8635bb48c7c
Merge with SWT 3.5
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Mon, 01 Dec 2008 17:07:00 +0100 |
parents | e831403a80a9 |
children | cfa563df4fdd |
line wrap: on
line diff
--- a/dwt/widgets/Group.d Tue Oct 21 15:20:04 2008 +0200 +++ b/dwt/widgets/Group.d Mon Dec 01 17:07:00 2008 +0100 @@ -1,5 +1,5 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. +/******************************************************************************* + * Copyright (c) 2000, 2008 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -17,10 +17,12 @@ import dwt.DWTException; import dwt.graphics.Rectangle; import dwt.internal.cocoa.NSBox; +import dwt.internal.cocoa.NSFont; import dwt.internal.cocoa.NSRect; import dwt.internal.cocoa.NSSize; import dwt.internal.cocoa.NSString; import dwt.internal.cocoa.NSView; +import dwt.internal.cocoa.OS; import dwt.internal.cocoa.SWTBox; import dwt.internal.cocoa.SWTView; @@ -43,9 +45,12 @@ * </p><p> * IMPORTANT: This class is <em>not</em> intended to be subclassed. * </p> + * + * @see <a href="http://www.eclipse.org/swt/examples.php">DWT Example: ControlExample</a> + * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> */ public class Group : Composite { - SWTView contentView; + NSView contentView; String text = ""; /** @@ -103,10 +108,11 @@ public Rectangle computeTrim (int x, int y, int width, int height) { checkWidget (); NSBox widget = cast(NSBox)view; + int border = (int)Math.ceil (widget.borderWidth ()); NSSize margins = widget.contentViewMargins(); NSRect frame = contentView.frame(); - width += margins.width * 2; - height += margins.height * 2 + frame.y; + width += (margins.width + border) * 2; + height += (margins.height + border) * 2 + frame.y; return super.computeTrim(x, y, width, height); } @@ -114,19 +120,23 @@ return contentView; } +void deregister () { + super.deregister (); + display.removeWidget (contentView); + SWTBox box = (SWTBox)view; + display.removeWidget (box.titleCell()); +} + void createHandle () { - SWTBox widget = cast(SWTBox)new SWTBox().alloc(); + NSBox widget = cast(NSBox)(new SWTBox()).alloc(); widget.initWithFrame(new NSRect()); - widget.setTitle(NSString.stringWith("")); - widget.setTag(jniRef); - SWTView contentWidget = cast(SWTView)new SWTView().alloc(); + widget.setTitlePosition(OS.NSNoTitle); + NSView contentWidget = (NSView)new SWTView().alloc(); contentWidget.initWithFrame(new NSRect()); - contentWidget.setTag(jniRef); // contentWidget.setDrawsBackground(false); widget.setContentView(contentWidget); contentView = contentWidget; - view = widget; - parent.contentView().addSubview_(widget); + view = widget; } public Rectangle getClientArea () { @@ -156,15 +166,27 @@ return text; } +float getThemeAlpha () { + return 0.25f * parent.getThemeAlpha (); +} + +void register () { + super.register (); + display.addWidget (contentView, this); + SWTBox box = (SWTBox)view; + display.addWidget (box.titleCell(), this); +} + void releaseHandle () { super.releaseHandle (); - if (contentView !is null) { - contentView.setTag(-1); - contentView.release(); - } + if (contentView !is null) contentView.release(); contentView = null; } +void setFont(NSFont font) { + ((NSBox) view).setTitleFont(font); +} + /** * Sets the receiver's text, which is the string that will * be displayed as the receiver's <em>title</em>, to the argument, @@ -196,7 +218,9 @@ char [] buffer = new char [text.length ()]; text.getChars (0, buffer.length, buffer, 0); int length = fixMnemonic (buffer); - (cast(NSBox)view).setTitle(NSString.stringWithCharacters(buffer, length)); + NSBox box = cast(NSBox)view; + box.setTitlePosition(length is 0 ? OS.NSNoTitle : OS.NSAtTop); + box.setTitle(NSString.stringWithCharacters(buffer, length)); } }