1 /*************************************<+>*************************************
2 *****************************************************************************
8 ** Description: Contains code for workSpace widget class.
10 *****************************************************************************
12 ** Copyright (c) 1988 by Hewlett-Packard Company
13 ** Copyright (c) 1988 by the Massachusetts Institute of Technology
15 ** Permission to use, copy, modify, and distribute this software
16 ** and its documentation for any purpose and without fee is hereby
17 ** granted, provided that the above copyright notice appear in all
18 ** copies and that both that copyright notice and this permission
19 ** notice appear in supporting documentation, and that the names of
20 ** Hewlett-Packard or M.I.T. not be used in advertising or publicity
21 ** pertaining to distribution of the software without specific, written
24 *****************************************************************************
25 *************************************<+>*************************************/
31 #include <X11/StringDefs.h>
32 #include <X11/keysymdef.h>
33 #include <X11/IntrinsicP.h>
34 #include <X11/Intrinsic.h>
37 #include <Xw/WorkSpace.h>
38 #include <Xw/WorkSpaceP.h>
41 /* Event procedures referenced in the actions list */
43 static void KeyDown();
46 static void Release();
49 /* Default translation table and action list */
51 static char defaultTranslations
[] =
52 "<KeyDown>: keydown()\n\
54 <BtnDown>: select()\n\
56 <EnterWindow>: enter()\n\
57 <LeaveWindow>: leave()";
60 static XtActionsRec actionsList
[] =
62 { "keydown", (XtActionProc
) KeyDown
},
63 { "keyup", (XtActionProc
) KeyUp
},
64 { "select", (XtActionProc
) Select
},
65 { "release", (XtActionProc
) Release
},
66 { "enter", (XtActionProc
) _XwPrimitiveEnter
},
67 { "leave", (XtActionProc
) _XwPrimitiveLeave
},
71 /* Resource list for WorkSpace */
73 static XtResource resources
[] =
76 XtNexpose
, XtCCallback
, XtRCallback
, sizeof (caddr_t
),
77 XtOffset (XwWorkSpaceWidget
, workSpace
.expose
),
78 XtRPointer
, (caddr_t
) NULL
82 XtNresize
, XtCCallback
, XtRCallback
, sizeof (caddr_t
),
83 XtOffset (XwWorkSpaceWidget
, workSpace
.resize
),
84 XtRPointer
, (caddr_t
) NULL
88 XtNkeyDown
, XtCCallback
, XtRCallback
, sizeof (caddr_t
),
89 XtOffset (XwWorkSpaceWidget
, workSpace
.key_down
),
90 XtRPointer
, (caddr_t
) NULL
94 XtNkeyUp
, XtCCallback
, XtRCallback
, sizeof (caddr_t
),
95 XtOffset (XwWorkSpaceWidget
, workSpace
.key_up
),
96 XtRPointer
, (caddr_t
) NULL
101 /* Static routine definitions */
103 static void Initialize();
104 static void Redisplay();
105 static void Resize();
106 static void Destroy();
107 static Boolean
SetValues();
110 /* The WorkSpace class record definition */
112 XwWorkSpaceClassRec XwworkSpaceClassRec
=
115 (WidgetClass
) &XwprimitiveClassRec
, /* superclass */
116 "XwWorkSpace", /* class_name */
117 sizeof(XwWorkSpaceRec
), /* widget_size */
118 NULL
, /* class_initialize */
119 NULL
, /* class_part_initialize */
120 FALSE
, /* class_inited */
121 (XtInitProc
) Initialize
, /* initialize */
122 NULL
, /* initialize_hook */
123 _XwRealize
, /* realize */
124 actionsList
, /* actions */
125 XtNumber(actionsList
), /* num_actions */
126 resources
, /* resources */
127 XtNumber(resources
), /* num_resources */
128 NULLQUARK
, /* xrm_class */
129 TRUE
, /* compress_motion */
130 TRUE
, /* compress_exposure */
131 TRUE
, /* compress_enterleave */
132 FALSE
, /* visible_interest */
133 (XtWidgetProc
) Destroy
, /* destroy */
134 (XtWidgetProc
) Resize
, /* resize */
135 (XtExposeProc
) Redisplay
, /* expose */
136 (XtSetValuesFunc
) SetValues
, /* set_values */
137 NULL
, /* set_values_hook */
138 XtInheritSetValuesAlmost
, /* set_values_almost */
139 NULL
, /* get_values_hook */
140 NULL
, /* accept_focus */
141 XtVersion
, /* version */
142 NULL
, /* callback private */
143 defaultTranslations
, /* tm_table */
144 NULL
, /* query_geometry */
145 /* display_accelerator */ XtInheritDisplayAccelerator
,
150 NULL
, /* Primitive border_highlight */
151 NULL
, /* Primitive border_unhighlight */
152 NULL
, /* Primitive select_proc */
153 NULL
, /* Primitive release_proc */
154 NULL
, /* Primitive toggle_proc */
158 WidgetClass XwworkSpaceWidgetClass
= (WidgetClass
) &XwworkSpaceClassRec
;
163 /************************************************************************
166 * The main widget instance initialization routine.
168 ************************************************************************/
170 static void Initialize (request
, new)
171 XwWorkSpaceWidget request
, new;
174 if (request
-> core
.width
== 0)
175 new -> core
.width
+= 20;
176 if (request
-> core
.height
== 0)
177 new -> core
.height
+= 20;
183 /************************************************************************
186 * Draw the traversal/enter border, and
187 * invoke the application exposure callbacks.
189 ************************************************************************/
191 static void Redisplay (hw
, event
, region
)
192 XwWorkSpaceWidget hw
;
197 if (hw
-> primitive
.highlighted
)
198 _XwHighlightBorder (hw
);
199 else if (hw
-> primitive
.display_highlighted
)
200 _XwUnhighlightBorder (hw
);
202 XtCallCallbacks ((Widget
)hw
, XtNexpose
, region
);
208 /************************************************************************
211 * Invoke the application resize callbacks.
213 ************************************************************************/
215 static void Resize (hw
)
216 XwWorkSpaceWidget hw
;
219 XtCallCallbacks ((Widget
)hw
, XtNresize
, NULL
);
225 /************************************************************************
228 * Remove the callback lists.
230 ************************************************************************/
232 static void Destroy (hw
)
233 XwWorkSpaceWidget hw
;
236 XtRemoveAllCallbacks ((Widget
)hw
, XtNexpose
);
237 XtRemoveAllCallbacks ((Widget
)hw
, XtNresize
);
238 XtRemoveAllCallbacks ((Widget
)hw
, XtNkeyDown
);
244 /************************************************************************
248 ************************************************************************/
250 static Boolean
SetValues (current
, request
, new)
251 XwWorkSpaceWidget current
, request
, new;
260 /************************************************************************
263 * This function processes key presses occuring on the workSpace.
265 ************************************************************************/
267 static void KeyDown (hw
, event
)
268 XwWorkSpaceWidget hw
;
269 XButtonPressedEvent
* event
;
272 XtCallCallbacks ((Widget
)hw
, XtNkeyDown
, event
);
276 /************************************************************************
279 * This function processes key releases occuring on the workSpace.
281 ************************************************************************/
283 static void KeyUp (hw
, event
)
284 XwWorkSpaceWidget hw
;
285 XButtonPressedEvent
* event
;
288 XtCallCallbacks ((Widget
)hw
, XtNkeyUp
, event
);
294 /************************************************************************
297 * This function processes selections occuring on the workSpace.
299 ************************************************************************/
301 static void Select (hw
, event
)
302 XwWorkSpaceWidget hw
;
303 XButtonPressedEvent
* event
;
306 XtCallCallbacks ((Widget
)hw
, XtNselect
, event
);
312 /************************************************************************
315 * This function processes releases occuring on the workSpace.
317 ************************************************************************/
319 static void Release (hw
, event
)
320 XwWorkSpaceWidget hw
;
324 XtCallCallbacks ((Widget
)hw
, XtNrelease
, event
);