1 #if ( !defined(lint) && !defined(SABER) )
2 static char Xrcsid
[] = "$XConsortium: Sme.c,v 1.6 89/12/11 15:20:07 kit Exp $";
6 * Copyright 1989 Massachusetts Institute of Technology
8 * Permission to use, copy, modify, distribute, and sell this software and its
9 * documentation for any purpose is hereby granted without fee, provided that
10 * the above copyright notice appear in all copies and that both that
11 * copyright notice and this permission notice appear in supporting
12 * documentation, and that the name of M.I.T. not be used in advertising or
13 * publicity pertaining to distribution of the software without specific,
14 * written prior permission. M.I.T. makes no representations about the
15 * suitability of this software for any purpose. It is provided "as is"
16 * without express or implied warranty.
18 * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
20 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
21 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
22 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
23 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
27 * Sme.c - Source code for the generic menu entry
29 * Date: September 26, 1989
31 * By: Chris D. Peterson
33 * kit@expo.lcs.mit.edu
37 #include <X11/IntrinsicP.h>
38 #include <X11/StringDefs.h>
40 #include <./Xaw3_1XawInit.h>
41 #include <./Xaw3_1SmeP.h>
42 #include <./Xaw3_1Cardinals.h>
44 #define offset(field) XtOffset(SmeObject, sme.field)
45 static XtResource resources
[] = {
46 {XtNcallback
, XtCCallback
, XtRCallback
, sizeof(caddr_t
),
47 offset(callbacks
), XtRCallback
, (caddr_t
)NULL
},
52 * Semi Public function definitions.
55 static void Unhighlight(), Highlight(), Notify(), ClassPartInitialize();
56 static void Initialize();
57 static XtGeometryResult
QueryGeometry();
59 #define SUPERCLASS (&rectObjClassRec)
61 SmeClassRec smeClassRec
= {
63 /* superclass */ (WidgetClass
) SUPERCLASS
,
64 /* class_name */ "Sme",
65 /* size */ sizeof(SmeRec
),
66 /* class_initialize */ XawInitializeWidgetSet
,
67 /* class_part_initialize*/ ClassPartInitialize
,
68 /* Class init'ed */ FALSE
,
69 /* initialize */ Initialize
,
70 /* initialize_hook */ NULL
,
73 /* num_actions */ ZERO
,
74 /* resources */ resources
,
75 /* resource_count */ XtNumber(resources
),
76 /* xrm_class */ NULLQUARK
,
77 /* compress_motion */ FALSE
,
78 /* compress_exposure */ FALSE
,
79 /* compress_enterleave*/ FALSE
,
80 /* visible_interest */ FALSE
,
84 /* set_values */ NULL
,
85 /* set_values_hook */ NULL
,
86 /* set_values_almost */ XtInheritSetValuesAlmost
,
87 /* get_values_hook */ NULL
,
88 /* accept_focus */ NULL
,
89 /* intrinsics version */ XtVersion
,
90 /* callback offsets */ NULL
,
92 /* query_geometry */ QueryGeometry
,
93 /* display_accelerator*/ NULL
,
96 /* Simple Menu Entry Fields */
98 /* highlight */ Highlight
,
99 /* unhighlight */ Unhighlight
,
105 WidgetClass smeObjectClass
= (WidgetClass
) &smeClassRec
;
107 /************************************************************
109 * Semi-Public Functions.
111 ************************************************************/
113 /* Function Name: ClassPartInitialize
114 * Description: handles inheritance of class functions.
115 * Arguments: class - the widget classs of this widget.
120 ClassPartInitialize(class)
123 SmeObjectClass m_ent
, superC
;
125 m_ent
= (SmeObjectClass
) class;
126 superC
= (SmeObjectClass
) m_ent
->rect_class
.superclass
;
129 * We don't need to check for null super since we'll get to TextSink
133 if (m_ent
->sme_class
.highlight
== XtInheritHighlight
)
134 m_ent
->sme_class
.highlight
= superC
->sme_class
.highlight
;
136 if (m_ent
->sme_class
.unhighlight
== XtInheritUnhighlight
)
137 m_ent
->sme_class
.unhighlight
= superC
->sme_class
.unhighlight
;
139 if (m_ent
->sme_class
.notify
== XtInheritNotify
)
140 m_ent
->sme_class
.notify
= superC
->sme_class
.notify
;
143 /* Function Name: Initialize
144 * Description: Initializes the simple menu widget
145 * Arguments: request - the widget requested by the argument list.
146 * new - the new widget with both resource and non
150 * MENU ENTRIES CANNOT HAVE BORDERS.
155 Initialize(request
, new)
158 SmeObject entry
= (SmeObject
) new;
160 entry
->rectangle
.border_width
= 0;
163 /* Function Name: Highlight
164 * Description: The default highlight proceedure for menu entries.
165 * Arguments: w - the menu entry.
174 /* This space intentionally left blank. */
177 /* Function Name: Unhighlight
178 * Description: The default unhighlight proceedure for menu entries.
179 * Arguments: w - the menu entry.
188 /* This space intentionally left blank. */
191 /* Function Name: Notify
192 * Description: calls the callback proceedures for this entry.
193 * Arguments: w - the menu entry.
201 XtCallCallbacks(w
, XtNcallback
, NULL
);
204 /* Function Name: QueryGeometry.
205 * Description: Returns the preferred geometry for this widget.
206 * Arguments: w - the menu entry object.
207 * itended, return - the intended and return geometry info.
208 * Returns: A Geometry Result.
210 * See the Intrinsics manual for details on what this function is for.
212 * I just return the height and a width of 1.
215 static XtGeometryResult
216 QueryGeometry(w
, intended
, return_val
)
218 XtWidgetGeometry
*intended
, *return_val
;
220 SmeObject entry
= (SmeObject
) w
;
222 XtGeometryResult ret_val
= XtGeometryYes
;
223 XtGeometryMask mode
= intended
->request_mode
;
225 width
= 1; /* we can be really small. */
227 if ( ((mode
& CWWidth
) && (intended
->width
!= width
)) ||
228 !(mode
& CWWidth
) ) {
229 return_val
->request_mode
|= CWWidth
;
230 return_val
->width
= width
;
231 mode
= return_val
->request_mode
;
233 if ( (mode
& CWWidth
) && (width
== entry
->rectangle
.width
) )
234 return(XtGeometryNo
);
235 return(XtGeometryAlmost
);