View | Details | Raw Unified | Return to bug 193318 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse SWT/wpf/org/eclipse/swt/widgets/CoolItem.java (+110 lines)
Lines 34-39 Link Here
34
public class CoolItem extends Item {
34
public class CoolItem extends Item {
35
	CoolBar parent;
35
	CoolBar parent;
36
	Control control;
36
	Control control;
37
	Menu menu;
37
38
38
/**
39
/**
39
 * Constructs a new instance of this class given its parent
40
 * Constructs a new instance of this class given its parent
Lines 110-115 Link Here
110
}
111
}
111
112
112
/**
113
/**
114
 * Adds the listener to the collection of listeners who will
115
 * be notified when the platform-specific chevron menu trigger
116
 * has occurred, by sending it one of the messages defined in
117
 * the <code>MenuDetectListener</code> interface.
118
 *
119
 * @param listener the listener which should be notified
120
 *
121
 * @exception IllegalArgumentException <ul>
122
 *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
123
 * </ul>
124
 * @exception SWTException <ul>
125
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
126
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
127
 * </ul>
128
 *
129
 * @see MenuDetectListener
130
 * @see #removeMenuDetectListener
131
 *
132
 * @since 3.4
133
 */
134
public void addMenuDetectListener (MenuDetectListener listener) {
135
	checkWidget ();
136
	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
137
	TypedListener typedListener = new TypedListener (listener);
138
	addListener (SWT.MenuDetect, typedListener);
139
}
140
141
/**
113
 * Adds the listener to the collection of listeners that will
142
 * Adds the listener to the collection of listeners that will
114
 * be notified when the control is selected by the user, by sending it one
143
 * be notified when the control is selected by the user, by sending it one
115
 * of the messages defined in the <code>SelectionListener</code>
144
 * of the messages defined in the <code>SelectionListener</code>
Lines 285-290 Link Here
285
}
314
}
286
315
287
/**
316
/**
317
 * Returns the receiver's chevron menu if it has one, or null 
318
 * if it does not.
319
 * 
320
 * @return the receiver's drop-down menu
321
 * @exception SWTException <ul>
322
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
323
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
324
 * </ul>
325
 * 
326
 * @since 3.4
327
 */
328
public Menu getMenu () {
329
	checkWidget();
330
	return menu;
331
}
332
333
/**
288
 * Returns the receiver's parent, which must be a <code>CoolBar</code>.
334
 * Returns the receiver's parent, which must be a <code>CoolBar</code>.
289
 *
335
 *
290
 * @return the receiver's parent
336
 * @return the receiver's parent
Lines 300-305 Link Here
300
}
346
}
301
347
302
/**
348
/**
349
 * Sets the receiver's chevron menu to the argument, which may be 
350
 * null indicating that no drop-down menu should be displayed.
351
 * <p>
352
 * If this property is null a drop-down menu can still be displayed manually by adding a
353
 * {@link SelectionListener} to the receiver and handling{@link SWT#ARROW} events.
354
 * 
355
 * @param menu the drop-down menu to be displayed when the receiver's arrow is pressed
356
 * @exception SWTException <ul>
357
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
358
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
359
 * </ul>
360
 * 
361
 * @since 3.4
362
 */
363
public void setMenu (Menu menu) {
364
	checkWidget();
365
	if (menu != null) {
366
		if (menu.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
367
		if ((menu.style & SWT.POP_UP) == 0) {
368
			error (SWT.ERROR_MENU_NOT_POP_UP);
369
		}
370
		if (menu.parent != parent.menuShell ()) {
371
			error (SWT.ERROR_INVALID_PARENT);
372
		}
373
	}
374
	this.menu = menu;
375
}
376
377
/**
303
 * Returns a point describing the receiver's ideal size.
378
 * Returns a point describing the receiver's ideal size.
304
 * The x coordinate of the result is the ideal width of the receiver.
379
 * The x coordinate of the result is the ideal width of the receiver.
305
 * The y coordinate of the result is the ideal height of the receiver.
380
 * The y coordinate of the result is the ideal height of the receiver.
Lines 373-378 Link Here
373
	return result;
448
	return result;
374
}
449
}
375
450
451
void releaseWidget () {
452
	super.releaseWidget ();
453
	if (menu != null && !menu.isDisposed ()) {
454
		menu.dispose ();
455
	}
456
	menu = null;
457
}
458
376
void releaseHandle () {
459
void releaseHandle () {
377
	super.releaseHandle ();
460
	super.releaseHandle ();
378
	if (handle != 0) OS.GCHandle_Free (handle);
461
	if (handle != 0) OS.GCHandle_Free (handle);
Lines 381-386 Link Here
381
}
464
}
382
465
383
/**
466
/**
467
 * Removes the listener from the collection of listeners who will
468
 * be notified when the platform-specific chevron menu trigger has
469
 * occurred.
470
 *
471
 * @param listener the listener which should no longer be notified
472
 *
473
 * @exception IllegalArgumentException <ul>
474
 *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
475
 * </ul>
476
 * @exception SWTException <ul>
477
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
478
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
479
 * </ul>
480
 *
481
 * @see MenuDetectListener
482
 * @see #addMenuDetectListener
483
 *
484
 * @since 3.4
485
 */
486
public void removeMenuDetectListener (MenuDetectListener listener) {
487
	checkWidget ();
488
	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
489
	if (eventTable == null) return;
490
	eventTable.unhook (SWT.MenuDetect, listener);
491
}
492
493
/**
384
 * Removes the listener from the collection of listeners that
494
 * Removes the listener from the collection of listeners that
385
 * will be notified when the control is selected by the user.
495
 * will be notified when the control is selected by the user.
386
 *
496
 *
(-)Eclipse SWT/wpf/org/eclipse/swt/widgets/Control.java (-13 / +13 lines)
Lines 17-23 Link Here
17
import org.eclipse.swt.accessibility.*;
17
import org.eclipse.swt.accessibility.*;
18
18
19
//TEMPORARY CODE
19
//TEMPORARY CODE
20
import org.eclipse.swt.effects.*;
20
//import org.eclipse.swt.effects.*;
21
21
22
/**
22
/**
23
 * Control is the abstract superclass of all windowed user interface classes.
23
 * Control is the abstract superclass of all windowed user interface classes.
Lines 2634-2651 Link Here
2634
/**
2634
/**
2635
 * WARNING: THIS API IS UNDER CONSTRUCTION AND SHOULD NOT BE USED
2635
 * WARNING: THIS API IS UNDER CONSTRUCTION AND SHOULD NOT BE USED
2636
 */
2636
 */
2637
public void setEffect(Effect effect){
2637
//public void setEffect(Effect effect){
2638
	checkWidget ();
2638
//	checkWidget ();
2639
	if (effect != null && effect.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
2639
//	if (effect != null && effect.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
2640
	if (effect != null) {
2640
//	if (effect != null) {
2641
		OS.UIElement_BitmapEffect (handle, effect.handle);
2641
//		OS.UIElement_BitmapEffect (handle, effect.handle);
2642
		OS.UIElement_ClipToBounds (topHandle (), false);
2642
//		OS.UIElement_ClipToBounds (topHandle (), false);
2643
	} else {
2643
//	} else {
2644
		OS.UIElement_BitmapEffect (handle, 0);
2644
//		OS.UIElement_BitmapEffect (handle, 0);
2645
		setClipping();
2645
//		setClipping();
2646
	}
2646
//	}
2647
//	updateLayout(handle);
2647
////	updateLayout(handle);
2648
}
2648
//}
2649
2649
2650
/**
2650
/**
2651
 * Enables the receiver if the argument is <code>true</code>,
2651
 * Enables the receiver if the argument is <code>true</code>,
(-)Eclipse SWT/wpf/org/eclipse/swt/widgets/ToolItem.java (+142 lines)
Lines 36-41 Link Here
36
	int imageHandle, textHandle, arrowHandle;
36
	int imageHandle, textHandle, arrowHandle;
37
	ToolBar parent;
37
	ToolBar parent;
38
	Control control;
38
	Control control;
39
	Menu menu;
39
	String toolTipText;
40
	String toolTipText;
40
	Image disabledImage, hotImage;
41
	Image disabledImage, hotImage;
41
	boolean ignoreSelection;
42
	boolean ignoreSelection;
Lines 124-129 Link Here
124
125
125
/**
126
/**
126
 * Adds the listener to the collection of listeners who will
127
 * Adds the listener to the collection of listeners who will
128
 * be notified when the platform-specific drop-down menu trigger
129
 * has occurred, by sending it one of the messages defined in
130
 * the <code>MenuDetectListener</code> interface.
131
 *
132
 * @param listener the listener which should be notified
133
 *
134
 * @exception IllegalArgumentException <ul>
135
 *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
136
 * </ul>
137
 * @exception SWTException <ul>
138
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
139
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
140
 * </ul>
141
 *
142
 * @see MenuDetectListener
143
 * @see #removeMenuDetectListener
144
 *
145
 * @since 3.4
146
 */
147
public void addMenuDetectListener (MenuDetectListener listener) {
148
	checkWidget ();
149
	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
150
	TypedListener typedListener = new TypedListener (listener);
151
	addListener (SWT.MenuDetect, typedListener);
152
}
153
154
/**
155
 * Adds the listener to the collection of listeners who will
127
 * be notified when the control is selected by the user, by sending
156
 * be notified when the control is selected by the user, by sending
128
 * it one of the messages defined in the <code>SelectionListener</code>
157
 * it one of the messages defined in the <code>SelectionListener</code>
129
 * interface.
158
 * interface.
Lines 315-320 Link Here
315
}
344
}
316
345
317
/**
346
/**
347
 * Returns the receiver's drop-down menu if it has one, or null 
348
 * if it does not.
349
 * <p>
350
 * The drop-down menu is activated when the arrow of an {@link SWT#DROP_DOWN}-styled receiver is pressed.
351
 * </p>
352
 * 
353
 * @return the receiver's drop-down menu
354
 * @exception SWTException <ul>
355
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
356
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
357
 * </ul>
358
 * 
359
 * @since 3.4
360
 */
361
public Menu getMenu () {
362
	checkWidget();
363
	return menu;
364
}
365
366
/**
318
 * Returns the receiver's disabled image if it has one, or null
367
 * Returns the receiver's disabled image if it has one, or null
319
 * if it does not.
368
 * if it does not.
320
 * <p>
369
 * <p>
Lines 454-459 Link Here
454
	if (!checkEvent (e)) return;
503
	if (!checkEvent (e)) return;
455
	if (ignoreSelection) return;
504
	if (ignoreSelection) return;
456
	Event event = new Event ();
505
	Event event = new Event ();
506
	Point showTheMenuPos = null;
457
	if ((style & SWT.DROP_DOWN) != 0) {
507
	if ((style & SWT.DROP_DOWN) != 0) {
458
		int mousePos = OS.Mouse_GetPosition (handle);
508
		int mousePos = OS.Mouse_GetPosition (handle);
459
		int zero = OS.gcnew_Point (0, OS.FrameworkElement_ActualHeight (topHandle ()));
509
		int zero = OS.gcnew_Point (0, OS.FrameworkElement_ActualHeight (topHandle ()));
Lines 463-473 Link Here
463
			int location = OS.UIElement_TranslatePoint (handle, zero, parent.handle);
513
			int location = OS.UIElement_TranslatePoint (handle, zero, parent.handle);
464
			event.x = (int) OS.Point_X (location);
514
			event.x = (int) OS.Point_X (location);
465
			event.y = (int) OS.Point_Y (location);
515
			event.y = (int) OS.Point_Y (location);
516
			if (sendMenuDetectEvent (event.x, event.y, SWT.ARROW)) {
517
				showTheMenuPos = parent.toDisplay(event.x, event.y);
518
			}
466
			OS.GCHandle_Free (location);
519
			OS.GCHandle_Free (location);
467
		}
520
		}
468
		OS.GCHandle_Free (arrowPos);
521
		OS.GCHandle_Free (arrowPos);
469
		OS.GCHandle_Free (zero);
522
		OS.GCHandle_Free (zero);
470
		OS.GCHandle_Free (mousePos);
523
		OS.GCHandle_Free (mousePos);
524
	} else {
525
		int zero = OS.gcnew_Point (0, OS.FrameworkElement_ActualHeight (topHandle ()));
526
		int location = OS.UIElement_TranslatePoint (handle, zero, parent.handle);
527
		int x = (int) OS.Point_X (location);
528
		int y = (int) OS.Point_Y (location);
529
		if (sendMenuDetectEvent (x, y, 0)) {
530
			showTheMenuPos = parent.toDisplay(x, y);
531
		}
532
		OS.GCHandle_Free(zero);
533
		OS.GCHandle_Free(location);
534
	}
535
	if (showTheMenuPos != null) {
536
		menu.setLocation (showTheMenuPos.x, showTheMenuPos.y);
537
		menu.setVisible (true);
538
		return;
471
	}
539
	}
472
	postEvent (SWT.Selection, event);
540
	postEvent (SWT.Selection, event);
473
}
541
}
Lines 542-547 Link Here
542
610
543
void releaseWidget () {
611
void releaseWidget () {
544
	super.releaseWidget ();
612
	super.releaseWidget ();
613
	if (menu != null && !menu.isDisposed ()) {
614
		menu.dispose ();
615
	}
616
	menu = null;
545
	control = null;
617
	control = null;
546
	toolTipText = null;
618
	toolTipText = null;
547
	image = disabledImage = hotImage = null;
619
	image = disabledImage = hotImage = null;
Lines 568-573 Link Here
568
640
569
/**
641
/**
570
 * Removes the listener from the collection of listeners who will
642
 * Removes the listener from the collection of listeners who will
643
 * be notified when the platform-specific drop-down menu trigger has
644
 * occurred.
645
 *
646
 * @param listener the listener which should no longer be notified
647
 *
648
 * @exception IllegalArgumentException <ul>
649
 *    <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
650
 * </ul>
651
 * @exception SWTException <ul>
652
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
653
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
654
 * </ul>
655
 *
656
 * @see MenuDetectListener
657
 * @see #addMenuDetectListener
658
 *
659
 * @since 3.4
660
 */
661
public void removeMenuDetectListener (MenuDetectListener listener) {
662
	checkWidget ();
663
	if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
664
	if (eventTable == null) return;
665
	eventTable.unhook (SWT.MenuDetect, listener);
666
}
667
668
/**
669
 * Removes the listener from the collection of listeners who will
571
 * be notified when the control is selected by the user.
670
 * be notified when the control is selected by the user.
572
 *
671
 *
573
 * @param listener the listener which should no longer be notified
672
 * @param listener the listener which should no longer be notified
Lines 636-641 Link Here
636
}
735
}
637
736
638
/**
737
/**
738
 * Sets the receiver's drop-down menu to the argument, which may be 
739
 * null indicating that no drop-down menu should be displayed.
740
 * <p>
741
 * If this property is null a drop-down menu can still be displayed manually by adding a
742
 * {@link SelectionListener} to the receiver and handling{@link SWT#ARROW} events.
743
 * <p>
744
 * The drop-down menu is activated when the arrow of an {@link SWT#DROP_DOWN}-styled
745
 * receiver or any portion of an {@link SWT#PUSH}-styled receiver is pressed.
746
 * </p>
747
 * 
748
 * @param menu the drop-down menu to be displayed when the receiver's arrow is pressed
749
 * @exception SWTException <ul>
750
 *    <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
751
 *    <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
752
 * </ul>
753
 * 
754
 * @since 3.4
755
 */
756
public void setMenu (Menu menu) {
757
	checkWidget();
758
	if (menu != null) {
759
		if (menu.isDisposed()) SWT.error(SWT.ERROR_INVALID_ARGUMENT);
760
		if ((menu.style & SWT.POP_UP) == 0) {
761
			error (SWT.ERROR_MENU_NOT_POP_UP);
762
		}
763
		if (menu.parent != parent.menuShell ()) {
764
			error (SWT.ERROR_INVALID_PARENT);
765
		}
766
	}
767
	this.menu = menu;
768
}
769
770
/**
639
 * Enables the receiver if the argument is <code>true</code>,
771
 * Enables the receiver if the argument is <code>true</code>,
640
 * and disables it otherwise.
772
 * and disables it otherwise.
641
 * <p>
773
 * <p>
Lines 833-836 Link Here
833
	OS.FrameworkElement_Margin (imageHandle, margin);
965
	OS.FrameworkElement_Margin (imageHandle, margin);
834
	OS.GCHandle_Free (margin);
966
	OS.GCHandle_Free (margin);
835
}
967
}
968
969
private boolean sendMenuDetectEvent (int x, int y, int detail) {
970
	Event event = new Event ();
971
	event.detail = detail;
972
	event.x = x;
973
	event.y = y;
974
	this.sendEvent (SWT.MenuDetect, event);
975
	return event.doit && menu != null && !menu.isDisposed ();
976
}
977
836
}
978
}

Return to bug 193318