org.eclipse.swt.custom
Class CCombo

java.lang.Object
  |
  +--org.eclipse.swt.widgets.Widget
        |
        +--org.eclipse.swt.widgets.Control
              |
              +--org.eclipse.swt.widgets.Scrollable
                    |
                    +--org.eclipse.swt.widgets.Composite
                          |
                          +--org.eclipse.swt.custom.CCombo
All Implemented Interfaces:
Drawable

public final class CCombo
extends Composite

Safe: The CCombo class represents a selectable user interface object that combines a text field and a list and issues notificiation when an item is selected from the list.

Note that although this class is a subclass of Composite, it does not make sense to add children to it, or set a layout on it.

Styles:
BORDER, READ_ONLY, FLAT
Events:
Selection


Field Summary
(package private)  Button arrow
           
(package private)  boolean hasFocus
           
(package private) static int ITEMS_SHOWING
           
(package private)  List list
           
(package private)  Shell popup
           
(package private)  Text text
           
 
Fields inherited from class org.eclipse.swt.widgets.Composite
 
Fields inherited from class org.eclipse.swt.widgets.Scrollable
 
Fields inherited from class org.eclipse.swt.widgets.Control
handle
 
Fields inherited from class org.eclipse.swt.widgets.Widget
 
Constructor Summary
CCombo(Composite parent, int style)
          Enabled: Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.
 
Method Summary
 void add(String string)
          Enabled: Adds an item.
 void add(String string, int index)
          Enabled: Adds an item at an index.
 void addModifyListener(ModifyListener listener)
          Enabled: Adds the listener to receive events.
 void addSelectionListener(SelectionListener listener)
          Enabled: Adds the listener to receive events.
(package private)  void arrowEvent(Event event)
           
(package private) static int checkStyle(int style)
           
 void clearSelection()
          Enabled: Clears the current selection.
(package private)  void comboEvent(Event event)
           
 Point computeSize(int wHint, int hHint, boolean changed)
          Enabled:
 void deselect(int index)
          Enabled: Deselects an item.
 void deselectAll()
          Enabled: Deselects all items.
(package private)  void dropDown(boolean drop)
           
 Control[] getChildren()
          Enabled:
(package private)  boolean getEditable()
           
 String getItem(int index)
          Enabled: Gets an item at an index.
 int getItemCount()
          Enabled: Gets the number of items.
 int getItemHeight()
          Enabled: Gets the height of one item.
 String[] getItems()
          Enabled: Gets the items.
 Point getSelection()
          Enabled: Gets the selection.
 int getSelectionIndex()
          Enabled: Gets the index of the selected item.
 String getText()
          Enabled: Gets the widget text.
 int getTextHeight()
          Enabled: Gets the height of the combo's text field.
 int getTextLimit()
          Enabled: Gets the text limit.
 int indexOf(String string)
          Enabled: Gets the index of an item.
 int indexOf(String string, int start)
          Enabled: Gets the index of an item.
(package private)  void initAccessible()
           
(package private)  void internalLayout()
           
(package private)  boolean isDropped()
           
 boolean isFocusControl()
          Enabled:
(package private)  void listEvent(Event event)
           
(package private)  void popupEvent(Event event)
           
 void redraw(int x, int y, int width, int height, boolean all)
          Enabled:
 void remove(int index)
          Enabled: Removes an item at an index.
 void remove(int start, int end)
          Enabled: Removes a range of items.
 void remove(String string)
          Enabled: Removes an item.
 void removeAll()
          Enabled: Removes all items.
 void removeModifyListener(ModifyListener listener)
          Enabled: Removes the listener.
 void removeSelectionListener(SelectionListener listener)
          Enabled: Removes the listener.
 void select(int index)
          Enabled: Selects an item.
 void setBackground(Color color)
          Enabled:
 boolean setFocus()
          Suppressed:
 void setFont(Font font)
          Enabled:
 void setForeground(Color color)
          Enabled:
 void setItem(int index, String string)
          Enabled: Sets the text of an item; indexing is zero based.
 void setItems(String[] items)
          Enabled: Sets all items.
 void setSelection(Point selection)
          Enabled: Sets the new selection.
 void setText(String string)
          Enabled: Sets the widget text.
 void setTextLimit(int limit)
          Enabled: Sets the text limit.
 void setToolTipText(String string)
          Enabled:
 void setVisible(boolean visible)
          Enabled:
(package private)  void textEvent(Event event)
           
 
Methods inherited from class org.eclipse.swt.widgets.Composite
checkSubclass, getLayout, getTabList, layout, layout, moveAbove, moveBelow, setLayout, setTabList
 
Methods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getVerticalBar
 
Methods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addFocusListener, addHelpListener, addKeyListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addPaintListener, addTraverseListener, computeSize, forceFocus, getAccessible, getBackground, getBorderWidth, getBounds, getDisplay, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getParent, getShell, getSize, getToolTipText, getVisible, internal_dispose_GC, internal_new_GC, isDisposed, isEnabled, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, redraw, removeControlListener, removeFocusListener, removeHelpListener, removeKeyListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removePaintListener, removeTraverseListener, setBounds, setBounds, setCapture, setCursor, setEnabled, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setSize, setSize, toControl, toControl, toDisplay, toDisplay, transferActive, transferFocus, traverse, update
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getStyle, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ITEMS_SHOWING

static final int ITEMS_SHOWING

text

Text text

list

List list

popup

Shell popup

arrow

Button arrow

hasFocus

boolean hasFocus
Constructor Detail

CCombo

public CCombo(Composite parent,
              int style)
Enabled: Constructs a new instance of this class given its parent and a style value describing its behavior and appearance.

The style value is either one of the style constants defined in class SWT which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using the int "|" operator) two or more of those SWT style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.

Parameters:
parent - a widget which will be the parent of the new instance (cannot be null)
style - the style of widget to construct
See Also:
SWT.BORDER, SWT.READ_ONLY, SWT.FLAT, Widget.getStyle()
Method Detail

checkStyle

static int checkStyle(int style)

add

public void add(String string)
Enabled: Adds an item.

The item is placed at the end of the list. Indexing is zero based.

Parameters:
string - the new item

add

public void add(String string,
                int index)
Enabled: Adds an item at an index.

The item is placed at an index in the list. Indexing is zero based. This operation will fail when the index is out of range.

Parameters:
string - the new item
index - the index for the item

addModifyListener

public void addModifyListener(ModifyListener listener)
Enabled: Adds the listener to receive events.

Parameters:
listener - the listener

addSelectionListener

public void addSelectionListener(SelectionListener listener)
Enabled: Adds the listener to receive events.

Parameters:
listener - the listener

arrowEvent

void arrowEvent(Event event)

clearSelection

public void clearSelection()
Enabled: Clears the current selection.


comboEvent

void comboEvent(Event event)

computeSize

public Point computeSize(int wHint,
                         int hHint,
                         boolean changed)
Enabled:

Overrides:
computeSize in class Composite
Parameters:
wHint - the width hint (can be SWT.DEFAULT)
hHint - the height hint (can be SWT.DEFAULT)
changed - true if the control's contents have changed, and false otherwise
Returns:
the preferred size of the control.
See Also:
Layout, Control.getBorderWidth(), Control.getBounds(), Control.getSize(), Control.pack(), "computeTrim, getClientArea for controls that implement them"

deselect

public void deselect(int index)
Enabled: Deselects an item.

If the item at an index is selected, it is deselected. If the item at an index is not selected, it remains deselected. Indices that are out of range are ignored. Indexing is zero based.

Parameters:
index - the index of the item

deselectAll

public void deselectAll()
Enabled: Deselects all items.

If an item is selected, it is deselected. If an item is not selected, it remains unselected.


dropDown

void dropDown(boolean drop)

getChildren

public Control[] getChildren()
Enabled:

Overrides:
getChildren in class Composite
Returns:
an array of children

getEditable

boolean getEditable()

getItem

public String getItem(int index)
Enabled: Gets an item at an index.

Indexing is zero based. This operation will fail when the index is out of range or an item could not be queried from the OS.

Parameters:
index - the index of the item
Returns:
the item

getItemCount

public int getItemCount()
Enabled: Gets the number of items.

This operation will fail if the number of items could not be queried from the OS.

Returns:
the number of items in the widget

getItemHeight

public int getItemHeight()
Enabled: Gets the height of one item.

This operation will fail if the height of one item could not be queried from the OS.

Returns:
the height of one item in the widget

getItems

public String[] getItems()
Enabled: Gets the items.

This operation will fail if the items cannot be queried from the OS.

Returns:
the items in the widget

getSelection

public Point getSelection()
Enabled: Gets the selection.

Returns:
a point representing the selection start and end

getSelectionIndex

public int getSelectionIndex()
Enabled: Gets the index of the selected item.

Indexing is zero based. If no item is selected -1 is returned.

Returns:
the index of the selected item.

getText

public String getText()
Enabled: Gets the widget text.

If the widget has no text, an empty string is returned.

Returns:
the widget text

getTextHeight

public int getTextHeight()
Enabled: Gets the height of the combo's text field.

The operation will fail if the height cannot be queried from the OS.

Returns:
the height of the combo's text field.

getTextLimit

public int getTextLimit()
Enabled: Gets the text limit.

Returns:
the text limit

indexOf

public int indexOf(String string)
Enabled: Gets the index of an item.

The list is searched starting at 0 until an item is found that is equal to the search item. If no item is found, -1 is returned. Indexing is zero based.

Parameters:
string - the search item
Returns:
the index of the item

indexOf

public int indexOf(String string,
                   int start)
Enabled: Gets the index of an item.

The widget is searched starting at start including the end position until an item is found that is equal to the search itenm. If no item is found, -1 is returned. Indexing is zero based.

Parameters:
string - the search item
Returns:
the index of the item

initAccessible

void initAccessible()

isDropped

boolean isDropped()

isFocusControl

public boolean isFocusControl()
Enabled:

Overrides:
isFocusControl in class Control
Returns:
the receiver's focus state

internalLayout

void internalLayout()

listEvent

void listEvent(Event event)

popupEvent

void popupEvent(Event event)

redraw

public void redraw(int x,
                   int y,
                   int width,
                   int height,
                   boolean all)
Enabled:

Overrides:
redraw in class Control
Parameters:
x - the x coordinate of the area to draw
y - the y coordinate of the area to draw
width - the width of the area to draw
height - the height of the area to draw
all - true if children should redraw, and false otherwise
See Also:
Control.update()

remove

public void remove(int index)
Enabled: Removes an item at an index.

Indexing is zero based. This operation will fail when the index is out of range or an item could not be removed from the OS.

Parameters:
index - the index of the item
Returns:
the selection state

remove

public void remove(int start,
                   int end)
Enabled: Removes a range of items.

Indexing is zero based. The range of items is from the start index up to and including the end index. This operation will fail when the index is out of range or an item could not be removed from the OS.

Parameters:
start - the start of the range
end - the end of the range

remove

public void remove(String string)
Enabled: Removes an item.

This operation will fail when the item could not be removed from the OS.

Parameters:
string - the search item

removeAll

public void removeAll()
Enabled: Removes all items.


removeModifyListener

public void removeModifyListener(ModifyListener listener)
Enabled: Removes the listener.

Parameters:
listener - the listener

removeSelectionListener

public void removeSelectionListener(SelectionListener listener)
Enabled: Removes the listener.

Parameters:
listener - the listener

select

public void select(int index)
Enabled: Selects an item.

If the item at an index is not selected, it is selected. Indices that are out of range are ignored. Indexing is zero based.

Parameters:
index - the index of the item

setBackground

public void setBackground(Color color)
Enabled:

Overrides:
setBackground in class Control
Parameters:
color - the new color (or null)

setFocus

public boolean setFocus()
Suppressed:

Overrides:
setFocus in class Composite
Returns:
true if the control got focus, and false if it was unable to.
See Also:
Control.forceFocus()

setFont

public void setFont(Font font)
Enabled:

Overrides:
setFont in class Control
Parameters:
font - the new font (or null)

setForeground

public void setForeground(Color color)
Enabled:

Overrides:
setForeground in class Control
Parameters:
color - the new color (or null)

setItem

public void setItem(int index,
                    String string)
Enabled: Sets the text of an item; indexing is zero based. This operation will fail when the index is out of range or an item could not be changed in the OS.

Parameters:
index - the index for the item
string - the item

setItems

public void setItems(String[] items)
Enabled: Sets all items.

Parameters:
items - the array of items

setSelection

public void setSelection(Point selection)
Enabled: Sets the new selection.

Parameters:
selection - point representing the start and the end of the new selection

setText

public void setText(String string)
Enabled: Sets the widget text.

Parameters:
string - the widget text

setTextLimit

public void setTextLimit(int limit)
Enabled: Sets the text limit.

Parameters:
limit - new text limit

setToolTipText

public void setToolTipText(String string)
Enabled:

Overrides:
setToolTipText in class Control
Parameters:
string - the new tool tip text (or null)

setVisible

public void setVisible(boolean visible)
Enabled:

Overrides:
setVisible in class Control
Parameters:
visible - the new visibility state

textEvent

void textEvent(Event event)


comments?