changeset 62:2be5174bdb5d

Sync with latest DW code. Tab and RGB fixes.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 08 Dec 2001 04:47:43 +0000
parents 4a02842f8074
children a6801a2260af
files compat.c compat.h dw.h os2/dw.c
diffstat 4 files changed, 19 insertions(+), 113 deletions(-) [+]
line wrap: on
line diff
--- a/compat.c	Wed Dec 05 06:03:49 2001 +0000
+++ b/compat.c	Sat Dec 08 04:47:43 2001 +0000
@@ -210,7 +210,7 @@
 
 /* Return in K to avoid big problems exceeding an
    unsigned long when no 64bit integers are available */
-#if defined(__IBMC__) || (defined(__WIN32__) && !defined(__CYGWIN32__))
+#if (defined(__IBMC__) && __IBMC__ < 360) || (defined(__WIN32__) && !defined(__CYGWIN32__))
 unsigned long drivefree(int drive)
 #else
 unsigned long long drivefree(int drive)
@@ -233,7 +233,7 @@
 
 	kbytes = aulFSInfoBuf[3]/1024;
 
-	return (unsigned long)(kbytes * aulFSInfoBuf[1] * aulFSInfoBuf[4]);
+	return (kbytes * aulFSInfoBuf[1] * aulFSInfoBuf[4]);
 #elif defined(__WIN32__) || defined(WINNT)
 	char buffer[10] = "C:\\";
 	DWORD spc, bps, fc, tc;
@@ -246,7 +246,7 @@
 
 	kbytes = fc/1024;
 
-	return (unsigned long)(spc*bps*kbytes);
+	return (spc*bps*kbytes);
 #elif defined(__FreeBSD__)
 	struct statfs *fsp;
 	int entries, index = 1;
@@ -318,7 +318,7 @@
 
 /* Return in K to avoid big problems exceeding an
    unsigned long when no 64bit integers are available */
-#if defined(__IBMC__) || (defined(__WIN32__) && !defined(__CYGWIN32__))
+#if (defined(__IBMC__) && __IBMC__  < 360) || (defined(__WIN32__) && !defined(__CYGWIN32__))
 unsigned long drivesize(int drive)
 #else
 unsigned long long drivesize(int drive)
@@ -341,7 +341,7 @@
 
 	kbytes = aulFSInfoBuf[2]/1024;
 
-	return (unsigned long)(kbytes * aulFSInfoBuf[1] * aulFSInfoBuf[4]);
+	return (kbytes * aulFSInfoBuf[1] * aulFSInfoBuf[4]);
 #elif defined(__WIN32__) || defined(WINNT)
 	char buffer[10] = "C:\\";
 	DWORD spc, bps, fc, tc;
@@ -354,7 +354,7 @@
 
 	kbytes = tc/1024;
 
-	return (unsigned long)(spc*bps*kbytes);
+	return (spc*bps*kbytes);
 #elif defined(__FreeBSD__)
 	struct statfs *fsp;
 	int entries, index = 1;
--- a/compat.h	Wed Dec 05 06:03:49 2001 +0000
+++ b/compat.h	Sat Dec 08 04:47:43 2001 +0000
@@ -196,7 +196,7 @@
 void nonblock(int fd);
 void block(int fd);
 void setfileinfo(char *filename, char *url, char *logfile);
-#if defined(__IBMC__) || defined(__WIN32__)
+#if (defined(__IBMC__) && __IBMC__ < 360) || (defined(__WIN32__) && !defined(__CYGWIN32__))
 unsigned long drivesize(int drive);
 unsigned long drivefree(int drive);
 #else
--- a/dw.h	Wed Dec 05 06:03:49 2001 +0000
+++ b/dw.h	Sat Dec 08 04:47:43 2001 +0000
@@ -132,11 +132,6 @@
 	HWND menu;
 } *HMENUI;
 
-typedef struct _percentbar {
-	unsigned long pos;
-	PFNWP oldproc;
-} PercentBar;
-
 extern HAB dwhab;
 extern HMQ dwhmq;
 #endif
@@ -566,7 +561,7 @@
 #define DW_PIXMAP_WIDTH(x) (x ? x->width : 0)
 #define DW_PIXMAP_HEIGHT(x) (x ? x->height : 0)
 
-#define DW_RGB_COLOR (0xFF000000)
+#define DW_RGB_COLOR (0xF0000000)
 #define DW_RGB_MASK (0x00FFFFFF)
 #define DW_RED_MASK (0x000000FF)
 #define DW_GREEN_MASK (0x0000FF00)
@@ -574,7 +569,7 @@
 #define DW_RED_VALUE(a) (a & DW_RED_MASK)
 #define DW_GREEN_VALUE(a) ((a & DW_GREEN_MASK) >> 8)
 #define DW_BLUE_VALUE(a) ((a & DW_BLUE_MASK) >> 16)
-#define DW_RGB(a, b, c) (0xFF000000 | a | b << 8 | c << 16)
+#define DW_RGB(a, b, c) (0xF0000000 | a | b << 8 | c << 16)
 
 #if defined(__OS2__) || defined(__EMX__)
 #define DW_OS2_RGB(a) ((DW_RED_VALUE(a) << 16) | (DW_GREEN_VALUE(a) << 8) | DW_BLUE_VALUE(a))
--- a/os2/dw.c	Wed Dec 05 06:03:49 2001 +0000
+++ b/os2/dw.c	Sat Dec 08 04:47:43 2001 +0000
@@ -186,6 +186,8 @@
 
 		if(strncmp(tmpbuf, "#3", 3)==0 && dw)  /* Button */
 			WinSetOwner(child, dw);
+		if(strncmp(tmpbuf, "#38", 4)==0 && dw)  /* Slider */
+			WinSetOwner(child, 0);
 		else if(strncmp(tmpbuf, "dynamicwindows", 14) == 0)
 			dw = child;
 
@@ -1363,84 +1365,10 @@
 /* This procedure handles drawing of a percent bar */
 MRESULT EXPENTRY _percentproc(HWND hWnd, ULONG msg, MPARAM mp1, MPARAM mp2)
 {
-	PercentBar *blah = (PercentBar *)WinQueryWindowPtr(hWnd, QWP_USER);
+	WindowData *blah = (WindowData *)WinQueryWindowPtr(hWnd, QWP_USER);
 
 	if(blah)
-	{
-		PFNWP myfunc = blah->oldproc;
-
-		switch(msg)
-		{
-		case WM_PAINT:
-			{
-				HPS hpsPaint;
-				RECTL rclPaint, rclBar;
-
-				hpsPaint = WinBeginPaint(hWnd, 0, 0);
-				WinQueryWindowRect(hWnd, &rclPaint);
-
-				/* Draw outer border */
-				rclBar = rclPaint;
-				GpiSetColor(hpsPaint, CLR_PALEGRAY);
-				_Top(hpsPaint, rclBar);
-				_Bottom(hpsPaint, rclBar);
-				rclBar.yTop--;
-				GpiSetColor(hpsPaint, CLR_WHITE);
-				_Right(hpsPaint, rclBar);
-				rclBar.yBottom++;
-				GpiSetColor(hpsPaint, CLR_DARKGRAY);
-				_Left(hpsPaint, rclBar);
-
-				/* Draw inner border */
-				rclBar.xLeft++;
-				rclBar.xRight--;
-				GpiSetColor(hpsPaint, CLR_DARKGRAY);
-				_Left(hpsPaint, rclBar);
-				_Top(hpsPaint, rclBar);
-				GpiSetColor(hpsPaint, CLR_WHITE);
-				_Bottom(hpsPaint, rclBar);
-				_Right(hpsPaint, rclBar);
-
-				/* Draw bar border */
-				rclBar.xLeft++;
-				rclBar.xRight--;
-				rclBar.yBottom++;
-				rclBar.yTop--;
-				GpiSetColor(hpsPaint, CLR_DARKGRAY);
-				_Left(hpsPaint, rclBar);
-				_Top(hpsPaint, rclBar);
-				_Bottom(hpsPaint, rclBar);
-				_Right(hpsPaint, rclBar);
-
-				if(blah->pos)
-				{
-					rclBar.xRight = 3 + blah->pos;
-					_Right(hpsPaint, rclBar);
-
-					/* Draw Bar itself */
-					rclBar.xLeft = rclPaint.xLeft + 3;
-					rclBar.xRight = rclPaint.xLeft +  2 + blah->pos;
-					rclBar.yTop = rclPaint.yTop - 3;
-					rclBar.yBottom = rclPaint.yBottom + 3;
-
-					WinFillRect(hpsPaint, &rclBar, CLR_DARKBLUE);
-				}
-
-				/* Draw the background */
-				rclBar.xLeft = rclPaint.xLeft + 3 + blah->pos;
-				rclBar.xRight = rclPaint.xRight - 3;
-				rclBar.yTop = rclPaint.yTop - 3;
-				rclBar.yBottom = rclPaint.yBottom + 3;
-
-				WinFillRect(hpsPaint, &rclBar, CLR_PALEGRAY);
-
-				WinEndPaint(hpsPaint);
-
-				return (MRESULT)TRUE;
-			}
-		}
-		return myfunc(hWnd, msg, mp1, mp2);
-	}
+		return blah->oldproc(hWnd, msg, mp1, mp2);
 
 	return WinDefWindowProc(hWnd, msg, mp1, mp2);
 }
@@ -4030,22 +3958,20 @@
  */
 HWND dw_percent_new(ULONG id)
 {
-	PercentBar *blah = malloc(sizeof(PercentBar));
+	WindowData *blah = calloc(1, sizeof(WindowData));
 	HWND tmp = WinCreateWindow(HWND_OBJECT,
-							   WC_STATIC,
+							   WC_SLIDER,
 							   "",
-							   WS_VISIBLE | SS_TEXT,
+							   WS_VISIBLE | SLS_READONLY
+							   | SLS_RIBBONSTRIP,
 							   0,0,2000,1000,
 							   NULLHANDLE,
 							   HWND_TOP,
 							   id,
 							   NULL,
 							   NULL);
-	dw_window_set_font(tmp, DefaultFont);
-	dw_window_set_color(tmp, DW_CLR_BLUE, DW_CLR_PALEGRAY);
 
 	blah->oldproc = WinSubclassWindow(tmp, _percentproc);
-	blah->pos = 0;
 	WinSetWindowPtr(tmp, QWP_USER, blah);
 	return tmp;
 }
@@ -4900,13 +4826,7 @@
  */
 unsigned int dw_percent_query_range(HWND handle)
 {
-	unsigned long width;
-
-	dw_window_get_pos_size(handle, 0, 0, &width, 0);
-
-	if(width - 6 < 1)
-		return 1;
-	return width - 6;
+	return SHORT2FROMMP(WinSendMsg(handle, SLM_QUERYSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), 0));
 }
 
 /*
@@ -4917,16 +4837,7 @@
  */
 void dw_percent_set_pos(HWND handle, unsigned int position)
 {
-	PercentBar *pb = (PercentBar *)WinQueryWindowPtr(handle, 0);
-
-	if(pb)
-	{
-		RECTL rcl;
-
-		pb->pos = position;
-		WinQueryWindowRect(handle, &rcl);
-		WinInvalidateRect(handle, &rcl, FALSE);
-	}
+	WinSendMsg(handle, SLM_SETSLIDERINFO, MPFROM2SHORT(SMA_SLIDERARMPOSITION,SMA_RANGEVALUE), (MPARAM)position);
 }
 
 /*