Sme.c

Go to the documentation of this file.
00001 /* $XConsortium: Sme.c,v 1.12 94/04/17 20:12:48 kaleb Exp $ */
00002 
00003 /*
00004 Copyright (c) 1989, 1994  X Consortium
00005 
00006 Permission is hereby granted, free of charge, to any person obtaining a copy
00007 of this software and associated documentation files (the "Software"), to deal
00008 in the Software without restriction, including without limitation the rights
00009 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00010 copies of the Software, and to permit persons to whom the Software is
00011 furnished to do so, subject to the following conditions:
00012 
00013 The above copyright notice and this permission notice shall be included in
00014 all copies or substantial portions of the Software.
00015 
00016 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00017 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00018 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
00019 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00020 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00021 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00022 
00023 Except as contained in this notice, the name of the X Consortium shall not be
00024 used in advertising or otherwise to promote the sale, use or other dealings
00025 in this Software without prior written authorization from the X Consortium.
00026  */
00027 
00028 /*
00029  * Sme.c - Source code for the generic menu entry
00030  *
00031  * Date:    September 26, 1989
00032  *
00033  * By:      Chris D. Peterson
00034  *          MIT X Consortium 
00035  *          kit@expo.lcs.mit.edu
00036  */
00037 
00038 #include <stdio.h>
00039 #include <X11/IntrinsicP.h>
00040 #include <X11/StringDefs.h>
00041 
00042 #include <X11/Xaw3d/XawInit.h>
00043 #include <X11/Xaw3d/SmeP.h>
00044 #include <X11/Xaw3d/Cardinals.h>
00045 
00046 #define offset(field) XtOffsetOf(SmeRec, sme.field)
00047 static XtResource resources[] = {
00048   {XtNcallback, XtCCallback, XtRCallback, sizeof(XtPointer),
00049      offset(callbacks), XtRCallback, (XtPointer)NULL},
00050   {XtNinternational, XtCInternational, XtRBoolean, sizeof(Boolean),
00051      offset(international), XtRImmediate, (XtPointer) FALSE},
00052 };   
00053 #undef offset
00054 
00055 /*
00056  * Semi Public function definitions. 
00057  */
00058 
00059 static void Unhighlight(), Highlight(), Notify(), ClassPartInitialize();
00060 static void Initialize();
00061 static XtGeometryResult QueryGeometry();
00062 
00063 #define SUPERCLASS (&rectObjClassRec)
00064 
00065 SmeClassRec smeClassRec = {
00066   {
00067     /* superclass         */    (WidgetClass) SUPERCLASS,
00068     /* class_name         */    "Sme",
00069     /* size               */    sizeof(SmeRec),
00070     /* class_initialize   */    XawInitializeWidgetSet,
00071     /* class_part_initialize*/  ClassPartInitialize,
00072     /* Class init'ed      */    FALSE,
00073     /* initialize         */    Initialize,
00074     /* initialize_hook    */    NULL,
00075     /* realize            */    NULL,
00076     /* actions            */    NULL,
00077     /* num_actions        */    ZERO,
00078     /* resources          */    resources,
00079     /* resource_count     */    XtNumber(resources),
00080     /* xrm_class          */    NULLQUARK,
00081     /* compress_motion    */    FALSE, 
00082     /* compress_exposure  */    FALSE,
00083     /* compress_enterleave*/    FALSE,
00084     /* visible_interest   */    FALSE,
00085     /* destroy            */    NULL,
00086     /* resize             */    NULL,
00087     /* expose             */    NULL,
00088     /* set_values         */    NULL,
00089     /* set_values_hook    */    NULL,
00090     /* set_values_almost  */    XtInheritSetValuesAlmost,  
00091     /* get_values_hook    */    NULL,                   
00092     /* accept_focus       */    NULL,
00093     /* intrinsics version */    XtVersion,
00094     /* callback offsets   */    NULL,
00095     /* tm_table           */    NULL,
00096     /* query_geometry     */    QueryGeometry,
00097     /* display_accelerator*/    NULL,
00098     /* extension          */    NULL
00099   },{
00100     /* Simple Menu Entry Fields */
00101       
00102     /* highlight */             Highlight,
00103     /* unhighlight */           Unhighlight,
00104     /* notify */                Notify,         
00105     /* extension */             NULL                            
00106   }
00107 };
00108 
00109 WidgetClass smeObjectClass = (WidgetClass) &smeClassRec;
00110 
00111 /************************************************************
00112  *
00113  * Semi-Public Functions.
00114  *
00115  ************************************************************/
00116 
00117 /*      Function Name: ClassPartInitialize
00118  *      Description: handles inheritance of class functions.
00119  *      Arguments: class - the widget classs of this widget.
00120  *      Returns: none.
00121  */
00122 
00123 static void
00124 ClassPartInitialize(class)
00125 WidgetClass class;
00126 {
00127     SmeObjectClass m_ent, superC;
00128 
00129     m_ent = (SmeObjectClass) class;
00130     superC = (SmeObjectClass) m_ent->rect_class.superclass;
00131 
00132 /* 
00133  * We don't need to check for null super since we'll get to TextSink
00134  * eventually.
00135  */
00136 
00137     if (m_ent->sme_class.highlight == XtInheritHighlight) 
00138         m_ent->sme_class.highlight = superC->sme_class.highlight;
00139 
00140     if (m_ent->sme_class.unhighlight == XtInheritUnhighlight)
00141         m_ent->sme_class.unhighlight = superC->sme_class.unhighlight;
00142 
00143     if (m_ent->sme_class.notify == XtInheritNotify) 
00144         m_ent->sme_class.notify = superC->sme_class.notify;
00145 }
00146 
00147 /*      Function Name: Initialize
00148  *      Description: Initializes the simple menu widget
00149  *      Arguments: request - the widget requested by the argument list.
00150  *                 new     - the new widget with both resource and non
00151  *                           resource values.
00152  *      Returns: none.
00153  * 
00154  * MENU ENTRIES CANNOT HAVE BORDERS.
00155  */
00156 
00157 /* ARGSUSED */
00158 static void
00159 Initialize(request, new, args, num_args)
00160 Widget request, new;
00161 ArgList args;
00162 Cardinal *num_args;
00163 {
00164     SmeObject entry = (SmeObject) new;
00165 
00166     entry->rectangle.border_width = 0;
00167 }
00168 
00169 /*      Function Name: Highlight
00170  *      Description: The default highlight proceedure for menu entries.
00171  *      Arguments: w - the menu entry.
00172  *      Returns: none.
00173  */
00174 
00175 /* ARGSUSED */
00176 static void
00177 Highlight(w)
00178 Widget w;
00179 {
00180 /* This space intentionally left blank. */
00181 }
00182 
00183 /*      Function Name: Unhighlight
00184  *      Description: The default unhighlight proceedure for menu entries.
00185  *      Arguments: w - the menu entry.
00186  *      Returns: none.
00187  */
00188 
00189 /* ARGSUSED */
00190 static void
00191 Unhighlight(w)
00192 Widget w;
00193 {
00194 /* This space intentionally left blank. */
00195 }
00196 
00197 /*      Function Name: Notify
00198  *      Description: calls the callback proceedures for this entry.
00199  *      Arguments: w - the menu entry.
00200  *      Returns: none.
00201  */
00202 
00203 static void
00204 Notify(w) 
00205 Widget w;
00206 {
00207     XtCallCallbacks(w, XtNcallback, (XtPointer)NULL);
00208 }
00209 
00210 /*      Function Name: QueryGeometry.
00211  *      Description: Returns the preferred geometry for this widget.
00212  *      Arguments: w - the menu entry object.
00213  *                 itended, return - the intended and return geometry info.
00214  *      Returns: A Geometry Result.
00215  *
00216  * See the Intrinsics manual for details on what this function is for.
00217  * 
00218  * I just return the height and a width of 1.
00219  */
00220 
00221 static XtGeometryResult
00222 QueryGeometry(w, intended, return_val) 
00223 Widget w;
00224 XtWidgetGeometry *intended, *return_val;
00225 {
00226     SmeObject entry = (SmeObject) w;
00227     Dimension width;
00228     XtGeometryResult ret_val = XtGeometryYes;
00229     XtGeometryMask mode = intended->request_mode;
00230 
00231     width = 1;                  /* we can be really small. */
00232 
00233     if ( ((mode & CWWidth) && (intended->width != width)) ||
00234          !(mode & CWWidth) ) {
00235         return_val->request_mode |= CWWidth;
00236         return_val->width = width;
00237         mode = return_val->request_mode;
00238         
00239         if ( (mode & CWWidth) && (width == entry->rectangle.width) )
00240             return(XtGeometryNo);
00241         return(XtGeometryAlmost);
00242     }
00243     return(ret_val);
00244 }

Generated on Sun Mar 4 15:03:55 2007 for Scilab [trunk] by  doxygen 1.5.1