20 #if GTK_MAJOR_VERSION>2 21 #error "Support not ready for GTK major version > 2" 50 column=gtk_tree_view_column_new();
51 gtk_tree_view_column_set_title (column, title);
52 setTitleAlignment(0.5);
59 pair<string *, GType> *deleteMe=
remove();
60 delete deleteMe->first;
69 gtk_tree_view_column_set_alignment(column, align);
78 GList*renderers=gtk_tree_view_column_get_cell_renderers(column);
79 for (
unsigned int i=0;i<g_list_length(renderers);i++)
81 gtk_cell_renderer_set_alignment(GTK_CELL_RENDERER(g_list_nth_data(renderers,i)), xAlign, yAlign);
121 SelectionColumn &
add(
string *name, GType whichType, GtkCellRenderer *renderer,
int source, gboolean expand=
true) {
122 gtk_cell_renderer_set_alignment(renderer, 0.5,0.5);
124 gtk_tree_view_column_pack_start (column, renderer, expand);
125 gtk_tree_view_column_add_attribute (column, renderer, name->c_str(), source);
150 return add(detail.first,G_TYPE_STRING,(GtkCellRenderer *)detail.second, number);
158 return add(detail.first,GDK_TYPE_PIXBUF,(GtkCellRenderer *)detail.second, number);
186 gtk_tree_view_column_set_sizing(column,sz);
194 return gtk_tree_view_column_get_sizing(column);
245 tree = gtk_tree_view_new();
271 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree)));
272 GtkTreeIter* iter =
new GtkTreeIter;
273 if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(store), iter, NULL,gtk_tree_model_iter_n_children(GTK_TREE_MODEL(store), NULL)-1))
286 store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree)));
287 GtkTreeIter* iter=NULL;
289 iter=
new GtkTreeIter;
291 gtk_tree_store_append(store, iter, NULL);
302 GtkTreeIter*
appendNewIter(GtkTreeStore *store, gboolean sameRow, gboolean sameColumn) {
303 GtkTreeIter* iter=NULL;
307 iter=getLastIter(store);
311 iter=appendRow(store);
330 while (next()!=currentCol)
349 Selection(
const char *listName, GCallback callback=NULL,
void *data=NULL) {
350 init(listName, callback, data);
363 void init(
const char *listName, GCallback callback=NULL,
void *data=NULL) {
365 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
370 *sc<<pair<string*, GtkCellRendererText*>(
new string(
"text"), GTK_CELL_RENDERER_TEXT(gtk_cell_renderer_text_new()));
374 if (callback && data)
375 setSelectionCallback(
"changed", callback, data);
377 setSelectionCallback(callback);
384 setSelectionCallback(
"changed", callback,
this);
393 changedHandlerID=g_signal_connect(selection, event, callback, data);
408 g_signal_connect(tree, event, G_CALLBACK(callback), data);
416 gtk_tree_view_append_column(GTK_TREE_VIEW(tree), current()->getColumn());
433 GType *types =
new GType[getCount()];
436 for (
int i=0; i<getCount(); i++) {
437 types[i]=next()->current()->second;
440 while (next()!=newCol) ;
442 GtkTreeStore *store = gtk_tree_store_newv(getCount(), types);
443 gtk_tree_view_set_model(GTK_TREE_VIEW(tree), GTK_TREE_MODEL(store));
444 g_object_unref(store);
446 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree));
454 g_signal_connect_after(selection,
"changed", G_CALLBACK(callback), data);
466 gtk_widget_show_all(tree);
472 gtk_widget_hide(tree);
480 getSelection(valueS);
481 strcpy(value,valueS.c_str());
492 int colNum=currentColumnNumber();
494 if (gtk_tree_selection_get_selected(GTK_TREE_SELECTION(selection), &model, &iter)) {
495 gtk_tree_model_get(model, &iter, colNum, &val, -1);
513 void add(
const char *text, gboolean sameRow=
false, gboolean sameColumn=
true) {
514 GtkTreeStore *store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree)));
515 GtkTreeIter* iter=appendNewIter(store, sameRow, sameColumn);
517 int whichColumn=currentColumnNumber();
519 gtk_tree_store_set(store, iter, whichColumn, text, -1);
532 void add(GdkPixbuf *pixbuf, gboolean sameRow=
false, gboolean sameColumn=
true) {
533 GtkTreeStore *store = GTK_TREE_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(tree)));
534 GtkTreeIter* iter=appendNewIter(store, sameRow, sameColumn);
536 int whichColumn=currentColumnNumber();
538 gtk_tree_store_set(store, iter, whichColumn, pixbuf, -1);
546 if (changedHandlerID)
547 g_signal_handler_block(selection, changedHandlerID);
549 GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (tree));
552 if (gtk_tree_model_get_iter_first(model, &iter) == FALSE)
554 gtk_tree_store_clear(GTK_TREE_STORE(model));
556 if (changedHandlerID)
557 g_signal_handler_unblock(selection, changedHandlerID);
660 GtkTreePath *pathLocal = gtk_tree_path_new_from_string (path);
662 gtk_tree_selection_select_path(selection, pathLocal);
665 #endif //SELECTION_H_ void selectRow(char *path)
GtkTreeIter * appendRow(GtkTreeStore *store=NULL)
Selection & operator<<(GdkPixbuf *pixbuf)
Selection & operator<<(SelectionColumn *newCol)
int number
The number of this column.
GtkTreeViewColumn * column
Selection(const char *listName, GCallback callback=NULL, void *data=NULL)
Selection GtkTreeView based widget Inherits from a LinkList of GtkTreeViewColumn* which allows modifi...
virtual ~SelectionColumn(void)
GtkWidget * getWidget(void)
void setSelectionCallback(const char *event, GCallback callback, gpointer data)
void init(const char *listName, GCallback callback=NULL, void *data=NULL)
GtkTreeSelection * selection
The tree selection box.
Selection & operator<<(const char *text)
void add(SelectionColumn *newCol)
void setTreeCallback(const char *event, GCallback callback, gpointer data)
gulong changedHandlerID
The callback handler id for when the selection is changed.
void add(GdkPixbuf *pixbuf, gboolean sameRow=false, gboolean sameColumn=true)
void setAlignment(float xAlign, float yAlign)
Set the alignment of the column contents Sets the alignment of the column contents - applies to all r...
void setTitleAlignment(float align)
Set the alignment of the column title in the header Sets the alignment of the column heading to 0...
void getSelection(char *value)
GtkWidget * tree
The tree of items for the selection widget.
void add(TYPE newElement)
Adds as the current element ... Added to the next of the current lug.
void add(const char *text, gboolean sameRow=false, gboolean sameColumn=true)
SelectionColumn(const char *title, int number_)
void getSelection(string &value)
Selection & operator<<(const string text)
SelectionColumn & add(string *name, GType whichType, GtkCellRenderer *renderer, int source, gboolean expand=true)
GtkTreeIter * getLastIter(GtkTreeStore *store=NULL)
GtkTreeViewColumn * getColumn(void)
int currentColumnNumber(void)
void setSelectionCallback(GCallback callback)
void setSizing(GtkTreeViewColumnSizing sz)
GtkTreeViewColumnSizing getSizing(void)
GtkTreeIter * appendNewIter(GtkTreeStore *store, gboolean sameRow, gboolean sameColumn)
void setCallbackAfter(GCallback callback, void *data)
change the callback data to be returned with the callback.