public abstract class BaseCombo
extends org.eclipse.swt.widgets.Canvas
Modifier and Type | Class and Description |
---|---|
protected class |
BaseCombo.DropComboLayout
Special layout implementation to position the combo's drop-down Button
within its Text.
|
Modifier and Type | Field and Description |
---|---|
protected VButton |
button
The Button widget of a DROP_DOWN style combo.
|
protected static int |
BUTTON_ALWAYS
A constant indicating that the drop down button is always visible.
|
protected static int |
BUTTON_AUTO
A constant indicating that the drop down button is visible when the text
box has the focus, and is hidden otherwise.
|
protected static int |
BUTTON_NEVER
A constant indicating that the drop down button is never visible.
|
protected static int |
BUTTON_ONLY
A style constant indicating that this combo will only have a drop down
button, rather than a button and a text box.
|
(package private) boolean |
buttonActive
boolean to disable button on open state.
|
protected static boolean |
carbon
true if the platform is carbon, false otherwise
|
protected org.eclipse.swt.widgets.Control |
content
The widget contents of the popup Shell in a DROP_DOWN combo or the full
contents of a SIMPLE combo.
|
protected org.eclipse.swt.widgets.Shell |
contentShell
The popup Shell widget of a DROP_DOWN style combo.
|
protected boolean |
defaultButtonImage
True if a default image should be used for the button; false otherwise -
as is the case when an image is set using
setButtonImage(Image) |
protected static boolean |
gtk
true if the platform is gtk, false otherwise
|
protected boolean |
leftAlign
Flag to indicate that this combo's BUTTON should be displayed on the left
side of its Text.
|
protected VPanel |
panel
The VPanel that is the base of this widget.
|
protected boolean |
simple
Flag to indicate that this is a SIMPLE style combo.
|
protected int |
style
The style bits requested.
|
protected VNative<org.eclipse.swt.widgets.Text> |
text
The Text widget of a DROP_DOWN style combo.
|
protected static int |
textMarginHeight
A constant value used to pad the computed height for this widget, so that
the combo's Button will fit without clipping its top and bottom borders.
|
protected static boolean |
win32
true if the platform is win32, false otherwise
|
Constructor and Description |
---|
BaseCombo(org.eclipse.swt.widgets.Composite parent,
int style)
Main constructor -- must be called by all subclasses in their own
constructors.
|
Modifier and Type | Method and Description |
---|---|
void |
addKeyListener(org.eclipse.swt.events.KeyListener listener)
Adds the listener to the collection of listeners who will
be notified when keys are pressed and released on the system keyboard, by sending
it one of the messages defined in the
KeyListener
interface. |
void |
addModifyListener(org.eclipse.swt.events.ModifyListener listener)
Adds the listener to the collection of listeners who will be notified
when the receiver's text is modified, by sending it one of the messages
defined in the
ModifyListener interface.Note that this is NOT the correct way to listen for changes in the underlying model for the combo. |
void |
addTraverseListener(org.eclipse.swt.events.TraverseListener listener)
Adds the listener to the collection of listeners who will
be notified when traversal events occur, by sending it
one of the messages defined in the
TraverseListener
interface. |
protected boolean |
checkButton() |
protected boolean |
checkContent() |
protected boolean |
checkContentShell() |
protected boolean |
checkText() |
protected static boolean |
containsControl(org.eclipse.swt.widgets.Control control,
org.eclipse.swt.widgets.Composite composite)
A recursive method to find out if a composite is an ancestor of a
control.
|
protected void |
doSetButtonImage(org.eclipse.swt.graphics.Image image) |
protected org.eclipse.swt.widgets.Control |
getContent() |
protected org.eclipse.swt.widgets.Shell |
getContentShell() |
boolean |
getEditable()
Returns the editable state.
|
boolean |
getEnabled()
Fixes bug 181442: [CDateTime] Incorrect getEnabled()
|
protected boolean |
getHoldOpen() |
org.eclipse.swt.widgets.Menu |
getMenu()
returns the menu for this combo
|
protected VControl |
getStretchControl() |
int |
getStyle() |
java.lang.String |
getText()
Returns the text of this combo
|
protected boolean |
isDropDown() |
boolean |
isOpen() |
protected boolean |
isRTL() |
protected boolean |
isSimple() |
protected void |
postClose(org.eclipse.swt.widgets.Shell popup)
called just after the content shell is set not-visible and has
"closed"
|
protected void |
postOpen(org.eclipse.swt.widgets.Shell popup)
called after the content shell is set visible and has "opened"
|
protected void |
preClose(org.eclipse.swt.widgets.Shell popup)
called just before the content shell is set not-visible and
"closes"
|
protected void |
preOpen(org.eclipse.swt.widgets.Shell popup)
called just before the content shell is set visible and "opens"
|
void |
removeKeyListener(org.eclipse.swt.events.KeyListener listener)
Removes the listener from the collection of listeners who will
be notified when keys are pressed and released on the system keyboard.
|
void |
removeModifyListener(org.eclipse.swt.events.ModifyListener listener)
Removes the listener from the collection of listeners who will be
notified when the receiver's text is modified.
|
void |
removeTraverseListener(org.eclipse.swt.events.TraverseListener listener)
Removes the listener from the collection of listeners who will
be notified when traversal events occur.
|
void |
setBackground(org.eclipse.swt.graphics.Color color) |
protected void |
setButtonAlignment(int alignment)
Set the alignment of the button in relation to the text box.
|
protected void |
setButtonImage(org.eclipse.swt.graphics.Image image)
Set the custom image for the drop down button.
|
protected void |
setButtonText(java.lang.String text)
Set the text for the drop down button.
|
protected void |
setButtonVisibility(int visibility)
Set the visibility style of the drop button.
|
protected void |
setButtonVisible(boolean visible)
Set the visible state of the button
|
protected void |
setContent(org.eclipse.swt.widgets.Control content)
set the content of the popup shell
|
protected abstract boolean |
setContentFocus()
Called when the popup shell has been open, this method provides a
location for subclasses to set the focus to the content.
|
void |
setEditable(boolean editable)
Sets the editable state.
|
void |
setEnabled(boolean enabled) |
boolean |
setFocus() |
void |
setFont(org.eclipse.swt.graphics.Font font) |
void |
setForeground(org.eclipse.swt.graphics.Color color) |
protected void |
setHoldOpen(boolean holdOpen)
if holdOpen is true, the popup shell will not close regardless of events
and/or calls to popUp(false) until holdOpen is first set false
|
void |
setMenu(org.eclipse.swt.widgets.Menu menu)
Sets the menu for the Text widget of this DropCombo
|
protected void |
setModifyEventProperties(org.eclipse.swt.widgets.Event e)
Provides a chance for subclasses to set the properties of the modify
event called when the text is modified.
|
protected void |
setOpen(boolean open)
Convenience method for BaseCombo:setOpen(boolean, Runnable), omitting optional runnable.
|
protected void |
setOpen(boolean open,
java.lang.Runnable callback)
If 'open' is true, then open the popup shell (time/date picker) (set to visible)
If 'open' is false, close the popup shell (set to not visible) If content == null or isOpen() == open this
method simply returns.If contentShell == null then contentShell will be created. |
protected void |
setPositionControl(VControl positionControl)
sets the control to which the popup will align itself
|
protected void |
setStretch(boolean stretch)
If stretch is false, then the width of the popup will be set to its
preferred width (via computeSize(SWT.DEFAULT, SWT.DEFAULT))
|
void |
setToolTipText(java.lang.String tooltip)
Sets the tooltip on the text and button parts of this Composite widget.
|
drawBackground, getCaret, getIME, scroll, setCaret, setIME
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setLayout, setLayoutDeferred, setTabList
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, computeSize, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getFont, getForeground, getLayoutData, getLocation, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, requestLayout, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setLayoutData, setLocation, setLocation, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString
protected static final boolean carbon
protected static final boolean gtk
protected static final boolean win32
protected static final int textMarginHeight
protected static final int BUTTON_ONLY
protected static final int BUTTON_ALWAYS
BUTTON_AUTO
,
BUTTON_NEVER
,
Constant Field Valuesprotected static final int BUTTON_NEVER
This setting may be useful if the subclass of this BaseCombo allows
programmatic opening and closing of the drop down shell via
setOpen(boolean)
, or a similar method.
protected static final int BUTTON_AUTO
BUTTON_ALWAYS
,
BUTTON_NEVER
,
Constant Field Valuesboolean buttonActive
protected VPanel panel
protected VButton button
protected boolean defaultButtonImage
setButtonImage(Image)
setButtonImage(Image)
protected VNative<org.eclipse.swt.widgets.Text> text
protected org.eclipse.swt.widgets.Shell contentShell
protected org.eclipse.swt.widgets.Control content
protected int style
getStyle()
if invalid bits were requested.protected boolean simple
protected boolean leftAlign
public BaseCombo(org.eclipse.swt.widgets.Composite parent, int style)
SWT.TOGGLE, SWT.PUSH, SWT.ARROW, SWT.FLAT, SWT.TRAIL, SWT.LEAD, SWT.BORDER, SWT.SIMPLE, SWT.DROP_DOWN
parent
- the visual parent of this widgetstyle
- the requested SWT style bitmask for this widgetprotected static boolean containsControl(org.eclipse.swt.widgets.Control control, org.eclipse.swt.widgets.Composite composite)
control
- composite
- public void addKeyListener(org.eclipse.swt.events.KeyListener listener)
KeyListener
interface.
When a key listener is added to a control, the control will take part in widget traversal. By default, all traversal keys (such as the tab key and so on) are delivered to the control. In order for a control to take part in traversal, it should listen for traversal events. Otherwise, the user can traverse into a control but not out. Note that native controls such as table and tree implement key traversal in the operating system. It is not necessary to add traversal listeners for these controls, unless you want to override the default traversal.
addKeyListener
in class org.eclipse.swt.widgets.Control
listener
- the listener which should be notifiedjava.lang.IllegalArgumentException
- org.eclipse.swt.SWTException
- KeyListener
,
removeKeyListener(org.eclipse.swt.events.KeyListener)
public void addModifyListener(org.eclipse.swt.events.ModifyListener listener)
ModifyListener
interface.SelectionListener
.listener
- the listener which should be notifiedjava.lang.IllegalArgumentException
- org.eclipse.swt.SWTException
- ModifyListener
,
removeModifyListener(org.eclipse.swt.events.ModifyListener)
public void addTraverseListener(org.eclipse.swt.events.TraverseListener listener)
TraverseListener
interface.addTraverseListener
in class org.eclipse.swt.widgets.Control
listener
- the listener which should be notifiedjava.lang.IllegalArgumentException
- org.eclipse.swt.SWTException
- TraverseListener
,
removeTraverseListener(org.eclipse.swt.events.TraverseListener)
protected boolean checkButton()
button
field is in a fit state to be usedprotected boolean checkContent()
content
field is in a fit state to be usedprotected boolean checkContentShell()
contentShell
field is in a fit state to be
usedprotected boolean checkText()
text
field is in a fit state to be usedprotected final void doSetButtonImage(org.eclipse.swt.graphics.Image image)
image
- protected org.eclipse.swt.widgets.Control getContent()
protected org.eclipse.swt.widgets.Shell getContentShell()
public boolean getEditable()
org.eclipse.swt.SWTException
- public boolean getEnabled()
getEnabled
in class org.eclipse.swt.widgets.Control
protected boolean getHoldOpen()
public org.eclipse.swt.widgets.Menu getMenu()
getMenu
in class org.eclipse.swt.widgets.Control
protected VControl getStretchControl()
public int getStyle()
getStyle
in class org.eclipse.swt.widgets.Widget
public java.lang.String getText()
protected boolean isDropDown()
public boolean isOpen()
protected boolean isRTL()
protected boolean isSimple()
protected void postClose(org.eclipse.swt.widgets.Shell popup)
override if you want to do something with the shell just after becoming not visible
popup
- preClose(Shell)
protected void postOpen(org.eclipse.swt.widgets.Shell popup)
override if you want to do something with the shell just after becoming visible
popup
- preOpen(Shell)
protected void preClose(org.eclipse.swt.widgets.Shell popup)
override if you want to do something with the shell prior to it becoming not visible
popup
- postClose(Shell)
protected void preOpen(org.eclipse.swt.widgets.Shell popup)
override if you want to do something with the shell prior to it becoming visible
popup
- postOpen(Shell)
public void removeKeyListener(org.eclipse.swt.events.KeyListener listener)
removeKeyListener
in class org.eclipse.swt.widgets.Control
listener
- the listener which should no longer be notifiedjava.lang.IllegalArgumentException
- org.eclipse.swt.SWTException
- KeyListener
,
addKeyListener(org.eclipse.swt.events.KeyListener)
public void removeModifyListener(org.eclipse.swt.events.ModifyListener listener)
listener
- the listener which should no longer be notifiedjava.lang.IllegalArgumentException
- org.eclipse.swt.SWTException
- ModifyListener
,
addModifyListener(org.eclipse.swt.events.ModifyListener)
public void removeTraverseListener(org.eclipse.swt.events.TraverseListener listener)
removeTraverseListener
in class org.eclipse.swt.widgets.Control
listener
- the listener which should no longer be notifiedjava.lang.IllegalArgumentException
- org.eclipse.swt.SWTException
- TraverseListener
,
addTraverseListener(org.eclipse.swt.events.TraverseListener)
protected void setButtonAlignment(int alignment)
alignment
- can be either SWT.LEFT or SWT.RIGHT. Other values have no
effect.protected void setButtonImage(org.eclipse.swt.graphics.Image image)
image
- protected void setButtonText(java.lang.String text)
text
- protected void setButtonVisibility(int visibility)
The style will be forced to NEVER if the contents are null
visibility
- the visibility style constantsetButtonVisible(boolean)
protected void setButtonVisible(boolean visible)
Note: This method is only useful when the button's visibility style is either AUTO or MANUAL.
visible
- setButtonVisibility(int)
protected void setContent(org.eclipse.swt.widgets.Control content)
Can be a single control, or a Composite consisting of many controls
content
- protected abstract boolean setContentFocus()
public void setEditable(boolean editable)
editable
- the new editable statepublic void setEnabled(boolean enabled)
setEnabled
in class org.eclipse.swt.widgets.Control
public boolean setFocus()
setFocus
in class org.eclipse.swt.widgets.Composite
public void setFont(org.eclipse.swt.graphics.Font font)
setFont
in class org.eclipse.swt.widgets.Canvas
Canvas.setFont(org.eclipse.swt.graphics.Font)
public void setBackground(org.eclipse.swt.graphics.Color color)
setBackground
in class org.eclipse.swt.widgets.Control
Control.setBackground(org.eclipse.swt.graphics.Color)
public void setForeground(org.eclipse.swt.graphics.Color color)
setForeground
in class org.eclipse.swt.widgets.Control
Control.setForeground(org.eclipse.swt.graphics.Color)
protected void setHoldOpen(boolean holdOpen)
merely sets the holdOpen flag, does not change popup visibility state
holdOpen
- public void setMenu(org.eclipse.swt.widgets.Menu menu)
Note that setting the menu to null causes the native menu to be used
If the intent is to disable the menu, then set it to a blank menu
setMenu
in class org.eclipse.swt.widgets.Control
protected void setModifyEventProperties(org.eclipse.swt.widgets.Event e)
For example, CDateTime overrides this method to set the data field to the
current time:
e.data = calendar.getTime();
e
- protected void setOpen(boolean open)
open
- true to open the popup (date/time picker) shell, false to close it.
setOpen(boolean, Runnable)
protected void setOpen(boolean open, java.lang.Runnable callback)
content == null
or isOpen() == open
this
method simply returns.contentShell == null
then contentShell
will be created.open
- true to open the popup (date/time picker) shell, false to close it.callback
- an optional runnable to be run when the operation completes.
setOpen(boolean)
protected void setPositionControl(VControl positionControl)
the control does not necessarily need to be "this" or the button, but will default to "this" if positionControl == null
positionControl
- protected void setStretch(boolean stretch)
However, if stretchControl is true, the width of the popup will be stretched to equal the width of this control (if, however, popup's preferred width is greater than this control's width popup will not be shrunk down)
stretch
- public void setToolTipText(java.lang.String tooltip)
setToolTipText
in class org.eclipse.swt.widgets.Control
tooltip
- the new tooltip text