changeset 124:edf615d8266e

Use float instead of int for percent on Windows. And a minor safety check on OS/2.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 20 Oct 2002 01:41:04 +0000
parents 63f61a702b17
children 0d2cbd9d4028
files os2/dw.c win/dw.c
diffstat 2 files changed, 20 insertions(+), 65 deletions(-) [+]
line wrap: on
line diff
--- a/os2/dw.c	Sun Oct 20 01:32:08 2002 +0000
+++ b/os2/dw.c	Sun Oct 20 01:41:04 2002 +0000
@@ -2319,7 +2319,7 @@
 		{
 			int x = SHORT1FROMMP(mp2), y = SHORT2FROMMP(mp2);
 
-			if(x > 0 && y > 0)
+			if(x > 0 && y > 0 && percent)
 			{
 				if(type == BOXHORZ)
 				{
--- a/win/dw.c	Sun Oct 20 01:32:08 2002 +0000
+++ b/win/dw.c	Sun Oct 20 01:41:04 2002 +0000
@@ -2303,7 +2303,7 @@
 /* This handles any activity on the splitbars (sizers) */
 BOOL CALLBACK _splitwndproc(HWND hwnd, UINT msg, WPARAM mp1, LPARAM mp2)
 {
-	int percent = (int)dw_window_get_data(hwnd, "_dw_percent");
+	float *percent = (float *)dw_window_get_data(hwnd, "_dw_percent");
 	int type = (int)dw_window_get_data(hwnd, "_dw_type");
 
 	switch (msg)
@@ -2316,12 +2316,12 @@
 		{
 			int x = LOWORD(mp2), y = HIWORD(mp2);
 
-			if(x > 0 && y > 0)
+			if(x > 0 && y > 0 && percent)
 			{
 				if(type == BOXHORZ)
 				{
 					int newx = x - SPLITBAR_WIDTH, newy = y;
-					float ratio = (float)percent/(float)100;
+					float ratio = (float)*percent/(float)100.0;
 					HWND handle = (HWND)dw_window_get_data(hwnd, "_dw_topleft");
 					Box *tmp = (Box *)GetWindowLong(handle, GWL_USERDATA);
 
@@ -2343,7 +2343,7 @@
                 else
 				{
 					int newx = x, newy = y - SPLITBAR_WIDTH;
-					float ratio = (float)(100-percent)/(float)100;
+					float ratio = (float)(100.0-*percent)/(float)100.0;
 					HWND handle = (HWND)dw_window_get_data(hwnd, "_dw_bottomright");
 					Box *tmp = (Box *)GetWindowLong(handle, GWL_USERDATA);
 
@@ -6785,6 +6785,7 @@
 	if(tmp)
 	{
 		HWND tmpbox = dw_box_new(BOXVERT, 0);
+        float *percent = (float *)malloc(sizeof(float));
 
 		dw_box_pack_start(tmpbox, topleft, 1, 1, TRUE, TRUE, 0);
 		SetParent(tmpbox, tmp);
@@ -6794,7 +6795,8 @@
 		dw_box_pack_start(tmpbox, bottomright, 1, 1, TRUE, TRUE, 0);
 		SetParent(tmpbox, tmp);
 		dw_window_set_data(tmp, "_dw_bottomright", (void *)tmpbox);
-		dw_window_set_data(tmp, "_dw_percent", (void *)50);
+		*percent = 50.0;
+		dw_window_set_data(tmp, "_dw_percent", (void *)percent);
 		dw_window_set_data(tmp, "_dw_type", (void *)type);
 	}
 	return tmp;
@@ -6805,10 +6807,13 @@
  * Parameters:
  *       handle: The handle to the splitbar returned by dw_splitbar_new().
  */
-void dw_splitbar_set(HWND handle, int percent)
+void dw_splitbar_set(HWND handle, float percent)
 {
 	/* We probably need to force a redraw here */
-	dw_window_set_data(handle, "_dw_percent", (void *)percent);
+	float *mypercent = (float *)dw_window_get_data(handle, "_dw_percent");
+
+	if(mypercent)
+		*mypercent = percent;
 }
 
 /*
@@ -6816,63 +6821,13 @@
  * Parameters:
  *       handle: The handle to the splitbar returned by dw_splitbar_new().
  */
-int dw_splitbar_get(HWND handle)
-{
-	return (int)dw_window_get_data(handle, "_dw_percent");
-}
-
-/*
- * Pack a splitbar (sizer) into the specified box from the start.
- * Parameters:
- *       box: Window handle of the box to be packed into.
- */
-void dw_box_pack_splitbar_start(HWND box)
-{
-	Box *thisbox = (Box *)GetWindowLong(box, GWL_USERDATA);
-
-	if(thisbox)
-	{
-		HWND tmp = CreateWindow(SplitbarClassName,
-								"",
-								WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
-								0,0,2000,1000,
-								DW_HWND_OBJECT,
-								NULL,
-								DWInstance,
-								NULL);
-		if(thisbox->type == BOXVERT)
-			dw_box_pack_start(box, tmp, 1, SPLITBAR_WIDTH, TRUE, FALSE, 0);
-		else
-			dw_box_pack_start(box, tmp, SPLITBAR_WIDTH, 1, FALSE, TRUE, 0);
-
-	}
-}
-
-/*
- * Pack a splitbar (sizer) into the specified box from the end.
- * Parameters:
- *       box: Window handle of the box to be packed into.
- */
-void dw_box_pack_splitbar_end(HWND box)
-{
-	Box *thisbox = (Box *)GetWindowLong(box, GWL_USERDATA);
-
-	if(thisbox)
-	{
-		HWND tmp = CreateWindow(SplitbarClassName,
-								"",
-								WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN,
-								0,0,2000,1000,
-								DW_HWND_OBJECT,
-								NULL,
-								DWInstance,
-								NULL);
-		if(thisbox->type == BOXVERT)
-			dw_box_pack_end(box, tmp, 1, SPLITBAR_WIDTH, TRUE, FALSE, 0);
-		else
-			dw_box_pack_end(box, tmp, SPLITBAR_WIDTH, 1, FALSE, TRUE, 0);
-
-	}
+float dw_splitbar_get(HWND handle)
+{
+	float *percent = (float *)dw_window_get_data(handle, "_dw_percent");
+
+	if(percent)
+		return *percent;
+	return 0.0;
 }
 
 /*