Mercurial > projects > dwt-addons
comparison dwtx/jface/window/ToolTip.d @ 120:3b2353d77f37
Fix: DMD anon class problems
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Mon, 11 Aug 2008 11:14:42 +0200 |
parents | 04b47443bb01 |
children | 862b05e0334a |
comparison
equal
deleted
inserted
replaced
119:35f1d208f3c3 | 120:3b2353d77f37 |
---|---|
12 * Frank Benoit <benoit@tionex.de> | 12 * Frank Benoit <benoit@tionex.de> |
13 *******************************************************************************/ | 13 *******************************************************************************/ |
14 | 14 |
15 module dwtx.jface.window.ToolTip; | 15 module dwtx.jface.window.ToolTip; |
16 | 16 |
17 import tango.util.log.Trace; | |
17 | 18 |
18 import dwt.DWT; | 19 import dwt.DWT; |
19 import dwt.events.DisposeEvent; | 20 import dwt.events.DisposeEvent; |
20 import dwt.events.DisposeListener; | 21 import dwt.events.DisposeListener; |
21 import dwt.graphics.Point; | 22 import dwt.graphics.Point; |
105 * <code>true</code> if the activation is done manually using | 106 * <code>true</code> if the activation is done manually using |
106 * {@link #show(Point)} | 107 * {@link #show(Point)} |
107 * @see #RECREATE | 108 * @see #RECREATE |
108 * @see #NO_RECREATE | 109 * @see #NO_RECREATE |
109 */ | 110 */ |
110 public this(Control control_, int style, bool manualActivation) { | 111 public this(Control control, int style, bool manualActivation) { |
111 this.control = control_; | 112 this.control = control; |
112 this.style = style; | 113 this.style = style; |
113 this.hideListener = new TooltipHideListener(); | 114 this.hideListener = new TooltipHideListener(); |
114 this.control.addDisposeListener(new class DisposeListener { | 115 this.control.addDisposeListener(new class DisposeListener { |
115 | 116 |
116 public void widgetDisposed(DisposeEvent e) { | 117 public void widgetDisposed(DisposeEvent e) { |
117 data = null; | 118 this.outer.data = null; |
118 deactivate(); | 119 this.outer.deactivate(); |
119 } | 120 } |
120 | 121 |
121 }); | 122 }); |
122 | 123 |
123 this.listener = new ToolTipOwnerControlListener(); | 124 this.listener = new ToolTipOwnerControlListener(); |
124 this.shellListener = new class Listener { | 125 this.shellListener = dgListener( (Event event_, Control control_, ToolTip tooltip_) { |
125 public void handleEvent(Event event) { | 126 if( control_ !is null |
126 if( control_ !is null | 127 && ! control_.isDisposed() ) { |
127 && ! control_.isDisposed() ) { | 128 control_.getDisplay().asyncExec( dgRunnable( (Event event__, Control control__, ToolTip tooltip__){ |
128 control_.getDisplay().asyncExec( dgRunnable( (Event event_){ | 129 // Check if the new active shell is the tooltip |
129 // Check if the new active shell is the tooltip | 130 // itself |
130 // itself | 131 if( control__.getDisplay().getActiveShell() !is CURRENT_TOOLTIP) { |
131 if( control_.getDisplay().getActiveShell() !is CURRENT_TOOLTIP) { | 132 tooltip__.toolTipHide(CURRENT_TOOLTIP, event__); |
132 toolTipHide(CURRENT_TOOLTIP, event_); | 133 |
133 | 134 } |
134 } | 135 }, event_, control_, tooltip_)); |
135 }, event)); | 136 } |
136 } | 137 }, control, this); |
137 } | |
138 }; | |
139 | 138 |
140 if (!manualActivation) { | 139 if (!manualActivation) { |
141 activate(); | 140 activate(); |
142 } | 141 } |
143 } | 142 } |
448 public Point getLocation(Point tipSize, Event event) { | 447 public Point getLocation(Point tipSize, Event event) { |
449 return control.toDisplay(event.x + xShift, event.y + yShift); | 448 return control.toDisplay(event.x + xShift, event.y + yShift); |
450 } | 449 } |
451 | 450 |
452 private void toolTipHide(Shell tip, Event event) { | 451 private void toolTipHide(Shell tip, Event event) { |
452 assert(this); | |
453 if (tip !is null && !tip.isDisposed() && shouldHideToolTip(event)) { | 453 if (tip !is null && !tip.isDisposed() && shouldHideToolTip(event)) { |
454 assert(this); | |
454 control.getShell().removeListener(DWT.Deactivate, shellListener); | 455 control.getShell().removeListener(DWT.Deactivate, shellListener); |
455 currentArea = null; | 456 currentArea = null; |
456 passOnEvent(tip, event); | 457 passOnEvent(tip, event); |
457 tip.dispose(); | 458 tip.dispose(); |
458 CURRENT_TOOLTIP = null; | 459 CURRENT_TOOLTIP = null; |
518 CURRENT_TOOLTIP = shell; | 519 CURRENT_TOOLTIP = shell; |
519 | 520 |
520 control.getShell().addListener(DWT.Deactivate, shellListener); | 521 control.getShell().addListener(DWT.Deactivate, shellListener); |
521 | 522 |
522 if (popupDelay > 0) { | 523 if (popupDelay > 0) { |
523 control.getDisplay().timerExec(popupDelay, new class(shell,event) Runnable { | 524 control.getDisplay().timerExec(popupDelay, dgRunnable( (Shell shell_,Event event_, ToolTip tooltip_){ |
524 Shell shell_; | 525 assert(tooltip_); |
525 Event event_; | 526 tooltip_.toolTipShow(shell_, event_); |
526 this(Shell a,Event b){ shell_=a; event_=b; } | 527 },shell,event, this)); |
527 public void run() { | |
528 toolTipShow(shell_, event_); | |
529 } | |
530 }); | |
531 } else { | 528 } else { |
532 toolTipShow(CURRENT_TOOLTIP, event); | 529 toolTipShow(CURRENT_TOOLTIP, event); |
533 } | 530 } |
534 | 531 |
535 if (hideDelay > 0) { | 532 if (hideDelay > 0) { |
536 control.getDisplay().timerExec(popupDelay + hideDelay, | 533 control.getDisplay().timerExec(popupDelay + hideDelay, dgRunnable( (Shell shell_, ToolTip tooltip_){ |
537 new class(shell) Runnable { | 534 assert(tooltip_); |
538 Shell shell_; | 535 tooltip_.toolTipHide(shell_, null); |
539 this(Shell a){ shell_=a; } | 536 }, shell, this )); |
540 public void run() { | |
541 toolTipHide(shell, null); | |
542 } | |
543 }); | |
544 } | 537 } |
545 } | 538 } |
546 | 539 |
547 private void toolTipHookByTypeRecursively(Control c, bool add, int type) { | 540 private void toolTipHookByTypeRecursively(Control c, bool add, int type) { |
548 if (add) { | 541 if (add) { |