changeset 55:b6948eac375a

Sync with the latest dynamic windows, tree fixes, and other miscellaneous stuff.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 21 Nov 2001 22:31:55 +0000
parents c4e1139d9872
children b0f94956c981
files gtk/dw.c os2/dw.c win/dw.c
diffstat 3 files changed, 147 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/gtk/dw.c	Sat Nov 17 17:40:16 2001 +0000
+++ b/gtk/dw.c	Wed Nov 21 22:31:55 2001 +0000
@@ -2959,7 +2959,6 @@
 	if(lastselect == item)
 		gtk_object_set_data(GTK_OBJECT(handle), "lastselect", NULL);
 
-	gtk_tree_remove_item(GTK_TREE(tree), item);
 	gtk_widget_destroy(item);
 	DW_MUTEX_UNLOCK;
 }
@@ -5408,6 +5407,12 @@
 		if(GTK_IS_COMBO(thiswindow))
 			thiswindow = GTK_COMBO(thiswindow)->entry;
 	}
+	else if(strcmp(signame, "lose-focus") == 0)
+	{
+		thisname = "focus-out-event";
+		if(GTK_IS_COMBO(thiswindow))
+			thiswindow = GTK_COMBO(thiswindow)->entry;
+	}
 	else if(GTK_IS_TREE(thiswindow) && strcmp(signame, "tree-select") == 0)
 	{
 		if(thisfunc)
--- a/os2/dw.c	Sat Nov 17 17:40:16 2001 +0000
+++ b/os2/dw.c	Wed Nov 21 22:31:55 2001 +0000
@@ -45,6 +45,7 @@
 HWND hwndBubble = NULLHANDLE, hwndBubbleLast = NULLHANDLE;
 PRECORDCORE pCore = NULL;
 ULONG aulBuffer[4];
+HWND lasthcnr = 0, lastitem = 0;
 
 #define IS_WARP4() (aulBuffer[0] == 20 && aulBuffer[1] >= 40)
 
@@ -92,7 +93,7 @@
 } SignalList;
 
 /* List of signals and their equivilent OS/2 message */
-#define SIGNALMAX 13
+#define SIGNALMAX 14
 
 SignalList SignalTranslate[SIGNALMAX] = {
 	{ WM_SIZE, "configure_event" },
@@ -107,7 +108,8 @@
 	{ CN_CONTEXTMENU, "container-context" },
 	{ LN_SELECT, "item-select" },
 	{ CN_EMPHASIS, "tree-select" },
-	{ WM_SETFOCUS, "set-focus" }
+	{ WM_SETFOCUS, "set-focus" },
+	{ WM_USER+1, "lose-focus" }
 };
 
 /* This function adds a signal handler callback into the linked list.
@@ -116,6 +118,11 @@
 {
 	SignalHandler *new = malloc(sizeof(SignalHandler));
 
+#ifndef NO_SIGNALS
+	if(message == WM_COMMAND)
+		dw_signal_disconnect_by_window(window);
+#endif
+
 	new->message = message;
 	new->window = window;
 	new->signalfunction = signalfunction;
@@ -188,6 +195,22 @@
 	return;
 }
 
+void _disconnect_windows(HWND handle)
+{
+	HENUM henum;
+	HWND child;
+
+#ifndef NO_SIGNALS
+	dw_signal_disconnect_by_window(handle);
+#endif
+
+	henum = WinBeginEnumWindows(handle);
+	while((child = WinGetNextWindow(henum)) != NULLHANDLE)
+		_disconnect_windows(child);
+
+	WinEndEnumWindows(henum);
+}
+
 /* This function removes and handlers on windows and frees
  * the user memory allocated to it.
  */
@@ -233,9 +256,9 @@
 	/* These are the window classes which can
 	 * obtain input focus.
 	 */
-	if(strncmp(tmpbuf, "#2", 3)==0 ||  /* Entryfield */
+	if(strncmp(tmpbuf, "#2", 3)==0 ||  /* Combobox */
 	   strncmp(tmpbuf, "#3", 3)==0 ||  /* Button */
-	   strncmp(tmpbuf, "#6", 3)==0 ||  /* Combobox */
+	   strncmp(tmpbuf, "#6", 3)==0 ||  /* Entryfield */
 	   strncmp(tmpbuf, "#7", 3)==0 ||  /* List box */
 	   strncmp(tmpbuf, "#10", 3)==0 || /* MLE */
 	   strncmp(tmpbuf, "#32", 3)==0 || /* Spinbutton */
@@ -419,7 +442,7 @@
 /* This function finds the first widget in the
  * layout and moves the current focus to it.
  */
-void _initial_focus(HWND handle)
+int _initial_focus(HWND handle)
 {
 	Box *thisbox = NULL;
 	HWND box;
@@ -427,11 +450,12 @@
 	box = WinWindowFromID(handle, FID_CLIENT);
 	if(box)
 		thisbox = WinQueryWindowPtr(box, QWP_USER);
+	else
+		return 1;
 
 	if(thisbox)
-	{
 		_focus_check_box(thisbox, handle, 3, thisbox->defaultitem);
-	}
+	return 0;
 }
 
 /* This function finds the current widget in the
@@ -1238,12 +1262,33 @@
 		WinSetFocus(HWND_DESKTOP, handle);
 }
 
+MRESULT EXPENTRY _comboentryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
+{
+	WindowData *blah = (WindowData *)WinQueryWindowPtr(hWnd, QWP_USER);
+
+	switch(msg)
+	{
+	case WM_SETFOCUS:
+		_run_event(hWnd, msg, mp1, mp2);
+		break;
+	}
+
+	if(blah && blah->oldproc)
+		return blah->oldproc(hWnd, msg, mp1, mp2);
+
+	return WinDefWindowProc(hWnd, msg, mp1, mp2);
+}
+
 /* Originally just intended for entryfields, it now serves as a generic
  * procedure for handling TAB presses to change input focus on controls.
  */
 MRESULT EXPENTRY _entryproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
 {
 	WindowData *blah = (WindowData *)WinQueryWindowPtr(hWnd, QWP_USER);
+	PFNWP oldproc = 0;
+
+	if(blah)
+		oldproc = blah->oldproc;
 
 	switch(msg)
 	{
@@ -1273,8 +1318,9 @@
 
 		break;
 	}
-	if(blah && blah->oldproc)
-		return blah->oldproc(hWnd, msg, mp1, mp2);
+
+	if(oldproc)
+		return oldproc(hWnd, msg, mp1, mp2);
 
 	return WinDefWindowProc(hWnd, msg, mp1, mp2);
 }
@@ -1285,6 +1331,10 @@
 MRESULT EXPENTRY _comboproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
 {
 	WindowData *blah = WinQueryWindowPtr(hWnd, QWP_USER);
+	PFNWP oldproc = 0;
+
+	if(blah)
+		oldproc = blah->oldproc;
 
 	switch(msg)
 	{
@@ -1331,8 +1381,8 @@
 		}
 		break;
 	}
-	if(blah && blah->oldproc)
-		return blah->oldproc(hWnd, msg, mp1, mp2);
+	if(oldproc)
+		return oldproc(hWnd, msg, mp1, mp2);
 
 	return WinDefWindowProc(hWnd, msg, mp1, mp2);
 }
@@ -1395,13 +1445,13 @@
 	/* Find any callbacks for this function */
 	while(tmp)
 	{
-		if(tmp->message == msg || msg == WM_CONTROL)
+		if(tmp->message == msg || msg == WM_CONTROL || tmp->message == WM_USER+1)
 		{
 			switch(msg)
 			{
 			case WM_SETFOCUS:
 				{
-					if(mp2)
+					if((mp2 && tmp->message == WM_SETFOCUS) || (!mp2 && tmp->message == WM_USER+1))
 					{
 						int (*setfocusfunc)(HWND, void *) = (int (*)(HWND, void *))tmp->signalfunction;
 
@@ -1616,6 +1666,7 @@
 									pre.fEmphasisMask = CRA_CURSORED;
 									pre.hwndCnr = tmp->window;
 									_run_event(hWnd, WM_CONTROL, MPFROM2SHORT(0, CN_EMPHASIS), (MPARAM)&pre);
+									pre.pRecord->flRecordAttr |= CRA_CURSORED;
 								}
 								result = containercontextfunc(tmp->window, text, x, y, tmp->data, user);
 								tmp = NULL;
@@ -1637,12 +1688,21 @@
 									{
 										PCNRITEM pci = (PCNRITEM)pre->pRecord;
 
-										if(pci && pre->fEmphasisMask & CRA_CURSORED)
+										if(pci && pre->fEmphasisMask & CRA_CURSORED && (pci->rc.flRecordAttr & CRA_CURSORED))
 										{
 											int (*treeselectfunc)(HWND, HWND, char *, void *, void *) = (int (*)(HWND, HWND, char *, void *, void *))tmp->signalfunction;
 
-											result = treeselectfunc(tmp->window, (HWND)pci, pci->rc.pszIcon, pci->user, tmp->data);
-
+											if(lasthcnr == tmp->window && lastitem == (HWND)pci)
+											{
+												lasthcnr = 0;
+												lastitem = 0;
+											}
+											else
+											{
+												lasthcnr = tmp->window;
+												lastitem = (HWND)pci;
+												result = treeselectfunc(tmp->window, (HWND)pci, pci->rc.pszIcon, pci->user, tmp->data);
+											}
 											tmp = NULL;
 										}
 									}
@@ -2787,7 +2847,7 @@
 		free(thisitem);
 		thisbox->count--;
 	}
-	_free_window_memory(handle);
+	_disconnect_windows(handle);
 	return WinDestroyWindow(handle);
 }
 
@@ -3519,6 +3579,16 @@
 							   id,
 							   NULL,
 							   NULL);
+	HENUM henum = WinBeginEnumWindows(tmp);
+	HWND child;
+	
+	while((child = WinGetNextWindow(henum)) != NULLHANDLE)
+	{
+		WindowData *moreblah = calloc(1, sizeof(WindowData));
+		moreblah->oldproc = WinSubclassWindow(child, _comboentryproc);
+		WinSetWindowPtr(child, QWP_USER, moreblah);
+	}
+	WinEndEnumWindows(henum);
 	dw_window_set_font(tmp, DefaultFont);
 	dw_window_set_color(tmp, DW_CLR_BLACK, DW_CLR_WHITE);
 	blah->oldproc = WinSubclassWindow(tmp, _comboproc);
@@ -4678,7 +4748,7 @@
 	/* Fill in the parent record data */
 
 	pci->rc.cb          = sizeof(MINIRECORDCORE);
-	pci->rc.pszIcon     = title;
+	pci->rc.pszIcon     = strdup(title);
 	pci->rc.hptrIcon    = icon;
 
 	pci->hptrIcon       = icon;
@@ -4719,7 +4789,10 @@
 	if(!pci)
 		return;
 
-	pci->rc.pszIcon     = title;
+	if(pci->rc.pszIcon)
+		free(pci->rc.pszIcon);
+
+	pci->rc.pszIcon     = strdup(title);
 	pci->rc.hptrIcon    = icon;
 
 	pci->hptrIcon       = icon;
@@ -4761,6 +4834,8 @@
 		pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
 	}
 	WinSendMsg(handle, CM_SETRECORDEMPHASIS, (MPARAM)item, MPFROM2SHORT(TRUE, CRA_SELECTED | CRA_CURSORED));
+	lastitem = 0;
+	lasthcnr = 0;
 }
 
 /*
@@ -4804,6 +4879,13 @@
 void dw_tree_delete(HWND handle, HWND item)
 {
 	PCNRITEM     pci = (PCNRITEM)item;
+
+	if(!item)
+		return;
+
+	if(pci->rc.pszIcon)
+		free(pci->rc.pszIcon);
+
 	WinSendMsg(handle, CM_REMOVERECORD, (MPARAM)&pci, MPFROM2SHORT(1, CMA_INVALIDATE | CMA_FREE));
 }
 
@@ -6439,7 +6521,7 @@
  */
 int dw_exec(char *program, int type, char **params)
 {
-	return spawnvp(P_NOWAIT, program, params);
+	return spawnvp(P_NOWAIT, program, (const char **)params);
 }
 
 /*
@@ -6533,6 +6615,21 @@
 {
 	ULONG message = 0L;
 
+	if(strcmp(signame, "lose-focus") == 0)
+	{
+		char tmpbuf[100];
+
+		WinQueryClassName(window, 99, tmpbuf);
+
+		if(strncmp(tmpbuf, "#2", 3) == 0)
+		{
+			HENUM henum = WinBeginEnumWindows(window);
+			HWND child = WinGetNextWindow(henum);
+			WinEndEnumWindows(henum);
+			if(child)
+				window = child;
+		}
+	}
 	if(window && signame && sigfunc)
 	{
 		if((message = _findsigmessage(signame)) != 0)
--- a/win/dw.c	Sat Nov 17 17:40:16 2001 +0000
+++ b/win/dw.c	Wed Nov 21 22:31:55 2001 +0000
@@ -99,7 +99,7 @@
 } SignalList;
 
 /* List of signals and their equivilent Win32 message */
-#define SIGNALMAX 13
+#define SIGNALMAX 14
 
 SignalList SignalTranslate[SIGNALMAX] = {
 	{ WM_SIZE, "configure_event" },
@@ -114,7 +114,8 @@
 	{ NM_RCLICK, "container-context" },
 	{ LBN_SELCHANGE, "item-select" },
 	{ TVN_SELCHANGED, "tree-select" },
-	{ WM_SETFOCUS, "set-focus" }
+	{ WM_SETFOCUS, "set-focus" },
+	{ WM_USER+1, "lose-focus" }
 };
 
 #ifdef BUILD_DLL
@@ -242,6 +243,11 @@
 {
 	SignalHandler *new = malloc(sizeof(SignalHandler));
 
+#ifndef NO_SIGNALS
+	if(message == WM_COMMAND)
+		dw_signal_disconnect_by_window(window);
+#endif
+
 	new->message = message;
 	new->window = window;
 	new->signalfunction = signalfunction;
@@ -457,6 +463,16 @@
 void _initial_focus(HWND handle)
 {
 	Box *thisbox;
+	char tmpbuf[100];
+
+	if(!handle)
+		return;
+
+	GetClassName(handle, tmpbuf, 99);
+
+	if(strnicmp(tmpbuf, ClassName, strlen(ClassName))!=0)
+		return;
+
 
 	if(handle)
 		thisbox = (Box *)GetWindowLong(handle, GWL_USERDATA);
@@ -1013,7 +1029,7 @@
 		/* Find any callbacks for this function */
 		while(tmp)
 		{
-			if(tmp->message == msg || msg == WM_COMMAND || msg == WM_NOTIFY)
+			if(tmp->message == msg || msg == WM_COMMAND || msg == WM_NOTIFY || tmp->message == WM_USER+1)
 			{
 				switch(msg)
 				{
@@ -1592,6 +1608,7 @@
 {
 	ColorInfo *cinfo;
 	char tmpbuf[100];
+	WNDPROC pOldProc = 0;
 
 	cinfo = (ColorInfo *)GetWindowLong(hWnd, GWL_USERDATA);
 
@@ -1601,6 +1618,8 @@
 
 	if(cinfo)
 	{
+		pOldProc = cinfo->pOldProc;
+
 		switch( msg )
 		{
 		case WM_SETFOCUS:
@@ -1720,9 +1739,9 @@
 		}
 	}
 
-	if(!cinfo || !cinfo->pOldProc)
+	if(!pOldProc)
 		return DefWindowProc(hWnd, msg, mp1, mp2);
-	return CallWindowProc(cinfo->pOldProc, hWnd, msg, mp1, mp2);
+	return CallWindowProc(pOldProc, hWnd, msg, mp1, mp2);
 }
 
 BOOL CALLBACK _containerwndproc(HWND hWnd, UINT msg, WPARAM mp1, LPARAM mp2)