Lines 11-16
Link Here
|
11 |
package org.eclipse.swt.widgets; |
11 |
package org.eclipse.swt.widgets; |
12 |
|
12 |
|
13 |
|
13 |
|
|
|
14 |
import org.eclipse.swt.internal.ToolItemHelper; |
14 |
import org.eclipse.swt.internal.motif.*; |
15 |
import org.eclipse.swt.internal.motif.*; |
15 |
import org.eclipse.swt.*; |
16 |
import org.eclipse.swt.*; |
16 |
import org.eclipse.swt.graphics.*; |
17 |
import org.eclipse.swt.graphics.*; |
Lines 35-40
Link Here
|
35 |
public class ToolItem extends Item { |
36 |
public class ToolItem extends Item { |
36 |
ToolBar parent; |
37 |
ToolBar parent; |
37 |
Image hotImage, disabledImage; |
38 |
Image hotImage, disabledImage; |
|
|
39 |
Menu dropDownMenu; |
38 |
String toolTipText; |
40 |
String toolTipText; |
39 |
Control control; |
41 |
Control control; |
40 |
int width = DEFAULT_SEPARATOR_WIDTH; |
42 |
int width = DEFAULT_SEPARATOR_WIDTH; |
Lines 216-222
Link Here
|
216 |
} |
218 |
} |
217 |
} |
219 |
} |
218 |
if (state != 0) setInputState (event, state); |
220 |
if (state != 0) setInputState (event, state); |
219 |
postEvent (SWT.Selection, event); |
221 |
if (event.detail == SWT.ARROW) { |
|
|
222 |
sendEvent (SWT.Selection, event); |
223 |
if (event.doit) { |
224 |
ToolItemHelper.showDropDownMenu (this); |
225 |
} |
226 |
} else { |
227 |
postEvent (SWT.Selection, event); |
228 |
} |
220 |
} |
229 |
} |
221 |
|
230 |
|
222 |
Point computeSize (GC gc) { |
231 |
Point computeSize (GC gc) { |
Lines 360-365
Link Here
|
360 |
return disabledImage; |
369 |
return disabledImage; |
361 |
} |
370 |
} |
362 |
/** |
371 |
/** |
|
|
372 |
* Returns the receiver's drop-down menu if it has one, or null |
373 |
* if it does not. |
374 |
* <p> |
375 |
* The drop-down menu is activated when the arrow of an {@link SWT#DROP_DOWN}-styled receiver is pressed. |
376 |
* </p> |
377 |
* |
378 |
* @return the receiver's drop-down menu |
379 |
* @exception SWTException <ul> |
380 |
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
381 |
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
382 |
* </ul> |
383 |
*/ |
384 |
public Menu getDropDownMenu () { |
385 |
checkWidget(); |
386 |
return dropDownMenu; |
387 |
} |
388 |
/** |
363 |
* Returns <code>true</code> if the receiver is enabled, and |
389 |
* Returns <code>true</code> if the receiver is enabled, and |
364 |
* <code>false</code> otherwise. A disabled control is typically |
390 |
* <code>false</code> otherwise. A disabled control is typically |
365 |
* not selectable from the user interface and draws with an |
391 |
* not selectable from the user interface and draws with an |
Lines 702-707
Link Here
|
702 |
disabledImage = image; |
728 |
disabledImage = image; |
703 |
if (!getEnabled ()) redraw (); |
729 |
if (!getEnabled ()) redraw (); |
704 |
} |
730 |
} |
|
|
731 |
/** |
732 |
* Sets the receiver's drop-down menu to the argument, which may be |
733 |
* null indicating that no drop-down menu should be displayed. |
734 |
* <p> |
735 |
* If this property is null a drop-down menu can still be displayed manually by adding a |
736 |
* {@link SelectionListener} to the receiver and handling{@link SWT#ARROW} events. |
737 |
* <p> |
738 |
* The drop-down menu is activated when the arrow of an {@link SWT#DROP_DOWN}-styled receiver is pressed. |
739 |
* Attempts to set a drop-dwn menu for a receiver that does not have the {@link SWT#DROP_DOWN} |
740 |
* style are ignored. |
741 |
* </p> |
742 |
* |
743 |
* @param menu the drop-down menu to be displayed when the receiver's arrow is pressed |
744 |
* @exception SWTException <ul> |
745 |
* <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li> |
746 |
* <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li> |
747 |
* </ul> |
748 |
*/ |
749 |
public void setDropDownMenu (Menu menu) { |
750 |
checkWidget(); |
751 |
if ((style & SWT.DROP_DOWN) == 0) return; |
752 |
dropDownMenu = menu; |
753 |
} |
705 |
boolean setFocus () { |
754 |
boolean setFocus () { |
706 |
if ((style & SWT.SEPARATOR) != 0) return false; |
755 |
if ((style & SWT.SEPARATOR) != 0) return false; |
707 |
return XmProcessTraversal (handle, OS.XmTRAVERSE_CURRENT); |
756 |
return XmProcessTraversal (handle, OS.XmTRAVERSE_CURRENT); |