1 /*******************************************************************************
2 * Copyright (c) 2000, 2018 IBM Corporation and others.
4 * This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License 2.0
6 * which accompanies this distribution, and is available at
7 * https://www.eclipse.org/legal/epl-2.0/
9 * SPDX-License-Identifier: EPL-2.0
12 * IBM Corporation - initial API and implementation
13 *******************************************************************************/
14 package org.eclipse.swt.widgets;
17 import org.eclipse.swt.*;
18 import org.eclipse.swt.events.*;
19 import org.eclipse.swt.graphics.*;
20 import org.eclipse.swt.internal.*;
21 import org.eclipse.swt.internal.win32.*;
24 * Instances of this class are selectable user interface
25 * objects that represent the dynamically positionable
26 * areas of a <code>CoolBar</code>.
28 * <dt><b>Styles:</b></dt>
30 * <dt><b>Events:</b></dt>
34 * IMPORTANT: This class is <em>not</em> intended to be subclassed.
37 * @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>
38 * @noextend This class is not intended to be subclassed by clients.
40 public class CoolItem extends Item {
44 boolean ideal, minimum;
47 * Constructs a new instance of this class given its parent
48 * (which must be a <code>CoolBar</code>) and a style value
49 * describing its behavior and appearance. The item is added
50 * to the end of the items maintained by its parent.
52 * The style value is either one of the style constants defined in
53 * class <code>SWT</code> which is applicable to instances of this
54 * class, or must be built by <em>bitwise OR</em>'ing together
55 * (that is, using the <code>int</code> "|" operator) two or more
56 * of those <code>SWT</code> style constants. The class description
57 * lists the style constants that are applicable to the class.
58 * Style bits are also inherited from superclasses.
61 * @param parent a composite control which will be the parent of the new instance (cannot be null)
62 * @param style the style of control to construct
64 * @exception IllegalArgumentException <ul>
65 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
67 * @exception SWTException <ul>
68 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
69 * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
73 * @see Widget#checkSubclass
74 * @see Widget#getStyle
76 public CoolItem (CoolBar parent, int style) {
77 super (parent, style);
79 parent.createItem (this, parent.getItemCount ());
83 * Constructs a new instance of this class given its parent
84 * (which must be a <code>CoolBar</code>), a style value
85 * describing its behavior and appearance, and the index
86 * at which to place it in the items maintained by its parent.
88 * The style value is either one of the style constants defined in
89 * class <code>SWT</code> which is applicable to instances of this
90 * class, or must be built by <em>bitwise OR</em>'ing together
91 * (that is, using the <code>int</code> "|" operator) two or more
92 * of those <code>SWT</code> style constants. The class description
93 * lists the style constants that are applicable to the class.
94 * Style bits are also inherited from superclasses.
97 * @param parent a composite control which will be the parent of the new instance (cannot be null)
98 * @param style the style of control to construct
99 * @param index the zero-relative index at which to store the receiver in its parent
101 * @exception IllegalArgumentException <ul>
102 * <li>ERROR_NULL_ARGUMENT - if the parent is null</li>
103 * <li>ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)</li>
105 * @exception SWTException <ul>
106 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent</li>
107 * <li>ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass</li>
111 * @see Widget#checkSubclass
112 * @see Widget#getStyle
114 public CoolItem (CoolBar parent, int style, int index) {
115 super (parent, style);
116 this.parent = parent;
117 parent.createItem (this, index);
121 * Adds the listener to the collection of listeners that will
122 * be notified when the control is selected by the user, by sending it one
123 * of the messages defined in the <code>SelectionListener</code>
126 * If <code>widgetSelected</code> is called when the mouse is over
127 * the drop-down arrow (or 'chevron') portion of the cool item,
128 * the event object detail field contains the value <code>SWT.ARROW</code>,
129 * and the x and y fields in the event object represent the point at
130 * the bottom left of the chevron, where the menu should be popped up.
131 * <code>widgetDefaultSelected</code> is not called.
134 * @param listener the listener which should be notified when the control is selected by the user
136 * @exception IllegalArgumentException <ul>
137 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
139 * @exception SWTException <ul>
140 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
141 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
144 * @see SelectionListener
145 * @see #removeSelectionListener
146 * @see SelectionEvent
150 public void addSelectionListener(SelectionListener listener) {
152 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
153 TypedListener typedListener = new TypedListener (listener);
154 addListener (SWT.Selection,typedListener);
155 addListener (SWT.DefaultSelection,typedListener);
159 protected void checkSubclass () {
160 if (!isValidSubclass ()) error (SWT.ERROR_INVALID_SUBCLASS);
164 * Returns the preferred size of the receiver.
166 * The <em>preferred size</em> of a <code>CoolItem</code> is the size that
167 * it would best be displayed at. The width hint and height hint arguments
168 * allow the caller to ask the instance questions such as "Given a particular
169 * width, how high does it need to be to show all of the contents?"
170 * To indicate that the caller does not wish to constrain a particular
171 * dimension, the constant <code>SWT.DEFAULT</code> is passed for the hint.
174 * @param wHint the width hint (can be <code>SWT.DEFAULT</code>)
175 * @param hHint the height hint (can be <code>SWT.DEFAULT</code>)
176 * @return the preferred size
178 * @exception SWTException <ul>
179 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
180 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
186 * @see Control#getBorderWidth
187 * @see Scrollable#computeTrim
188 * @see Scrollable#getClientArea
190 public Point computeSize (int wHint, int hHint) {
192 wHint = (wHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(wHint) : wHint);
193 hHint = (hHint != SWT.DEFAULT ? DPIUtil.autoScaleUp(hHint) : hHint);
194 return DPIUtil.autoScaleDown(computeSizeInPixels(wHint, hHint));
196 Point computeSizeInPixels (int wHint, int hHint) {
197 int index = parent.indexOf (this);
198 if (index == -1) return new Point (0, 0);
199 int width = wHint, height = hHint;
200 if (wHint == SWT.DEFAULT) width = 32;
201 if (hHint == SWT.DEFAULT) height = 32;
202 if ((parent.style & SWT.VERTICAL) != 0) {
203 height += parent.getMargin (index);
205 width += parent.getMargin (index);
207 return new Point (width, height);
211 void destroyWidget () {
212 parent.destroyItem (this);
217 * Returns a rectangle describing the receiver's size and location
218 * relative to its parent.
220 * @return the receiver's bounding rectangle
222 * @exception SWTException <ul>
223 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
224 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
227 public Rectangle getBounds () {
229 return DPIUtil.autoScaleDown(getBoundsInPixels());
232 Rectangle getBoundsInPixels () {
233 int index = parent.indexOf (this);
234 if (index == -1) return new Rectangle (0, 0, 0, 0);
235 long hwnd = parent.handle;
236 RECT rect = new RECT ();
237 OS.SendMessage (hwnd, OS.RB_GETRECT, index, rect);
238 MARGINS margins = new MARGINS ();
239 OS.SendMessage (hwnd, OS.RB_GETBANDMARGINS, 0, margins);
240 rect.left -= margins.cxLeftWidth;
241 rect.right += margins.cxRightWidth;
242 if (!parent.isLastItemOfRow (index)) {
243 rect.right += (parent.style & SWT.FLAT) == 0 ? CoolBar.SEPARATOR_WIDTH : 0;
245 int width = rect.right - rect.left;
246 int height = rect.bottom - rect.top;
247 if ((parent.style & SWT.VERTICAL) != 0) {
248 return new Rectangle (rect.top, rect.left, height, width);
250 return new Rectangle (rect.left, rect.top, width, height);
253 Rectangle getClientArea () {
255 int index = parent.indexOf (this);
256 if (index == -1) return new Rectangle (0, 0, 0, 0);
257 long hwnd = parent.handle;
258 RECT insetRect = new RECT ();
259 OS.SendMessage (hwnd, OS.RB_GETBANDBORDERS, index, insetRect);
260 RECT rect = new RECT ();
261 OS.SendMessage (hwnd, OS.RB_GETRECT, index, rect);
262 int x = rect.left + insetRect.left;
264 int width = rect.right - rect.left - insetRect.left;
265 int height = rect.bottom - rect.top;
266 if ((parent.style & SWT.FLAT) == 0) {
268 width -= insetRect.right;
269 height -= insetRect.top + insetRect.bottom;
272 REBARBANDINFO rbBand = new REBARBANDINFO ();
273 rbBand.cbSize = REBARBANDINFO.sizeof;
274 rbBand.fMask = OS.RBBIM_HEADERSIZE;
275 OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
276 width = width - rbBand.cxHeader + 1;
278 return new Rectangle (x, y, Math.max (0, width), Math.max (0, height));
282 * Returns the control that is associated with the receiver.
284 * @return the control that is contained by the receiver
286 * @exception SWTException <ul>
287 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
288 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
291 public Control getControl () {
297 * Returns the receiver's parent, which must be a <code>CoolBar</code>.
299 * @return the receiver's parent
301 * @exception SWTException <ul>
302 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
303 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
306 public CoolBar getParent () {
312 void releaseHandle () {
313 super.releaseHandle ();
320 * Sets the control that is associated with the receiver
323 * @param control the new control that will be contained by the receiver
325 * @exception IllegalArgumentException <ul>
326 * <li>ERROR_INVALID_ARGUMENT - if the control has been disposed</li>
327 * <li>ERROR_INVALID_PARENT - if the control is not in the same widget tree</li>
329 * @exception SWTException <ul>
330 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
331 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
334 public void setControl (Control control) {
336 if (control != null) {
337 if (control.isDisposed()) error (SWT.ERROR_INVALID_ARGUMENT);
338 if (control.parent != parent) error (SWT.ERROR_INVALID_PARENT);
340 int index = parent.indexOf (this);
341 if (index == -1) return;
342 if (this.control != null && this.control.isDisposed ()) {
345 Control oldControl = this.control, newControl = control;
346 long hwnd = parent.handle;
347 long hwndChild = newControl != null ? control.topHandle () : 0;
348 REBARBANDINFO rbBand = new REBARBANDINFO ();
349 rbBand.cbSize = REBARBANDINFO.sizeof;
350 rbBand.fMask = OS.RBBIM_CHILD;
351 rbBand.hwndChild = hwndChild;
352 this.control = newControl;
355 * Feature in Windows. When Windows sets the rebar band child,
356 * it makes the new child visible and hides the old child and
357 * moves the new child to the top of the Z-order. The fix is
358 * to save and restore the visibility and Z-order.
361 if (newControl != null) {
362 hwndAbove = OS.GetWindow (hwndChild, OS.GW_HWNDPREV);
364 boolean hideNew = newControl != null && !newControl.getVisible ();
365 boolean showOld = oldControl != null && oldControl.getVisible ();
366 OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);
367 if (hideNew) newControl.setVisible (false);
368 if (showOld) oldControl.setVisible (true);
369 if (hwndAbove != 0 && hwndAbove != hwndChild) {
370 int flags = OS.SWP_NOSIZE | OS.SWP_NOMOVE | OS.SWP_NOACTIVATE;
371 OS.SetWindowPos (hwndChild, hwndAbove, 0, 0, 0, 0, flags);
376 * Returns a point describing the receiver's ideal size.
377 * The x coordinate of the result is the ideal width of the receiver.
378 * The y coordinate of the result is the ideal height of the receiver.
380 * @return the receiver's ideal size
382 * @exception SWTException <ul>
383 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
384 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
387 public Point getPreferredSize () {
389 return DPIUtil.autoScaleDown(getPreferredSizeInPixels());
392 Point getPreferredSizeInPixels () {
393 int index = parent.indexOf (this);
394 if (index == -1) return new Point (0, 0);
395 long hwnd = parent.handle;
396 REBARBANDINFO rbBand = new REBARBANDINFO ();
397 rbBand.cbSize = REBARBANDINFO.sizeof;
398 rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_IDEALSIZE;
399 OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
400 int width = rbBand.cxIdeal + parent.getMargin (index);
401 if ((parent.style & SWT.VERTICAL) != 0) {
402 return new Point (rbBand.cyMaxChild, width);
404 return new Point (width, rbBand.cyMaxChild);
408 * Sets the receiver's ideal size to the point specified by the arguments.
410 * @param width the new ideal width for the receiver
411 * @param height the new ideal height for the receiver
413 * @exception SWTException <ul>
414 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
415 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
418 public void setPreferredSize (int width, int height) {
420 setPreferredSizeInPixels(DPIUtil.autoScaleUp(width), DPIUtil.autoScaleUp(height));
423 void setPreferredSizeInPixels (int width, int height) {
424 int index = parent.indexOf (this);
425 if (index == -1) return;
426 width = Math.max (0, width);
427 height = Math.max (0, height);
429 long hwnd = parent.handle;
430 int cxIdeal, cyMaxChild;
431 if ((parent.style & SWT.VERTICAL) != 0) {
432 cxIdeal = Math.max (0, height - parent.getMargin (index));
435 cxIdeal = Math.max (0, width - parent.getMargin (index));
438 REBARBANDINFO rbBand = new REBARBANDINFO ();
439 rbBand.cbSize = REBARBANDINFO.sizeof;
441 /* Get the child size fields first so we don't overwrite them. */
442 rbBand.fMask = OS.RBBIM_CHILDSIZE;
443 OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
445 /* Set the size fields we are currently modifying. */
446 rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_IDEALSIZE;
447 rbBand.cxIdeal = cxIdeal;
448 rbBand.cyMaxChild = cyMaxChild;
449 if (!minimum) rbBand.cyMinChild = cyMaxChild;
450 OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);
454 * Sets the receiver's ideal size to the point specified by the argument.
456 * @param size the new ideal size for the receiver
458 * @exception IllegalArgumentException <ul>
459 * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
461 * @exception SWTException <ul>
462 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
463 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
466 public void setPreferredSize (Point size) {
468 if (size == null) error(SWT.ERROR_NULL_ARGUMENT);
469 size = DPIUtil.autoScaleUp(size);
470 setPreferredSizeInPixels(size.x, size.y);
474 * Returns a point describing the receiver's size. The
475 * x coordinate of the result is the width of the receiver.
476 * The y coordinate of the result is the height of the
479 * @return the receiver's size
481 * @exception SWTException <ul>
482 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
483 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
486 public Point getSize () {
488 return DPIUtil.autoScaleDown(getSizeInPixels());
491 Point getSizeInPixels() {
492 int index = parent.indexOf (this);
493 if (index == -1) new Point (0, 0);
494 long hwnd = parent.handle;
495 RECT rect = new RECT ();
496 OS.SendMessage (hwnd, OS.RB_GETRECT, index, rect);
497 MARGINS margins = new MARGINS ();
498 OS.SendMessage (hwnd, OS.RB_GETBANDMARGINS, 0, margins);
499 rect.left -= margins.cxLeftWidth;
500 rect.right += margins.cxRightWidth;
501 if (!parent.isLastItemOfRow (index)) {
502 rect.right += (parent.style & SWT.FLAT) == 0 ? CoolBar.SEPARATOR_WIDTH : 0;
504 int width = rect.right - rect.left;
505 int height = rect.bottom - rect.top;
506 if ((parent.style & SWT.VERTICAL) != 0) {
507 return new Point (height, width);
509 return new Point (width, height);
513 * Sets the receiver's size to the point specified by the arguments.
515 * Note: Attempting to set the width or height of the
516 * receiver to a negative number will cause that
517 * value to be set to zero instead.
520 * @param width the new width for the receiver
521 * @param height the new height for the receiver
523 * @exception SWTException <ul>
524 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
525 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
528 public void setSize (int width, int height) {
530 setSizeInPixels(DPIUtil.autoScaleUp(width), DPIUtil.autoScaleUp(height));
533 void setSizeInPixels (int width, int height) {
534 int index = parent.indexOf (this);
535 if (index == -1) return;
536 width = Math.max (0, width);
537 height = Math.max (0, height);
538 long hwnd = parent.handle;
539 int cx, cyChild, cxIdeal;
540 if ((parent.style & SWT.VERTICAL) != 0) {
543 cxIdeal = Math.max (0, height - parent.getMargin (index));
547 cxIdeal = Math.max (0, width - parent.getMargin (index));
549 REBARBANDINFO rbBand = new REBARBANDINFO ();
550 rbBand.cbSize = REBARBANDINFO.sizeof;
552 /* Get the child size fields first so we don't overwrite them. */
553 rbBand.fMask = OS.RBBIM_CHILDSIZE | OS.RBBIM_IDEALSIZE;
554 OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
556 /* Set the size fields we are currently modifying. */
557 if (!ideal) rbBand.cxIdeal = cxIdeal;
558 if (!minimum) rbBand.cyMinChild = cyChild;
559 rbBand.cyChild = cyChild;
562 * Do not set the size for the last item on the row.
564 if (!parent.isLastItemOfRow (index)) {
565 MARGINS margins = new MARGINS ();
566 OS.SendMessage (hwnd, OS.RB_GETBANDMARGINS, 0, margins);
567 cx -= margins.cxLeftWidth + margins.cxRightWidth;
568 int separator = (parent.style & SWT.FLAT) == 0 ? CoolBar.SEPARATOR_WIDTH : 0;
569 rbBand.cx = cx - separator;
570 rbBand.fMask |= OS.RBBIM_SIZE;
572 OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);
576 * Sets the receiver's size to the point specified by the argument.
578 * Note: Attempting to set the width or height of the
579 * receiver to a negative number will cause them to be
580 * set to zero instead.
583 * @param size the new size for the receiver
585 * @exception IllegalArgumentException <ul>
586 * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
588 * @exception SWTException <ul>
589 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
590 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
593 public void setSize (Point size) {
595 if (size == null) error(SWT.ERROR_NULL_ARGUMENT);
596 size = DPIUtil.autoScaleUp(size);
597 setSizeInPixels(size.x, size.y);
601 * Returns the minimum size that the cool item can
602 * be resized to using the cool item's gripper.
604 * @return a point containing the minimum width and height of the cool item, in SWT logical points
606 * @exception SWTException <ul>
607 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
608 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
613 public Point getMinimumSize () {
615 return DPIUtil.autoScaleDown(getMinimumSizeInPixels());
618 Point getMinimumSizeInPixels () {
619 int index = parent.indexOf (this);
620 if (index == -1) return new Point (0, 0);
621 long hwnd = parent.handle;
622 REBARBANDINFO rbBand = new REBARBANDINFO ();
623 rbBand.cbSize = REBARBANDINFO.sizeof;
624 rbBand.fMask = OS.RBBIM_CHILDSIZE;
625 OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
626 if ((parent.style & SWT.VERTICAL) != 0) {
627 return new Point (rbBand.cyMinChild, rbBand.cxMinChild);
629 return new Point (rbBand.cxMinChild, rbBand.cyMinChild);
633 * Sets the minimum size that the cool item can be resized to
634 * using the cool item's gripper, to the point specified by the arguments.
636 * @param width the minimum width of the cool item, in SWT logical points
637 * @param height the minimum height of the cool item, in SWT logical points
639 * @exception SWTException <ul>
640 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
641 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
646 public void setMinimumSize (int width, int height) {
648 setMinimumSizeInPixels(DPIUtil.autoScaleUp(width), DPIUtil.autoScaleUp(height));
651 void setMinimumSizeInPixels (int width, int height) {
652 int index = parent.indexOf (this);
653 if (index == -1) return;
654 width = Math.max (0, width);
655 height = Math.max (0, height);
657 long hwnd = parent.handle;
658 int cxMinChild, cyMinChild;
659 if ((parent.style & SWT.VERTICAL) != 0) {
666 REBARBANDINFO rbBand = new REBARBANDINFO ();
667 rbBand.cbSize = REBARBANDINFO.sizeof;
669 /* Get the child size fields first so we don't overwrite them. */
670 rbBand.fMask = OS.RBBIM_CHILDSIZE;
671 OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
673 /* Set the size fields we are currently modifying. */
674 rbBand.cxMinChild = cxMinChild;
675 rbBand.cyMinChild = cyMinChild;
676 OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);
680 * Sets the minimum size that the cool item can be resized to
681 * using the cool item's gripper, to the point specified by the argument.
683 * @param size a point representing the minimum width and height of the cool item, in SWT logical points
685 * @exception IllegalArgumentException <ul>
686 * <li>ERROR_NULL_ARGUMENT - if the point is null</li>
688 * @exception SWTException <ul>
689 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
690 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
695 public void setMinimumSize (Point size) {
697 if (size == null) error (SWT.ERROR_NULL_ARGUMENT);
698 size = DPIUtil.autoScaleUp(size);
699 setMinimumSizeInPixels(size.x, size.y);
703 int index = parent.indexOf (this);
704 long hwnd = parent.handle;
705 REBARBANDINFO rbBand = new REBARBANDINFO ();
706 rbBand.cbSize = REBARBANDINFO.sizeof;
707 rbBand.fMask = OS.RBBIM_STYLE;
708 OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
709 return (rbBand.fStyle & OS.RBBS_BREAK) != 0;
712 void setWrap(boolean wrap) {
713 int index = parent.indexOf (this);
714 long hwnd = parent.handle;
715 REBARBANDINFO rbBand = new REBARBANDINFO ();
716 rbBand.cbSize = REBARBANDINFO.sizeof;
717 rbBand.fMask = OS.RBBIM_STYLE;
718 OS.SendMessage (hwnd, OS.RB_GETBANDINFO, index, rbBand);
720 rbBand.fStyle |= OS.RBBS_BREAK;
722 rbBand.fStyle &= ~OS.RBBS_BREAK;
724 OS.SendMessage (hwnd, OS.RB_SETBANDINFO, index, rbBand);
728 * Removes the listener from the collection of listeners that
729 * will be notified when the control is selected by the user.
731 * @param listener the listener which should no longer be notified
733 * @exception IllegalArgumentException <ul>
734 * <li>ERROR_NULL_ARGUMENT - if the listener is null</li>
736 * @exception SWTException <ul>
737 * <li>ERROR_WIDGET_DISPOSED - if the receiver has been disposed</li>
738 * <li>ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver</li>
741 * @see SelectionListener
742 * @see #addSelectionListener
746 public void removeSelectionListener(SelectionListener listener) {
748 if (listener == null) error (SWT.ERROR_NULL_ARGUMENT);
749 if (eventTable == null) return;
750 eventTable.unhook (SWT.Selection, listener);
751 eventTable.unhook (SWT.DefaultSelection,listener);