changeset 39:3aa9ef0b3996

Added focus fixes and set-focus fixes on all three platforms.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 19 Oct 2001 14:16:50 +0000
parents 538db2a48bac
children 88c9c7410c22
files dw.h gtk/dw.c os2/dw.c win/dw.c
diffstat 4 files changed, 88 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/dw.h	Wed Oct 17 19:22:39 2001 +0000
+++ b/dw.h	Fri Oct 19 14:16:50 2001 +0000
@@ -255,7 +255,7 @@
 typedef struct _color {
 	int fore;
 	int back;
-	HWND buddy;
+	HWND combo, buddy;
 	int user;
 	HBRUSH hbrush;
 	char fontname[128];
--- a/gtk/dw.c	Wed Oct 17 19:22:39 2001 +0000
+++ b/gtk/dw.c	Fri Oct 19 14:16:50 2001 +0000
@@ -307,6 +307,10 @@
 void _item_select_event(GtkWidget *widget, GtkWidget *child, gpointer data)
 {
 	SignalHandler *work = (SignalHandler *)data;
+	static int _dw_recursing = 0;
+
+	if(_dw_recursing)
+		return;
 
 	if(work)
 	{
@@ -314,6 +318,8 @@
 		GList *list;
 		int item = 0;
 
+		_dw_recursing = 1;
+
 		if(GTK_IS_COMBO(work->window))
 			list = GTK_LIST(GTK_COMBO(work->window)->list)->children;
 		else if(GTK_IS_LIST(widget))
@@ -332,6 +338,7 @@
 			item++;
 			list = list->next;
 		}
+		_dw_recursing = 0;
 	}
 }
 
@@ -4873,6 +4880,8 @@
 	else if(strcmp(signame, "set-focus") == 0)
 	{
 		thisname = "focus-in-event";
+		if(GTK_IS_COMBO(thiswindow))
+			thiswindow = GTK_COMBO(thiswindow)->entry;
 	}
 	else if(GTK_IS_TREE(thiswindow) && strcmp(signame, "tree-select") == 0)
 	{
--- a/os2/dw.c	Wed Oct 17 19:22:39 2001 +0000
+++ b/os2/dw.c	Fri Oct 19 14:16:50 2001 +0000
@@ -1255,6 +1255,14 @@
 			return FALSE;
 		}
 		break;
+	case WM_BUTTON1DOWN:
+	case WM_BUTTON2DOWN:
+	case WM_BUTTON3DOWN:
+		_run_event(hWnd, WM_SETFOCUS, (MPARAM)FALSE, (MPARAM)TRUE);
+		break;
+	case WM_SETFOCUS:
+		_run_event(hWnd, msg, mp1, mp2);
+		break;
 	case WM_PAINT:
 		{
 			HWND parent = WinQueryWindow(hWnd, QW_PARENT);
@@ -1568,8 +1576,9 @@
 							int (*listboxselectfunc)(HWND, int, void *) = (int (*)(HWND, int, void *))tmp->signalfunction;
 							int id = SHORT1FROMMP(mp1);
 							HWND conthwnd = dw_window_from_id(hWnd, id);
-
-							if(tmp->window == conthwnd || (!id && tmp->window == (HWND)mp2))
+							static int _recursing = 0;
+
+							if(_recursing == 0 && (tmp->window == conthwnd || (!id && tmp->window == (HWND)mp2)))
 							{
 								char buf1[500], classbuf[100];
 								unsigned int index = dw_listbox_selected(tmp->window);
@@ -1578,6 +1587,8 @@
 
 								WinQueryClassName(tmp->window, 99, classbuf);
 
+								_recursing = 1;
+
 								if(id && strncmp(classbuf, "#2", 3)==0)
 								{
 									char *buf2;
@@ -1596,6 +1607,7 @@
 								else
 									result = listboxselectfunc(tmp->window, index, tmp->data);
 
+								_recursing = 0;
 								tmp = NULL;
 							}
 						}
@@ -1734,7 +1746,11 @@
 				mybox->flags = DW_MINIMIZED;
 
 			if(mybox && (swp->fl & SWP_RESTORE))
+			{
+				if(!mybox->titlebar && mybox->hwndtitle)
+					WinSetParent(mybox->hwndtitle, HWND_OBJECT, FALSE);
 				mybox->flags = 0;
+			}
 
 			if(mybox && (swp->fl & SWP_MAXIMIZE))
 			{
@@ -2184,7 +2200,10 @@
 	{
 #ifndef NO_SIGNALS
 	case WM_SETFOCUS:
-		_wndproc(hwnd, msg, mp1, mp2);
+		if(mp2)
+			_run_event(hwnd, msg, mp1, mp2);
+		else
+			WinSendMsg(hwnd, BM_SETDEFAULT, 0, 0);
 		break;
 	case WM_BUTTON1UP:
 		{
@@ -2260,6 +2279,7 @@
 			if(SHORT1FROMMP(mp2) == '\t')
 			{
 				_shift_focus(hwnd);
+				WinSendMsg(hwnd, BM_SETDEFAULT, 0, 0);
 				return FALSE;
 			}
 		}
@@ -2615,6 +2635,19 @@
  */
 int dw_window_minimize(HWND handle)
 {
+	HWND hwndclient = WinWindowFromID(handle, FID_CLIENT);
+
+	if(hwndclient)
+	{
+		Box *box = (Box *)WinQueryWindowPtr(hwndclient, QWP_USER);
+
+		if(box)
+		{
+			if(!box->titlebar && box->hwndtitle)
+				WinSetParent(box->hwndtitle, handle, FALSE);
+		}
+	}
+
 	return WinSetWindowPos(handle, NULLHANDLE, 0, 0, 0, 0, SWP_MINIMIZE);
 }
 
@@ -2796,7 +2829,15 @@
 
 	flStyle |= FCF_NOBYTEALIGN;
 
+	if(flStyle & DW_FCF_TITLEBAR)
+		newbox->titlebar = 1;
+	else
+		flStyle |= FCF_TITLEBAR;
+
 	hwndframe = WinCreateStdWindow(hwndOwner, 0L, &flStyle, ClassName, title, 0L, NULLHANDLE, 0L, &hwndclient);
+	newbox->hwndtitle = WinWindowFromID(hwndframe, FID_TITLEBAR);
+	if(!newbox->titlebar && newbox->hwndtitle)
+		WinSetParent(newbox->hwndtitle, HWND_OBJECT, FALSE);
 	*blah = WinSubclassWindow(hwndframe, _sizeproc);
 	WinSetWindowPtr(hwndframe, QWP_USER, blah);
 	WinSetWindowPtr(hwndclient, QWP_USER, newbox);
--- a/win/dw.c	Wed Oct 17 19:22:39 2001 +0000
+++ b/win/dw.c	Fri Oct 19 14:16:50 2001 +0000
@@ -293,6 +293,9 @@
 	if(!handle)
 		return 0;
 
+	if(!IsWindowEnabled(handle))
+		return 0;
+
 	GetClassName(handle, tmpbuf, 99);
 
 	/* These are the window classes which can
@@ -320,6 +323,13 @@
 		if(cinfo && cinfo->buddy)
 			return cinfo->buddy;
 	}
+	if(strnicmp(tmpbuf, COMBOBOXCLASSNAME, strlen(COMBOBOXCLASSNAME))==0) /* Combobox */
+	{
+		ColorInfo *cinfo = (ColorInfo *)GetWindowLong(handle, GWL_USERDATA);
+
+		if(cinfo && cinfo->buddy)
+			return cinfo->buddy;
+	}
 	return handle;
 }
 
@@ -1516,7 +1526,9 @@
 		case WM_CHAR:
 			if(LOWORD(mp1) == '\t')
 			{
-				if(cinfo->buddy)
+				if(cinfo->combo)
+					_shift_focus(cinfo->combo);
+				else if(cinfo->buddy)
 					_shift_focus(cinfo->buddy);
 				else
 					_shift_focus(hWnd);
@@ -1525,7 +1537,7 @@
 			/* Tell the spinner control that a keypress has
 			 * occured and to update it's internal value.
 			 */
-			if(cinfo->buddy)
+			if(cinfo->buddy && !cinfo->combo)
 				SendMessage(cinfo->buddy, WM_USER+10, 0, 0);
 			break;
 		case WM_USER+10:
@@ -2532,7 +2544,7 @@
  */
 int dw_window_show(HWND handle)
 {
-    int rc = ShowWindow(handle, SW_SHOW);
+	int rc = ShowWindow(handle, SW_SHOW);
 	SetFocus(handle);
 	_initial_focus(handle);
 	return rc;
@@ -3277,6 +3289,19 @@
 	return tmp;
 }
 
+BOOL CALLBACK _subclass_child(HWND handle, LPARAM lp)
+{
+	ColorInfo *cinfo = (ColorInfo *)lp;
+
+	if(cinfo)
+	{
+		cinfo->buddy = handle;
+		cinfo->pOldProc = (WNDPROC)SubclassWindow(handle, _colorwndproc);
+		SetWindowLong(handle, GWL_USERDATA, (ULONG)cinfo);
+	}
+	return FALSE;
+}
+
 /*
  * Create a new Combobox window (widget) to be packed.
  * Parameters:
@@ -3293,7 +3318,7 @@
 							(HMENU)id,
 							NULL,
 							NULL);
-	ContainerInfo *cinfo = (ContainerInfo *)calloc(1, sizeof(ContainerInfo));
+	ColorInfo *cinfo = (ColorInfo *)calloc(1, sizeof(ColorInfo));
 
 	if(!cinfo)
 	{
@@ -3301,9 +3326,10 @@
 		return NULL;
 	}
 
-	cinfo->cinfo.fore = -1;
-	cinfo->cinfo.back = -1;
-	cinfo->pOldProc = (WNDPROC)SubclassWindow(tmp, _containerwndproc);
+	cinfo->fore = -1;
+	cinfo->back = -1;
+	cinfo->combo = tmp;
+	EnumChildWindows(tmp, _subclass_child, (LPARAM)cinfo);
 
 	SetWindowLong(tmp, GWL_USERDATA, (ULONG)cinfo);
 	dw_window_set_font(tmp, DefaultFont);
@@ -4278,7 +4304,7 @@
 	SetWindowText(handle, tmpbuf);
 
 	free(tmpbuf);
-	return startpoint+strlen(buffer);
+	return startpoint+strlen(buffer) - 1;
 }
 
 /*