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 librararies 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 ************************************<+>*************************************/
58 #include "DisplayAreaP.h"
59 #include "DisplayAreaI.h"
61 #include "CallbacksI.h"
66 /******** Private Function Declarations ********/
67 /******** End Private Function Declarations ********/
69 /******** End Private Defines ********/
71 /******** Private Variable Declarations ********/
73 /******** End Private Variable Declarations ********/
75 /******************************************************************************
77 ******************************************************************************/
78 /******************************************************************************
79 * Semi Public Functions
80 *****************************************************************************/
81 /*****************************************************************************
82 * Function: _DtHelpCopyAction
84 * _DtHelpCopyAction - Copy the current info to the clipboard
86 *****************************************************************************/
97 XtSetArg(args[0], XmNuserData, &userData);
98 XtGetValues(widget, args, 1);
100 _DtHelpInitiateClipboard(userData);;
102 } /* End _DtHelpCopyAction */
104 /*****************************************************************************
105 * Function: _DtHelpDeSelectAll
107 * _DtHelpDeSelectAll - Deselects the information in the widget.
109 *****************************************************************************/
115 Cardinal *num_params)
120 XtSetArg(args[0], XmNuserData, &userData);
121 XtGetValues(widget, args, 1);
123 if (userData != NULL)
124 _DtHelpClearSelection (userData);
126 } /* End _DtHelpDeSelectAll */
128 /*****************************************************************************
129 * Function: _DtHelpSelectAll
131 * _DtHelpSelectAll - Selects all the information in the widget.
133 *****************************************************************************/
139 Cardinal *num_params)
144 XtSetArg(args[0], XmNuserData, &userData);
145 XtGetValues(widget, args, 1);
147 if (userData != NULL)
149 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) userData;
151 _DtCanvasMoveTraversal(pDAS->canvas, _DtCvTRAVERSAL_OFF, False, True,
152 NULL, NULL, NULL, NULL, NULL);
153 _DtHelpGetClearSelection (widget, userData);
154 _DtCanvasProcessSelection(pDAS->canvas, 0, 0, _DtCvSELECTION_START);
155 _DtCanvasProcessSelection(pDAS->canvas, pDAS->dispUseWidth,
156 pDAS->maxYpos, _DtCvSELECTION_END);
157 _DtCanvasMoveTraversal(pDAS->canvas, _DtCvTRAVERSAL_ON, False, True,
158 NULL, NULL, NULL, NULL, NULL);
159 pDAS->text_selected = True;
162 } /* End _DtHelpSelectAll */
164 /*****************************************************************************
165 * Function: _DtHelpActivateLink
167 * _DtHelpSelectAll - Selects all the information in the widget.
169 *****************************************************************************/
171 _DtHelpActivateLink (
175 Cardinal *num_params)
178 DtHelpDispAreaStruct *pDAS;
179 _DtCvLinkInfo ceHyper;
180 DtHelpHyperTextStruct callData;
182 XtSetArg(args[0], XmNuserData, &pDAS);
183 XtGetValues(widget, args, 1);
190 if (_DtCvSTATUS_OK == _DtCanvasGetCurLink(pDAS->canvas, &ceHyper))
192 callData.reason = XmCR_ACTIVATE;
193 callData.event = event;
194 callData.window = XtWindow (pDAS->dispWid);
195 callData.specification = ceHyper.specification;
196 callData.hyper_type = ceHyper.hyper_type;
197 callData.window_hint = ceHyper.win_hint;
198 (*(pDAS->hyperCall)) (pDAS, pDAS->clientData, &callData);
201 else /* dtinfo context */
203 _DtCvPointer mark_enclosure = NULL;
207 status = _DtCanvasGetCurTraversal(pDAS->canvas, &ceHyper,
210 if (status == _DtCvSTATUS_LINK)
212 callData.reason = XmCR_ACTIVATE;
213 callData.event = event;
214 callData.window = XtWindow (pDAS->dispWid);
215 callData.specification = ceHyper.specification;
216 callData.hyper_type = ceHyper.hyper_type;
217 callData.window_hint = ceHyper.win_hint;
218 (*(pDAS->hyperCall)) (pDAS, pDAS->clientData, &callData);
220 else if (status == _DtCvSTATUS_MARK)
222 callData.reason = XmCR_ACTIVATE;
223 callData.event = event;
224 callData.window = XtWindow (pDAS->dispWid);
225 callData.specification = mark_enclosure;
226 callData.hyper_type = -1; /* signifies it's a mark */
227 callData.window_hint = 0;
228 (*(pDAS->hyperCall)) (pDAS, pDAS->clientData, &callData);
231 /* otherwise do nothing */
234 } /* End _DtHelpActivateLink */
236 /*****************************************************************************
237 * Function: _DtHelpPageUpOrDown
239 * _DtHelpPageUpOrDown - Selects all the information in the widget.
241 *****************************************************************************/
243 _DtHelpPageUpOrDown (
247 Cardinal *num_params)
255 XtSetArg(args[0], XmNuserData, &userData);
256 XtGetValues(widget, args, 1);
258 if (userData != NULL)
260 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) userData;
262 diff = pDAS->dispUseHeight - pDAS->lineHeight;
264 keyPressed = atoi(*params);
268 newY = pDAS->firstVisible + diff;
271 * Is the new Y position too large?
274 if (newY + ((int)pDAS->dispUseHeight) > pDAS->maxYpos)
275 newY = pDAS->maxYpos - pDAS->dispUseHeight;
278 * Is the new Y before the begining?
284 if (newY != pDAS->firstVisible)
286 pDAS->firstVisible = newY;
287 XtSetArg(args[0], XmNvalue, newY);
288 XtSetValues (pDAS->vertScrollWid, args, 1);
290 if (pDAS->vScrollNotify)
291 (pDAS->vScrollNotify)(pDAS->clientData, pDAS->firstVisible);
293 _DtHelpCleanAndDrawWholeCanvas (userData);
297 } /* End _DtHelpPageUpOrDown */
299 /*****************************************************************************
300 * Function: _DtHelpPageLeftOrRight
302 * _DtHelpPageLeftOrRight - Selects all the information in the widget.
304 *****************************************************************************/
306 _DtHelpPageLeftOrRight (
310 Cardinal *num_params)
318 XtSetArg(args[0], XmNuserData, &userData);
319 XtGetValues(widget, args, 1);
321 if (userData != NULL)
323 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) userData;
325 diff = pDAS->dispUseWidth - ((int) pDAS->charWidth / 10);
327 keyPressed = atoi(*params);
331 newX = pDAS->virtualX + diff;
334 * Is the new X position too large?
337 if (newX + ((int)pDAS->dispUseWidth) > pDAS->maxX)
338 newX = pDAS->maxX - pDAS->dispUseWidth;
341 * Is the new X before the begining?
347 if (newX != pDAS->virtualX)
349 pDAS->virtualX = newX;
350 XtSetArg(args[0], XmNvalue, newX);
351 XtSetValues (pDAS->horzScrollWid, args, 1);
353 _DtHelpCleanAndDrawWholeCanvas (userData);
357 } /* End _DtHelpPageLeftOrRight */
359 /*****************************************************************************
360 * Function: _DtHelpNextLink
362 * _DtHelpNextLink - Moves the traversal to the requested hypertext link.
364 *****************************************************************************/
370 Cardinal *num_params)
372 _DtCvTraversalCmd cmd = _DtCvTRAVERSAL_NEXT;
381 XtSetArg(args[0], XmNuserData, &userData);
382 XtGetValues(widget, args, 1);
384 if (userData != NULL)
386 DtHelpDispAreaStruct *pDAS = (DtHelpDispAreaStruct *) userData;
388 switch(atoi(*params))
390 case 0: cmd = _DtCvTRAVERSAL_PREV;
392 case 2: cmd = _DtCvTRAVERSAL_TOP;
394 case 3: cmd = _DtCvTRAVERSAL_BOTTOM;
398 if (_DtCvSTATUS_OK == _DtCanvasMoveTraversal(pDAS->canvas, cmd, False,
399 (XtIsRealized(pDAS->dispWid) ? True : False),
400 NULL, &newX, &newY, NULL, &height))
403 * take into account our traversal indicator
405 newY -= pDAS->lineThickness;
406 height += (2 * pDAS->lineThickness);
408 top = pDAS->firstVisible;
409 diff = ((int) pDAS->dispUseHeight) * 2 / 3;
413 if (cmd == _DtCvTRAVERSAL_TOP && newY <= diff)
416 else if (newY + height > top + ((int) pDAS->dispUseHeight))
418 top = newY + height - ((int) pDAS->dispUseHeight);
419 if (cmd == _DtCvTRAVERSAL_BOTTOM &&
420 newY >= (pDAS->maxYpos - diff))
421 top = pDAS->maxYpos - pDAS->dispUseHeight;
424 if (top != pDAS->firstVisible)
426 pDAS->firstVisible = top;
428 if (top + ((int)pDAS->dispUseHeight) > pDAS->maxYpos)
430 pDAS->firstVisible = pDAS->maxYpos - pDAS->dispUseHeight;
431 if (pDAS->firstVisible < 0)
432 pDAS->firstVisible = 0;
435 XtSetArg (args[0], XmNvalue, pDAS->firstVisible);
436 XtSetValues (pDAS->vertScrollWid, args, 1);
438 if (pDAS->vScrollNotify)
439 (pDAS->vScrollNotify)(pDAS->clientData, pDAS->firstVisible);
442 * re-draw the information
444 _DtHelpCleanAndDrawWholeCanvas (userData);
449 } /* End _DtHelpNextLink */