Changeset 93
- Timestamp:
- 01/30/06 09:15:51 (3 years ago)
- Files:
-
- trunk/current/win32/import/dwt/widgets/table.d (modified) (24 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/current/win32/import/dwt/widgets/table.d
r82 r93 31 31 private import dwt.events.listeners; 32 32 private import dwt.util.util; 33 private import dwt.util.vector; 33 34 private import dwt.util.eventhandler; 34 35 … … 550 551 int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0); 551 552 int columnCount = count + 1; 552 if (count == 1 && columns [0] is null) count = 0;553 if (count == 1 && columns.length == 0) count = 0; 553 554 if (!(0 <= index && index <= count)) error(__FILE__, __LINE__, DWT.ERROR_INVALID_RANGE); 554 if (count == columns.length) { 555 TableColumn [] newColumns = new TableColumn [columns.length + 4]; 556 System.arraycopy (cast(Object[])columns, 0, cast(Object[])newColumns, 0, columns.length); 557 columns = newColumns; 558 } 555 556 // if (count == columns.length) { 557 // TableColumn [] newColumns = new TableColumn [columns.length + 4]; 558 // System.arraycopy (cast(Object[])columns, 0, cast(Object[])newColumns, 0, columns.length); 559 // columns = newColumns; 560 // } 559 561 int itemCount = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0); 560 562 for (int i=0; i<itemCount; i++) { … … 621 623 * or LVM_SETCOLUMN. 622 624 */ 623 System.arraycopy (columns, index, columns, index + 1, count - index); 624 columns [index] = column; 625 TVector!(TableColumn).insert(columns, column, index); 626 // System.arraycopy (columns, index, columns, index + 1, count - index); 627 // columns [index] = column; 625 628 if (index == 0) { 626 629 if (count > 0) { … … 722 725 super.createWidget (); 723 726 items = new TableItem [4]; 724 columns = new TableColumn [4];727 // columns = new TableColumn [4]; 725 728 } 726 729 … … 848 851 HWND hwndHeader = cast(HWND)OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0); 849 852 int columnCount = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0); 850 int index = 0; 851 while (index < columnCount) { 852 if (columns [index] is column) break; 853 index++; 854 } 853 854 int index = TVector!(TableColumn).indexOf(columns, column); 855 // int index = 0; 856 // while (index < columnCount) { 857 // if (columns [index] is column) break; 858 // index++; 859 // } 855 860 boolean first = false; 856 861 if (index == 0) { … … 894 899 } 895 900 if (first) index = 0; 896 System.arraycopy (columns, index + 1, columns, index, --columnCount - index); 897 columns [columnCount] = null; 901 902 TVector!(TableColumn).remove(columns, index); 903 // System.arraycopy (columns, index + 1, columns, index, --columnCount - index); 904 // columns [columnCount] = null; 905 898 906 int itemCount = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0); 899 907 for (int i=0; i<itemCount; i++) { … … 980 988 HWND hwndHeader = cast(HWND)OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0); 981 989 int columnCount = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0); 982 if (columnCount == 1 && columns [0] is null) columnCount = 0;990 if (columnCount == 1 && columns.length == 0) columnCount = 0; 983 991 int i = 0; 984 992 while (i < columnCount) { … … 1046 1054 HWND hwndHeader = cast(HWND)OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0); 1047 1055 int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0); 1048 if (count == 1 && columns [0] is null) count = 0;1056 if (count == 1 && columns.length == 0) count = 0; 1049 1057 if (!(0 <= index && index < count)) error(__FILE__, __LINE__, DWT.ERROR_INVALID_RANGE); 1050 1058 return columns [index]; … … 1072 1080 HWND hwndHeader = cast(HWND)OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0); 1073 1081 int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0); 1074 if (count == 1 && columns [0] is null) count = 0;1082 if (count == 1 && columns.length == 0) count = 0; 1075 1083 return count; 1076 1084 } … … 1100 1108 HWND hwndHeader = cast(HWND)OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0); 1101 1109 int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0); 1102 if (count == 1 && columns [0] is null) count = 0; 1103 TableColumn [] result = new TableColumn [count]; 1104 System.arraycopy (columns, 0, result, 0, count); 1105 return result; 1110 if (count == 1 && columns.length == 0) count = 0; 1111 1112 return columns.dup; 1106 1113 } 1107 1114 … … 1546 1553 checkWidget (); 1547 1554 if (column is null) error(__FILE__, __LINE__, DWT.ERROR_NULL_ARGUMENT); 1548 HWND hwndHeader = cast(HWND)OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0); 1549 int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0); 1550 for (int i=0; i<count; i++) { 1551 if (columns [i] is column) return i; 1552 } 1553 return -1; 1555 1556 return TVector!(TableColumn).indexOf(columns, column); 1557 1558 // HWND hwndHeader = cast(HWND)OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0); 1559 // int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0); 1560 // for (int i=0; i<count; i++) { 1561 // if (columns [i] is column) return i; 1562 // } 1563 // return -1; 1554 1564 } 1555 1565 … … 1618 1628 HWND hwndHeader = cast(HWND)OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0); 1619 1629 int columnCount = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0); 1620 if (columnCount == 1 && columns [0] is null) columnCount = 0;1621 for (int i=0; i<column Count; i++) {1630 if (columnCount == 1 && columns.length == 0) columnCount = 0; 1631 for (int i=0; i<columns.length; i++) { 1622 1632 TableColumn column = columns [i]; 1623 1633 if (!column.isDisposed ()) column.releaseResources (); … … 1809 1819 HWND hwndHeader = cast(HWND)OS.SendMessage (handle, OS.LVM_GETHEADER, 0, 0); 1810 1820 int columnCount = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0); 1811 if (columnCount == 1 && columns [0] is null) columnCount = 0;1821 if (columnCount == 1 && columns.length == 0) columnCount = 0; 1812 1822 int itemCount = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0); 1813 1823 … … 1864 1874 if (imageList !is null) { 1865 1875 int i = 0; 1866 while (i < column Count) {1876 while (i < columns.length) { 1867 1877 TableColumn column = columns [i]; 1868 1878 if (column.getImage () !is null) break; … … 1931 1941 int length = indices.length; 1932 1942 if (length == 0 || ((style & DWT.SINGLE) != 0 && length > 1)) return; 1933 LVITEM * lvItem = new LVITEM ();1943 LVITEM lvItem; 1934 1944 lvItem.state = OS.LVIS_SELECTED; 1935 1945 lvItem.stateMask = OS.LVIS_SELECTED; … … 1941 1951 if (indices [i] >= 0) { 1942 1952 ignoreSelect = true; 1943 OS.SendMessage (handle, OS.LVM_SETITEMSTATE, indices [i], lvItem);1953 OS.SendMessage (handle, OS.LVM_SETITEMSTATE, indices [i], &lvItem); 1944 1954 ignoreSelect = false; 1945 1955 } … … 1966 1976 */ 1967 1977 if (index < 0) return; 1968 LVITEM * lvItem = new LVITEM ();1978 LVITEM lvItem; 1969 1979 lvItem.state = OS.LVIS_SELECTED; 1970 1980 lvItem.stateMask = OS.LVIS_SELECTED; 1971 1981 ignoreSelect = true; 1972 OS.SendMessage (handle, OS.LVM_SETITEMSTATE, index, lvItem);1982 OS.SendMessage (handle, OS.LVM_SETITEMSTATE, index, &lvItem); 1973 1983 ignoreSelect = false; 1974 1984 } … … 2010 2020 * items. Indices must be greater than -1. 2011 2021 */ 2012 LVITEM * lvItem = new LVITEM ();2022 LVITEM lvItem; 2013 2023 lvItem.state = OS.LVIS_SELECTED; 2014 2024 lvItem.stateMask = OS.LVIS_SELECTED; 2015 2025 for (int i=start; i<=end; i++) { 2016 2026 ignoreSelect = true; 2017 OS.SendMessage (handle, OS.LVM_SETITEMSTATE, i, lvItem);2027 OS.SendMessage (handle, OS.LVM_SETITEMSTATE, i, &lvItem); 2018 2028 ignoreSelect = false; 2019 2029 } … … 2034 2044 checkWidget (); 2035 2045 if ((style & DWT.SINGLE) != 0) return; 2036 LVITEM * lvItem = new LVITEM ();2046 LVITEM lvItem; 2037 2047 lvItem.mask = OS.LVIF_STATE; 2038 2048 lvItem.state = OS.LVIS_SELECTED; 2039 2049 lvItem.stateMask = OS.LVIS_SELECTED; 2040 2050 ignoreSelect = true; 2041 OS.SendMessage (handle, OS.LVM_SETITEMSTATE, -1, lvItem);2051 OS.SendMessage (handle, OS.LVM_SETITEMSTATE, -1, &lvItem); 2042 2052 ignoreSelect = false; 2043 2053 } … … 2502 2512 * LVM_SETCOUMNWIDTH with LVSCW_AUTOSIZE. 2503 2513 */ 2504 if (count == 1 && columns [0] is null) {2514 if (count == 1 && columns.length == 0) { 2505 2515 int newWidth = 0; 2506 2516 count = OS.SendMessage (handle, OS.LVM_GETITEMCOUNT, 0, 0); … … 3176 3186 case OS.HDN_DIVIDERDBLCLICKW: 3177 3187 case OS.HDN_DIVIDERDBLCLICKA:{ 3178 NMHEADER* phdn = new NMHEADER (); 3179 OS.MoveMemory (phdn, lParam, NMHEADER.sizeof); 3188 NMHEADER* phdn = cast(NMHEADER*)lParam; 3180 3189 TableColumn column = columns [phdn.iItem]; 3181 3190 if (column !is null && !column.getResizable ()) { … … 3223 3232 if (isDisposed ()) return LDWTRESULT.ZERO; 3224 3233 int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0); 3225 if (count == 1 && columns [0] is null) count = 0;3234 if (count == 1 && columns.length == 0) count = 0; 3226 3235 /* 3227 3236 * It is possible (but unlikely), that application … … 3230 3239 * for those columns that have not been destroyed. 3231 3240 */ 3232 TableColumn [] newColumns = new TableColumn [count]; 3233 System.arraycopy (columns, 0, newColumns, 0, count); 3241 TableColumn [] newColumns = columns.dup; 3234 3242 for (int i=phdn.iItem+1; i<count; i++) { 3235 3243 if (!newColumns [i].isDisposed ()) { … … 3244 3252 case OS.HDN_ITEMDBLCLICKW: 3245 3253 case OS.HDN_ITEMDBLCLICKA: { 3246 NMHEADER* phdn = new NMHEADER (); 3247 OS.MoveMemory (phdn, lParam, NMHEADER.sizeof); 3254 NMHEADER* phdn = cast(NMHEADER*)lParam; 3248 3255 TableColumn column = columns [phdn.iItem]; 3249 3256 if (column !is null) {
