2 Copyright 1989, 1998 The Open Group
4 Permission to use, copy, modify, distribute, and sell this software and its
5 documentation for any purpose is hereby granted without fee, provided that
6 the above copyright notice appear in all copies and that both that
7 copyright notice and this permission notice appear in supporting
10 The above copyright notice and this permission notice shall be included in
11 all copies or substantial portions of the Software.
13 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
17 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 Except as contained in this notice, the name of The Open Group shall not be
21 used in advertising or otherwise to promote the sale, use or other dealings
22 in this Software without prior written authorization from The Open Group.
24 * Author: Chris D. Peterson, MIT X Consortium
28 * Sme.c - Source code for the generic menu entry
30 * Date: September 26, 1989
32 * By: Chris D. Peterson
34 * kit@expo.lcs.mit.edu
41 #include <X11/IntrinsicP.h>
42 #include <X11/StringDefs.h>
43 #include <X11/Xaw/Cardinals.h>
44 #include <X11/Xaw/SmeLineP.h>
45 #include <X11/Xaw/XawInit.h>
51 static void XawSmeLineDestroy(Widget);
52 static void XawSmeLineInitialize(Widget, Widget, ArgList, Cardinal*);
53 static void XawSmeLineRedisplay(Widget, XEvent*, Region);
54 static Boolean XawSmeLineSetValues(Widget, Widget, Widget,
60 static void CreateGC(Widget);
61 static void DestroyGC(Widget);
66 #define offset(field) XtOffsetOf(SmeLineRec, sme_line.field)
67 static XtResource resources[] = {
84 (XtPointer)XtUnspecifiedPixmap
98 #define Superclass (&smeClassRec)
99 SmeLineClassRec smeLineClassRec = {
102 (WidgetClass)Superclass, /* superclass */
103 "SmeLine", /* class_name */
104 sizeof(SmeLineRec), /* widget_size */
105 XawInitializeWidgetSet, /* class_initialize */
106 NULL, /* class_part_initialize */
107 False, /* class inited */
108 XawSmeLineInitialize, /* initialize */
109 NULL, /* initialize_hook */
113 resources, /* resources */
114 XtNumber(resources), /* num_resources */
115 NULLQUARK, /* xrm_class */
116 False, /* compress_motion */
117 False, /* compress_exposure */
118 False, /* compress_enterleave */
119 False, /* visible_interest */
120 XawSmeLineDestroy, /* destroy */
122 XawSmeLineRedisplay, /* expose */
123 XawSmeLineSetValues, /* set_values */
124 NULL, /* set_values_hook */
125 XtInheritSetValuesAlmost, /* set_values_almost */
126 NULL, /* get_values_hook */
127 NULL, /* accept_focus */
128 XtVersion, /* intrinsics version */
129 NULL, /* callback offsets */
131 XtInheritQueryGeometry, /* query_geometry */
132 NULL, /* display_accelerator */
133 NULL, /* extension */
137 XtInheritHighlight, /* highlight */
138 XtInheritUnhighlight, /* unhighlight */
139 XtInheritNotify, /* notify */
140 NULL, /* extension */
144 NULL, /* extension */
148 WidgetClass smeLineObjectClass = (WidgetClass)&smeLineClassRec;
155 XawSmeLineInitialize(Widget request, Widget cnew,
156 ArgList args, Cardinal *num_args)
158 SmeLineObject entry = (SmeLineObject)cnew;
160 if (XtHeight(entry) == 0)
161 XtHeight(entry) = entry->sme_line.line_width;
171 * w - Line entry widget
174 * Creates the GC for the line entry widget.
177 * We can only share the GC if there is no stipple, because
178 * we need to change the stipple origin when drawing
183 SmeLineObject entry = (SmeLineObject)w;
185 XtGCMask mask = GCForeground | GCGraphicsExposures | GCLineWidth;
187 values.foreground = entry->sme_line.foreground;
188 values.graphics_exposures = False;
189 values.line_width = entry->sme_line.line_width;
191 if (entry->sme_line.stipple != XtUnspecifiedPixmap) {
192 values.stipple = entry->sme_line.stipple;
193 values.fill_style = FillStippled;
194 mask |= GCStipple | GCFillStyle;
196 entry->sme_line.gc = XCreateGC(XtDisplayOfObject(w),
197 RootWindowOfScreen(XtScreenOfObject(w)),
201 entry->sme_line.gc = XtGetGC(w, mask, &values);
205 XawSmeLineDestroy(Widget w)
213 SmeLineObject entry = (SmeLineObject)w;
215 if (entry->sme_line.stipple != XtUnspecifiedPixmap)
216 XFreeGC(XtDisplayOfObject(w), entry->sme_line.gc);
218 XtReleaseGC(w, entry->sme_line.gc);
223 XawSmeLineRedisplay(Widget w, XEvent *event, Region region)
225 SmeLineObject entry = (SmeLineObject)w;
226 int y = XtY(w) + (((int)XtHeight(w) - entry->sme_line.line_width) >> 1);
228 if (entry->sme_line.stipple != XtUnspecifiedPixmap)
229 XSetTSOrigin(XtDisplayOfObject(w), entry->sme_line.gc, 0, y);
231 XFillRectangle(XtDisplayOfObject(w), XtWindowOfObject(w),
232 entry->sme_line.gc, XtX(w), y,
233 XtWidth(w), entry->sme_line.line_width);
238 * XawSmeLineSetValues
241 * current - current state of the widget
242 * request - what was requested
243 * cnew - what the widget will become
246 * Relayout the menu when one of the resources is changed.
250 XawSmeLineSetValues(Widget current, Widget request, Widget cnew,
251 ArgList args, Cardinal *num_args)
253 SmeLineObject entry = (SmeLineObject)cnew;
254 SmeLineObject old_entry = (SmeLineObject)current;
256 if (entry->sme_line.line_width != old_entry->sme_line.line_width &&
257 entry->sme_line.stipple != old_entry->sme_line.stipple) {