Mercurial > projects > dwt-linux
comparison dwt/widgets/Table.d @ 240:ce446666f5a2
Update to SWT 3.4M7
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 12 May 2008 19:13:01 +0200 |
parents | 380bad9f6852 |
children | 5a30aa9820f3 |
comparison
equal
deleted
inserted
replaced
239:06a1f6829310 | 240:ce446666f5a2 |
---|---|
182 return items [index] = new TableItem (this, DWT.NONE, index, false); | 182 return items [index] = new TableItem (this, DWT.NONE, index, false); |
183 } | 183 } |
184 | 184 |
185 static int checkStyle (int style) { | 185 static int checkStyle (int style) { |
186 /* | 186 /* |
187 * To be compatible with Windows, force the H_SCROLL | 187 * Feature in Windows. Even when WS_HSCROLL or |
188 * and V_SCROLL style bits. On Windows, it is not | 188 * WS_VSCROLL is not specified, Windows creates |
189 * possible to create a table without scroll bars. | 189 * trees and tables with scroll bars. The fix |
190 * is to set H_SCROLL and V_SCROLL. | |
191 * | |
192 * NOTE: This code appears on all platforms so that | |
193 * applications have consistent scroll bar behavior. | |
190 */ | 194 */ |
191 style |= DWT.H_SCROLL | DWT.V_SCROLL; | 195 if ((style & DWT.NO_SCROLL) is 0) { |
196 style |= DWT.H_SCROLL | DWT.V_SCROLL; | |
197 } | |
192 /* GTK is always FULL_SELECTION */ | 198 /* GTK is always FULL_SELECTION */ |
193 style |= DWT.FULL_SELECTION; | 199 style |= DWT.FULL_SELECTION; |
194 return checkBits (style, DWT.SINGLE, DWT.MULTI, 0, 0, 0, 0); | 200 return checkBits (style, DWT.SINGLE, DWT.MULTI, 0, 0, 0, 0); |
195 } | 201 } |
196 | 202 |
1151 int width = (state & ZERO_WIDTH) !is 0 ? 0 : OS.GTK_WIDGET_WIDTH (clientHandle); | 1157 int width = (state & ZERO_WIDTH) !is 0 ? 0 : OS.GTK_WIDGET_WIDTH (clientHandle); |
1152 int height = (state & ZERO_HEIGHT) !is 0 ? 0 : OS.GTK_WIDGET_HEIGHT (clientHandle); | 1158 int height = (state & ZERO_HEIGHT) !is 0 ? 0 : OS.GTK_WIDGET_HEIGHT (clientHandle); |
1153 return new Rectangle (fixedX - binX, fixedY - binY, width, height); | 1159 return new Rectangle (fixedX - binX, fixedY - binY, width, height); |
1154 } | 1160 } |
1155 | 1161 |
1162 int getClientWidth () { | |
1163 int w, h; | |
1164 OS.gtk_widget_realize (handle); | |
1165 OS.gdk_drawable_get_size(OS.gtk_tree_view_get_bin_window(handle), &w, &h); | |
1166 return w; | |
1167 } | |
1168 | |
1156 /** | 1169 /** |
1157 * Returns the column at the given, zero-relative index in the | 1170 * Returns the column at the given, zero-relative index in the |
1158 * receiver. Throws an exception if the index is out of range. | 1171 * receiver. Throws an exception if the index is out of range. |
1159 * Columns are returned in the order that they were created. | 1172 * Columns are returned in the order that they were created. |
1160 * If no <code>TableColumn</code>s were created by the programmer, | 1173 * If no <code>TableColumn</code>s were created by the programmer, |
2360 if (item !is null && !item.isDisposed ()) item.release (false); | 2373 if (item !is null && !item.isDisposed ()) item.release (false); |
2361 --index; | 2374 --index; |
2362 } | 2375 } |
2363 items = new TableItem [4]; | 2376 items = new TableItem [4]; |
2364 itemCount = 0; | 2377 itemCount = 0; |
2365 | |
2366 /* | |
2367 * Bug in GTK. In version 2.3.2, when the property fixed-height-mode | |
2368 * is set and there are items in the list, OS.gtk_list_store_clear() | |
2369 * segment faults. The fix is to create a new empty model instead. | |
2370 */ | |
2371 auto selection = OS.gtk_tree_view_get_selection (handle); | 2378 auto selection = OS.gtk_tree_view_get_selection (handle); |
2372 OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udCHANGED); | 2379 OS.g_signal_handlers_block_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udCHANGED); |
2373 // OS.gtk_list_store_clear (modelHandle); | 2380 OS.gtk_list_store_clear (modelHandle); |
2374 auto oldModel = modelHandle; | |
2375 auto types = getColumnTypes (Math.max (1,columnCount)); | |
2376 auto newModel = OS.gtk_list_store_newv (types.length, types.ptr); | |
2377 if (newModel is null) error (DWT.ERROR_NO_HANDLES); | |
2378 OS.gtk_tree_view_set_model (handle, newModel); | |
2379 OS.g_object_unref (oldModel); | |
2380 modelHandle = cast(GtkWidget*)newModel; | |
2381 OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udCHANGED); | 2381 OS.g_signal_handlers_unblock_matched (selection, OS.G_SIGNAL_MATCH_DATA, 0, 0, null, null, udCHANGED); |
2382 | 2382 |
2383 resetCustomDraw (); | 2383 resetCustomDraw (); |
2384 /* Disable searching when using VIRTUAL */ | 2384 /* Disable searching when using VIRTUAL */ |
2385 if ((style & DWT.VIRTUAL) !is 0) { | 2385 if ((style & DWT.VIRTUAL) !is 0) { |
2483 event.width = contentWidth; | 2483 event.width = contentWidth; |
2484 event.height = contentHeight; | 2484 event.height = contentHeight; |
2485 sendEvent (DWT.MeasureItem, event); | 2485 sendEvent (DWT.MeasureItem, event); |
2486 gc.dispose (); | 2486 gc.dispose (); |
2487 contentWidth = event.width - imageWidth; | 2487 contentWidth = event.width - imageWidth; |
2488 contentHeight = event.height; | 2488 if (contentHeight < event.height) contentHeight = event.height; |
2489 if (width !is null) *width = contentWidth; | 2489 if (width !is null) *width = contentWidth; |
2490 if (height !is null) *height = contentHeight; | 2490 if (height !is null) *height = contentHeight; |
2491 } | 2491 } |
2492 } | 2492 } |
2493 } | 2493 } |
2560 } else { | 2560 } else { |
2561 gc.setBackground (item.getBackground (columnIndex)); | 2561 gc.setBackground (item.getBackground (columnIndex)); |
2562 gc.setForeground (item.getForeground (columnIndex)); | 2562 gc.setForeground (item.getForeground (columnIndex)); |
2563 } | 2563 } |
2564 gc.setFont (item.getFont (columnIndex)); | 2564 gc.setFont (item.getFont (columnIndex)); |
2565 if ((style & DWT.MIRRORED) !is 0) rect.x = getClientWidth () - rect.width - rect.x; | |
2565 gc.setClipping (rect.x, rect.y, rect.width, rect.height); | 2566 gc.setClipping (rect.x, rect.y, rect.width, rect.height); |
2566 Event event = new Event (); | 2567 Event event = new Event (); |
2567 event.item = item; | 2568 event.item = item; |
2568 event.index = columnIndex; | 2569 event.index = columnIndex; |
2569 event.gc = gc; | 2570 event.gc = gc; |
2632 gc.setBackground (item.getBackground (columnIndex)); | 2633 gc.setBackground (item.getBackground (columnIndex)); |
2633 Color foreground = drawForeground !is null ? Color.gtk_new (display, drawForeground) : item.getForeground (columnIndex); | 2634 Color foreground = drawForeground !is null ? Color.gtk_new (display, drawForeground) : item.getForeground (columnIndex); |
2634 gc.setForeground (foreground); | 2635 gc.setForeground (foreground); |
2635 } | 2636 } |
2636 gc.setFont (item.getFont (columnIndex)); | 2637 gc.setFont (item.getFont (columnIndex)); |
2638 if ((style & DWT.MIRRORED) !is 0) rect.x = getClientWidth () - rect.width - rect.x; | |
2637 gc.setClipping (rect.x, rect.y, rect.width, rect.height); | 2639 gc.setClipping (rect.x, rect.y, rect.width, rect.height); |
2638 Event event = new Event (); | 2640 Event event = new Event (); |
2639 event.item = item; | 2641 event.item = item; |
2640 event.index = columnIndex; | 2642 event.index = columnIndex; |
2641 event.gc = gc; | 2643 event.gc = gc; |