1 /* $TOG: SpinBP.h /main/7 1999/09/01 17:14:17 mgreess $ */
2 /*
3  * Motif
4  *
5  * Copyright (c) 1987-2012, The Open Group. All rights reserved.
6  *
7  * These libraries and programs are free software; you can
8  * redistribute them and/or modify them under the terms of the GNU
9  * Lesser General Public License as published by the Free Software
10  * Foundation; either version 2 of the License, or (at your option)
11  * any later version.
12  *
13  * These libraries and programs are distributed in the hope that
14  * they will be useful, but WITHOUT ANY WARRANTY; without even the
15  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16  * PURPOSE. See the GNU Lesser General Public License for more
17  * details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with these librararies and programs; if not, write
21  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
22  * Floor, Boston, MA 02110-1301 USA
23  */
24 /*
25  * HISTORY
26  */
27 
28 #ifndef _XmSpinBP_h
29 #define _XmSpinBP_h
30 
31 #include <Xm/LabelP.h>
32 #include <Xm/ManagerP.h>
33 #include <Xm/SpinB.h>
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 /*  Spin constraints */
40 
41 typedef struct _XmSpinBoxConstraint
42 {
43   XmStringTable  values;        /* array of XmString */
44   int            position;      /* position of current selection */
45   int            num_values;    /* number of XmString in the array */
46 
47   int            minimum_value; /* parameters for autonumeric mode */
48   int            maximum_value;
49   int            increment_value;
50   short	         decimal_points;
51 
52   unsigned char  sb_child_type;
53   unsigned char  arrow_sensitivity;
54   Boolean	 wrap;
55   unsigned char  position_type; /* governs interpretation of .position:
56 					XmPOSITION_{ARRAY,VALUE} */
57 } XmSpinBoxConstraintPart, *XmSpinBoxConstraint;
58 
59 typedef struct _XmSpinBoxConstraintRec
60 {
61   XmManagerConstraintPart manager;
62   XmSpinBoxConstraintPart spinBox;
63 } XmSpinBoxConstraintRec, *XmSpinBoxConstraintPtr;
64 
65 typedef Widget	(*XmGetCallbackWidgetProc)(Widget);
66 
67 /*  Spin class structure  */
68 typedef struct _XmSpinBoxClassPart
69 {
70   XmGetCallbackWidgetProc    get_callback_widget;
71   XtPointer                  extension;			/* not used */
72 } XmSpinBoxClassPart;
73 
74 
75 /*  Full class record declaration for Spin class  */
76 
77 typedef struct _XmSpinBoxClassRec
78 {
79   CoreClassPart              core_class;
80   CompositeClassPart         composite_class;
81   ConstraintClassPart        constraint_class;
82   XmManagerClassPart         manager_class;
83   XmSpinBoxClassPart         spinBox_class;
84 } XmSpinBoxClassRec;
85 
86 externalref XmSpinBoxClassRec xmSpinBoxClassRec;
87 
88 /*  The Spin instance record  */
89 
90 typedef struct _XmSpinBoxPart
91 {
92       Dimension	     arrow_size;
93       Dimension	     margin_width;
94       Dimension	     margin_height;
95       Dimension	     spacing;
96       unsigned int   initial_delay;
97       unsigned int   repeat_delay;
98       XtCallbackList modify_verify_cb; /* CB list for new selection */
99       XtCallbackList value_changed_cb; /* CB list for new selection */
100       XRectangle     up_arrow_rect;
101       XRectangle     down_arrow_rect;
102       Widget         textw;         /* text widget */
103       int	     boundary;
104       int	     last_hit;
105       int	     make_change;
106       Dimension	     ideal_height;
107       Dimension	     ideal_width;
108       GC	     arrow_gc;
109       GC	     insensitive_gc;
110       Mask	     dim_mask; 	    /* for the navigator trait */
111       XtIntervalId   spin_timer;
112       Boolean	     up_arrow_pressed;
113       Boolean	     down_arrow_pressed;
114       unsigned char  arrow_layout;
115       unsigned char  default_arrow_sensitivity;
116       Dimension	     detail_shadow_thickness;
117       unsigned char  arrow_orientation;	/* Xm_ARROWS_{VERTICAL,HORIZONTAL} */
118 } XmSpinBoxPart;
119 
120 
121 /*  Full instance record declaration  */
122 
123 typedef struct _XmSpinBoxRec
124 {
125   CorePart              core;
126   CompositePart         composite;
127   ConstraintPart        constraint;
128   XmManagerPart         manager;
129   XmSpinBoxPart         spinBox;
130 } XmSpinBoxRec;
131 
132 /*  Macros */
133 #define XmRPositionValue	"PositionValue"
134 
135 #define SB_GetConstraintRec(w) \
136   ((XmSpinBoxConstraint)(&((XmSpinBoxConstraintPtr) (w)->core.constraints)->spinBox))
137 
138 #define SB_WithChild(w) \
139   (((XmSpinBoxRec *) (w))->spinBox.textw != NULL)
140 
141 #define SB_ChildCount(w) \
142   (((XmSpinBoxRec *) (w))->composite.num_children)
143 
144 #define SB_GetArrowOrientation(w) \
145   (((XmSpinBoxRec *) (w))->spinBox.arrow_orientation)
146 
147 #define SB_ChildIsNumeric(wc) \
148   (((XmSpinBoxConstraint) (wc))->sb_child_type == (unsigned char) XmNUMERIC)
149 
150 #define SB_ChildPositionTypeIsValue(wc) \
151   (((XmSpinBoxConstraint) (wc))->position_type == \
152    (unsigned char) XmPOSITION_VALUE)
153 
154 #define SB_ChildMaximumPositionValue(wc) \
155   ( ( ((wc) == (XmSpinBoxConstraint) NULL) ?  \
156         0 : \
157         ( (SB_ChildIsNumeric(wc)) ? \
158 	    (wc)->maximum_value : \
159             ( ((wc)->num_values  > 0) ? \
160 		((wc)->num_values - 1) : \
161 		0 \
162 	    ) \
163 	) \
164     ) \
165   )
166 
167 #define SB_ChildMinimumPositionValue(wc) \
168   ( ( ((wc) == (XmSpinBoxConstraint) NULL) ?  \
169         0 : \
170         ( (SB_ChildIsNumeric(wc)) ? \
171           (wc)->minimum_value : \
172           0 \
173         ) \
174     ) \
175   )
176 
177 #ifdef __cplusplus
178 }  /* Close scope of 'extern "C"' declaration which encloses file. */
179 #endif
180 
181 #endif  /* _SpinBP_h */
182 /* DON'T ADD ANYTHING AFTER THIS #endif */
183 
184 
185 
186