]> git.saurik.com Git - wxWidgets.git/blobdiff - src/motif/gauge.cpp
Fix wxEncodingConverter::Convert(wchar_t) documentation.
[wxWidgets.git] / src / motif / gauge.cpp
index f7c6a70d2e776fb06966896998e36db024c5686c..c63649ca06fe25ad47ac02fafc428868094a45a0 100644 (file)
@@ -1,31 +1,36 @@
 /////////////////////////////////////////////////////////////////////////////
 /////////////////////////////////////////////////////////////////////////////
-// 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
 /////////////////////////////////////////////////////////////////////////////
 
 /////////////////////////////////////////////////////////////////////////////
 
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
-#pragma implementation "gauge.h"
-#endif
-
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 #ifdef __VMS
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 #ifdef __VMS
-#include <wx/vms_x_fix.h>
+#include "wx/vms_x_fix.h"
 #undef XtDisplay
 #undef XtScreen
 #undef XtWindow
 #undef XtIsRealized
 #undef XtParent
 #undef XtDisplay
 #undef XtScreen
 #undef XtWindow
 #undef XtIsRealized
 #undef XtParent
+#undef XtClass
 #endif
 
 #endif
 
-# include "wx/gauge.h"
+#include "wx/gauge.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/math.h"
+#endif
+
+#ifdef __OS2__
+#include <types.h>
+#endif
 
 #ifdef __VMS__
 #pragma message disable nosimpint
 
 #ifdef __VMS__
 #pragma message disable nosimpint
@@ -39,8 +44,6 @@
 #endif
 #include "wx/motif/private.h"
 
 #endif
 #include "wx/motif/private.h"
 
-IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
-
 #if !wxCHECK_MOTIF_VERSION( 2, 0 ) || wxCHECK_LESSTIF()
 
 // XmGauge copyright notice:
 #if !wxCHECK_MOTIF_VERSION( 2, 0 ) || wxCHECK_LESSTIF()
 
 // XmGauge copyright notice:
@@ -70,8 +73,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
 */
 
 //// PUBLIC XMGAUGE DECLARATIONS
 */
 
 //// 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;
@@ -104,6 +107,7 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
 {
     if( !CreateControl( parent, id, pos, size, style, validator, name ) )
         return false;
 {
     if( !CreateControl( parent, id, pos, size, style, validator, name ) )
         return false;
+    PreCreation();
 
     Widget parentWidget = (Widget) parent->GetClientWidget();
 
 
     Widget parentWidget = (Widget) parent->GetClientWidget();
 
@@ -139,17 +143,14 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
 
     int x = pos.x; int y = pos.y;
     wxSize best = GetBestSize();
 
     int x = pos.x; int y = pos.y;
     wxSize best = GetBestSize();
-    if( size.x != -1 ) best.x = size.x;
-    if( size.y != -1 ) best.y = size.y;
-
-    ChangeFont(FALSE);
+    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);
 
     AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y,
                   best.x, best.y);
 
-    ChangeBackgroundColour();
-
-    return TRUE;
+    return true;
 }
 
 wxSize wxGauge::DoGetBestSize() const
 }
 
 wxSize wxGauge::DoGetBestSize() const
@@ -220,9 +221,9 @@ typedef struct {
 } XmGaugeClassPart;
 
 typedef struct _XmGaugeClassRec {
 } XmGaugeClassPart;
 
 typedef struct _XmGaugeClassRec {
-    CoreClassPart              core_class;
-    XmPrimitiveClassPart       primitive_class;
-    XmGaugeClassPart           gauge_class;
+    CoreClassPart         core_class;
+    XmPrimitiveClassPart  primitive_class;
+    XmGaugeClassPart      gauge_class;
 } XmGaugeClassRec;
 
 
 } XmGaugeClassRec;
 
 
@@ -237,16 +238,16 @@ typedef struct _XmGaugePart{
     XtCallbackList valueChangedCallback;
 
     /* private fields */
     XtCallbackList valueChangedCallback;
 
     /* 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;
@@ -407,7 +408,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) {
@@ -426,7 +427,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:
@@ -514,7 +515,7 @@ ExposeProc(Widget w, XEvent *WXUNUSED(event), Region WXUNUSED(r))
         gw->primitive.top_shadow_GC,
         gw->primitive.bottom_shadow_GC,
         0, 0, w->core.width, w->core.height,
         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);
 #undef THIS
 }
     DrawSlider(gw, False);
 #undef THIS
 }
@@ -554,53 +555,53 @@ resources[] = {
 
 
 XmGaugeClassRec xmGaugeClassRec = {
 
 
 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;
@@ -672,8 +673,6 @@ GaugePick(Widget WXUNUSED(w), XEvent *WXUNUSED(e), String *WXUNUSED(args), Cardi
 #endif
 }
 
 #endif
 }
 
-#define round(x) ( (x) > 0 ? ((x) + 0.5) : -(-(x) + 0.5) )
-
 void
 GaugeDrag(Widget WXUNUSED(w), XEvent *WXUNUSED(e), String *WXUNUSED(args), Cardinal  *WXUNUSED(num_args))
 {
 void
 GaugeDrag(Widget WXUNUSED(w), XEvent *WXUNUSED(e), String *WXUNUSED(args), Cardinal  *WXUNUSED(num_args))
 {
@@ -719,7 +718,7 @@ GaugeDrag(Widget WXUNUSED(w), XEvent *WXUNUSED(e), String *WXUNUSED(args), Cardi
 
     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.value = value;
     THIS.oldx = x;