|
java-gnome version 4.0.19 | ||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Objectorg.freedesktop.bindings.Pointer
org.freedesktop.bindings.Proxy
org.gnome.glib.Object
org.gnome.gtk.Object
org.gnome.gtk.Widget
org.gnome.gtk.Container
org.gnome.gtk.Bin
org.gnome.gtk.ComboBox
public class ComboBox
A Widget used to choose from a list of items.
Internally, ComboBox uses a TreeModel to store the items, giving you the
same MVC power of GTK's TreeView/TreeModel system. There is also an
alternative API which can be used to create and manipulate ComboBoxes which
are comprised only of text. If that is your requirement, see
TextComboBox
.
ComboBox is a CellLayout, that is, it possesses many of the same aspects as a TreeViewColumn, and, along with being backed by a TreeModel, is used in much the same way as a TreeView: create a ListStore or TreeStore then build the GUI side by creating CellRenderers against the ComboBox.
An abbreviated example of using this follows; assuming a ListStore
model
with at least DataColumnString column
in
it,
combo = new ComboBox(model); renderer = new CellRendererText(combo); renderer.setText(column);and that's it. While conceptually straight forward, it turns out to be a lot of work if all you're doing is a single column of DataColumnString. But the ability to also have a DataColumnReference in your model means you can get a link back the object that is being represented by the "mere" text label being displayed to the user, and this can be very powerful. Likewise, you can build ComboBoxes with more complicated layouts, for example having with several verticals of text and perhaps an image packed into the ComboBox as well. Finally, don't forget that you can use several different views against one TreeModel, so a TreeModel that is in use somewhere else in your app can also be the source data for your ComboBox.
The underlying GtkComboBox
is actually presents two
different APIs that are essentially mutually exclusive, which is why we
have split this into two public classes.
Nested Class Summary | |
---|---|
static interface |
ComboBox.Changed
This signal emitted whenever a different item is selected by the user. |
Nested classes/interfaces inherited from class org.gnome.gtk.Widget |
---|
Widget.ButtonPressEvent, Widget.ButtonReleaseEvent, Widget.EnterNotifyEvent, Widget.ExposeEvent, Widget.FocusInEvent, Widget.FocusOutEvent, Widget.Hide, Widget.KeyPressEvent, Widget.KeyReleaseEvent, Widget.LeaveNotifyEvent, Widget.MapEvent, Widget.MotionNotifyEvent, Widget.PopupMenu, Widget.ScrollEvent, Widget.UnmapEvent, Widget.VisibilityNotifyEvent |
Nested classes/interfaces inherited from class org.gnome.gtk.Object |
---|
Object.Destroy |
Constructor Summary | |
---|---|
ComboBox(TreeModel model)
Construct a new full-power TreeModel-backed ComboBox. |
Method Summary | |
---|---|
void |
connect(ComboBox.Changed handler)
Hook up a ComboBox.Changed handler to the Widget. |
int |
getActive()
Returns the index of the active item in the ComboBox. |
TreeIter |
getActiveIter()
Get a TreeIter pointing at the currently selected row. |
void |
popdown()
Programmatically tell the ComboBox popup to go away. |
void |
popup()
Cause the popup part of the ComboBox to raise and present itself. |
void |
setActive(int active)
Change the active item within this ComboBox to be the one at the supplied index. |
void |
setActiveIter(TreeIter row)
Set the ComboBox to be pointing at the row nominated by the TreeIter argument. |
void |
setModel(TreeModel model)
Set or change the TreeModel from which this ComboBox draws its data. |
Methods inherited from class org.gnome.gtk.Bin |
---|
getChild |
Methods inherited from class org.gnome.gtk.Container |
---|
add, getChildren, remove, setBorderWidth |
Methods inherited from class org.gnome.gtk.Widget |
---|
activate, addEvents, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, connect, getAllocation, getCanDefault, getCanFocus, getHasFocus, getName, getParent, getRequisition, getSensitive, getToplevel, getWindow, grabAdd, grabDefault, grabFocus, grabRemove, hide, isSensitive, modifyBackground, modifyBase, modifyFont, modifyText, queueDraw, queueDrawArea, realize, setCanDefault, setCanFocus, setColormap, setEvents, setName, setSensitive, setSizeRequest, setTooltipMarkup, setTooltipText, show, showAll |
Methods inherited from class org.gnome.gtk.Object |
---|
connect, destroy |
Methods inherited from class org.freedesktop.bindings.Pointer |
---|
toString |
Methods inherited from class Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ComboBox(TreeModel model)
If subclassing ComboBox, use the protected
no-arg constructor and then set the Model
later with setModel()
.
Method Detail |
---|
public void connect(ComboBox.Changed handler)
ComboBox.Changed
handler to the Widget.
since 4.0.3
public int getActive()
2
means the third item
in the list is currently the active item.
This will return -1
if there is no active item.
public TreeIter getActiveIter()
null
will be returned.
public void popdown()
public void popup()
public void setActive(int active)
0
.
public void setActiveIter(TreeIter row)
public void setModel(TreeModel model)
|
![]() java-gnome |
||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |