File: MwRuler.h

package info (click to toggle)
mowitz 0.2.0-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 4,168 kB
  • ctags: 4,214
  • sloc: ansic: 30,869; sh: 9,051; makefile: 169
file content (295 lines) | stat: -rw-r--r-- 7,670 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
/* $Id: Ruler.h,v 1.1 1999/08/27 18:33:57 falk Exp $
 *
 * This widget draws a ruler.  An arrow may be drawn on the ruler to
 * indicate a value, typically a cursor position.  The user may also grip
 * the ruler and slide it, typically to scroll a window.
 *
 * The ruler consists of three elements:
 *	Numeric labels
 *	Tic marks
 *	An optional sliding arrow indicating a value.
 *
 * Numeric labels occur at every unit along the ruler (space
 * permitting). In addition, fractions will also be displayed between
 * the labels.
 *
 * Likewise, major tic marks will be displayed at every unit along the ruler,
 * with minor tic marks in between.
 *
 */


#ifndef _MwRuler_h
#define _MwRuler_h

#include <X11/Core.h>


/***********************************************************************
 *
 * Ruler Widget (subclass of Core)
 *
 ***********************************************************************/

/* Parameters:

 Name		     Class		RepType		Default Value
 ----		     -----		-------		-------------
 markStep	     Step		int		1
 markDiv	     Divisions		int		32
 labelStep	     Step		int		1
 labelDiv	     Divisions		int		32
 labelStyle	     LabelStyle		XtLabelStyle	Fraction
 orientation	     Orientation	int		North
 foreground	     Foreground		Pixel		XtDefaultForeground
 pointerColor	     Foreground		Pixel		XtDefaultForeground
 showPointer	     ShowPointer	Boolean		True
 minValue	     MinValue		float		0.0
 scale		     Scale		float		100.0
 value		     Value		float		0.0
 iValue		     IValue		int		0
 font		     Font		XFontStruct*	XtDefaultFont
 fracFont	     Font		XFontStruct*	font
 cursor		     Cursor		Cursor*
 internalWidth	     Width		Dimension	4
 internalHeight	     Height		Dimension	2
 callback	     Callback		XtCallbackList	NULL
 userData	     UserData		XtPointer	NULL

 background	     Background		Pixel		XtDefaultBackground
 border		     BorderColor	Pixel		XtDefaultForeground
 borderWidth	     BorderWidth	Dimension	1
 destroyCallback     Callback		Pointer		NULL
 mappedWhenManaged   MappedWhenManaged	Boolean		True
 width		     Width		Dimension	0
 height		     Height		Dimension	0
 x		     Position		Position	0
 y		     Position		Position	0

 Notes:

  * MarkStep controls how many units apart major tic marks are drawn.
    Set to zero to disable.  MarkDiv controls how many minor tic marks
    are drawn between major tic marks.  Set to zero to disable.  If there
    is not enough room for tic marks, the ruler widget will choose a
    lower value for MarkDiv and/or a higher value for MarkStep.
  * LabelStep, LabelDiv are the same, but for labels.
  * LabelStyle is either "Fraction" or "Decimal"
  * Orientation controls the orientation of the ruler.  North is horizontal
    orientation with tic marks at the bottom (useful for rulers North of
    drawing windows.)  South is horizontal with tic marks at top.  East is
    vertical with tic marks on left.  West is vertical with tic marks on right.
  * PointerColor is the color of the arrow.
  * minValue is the minimum value displayed by the ruler, shown at the left
    or top of the ruler.
  * Scale is the number of pixels per unit in the ruler.
  * Value is the ruler value indicated by the pointer.
  * Ivalue is the pointer position in pixels.  Setting Ivalue sets Value
    to the nearest approximation, and visa-versa
  * Callback is called whenever the user manipulates the ruler.  Call_data
    is a pointer to a RulerReport structure.
  * FracFont is the font to use for fractions.
  * Cursor is either XC_sb_h_double_arrow or XC_sb_v_double_arrow,
    depending on orientation.  If the ruler is insensitive, the
    cursor is None.
*/

/* New fields */

#ifndef	XtNmarkStep
#define	XtNmarkStep	"markStep"
#define	XtNlabelStep	"labelStep"
#define	XtCStep		"Step"
#define	XtNlabelStyle	"labelStyle"
#define	XtCLabelStyle	"LabelStyle"
#define	XtRLabelStyle	XtCLabelStyle
#define	XtNmarkDiv	"markDiv"
#define	XtNlabelDiv	"labelDiv"
#define	XtCDivisions	"Divisions"
#define	XtNminValue	"minValue"
#define	XtCMinValue	"MinValue"
#define	XtNscale	"scale"
#define	XtCScale	"Scale"
#define	XtNiValue	"iValue"
#define	XtCIValue	"IValue"
#endif

#ifndef	XtNorientation
#define	XtNorientation	"orientation"
#define	XtCOrientation	"Orientation"
#endif

#ifndef	XtNpointerColor
#define	XtNpointerColor	"pointerColor"
#define	XtCPointerColor	"PointerColor"
#endif

#ifndef	XtNshowPointer
#define	XtNshowPointer	"showPointer"
#define	XtCShowPointer	"ShowPointer"
#endif

#ifndef	XtNcursor
#define	XtNcursor	"cursor"
#endif

#ifndef	XtNuserData
#define	XtNuserData	"userData"
#define	XtCUserData	"UserData"
#endif

#ifndef	XtNfracFont
#define	XtNfracFont	"fracFont"
#endif

#ifndef	XtNshadowWidth
#define XtNshadowWidth "shadowWidth"
#define XtCShadowWidth "ShadowWidth"
#define XtNtopShadowPixel "topShadowPixel"
#define XtCTopShadowPixel "TopShadowPixel"
#define XtNbottomShadowPixel "bottomShadowPixel"
#define XtCBottomShadowPixel "BottomShadowPixel"
#define XtNtopShadowContrast "topShadowContrast"
#define XtCTopShadowContrast "TopShadowContrast"
#define XtNbottomShadowContrast "bottomShadowContrast"
#define XtCBottomShadowContrast "BottomShadowContrast"
#endif

#ifndef	XtNtopShadowPixmap
#define	XtNtopShadowPixmap	"topShadowPixmap"
#define	XtCTopShadowPixmap	"TopShadowPixmap"
#define	XtNbottomShadowPixmap	"bottomShadowPixmap"
#define	XtCBottomShadowPixmap	"BottomShadowPixmap"
#endif

#ifndef	XtNbeNiceToColormap
#define XtNbeNiceToColormap "beNiceToColormap"
#define XtCBeNiceToColormap "BeNiceToColormap"
#define XtNbeNiceToColourmap "beNiceToColormap"
#define XtCBeNiceToColourmap "BeNiceToColormap"
#endif

/* Class record constants */

extern WidgetClass mwRulerWidgetClass;

typedef struct _MwRulerClassRec *MwRulerWidgetClass;
typedef struct _MwRulerRec      *MwRulerWidget;

typedef	struct {
	  enum {START,SCROLL,STOP} what ;
	  float	minValue ;	/* new minValue */
	  int	dx, dy ;	/* scroll amount, pixels */
	} MwRulerReport ;

typedef	enum {FRACTION, DECIMAL} XtLabelStyle ;

_XFUNCPROTOBEGIN

extern	void			/* set minimum value and scale */
MwRulerSetMinScale(
#if NeedFunctionPrototypes
	Widget	w,
	double	minValue,
	double	scale
#endif
) ;

extern	void		/* set minimum value */
MwRulerSetMin(
#if NeedFunctionPrototypes
	Widget	w,
	double	minValue
#endif
) ;

extern	void		/* set minimum value at position other than 0 */
MwRulerSetMinPosition(
#if NeedFunctionPrototypes
	Widget	w,
	double	minValue,
	int	position
#endif
) ;

extern	void			/* set scale */
MwRulerSetScale(
#if NeedFunctionPrototypes
	Widget	w,
	double	scale
#endif
) ;

extern	double			/* get minimum value */
MwRulerGetMin(
#if NeedFunctionPrototypes
	Widget	w
#endif
) ;

extern	double			/* get scale */
MwRulerGetScale(
#if NeedFunctionPrototypes
	Widget	w
#endif
) ;

extern	void			/* set pointer value */
MwRulerSetValue(
#if NeedFunctionPrototypes
	Widget	w,
	double	value
#endif
) ;

extern	void			/* set pointer pixel position */
MwRulerSetIValue(
#if NeedFunctionPrototypes
	Widget	w,
	int	value
#endif
) ;

extern	void			/* set pointer pixel position */
MwRulerShowPointer(
#if NeedFunctionPrototypes
	Widget	w,
	Bool	show	/* true or false */
#endif
) ;

extern	double			/* get pointer value */
MwRulerGetValue(
#if NeedFunctionPrototypes
	Widget	w
#endif
) ;

extern	int			/* get pointer pixel position */
MwRulerGetIValue(
#if NeedFunctionPrototypes
	Widget	w
#endif
) ;


extern	double			/* map pixel position to value */
MwRulerPosition2Value(
#if NeedFunctionPrototypes
	Widget	w,
	int	position
#endif
) ;


extern	int			/* map value to pixel position */
MwRulerValue2Position(
#if NeedFunctionPrototypes
	Widget	w,
	double	value
#endif
) ;

_XFUNCPROTOEND

#endif /* _MwRuler_h */