diff options
author | Veronika Irvine <veronika> | 2006-02-09 19:22:34 +0000 |
---|---|---|
committer | Veronika Irvine <veronika> | 2006-02-09 19:22:34 +0000 |
commit | 063685a169683c6f9ba82158e73aa27116b562f1 (patch) | |
tree | 86a151c4119199d388afc3b0bae3b00440880e7f | |
parent | 8b07739025e4483fd6ae8247a0edcd7b527a4681 (diff) | |
download | eclipse.platform.swt-063685a169683c6f9ba82158e73aa27116b562f1.tar.gz eclipse.platform.swt-063685a169683c6f9ba82158e73aa27116b562f1.tar.xz eclipse.platform.swt-063685a169683c6f9ba82158e73aa27116b562f1.zip |
Bug 126966 can't set text or image asynchronously in virtual table or tree
4 files changed, 73 insertions, 11 deletions
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java index 1f6016153b..b6eb899d92 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Table.java @@ -228,7 +228,7 @@ int /*long*/ cellDataProc (int /*long*/ tree_column, int /*long*/ cell, int /*lo } if (setData) { ignoreCell = cell; - setScrollWidth (tree_column, iter); + setScrollWidth (tree_column, item); ignoreCell = 0; } return 0; @@ -2809,15 +2809,15 @@ public void setRedraw (boolean redraw) { } } -void setScrollWidth (int /*long*/ column, int /*long*/ iter) { - if (columnCount != 0) return; +void setScrollWidth (int /*long*/ column, TableItem item) { + if (columnCount != 0 || currentItem == item) return; /* * Use GTK_TREE_VIEW_COLUMN_GROW_ONLY on GTK versions < 2.3.2 * because fixed_height_mode is not supported. */ if (((style & SWT.VIRTUAL) != 0) && OS.GTK_VERSION < OS.VERSION (2, 3, 2)) return; - int width = OS.gtk_tree_view_column_get_width (column); - int itemWidth = calculateWidth (column, iter); + int width = OS.gtk_tree_view_column_get_fixed_width (column); + int itemWidth = calculateWidth (column, item.handle); if (width < itemWidth) { OS.gtk_tree_view_column_set_fixed_width (column, itemWidth); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java index 6a865550c3..833425884d 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/TableItem.java @@ -893,7 +893,7 @@ public void setGrayed (boolean grayed) { */ public void setImage (int index, Image image) { checkWidget (); - if (image != null && image.isDisposed()) { + if (image != null && image.isDisposed ()) { error(SWT.ERROR_INVALID_ARGUMENT); } int count = Math.max (1, parent.getColumnCount ()); @@ -908,6 +908,30 @@ public void setImage (int index, Image image) { } int modelIndex = parent.columnCount == 0 ? Table.FIRST_COLUMN : parent.columns [index].modelIndex; OS.gtk_list_store_set (parent.modelHandle, handle, modelIndex + Table.CELL_PIXBUF, pixbuf, -1); + if (image != null && parent.columnCount == 0) { + int /*long*/parentHandle = parent.handle; + int /*long*/ column = OS.gtk_tree_view_get_column (parentHandle, 0); + if (OS.gtk_tree_view_column_get_sizing (column) == OS.GTK_TREE_VIEW_COLUMN_FIXED) { + parent.setScrollWidth (column, this); + /* + * Bug in GTK. When in fixed height mode, GTK does not recalculate the cell renderer width + * when the image is changed in the model. The fix is to force it to recalculate the width if + * more space is required. + */ + int [] w = new int [1]; + int /*long*/ pixbufRenderer = parent.getPixbufRenderer(column); + OS.gtk_tree_view_column_cell_get_position (column, pixbufRenderer, null, w); + if (w[0] < image.getBounds().width) { + /* + * There is no direct way to clear the cell renderer width so we + * are relying on the fact that it is done as part of modifying + * the style. + */ + int /*long*/ style = OS.gtk_widget_get_modifier_style (parentHandle); + OS.gtk_widget_modify_style (parentHandle, style); + } + } + } cached = true; } @@ -980,6 +1004,13 @@ public void setText (int index, String string) { byte[] buffer = Converter.wcsToMbcs (null, string, true); int modelIndex = parent.columnCount == 0 ? Table.FIRST_COLUMN : parent.columns [index].modelIndex; OS.gtk_list_store_set (parent.modelHandle, handle, modelIndex + Table.CELL_TEXT, buffer, -1); + if (parent.columnCount == 0) { + int /*long*/parentHandle = parent.handle; + int /*long*/ column = OS.gtk_tree_view_get_column (parentHandle, 0); + if (OS.gtk_tree_view_column_get_sizing (column) == OS.GTK_TREE_VIEW_COLUMN_FIXED) { + parent.setScrollWidth (column, this); + } + } cached = true; } 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 b3a0ecfd57..8b293bc32a 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 @@ -259,7 +259,7 @@ int /*long*/ cellDataProc (int /*long*/ tree_column, int /*long*/ cell, int /*lo } if (setData) { ignoreCell = cell; - setScrollWidth (tree_column, iter); + setScrollWidth (tree_column, item); ignoreCell = 0; } return 0; @@ -2571,15 +2571,15 @@ void setParentWindow (int /*long*/ widget) { OS.gtk_widget_set_parent_window (widget, window); } -void setScrollWidth (int /*long*/ column, int /*long*/ iter) { - if (columnCount != 0) return; +void setScrollWidth (int /*long*/ column, TreeItem item) { + if (columnCount != 0 || currentItem == item) return; /* * Use GTK_TREE_VIEW_COLUMN_GROW_ONLY on GTK versions < 2.3.2 * because fixed_height_mode is not supported. */ if (((style & SWT.VIRTUAL) != 0) && OS.GTK_VERSION < OS.VERSION (2, 3, 2)) return; - int width = OS.gtk_tree_view_column_get_width (column); - int itemWidth = calculateWidth (column, iter); + int width = OS.gtk_tree_view_column_get_fixed_width (column); + int itemWidth = calculateWidth (column, item.handle); if (width < itemWidth) { OS.gtk_tree_view_column_set_fixed_width (column, itemWidth); } 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 bcf1ba836c..93716c44ab 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 @@ -1315,6 +1315,30 @@ public void setImage (int index, Image image) { } int modelIndex = parent.columnCount == 0 ? Tree.FIRST_COLUMN : parent.columns [index].modelIndex; OS.gtk_tree_store_set (parent.modelHandle, handle, modelIndex + Tree.CELL_PIXBUF, pixbuf, -1); + if (image != null && parent.columnCount == 0) { + int /*long*/parentHandle = parent.handle; + int /*long*/ column = OS.gtk_tree_view_get_column (parentHandle, 0); + if (OS.gtk_tree_view_column_get_sizing (column) == OS.GTK_TREE_VIEW_COLUMN_FIXED) { + parent.setScrollWidth (column, this); + /* + * Bug in GTK. When in fixed height mode, GTK does not recalculate the cell renderer width + * when the image is changed in the model. The fix is to force it to recalculate the width if + * more space is required. + */ + int [] w = new int [1]; + int /*long*/ pixbufRenderer = parent.getPixbufRenderer(column); + OS.gtk_tree_view_column_cell_get_position (column, pixbufRenderer, null, w); + if (w[0] < image.getBounds().width) { + /* + * There is no direct way to clear the cell renderer width so we + * are relying on the fact that it is done as part of modifying + * the style. + */ + int /*long*/ style = OS.gtk_widget_get_modifier_style (parentHandle); + OS.gtk_widget_modify_style (parentHandle, style); + } + } + } cached = true; } @@ -1377,6 +1401,13 @@ public void setText (int index, String string) { byte[] buffer = Converter.wcsToMbcs (null, string, true); int modelIndex = parent.columnCount == 0 ? Tree.FIRST_COLUMN : parent.columns [index].modelIndex; OS.gtk_tree_store_set (parent.modelHandle, handle, modelIndex + Tree.CELL_TEXT, buffer, -1); + if (parent.columnCount == 0) { + int /*long*/parentHandle = parent.handle; + int /*long*/ column = OS.gtk_tree_view_get_column (parentHandle, 0); + if (OS.gtk_tree_view_column_get_sizing (column) == OS.GTK_TREE_VIEW_COLUMN_FIXED) { + parent.setScrollWidth (column, this); + } + } cached = true; } |