Mercurial > projects > dwt-win
comparison dwt/widgets/Button.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 | 6f75fdfa1bcd |
children | 36f5cb12e1a2 |
comparison
equal
deleted
inserted
replaced
211:ff59aeb96cac | 212:ab60f3309436 |
---|---|
58 | 58 |
59 alias Control.computeSize computeSize; | 59 alias Control.computeSize computeSize; |
60 alias Control.windowProc windowProc; | 60 alias Control.windowProc windowProc; |
61 | 61 |
62 alias extern(Windows) int function( HWND, uint, uint, int ) TWindowProc; | 62 alias extern(Windows) int function( HWND, uint, uint, int ) TWindowProc; |
63 char[] text = "", message = ""; | 63 String text = "", message = ""; |
64 Image image, image2, disabledImage; | 64 Image image, image2, disabledImage; |
65 ImageList imageList; | 65 ImageList imageList; |
66 bool ignoreMouse; | 66 bool ignoreMouse; |
67 static const int MARGIN = 4; | 67 static const int MARGIN = 4; |
68 private static /+const+/ int CHECK_WIDTH, CHECK_HEIGHT; | 68 private static /+const+/ int CHECK_WIDTH, CHECK_HEIGHT; |
280 if (newBits !is oldBits) OS.SetWindowLong (handle, OS.GWL_STYLE, newBits); | 280 if (newBits !is oldBits) OS.SetWindowLong (handle, OS.GWL_STYLE, newBits); |
281 OS.SendMessage (handle, OS.BM_SETIMAGE, fImageType, hImage); | 281 OS.SendMessage (handle, OS.BM_SETIMAGE, fImageType, hImage); |
282 } | 282 } |
283 } | 283 } |
284 | 284 |
285 void _setText (char[] text) { | 285 void _setText (String text) { |
286 int oldBits = OS.GetWindowLong (handle, OS.GWL_STYLE), newBits = oldBits; | 286 int oldBits = OS.GetWindowLong (handle, OS.GWL_STYLE), newBits = oldBits; |
287 if (OS.COMCTL32_MAJOR >= 6) { | 287 if (OS.COMCTL32_MAJOR >= 6) { |
288 newBits &= ~(OS.BS_LEFT | OS.BS_CENTER | OS.BS_RIGHT); | 288 newBits &= ~(OS.BS_LEFT | OS.BS_CENTER | OS.BS_RIGHT); |
289 if ((style & DWT.LEFT) !is 0) newBits |= OS.BS_LEFT; | 289 if ((style & DWT.LEFT) !is 0) newBits |= OS.BS_LEFT; |
290 if ((style & DWT.CENTER) !is 0) newBits |= OS.BS_CENTER; | 290 if ((style & DWT.CENTER) !is 0) newBits |= OS.BS_CENTER; |
544 if ((style & DWT.RIGHT_TO_LEFT) !is 0) { | 544 if ((style & DWT.RIGHT_TO_LEFT) !is 0) { |
545 if (OS.COMCTL32_MAJOR < 6 || !OS.IsAppThemed ()) { | 545 if (OS.COMCTL32_MAJOR < 6 || !OS.IsAppThemed ()) { |
546 int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); | 546 int bits = OS.GetWindowLong (handle, OS.GWL_STYLE); |
547 bool hasImage = (bits & (OS.BS_BITMAP | OS.BS_ICON)) !is 0; | 547 bool hasImage = (bits & (OS.BS_BITMAP | OS.BS_ICON)) !is 0; |
548 if (!hasImage) { | 548 if (!hasImage) { |
549 char[] string = enabled ? text : " " ~ text ~ " "; | 549 String string = enabled ? text : " " ~ text ~ " "; |
550 TCHAR* buffer = StrToTCHARz (getCodePage (), string); | 550 TCHAR* buffer = StrToTCHARz (getCodePage (), string); |
551 OS.SetWindowText (handle, buffer); | 551 OS.SetWindowText (handle, buffer); |
552 } | 552 } |
553 } | 553 } |
554 } | 554 } |
652 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 652 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
653 * </ul> | 653 * </ul> |
654 * | 654 * |
655 * @since 3.3 | 655 * @since 3.3 |
656 */ | 656 */ |
657 /*public*/ char[] getMessage () { | 657 /*public*/ String getMessage () { |
658 checkWidget (); | 658 checkWidget (); |
659 return message; | 659 return message; |
660 } | 660 } |
661 | 661 |
662 override char[] getNameText () { | 662 override String getNameText () { |
663 return getText (); | 663 return getText (); |
664 } | 664 } |
665 | 665 |
666 /** | 666 /** |
667 * Returns <code>true</code> if the receiver is selected, | 667 * Returns <code>true</code> if the receiver is selected, |
696 * @exception DWTException <ul> | 696 * @exception DWTException <ul> |
697 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 697 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
698 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 698 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
699 * </ul> | 699 * </ul> |
700 */ | 700 */ |
701 public char[] getText () { | 701 public String getText () { |
702 checkWidget (); | 702 checkWidget (); |
703 if ((style & DWT.ARROW) !is 0) return ""; | 703 if ((style & DWT.ARROW) !is 0) return ""; |
704 return text; | 704 return text; |
705 } | 705 } |
706 | 706 |
920 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 920 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
921 * </ul> | 921 * </ul> |
922 * | 922 * |
923 * @since 3.3 | 923 * @since 3.3 |
924 */ | 924 */ |
925 /*public*/ void setMessage (char[] message) { | 925 /*public*/ void setMessage (String message) { |
926 checkWidget (); | 926 checkWidget (); |
927 if (message is null) error (DWT.ERROR_NULL_ARGUMENT); | 927 if (message is null) error (DWT.ERROR_NULL_ARGUMENT); |
928 this.message = message; | 928 this.message = message; |
929 if (OS.COMCTL32_VERSION >= OS.VERSION (6, 1)) { | 929 if (OS.COMCTL32_VERSION >= OS.VERSION (6, 1)) { |
930 if ((style & DWT.COMMAND) !is 0) { | 930 if ((style & DWT.COMMAND) !is 0) { |
1021 * @exception DWTException <ul> | 1021 * @exception DWTException <ul> |
1022 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> | 1022 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
1023 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> | 1023 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
1024 * </ul> | 1024 * </ul> |
1025 */ | 1025 */ |
1026 public void setText (char[] string) { | 1026 public void setText (String string) { |
1027 checkWidget (); | 1027 checkWidget (); |
1028 if (string is null) error (DWT.ERROR_NULL_ARGUMENT); | 1028 if (string is null) error (DWT.ERROR_NULL_ARGUMENT); |
1029 if ((style & DWT.ARROW) !is 0) return; | 1029 if ((style & DWT.ARROW) !is 0) return; |
1030 text = string; | 1030 text = string; |
1031 /* This code is intentionally commented */ | 1031 /* This code is intentionally commented */ |
1051 if ((style & DWT.TOGGLE) !is 0) return bits | OS.BS_PUSHLIKE | OS.BS_CHECKBOX | OS.WS_TABSTOP; | 1051 if ((style & DWT.TOGGLE) !is 0) return bits | OS.BS_PUSHLIKE | OS.BS_CHECKBOX | OS.WS_TABSTOP; |
1052 if ((style & DWT.COMMAND) !is 0) return bits | OS.BS_COMMANDLINK | OS.WS_TABSTOP; | 1052 if ((style & DWT.COMMAND) !is 0) return bits | OS.BS_COMMANDLINK | OS.WS_TABSTOP; |
1053 return bits | OS.BS_PUSHBUTTON | OS.WS_TABSTOP; | 1053 return bits | OS.BS_PUSHBUTTON | OS.WS_TABSTOP; |
1054 } | 1054 } |
1055 | 1055 |
1056 override char[] windowClass () { | 1056 override String windowClass () { |
1057 return TCHARzToStr( ButtonClass.ptr ); | 1057 return TCHARzToStr( ButtonClass.ptr ); |
1058 } | 1058 } |
1059 | 1059 |
1060 override int windowProc () { | 1060 override int windowProc () { |
1061 return cast(int) ButtonProc; | 1061 return cast(int) ButtonProc; |