2 Copyright 1989, 1994, 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.
26 * Date: September 26, 1989
28 * By: Chris D. Peterson
30 * kit@expo.lcs.mit.edu
37 #include <X11/IntrinsicP.h>
38 #include <X11/StringDefs.h>
39 #include <X11/Xaw/Cardinals.h>
40 #include <X11/Xaw/SmeP.h>
41 #include <X11/Xaw/XawInit.h>
47 static void Highlight(Widget);
48 static void Notify(Widget);
49 static void Unhighlight(Widget);
50 static void XawSmeClassPartInitialize(WidgetClass);
51 static void XawSmeInitialize(Widget, Widget, ArgList, Cardinal*);
52 static XtGeometryResult XawSmeQueryGeometry(Widget, XtWidgetGeometry*,
58 #define offset(field) XtOffsetOf(SmeRec, sme.field)
59 static XtResource resources[] = {
74 offset(international),
81 #define Superclass (&rectObjClassRec)
82 SmeClassRec smeClassRec = {
85 (WidgetClass)Superclass, /* superclass */
86 "Sme", /* class_name */
87 sizeof(SmeRec), /* widget_size */
88 XawInitializeWidgetSet, /* class_initialize */
89 XawSmeClassPartInitialize, /* class_part_initialize */
90 False, /* class_initialized */
91 XawSmeInitialize, /* initialize */
92 NULL, /* initialize_hook */
96 resources, /* resources */
97 XtNumber(resources), /* num_resources */
98 NULLQUARK, /* xrm_class */
99 False, /* compress_motion */
100 False, /* compress_exposure */
101 False, /* compress_enterleave */
102 False, /* visible_interest */
106 NULL, /* set_values */
107 NULL, /* set_values_hook */
108 XtInheritSetValuesAlmost, /* set_values_almost */
109 NULL, /* get_values_hook */
110 NULL, /* accept_focus */
111 XtVersion, /* intrinsics_version */
112 NULL, /* callback offsets */
114 XawSmeQueryGeometry, /* query_geometry */
115 NULL, /* display_accelerator */
116 NULL, /* extension */
120 Highlight, /* highlight */
121 Unhighlight, /* unhighlight */
123 NULL, /* extension */
127 WidgetClass smeObjectClass = (WidgetClass)&smeClassRec;
134 * XawSmeClassPartInitialize
137 * cclass - widget classs of this widget
140 * Handles inheritance of class functions.
143 XawSmeClassPartInitialize(WidgetClass cclass)
145 SmeObjectClass m_ent, superC;
147 m_ent = (SmeObjectClass)cclass;
148 superC = (SmeObjectClass)m_ent->rect_class.superclass;
150 if (m_ent->sme_class.highlight == XtInheritHighlight)
151 m_ent->sme_class.highlight = superC->sme_class.highlight;
153 if (m_ent->sme_class.unhighlight == XtInheritUnhighlight)
154 m_ent->sme_class.unhighlight = superC->sme_class.unhighlight;
156 if (m_ent->sme_class.notify == XtInheritNotify)
157 m_ent->sme_class.notify = superC->sme_class.notify;
165 * request - widget requested by the argument list
166 * cnew - new widget with both resource and non resource values
169 * Initializes the simple menu widget entry
173 XawSmeInitialize(Widget request, Widget cnew,
174 ArgList args, Cardinal *num_args)
176 SmeObject entry = (SmeObject)cnew;
178 entry->rectangle.border_width = 0;
189 * Default highlight proceedure for menu entries.
205 * Default unhighlight proceedure for menu entries.
209 Unhighlight(Widget w)
221 * Calls the callback proceedures for this entry.
226 XtCallCallbacks(w, XtNcallback, NULL);
234 * w - menu entry object
235 * itended - intended and return geometry info
239 * Returns the preferred geometry for this widget.
245 * See the Intrinsics manual for details on what this function is for.
247 static XtGeometryResult
248 XawSmeQueryGeometry(Widget w, XtWidgetGeometry *intended,
249 XtWidgetGeometry *return_val)
251 SmeObject entry = (SmeObject)w;
253 XtGeometryResult ret_val = XtGeometryYes;
254 XtGeometryMask mode = intended->request_mode;
258 if (((mode & CWWidth) && intended->width != width) || !(mode & CWWidth)) {
259 return_val->request_mode |= CWWidth;
260 return_val->width = width;
261 mode = return_val->request_mode;
263 if ((mode & CWWidth) && width == XtWidth(entry))
264 return (XtGeometryNo);
265 return (XtGeometryAlmost);