1 /* $Id: Ruler.h,v 1.1 1999/08/27 18:33:57 falk Exp $ 2 * 3 * This widget draws a ruler. An arrow may be drawn on the ruler to 4 * indicate a value, typically a cursor position. The user may also grip 5 * the ruler and slide it, typically to scroll a window. 6 * 7 * The ruler consists of three elements: 8 * Numeric labels 9 * Tic marks 10 * An optional sliding arrow indicating a value. 11 * 12 * Numeric labels occur at every unit along the ruler (space 13 * permitting). In addition, fractions will also be displayed between 14 * the labels. 15 * 16 * Likewise, major tic marks will be displayed at every unit along the ruler, 17 * with minor tic marks in between. 18 * 19 */ 20 21 22 #ifndef _MwRuler_h 23 #define _MwRuler_h 24 25 #include <X11/Core.h> 26 27 28 /*********************************************************************** 29 * 30 * Ruler Widget (subclass of Core) 31 * 32 ***********************************************************************/ 33 34 /* Parameters: 35 36 Name Class RepType Default Value 37 ---- ----- ------- ------------- 38 markStep Step int 1 39 markDiv Divisions int 32 40 labelStep Step int 1 41 labelDiv Divisions int 32 42 labelStyle LabelStyle XtLabelStyle Fraction 43 orientation Orientation int North 44 foreground Foreground Pixel XtDefaultForeground 45 pointerColor Foreground Pixel XtDefaultForeground 46 showPointer ShowPointer Boolean True 47 minValue MinValue float 0.0 48 scale Scale float 100.0 49 value Value float 0.0 50 iValue IValue int 0 51 font Font XFontStruct* XtDefaultFont 52 fracFont Font XFontStruct* font 53 cursor Cursor Cursor* 54 internalWidth Width Dimension 4 55 internalHeight Height Dimension 2 56 callback Callback XtCallbackList NULL 57 userData UserData XtPointer NULL 58 59 background Background Pixel XtDefaultBackground 60 border BorderColor Pixel XtDefaultForeground 61 borderWidth BorderWidth Dimension 1 62 destroyCallback Callback Pointer NULL 63 mappedWhenManaged MappedWhenManaged Boolean True 64 width Width Dimension 0 65 height Height Dimension 0 66 x Position Position 0 67 y Position Position 0 68 69 Notes: 70 71 * MarkStep controls how many units apart major tic marks are drawn. 72 Set to zero to disable. MarkDiv controls how many minor tic marks 73 are drawn between major tic marks. Set to zero to disable. If there 74 is not enough room for tic marks, the ruler widget will choose a 75 lower value for MarkDiv and/or a higher value for MarkStep. 76 * LabelStep, LabelDiv are the same, but for labels. 77 * LabelStyle is either "Fraction" or "Decimal" 78 * Orientation controls the orientation of the ruler. North is horizontal 79 orientation with tic marks at the bottom (useful for rulers North of 80 drawing windows.) South is horizontal with tic marks at top. East is 81 vertical with tic marks on left. West is vertical with tic marks on right. 82 * PointerColor is the color of the arrow. 83 * minValue is the minimum value displayed by the ruler, shown at the left 84 or top of the ruler. 85 * Scale is the number of pixels per unit in the ruler. 86 * Value is the ruler value indicated by the pointer. 87 * Ivalue is the pointer position in pixels. Setting Ivalue sets Value 88 to the nearest approximation, and visa-versa 89 * Callback is called whenever the user manipulates the ruler. Call_data 90 is a pointer to a RulerReport structure. 91 * FracFont is the font to use for fractions. 92 * Cursor is either XC_sb_h_double_arrow or XC_sb_v_double_arrow, 93 depending on orientation. If the ruler is insensitive, the 94 cursor is None. 95 */ 96 97 /* New fields */ 98 99 #ifndef XtNmarkStep 100 #define XtNmarkStep "markStep" 101 #define XtNlabelStep "labelStep" 102 #define XtCStep "Step" 103 #define XtNlabelStyle "labelStyle" 104 #define XtCLabelStyle "LabelStyle" 105 #define XtRLabelStyle XtCLabelStyle 106 #define XtNmarkDiv "markDiv" 107 #define XtNlabelDiv "labelDiv" 108 #define XtCDivisions "Divisions" 109 #define XtNminValue "minValue" 110 #define XtCMinValue "MinValue" 111 #define XtNscale "scale" 112 #define XtCScale "Scale" 113 #define XtNiValue "iValue" 114 #define XtCIValue "IValue" 115 #endif 116 117 #ifndef XtNorientation 118 #define XtNorientation "orientation" 119 #define XtCOrientation "Orientation" 120 #endif 121 122 #ifndef XtNpointerColor 123 #define XtNpointerColor "pointerColor" 124 #define XtCPointerColor "PointerColor" 125 #endif 126 127 #ifndef XtNshowPointer 128 #define XtNshowPointer "showPointer" 129 #define XtCShowPointer "ShowPointer" 130 #endif 131 132 #ifndef XtNcursor 133 #define XtNcursor "cursor" 134 #endif 135 136 #ifndef XtNuserData 137 #define XtNuserData "userData" 138 #define XtCUserData "UserData" 139 #endif 140 141 #ifndef XtNfracFont 142 #define XtNfracFont "fracFont" 143 #endif 144 145 #ifndef XtNshadowWidth 146 #define XtNshadowWidth "shadowWidth" 147 #define XtCShadowWidth "ShadowWidth" 148 #define XtNtopShadowPixel "topShadowPixel" 149 #define XtCTopShadowPixel "TopShadowPixel" 150 #define XtNbottomShadowPixel "bottomShadowPixel" 151 #define XtCBottomShadowPixel "BottomShadowPixel" 152 #define XtNtopShadowContrast "topShadowContrast" 153 #define XtCTopShadowContrast "TopShadowContrast" 154 #define XtNbottomShadowContrast "bottomShadowContrast" 155 #define XtCBottomShadowContrast "BottomShadowContrast" 156 #endif 157 158 #ifndef XtNtopShadowPixmap 159 #define XtNtopShadowPixmap "topShadowPixmap" 160 #define XtCTopShadowPixmap "TopShadowPixmap" 161 #define XtNbottomShadowPixmap "bottomShadowPixmap" 162 #define XtCBottomShadowPixmap "BottomShadowPixmap" 163 #endif 164 165 #ifndef XtNbeNiceToColormap 166 #define XtNbeNiceToColormap "beNiceToColormap" 167 #define XtCBeNiceToColormap "BeNiceToColormap" 168 #define XtNbeNiceToColourmap "beNiceToColormap" 169 #define XtCBeNiceToColourmap "BeNiceToColormap" 170 #endif 171 172 /* Class record constants */ 173 174 extern WidgetClass mwRulerWidgetClass; 175 176 typedef struct _MwRulerClassRec *MwRulerWidgetClass; 177 typedef struct _MwRulerRec *MwRulerWidget; 178 179 typedef struct { 180 enum {START,SCROLL,STOP} what ; 181 float minValue ; /* new minValue */ 182 int dx, dy ; /* scroll amount, pixels */ 183 } MwRulerReport ; 184 185 typedef enum {FRACTION, DECIMAL} XtLabelStyle ; 186 187 _XFUNCPROTOBEGIN 188 189 extern void /* set minimum value and scale */ 190 MwRulerSetMinScale( 191 #if NeedFunctionPrototypes 192 Widget w, 193 double minValue, 194 double scale 195 #endif 196 ) ; 197 198 extern void /* set minimum value */ 199 MwRulerSetMin( 200 #if NeedFunctionPrototypes 201 Widget w, 202 double minValue 203 #endif 204 ) ; 205 206 extern void /* set minimum value at position other than 0 */ 207 MwRulerSetMinPosition( 208 #if NeedFunctionPrototypes 209 Widget w, 210 double minValue, 211 int position 212 #endif 213 ) ; 214 215 extern void /* set scale */ 216 MwRulerSetScale( 217 #if NeedFunctionPrototypes 218 Widget w, 219 double scale 220 #endif 221 ) ; 222 223 extern double /* get minimum value */ 224 MwRulerGetMin( 225 #if NeedFunctionPrototypes 226 Widget w 227 #endif 228 ) ; 229 230 extern double /* get scale */ 231 MwRulerGetScale( 232 #if NeedFunctionPrototypes 233 Widget w 234 #endif 235 ) ; 236 237 extern void /* set pointer value */ 238 MwRulerSetValue( 239 #if NeedFunctionPrototypes 240 Widget w, 241 double value 242 #endif 243 ) ; 244 245 extern void /* set pointer pixel position */ 246 MwRulerSetIValue( 247 #if NeedFunctionPrototypes 248 Widget w, 249 int value 250 #endif 251 ) ; 252 253 extern void /* set pointer pixel position */ 254 MwRulerShowPointer( 255 #if NeedFunctionPrototypes 256 Widget w, 257 Bool show /* true or false */ 258 #endif 259 ) ; 260 261 extern double /* get pointer value */ 262 MwRulerGetValue( 263 #if NeedFunctionPrototypes 264 Widget w 265 #endif 266 ) ; 267 268 extern int /* get pointer pixel position */ 269 MwRulerGetIValue( 270 #if NeedFunctionPrototypes 271 Widget w 272 #endif 273 ) ; 274 275 276 extern double /* map pixel position to value */ 277 MwRulerPosition2Value( 278 #if NeedFunctionPrototypes 279 Widget w, 280 int position 281 #endif 282 ) ; 283 284 285 extern int /* map value to pixel position */ 286 MwRulerValue2Position( 287 #if NeedFunctionPrototypes 288 Widget w, 289 double value 290 #endif 291 ) ; 292 293 _XFUNCPROTOEND 294 295 #endif /* _MwRuler_h */ 296