comparison dwt/widgets/Tree.d @ 212:ab60f3309436

reverted the char[] to String and use the an alias.
author Frank Benoit <benoit@tionex.de>
date Mon, 05 May 2008 00:12:38 +0200
parents 25f88bf5a6df
children 36f5cb12e1a2
comparison
equal deleted inserted replaced
211:ff59aeb96cac 212:ab60f3309436
827 * and DT_ENDELLIPSIS, the ellipsis can draw outside of the 827 * and DT_ENDELLIPSIS, the ellipsis can draw outside of the
828 * rectangle when the rectangle is empty. The fix is avoid 828 * rectangle when the rectangle is empty. The fix is avoid
829 * all text drawing for empty rectangles. 829 * all text drawing for empty rectangles.
830 */ 830 */
831 if (rect.left < rect.right) { 831 if (rect.left < rect.right) {
832 char[] string = null; 832 String string = null;
833 if (index is 0) { 833 if (index is 0) {
834 string = item.text; 834 string = item.text;
835 } else { 835 } else {
836 char[] [] strings = item.strings; 836 String [] strings = item.strings;
837 if (strings !is null) string = strings [index]; 837 if (strings !is null) string = strings [index];
838 } 838 }
839 if (string !is null) { 839 if (string !is null) {
840 if (hFont !is cast(HFONT)-1) hFont = OS.SelectObject (hDC, hFont); 840 if (hFont !is cast(HFONT)-1) hFont = OS.SelectObject (hDC, hFont);
841 if (clrText !is -1) clrText = OS.SetTextColor (hDC, clrText); 841 if (clrText !is -1) clrText = OS.SetTextColor (hDC, clrText);
1815 private static extern(Windows) int CompareFunc (int lParam1, int lParam2, int lParamSort) { 1815 private static extern(Windows) int CompareFunc (int lParam1, int lParam2, int lParamSort) {
1816 return sThis.CompareProc( lParam1, lParam2, lParamSort ); 1816 return sThis.CompareProc( lParam1, lParam2, lParamSort );
1817 } 1817 }
1818 int CompareProc (int lParam1, int lParam2, int lParamSort) { 1818 int CompareProc (int lParam1, int lParam2, int lParamSort) {
1819 TreeItem item1 = items [lParam1], item2 = items [lParam2]; 1819 TreeItem item1 = items [lParam1], item2 = items [lParam2];
1820 char[] text1 = item1.getText (lParamSort), text2 = item2.getText (lParamSort); 1820 String text1 = item1.getText (lParamSort), text2 = item2.getText (lParamSort);
1821 return sortDirection is DWT.UP ? ( text1 < text2 ) : ( text2 < text1 ); 1821 return sortDirection is DWT.UP ? ( text1 < text2 ) : ( text2 < text1 );
1822 } 1822 }
1823 1823
1824 override public Point computeSize (int wHint, int hHint, bool changed) { 1824 override public Point computeSize (int wHint, int hHint, bool changed) {
1825 checkWidget (); 1825 checkWidget ();
1962 columns = newColumns; 1962 columns = newColumns;
1963 } 1963 }
1964 for (int i=0; i<items.length; i++) { 1964 for (int i=0; i<items.length; i++) {
1965 TreeItem item = items [i]; 1965 TreeItem item = items [i];
1966 if (item !is null) { 1966 if (item !is null) {
1967 char[] [] strings = item.strings; 1967 String [] strings = item.strings;
1968 if (strings !is null) { 1968 if (strings !is null) {
1969 char[] [] temp = new char[] [columnCount + 1]; 1969 String [] temp = new String [columnCount + 1];
1970 System.arraycopy (strings, 0, temp, 0, index); 1970 System.arraycopy (strings, 0, temp, 0, index);
1971 System.arraycopy (strings, index, temp, index + 1, columnCount - index); 1971 System.arraycopy (strings, index, temp, index + 1, columnCount - index);
1972 item.strings = temp; 1972 item.strings = temp;
1973 } 1973 }
1974 Image [] images = item.images; 1974 Image [] images = item.images;
1979 item.images = temp; 1979 item.images = temp;
1980 } 1980 }
1981 if (index is 0) { 1981 if (index is 0) {
1982 if (columnCount !is 0) { 1982 if (columnCount !is 0) {
1983 if (strings is null) { 1983 if (strings is null) {
1984 item.strings = new char[] [columnCount + 1]; 1984 item.strings = new String [columnCount + 1];
1985 item.strings [1] = item.text; 1985 item.strings [1] = item.text;
1986 } 1986 }
1987 item.text = ""; 1987 item.text = "";
1988 if (images is null) { 1988 if (images is null) {
1989 item.images = new Image [columnCount + 1]; 1989 item.images = new Image [columnCount + 1];
2424 item.cellBackground = null; 2424 item.cellBackground = null;
2425 item.cellForeground = null; 2425 item.cellForeground = null;
2426 item.cellFont = null; 2426 item.cellFont = null;
2427 } else { 2427 } else {
2428 if (item.strings !is null) { 2428 if (item.strings !is null) {
2429 char[] [] strings = item.strings; 2429 String [] strings = item.strings;
2430 if (index is 0) { 2430 if (index is 0) {
2431 item.text = strings [1] !is null ? strings [1] : ""; 2431 item.text = strings [1] !is null ? strings [1] : "";
2432 } 2432 }
2433 char[] [] temp = new char[] [columnCount]; 2433 String [] temp = new String [columnCount];
2434 System.arraycopy (strings, 0, temp, 0, index); 2434 System.arraycopy (strings, 0, temp, 0, index);
2435 System.arraycopy (strings, index + 1, temp, index, columnCount - index); 2435 System.arraycopy (strings, index + 1, temp, index, columnCount - index);
2436 item.strings = temp; 2436 item.strings = temp;
2437 } else { 2437 } else {
2438 if (index is 0) item.text = ""; 2438 if (index is 0) item.text = "";
5063 if (hwndHeader !is null) { 5063 if (hwndHeader !is null) {
5064 OS.SetWindowLong (hwndHeader, OS.GWL_WNDPROC, display.windowProc); 5064 OS.SetWindowLong (hwndHeader, OS.GWL_WNDPROC, display.windowProc);
5065 } 5065 }
5066 } 5066 }
5067 5067
5068 override char[] toolTipText (NMTTDISPINFO* hdr) { 5068 override String toolTipText (NMTTDISPINFO* hdr) {
5069 auto hwndToolTip = cast(HWND) OS.SendMessage (handle, OS.TVM_GETTOOLTIPS, 0, 0); 5069 auto hwndToolTip = cast(HWND) OS.SendMessage (handle, OS.TVM_GETTOOLTIPS, 0, 0);
5070 if (hwndToolTip is hdr.hdr.hwndFrom && toolTipText_ !is null) return ""; //$NON-NLS-1$ 5070 if (hwndToolTip is hdr.hdr.hwndFrom && toolTipText_ !is null) return ""; //$NON-NLS-1$
5071 if (headerToolTipHandle is hdr.hdr.hwndFrom) { 5071 if (headerToolTipHandle is hdr.hdr.hwndFrom) {
5072 int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0); 5072 int count = OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0);
5073 for (int i=0; i<count; i++) { 5073 for (int i=0; i<count; i++) {
5094 if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont); 5094 if (newFont !is null) oldFont = OS.SelectObject (hDC, newFont);
5095 RECT rect; 5095 RECT rect;
5096 OS.GetClientRect (hwndParent, &rect); 5096 OS.GetClientRect (hwndParent, &rect);
5097 OS.MapWindowPoints (hwndParent, handle, cast(POINT*) &rect, 2); 5097 OS.MapWindowPoints (hwndParent, handle, cast(POINT*) &rect, 2);
5098 TreeItem item = _getItem (lpht.hItem); 5098 TreeItem item = _getItem (lpht.hItem);
5099 char[] text = null; 5099 String text = null;
5100 int index = 0, count = Math.max (1, OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0)); 5100 int index = 0, count = Math.max (1, OS.SendMessage (hwndHeader, OS.HDM_GETITEMCOUNT, 0, 0));
5101 int [] order = new int [count]; 5101 int [] order = new int [count];
5102 OS.SendMessage (hwndHeader, OS.HDM_GETORDERARRAY, count, order.ptr); 5102 OS.SendMessage (hwndHeader, OS.HDM_GETORDERARRAY, count, order.ptr);
5103 while (index < count) { 5103 while (index < count) {
5104 HFONT hFont = item.cellFont !is null ? item.cellFont [order [index]] : cast(HFONT)-1; 5104 HFONT hFont = item.cellFont !is null ? item.cellFont [order [index]] : cast(HFONT)-1;
5112 RECT textRect = item.getBounds (order [index], true, false, false, false, false, hDC); 5112 RECT textRect = item.getBounds (order [index], true, false, false, false, false, hDC);
5113 if (textRect.right > cellRect.right) { 5113 if (textRect.right > cellRect.right) {
5114 if (order [index] is 0) { 5114 if (order [index] is 0) {
5115 text = item.text; 5115 text = item.text;
5116 } else { 5116 } else {
5117 char[][] strings = item.strings; 5117 String[] strings = item.strings;
5118 if (strings !is null) text = strings [order [index]]; 5118 if (strings !is null) text = strings [order [index]];
5119 } 5119 }
5120 } 5120 }
5121 break; 5121 break;
5122 } 5122 }
5264 } 5264 }
5265 // bits |= OS.TVS_NOTOOLTIPS | OS.TVS_DISABLEDRAGDROP; 5265 // bits |= OS.TVS_NOTOOLTIPS | OS.TVS_DISABLEDRAGDROP;
5266 return bits | OS.TVS_DISABLEDRAGDROP; 5266 return bits | OS.TVS_DISABLEDRAGDROP;
5267 } 5267 }
5268 5268
5269 override char[] windowClass () { 5269 override String windowClass () {
5270 return TCHARsToStr(TreeClass); 5270 return TCHARsToStr(TreeClass);
5271 } 5271 }
5272 5272
5273 override int windowProc () { 5273 override int windowProc () {
5274 return cast(int) TreeProc; 5274 return cast(int) TreeProc;
6911 int index = 0; 6911 int index = 0;
6912 if (hwndHeader !is null) { 6912 if (hwndHeader !is null) {
6913 index = OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0); 6913 index = OS.SendMessage (hwndHeader, OS.HDM_ORDERTOINDEX, 0, 0);
6914 } 6914 }
6915 if ((lptvdi.item.mask & OS.TVIF_TEXT) !is 0) { 6915 if ((lptvdi.item.mask & OS.TVIF_TEXT) !is 0) {
6916 char[] string = null; 6916 String string = null;
6917 if (index is 0) { 6917 if (index is 0) {
6918 string = item.text; 6918 string = item.text;
6919 } else { 6919 } else {
6920 char[] [] strings = item.strings; 6920 String [] strings = item.strings;
6921 if (strings !is null) string = strings [index]; 6921 if (strings !is null) string = strings [index];
6922 } 6922 }
6923 if (string !is null) { 6923 if (string !is null) {
6924 TCHAR[] buffer = StrToTCHARs (getCodePage (), string, false); 6924 TCHAR[] buffer = StrToTCHARs (getCodePage (), string, false);
6925 int byteCount = Math.min (buffer.length, lptvdi.item.cchTextMax - 1) * TCHAR.sizeof; 6925 int byteCount = Math.min (buffer.length, lptvdi.item.cchTextMax - 1) * TCHAR.sizeof;