2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GtkComboBox.html
46 * - gtk_combo_box_new_text
56 * - AtkObject* -> ObjectAtk
57 * - GtkTreeIter* -> TreeIter
58 * - GtkTreeModel* -> TreeModel
64 private import gtk
.gtktypes
;
66 private import lib
.gtk
;
68 private import atk
.ObjectAtk
;
69 private import glib
.Str
;
70 private import gtk
.TreeModel
;
71 private import gtk
.TreeIter
;
72 private import gtk
.CellRenderer
;
73 private import gtk
.CellLayoutIF
;
74 private import gtk
.CellLayoutT
;
78 * A GtkComboBox is a widget that allows the user to choose from a
79 * list of valid choices. The GtkComboBox displays the selected
80 * choice. When activated, the GtkComboBox displays a popup
81 * which allows the user to make a new choice. The style in which
82 * the selected value is displayed, and the style of the popup is
83 * determined by the current theme. It may be similar to a GtkOptionMenu,
84 * or similar to a Windows-style combo box.
85 * Unlike its predecessors GtkCombo and GtkOptionMenu, the GtkComboBox
86 * uses the model-view pattern; the list of valid choices is specified in the
87 * form of a tree model, and the display of the choices can be adapted to
88 * the data in the model by using cell renderers, as you would in a tree view.
89 * This is possible since GtkComboBox implements the GtkCellLayout interface.
90 * The tree model holding the valid choices is not restricted to a flat list,
91 * it can be a real tree, and the popup will reflect the tree structure.
92 * In addition to the model-view API, GtkComboBox offers a simple API which
93 * is suitable for text-only combo boxes, and hides the complexity of managing
94 * the data in a model. It consists of the functions gtk_combo_box_new_text(),
95 * gtk_combo_box_append_text(), gtk_combo_box_insert_text(),
96 * gtk_combo_box_prepend_text(), gtk_combo_box_remove_text() and
97 * gtk_combo_box_get_active_text().
99 private import gtk
.Bin
;
100 public class ComboBox
: Bin
, CellLayoutIF
103 /** the main Gtk struct */
104 protected GtkComboBox
* gtkComboBox
;
107 public GtkComboBox
* getComboBoxStruct()
113 /** the main Gtk struct as a void* */
114 protected void* getStruct()
116 return cast(void*)gtkComboBox
;
120 * Sets our main struct and passes it to the parent class
122 public this (GtkComboBox
* gtkComboBox
)
124 super(cast(GtkBin
*)gtkComboBox
);
125 this.gtkComboBox
= gtkComboBox
;
128 private int count
= 0;
129 public int maxCount
= 0;
132 // add the CellLayout capabilities
133 mixin CellLayoutT
!(GtkComboBox
);
136 * Creates a new empty GtkComboBox.
137 * If text is true then
138 * constructs a new text combo box, which is a
139 * GtkComboBox just displaying strings. If you use this function to create
140 * a text combo box, you should only manipulate its data source with the
141 * following convenience functions: gtk_combo_box_append_text(),
142 * gtk_combo_box_insert_text(), gtk_combo_box_prepend_text() and
143 * gtk_combo_box_remove_text().
148 public this (bit text
=true)
152 // GtkWidget* gtk_combo_box_new_text (void);
153 this(cast(GtkComboBox
*)gtk_combo_box_new_text() );
157 // GtkWidget* gtk_combo_box_new (void);
158 this(cast(GtkComboBox
*)gtk_combo_box_new() );
162 public void setActiveText(char[] text
, bool insert
=false)
164 int currActive
= getActive();
168 while ( !found
&& active
==getActive
)
170 found
= text
==getActiveText();
182 //setActive(currActive);
189 int getIndex(char[] text
)
191 TreeIter iter
= new TreeIter();
192 TreeModel model
= getModel();
193 iter
.setModel(model
);
197 if ( model
.getIterFirst(iter
) )
199 while ( !end
&& iter
!is null && !found
)
201 found
= iter
.getValueString(0) == text
;
204 end
= !model
.iterNext(iter
);
213 return end ?
-1 : index
;
216 void prependOrReplaceText(char[] text
)
218 int index
= getIndex(text
);
224 else if ( index
== -1 )
234 // imports for the signal processing
235 private import gobject
.Signals
;
236 private import gdk
.gdktypes
;
237 int[char[]] connectedSignals
;
239 void delegate(ComboBox
)[] onChangedListeners
;
240 void addOnChanged(void delegate(ComboBox
) dlg
)
242 if ( !("changed" in connectedSignals
) )
247 cast(GCallback
)&callBackChanged
,
250 cast(ConnectFlags
)0);
251 connectedSignals
["changed"] = 1;
253 onChangedListeners
~= dlg
;
255 extern(C
) static void callBackChanged(GtkComboBox
* widgetStruct
, ComboBox comboBox
)
257 bit consumed
= false;
259 foreach ( void delegate(ComboBox
) dlg
; comboBox
.onChangedListeners
)
271 * Creates a new GtkComboBox with the model initialized to model.
278 public this (TreeModel model
)
280 // GtkWidget* gtk_combo_box_new_with_model (GtkTreeModel *model);
281 this(cast(GtkComboBox
*)gtk_combo_box_new_with_model((model
is null) ?
null : model
.getTreeModelStruct()) );
285 * Returns the wrap width which is used to determine the number
286 * of columns for the popup menu. If the wrap width is larger than
287 * 1, the combo box is in table mode.
294 public int getWrapWidth()
296 // gint gtk_combo_box_get_wrap_width (GtkComboBox *combo_box);
297 return gtk_combo_box_get_wrap_width(gtkComboBox
);
301 * Sets the wrap width of combo_box to be width. The wrap width is basically
302 * the preferred number of columns when you want the popup to be layed out
307 * Preferred number of columns.
310 public void setWrapWidth(int width
)
312 // void gtk_combo_box_set_wrap_width (GtkComboBox *combo_box, gint width);
313 gtk_combo_box_set_wrap_width(gtkComboBox
, width
);
317 * Returns the column with row span information for combo_box.
321 * the row span column.
324 public int getRowSpanColumn()
326 // gint gtk_combo_box_get_row_span_column (GtkComboBox *combo_box);
327 return gtk_combo_box_get_row_span_column(gtkComboBox
);
331 * Sets the column with row span information for combo_box to be row_span.
332 * The row span column contains integers which indicate how many rows
333 * an item should span.
337 * A column in the model passed during construction.
340 public void setRowSpanColumn(int rowSpan
)
342 // void gtk_combo_box_set_row_span_column (GtkComboBox *combo_box, gint row_span);
343 gtk_combo_box_set_row_span_column(gtkComboBox
, rowSpan
);
347 * Returns the column with column span information for combo_box.
351 * the column span column.
354 public int getColumnSpanColumn()
356 // gint gtk_combo_box_get_column_span_column (GtkComboBox *combo_box);
357 return gtk_combo_box_get_column_span_column(gtkComboBox
);
361 * Sets the column with column span information for combo_box to be
362 * column_span. The column span column contains integers which indicate
363 * how many columns an item should span.
367 * A column in the model passed during construction.
370 public void setColumnSpanColumn(int columnSpan
)
372 // void gtk_combo_box_set_column_span_column (GtkComboBox *combo_box, gint column_span);
373 gtk_combo_box_set_column_span_column(gtkComboBox
, columnSpan
);
377 * Returns the index of the currently active item, or -1 if there's no
378 * active item. If the model is a non-flat treemodel, and the active item
379 * is not an immediate child of the root of the tree, this function returns
380 * gtk_tree_path_get_indices (path)[0], where
381 * path is the GtkTreePath of the active item.
385 * An integer which is the index of the currently active item, or
386 * -1 if there's no active item.
389 public int getActive()
391 // gint gtk_combo_box_get_active (GtkComboBox *combo_box);
392 return gtk_combo_box_get_active(gtkComboBox
);
396 * Sets the active item of combo_box to be the item at index.
400 * An index in the model passed during construction, or -1 to have
404 public void setActive(int index
)
406 // void gtk_combo_box_set_active (GtkComboBox *combo_box, gint index_);
407 gtk_combo_box_set_active(gtkComboBox
, index
);
411 * Sets iter to point to the current active item, if it exists.
415 * The uninitialized GtkTreeIter.
417 * TRUE, if iter was set
420 public int getActiveIter(TreeIter iter
)
422 // gboolean gtk_combo_box_get_active_iter (GtkComboBox *combo_box, GtkTreeIter *iter);
423 return gtk_combo_box_get_active_iter(gtkComboBox
, (iter
is null) ?
null : iter
.getTreeIterStruct());
427 * Sets the current active item to be the one referenced by iter.
428 * iter must correspond to a path of depth one.
435 public void setActiveIter(TreeIter iter
)
437 // void gtk_combo_box_set_active_iter (GtkComboBox *combo_box, GtkTreeIter *iter);
438 gtk_combo_box_set_active_iter(gtkComboBox
, (iter
is null) ?
null : iter
.getTreeIterStruct());
442 * Returns the GtkTreeModel which is acting as data source for combo_box.
446 * A GtkTreeModel which was passed during construction.
449 public TreeModel
getModel()
451 // GtkTreeModel* gtk_combo_box_get_model (GtkComboBox *combo_box);
452 return new TreeModel( gtk_combo_box_get_model(gtkComboBox
) );
456 * Sets the model used by combo_box to be model. Will unset a previously set
457 * model (if applicable). If model is NULL, then it will unset the model.
458 * Note that this function does not clear the cell renderers, you have to
459 * call gtk_combo_box_cell_layout_clear() yourself if you need to set up
460 * different cell renderers for the new model.
467 public void setModel(TreeModel model
)
469 // void gtk_combo_box_set_model (GtkComboBox *combo_box, GtkTreeModel *model);
470 gtk_combo_box_set_model(gtkComboBox
, (model
is null) ?
null : model
.getTreeModelStruct());
475 * Appends string to the list of strings stored in combo_box. Note that
476 * you can only use this function with combo boxes constructed with
477 * gtk_combo_box_new_text().
479 * A GtkComboBox constructed using gtk_combo_box_new_text().
484 public void appendText(char[] text
)
486 // void gtk_combo_box_append_text (GtkComboBox *combo_box, const gchar *text);
487 gtk_combo_box_append_text(gtkComboBox
, Str
.toStringz(text
));
491 * Inserts string at position in the list of strings stored in combo_box.
492 * Note that you can only use this function with combo boxes constructed
493 * with gtk_combo_box_new_text().
495 * A GtkComboBox constructed using gtk_combo_box_new_text().
497 * An index to insert text.
502 public void insertText(int position
, char[] text
)
504 // void gtk_combo_box_insert_text (GtkComboBox *combo_box, gint position, const gchar *text);
505 gtk_combo_box_insert_text(gtkComboBox
, position
, Str
.toStringz(text
));
509 * Prepends string to the list of strings stored in combo_box. Note that
510 * you can only use this function with combo boxes constructed with
511 * gtk_combo_box_new_text().
513 * A GtkComboBox constructed with gtk_combo_box_new_text().
518 public void prependText(char[] text
)
520 // void gtk_combo_box_prepend_text (GtkComboBox *combo_box, const gchar *text);
521 gtk_combo_box_prepend_text(gtkComboBox
, Str
.toStringz(text
));
525 * Removes the string at position from combo_box. Note that you can only use
526 * this function with combo boxes constructed with gtk_combo_box_new_text().
528 * A GtkComboBox constructed with gtk_combo_box_new_text().
530 * Index of the item to remove.
533 public void removeText(int position
)
535 // void gtk_combo_box_remove_text (GtkComboBox *combo_box, gint position);
536 gtk_combo_box_remove_text(gtkComboBox
, position
);
540 * Returns the currently active string in combo_box or NULL if none
541 * is selected. Note that you can only use this function with combo
542 * boxes constructed with gtk_combo_box_new_text() and with
545 * A GtkComboBox constructed with gtk_combo_box_new_text().
547 * a newly allocated string containing the currently active text.
550 public char[] getActiveText()
552 // gchar* gtk_combo_box_get_active_text (GtkComboBox *combo_box);
553 return Str
.toString(gtk_combo_box_get_active_text(gtkComboBox
) );
557 * Pops up the menu or dropdown list of combo_box.
558 * This function is mostly intended for use by accessibility technologies;
559 * applications should have little use for it.
566 // void gtk_combo_box_popup (GtkComboBox *combo_box);
567 gtk_combo_box_popup(gtkComboBox
);
571 * Hides the menu or dropdown list of combo_box.
572 * This function is mostly intended for use by accessibility technologies;
573 * applications should have little use for it.
578 public void popdown()
580 // void gtk_combo_box_popdown (GtkComboBox *combo_box);
581 gtk_combo_box_popdown(gtkComboBox
);
585 * Gets the accessible object corresponding to the combo box's popup.
586 * This function is mostly intended for use by accessibility technologies;
587 * applications should have little use for it.
591 * the accessible object corresponding to the combo box's popup.
594 public ObjectAtk
getPopupAccessible()
596 // AtkObject* gtk_combo_box_get_popup_accessible (GtkComboBox *combo_box);
597 return new ObjectAtk( gtk_combo_box_get_popup_accessible(gtkComboBox
) );
601 * Returns the current row separator function.
605 * the current row separator function.
608 public GtkTreeViewRowSeparatorFunc
getRowSeparatorFunc()
610 // GtkTreeViewRowSeparatorFunc gtk_combo_box_get_row_separator_func (GtkComboBox *combo_box);
611 return gtk_combo_box_get_row_separator_func(gtkComboBox
);
615 * Sets the row separator function, which is used to determine
616 * whether a row should be drawn as a separator. If the row separator
617 * function is NULL, no separators are drawn. This is the default value.
621 * a GtkTreeViewRowSeparatorFunc
623 * user data to pass to func, or NULL
625 * destroy notifier for data, or NULL
628 public void setRowSeparatorFunc(GtkTreeViewRowSeparatorFunc func
, void* data
, GtkDestroyNotify destroy
)
630 // void gtk_combo_box_set_row_separator_func (GtkComboBox *combo_box, GtkTreeViewRowSeparatorFunc func, gpointer data, GtkDestroyNotify destroy);
631 gtk_combo_box_set_row_separator_func(gtkComboBox
, func
, data
, destroy
);
635 * Sets whether the popup menu should have a tearoff
640 * TRUE to add tearoff menu items
643 public void setAddTearoffs(int addTearoffs
)
645 // void gtk_combo_box_set_add_tearoffs (GtkComboBox *combo_box, gboolean add_tearoffs);
646 gtk_combo_box_set_add_tearoffs(gtkComboBox
, addTearoffs
);
650 * Gets the current value of the :add-tearoffs property.
654 * the current value of the :add-tearoffs property.
656 public int getAddTearoffs()
658 // gboolean gtk_combo_box_get_add_tearoffs (GtkComboBox *combo_box);
659 return gtk_combo_box_get_add_tearoffs(gtkComboBox
);
663 * Sets the menu's title in tearoff mode.
667 * a title for the menu in tearoff mode.
670 public void setTitle(char[] title
)
672 // void gtk_combo_box_set_title (GtkComboBox *combo_box, const gchar *title);
673 gtk_combo_box_set_title(gtkComboBox
, Str
.toStringz(title
));
677 * Gets the current title of the menu in tearoff mode. See
678 * gtk_combo_box_set_add_tearoffs().
682 * the menu's title in tearoff mode. This is an internal copy of the
683 * string which must not be freed.
686 public char[] getTitle()
688 // const gchar* gtk_combo_box_get_title (GtkComboBox *combo_box);
689 return Str
.toString(gtk_combo_box_get_title(gtkComboBox
) );
693 * Sets whether the combo box will grab focus when it is clicked with
694 * the mouse. Making mouse clicks not grab focus is useful in places
695 * like toolbars where you don't want the keyboard focus removed from
696 * the main area of the application.
700 * whether the combo box grabs focus when clicked
704 public void setFocusOnClick(int focusOnClick
)
706 // void gtk_combo_box_set_focus_on_click (GtkComboBox *combo, gboolean focus_on_click);
707 gtk_combo_box_set_focus_on_click(gtkComboBox
, focusOnClick
);
711 * Returns whether the combo box grabs focus when it is clicked
712 * with the mouse. See gtk_combo_box_set_focus_on_click().
716 * TRUE if the combo box grabs focus when it is
717 * clicked with the mouse.
720 * The "active" property
721 * "active" gint : Read / Write
722 * The item which is currently active. If the model is a non-flat treemodel,
723 * and the active item is not an immediate child of the root of the tree,
724 * this property has the value gtk_tree_path_get_indices (path)[0],
725 * where path is the GtkTreePath of the active item.
726 * Allowed values: >= -1
730 public int getFocusOnClick()
732 // gboolean gtk_combo_box_get_focus_on_click (GtkComboBox *combo);
733 return gtk_combo_box_get_focus_on_click(gtkComboBox
);