comparison dwt/widgets/Link.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 8b6d038b7f79
children 36f5cb12e1a2
comparison
equal deleted inserted replaced
211:ff59aeb96cac 212:ab60f3309436
63 public class Link : Control { 63 public class Link : Control {
64 64
65 alias Control.computeSize computeSize; 65 alias Control.computeSize computeSize;
66 alias Control.windowProc windowProc; 66 alias Control.windowProc windowProc;
67 67
68 char[] text; 68 String text;
69 TextLayout layout; 69 TextLayout layout;
70 Color linkColor, disabledColor; 70 Color linkColor, disabledColor;
71 Point [] offsets; 71 Point [] offsets;
72 Point selection; 72 Point selection;
73 char[] [] ids; 73 String [] ids;
74 int [] mnemonics; 74 int [] mnemonics;
75 int focusIndex, mouseDownIndex; 75 int focusIndex, mouseDownIndex;
76 HFONT font; 76 HFONT font;
77 static /+const+/ RGB LINK_FOREGROUND; 77 static /+const+/ RGB LINK_FOREGROUND;
78 static /+const+/ WNDPROC LinkProc; 78 static /+const+/ WNDPROC LinkProc;
224 } else { 224 } else {
225 linkColor = new Color (display, LINK_FOREGROUND); 225 linkColor = new Color (display, LINK_FOREGROUND);
226 } 226 }
227 disabledColor = Color.win32_new (display, OS.GetSysColor (OS.COLOR_GRAYTEXT)); 227 disabledColor = Color.win32_new (display, OS.GetSysColor (OS.COLOR_GRAYTEXT));
228 offsets = new Point [0]; 228 offsets = new Point [0];
229 ids = new char[] [0]; 229 ids = new String [0];
230 mnemonics = new int [0]; 230 mnemonics = new int [0];
231 selection = new Point (-1, -1); 231 selection = new Point (-1, -1);
232 focusIndex = mouseDownIndex = -1; 232 focusIndex = mouseDownIndex = -1;
233 } 233 }
234 } 234 }
349 if (hasFocus ()) e.childID = ACC.CHILDID_SELF; 349 if (hasFocus ()) e.childID = ACC.CHILDID_SELF;
350 } 350 }
351 }); 351 });
352 } 352 }
353 353
354 override char[] getNameText () { 354 override String getNameText () {
355 return getText (); 355 return getText ();
356 } 356 }
357 357
358 Rectangle [] getRectangles (int linkIndex) { 358 Rectangle [] getRectangles (int linkIndex) {
359 int lineCount = layout.getLineCount (); 359 int lineCount = layout.getLineCount ();
393 * @exception DWTException <ul> 393 * @exception DWTException <ul>
394 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 394 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
395 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 395 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
396 * </ul> 396 * </ul>
397 */ 397 */
398 public char[] getText () { 398 public String getText () {
399 checkWidget (); 399 checkWidget ();
400 return text; 400 return text;
401 } 401 }
402 402
403 char[] parse (char[] string) { 403 String parse (String string) {
404 int length_ = string.length; 404 int length_ = string.length;
405 offsets = new Point [length_ / 4]; 405 offsets = new Point [length_ / 4];
406 ids = new char[] [length_ / 4]; 406 ids = new String [length_ / 4];
407 mnemonics = new int [length_ / 4 + 1]; 407 mnemonics = new int [length_ / 4 + 1];
408 StringBuffer result = new StringBuffer (); 408 StringBuffer result = new StringBuffer ();
409 char [] buffer = new char [length_]; 409 char [] buffer = new char [length_];
410 string.getChars (0, string.length, buffer, 0); 410 string.getChars (0, string.length, buffer, 0);
411 int index = 0, state = 0, linkIndex = 0; 411 int index = 0, state = 0, linkIndex = 0;
535 } 535 }
536 if (offsets.length !is linkIndex) { 536 if (offsets.length !is linkIndex) {
537 Point [] newOffsets = new Point [linkIndex]; 537 Point [] newOffsets = new Point [linkIndex];
538 System.arraycopy (offsets, 0, newOffsets, 0, linkIndex); 538 System.arraycopy (offsets, 0, newOffsets, 0, linkIndex);
539 offsets = newOffsets; 539 offsets = newOffsets;
540 char[] [] newIDs = new char[] [linkIndex]; 540 String [] newIDs = new String [linkIndex];
541 System.arraycopy (ids, 0, newIDs, 0, linkIndex); 541 System.arraycopy (ids, 0, newIDs, 0, linkIndex);
542 ids = newIDs; 542 ids = newIDs;
543 int [] newMnemonics = new int [linkIndex + 1]; 543 int [] newMnemonics = new int [linkIndex + 1];
544 System.arraycopy (mnemonics, 0, newMnemonics, 0, linkIndex + 1); 544 System.arraycopy (mnemonics, 0, newMnemonics, 0, linkIndex + 1);
545 mnemonics = newMnemonics; 545 mnemonics = newMnemonics;
624 * @exception DWTException <ul> 624 * @exception DWTException <ul>
625 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> 625 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
626 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> 626 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
627 * </ul> 627 * </ul>
628 */ 628 */
629 public void setText (char[] string) { 629 public void setText (String string) {
630 checkWidget (); 630 checkWidget ();
631 if (string is null) error (DWT.ERROR_NULL_ARGUMENT); 631 if (string is null) error (DWT.ERROR_NULL_ARGUMENT);
632 if (string==/*eq*/text) return; 632 if (string==/*eq*/text) return;
633 text = string; 633 text = string;
634 if (OS.COMCTL32_MAJOR >= 6) { 634 if (OS.COMCTL32_MAJOR >= 6) {
677 override int widgetStyle () { 677 override int widgetStyle () {
678 int bits = super.widgetStyle (); 678 int bits = super.widgetStyle ();
679 return bits | OS.WS_TABSTOP; 679 return bits | OS.WS_TABSTOP;
680 } 680 }
681 681
682 override char[] windowClass () { 682 override String windowClass () {
683 return OS.COMCTL32_MAJOR >= 6 ? TCHARsToStr(LinkClass) : display.windowClass(); 683 return OS.COMCTL32_MAJOR >= 6 ? TCHARsToStr(LinkClass) : display.windowClass();
684 } 684 }
685 685
686 override int windowProc () { 686 override int windowProc () {
687 return LinkProc !is null ? cast(int)LinkProc : display.windowProc(); 687 return LinkProc !is null ? cast(int)LinkProc : display.windowProc();