Mercurial > projects > dwt-mac
diff dwt/widgets/TabItem.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/TabItem.d Tue Oct 21 15:20:04 2008 +0200 +++ b/dwt/widgets/TabItem.d Mon Dec 01 17:07:00 2008 +0100 @@ -1,5 +1,5 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 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 @@ -18,10 +18,12 @@ import dwt.graphics.Image; import dwt.graphics.Rectangle; import dwt.internal.cocoa.NSPoint; +import dwt.internal.cocoa.NSRect; import dwt.internal.cocoa.NSSize; import dwt.internal.cocoa.NSString; import dwt.internal.cocoa.NSTabViewItem; import dwt.internal.cocoa.NSValue; +import dwt.internal.cocoa.NSView; import dwt.internal.cocoa.NSWindow; import dwt.internal.cocoa.OS; @@ -37,6 +39,9 @@ * <p> * IMPORTANT: This class is <em>not</em> intended to be subclassed. * </p> + * + * @see <a href="http://www.eclipse.org/swt/snippets/#tabfolder">TabFolder, TabItem snippets</a> + * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> */ public class TabItem : Item { TabFolder parent; @@ -143,21 +148,21 @@ public Rectangle getBounds() { checkWidget(); Rectangle result = new Rectangle (0, 0, 0, 0); - if (nsItem.respondsToSelector (OS.sel_accessibilityAttributeValue_1)) { - int posValue = OS.objc_msgSend (nsItem.id, OS.sel_accessibilityAttributeValue_1, OS.NSAccessibilityPositionAttribute ()); - int sizeValue = OS.objc_msgSend (nsItem.id, OS.sel_accessibilityAttributeValue_1, OS.NSAccessibilitySizeAttribute ()); + if (nsItem.respondsToSelector (OS.sel_accessibilityAttributeValue_)) { + int /*long*/ posValue = OS.objc_msgSend (nsItem.id, OS.sel_accessibilityAttributeValue_, OS.NSAccessibilityPositionAttribute ()); + int /*long*/ sizeValue = OS.objc_msgSend (nsItem.id, OS.sel_accessibilityAttributeValue_, OS.NSAccessibilitySizeAttribute ()); NSValue val = new NSValue (posValue); NSPoint pt = val.pointValue (); NSWindow window = parent.view.window (); - pt.y = window.screen ().frame ().height - pt.y; + pt.y = display.getPrimaryFrame().height - pt.y; pt = parent.view.convertPoint_fromView_ (pt, null); pt = window.convertScreenToBase (pt); result.x = cast(int) pt.x; result.y = cast(int) pt.y; val = new NSValue (sizeValue); NSSize size = val.sizeValue (); - result.width = cast(int) size.width; - result.height = cast(int) size.height; + result.width = cast(int) Math.ceil (size.width); + result.height = cast(int) Math.ceil (size.height); } return result; } @@ -259,14 +264,21 @@ int index = parent.indexOf (this); if (index !is parent.getSelectionIndex ()) { if (newControl !is null) newControl.setVisible (false); - return; + } else { + if (newControl !is null) { + newControl.setVisible (true); + } + if (oldControl !is null) oldControl.setVisible (false); } + NSView view; if (newControl !is null) { -// nsItem.setView(control.topView ()); - newControl.setBounds (parent.getClientArea ()); - newControl.setVisible (true); + view = newControl.topView(); + } else { + view = (NSView)new NSView().alloc(); + view.initWithFrame (new NSRect()); + view.autorelease(); } - if (oldControl !is null) oldControl.setVisible (false); + nsItem.setView (view); } public void setImage (Image image) {