changeset 311:24c1dfffe97e

Unified the callback functions for tree and container widgets.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 31 Mar 2003 09:57:45 +0000
parents 77105fe19c1f
children ff8f23594b15
files dwtest.c gtk/dw.c os2/dw.c win/dw.c
diffstat 4 files changed, 39 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/dwtest.c	Mon Mar 31 09:18:00 2003 +0000
+++ b/dwtest.c	Mon Mar 31 09:57:45 2003 +0000
@@ -346,52 +346,42 @@
 	return TRUE;
 }
 
-int DWSIGNAL container_select_cb( HWND window, char *text, void *data )
+int DWSIGNAL item_enter_cb( HWND window, char *text, void *data )
 {
-	char buf[100];
+	char buf[200];
 	HWND statline = (HWND)data;
 
-	sprintf(buf,"container-select: Window: %d Text: %s", window, text );
-	dw_window_set_text( statline, buf);
-	return 0;
-}
-
-int DWSIGNAL container_context_cb( HWND window, char *text, int x, int y, void *data )
-{
-	char buf[100];
-	HWND statline = (HWND)data;
-
-	sprintf(buf,"container-context: Window: %d Text: %s x: %d y: %d", window, text, x, y );
+	sprintf(buf,"DW_SIGNAL_ITEM_ENTER: Window: %x Text: %s Data:", window, text, data );
 	dw_window_set_text( statline, buf);
 	return 0;
 }
 
-int DWSIGNAL tree_context_cb( HWND window, char *text, int x, int y, void *data, void *itemdata )
+int DWSIGNAL item_context_cb( HWND window, char *text, int x, int y, void *data, void *itemdata )
 {
-	char buf[100];
+	char buf[200];
 	HWND statline = (HWND)data;
 
-	sprintf(buf,"tree-context: Window: %d Text: %s x: %d y: %d", window, text, x, y );
+	sprintf(buf,"DW_SIGNAL_ITEM_CONTEXT: Window: %x Text: %s x: %d y: %d Itemdata: %x", window, text, x, y, itemdata );
 	dw_window_set_text( statline, buf);
 	return 0;
 }
 
-int DWSIGNAL item_select_cb( HWND window, int item, void *data )
+int DWSIGNAL list_select_cb( HWND window, int item, void *data )
 {
-	char buf[100];
+	char buf[200];
 	HWND statline = (HWND)data;
 
-	sprintf(buf,"item-seelct: Window: %d Item: %d", window, item );
+	sprintf(buf,"DW_SIGNAL_LIST_SELECT: Window: %d Item: %d", window, item );
 	dw_window_set_text( statline, buf);
 	return 0;
 }
 
-int DWSIGNAL tree_select_cb( HWND window, HWND item, char *text, void *itemdata, void *data )
+int DWSIGNAL item_select_cb( HWND window, HWND item, char *text, void *data, void *itemdata )
 {
-	char buf[100];
+	char buf[200];
 	HWND statline = (HWND)data;
 
-	sprintf(buf,"tree-select: Window: %d Item: %d Text: %s", window, item, text );
+	sprintf(buf,"DW_SIGNAL_ITEM_SELECT: Window: %x Item: %x Text: %s Itemdata: %x", window, item, text, itemdata );
 	dw_window_set_text( statline, buf);
 	return 0;
 }
@@ -446,9 +436,9 @@
 	dw_window_set_color(buttonbox, DW_CLR_DARKCYAN, DW_CLR_PALEGRAY);
 	dw_window_set_color(okbutton, DW_CLR_PALEGRAY, DW_CLR_DARKCYAN);
 
-	dw_signal_connect(browsebutton, "clicked", DW_SIGNAL_FUNC(browse_callback), (void *)notebookbox1);
-	dw_signal_connect(okbutton, "clicked", DW_SIGNAL_FUNC(beep_callback), (void *)notebookbox1);
-	dw_signal_connect(cancelbutton, "clicked", DW_SIGNAL_FUNC(exit_callback), (void *)mainwindow);
+	dw_signal_connect(browsebutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(browse_callback), (void *)notebookbox1);
+	dw_signal_connect(okbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(beep_callback), (void *)notebookbox1);
+	dw_signal_connect(cancelbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(exit_callback), (void *)mainwindow);
 }
 
 
@@ -503,13 +493,13 @@
 	dw_messagebox("DWTest", "Width: %d Height: %d\n", font_width, font_height);
 	dw_draw_rect(0, text1pm, TRUE, 0, 0, font_width*width1, font_height*rows);
 	dw_draw_rect(0, text2pm, TRUE, 0, 0, font_width*cols, font_height*rows);
-	dw_signal_connect(textbox1, "expose_event", DW_SIGNAL_FUNC(text_expose), NULL);
-	dw_signal_connect(textbox2, "expose_event", DW_SIGNAL_FUNC(text_expose), NULL);
-	dw_signal_connect(textbox2, "configure_event", DW_SIGNAL_FUNC(configure_event), text2pm);
-	dw_signal_connect(hscrollbar, "value_changed", DW_SIGNAL_FUNC(scrollbar_valuechanged), (void *)status);
-	dw_signal_connect(vscrollbar, "value_changed", DW_SIGNAL_FUNC(scrollbar_valuechanged), (void *)status);
+	dw_signal_connect(textbox1, DW_SIGNAL_EXPOSE, DW_SIGNAL_FUNC(text_expose), NULL);
+	dw_signal_connect(textbox2, DW_SIGNAL_EXPOSE, DW_SIGNAL_FUNC(text_expose), NULL);
+	dw_signal_connect(textbox2, DW_SIGNAL_CONFIGURE, DW_SIGNAL_FUNC(configure_event), text2pm);
+	dw_signal_connect(hscrollbar, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(scrollbar_valuechanged), (void *)status);
+	dw_signal_connect(vscrollbar, DW_SIGNAL_VALUE_CHANGED, DW_SIGNAL_FUNC(scrollbar_valuechanged), (void *)status);
 
-	dw_signal_connect(mainwindow, "key_press_event", DW_SIGNAL_FUNC(keypress_callback), NULL);
+	dw_signal_connect(mainwindow, DW_SIGNAL_KEY_PRESS, DW_SIGNAL_FUNC(keypress_callback), NULL);
 }
 
 void tree_add(void)
@@ -539,13 +529,8 @@
 	t6 = dw_tree_insert(tree, "tree file 4", fileicon, t2, NULL );
 
 	/* set up our signal trappers... */
-	/* looks odd, we use a container-context signal on a tree widget! */
-	dw_signal_connect(tree, "container-context", DW_SIGNAL_FUNC(container_context_cb), tree_status);
-	dw_signal_connect(tree, "tree-select", DW_SIGNAL_FUNC(tree_select_cb), tree_status);
-	/* also odd; the tree-context doesn't seem to do anything. In fact GTK complains that
-	 * tree-context is invalid in a tree widget
-	 */
-	dw_signal_connect(tree, "tree-context", DW_SIGNAL_FUNC(tree_context_cb), tree_status);
+	dw_signal_connect(tree, DW_SIGNAL_ITEM_CONTEXT, DW_SIGNAL_FUNC(item_context_cb), (void *)tree_status);
+	dw_signal_connect(tree, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(item_select_cb), (void *)tree_status);
 }
 
 void container_add(void)
@@ -606,13 +591,9 @@
 	dw_container_optimize(container);
 
 	/* connect our event trappers... */
-	dw_signal_connect(container, "container-select", DW_SIGNAL_FUNC(container_select_cb), container_status);
-	dw_signal_connect(container, "container-context", DW_SIGNAL_FUNC(container_context_cb), container_status);
-	/* NOTE that even though we are trapping a tree-select on a container, we have to set
-	 * a container-select callback handler, otherwise dwindows will crash, because
-	 * the prototypes for tree-select and container-select callback handlers are different
-	 */
-	dw_signal_connect(container, "tree-select", DW_SIGNAL_FUNC(container_select_cb), container_status);
+	dw_signal_connect(container, DW_SIGNAL_ITEM_ENTER, DW_SIGNAL_FUNC(item_enter_cb), (void *)container_status);
+	dw_signal_connect(container, DW_SIGNAL_ITEM_CONTEXT, DW_SIGNAL_FUNC(item_context_cb), (void *)container_status);
+	dw_signal_connect(container, DW_SIGNAL_ITEM_SELECT, DW_SIGNAL_FUNC(item_select_cb), (void *)container_status);
 }
 
 /* Beep every second */
@@ -668,7 +649,7 @@
 	dw_notebook_page_set_text( notebook, notebookpage4, "container");
 	container_add();
 
-	dw_signal_connect(mainwindow, "delete_event", DW_SIGNAL_FUNC(exit_callback), (void *)mainwindow);
+	dw_signal_connect(mainwindow, DW_SIGNAL_DELETE, DW_SIGNAL_FUNC(exit_callback), (void *)mainwindow);
 	timerid = dw_timer_connect(1000, DW_SIGNAL_FUNC(timer_callback), 0);
 	dw_window_set_usize(mainwindow, 640, 480);
 	dw_window_show(mainwindow);
--- a/gtk/dw.c	Mon Mar 31 09:18:00 2003 +0000
+++ b/gtk/dw.c	Mon Mar 31 09:57:45 2003 +0000
@@ -490,7 +490,7 @@
 		{
 			GtkTreeModel *store = (GtkTreeModel *)gtk_object_get_data(GTK_OBJECT(widget), "_dw_tree_store");
 			gtk_tree_model_get(store, &iter, 0, &text, 2, &itemdata, 3, &item, -1);
-			retval = treeselectfunc(work->window, item, text, itemdata, work->data);
+			retval = treeselectfunc(work->window, item, text, work->data, itemdata);
 		}
 	}
 	return retval;
@@ -515,7 +515,7 @@
 		int (*treeselectfunc)(HWND, HWND, char *, void *, void *) = work->func;
 		char *text = (char *)gtk_object_get_data(GTK_OBJECT(child), "text");
 		void *itemdata = (void *)gtk_object_get_data(GTK_OBJECT(child), "itemdata");
-		retval = treeselectfunc(work->window, child, text, itemdata, work->data);
+		retval = treeselectfunc(work->window, child, text, work->data, itemdata);
 	}
 	return retval;
 }
@@ -567,9 +567,9 @@
 {
 	SignalHandler *work = (SignalHandler *)data;
 	char *rowdata = gtk_clist_get_row_data(GTK_CLIST(widget), row);
-	int (*contextfunc)(HWND, char *, void *) = work->func;
-
-	return contextfunc(work->window, rowdata, work->data);;
+	int (*contextfunc)(HWND, HWND, char *, void *, void *) = work->func;
+
+	return contextfunc(work->window, 0, rowdata, work->data, 0);;
 }
 
 static gint _unselect_row(GtkWidget *widget, gint row, gint column, GdkEventButton *event, gpointer data)
--- a/os2/dw.c	Mon Mar 31 09:18:00 2003 +0000
+++ b/os2/dw.c	Mon Mar 31 09:57:45 2003 +0000
@@ -2147,16 +2147,12 @@
 
 										if(pci && pre->fEmphasisMask & CRA_CURSORED && (pci->rc.flRecordAttr & CRA_CURSORED))
 										{
+											int (* API treeselectfunc)(HWND, HWND, char *, void *, void *) = (int (* API)(HWND, HWND, char *, void *, void *))tmp->signalfunction;
+
 											if(dw_window_get_data(tmp->window, "_dw_container"))
-											{
-												int (* API containerselectfunc)(HWND, char *, void *) = (int (* API)(HWND, char *, void *))tmp->signalfunction;
-
-												result = containerselectfunc(tmp->window, pci->rc.pszIcon, tmp->data);
-											}
+												result = treeselectfunc(tmp->window, 0, pci->rc.pszIcon, tmp->data, 0);
 											else
 											{
-												int (* API treeselectfunc)(HWND, HWND, char *, void *, void *) = (int (* API)(HWND, HWND, char *, void *, void *))tmp->signalfunction;
-
 												if(lasthcnr == tmp->window && lastitem == (HWND)pci)
 												{
 													lasthcnr = 0;
@@ -2166,7 +2162,7 @@
 												{
 													lasthcnr = tmp->window;
 													lastitem = (HWND)pci;
-													result = treeselectfunc(tmp->window, (HWND)pci, pci->rc.pszIcon, pci->user, tmp->data);
+													result = treeselectfunc(tmp->window, (HWND)pci, pci->rc.pszIcon, tmp->data, pci->user);
 												}
 											}
 											tmp = NULL;
--- a/win/dw.c	Mon Mar 31 09:18:00 2003 +0000
+++ b/win/dw.c	Mon Mar 31 09:57:45 2003 +0000
@@ -1500,7 +1500,7 @@
 
 										ptrs = (void **)tvi.lParam;
 										if(ptrs)
-											result = treeselectfunc(tmp->window, (HWND)tem->itemNew.hItem, (char *)ptrs[0], (void *)ptrs[1], tmp->data);
+											result = treeselectfunc(tmp->window, (HWND)tem->itemNew.hItem, (char *)ptrs[0], tmp->data, (void *)ptrs[1]);
 
 										tmp = NULL;
 									}
@@ -1556,7 +1556,7 @@
 
 										if(iItem > -1)
 										{
-											int (*containerselectfunc)(HWND, char *, void *) = tmp->signalfunction;
+											int (*treeselectfunc)(HWND, HWND, char *, void *, void *) = tmp->signalfunction;
 
 											lvi.iItem = iItem;
 											lvi.mask = LVIF_PARAM;
@@ -1567,7 +1567,7 @@
 											if(lvi.lParam < 100)
 												lvi.lParam = 0;
 
-											containerselectfunc(tmp->window, (char *)lvi.lParam, tmp->data);
+											treeselectfunc(tmp->window, 0, (char *)lvi.lParam, tmp->data, 0);
 											tmp = NULL;
 										}
 									}