2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: Actions.c /main/8 1996/10/30 10:03:40 pascale $ */
24 /************************************<+>*************************************
25 ****************************************************************************
29 ** Project: Display Area Library
31 ** Description: This body of code handles the actions for the
34 ** (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992 Hewlett-Packard Company
36 ** (c) Copyright 1993, 1994 Hewlett-Packard Company
37 ** (c) Copyright 1993, 1994 International Business Machines Corp.
38 ** (c) Copyright 1993, 1994 Sun Microsystems, Inc.
39 ** (c) Copyright 1993, 1994 Novell, Inc.
42 ****************************************************************************
43 ************************************<+>*************************************/
59 #include "DisplayAreaP.h"
60 #include "DisplayAreaI.h"
62 #include "CallbacksI.h"
67 /******** Private Function Declarations ********/
68 /******** End Private Function Declarations ********/
70 /******** End Private Defines ********/
72 /******** Private Variable Declarations ********/
74 /******** End Private Variable Declarations ********/
76 /******************************************************************************
78 ******************************************************************************/
79 /******************************************************************************
80 * Semi Public Functions
81 *****************************************************************************/
82 /*****************************************************************************
83 * Function: _DtHelpCopyAction
85 * _DtHelpCopyAction - Copy the current info to the clipboard
87 *****************************************************************************/
98 XtSetArg(args[0], XmNuserData, &userData);
99 XtGetValues(widget, args, 1);
101 _DtHelpInitiateClipboard(userData);;
103 } /* End _DtHelpCopyAction */
105 /*****************************************************************************
106 * Function: _DtHelpDeSelectAll
108 * _DtHelpDeSelectAll - Deselects the information in the widget.
110 *****************************************************************************/
116 Cardinal *num_params)
121 XtSetArg(args[0], XmNuserData, &userData);
122 XtGetValues(widget, args, 1);
124 if (userData != NULL)
125 _DtHelpClearSelection (userData);
127 } /* End _DtHelpDeSelectAll */
129 /*****************************************************************************
130 * Function: _DtHelpSelectAll
132 * _DtHelpSelectAll - Selects all the information in the widget.
134 *****************************************************************************/
140 Cardinal *num_params)
145 XtSetArg(args[0], XmNuserData, &userData);
146 XtGetValues(widget, args, 1);
148 if (userData != NULL)
150 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) userData;
152 _DtCanvasMoveTraversal(pDAS->canvas, _DtCvTRAVERSAL_OFF, False, True,
153 NULL, NULL, NULL, NULL, NULL);
154 _DtHelpGetClearSelection (widget, userData);
155 _DtCanvasProcessSelection(pDAS->canvas, 0, 0, _DtCvSELECTION_START);
156 _DtCanvasProcessSelection(pDAS->canvas, pDAS->dispUseWidth,
157 pDAS->maxYpos, _DtCvSELECTION_END);
158 _DtCanvasMoveTraversal(pDAS->canvas, _DtCvTRAVERSAL_ON, False, True,
159 NULL, NULL, NULL, NULL, NULL);
160 pDAS->text_selected = True;
163 } /* End _DtHelpSelectAll */
165 /*****************************************************************************
166 * Function: _DtHelpActivateLink
168 * _DtHelpSelectAll - Selects all the information in the widget.
170 *****************************************************************************/
172 _DtHelpActivateLink (
176 Cardinal *num_params)
179 DtHelpDispAreaStruct *pDAS;
180 _DtCvLinkInfo ceHyper;
181 DtHelpHyperTextStruct callData;
183 XtSetArg(args[0], XmNuserData, &pDAS);
184 XtGetValues(widget, args, 1);
191 if (_DtCvSTATUS_OK == _DtCanvasGetCurLink(pDAS->canvas, &ceHyper))
193 callData.reason = XmCR_ACTIVATE;
194 callData.event = event;
195 callData.window = XtWindow (pDAS->dispWid);
196 callData.specification = ceHyper.specification;
197 callData.hyper_type = ceHyper.hyper_type;
198 callData.window_hint = ceHyper.win_hint;
199 (*(pDAS->hyperCall)) (pDAS, pDAS->clientData, &callData);
202 else /* dtinfo context */
204 _DtCvPointer mark_enclosure = NULL;
208 status = _DtCanvasGetCurTraversal(pDAS->canvas, &ceHyper,
211 if (status == _DtCvSTATUS_LINK)
213 callData.reason = XmCR_ACTIVATE;
214 callData.event = event;
215 callData.window = XtWindow (pDAS->dispWid);
216 callData.specification = ceHyper.specification;
217 callData.hyper_type = ceHyper.hyper_type;
218 callData.window_hint = ceHyper.win_hint;
219 (*(pDAS->hyperCall)) (pDAS, pDAS->clientData, &callData);
221 else if (status == _DtCvSTATUS_MARK)
223 callData.reason = XmCR_ACTIVATE;
224 callData.event = event;
225 callData.window = XtWindow (pDAS->dispWid);
226 callData.specification = mark_enclosure;
227 callData.hyper_type = -1; /* signifies it's a mark */
228 callData.window_hint = 0;
229 (*(pDAS->hyperCall)) (pDAS, pDAS->clientData, &callData);
232 /* otherwise do nothing */
235 } /* End _DtHelpActivateLink */
237 /*****************************************************************************
238 * Function: _DtHelpPageUpOrDown
240 * _DtHelpPageUpOrDown - Selects all the information in the widget.
242 *****************************************************************************/
244 _DtHelpPageUpOrDown (
248 Cardinal *num_params)
256 XtSetArg(args[0], XmNuserData, &userData);
257 XtGetValues(widget, args, 1);
259 if (userData != NULL)
261 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) userData;
263 diff = pDAS->dispUseHeight - pDAS->lineHeight;
265 keyPressed = atoi(*params);
269 newY = pDAS->firstVisible + diff;
272 * Is the new Y position too large?
275 if (newY + ((int)pDAS->dispUseHeight) > pDAS->maxYpos)
276 newY = pDAS->maxYpos - pDAS->dispUseHeight;
279 * Is the new Y before the begining?
285 if (newY != pDAS->firstVisible)
287 pDAS->firstVisible = newY;
288 XtSetArg(args[0], XmNvalue, newY);
289 XtSetValues (pDAS->vertScrollWid, args, 1);
291 if (pDAS->vScrollNotify)
292 (pDAS->vScrollNotify)(pDAS->clientData, pDAS->firstVisible);
294 _DtHelpCleanAndDrawWholeCanvas (userData);
298 } /* End _DtHelpPageUpOrDown */
300 /*****************************************************************************
301 * Function: _DtHelpPageLeftOrRight
303 * _DtHelpPageLeftOrRight - Selects all the information in the widget.
305 *****************************************************************************/
307 _DtHelpPageLeftOrRight (
311 Cardinal *num_params)
319 XtSetArg(args[0], XmNuserData, &userData);
320 XtGetValues(widget, args, 1);
322 if (userData != NULL)
324 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) userData;
326 diff = pDAS->dispUseWidth - ((int) pDAS->charWidth / 10);
328 keyPressed = atoi(*params);
332 newX = pDAS->virtualX + diff;
335 * Is the new X position too large?
338 if (newX + ((int)pDAS->dispUseWidth) > pDAS->maxX)
339 newX = pDAS->maxX - pDAS->dispUseWidth;
342 * Is the new X before the begining?
348 if (newX != pDAS->virtualX)
350 pDAS->virtualX = newX;
351 XtSetArg(args[0], XmNvalue, newX);
352 XtSetValues (pDAS->horzScrollWid, args, 1);
354 _DtHelpCleanAndDrawWholeCanvas (userData);
358 } /* End _DtHelpPageLeftOrRight */
360 /*****************************************************************************
361 * Function: _DtHelpNextLink
363 * _DtHelpNextLink - Moves the traversal to the requested hypertext link.
365 *****************************************************************************/
371 Cardinal *num_params)
373 _DtCvTraversalCmd cmd = _DtCvTRAVERSAL_NEXT;
382 XtSetArg(args[0], XmNuserData, &userData);
383 XtGetValues(widget, args, 1);
385 if (userData != NULL)
387 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) userData;
389 switch(atoi(*params))
391 case 0: cmd = _DtCvTRAVERSAL_PREV;
393 case 2: cmd = _DtCvTRAVERSAL_TOP;
395 case 3: cmd = _DtCvTRAVERSAL_BOTTOM;
399 if (_DtCvSTATUS_OK == _DtCanvasMoveTraversal(pDAS->canvas, cmd, False,
400 (XtIsRealized(pDAS->dispWid) ? True : False),
401 NULL, &newX, &newY, NULL, &height))
404 * take into account our traversal indicator
406 newY -= pDAS->lineThickness;
407 height += (2 * pDAS->lineThickness);
409 top = pDAS->firstVisible;
410 diff = ((int) pDAS->dispUseHeight) * 2 / 3;
414 if (cmd == _DtCvTRAVERSAL_TOP && newY <= diff)
417 else if (newY + height > top + ((int) pDAS->dispUseHeight))
419 top = newY + height - ((int) pDAS->dispUseHeight);
420 if (cmd == _DtCvTRAVERSAL_BOTTOM &&
421 newY >= (pDAS->maxYpos - diff))
422 top = pDAS->maxYpos - pDAS->dispUseHeight;
425 if (top != pDAS->firstVisible)
427 pDAS->firstVisible = top;
429 if (top + ((int)pDAS->dispUseHeight) > pDAS->maxYpos)
431 pDAS->firstVisible = pDAS->maxYpos - pDAS->dispUseHeight;
432 if (pDAS->firstVisible < 0)
433 pDAS->firstVisible = 0;
436 XtSetArg (args[0], XmNvalue, pDAS->firstVisible);
437 XtSetValues (pDAS->vertScrollWid, args, 1);
439 if (pDAS->vScrollNotify)
440 (pDAS->vScrollNotify)(pDAS->clientData, pDAS->firstVisible);
443 * re-draw the information
445 _DtHelpCleanAndDrawWholeCanvas (userData);
450 } /* End _DtHelpNextLink */