diff os2/dw.c @ 69:9510897c0b03

Added new container functions, and implemented some missing functionality.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 04 Feb 2002 16:04:43 +0000
parents 8d6100960adf
children 5e7a4d93d8d7
line wrap: on
line diff
--- a/os2/dw.c	Tue Jan 22 23:45:01 2002 +0000
+++ b/os2/dw.c	Mon Feb 04 16:04:43 2002 +0000
@@ -5473,7 +5473,9 @@
 
 	temp = (PRECORDCORE)ci->data;
 
-	WinSendMsg(handle, CM_QUERYCNRINFO, (MPARAM)&cnr, MPFROMSHORT(sizeof(CNRINFO)));
+	if(!WinSendMsg(handle, CM_QUERYCNRINFO, (MPARAM)&cnr, MPFROMSHORT(sizeof(CNRINFO))))
+		return;
+
 	currentcount = cnr.cRecords;
 
 	/* Figure out the offsets to the items in the struct */
@@ -5612,6 +5614,8 @@
 			break;
 		DosSleep(1);
 	}
+
+	free(ci);
 }
 
 /*
@@ -5719,7 +5723,7 @@
 		{
 			while(pCore)
 			{
-				if(pCore->flRecordAttr & CRA_SELECTED)
+				if(pCore->flRecordAttr & flags)
 					return pCore->pszIcon;
 				pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
 			}
@@ -5747,7 +5751,7 @@
 		{
 			while(pCore)
 			{
-				if(pCore->flRecordAttr & CRA_SELECTED)
+				if(pCore->flRecordAttr & flags)
 					return pCore->pszIcon;
 
 				pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
@@ -5760,6 +5764,53 @@
 }
 
 /*
+ * Cursors the item with the text speficied, and scrolls to that item.
+ * Parameters:
+ *       handle: Handle to the window (widget) to be queried.
+ *       text:  Text usually returned by dw_container_query().
+ */
+void dw_container_cursor(HWND handle, char *text)
+{
+	RECTL viewport, item;
+
+	pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)0L, MPFROM2SHORT(CMA_FIRST, CMA_ITEMORDER));
+	while(pCore)
+	{
+		if(pCore->pszIcon == text)
+		{
+			QUERYRECORDRECT qrr;
+			int scrollpixels = 0, midway;
+
+			qrr.cb = sizeof(QUERYRECORDRECT);
+			qrr.pRecord = pCore;
+			qrr.fRightSplitWindow = 0;
+			qrr.fsExtent = CMA_TEXT;
+
+			WinSendMsg(handle, CM_SETRECORDEMPHASIS, (MPARAM)pCore, MPFROM2SHORT(TRUE, CRA_CURSORED));
+			WinSendMsg(handle, CM_QUERYVIEWPORTRECT, (MPARAM)&viewport, MPFROM2SHORT(CMA_WORKSPACE, FALSE));
+			WinSendMsg(handle, CM_QUERYRECORDRECT, (MPARAM)&item, (MPARAM)&qrr);
+
+			midway = (viewport.yTop - viewport.yBottom)/2;
+			scrollpixels = viewport.yTop - (item.yTop + midway);
+
+			WinSendMsg(handle, CM_SCROLLWINDOW, MPFROMSHORT(CMA_VERTICAL),  MPFROMLONG(scrollpixels));
+			return;
+		}
+
+		pCore = WinSendMsg(handle, CM_QUERYRECORD, (MPARAM)pCore, MPFROM2SHORT(CMA_NEXT, CMA_ITEMORDER));
+	}
+}
+
+/*
+ * Optimizes the column widths so that all data is visible.
+ * Parameters:
+ *       handle: Handle to the window (widget) to be optimized.
+ */
+void dw_container_optimize(HWND handle)
+{
+}
+
+/*
  * Creates a rendering context widget (window) to be packed.
  * Parameters:
  *       id: An id to be used with dw_window_from_id.