Mercurial > projects > dwt-win
comparison dwt/widgets/Table.d @ 246:fd9c62a2998e
Updater SWT 3.4M7 to 3.4
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Tue, 01 Jul 2008 10:15:59 +0200 |
parents | ecb80b2a89e1 |
children | b3dbd786541a |
comparison
equal
deleted
inserted
replaced
245:d8c3d4a4f2b0 | 246:fd9c62a2998e |
---|---|
1 /******************************************************************************* | 1 /******************************************************************************* |
2 * Copyright (c) 2000, 2007 IBM Corporation and others. | 2 * Copyright (c) 2000, 2008 IBM Corporation and others. |
3 * All rights reserved. This program and the accompanying materials | 3 * All rights reserved. This program and the accompanying materials |
4 * are made available under the terms of the Eclipse Public License v1.0 | 4 * are made available under the terms of the Eclipse Public License v1.0 |
5 * which accompanies this distribution, and is available at | 5 * which accompanies this distribution, and is available at |
6 * http://www.eclipse.org/legal/epl-v10.html | 6 * http://www.eclipse.org/legal/epl-v10.html |
7 * | 7 * |
21 import dwt.graphics.GCData; | 21 import dwt.graphics.GCData; |
22 import dwt.graphics.Image; | 22 import dwt.graphics.Image; |
23 import dwt.graphics.Point; | 23 import dwt.graphics.Point; |
24 import dwt.graphics.Rectangle; | 24 import dwt.graphics.Rectangle; |
25 import dwt.internal.ImageList; | 25 import dwt.internal.ImageList; |
26 import dwt.internal.win32.BITMAPINFOHEADER; | |
26 import dwt.internal.win32.OS; | 27 import dwt.internal.win32.OS; |
27 | 28 |
28 import dwt.widgets.Composite; | 29 import dwt.widgets.Composite; |
29 import dwt.widgets.TableItem; | 30 import dwt.widgets.TableItem; |
30 import dwt.widgets.TableColumn; | 31 import dwt.widgets.TableColumn; |
80 * </p><p> | 81 * </p><p> |
81 * Note: Only one of the styles SINGLE, and MULTI may be specified. | 82 * Note: Only one of the styles SINGLE, and MULTI may be specified. |
82 * </p><p> | 83 * </p><p> |
83 * IMPORTANT: This class is <em>not</em> intended to be subclassed. | 84 * IMPORTANT: This class is <em>not</em> intended to be subclassed. |
84 * </p> | 85 * </p> |
86 * | |
87 * @see <a href="http://www.eclipse.org/swt/snippets/#table">Table, TableItem, TableColumn snippets</a> | |
88 * @see <a href="http://www.eclipse.org/swt/examples.php">DWT Example: ControlExample</a> | |
89 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a> | |
85 */ | 90 */ |
86 | 91 |
87 public class Table : Composite { | 92 public class Table : Composite { |
88 | 93 |
89 alias Composite.computeSize computeSize; | 94 alias Composite.computeSize computeSize; |
110 static const int SORT_WIDTH = 10; | 115 static const int SORT_WIDTH = 10; |
111 static const int HEADER_MARGIN = 12; | 116 static const int HEADER_MARGIN = 12; |
112 static const int HEADER_EXTRA = 3; | 117 static const int HEADER_EXTRA = 3; |
113 static const int VISTA_EXTRA = 2; | 118 static const int VISTA_EXTRA = 2; |
114 static const int EXPLORER_EXTRA = 2; | 119 static const int EXPLORER_EXTRA = 2; |
115 static final int H_SCROLL_LIMIT = 32; | 120 static const int H_SCROLL_LIMIT = 32; |
116 static final int V_SCROLL_LIMIT = 16; | 121 static const int V_SCROLL_LIMIT = 16; |
122 static const int DRAG_IMAGE_SIZE = 301; | |
117 static const bool EXPLORER_THEME = true; | 123 static const bool EXPLORER_THEME = true; |
118 private static /+const+/ WNDPROC TableProc; | 124 private static /+const+/ WNDPROC TableProc; |
119 static const TCHAR[] TableClass = OS.WC_LISTVIEW; | 125 static const TCHAR[] TableClass = OS.WC_LISTVIEW; |
120 | 126 |
121 private static bool static_this_completed = false; | 127 private static bool static_this_completed = false; |
5425 } | 5431 } |
5426 return callWindowProc (hwnd, msg, wParam, lParam); | 5432 return callWindowProc (hwnd, msg, wParam, lParam); |
5427 } | 5433 } |
5428 if (msg is Display.DI_GETDRAGIMAGE) { | 5434 if (msg is Display.DI_GETDRAGIMAGE) { |
5429 /* | 5435 /* |
5430 * Bug in Windows. For some reason, DI_GETDRAGIMAGE | 5436 * Bug in Windows. On Vista, for some reason, DI_GETDRAGIMAGE |
5431 * returns an image that does not contain strings. | 5437 * returns an image that does not contain strings. |
5432 * The fix is to disable the table window proc. | |
5433 * | 5438 * |
5434 * NOTE: This only happens on Vista. | 5439 * Bug in Windows. For custom draw control the window origin the |
5440 * in HDC is wrong. | |
5441 * | |
5442 * The fix for both cases is to create the image using PrintWindow(). | |
5435 */ | 5443 */ |
5436 if (!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) return 0; | 5444 if ((!OS.IsWinCE && OS.WIN32_VERSION >= OS.VERSION (6, 0)) || hooks (DWT.EraseItem) || hooks (DWT.PaintItem)) { |
5437 //TEMPORARY CODE | 5445 int topIndex = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETTOPINDEX, 0, 0); |
5438 if (hooks (DWT.EraseItem) || hooks (DWT.PaintItem)) return 0; | 5446 int selection = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETNEXTITEM, topIndex - 1, OS.LVNI_SELECTED); |
5439 // if (getSelectionCount () !is 1) return 0; | 5447 if (selection is -1) return 0; |
5448 POINT mousePos = new POINT (); | |
5449 OS.POINTSTOPOINT (mousePos, OS.GetMessagePos ()); | |
5450 OS.MapWindowPoints(0, handle, mousePos, 1); | |
5451 RECT clientRect = new RECT (); | |
5452 OS.GetClientRect (handle, clientRect); | |
5453 TableItem item = _getItem (selection); | |
5454 RECT rect = item.getBounds (selection, 0, true, true, true); | |
5455 if ((style & DWT.FULL_SELECTION) !is 0) { | |
5456 int width = DRAG_IMAGE_SIZE; | |
5457 rect.left = Math.max (clientRect.left, mousePos.x - width / 2); | |
5458 if (clientRect.right > rect.left + width) { | |
5459 rect.right = rect.left + width; | |
5460 } else { | |
5461 rect.right = clientRect.right; | |
5462 rect.left = Math.max (clientRect.left, rect.right - width); | |
5463 } | |
5464 } | |
5465 int /*long*/ hRgn = OS.CreateRectRgn (rect.left, rect.top, rect.right, rect.bottom); | |
5466 while ((selection = (int)/*64*/OS.SendMessage (handle, OS.LVM_GETNEXTITEM, selection, OS.LVNI_SELECTED)) !is -1) { | |
5467 if (rect.bottom - rect.top > DRAG_IMAGE_SIZE) break; | |
5468 if (rect.bottom > clientRect.bottom) break; | |
5469 RECT itemRect = item.getBounds (selection, 0, true, true, true); | |
5470 int /*long*/ rectRgn = OS.CreateRectRgn (rect.left, itemRect.top, rect.right, itemRect.bottom); | |
5471 OS.CombineRgn (hRgn, hRgn, rectRgn, OS.RGN_OR); | |
5472 OS.DeleteObject (rectRgn); | |
5473 rect.bottom = itemRect.bottom; | |
5474 } | |
5475 OS.GetRgnBox (hRgn, rect); | |
5476 | |
5477 /* Create resources */ | |
5478 int /*long*/ hdc = OS.GetDC (handle); | |
5479 int /*long*/ memHdc = OS.CreateCompatibleDC (hdc); | |
5480 BITMAPINFOHEADER bmiHeader = new BITMAPINFOHEADER (); | |
5481 bmiHeader.biSize = BITMAPINFOHEADER.sizeof; | |
5482 bmiHeader.biWidth = rect.right - rect.left; | |
5483 bmiHeader.biHeight = -(rect.bottom - rect.top); | |
5484 bmiHeader.biPlanes = 1; | |
5485 bmiHeader.biBitCount = 32; | |
5486 bmiHeader.biCompression = OS.BI_RGB; | |
5487 byte [] bmi = new byte [BITMAPINFOHEADER.sizeof]; | |
5488 OS.MoveMemory (bmi, bmiHeader, BITMAPINFOHEADER.sizeof); | |
5489 int /*long*/ [] pBits = new int /*long*/ [1]; | |
5490 int /*long*/ memDib = OS.CreateDIBSection (0, bmi, OS.DIB_RGB_COLORS, pBits, 0, 0); | |
5491 if (memDib is 0) DWT.error (DWT.ERROR_NO_HANDLES); | |
5492 int /*long*/ oldMemBitmap = OS.SelectObject (memHdc, memDib); | |
5493 int colorKey = 0x0000FD; | |
5494 POINT pt = new POINT(); | |
5495 OS.SetWindowOrgEx (memHdc, rect.left, rect.top, pt); | |
5496 OS.FillRect (memHdc, rect, findBrush (colorKey, OS.BS_SOLID)); | |
5497 OS.OffsetRgn (hRgn, -rect.left, -rect.top); | |
5498 OS.SelectClipRgn (memHdc, hRgn); | |
5499 OS.PrintWindow (handle, memHdc, 0); | |
5500 OS.SetWindowOrgEx (memHdc, pt.x, pt.y, null); | |
5501 OS.SelectObject (memHdc, oldMemBitmap); | |
5502 OS.DeleteDC (memHdc); | |
5503 OS.ReleaseDC (0, hdc); | |
5504 OS.DeleteObject (hRgn); | |
5505 | |
5506 SHDRAGIMAGE shdi = new SHDRAGIMAGE (); | |
5507 shdi.hbmpDragImage = memDib; | |
5508 shdi.crColorKey = colorKey; | |
5509 shdi.sizeDragImage.cx = bmiHeader.biWidth; | |
5510 shdi.sizeDragImage.cy = -bmiHeader.biHeight; | |
5511 shdi.ptOffset.x = mousePos.x - rect.left; | |
5512 shdi.ptOffset.y = mousePos.y - rect.top; | |
5513 if ((style & DWT.MIRRORED) !is 0) { | |
5514 shdi.ptOffset.x = shdi.sizeDragImage.cx - shdi.ptOffset.x; | |
5515 } | |
5516 OS.MoveMemory (lParam, shdi, SHDRAGIMAGE.sizeof); | |
5517 return 1; | |
5518 } | |
5440 } | 5519 } |
5441 return super.windowProc (hwnd, msg, wParam, lParam); | 5520 return super.windowProc (hwnd, msg, wParam, lParam); |
5442 } | 5521 } |
5443 | 5522 |
5444 override LRESULT WM_CHAR (int wParam, int lParam) { | 5523 override LRESULT WM_CHAR (int wParam, int lParam) { |