Xaw3_1Sme.c revision 749
749N/A#if ( !defined(lint) && !defined(SABER) )
749N/Astatic char Xrcsid[] = "$XConsortium: Sme.c,v 1.6 89/12/11 15:20:07 kit Exp $";
749N/A#endif
749N/A
749N/A/*
749N/A * Copyright 1989 Massachusetts Institute of Technology
749N/A *
749N/A * Permission to use, copy, modify, distribute, and sell this software and its
749N/A * documentation for any purpose is hereby granted without fee, provided that
749N/A * the above copyright notice appear in all copies and that both that
749N/A * copyright notice and this permission notice appear in supporting
749N/A * documentation, and that the name of M.I.T. not be used in advertising or
749N/A * publicity pertaining to distribution of the software without specific,
749N/A * written prior permission. M.I.T. makes no representations about the
749N/A * suitability of this software for any purpose. It is provided "as is"
749N/A * without express or implied warranty.
749N/A *
749N/A * M.I.T. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
749N/A * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL M.I.T.
749N/A * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
749N/A * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
749N/A * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
749N/A * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
749N/A */
749N/A
749N/A/*
749N/A * Sme.c - Source code for the generic menu entry
749N/A *
749N/A * Date: September 26, 1989
749N/A *
749N/A * By: Chris D. Peterson
749N/A * MIT X Consortium
749N/A * kit@expo.lcs.mit.edu
749N/A */
749N/A
749N/A#include <stdio.h>
749N/A#include <X11/IntrinsicP.h>
749N/A#include <X11/StringDefs.h>
749N/A
749N/A#include <./Xaw3_1XawInit.h>
749N/A#include <./Xaw3_1SmeP.h>
749N/A#include <./Xaw3_1Cardinals.h>
749N/A
749N/A#define offset(field) XtOffset(SmeObject, sme.field)
749N/Astatic XtResource resources[] = {
749N/A {XtNcallback, XtCCallback, XtRCallback, sizeof(caddr_t),
749N/A offset(callbacks), XtRCallback, (caddr_t)NULL},
749N/A};
749N/A#undef offset
749N/A
749N/A/*
749N/A * Semi Public function definitions.
749N/A */
749N/A
749N/Astatic void Unhighlight(), Highlight(), Notify(), ClassPartInitialize();
749N/Astatic void Initialize();
749N/Astatic XtGeometryResult QueryGeometry();
749N/A
749N/A#define SUPERCLASS (&rectObjClassRec)
749N/A
749N/ASmeClassRec smeClassRec = {
749N/A {
749N/A /* superclass */ (WidgetClass) SUPERCLASS,
749N/A /* class_name */ "Sme",
749N/A /* size */ sizeof(SmeRec),
749N/A /* class_initialize */ XawInitializeWidgetSet,
749N/A /* class_part_initialize*/ ClassPartInitialize,
749N/A /* Class init'ed */ FALSE,
749N/A /* initialize */ Initialize,
749N/A /* initialize_hook */ NULL,
749N/A /* realize */ NULL,
749N/A /* actions */ NULL,
749N/A /* num_actions */ ZERO,
749N/A /* resources */ resources,
749N/A /* resource_count */ XtNumber(resources),
749N/A /* xrm_class */ NULLQUARK,
749N/A /* compress_motion */ FALSE,
749N/A /* compress_exposure */ FALSE,
749N/A /* compress_enterleave*/ FALSE,
749N/A /* visible_interest */ FALSE,
749N/A /* destroy */ NULL,
749N/A /* resize */ NULL,
749N/A /* expose */ NULL,
749N/A /* set_values */ NULL,
749N/A /* set_values_hook */ NULL,
749N/A /* set_values_almost */ XtInheritSetValuesAlmost,
749N/A /* get_values_hook */ NULL,
749N/A /* accept_focus */ NULL,
749N/A /* intrinsics version */ XtVersion,
749N/A /* callback offsets */ NULL,
749N/A /* tm_table */ NULL,
749N/A /* query_geometry */ QueryGeometry,
749N/A /* display_accelerator*/ NULL,
749N/A /* extension */ NULL
749N/A },{
749N/A /* Simple Menu Entry Fields */
749N/A
749N/A /* highlight */ Highlight,
749N/A /* unhighlight */ Unhighlight,
749N/A /* notify */ Notify,
749N/A /* extension */ NULL
749N/A }
749N/A};
749N/A
749N/AWidgetClass smeObjectClass = (WidgetClass) &smeClassRec;
749N/A
749N/A/************************************************************
749N/A *
749N/A * Semi-Public Functions.
749N/A *
749N/A ************************************************************/
749N/A
749N/A/* Function Name: ClassPartInitialize
749N/A * Description: handles inheritance of class functions.
749N/A * Arguments: class - the widget classs of this widget.
749N/A * Returns: none.
749N/A */
749N/A
749N/Astatic void
749N/AClassPartInitialize(class)
749N/AWidgetClass class;
749N/A{
749N/A SmeObjectClass m_ent, superC;
749N/A
749N/A m_ent = (SmeObjectClass) class;
749N/A superC = (SmeObjectClass) m_ent->rect_class.superclass;
749N/A
749N/A/*
749N/A * We don't need to check for null super since we'll get to TextSink
749N/A * eventually.
749N/A */
749N/A
749N/A if (m_ent->sme_class.highlight == XtInheritHighlight)
749N/A m_ent->sme_class.highlight = superC->sme_class.highlight;
749N/A
749N/A if (m_ent->sme_class.unhighlight == XtInheritUnhighlight)
749N/A m_ent->sme_class.unhighlight = superC->sme_class.unhighlight;
749N/A
749N/A if (m_ent->sme_class.notify == XtInheritNotify)
749N/A m_ent->sme_class.notify = superC->sme_class.notify;
749N/A}
749N/A
749N/A/* Function Name: Initialize
749N/A * Description: Initializes the simple menu widget
749N/A * Arguments: request - the widget requested by the argument list.
749N/A * new - the new widget with both resource and non
749N/A * resource values.
749N/A * Returns: none.
749N/A *
749N/A * MENU ENTRIES CANNOT HAVE BORDERS.
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Astatic void
749N/AInitialize(request, new)
749N/AWidget request, new;
749N/A{
749N/A SmeObject entry = (SmeObject) new;
749N/A
749N/A entry->rectangle.border_width = 0;
749N/A}
749N/A
749N/A/* Function Name: Highlight
749N/A * Description: The default highlight proceedure for menu entries.
749N/A * Arguments: w - the menu entry.
749N/A * Returns: none.
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Astatic void
749N/AHighlight(w)
749N/AWidget w;
749N/A{
749N/A/* This space intentionally left blank. */
749N/A}
749N/A
749N/A/* Function Name: Unhighlight
749N/A * Description: The default unhighlight proceedure for menu entries.
749N/A * Arguments: w - the menu entry.
749N/A * Returns: none.
749N/A */
749N/A
749N/A/* ARGSUSED */
749N/Astatic void
749N/AUnhighlight(w)
749N/AWidget w;
749N/A{
749N/A/* This space intentionally left blank. */
749N/A}
749N/A
749N/A/* Function Name: Notify
749N/A * Description: calls the callback proceedures for this entry.
749N/A * Arguments: w - the menu entry.
749N/A * Returns: none.
749N/A */
749N/A
749N/Astatic void
749N/ANotify(w)
749N/AWidget w;
749N/A{
749N/A XtCallCallbacks(w, XtNcallback, NULL);
749N/A}
749N/A
749N/A/* Function Name: QueryGeometry.
749N/A * Description: Returns the preferred geometry for this widget.
749N/A * Arguments: w - the menu entry object.
749N/A * itended, return - the intended and return geometry info.
749N/A * Returns: A Geometry Result.
749N/A *
749N/A * See the Intrinsics manual for details on what this function is for.
749N/A *
749N/A * I just return the height and a width of 1.
749N/A */
749N/A
749N/Astatic XtGeometryResult
749N/AQueryGeometry(w, intended, return_val)
749N/AWidget w;
749N/AXtWidgetGeometry *intended, *return_val;
749N/A{
749N/A SmeObject entry = (SmeObject) w;
749N/A Dimension width;
749N/A XtGeometryResult ret_val = XtGeometryYes;
749N/A XtGeometryMask mode = intended->request_mode;
749N/A
749N/A width = 1; /* we can be really small. */
749N/A
749N/A if ( ((mode & CWWidth) && (intended->width != width)) ||
749N/A !(mode & CWWidth) ) {
749N/A return_val->request_mode |= CWWidth;
749N/A return_val->width = width;
749N/A mode = return_val->request_mode;
749N/A
749N/A if ( (mode & CWWidth) && (width == entry->rectangle.width) )
749N/A return(XtGeometryNo);
749N/A return(XtGeometryAlmost);
749N/A }
749N/A return(ret_val);
749N/A}