Release 0.4.0

Mon Sep 13 05:00:11 1993  Eric Youngdale

	* [Makefile] [if1632/relay.c] [include/dlls.h] [selector.c]
	  [loader/wine.c] [tools/build.c]
	Added ability to generate missing functions statistics.

Mon Sep 13 12:09:47 1993  Scott A. Laird  (scott@curly)

	* [WIN31-APPLETS]
	Added new file.

	* [if1632/kernel.spec]
	Added definitions for GetProfile{Int,String} and SetHandleCount.

	* [if1632/keyboard.spec]
	Created interface specification for Keyboard driver DLL.

	* [if1632/relay.c]
	Added keyboard.dll to list of included DLLs.

	* [if1632/user.spec]
	Added LoadAccelerators definition.

	* [loader/resource.c]
	Added LoadAccelerators stub.

	* [misc/file.c]
	Changed OpenFile, and added SetHandleCount (for winfile.exe)

	* [misc/keyboard.c]
	Added keyboard code.

	* [misc/profile.c] [misc/xt.c]
	Moved GetPrivateProfile* commands here, and added GetProfile*
	commands.

Mon Sep 13 10:24:37 1993  Andrew Bulhak

	* [windows/utility.c]
	Implemented MulDiv(), OutputDebugString() and wvsprintf()

Fri Sep 10 09:13:30 1993  John Brezak

	* [*/Makefile]
	Created patch to allow BSD make to build wine.

	* [windows/win.c]
	Fixed NULL pointer reference.

	* [windows/message.c] [misc/xt.c]
	Defined HZ to handle system specific timing.

	* [windows/graphics.c]
	Use M_PI is PI

	* [objects/pallete.c]
	NetBSD does not have /usr/include/values.h and MAXINT is INT_MAX.

	* [dump.c] [ldt.c] [wine.c]
	ifdef'ed linux headers for linux compile.

	* [loader/ldtlib.c]
	Add NetBSD system calls when compiled on that system.

	* [loader/selector.c]
	Use mmap(MAP_ANON, ...) for NetBSD.

	* [if1632/call.S]
	Fixed selector assumptions.

Thu Sep 9 20:01:37 1993  David Metcalfe

	* [controls/WinButton*] [controls/button.c] [controls/widget.c]
  	  [windows/win.c] [windows/class.c]
	Added 3D button control and tied into CreateWindow()

Thu Sep  9 07:35:24 1993  Scott Laird

	* [if1632/sound.spec]
	Created interface specification for SOUND DLL.

	* [if1632/win87em.spec]
	Added more functions to the WIN87EM DLL interface specification

	* [misc/emulate.c]
	Created stubs for the new math emulation functions.

	* [misc/sound.c]
	Created stubs for the SOUND DLL.

Sun Sep  5 21:02:10 1993  John Burton

	* [if1632/kernel.spec]
	Added interface specifications for OpenFile, _lclose, _lread, _lopen,
	and _lwrite.

	* [include/windows.h]
	Added OF_ macros

	* [misc/file.c]
	Implemented OpenFile, _lclose, _lread, _lopen and _lwrite.

Fri Sep  3 18:47:03 1993  Alexandre Julliard

        * [windows/dc.c]
	Bug fix

	* [objects/text.c]
	Bug fix

Fri Sep  3 18:47:03 1993  Bob Amstadt

        * [objects/linedda.c]
        Finished LineDDA().
diff --git a/controls/Makefile b/controls/Makefile
index 4c7b67a..dc3c187 100644
--- a/controls/Makefile
+++ b/controls/Makefile
@@ -1,7 +1,7 @@
 CFLAGS=$(COPTS) $(DEBUGOPTS) -I$(INCLUDE_DIR)
 
-OBJS=menu.o widgets.o SmeMenuButto.o WinLabel.o WinCommand.o WinMenuButto.o
-#     WinButton.o
+OBJS=menu.o widgets.o button.o SmeMenuButto.o WinLabel.o WinCommand.o \
+     WinMenuButto.o WinButton.o
 
 default: controls.o
 
diff --git a/controls/WinButton.c b/controls/WinButton.c
new file mode 100644
index 0000000..59773ce
--- /dev/null
+++ b/controls/WinButton.c
@@ -0,0 +1,605 @@
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
+
+                        All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its 
+documentation for any purpose and without fee is hereby granted, 
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in 
+supporting documentation, and that the names of Digital or MIT not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.  
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+ * Modifications for Wine
+ *
+ * 8/28/93  David Metcalfe (david@prism.demon.co.uk)
+ *          Created from Command widget and added 3D effect
+ */
+
+/*
+ * WinButton.c - WinButton button widget
+ */
+
+#include <stdio.h>
+#include <X11/IntrinsicP.h>
+#include <X11/StringDefs.h>
+#include <X11/Xmu/Misc.h>
+#include <X11/Xaw/XawInit.h>
+#include "WinButtonP.h"
+#include <X11/Xmu/Converters.h>
+
+#define DEFAULT_HIGHLIGHT_THICKNESS 0
+#define DEFAULT_SHAPE_HIGHLIGHT 32767
+
+/****************************************************************
+ *
+ * Full class record constant
+ *
+ ****************************************************************/
+
+/* Private Data */
+
+static char defaultTranslations[] =
+    "<EnterWindow>:	highlight()		\n\
+     <LeaveWindow>:	reset()			\n\
+     <Btn1Down>:	set()			\n\
+     <Btn1Up>:		notify() unset()	";
+
+#define offset(field) XtOffsetOf(WinButtonRec, field)
+static XtResource resources[] = { 
+   {XtNcallback, XtCCallback, XtRCallback, sizeof(XtPointer), 
+      offset(winbutton.callbacks), XtRCallback, (XtPointer)NULL},
+   {XtNhighlightThickness, XtCThickness, XtRDimension, sizeof(Dimension),
+      offset(winbutton.highlight_thickness), XtRImmediate,
+      (XtPointer) DEFAULT_SHAPE_HIGHLIGHT},
+   {XtNshapeStyle, XtCShapeStyle, XtRShapeStyle, sizeof(int),
+      offset(winbutton.shape_style), XtRImmediate, 
+	    (XtPointer)XawShapeRectangle},
+   {XtNcornerRoundPercent, XtCCornerRoundPercent, 
+	XtRDimension, sizeof(Dimension),
+	offset(winbutton.corner_round), XtRImmediate, (XtPointer) 25},
+   {XtNshadowThickness, XtCShadowThickness, XtRDimension, sizeof(Dimension),
+	offset(winbutton.shadow_thickness), XtRImmediate, (XtPointer) 2},
+   {XtNshadowHighlight, XtCShadowHighlight, XtRPixel, sizeof(Pixel),
+        offset(winbutton.shadow_highlight), XtRString, (XtPointer) "white"},
+   {XtNshadowShade, XtCShadowShade, XtRPixel, sizeof(Pixel),
+	offset(winbutton.shadow_shade), XtRString, (XtPointer) "grey25"},
+};
+#undef offset
+
+static Boolean SetValues();
+static void Initialize(), Redisplay(), Set(), Reset(), Notify(), Unset();
+static void Highlight(), Unhighlight(), Destroy(), PaintWinButtonWidget();
+static void ClassInitialize();
+static Boolean ShapeButton();
+static void Realize(), Resize();
+
+static XtActionsRec actionsList[] = {
+  {"set",		Set},
+  {"notify",		Notify},
+  {"highlight",		Highlight},
+  {"reset",		Reset},
+  {"unset",		Unset},
+  {"unhighlight",	Unhighlight}
+};
+
+#define SuperClass ((WinLabelWidgetClass)&winLabelClassRec)
+
+WinButtonClassRec winButtonClassRec = {
+  {
+    (WidgetClass) SuperClass,		/* superclass		  */	
+    "WinButton",			/* class_name		  */
+    sizeof(WinButtonRec),		/* size			  */
+    ClassInitialize,			/* class_initialize	  */
+    NULL,				/* class_part_initialize  */
+    FALSE,				/* class_inited		  */
+    Initialize,				/* initialize		  */
+    NULL,				/* initialize_hook	  */
+    Realize,				/* realize		  */
+    actionsList,			/* actions		  */
+    XtNumber(actionsList),		/* num_actions		  */
+    resources,				/* resources		  */
+    XtNumber(resources),		/* resource_count	  */
+    NULLQUARK,				/* xrm_class		  */
+    FALSE,				/* compress_motion	  */
+    TRUE,				/* compress_exposure	  */
+    TRUE,				/* compress_enterleave    */
+    FALSE,				/* visible_interest	  */
+    Destroy,				/* destroy		  */
+    Resize,				/* resize		  */
+    Redisplay,				/* expose		  */
+    SetValues,				/* set_values		  */
+    NULL,				/* set_values_hook	  */
+    XtInheritSetValuesAlmost,		/* set_values_almost	  */
+    NULL,				/* get_values_hook	  */
+    NULL,				/* accept_focus		  */
+    XtVersion,				/* version		  */
+    NULL,				/* callback_private	  */
+    defaultTranslations,		/* tm_table		  */
+    XtInheritQueryGeometry,		/* query_geometry	  */
+    XtInheritDisplayAccelerator,	/* display_accelerator	  */
+    NULL				/* extension		  */
+  },  /* CoreClass fields initialization */
+  {
+    XtInheritChangeSensitive		/* change_sensitive	*/
+  },  /* SimpleClass fields initialization */
+  {
+    0,                                     /* field not used    */
+  },  /* WinLabelClass fields initialization */
+  {
+    0,                                     /* field not used    */
+  },  /* WinButtonClass fields initialization */
+};
+
+  /* for public consumption */
+WidgetClass winButtonWidgetClass = (WidgetClass) &winButtonClassRec;
+
+/****************************************************************
+ *
+ * Private Procedures
+ *
+ ****************************************************************/
+
+static GC 
+Get_GC(cbw, fg, bg)
+WinButtonWidget cbw;
+Pixel fg, bg;
+{
+  XGCValues	values;
+  
+  values.foreground   = fg;
+  values.background	= bg;
+  values.font		= cbw->winlabel.font->fid;
+  values.cap_style = CapProjecting;
+  
+  if (cbw->winbutton.highlight_thickness > 1 )
+    values.line_width   = cbw->winbutton.highlight_thickness;
+  else 
+    values.line_width   = 0;
+  
+  return XtGetGC((Widget)cbw,
+		 (GCForeground|GCBackground|GCFont|GCLineWidth|GCCapStyle),
+		 &values);
+}
+
+static void 
+Get_Shadow_GCs(cbw)
+WinButtonWidget cbw;
+{
+  XGCValues	values;
+  
+  values.foreground     = cbw->winbutton.shadow_highlight;
+  values.line_width	= cbw->winbutton.shadow_thickness;
+  values.cap_style      = CapProjecting;
+  cbw->winbutton.shadow_highlight_gc =
+	  XtGetGC((Widget)cbw, (GCForeground|GCLineWidth|GCCapStyle), &values);
+
+  values.foreground     = cbw->winbutton.shadow_shade;
+  values.line_width	= cbw->winbutton.shadow_thickness;
+  values.cap_style      = CapProjecting;
+  cbw->winbutton.shadow_shade_gc =
+	  XtGetGC((Widget)cbw, (GCForeground|GCLineWidth|GCCapStyle), &values);
+}
+
+
+/* ARGSUSED */
+static void 
+Initialize(request, new, args, num_args)
+Widget request, new;
+ArgList args;			/* unused */
+Cardinal *num_args;		/* unused */
+{
+  WinButtonWidget cbw = (WinButtonWidget) new;
+  int shape_event_base, shape_error_base;
+
+  if (cbw->winbutton.shape_style != XawShapeRectangle
+      && !XShapeQueryExtension(XtDisplay(new), &shape_event_base, 
+			       &shape_error_base))
+      cbw->winbutton.shape_style = XawShapeRectangle;
+  if (cbw->winbutton.highlight_thickness == DEFAULT_SHAPE_HIGHLIGHT) {
+      if (cbw->winbutton.shape_style != XawShapeRectangle)
+	  cbw->winbutton.highlight_thickness = 0;
+      else
+	  cbw->winbutton.highlight_thickness = DEFAULT_HIGHLIGHT_THICKNESS;
+  }
+
+  XtVaSetValues(new, XtNbackground, "grey75");
+  cbw->winbutton.normal_GC = Get_GC(cbw, cbw->winlabel.foreground, 
+				  cbw->core.background_pixel);
+  cbw->winbutton.inverse_GC = Get_GC(cbw, cbw->core.background_pixel, 
+				   cbw->winlabel.foreground);
+  XtReleaseGC(new, cbw->winlabel.normal_GC);
+  cbw->winlabel.normal_GC = cbw->winbutton.normal_GC;
+
+  Get_Shadow_GCs(cbw);
+
+  cbw->winbutton.set = FALSE;
+  cbw->winbutton.highlighted = HighlightNone;
+}
+
+static Region 
+HighlightRegion(cbw)
+WinButtonWidget cbw;
+{
+  static Region outerRegion = NULL, innerRegion, emptyRegion;
+  XRectangle rect;
+
+  if (cbw->winbutton.highlight_thickness == 0 ||
+      cbw->winbutton.highlight_thickness >
+      (Dimension) ((Dimension) Min(cbw->core.width, cbw->core.height)/2))
+    return(NULL);
+
+  if (outerRegion == NULL) {
+    /* save time by allocating scratch regions only once. */
+    outerRegion = XCreateRegion();
+    innerRegion = XCreateRegion();
+    emptyRegion = XCreateRegion();
+  }
+
+  rect.x = rect.y = 0;
+  rect.width = cbw->core.width;
+  rect.height = cbw->core.height;
+  XUnionRectWithRegion( &rect, emptyRegion, outerRegion );
+  rect.x = rect.y = cbw->winbutton.highlight_thickness;
+  rect.width -= cbw->winbutton.highlight_thickness * 2;
+  rect.height -= cbw->winbutton.highlight_thickness * 2;
+  XUnionRectWithRegion( &rect, emptyRegion, innerRegion );
+  XSubtractRegion( outerRegion, innerRegion, outerRegion );
+  return outerRegion;
+}
+
+/***************************
+*
+*  Action Procedures
+*
+***************************/
+
+/* ARGSUSED */
+static void 
+Set(w,event,params,num_params)
+Widget w;
+XEvent *event;
+String *params;		/* unused */
+Cardinal *num_params;	/* unused */
+{
+  WinButtonWidget cbw = (WinButtonWidget)w;
+
+  if (cbw->winbutton.set)
+    return;
+
+  cbw->winbutton.set= TRUE;
+  if (XtIsRealized(w))
+    PaintWinButtonWidget(w, (Region) NULL, TRUE);
+}
+
+/* ARGSUSED */
+static void
+Unset(w,event,params,num_params)
+Widget w;
+XEvent *event;
+String *params;		/* unused */
+Cardinal *num_params;
+{
+  WinButtonWidget cbw = (WinButtonWidget)w;
+
+  if (!cbw->winbutton.set)
+    return;
+
+  cbw->winbutton.set = FALSE;
+  if (XtIsRealized(w)) {
+    XClearWindow(XtDisplay(w), XtWindow(w));
+    PaintWinButtonWidget(w, (Region) NULL, TRUE);
+  }
+}
+
+/* ARGSUSED */
+static void 
+Reset(w,event,params,num_params)
+Widget w;
+XEvent *event;
+String *params;		/* unused */
+Cardinal *num_params;   /* unused */
+{
+  WinButtonWidget cbw = (WinButtonWidget)w;
+
+  if (cbw->winbutton.set) {
+    cbw->winbutton.highlighted = HighlightNone;
+    Unset(w, event, params, num_params);
+  }
+  else
+    Unhighlight(w, event, params, num_params);
+}
+
+/* ARGSUSED */
+static void 
+Highlight(w,event,params,num_params)
+Widget w;
+XEvent *event;
+String *params;		
+Cardinal *num_params;	
+{
+  WinButtonWidget cbw = (WinButtonWidget)w;
+
+  if ( *num_params == (Cardinal) 0) 
+    cbw->winbutton.highlighted = HighlightWhenUnset;
+  else {
+    if ( *num_params != (Cardinal) 1) 
+      XtWarning("Too many parameters passed to highlight action table.");
+    switch (params[0][0]) {
+    case 'A':
+    case 'a':
+      cbw->winbutton.highlighted = HighlightAlways;
+      break;
+    default:
+      cbw->winbutton.highlighted = HighlightWhenUnset;
+      break;
+    }
+  }
+
+  if (XtIsRealized(w))
+    PaintWinButtonWidget(w, HighlightRegion(cbw), TRUE);
+}
+
+/* ARGSUSED */
+static void 
+Unhighlight(w,event,params,num_params)
+Widget w;
+XEvent *event;
+String *params;		/* unused */
+Cardinal *num_params;	/* unused */
+{
+  WinButtonWidget cbw = (WinButtonWidget)w;
+
+  cbw->winbutton.highlighted = HighlightNone;
+  if (XtIsRealized(w))
+    PaintWinButtonWidget(w, HighlightRegion(cbw), TRUE);
+}
+
+/* ARGSUSED */
+static void 
+Notify(w,event,params,num_params)
+Widget w;
+XEvent *event;
+String *params;		/* unused */
+Cardinal *num_params;	/* unused */
+{
+  WinButtonWidget cbw = (WinButtonWidget)w; 
+
+  /* check to be sure state is still Set so that user can cancel
+     the action (e.g. by moving outside the window, in the default
+     bindings.
+  */
+  if (cbw->winbutton.set)
+    XtCallCallbackList(w, cbw->winbutton.callbacks, NULL);
+}
+
+/*
+ * Repaint the widget window
+ */
+
+/************************
+*
+*  REDISPLAY (DRAW)
+*
+************************/
+
+/* ARGSUSED */
+static void 
+Redisplay(w, event, region)
+Widget w;
+XEvent *event;
+Region region;
+{
+  PaintWinButtonWidget(w, region, FALSE);
+}
+
+/*	Function Name: PaintWinButtonWidget
+ *	Description: Paints the winbutton widget.
+ *	Arguments: w - the winbutton widget.
+ *                 region - region to paint (passed to the superclass).
+ *                 change - did it change either set or highlight state?
+ *	Returns: none
+ */
+
+static void 
+PaintWinButtonWidget(w, region, change)
+Widget w;
+Region region;
+Boolean change;
+{
+  WinButtonWidget cbw = (WinButtonWidget) w;
+  Boolean very_thick;
+  GC norm_gc, rev_gc;
+  int offset;
+   
+  very_thick = cbw->winbutton.highlight_thickness >
+               (Dimension)((Dimension) Min(cbw->core.width, 
+					   cbw->core.height)/2);
+
+  offset = cbw->winbutton.shadow_thickness / 2;
+  if (cbw->winbutton.set) {
+      XClearWindow(XtDisplay(w), XtWindow(w));
+      region = NULL;		/* Force label to repaint text. */
+  }
+  else {
+      XDrawLine(XtDisplay(w), XtWindow(w), cbw->winbutton.shadow_highlight_gc,
+		offset, offset, cbw->core.width - offset, offset);
+      XDrawLine(XtDisplay(w), XtWindow(w), cbw->winbutton.shadow_highlight_gc,
+		offset, offset, offset, cbw->core.height - offset);
+      XDrawLine(XtDisplay(w), XtWindow(w), cbw->winbutton.shadow_shade_gc,
+		offset, cbw->core.height - offset + 1, 
+		cbw->core.width - offset, cbw->core.height - offset);
+      XDrawLine(XtDisplay(w), XtWindow(w), cbw->winbutton.shadow_shade_gc,
+		cbw->core.width - offset, offset + 1, 
+		cbw->core.width - offset, cbw->core.height - offset);
+  }
+
+  if (cbw->winbutton.highlight_thickness <= 0)
+  {
+    (*SuperClass->core_class.expose) (w, (XEvent *) NULL, region);
+    return;
+  }
+
+/*
+ * If we are set then use the same colors as if we are not highlighted. 
+ */
+
+  if (cbw->winbutton.set == (cbw->winbutton.highlighted == HighlightNone)) {
+    norm_gc = cbw->winbutton.inverse_GC;
+    rev_gc = cbw->winbutton.normal_GC;
+  }
+  else {
+    norm_gc = cbw->winbutton.normal_GC;
+    rev_gc = cbw->winbutton.inverse_GC;
+  }
+
+  if ( !( (!change && (cbw->winbutton.highlighted == HighlightNone)) ||
+	  ((cbw->winbutton.highlighted == HighlightWhenUnset) &&
+	   (cbw->winbutton.set))) ) {
+    if (very_thick) {
+      cbw->winlabel.normal_GC = norm_gc; /* Give the label the right GC. */
+      XFillRectangle(XtDisplay(w),XtWindow(w), rev_gc,
+		     0, 0, cbw->core.width, cbw->core.height);
+    }
+    else {
+      /* wide lines are centered on the path, so indent it */
+      int offset = cbw->winbutton.highlight_thickness/2;
+      XDrawRectangle(XtDisplay(w),XtWindow(w), rev_gc, offset, offset, 
+		     cbw->core.width - cbw->winbutton.highlight_thickness,
+		     cbw->core.height - cbw->winbutton.highlight_thickness);
+    }
+  }
+  (*SuperClass->core_class.expose) (w, (XEvent *) NULL, region);
+}
+
+static void 
+Destroy(w)
+Widget w;
+{
+  WinButtonWidget cbw = (WinButtonWidget) w;
+
+  /* so WinLabel can release it */
+  if (cbw->winlabel.normal_GC == cbw->winbutton.normal_GC)
+    XtReleaseGC( w, cbw->winbutton.inverse_GC );
+  else
+    XtReleaseGC( w, cbw->winbutton.normal_GC );
+}
+
+/*
+ * Set specified arguments into widget
+ */
+
+/* ARGSUSED */
+static Boolean 
+SetValues (current, request, new)
+Widget current, request, new;
+{
+  WinButtonWidget oldcbw = (WinButtonWidget) current;
+  WinButtonWidget cbw = (WinButtonWidget) new;
+  Boolean redisplay = False;
+
+  if ( oldcbw->core.sensitive != cbw->core.sensitive && !cbw->core.sensitive) {
+    /* about to become insensitive */
+    cbw->winbutton.set = FALSE;
+    cbw->winbutton.highlighted = HighlightNone;
+    redisplay = TRUE;
+  }
+  
+  if ( (oldcbw->winlabel.foreground != cbw->winlabel.foreground)           ||
+       (oldcbw->core.background_pixel != cbw->core.background_pixel) ||
+       (oldcbw->winbutton.highlight_thickness != 
+                                   cbw->winbutton.highlight_thickness) ||
+       (oldcbw->winlabel.font != cbw->winlabel.font) ) 
+  {
+    if (oldcbw->winlabel.normal_GC == oldcbw->winbutton.normal_GC)
+	/* WinLabel has release one of these */
+      XtReleaseGC(new, cbw->winbutton.inverse_GC);
+    else
+      XtReleaseGC(new, cbw->winbutton.normal_GC);
+
+    cbw->winbutton.normal_GC = Get_GC(cbw, cbw->winlabel.foreground, 
+				    cbw->core.background_pixel);
+    cbw->winbutton.inverse_GC = Get_GC(cbw, cbw->core.background_pixel, 
+				     cbw->winlabel.foreground);
+    XtReleaseGC(new, cbw->winlabel.normal_GC);
+    cbw->winlabel.normal_GC = (cbw->winbutton.set
+			    ? cbw->winbutton.inverse_GC
+			    : cbw->winbutton.normal_GC);
+    
+    redisplay = True;
+  }
+
+  if ( XtIsRealized(new)
+       && oldcbw->winbutton.shape_style != cbw->winbutton.shape_style
+       && !ShapeButton(cbw, TRUE))
+  {
+      cbw->winbutton.shape_style = oldcbw->winbutton.shape_style;
+  }
+
+  return (redisplay);
+}
+
+static void ClassInitialize()
+{
+    XawInitializeWidgetSet();
+    XtSetTypeConverter( XtRString, XtRShapeStyle, XmuCvtStringToShapeStyle,
+		        NULL, 0, XtCacheNone, NULL );
+}
+
+
+static Boolean
+ShapeButton(cbw, checkRectangular)
+WinButtonWidget cbw;
+Boolean checkRectangular;
+{
+    Dimension corner_size;
+
+    if ( (cbw->winbutton.shape_style == XawShapeRoundedRectangle) ) {
+	corner_size = (cbw->core.width < cbw->core.height) ? cbw->core.width 
+	                                                   : cbw->core.height;
+	corner_size = (int) (corner_size * cbw->winbutton.corner_round) / 100;
+    }
+
+    if (checkRectangular || cbw->winbutton.shape_style != XawShapeRectangle) {
+	if (!XmuReshapeWidget((Widget) cbw, cbw->winbutton.shape_style,
+			      corner_size, corner_size)) {
+	    cbw->winbutton.shape_style = XawShapeRectangle;
+	    return(False);
+	}
+    }
+    return(TRUE);
+}
+
+static void Realize(w, valueMask, attributes)
+    Widget w;
+    Mask *valueMask;
+    XSetWindowAttributes *attributes;
+{
+    (*winButtonWidgetClass->core_class.superclass->core_class.realize)
+	(w, valueMask, attributes);
+
+    ShapeButton( (WinButtonWidget) w, FALSE);
+}
+
+static void Resize(w)
+    Widget w;
+{
+    if (XtIsRealized(w)) 
+	ShapeButton( (WinButtonWidget) w, FALSE);
+
+    (*winButtonWidgetClass->core_class.superclass->core_class.resize)(w);
+}
+
diff --git a/controls/WinButton.h b/controls/WinButton.h
new file mode 100644
index 0000000..54dee6a
--- /dev/null
+++ b/controls/WinButton.h
@@ -0,0 +1,109 @@
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
+
+                        All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its 
+documentation for any purpose and without fee is hereby granted, 
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in 
+supporting documentation, and that the names of Digital or MIT not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.  
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+ * Modifications for Wine
+ *
+ * 8/28/93  David Metcalfe (david@prism.demon.co.uk)
+ *          Created from Command widget and added 3D effect
+ */
+
+#ifndef _WinButton_h
+#define _WinButton_h
+
+#include "WinLabel.h"
+
+/* WinButton widget resources:
+
+ Name		     Class		RepType		Default Value
+ ----		     -----		-------		-------------
+ accelerators	     Accelerators	AcceleratorTable NULL
+ ancestorSensitive   AncestorSensitive	Boolean		True
+ background	     Background		Pixel		XtDefaultBackground
+ backgroundPixmap    Pixmap		Pixmap		XtUnspecifiedPixmap
+ bitmap		     Pixmap		Pixmap		None
+ borderColor	     BorderColor	Pixel		XtDefaultForeground
+ borderPixmap	     Pixmap		Pixmap		XtUnspecifiedPixmap
+ borderWidth	     BorderWidth	Dimension	1
+ callback	     Callback		XtCallbackList	NULL
+ colormap	     Colormap		Colormap	parent's colormap
+ cornerRoundPercent  CornerRoundPercent	Dimension	25
+ cursor		     Cursor		Cursor		None
+ cursorName	     Cursor		String		NULL
+ depth		     Depth		int		parent's depth
+ destroyCallback     Callback		XtCallbackList	NULL
+ encoding	     Encoding		UnsignedChar	XawTextEncoding8bit
+ font		     Font		XFontStruct*	XtDefaultFont
+ foreground	     Foreground		Pixel		XtDefaultForeground
+ height		     Height		Dimension	text height
+ highlightThickness  Thickness		Dimension	0 if shaped, else 2
+ insensitiveBorder   Insensitive	Pixmap		Gray
+ internalHeight	     Height		Dimension	2
+ internalWidth	     Width		Dimension	4
+ justify	     Justify		XtJustify	XtJustifyCenter
+ label		     Label		String		NULL
+ leftBitmap	     LeftBitmap		Pixmap		None
+ mappedWhenManaged   MappedWhenManaged	Boolean		True
+ pointerColor	     Foreground		Pixel		XtDefaultForeground
+ pointerColorBackground Background	Pixel		XtDefaultBackground
+ resize		     Resize		Boolean		True
+ screen		     Screen		Screen		parent's Screen
+ sensitive	     Sensitive		Boolean		True
+ shadowHighlight     ShadowHighlight    Pixel           White
+ shadowShade         ShadowShade        Pixel           Grey25
+ shadowThickness     ShadowThickness    Dimension       2 
+ shapeStyle	     ShapeStyle		ShapeStyle	Rectangle
+ translations	     Translations	TranslationTable see doc or source
+ width		     Width		Dimension	text width
+ x		     Position		Position	0
+ y		     Position		Position	0
+
+*/
+
+#define XtNhighlightThickness "highlightThickness"
+
+#define XtNshapeStyle "shapeStyle"
+#define XtCShapeStyle "ShapeStyle"
+#define XtRShapeStyle "ShapeStyle"
+#define XtNcornerRoundPercent "cornerRoundPercent"
+#define XtCCornerRoundPercent "CornerRoundPercent"
+#define XtNshadowThickness "shadowThickness"
+#define XtCShadowThickness "ShadowThickness"
+#define XtNshadowHighlight "shadowHighlight"
+#define XtCShadowHighlight "ShadowHighlight"
+#define XtNshadowShade "shadowShade"
+#define XtCShadowShade "ShadowShade"
+
+#define XawShapeRectangle XmuShapeRectangle
+#define XawShapeOval XmuShapeOval
+#define XawShapeEllipse XmuShapeEllipse
+#define XawShapeRoundedRectangle XmuShapeRoundedRectangle
+
+extern WidgetClass     winButtonWidgetClass;
+
+typedef struct _WinButtonClassRec   *WinButtonWidgetClass;
+typedef struct _WinButtonRec        *WinButtonWidget;
+
+#endif /* _WinButton_h */
+/* DON'T ADD STUFF AFTER THIS */
diff --git a/controls/WinButtonP.h b/controls/WinButtonP.h
new file mode 100644
index 0000000..207f19a
--- /dev/null
+++ b/controls/WinButtonP.h
@@ -0,0 +1,123 @@
+/***********************************************************
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
+and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
+
+                        All Rights Reserved
+
+Permission to use, copy, modify, and distribute this software and its 
+documentation for any purpose and without fee is hereby granted, 
+provided that the above copyright notice appear in all copies and that
+both that copyright notice and this permission notice appear in 
+supporting documentation, and that the names of Digital or MIT not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.  
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
+ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+SOFTWARE.
+
+******************************************************************/
+
+/*
+ * Modifications for Wine
+ *
+ * 8/28/93  David Metcalfe (david@prism.demon.co.uk)
+ *          Created from Command widget and added 3D effect
+ */
+
+/* 
+ * WinButtonP.h - Private definitions for WinButton widget
+ * 
+ */
+
+#ifndef _WinButtonP_h
+#define _WinButtonP_h
+
+#include "WinButton.h"
+#include "WinLabelP.h"
+
+/***********************************************************************
+ *
+ * WinButton Widget Private Data
+ *
+ ***********************************************************************/
+
+typedef enum {
+  HighlightNone,		/* Do not highlight. */
+  HighlightWhenUnset,		/* Highlight only when unset, this is
+				   to preserve current command widget 
+				   functionality. */
+  HighlightAlways		/* Always highlight, lets the toggle widget
+				   and other subclasses do the right thing. */
+} XtCommandHighlight;
+
+/************************************
+ *
+ *  Class structure
+ *
+ ***********************************/
+
+
+   /* New fields for the WinButton widget class record */
+typedef struct _WinButtonClass 
+  {
+    int makes_compiler_happy;  /* not used */
+  } WinButtonClassPart;
+
+   /* Full class record declaration */
+typedef struct _WinButtonClassRec {
+    CoreClassPart	core_class;
+    SimpleClassPart	simple_class;
+    WinLabelClassPart	winlabel_class;
+    WinButtonClassPart  winbutton_class;
+} WinButtonClassRec;
+
+extern WinButtonClassRec winButtonClassRec;
+
+/***************************************
+ *
+ *  Instance (widget) structure 
+ *
+ **************************************/
+
+    /* New fields for the WinButton widget record */
+typedef struct {
+    /* resources */
+    Dimension   highlight_thickness;
+    Dimension   shadow_thickness;
+    Pixel       shadow_shade;
+    Pixel       shadow_highlight;
+    XtCallbackList callbacks;
+
+    /* private state */
+    Pixmap      	gray_pixmap;
+    GC          	normal_GC;
+    GC          	inverse_GC;
+    GC                  shadow_highlight_gc;
+    GC                  shadow_shade_gc;
+    Boolean     	set;
+    XtCommandHighlight	highlighted;
+    /* more resources */
+    int			shape_style;    
+    Dimension		corner_round;
+} WinButtonPart;
+
+
+/*    XtEventsPtr eventTable;*/
+
+
+   /* Full widget declaration */
+typedef struct _WinButtonRec {
+    CorePart         core;
+    SimplePart	     simple;
+    WinLabelPart     winlabel;
+    WinButtonPart    winbutton;
+} WinButtonRec;
+
+#endif /* _WinButtonP_h */
+
+
diff --git a/controls/button.c b/controls/button.c
new file mode 100644
index 0000000..3a65bc0
--- /dev/null
+++ b/controls/button.c
@@ -0,0 +1,86 @@
+/*
+ * Interface code to button widgets
+ *
+ * Copyright  David W. Metcalfe, 1993
+ *
+ */
+
+static char Copyright[] = "Copyright  David W. Metcalfe, 1993";
+
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include "WinButton.h"
+#include "windows.h"
+#include "heap.h"
+#include "win.h"
+
+static void BUTTON_WinButtonCallback(Widget w, XtPointer client_data,
+				               XtPointer call_data);
+
+void BUTTON_CreateButton(LPSTR className, LPSTR buttonLabel, HWND hwnd)
+{
+    WND *wndPtr    = WIN_FindWndPtr(hwnd);
+    WND *parentPtr = WIN_FindWndPtr(wndPtr->hwndParent);
+    DWORD style;
+    char widgetName[15];
+
+#ifdef DEBUG_BUTTON
+    printf("button: label = %s, x = %d, y = %d\n", buttonLabel,
+	   wndPtr->rectClient.left, wndPtr->rectClient.top);
+    printf("        width = %d, height = %d\n",
+	   wndPtr->rectClient.right - wndPtr->rectClient.left,
+	   wndPtr->rectClient.bottom - wndPtr->rectClient.top);
+#endif
+
+    if (!wndPtr)
+	return;
+
+    style = wndPtr->dwStyle & 0x0000000F;
+
+    switch (style)
+    {
+    case BS_PUSHBUTTON:
+    case BS_DEFPUSHBUTTON:
+	sprintf(widgetName, "%s%d", className, wndPtr->wIDmenu);
+	wndPtr->winWidget = XtVaCreateManagedWidget(widgetName,
+				      winButtonWidgetClass,
+				      parentPtr->winWidget,
+				      XtNlabel, buttonLabel,
+				      XtNx, wndPtr->rectClient.left,
+				      XtNy, wndPtr->rectClient.top,
+				      XtNwidth, wndPtr->rectClient.right -
+					        wndPtr->rectClient.left,
+				      XtNheight, wndPtr->rectClient.bottom -
+					         wndPtr->rectClient.top,
+				      XtVaTypedArg, XtNbackground, XtRString,
+					      "grey70", strlen("grey75")+1,
+				      NULL);
+
+	XtAddCallback(wndPtr->winWidget, XtNcallback,
+		      BUTTON_WinButtonCallback, (XtPointer) hwnd);
+	break;
+
+    default:
+	printf("CreateButton: Unsupported button style %lX\n", 
+	                                         wndPtr->dwStyle);
+    }
+
+    GlobalUnlock(hwnd);
+    GlobalUnlock(wndPtr->hwndParent);
+}
+
+static void BUTTON_WinButtonCallback(Widget w, XtPointer client_data,
+				               XtPointer call_data)
+{
+    HWND hwnd = (HWND) client_data;
+    WND  *wndPtr;
+    wndPtr = WIN_FindWndPtr(hwnd);
+
+    CallWindowProc(wndPtr->lpfnWndProc, wndPtr->hwndParent, WM_COMMAND,
+		   wndPtr->wIDmenu, MAKELPARAM(hwnd, BN_CLICKED));
+
+    GlobalUnlock(hwnd);
+}
+
+
+
diff --git a/controls/widgets.c b/controls/widgets.c
index f80a23e..3c68d9c 100644
--- a/controls/widgets.c
+++ b/controls/widgets.c
@@ -7,6 +7,7 @@
 static char Copyright[] = "Copyright  Alexandre Julliard, 1993";
 
 #include "windows.h"
+#include "win.h"
 
 
 static LONG WIDGETS_ButtonWndProc( HWND hwnd, WORD message,
@@ -71,18 +72,20 @@
 	return 0;
 	
     case WM_PAINT:
-	{
-	    HDC hdc;
-	    PAINTSTRUCT ps;
-	    RECT rect;
-	
-	    hdc = BeginPaint( hwnd, &ps );
-	    GetClientRect( hwnd, &rect );
-	    DrawText(hdc, "Button", -1, &rect,
-		     DT_SINGLELINE | DT_CENTER | DT_VCENTER );
-	    EndPaint( hwnd, &ps );
-	    return 0;
-	}
+    {
+	PAINTSTRUCT ps;
+	BeginPaint( hwnd, &ps );
+	EndPaint( hwnd, &ps );
+	return 0;
+    }
+
+    case WM_COMMAND:
+    {
+	WND  *wndParent;
+	wndParent = WIN_FindWndPtr(hwnd);
+	CallWindowProc(wndParent->lpfnWndProc, hwnd, message, wParam, lParam);
+	return 0;
+    }
 	
     default:
 	return DefWindowProc( hwnd, message, wParam, lParam );