]> git.saurik.com Git - wxWidgets.git/blobdiff - src/motif/gauge.cpp
Implemented wxGDIObject::Create/CloneGDIRefData() for the relevant classes.
[wxWidgets.git] / src / motif / gauge.cpp
index 73beaae217e1c35c81b55cad0970a204259dbe12..4ccdf87265d359bc8bccf2375a231e8e9411fdbb 100644 (file)
@@ -1,26 +1,52 @@
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
-// Name:        gauge.cpp
+// Name:        src/motif/gauge.cpp
 // Purpose:     wxGauge class
 // Author:      Julian Smart
 // Modified by:
 // Created:     17/09/98
 // RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart
 // Purpose:     wxGauge class
 // Author:      Julian Smart
 // Modified by:
 // Created:     17/09/98
 // RCS-ID:      $Id$
 // Copyright:   (c) Julian Smart
-// Licence:    wxWindows licence
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 /////////////////////////////////////////////////////////////////////////////
 
-#ifdef __GNUG__
-#pragma implementation "gauge.h"
+// For compilers that support precompilation, includes "wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __VMS
+#include "wx/vms_x_fix.h"
+#undef XtDisplay
+#undef XtScreen
+#undef XtWindow
+#undef XtIsRealized
+#undef XtParent
+#undef XtClass
 #endif
 
 #include "wx/gauge.h"
 
 #endif
 
 #include "wx/gauge.h"
 
+#ifndef WX_PRECOMP
+    #include "wx/math.h"
+#endif
+
+#ifdef __OS2__
+#include <types.h>
+#endif
+
+#ifdef __VMS__
+#pragma message disable nosimpint
+#endif
 #include <Xm/Xm.h>
 #include <Xm/Xm.h>
-#include <wx/motif/private.h>
+#ifdef __WXMOTIF20__
+#include <Xm/Scale.h>
+#endif // __WXMOTIF20__
+#ifdef __VMS__
+#pragma message enable nosimpint
+#endif
+#include "wx/motif/private.h"
 
 
-#if !USE_SHARED_LIBRARY
 IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
 IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
-#endif
+
+#if !wxCHECK_MOTIF_VERSION( 2, 0 ) || wxCHECK_LESSTIF()
 
 // XmGauge copyright notice:
 
 
 // XmGauge copyright notice:
 
@@ -43,14 +69,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
 * 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
 * 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 
+* action, arising out of or in connection with the use
 * or performance of this software.
 *
 */
 
 //// PUBLIC XMGAUGE DECLARATIONS
 * or performance of this software.
 *
 */
 
 //// PUBLIC XMGAUGE DECLARATIONS
-typedef struct _XmGaugeClassRec*       XmGaugeWidgetClass;
-typedef struct _XmGaugeRec*            XmGaugeWidget;
+typedef struct _XmGaugeClassRec*  XmGaugeWidgetClass;
+typedef struct _XmGaugeRec*       XmGaugeWidget;
 
 #ifdef __cplusplus
 extern "C" WidgetClass xmGaugeWidgetClass;
 
 #ifdef __cplusplus
 extern "C" WidgetClass xmGaugeWidgetClass;
@@ -71,7 +97,7 @@ XmGaugeSetValue(Widget w, int value);
 int
 XmGaugeGetValue(Widget w);
 
 int
 XmGaugeGetValue(Widget w);
 
-
+#endif // !wxCHECK_MOTIF_VERSION( 2, 0 ) || wxCHECK_LESSTIF()
 
 bool wxGauge::Create(wxWindow *parent, wxWindowID id,
                      int range,
 
 bool wxGauge::Create(wxWindow *parent, wxWindowID id,
                      int range,
@@ -81,25 +107,15 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
                      const wxValidator& validator,
                      const wxString& name)
 {
                      const wxValidator& validator,
                      const wxString& name)
 {
-    SetName(name);
-    SetValidator(validator);
-    m_rangeMax = range;
-    m_windowStyle = style;
-    m_backgroundColour = parent->GetBackgroundColour();
-    m_foregroundColour = parent->GetForegroundColour();
-    
-    if (parent) parent->AddChild(this);
-    
-    if ( id == -1 )
-        m_windowId = (int)NewControlId();
-    else
-        m_windowId = id;
-    
+    if( !CreateControl( parent, id, pos, size, style, validator, name ) )
+        return false;
+    PreCreation();
+
     Widget parentWidget = (Widget) parent->GetClientWidget();
     Widget parentWidget = (Widget) parent->GetClientWidget();
-    
-    Arg args[4];
+
+    Arg args[7];
     int count = 4;
     int count = 4;
-    if (style & wxHORIZONTAL)
+    if (style & wxGA_HORIZONTAL)
     {
         XtSetArg (args[0], XmNorientation, XmHORIZONTAL);
         XtSetArg (args[1], XmNprocessingDirection, XmMAX_ON_RIGHT);
     {
         XtSetArg (args[0], XmNorientation, XmHORIZONTAL);
         XtSetArg (args[1], XmNprocessingDirection, XmMAX_ON_RIGHT);
@@ -111,32 +127,40 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
     }
     XtSetArg(args[2], XmNminimum, 0);
     XtSetArg(args[3], XmNmaximum, range);
     }
     XtSetArg(args[2], XmNminimum, 0);
     XtSetArg(args[3], XmNmaximum, range);
-    Widget gaugeWidget = XtCreateManagedWidget("gauge", xmGaugeWidgetClass, parentWidget, args, count);
+#if wxCHECK_MOTIF_VERSION( 2, 0 ) && !wxCHECK_LESSTIF()
+    XtSetArg(args[4], XmNeditable, False); ++count;
+    XtSetArg(args[5], XmNslidingMode, XmTHERMOMETER); ++count;
+    // XtSetArg(args[6], XmNsliderVisual, XmFOREGROUND_COLOR ); ++count;
+    Widget gaugeWidget =
+        XtCreateManagedWidget("gauge", xmScaleWidgetClass,
+                              parentWidget, args, count);
+#else
+    Widget gaugeWidget =
+        XtCreateManagedWidget("gauge", xmGaugeWidgetClass,
+                              parentWidget, args, count);
+#endif
     m_mainWidget = (WXWidget) gaugeWidget ;
     m_mainWidget = (WXWidget) gaugeWidget ;
-    
+
     XtManageChild (gaugeWidget);
     XtManageChild (gaugeWidget);
-    
+
     int x = pos.x; int y = pos.y;
     int x = pos.x; int y = pos.y;
-    int width = size.x; int height = size.y;
-    if (width == -1)
-        width = 150;
-    if (height == -1)
-        height = 80;
-    
-    m_windowFont = parent->GetFont();
-    ChangeFont(FALSE);
-    
-    SetCanAddEventHandler(TRUE);
-    AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, width, height);
-    
-    ChangeBackgroundColour();
-    
-    return TRUE;
+    wxSize best = GetBestSize();
+    if( size.x != wxDefaultCoord ) best.x = size.x;
+    if( size.y != wxDefaultCoord ) best.y = size.y;
+
+    PostCreation();
+    AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y,
+                  best.x, best.y);
+
+    return true;
 }
 
 }
 
-void wxGauge::SetSize(int x, int y, int width, int height, int sizeFlags)
+wxSize wxGauge::DoGetBestSize() const
 {
 {
-    wxControl::SetSize(x, y, width, height, sizeFlags);
+    if( HasFlag(wxGA_HORIZONTAL) )
+        return wxSize( 100, 18 );
+    else
+        return wxSize( 18, 100 );
 }
 
 void wxGauge::SetShadowWidth(int w)
 }
 
 void wxGauge::SetShadowWidth(int w)
@@ -146,19 +170,13 @@ void wxGauge::SetShadowWidth(int w)
     XtVaSetValues((Widget) m_mainWidget, XmNshadowThickness, w, NULL);
 }
 
     XtVaSetValues((Widget) m_mainWidget, XmNshadowThickness, w, NULL);
 }
 
-void wxGauge::SetBezelFace(int w)
-{
-}
-
 void wxGauge::SetRange(int r)
 {
 void wxGauge::SetRange(int r)
 {
-    m_rangeMax = r;
     XtVaSetValues((Widget) m_mainWidget, XmNmaximum, r, NULL);
 }
 
 void wxGauge::SetValue(int pos)
 {
     XtVaSetValues((Widget) m_mainWidget, XmNmaximum, r, NULL);
 }
 
 void wxGauge::SetValue(int pos)
 {
-    m_gaugePos = pos;
     XtVaSetValues((Widget) m_mainWidget, XmNvalue, pos, NULL);
 }
 
     XtVaSetValues((Widget) m_mainWidget, XmNvalue, pos, NULL);
 }
 
@@ -169,17 +187,11 @@ int wxGauge::GetShadowWidth() const
     return (int)w;
 }
 
     return (int)w;
 }
 
-int wxGauge::GetBezelFace() const
-{
-    return 0;
-}
-
 int wxGauge::GetRange() const
 {
     int r;
     XtVaGetValues((Widget) m_mainWidget, XmNmaximum, &r, NULL);
     return (int)r;
 int wxGauge::GetRange() const
 {
     int r;
     XtVaGetValues((Widget) m_mainWidget, XmNmaximum, &r, NULL);
     return (int)r;
-    //    return m_rangeMax;
 }
 
 int wxGauge::GetValue() const
 }
 
 int wxGauge::GetValue() const
@@ -187,23 +199,19 @@ int wxGauge::GetValue() const
     int pos;
     XtVaGetValues((Widget) m_mainWidget, XmNvalue, &pos, NULL);
     return pos;
     int pos;
     XtVaGetValues((Widget) m_mainWidget, XmNvalue, &pos, NULL);
     return pos;
-    //    return m_gaugePos;
-}
-
-void wxGauge::ChangeFont(bool keepOriginalSize)
-{
-    wxWindow::ChangeFont(keepOriginalSize);
 }
 
 }
 
-void wxGauge::ChangeBackgroundColour()
+void wxGauge::DoMoveWindow(int x, int y, int width, int height)
 {
 {
-    wxWindow::ChangeBackgroundColour();
+    wxGaugeBase::DoMoveWindow( x, y, width, height );
+#ifdef __WXMOTIF20__
+    XtVaSetValues( (Widget)m_mainWidget,
+                   XmNscaleHeight, height,
+                   NULL );
+#endif
 }
 
 }
 
-void wxGauge::ChangeForegroundColour()
-{
-    wxWindow::ChangeForegroundColour();
-}
+#if !wxCHECK_MOTIF_VERSION( 2, 0 ) || wxCHECK_LESSTIF()
 
 //// PRIVATE DECLARATIONS FOR XMGAUGE
 
 
 //// PRIVATE DECLARATIONS FOR XMGAUGE
 
@@ -214,10 +222,10 @@ typedef struct {
     int empty;
 } XmGaugeClassPart;
 
     int empty;
 } XmGaugeClassPart;
 
-typedef struct _XmGaugeClassRec {    
-    CoreClassPart              core_class;
-    XmPrimitiveClassPart       primitive_class;
-    XmGaugeClassPart           gauge_class;
+typedef struct _XmGaugeClassRec {
+    CoreClassPart         core_class;
+    XmPrimitiveClassPart  primitive_class;
+    XmGaugeClassPart      gauge_class;
 } XmGaugeClassRec;
 
 
 } XmGaugeClassRec;
 
 
@@ -227,21 +235,21 @@ typedef struct _XmGaugePart{
     int maximum;
     unsigned char orientation;
     unsigned char processingDirection;
     int maximum;
     unsigned char orientation;
     unsigned char processingDirection;
-    
+
     XtCallbackList dragCallback;
     XtCallbackList valueChangedCallback;
     XtCallbackList dragCallback;
     XtCallbackList valueChangedCallback;
-    
+
     /* private fields */
     /* private fields */
-    Boolean dragging;          /* drag in progress ? */
+    Boolean dragging; /* drag in progress ? */
     int oldx, oldy;
     GC gc;
 } XmGaugePart;
 
 
 typedef struct _XmGaugeRec {
     int oldx, oldy;
     GC gc;
 } XmGaugePart;
 
 
 typedef struct _XmGaugeRec {
-    CorePart           core;
-    XmPrimitivePart    primitive;
-    XmGaugePart                gauge;
+    CorePart         core;
+    XmPrimitivePart  primitive;
+    XmGaugePart      gauge;
 } XmGaugeRec;
 
 extern XmGaugeClassRec xmGaugeClassRec;
 } XmGaugeRec;
 
 extern XmGaugeClassRec xmGaugeClassRec;
@@ -252,9 +260,9 @@ extern XmGaugeClassRec xmGaugeClassRec;
 
 void
 GaugePick(Widget w, XEvent *e, String *args, Cardinal  *num_args);
 
 void
 GaugePick(Widget w, XEvent *e, String *args, Cardinal  *num_args);
-void 
+void
 GaugeDrag(Widget w, XEvent *e, String *args, Cardinal  *num_args);
 GaugeDrag(Widget w, XEvent *e, String *args, Cardinal  *num_args);
-void 
+void
 GaugeDrop(Widget w, XEvent *e, String *args, Cardinal  *num_args);
 
 
 GaugeDrop(Widget w, XEvent *e, String *args, Cardinal  *num_args);
 
 
@@ -285,9 +293,9 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
     unsigned long backgr,foregr;
     XRectangle rects[1];
     ***/
     unsigned long backgr,foregr;
     XRectangle rects[1];
     ***/
-    
+
     sht = gw->primitive.shadow_thickness;
     sht = gw->primitive.shadow_thickness;
-    
+
     ratio =  (float)THIS.value/
         (float)(THIS.maximum - THIS.minimum);
         /***chubraev
     ratio =  (float)THIS.value/
         (float)(THIS.maximum - THIS.minimum);
         /***chubraev
@@ -295,7 +303,7 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
         len=strlen(string);
         XtVaGetValues(gw,XmNbackground,&backgr,XmNforeground,&foregr,NULL);
     ***/
         len=strlen(string);
         XtVaGetValues(gw,XmNbackground,&backgr,XmNforeground,&foregr,NULL);
     ***/
-    
+
     if(clear) {
         XClearArea(XtDisplay(gw), XtWindow(gw), sht, sht,
             gw->core.width - 2 * sht, gw->core.height - 2 * sht, False);
     if(clear) {
         XClearArea(XtDisplay(gw), XtWindow(gw), sht, sht,
             gw->core.width - 2 * sht, gw->core.height - 2 * sht, False);
@@ -304,7 +312,7 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
     case XmHORIZONTAL:
         size = (int) ((gw->core.width - 2 * sht)*ratio);
         /***chubraev
     case XmHORIZONTAL:
         size = (int) ((gw->core.width - 2 * sht)*ratio);
         /***chubraev
-        XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2, 
+        XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2,
         gw->core.height - 2 * sht, string, len);
         ***/
         switch(THIS.processingDirection) {
         gw->core.height - 2 * sht, string, len);
         ***/
         switch(THIS.processingDirection) {
@@ -312,7 +320,7 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
         case XmMAX_ON_BOTTOM:
             XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
                 sht, sht, size, gw->core.height - 2 * sht);
         case XmMAX_ON_BOTTOM:
             XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
                 sht, sht, size, gw->core.height - 2 * sht);
-            
+
                 /***chubraev
                 rects[0].x = sht; rects[0].y = sht;
                 rects[0].width = size; rects[0].height = gw->core.height - 2 * sht;
                 /***chubraev
                 rects[0].x = sht; rects[0].y = sht;
                 rects[0].width = size; rects[0].height = gw->core.height - 2 * sht;
@@ -323,7 +331,7 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
             XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
                 gw->core.width - size - sht, sht,
                 size, gw->core.height - 2 * sht);
             XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
                 gw->core.width - size - sht, sht,
                 size, gw->core.height - 2 * sht);
-            
+
                 /***chubraev
                 rects[0].x = gw->core.width - size - sht; rects[0].y = sht;
                 rects[0].width = size; rects[0].height = gw->core.height - 2 * sht;
                 /***chubraev
                 rects[0].x = gw->core.width - size - sht; rects[0].y = sht;
                 rects[0].width = size; rects[0].height = gw->core.height - 2 * sht;
@@ -333,15 +341,15 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
         /***chubraev
         XSetClipRectangles(XtDisplay(gw), THIS.gc, 0, 0, rects, 1, Unsorted);
         XSetForeground(XtDisplay(gw), THIS.gc, backgr);
         /***chubraev
         XSetClipRectangles(XtDisplay(gw), THIS.gc, 0, 0, rects, 1, Unsorted);
         XSetForeground(XtDisplay(gw), THIS.gc, backgr);
-        XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2, 
+        XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2,
         gw->core.height - 2 * sht, string, len);
         ***/
         gw->core.height - 2 * sht, string, len);
         ***/
-        
+
         break;
         case XmVERTICAL:
             size = (int) ((gw->core.height - 2 * sht)*ratio);
             /***chubraev
         break;
         case XmVERTICAL:
             size = (int) ((gw->core.height - 2 * sht)*ratio);
             /***chubraev
-            XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht, 
+            XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht,
             sht+gw->core.height/2, string,len);
             ***/
             switch(THIS.processingDirection) {
             sht+gw->core.height/2, string,len);
             ***/
             switch(THIS.processingDirection) {
@@ -349,7 +357,7 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
             case XmMAX_ON_BOTTOM:
                 XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
                     sht, sht, gw->core.width - 2 * sht, size);
             case XmMAX_ON_BOTTOM:
                 XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
                     sht, sht, gw->core.width - 2 * sht, size);
-                
+
                     /***chubraev
                     rects[0].x = sht; rects[0].y = sht;
                     rects[0].width = gw->core.width - 2 * sht; rects[0].height = size;
                     /***chubraev
                     rects[0].x = sht; rects[0].y = sht;
                     rects[0].width = gw->core.width - 2 * sht; rects[0].height = size;
@@ -360,7 +368,7 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
                 XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
                     sht, gw->core.height - size - sht,
                     gw->core.width - 2 * sht, size);
                 XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
                     sht, gw->core.height - size - sht,
                     gw->core.width - 2 * sht, size);
-                
+
                     /***chubraev
                     rects[0].x = sht; rects[0].y = gw->core.height - size - sht;
                     rects[0].width = gw->core.width - 2 * sht; rects[0].height = size;
                     /***chubraev
                     rects[0].x = sht; rects[0].y = gw->core.height - size - sht;
                     rects[0].width = gw->core.width - 2 * sht; rects[0].height = size;
@@ -369,7 +377,7 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
             /***chubraev
             XSetClipRectangles(XtDisplay(gw), THIS.gc, 0, 0, rects, 1, Unsorted);
             XSetForeground(XtDisplay(gw), THIS.gc, backgr);
             /***chubraev
             XSetClipRectangles(XtDisplay(gw), THIS.gc, 0, 0, rects, 1, Unsorted);
             XSetForeground(XtDisplay(gw), THIS.gc, backgr);
-            XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht, 
+            XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht,
             sht+gw->core.height/2, string,len);
             ***/
             break;
             sht+gw->core.height/2, string,len);
             ***/
             break;
@@ -378,7 +386,7 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
     XSetClipMask(XtDisplay(gw), THIS.gc, None);
     XSetForeground(XtDisplay(gw), THIS.gc, foregr);
     ***/
     XSetClipMask(XtDisplay(gw), THIS.gc, None);
     XSetForeground(XtDisplay(gw), THIS.gc, foregr);
     ***/
-#undef THIS    
+#undef THIS
 }
 
 /* Old code
 }
 
 /* Old code
@@ -390,7 +398,7 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
 #define THIS gw->gauge
     int size, sht;
     /*    float ratio; */
 #define THIS gw->gauge
     int size, sht;
     /*    float ratio; */
-    
+
     sht = gw->primitive.shadow_thickness;
     /* See fix comment below: can cause divide by zero error.
     ratio = (float)((float)THIS.maximum -
     sht = gw->primitive.shadow_thickness;
     /* See fix comment below: can cause divide by zero error.
     ratio = (float)((float)THIS.maximum -
@@ -402,7 +410,7 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
     }
     switch(THIS.orientation) {
     case XmHORIZONTAL:
     }
     switch(THIS.orientation) {
     case XmHORIZONTAL:
-        /*     size = (gw->core.width - 2 * sht) / ratio; */
+        /* size = (gw->core.width - 2 * sht) / ratio; */
         /* A fix suggested by Dmitri Chubraev */
         size = (gw->core.width - 2 * sht) /((float)THIS.maximum-(float)THIS.minimum)*(float)THIS.value;
         switch(THIS.processingDirection) {
         /* A fix suggested by Dmitri Chubraev */
         size = (gw->core.width - 2 * sht) /((float)THIS.maximum-(float)THIS.minimum)*(float)THIS.value;
         switch(THIS.processingDirection) {
@@ -421,7 +429,7 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
         break;
         case XmVERTICAL:
             size = (gw->core.height - 2 * sht) /((float)THIS.maximum-(float)THIS.minimum)*(float)THIS.value;
         break;
         case XmVERTICAL:
             size = (gw->core.height - 2 * sht) /((float)THIS.maximum-(float)THIS.minimum)*(float)THIS.value;
-            /* size = (gw->core.height - 2 * sht)/ ratio; */
+            /* size = (gw->core.height - 2 * sht)/ ratio; */
             switch(THIS.processingDirection) {
             case XmMAX_ON_RIGHT:
             case XmMAX_ON_BOTTOM:
             switch(THIS.processingDirection) {
             case XmMAX_ON_RIGHT:
             case XmMAX_ON_BOTTOM:
@@ -436,22 +444,22 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
             }
             break;
     }
             }
             break;
     }
-#undef THIS    
+#undef THIS
 }
 #endif
 
 static void
 }
 #endif
 
 static void
-Initialize(Widget req, Widget new_w, ArgList args, Cardinal *num_args )
+Initialize(Widget WXUNUSED(req), Widget new_w, ArgList WXUNUSED(args), Cardinal *WXUNUSED(num_args ))
 {
     XmGaugeWidget gw = (XmGaugeWidget)new_w;
 #define THIS gw->gauge
     XGCValues values;
 {
     XmGaugeWidget gw = (XmGaugeWidget)new_w;
 #define THIS gw->gauge
     XGCValues values;
-    
+
     values.foreground = gw->primitive.foreground;
     THIS.gc = XtGetGC(new_w, GCForeground, &values);
     values.foreground = gw->primitive.foreground;
     THIS.gc = XtGetGC(new_w, GCForeground, &values);
-    
-#undef THIS    
-    
+
+#undef THIS
+
 }
 
 
 }
 
 
@@ -462,7 +470,7 @@ Destroy(Widget w)
     XmGaugeWidget gw = (XmGaugeWidget)w;
 #define THIS gw->gauge
     XtReleaseGC(w, THIS.gc);
     XmGaugeWidget gw = (XmGaugeWidget)w;
 #define THIS gw->gauge
     XtReleaseGC(w, THIS.gc);
-#undef THIS    
+#undef THIS
 }
 
 
 }
 
 
@@ -471,18 +479,18 @@ Destroy(Widget w)
 static Boolean
 SetValues(
           Widget cw,
 static Boolean
 SetValues(
           Widget cw,
-          Widget rw,
+          Widget WXUNUSED(rw),
           Widget nw,
           Widget nw,
-          ArgList args,
-          Cardinal *num_args )
+          ArgList WXUNUSED(args),
+          Cardinal *WXUNUSED(num_args) )
 {
     XmGaugeWidget cgw = (XmGaugeWidget)cw;
     XmGaugeWidget ngw = (XmGaugeWidget)nw;
 {
     XmGaugeWidget cgw = (XmGaugeWidget)cw;
     XmGaugeWidget ngw = (XmGaugeWidget)nw;
-    
+
     Boolean redraw = False;
     if(cgw->primitive.foreground != ngw->primitive.foreground) {
         XGCValues values;
     Boolean redraw = False;
     if(cgw->primitive.foreground != ngw->primitive.foreground) {
         XGCValues values;
-        
+
         redraw = True;
         XtReleaseGC(nw, ngw->gauge.gc);
         values.foreground = ngw->primitive.foreground;
         redraw = True;
         XtReleaseGC(nw, ngw->gauge.gc);
         values.foreground = ngw->primitive.foreground;
@@ -498,104 +506,104 @@ SetValues(
 
 
 static void
 
 
 static void
-ExposeProc(Widget w, XEvent *event, Region r)
+ExposeProc(Widget w, XEvent *WXUNUSED(event), Region WXUNUSED(r))
 {
     XmGaugeWidget gw = (XmGaugeWidget)w;
 #define THIS gw->gauge
     int sht;
 {
     XmGaugeWidget gw = (XmGaugeWidget)w;
 #define THIS gw->gauge
     int sht;
-    
+
     sht = gw->primitive.shadow_thickness;
     _XmDrawShadows(XtDisplay(w), XtWindow(w),
         gw->primitive.top_shadow_GC,
         gw->primitive.bottom_shadow_GC,
         0, 0, w->core.width, w->core.height,
     sht = gw->primitive.shadow_thickness;
     _XmDrawShadows(XtDisplay(w), XtWindow(w),
         gw->primitive.top_shadow_GC,
         gw->primitive.bottom_shadow_GC,
         0, 0, w->core.width, w->core.height,
-        sht, XmSHADOW_IN);
+        (Dimension)sht, XmSHADOW_IN);
     DrawSlider(gw, False);
     DrawSlider(gw, False);
-#undef THIS    
+#undef THIS
 }
 
 
 
 
 
 }
 
 
 
 
 
-static XtResource 
+static XtResource
 resources[] = {
 #define offset(field) XtOffset(XmGaugeWidget, gauge.field)
     {XmNvalue, XmCValue, XtRInt, sizeof(int),
         offset(value), XtRImmediate, (caddr_t)10},
 resources[] = {
 #define offset(field) XtOffset(XmGaugeWidget, gauge.field)
     {XmNvalue, XmCValue, XtRInt, sizeof(int),
         offset(value), XtRImmediate, (caddr_t)10},
-        
+
     {XmNminimum, XmCValue, XtRInt, sizeof(int),
     offset(minimum), XtRImmediate, (caddr_t)0},
     {XmNminimum, XmCValue, XtRInt, sizeof(int),
     offset(minimum), XtRImmediate, (caddr_t)0},
-    
+
     {XmNmaximum, XmCValue, XtRInt, sizeof(int),
     offset(maximum), XtRImmediate, (caddr_t)100},
     {XmNmaximum, XmCValue, XtRInt, sizeof(int),
     offset(maximum), XtRImmediate, (caddr_t)100},
-    
+
     {XmNorientation, XmCOrientation, XmROrientation, sizeof(unsigned char),
     offset(orientation), XtRImmediate, (caddr_t)XmVERTICAL},
     {XmNorientation, XmCOrientation, XmROrientation, sizeof(unsigned char),
     offset(orientation), XtRImmediate, (caddr_t)XmVERTICAL},
-    
+
     {XmNprocessingDirection, XmCProcessingDirection,
     XmRProcessingDirection, sizeof(unsigned char),
     offset(processingDirection), XtRImmediate, (caddr_t)XmMAX_ON_RIGHT},
     {XmNprocessingDirection, XmCProcessingDirection,
     XmRProcessingDirection, sizeof(unsigned char),
     offset(processingDirection), XtRImmediate, (caddr_t)XmMAX_ON_RIGHT},
-    
+
     {XmNdragCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList),
     offset(dragCallback), XtRImmediate, (caddr_t)NULL},
     {XmNdragCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList),
     offset(dragCallback), XtRImmediate, (caddr_t)NULL},
-    
+
     {XmNvalueChangedCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList),
     offset(valueChangedCallback), XtRImmediate, (caddr_t)NULL},
     {XmNvalueChangedCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList),
     offset(valueChangedCallback), XtRImmediate, (caddr_t)NULL},
-    
-    
+
+
 #undef offset
 };
 
 
 XmGaugeClassRec xmGaugeClassRec = {
 #undef offset
 };
 
 
 XmGaugeClassRec xmGaugeClassRec = {
-    {                          /* core fields */
-        (WidgetClass) &xmPrimitiveClassRec, /* superclass              */
-            "XmGauge",         /* class_name           */
-            sizeof(XmGaugeRec),        /* widget_size          */
-            NULL,                      /* class_initialize             */
-            NULL,                      /* class_part_initialize        */
-            FALSE,                     /* class_inited         */
-            Initialize,                /* initialize           */
-            NULL,                      /* initialize_hook              */
-            XtInheritRealize,  /* realize                      */
-            actions,           /* actions                      */
-            XtNumber(actions), /* num_actions          */
-            resources,         /* resources            */
-            XtNumber(resources),       /* num_resources                */
-            NULLQUARK,         /* xrm_class            */
-            TRUE,                      /* compress_motion              */
-            TRUE,                      /* compress_exposure    */
-            TRUE,                      /* compress_enterleave  */
-            FALSE,                     /* visible_interest             */
-            Destroy,           /* destroy                      */
-            NULL,                      /* resize                       */
-            ExposeProc,                /* expose                       */
-            SetValues,         /* set_values           */
-            NULL,                      /* set_values_hook              */
-            XtInheritSetValuesAlmost, /* set_values_almost     */
-            NULL,                      /* get_values_hook              */
-            NULL,                      /* accept_focus         */
-            XtVersion,         /* version                      */
-            NULL,                      /* callback_private             */
-            translations,              /* tm_table                     */
-            NULL,                      /* query_geometry               */
-            NULL,                      /* display_accelerator  */
-            NULL                       /* extension            */
+    {    /* core fields */
+        (WidgetClass) &xmPrimitiveClassRec, /* superclass */
+        "XmGauge",            /* class_name */
+        sizeof(XmGaugeRec),   /* widget_size */
+        NULL,                 /* class_initialize */
+        NULL,                 /* class_part_initialize */
+        False,                /* class_inited */
+        Initialize,           /* initialize */
+        NULL,                 /* initialize_hook */
+        XtInheritRealize,     /* realize */
+        actions,              /* actions */
+        XtNumber(actions),    /* num_actions */
+        resources,            /* resources */
+        XtNumber(resources),  /* num_resources */
+        NULLQUARK,            /* xrm_class */
+        True,                 /* compress_motion */
+        True,                 /* compress_exposure */
+        True,                 /* compress_enterleave */
+        False,                /* visible_interest */
+        Destroy,              /* destroy */
+        NULL,                 /* resize */
+        ExposeProc,           /* expose */
+        SetValues,            /* set_values */
+        NULL,                 /* set_values_hook */
+        XtInheritSetValuesAlmost, /* set_values_almost */
+        NULL,                 /* get_values_hook */
+        NULL,                 /* accept_focus */
+        XtVersion,            /* version */
+        NULL,                 /* callback_private */
+        translations,         /* tm_table */
+        NULL,                 /* query_geometry */
+        NULL,                 /* display_accelerator */
+        NULL                  /* extension */
     },
     },
-                               /* primitive_class fields */
+    /* primitive_class fields */
     {
     {
-            NULL,                      /* border_highlight     */
-                NULL,                  /* border_unhighlight   */
-                NULL,                  /* translations         */
-                NULL,                  /* arm_and_activate     */
-                NULL,                  /* syn_resources        */
-                0,                     /* num_syn_resources    */
-                NULL                   /* extension            */
-        },
-        { /* gauge fields */
-                0                      /* empty                */
-            }
+        NULL,                 /* border_highlight */
+        NULL,                 /* border_unhighlight */
+        NULL,                 /* translations */
+        NULL,                 /* arm_and_activate */
+        NULL,                 /* syn_resources */
+        0,                    /* num_syn_resources */
+        NULL                  /* extension */
+    },
+    { /* gauge fields */
+        0                     /* empty */
+    }
 };
 
 WidgetClass xmGaugeWidgetClass = (WidgetClass)&xmGaugeClassRec;
 };
 
 WidgetClass xmGaugeWidgetClass = (WidgetClass)&xmGaugeClassRec;
@@ -603,10 +611,10 @@ WidgetClass xmGaugeWidgetClass = (WidgetClass)&xmGaugeClassRec;
 
 
 
 
 
 
-void 
-GaugePick(Widget w, XEvent *e, String *args, Cardinal  *num_args)
+void
+GaugePick(Widget WXUNUSED(w), XEvent *WXUNUSED(e), String *WXUNUSED(args), Cardinal  *WXUNUSED(num_args))
 {
 {
-    /* Commented out for a read-only gauge in wxWindows */
+    /* Commented out for a read-only gauge in wxWidgets */
 #if 0
     XmGaugeWidget gw = (XmGaugeWidget)w;
 #define THIS gw->gauge
 #if 0
     XmGaugeWidget gw = (XmGaugeWidget)w;
 #define THIS gw->gauge
@@ -615,7 +623,7 @@ GaugePick(Widget w, XEvent *e, String *args, Cardinal  *num_args)
     Boolean dragging = False;
     XButtonEvent *event = (XButtonEvent *)e;
     int x, y;
     Boolean dragging = False;
     XButtonEvent *event = (XButtonEvent *)e;
     int x, y;
-    
+
     x = event->x;
     y = event->y;
     sht = gw->primitive.shadow_thickness;
     x = event->x;
     y = event->y;
     sht = gw->primitive.shadow_thickness;
@@ -624,10 +632,10 @@ GaugePick(Widget w, XEvent *e, String *args, Cardinal  *num_args)
         gw->primitive.bottom_shadow_GC,
         0, 0, w->core.width, w->core.height,
         sht, XmSHADOW_IN);
         gw->primitive.bottom_shadow_GC,
         0, 0, w->core.width, w->core.height,
         sht, XmSHADOW_IN);
-    
-    
+
+
     ratio = (float)((float)THIS.maximum -
     ratio = (float)((float)THIS.maximum -
-        (float)THIS.minimum) / (float)THIS.value;                 
+        (float)THIS.minimum) / (float)THIS.value;
     switch(THIS.orientation) {
     case XmHORIZONTAL:
         size = (w->core.width - 2 * sht) / ratio;
     switch(THIS.orientation) {
     case XmHORIZONTAL:
         size = (w->core.width - 2 * sht) / ratio;
@@ -663,29 +671,27 @@ GaugePick(Widget w, XEvent *e, String *args, Cardinal  *num_args)
     THIS.dragging = dragging;
     THIS.oldx = x;
     THIS.oldy = y;
     THIS.dragging = dragging;
     THIS.oldx = x;
     THIS.oldy = y;
-#undef THIS    
+#undef THIS
 #endif
 }
 
 #endif
 }
 
-#define round(x) ( (x) > 0 ? ((x) + 0.5) : -(-(x) + 0.5) )
-
-void 
-GaugeDrag(Widget w, XEvent *e, String *args, Cardinal  *num_args)
+void
+GaugeDrag(Widget WXUNUSED(w), XEvent *WXUNUSED(e), String *WXUNUSED(args), Cardinal  *WXUNUSED(num_args))
 {
 {
-    /* Commented out for a read-only gauge in wxWindows */
+    /* Commented out for a read-only gauge in wxWidgets */
 #if 0
     XmGaugeWidget gw = (XmGaugeWidget)w;
 #define THIS gw->gauge
     int sht, x, y, max, value;
     float ratio, nratio, size, nsize, fvalue, delta;
     XMotionEvent *event = (XMotionEvent *)e;
 #if 0
     XmGaugeWidget gw = (XmGaugeWidget)w;
 #define THIS gw->gauge
     int sht, x, y, max, value;
     float ratio, nratio, size, nsize, fvalue, delta;
     XMotionEvent *event = (XMotionEvent *)e;
-    
+
     if( ! THIS.dragging) return;
     if( ! THIS.dragging) return;
-    
+
     x = event->x;
     y = event->y;
     sht = gw->primitive.shadow_thickness;
     x = event->x;
     y = event->y;
     sht = gw->primitive.shadow_thickness;
-    
+
     ratio = (float)THIS.value / (float)((float)THIS.maximum -
         (float)THIS.minimum);
     switch(THIS.orientation) {
     ratio = (float)THIS.value / (float)((float)THIS.maximum -
         (float)THIS.minimum);
     switch(THIS.orientation) {
@@ -711,21 +717,21 @@ GaugeDrag(Widget w, XEvent *e, String *args, Cardinal  *num_args)
     if(nsize > (float)max) nsize = (float)max;
     if(nsize < (float)0 ) nsize = (float)0;
     nratio =  nsize / (float)max;
     if(nsize > (float)max) nsize = (float)max;
     if(nsize < (float)0 ) nsize = (float)0;
     nratio =  nsize / (float)max;
-    
+
     fvalue = (int)((float)THIS.maximum -
         (float)THIS.minimum) * (float)nsize / (float)max;
     fvalue = (int)((float)THIS.maximum -
         (float)THIS.minimum) * (float)nsize / (float)max;
-    value = round(fvalue);
-    
+    value = wxRound(fvalue);
+
     THIS.value = value;
     THIS.oldx = x;
     THIS.oldy = y;
     THIS.value = value;
     THIS.oldx = x;
     THIS.oldy = y;
-    
+
     /* clear old slider only if it was larger */
     DrawSlider(gw, (nsize < size));
     /* clear old slider only if it was larger */
     DrawSlider(gw, (nsize < size));
-    
+
     {
         XmGaugeCallbackStruct call;
     {
         XmGaugeCallbackStruct call;
-        
+
         if(NULL  != THIS.dragCallback) {
             call.reason = XmCR_DRAG;
             call.event = e;
         if(NULL  != THIS.dragCallback) {
             call.reason = XmCR_DRAG;
             call.event = e;
@@ -733,20 +739,20 @@ GaugeDrag(Widget w, XEvent *e, String *args, Cardinal  *num_args)
             XtCallCallbacks(w, XmNdragCallback, &call);
         }
     }
             XtCallCallbacks(w, XmNdragCallback, &call);
         }
     }
-#undef THIS    
+#undef THIS
 #endif
 }
 
 
 #endif
 }
 
 
-void 
-GaugeDrop(Widget w, XEvent *e, String *args, Cardinal  *num_args)
+void
+GaugeDrop(Widget WXUNUSED(w), XEvent *WXUNUSED(e), String *WXUNUSED(args), Cardinal  *WXUNUSED(num_args))
 {
 {
-    /* Commented out for a read-only gauge in wxWindows */
+    /* Commented out for a read-only gauge in wxWidgets */
 #if 0
     XmGaugeWidget gw = (XmGaugeWidget)w;
 #define THIS gw->gauge
     if( ! THIS.dragging) return;
 #if 0
     XmGaugeWidget gw = (XmGaugeWidget)w;
 #define THIS gw->gauge
     if( ! THIS.dragging) return;
-    
+
     if(NULL  != THIS.valueChangedCallback) {
         XmGaugeCallbackStruct call;
         call.reason = XmCR_VALUE_CHANGED;
     if(NULL  != THIS.valueChangedCallback) {
         XmGaugeCallbackStruct call;
         call.reason = XmCR_VALUE_CHANGED;
@@ -755,7 +761,7 @@ GaugeDrop(Widget w, XEvent *e, String *args, Cardinal  *num_args)
         XtCallCallbacks(w, XmNvalueChangedCallback, &call);
     }
     THIS.dragging = False;
         XtCallCallbacks(w, XmNvalueChangedCallback, &call);
     }
     THIS.dragging = False;
-#undef THIS    
+#undef THIS
 #endif
 }
 
 #endif
 }
 
@@ -763,7 +769,7 @@ void
 XmGaugeSetValue(Widget w, int value)
 {
     XmGaugeWidget gw = (XmGaugeWidget)w;
 XmGaugeSetValue(Widget w, int value)
 {
     XmGaugeWidget gw = (XmGaugeWidget)w;
-    
+
     gw->gauge.value = value;
     DrawSlider(gw, True);
     XFlush(XtDisplay(w));
     gw->gauge.value = value;
     DrawSlider(gw, True);
     XFlush(XtDisplay(w));
@@ -771,8 +777,10 @@ XmGaugeSetValue(Widget w, int value)
 
 int
 XmGaugeGetValue(Widget w)
 
 int
 XmGaugeGetValue(Widget w)
-{    
+{
     XmGaugeWidget gw = (XmGaugeWidget)w;
     XmGaugeWidget gw = (XmGaugeWidget)w;
-    
+
     return gw->gauge.value;
 }
     return gw->gauge.value;
 }
+
+#endif // !wxCHECK_MOTIF_VERSION( 2, 0 ) || wxCHECK_LESSTIF()