1 /* $TOG: XUICreate.c /main/22 1997/06/18 17:33:46 samborn $ */
2 /************************************<+>*************************************
3 ****************************************************************************
7 ** Project: Cde Help System
9 ** Description: Builds a GUI containing a Drawn Button with scroll
10 ** bars and wraps it around a canvas.
12 ****************************************************************************
13 ************************************<+>*************************************/
15 * (c) Copyright 1996 Digital Equipment Corporation.
16 * (c) Copyright 1987, 1988, 1989, 1990, 1991, 1992,
17 1993, 1994, 1996 Hewlett-Packard Company.
18 * (c) Copyright 1993, 1994, 1996 International Business Machines Corp.
19 * (c) Copyright 1993, 1994, 1996 Sun Microsystems, Inc.
20 * (c) Copyright 1993, 1994, 1996 Novell, Inc.
21 * (c) Copyright 1996 FUJITSU LIMITED.
22 * (c) Copyright 1996 Hitachi.
32 #include <Xm/AtomMgr.h>
33 #include <Xm/DrawnB.h>
35 #include <Xm/ScrollBar.h>
41 #include "CanvasSegP.h"
47 #include "DisplayAreaP.h"
48 #include "CallbacksI.h"
49 #include "XUICreateI.h"
51 #include "FontAttrI.h"
53 #include "FormatUtilI.h"
55 #include "XInterfaceI.h"
61 /******** Private Function Declarations ********/
62 static Boolean get_fontsetproperty(
65 unsigned long *value_return);
66 /******** End Private Function Declarations ********/
68 /******** Private Variables ********/
70 static _DtCvVirtualInfo DefVirtFunctions =
72 _DtHelpDAGetCvsMetrics, /* void (*_DtCvGetMetrics)() */
73 _DtHelpDARenderElem, /* void (*_DtCvRenderElem)() */
74 _DtHelpDAGetStrWidth, /* _DtCvUnit (*_DtCvGetElemWidth)() */
75 _DtHelpDAGetFontMetrics, /* void (*_DtCvGetFontMetrics)() */
76 _DtHelpDABuildSelection, /* void (*_DtCvBuildSelection)() */
77 NULL, /* _DtCvStatus (*_DtCvFilterExecCmd)()*/
80 /******** End Private Variables ********/
82 /******** Semi-Private Variables ********/
83 /******** End Semi-Private Variables ********/
85 /******************************************************************************
87 * Here are the type and variable declarations for finding view subresources.
89 *****************************************************************************/
92 * These are used to parse subresources for the text display areas.
109 static XtResource Resources[] = {
111 "leading", "Leading", XmRInt, sizeof(int),
112 XtOffset(DAArgsPtr, leading), XmRImmediate, (XtPointer) 1
116 XmNmarginWidth, XmCMarginWidth, XmRInt, sizeof(int),
117 XtOffset(DAArgsPtr, marginWidth), XmRImmediate, (XtPointer) 5
121 XmNmarginHeight, XmCMarginHeight, XmRInt, sizeof(int),
122 XtOffset(DAArgsPtr, marginHeight), XmRImmediate, (XtPointer) 5
126 "moveThreshold", "MoveThreshold", XmRInt, sizeof(int),
127 XtOffset(DAArgsPtr, moveThreshold), XmRImmediate, (XtPointer) 10
131 XmNinitialDelay, XmCInitialDelay, XmRInt, sizeof(int),
132 XtOffset(DAArgsPtr, initialDelay), XmRImmediate, (XtPointer) 250
136 XmNrepeatDelay, XmCRepeatDelay, XmRInt, sizeof(int),
137 XtOffset(DAArgsPtr, repeatDelay), XmRImmediate, (XtPointer) 50
141 "userFont", XmCFontList, XmRFontList, sizeof (XmFontList),
142 XtOffset(DAArgsPtr, userFont), XmRString, "Fixed"
146 "searchColor", "SearchColor", XtRPixel, sizeof (Pixel),
147 XtOffset(DAArgsPtr, search_color), XmRString, "blue"
152 static String DrawnBTransTable = "\
153 ~s ~m ~a <Key>Return: ActivateLink()\n\
154 ~s c ~m ~a <Key>backslash: DeSelectAll()\n\
155 ~s c ~m ~a <Key>slash: SelectAll()\n\
156 ~s ~m ~a <Key>space: ActivateLink()\n\
157 <Key>osfActivate: ActivateLink()\n\
158 <Key>osfCopy: CopyToClipboard()\n\
159 ~c <Key>osfDown: NextLink(1)\n\
160 c <Key>osfDown: PageUpOrDown(1)\n\
161 ~s c ~m ~a <Key>osfInsert: CopyToClipboard()\n\
162 ~c <Key>osfLeft: NextLink(0)\n\
163 c <Key>osfLeft: PageLeftOrRight(0)\n\
164 ~c <Key>osfPageDown: PageUpOrDown(1)\n\
165 c <Key>osfPageDown: PageLeftOrRight(1)\n\
166 <Key>osfPageLeft: PageLeftOrRight(0)\n\
167 <Key>osfPageRight: PageLeftOrRight(1)\n\
168 ~c <Key>osfPageUp: PageUpOrDown(0)\n\
169 c <Key>osfPageUp: PageLeftOrRight(0)\n\
170 ~c <Key>osfRight: NextLink(1)\n\
171 c <Key>osfRight: PageLeftOrRight(1)\n\
172 ~s ~c <Key>osfSelect: ActivateLink()\n\
173 ~c <Key>osfUp: NextLink(0)\n\
174 c <Key>osfUp: PageUpOrDown(0)\n\
175 c <Key>osfBeginLine: NextLink(2)\n\
176 c <Key>osfEndLine: NextLink(3)\
179 static XtTranslations DrawnBTrans = NULL;
181 /*********************************************************************
183 *********************************************************************/
184 /* This function returns the max value of XGetFontProperty calls for each
185 * font in the fontset.
191 unsigned long *value_return)
194 XFontStruct **font_list;
200 numfont=XFontsOfFontSet(fontset,&font_list,&name_list);
201 for(i = 0; i < numfont; i++) {
202 if(XGetFontProperty(font_list[i], atom, &value) == TRUE) {
204 *value_return = value;
208 if(value > *value_return)
209 *value_return = value;
217 * This function returns the underline distance and size for the base
223 DtHelpDispAreaStruct *pDAS,
224 int *ret_underThick )
228 XFontSetExtents *extents;
231 * cast the parameter as a pointer to a long though the value
232 * returned is really a int.
234 idx = __DtHelpDefaultFontIndexGet(pDAS);
237 myFont = (XtPointer)__DtHelpFontSetGet(pDAS->font_info, idx);
238 if (get_fontsetproperty((XFontSet)myFont, XA_UNDERLINE_POSITION,
239 ((unsigned long *) &(pDAS->underLine))) == FALSE)
241 extents = XExtentsOfFontSet((XFontSet)myFont);
242 pDAS->underLine = ((int)(extents->max_ink_extent.height +
243 extents->max_ink_extent.y)) / 2;
248 myFont = (XtPointer)__DtHelpFontStructGet(pDAS->font_info, idx);
249 if (XGetFontProperty((XFontStruct *)myFont, XA_UNDERLINE_POSITION,
250 ((unsigned long *) &(pDAS->underLine))) == FALSE)
251 pDAS->underLine = ((XFontStruct *)myFont)->max_bounds.descent / 2;
255 * if we do not find an underline thickness for the font
256 * use 15% of the font height.
258 * cast the parameter to a pointer to a long though the value
259 * returned is really a unsigned int.
263 if (get_fontsetproperty((XFontSet)myFont, XA_UNDERLINE_THICKNESS,
264 ((unsigned long *) ret_underThick)) == FALSE)
265 *ret_underThick = pDAS->lineHeight * 15 / 100;
269 if (XGetFontProperty((XFontStruct *)myFont, XA_UNDERLINE_THICKNESS,
270 ((unsigned long *) ret_underThick)) == FALSE)
271 *ret_underThick = pDAS->lineHeight * 15 / 100;
276 * now adjust the underline depth so that the when the underline is
277 * drawn the top of the line is UNDERLINE_POSITION pixels below
281 * SYSTEM - ifdef this for other architectures.
282 * an example of Hewlett-Packard's implementation is given for reference.
284 /* On Hewlett-Packard machines lines are */
285 /* drawn like this: */
287 /* line width 1: y-> **************** */
289 /* **************** */
290 /* line width 2: y-> **************** */
292 /* **************** */
293 /* line width 3: y-> **************** */
294 /* **************** */
296 /* **************** */
297 /* **************** */
298 /* line width 4: y-> **************** */
299 /* **************** */
301 /* **************** */
302 /* **************** */
303 /* line width 5: y-> **************** */
304 /* **************** */
305 /* **************** */
308 pDAS->underLine = pDAS->underLine + (*ret_underThick) / 2;
312 /*********************************************************************
314 *********************************************************************/
315 /*********************************************************************
318 * CreateDA creates a Text Graphic area with the appropriate scroll bars.
320 *********************************************************************/
327 Boolean traversal_flag,
328 _DtCvValue honor_size,
329 _DtCvRenderType render_type,
332 unsigned short media_resolution,
333 void (*hyperTextCB)(),
335 int (*exec_ok_routine)(),
336 XtPointer client_data,
337 XmFontList default_list )
339 DtHelpDispAreaStruct *pDAS;
345 int maxFontCharWidth;
349 short shadowThick, highThick;
350 Dimension hBarHeight = 0;
351 Dimension vBarWidth = 0;
356 Display *dpy = XtDisplay(parent);
357 Screen *retScr = XtScreen(parent);
358 int screen = XScreenNumberOfScreen(retScr);
364 unsigned long gcMask;
366 unsigned long char_width;
370 XFontStruct *tmpFont = NULL;
371 XtPointer default_font = NULL;
372 XRectangle rectangle[1];
374 XmFontContext fontContext;
375 XmFontListEntry fontEntry;
378 /* Allocate the Display Area. */
379 pDAS = (DtHelpDispAreaStruct *) XtMalloc(sizeof(DtHelpDispAreaStruct));
384 XtGetSubresources(parent, &DA_args, name, "XmDrawnButton",
385 Resources, XtNumber(Resources), NULL, 0);
393 * initialize the structure variables.
395 pDAS->text_selected = False;
396 pDAS->primary = False;
397 pDAS->select_state = _DtHelpNothingDoing;
402 pDAS->toc_flag = _DT_HELP_SHADOW_TRAVERSAL | _DT_HELP_NOT_INITIALIZED;
408 pDAS->firstVisible = 0;
409 pDAS->visibleCount = rows;
411 pDAS->neededFlags = 0;
412 pDAS->vert_init_scr = DA_args.initialDelay;
413 pDAS->vert_rep_scr = DA_args.repeatDelay;
414 pDAS->horz_init_scr = DA_args.initialDelay;
415 pDAS->horz_rep_scr = DA_args.repeatDelay;
416 pDAS->moveThreshold = DA_args.moveThreshold;
417 pDAS->marginWidth = DA_args.marginWidth;
418 pDAS->marginHeight = DA_args.marginHeight;
419 pDAS->searchColor = DA_args.search_color;
421 pDAS->spc_chars = NULL;
422 pDAS->scr_timer_id = NULL;
423 pDAS->def_pix = NULL;
424 pDAS->context = NULL;
425 pDAS->vertIsMapped = False;
426 pDAS->horzIsMapped = False;
427 pDAS->lst_topic = NULL;
428 pDAS->nextNonVisible = 0;
429 pDAS->media_resolution = media_resolution;
430 pDAS->honor_size = honor_size;
431 pDAS->render_type = render_type;
433 pDAS->stipple = None;
436 * locale dependant information
438 pDAS->nl_to_space = 1;
439 pDAS->cant_begin_chars = NULL;
440 pDAS->cant_end_chars = NULL;
442 _DtHelpLoadMultiInfo (&(pDAS->cant_begin_chars),
443 &(pDAS->cant_end_chars), &(pDAS->nl_to_space));
446 * initialize the hypertext callback pointer
448 pDAS->exec_filter = exec_ok_routine;
449 pDAS->hyperCall = hyperTextCB;
450 pDAS->resizeCall = resizeCB;
451 pDAS->clientData = client_data;
454 * zero out other callback fields
456 pDAS->vScrollNotify = NULL ;
457 pDAS->armCallback = NULL ;
460 * create the atoms needed
462 xa_ave_width = XmInternAtom(dpy, "AVERAGE_WIDTH" , False);
465 * Malloc for the default font.
467 (void) XmeRenderTableGetDefaultFont(DA_args.userFont, &tmpFont);
468 if (default_list != NULL &&
469 XmFontListInitFontContext (&fontContext, default_list))
471 fontEntry = XmFontListNextEntry (fontContext);
472 if (fontEntry != NULL)
473 default_font = XmFontListEntryGetFont (fontEntry, &fontType);
475 XmFontListFreeFontContext (fontContext);
479 * fake out the next call by using the parent as the display widget
481 pDAS->dispWid = parent;
482 __DtHelpFontDatabaseInit (pDAS, default_font, fontType, tmpFont);
485 * Get the base font meterics.
487 __DtHelpFontMetrics (pDAS->font_info, __DtHelpDefaultFontIndexGet(pDAS),
488 &maxFontAscent, &maxFontDescent, &maxFontCharWidth,
491 pDAS->leading = DA_args.leading;
492 pDAS->fontAscent = maxFontAscent;
493 pDAS->lineHeight = maxFontAscent + maxFontDescent + pDAS->leading + 1;
495 n = __DtHelpDefaultFontIndexGet(pDAS);
497 value = get_fontsetproperty(__DtHelpFontSetGet(pDAS->font_info, n),
498 xa_ave_width, ((unsigned long *) &(pDAS->charWidth)));
500 value = XGetFontProperty(__DtHelpFontStructGet(pDAS->font_info, n),
501 xa_ave_width, ((unsigned long *) &(pDAS->charWidth)));
503 if (False == value || 0 == pDAS->charWidth)
505 int len = maxFontCharWidth;
508 len += XmbTextEscapement(
509 __DtHelpFontSetGet(pDAS->font_info,n),"1",1);
511 len += XTextWidth(__DtHelpFontStructGet(pDAS->font_info, n),"1",1);
513 pDAS->charWidth = 10 * len / 2;
517 * Create the form to manage the window and scroll bars.
520 XtSetArg(args[n], XmNresizePolicy , XmRESIZE_ANY); ++n;
521 XtSetArg(args[n], XmNshadowType , XmSHADOW_OUT); ++n;
522 form = XmCreateForm(parent, "DisplayAreaForm", args, n);
526 * force the shadowThickness to zero. The XmManager will try to set
530 XtSetArg(args[n], XmNshadowThickness , 0); ++n;
531 XtSetArg(args[n], XmNhighlightThickness, 0); ++n;
532 XtSetValues (form, args, n);
535 * get the colors and margin widths and heights
538 XtSetArg (args[n], XmNmarginWidth , &margin_width); ++n;
539 XtSetArg (args[n], XmNmarginHeight, &margin_height); ++n;
540 XtSetArg (args[n], XmNcolormap , &colormap); ++n;
541 XtGetValues(form, args, n);
543 /* Create the vertical scrollbar. */
544 pDAS->vertScrollWid = NULL;
545 if (vert_flag != _DtHelpNONE)
547 if (vert_flag == _DtHelpSTATIC)
548 pDAS->vertIsMapped = True;
551 XtSetArg(args[n], XmNtopAttachment , XmATTACH_FORM); ++n;
552 XtSetArg(args[n], XmNtopOffset , 0); ++n;
553 XtSetArg(args[n], XmNbottomAttachment , XmATTACH_FORM); ++n;
554 XtSetArg(args[n], XmNbottomOffset , margin_height); ++n;
555 XtSetArg(args[n], XmNrightAttachment , XmATTACH_FORM); ++n;
556 XtSetArg(args[n], XmNrightOffset , 0); ++n;
557 XtSetArg(args[n], XmNorientation , XmVERTICAL); ++n;
558 XtSetArg(args[n], XmNtraversalOn , True); ++n;
559 XtSetArg(args[n], XmNhighlightThickness, 1); ++n;
560 XtSetArg(args[n], XmNshadowType , XmSHADOW_IN); ++n;
561 XtSetArg(args[n], XmNvalue , 0); ++n;
562 XtSetArg(args[n], XmNminimum , 0); ++n;
563 /* fake out the scrollbar manager, who will init dims to 100 */
564 XtSetArg(args[n], XmNheight , 1); ++n;
565 XtSetArg(args[n], XmNmaximum , 1); ++n;
566 XtSetArg(args[n], XmNincrement , 1); ++n;
567 XtSetArg(args[n], XmNpageIncrement , 1); ++n;
568 XtSetArg(args[n], XmNsliderSize , 1); ++n;
569 XtSetArg(args[n], XtNmappedWhenManaged , pDAS->vertIsMapped); ++n;
570 pDAS->vertScrollWid = XmCreateScrollBar(form,
571 "DisplayDtHelpVertScrollBar", args, n);
573 XtManageChild(pDAS->vertScrollWid);
574 if (vert_flag != _DtHelpSTATIC)
575 pDAS->neededFlags = _DtHelpSET_AS_NEEDED (pDAS->neededFlags,
576 _DtHelpVERTICAL_SCROLLBAR);
578 XtAddCallback(pDAS->vertScrollWid, XmNdragCallback,
579 _DtHelpVertScrollCB, (XtPointer) pDAS);
580 XtAddCallback(pDAS->vertScrollWid, XmNincrementCallback,
581 _DtHelpVertScrollCB, (XtPointer) pDAS);
582 XtAddCallback(pDAS->vertScrollWid, XmNdecrementCallback,
583 _DtHelpVertScrollCB, (XtPointer) pDAS);
584 XtAddCallback(pDAS->vertScrollWid, XmNpageIncrementCallback,
585 _DtHelpVertScrollCB, (XtPointer) pDAS);
586 XtAddCallback(pDAS->vertScrollWid, XmNpageDecrementCallback,
587 _DtHelpVertScrollCB, (XtPointer) pDAS);
588 XtAddCallback(pDAS->vertScrollWid, XmNtoBottomCallback,
589 _DtHelpVertScrollCB, (XtPointer) pDAS);
590 XtAddCallback(pDAS->vertScrollWid, XmNtoTopCallback,
591 _DtHelpVertScrollCB, (XtPointer) pDAS);
592 XtAddCallback(pDAS->vertScrollWid, XmNvalueChangedCallback,
593 _DtHelpVertScrollCB, (XtPointer) pDAS);
595 XtAddEventHandler (pDAS->vertScrollWid, ButtonPressMask, True,
596 (XtEventHandler)_DtHelpMoveBtnFocusCB,(XtPointer) pDAS);
600 /* Create the horizontal scrollbar. */
601 pDAS->horzScrollWid = NULL;
602 if (horz_flag != _DtHelpNONE)
604 if (horz_flag == _DtHelpSTATIC)
605 pDAS->horzIsMapped = True;
608 XtSetArg(args[n], XmNbottomAttachment , XmATTACH_FORM); ++n;
609 XtSetArg(args[n], XmNbottomOffset , 0); ++n;
610 XtSetArg(args[n], XmNrightAttachment , XmATTACH_FORM); ++n;
611 XtSetArg(args[n], XmNrightOffset , margin_width); ++n;
612 XtSetArg(args[n], XmNleftAttachment , XmATTACH_FORM); ++n;
613 XtSetArg(args[n], XmNleftOffset , 0); ++n;
614 XtSetArg(args[n], XmNorientation , XmHORIZONTAL); ++n;
615 XtSetArg(args[n], XmNtraversalOn , True); ++n;
616 XtSetArg(args[n], XmNhighlightThickness, 1); ++n;
617 XtSetArg(args[n], XmNshadowType , XmSHADOW_IN); ++n;
618 XtSetArg(args[n], XmNvalue , 0); ++n;
619 XtSetArg(args[n], XmNminimum , 0); ++n;
620 XtSetArg(args[n], XmNmaximum , (pDAS->charWidth/10)); ++n;
621 /* fake out the scrollbar manager, who will init dims to 100 */
622 XtSetArg(args[n], XmNwidth , 1); ++n;
623 XtSetArg(args[n], XmNincrement , (pDAS->charWidth/10)); ++n;
624 XtSetArg(args[n], XmNpageIncrement , (pDAS->charWidth/10)); ++n;
625 XtSetArg(args[n], XmNsliderSize , (pDAS->charWidth/10)); ++n;
626 XtSetArg(args[n], XtNmappedWhenManaged , pDAS->horzIsMapped); ++n;
627 pDAS->horzScrollWid = XmCreateScrollBar(form,
628 "DisplayHorzScrollBar", args, n);
629 XtManageChild(pDAS->horzScrollWid);
630 if (horz_flag != _DtHelpSTATIC)
631 pDAS->neededFlags = _DtHelpSET_AS_NEEDED (pDAS->neededFlags,
632 _DtHelpHORIZONTAL_SCROLLBAR);
634 XtAddCallback(pDAS->horzScrollWid, XmNdragCallback,
635 _DtHelpHorzScrollCB, (XtPointer) pDAS);
636 XtAddCallback(pDAS->horzScrollWid, XmNincrementCallback,
637 _DtHelpHorzScrollCB, (XtPointer) pDAS);
638 XtAddCallback(pDAS->horzScrollWid, XmNdecrementCallback,
639 _DtHelpHorzScrollCB, (XtPointer) pDAS);
640 XtAddCallback(pDAS->horzScrollWid, XmNpageIncrementCallback,
641 _DtHelpHorzScrollCB, (XtPointer) pDAS);
642 XtAddCallback(pDAS->horzScrollWid, XmNpageDecrementCallback,
643 _DtHelpHorzScrollCB, (XtPointer) pDAS);
644 XtAddCallback(pDAS->horzScrollWid, XmNtoBottomCallback,
645 _DtHelpHorzScrollCB, (XtPointer) pDAS);
646 XtAddCallback(pDAS->horzScrollWid, XmNtoTopCallback,
647 _DtHelpHorzScrollCB, (XtPointer) pDAS);
648 XtAddCallback(pDAS->horzScrollWid, XmNvalueChangedCallback,
649 _DtHelpHorzScrollCB, (XtPointer) pDAS);
653 * check for the horizontal attachments
656 if (horz_flag == _DtHelpSTATIC)
658 XtSetArg(args[n], XmNbottomAttachment , XmATTACH_WIDGET); ++n;
659 XtSetArg(args[n], XmNbottomWidget , pDAS->horzScrollWid); ++n;
663 XtSetArg(args[n], XmNbottomAttachment , XmATTACH_FORM); ++n;
667 * check for the vertical attachments
669 if (vert_flag == _DtHelpSTATIC)
671 XtSetArg(args[n], XmNrightAttachment , XmATTACH_WIDGET); ++n;
672 XtSetArg(args[n], XmNrightWidget , pDAS->vertScrollWid); ++n;
676 XtSetArg(args[n], XmNrightAttachment , XmATTACH_FORM); ++n;
680 * do the rest of the arguments
682 XtSetArg(args[n], XmNbottomOffset , margin_height); ++n;
683 XtSetArg(args[n], XmNrightOffset , margin_width); ++n;
684 XtSetArg(args[n], XmNtopAttachment , XmATTACH_FORM); ++n;
685 XtSetArg(args[n], XmNtopOffset , 0); ++n;
686 XtSetArg(args[n], XmNleftAttachment , XmATTACH_FORM); ++n;
687 XtSetArg(args[n], XmNleftOffset , 0); ++n;
688 XtSetArg(args[n], XmNrecomputeSize , False); ++n;
689 XtSetArg(args[n], XmNpushButtonEnabled , False); ++n;
690 XtSetArg(args[n], XmNtraversalOn , True); ++n;
691 XtSetArg(args[n], XmNhighlightThickness, 1); ++n;
692 XtSetArg(args[n], XmNshadowType , XmSHADOW_IN); ++n;
693 XtSetArg(args[n], XmNmultiClick , XmMULTICLICK_DISCARD); ++n;
694 XtSetArg(args[n], XmNuserData , pDAS); ++n;
695 pDAS->dispWid = XmCreateDrawnButton(form, name, args, n);
696 XtManageChild(pDAS->dispWid);
698 XtAddCallback(pDAS->dispWid, XmNexposeCallback, _DtHelpExposeCB,
700 XtAddCallback(pDAS->dispWid, XmNresizeCallback, _DtHelpResizeCB,
702 XtAddCallback(pDAS->dispWid, XmNarmCallback, _DtHelpClickOrSelectCB,
704 XtAddCallback(pDAS->dispWid, XmNdisarmCallback, _DtHelpEndSelectionCB,
707 XtAddEventHandler (pDAS->dispWid, Button1MotionMask, True,
708 (XtEventHandler)_DtHelpMouseMoveCB, (XtPointer) pDAS);
712 * parse the translations.
714 _DtHelpProcessLock();
715 if (DrawnBTrans == NULL)
716 DrawnBTrans = XtParseTranslationTable(DrawnBTransTable);
719 * override the translations
720 XtSetArg(args[n], XmNtranslations , DrawnBTrans); ++n;
722 if (DrawnBTrans != NULL)
723 XtOverrideTranslations(pDAS->dispWid, DrawnBTrans);
724 _DtHelpProcessUnlock();
726 if (_XmGetFocusPolicy(parent) == XmPOINTER)
728 XtAddEventHandler (pDAS->dispWid, EnterWindowMask, True,
729 (XtEventHandler)_DtHelpEnterLeaveCB, (XtPointer) pDAS);
730 XtAddEventHandler (pDAS->dispWid, LeaveWindowMask, True,
731 (XtEventHandler)_DtHelpEnterLeaveCB, (XtPointer) pDAS);
734 XtAddEventHandler (pDAS->dispWid, FocusChangeMask, True,
735 (XtEventHandler)_DtHelpFocusCB, (XtPointer) pDAS);
737 XtAddEventHandler (pDAS->dispWid, VisibilityChangeMask, True,
738 (XtEventHandler)_DtHelpVisibilityCB, (XtPointer) pDAS);
741 /* Add a destroy callback so that the display area can clean up prior to
742 * the help widget getting destroyed (e.g. display area's parent)
744 XtAddCallback(pDAS->dispWid, XmNdestroyCallback,
745 _DtHelpDisplayAreaDestroyCB, (XtPointer) pDAS);
748 XtSetArg(args[n], XmNshadowThickness , &shadowThick); ++n;
749 XtSetArg(args[n], XmNhighlightThickness, &highThick); ++n;
750 XtSetArg(args[n], XmNforeground , &(pDAS->foregroundColor)); ++n;
751 XtSetArg(args[n], XmNbackground , &(pDAS->backgroundColor)); ++n;
752 XtSetArg(args[n], XmNhighlightColor, &(pDAS->traversalColor) ); ++n;
753 XtSetArg(args[n], XmNdepth , &(pDAS->depth) ); ++n;
754 XtGetValues(pDAS->dispWid, args, n);
755 pDAS->decorThickness = shadowThick + highThick;
758 * Get the underline information
760 GetUnderLineInfo (dpy, pDAS, &(pDAS->lineThickness));
763 * get the tiling pattern.
765 tile = XmGetPixmap (XtScreen(pDAS->dispWid), "50_foreground",
766 pDAS->foregroundColor, pDAS->backgroundColor);
769 * Get the data for the graphics contexts and create the GC's.
771 gcMask = (GCFunction | GCPlaneMask | GCForeground |
772 GCBackground | GCLineWidth | GCLineStyle |
773 GCClipXOrigin | GCClipYOrigin | GCClipMask);
775 gcValues.function = GXcopy;
776 gcValues.plane_mask = AllPlanes;
777 gcValues.foreground = pDAS->foregroundColor;
778 gcValues.background = pDAS->backgroundColor;
779 gcValues.line_style = LineSolid;
780 gcValues.line_width = pDAS->lineThickness;
781 gcValues.clip_x_origin = 0;
782 gcValues.clip_y_origin = 0;
783 gcValues.clip_mask = None;
787 gcValues.tile = tile;
790 pDAS->normalGC = XCreateGC(dpy,
791 RootWindowOfScreen(XtScreen(pDAS->dispWid)), gcMask, &gcValues);
794 pDAS->pixmapGC = XCreateGC(dpy,
795 RootWindowOfScreen(XtScreen(pDAS->dispWid)), gcMask, &gcValues);
797 gcValues.foreground = pDAS->backgroundColor;
798 gcValues.background = pDAS->foregroundColor;
799 pDAS->invertGC = XCreateGC(dpy,
800 RootWindowOfScreen(XtScreen(pDAS->dispWid)), gcMask, &gcValues);
803 * Set the size of the text view area to the requested
804 * number of columns and lines.
806 char_width = pDAS->charWidth * columns;
809 * Make sure the margins include enough room for a traversal line
811 if (((int) pDAS->marginWidth) < pDAS->lineThickness)
812 pDAS->marginWidth = pDAS->lineThickness;
813 if (((int) pDAS->marginHeight) < pDAS->lineThickness)
814 pDAS->marginHeight = pDAS->lineThickness;
815 if (pDAS->leading < pDAS->lineThickness)
816 pDAS->leading = pDAS->lineThickness;
819 * get the scrollbar widths.
821 if (NULL != pDAS->horzScrollWid)
824 XtSetArg(args[n], XmNheight , &hBarHeight); n++;
825 XtSetArg(args[n], XmNinitialDelay, &(pDAS->horz_init_scr)); n++;
826 XtSetArg(args[n], XmNrepeatDelay , &(pDAS->horz_rep_scr)); n++;
827 XtGetValues(pDAS->horzScrollWid, args, n);
830 if (NULL != pDAS->vertScrollWid)
833 XtSetArg(args[n], XmNwidth , &vBarWidth); n++;
834 XtSetArg(args[n], XmNinitialDelay, &(pDAS->vert_init_scr)); n++;
835 XtSetArg(args[n], XmNrepeatDelay , &(pDAS->vert_rep_scr)); n++;
836 XtGetValues(pDAS->vertScrollWid, args, n);
840 * calculate the display area height/width
842 pDAS->dispUseWidth = ((int) (char_width / 10 + (char_width % 10 ? 1 : 0)))
843 + 2 * pDAS->marginWidth;
844 if (vert_flag != _DtHelpSTATIC && pDAS->dispUseWidth < vBarWidth)
845 pDAS->dispUseWidth = vBarWidth;
846 pDAS->dispWidth = pDAS->dispUseWidth + 2 * pDAS->decorThickness;
848 pDAS->dispUseHeight = pDAS->lineHeight * rows;
849 if (horz_flag != _DtHelpSTATIC && pDAS->dispUseHeight < hBarHeight)
850 pDAS->dispUseHeight = hBarHeight;
851 pDAS->dispHeight = pDAS->dispUseHeight + 2 * pDAS->decorThickness;
854 * Truncate the width and height to the size of the display.
855 * This will prevent an X protocal error when it is asked for
856 * a too large size. Besides, any decent window manager will
857 * force the overall size to the height and width of the display.
858 * This simply refines the size down to a closer (but not perfect)
861 if (((int) pDAS->dispWidth) > XDisplayWidth (dpy, screen)) {
862 pDAS->dispWidth = XDisplayWidth (dpy, screen);
864 if (((int) pDAS->dispHeight) > XDisplayHeight (dpy, screen)) {
865 pDAS->dispHeight = XDisplayHeight (dpy, screen);
870 pDAS->formHeight = 0;
871 XtSetArg(args[n], XmNwidth, pDAS->dispWidth); ++n;
872 XtSetArg(args[n], XmNheight, pDAS->dispHeight); ++n;
873 XtSetValues(pDAS->dispWid, args, n);
876 * set the scroll bar values
878 if (pDAS->vertScrollWid != NULL)
881 XtSetArg(args[n], XmNmaximum , pDAS->dispUseHeight); ++n;
882 XtSetArg(args[n], XmNincrement , pDAS->lineHeight); ++n;
883 XtSetArg(args[n], XmNpageIncrement , pDAS->lineHeight); ++n;
884 XtSetArg(args[n], XmNsliderSize , pDAS->dispUseHeight); ++n;
885 XtSetValues(pDAS->vertScrollWid, args, n);
888 if (pDAS->resizeCall)
889 (*(pDAS->resizeCall)) (pDAS->clientData);
892 * calculate the offset for the right edge of the
893 * horizontal scrollbar.
895 if (vert_flag == _DtHelpSTATIC && pDAS->horzScrollWid)
897 width = vBarWidth + margin_width;
899 XtSetArg(args[0], XmNrightOffset , width);
900 XtSetValues(pDAS->horzScrollWid, args, 1);
904 * calculate the offset for the bottom end of the
905 * vertical scrollbar.
907 if (horz_flag == _DtHelpSTATIC && pDAS->vertScrollWid)
909 width = hBarHeight + margin_height;
911 XtSetArg(args[0], XmNbottomOffset , width);
912 XtSetValues(pDAS->vertScrollWid, args, 1);
915 rectangle[0].x = pDAS->decorThickness;
916 rectangle[0].y = pDAS->decorThickness;
917 rectangle[0].width = pDAS->dispUseWidth;
918 rectangle[0].height = pDAS->dispUseHeight;
919 XSetClipRectangles(XtDisplay(pDAS->dispWid), pDAS->normalGC, 0, 0,
920 rectangle, 1, Unsorted);
921 XSetClipRectangles(XtDisplay(pDAS->dispWid), pDAS->invertGC, 0, 0,
922 rectangle, 1, Unsorted);
925 * get the colormap and the visual
927 if (!XtIsShell(parent) && XtParent(parent) != NULL)
928 parent = XtParent(parent);
933 XtSetArg (args[n], XmNcolormap, &(pDAS->colormap)); n++;
934 XtSetArg (args[n], XmNvisual , &(pDAS->visual )); n++;
935 XtGetValues (parent, args, n);
937 if (pDAS->visual == NULL)
938 pDAS->visual = XDefaultVisualOfScreen(XtScreen(pDAS->dispWid));
943 _DtHelpProcessLock();
944 DefVirtFunctions.exec_cmd_filter = exec_ok_routine;
946 pDAS->canvas = _DtCanvasCreate (DefVirtFunctions, (_DtCvPointer) pDAS);
947 _DtHelpProcessUnlock();
949 return (XtPointer) pDAS;
951 } /* End _DtHelpCreateDA */
954 /*********************************************************************
955 * Function: CreateDisplayArea
957 * Creates a Text Graphic area with the appropriate scroll bars.
958 * specifying the size with rows and columns
960 *********************************************************************/
962 _DtHelpCreateDisplayArea(
967 Boolean traversal_flag,
970 void (*hyperTextCB)(),
972 int (*exec_ok_routine)(),
973 XtPointer client_data,
974 XmFontList default_list )
976 return HelpCreateDA(parent, name,
977 vert_flag, horz_flag,
979 _DtCvIGNORE_BOUNDARY, _DtCvRENDER_PARTIAL,
981 hyperTextCB, resizeCB, exec_ok_routine,
982 client_data, default_list);
985 /*********************************************************************
986 * Function: CreateOutputArea
988 * Creates a Text Graphic area with the appropriate scroll bars.
989 * specifying the size with width and height
991 *********************************************************************/
993 _DtHelpCreateOutputArea(
998 Boolean traversal_flag,
999 _DtCvValue honor_size,
1000 _DtCvRenderType render_type,
1003 unsigned short media_resolution,
1004 void (*hyperTextCB)(),
1006 int (*exec_ok_routine)(),
1007 XtPointer client_data,
1008 XmFontList default_list )
1010 DtHelpDispAreaStruct *pDAS;
1012 pDAS = HelpCreateDA(parent, name,
1013 vert_flag, horz_flag,
1014 traversal_flag, honor_size, render_type,
1015 1, 1, media_resolution,
1016 hyperTextCB, resizeCB, exec_ok_routine,
1017 client_data, default_list);
1018 /* if area created successfully, then resize it to the given size */
1020 _DtHelpSetScrollBars(pDAS, width, height);