+ 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()
+{
+ wxWindow::ChangeBackgroundColour();
+}
+
+void wxGauge::ChangeForegroundColour()
+{
+ wxWindow::ChangeForegroundColour();
+}
+
+//// PRIVATE DECLARATIONS FOR XMGAUGE
+
+#include <Xm/PrimitiveP.h>
+#include <Xm/DrawP.h>
+
+typedef struct {
+ int empty;
+} XmGaugeClassPart;
+
+typedef struct _XmGaugeClassRec {
+ CoreClassPart core_class;
+ XmPrimitiveClassPart primitive_class;
+ XmGaugeClassPart gauge_class;
+} XmGaugeClassRec;
+
+
+typedef struct _XmGaugePart{
+ int value;
+ int minimum;
+ int maximum;
+ unsigned char orientation;
+ unsigned char processingDirection;
+
+ XtCallbackList dragCallback;
+ XtCallbackList valueChangedCallback;
+
+ /* private fields */
+ Boolean dragging; /* drag in progress ? */
+ int oldx, oldy;
+ GC gc;
+} XmGaugePart;
+
+
+typedef struct _XmGaugeRec {
+ CorePart core;
+ XmPrimitivePart primitive;
+ XmGaugePart gauge;
+} XmGaugeRec;
+
+extern XmGaugeClassRec xmGaugeClassRec;
+
+/* Copyright 1994 GROUPE BULL -- See license conditions in file COPYRIGHT */
+
+//// XMGAUGE IMPLEMENTATION
+
+void
+GaugePick(Widget w, XEvent *e, String *args, Cardinal *num_args);
+void
+GaugeDrag(Widget w, XEvent *e, String *args, Cardinal *num_args);
+void
+GaugeDrop(Widget w, XEvent *e, String *args, Cardinal *num_args);
+
+
+
+static char translations[] =
+"<Btn1Down>: GaugePick()\n\
+ <Btn1Motion>: GaugeDrag()\n\
+ <Btn1Up>: GaugeDrop()\n\
+";
+
+
+
+static XtActionsRec actions[] = {
+ {"GaugePick", GaugePick},
+ {"GaugeDrag", GaugeDrag},
+ {"GaugeDrop", GaugeDrop},
+};
+
+static void
+DrawSlider(XmGaugeWidget gw, Boolean clear)
+{
+#define THIS gw->gauge
+ int size, sht;
+ float ratio;
+/***chubraev
+ char string[20];
+ int len;
+ unsigned long backgr,foregr;
+ XRectangle rects[1];
+***/
+
+ sht = gw->primitive.shadow_thickness;
+
+ ratio = (float)THIS.value/
+ (float)(THIS.maximum - THIS.minimum);
+/***chubraev
+ sprintf(string,"%-d%%",(int)(ratio*100));
+ 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);
+ }
+ switch(THIS.orientation) {
+ case XmHORIZONTAL:
+ size = (int) ((gw->core.width - 2 * sht)*ratio);
+ /***chubraev
+ XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2,
+gw->core.height - 2 * sht, string, len);
+ ***/
+ switch(THIS.processingDirection) {
+ case XmMAX_ON_RIGHT:
+ 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;
+ ***/
+ break;
+ case XmMAX_ON_LEFT:
+ case XmMAX_ON_TOP:
+ 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;
+ ***/
+ break;
+ }
+ /***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,
+gw->core.height - 2 * sht, string, len);
+ ***/
+
+ break;
+ case XmVERTICAL:
+ size = (int) ((gw->core.height - 2 * sht)*ratio);
+ /***chubraev
+ XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht,
+sht+gw->core.height/2, string,len);
+ ***/
+ switch(THIS.processingDirection) {
+ case XmMAX_ON_RIGHT:
+ 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;
+ ***/
+ break;
+ case XmMAX_ON_LEFT:
+ case XmMAX_ON_TOP:
+ 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
+ XSetClipRectangles(XtDisplay(gw), THIS.gc, 0, 0, rects, 1, Unsorted);
+ XSetForeground(XtDisplay(gw), THIS.gc, backgr);
+ XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht,
+sht+gw->core.height/2, string,len);
+ ***/
+ break;
+ }
+ /***chubraev
+ XSetClipMask(XtDisplay(gw), THIS.gc, None);
+ XSetForeground(XtDisplay(gw), THIS.gc, foregr);
+ ***/
+#undef THIS
+}
+
+/* Old code
+ */
+#if 0
+static void
+DrawSlider(XmGaugeWidget gw, Boolean clear)
+{
+#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 -
+ (float)THIS.minimum) / (float)THIS.value;
+*/
+ if(clear) {
+ XClearArea(XtDisplay(gw), XtWindow(gw), sht, sht,
+ gw->core.width - 2 * sht, gw->core.height - 2 * sht, False);
+ }
+ switch(THIS.orientation) {
+ case XmHORIZONTAL:
+/* 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) {
+ case XmMAX_ON_RIGHT:
+ case XmMAX_ON_BOTTOM:
+ XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
+ sht, sht, size, gw->core.height - 2 * sht);
+ break;
+ case XmMAX_ON_LEFT:
+ case XmMAX_ON_TOP:
+ XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
+ gw->core.width - size - sht, sht,
+ size, gw->core.height - 2 * sht);
+ break;
+ }
+ 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; */
+ switch(THIS.processingDirection) {
+ case XmMAX_ON_RIGHT:
+ case XmMAX_ON_BOTTOM:
+ XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
+ sht, sht, gw->core.width - 2 * sht, size);
+ break;
+ case XmMAX_ON_LEFT:
+ case XmMAX_ON_TOP:
+ XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
+ sht, gw->core.height - size - sht,
+ gw->core.width - 2 * sht, size);
+ }
+ break;
+ }
+#undef THIS
+}
+#endif
+
+static void
+Initialize(Widget req, Widget new_w, ArgList args, Cardinal *num_args )
+{
+ XmGaugeWidget gw = (XmGaugeWidget)new_w;
+#define THIS gw->gauge
+ XGCValues values;
+
+ values.foreground = gw->primitive.foreground;
+ THIS.gc = XtGetGC(new_w, GCForeground, &values);
+
+#undef THIS
+
+}
+
+
+
+static void
+Destroy(Widget w)
+{
+ XmGaugeWidget gw = (XmGaugeWidget)w;
+#define THIS gw->gauge
+ XtReleaseGC(w, THIS.gc);
+#undef THIS
+}
+
+
+
+
+static Boolean
+SetValues(
+ Widget cw,
+ Widget rw,
+ Widget nw,
+ ArgList args,
+ Cardinal *num_args )
+{
+ XmGaugeWidget cgw = (XmGaugeWidget)cw;
+ XmGaugeWidget ngw = (XmGaugeWidget)nw;
+
+ Boolean redraw = False;
+ if(cgw->primitive.foreground != ngw->primitive.foreground) {
+ XGCValues values;
+
+ redraw = True;
+ XtReleaseGC(nw, ngw->gauge.gc);
+ values.foreground = ngw->primitive.foreground;
+ ngw->gauge.gc = XtGetGC(nw, GCForeground, &values);
+ }
+ if(cgw->gauge.value != ngw->gauge.value) {
+ redraw = True;
+ }
+ return redraw;
+}
+
+
+
+
+static void
+ExposeProc(Widget w, XEvent *event, Region r)
+{
+ 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, XmSHADOW_IN);
+ DrawSlider(gw, False);
+#undef THIS