2 static char Xrcsid
[] = "$XConsortium: Simple.c,v 1.26 89/12/18 10:52:32 rws Exp $";
5 /***********************************************************
6 Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts,
7 and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
11 Permission to use, copy, modify, and distribute this software and its
12 documentation for any purpose and without fee is hereby granted,
13 provided that the above copyright notice appear in all copies and that
14 both that copyright notice and this permission notice appear in
15 supporting documentation, and that the names of Digital or MIT not be
16 used in advertising or publicity pertaining to distribution of the
17 software without specific, written prior permission.
19 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
20 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
21 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
22 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
23 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
24 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
27 ******************************************************************/
30 #include <X11/IntrinsicP.h>
31 #include <X11/StringDefs.h>
32 #include <./Xaw3_1XawInit.h>
33 #include <./Xaw3_1SimpleP.h>
35 #define UnspecifiedPixmap 2 /* %%% should be NULL, according to the spec */
37 static XtResource resources
[] = {
38 #define offset(field) XtOffset(SimpleWidget, simple.field)
39 {XtNcursor
, XtCCursor
, XtRCursor
, sizeof(Cursor
),
40 offset(cursor
), XtRImmediate
, (caddr_t
) None
},
41 {XtNinsensitiveBorder
, XtCInsensitive
, XtRPixmap
, sizeof(Pixmap
),
42 offset(insensitive_border
), XtRImmediate
, (caddr_t
) NULL
}
46 static void ClassPartInitialize(), Realize();
47 static Boolean
SetValues(), ChangeSensitive();
49 SimpleClassRec simpleClassRec
= {
51 /* superclass */ (WidgetClass
) &widgetClassRec
,
52 /* class_name */ "Simple",
53 /* widget_size */ sizeof(SimpleRec
),
54 /* class_initialize */ XawInitializeWidgetSet
,
55 /* class_part_initialize */ ClassPartInitialize
,
56 /* class_inited */ FALSE
,
57 /* initialize */ NULL
,
58 /* initialize_hook */ NULL
,
59 /* realize */ Realize
,
62 /* resources */ resources
,
63 /* num_resources */ XtNumber(resources
),
64 /* xrm_class */ NULLQUARK
,
65 /* compress_motion */ TRUE
,
66 /* compress_exposure */ TRUE
,
67 /* compress_enterleave */ TRUE
,
68 /* visible_interest */ FALSE
,
72 /* set_values */ SetValues
,
73 /* set_values_hook */ NULL
,
74 /* set_values_almost */ XtInheritSetValuesAlmost
,
75 /* get_values_hook */ NULL
,
76 /* accept_focus */ NULL
,
77 /* version */ XtVersion
,
78 /* callback_private */ NULL
,
80 /* query_geometry */ XtInheritQueryGeometry
,
81 /* display_accelerator */ XtInheritDisplayAccelerator
,
85 /* change_sensitive */ ChangeSensitive
89 WidgetClass simpleWidgetClass
= (WidgetClass
)&simpleClassRec
;
91 static void ClassPartInitialize(class)
94 register SimpleWidgetClass c
= (SimpleWidgetClass
)class;
96 if (c
->simple_class
.change_sensitive
== NULL
) {
100 "%s Widget: The Simple Widget class method 'change_sensitive' is undefined.\nA function must be defined or inherited.",
101 c
->core_class
.class_name
);
103 c
->simple_class
.change_sensitive
= ChangeSensitive
;
106 if (c
->simple_class
.change_sensitive
== XtInheritChangeSensitive
)
107 c
->simple_class
.change_sensitive
= ChangeSensitive
;
112 static void Realize(w
, valueMask
, attributes
)
115 XSetWindowAttributes
*attributes
;
117 Pixmap border_pixmap
;
119 if (!XtIsSensitive(w
)) {
120 /* change border to gray; have to remember the old one,
121 * so XtDestroyWidget deletes the proper one */
122 if (((SimpleWidget
)w
)->simple
.insensitive_border
== NULL
)
123 ((SimpleWidget
)w
)->simple
.insensitive_border
=
124 XmuCreateStippledPixmap(XtScreen(w
),
125 w
->core
.border_pixel
,
126 w
->core
.background_pixel
,
128 border_pixmap
= w
->core
.border_pixmap
;
129 attributes
->border_pixmap
=
130 w
->core
.border_pixmap
= ((SimpleWidget
)w
)->simple
.insensitive_border
;
132 *valueMask
|= CWBorderPixmap
;
133 *valueMask
&= ~CWBorderPixel
;
136 if ((attributes
->cursor
= ((SimpleWidget
)w
)->simple
.cursor
) != None
)
137 *valueMask
|= CWCursor
;
139 XtCreateWindow( w
, (unsigned int)InputOutput
, (Visual
*)CopyFromParent
,
140 *valueMask
, attributes
);
142 if (!XtIsSensitive(w
))
143 w
->core
.border_pixmap
= border_pixmap
;
149 static Boolean
SetValues(current
, request
, new)
150 Widget current
, request
, new;
152 SimpleWidget s_old
= (SimpleWidget
) current
;
153 SimpleWidget s_new
= (SimpleWidget
) new;
155 if ( XtIsSensitive(current
) != XtIsSensitive(new) )
156 (*((SimpleWidgetClass
)XtClass(new))->
157 simple_class
.change_sensitive
) ( new );
159 if ( (s_old
->simple
.cursor
!= s_new
->simple
.cursor
) && XtIsRealized(new))
160 XDefineCursor(XtDisplay(new), XtWindow(new), s_new
->simple
.cursor
);
166 static Boolean
ChangeSensitive(w
)
169 if (XtIsRealized(w
)) {
170 if (XtIsSensitive(w
))
171 if (w
->core
.border_pixmap
!= UnspecifiedPixmap
)
172 XSetWindowBorderPixmap( XtDisplay(w
), XtWindow(w
),
173 w
->core
.border_pixmap
);
175 XSetWindowBorder( XtDisplay(w
), XtWindow(w
),
176 w
->core
.border_pixel
);
178 if (((SimpleWidget
)w
)->simple
.insensitive_border
== NULL
)
179 ((SimpleWidget
)w
)->simple
.insensitive_border
=
180 XmuCreateStippledPixmap(XtScreen(w
),
181 w
->core
.border_pixel
,
182 w
->core
.background_pixel
,
184 XSetWindowBorderPixmap( XtDisplay(w
), XtWindow(w
),
186 simple
.insensitive_border
);