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