source: trunk/third/x3270/Cme.c @ 9081

Revision 9081, 7.1 KB checked in by ghudson, 28 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r9080, which included commits to RCS files with non-trunk default branches.
Line 
1/* (from) $XConsortium: Sme.c,v 1.9 91/02/17 16:44:14 rws Exp $ */
2
3/*
4 * Modifications Copyright 1995 by Paul Mattes.
5 *   Permission to use, copy, modify, and distribute this software and its
6 *   documentation for any purpose and without fee is hereby granted,
7 *   provided that the above copyright notice appear in all copies and that
8 *   both that copyright notice and this permission notice appear in
9 *   supporting documentation.
10 *
11 * Copyright 1989 Massachusetts Institute of Technology
12 *
13 * Permission to use, copy, modify, distribute, and sell this software and its
14 * documentation for any purpose is hereby granted without fee, provided that
15 * the above copyright notice appear in all copies and that both that
16 * copyright notice and this permission notice appear in supporting
17 * documentation, and that the name of M.I.T. not be used in advertising or
18 * publicity pertaining to distribution of the software without specific,
19 * written prior permission.  M.I.T. makes no representations about the
20 * suitability of this software for any purpose.  It is provided "as is"
21 * without express or implied warranty.
22 *
23 * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
25 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
26 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
27 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
28 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
29 */
30
31/*
32 * Cme.c - Source code for the generic menu entry
33 * (from) Sme.c - Source code for the generic menu entry
34 *
35 * Date:    September 26, 1989
36 *
37 * By:      Chris D. Peterson
38 *          MIT X Consortium
39 *          kit@expo.lcs.mit.edu
40 */
41
42#include <stdio.h>
43#include <X11/IntrinsicP.h>
44#include <X11/StringDefs.h>
45
46#include <X11/Xaw/XawInit.h>
47#include "CmeP.h"
48#include <X11/Xaw/Cardinals.h>
49
50#define offset(field) XtOffsetOf(CmeRec, cme.field)
51static XtResource resources[] = {
52  {XtNcallback, XtCCallback, XtRCallback, sizeof(XtPointer),
53     offset(callbacks), XtRCallback, (XtPointer)NULL},
54};   
55#undef offset
56
57/*
58 * Semi Public function definitions.
59 */
60
61static void Unhighlight(), Highlight(), Notify(), ClassPartInitialize();
62static void Initialize();
63static XtGeometryResult QueryGeometry();
64
65#define SUPERCLASS (&rectObjClassRec)
66
67CmeClassRec cmeClassRec = {
68  {
69    /* superclass         */    (WidgetClass) SUPERCLASS,
70    /* class_name         */    "Cme",
71    /* size               */    sizeof(CmeRec),
72    /* class_initialize   */    XawInitializeWidgetSet,
73    /* class_part_initialize*/  ClassPartInitialize,
74    /* Class init'ed      */    FALSE,
75    /* initialize         */    Initialize,
76    /* initialize_hook    */    NULL,
77    /* realize            */    NULL,
78    /* actions            */    NULL,
79    /* num_actions        */    ZERO,
80    /* resources          */    resources,
81    /* resource_count     */    XtNumber(resources),
82    /* xrm_class          */    NULLQUARK,
83    /* compress_motion    */    FALSE,
84    /* compress_exposure  */    FALSE,
85    /* compress_enterleave*/    FALSE,
86    /* visible_interest   */    FALSE,
87    /* destroy            */    NULL,
88    /* resize             */    NULL,
89    /* expose             */    NULL,
90    /* set_values         */    NULL,
91    /* set_values_hook    */    NULL,
92    /* set_values_almost  */    XtInheritSetValuesAlmost, 
93    /* get_values_hook    */    NULL,                   
94    /* accept_focus       */    NULL,
95    /* intrinsics version */    XtVersion,
96    /* callback offsets   */    NULL,
97    /* tm_table           */    NULL,
98    /* query_geometry     */    QueryGeometry,
99    /* display_accelerator*/    NULL,
100    /* extension          */    NULL
101  },{
102    /* Complex Menu Entry Fields */
103     
104    /* highlight */             Highlight,
105    /* unhighlight */           Unhighlight,
106    /* notify */                Notify,         
107    /* extension */             NULL                           
108  }
109};
110
111WidgetClass cmeObjectClass = (WidgetClass) &cmeClassRec;
112
113/************************************************************
114 *
115 * Semi-Public Functions.
116 *
117 ************************************************************/
118
119/*      Function Name: ClassPartInitialize
120 *      Description: handles inheritance of class functions.
121 *      Arguments: class - the widget classs of this widget.
122 *      Returns: none.
123 */
124
125static void
126ClassPartInitialize(class)
127WidgetClass class;
128{
129    CmeObjectClass m_ent, superC;
130
131    m_ent = (CmeObjectClass) class;
132    superC = (CmeObjectClass) m_ent->rect_class.superclass;
133
134/*
135 * We don't need to check for null super since we'll get to TextSink
136 * eventually.
137 */
138
139    if (m_ent->cme_class.highlight == XtInheritHighlight)
140        m_ent->cme_class.highlight = superC->cme_class.highlight;
141
142    if (m_ent->cme_class.unhighlight == XtInheritUnhighlight)
143        m_ent->cme_class.unhighlight = superC->cme_class.unhighlight;
144
145    if (m_ent->cme_class.notify == XtInheritNotify)
146        m_ent->cme_class.notify = superC->cme_class.notify;
147}
148
149/*      Function Name: Initialize
150 *      Description: Initializes the complex menu widget
151 *      Arguments: request - the widget requested by the argument list.
152 *                 new     - the new widget with both resource and non
153 *                           resource values.
154 *      Returns: none.
155 *
156 * MENU ENTRIES CANNOT HAVE BORDERS.
157 */
158
159/* ARGSUSED */
160static void
161Initialize(request, new)
162Widget request, new;
163{
164    CmeObject entry = (CmeObject) new;
165
166    entry->rectangle.border_width = 0;
167}
168
169/*      Function Name: Highlight
170 *      Description: The default highlight proceedure for menu entries.
171 *      Arguments: w - the menu entry.
172 *      Returns: none.
173 */
174
175/* ARGSUSED */
176static void
177Highlight(w)
178Widget w;
179{
180/* This space intentionally left blank. */
181}
182
183/*      Function Name: Unhighlight
184 *      Description: The default unhighlight proceedure for menu entries.
185 *      Arguments: w - the menu entry.
186 *      Returns: none.
187 */
188
189/* ARGSUSED */
190static void
191Unhighlight(w)
192Widget w;
193{
194/* This space intentionally left blank. */
195}
196
197/*      Function Name: Notify
198 *      Description: calls the callback proceedures for this entry.
199 *      Arguments: w - the menu entry.
200 *      Returns: none.
201 */
202
203static void
204Notify(w)
205Widget w;
206{
207    XtCallCallbacks(w, XtNcallback, NULL);
208}
209
210/*      Function Name: QueryGeometry.
211 *      Description: Returns the preferred geometry for this widget.
212 *      Arguments: w - the menu entry object.
213 *                 itended, return - the intended and return geometry info.
214 *      Returns: A Geometry Result.
215 *
216 * See the Intrinsics manual for details on what this function is for.
217 *
218 * I just return the height and a width of 1.
219 */
220
221static XtGeometryResult
222QueryGeometry(w, intended, return_val)
223Widget w;
224XtWidgetGeometry *intended, *return_val;
225{
226    CmeObject entry = (CmeObject) w;
227    Dimension width;
228    XtGeometryResult ret_val = XtGeometryYes;
229    XtGeometryMask mode = intended->request_mode;
230
231    width = 1;                  /* we can be really small. */
232
233    if ( ((mode & CWWidth) && (intended->width != width)) ||
234         !(mode & CWWidth) ) {
235        return_val->request_mode |= CWWidth;
236        return_val->width = width;
237        mode = return_val->request_mode;
238       
239        if ( (mode & CWWidth) && (width == entry->rectangle.width) )
240            return(XtGeometryNo);
241        return(XtGeometryAlmost);
242    }
243    return(ret_val);
244}
Note: See TracBrowser for help on using the repository browser.