Mercurial > projects > dwt-mac
comparison dwt/widgets/Display.d @ 132:a45406361e44
Fixed the Caret blinking
author | Jacob Carlborg <doob@me.com> |
---|---|
date | Sun, 22 Mar 2009 20:22:57 +0100 |
parents | ad4e1fe71a5a |
children | c41e13089a3c |
comparison
equal
deleted
inserted
replaced
131:03fac5984741 | 132:a45406361e44 |
---|---|
329 | 329 |
330 /* Display Data */ | 330 /* Display Data */ |
331 Object data; | 331 Object data; |
332 String [] keys; | 332 String [] keys; |
333 Object [] values; | 333 Object [] values; |
334 | 334 |
335 /* | 335 /* |
336 * TEMPORARY CODE. Install the runnable that | 336 * TEMPORARY CODE. Install the runnable that |
337 * gets the current display. This code will | 337 * gets the current display. This code will |
338 * be removed in the future. | 338 * be removed in the future. |
339 */ | 339 */ |
345 if (device is null) { | 345 if (device is null) { |
346 device = getDefault (); | 346 device = getDefault (); |
347 } | 347 } |
348 setDevice (device); | 348 setDevice (device); |
349 } | 349 } |
350 }; | 350 }; |
351 } | 351 } |
352 | 352 |
353 /* | 353 /* |
354 * TEMPORARY CODE. | 354 * TEMPORARY CODE. |
355 */ | 355 */ |
623 screenID = new int[32]; | 623 screenID = new int[32]; |
624 screenCascade = new NSPoint*[32]; | 624 screenCascade = new NSPoint*[32]; |
625 cursors = new Cursor [DWT.CURSOR_HAND + 1]; | 625 cursors = new Cursor [DWT.CURSOR_HAND + 1]; |
626 timerDelegate = cast(SWTWindowDelegate)(new SWTWindowDelegate()).alloc().init(); | 626 timerDelegate = cast(SWTWindowDelegate)(new SWTWindowDelegate()).alloc().init(); |
627 | 627 |
628 caretTimer = new class(currentCaret) Runnable { | 628 caretTimer = new CaretTimer; |
629 Caret currentCaret; | 629 hoverTimer = new HoverTimer; |
630 | |
631 this (Caret currentCaret) | |
632 { | |
633 this.currentCaret = currentCaret; | |
634 } | |
635 | |
636 public void run () { | |
637 if (currentCaret !is null) { | |
638 if (currentCaret is null || currentCaret.isDisposed()) return; | |
639 if (currentCaret.blinkCaret ()) { | |
640 int blinkRate = currentCaret.blinkRate; | |
641 if (blinkRate !is 0) timerExec (blinkRate, this); | |
642 } else { | |
643 currentCaret = null; | |
644 } | |
645 } | |
646 | |
647 } | |
648 }; | |
649 | |
650 hoverTimer = new class(currentControl) Runnable { | |
651 Control currentControl; | |
652 | |
653 this (Control currentControl) | |
654 { | |
655 this.currentControl = currentControl; | |
656 } | |
657 | |
658 public void run () { | |
659 if (currentControl !is null && !currentControl.isDisposed()) { | |
660 currentControl.sendMouseEvent (null, DWT.MouseHover, trackingControl !is null); | |
661 } | |
662 } | |
663 }; | |
664 } | 630 } |
665 | 631 |
666 static void checkDisplay (Thread thread, bool multiple) { | 632 static void checkDisplay (Thread thread, bool multiple) { |
667 synchronized (Device.classinfo) { | 633 synchronized (Device.classinfo) { |
668 for (int i=0; i<Displays.length; i++) { | 634 for (int i=0; i<Displays.length; i++) { |
3102 APP_NAME = name; | 3068 APP_NAME = name; |
3103 } | 3069 } |
3104 | 3070 |
3105 //TODO use custom timer instead of timerExec | 3071 //TODO use custom timer instead of timerExec |
3106 Runnable hoverTimer; | 3072 Runnable hoverTimer; |
3073 | |
3074 class HoverTimer : Runnable | |
3075 { | |
3076 public void run () { | |
3077 if (currentControl !is null && !currentControl.isDisposed()) { | |
3078 currentControl.sendMouseEvent (null, DWT.MouseHover, trackingControl !is null); | |
3079 } | |
3080 } | |
3081 } | |
3107 | 3082 |
3108 //TODO - use custom timer instead of timerExec | 3083 //TODO - use custom timer instead of timerExec |
3109 Runnable caretTimer; | 3084 Runnable caretTimer; |
3085 | |
3086 class CaretTimer : Runnable | |
3087 { | |
3088 public void run () { | |
3089 if (currentCaret !is null) { | |
3090 if (this.outer.currentCaret is null || this.outer.currentCaret.isDisposed()) return; | |
3091 if (currentCaret.blinkCaret ()) { | |
3092 int blinkRate = currentCaret.blinkRate; | |
3093 if (blinkRate !is 0) timerExec (blinkRate, this); | |
3094 } else { | |
3095 currentCaret = null; | |
3096 } | |
3097 } | |
3098 } | |
3099 } | |
3110 | 3100 |
3111 void setCurrentCaret (Caret caret) { | 3101 void setCurrentCaret (Caret caret) { |
3112 // if (caretID !is 0) OS.RemoveEventLoopTimer (caretID); | 3102 // if (caretID !is 0) OS.RemoveEventLoopTimer (caretID); |
3113 // caretID = 0; | 3103 // caretID = 0; |
3114 currentCaret = caret; | 3104 currentCaret = caret; |
3115 if (currentCaret !is null) { | 3105 if (currentCaret !is null) { |
3116 int blinkRate = currentCaret.blinkRate; | 3106 int blinkRate = currentCaret.blinkRate; |
3117 timerExec (blinkRate, caretTimer); | 3107 timerExec (blinkRate, caretTimer); |
3118 } | 3108 } |
3119 } | 3109 } |