749N/A#ifndef lint
749N/Astatic char Xrcsid[] = "$XConsortium: Simple.c,v 1.26 89/12/18 10:52:32 rws Exp $";
749N/A#endif /* lint */
749N/A
749N/A/***********************************************************
749N/ACopyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
749N/Aand the Massachusetts Institute of Technology, Cambridge, Massachusetts.
749N/A
749N/A All Rights Reserved
749N/A
749N/APermission to use, copy, modify, and distribute this software and its
749N/Adocumentation for any purpose and without fee is hereby granted,
749N/Aprovided that the above copyright notice appear in all copies and that
749N/Aboth that copyright notice and this permission notice appear in
749N/Asupporting documentation, and that the names of Digital or MIT not be
749N/Aused in advertising or publicity pertaining to distribution of the
749N/Asoftware without specific, written prior permission.
749N/A
749N/ADIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
749N/AALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
749N/ADIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
749N/AANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
749N/AWHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
749N/AARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
749N/ASOFTWARE.
749N/A
749N/A******************************************************************/
749N/A
749N/A#include <stdio.h>
749N/A#include <X11/IntrinsicP.h>
749N/A#include <X11/StringDefs.h>
749N/A#include <./Xaw3_1XawInit.h>
749N/A#include <./Xaw3_1SimpleP.h>
749N/A
749N/A#define UnspecifiedPixmap 2 /* %%% should be NULL, according to the spec */
749N/A
749N/Astatic XtResource resources[] = {
749N/A#define offset(field) XtOffset(SimpleWidget, simple.field)
749N/A {XtNcursor, XtCCursor, XtRCursor, sizeof(Cursor),
749N/A offset(cursor), XtRImmediate, (caddr_t) None},
749N/A {XtNinsensitiveBorder, XtCInsensitive, XtRPixmap, sizeof(Pixmap),
749N/A offset(insensitive_border), XtRImmediate, (caddr_t) NULL}
749N/A#undef offset
749N/A};
749N/A
749N/Astatic void ClassPartInitialize(), Realize();
749N/Astatic Boolean SetValues(), ChangeSensitive();
749N/A
749N/ASimpleClassRec simpleClassRec = {
749N/A { /* core fields */
749N/A /* superclass */ (WidgetClass) &widgetClassRec,
749N/A /* class_name */ "Simple",
749N/A /* widget_size */ sizeof(SimpleRec),
749N/A /* class_initialize */ XawInitializeWidgetSet,
749N/A /* class_part_initialize */ ClassPartInitialize,
749N/A /* class_inited */ FALSE,
749N/A /* initialize */ NULL,
749N/A /* initialize_hook */ NULL,
749N/A /* realize */ Realize,
749N/A /* actions */ NULL,
749N/A /* num_actions */ 0,
749N/A /* resources */ resources,
749N/A /* num_resources */ XtNumber(resources),
749N/A /* xrm_class */ NULLQUARK,
749N/A /* compress_motion */ TRUE,
749N/A /* compress_exposure */ TRUE,
749N/A /* compress_enterleave */ TRUE,
749N/A /* visible_interest */ FALSE,
749N/A /* destroy */ NULL,
749N/A /* resize */ NULL,
749N/A /* expose */ NULL,
749N/A /* set_values */ SetValues,
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 /* version */ XtVersion,
749N/A /* callback_private */ NULL,
749N/A /* tm_table */ NULL,
749N/A /* query_geometry */ XtInheritQueryGeometry,
749N/A /* display_accelerator */ XtInheritDisplayAccelerator,
749N/A /* extension */ NULL
749N/A },
749N/A { /* simple fields */
749N/A /* change_sensitive */ ChangeSensitive
749N/A }
749N/A};
749N/A
749N/AWidgetClass simpleWidgetClass = (WidgetClass)&simpleClassRec;
749N/A
749N/Astatic void ClassPartInitialize(class)
749N/A WidgetClass class;
749N/A{
749N/A register SimpleWidgetClass c = (SimpleWidgetClass)class;
749N/A
749N/A if (c->simple_class.change_sensitive == NULL) {
749N/A char buf[BUFSIZ];
749N/A
749N/A sprintf(buf,
749N/A "%s Widget: The Simple Widget class method 'change_sensitive' is undefined.\nA function must be defined or inherited.",
749N/A c->core_class.class_name);
749N/A XtWarning(buf);
749N/A c->simple_class.change_sensitive = ChangeSensitive;
749N/A }
749N/A
749N/A if (c->simple_class.change_sensitive == XtInheritChangeSensitive)
749N/A c->simple_class.change_sensitive = ChangeSensitive;
749N/A
749N/A
749N/A}
749N/A
749N/Astatic void Realize(w, valueMask, attributes)
749N/A register Widget w;
749N/A Mask *valueMask;
749N/A XSetWindowAttributes *attributes;
749N/A{
749N/A Pixmap border_pixmap;
749N/A
749N/A if (!XtIsSensitive(w)) {
749N/A /* change border to gray; have to remember the old one,
749N/A * so XtDestroyWidget deletes the proper one */
749N/A if (((SimpleWidget)w)->simple.insensitive_border == NULL)
749N/A ((SimpleWidget)w)->simple.insensitive_border =
749N/A XmuCreateStippledPixmap(XtScreen(w),
749N/A w->core.border_pixel,
749N/A w->core.background_pixel,
749N/A w->core.depth);
749N/A border_pixmap = w->core.border_pixmap;
749N/A attributes->border_pixmap =
749N/A w->core.border_pixmap = ((SimpleWidget)w)->simple.insensitive_border;
749N/A
749N/A *valueMask |= CWBorderPixmap;
749N/A *valueMask &= ~CWBorderPixel;
749N/A }
749N/A
749N/A if ((attributes->cursor = ((SimpleWidget)w)->simple.cursor) != None)
749N/A *valueMask |= CWCursor;
749N/A
749N/A XtCreateWindow( w, (unsigned int)InputOutput, (Visual *)CopyFromParent,
749N/A *valueMask, attributes );
749N/A
749N/A if (!XtIsSensitive(w))
749N/A w->core.border_pixmap = border_pixmap;
749N/A
749N/A}
749N/A
749N/A
749N/A/* ARGSUSED */
749N/Astatic Boolean SetValues(current, request, new)
749N/A Widget current, request, new;
749N/A{
749N/A SimpleWidget s_old = (SimpleWidget) current;
749N/A SimpleWidget s_new = (SimpleWidget) new;
749N/A
749N/A if ( XtIsSensitive(current) != XtIsSensitive(new) )
749N/A (*((SimpleWidgetClass)XtClass(new))->
749N/A simple_class.change_sensitive) ( new );
749N/A
749N/A if ( (s_old->simple.cursor != s_new->simple.cursor) && XtIsRealized(new))
749N/A XDefineCursor(XtDisplay(new), XtWindow(new), s_new->simple.cursor);
749N/A
749N/A return False;
749N/A}
749N/A
749N/A
749N/Astatic Boolean ChangeSensitive(w)
749N/A register Widget w;
749N/A{
749N/A if (XtIsRealized(w)) {
749N/A if (XtIsSensitive(w))
749N/A if (w->core.border_pixmap != UnspecifiedPixmap)
749N/A XSetWindowBorderPixmap( XtDisplay(w), XtWindow(w),
749N/A w->core.border_pixmap );
749N/A else
749N/A XSetWindowBorder( XtDisplay(w), XtWindow(w),
749N/A w->core.border_pixel );
749N/A else {
749N/A if (((SimpleWidget)w)->simple.insensitive_border == NULL)
749N/A ((SimpleWidget)w)->simple.insensitive_border =
749N/A XmuCreateStippledPixmap(XtScreen(w),
749N/A w->core.border_pixel,
749N/A w->core.background_pixel,
749N/A w->core.depth);
749N/A XSetWindowBorderPixmap( XtDisplay(w), XtWindow(w),
749N/A ((SimpleWidget)w)->
749N/A simple.insensitive_border );
749N/A }
749N/A }
749N/A return False;
749N/A}
749N/A