annotate lwlib/xlwgauge.c @ 5167:e374ea766cc1

clean up, rearrange allocation statistics code -------------------- ChangeLog entries follow: -------------------- src/ChangeLog addition: 2010-03-21 Ben Wing <ben@xemacs.org> * alloc.c: * alloc.c (assert_proper_sizing): * alloc.c (c_readonly): * alloc.c (malloced_storage_size): * alloc.c (fixed_type_block_overhead): * alloc.c (lisp_object_storage_size): * alloc.c (inc_lrecord_stats): * alloc.c (dec_lrecord_stats): * alloc.c (pluralize_word): * alloc.c (object_memory_usage_stats): * alloc.c (Fobject_memory_usage): * alloc.c (compute_memusage_stats_length): * alloc.c (disksave_object_finalization_1): * alloc.c (Fgarbage_collect): * mc-alloc.c: * mc-alloc.c (mc_alloced_storage_size): * mc-alloc.h: No functionality change here. Collect the allocations-statistics code that was scattered throughout alloc.c into one place. Add remaining section headings so that all sections have headings clearly identifying the start of the section and its purpose. Expose mc_alloced_storage_size() even when not MEMORY_USAGE_STATS; this fixes build problems and is related to the export of lisp_object_storage_size() and malloced_storage_size() when non-MEMORY_USAGE_STATS in the previous change set.
author Ben Wing <ben@xemacs.org>
date Sun, 21 Mar 2010 04:41:49 -0500
parents 8b63e21b0436
children 308d34e9f07d
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
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
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
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
9 later version.
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
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
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 /* Synched up with: Gauge.c 1.2 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
22
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 * Gauge.c - Gauge widget
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
25 *
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
26 * Author: Edward A. Falk
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
27 * falk@falconer.vip.best.com
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
28 *
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
29 * Date: July 9, 1997
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
30 *
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
31 * Note: for fun and demonstration purposes, I have added selection
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
32 * capabilities to this widget. If you select the widget, you create
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
33 * a primary selection containing the current value of the widget in
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
34 * both integer and string form. If you copy into the widget, the
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
35 * primary selection is converted to an integer value and the gauge is
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
36 * set to that value.
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
37 */
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 /* TODO: display time instead of value
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
40 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
41
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
42 #define DEF_LEN 50 /* default width (or height for vertical gauge) */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
43 #define MIN_LEN 10 /* minimum reasonable width (height) */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
44 #define TIC_LEN 6 /* length of tic marks */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
45 #define GA_WID 3 /* width of gauge */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
46 #define MS_PER_SEC 1000
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
47
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
48 #include <config.h>
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
49 #include <stdlib.h>
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
50 #include <stdio.h>
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
51 #include <ctype.h>
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
52 #include <X11/IntrinsicP.h>
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
53 #include <X11/Xatom.h>
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
54 #include <X11/StringDefs.h>
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
55 #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
56 #include "xt-wrappers.h"
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
57 #include "xlwgaugeP.h"
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
58 #include <X11/Xmu/Atoms.h>
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
59 #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
60 #include <X11/Xmu/Misc.h>
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
61 #include <X11/Xmu/StdSel.h>
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 /****************************************************************
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 * Gauge resources
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
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
70
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
71 static char defaultTranslations[] =
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
72 "<Btn1Up>: select()\n\
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
73 <Key>F1: select(CLIPBOARD)\n\
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
74 <Btn2Up>: paste()\n\
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
75 <Key>F2: paste(CLIPBOARD)" ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
76
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
77
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
78
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
79 #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
80 #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
81 Xt_RESOURCE (name, _class, intrepr, type, offset(member), extrepr, value)
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
82 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
83 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
84 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
85 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
86 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
87 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
88 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
89 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
90 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
91 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 (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
93 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
94 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
95 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
96 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
97 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
98 XtRImmediate, NULL),
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
99 };
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
100 #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
101 #undef res
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
102
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 /* member functions */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
105
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
106 static void GaugeClassInit (void);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
107 static void GaugeInit (Widget, Widget, ArgList, Cardinal *);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
108 static void GaugeDestroy (Widget);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
109 static void GaugeResize (Widget);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
110 static void GaugeExpose (Widget, XEvent *, Region);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
111 static Boolean GaugeSetValues (Widget, Widget, Widget, ArgList, Cardinal *);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
112 static XtGeometryResult GaugeQueryGeometry (Widget, XtWidgetGeometry *,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
113 XtWidgetGeometry *);
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 /* action procs */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
116
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
117 static void GaugeSelect (Widget, XEvent *, String *, Cardinal *);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
118 static void GaugePaste (Widget, XEvent *, String *, Cardinal *);
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 /* internal privates */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
121
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
122 static void GaugeSize (GaugeWidget, Dimension *, Dimension *, Dimension);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
123 static void MaxLabel (GaugeWidget, Dimension *, Dimension *,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
124 Dimension *, Dimension *);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
125 static void AutoScale (GaugeWidget);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
126 static void EnableUpdate (GaugeWidget);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
127 static void DisableUpdate (GaugeWidget);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
128
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
129 static void GaugeGetValue (XtPointer, XtIntervalId *);
3968
16b17fd1dc93 [xemacs-hg @ 2007-05-20 15:56:30 by stephent]
stephent
parents: 3374
diff changeset
130 static void GaugeMercury (Display *, Window, GC, GaugeWidget, int, int);
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
131
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
132 static Boolean GaugeConvert (Widget, Atom *, Atom *, Atom *,
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
133 XtPointer *, unsigned long *, int *);
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
134 static void GaugeLoseSel (Widget, Atom *);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
135 static void GaugeDoneSel (Widget, Atom *, Atom *);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
136 static void GaugeGetSelCB (Widget, XtPointer, Atom *, Atom *,
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
137 XtPointer, unsigned long *, int *);
424
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 static GC Get_GC (GaugeWidget, Pixel);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
140
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
141
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
142 static XtActionsRec actionsList[] =
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
143 {
4528
726060ee587c First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents: 4522
diff changeset
144 { (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
145 { (String) "paste", GaugePaste },
424
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 /****************************************************************
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 * Full class record constant
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 ****************************************************************/
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
155
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
156 GaugeClassRec gaugeClassRec = {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
157 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
158 /* core_class fields */
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
159 /* 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
160 /* class_name */ (String) "Gauge",
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
161 /* widget_size */ sizeof(GaugeRec),
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
162 /* class_initialize */ GaugeClassInit,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
163 /* class_part_initialize */ NULL,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
164 /* class_inited */ FALSE,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
165 /* initialize */ GaugeInit,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
166 /* initialize_hook */ NULL,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
167 /* realize */ XtInheritRealize, /* TODO? */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
168 /* actions */ actionsList,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
169 /* num_actions */ XtNumber(actionsList),
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
170 /* resources */ resources,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
171 /* num_resources */ XtNumber(resources),
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
172 /* xrm_class */ NULLQUARK,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
173 /* compress_motion */ TRUE,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
174 /* compress_exposure */ TRUE,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
175 /* compress_enterleave */ TRUE,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
176 /* visible_interest */ FALSE,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
177 /* destroy */ GaugeDestroy,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
178 /* resize */ GaugeResize,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
179 /* expose */ GaugeExpose,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
180 /* set_values */ GaugeSetValues,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
181 /* set_values_hook */ NULL,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
182 /* set_values_almost */ XtInheritSetValuesAlmost,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
183 /* get_values_hook */ NULL,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
184 /* accept_focus */ NULL,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
185 /* version */ XtVersion,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
186 /* callback_private */ NULL,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
187 /* tm_table */ defaultTranslations,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
188 /* query_geometry */ GaugeQueryGeometry,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
189 /* display_accelerator */ XtInheritDisplayAccelerator,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
190 /* extension */ NULL
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 /* Simple class fields initialization */
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 /* change_sensitive */ XtInheritChangeSensitive
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
195 },
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
196 #ifdef _ThreeDP_h
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
197 /* ThreeD class fields initialization */
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 XtInheritXaw3dShadowDraw /* shadowdraw */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
200 },
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
201 #endif
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
202 /* Label class fields initialization */
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 /* ignore */ 0
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 /* Gauge class fields initialization */
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 /* extension */ NULL
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 };
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 WidgetClass gaugeWidgetClass = (WidgetClass)&gaugeClassRec;
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 /****************************************************************
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 * Member Procedures
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 ****************************************************************/
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
222
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
223 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
224 GaugeClassInit (void)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
225 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
226 XawInitializeWidgetSet();
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
227 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
228 NULL, 0) ;
424
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
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
232
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
233 /* ARGSUSED */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
234 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
235 GaugeInit (Widget request,
3055
6c9e392b4307 [xemacs-hg @ 2005-11-10 15:47:33 by crestani]
crestani
parents: 2286
diff changeset
236 Widget new_,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
237 ArgList UNUSED (args),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
238 Cardinal *UNUSED (num_args))
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
239 {
3055
6c9e392b4307 [xemacs-hg @ 2005-11-10 15:47:33 by crestani]
crestani
parents: 2286
diff changeset
240 GaugeWidget gw = (GaugeWidget) new_;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
241
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
242 if( gw->gauge.v0 == 0 && gw->gauge.v1 == 0 ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
243 gw->gauge.autoScaleUp = gw->gauge.autoScaleDown = TRUE ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
244 AutoScale(gw) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
245 }
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 size not explicitly set, set it to our preferred size now. */
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 if( request->core.width == 0 || request->core.height == 0 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
250 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
251 Dimension w,h ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
252 GaugeSize(gw, &w,&h, DEF_LEN) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
253 if( request->core.width == 0 )
3055
6c9e392b4307 [xemacs-hg @ 2005-11-10 15:47:33 by crestani]
crestani
parents: 2286
diff changeset
254 new_->core.width = w ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
255 if( request->core.height == 0 )
3055
6c9e392b4307 [xemacs-hg @ 2005-11-10 15:47:33 by crestani]
crestani
parents: 2286
diff changeset
256 new_->core.height = h ;
6c9e392b4307 [xemacs-hg @ 2005-11-10 15:47:33 by crestani]
crestani
parents: 2286
diff changeset
257 gw->core.widget_class->core_class.resize(new_) ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
258 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
259
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
260 gw->gauge.selected = None ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
261 gw->gauge.selstr = NULL ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
262
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
263 if( gw->gauge.update > 0 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
264 EnableUpdate(gw) ;
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 gw->gauge.inverse_GC = Get_GC(gw, gw->core.background_pixel) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
267 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
268
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
269 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
270 GaugeDestroy (Widget 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 GaugeWidget gw = (GaugeWidget)w;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
273
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
274 if( gw->gauge.selstr != NULL )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
275 XtFree(gw->gauge.selstr) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
276
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
277 if( gw->gauge.selected != None )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
278 XtDisownSelection(w, gw->gauge.selected, CurrentTime) ;
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 XtReleaseGC(w, gw->gauge.inverse_GC) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
281
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
282 if( gw->gauge.update > 0 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
283 DisableUpdate(gw) ;
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
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
286
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
287 /* React to size change from manager. Label widget will compute some
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
288 * internal stuff, but we need to override.
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
289 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
290
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
291 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
292 GaugeResize (Widget w)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
293 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
294 GaugeWidget gw = (GaugeWidget)w;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
295 int size ; /* height (width) of gauge */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
296 int vmargin ; /* vertical (horizontal) margin */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
297 int hmargin ; /* horizontal (vertical) margin */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
298
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
299 vmargin = gw->gauge.orientation == XtorientHorizontal ?
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
300 gw->label.internal_height : gw->label.internal_width ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
301 hmargin = gw->gauge.orientation == XtorientHorizontal ?
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
302 gw->label.internal_width : gw->label.internal_height ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
303
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
304 /* 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
305 * we're recomputing everything from scratch anyway.
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
306 */
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 /* find total height (width) of contents */
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 size = GA_WID+2 ; /* gauge itself + edges */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
311
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
312 if( gw->gauge.ntics > 1 ) /* tic marks */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
313 size += vmargin + TIC_LEN ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
314
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
315 if( gw->gauge.nlabels > 1 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
316 {
4932
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 4769
diff changeset
317 Dimension lwm, lw0=0, lw1 ;/* width of max, left, right labels */
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
318 Dimension lh ;
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 MaxLabel(gw,&lwm,&lh, &lw0,&lw1) ;
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 if( gw->gauge.orientation == XtorientHorizontal )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
323 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
324 gw->gauge.margin0 = lw0 / 2 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
325 gw->gauge.margin1 = lw1 / 2 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
326 size += lh + vmargin ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
327 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
328 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
329 {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
330 gw->gauge.margin0 =
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
331 gw->gauge.margin1 = lh / 2 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
332 size += lwm + vmargin ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
333 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
334 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
335 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
336 gw->gauge.margin0 = gw->gauge.margin1 = 0 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
337
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
338 gw->gauge.margin0 += hmargin ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
339 gw->gauge.margin1 += hmargin ;
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 /* Now distribute height (width) over components */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
342
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
343 if( gw->gauge.orientation == XtorientHorizontal )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
344 gw->gauge.gmargin = (gw->core.height-size)/2 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
345 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
346 gw->gauge.gmargin = (gw->core.width-size)/2 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
347
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
348 gw->gauge.tmargin = gw->gauge.gmargin + GA_WID+2 + vmargin ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
349 if( gw->gauge.ntics > 1 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
350 gw->gauge.lmargin = gw->gauge.tmargin + TIC_LEN + vmargin ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
351 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
352 gw->gauge.lmargin = gw->gauge.tmargin ;
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
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 * Repaint the widget window
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
357 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
358
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
359 /* ARGSUSED */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
360 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
361 GaugeExpose (Widget w,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
362 XEvent *UNUSED (event),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
363 Region UNUSED (region))
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
364 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
365 GaugeWidget gw = (GaugeWidget) w;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
366 register Display *dpy = XtDisplay(w) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
367 register Window win = XtWindow(w) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
368 GC gc; /* foreground, background */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
369 GC gctop, gcbot ; /* dark, light shadows */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
370
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
371 int len ; /* length (width or height) of widget */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
372 int e0,e1 ; /* ends of the gauge */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
373 int x ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
374 int y ; /* vertical (horizontal) position */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
375 int i ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
376 int v0 = gw->gauge.v0 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
377 int v1 = gw->gauge.v1 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
378 int value = gw->gauge.value ;
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 gc = XtIsSensitive(w) ? gw->label.normal_GC : gw->label.gray_GC ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
381
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
382
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
383 #ifdef _ThreeDP_h
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
384 gctop = gw->threeD.bot_shadow_GC ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
385 gcbot = gw->threeD.top_shadow_GC ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
386 #else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
387 gctop = gcbot = gc ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
388 #endif
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
389
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
390 if( gw->gauge.orientation == XtorientHorizontal ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
391 len = gw->core.width ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
392 } else {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
393 len = gw->core.height ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
394 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
395
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
396 /* if the gauge is selected, signify by drawing the background
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
397 * in a contrasting color.
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
398 */
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 if( gw->gauge.selected )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
401 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
402 XFillRectangle(dpy,win, gc, 0,0, w->core.width,w->core.height) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
403 gc = gw->gauge.inverse_GC ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
404 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
405
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
406 e0 = gw->gauge.margin0 ; /* left (top) end */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
407 e1 = len - gw->gauge.margin1 -1 ; /* right (bottom) end */
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 /* Draw the Gauge itself */
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 y = gw->gauge.gmargin ;
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 if( gw->gauge.orientation == XtorientHorizontal ) /* horizontal */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
414 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
415 XDrawLine(dpy,win,gctop, e0+1,y, e1-1,y) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
416 XDrawLine(dpy,win,gctop, e0,y+1, e0,y+GA_WID) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
417 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
418 XDrawLine(dpy,win,gcbot, e1,y+1, e1,y+GA_WID) ;
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 else /* vertical */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
421 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
422 XDrawLine(dpy,win,gctop, y,e0+1, y,e1-1) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
423 XDrawLine(dpy,win,gctop, y+1,e0, y+GA_WID,e0) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
424 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
425 XDrawLine(dpy,win,gcbot, y+1,e1, y+GA_WID,e1) ;
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
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 /* draw the mercury */
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 GaugeMercury(dpy, win, gc, gw, 0,value) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
432
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 if( gw->gauge.ntics > 1 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
435 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
436 y = gw->gauge.tmargin ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
437 for(i=0; i<gw->gauge.ntics; ++i)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
438 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
439 x = e0 + i*(e1-e0-1)/(gw->gauge.ntics-1) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
440 if( gw->gauge.orientation == XtorientHorizontal ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
441 XDrawLine(dpy,win,gcbot, x,y+1, x,y+TIC_LEN-2) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
442 XDrawLine(dpy,win,gcbot, x,y, x+1,y) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
443 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
444 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
445 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
446 else {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
447 XDrawLine(dpy,win,gcbot, y+1,x, y+TIC_LEN-2,x) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
448 XDrawLine(dpy,win,gcbot, y,x, y,x+1) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
449 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
450 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
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 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
454
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
455 /* draw labels */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
456 if( gw->gauge.nlabels > 1 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
457 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
458 char label[20], *s = label ;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
459 int xlen, wd,h =0 ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
460
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
461 if( gw->gauge.orientation == XtorientHorizontal )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
462 y = gw->gauge.lmargin + gw->label.font->max_bounds.ascent - 1 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
463 else {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
464 y = gw->gauge.lmargin ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
465 h = gw->label.font->max_bounds.ascent / 2 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
466 }
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 for(i=0; i<gw->gauge.nlabels; ++i)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
469 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
470 if( gw->gauge.labels == NULL )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
471 sprintf(label, "%d", v0+i*(v1 - v0)/(gw->gauge.nlabels - 1)) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
472 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
473 s = gw->gauge.labels[i] ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
474 if( s != NULL ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
475 x = e0 + i*(e1-e0-1)/(gw->gauge.nlabels-1) ;
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
476 xlen = strlen(s) ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
477 if( gw->gauge.orientation == XtorientHorizontal ) {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
478 wd = XTextWidth(gw->label.font, s, xlen) ;
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
479 XDrawString(dpy,win,gc, x-wd/2,y, s,xlen) ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
480 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
481 else {
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
482 XDrawString(dpy,win,gc, y,x+h, s,xlen) ;
424
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
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 * Set specified arguments into widget
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
492 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
493
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
494 static Boolean
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
495 GaugeSetValues (Widget old,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
496 Widget UNUSED (request),
3055
6c9e392b4307 [xemacs-hg @ 2005-11-10 15:47:33 by crestani]
crestani
parents: 2286
diff changeset
497 Widget new_,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
498 ArgList UNUSED (args),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
499 Cardinal *UNUSED (num_args))
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
500 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
501 GaugeWidget oldgw = (GaugeWidget) old;
3055
6c9e392b4307 [xemacs-hg @ 2005-11-10 15:47:33 by crestani]
crestani
parents: 2286
diff changeset
502 GaugeWidget gw = (GaugeWidget) new_;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
503 Boolean was_resized = False;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
504
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
505 if( gw->gauge.selected != None ) {
3055
6c9e392b4307 [xemacs-hg @ 2005-11-10 15:47:33 by crestani]
crestani
parents: 2286
diff changeset
506 XtDisownSelection(new_, gw->gauge.selected, CurrentTime) ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
507 gw->gauge.selected = None ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
508 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
509
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
510 /* Changes to v0,v1,labels, ntics, nlabels require resize & redraw. */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
511 /* Change to value requires redraw and possible resize if autoscale */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
512
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
513 was_resized =
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
514 gw->gauge.v0 != oldgw->gauge.v0 ||
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
515 gw->gauge.v1 != oldgw->gauge.v1 ||
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
516 gw->gauge.ntics != oldgw->gauge.ntics ||
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
517 gw->gauge.nlabels != oldgw->gauge.nlabels ||
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
518 gw->gauge.labels != oldgw->gauge.labels ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
519
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
520 if( (gw->gauge.autoScaleUp && gw->gauge.value > gw->gauge.v1) ||
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
521 (gw->gauge.autoScaleDown && gw->gauge.value < gw->gauge.v1/3 ))
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
522 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
523 AutoScale(gw) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
524 was_resized = TRUE ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
525 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
526
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
527 if( was_resized ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
528 if( gw->label.resize )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
529 GaugeSize(gw, &gw->core.width, &gw->core.height, DEF_LEN) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
530 else
3055
6c9e392b4307 [xemacs-hg @ 2005-11-10 15:47:33 by crestani]
crestani
parents: 2286
diff changeset
531 GaugeResize(new_) ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
532 }
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
533
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
534 if( gw->gauge.update != oldgw->gauge.update )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
535 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
536 if( gw->gauge.update > 0 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
537 EnableUpdate(gw) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
538 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
539 DisableUpdate(gw) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
540 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
541
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
542 if( gw->core.background_pixel != oldgw->core.background_pixel )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
543 {
3055
6c9e392b4307 [xemacs-hg @ 2005-11-10 15:47:33 by crestani]
crestani
parents: 2286
diff changeset
544 XtReleaseGC(new_, gw->gauge.inverse_GC) ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
545 gw->gauge.inverse_GC = Get_GC(gw, gw->core.background_pixel) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
546 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
547
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
548 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
549 XtIsSensitive(old) != XtIsSensitive(new_);
424
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
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
552
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
553 static XtGeometryResult
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
554 GaugeQueryGeometry (Widget w,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
555 XtWidgetGeometry *intended,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
556 XtWidgetGeometry *preferred)
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 register GaugeWidget gw = (GaugeWidget)w;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
559
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
560 if( intended->width == w->core.width &&
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
561 intended->height == w->core.height )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
562 return XtGeometryNo ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
563
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
564 preferred->request_mode = CWWidth | CWHeight;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
565 GaugeSize(gw, &preferred->width, &preferred->height, DEF_LEN) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
566
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
567 if( (!(intended->request_mode & CWWidth) ||
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
568 intended->width >= preferred->width) &&
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
569 (!(intended->request_mode & CWHeight) ||
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
570 intended->height >= preferred->height) )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
571 return XtGeometryYes;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
572 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
573 return XtGeometryAlmost;
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 /****************************************************************
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 * Action Procedures
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 ****************************************************************/
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
584
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
585 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
586 GaugeSelect (Widget w,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
587 XEvent *event,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
588 String *params,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
589 Cardinal *num_params)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
590 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
591 GaugeWidget gw = (GaugeWidget)w ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
592 Atom seln = XA_PRIMARY ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
593
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
594 if( gw->gauge.selected != None ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
595 XtDisownSelection(w, gw->gauge.selected, CurrentTime) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
596 gw->gauge.selected = None ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
597 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
598
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
599 if( *num_params > 0 ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
600 seln = XInternAtom(XtDisplay(w), params[0], False) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
601 printf("atom %s is %ld\n", params[0], seln) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
602 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
603
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
604 if( ! XtOwnSelection(w, seln, event->xbutton.time, GaugeConvert,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
605 GaugeLoseSel, GaugeDoneSel) )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
606 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
607 /* in real code, this error message would be replaced by
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
608 * something more elegant, or at least deleted
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
609 */
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 fprintf(stderr, "Gauge failed to get selection, try again\n") ;
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 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
614 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
615 gw->gauge.selected = TRUE ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
616 gw->gauge.selstr = (String)XtMalloc(4*sizeof(int)) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
617 sprintf(gw->gauge.selstr, "%d", gw->gauge.value) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
618 GaugeExpose(w,0,0) ;
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
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
622
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
623 static Boolean
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
624 GaugeConvert (Widget w,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
625 Atom *selection, /* usually XA_PRIMARY */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
626 Atom *target, /* requested target */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
627 Atom *type, /* returned type */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
628 XtPointer *value, /* returned value */
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
629 unsigned long *length, /* returned length */
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
630 int *format) /* returned format */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
631 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
632 GaugeWidget gw = (GaugeWidget)w ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
633 XSelectionRequestEvent *req ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
634
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
635 printf( "requesting selection %s:%s\n",
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
636 XGetAtomName(XtDisplay(w),*selection),
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
637 XGetAtomName(XtDisplay(w),*target));
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
638
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
639 if( *target == XA_TARGETS(XtDisplay(w)) )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
640 {
2271
0dfff19d20da [xemacs-hg @ 2004-09-14 20:26:40 by james]
james
parents: 647
diff changeset
641 XPointer stdTargets;
0dfff19d20da [xemacs-hg @ 2004-09-14 20:26:40 by james]
james
parents: 647
diff changeset
642 Atom *rval ;
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 442
diff changeset
643 unsigned long stdLength ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
644
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
645 /* XmuConvertStandardSelection can handle this. This function
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
646 * will return a list of standard targets. We prepend TEXT,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
647 * STRING and INTEGER to the list and return it.
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
648 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
649
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
650 req = XtGetSelectionRequest(w, *selection, NULL) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
651 XmuConvertStandardSelection(w, req->time, selection, target,
2271
0dfff19d20da [xemacs-hg @ 2004-09-14 20:26:40 by james]
james
parents: 647
diff changeset
652 type, &stdTargets, &stdLength, format) ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
653
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
654 *type = XA_ATOM ; /* TODO: needed? */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
655 *length = stdLength + 3 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
656 rval = (Atom *) XtMalloc(sizeof(Atom)*(stdLength+3)) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
657 *value = (XtPointer) rval ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
658 *rval++ = XA_INTEGER ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
659 *rval++ = XA_STRING ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
660 *rval++ = XA_TEXT(XtDisplay(w)) ;
2271
0dfff19d20da [xemacs-hg @ 2004-09-14 20:26:40 by james]
james
parents: 647
diff changeset
661 memcpy(rval, stdTargets, stdLength*sizeof(Atom)) ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
662 XtFree((char*) stdTargets) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
663 *format = 8*sizeof(Atom) ; /* TODO: needed? */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
664 return True ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
665 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
666
4769
5460287a3327 Remove support for pre-X11R5 systems, including systems without Xmu. See
Jerry James <james@xemacs.org>
parents: 4528
diff changeset
667 else if( *target == XA_INTEGER )
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
668 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
669 *type = XA_INTEGER ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
670 *length = 1 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
671 *value = (XtPointer) &gw->gauge.value ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
672 *format = 8*sizeof(int) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
673 return True ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
674 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
675
4769
5460287a3327 Remove support for pre-X11R5 systems, including systems without Xmu. See
Jerry James <james@xemacs.org>
parents: 4528
diff changeset
676 else if( *target == XA_STRING || *target == XA_TEXT(XtDisplay(w)) )
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
677 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
678 *type = *target ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
679 *length = strlen(gw->gauge.selstr)*sizeof(char) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
680 *value = (XtPointer) gw->gauge.selstr ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
681 *format = 8 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
682 return True ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
683 }
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 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
686 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
687 /* anything else, we just give it to XmuConvertStandardSelection() */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
688 req = XtGetSelectionRequest(w, *selection, NULL) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
689 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
690 type, (XPointer *) value, length, format) )
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
691 return True ;
4769
5460287a3327 Remove support for pre-X11R5 systems, including systems without Xmu. See
Jerry James <james@xemacs.org>
parents: 4528
diff changeset
692 else {
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
693 printf(
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
694 "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
695 XGetAtomName(XtDisplay(w),*selection),
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
696 XGetAtomName(XtDisplay(w),*target));
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
697 return False ;
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
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
703
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
704 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
705 GaugeLoseSel (Widget w,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
706 Atom *UNUSED (selection)) /* usually XA_PRIMARY */
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
707 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
708 GaugeWidget gw = (GaugeWidget)w ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
709 Display *dpy = XtDisplay(w) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
710 Window win = XtWindow(w) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
711
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
712 if( gw->gauge.selstr != NULL ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
713 XtFree(gw->gauge.selstr) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
714 gw->gauge.selstr = NULL ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
715 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
716
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
717 gw->gauge.selected = False ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
718 XClearWindow(dpy,win) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
719 GaugeExpose(w,0,0) ;
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
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
722
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
723 static void
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
724 GaugeDoneSel (Widget UNUSED (w),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
725 Atom *UNUSED (selection), /* usually XA_PRIMARY */
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
726 Atom *UNUSED (target)) /* requested target */
424
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 /* selection done, anything to do? */
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
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
731
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
732 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
733 GaugePaste (Widget w,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
734 XEvent *event,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
735 String *params,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
736 Cardinal *num_params)
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 Atom seln = XA_PRIMARY ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
739
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
740 if( *num_params > 0 ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
741 seln = XInternAtom(XtDisplay(w), params[0], False) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
742 printf("atom %s is %ld\n", params[0], seln) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
743 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
744
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
745 /* try for integer value first */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
746 XtGetSelectionValue(w, seln, XA_INTEGER,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
747 GaugeGetSelCB, (XtPointer)XA_INTEGER,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
748 event->xbutton.time) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
749 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
750
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
751 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
752 GaugeGetSelCB (Widget w,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
753 XtPointer client,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
754 Atom *selection,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
755 Atom *type,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
756 XtPointer value,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
757 unsigned long *UNUSED (length),
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
758 int *UNUSED (format))
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
759 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
760 Display *dpy = XtDisplay(w) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
761 Atom target = (Atom)client ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
762 int *iptr ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
763 char *cptr ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
764
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
765 if( *type == XA_INTEGER ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
766 iptr = (int *)value ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
767 XawGaugeSetValue(w, *iptr) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
768 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
769
4769
5460287a3327 Remove support for pre-X11R5 systems, including systems without Xmu. See
Jerry James <james@xemacs.org>
parents: 4528
diff changeset
770 else if( *type == XA_STRING || *type == XA_TEXT(dpy) ) {
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
771 cptr = (char *)value ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
772 XawGaugeSetValue(w, atoi(cptr)) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
773 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
774
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
775 /* failed, try string */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
776 else if( *type == None && target == XA_INTEGER )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
777 XtGetSelectionValue(w, *selection, XA_STRING,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
778 GaugeGetSelCB, (XtPointer)XA_STRING,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
779 CurrentTime) ;
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 /****************************************************************
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 * Public Procedures
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
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
790
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
791 /* Change gauge value. Only undraw or draw what needs to be
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
792 * changed.
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
793 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
794
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
795 void
3968
16b17fd1dc93 [xemacs-hg @ 2007-05-20 15:56:30 by stephent]
stephent
parents: 3374
diff changeset
796 XawGaugeSetValue (Widget w, int value)
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
797 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
798 GaugeWidget gw = (GaugeWidget)w ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
799 int oldvalue ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
800 GC gc ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
801
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
802 if( gw->gauge.selected != None ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
803 XtDisownSelection(w, gw->gauge.selected, CurrentTime) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
804 gw->gauge.selected = None ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
805 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
806
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
807 if( !XtIsRealized(w) ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
808 gw->gauge.value = value ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
809 return ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
810 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
811
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
812 /* need to rescale? */
647
b39c14581166 [xemacs-hg @ 2001-08-13 04:45:47 by ben]
ben
parents: 458
diff changeset
813 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
814 (gw->gauge.autoScaleDown && (int) value < gw->gauge.v1/3 ))
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
815 {
3374
174eb4da74fb [xemacs-hg @ 2006-05-02 15:30:31 by james]
james
parents: 3055
diff changeset
816 XtVaSetValues(w, XtNvalue, value, NULL) ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
817 return ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
818 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
819
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
820 oldvalue = gw->gauge.value ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
821 gw->gauge.value = value ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
822
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
823 gc = XtIsSensitive(w) ? gw->label.normal_GC : gw->label.gray_GC ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
824 GaugeMercury(XtDisplay(w), XtWindow(w), gc, gw, oldvalue,value) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
825 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
826
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
827
3968
16b17fd1dc93 [xemacs-hg @ 2007-05-20 15:56:30 by stephent]
stephent
parents: 3374
diff changeset
828 int
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
829 XawGaugeGetValue (Widget w)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
830 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
831 GaugeWidget gw = (GaugeWidget)w ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
832 return gw->gauge.value ;
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 /****************************************************************
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 * Private Procedures
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 ****************************************************************/
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 /* draw the mercury over a specific region */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
845
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
846 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
847 GaugeMercury (Display *dpy,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
848 Window win,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
849 GC gc,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
850 GaugeWidget gw,
3968
16b17fd1dc93 [xemacs-hg @ 2007-05-20 15:56:30 by stephent]
stephent
parents: 3374
diff changeset
851 int val0,
16b17fd1dc93 [xemacs-hg @ 2007-05-20 15:56:30 by stephent]
stephent
parents: 3374
diff changeset
852 int val1)
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
853 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
854 int v0 = gw->gauge.v0 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
855 int v1 = gw->gauge.v1 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
856 int vd = v1 - v0 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
857 Dimension len ; /* length (width or height) of gauge */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
858 Position e0, e1 ; /* gauge ends */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
859 Position p0, p1 ; /* mercury ends */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
860 int y ; /* vertical (horizontal) position */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
861 Boolean undraw = FALSE ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
862
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
863 len = gw->gauge.orientation == XtorientHorizontal ?
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
864 gw->core.width : gw->core.height ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
865
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
866 e0 = gw->gauge.margin0 ; /* left (top) end */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
867 e1 = len - gw->gauge.margin1 -1 ; /* right (bottom) end */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
868
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
869 if( vd <= 0 ) vd = 1 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
870
3968
16b17fd1dc93 [xemacs-hg @ 2007-05-20 15:56:30 by stephent]
stephent
parents: 3374
diff changeset
871 if( val0 < v0 ) val0 = v0 ;
16b17fd1dc93 [xemacs-hg @ 2007-05-20 15:56:30 by stephent]
stephent
parents: 3374
diff changeset
872 else if( val0 > v1 ) val0 = v1 ;
16b17fd1dc93 [xemacs-hg @ 2007-05-20 15:56:30 by stephent]
stephent
parents: 3374
diff changeset
873 if( val1 < v0 ) val1 = v0 ;
16b17fd1dc93 [xemacs-hg @ 2007-05-20 15:56:30 by stephent]
stephent
parents: 3374
diff changeset
874 else if( val1 > v1 ) val1 = v1 ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
875
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
876 p0 = (val0-v0)*(e1-e0-1)/vd ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
877 p1 = (val1-v0)*(e1-e0-1)/vd ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
878
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
879 if( p1 == p0 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
880 return ;
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 y = gw->gauge.gmargin ;
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 if( p1 < p0 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
885 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
886 Position tmp = p0 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
887 p0 = p1 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
888 p1 = tmp ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
889 gc = gw->label.normal_GC ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
890 XSetForeground(dpy,gc, gw->core.background_pixel) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
891 undraw = TRUE ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
892 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
893
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
894 if( gw->gauge.orientation == XtorientHorizontal )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
895 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
896 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
897 XFillRectangle(dpy,win,gc, y+1,e1-p1, GA_WID,p1-p0) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
898
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
899 if( undraw )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
900 XSetForeground(dpy,gc, gw->label.foreground) ;
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
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
904
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
905 /* Search the labels, find the largest one. */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
906 /* TODO: handle vertical fonts? */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
907
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
908 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
909 MaxLabel (GaugeWidget gw,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
910 Dimension *wid, /* max label width */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
911 Dimension *hgt, /* max label height */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
912 Dimension *w0, /* width of first label */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
913 Dimension *w1) /* width of last label */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
914 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
915 char lstr[80], *lbl ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
916 int w ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
917 XFontStruct *font = gw->label.font ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
918 int i ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
919 int lw = 0;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
920 int v0 = gw->gauge.v0 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
921 int dv = gw->gauge.v1 - v0 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
922 int n = gw->gauge.nlabels ;
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 )
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 if( --n <= 0 ) {n = 1 ; v0 += dv/2 ;}
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
927
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
928 /* loop through all labels, figure out how much room they
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
929 * need.
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
930 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
931 w = 0 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
932 for(i=0; i<gw->gauge.nlabels; ++i)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
933 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
934 if( gw->gauge.labels == NULL ) /* numeric labels */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
935 sprintf(lbl = lstr,"%d", v0 + i*dv/n) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
936 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
937 lbl = gw->gauge.labels[i] ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
938
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
939 if( lbl != NULL ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
940 lw = XTextWidth(font, lbl, strlen(lbl)) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
941 w = Max( w, lw ) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
942 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
943 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
944 lw = 0 ;
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( i == 0 && w0 != NULL ) *w0 = 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 if( w1 != NULL ) *w1 = lw ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
949
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
950 *wid = w ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
951 *hgt = font->max_bounds.ascent + font->max_bounds.descent ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
952 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
953 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
954 *wid = *hgt = 0 ;
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
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
957
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
958 /* Determine the preferred size for this widget. choose 100x100 for
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
959 * debugging.
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
960 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
961
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
962 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
963 GaugeSize (GaugeWidget gw,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
964 Dimension *wid,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
965 Dimension *hgt,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
966 Dimension min_len)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
967 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
968 int w,h ; /* width, height of gauge */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
969 int vmargin ; /* vertical margin */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
970 int hmargin ; /* horizontal margin */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
971
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
972 hmargin = gw->label.internal_width ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
973 vmargin = gw->label.internal_height ;
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 /* find total height (width) of contents */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
976
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 /* find minimum size for undecorated gauge */
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 if( gw->gauge.orientation == XtorientHorizontal )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
981 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
982 w = min_len ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
983 h = GA_WID+2 ; /* gauge itself + edges */
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 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
986 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
987 w = GA_WID+2 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
988 h = min_len ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
989 }
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.ntics > 0 )
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 if( gw->gauge.orientation == XtorientHorizontal )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
994 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
995 w = Max(w, gw->gauge.ntics*3) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
996 h += vmargin + TIC_LEN ;
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 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
999 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1000 w += hmargin + TIC_LEN ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1001 h = Max(h, gw->gauge.ntics*3) ;
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
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1005
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1006 /* If labels are requested, this gets a little interesting.
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1007 * 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
1008 * the centers of the labels evenly spaced. The labels at the ends
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1009 * will not be the same width, meaning that the gauge itself need
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1010 * not be centered in the widget.
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1011 *
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1012 * First, determine the spacing. This is the width of the widest
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1013 * label, plus the internal margin. Total length of the gauge is
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1014 * spacing * (nlabels-1). To this, we add half the width of the
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1015 * left-most label and half the width of the right-most label
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1016 * to get the entire desired width of the widget.
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1017 */
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1018 if( gw->gauge.nlabels > 0 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1019 {
4932
8b63e21b0436 fix compile issues with gcc 4
Ben Wing <ben@xemacs.org>
parents: 4769
diff changeset
1020 Dimension lwm, lw0=0, lw1 ;/* width of max, left, right labels */
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1021 Dimension lh ;
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 MaxLabel(gw,&lwm,&lh, &lw0,&lw1) ;
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 if( gw->gauge.orientation == XtorientHorizontal )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1026 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1027 lwm = (lwm+hmargin) * (gw->gauge.nlabels-1) + (lw0+lw1)/2 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1028 w = Max(w, lwm) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1029 h += lh + vmargin ;
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 else
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1032 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1033 lh = lh*gw->gauge.nlabels + (gw->gauge.nlabels - 1)*vmargin ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1034 h = Max(h, lh) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1035 w += lwm + hmargin ;
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 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1038
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1039 w += hmargin*2 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1040 h += vmargin*2 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1041
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1042 *wid = w ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1043 *hgt = h ;
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
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1047
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1048 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1049 AutoScale (GaugeWidget gw)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1050 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1051 static int scales[3] = {1,2,5} ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1052 int sptr = 0, smult=1 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1053
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1054 if( gw->gauge.autoScaleDown )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1055 gw->gauge.v1 = 0 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1056 while( gw->gauge.value > gw->gauge.v1 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1057 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1058 if( ++sptr > 2 ) {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1059 sptr = 0 ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1060 smult *= 10 ;
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 gw->gauge.v1 = scales[sptr] * smult ;
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 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1065
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1066 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1067 EnableUpdate (GaugeWidget gw)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1068 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1069 gw->gauge.intervalId =
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1070 XtAppAddTimeOut(XtWidgetToApplicationContext((Widget)gw),
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1071 gw->gauge.update * MS_PER_SEC, GaugeGetValue,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1072 (XtPointer)gw) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1073 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1074
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1075 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1076 DisableUpdate (GaugeWidget gw)
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 XtRemoveTimeOut(gw->gauge.intervalId) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1079 }
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1080
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1081 static void
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1082 GaugeGetValue (XtPointer clientData,
2286
04bc9d2f42c7 [xemacs-hg @ 2004-09-20 19:18:55 by james]
james
parents: 2271
diff changeset
1083 XtIntervalId *UNUSED (intervalId))
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1084 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1085 GaugeWidget gw = (GaugeWidget)clientData ;
3968
16b17fd1dc93 [xemacs-hg @ 2007-05-20 15:56:30 by stephent]
stephent
parents: 3374
diff changeset
1086 int value ;
424
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1087
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1088 if( gw->gauge.update > 0 )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1089 EnableUpdate(gw) ;
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 if( gw->gauge.getValue != NULL )
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1092 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1093 XtCallCallbackList((Widget)gw, gw->gauge.getValue, (XtPointer)&value);
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1094 XawGaugeSetValue((Widget)gw, value) ;
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
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1098
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1099 static GC
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1100 Get_GC (GaugeWidget gw,
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1101 Pixel fg)
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1102 {
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1103 XGCValues values ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1104 #define vmask GCForeground
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1105 #define umask (GCBackground|GCSubwindowMode|GCGraphicsExposures|GCDashOffset\
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1106 |GCFont|GCDashList|GCArcMode)
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 values.foreground = fg ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1109
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1110 return XtAllocateGC((Widget)gw, 0, vmask, &values, 0L, umask) ;
11054d720c21 Import from CVS: tag r21-2-20
cvs
parents:
diff changeset
1111 }