2
* @OPENGROUP_COPYRIGHT@
4
* Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
5
* Copyright (c) 1996, 1997, 1998, 1999, 2000 The Open Group
6
* ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
7
* the full copyright text.
9
* This software is subject to an open license. It may only be
10
* used on, with or for operating systems which are themselves open
11
* source systems. You must contact The Open Group for a license
12
* allowing distribution and sublicensing of this software on, with,
13
* or for operating systems which are not Open Source programs.
15
* See http://www.opengroup.org/openmotif/license for full
16
* details of the license agreement. Any use, reproduction, or
17
* distribution of the program constitutes recipient's acceptance of
20
* EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS
21
* PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22
* KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY
23
* WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
24
* OR FITNESS FOR A PARTICULAR PURPOSE
26
* EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
27
* NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT,
28
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29
* DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED
30
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32
* ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE
33
* EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE
34
* POSSIBILITY OF SUCH DAMAGES.
41
static char rcsid[] = "$XConsortium: Sash.c /main/12 1995/07/13 17:51:55 drk $"
44
/* (c) Copyright 1989, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
45
/* (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 HEWLETT-PACKARD COMPANY */
46
/* (c) Copyright 1988 MASSACHUSETTS INSTITUTE OF TECHNOLOGY */
53
#include <X11/cursorfont.h>
56
#include <Xm/TransltnsP.h>
58
#include <Xm/DisplayP.h>
59
#include "MenuStateI.h"
60
#include "TraversalI.h"
62
#define defTranslations _XmSash_defTranslations
65
/******** Static Function Declarations ********/
67
static void ClassPartInitialize(
69
static void ClassInitialize( void ) ;
70
static void Initialize(
75
static void HighlightSash(
77
static void UnhighlightSash(
79
static XmNavigability WidgetNavigable(
81
static void SashFocusIn(
85
Cardinal *num_params) ;
86
static void SashFocusOut(
90
Cardinal *num_params) ;
91
static void SashAction(
95
Cardinal *num_params) ;
98
XtValueMask *p_valueMask,
99
XSetWindowAttributes *attributes) ;
100
static void Redisplay(
105
static void SashDisplayDestroyCallback (
107
XtPointer client_data,
108
XtPointer call_data );
109
/******** End Static Function Declarations ********/
112
static XtResource resources[] = {
113
{XmNborderWidth, XmCBorderWidth, XmRHorizontalDimension, sizeof(Dimension),
114
XtOffsetOf( struct _XmSashRec, core.border_width), XmRImmediate, (XtPointer) 0},
116
{XmNcallback, XmCCallback, XmRCallback, sizeof(XtCallbackList),
117
XtOffsetOf( struct _XmSashRec, sash.sash_action), XmRPointer, NULL},
119
{ XmNnavigationType, XmCNavigationType, XmRNavigationType,
120
sizeof (unsigned char),
121
XtOffsetOf( struct _XmPrimitiveRec, primitive.navigation_type),
122
XmRImmediate, (XtPointer) XmSTICKY_TAB_GROUP},
126
static XtActionsRec actionsList[] =
128
{"SashAction", SashAction},
129
{"SashFocusIn", SashFocusIn},
130
{"SashFocusOut", SashFocusOut},
134
static XmBaseClassExtRec SashBaseClassExtRec = {
137
XmBaseClassExtVersion,
138
sizeof(XmBaseClassExtRec),
139
NULL, /* InitializePrehook */
140
NULL, /* SetValuesPrehook */
141
NULL, /* InitializePosthook */
142
NULL, /* SetValuesPosthook */
143
NULL, /* secondaryObjectClass */
144
NULL, /* secondaryCreate */
145
NULL, /* getSecRes data */
146
{ 0 }, /* fastSubclass flags */
147
NULL, /* get_values_prehook */
148
NULL, /* get_values_posthook */
149
NULL, /* classPartInitPrehook */
150
NULL, /* classPartInitPosthook*/
151
NULL, /* ext_resources */
152
NULL, /* compiled_ext_resources*/
153
0, /* num_ext_resources */
154
FALSE, /* use_sub_resources */
155
WidgetNavigable, /* widgetNavigable */
156
XmInheritFocusChange, /* focusChange */
159
externaldef(xmsashclassrec) XmSashClassRec xmSashClassRec = {
161
/* core class fields */
162
/* superclass */ (WidgetClass) &xmPrimitiveClassRec,
163
/* class name */ "XmSash",
164
/* size */ sizeof(XmSashRec),
165
/* class initialize */ ClassInitialize,
166
/* class_part_init */ ClassPartInitialize,
167
/* class_inited */ FALSE,
168
/* initialize */ Initialize,
169
/* initialize_hook */ NULL,
170
/* realize */ Realize,
171
/* actions */ actionsList,
172
/* num_actions */ XtNumber(actionsList),
173
/* resourses */ resources,
174
/* resource_count */ XtNumber(resources),
175
/* xrm_class */ NULLQUARK,
176
/* compress_motion */ TRUE,
177
/* compress_exposure */ XtExposeCompressMaximal,
178
/* compress_enter/lv */ TRUE,
179
/* visible_interest */ FALSE,
182
/* expose */ Redisplay,
183
/* set_values */ NULL,
184
/* set_values_hook */ NULL,
185
/* set_values_almost */ XtInheritSetValuesAlmost,
186
/* get_values_hook */ NULL,
187
/* accept_focus */ NULL,
188
/* version */ XtVersion,
189
/* callback_private */ NULL,
190
/* tm_table */ defTranslations,
191
/* query_geometry */ NULL,
192
NULL, /* display_accelerator */
193
(XtPointer)&SashBaseClassExtRec, /* extension */
197
XmInheritWidgetProc, /* Primitive border_highlight */
198
XmInheritWidgetProc, /* Primitive border_unhighlight */
199
NULL, /* translations */
200
NULL, /* arm_and_activate */
201
NULL, /* get resources */
202
0, /* num get_resources */
203
NULL, /* extension */
207
(XtPointer) NULL, /* extension */
212
externaldef(xmsashwidgetclass) WidgetClass xmSashWidgetClass =
213
(WidgetClass) &xmSashClassRec;
215
/************************************************************************
217
* ClassPartInitialize
218
* Set up the fast subclassing for the widget.
220
************************************************************************/
225
_XmFastSubclassInit(wc, XmSASH_BIT);
228
/************************************************************************
231
* Initialize the primitive part of class structure with
232
* routines to do special highlight & unhighlight for Sash.
234
************************************************************************/
236
ClassInitialize( void )
238
xmSashClassRec.primitive_class.border_highlight =
240
xmSashClassRec.primitive_class.border_unhighlight =
242
SashBaseClassExtRec.record_type = XmQmotif;
250
ArgList args, /* unused */
251
Cardinal *num_args ) /* unused */
253
XmSashWidget request = (XmSashWidget) rw ;
254
XmSashWidget new_w = (XmSashWidget) nw ;
255
if (request->core.width == 0)
256
new_w->core.width += SASHSIZE;
257
if (request->core.height == 0)
258
new_w->core.height += SASHSIZE;
259
new_w->sash.has_focus = False;
268
x = y = ((XmSashWidget) sash)->primitive.shadow_thickness;
270
XFillRectangle( XtDisplay( sash), XtWindow( sash),
271
((XmSashWidget) sash)->primitive.highlight_GC,
272
x,y, sash->core.width-(2*x), sash->core.height-(2*y));
281
x = y = ((XmSashWidget) sash)->primitive.shadow_thickness;
283
XClearArea( XtDisplay( sash), XtWindow( sash),
284
x,y, sash->core.width-(2*x), sash->core.height-(2*y),
288
static XmNavigability
292
if( _XmShellIsExclusive( wid) )
294
/* Preserve 1.0 behavior. (Why? Don't ask me!)
296
return XmNOT_NAVIGABLE ;
298
if( XtIsSensitive(wid)
299
&& ((XmPrimitiveWidget) wid)->primitive.traversal_on )
301
XmNavigationType nav_type = ((XmPrimitiveWidget) wid)
302
->primitive.navigation_type ;
303
if( (nav_type == XmSTICKY_TAB_GROUP)
304
|| (nav_type == XmEXCLUSIVE_TAB_GROUP)
305
|| ( (nav_type == XmTAB_GROUP)
306
&& !_XmShellIsExclusive( wid)) )
308
return XmTAB_NAVIGABLE ;
311
return XmNOT_NAVIGABLE ;
320
Cardinal *num_params )
322
register XmSashWidget sash = (XmSashWidget) w;
324
if (event->xany.type != FocusIn || !event->xfocus.send_event)
327
if (_XmGetFocusPolicy( (Widget) sash) == XmEXPLICIT)
331
XmeDrawShadows (XtDisplay (w), XtWindow (w),
332
sash->primitive.top_shadow_GC,
333
sash->primitive.bottom_shadow_GC,
334
0,0,w->core.width, w->core.height,
335
sash->primitive.shadow_thickness,
338
sash->sash.has_focus = True;
347
Cardinal *num_params )
349
register XmSashWidget sash = (XmSashWidget) w;
351
if (event->xany.type != FocusOut || !event->xfocus.send_event)
354
if (_XmGetFocusPolicy( (Widget) sash) == XmEXPLICIT)
357
XmeDrawShadows (XtDisplay (w), XtWindow (w),
358
sash->primitive.top_shadow_GC,
359
sash->primitive.bottom_shadow_GC,
360
0,0,w->core.width, w->core.height,
361
sash->primitive.shadow_thickness,
364
sash->sash.has_focus = False;
372
Cardinal *num_params )
374
register XmSashWidget sash = (XmSashWidget) widget;
375
SashCallDataRec call_data;
377
call_data.event = event;
378
call_data.params = params;
379
call_data.num_params = *num_params;
381
XtCallCallbackList(widget, sash->sash.sash_action, (XtPointer)&call_data);
387
XtValueMask *p_valueMask,
388
XSetWindowAttributes *attributes )
390
XmDisplay dd = (XmDisplay) XmGetXmDisplay(XtDisplay(w));
392
((XmDisplayInfo *)(dd->display.displayInfo))->SashCursor;
394
if (0L == SashCursor)
396
/* create some data shared among all instances on this
397
** display; the first one along can create it, and
398
** any one can remove it; note no reference count
401
((XmDisplayInfo *)(dd->display.displayInfo))->SashCursor =
402
XCreateFontCursor(XtDisplay(w), XC_crosshair);
403
XtAddCallback((Widget)dd, XtNdestroyCallback,
404
SashDisplayDestroyCallback, (XtPointer) NULL);
407
attributes->cursor = SashCursor;
408
XtCreateWindow (w, InputOutput, CopyFromParent,
409
*p_valueMask | CWCursor, attributes);
414
SashDisplayDestroyCallback
416
XtPointer client_data, /* unused */
417
XtPointer call_data ) /* unused */
419
XmDisplay dd = (XmDisplay) XmGetXmDisplay(XtDisplay(w));
421
if ((XmDisplay)NULL != dd)
424
((XmDisplayInfo *)(dd->display.displayInfo))->SashCursor;
425
if (0L != SashCursor)
427
XFreeCursor(XtDisplay(w), SashCursor);
429
((XmDisplayInfo *)(dd->display.displayInfo))->SashCursor= 0L;
438
/*************************************<->*************************************
440
* Redisplay (w, event)
444
* Cause the widget, identified by w, to be redisplayed.
449
* w = widget to be redisplayed;
450
* event = event structure identifying need for redisplay on this
460
*************************************<->***********************************/
468
register XmSashWidget sash = (XmSashWidget) w;
470
XmeDrawShadows (XtDisplay (w), XtWindow (w),
471
sash->primitive.top_shadow_GC,
472
sash->primitive.bottom_shadow_GC,
473
0,0,w->core.width, w->core.height,
474
sash->primitive.shadow_thickness,
477
if (sash->sash.has_focus) HighlightSash(w);