Mercurial > projects > dwt-addons
diff dwtx/jface/fieldassist/ComboContentAdapter.d @ 70:46a6e0e6ccd4
Merge with d-fied sources of 3.4M7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Thu, 22 May 2008 01:36:46 +0200 |
parents | f12d40e7da8f |
children | 5df4896124c7 |
line wrap: on
line diff
--- a/dwtx/jface/fieldassist/ComboContentAdapter.d Mon May 19 13:41:06 2008 +0200 +++ b/dwtx/jface/fieldassist/ComboContentAdapter.d Thu May 22 01:36:46 2008 +0200 @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. + * Copyright (c) 2005, 2007 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 @@ -12,6 +12,7 @@ *******************************************************************************/ module dwtx.jface.fieldassist.ComboContentAdapter; +import dwt.DWT; import dwtx.jface.fieldassist.IControlContentAdapter; import dwt.graphics.GC; @@ -30,7 +31,18 @@ * * @since 3.2 */ -public class ComboContentAdapter : IControlContentAdapter { +public class ComboContentAdapter : IControlContentAdapter, + IControlContentAdapter2 { + + /* + * Set to <code>true</code> if we should compute the text + * vertical bounds rather than just use the field size. + * Workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=164748 + * The corresponding DWT bug is + * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44072 + */ + private static final bool COMPUTE_TEXT_USING_CLIENTAREA = !"carbon".equals(DWT.getPlatform()); //$NON-NLS-1$ + /* * (non-Javadoc) @@ -92,6 +104,8 @@ * @see dwtx.jface.fieldassist.IControlContentAdapter#getInsertionBounds(dwt.widgets.Control) */ public Rectangle getInsertionBounds(Control control) { + // This doesn't take horizontal scrolling into affect. + // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=204599 Combo combo = cast(Combo) control; int position = combo.getSelection().y; String contents = combo.getText(); @@ -100,8 +114,11 @@ Point extent = gc.textExtent(contents.substring(0, Math.min(position, contents.length))); gc.dispose(); - return new Rectangle(combo.getClientArea().x + extent.x, combo + if (COMPUTE_TEXT_USING_CLIENTAREA) { + return new Rectangle(combo.getClientArea().x + extent.x, combo .getClientArea().y, 1, combo.getClientArea().height); + } + return new Rectangle(extent.x, 0, 1, combo.getSize().y); } /* @@ -114,4 +131,27 @@ (cast(Combo) control).setSelection(new Point(index, index)); } + /* + * (non-Javadoc) + * + * @see dwtx.jface.fieldassist.IControlContentAdapter2#getSelection(dwt.widgets.Control) + * + * @since 3.4 + */ + public Point getSelection(Control control) { + return ((Combo) control).getSelection(); + } + + /* + * (non-Javadoc) + * + * @see dwtx.jface.fieldassist.IControlContentAdapter2#setSelection(dwt.widgets.Control, + * dwt.graphics.Point) + * + * @since 3.4 + */ + public void setSelection(Control control, Point range) { + ((Combo) control).setSelection(range); + } + }