]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/motif/gauge.cpp
#ifdefed out Ole... functions for Cygwin.
[wxWidgets.git] / src / motif / gauge.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: gauge.cpp
3// Purpose: wxGauge class
4// Author: Julian Smart
5// Modified by:
6// Created: 17/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifdef __GNUG__
13#pragma implementation "gauge.h"
14#endif
15
16#include "wx/gauge.h"
17
18#include <Xm/Xm.h>
19#include <wx/motif/private.h>
20
21#if !USE_SHARED_LIBRARY
22IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
23#endif
24
25// XmGauge copyright notice:
26
27/*
28 * Copyright 1994 GROUPE BULL
29 *
30 * Permission to use, copy, modify, and distribute this software and its
31 * documentation for any purpose and without fee is hereby granted, provided
32 * that the above copyright notice appear in all copies and that both that
33 * copyright notice and this permission notice appear in supporting
34 * documentation, and that the name of GROUPE BULL not be used in advertising
35 * or publicity pertaining to distribution of the software without specific,
36 * written prior permission. GROUPE BULL makes no representations about the
37 * suitability of this software for any purpose. It is provided "as is"
38 * without express or implied warranty.
39 *
40 * GROUPE BULL disclaims all warranties with regard to this software,
41 * including all implied warranties of merchantability and fitness,
42 * in no event shall GROUPE BULL be liable for any special,
43 * indirect or consequential damages or any damages
44 * whatsoever resulting from loss of use, data or profits,
45 * whether in an action of contract, negligence or other tortious
46 * action, arising out of or in connection with the use
47 * or performance of this software.
48 *
49 */
50
51//// PUBLIC XMGAUGE DECLARATIONS
52typedef struct _XmGaugeClassRec* XmGaugeWidgetClass;
53typedef struct _XmGaugeRec* XmGaugeWidget;
54
55#ifdef __cplusplus
56extern "C" WidgetClass xmGaugeWidgetClass;
57#else
58extern WidgetClass xmGaugeWidgetClass;
59#endif
60
61typedef struct _XmGaugeCallbackStruct{
62 int reason;
63 XEvent *event;
64 int value;
65} XmGaugeCallbackStruct;
66
67
68void
69XmGaugeSetValue(Widget w, int value);
70
71int
72XmGaugeGetValue(Widget w);
73
74
75
76bool wxGauge::Create(wxWindow *parent, wxWindowID id,
77 int range,
78 const wxPoint& pos,
79 const wxSize& size,
80 long style,
81 const wxValidator& validator,
82 const wxString& name)
83{
84 SetName(name);
85 SetValidator(validator);
86 m_rangeMax = range;
87 m_windowStyle = style;
88 m_backgroundColour = parent->GetBackgroundColour();
89 m_foregroundColour = parent->GetForegroundColour();
90
91 if (parent) parent->AddChild(this);
92
93 if ( id == -1 )
94 m_windowId = (int)NewControlId();
95 else
96 m_windowId = id;
97
98 Widget parentWidget = (Widget) parent->GetClientWidget();
99
100 Arg args[4];
101 int count = 4;
102 if (style & wxHORIZONTAL)
103 {
104 XtSetArg (args[0], XmNorientation, XmHORIZONTAL);
105 XtSetArg (args[1], XmNprocessingDirection, XmMAX_ON_RIGHT);
106 }
107 else
108 {
109 XtSetArg (args[0], XmNorientation, XmVERTICAL);
110 XtSetArg (args[1], XmNprocessingDirection, XmMAX_ON_TOP);
111 }
112 XtSetArg(args[2], XmNminimum, 0);
113 XtSetArg(args[3], XmNmaximum, range);
114 Widget gaugeWidget = XtCreateManagedWidget("gauge", xmGaugeWidgetClass, parentWidget, args, count);
115 m_mainWidget = (WXWidget) gaugeWidget ;
116
117 XtManageChild (gaugeWidget);
118
119 int x = pos.x; int y = pos.y;
120 int width = size.x; int height = size.y;
121 if (width == -1)
122 width = 150;
123 if (height == -1)
124 height = 80;
125
126 m_windowFont = parent->GetFont();
127 ChangeFont(FALSE);
128
129 SetCanAddEventHandler(TRUE);
130 AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, width, height);
131
132 ChangeBackgroundColour();
133
134 return TRUE;
135}
136
137void wxGauge::SetSize(int x, int y, int width, int height, int sizeFlags)
138{
139 wxControl::SetSize(x, y, width, height, sizeFlags);
140}
141
142void wxGauge::SetShadowWidth(int w)
143{
144 if (w == 0)
145 w = 1;
146 XtVaSetValues((Widget) m_mainWidget, XmNshadowThickness, w, NULL);
147}
148
149void wxGauge::SetBezelFace(int w)
150{
151}
152
153void wxGauge::SetRange(int r)
154{
155 m_rangeMax = r;
156 XtVaSetValues((Widget) m_mainWidget, XmNmaximum, r, NULL);
157}
158
159void wxGauge::SetValue(int pos)
160{
161 m_gaugePos = pos;
162 XtVaSetValues((Widget) m_mainWidget, XmNvalue, pos, NULL);
163}
164
165int wxGauge::GetShadowWidth() const
166{
167 Dimension w;
168 XtVaGetValues((Widget) m_mainWidget, XmNshadowThickness, &w, NULL);
169 return (int)w;
170}
171
172int wxGauge::GetBezelFace() const
173{
174 return 0;
175}
176
177int wxGauge::GetRange() const
178{
179 int r;
180 XtVaGetValues((Widget) m_mainWidget, XmNmaximum, &r, NULL);
181 return (int)r;
182// return m_rangeMax;
183}
184
185int wxGauge::GetValue() const
186{
187 int pos;
188 XtVaGetValues((Widget) m_mainWidget, XmNvalue, &pos, NULL);
189 return pos;
190// return m_gaugePos;
191}
192
193void wxGauge::ChangeFont(bool keepOriginalSize)
194{
195 wxWindow::ChangeFont(keepOriginalSize);
196}
197
198void wxGauge::ChangeBackgroundColour()
199{
200 wxWindow::ChangeBackgroundColour();
201}
202
203void wxGauge::ChangeForegroundColour()
204{
205 wxWindow::ChangeForegroundColour();
206}
207
208//// PRIVATE DECLARATIONS FOR XMGAUGE
209
210#include <Xm/PrimitiveP.h>
211#include <Xm/DrawP.h>
212
213typedef struct {
214 int empty;
215} XmGaugeClassPart;
216
217typedef struct _XmGaugeClassRec {
218 CoreClassPart core_class;
219 XmPrimitiveClassPart primitive_class;
220 XmGaugeClassPart gauge_class;
221} XmGaugeClassRec;
222
223
224typedef struct _XmGaugePart{
225 int value;
226 int minimum;
227 int maximum;
228 unsigned char orientation;
229 unsigned char processingDirection;
230
231 XtCallbackList dragCallback;
232 XtCallbackList valueChangedCallback;
233
234 /* private fields */
235 Boolean dragging; /* drag in progress ? */
236 int oldx, oldy;
237 GC gc;
238} XmGaugePart;
239
240
241typedef struct _XmGaugeRec {
242 CorePart core;
243 XmPrimitivePart primitive;
244 XmGaugePart gauge;
245} XmGaugeRec;
246
247extern XmGaugeClassRec xmGaugeClassRec;
248
249/* Copyright 1994 GROUPE BULL -- See license conditions in file COPYRIGHT */
250
251//// XMGAUGE IMPLEMENTATION
252
253void
254GaugePick(Widget w, XEvent *e, String *args, Cardinal *num_args);
255void
256GaugeDrag(Widget w, XEvent *e, String *args, Cardinal *num_args);
257void
258GaugeDrop(Widget w, XEvent *e, String *args, Cardinal *num_args);
259
260
261
262static char translations[] =
263"<Btn1Down>: GaugePick()\n\
264 <Btn1Motion>: GaugeDrag()\n\
265 <Btn1Up>: GaugeDrop()\n\
266";
267
268
269
270static XtActionsRec actions[] = {
271 {"GaugePick", GaugePick},
272 {"GaugeDrag", GaugeDrag},
273 {"GaugeDrop", GaugeDrop},
274};
275
276static void
277DrawSlider(XmGaugeWidget gw, Boolean clear)
278{
279#define THIS gw->gauge
280 int size, sht;
281 float ratio;
282/***chubraev
283 char string[20];
284 int len;
285 unsigned long backgr,foregr;
286 XRectangle rects[1];
287***/
288
289 sht = gw->primitive.shadow_thickness;
290
291 ratio = (float)THIS.value/
292 (float)(THIS.maximum - THIS.minimum);
293/***chubraev
294 sprintf(string,"%-d%%",(int)(ratio*100));
295 len=strlen(string);
296 XtVaGetValues(gw,XmNbackground,&backgr,XmNforeground,&foregr,NULL);
297***/
298
299 if(clear) {
300 XClearArea(XtDisplay(gw), XtWindow(gw), sht, sht,
301 gw->core.width - 2 * sht, gw->core.height - 2 * sht, False);
302 }
303 switch(THIS.orientation) {
304 case XmHORIZONTAL:
305 size = (int) ((gw->core.width - 2 * sht)*ratio);
306 /***chubraev
307 XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2,
308gw->core.height - 2 * sht, string, len);
309 ***/
310 switch(THIS.processingDirection) {
311 case XmMAX_ON_RIGHT:
312 case XmMAX_ON_BOTTOM:
313 XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
314 sht, sht, size, gw->core.height - 2 * sht);
315
316 /***chubraev
317 rects[0].x = sht; rects[0].y = sht;
318 rects[0].width = size; rects[0].height = gw->core.height - 2 * sht;
319 ***/
320 break;
321 case XmMAX_ON_LEFT:
322 case XmMAX_ON_TOP:
323 XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
324 gw->core.width - size - sht, sht,
325 size, gw->core.height - 2 * sht);
326
327 /***chubraev
328 rects[0].x = gw->core.width - size - sht; rects[0].y = sht;
329 rects[0].width = size; rects[0].height = gw->core.height - 2 * sht;
330 ***/
331 break;
332 }
333 /***chubraev
334 XSetClipRectangles(XtDisplay(gw), THIS.gc, 0, 0, rects, 1, Unsorted);
335 XSetForeground(XtDisplay(gw), THIS.gc, backgr);
336 XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2,
337gw->core.height - 2 * sht, string, len);
338 ***/
339
340 break;
341 case XmVERTICAL:
342 size = (int) ((gw->core.height - 2 * sht)*ratio);
343 /***chubraev
344 XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht,
345sht+gw->core.height/2, string,len);
346 ***/
347 switch(THIS.processingDirection) {
348 case XmMAX_ON_RIGHT:
349 case XmMAX_ON_BOTTOM:
350 XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
351 sht, sht, gw->core.width - 2 * sht, size);
352
353 /***chubraev
354 rects[0].x = sht; rects[0].y = sht;
355 rects[0].width = gw->core.width - 2 * sht; rects[0].height = size;
356 ***/
357 break;
358 case XmMAX_ON_LEFT:
359 case XmMAX_ON_TOP:
360 XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
361 sht, gw->core.height - size - sht,
362 gw->core.width - 2 * sht, size);
363
364 /***chubraev
365 rects[0].x = sht; rects[0].y = gw->core.height - size - sht;
366 rects[0].width = gw->core.width - 2 * sht; rects[0].height = size;
367 ***/
368 }
369 /***chubraev
370 XSetClipRectangles(XtDisplay(gw), THIS.gc, 0, 0, rects, 1, Unsorted);
371 XSetForeground(XtDisplay(gw), THIS.gc, backgr);
372 XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht,
373sht+gw->core.height/2, string,len);
374 ***/
375 break;
376 }
377 /***chubraev
378 XSetClipMask(XtDisplay(gw), THIS.gc, None);
379 XSetForeground(XtDisplay(gw), THIS.gc, foregr);
380 ***/
381#undef THIS
382}
383
384/* Old code
385 */
386#if 0
387static void
388DrawSlider(XmGaugeWidget gw, Boolean clear)
389{
390#define THIS gw->gauge
391 int size, sht;
392/* float ratio; */
393
394 sht = gw->primitive.shadow_thickness;
395/* See fix comment below: can cause divide by zero error.
396 ratio = (float)((float)THIS.maximum -
397 (float)THIS.minimum) / (float)THIS.value;
398*/
399 if(clear) {
400 XClearArea(XtDisplay(gw), XtWindow(gw), sht, sht,
401 gw->core.width - 2 * sht, gw->core.height - 2 * sht, False);
402 }
403 switch(THIS.orientation) {
404 case XmHORIZONTAL:
405/* size = (gw->core.width - 2 * sht) / ratio; */
406/* A fix suggested by Dmitri Chubraev */
407 size = (gw->core.width - 2 * sht) /((float)THIS.maximum-(float)THIS.minimum)*(float)THIS.value;
408 switch(THIS.processingDirection) {
409 case XmMAX_ON_RIGHT:
410 case XmMAX_ON_BOTTOM:
411 XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
412 sht, sht, size, gw->core.height - 2 * sht);
413 break;
414 case XmMAX_ON_LEFT:
415 case XmMAX_ON_TOP:
416 XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
417 gw->core.width - size - sht, sht,
418 size, gw->core.height - 2 * sht);
419 break;
420 }
421 break;
422 case XmVERTICAL:
423 size = (gw->core.height - 2 * sht) /((float)THIS.maximum-(float)THIS.minimum)*(float)THIS.value;
424/* size = (gw->core.height - 2 * sht)/ ratio; */
425 switch(THIS.processingDirection) {
426 case XmMAX_ON_RIGHT:
427 case XmMAX_ON_BOTTOM:
428 XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
429 sht, sht, gw->core.width - 2 * sht, size);
430 break;
431 case XmMAX_ON_LEFT:
432 case XmMAX_ON_TOP:
433 XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
434 sht, gw->core.height - size - sht,
435 gw->core.width - 2 * sht, size);
436 }
437 break;
438 }
439#undef THIS
440}
441#endif
442
443static void
444Initialize(Widget req, Widget new_w, ArgList args, Cardinal *num_args )
445{
446 XmGaugeWidget gw = (XmGaugeWidget)new_w;
447#define THIS gw->gauge
448 XGCValues values;
449
450 values.foreground = gw->primitive.foreground;
451 THIS.gc = XtGetGC(new_w, GCForeground, &values);
452
453#undef THIS
454
455}
456
457
458
459static void
460Destroy(Widget w)
461{
462 XmGaugeWidget gw = (XmGaugeWidget)w;
463#define THIS gw->gauge
464 XtReleaseGC(w, THIS.gc);
465#undef THIS
466}
467
468
469
470
471static Boolean
472SetValues(
473 Widget cw,
474 Widget rw,
475 Widget nw,
476 ArgList args,
477 Cardinal *num_args )
478{
479 XmGaugeWidget cgw = (XmGaugeWidget)cw;
480 XmGaugeWidget ngw = (XmGaugeWidget)nw;
481
482 Boolean redraw = False;
483 if(cgw->primitive.foreground != ngw->primitive.foreground) {
484 XGCValues values;
485
486 redraw = True;
487 XtReleaseGC(nw, ngw->gauge.gc);
488 values.foreground = ngw->primitive.foreground;
489 ngw->gauge.gc = XtGetGC(nw, GCForeground, &values);
490 }
491 if(cgw->gauge.value != ngw->gauge.value) {
492 redraw = True;
493 }
494 return redraw;
495}
496
497
498
499
500static void
501ExposeProc(Widget w, XEvent *event, Region r)
502{
503 XmGaugeWidget gw = (XmGaugeWidget)w;
504#define THIS gw->gauge
505 int sht;
506
507 sht = gw->primitive.shadow_thickness;
508 _XmDrawShadows(XtDisplay(w), XtWindow(w),
509 gw->primitive.top_shadow_GC,
510 gw->primitive.bottom_shadow_GC,
511 0, 0, w->core.width, w->core.height,
512 sht, XmSHADOW_IN);
513 DrawSlider(gw, False);
514#undef THIS
515}
516
517
518
519
520
521static XtResource
522resources[] = {
523#define offset(field) XtOffset(XmGaugeWidget, gauge.field)
524 {XmNvalue, XmCValue, XtRInt, sizeof(int),
525 offset(value), XtRImmediate, (caddr_t)10},
526
527 {XmNminimum, XmCValue, XtRInt, sizeof(int),
528 offset(minimum), XtRImmediate, (caddr_t)0},
529
530 {XmNmaximum, XmCValue, XtRInt, sizeof(int),
531 offset(maximum), XtRImmediate, (caddr_t)100},
532
533 {XmNorientation, XmCOrientation, XmROrientation, sizeof(unsigned char),
534 offset(orientation), XtRImmediate, (caddr_t)XmVERTICAL},
535
536 {XmNprocessingDirection, XmCProcessingDirection,
537 XmRProcessingDirection, sizeof(unsigned char),
538 offset(processingDirection), XtRImmediate, (caddr_t)XmMAX_ON_RIGHT},
539
540 {XmNdragCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList),
541 offset(dragCallback), XtRImmediate, (caddr_t)NULL},
542
543 {XmNvalueChangedCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList),
544 offset(valueChangedCallback), XtRImmediate, (caddr_t)NULL},
545
546
547#undef offset
548};
549
550
551XmGaugeClassRec xmGaugeClassRec = {
552 { /* core fields */
553 (WidgetClass) &xmPrimitiveClassRec, /* superclass */
554 "XmGauge", /* class_name */
555 sizeof(XmGaugeRec), /* widget_size */
556 NULL, /* class_initialize */
557 NULL, /* class_part_initialize */
558 FALSE, /* class_inited */
559 Initialize, /* initialize */
560 NULL, /* initialize_hook */
561 XtInheritRealize, /* realize */
562 actions, /* actions */
563 XtNumber(actions), /* num_actions */
564 resources, /* resources */
565 XtNumber(resources), /* num_resources */
566 NULLQUARK, /* xrm_class */
567 TRUE, /* compress_motion */
568 TRUE, /* compress_exposure */
569 TRUE, /* compress_enterleave */
570 FALSE, /* visible_interest */
571 Destroy, /* destroy */
572 NULL, /* resize */
573 ExposeProc, /* expose */
574 SetValues, /* set_values */
575 NULL, /* set_values_hook */
576 XtInheritSetValuesAlmost, /* set_values_almost */
577 NULL, /* get_values_hook */
578 NULL, /* accept_focus */
579 XtVersion, /* version */
580 NULL, /* callback_private */
581 translations, /* tm_table */
582 NULL, /* query_geometry */
583 NULL, /* display_accelerator */
584 NULL /* extension */
585 },
586 /* primitive_class fields */
587 {
588 NULL, /* border_highlight */
589 NULL, /* border_unhighlight */
590 NULL, /* translations */
591 NULL, /* arm_and_activate */
592 NULL, /* syn_resources */
593 0, /* num_syn_resources */
594 NULL /* extension */
595 },
596 { /* gauge fields */
597 0 /* empty */
598 }
599};
600
601WidgetClass xmGaugeWidgetClass = (WidgetClass)&xmGaugeClassRec;
602
603
604
605
606void
607GaugePick(Widget w, XEvent *e, String *args, Cardinal *num_args)
608{
609/* Commented out for a read-only gauge in wxWindows */
610#if 0
611 XmGaugeWidget gw = (XmGaugeWidget)w;
612#define THIS gw->gauge
613 int size, sht;
614 float ratio;
615 Boolean dragging = False;
616 XButtonEvent *event = (XButtonEvent *)e;
617 int x, y;
618
619 x = event->x;
620 y = event->y;
621 sht = gw->primitive.shadow_thickness;
622 _XmDrawShadows(XtDisplay(w), XtWindow(w),
623 gw->primitive.top_shadow_GC,
624 gw->primitive.bottom_shadow_GC,
625 0, 0, w->core.width, w->core.height,
626 sht, XmSHADOW_IN);
627
628
629 ratio = (float)((float)THIS.maximum -
630 (float)THIS.minimum) / (float)THIS.value;
631 switch(THIS.orientation) {
632 case XmHORIZONTAL:
633 size = (w->core.width - 2 * sht) / ratio;
634 switch(THIS.processingDirection) {
635 case XmMAX_ON_RIGHT:
636 case XmMAX_ON_BOTTOM:
637 dragging = (x > sht) && (y > sht) &&
638 (x < sht + size) && (y < w->core.height - sht);
639 break;
640 case XmMAX_ON_LEFT:
641 case XmMAX_ON_TOP:
642 dragging = (x > w->core.width - size - sht) && (y > sht) &&
643 (x < w->core.width - sht) && (y < w->core.height + sht);
644 break;
645 }
646 break;
647 case XmVERTICAL:
648 size = (w->core.height - 2 * sht) / ratio;
649 switch(THIS.processingDirection) {
650 case XmMAX_ON_RIGHT:
651 case XmMAX_ON_BOTTOM:
652 dragging = (x > sht) && (y > sht) &&
653 (x < w->core.width - sht) &&
654 (y < w->core.width - 2 * sht + size);
655 break;
656 case XmMAX_ON_LEFT:
657 case XmMAX_ON_TOP:
658 dragging = (x > sht) && (y > w->core.height - size - sht) &&
659 (x < w->core.width - sht) && (y < w->core.height - sht);
660 }
661 break;
662 }
663 THIS.dragging = dragging;
664 THIS.oldx = x;
665 THIS.oldy = y;
666#undef THIS
667#endif
668}
669
670#define round(x) ( (x) > 0 ? ((x) + 0.5) : -(-(x) + 0.5) )
671
672void
673GaugeDrag(Widget w, XEvent *e, String *args, Cardinal *num_args)
674{
675/* Commented out for a read-only gauge in wxWindows */
676#if 0
677 XmGaugeWidget gw = (XmGaugeWidget)w;
678#define THIS gw->gauge
679 int sht, x, y, max, value;
680 float ratio, nratio, size, nsize, fvalue, delta;
681 XMotionEvent *event = (XMotionEvent *)e;
682
683 if( ! THIS.dragging) return;
684
685 x = event->x;
686 y = event->y;
687 sht = gw->primitive.shadow_thickness;
688
689 ratio = (float)THIS.value / (float)((float)THIS.maximum -
690 (float)THIS.minimum);
691 switch(THIS.orientation) {
692 case XmHORIZONTAL:
693 max = (w->core.width - 2 * sht);
694 size = (float)max * ratio;
695 delta = (float)x - (float)THIS.oldx;
696 break;
697 case XmVERTICAL:
698 max = (w->core.height - 2 * sht);
699 size = (float) max * ratio;
700 delta = (float)y - (float)THIS.oldy;
701 break;
702 }
703 switch(THIS.processingDirection) {
704 case XmMAX_ON_RIGHT:
705 case XmMAX_ON_BOTTOM:
706 nsize = size + delta;
707 break;
708 default:
709 nsize = size - delta;
710 }
711 if(nsize > (float)max) nsize = (float)max;
712 if(nsize < (float)0 ) nsize = (float)0;
713 nratio = nsize / (float)max;
714
715 fvalue = (int)((float)THIS.maximum -
716 (float)THIS.minimum) * (float)nsize / (float)max;
717 value = round(fvalue);
718
719 THIS.value = value;
720 THIS.oldx = x;
721 THIS.oldy = y;
722
723 /* clear old slider only if it was larger */
724 DrawSlider(gw, (nsize < size));
725
726 {
727 XmGaugeCallbackStruct call;
728
729 if(NULL != THIS.dragCallback) {
730 call.reason = XmCR_DRAG;
731 call.event = e;
732 call.value = THIS.value;
733 XtCallCallbacks(w, XmNdragCallback, &call);
734 }
735 }
736#undef THIS
737#endif
738}
739
740
741void
742GaugeDrop(Widget w, XEvent *e, String *args, Cardinal *num_args)
743{
744/* Commented out for a read-only gauge in wxWindows */
745#if 0
746 XmGaugeWidget gw = (XmGaugeWidget)w;
747#define THIS gw->gauge
748 if( ! THIS.dragging) return;
749
750 if(NULL != THIS.valueChangedCallback) {
751 XmGaugeCallbackStruct call;
752 call.reason = XmCR_VALUE_CHANGED;
753 call.event = e;
754 call.value = THIS.value;
755 XtCallCallbacks(w, XmNvalueChangedCallback, &call);
756 }
757 THIS.dragging = False;
758#undef THIS
759#endif
760}
761
762void
763XmGaugeSetValue(Widget w, int value)
764{
765 XmGaugeWidget gw = (XmGaugeWidget)w;
766
767 gw->gauge.value = value;
768 DrawSlider(gw, True);
769 XFlush(XtDisplay(w));
770}
771
772int
773XmGaugeGetValue(Widget w)
774{
775 XmGaugeWidget gw = (XmGaugeWidget)w;
776
777 return gw->gauge.value;
778}