Maintainer | gtk2hs-users@lists.sourceforge.net |
---|---|
Stability | provisional |
Portability | portable (depends on GHC) |
Safe Haskell | None |
Language | Haskell98 |
A widget used to choose from a list of items.
- Module available since Gtk+ version 2.4
- data ComboBox
- class BinClass o => ComboBoxClass o
- castToComboBox :: GObjectClass obj => obj -> ComboBox
- gTypeComboBox :: GType
- toComboBox :: ComboBoxClass o => o -> ComboBox
- type ComboBoxText = Text
- comboBoxNew :: IO ComboBox
- comboBoxNewWithEntry :: IO ComboBox
- comboBoxNewText :: IO ComboBox
- comboBoxNewWithModel :: TreeModelClass model => model -> IO ComboBox
- comboBoxNewWithModelAndEntry :: TreeModelClass model => model -> IO ComboBox
- comboBoxSetModelText :: ComboBoxClass self => self -> IO (ListStore ComboBoxText)
- comboBoxGetModelText :: ComboBoxClass self => self -> IO (ListStore ComboBoxText)
- comboBoxAppendText :: ComboBoxClass self => self -> ComboBoxText -> IO Int
- comboBoxInsertText :: ComboBoxClass self => self -> Int -> ComboBoxText -> IO ()
- comboBoxPrependText :: ComboBoxClass self => self -> ComboBoxText -> IO ()
- comboBoxRemoveText :: ComboBoxClass self => self -> Int -> IO ()
- comboBoxGetActiveText :: ComboBoxClass self => self -> IO (Maybe ComboBoxText)
- comboBoxGetWrapWidth :: ComboBoxClass self => self -> IO Int
- comboBoxSetWrapWidth :: ComboBoxClass self => self -> Int -> IO ()
- comboBoxGetRowSpanColumn :: ComboBoxClass self => self -> IO (ColumnId row Int)
- comboBoxSetRowSpanColumn :: ComboBoxClass self => self -> ColumnId row Int -> IO ()
- comboBoxGetColumnSpanColumn :: ComboBoxClass self => self -> IO (ColumnId row Int)
- comboBoxSetColumnSpanColumn :: ComboBoxClass self => self -> ColumnId row Int -> IO ()
- comboBoxGetActive :: ComboBoxClass self => self -> IO Int
- comboBoxSetActive :: ComboBoxClass self => self -> Int -> IO ()
- comboBoxGetActiveIter :: ComboBoxClass self => self -> IO (Maybe TreeIter)
- comboBoxSetActiveIter :: ComboBoxClass self => self -> TreeIter -> IO ()
- comboBoxGetModel :: ComboBoxClass self => self -> IO (Maybe TreeModel)
- comboBoxSetModel :: (ComboBoxClass self, TreeModelClass model) => self -> Maybe model -> IO ()
- comboBoxPopup :: ComboBoxClass self => self -> IO ()
- comboBoxPopdown :: ComboBoxClass self => self -> IO ()
- comboBoxSetRowSeparatorSource :: (ComboBoxClass self, TreeModelClass (model row), TypedTreeModelClass model) => self -> Maybe (model row, row -> Bool) -> IO ()
- comboBoxSetAddTearoffs :: ComboBoxClass self => self -> Bool -> IO ()
- comboBoxGetAddTearoffs :: ComboBoxClass self => self -> IO Bool
- comboBoxSetTitle :: (ComboBoxClass self, GlibString string) => self -> string -> IO ()
- comboBoxGetTitle :: (ComboBoxClass self, GlibString string) => self -> IO string
- comboBoxSetFocusOnClick :: ComboBoxClass self => self -> Bool -> IO ()
- comboBoxGetFocusOnClick :: ComboBoxClass self => self -> IO Bool
- comboBoxModel :: (ComboBoxClass self, TreeModelClass treeModel) => ReadWriteAttr self TreeModel treeModel
- comboBoxWrapWidth :: ComboBoxClass self => Attr self Int
- comboBoxRowSpanColumn :: ComboBoxClass self => Attr self (ColumnId row Int)
- comboBoxColumnSpanColumn :: ComboBoxClass self => Attr self (ColumnId row Int)
- comboBoxActive :: ComboBoxClass self => Attr self Int
- comboBoxAddTearoffs :: ComboBoxClass self => Attr self Bool
- comboBoxHasFrame :: ComboBoxClass self => Attr self Bool
- comboBoxFocusOnClick :: ComboBoxClass self => Attr self Bool
- comboBoxTearoffTitle :: (ComboBoxClass self, GlibString string) => Attr self string
- comboBoxPopupShown :: ComboBoxClass self => ReadAttr self Bool
- comboBoxTitle :: (ComboBoxClass self, GlibString string) => Attr self string
- comboBoxGetHasEntry :: ComboBoxClass self => self -> IO Bool
- comboBoxSetEntryTextColumn :: ComboBoxClass comboBox => comboBox -> ColumnId row ComboBoxText -> IO ()
- comboBoxGetEntryTextColumn :: ComboBoxClass comboBox => comboBox -> IO (ColumnId row ComboBoxText)
- changed :: ComboBoxClass self => Signal self (IO ())
- onChanged :: ComboBoxClass self => self -> IO () -> IO (ConnectId self)
- afterChanged :: ComboBoxClass self => self -> IO () -> IO (ConnectId self)
Detail
A ComboBox
is a widget that allows the user to choose from a list of
valid choices. The ComboBox
displays the selected choice. When activated,
the ComboBox
displays a popup which allows the user to make a new choice.
The style in which the selected value is displayed, and the style of the
popup is determined by the current theme. It may be similar to a
OptionMenu
, or similar to a Windows-style combo box.
Unlike its predecessors Combo
and OptionMenu
, the ComboBox
uses the
model-view pattern; the list of valid choices is specified in the form of a
tree model, and the display of the choices can be adapted to the data in
the model by using cell renderers, as you would in a tree view. This is
possible since ComboBox
implements the CellLayout
interface. The tree
model holding the valid choices is not restricted to a flat list, it can be
a real tree, and the popup will reflect the tree structure.
In addition to the general model-view API, ComboBox
offers the function
comboBoxNewText
which creates a text-only combo box.
Class Hierarchy
|GObject
| +----Object
| +----Widget
| +----Container
| +----Bin
| +----ComboBox | +----ComboBoxEntry
Types
castToComboBox :: GObjectClass obj => obj -> ComboBox Source
toComboBox :: ComboBoxClass o => o -> ComboBox Source
type ComboBoxText = Text Source
Create a combo box that holds strings.
This function stores a ListStore
with the
widget and sets the model to the list store. The widget can contain only
strings. The model can be retrieved with comboBoxGetModel
. The list
store can be retrieved with comboBoxGetModelText
.
Any exisiting model or renderers are removed before setting the new text
model.
Note that the functions comboBoxAppendText
, comboBoxInsertText
,
comboBoxPrependText
, comboBoxRemoveText
and comboBoxGetActiveText
can be called on a combo box only once comboBoxSetModelText
is called.
Constructors
comboBoxNew :: IO ComboBox Source
Creates a new empty ComboBox
.
comboBoxNewWithEntry :: IO ComboBox Source
Creates a new empty ComboBox
with an entry.
- Available since Gtk+ version 2.24
comboBoxNewText :: IO ComboBox Source
Convenience function which constructs a new text combo box that is a
ComboBox
just displaying strings. This function internally calls
comboBoxSetModelText
after creating a new combo box.
:: TreeModelClass model | |
=> model |
|
-> IO ComboBox |
Creates a new ComboBox
with the model initialized to model
.
comboBoxNewWithModelAndEntry Source
:: TreeModelClass model | |
=> model |
|
-> IO ComboBox |
Creates a new empty ComboBox
with an entry and with the model initialized to model
.
- Available since Gtk+ version 2.24
Methods
Simple Text API
comboBoxSetModelText :: ComboBoxClass self => self -> IO (ListStore ComboBoxText) Source
comboBoxGetModelText :: ComboBoxClass self => self -> IO (ListStore ComboBoxText) Source
Retrieve the model that was created with comboBoxSetModelText
.
comboBoxAppendText :: ComboBoxClass self => self -> ComboBoxText -> IO Int Source
Appends string
to the list of strings stored in comboBox
. Note that
you can only use this function with combo boxes constructed with
comboBoxNewText
. Returns the index of the appended text.
:: ComboBoxClass self | |
=> self | |
-> Int |
|
-> ComboBoxText |
|
-> IO () |
Inserts string
at position
in the list of strings stored in
comboBox
. Note that you can only use this function with combo boxes
constructed with comboBoxNewText
.
comboBoxPrependText :: ComboBoxClass self => self -> ComboBoxText -> IO () Source
Prepends string
to the list of strings stored in comboBox
. Note that
you can only use this function with combo boxes constructed with
comboBoxNewText
.
:: ComboBoxClass self | |
=> self | |
-> Int |
|
-> IO () |
Removes the string at position
from comboBox
. Note that you can only
use this function with combo boxes constructed with comboBoxNewText
.
comboBoxGetActiveText :: ComboBoxClass self => self -> IO (Maybe ComboBoxText) Source
Returns the currently active string in comboBox
or Nothing
if none is
selected. Note that you can only use this function with combo boxes
constructed with comboBoxNewText
.
Standard API
comboBoxGetWrapWidth :: ComboBoxClass self => self -> IO Int Source
Returns the wrap width which is used to determine the number of columns for the popup menu. If the wrap width is larger than 1, the combo box is in table mode.
- Available since Gtk+ version 2.6
comboBoxSetWrapWidth :: ComboBoxClass self => self -> Int -> IO () Source
Sets the wrap width of the combo box to be width
. The wrap width is
basically the preferred number of columns when you want the popup to be
laid out in a table.
comboBoxGetRowSpanColumn :: ComboBoxClass self => self -> IO (ColumnId row Int) Source
Gets the column with row span information for comboBox
.
- Available since Gtk+ version 2.6
comboBoxSetRowSpanColumn :: ComboBoxClass self => self -> ColumnId row Int -> IO () Source
Sets the column with row span information for comboBox
to be rowSpan
.
The row span column contains integers which indicate how many rows an item
should span.
comboBoxGetColumnSpanColumn :: ComboBoxClass self => self -> IO (ColumnId row Int) Source
Gets the source of the column span information for the combo box.
- Available since Gtk+ version 2.6
comboBoxSetColumnSpanColumn :: ComboBoxClass self => self -> ColumnId row Int -> IO () Source
Sets the source of the column span information for the combo box. The column span source contains integers which indicate how many columns an item should span.
:: ComboBoxClass self | |
=> self | |
-> IO Int | returns An integer which is the index of the currently active item, or -1 if there's no active item. |
Returns the index of the currently active item, or -1 if there is no
active item. If the model is a non-flat treemodel, and the active item is
not an immediate child of the root of the tree, this function returns
, where treePathGetIndices
path !! 0path
is the TreePath
of the
active item.
:: ComboBoxClass self | |
=> self | |
-> Int |
|
-> IO () |
Sets the active item of comboBox
to be the item at index
.
comboBoxGetActiveIter :: ComboBoxClass self => self -> IO (Maybe TreeIter) Source
Returns a TreeIter
that points to the current active item, if it
exists, or Nothing
if there is no current active item.
:: ComboBoxClass self | |
=> self | |
-> TreeIter |
|
-> IO () |
Sets the current active item to be the one referenced by iter
. iter
must correspond to a path of depth one.
:: ComboBoxClass self | |
=> self | |
-> IO (Maybe TreeModel) | returns A |
Returns the TreeModel
which is acting as data source for comboBox
.
comboBoxSetModel :: (ComboBoxClass self, TreeModelClass model) => self -> Maybe model -> IO () Source
Sets the model used by comboBox
to be model
. Will unset a previously
set model (if applicable). If model is Nothing
, then it will unset the
model.
Note that this function does not clear the cell renderers, you have to call
comboBoxCellLayoutClear
yourself if you need to set up different cell
renderers for the new model.
comboBoxPopup :: ComboBoxClass self => self -> IO () Source
Pops up the menu or dropdown list of the combo box.
This function is mostly intended for use by accessibility technologies; applications should have little use for it.
comboBoxPopdown :: ComboBoxClass self => self -> IO () Source
Hides the menu or dropdown list of comboBox
.
This function is mostly intended for use by accessibility technologies; applications should have little use for it.
comboBoxSetRowSeparatorSource Source
:: (ComboBoxClass self, TreeModelClass (model row), TypedTreeModelClass model) | |
=> self | the |
-> Maybe (model row, row -> Bool) | The model and a function to extract a Boolean from it. |
-> IO () |
Installs a mapping from the model to a row separator flag, which is used
to determine whether a row should be drawn as a separator. If the row
separator mapping is Nothing
, no separators are drawn. This is the
default value.
- Available since Gtk+ version 2.6
:: ComboBoxClass self | |
=> self | |
-> Bool |
|
-> IO () |
Sets whether the popup menu should have a tearoff menu item.
- Available since Gtk+ version 2.6
comboBoxGetAddTearoffs :: ComboBoxClass self => self -> IO Bool Source
Gets the current value of the :add-tearoffs property.
:: (ComboBoxClass self, GlibString string) | |
=> self | |
-> string |
|
-> IO () |
Sets the menu's title in tearoff mode.
- Available since Gtk+ version 2.10
:: (ComboBoxClass self, GlibString string) | |
=> self | |
-> IO string | returns the menu's title in tearoff mode. |
Gets the current title of the menu in tearoff mode. See
comboBoxSetAddTearoffs
.
- Available since Gtk+ version 2.10
comboBoxSetFocusOnClick Source
:: ComboBoxClass self | |
=> self | |
-> Bool |
|
-> IO () |
Sets whether the combo box will grab focus when it is clicked with the mouse. Making mouse clicks not grab focus is useful in places like toolbars where you don't want the keyboard focus removed from the main area of the application.
- Available since Gtk+ version 2.6
comboBoxGetFocusOnClick Source
:: ComboBoxClass self | |
=> self | |
-> IO Bool | returns |
Returns whether the combo box grabs focus when it is clicked with the
mouse. See comboBoxSetFocusOnClick
.
- Available since Gtk+ version 2.6
Attributes
comboBoxModel :: (ComboBoxClass self, TreeModelClass treeModel) => ReadWriteAttr self TreeModel treeModel Source
The model from which the combo box takes the values shown in the list.
comboBoxWrapWidth :: ComboBoxClass self => Attr self Int Source
If wrap-width is set to a positive value, the list will be displayed in multiple columns, the number of columns is determined by wrap-width.
Allowed values: >= 0
Default value: 0
comboBoxRowSpanColumn :: ComboBoxClass self => Attr self (ColumnId row Int) Source
The values of that column are used to determine how many rows a value in the list will span. Therefore, the values in the model column pointed to by this property must be greater than zero and not larger than wrap-width.
Default value: invalidColumnId
- Available since Gtk+ version 2.6
comboBoxColumnSpanColumn :: ComboBoxClass self => Attr self (ColumnId row Int) Source
The values of that column are used to determine how many columns a value in the list will span.
Default value: invalidColumnId
- Available since Gtk+ version 2.6
comboBoxActive :: ComboBoxClass self => Attr self Int Source
The item which is currently active. This value only makes sense for a list model.
comboBoxAddTearoffs :: ComboBoxClass self => Attr self Bool Source
The add-tearoffs property controls whether generated menus have tearoff menu items.
Note that this only affects menu style combo boxes.
Default value: False
- Available since Gtk+ version 2.6
comboBoxHasFrame :: ComboBoxClass self => Attr self Bool Source
The has-frame property controls whether a frame is drawn around the entry.
Default value: True
- Available since Gtk+ version 2.6
comboBoxFocusOnClick :: ComboBoxClass self => Attr self Bool Source
Whether the combo box grabs focus when it is clicked with the mouse.
Default value: True
comboBoxTearoffTitle :: (ComboBoxClass self, GlibString string) => Attr self string Source
A title that may be displayed by the window manager when the popup is torn-off.
Default value: ""
- Available since Gtk+ version 2.10
comboBoxPopupShown :: ComboBoxClass self => ReadAttr self Bool Source
Whether the combo boxes dropdown is popped up. Note that this property is mainly useful because it allows you to connect to notify::popup-shown.
Default value: False
- Available since Gtk+ version 2.10
comboBoxTitle :: (ComboBoxClass self, GlibString string) => Attr self string Source
'title' property. See comboBoxGetTitle
and comboBoxSetTitle
- Available since Gtk+ version 2.10
:: ComboBoxClass self | |
=> self | |
-> IO Bool | returns whether there is an entry in |
Returns whether the combo box has an entry.
- Available since Gtk+ version 2.24
comboBoxSetEntryTextColumn Source
:: ComboBoxClass comboBox | |
=> comboBox | |
-> ColumnId row ComboBoxText |
|
-> IO () |
Sets the model column which combo_box should use to get strings from
to be textColumn
. The column text_column in the model of comboBox
must be of type ComboBoxText.
This is only relevant if comboBox
has been created with "has-entry"
as True.
- Available since Gtk+ version 2.24
comboBoxGetEntryTextColumn Source
:: ComboBoxClass comboBox | |
=> comboBox | |
-> IO (ColumnId row ComboBoxText) | returns a column in the data source model of |
Returns the column which comboBox
is using to get the strings from to
display in the internal entry.
- Available since Gtk+ version 2.24
Signals
changed :: ComboBoxClass self => Signal self (IO ()) Source
The changed signal is emitted when the active item is changed. The can be
due to the user selecting a different item from the list, or due to a call
to comboBoxSetActiveIter
. It will also be emitted while typing into a
ComboBoxEntry
, as well as when selecting an item from the
ComboBoxEntry'
s list.
Deprecated
onChanged :: ComboBoxClass self => self -> IO () -> IO (ConnectId self) Source
Deprecated: instead of 'onChanged obj' use 'on obj changed'
afterChanged :: ComboBoxClass self => self -> IO () -> IO (ConnectId self) Source
Deprecated: instead of 'afterChanged obj' use 'after obj changed'