diff options
author | Steve Northover <steve> | 2004-05-26 22:04:16 +0000 |
---|---|---|
committer | Steve Northover <steve> | 2004-05-26 22:04:16 +0000 |
commit | 080b55c089b6da213622973bb9a887999c3981a8 (patch) | |
tree | 83f28b950b36d1b060fddf54351f6787b2ae400d | |
parent | 165b235abe4afb372cafc0a5219ce04d60acea0b (diff) | |
download | eclipse.platform.swt-080b55c089b6da213622973bb9a887999c3981a8.tar.gz eclipse.platform.swt-080b55c089b6da213622973bb9a887999c3981a8.tar.xz eclipse.platform.swt-080b55c089b6da213622973bb9a887999c3981a8.zip |
7845
5 files changed, 61 insertions, 10 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java index 5395a3ed77..d05263de29 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Button.java @@ -176,7 +176,7 @@ public Point computeSize (int wHint, int hHint, boolean changed) { int [] argList1 = {OS.XmNlabelString, 0}; OS.XtGetValues (handle, argList1, argList1.length / 2); int xmString = argList1 [1]; - if (OS.XmStringEmpty (xmString)) height += getFontHeight (); + if (OS.XmStringEmpty (xmString)) height += getFontHeight (font.handle); if (xmString != 0) OS.XmStringFree (xmString); } if (wHint != SWT.DEFAULT || hHint != SWT.DEFAULT) { diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java index 011a4de1c0..b9f7dca776 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Combo.java @@ -54,6 +54,8 @@ import org.eclipse.swt.events.*; * @see List */ public class Combo extends Composite { + int visibleCount = 5; + /** * the operating system limit for the number of characters * that the text field in an instance of this class can hold @@ -537,11 +539,11 @@ public int getItemHeight () { checkWidget(); int [] listHandleArgs = {OS.XmNlist, 0}; OS.XtGetValues (handle, listHandleArgs, listHandleArgs.length / 2); - int [] argList = {OS.XmNlistSpacing, 0, OS.XmNhighlightThickness, 0}; + int [] argList = {OS.XmNlistSpacing, 0, OS.XmNhighlightThickness, 0, OS.XmNfontList, 0}; OS.XtGetValues (listHandleArgs[1], argList, argList.length / 2); - int spacing = argList [1], highlight = argList [3]; + int spacing = argList [1], highlight = argList [3], fontList = argList [5]; /* Result is from empirical analysis on Linux and AIX */ - return getFontHeight () + spacing + (2 * highlight); + return getFontHeight (fontList) + spacing + (2 * highlight); } /** * Returns an array of <code>String</code>s which are the items @@ -720,7 +722,7 @@ public int getTextHeight () { OS.XtGetValues (handle, argList, argList.length / 2); int [] argList2 = {OS.XmNmarginHeight, 0}; OS.XtGetValues (argList[1], argList2, argList2.length / 2); - int height = getFontHeight (); + int height = getFontHeight (font.handle); XRectangle rect = new XRectangle (); OS.XmWidgetGetDisplayRect (argList[1], rect); height += (rect.y * 2) + (2 * argList2[1]); @@ -752,6 +754,26 @@ public int getTextLimit () { OS.XtGetValues (handle, argList, argList.length / 2); return OS.XmTextGetMaxLength (argList[1]); } +/** + * Gets the number of items that are visible in the drop + * down portion of the receiver's list. + * + * @return the number of items that are visible + * + * @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.0 + */ +public int getVisibleCount () { + checkWidget (); + if ((style & SWT.SIMPLE) != 0) return visibleCount; + int [] argList = new int [] {OS.XmNvisibleItemCount, 0}; + OS.XtGetValues (handle, argList, argList.length / 2); + return argList [1]; +} void hookEvents () { super.hookEvents (); int windowProc = display.windowProc; @@ -1375,7 +1397,36 @@ public void setTextLimit (int limit) { OS.XtGetValues (handle, argList, argList.length / 2); OS.XmTextSetMaxLength (argList[1], limit); } - +/** + * Sets the number of items that are visible in the drop + * down portion of the receiver's list. + * + * @param count the new number of items to be visible + * + * @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.0 + */ +public void setVisibleCount (int count) { + checkWidget (); + if (count < 0) return; + this.visibleCount = count; + /* + * But in Motif. Setting the XmNvisibleItemCount resource + * for the combo box after it has been realized causes the + * widget is layout badly, sometimes moving the drop down + * arrow part of the combo box outside of the bounds. + * The fix is to set the XmNvisibleItemCount resource on + * the list instead. + */ + int [] argList1 = new int [] {OS.XmNlist, 0}; + OS.XtGetValues (handle, argList1, argList1.length / 2); + int [] argList2 = {OS.XmNvisibleItemCount, count}; + OS.XtSetValues (argList1 [1], argList2, argList2.length / 2); +} void deregister () { super.deregister (); int [] argList = {OS.XmNtextField, 0}; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java index 8677929890..f756e00f89 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Control.java @@ -745,11 +745,11 @@ int getFontAscent (int font) { return ascent; } -int getFontHeight () { +int getFontHeight (int font) { /* Create a font context to iterate over each element in the font list */ int [] buffer = new int [1]; - if (!OS.XmFontListInitFontContext (buffer, font.handle)) { + if (!OS.XmFontListInitFontContext (buffer, font)) { error (SWT.ERROR_NO_HANDLES); } int context = buffer [0]; diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/List.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/List.java index 3791695c6e..393d7abf2f 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/List.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/List.java @@ -499,7 +499,7 @@ public int getItemHeight () { int spacing = argList [1], highlight = argList [3]; /* Result is from empirical analysis on Linux and AIX */ - return getFontHeight () + spacing + highlight + 1; + return getFontHeight (font.handle) + spacing + highlight + 1; } /** * Returns an array of <code>String</code>s which are the items diff --git a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java index def7c66c61..cb4912050b 100755 --- a/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/motif/org/eclipse/swt/widgets/Text.java @@ -585,7 +585,7 @@ public String getLineDelimiter () { */ public int getLineHeight () { checkWidget(); - return getFontHeight (); + return getFontHeight (font.handle); } int getLineNumber (int position) { if (position == 0) return 0; |