17a84e134Smrg/* 27a84e134SmrgCopyright 1989, 1994, 1998 The Open Group 37a84e134Smrg 47a84e134SmrgPermission to use, copy, modify, distribute, and sell this software and its 57a84e134Smrgdocumentation for any purpose is hereby granted without fee, provided that 67a84e134Smrgthe above copyright notice appear in all copies and that both that 77a84e134Smrgcopyright notice and this permission notice appear in supporting 87a84e134Smrgdocumentation. 97a84e134Smrg 107a84e134SmrgThe above copyright notice and this permission notice shall be included in 117a84e134Smrgall copies or substantial portions of the Software. 127a84e134Smrg 137a84e134SmrgTHE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 147a84e134SmrgIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 157a84e134SmrgFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 167a84e134SmrgOPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 177a84e134SmrgAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 187a84e134SmrgCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 197a84e134Smrg 207a84e134SmrgExcept as contained in this notice, the name of The Open Group shall not be 217a84e134Smrgused in advertising or otherwise to promote the sale, use or other dealings 227a84e134Smrgin this Software without prior written authorization from The Open Group. 237a84e134Smrg */ 247a84e134Smrg 257a84e134Smrg/* 267a84e134Smrg * Date: September 26, 1989 277a84e134Smrg * 287a84e134Smrg * By: Chris D. Peterson 29421c997bSmrg * MIT X Consortium 307a84e134Smrg * kit@expo.lcs.mit.edu 317a84e134Smrg */ 327a84e134Smrg 337a84e134Smrg#ifdef HAVE_CONFIG_H 347a84e134Smrg#include <config.h> 357a84e134Smrg#endif 367a84e134Smrg#include <stdio.h> 377a84e134Smrg#include <X11/IntrinsicP.h> 387a84e134Smrg#include <X11/StringDefs.h> 397a84e134Smrg#include <X11/Xaw/Cardinals.h> 407a84e134Smrg#include <X11/Xaw/SmeP.h> 417a84e134Smrg#include <X11/Xaw/XawInit.h> 427a84e134Smrg#include "Private.h" 437a84e134Smrg 447a84e134Smrg/* 457a84e134Smrg * Class Methods 467a84e134Smrg */ 477a84e134Smrgstatic void Highlight(Widget); 487a84e134Smrgstatic void Notify(Widget); 497a84e134Smrgstatic void Unhighlight(Widget); 507a84e134Smrgstatic void XawSmeClassPartInitialize(WidgetClass); 517a84e134Smrgstatic void XawSmeInitialize(Widget, Widget, ArgList, Cardinal*); 527a84e134Smrgstatic XtGeometryResult XawSmeQueryGeometry(Widget, XtWidgetGeometry*, 537a84e134Smrg XtWidgetGeometry*); 547a84e134Smrg 557a84e134Smrg/* 567a84e134Smrg * Initialization 577a84e134Smrg */ 587a84e134Smrg#define offset(field) XtOffsetOf(SmeRec, sme.field) 597a84e134Smrgstatic XtResource resources[] = { 607a84e134Smrg { 617a84e134Smrg XtNcallback, 627a84e134Smrg XtCCallback, 637a84e134Smrg XtRCallback, 647a84e134Smrg sizeof(XtPointer), 657a84e134Smrg offset(callbacks), 667a84e134Smrg XtRCallback, 677a84e134Smrg NULL 687a84e134Smrg }, 697a84e134Smrg { 707a84e134Smrg XtNinternational, 717a84e134Smrg XtCInternational, 727a84e134Smrg XtRBoolean, 737a84e134Smrg sizeof(Boolean), 747a84e134Smrg offset(international), 757a84e134Smrg XtRImmediate, 767a84e134Smrg (XtPointer)False 777a84e134Smrg }, 78421c997bSmrg}; 797a84e134Smrg#undef offset 807a84e134Smrg 817a84e134Smrg#define Superclass (&rectObjClassRec) 827a84e134SmrgSmeClassRec smeClassRec = { 837a84e134Smrg /* rectangle */ 847a84e134Smrg { 857a84e134Smrg (WidgetClass)Superclass, /* superclass */ 867a84e134Smrg "Sme", /* class_name */ 877a84e134Smrg sizeof(SmeRec), /* widget_size */ 887a84e134Smrg XawInitializeWidgetSet, /* class_initialize */ 897a84e134Smrg XawSmeClassPartInitialize, /* class_part_initialize */ 907a84e134Smrg False, /* class_initialized */ 917a84e134Smrg XawSmeInitialize, /* initialize */ 927a84e134Smrg NULL, /* initialize_hook */ 937a84e134Smrg NULL, /* realize */ 947a84e134Smrg NULL, /* actions */ 957a84e134Smrg 0, /* num_actions */ 967a84e134Smrg resources, /* resources */ 977a84e134Smrg XtNumber(resources), /* num_resources */ 987a84e134Smrg NULLQUARK, /* xrm_class */ 997a84e134Smrg False, /* compress_motion */ 1007a84e134Smrg False, /* compress_exposure */ 1017a84e134Smrg False, /* compress_enterleave */ 1027a84e134Smrg False, /* visible_interest */ 1037a84e134Smrg NULL, /* destroy */ 1047a84e134Smrg NULL, /* resize */ 1057a84e134Smrg NULL, /* expose */ 1067a84e134Smrg NULL, /* set_values */ 1077a84e134Smrg NULL, /* set_values_hook */ 1087a84e134Smrg XtInheritSetValuesAlmost, /* set_values_almost */ 1097a84e134Smrg NULL, /* get_values_hook */ 1107a84e134Smrg NULL, /* accept_focus */ 1117a84e134Smrg XtVersion, /* intrinsics_version */ 1127a84e134Smrg NULL, /* callback offsets */ 1137a84e134Smrg NULL, /* tm_table */ 1147a84e134Smrg XawSmeQueryGeometry, /* query_geometry */ 1157a84e134Smrg NULL, /* display_accelerator */ 1167a84e134Smrg NULL, /* extension */ 1177a84e134Smrg }, 1187a84e134Smrg /* sme */ 1197a84e134Smrg { 1207a84e134Smrg Highlight, /* highlight */ 1217a84e134Smrg Unhighlight, /* unhighlight */ 1227a84e134Smrg Notify, /* notify */ 1237a84e134Smrg NULL, /* extension */ 1247a84e134Smrg } 1257a84e134Smrg}; 1267a84e134Smrg 1277a84e134SmrgWidgetClass smeObjectClass = (WidgetClass)&smeClassRec; 1287a84e134Smrg 1297a84e134Smrg/* 1307a84e134Smrg * Implementation 1317a84e134Smrg */ 1327a84e134Smrg/* 1337a84e134Smrg * Function: 1347a84e134Smrg * XawSmeClassPartInitialize 1357a84e134Smrg * 1367a84e134Smrg * Parameters: 1375b16253fSmrg * cclass - widget class of this widget 1387a84e134Smrg * 1397a84e134Smrg * Description: 1407a84e134Smrg * Handles inheritance of class functions. 1417a84e134Smrg */ 1427a84e134Smrgstatic void 1437a84e134SmrgXawSmeClassPartInitialize(WidgetClass cclass) 1447a84e134Smrg{ 1457a84e134Smrg SmeObjectClass m_ent, superC; 1467a84e134Smrg 1477a84e134Smrg m_ent = (SmeObjectClass)cclass; 1487a84e134Smrg superC = (SmeObjectClass)m_ent->rect_class.superclass; 1497a84e134Smrg 150421c997bSmrg if (m_ent->sme_class.highlight == XtInheritHighlight) 1517a84e134Smrg m_ent->sme_class.highlight = superC->sme_class.highlight; 1527a84e134Smrg 1537a84e134Smrg if (m_ent->sme_class.unhighlight == XtInheritUnhighlight) 1547a84e134Smrg m_ent->sme_class.unhighlight = superC->sme_class.unhighlight; 1557a84e134Smrg 156421c997bSmrg if (m_ent->sme_class.notify == XtInheritNotify) 1577a84e134Smrg m_ent->sme_class.notify = superC->sme_class.notify; 1587a84e134Smrg} 1597a84e134Smrg 1607a84e134Smrg/* 1617a84e134Smrg * Function: 1627a84e134Smrg * XawSmeInitialize 1637a84e134Smrg * 1647a84e134Smrg * Parameters: 1657a84e134Smrg * request - widget requested by the argument list 1667a84e134Smrg * cnew - new widget with both resource and non resource values 167421c997bSmrg * 1687a84e134Smrg * Description: 1697a84e134Smrg * Initializes the simple menu widget entry 1707a84e134Smrg */ 1717a84e134Smrg/*ARGSUSED*/ 1727a84e134Smrgstatic void 1735ec34c4cSmrgXawSmeInitialize(Widget request _X_UNUSED, Widget cnew, 1745ec34c4cSmrg ArgList args _X_UNUSED, Cardinal *num_args _X_UNUSED) 1757a84e134Smrg{ 1767a84e134Smrg SmeObject entry = (SmeObject)cnew; 1777a84e134Smrg 1787a84e134Smrg entry->rectangle.border_width = 0; 1797a84e134Smrg} 1807a84e134Smrg 1817a84e134Smrg/* 1827a84e134Smrg * Function: 1837a84e134Smrg * Highlight 1847a84e134Smrg * 1857a84e134Smrg * Parameters: 1867a84e134Smrg * w - menu entry 1877a84e134Smrg * 1887a84e134Smrg * Description: 1895b16253fSmrg * Default highlight procedure for menu entries. 1907a84e134Smrg */ 1917a84e134Smrg/*ARGSUSED*/ 1927a84e134Smrgstatic void 1935ec34c4cSmrgHighlight(Widget w _X_UNUSED) 1947a84e134Smrg{ 1957a84e134Smrg} 1967a84e134Smrg 1977a84e134Smrg/* 1987a84e134Smrg * Function: 1997a84e134Smrg * Unhighlight 2007a84e134Smrg * 2017a84e134Smrg * Parameters: 2027a84e134Smrg * w - menu entry 2037a84e134Smrg * 2047a84e134Smrg * Description: 2055b16253fSmrg * Default unhighlight procedure for menu entries. 2067a84e134Smrg */ 2077a84e134Smrg/*ARGSUSED*/ 2087a84e134Smrgstatic void 2095ec34c4cSmrgUnhighlight(Widget w _X_UNUSED) 2107a84e134Smrg{ 2117a84e134Smrg} 2127a84e134Smrg 2137a84e134Smrg/* 2147a84e134Smrg * Function: 2157a84e134Smrg * Notify 2167a84e134Smrg * 2177a84e134Smrg * Parameters: 2187a84e134Smrg * w - menu entry 2197a84e134Smrg * 2207a84e134Smrg * Description: 2215b16253fSmrg * Calls the callback procedures for this entry. 2227a84e134Smrg */ 2237a84e134Smrgstatic void 2247a84e134SmrgNotify(Widget w) 2257a84e134Smrg{ 2267a84e134Smrg XtCallCallbacks(w, XtNcallback, NULL); 2277a84e134Smrg} 2287a84e134Smrg 2297a84e134Smrg/* 2307a84e134Smrg * Function: 2317a84e134Smrg * QueryGeometry 2327a84e134Smrg * 2337a84e134Smrg * Parameeters: 2347a84e134Smrg * w - menu entry object 2357a84e134Smrg * itended - intended and return geometry info 2367a84e134Smrg * return_val - 237421c997bSmrg * 2387a84e134Smrg * Description: 2397a84e134Smrg * Returns the preferred geometry for this widget. 2407a84e134Smrg * 2417a84e134Smrg * Returns: 2427a84e134Smrg * Geometry Result 2437a84e134Smrg * 2447a84e134Smrg * Note: 2457a84e134Smrg * See the Intrinsics manual for details on what this function is for. 2467a84e134Smrg */ 2477a84e134Smrgstatic XtGeometryResult 2487a84e134SmrgXawSmeQueryGeometry(Widget w, XtWidgetGeometry *intended, 2497a84e134Smrg XtWidgetGeometry *return_val) 2507a84e134Smrg{ 2517a84e134Smrg SmeObject entry = (SmeObject)w; 2527a84e134Smrg Dimension width; 2537a84e134Smrg XtGeometryResult ret_val = XtGeometryYes; 2547a84e134Smrg XtGeometryMask mode = intended->request_mode; 2557a84e134Smrg 2567a84e134Smrg width = 1; 2577a84e134Smrg 2587a84e134Smrg if (((mode & CWWidth) && intended->width != width) || !(mode & CWWidth)) { 2597a84e134Smrg return_val->request_mode |= CWWidth; 2607a84e134Smrg return_val->width = width; 2617a84e134Smrg mode = return_val->request_mode; 262421c997bSmrg 2637a84e134Smrg if ((mode & CWWidth) && width == XtWidth(entry)) 2647a84e134Smrg return (XtGeometryNo); 2657a84e134Smrg return (XtGeometryAlmost); 2667a84e134Smrg } 2677a84e134Smrg 2687a84e134Smrg return (ret_val); 2697a84e134Smrg} 270