annotate lwlib/xlwgauge.c @ 5904:ee27ca517e90

Revise print_symbol(), never calling is{float,ratio}_string(). src/ChangeLog addition: 2015-05-08 Aidan Kehoe <kehoea@parhasard.net> * print.c (print_symbol): Revise this. No longer call isfloat_string() and isratio_string() on practically every symbol seen; check explicitly for the known float format in this function, which turns out to be a more limited and cheap job than you would think. Also check for integer and ratio syntax in passing. Use Vdigit_fixnum_map when working out whether a given character is a digit. * lisp.h: Make Vdigit_fixnum_map available generally. tests/ChangeLog addition: 2015-05-08 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-reader-tests.el: Check read and print handling of symbols that look like numbers. In passing, check the read and print handling of the associated numbers.
author Aidan Kehoe <kehoea@parhasard.net>
date Fri, 08 May 2015 14:33:46 +0100
parents 308d34e9f07d
children 574f0cded429
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1 /* Gauge Widget for XEmacs.
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
2 Copyright (C) 1999 Edward A. Falk
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
3
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
4 This file is part of XEmacs.
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
5
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4932
diff changeset
6 XEmacs is free software: you can redistribute it and/or modify it
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4932
diff changeset
8 Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4932
diff changeset
9 option) any later version.
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
10
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
14 for more details.
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
15
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 4932
diff changeset
17 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
18
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
19 /* Synched up with: Gauge.c 1.2 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
20
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
21 /*
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
22 * Gauge.c - Gauge widget
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
23 *
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
24 * Author: Edward A. Falk
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
25 * falk@falconer.vip.best.com
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
26 *
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
27 * Date: July 9, 1997
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
28 *
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
29 * Note: for fun and demonstration purposes, I have added selection
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
30 * capabilities to this widget. If you select the widget, you create
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
31 * a primary selection containing the current value of the widget in
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
32 * both integer and string form. If you copy into the widget, the
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
33 * primary selection is converted to an integer value and the gauge is
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
34 * set to that value.
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
35 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
36
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
37 /* TODO: display time instead of value
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
38 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
39
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
40 #define DEF_LEN 50 /* default width (or height for vertical gauge) */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
41 #define MIN_LEN 10 /* minimum reasonable width (height) */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
42 #define TIC_LEN 6 /* length of tic marks */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
43 #define GA_WID 3 /* width of gauge */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
44 #define MS_PER_SEC 1000
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
45
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
46 #include <config.h>
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
47 #include <stdlib.h>
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
48 #include <stdio.h>
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
49 #include <ctype.h>
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
50 #include <X11/IntrinsicP.h>
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
51 #include <X11/Xatom.h>
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
52 #include <X11/StringDefs.h>
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
53 #include ATHENA_XawInit_h_
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
54 #include "xt-wrappers.h"
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
55 #include "xlwgaugeP.h"
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
56 #include <X11/Xmu/Atoms.h>
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
57 #include <X11/Xmu/Drawing.h>
4769
5460287a3327 Remove support for pre-X11R5 systems, including systems without Xmu. See
Jerry James <james@xemacs.org>
parents: 4528
diff changeset
58 #include <X11/Xmu/Misc.h>
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
59 #include <X11/Xmu/StdSel.h>
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
60
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
61
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
62 /****************************************************************
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
63 *
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
64 * Gauge resources
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
65 *
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
66 ****************************************************************/
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
67
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
68
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
69 static char defaultTranslations[] =
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
70 "<Btn1Up>: select()\n\
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
71 <Key>F1: select(CLIPBOARD)\n\
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
72 <Btn2Up>: paste()\n\
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
73 <Key>F2: paste(CLIPBOARD)" ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
74
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
75
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
76
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
77 #define offset(field) XtOffsetOf(GaugeRec, gauge.field)
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
78 #define res(name,_class,intrepr,type,member,extrepr,value) \
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
79 Xt_RESOURCE (name, _class, intrepr, type, offset(member), extrepr, value)
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
80 static XtResource resources[] = {
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
81 res (XtNvalue, XtCValue, XtRInt, int, value, XtRImmediate, 0),
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
82 res (XtNminValue, XtCMinValue, XtRInt, int, v0, XtRImmediate, 0),
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
83 res (XtNmaxValue, XtCMaxValue, XtRInt, int, v1, XtRImmediate, 100),
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
84 res (XtNntics, XtCNTics, XtRInt, int, ntics, XtRImmediate, 0),
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
85 res (XtNnlabels, XtCNLabels, XtRInt, int, nlabels, XtRImmediate, 0),
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
86 res (XtNlabels, XtCLabels, XtRStringArray, String *, labels,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
87 XtRStringArray, NULL),
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
88 res (XtNautoScaleUp, XtCAutoScaleUp, XtRBoolean, Boolean, autoScaleUp,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
89 XtRImmediate, FALSE),
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
90 res (XtNautoScaleDown, XtCAutoScaleDown, XtRBoolean, Boolean,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
91 autoScaleDown, XtRImmediate, FALSE),
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
92 res (XtNorientation, XtCOrientation, XtROrientation, XtOrientation,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
93 orientation, XtRImmediate, XtorientHorizontal),
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
94 res (XtNupdate, XtCInterval, XtRInt, int, update, XtRImmediate, 0),
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
95 res (XtNgetValue, XtCCallback, XtRCallback, XtPointer, getValue,
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
96 XtRImmediate, NULL),
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
97 };
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
98 #undef offset
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
99 #undef res
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
100
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
101
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
102 /* member functions */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
103
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
104 static void GaugeClassInit (void);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
105 static void GaugeInit (Widget, Widget, ArgList, Cardinal *);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
106 static void GaugeDestroy (Widget);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
107 static void GaugeResize (Widget);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
108 static void GaugeExpose (Widget, XEvent *, Region);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
109 static Boolean GaugeSetValues (Widget, Widget, Widget, ArgList, Cardinal *);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
110 static XtGeometryResult GaugeQueryGeometry (Widget, XtWidgetGeometry *,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
111 XtWidgetGeometry *);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
112
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
113 /* action procs */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
114
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
115 static void GaugeSelect (Widget, XEvent *, String *, Cardinal *);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
116 static void GaugePaste (Widget, XEvent *, String *, Cardinal *);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
117
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
118 /* internal privates */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
119
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
120 static void GaugeSize (GaugeWidget, Dimension *, Dimension *, Dimension);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
121 static void MaxLabel (GaugeWidget, Dimension *, Dimension *,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
122 Dimension *, Dimension *);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
123 static void AutoScale (GaugeWidget);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
124 static void EnableUpdate (GaugeWidget);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
125 static void DisableUpdate (GaugeWidget);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
126
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
127 static void GaugeGetValue (XtPointer, XtIntervalId *);
3968
16b17fd1dc93 [xemacs-hg @ 2007-05-20 15:56:30 by stephent]
stephent
parents: 3374
diff changeset
128 static void GaugeMercury (Display *, Window, GC, GaugeWidget, int, int);
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
129
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
130 static Boolean GaugeConvert (Widget, Atom *, Atom *, Atom *,
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
131 XtPointer *, unsigned long *, int *);
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
132 static void GaugeLoseSel (Widget, Atom *);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
133 static void GaugeDoneSel (Widget, Atom *, Atom *);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
134 static void GaugeGetSelCB (Widget, XtPointer, Atom *, Atom *,
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
135 XtPointer, unsigned long *, int *);
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
136
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
137 static GC Get_GC (GaugeWidget, Pixel);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
138
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
139
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
140 static XtActionsRec actionsList[] =
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
141 {
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
142 { (String) "select", GaugeSelect },
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
143 { (String) "paste", GaugePaste },
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
144 } ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
145
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
146
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
147
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
148 /****************************************************************
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
149 *
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
150 * Full class record constant
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
151 *
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
152 ****************************************************************/
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
153
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
154 GaugeClassRec gaugeClassRec = {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
155 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
156 /* core_class fields */
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
157 /* superclass */ (WidgetClass) &labelClassRec,
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
158 /* class_name */ (String) "Gauge",
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
159 /* widget_size */ sizeof(GaugeRec),
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
160 /* class_initialize */ GaugeClassInit,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
161 /* class_part_initialize */ NULL,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
162 /* class_inited */ FALSE,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
163 /* initialize */ GaugeInit,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
164 /* initialize_hook */ NULL,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
165 /* realize */ XtInheritRealize, /* TODO? */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
166 /* actions */ actionsList,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
167 /* num_actions */ XtNumber(actionsList),
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
168 /* resources */ resources,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
169 /* num_resources */ XtNumber(resources),
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
170 /* xrm_class */ NULLQUARK,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
171 /* compress_motion */ TRUE,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
172 /* compress_exposure */ TRUE,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
173 /* compress_enterleave */ TRUE,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
174 /* visible_interest */ FALSE,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
175 /* destroy */ GaugeDestroy,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
176 /* resize */ GaugeResize,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
177 /* expose */ GaugeExpose,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
178 /* set_values */ GaugeSetValues,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
179 /* set_values_hook */ NULL,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
180 /* set_values_almost */ XtInheritSetValuesAlmost,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
181 /* get_values_hook */ NULL,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
182 /* accept_focus */ NULL,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
183 /* version */ XtVersion,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
184 /* callback_private */ NULL,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
185 /* tm_table */ defaultTranslations,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
186 /* query_geometry */ GaugeQueryGeometry,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
187 /* display_accelerator */ XtInheritDisplayAccelerator,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
188 /* extension */ NULL
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
189 },
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
190 /* Simple class fields initialization */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
191 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
192 /* change_sensitive */ XtInheritChangeSensitive
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
193 },
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
194 #ifdef _ThreeDP_h
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
195 /* ThreeD class fields initialization */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
196 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
197 XtInheritXaw3dShadowDraw /* shadowdraw */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
198 },
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
199 #endif
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
200 /* Label class fields initialization */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
201 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
202 /* ignore */ 0
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
203 },
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
204 /* Gauge class fields initialization */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
205 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
206 /* extension */ NULL
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
207 },
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
208 };
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
209
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
210 WidgetClass gaugeWidgetClass = (WidgetClass)&gaugeClassRec;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
211
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
212
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
213
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
214
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
215 /****************************************************************
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
216 *
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
217 * Member Procedures
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
218 *
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
219 ****************************************************************/
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
220
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
221 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
222 GaugeClassInit (void)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
223 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
224 XawInitializeWidgetSet();
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
225 XtAddConverter(XtRString, XtROrientation, XmuCvtStringToOrientation,
4769
5460287a3327 Remove support for pre-X11R5 systems, including systems without Xmu. See
Jerry James <james@xemacs.org>
parents: 4528
diff changeset
226 NULL, 0) ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
227 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
228
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
229
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
230
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
231 /* ARGSUSED */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
232 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
233 GaugeInit (Widget request,
3055
6c9e392b4307 [xemacs-hg @ 2005-11-10 15:47:33 by crestani]
crestani
parents: 2286
diff changeset
234 Widget new_,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
235 ArgList UNUSED (args),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
236 Cardinal *UNUSED (num_args))
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
237 {
3055
6c9e392b4307 [xemacs-hg @ 2005-11-10 15:47:33 by crestani]
crestani
parents: 2286
diff changeset
238 GaugeWidget gw = (GaugeWidget) new_;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
239
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
240 if( gw->gauge.v0 == 0 && gw->gauge.v1 == 0 ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
241 gw->gauge.autoScaleUp = gw->gauge.autoScaleDown = TRUE ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
242 AutoScale(gw) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
243 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
244
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
245 /* If size not explicitly set, set it to our preferred size now. */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
246
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
247 if( request->core.width == 0 || request->core.height == 0 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
248 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
249 Dimension w,h ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
250 GaugeSize(gw, &w,&h, DEF_LEN) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
251 if( request->core.width == 0 )
3055
6c9e392b4307 [xemacs-hg @ 2005-11-10 15:47:33 by crestani]
crestani
parents: 2286
diff changeset
252 new_->core.width = w ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
253 if( request->core.height == 0 )
3055
6c9e392b4307 [xemacs-hg @ 2005-11-10 15:47:33 by crestani]
crestani
parents: 2286
diff changeset
254 new_->core.height = h ;
6c9e392b4307 [xemacs-hg @ 2005-11-10 15:47:33 by crestani]
crestani
parents: 2286
diff changeset
255 gw->core.widget_class->core_class.resize(new_) ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
256 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
257
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
258 gw->gauge.selected = None ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
259 gw->gauge.selstr = NULL ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
260
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
261 if( gw->gauge.update > 0 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
262 EnableUpdate(gw) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
263
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
264 gw->gauge.inverse_GC = Get_GC(gw, gw->core.background_pixel) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
265 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
266
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
267 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
268 GaugeDestroy (Widget w)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
269 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
270 GaugeWidget gw = (GaugeWidget)w;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
271
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
272 if( gw->gauge.selstr != NULL )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
273 XtFree(gw->gauge.selstr) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
274
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
275 if( gw->gauge.selected != None )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
276 XtDisownSelection(w, gw->gauge.selected, CurrentTime) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
277
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
278 XtReleaseGC(w, gw->gauge.inverse_GC) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
279
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
280 if( gw->gauge.update > 0 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
281 DisableUpdate(gw) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
282 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
283
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
284
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
285 /* React to size change from manager. Label widget will compute some
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
286 * internal stuff, but we need to override.
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
287 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
288
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
289 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
290 GaugeResize (Widget w)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
291 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
292 GaugeWidget gw = (GaugeWidget)w;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
293 int size ; /* height (width) of gauge */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
294 int vmargin ; /* vertical (horizontal) margin */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
295 int hmargin ; /* horizontal (vertical) margin */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
296
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
297 vmargin = gw->gauge.orientation == XtorientHorizontal ?
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
298 gw->label.internal_height : gw->label.internal_width ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
299 hmargin = gw->gauge.orientation == XtorientHorizontal ?
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
300 gw->label.internal_width : gw->label.internal_height ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
301
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
302 /* TODO: need to call parent resize proc? I don't think so since
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
303 * we're recomputing everything from scratch anyway.
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
304 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
305
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
306 /* find total height (width) of contents */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
307
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
308 size = GA_WID+2 ; /* gauge itself + edges */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
309
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
310 if( gw->gauge.ntics > 1 ) /* tic marks */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
311 size += vmargin + TIC_LEN ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
312
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
313 if( gw->gauge.nlabels > 1 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
314 {
4932
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 4769
diff changeset
315 Dimension lwm, lw0=0, lw1 ;/* width of max, left, right labels */
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
316 Dimension lh ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
317
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
318 MaxLabel(gw,&lwm,&lh, &lw0,&lw1) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
319
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
320 if( gw->gauge.orientation == XtorientHorizontal )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
321 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
322 gw->gauge.margin0 = lw0 / 2 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
323 gw->gauge.margin1 = lw1 / 2 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
324 size += lh + vmargin ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
325 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
326 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
327 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
328 gw->gauge.margin0 =
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
329 gw->gauge.margin1 = lh / 2 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
330 size += lwm + vmargin ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
331 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
332 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
333 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
334 gw->gauge.margin0 = gw->gauge.margin1 = 0 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
335
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
336 gw->gauge.margin0 += hmargin ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
337 gw->gauge.margin1 += hmargin ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
338
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
339 /* Now distribute height (width) over components */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
340
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
341 if( gw->gauge.orientation == XtorientHorizontal )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
342 gw->gauge.gmargin = (gw->core.height-size)/2 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
343 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
344 gw->gauge.gmargin = (gw->core.width-size)/2 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
345
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
346 gw->gauge.tmargin = gw->gauge.gmargin + GA_WID+2 + vmargin ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
347 if( gw->gauge.ntics > 1 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
348 gw->gauge.lmargin = gw->gauge.tmargin + TIC_LEN + vmargin ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
349 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
350 gw->gauge.lmargin = gw->gauge.tmargin ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
351 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
352
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
353 /*
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
354 * Repaint the widget window
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
355 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
356
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
357 /* ARGSUSED */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
358 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
359 GaugeExpose (Widget w,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
360 XEvent *UNUSED (event),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
361 Region UNUSED (region))
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
362 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
363 GaugeWidget gw = (GaugeWidget) w;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
364 register Display *dpy = XtDisplay(w) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
365 register Window win = XtWindow(w) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
366 GC gc; /* foreground, background */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
367 GC gctop, gcbot ; /* dark, light shadows */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
368
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
369 int len ; /* length (width or height) of widget */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
370 int e0,e1 ; /* ends of the gauge */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
371 int x ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
372 int y ; /* vertical (horizontal) position */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
373 int i ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
374 int v0 = gw->gauge.v0 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
375 int v1 = gw->gauge.v1 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
376 int value = gw->gauge.value ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
377
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
378 gc = XtIsSensitive(w) ? gw->label.normal_GC : gw->label.gray_GC ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
379
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
380
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
381 #ifdef _ThreeDP_h
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
382 gctop = gw->threeD.bot_shadow_GC ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
383 gcbot = gw->threeD.top_shadow_GC ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
384 #else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
385 gctop = gcbot = gc ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
386 #endif
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
387
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
388 if( gw->gauge.orientation == XtorientHorizontal ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
389 len = gw->core.width ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
390 } else {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
391 len = gw->core.height ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
392 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
393
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
394 /* if the gauge is selected, signify by drawing the background
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
395 * in a contrasting color.
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
396 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
397
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
398 if( gw->gauge.selected )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
399 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
400 XFillRectangle(dpy,win, gc, 0,0, w->core.width,w->core.height) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
401 gc = gw->gauge.inverse_GC ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
402 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
403
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
404 e0 = gw->gauge.margin0 ; /* left (top) end */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
405 e1 = len - gw->gauge.margin1 -1 ; /* right (bottom) end */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
406
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
407 /* Draw the Gauge itself */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
408
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
409 y = gw->gauge.gmargin ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
410
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
411 if( gw->gauge.orientation == XtorientHorizontal ) /* horizontal */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
412 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
413 XDrawLine(dpy,win,gctop, e0+1,y, e1-1,y) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
414 XDrawLine(dpy,win,gctop, e0,y+1, e0,y+GA_WID) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
415 XDrawLine(dpy,win,gcbot, e0+1, y+GA_WID+1, e1-1, y+GA_WID+1) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
416 XDrawLine(dpy,win,gcbot, e1,y+1, e1,y+GA_WID) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
417 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
418 else /* vertical */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
419 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
420 XDrawLine(dpy,win,gctop, y,e0+1, y,e1-1) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
421 XDrawLine(dpy,win,gctop, y+1,e0, y+GA_WID,e0) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
422 XDrawLine(dpy,win,gcbot, y+GA_WID+1,e0+1, y+GA_WID+1, e1-1) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
423 XDrawLine(dpy,win,gcbot, y+1,e1, y+GA_WID,e1) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
424 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
425
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
426
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
427 /* draw the mercury */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
428
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
429 GaugeMercury(dpy, win, gc, gw, 0,value) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
430
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
431
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
432 if( gw->gauge.ntics > 1 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
433 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
434 y = gw->gauge.tmargin ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
435 for(i=0; i<gw->gauge.ntics; ++i)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
436 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
437 x = e0 + i*(e1-e0-1)/(gw->gauge.ntics-1) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
438 if( gw->gauge.orientation == XtorientHorizontal ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
439 XDrawLine(dpy,win,gcbot, x,y+1, x,y+TIC_LEN-2) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
440 XDrawLine(dpy,win,gcbot, x,y, x+1,y) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
441 XDrawLine(dpy,win,gctop, x+1,y+1, x+1,y+TIC_LEN-2) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
442 XDrawLine(dpy,win,gctop, x,y+TIC_LEN-1, x+1,y+TIC_LEN-1) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
443 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
444 else {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
445 XDrawLine(dpy,win,gcbot, y+1,x, y+TIC_LEN-2,x) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
446 XDrawLine(dpy,win,gcbot, y,x, y,x+1) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
447 XDrawLine(dpy,win,gctop, y+1,x+1, y+TIC_LEN-2,x+1) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
448 XDrawLine(dpy,win,gctop, y+TIC_LEN-1,x, y+TIC_LEN-1,x+1) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
449 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
450 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
451 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
452
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
453 /* draw labels */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
454 if( gw->gauge.nlabels > 1 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
455 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
456 char label[20], *s = label ;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
457 int xlen, wd,h =0 ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
458
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
459 if( gw->gauge.orientation == XtorientHorizontal )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
460 y = gw->gauge.lmargin + gw->label.font->max_bounds.ascent - 1 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
461 else {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
462 y = gw->gauge.lmargin ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
463 h = gw->label.font->max_bounds.ascent / 2 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
464 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
465
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
466 for(i=0; i<gw->gauge.nlabels; ++i)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
467 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
468 if( gw->gauge.labels == NULL )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
469 sprintf(label, "%d", v0+i*(v1 - v0)/(gw->gauge.nlabels - 1)) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
470 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
471 s = gw->gauge.labels[i] ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
472 if( s != NULL ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
473 x = e0 + i*(e1-e0-1)/(gw->gauge.nlabels-1) ;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
474 xlen = strlen(s) ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
475 if( gw->gauge.orientation == XtorientHorizontal ) {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
476 wd = XTextWidth(gw->label.font, s, xlen) ;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
477 XDrawString(dpy,win,gc, x-wd/2,y, s,xlen) ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
478 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
479 else {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
480 XDrawString(dpy,win,gc, y,x+h, s,xlen) ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
481 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
482 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
483 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
484 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
485 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
486
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
487
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
488 /*
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
489 * Set specified arguments into widget
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
490 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
491
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
492 static Boolean
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
493 GaugeSetValues (Widget old,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
494 Widget UNUSED (request),
3055
6c9e392b4307 [xemacs-hg @ 2005-11-10 15:47:33 by crestani]
crestani
parents: 2286
diff changeset
495 Widget new_,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
496 ArgList UNUSED (args),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
497 Cardinal *UNUSED (num_args))
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
498 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
499 GaugeWidget oldgw = (GaugeWidget) old;
3055
6c9e392b4307 [xemacs-hg @ 2005-11-10 15:47:33 by crestani]
crestani
parents: 2286
diff changeset
500 GaugeWidget gw = (GaugeWidget) new_;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
501 Boolean was_resized = False;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
502
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
503 if( gw->gauge.selected != None ) {
3055
6c9e392b4307 [xemacs-hg @ 2005-11-10 15:47:33 by crestani]
crestani
parents: 2286
diff changeset
504 XtDisownSelection(new_, gw->gauge.selected, CurrentTime) ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
505 gw->gauge.selected = None ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
506 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
507
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
508 /* Changes to v0,v1,labels, ntics, nlabels require resize & redraw. */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
509 /* Change to value requires redraw and possible resize if autoscale */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
510
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
511 was_resized =
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
512 gw->gauge.v0 != oldgw->gauge.v0 ||
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
513 gw->gauge.v1 != oldgw->gauge.v1 ||
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
514 gw->gauge.ntics != oldgw->gauge.ntics ||
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
515 gw->gauge.nlabels != oldgw->gauge.nlabels ||
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
516 gw->gauge.labels != oldgw->gauge.labels ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
517
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
518 if( (gw->gauge.autoScaleUp && gw->gauge.value > gw->gauge.v1) ||
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
519 (gw->gauge.autoScaleDown && gw->gauge.value < gw->gauge.v1/3 ))
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
520 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
521 AutoScale(gw) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
522 was_resized = TRUE ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
523 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
524
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
525 if( was_resized ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
526 if( gw->label.resize )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
527 GaugeSize(gw, &gw->core.width, &gw->core.height, DEF_LEN) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
528 else
3055
6c9e392b4307 [xemacs-hg @ 2005-11-10 15:47:33 by crestani]
crestani
parents: 2286
diff changeset
529 GaugeResize(new_) ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
530 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
531
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
532 if( gw->gauge.update != oldgw->gauge.update )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
533 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
534 if( gw->gauge.update > 0 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
535 EnableUpdate(gw) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
536 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
537 DisableUpdate(gw) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
538 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
539
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
540 if( gw->core.background_pixel != oldgw->core.background_pixel )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
541 {
3055
6c9e392b4307 [xemacs-hg @ 2005-11-10 15:47:33 by crestani]
crestani
parents: 2286
diff changeset
542 XtReleaseGC(new_, gw->gauge.inverse_GC) ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
543 gw->gauge.inverse_GC = Get_GC(gw, gw->core.background_pixel) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
544 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
545
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
546 return was_resized || gw->gauge.value != oldgw->gauge.value ||
3055
6c9e392b4307 [xemacs-hg @ 2005-11-10 15:47:33 by crestani]
crestani
parents: 2286
diff changeset
547 XtIsSensitive(old) != XtIsSensitive(new_);
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
548 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
549
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
550
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
551 static XtGeometryResult
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
552 GaugeQueryGeometry (Widget w,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
553 XtWidgetGeometry *intended,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
554 XtWidgetGeometry *preferred)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
555 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
556 register GaugeWidget gw = (GaugeWidget)w;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
557
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
558 if( intended->width == w->core.width &&
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
559 intended->height == w->core.height )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
560 return XtGeometryNo ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
561
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
562 preferred->request_mode = CWWidth | CWHeight;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
563 GaugeSize(gw, &preferred->width, &preferred->height, DEF_LEN) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
564
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
565 if( (!(intended->request_mode & CWWidth) ||
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
566 intended->width >= preferred->width) &&
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
567 (!(intended->request_mode & CWHeight) ||
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
568 intended->height >= preferred->height) )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
569 return XtGeometryYes;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
570 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
571 return XtGeometryAlmost;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
572 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
573
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
574
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
575
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
576
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
577 /****************************************************************
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
578 *
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
579 * Action Procedures
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
580 *
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
581 ****************************************************************/
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
582
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
583 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
584 GaugeSelect (Widget w,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
585 XEvent *event,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
586 String *params,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
587 Cardinal *num_params)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
588 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
589 GaugeWidget gw = (GaugeWidget)w ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
590 Atom seln = XA_PRIMARY ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
591
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
592 if( gw->gauge.selected != None ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
593 XtDisownSelection(w, gw->gauge.selected, CurrentTime) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
594 gw->gauge.selected = None ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
595 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
596
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
597 if( *num_params > 0 ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
598 seln = XInternAtom(XtDisplay(w), params[0], False) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
599 printf("atom %s is %ld\n", params[0], seln) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
600 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
601
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
602 if( ! XtOwnSelection(w, seln, event->xbutton.time, GaugeConvert,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
603 GaugeLoseSel, GaugeDoneSel) )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
604 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
605 /* in real code, this error message would be replaced by
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
606 * something more elegant, or at least deleted
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
607 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
608
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
609 fprintf(stderr, "Gauge failed to get selection, try again\n") ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
610 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
611 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
612 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
613 gw->gauge.selected = TRUE ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
614 gw->gauge.selstr = (String)XtMalloc(4*sizeof(int)) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
615 sprintf(gw->gauge.selstr, "%d", gw->gauge.value) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
616 GaugeExpose(w,0,0) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
617 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
618 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
619
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
620
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
621 static Boolean
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
622 GaugeConvert (Widget w,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
623 Atom *selection, /* usually XA_PRIMARY */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
624 Atom *target, /* requested target */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
625 Atom *type, /* returned type */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
626 XtPointer *value, /* returned value */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
627 unsigned long *length, /* returned length */
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
628 int *format) /* returned format */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
629 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
630 GaugeWidget gw = (GaugeWidget)w ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
631 XSelectionRequestEvent *req ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
632
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
633 printf( "requesting selection %s:%s\n",
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
634 XGetAtomName(XtDisplay(w),*selection),
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
635 XGetAtomName(XtDisplay(w),*target));
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
636
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
637 if( *target == XA_TARGETS(XtDisplay(w)) )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
638 {
2271
0dfff19d20da [xemacs-hg @ 2004-09-14 20:26:40 by james]
james
parents: 647
diff changeset
639 XPointer stdTargets;
0dfff19d20da [xemacs-hg @ 2004-09-14 20:26:40 by james]
james
parents: 647
diff changeset
640 Atom *rval ;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
641 unsigned long stdLength ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
642
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
643 /* XmuConvertStandardSelection can handle this. This function
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
644 * will return a list of standard targets. We prepend TEXT,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
645 * STRING and INTEGER to the list and return it.
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
646 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
647
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
648 req = XtGetSelectionRequest(w, *selection, NULL) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
649 XmuConvertStandardSelection(w, req->time, selection, target,
2271
0dfff19d20da [xemacs-hg @ 2004-09-14 20:26:40 by james]
james
parents: 647
diff changeset
650 type, &stdTargets, &stdLength, format) ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
651
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
652 *type = XA_ATOM ; /* TODO: needed? */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
653 *length = stdLength + 3 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
654 rval = (Atom *) XtMalloc(sizeof(Atom)*(stdLength+3)) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
655 *value = (XtPointer) rval ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
656 *rval++ = XA_INTEGER ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
657 *rval++ = XA_STRING ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
658 *rval++ = XA_TEXT(XtDisplay(w)) ;
2271
0dfff19d20da [xemacs-hg @ 2004-09-14 20:26:40 by james]
james
parents: 647
diff changeset
659 memcpy(rval, stdTargets, stdLength*sizeof(Atom)) ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
660 XtFree((char*) stdTargets) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
661 *format = 8*sizeof(Atom) ; /* TODO: needed? */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
662 return True ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
663 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
664
4769
5460287a3327 Remove support for pre-X11R5 systems, including systems without Xmu. See
Jerry James <james@xemacs.org>
parents: 4528
diff changeset
665 else if( *target == XA_INTEGER )
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
666 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
667 *type = XA_INTEGER ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
668 *length = 1 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
669 *value = (XtPointer) &gw->gauge.value ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
670 *format = 8*sizeof(int) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
671 return True ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
672 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
673
4769
5460287a3327 Remove support for pre-X11R5 systems, including systems without Xmu. See
Jerry James <james@xemacs.org>
parents: 4528
diff changeset
674 else if( *target == XA_STRING || *target == XA_TEXT(XtDisplay(w)) )
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
675 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
676 *type = *target ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
677 *length = strlen(gw->gauge.selstr)*sizeof(char) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
678 *value = (XtPointer) gw->gauge.selstr ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
679 *format = 8 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
680 return True ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
681 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
682
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
683 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
684 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
685 /* anything else, we just give it to XmuConvertStandardSelection() */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
686 req = XtGetSelectionRequest(w, *selection, NULL) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
687 if( XmuConvertStandardSelection(w, req->time, selection, target,
4769
5460287a3327 Remove support for pre-X11R5 systems, including systems without Xmu. See
Jerry James <james@xemacs.org>
parents: 4528
diff changeset
688 type, (XPointer *) value, length, format) )
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
689 return True ;
4769
5460287a3327 Remove support for pre-X11R5 systems, including systems without Xmu. See
Jerry James <james@xemacs.org>
parents: 4528
diff changeset
690 else {
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
691 printf(
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
692 "Gauge: requestor is requesting unsupported selection %s:%s\n",
4769
5460287a3327 Remove support for pre-X11R5 systems, including systems without Xmu. See
Jerry James <james@xemacs.org>
parents: 4528
diff changeset
693 XGetAtomName(XtDisplay(w),*selection),
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
694 XGetAtomName(XtDisplay(w),*target));
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
695 return False ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
696 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
697 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
698 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
699
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
700
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
701
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
702 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
703 GaugeLoseSel (Widget w,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
704 Atom *UNUSED (selection)) /* usually XA_PRIMARY */
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
705 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
706 GaugeWidget gw = (GaugeWidget)w ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
707 Display *dpy = XtDisplay(w) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
708 Window win = XtWindow(w) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
709
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
710 if( gw->gauge.selstr != NULL ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
711 XtFree(gw->gauge.selstr) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
712 gw->gauge.selstr = NULL ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
713 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
714
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
715 gw->gauge.selected = False ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
716 XClearWindow(dpy,win) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
717 GaugeExpose(w,0,0) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
718 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
719
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
720
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
721 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
722 GaugeDoneSel (Widget UNUSED (w),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
723 Atom *UNUSED (selection), /* usually XA_PRIMARY */
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
724 Atom *UNUSED (target)) /* requested target */
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
725 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
726 /* selection done, anything to do? */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
727 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
728
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
729
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
730 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
731 GaugePaste (Widget w,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
732 XEvent *event,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
733 String *params,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
734 Cardinal *num_params)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
735 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
736 Atom seln = XA_PRIMARY ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
737
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
738 if( *num_params > 0 ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
739 seln = XInternAtom(XtDisplay(w), params[0], False) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
740 printf("atom %s is %ld\n", params[0], seln) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
741 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
742
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
743 /* try for integer value first */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
744 XtGetSelectionValue(w, seln, XA_INTEGER,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
745 GaugeGetSelCB, (XtPointer)XA_INTEGER,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
746 event->xbutton.time) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
747 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
748
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
749 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
750 GaugeGetSelCB (Widget w,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
751 XtPointer client,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
752 Atom *selection,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
753 Atom *type,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
754 XtPointer value,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
755 unsigned long *UNUSED (length),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
756 int *UNUSED (format))
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
757 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
758 Display *dpy = XtDisplay(w) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
759 Atom target = (Atom)client ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
760 int *iptr ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
761 char *cptr ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
762
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
763 if( *type == XA_INTEGER ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
764 iptr = (int *)value ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
765 XawGaugeSetValue(w, *iptr) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
766 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
767
4769
5460287a3327 Remove support for pre-X11R5 systems, including systems without Xmu. See
Jerry James <james@xemacs.org>
parents: 4528
diff changeset
768 else if( *type == XA_STRING || *type == XA_TEXT(dpy) ) {
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
769 cptr = (char *)value ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
770 XawGaugeSetValue(w, atoi(cptr)) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
771 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
772
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
773 /* failed, try string */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
774 else if( *type == None && target == XA_INTEGER )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
775 XtGetSelectionValue(w, *selection, XA_STRING,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
776 GaugeGetSelCB, (XtPointer)XA_STRING,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
777 CurrentTime) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
778 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
779
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
780
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
781
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
782 /****************************************************************
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
783 *
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
784 * Public Procedures
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
785 *
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
786 ****************************************************************/
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
787
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
788
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
789 /* Change gauge value. Only undraw or draw what needs to be
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
790 * changed.
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
791 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
792
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
793 void
3968
16b17fd1dc93 [xemacs-hg @ 2007-05-20 15:56:30 by stephent]
stephent
parents: 3374
diff changeset
794 XawGaugeSetValue (Widget w, int value)
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
795 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
796 GaugeWidget gw = (GaugeWidget)w ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
797 int oldvalue ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
798 GC gc ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
799
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
800 if( gw->gauge.selected != None ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
801 XtDisownSelection(w, gw->gauge.selected, CurrentTime) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
802 gw->gauge.selected = None ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
803 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
804
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
805 if( !XtIsRealized(w) ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
806 gw->gauge.value = value ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
807 return ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
808 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
809
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
810 /* need to rescale? */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 458
diff changeset
811 if(( gw->gauge.autoScaleUp && (int) value > gw->gauge.v1) ||
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 458
diff changeset
812 (gw->gauge.autoScaleDown && (int) value < gw->gauge.v1/3 ))
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
813 {
3374
174eb4da74fb [xemacs-hg @ 2006-05-02 15:30:31 by james]
james
parents: 3055
diff changeset
814 XtVaSetValues(w, XtNvalue, value, NULL) ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
815 return ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
816 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
817
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
818 oldvalue = gw->gauge.value ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
819 gw->gauge.value = value ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
820
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
821 gc = XtIsSensitive(w) ? gw->label.normal_GC : gw->label.gray_GC ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
822 GaugeMercury(XtDisplay(w), XtWindow(w), gc, gw, oldvalue,value) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
823 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
824
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
825
3968
16b17fd1dc93 [xemacs-hg @ 2007-05-20 15:56:30 by stephent]
stephent
parents: 3374
diff changeset
826 int
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
827 XawGaugeGetValue (Widget w)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
828 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
829 GaugeWidget gw = (GaugeWidget)w ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
830 return gw->gauge.value ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
831 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
832
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
833
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
834
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
835
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
836 /****************************************************************
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
837 *
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
838 * Private Procedures
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
839 *
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
840 ****************************************************************/
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
841
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
842 /* draw the mercury over a specific region */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
843
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
844 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
845 GaugeMercury (Display *dpy,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
846 Window win,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
847 GC gc,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
848 GaugeWidget gw,
3968
16b17fd1dc93 [xemacs-hg @ 2007-05-20 15:56:30 by stephent]
stephent
parents: 3374
diff changeset
849 int val0,
16b17fd1dc93 [xemacs-hg @ 2007-05-20 15:56:30 by stephent]
stephent
parents: 3374
diff changeset
850 int val1)
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
851 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
852 int v0 = gw->gauge.v0 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
853 int v1 = gw->gauge.v1 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
854 int vd = v1 - v0 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
855 Dimension len ; /* length (width or height) of gauge */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
856 Position e0, e1 ; /* gauge ends */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
857 Position p0, p1 ; /* mercury ends */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
858 int y ; /* vertical (horizontal) position */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
859 Boolean undraw = FALSE ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
860
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
861 len = gw->gauge.orientation == XtorientHorizontal ?
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
862 gw->core.width : gw->core.height ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
863
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
864 e0 = gw->gauge.margin0 ; /* left (top) end */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
865 e1 = len - gw->gauge.margin1 -1 ; /* right (bottom) end */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
866
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
867 if( vd <= 0 ) vd = 1 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
868
3968
16b17fd1dc93 [xemacs-hg @ 2007-05-20 15:56:30 by stephent]
stephent
parents: 3374
diff changeset
869 if( val0 < v0 ) val0 = v0 ;
16b17fd1dc93 [xemacs-hg @ 2007-05-20 15:56:30 by stephent]
stephent
parents: 3374
diff changeset
870 else if( val0 > v1 ) val0 = v1 ;
16b17fd1dc93 [xemacs-hg @ 2007-05-20 15:56:30 by stephent]
stephent
parents: 3374
diff changeset
871 if( val1 < v0 ) val1 = v0 ;
16b17fd1dc93 [xemacs-hg @ 2007-05-20 15:56:30 by stephent]
stephent
parents: 3374
diff changeset
872 else if( val1 > v1 ) val1 = v1 ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
873
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
874 p0 = (val0-v0)*(e1-e0-1)/vd ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
875 p1 = (val1-v0)*(e1-e0-1)/vd ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
876
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
877 if( p1 == p0 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
878 return ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
879
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
880 y = gw->gauge.gmargin ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
881
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
882 if( p1 < p0 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
883 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
884 Position tmp = p0 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
885 p0 = p1 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
886 p1 = tmp ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
887 gc = gw->label.normal_GC ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
888 XSetForeground(dpy,gc, gw->core.background_pixel) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
889 undraw = TRUE ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
890 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
891
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
892 if( gw->gauge.orientation == XtorientHorizontal )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
893 XFillRectangle(dpy,win,gc, e0+p0+1,y+1, p1-p0,GA_WID) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
894 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
895 XFillRectangle(dpy,win,gc, y+1,e1-p1, GA_WID,p1-p0) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
896
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
897 if( undraw )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
898 XSetForeground(dpy,gc, gw->label.foreground) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
899 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
900
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
901
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
902
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
903 /* Search the labels, find the largest one. */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
904 /* TODO: handle vertical fonts? */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
905
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
906 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
907 MaxLabel (GaugeWidget gw,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
908 Dimension *wid, /* max label width */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
909 Dimension *hgt, /* max label height */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
910 Dimension *w0, /* width of first label */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
911 Dimension *w1) /* width of last label */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
912 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
913 char lstr[80], *lbl ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
914 int w ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
915 XFontStruct *font = gw->label.font ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
916 int i ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
917 int lw = 0;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
918 int v0 = gw->gauge.v0 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
919 int dv = gw->gauge.v1 - v0 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
920 int n = gw->gauge.nlabels ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
921
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
922 if( n > 0 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
923 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
924 if( --n <= 0 ) {n = 1 ; v0 += dv/2 ;}
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
925
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
926 /* loop through all labels, figure out how much room they
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
927 * need.
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
928 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
929 w = 0 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
930 for(i=0; i<gw->gauge.nlabels; ++i)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
931 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
932 if( gw->gauge.labels == NULL ) /* numeric labels */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
933 sprintf(lbl = lstr,"%d", v0 + i*dv/n) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
934 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
935 lbl = gw->gauge.labels[i] ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
936
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
937 if( lbl != NULL ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
938 lw = XTextWidth(font, lbl, strlen(lbl)) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
939 w = Max( w, lw ) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
940 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
941 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
942 lw = 0 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
943
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
944 if( i == 0 && w0 != NULL ) *w0 = lw ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
945 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
946 if( w1 != NULL ) *w1 = lw ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
947
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
948 *wid = w ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
949 *hgt = font->max_bounds.ascent + font->max_bounds.descent ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
950 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
951 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
952 *wid = *hgt = 0 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
953 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
954
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
955
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
956 /* Determine the preferred size for this widget. choose 100x100 for
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
957 * debugging.
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
958 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
959
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
960 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
961 GaugeSize (GaugeWidget gw,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
962 Dimension *wid,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
963 Dimension *hgt,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
964 Dimension min_len)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
965 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
966 int w,h ; /* width, height of gauge */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
967 int vmargin ; /* vertical margin */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
968 int hmargin ; /* horizontal margin */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
969
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
970 hmargin = gw->label.internal_width ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
971 vmargin = gw->label.internal_height ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
972
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
973 /* find total height (width) of contents */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
974
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
975
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
976 /* find minimum size for undecorated gauge */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
977
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
978 if( gw->gauge.orientation == XtorientHorizontal )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
979 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
980 w = min_len ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
981 h = GA_WID+2 ; /* gauge itself + edges */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
982 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
983 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
984 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
985 w = GA_WID+2 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
986 h = min_len ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
987 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
988
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
989 if( gw->gauge.ntics > 0 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
990 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
991 if( gw->gauge.orientation == XtorientHorizontal )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
992 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
993 w = Max(w, gw->gauge.ntics*3) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
994 h += vmargin + TIC_LEN ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
995 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
996 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
997 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
998 w += hmargin + TIC_LEN ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
999 h = Max(h, gw->gauge.ntics*3) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1000 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1001 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1002
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1003
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1004 /* If labels are requested, this gets a little interesting.
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1005 * We want the end labels centered on the ends of the gauge and
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1006 * the centers of the labels evenly spaced. The labels at the ends
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1007 * will not be the same width, meaning that the gauge itself need
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1008 * not be centered in the widget.
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1009 *
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1010 * First, determine the spacing. This is the width of the widest
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1011 * label, plus the internal margin. Total length of the gauge is
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1012 * spacing * (nlabels-1). To this, we add half the width of the
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1013 * left-most label and half the width of the right-most label
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1014 * to get the entire desired width of the widget.
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1015 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1016 if( gw->gauge.nlabels > 0 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1017 {
4932
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 4769
diff changeset
1018 Dimension lwm, lw0=0, lw1 ;/* width of max, left, right labels */
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1019 Dimension lh ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1020
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1021 MaxLabel(gw,&lwm,&lh, &lw0,&lw1) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1022
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1023 if( gw->gauge.orientation == XtorientHorizontal )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1024 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1025 lwm = (lwm+hmargin) * (gw->gauge.nlabels-1) + (lw0+lw1)/2 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1026 w = Max(w, lwm) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1027 h += lh + vmargin ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1028 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1029 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1030 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1031 lh = lh*gw->gauge.nlabels + (gw->gauge.nlabels - 1)*vmargin ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1032 h = Max(h, lh) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1033 w += lwm + hmargin ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1034 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1035 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1036
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1037 w += hmargin*2 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1038 h += vmargin*2 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1039
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1040 *wid = w ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1041 *hgt = h ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1042 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1043
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1044
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1045
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1046 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1047 AutoScale (GaugeWidget gw)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1048 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1049 static int scales[3] = {1,2,5} ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1050 int sptr = 0, smult=1 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1051
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1052 if( gw->gauge.autoScaleDown )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1053 gw->gauge.v1 = 0 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1054 while( gw->gauge.value > gw->gauge.v1 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1055 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1056 if( ++sptr > 2 ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1057 sptr = 0 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1058 smult *= 10 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1059 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1060 gw->gauge.v1 = scales[sptr] * smult ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1061 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1062 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1063
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1064 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1065 EnableUpdate (GaugeWidget gw)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1066 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1067 gw->gauge.intervalId =
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1068 XtAppAddTimeOut(XtWidgetToApplicationContext((Widget)gw),
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1069 gw->gauge.update * MS_PER_SEC, GaugeGetValue,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1070 (XtPointer)gw) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1071 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1072
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1073 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1074 DisableUpdate (GaugeWidget gw)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1075 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1076 XtRemoveTimeOut(gw->gauge.intervalId) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1077 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1078
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1079 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1080 GaugeGetValue (XtPointer clientData,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
1081 XtIntervalId *UNUSED (intervalId))
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1082 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1083 GaugeWidget gw = (GaugeWidget)clientData ;
3968
16b17fd1dc93 [xemacs-hg @ 2007-05-20 15:56:30 by stephent]
stephent
parents: 3374
diff changeset
1084 int value ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1085
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1086 if( gw->gauge.update > 0 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1087 EnableUpdate(gw) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1088
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1089 if( gw->gauge.getValue != NULL )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1090 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1091 XtCallCallbackList((Widget)gw, gw->gauge.getValue, (XtPointer)&value);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1092 XawGaugeSetValue((Widget)gw, value) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1093 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1094 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1095
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1096
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1097 static GC
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1098 Get_GC (GaugeWidget gw,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1099 Pixel fg)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1100 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1101 XGCValues values ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1102 #define vmask GCForeground
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1103 #define umask (GCBackground|GCSubwindowMode|GCGraphicsExposures|GCDashOffset\
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1104 |GCFont|GCDashList|GCArcMode)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1105
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1106 values.foreground = fg ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1107
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1108 return XtAllocateGC((Widget)gw, 0, vmask, &values, 0L, umask) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1109 }