Mercurial > projects > dwt-win
comparison dwt/widgets/TableItem.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 | a155324d7a44 |
children | 36f5cb12e1a2 |
comparison
equal
deleted
inserted
replaced
211:ff59aeb96cac | 212:ab60f3309436 |
---|---|
41 * </p> | 41 * </p> |
42 */ | 42 */ |
43 | 43 |
44 public class TableItem : Item { | 44 public class TableItem : Item { |
45 Table parent; | 45 Table parent; |
46 char[] [] strings; | 46 String [] strings; |
47 Image [] images; | 47 Image [] images; |
48 bool checked, grayed, cached; | 48 bool checked, grayed, cached; |
49 int imageIndent, background = -1, foreground = -1; | 49 int imageIndent, background = -1, foreground = -1; |
50 HFONT font = cast(HFONT)-1; | 50 HFONT font = cast(HFONT)-1; |
51 int [] cellBackground, cellForeground; | 51 int [] cellBackground, cellForeground; |
382 int code = OS.SendMessage (hwnd, OS. LVM_GETSUBITEMRECT, row, &rect); | 382 int code = OS.SendMessage (hwnd, OS. LVM_GETSUBITEMRECT, row, &rect); |
383 parent.ignoreCustomDraw = false; | 383 parent.ignoreCustomDraw = false; |
384 if (code is 0) return RECT.init; | 384 if (code is 0) return RECT.init; |
385 if (!hasImage) rect.right = rect.left; | 385 if (!hasImage) rect.right = rect.left; |
386 if (getText) { | 386 if (getText) { |
387 char[] string = column is 0 ? text : strings !is null ? strings [column] : null; | 387 String string = column is 0 ? text : strings !is null ? strings [column] : null; |
388 if (string !is null) { | 388 if (string !is null) { |
389 RECT textRect; | 389 RECT textRect; |
390 TCHAR[] buffer = StrToTCHARs (parent.getCodePage (), string, false); | 390 TCHAR[] buffer = StrToTCHARs (parent.getCodePage (), string, false); |
391 int flags = OS.DT_NOPREFIX | OS.DT_SINGLELINE | OS.DT_CALCRECT; | 391 int flags = OS.DT_NOPREFIX | OS.DT_SINGLELINE | OS.DT_CALCRECT; |
392 OS.DrawText (hDC, buffer.ptr, buffer.length, &textRect, flags); | 392 OS.DrawText (hDC, buffer.ptr, buffer.length, &textRect, flags); |
597 checkWidget(); | 597 checkWidget(); |
598 if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED); | 598 if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED); |
599 return imageIndent; | 599 return imageIndent; |
600 } | 600 } |
601 | 601 |
602 override char[] getNameText () { | 602 override String getNameText () { |
603 if ((parent.style & DWT.VIRTUAL) !is 0) { | 603 if ((parent.style & DWT.VIRTUAL) !is 0) { |
604 if (!cached) return "*virtual*"; //$NON-NLS-1$ | 604 if (!cached) return "*virtual*"; //$NON-NLS-1$ |
605 } | 605 } |
606 return super.getNameText (); | 606 return super.getNameText (); |
607 } | 607 } |
619 public Table getParent () { | 619 public Table getParent () { |
620 checkWidget(); | 620 checkWidget(); |
621 return parent; | 621 return parent; |
622 } | 622 } |
623 | 623 |
624 override public char[] getText () { | 624 override public String getText () { |
625 checkWidget(); | 625 checkWidget(); |
626 if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED); | 626 if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED); |
627 return super.getText (); | 627 return super.getText (); |
628 } | 628 } |
629 | 629 |
637 * @exception DWTException <ul> | 637 * @exception DWTException <ul> |
638 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 638 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
639 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 639 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
640 * </ul> | 640 * </ul> |
641 */ | 641 */ |
642 public char[] getText (int index) { | 642 public String getText (int index) { |
643 checkWidget(); | 643 checkWidget(); |
644 if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED); | 644 if (!parent.checkData (this, true)) error (DWT.ERROR_WIDGET_DISPOSED); |
645 if (index is 0) return getText (); | 645 if (index is 0) return getText (); |
646 if (strings !is null) { | 646 if (strings !is null) { |
647 if (0 <= index && index < strings.length) { | 647 if (0 <= index && index < strings.length) { |
648 char[] string = strings [index]; | 648 String string = strings [index]; |
649 return string !is null ? string : ""; | 649 return string !is null ? string : ""; |
650 } | 650 } |
651 } | 651 } |
652 return ""; | 652 return ""; |
653 } | 653 } |
1164 * @exception DWTException <ul> | 1164 * @exception DWTException <ul> |
1165 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 1165 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
1166 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 1166 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
1167 * </ul> | 1167 * </ul> |
1168 */ | 1168 */ |
1169 public void setText (char[] [] strings) { | 1169 public void setText (String [] strings) { |
1170 checkWidget(); | 1170 checkWidget(); |
1171 if (strings is null) error (DWT.ERROR_NULL_ARGUMENT); | 1171 if (strings is null) error (DWT.ERROR_NULL_ARGUMENT); |
1172 for (int i=0; i<strings.length; i++) { | 1172 for (int i=0; i<strings.length; i++) { |
1173 char[] string = strings [i]; | 1173 String string = strings [i]; |
1174 if (string !is null) setText (i, string); | 1174 if (string !is null) setText (i, string); |
1175 } | 1175 } |
1176 } | 1176 } |
1177 | 1177 |
1178 /** | 1178 /** |
1187 * @exception DWTException <ul> | 1187 * @exception DWTException <ul> |
1188 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 1188 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
1189 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 1189 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
1190 * </ul> | 1190 * </ul> |
1191 */ | 1191 */ |
1192 public void setText (int index, char[] string) { | 1192 public void setText (int index, String string) { |
1193 checkWidget(); | 1193 checkWidget(); |
1194 if (string is null) error (DWT.ERROR_NULL_ARGUMENT); | 1194 if (string is null) error (DWT.ERROR_NULL_ARGUMENT); |
1195 if (index is 0) { | 1195 if (index is 0) { |
1196 if (string ==/*eq*/text) return; | 1196 if (string ==/*eq*/text) return; |
1197 super.setText (string.dup); | 1197 super.setText (string.dup); |
1198 } | 1198 } |
1199 int count = Math.max (1, parent.getColumnCount ()); | 1199 int count = Math.max (1, parent.getColumnCount ()); |
1200 if (0 > index || index > count - 1) return; | 1200 if (0 > index || index > count - 1) return; |
1201 if (strings is null && index !is 0) { | 1201 if (strings is null && index !is 0) { |
1202 strings = new char[][] (count); | 1202 strings = new String[] (count); |
1203 strings [0] = text; | 1203 strings [0] = text; |
1204 } | 1204 } |
1205 if (strings !is null) { | 1205 if (strings !is null) { |
1206 if (string==/*eq*/strings [index]) return; | 1206 if (string==/*eq*/strings [index]) return; |
1207 strings [index] = string.dup; | 1207 strings [index] = string.dup; |
1234 parent.setScrollWidth (this, false); | 1234 parent.setScrollWidth (this, false); |
1235 } | 1235 } |
1236 redraw (index, true, false); | 1236 redraw (index, true, false); |
1237 } | 1237 } |
1238 | 1238 |
1239 override public void setText (char[] string) { | 1239 override public void setText (String string) { |
1240 checkWidget(); | 1240 checkWidget(); |
1241 setText (0, string); | 1241 setText (0, string); |
1242 } | 1242 } |
1243 | 1243 |
1244 } | 1244 } |