diff options
author | Veronika Irvine | 2004-02-06 20:43:29 +0000 |
---|---|---|
committer | Veronika Irvine | 2004-02-06 20:43:29 +0000 |
commit | 96ede35c1f9d62653b738a089c9e2401a818784e (patch) | |
tree | c1aa9e771cfb7d90e260cc3b67cf728989fca29d /bundles | |
parent | 7f69d9d27b56539c5108aaeac507347897bd0f38 (diff) | |
download | eclipse.platform.swt-96ede35c1f9d62653b738a089c9e2401a818784e.tar.gz eclipse.platform.swt-96ede35c1f9d62653b738a089c9e2401a818784e.tar.xz eclipse.platform.swt-96ede35c1f9d62653b738a089c9e2401a818784e.zip |
add TreeItem setFont/getFont
Diffstat (limited to 'bundles')
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java | 18 | ||||
-rw-r--r-- | bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java | 48 |
2 files changed, 59 insertions, 7 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java index c1eeb44116..01e87725cc 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Tree.java @@ -49,9 +49,10 @@ public class Tree extends Composite { static final int PIXBUF_COLUMN = 1; static final int FOREGROUND_COLUMN = 2; static final int BACKGROUND_COLUMN = 3; - static final int ID_COLUMN = 4; - static final int CHECKED_COLUMN = 5; - static final int GRAYED_COLUMN = 6; + static final int FONT_COLUMN = 4; + static final int ID_COLUMN = 5; + static final int CHECKED_COLUMN = 6; + static final int GRAYED_COLUMN = 7; /** * Constructs a new instance of this class given its parent @@ -178,15 +179,17 @@ void createHandle (int index) { * 1 - pixmap * 2 - foreground * 3 - background - * 4 - id - * 5 - checked (if needed) - * 6 - grayed (if needed) + * 4 - font + * 5 - id + * 6 - checked (if needed) + * 7 - grayed (if needed) */ - int [] types = new int [(style & SWT.CHECK) !=0 ? 7 : 5]; + int [] types = new int [(style & SWT.CHECK) !=0 ? 8 : 6]; types [TEXT_COLUMN] = OS.G_TYPE_STRING (); types [PIXBUF_COLUMN] = OS.GDK_TYPE_PIXBUF (); types [FOREGROUND_COLUMN] = OS.GDK_TYPE_COLOR (); types [BACKGROUND_COLUMN] = OS.GDK_TYPE_COLOR (); + types [FONT_COLUMN] = OS.PANGO_TYPE_FONT_DESCRIPTION (); types [ID_COLUMN] = OS.G_TYPE_INT (); if ((style & SWT.CHECK) != 0) { types [CHECKED_COLUMN] = OS.G_TYPE_BOOLEAN (); @@ -231,6 +234,7 @@ void createHandle (int index) { OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, "text", TEXT_COLUMN); OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, "foreground-gdk", FOREGROUND_COLUMN); OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, "background-gdk", BACKGROUND_COLUMN); + OS.gtk_tree_view_column_add_attribute (columnHandle, textRenderer, "font-desc", FONT_COLUMN); int parentHandle = parent.parentingHandle (); OS.gtk_container_add (parentHandle, fixedHandle); OS.gtk_container_add (fixedHandle, scrolledHandle); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java index f12531a333..ee893cf54b 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TreeItem.java @@ -274,6 +274,27 @@ public boolean getExpanded () { } /** + * Returns the font that the receiver will use to paint textual information for this item. + * + * @return the receiver's font + * + * @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 Font getFont () { + checkWidget (); + int [] ptr = new int [1]; + OS.gtk_tree_model_get (parent.modelHandle, handle, Tree.FONT_COLUMN, ptr, -1); + if (ptr [0] == 0) return parent.getFont (); + return Font.gtk_new (display, ptr[0]); +} + + +/** * Returns the foreground color that the receiver will use to draw. * * @return the receiver's foreground color @@ -499,6 +520,33 @@ public void setExpanded (boolean expanded) { OS.gtk_tree_path_free (path); } + +/** + * Sets the font that the receiver will use to paint textual information + * for this item to the font specified by the argument, or to the default font + * for that kind of control if the argument is null. + * + * @param font the new font (or null) + * + * @exception IllegalArgumentException <ul> + * <li>ERROR_INVALID_ARGUMENT - if the argument has been disposed</li> + * </ul> + * @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 setFont (Font font){ + checkWidget (); + if (font != null && font.isDisposed ()) { + SWT.error (SWT.ERROR_INVALID_ARGUMENT); + } + int fontHandle = font != null ? font.handle : 0; + OS.gtk_tree_store_set (parent.modelHandle, handle, Tree.FONT_COLUMN, fontHandle, -1); +} + /** * Sets the receiver's foreground color to the color specified * by the argument, or to the default system color for the item |