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 /* $TOG: NodeWindowAgentMotif.C /main/94 1998/04/17 11:34:46 mgreess $ */
25 * (c) Copyright 1996 Digital Equipment Corporation.
26 * (c) Copyright 1996 Hewlett-Packard Company.
27 * (c) Copyright 1996 International Business Machines Corp.
28 * (c) Copyright 1996 Sun Microsystems, Inc.
29 * (c) Copyright 1996 Novell, Inc.
30 * (c) Copyright 1994, 1995, 1996 FUJITSU LIMITED.
31 * (c) Copyright 1996 Hitachi.
35 * Copyright (c) 1992 HAL Computer Systems International, Ltd.
36 * All rights reserved. Unpublished -- rights reserved under
37 * the Copyright Laws of the United States. USE OF A COPYRIGHT
38 * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
41 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
42 * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
43 * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
44 * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
47 * RESTRICTED RIGHTS LEGEND
48 * Use, duplication, or disclosure by the Government is subject
49 * to the restrictions as set forth in subparagraph (c)(l)(ii)
50 * of the Rights in Technical Data and Computer Software clause
51 * at DFARS 252.227-7013.
53 * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
65 #define C_NodeViewInfo
72 #define C_GraphicAgent
73 #define C_PrintPanelAgent
75 #define C_NodeWindowAgent
79 #define C_AnchorCanvas
84 #define C_BookmarkEdit
87 #define C_WindowGeometryPref
93 #define C_SearchResultsMgr
95 #define C_SearchScopeMgr
99 #define C_GlobalHistoryMgr
101 #define C_GhostScriptEventMgr
102 #define C_GraphicsMgr
118 #define C_PixmapGraphic
121 #define USES_OLIAS_FONT
123 #include "Managers/CatMgr.hh"
124 #include "Managers/WString.hh"
125 #include "Other/XmStringLocalized.hh"
127 #include "Marks/MarkInfo.hh"
129 #include <X11/cursorfont.h>
133 #include "Registration.hh"
135 // for DtCanvas Help stuff
136 #include <DtI/Access.h>
137 #include <DtI/XUICreateI.h>
138 #include <DtI/SetListI.h>
139 #include <DtI/CallbacksI.h>
140 #include <DtI/DisplayAreaI.h>
141 #include <DtI/FontI.h>
142 #include <DtI/FontAttrI.h>
143 #include <DtI/RegionI.h>
145 #include "OnlineRender/SegClientData.hh"
147 #include "utility/mmdb_exception.h"
149 #include <Xm/MainW.h>
150 #include <Xm/RowColumn.h>
151 #include <Xm/PushBG.h>
152 #include <Xm/PushB.h>
153 #include <Xm/ToggleBG.h>
154 #include <Xm/ToggleB.h>
155 #include <Xm/CascadeBG.h>
156 #include <Xm/SeparatoG.h>
157 #include <WWL/WTopLevelShell.h>
158 #include <WWL/WXmPushButton.h>
159 #include <WWL/WXmCascadeButtonGadget.h>
160 #include <WWL/WXmForm.h>
161 #include <WWL/WXmRowColumn.h>
162 #include <WWL/WXmMenu.h>
163 #include <WWL/WXmFrame.h>
164 #include <WWL/WXmLabel.h>
165 #include <WWL/WXmToggleButton.h>
166 #include <WWL/WXmArrowButton.h>
167 #include <WWL/WXmSeparator.h>
168 #include <WWL/WXmTextField.h>
169 #include <WWL/WXmDrawingArea.h>
170 #include <WWL/WXmDialogShell.h>
171 #include <WWL/WXmMessageBox.h>
173 #include <Xm/TextF.h>
185 #if defined(Internationalize) && defined(SunOS5)
190 #if defined(UseWideChars)
192 # define mbstowcs(a,b,c) Xmbstowcs(a,b,c)
193 # define wcstombs(a,b,c) Xwcstombs(a,b,c)
194 # elif defined(_IBMR2)
199 #define ON_ACTIVATE(WOBJ,FUNC) \
200 (WOBJ).SetActivateCallback (this, (WWL_FUN) &CLASS::FUNC)
201 #define ON_ARM(WOBJ,FUNC) \
202 (WOBJ).SetArmCallback (this, (WWL_FUN) &CLASS::FUNC)
203 #define ON_DISARM(WOBJ,FUNC) \
204 (WOBJ).SetDisarmCallback (this, (WWL_FUN) &CLASS::FUNC)
206 #define f_node_ptr f_node_view_info->node_ptr()
208 xList<UAS_Pointer<UAS_Common> > g_tab_list;
210 extern AppPrintData * l_AppPrintData;
214 typedef void (*resize_cb_ptr)();
215 typedef void (*hypertext_cb_ptr)();
218 #ifdef CV_HYPER_DEBUG
223 hypertext_cb (DtHelpDispAreaStruct* pDAS, NodeWindowAgent *agent,
224 DtHelpHyperTextStruct *callData)
226 #if defined(_IBMR2) && defined(CV_HYPER_BUG)
227 _DtCvLinkInfo ceHyper ;
229 _DtCvUnit downX, downY, upX, upY ;
231 downX = upX = pDAS->timerX ;
232 downY = upY = pDAS->timerY ;
234 if (_DtCvSTATUS_OK ==
235 _DtCanvasGetPosLink (pDAS->canvas, downX, downY, upX,
238 #ifdef CV_HYPER_DEBUG
239 cerr << "hypertext callback(" << callData->window_hint << "): " <<
240 ceHyper.specification << endl;
242 agent->link_to(ceHyper.specification);
246 if (callData->window_hint == 0) {
247 if (callData->hyper_type < 0) {
248 UAS_Pointer<Mark>& mark =
249 ((MarkCanvas*)(callData->specification))->mark_ptr();
250 #ifdef CV_HYPER_DEBUG
251 cerr << "hypertext callback(" << callData->window_hint << "): " <<
252 mark->name() << endl;
257 #ifdef CV_HYPER_DEBUG
258 cerr << "hypertext callback(" << callData->window_hint << "): " <<
259 callData->specification << endl;
261 agent->link_to(callData->specification);
268 resize_cb (NodeWindowAgent *agent)
270 agent->canvas_resize ();
274 h_scroll_callback (Widget,
275 XtPointer client_data,
278 NodeWindowAgent *agent = (NodeWindowAgent*)client_data ;
279 agent->hscroll (((XmScrollBarCallbackStruct*) call_data)->value) ;
283 v_scroll_callback (Widget,
284 XtPointer client_data,
287 #ifdef SCROLL_BOOKMARK_DEBUG
288 cerr << "our callback" << endl;
290 NodeWindowAgent *agent = (NodeWindowAgent*)client_data ;
291 agent->vscroll (((XmScrollBarCallbackStruct*) call_data)->value) ;
295 v_scroll_notify(void *client_data, unsigned int value)
297 ((NodeWindowAgent*)client_data)->vscroll (value);
301 detach_grCB (Widget, XtPointer client_data, XtPointer )
303 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
308 raise_grCB (Widget w, XtPointer client_data, XtPointer )
310 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
315 attach_grCB (Widget, XtPointer client_data, XtPointer )
317 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
322 NodeWindowAgent::attach_gr()
325 XtVaGetValues(f_detach_button, XmNuserData, &seg, NULL);
326 SegClientData* pSCD = (SegClientData*)(seg->client_use);
327 UAS_Pointer<Graphic> gr = (Graphic*)pSCD->GraphicHandle();
328 //GraphicAgent *agent = gr->get_agent();
329 //GraphicAgent *agent = graphics_mgr().get_agent(gr->locator());
331 if (gr->is_detached())
333 //agent->attach_graphic();
334 graphics_mgr().reattach_graphic(gr);
339 NodeWindowAgent::detach_gr()
342 XtVaGetValues(f_detach_button, XmNuserData, &seg, NULL);
344 SegClientData* pSCD = (SegClientData*)(seg->client_use);
345 UAS_Pointer<Graphic> gr = (Graphic*)pSCD->GraphicHandle();
346 if (!gr->is_detached())
347 graphics_mgr().detach (f_node_view_info->node_ptr(), gr);
351 NodeWindowAgent::raise_gr()
354 XtVaGetValues(f_detach_button, XmNuserData, &seg, NULL);
355 SegClientData* pSCD = (SegClientData*)(seg->client_use);
356 UAS_Pointer<Graphic> gr = (Graphic*)pSCD->GraphicHandle();
357 //GraphicAgent *agent = gr->get_agent();
358 UAS_String locator_str = gr->locator();
359 GraphicAgent *agent = graphics_mgr().get_agent(locator_str);
364 popup_menuCB (Widget, XtPointer client_data, XEvent *event, Boolean*)
366 XButtonPressedEvent *pevent = (XButtonPressedEvent*)event;
368 if (pevent->type != ButtonPress || pevent->button != Button3)
371 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
372 agent->popup_menu(pevent);
376 go_to_linkCB (Widget, XtPointer client_data, XtPointer )
378 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
383 open_new_nodeCB (Widget, XtPointer client_data, XtPointer )
385 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
386 agent->open_new_node();
389 // Display a section in current node window
391 NodeWindowAgent::go_to_link()
393 link_to((char*)f_link_spec);
397 // Display a section in a new Node Window
399 NodeWindowAgent::open_new_node()
401 node_mgr().force_new_window();
402 link_to((char*)f_link_spec);
407 NodeWindowAgent::exit_cb()
409 if (BookmarkEdit::modified_count() > 0)
412 resp = message_mgr().question_dialog (
413 (char*)UAS_String(CATGETS(Set_Messages, 2,
414 "Do you want to abandon your changes?")), (Widget)f_shell);
419 message_mgr().quit_dialog (
420 (char*)UAS_String(CATGETS(Set_Messages, 6,
421 "Do you really want to quit Dtinfo?")), (Widget)f_shell);
425 // pop up one of three menus:
426 // 1. If cursor is over a graphic, popup detach graphic menu.
427 // 2. If cursor is over hyperlink, popup link preview menu.
428 // 3. Else popup default menu.
430 NodeWindowAgent::popup_menu(XButtonPressedEvent* event)
433 _DtCvElemType seg_type;
434 seg = xy_to_seg(event->x, event->y, &seg_type);
439 // see if it's the graphic detach menu to popup
442 case _DtCvREGION_TYPE:
444 SegClientData* pSCD =
445 (SegClientData*)(seg->client_use);
446 UAS_Pointer<Graphic> gr = (Graphic*)pSCD->GraphicHandle();
447 if (gr->is_detached())
449 XtSetSensitive(f_attach_button, True);
450 XtSetSensitive(f_raise_button, True);
451 XtSetSensitive(f_detach_button, False);
455 XtSetSensitive(f_attach_button, False);
456 XtSetSensitive(f_raise_button, False);
457 XtSetSensitive(f_detach_button, True);
459 // the userdata for the detach buton is used to transfer
460 // the canvas segment to the detach, attach, raise callbacks.
461 XtVaSetValues(f_detach_button, XmNuserData, seg, NULL);
462 XmMenuPosition(f_detach_menu, event);
463 XtManageChild(f_detach_menu);
465 char* gr_type = (char*)gr->content_type();
466 gr_type = strchr(gr_type,'/');
471 snprintf(buff, sizeof(buff), "%s graphic", gr_type);
472 XmTextFieldSetString(f_status_text, buff);
476 case _DtCvSTRING_TYPE:
478 _DtCvLinkInfo ceHyper ;
479 _DtCvUnit downX, downY, upX, upY ;
481 downX = upX = event->x;
482 downY = upY = event->y;
484 if (XtIsManaged(f_help_dsp_area->vertScrollWid))
486 downY += f_vscrollbar_offset; // adjust y-pos for scroll bar
487 upY += f_vscrollbar_offset; // adjust y-pos for scroll bar
490 if (_DtCvSTATUS_OK ==
491 _DtCanvasGetPosLink (f_help_dsp_area->canvas,
496 f_link_spec = ceHyper.specification;
497 UAS_Pointer<UAS_Common> doc_ptr =
498 f_node_view_info->node_ptr()->create_relative((char*)f_link_spec);
499 // NOTE: create_relative may have failed if the infolib associated
500 // with spec had been removed. So check doc_ptr before
501 // calling preview_init
504 //preview_init(doc_ptr);
506 char preview_buffer[256];
508 UAS_String pt = doc_ptr->title();
509 *((char *) memcpy(title, (char *) pt, 127) + 127) = '\0';
510 UAS_String bn = doc_ptr->book_name(UAS_SHORT_TITLE);
511 const char *book_name = (char *) bn;
512 if (book_name != NULL && *book_name != '\0')
513 snprintf (preview_buffer, sizeof(preview_buffer),
514 CATGETS(Set_Messages, 8, "Link to %s: %s"), book_name, title);
516 snprintf (preview_buffer, sizeof(preview_buffer),
517 CATGETS(Set_Messages, 9, "Link to %s"), title);
518 WXmLabel lb = WXmLabel(f_preview_label);
519 lb.LabelString(WXmString(title));
521 XmTextFieldSetString(f_status_text, preview_buffer);
522 XmMenuPosition(f_preview_menu, event);
523 XtManageChild(f_preview_menu);
528 XmMenuPosition(f_default_menu, event);
529 XtManageChild(f_default_menu);
534 XmProcessTraversal(f_help_dsp_area->dispWid, XmTRAVERSE_CURRENT);
535 XmMenuPosition(f_default_menu, event);
536 XtManageChild(f_default_menu);
541 // Given an x,y coordinate, return the segment. The segment
542 // type that can be returned is a _DtCvREGION_TYPE or a
546 NodeWindowAgent::xy_to_seg(int x, int y, _DtCvElemType *element)
550 _DtCvUnit offx, offy;
556 if (XtIsManaged(f_help_dsp_area->vertScrollWid))
557 ypos += f_vscrollbar_offset; // adjust y-pos for scroll bar
558 if (XtIsManaged(f_help_dsp_area->horzScrollWid))
559 xpos += f_hscrollbar_offset; // adjust x-pos for scroll bar
561 status = _DtCanvasGetSpotInfo(f_help_dsp_area->canvas, xpos, ypos,
562 &seg, &offx, &offy, element);
564 if (status == _DtCvSTATUS_OK)
567 return (_DtCvSegment *)NULL;
571 NodeWindowAgent::disarm()
577 NodeWindowAgent::arm()
579 _DtCvLinkInfo ceHyper ;
581 _DtCvUnit downX, downY, upX, upY ;
583 downX = upX = f_help_dsp_area->timerX ;
584 downY = upY = f_help_dsp_area->timerY ;
586 if (XtIsManaged(f_help_dsp_area->vertScrollWid))
588 downY += f_vscrollbar_offset; // adjust y-pos for scroll bar
589 upY += f_vscrollbar_offset; // adjust y-pos for scroll bar
592 if (_DtCvSTATUS_OK ==
593 _DtCanvasGetPosLink (f_help_dsp_area->canvas, downX, downY, upX,
596 UAS_String spec(ceHyper.specification);
597 UAS_Pointer<UAS_Common> doc_ptr =
598 f_node_view_info->node_ptr()->create_relative(spec);
599 // NOTE: create_relative may have failed if the infolib associated
600 // with spec had been removed. So check doc_ptr before
601 // calling preview_init
603 preview_init(doc_ptr);
608 NodeWindowAgent::hscroll (unsigned int value)
610 f_hscrollbar_offset = value ;
614 NodeWindowAgent::vscroll (unsigned int value)
616 #ifdef SCROLL_BOOKMARK_DEBUG
617 cerr << "agent vscroll: " << value << endl;
620 f_vscrollbar_offset = value ;
622 List_Iterator <MarkIcon *> i (f_mark_icon_list);
626 i.item()->TopOffset (i.item()->ypos() - value);
631 static UAS_Pointer<Mark> &
634 static UAS_Pointer<Mark> da_mark;
641 find_segment_offset (_DtCvSegment *start, const _DtCvSegment *target,
646 arm_callback (void *client_data)
648 ((NodeWindowAgent*)client_data)->arm();
651 disarm_callback (Widget, XtPointer client_data, XtPointer)
653 ((NodeWindowAgent*)client_data)->disarm();
657 selection_end_callback(Widget, XtPointer, XtPointer)
659 SelectionChanged msg ;
660 node_mgr().UAS_Sender<SelectionChanged>::send_message (msg);
663 // For history jump to position stuff:
665 AnchorCanvas *g_history_anchor;
668 bool g_scroll_to_locator ;
669 char g_top_locator[4096] ;
671 // When updating for the purposes of changing style sheets
672 extern bool g_style_sheet_update ;
674 static bool g_ignore_wm_delete;
676 // /////////////////////////////////////////////////////////////////
677 // ancestral hierarchy handling class
678 // /////////////////////////////////////////////////////////////////
680 #define CLASS Ancestor
682 class Ancestor : public WWL
685 Ancestor (NodeWindowAgent *nwa, WXmPulldownMenu &p,
686 const char *title, const UAS_Pointer<UAS_Common> &toc_ptr)
687 : f_node_window_agent (nwa),
688 f_button (p, "button", WAutoManage,
689 WArgList (XmNlabelString, (XtArgVal) WXmString (title), NULL)),
692 ON_ACTIVATE (f_button,activate);
693 // Make it look like a label if the user can't select it.
694 // Note bogus assumption of 2 pixel wide shadow thickness.
695 if ((f_toc_ptr == 0) || f_toc_ptr->data_length() == 0)
697 f_button.Set (WArgList (XmNshadowThickness, 0,
707 void update (const char *title, UAS_Pointer<UAS_Common> toc_ptr);
710 NodeWindowAgent *f_node_window_agent;
711 WXmPushButton f_button;
712 UAS_Pointer<UAS_Common> f_toc_ptr;
716 Ancestor::update (const char *title, UAS_Pointer<UAS_Common> toc_ptr)
720 f_button.LabelString (title);
721 if ((toc_ptr == 0)|| toc_ptr->data_length() == 0)
723 f_button.Set (WArgList (XmNshadowThickness, 0,
730 f_button.Set (WArgList (XmNshadowThickness, 2,
747 if (f_toc_ptr == (UAS_Pointer<UAS_Common>)NULL)
751 UAS_Pointer<UAS_Common> current;
752 current = f_node_window_agent->f_node_view_info->node_ptr();
754 // Avoid redisplaying the current document.
755 if (f_toc_ptr == current)
760 if (f_toc_ptr != (UAS_Pointer<UAS_Common>)NULL)
762 node_mgr().set_preferred_window (f_node_window_agent);
763 f_toc_ptr->retrieve();
769 #define CLASS NodeWindowAgent
771 // /////////////////////////////////////////////////////////////////
773 // /////////////////////////////////////////////////////////////////
775 NodeWindowAgent::NodeWindowAgent (u_int serial_no)
776 : IcccmAgent((void*)this,(data_handler_t)&NodeWindowAgent::do_search_selection),
777 f_node_view_info (NULL),
779 f_help_dsp_area (NULL),
781 f_current_ancestor (NULL),
783 f_preview_timeout (NULL),
784 f_serial_number(serial_no),
785 f_history_display (FALSE),
786 f_vscrollbar_offset(0),
787 f_hscrollbar_offset(0),
788 f_graphic_segment(NULL),
789 f_graphics_handler(NULL),
790 f_close_sensitive(FALSE)
792 UAS_Common::request ((UAS_Receiver<UAS_LibraryDestroyedMsg> *) this);
794 // request MarkCreated messages
795 mark_mgr().request(this);
796 // request MarkDeleted/Changed etc messages
797 Mark::request (this);
801 // /////////////////////////////////////////////////////////////////
803 // /////////////////////////////////////////////////////////////////
805 NodeWindowAgent::~NodeWindowAgent()
807 List_Iterator<Ancestor *> i (f_ancestor_list);
811 f_ancestor_list.remove (i);
814 List_Iterator<BookTab *> t (f_tab_btn_list);
818 f_tab_btn_list.remove (t);
821 #ifdef LICENSE_MANAGEMENT
822 f_node_view_info->node_ptr()->returnlicense();
827 node_mgr().agent_deleted (this);
829 // The above call kills all the widgets.
830 if (f_graphics_handler)
831 delete f_graphics_handler ;
833 // clean things up so that the help display area deletion
834 // will not stomp on the memory we free when deleting the nodeviewinfo
835 _DtCanvasDestroy(f_help_dsp_area->canvas);
836 f_help_dsp_area->canvas = NULL ;
837 delete f_node_view_info;
839 f_help_dsp_area->canvas = NULL ;
842 delete f_wm_delete_callback;
847 // /////////////////////////////////////////////////////////////////
849 // /////////////////////////////////////////////////////////////////
852 exitCB(Widget, XtPointer client_data, XtPointer)
854 NodeWindowAgent *agent = (NodeWindowAgent*)client_data;
857 if (BookmarkEdit::modified_count() > 0)
860 resp = message_mgr().question_dialog (
861 (char*)UAS_String(CATGETS(Set_Messages, 2,
862 "Do you want to abandon your changes?")));
867 message_mgr().quit_dialog (
868 (char*)UAS_String(CATGETS(Set_Messages, 6,
869 "Do you really want to quit Dtinfo?")));
873 // /////////////////////////////////////////////////////////////////
875 // /////////////////////////////////////////////////////////////////
878 tool_bar_toggleCB(Widget, XtPointer client_data, XtPointer call_data)
880 Widget tool_bar = (Widget) client_data;
881 XmToggleButtonCallbackStruct *cdata =
882 (XmToggleButtonCallbackStruct *) call_data;
885 XtManageChild(tool_bar);
887 XtUnmanageChild(tool_bar);
891 search_area_toggleCB(Widget, XtPointer client_data, XtPointer call_data)
893 Widget search_area = (Widget) client_data;
894 XmToggleButtonCallbackStruct *cdata =
895 (XmToggleButtonCallbackStruct *) call_data;
898 XtManageChild(search_area);
900 XtUnmanageChild(search_area);
903 // /////////////////////////////////////////////////////////////////
905 // /////////////////////////////////////////////////////////////////
908 show_booklistCB(Widget, XtPointer, XtPointer)
910 UAS_List<UAS_String> env_infolibs(env().infolibs());
911 library_mgr().init(env_infolibs);
915 show_mapCB(Widget, XtPointer client_data, XtPointer)
918 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
919 UAS_Pointer<UAS_Common> bogus;
920 map_mgr().display_centered_on (bogus = agent->node_view_info()->node_ptr());
923 static void query_editorCB(Widget, XtPointer, XtPointer);
924 static void mark_listCB(Widget, XtPointer, XtPointer);
925 static void prefsCB(Widget, XtPointer, XtPointer);
926 static void section_historyCB(Widget, XtPointer, XtPointer);
927 static void open_urlCB(Widget, XtPointer, XtPointer);
928 static void search_historyCB(Widget, XtPointer, XtPointer);
929 static void scope_editorCB(Widget, XtPointer, XtPointer);
932 // /////////////////////////////////////////////////////////////////
933 // create_ui - create the user interface
934 // /////////////////////////////////////////////////////////////////
937 NodeWindowAgent::create_ui()
943 XmStringLocalized mtfstring;
947 UAS_Pointer<UAS_String> textstore;
949 // Widget w = XtCreatePopupShell("nodeview", topLevelShellWidgetClass,
950 // (Widget) toplevel(), NULL, 0);
952 f_shell = (WTopLevelShell*)(Widget)
953 WTopLevelShell (toplevel(), WPopup, "nodeview");
955 window_system().register_shell (f_shell);
957 string = CATGETS(Set_NodeWindowAgent, 1, "Dtinfo: Browser");
958 XtVaSetValues((Widget)f_shell, XmNtitle, string, NULL);
960 f_wm_delete_callback =
961 new WCallback (*f_shell, window_system().WM_DELETE_WINDOW(),
962 this, (WWL_FUN) &NodeWindowAgent::dismiss);
964 WindowGeometry wg = pref_mgr().get_geometry (PrefMgr::BrowseGeometry);
965 f_shell->Set(WArgList(XmNwidth, wg.width, XmNheight, wg.height, NULL));
967 Widget mainw = XtCreateWidget("mainw", xmMainWindowWidgetClass,
971 XtSetArg(args[n], XmNscrolledWindowChildType, XmMENU_BAR); n++;
972 Widget menu_bar = XmCreateMenuBar(mainw, (char*)"menu_bar", args, n);
975 XtSetArg(args[n], XmNorientation, XmHORIZONTAL); n++;
976 XtSetArg(args[n], XmNscrolledWindowChildType, XmCOMMAND_WINDOW); n++;
977 Widget tool_bar = XtCreateWidget("tool_bar", xmRowColumnWidgetClass,
981 XtSetArg(args[n], XmNscrolledWindowChildType, XmMESSAGE_WINDOW); n++;
982 Widget search_area = XtCreateWidget("search_area", xmFormWidgetClass,
986 Widget fileM = XmCreatePulldownMenu(menu_bar, (char*)"file_menu", 0, 0);
989 XtSetArg(args[n], XmNsubMenuId, fileM); n++;
990 widget = XtCreateManagedWidget("file", xmCascadeButtonGadgetClass,
992 help_agent().add_help_cb(widget);
995 mtfstring = CATGETS(Set_AgentLabel, 62, "Browser");
996 mnemonic = *CATGETS(Set_AgentLabel, 63, "");
997 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
999 widget = XtCreateManagedWidget("new", xmPushButtonGadgetClass, fileM, 0, 0);
1000 XtAddCallback(widget, XmNactivateCallback, cloneCB, this);
1002 mtfstring = CATGETS(Set_AgentLabel, 64, "New Window");
1003 mnemonic = *CATGETS(Set_AgentLabel, 65, "");
1004 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1006 XtCreateManagedWidget("sep1", xmSeparatorGadgetClass, fileM, 0, 0);
1008 f_print_as = XtCreateManagedWidget("print_as", xmPushButtonGadgetClass,
1010 XtAddCallback(f_print_as, XmNactivateCallback, print_asCB, this);
1012 mtfstring = CATGETS(Set_AgentLabel, 72, "Print...");
1013 mnemonic = *CATGETS(Set_AgentLabel, 71, "P");
1014 XtVaSetValues(f_print_as, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1016 XtCreateManagedWidget("sep2", xmSeparatorGadgetClass, fileM, 0, 0);
1018 widget = XtCreateManagedWidget("show", xmPushButtonGadgetClass, fileM, 0, 0);
1019 XtAddCallback(widget, XmNactivateCallback, show_locatorCB, this);
1021 mtfstring = CATGETS(Set_AgentLabel, 68, "Show Locator");
1022 mnemonic = *CATGETS(Set_AgentLabel, 69, "");
1023 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1025 XtCreateManagedWidget("sep3", xmSeparatorGadgetClass, fileM, 0, 0);
1028 XtSetArg(args[n], XmNsensitive, f_close_sensitive); n++;
1029 f_close = XtCreateManagedWidget("close", xmPushButtonGadgetClass,
1031 XtAddCallback(f_close, XmNactivateCallback, dismissCB, this);
1033 mtfstring = CATGETS(Set_AgentLabel, 74, "Close");
1034 mnemonic = *CATGETS(Set_AgentLabel, 75, "");
1035 XtVaSetValues(f_close, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1037 widget = XtCreateManagedWidget("exit", xmPushButtonGadgetClass, fileM, 0, 0);
1038 XtAddCallback(widget, XmNactivateCallback, exitCB, this);
1040 mtfstring = CATGETS(Set_AgentLabel, 76, "Exit");
1041 mnemonic = *CATGETS(Set_AgentLabel, 77, "");
1042 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1045 Widget searchM = XmCreatePulldownMenu(menu_bar, (char*)"search_menu", 0, 0);
1048 XtSetArg(args[n], XmNsubMenuId, searchM); n++;
1049 f_search_menu_button = XtCreateManagedWidget("search",
1050 xmCascadeButtonGadgetClass,
1052 help_agent().add_help_cb(f_search_menu_button);
1054 mtfstring = CATGETS(Set_AgentLabel, 102, "Search");
1055 mnemonic = *CATGETS(Set_AgentLabel, 103, "");
1056 XtVaSetValues(f_search_menu_button, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1058 widget = XtCreateManagedWidget("on_selection", xmPushButtonGadgetClass,
1060 XtAddCallback(widget, XmNactivateCallback, search_on_selectionCB, this);
1062 mtfstring = CATGETS(Set_AgentLabel, 78, "On Selection");
1063 mnemonic = *CATGETS(Set_AgentLabel, 79, "");
1064 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1066 widget = XtCreateManagedWidget("query_editor", xmPushButtonGadgetClass,
1068 XtAddCallback(widget, XmNactivateCallback, query_editorCB, 0);
1070 mtfstring = CATGETS(Set_AgentLabel, 80, "Query Editor");
1071 mnemonic = *CATGETS(Set_AgentLabel, 81, "");
1072 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1074 widget = XtCreateManagedWidget("scope_editor", xmPushButtonGadgetClass,
1076 XtAddCallback(widget, XmNactivateCallback, scope_editorCB, 0);
1078 mtfstring = CATGETS(Set_AgentLabel, 82, "Scope Editor");
1079 mnemonic = *CATGETS(Set_AgentLabel, 83, "");
1080 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1082 XtCreateManagedWidget("sep1", xmSeparatorGadgetClass, searchM, 0, 0);
1084 widget = XtCreateManagedWidget("search_history", xmPushButtonGadgetClass,
1086 XtAddCallback(widget, XmNactivateCallback, search_historyCB, 0);
1088 mtfstring = CATGETS(Set_AgentLabel, 84, "Search History");
1089 mnemonic = *CATGETS(Set_AgentLabel, 85, "");
1090 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1092 XtCreateManagedWidget("sep2", xmSeparatorGadgetClass, searchM, 0, 0);
1094 f_clear_search_hits =
1095 XtCreateManagedWidget("clear_search", xmPushButtonGadgetClass,
1097 XtAddCallback(f_clear_search_hits, XmNactivateCallback, clear_searchCB, this);
1099 XtVaSetValues(f_clear_search_hits,
1101 (XmString)XmStringLocalized(CATGETS(Set_AgentLabel, 86, "Clear Search Hits")),
1103 *CATGETS(Set_AgentLabel, 87, ""),
1106 XtCreateManagedWidget("sep3", xmSeparatorGadgetClass, searchM, 0, 0);
1108 f_search_prev = XtCreateManagedWidget("search_prev",
1109 xmPushButtonGadgetClass, searchM, 0, 0);
1110 XtAddCallback(f_search_prev, XmNactivateCallback, search_previousCB, this);
1112 mtfstring = CATGETS(Set_AgentLabel, 98, "Previous Search");
1113 mnemonic = *CATGETS(Set_AgentLabel, 99, "");
1114 XtVaSetValues(f_search_prev, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1116 f_search_next = XtCreateManagedWidget("search_next",
1117 xmPushButtonGadgetClass, searchM, 0, 0);
1118 XtAddCallback(f_search_next, XmNactivateCallback, search_nextCB, this);
1120 mtfstring = CATGETS(Set_AgentLabel, 100, "Next Search");
1121 mnemonic = *CATGETS(Set_AgentLabel, 101, "");
1122 XtVaSetValues(f_search_next, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1125 Widget goM = XmCreatePulldownMenu(menu_bar, (char*)"go_menu", 0, 0);
1127 XtSetArg(args[n], XmNsubMenuId, goM); n++;
1128 widget = XtCreateManagedWidget("go", xmCascadeButtonGadgetClass,
1130 help_agent().add_help_cb(widget);
1132 mtfstring = CATGETS(Set_AgentLabel, 104, "Go");
1133 mnemonic = *CATGETS(Set_AgentLabel, 105, "");
1134 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1136 f_history_prev = XtCreateManagedWidget("history_prev",
1137 xmPushButtonGadgetClass, goM, 0, 0);
1138 XtAddCallback(f_history_prev, XmNactivateCallback, history_prevCB, this);
1139 XtAddCallback(f_history_prev, XmNarmCallback, preview_history_prevCB, this);
1140 XtAddCallback(f_history_prev, XmNdisarmCallback, unpreviewCB, this);
1142 mtfstring = CATGETS(Set_AgentLabel, 88, "Back (History)");
1143 mnemonic = *CATGETS(Set_AgentLabel, 89, "");
1144 XtVaSetValues(f_history_prev, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1146 f_history_next = XtCreateManagedWidget("history_next",
1147 xmPushButtonGadgetClass, goM, 0, 0);
1148 XtAddCallback(f_history_next, XmNactivateCallback, history_nextCB, this);
1149 XtAddCallback(f_history_next, XmNarmCallback, preview_history_nextCB, this);
1150 XtAddCallback(f_history_next, XmNdisarmCallback, unpreviewCB, this);
1152 mtfstring = CATGETS(Set_AgentLabel, 90, "Forward (History)");
1153 mnemonic = *CATGETS(Set_AgentLabel, 91, "");
1154 XtVaSetValues(f_history_next, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1156 widget = XtCreateManagedWidget("section_history",
1157 xmPushButtonGadgetClass, goM, 0, 0);
1158 XtAddCallback(widget, XmNactivateCallback, section_historyCB, 0);
1160 mtfstring = CATGETS(Set_AgentLabel, 92, "History...");
1161 mnemonic = *CATGETS(Set_AgentLabel, 93, "");
1162 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1164 XtCreateManagedWidget("sep1", xmSeparatorGadgetClass, goM, 0, 0);
1166 f_node_next = XtCreateManagedWidget("section_next",
1167 xmPushButtonGadgetClass, goM, 0, 0);
1168 XtAddCallback(f_node_next, XmNactivateCallback, node_nextCB, this);
1169 XtAddCallback(f_node_next, XmNarmCallback, preview_nextCB, this);
1170 XtAddCallback(f_node_next, XmNdisarmCallback, unpreviewCB, this);
1172 mtfstring = CATGETS(Set_AgentLabel, 96, "Next Section");
1173 mnemonic = *CATGETS(Set_AgentLabel, 97, "");
1174 XtVaSetValues(f_node_next, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1176 f_node_prev = XtCreateManagedWidget("section_prev",
1177 xmPushButtonGadgetClass, goM, 0, 0);
1178 XtAddCallback(f_node_prev, XmNactivateCallback, node_previousCB, this);
1179 XtAddCallback(f_node_prev, XmNarmCallback, preview_previousCB, this);
1180 XtAddCallback(f_node_prev, XmNdisarmCallback, unpreviewCB, this);
1182 mtfstring = CATGETS(Set_AgentLabel, 94, "Previous Section");
1183 mnemonic = *CATGETS(Set_AgentLabel, 95, "");
1184 XtVaSetValues(f_node_prev, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1186 XtCreateManagedWidget("sep2", xmSeparatorGadgetClass, goM, 0, 0);
1188 widget = XtCreateManagedWidget("open", xmPushButtonGadgetClass, goM, 0, 0);
1189 XtAddCallback(widget, XmNactivateCallback, open_urlCB, 0);
1191 mtfstring = CATGETS(Set_AgentLabel, 66, "Open Locator...");
1192 mnemonic = *CATGETS(Set_AgentLabel, 67, "");
1193 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1196 Widget markM = XmCreatePulldownMenu(menu_bar, (char*)"marks_menu", 0, 0);
1199 XtSetArg(args[n], XmNsubMenuId, markM); n++;
1200 widget = XtCreateManagedWidget("marks", xmCascadeButtonGadgetClass,
1202 help_agent().add_help_cb(widget);
1204 mtfstring = CATGETS(Set_AgentLabel, 106, "Marks");
1205 mnemonic = *CATGETS(Set_AgentLabel, 107, "");
1206 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1208 f_create_bmrk = XtCreateManagedWidget("create_bmrk",
1209 xmPushButtonGadgetClass,
1211 XtAddCallback(f_create_bmrk, XmNactivateCallback, create_bookmarkCB, this);
1216 XtVaGetValues(f_create_bmrk, XmNfontList, &font, NULL);
1217 bmfont = XmFontListCopy(font);
1220 if (window_system().dtinfo_font())
1221 bmfont = XmFontListAppendEntry(bmfont, window_system().dtinfo_font());
1223 mtfstring = CATGETS(Set_AgentLabel, 108, "Create Bookmark");
1224 mnemonic = *CATGETS(Set_AgentLabel, 109, "");
1225 XtVaSetValues(f_create_bmrk, XmNlabelString, (XmString)mtfstring,
1226 XmNmnemonic, mnemonic,
1227 XmNfontList, bmfont, NULL);
1229 f_create_anno = XtCreateManagedWidget("create_anno",
1230 xmPushButtonGadgetClass,
1232 XtAddCallback(f_create_anno, XmNactivateCallback, create_annotationCB, this);
1234 mtfstring = CATGETS(Set_AgentLabel, 110, "Create Note...");
1235 mnemonic = *CATGETS(Set_AgentLabel, 111, "");
1236 XtVaSetValues(f_create_anno, XmNlabelString, (XmString)mtfstring,
1237 XmNmnemonic, mnemonic,
1238 XmNfontList, bmfont, NULL);
1240 XtCreateManagedWidget("sep1", xmSeparatorGadgetClass, markM, 0, 0);
1242 Widget list_marks = XtCreateManagedWidget("list_marks",
1243 xmPushButtonGadgetClass,
1245 XtAddCallback(list_marks, XmNactivateCallback, mark_listCB, 0);
1247 mtfstring = CATGETS(Set_AgentLabel, 112, "List Marks");
1248 mnemonic = *CATGETS(Set_AgentLabel, 113, "");
1249 XtVaSetValues(list_marks, XmNlabelString, (XmString)mtfstring,
1250 XmNmnemonic, mnemonic,
1251 XmNfontList, bmfont, NULL);
1253 XtCreateManagedWidget("sep2", xmSeparatorGadgetClass, markM, 0, 0);
1255 f_edit_mark = XtCreateManagedWidget("edit_mark",
1256 xmPushButtonGadgetClass, markM, 0, 0);
1257 XtAddCallback(f_edit_mark, XmNactivateCallback, edit_markCB, this);
1259 mtfstring = CATGETS(Set_AgentLabel, 114, "Edit Selection...");
1260 mnemonic = *CATGETS(Set_AgentLabel, 115, "");
1261 XtVaSetValues(f_edit_mark, XmNlabelString, (XmString)mtfstring,
1262 XmNmnemonic, mnemonic,
1263 XmNfontList, bmfont, NULL);
1265 f_move_mark = XtCreateManagedWidget("move_mark",
1266 xmPushButtonGadgetClass, markM, 0, 0);
1267 XtAddCallback(f_move_mark, XmNactivateCallback, move_markCB, this);
1269 mtfstring = CATGETS(Set_AgentLabel, 116, "Move Selection");
1270 mnemonic = *CATGETS(Set_AgentLabel, 117, "");
1271 XtVaSetValues(f_move_mark, XmNlabelString, (XmString)mtfstring,
1272 XmNmnemonic, mnemonic,
1273 XmNfontList, bmfont, NULL);
1275 f_delete_mark = XtCreateManagedWidget("delete_mark",
1276 xmPushButtonGadgetClass,
1278 XtAddCallback(f_delete_mark, XmNactivateCallback, delete_markCB, this);
1280 mtfstring = CATGETS(Set_AgentLabel, 118, "Delete Selection");
1281 mnemonic = *CATGETS(Set_AgentLabel, 119, "");
1282 XtVaSetValues(f_delete_mark, XmNlabelString, (XmString)mtfstring,
1283 XmNmnemonic, mnemonic,
1284 XmNfontList, bmfont, NULL);
1286 // Add the icons to the beginning of the label strings
1287 if (!window_system().nofonts())
1290 icon[1] = OLIAS_SPACE04;
1294 icon[0] = OLIAS_BOOKMARK_ICON;
1296 XtSetArg(args[n], XmNlabelString, &string); n++;
1297 XtGetValues(f_create_bmrk, args, n);
1299 XtSetArg(args[n], XmNlabelString,
1300 XmStringConcat(XmStringCreate(icon, (char*)OLIAS_FONT),
1302 XtSetValues(f_create_bmrk, args, n);
1304 icon[0] = OLIAS_ANNOTATION_ICON;
1306 XtSetArg(args[n], XmNlabelString, &string); n++;
1307 XtGetValues(f_create_anno, args, n);
1309 XtSetArg(args[n], XmNlabelString,
1310 XmStringConcat(XmStringCreate(icon, (char*)OLIAS_FONT),
1312 XtSetValues(f_create_anno, args, n);
1314 icon[0] = OLIAS_SPACE16;
1316 XtSetArg(args[n], XmNlabelString, &string); n++;
1317 XtGetValues(f_move_mark, args, n);
1319 XtSetArg(args[n], XmNlabelString,
1320 XmStringConcat(XmStringCreate(icon, (char*)OLIAS_FONT),
1322 XtSetValues(f_move_mark, args, n);
1325 XtSetArg(args[n], XmNlabelString, &string); n++;
1326 XtGetValues(list_marks, args, n);
1328 XtSetArg(args[n], XmNlabelString,
1329 XmStringConcat(XmStringCreate(icon, (char*)OLIAS_FONT),
1331 XtSetValues(list_marks, args, n);
1334 XtSetArg(args[n], XmNlabelString, &string); n++;
1335 XtGetValues(f_edit_mark, args, n);
1337 XtSetArg(args[n], XmNlabelString,
1338 XmStringConcat(XmStringCreate(icon, (char*)OLIAS_FONT),
1340 XtSetValues(f_edit_mark, args, n);
1343 XtSetArg(args[n], XmNlabelString, &string); n++;
1344 XtGetValues(f_delete_mark, args, n);
1346 XtSetArg(args[n], XmNlabelString,
1347 XmStringConcat(XmStringCreate(icon, (char*)OLIAS_FONT),
1349 XtSetValues(f_delete_mark, args, n);
1353 Widget optionsM = XmCreatePulldownMenu(menu_bar, (char*)"options_menu", 0, 0);
1356 XtSetArg(args[n], XmNsubMenuId, optionsM); n++;
1357 widget = XtCreateManagedWidget("options", xmCascadeButtonGadgetClass,
1359 help_agent().add_help_cb(widget);
1361 mtfstring = CATGETS(Set_AgentLabel, 120, "Options");
1362 mnemonic = *CATGETS(Set_AgentLabel, 121, "");
1363 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1365 widget = XtCreateManagedWidget("preferences", xmPushButtonGadgetClass,
1367 XtAddCallback(widget, XmNactivateCallback, prefsCB, 0);
1369 mtfstring = CATGETS(Set_AgentLabel, 122, "Preferences...");
1370 mnemonic = *CATGETS(Set_AgentLabel, 123, "");
1371 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1373 XtCreateManagedWidget("sep1", xmSeparatorGadgetClass, optionsM, 0, 0);
1375 f_detach_graphic = XtCreateManagedWidget("detach_graphic",
1376 xmPushButtonGadgetClass,
1378 XtAddCallback(f_detach_graphic, XmNactivateCallback, detach_graphicCB, this);
1380 mtfstring = CATGETS(Set_AgentLabel, 124, "Detach Graphic");
1381 mnemonic = *CATGETS(Set_AgentLabel, 125, "");
1382 XtVaSetValues(f_detach_graphic, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1384 XtCreateManagedWidget("sep2", xmSeparatorGadgetClass, optionsM, 0, 0);
1386 Widget tool_barT = XtCreateManagedWidget("show_tool_bar",
1387 xmToggleButtonGadgetClass,
1389 XtAddCallback(tool_barT, XmNvalueChangedCallback,
1390 tool_bar_toggleCB, tool_bar);
1392 mtfstring = CATGETS(Set_AgentLabel, 126, "Show Tool Bar");
1393 mnemonic = *CATGETS(Set_AgentLabel, 127, "");
1394 XtVaSetValues(tool_barT, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1396 Widget search_areaT = XtCreateManagedWidget("show_search_area",
1397 xmToggleButtonGadgetClass,
1399 XtAddCallback(search_areaT, XmNvalueChangedCallback,
1400 search_area_toggleCB, search_area);
1402 mtfstring = CATGETS(Set_AgentLabel, 128, "Show Search Area");
1403 mnemonic = *CATGETS(Set_AgentLabel, 129, "");
1404 XtVaSetValues(search_areaT, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1407 Widget windowsM = XmCreatePulldownMenu(menu_bar, (char*)"windows_menu", 0, 0);
1410 XtSetArg(args[n], XmNsubMenuId, windowsM); n++;
1411 widget = XtCreateManagedWidget("windows", xmCascadeButtonGadgetClass,
1413 help_agent().add_help_cb(widget);
1415 mtfstring = CATGETS(Set_AgentLabel, 130, "Windows");
1416 mnemonic = *CATGETS(Set_AgentLabel, 131, "");
1417 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1419 widget = XtCreateManagedWidget("booklist", xmPushButtonGadgetClass,
1421 XtAddCallback(widget, XmNactivateCallback, show_booklistCB, 0);
1423 mtfstring = CATGETS(Set_AgentLabel, 132, "Book List");
1424 mnemonic = *CATGETS(Set_AgentLabel, 133, "");
1425 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1427 widget = XtCreateManagedWidget("graphical_map", xmPushButtonGadgetClass,
1429 XtAddCallback(widget, XmNactivateCallback, show_mapCB, this);
1431 mtfstring = CATGETS(Set_AgentLabel, 134, "Graphical Map");
1432 mnemonic = *CATGETS(Set_AgentLabel, 135, "");
1433 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1437 Widget helpM = XmCreatePulldownMenu(menu_bar, (char*)"help_menu", 0, 0);
1439 XtSetArg(args[n], XmNsubMenuId, helpM); n++;
1440 widget = XtCreateManagedWidget("help", xmCascadeButtonGadgetClass,
1442 help_agent().add_help_cb(widget);
1445 XtSetArg(args[n], XmNmenuHelpWidget, widget); n++;
1446 XtSetValues(menu_bar, args, n);
1448 mtfstring = CATGETS(Set_AgentLabel, 143, "Help");
1449 mnemonic = *CATGETS(Set_AgentLabel, 144, "");
1450 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, XmNmnemonic, mnemonic, NULL);
1452 #define AM WAutoManage
1454 WXmPushButton on_overview (helpM, "on_overview", AM);
1455 WXmSeparator on_sep1 (helpM, "on_sep1", AM);
1456 WXmPushButton on_tasks (helpM, "on_tasks", AM);
1457 WXmPushButton on_reference (helpM, "on_reference", AM);
1458 WXmPushButton on_item (helpM, "on_item", AM);
1459 WXmSeparator on_sep2 (helpM, "on_sep2", AM);
1460 WXmPushButton on_help (helpM, "on_help" , AM);
1461 WXmSeparator on_sep3 (helpM, "on_sep3", AM);
1462 WXmPushButton on_about (helpM, "on_about" , AM);
1465 //WXmPushButton on_window (helpM, "on_window" , AM);
1466 // WXmPushButton on_application (helpM, "on_application", AM);
1467 // WXmPushButton index (helpM, "index" , AM);
1468 //WXmPushButton on_keys (helpM, "on_keys" , AM);
1469 //WXmPushButton on_version (helpM, "on_version" , AM);
1470 //ON_ACTIVATE (on_version, display_version);
1472 mtfstring = CATGETS(Set_AgentLabel, 257, "Overview");
1473 mnemonic = *CATGETS(Set_AgentLabel, 258, "");
1474 XtVaSetValues((Widget)on_overview, XmNlabelString, (XmString)mtfstring,
1475 XmNmnemonic, mnemonic, NULL);
1477 mtfstring = CATGETS(Set_AgentLabel, 249, "Tasks");
1478 mnemonic = *CATGETS(Set_AgentLabel, 250, "");
1479 XtVaSetValues((Widget)on_tasks, XmNlabelString, (XmString)mtfstring,
1480 XmNmnemonic, mnemonic, NULL);
1482 mtfstring = CATGETS(Set_AgentLabel, 251, "Reference");
1483 mnemonic = *CATGETS(Set_AgentLabel, 252, "");
1484 XtVaSetValues((Widget)on_reference, XmNlabelString, (XmString)mtfstring,
1485 XmNmnemonic, mnemonic, NULL);
1487 mtfstring = CATGETS(Set_AgentLabel, 50, "On Item...");
1488 mnemonic = *CATGETS(Set_AgentLabel, 51, "");
1489 XtVaSetValues((Widget)on_item, XmNlabelString, (XmString)mtfstring,
1490 XmNmnemonic, mnemonic, NULL);
1492 mtfstring = CATGETS(Set_AgentLabel, 253, "Using Help");
1493 mnemonic = *CATGETS(Set_AgentLabel, 254, "");
1494 XtVaSetValues((Widget)on_help, XmNlabelString, (XmString)mtfstring,
1495 XmNmnemonic, mnemonic, NULL);
1497 mtfstring = CATGETS(Set_AgentLabel, 255, "About Information Manager");
1498 mnemonic = *CATGETS(Set_AgentLabel, 256, "");
1499 XtVaSetValues((Widget)on_about, XmNlabelString, (XmString)mtfstring,
1500 XmNmnemonic, mnemonic, NULL);
1504 mtfstring = CATGETS(Set_AgentLabel, 147, "On Window");
1505 mnemonic = *CATGETS(Set_AgentLabel, 148, "");
1506 XtVaSetValues((Widget)on_window, XmNlabelString, (XmString)mtfstring,
1507 XmNmnemonic, mnemonic, NULL);
1508 // mtfstring = CATGETS(Set_AgentLabel, 149, "On Application");
1509 // mnemonic = *CATGETS(Set_AgentLabel, 150, "");
1510 // XtVaSetValues((Widget)on_application, XmNlabelString, (XmString)mtfstring,
1511 // XmNmnemonic, mnemonic, NULL);
1512 // mtfstring = CATGETS(Set_AgentLabel, 151, "Index");
1513 // mnemonic = *CATGETS(Set_AgentLabel, 152, "");
1514 // XtVaSetValues((Widget)index, XmNlabelString, (XmString)mtfstring,
1515 // XmNmnemonic, mnemonic, NULL);
1516 mtfstring = CATGETS(Set_AgentLabel, 155, "On Keys");
1517 mnemonic = *CATGETS(Set_AgentLabel, 156, "");
1518 XtVaSetValues((Widget)on_keys, XmNlabelString, (XmString)mtfstring,
1519 XmNmnemonic, mnemonic, NULL);
1520 mtfstring = CATGETS(Set_AgentLabel, 157, "On Version");
1521 mnemonic = *CATGETS(Set_AgentLabel, 158. "");
1522 XtVaSetValues((Widget)on_version, XmNlabelString, (XmString)mtfstring,
1523 XmNmnemonic, mnemonic, NULL);
1527 help_agent().add_activate_help ((Widget)on_overview, (char*)"on_overview");
1528 help_agent().add_activate_help ((Widget)on_tasks, (char*)"on_tasks");
1529 help_agent().add_activate_help ((Widget)on_reference, (char*)"on_reference");
1530 help_agent().add_activate_help ((Widget)on_reference, (char*)"on_reference");
1531 help_agent().add_context_help ((Widget)on_item);
1532 help_agent().add_activate_help ((Widget)on_help, (char*)"on_help");
1533 help_agent().add_activate_help ((Widget)on_about, (char*)"on_about");
1537 f_history_prev2 = XtCreateManagedWidget("history_prev",
1538 xmPushButtonWidgetClass,
1540 XtAddCallback(f_history_prev2, XmNactivateCallback, history_prevCB, this);
1541 XtAddCallback(f_history_prev2, XmNarmCallback, preview_history_prevCB, this);
1542 XtAddCallback(f_history_prev2, XmNdisarmCallback, unpreviewCB, this);
1543 help_agent().add_help_cb (f_history_prev2);
1545 textstore = new UAS_String(CATGETS(Set_AgentQHelp, 1,
1546 "Go to the previous section in history"));
1547 add_quick_help(f_history_prev2, (char*)*textstore);
1548 f_textstore.insert_item(textstore);
1550 f_history_next2 = XtCreateManagedWidget("history_next",
1551 xmPushButtonWidgetClass,
1553 XtAddCallback(f_history_next2, XmNactivateCallback, history_nextCB, this);
1554 XtAddCallback(f_history_next2, XmNarmCallback, preview_history_nextCB, this);
1555 XtAddCallback(f_history_next2, XmNdisarmCallback, unpreviewCB, this);
1556 help_agent().add_help_cb (f_history_next2);
1558 textstore = new UAS_String(CATGETS(Set_AgentQHelp, 2,
1559 "Go to the next section in history"));
1560 add_quick_help(f_history_next2, (char*)*textstore);
1561 f_textstore.insert_item(textstore);
1563 widget = XtCreateManagedWidget("space",
1567 f_node_prev2 = XtCreateManagedWidget("section_prev",
1568 xmPushButtonWidgetClass,
1570 XtAddCallback(f_node_prev2, XmNactivateCallback, node_previousCB, this);
1571 XtAddCallback(f_node_prev2, XmNarmCallback, preview_previousCB, this);
1572 XtAddCallback(f_node_prev2, XmNdisarmCallback, unpreviewCB, this);
1573 help_agent().add_help_cb (f_node_prev2);
1575 textstore = new UAS_String(CATGETS(Set_AgentQHelp, 3,
1576 "Go to the previous section in document"));
1577 add_quick_help(f_node_prev2, (char*)*textstore);
1578 f_textstore.insert_item(textstore);
1580 f_node_next2 = XtCreateManagedWidget("section_next",
1581 xmPushButtonWidgetClass,
1583 XtAddCallback(f_node_next2, XmNactivateCallback, node_nextCB, this);
1584 XtAddCallback(f_node_next2, XmNarmCallback, preview_nextCB, this);
1585 XtAddCallback(f_node_next2, XmNdisarmCallback, unpreviewCB, this);
1586 help_agent().add_help_cb (f_node_next2);
1588 textstore = new UAS_String(CATGETS(Set_AgentQHelp, 4,
1589 "Go to the next section in document"));
1590 add_quick_help(f_node_next2, (char*)*textstore);
1591 f_textstore.insert_item(textstore);
1593 widget = XtCreateManagedWidget("space",
1597 f_search_prev2 = XtCreateManagedWidget("search_prev",
1598 xmPushButtonWidgetClass,
1600 XtAddCallback(f_search_prev2, XmNactivateCallback, search_previousCB, this);
1601 help_agent().add_help_cb (f_search_prev2);
1603 textstore = new UAS_String(CATGETS(Set_AgentQHelp, 5,
1604 "Go to the previous search match"));
1605 add_quick_help(f_search_prev2, (char*)*textstore);
1606 f_textstore.insert_item(textstore);
1608 f_search_next2 = XtCreateManagedWidget("search_next",
1609 xmPushButtonWidgetClass,
1611 XtAddCallback(f_search_next2, XmNactivateCallback, search_nextCB, this);
1612 help_agent().add_help_cb (f_search_next2);
1614 textstore = new UAS_String(CATGETS(Set_AgentQHelp, 6,
1615 "Go to the next search match"));
1616 add_quick_help(f_search_next2, (char*)*textstore);
1617 f_textstore.insert_item(textstore);
1620 widget = XtCreateManagedWidget("space",
1625 f_print2 = XtCreateManagedWidget("print", xmPushButtonWidgetClass,
1627 XtAddCallback(f_print2, XmNactivateCallback, printCB, this);
1628 help_agent().add_help_cb (f_print2);
1630 textstore = new UAS_String(CATGETS(Set_AgentQHelp, 7,
1631 "Print current section"));
1632 add_quick_help(f_print2, (char*)*textstore);
1633 f_textstore.insert_item(textstore);
1635 widget = XtCreateManagedWidget("booklist", xmPushButtonWidgetClass,
1637 XtAddCallback(widget, XmNactivateCallback, show_booklistCB, 0);
1638 help_agent().add_help_cb (widget);
1640 textstore = new UAS_String(CATGETS(Set_AgentQHelp, 8, "Display Book List"));
1641 add_quick_help(widget, (char*)*textstore);
1642 f_textstore.insert_item(textstore);
1644 widget = XtCreateManagedWidget("graphical_map", xmPushButtonWidgetClass,
1646 XtAddCallback(widget, XmNactivateCallback, show_mapCB, this);
1647 help_agent().add_help_cb (widget);
1649 textstore = new UAS_String(CATGETS(Set_AgentQHelp, 9,
1650 "Display Graphical Map"));
1651 add_quick_help(widget, (char*)*textstore);
1652 f_textstore.insert_item(textstore);
1654 f_locked = pref_mgr().get_boolean (PrefMgr::BrowseLock);
1656 XtSetArg(args[n], XmNlabelType, XmPIXMAP); n++;
1658 // The opposite state always needs to be the semilocked pixmap.
1661 XtSetArg(args[n], XmNset, True); n++;
1662 XtSetArg(args[n], XmNselectPixmap,
1663 window_system().locked_pixmap(tool_bar)); n++;
1664 XtSetArg(args[n], XmNlabelPixmap,
1665 window_system().semilocked_pixmap(tool_bar)); n++;
1669 XtSetArg(args[n], XmNset, False); n++;
1670 XtSetArg(args[n], XmNlabelPixmap,
1671 window_system().unlocked_pixmap(tool_bar)); n++;
1672 XtSetArg(args[n], XmNselectPixmap,
1673 window_system().semilocked_pixmap(tool_bar)); n++;
1676 widget = XtCreateManagedWidget("lock", xmToggleButtonWidgetClass,
1678 XtAddCallback(widget, XmNvalueChangedCallback, lock_toggleCB, this);
1679 help_agent().add_help_cb (widget);
1681 textstore = new UAS_String(CATGETS(Set_AgentQHelp, 10,
1682 "Pin (unpin) this window, "
1683 "to prevent (allow) use for new documents."));
1684 add_quick_help(widget, (char*)*textstore);
1685 f_textstore.insert_item(textstore);
1687 mtfstring = CATGETS(Set_AgentLabel, 159, "Retain");
1688 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, NULL);
1692 XtSetArg(args[n], XmNscrolledWindowChildType, XmWORK_AREA); n++;
1693 f_form = XtCreateWidget("form", xmFormWidgetClass, mainw, args, n);
1696 f_title_menu = (WXmPulldownMenu*)(Widget)WXmPulldownMenu((WComposite&)f_form, (char*)"title_menu");
1698 XtSetArg(args[n], XmNsubMenuId, (Widget) f_title_menu); n++;
1699 f_title_option = (WXmOptionMenu*)(Widget)
1700 WXmOptionMenu ((WComposite&)f_form, (char*)"title", AM, args, n);
1701 help_agent().add_help_cb ((Widget)*f_title_option);
1703 f_tab_area = (WXmRowColumn*)(Widget) WXmRowColumn (f_form, "tab_area");
1704 f_tab_area->Manage();
1706 // this needs to be here for reference through the resources (attachments)
1707 Widget message = XtCreateManagedWidget("message", xmFrameWidgetClass,
1713 XtSetArg(args[n], XmNforeground, &fg); n++;
1714 XtSetArg(args[n], XmNbackground, &bg); n++;
1715 XtGetValues(message, args, n);
1717 XtSetArg(args[n], XmNforeground, fg); n++;
1718 XtSetArg(args[n], XmNbackground, bg); n++;
1719 f_status_text = XtCreateManagedWidget("text", xmTextFieldWidgetClass,
1721 string = CATGETS(Set_NodeWindowAgent, 2, "To preview a link destination, "
1722 "click and hold on the link.");
1723 XtVaSetValues(f_status_text, XmNvalue, string, NULL);
1728 WXmCascadeButton windows_cascade (menu_bar, "windows" , AM);
1729 WXmPulldownMenu windows_menu (menu_bar, (char*)"windows_menu" );
1730 WXmPushButton(windows_menu, "monitor", AM).
1731 SetActivateCallback(this, (WWL_FUN)&NodeWindowAgent::monitor, (void*)1);
1733 WXmPushButton(windows_menu, "monitor_off", AM).
1734 SetActivateCallback(this, (WWL_FUN)&NodeWindowAgent::monitor, 0);
1740 WXmCascadeButton debug_cascade (menu_bar, "debug" );
1741 WXmPulldownMenu debug_menu (menu_bar, (char*)"debug_menu" );
1742 WXmToggleButton command_processor (debug_menu, "command_processor", AM);
1743 WXmPushButton document_id (debug_menu, "document_id", AM);
1747 f_frame = (WXmFrame *)(Widget)WXmFrame (f_form, "frame" , AM);
1749 XmFontList defaultList = NULL;
1751 XtSetArg (args[n], XmNfontList, &defaultList); ++n;
1752 XtGetValues(f_status_text, args, n);
1754 f_help_dsp_area = (DtHelpDispAreaStruct*)
1755 _DtHelpCreateDisplayArea(WXmForm(*f_frame, "inform", WAutoManage),//parent
1756 (char*)"display_area", // name
1757 _DtHelpSTATIC, // vert flag
1758 _DtHelpAS_NEEDED, // horz flag
1759 FALSE, // traversal flag
1762 (hypertext_cb_ptr) hypertext_cb, // hypertext cb
1763 (resize_cb_ptr) resize_cb, // resize cb
1764 0, // exec ok routine
1765 this, // client_data
1766 defaultList // default font list
1769 assert( f_help_dsp_area && f_help_dsp_area->canvas );
1771 help_agent().add_help_cb (f_help_dsp_area->dispWid);
1772 help_agent().add_help_cb (f_help_dsp_area->vertScrollWid);
1773 help_agent().add_help_cb (f_help_dsp_area->horzScrollWid);
1775 // create detach graphic popup menu
1776 f_detach_menu = XmCreatePopupMenu(
1777 f_help_dsp_area->dispWid, (char*)"detach_graphic", NULL, 0);
1778 f_detach_button = XmCreatePushButton(f_detach_menu, (char*)"Detach Graphic", NULL, 0);
1779 XtAddCallback(f_detach_button, XmNactivateCallback, detach_grCB, this);
1780 XtManageChild(f_detach_button);
1781 mtfstring = CATGETS(Set_AgentLabel, 124, "Detach Graphic");
1782 XtVaSetValues(f_detach_button, XmNlabelString, (XmString)mtfstring, NULL);
1784 f_attach_button = XmCreatePushButton(f_detach_menu, (char*)"Attach Graphic", NULL, 0);
1785 XtAddCallback(f_attach_button, XmNactivateCallback, attach_grCB, this);
1786 XtManageChild(f_attach_button);
1787 mtfstring = CATGETS(Set_AgentLabel, 265, "Attach Graphic");
1788 XtVaSetValues(f_attach_button, XmNlabelString, (XmString)mtfstring, NULL);
1790 f_raise_button = XmCreatePushButton(f_detach_menu, (char*)"Raise Graphic", NULL, 0);
1791 XtAddCallback(f_raise_button, XmNactivateCallback, raise_grCB, this);
1792 XtManageChild(f_raise_button);
1793 mtfstring = CATGETS(Set_AgentLabel, 264, "Raise Graphic");
1794 XtVaSetValues(f_raise_button, XmNlabelString, (XmString)mtfstring, NULL);
1796 XtAddEventHandler (f_help_dsp_area->dispWid, ButtonPressMask, False, popup_menuCB, (XtPointer)this);
1799 // create link preview popup menu
1800 f_preview_menu = XmCreatePopupMenu(
1801 f_help_dsp_area->dispWid, (char*)"preview_menu", NULL, 0);
1803 f_preview_label = XmCreateLabel(f_preview_menu, (char*)"pre_label", NULL, 0);
1804 XtManageChild(f_preview_label);
1806 widget = XmCreateSeparator(f_preview_menu, (char*)"sep", NULL, 0);
1807 XtVaSetValues(widget, XmNseparatorType, XmDOUBLE_LINE, NULL);
1808 XtManageChild(widget);
1810 widget = XmCreatePushButton(f_preview_menu, (char*)"widget", NULL, 0);
1811 XtAddCallback(widget, XmNactivateCallback, go_to_linkCB, this);
1812 XtManageChild(widget);
1813 mtfstring = CATGETS(Set_AgentLabel, 168, "Display Link");
1814 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, NULL);
1816 widget = XmCreatePushButton(f_preview_menu, (char*)"widget", NULL, 0);
1817 XtAddCallback(widget, XmNactivateCallback, open_new_nodeCB, this);
1818 XtManageChild(widget);
1819 mtfstring = CATGETS(Set_AgentLabel, 64, "New Window");
1820 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, NULL);
1822 // create default popup menu
1823 f_default_menu = XmCreatePopupMenu(
1824 f_help_dsp_area->dispWid, (char*)"default_menu",NULL, 0);
1826 f_node_next3 = XmCreatePushButton(f_default_menu, (char*)"f_node_next3", NULL, 0);
1827 XtAddCallback(f_node_next3, XmNactivateCallback, node_nextCB, this);
1828 XtManageChild(f_node_next3);
1829 mtfstring = CATGETS(Set_AgentLabel, 96, "Next Section");
1830 XtVaSetValues(f_node_next3, XmNlabelString, (XmString)mtfstring, NULL);
1832 f_node_prev3 = XmCreatePushButton(f_default_menu, (char*)"f_node_prev3", NULL, 0);
1833 XtAddCallback(f_node_prev3, XmNactivateCallback, node_previousCB, this);
1834 XtManageChild(f_node_prev3);
1835 mtfstring = CATGETS(Set_AgentLabel, 94, "Previous Section");
1836 XtVaSetValues(f_node_prev3, XmNlabelString, (XmString)mtfstring, NULL);
1838 widget = XmCreateSeparator(f_default_menu, (char*)"sep", NULL, 0);
1839 XtManageChild(widget);
1841 widget = XmCreatePushButton(f_default_menu, (char*)"widget", NULL, 0);
1842 XtAddCallback(widget, XmNactivateCallback, show_locatorCB, this);
1843 XtManageChild(widget);
1844 mtfstring = CATGETS(Set_AgentLabel, 68, "Show Locator");
1845 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, NULL);
1847 widget = XmCreateSeparator(f_default_menu, (char*)"sep", NULL, 0);
1848 XtManageChild(widget);
1850 widget = XmCreatePushButton(f_default_menu, (char*)"widget", NULL, 0);
1851 XtAddCallback(widget, XmNactivateCallback, printCB, this);
1852 XtManageChild(widget);
1853 mtfstring = CATGETS(Set_AgentLabel, 70, "Print");
1854 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, NULL);
1858 f_help_dsp_area->vScrollNotify = v_scroll_notify ;
1859 f_help_dsp_area->armCallback = arm_callback;
1861 f_help_dsp_area->dtinfo = True;
1863 if (MB_CUR_MAX > 1) {
1865 // DtHelpDispAreaStruct cant_begin_chars
1866 WString cant_begin_chars = CATGETS(Set_NodeWindowAgent, 5, "");
1867 f_help_dsp_area->cant_begin_chars = cant_begin_chars.get_wstr();
1869 // DtHelpDispAreaStruct cant_end_chars
1870 WString cant_end_chars = CATGETS(Set_NodeWindowAgent, 6, "");
1871 f_help_dsp_area->cant_end_chars = cant_end_chars.get_wstr();
1875 for (i = 0; f_help_dsp_area->cant_begin_chars[i]; i++);
1876 fprintf(stderr, "(DEBUG) %d chars, cant_begin_chars=%s\n",
1877 i, cant_begin_chars.get_mbstr());
1878 for (i = 0; f_help_dsp_area->cant_end_chars[i]; i++);
1879 fprintf(stderr, "(DEBUG) %d chars, cant_end_chars=%s\n",
1880 i, cant_end_chars.get_mbstr());
1883 _DtCanvasLoadMetrics((_DtCvHandle)f_help_dsp_area->canvas);
1887 // install accelerators on f_viewport
1888 XtInstallAccelerators(f_form, f_search_prev);
1889 XtInstallAccelerators(f_form, f_search_next);
1891 // piggyback on the Help Area vertical scrollbar so we can scroll our
1893 XtAddCallback (f_help_dsp_area->vertScrollWid,
1895 v_scroll_callback, this);
1897 XtAddCallback (f_help_dsp_area->vertScrollWid,
1898 XmNincrementCallback,
1899 v_scroll_callback, this);
1901 XtAddCallback (f_help_dsp_area->vertScrollWid,
1902 XmNdecrementCallback,
1903 v_scroll_callback, this);
1905 XtAddCallback (f_help_dsp_area->vertScrollWid,
1906 XmNpageDecrementCallback,
1907 v_scroll_callback, this);
1909 XtAddCallback (f_help_dsp_area->vertScrollWid,
1910 XmNpageIncrementCallback,
1911 v_scroll_callback, this);
1913 XtAddCallback (f_help_dsp_area->vertScrollWid,
1914 XmNtoBottomCallback,
1915 v_scroll_callback, this);
1917 XtAddCallback (f_help_dsp_area->vertScrollWid,
1919 v_scroll_callback, this);
1921 XtAddCallback (f_help_dsp_area->vertScrollWid,
1922 XmNvalueChangedCallback,
1923 v_scroll_callback, this);
1925 // piggyback on the Help Area horizontal scrollbar so we can
1926 // track the detached graphic graphic.
1927 XtAddCallback (f_help_dsp_area->horzScrollWid,
1929 h_scroll_callback, this);
1931 XtAddCallback (f_help_dsp_area->horzScrollWid,
1932 XmNincrementCallback,
1933 h_scroll_callback, this);
1935 XtAddCallback (f_help_dsp_area->horzScrollWid,
1936 XmNdecrementCallback,
1937 h_scroll_callback, this);
1939 XtAddCallback (f_help_dsp_area->horzScrollWid,
1940 XmNpageDecrementCallback,
1941 h_scroll_callback, this);
1943 XtAddCallback (f_help_dsp_area->horzScrollWid,
1944 XmNpageIncrementCallback,
1945 h_scroll_callback, this);
1947 XtAddCallback (f_help_dsp_area->horzScrollWid,
1948 XmNtoBottomCallback,
1949 h_scroll_callback, this);
1951 XtAddCallback (f_help_dsp_area->horzScrollWid,
1953 h_scroll_callback, this);
1955 XtAddCallback (f_help_dsp_area->horzScrollWid,
1956 XmNvalueChangedCallback,
1957 h_scroll_callback, this);
1960 // Request MarkSelectionChanged message for all marks
1961 MarkCanvas::request (this);
1963 node_mgr().UAS_Sender<SelectionChanged>::request (this);
1967 widget = XmCreatePulldownMenu(search_area, (char*)"scope_menu", 0, 0);
1970 XtSetArg(args[n], XmNsubMenuId, widget); n++;
1971 XtManageChild(widget = XmCreateOptionMenu(search_area, (char*)"scope", args, n));
1972 help_agent().add_help_cb (widget);
1974 textstore = new UAS_String(CATGETS(Set_AgentQHelp, 60,
1975 "Specify search scope"));
1976 add_quick_help(widget, (char*)*textstore);
1977 f_textstore.insert_item(textstore);
1979 mtfstring = CATGETS(Set_AgentLabel, 59, "Search:");
1980 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, NULL);
1982 // hookup the ScopeMenu object here
1983 f_scope_menu = new ScopeMenu (widget, TRUE); // (require current section scop)
1986 XtSetArg(args[n], XmNleftAttachment, XmATTACH_WIDGET); n++;
1987 XtSetArg(args[n], XmNleftWidget, widget); n++;
1989 f_search_text = (WXmTextField*)(Widget)
1990 WXmTextField (search_area, "text", AM, args, n);
1991 XtAddEventHandler (*f_search_text, EnterWindowMask, False,
1992 (XtEventHandler) search_help, (XtPointer) this);
1993 XtAddEventHandler (*f_search_text, LeaveWindowMask, False,
1994 (XtEventHandler) search_help, (XtPointer) this);
1995 XtAddEventHandler (*f_search_text, FocusChangeMask, False,
1996 (XtEventHandler) search_help, (XtPointer) this);
1997 ON_ACTIVATE (*f_search_text, text_callback);
1998 help_agent().add_help_cb (*f_search_text);
2000 widget = XtCreateManagedWidget("scope_editor", xmPushButtonWidgetClass,
2002 XtAddCallback(widget, XmNactivateCallback, scope_editorCB, 0);
2003 help_agent().add_help_cb (widget);
2005 mtfstring = CATGETS(Set_AgentLabel, 46, "Scope Editor");
2006 XtVaSetValues(widget, XmNlabelString, (XmString)mtfstring, NULL);
2008 textstore = new UAS_String(CATGETS(Set_AgentQHelp, 11,
2009 "Specify search scope using the Scope Editor"));
2010 add_quick_help(widget, (char*)*textstore);
2011 f_textstore.insert_item(textstore);
2013 // set right attachment here since it cannot be set at creation time
2014 XtSetArg(args[n], XmNrightAttachment, XmATTACH_WIDGET); n++;
2015 XtSetArg(args[n], XmNrightWidget, widget); n++;
2016 XtSetValues(*f_search_text, args, n);
2019 /* -------- Debugging setup. Should be a function. -------- */
2021 bool debugging = window_system().get_boolean_app_resource("debug");
2023 if (debugging && False)
2024 debug_cascade.Manage();
2025 debug_cascade.SubMenuId (debug_menu);
2026 ON_ACTIVATE (document_id, document_id_display);
2029 XtManageChild(f_form);
2030 XtManageChild(menu_bar);
2031 if (XmToggleButtonGadgetGetState(tool_barT))
2032 XtManageChild(tool_bar);
2033 if (XmToggleButtonGadgetGetState(search_areaT))
2034 XtManageChild(search_area);
2035 XtManageChild(mainw);
2037 setStatus (eSuccess);
2040 // /////////////////////////////////////////////////////////////////
2041 // lock_toggle - callback for lock button
2042 // /////////////////////////////////////////////////////////////////
2045 NodeWindowAgent::lock_toggleCB(Widget lock,
2046 XtPointer client_data, XtPointer call_data)
2048 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
2049 XmToggleButtonCallbackStruct *cdata =
2050 (XmToggleButtonCallbackStruct*) call_data;
2054 agent->f_locked = cdata->set;
2057 if (agent->f_locked)
2059 XtSetArg(args[n], XmNselectPixmap,
2060 window_system().locked_pixmap(XtParent(lock))); n++;
2061 XtSetArg(args[n], XmNlabelPixmap,
2062 window_system().semilocked_pixmap(XtParent(lock))); n++;
2066 XtSetArg(args[n], XmNlabelPixmap,
2067 window_system().unlocked_pixmap(XtParent(lock))); n++;
2068 XtSetArg(args[n], XmNselectPixmap,
2069 window_system().semilocked_pixmap(XtParent(lock))); n++;
2071 XtSetValues(lock, args, n);
2073 // NOTE: This needs to be real time, not bogus X event time. [DJB]
2074 agent->f_last_access_time = (unsigned int) cdata->event->xany.serial;
2077 // /////////////////////////////////////////////////////////////////
2078 // dismiss - callback for close button
2079 // /////////////////////////////////////////////////////////////////
2082 NodeWindowAgent::dismissCB(Widget, XtPointer client_data, XtPointer)
2084 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
2089 NodeWindowAgent::dismiss()
2091 if (g_ignore_wm_delete)
2093 if (!XtIsSensitive(f_close)) {
2094 exitCB(0, (XtPointer) this, 0);
2101 // /////////////////////////////////////////////////////////////////
2102 // search_on_selection - perform query on X selection
2103 // /////////////////////////////////////////////////////////////////
2106 NodeWindowAgent::do_search_selection (const char* value, unsigned long)
2108 #ifdef SEARCH_SELECTION_DEBUG
2109 fprintf(stderr, "search selection = %s\n", value);
2112 if (value == NULL || *value == '\0')
2115 unsigned char* p = (unsigned char*)value;
2117 if (*p < ' ') *p = ' ';
2121 Xassert (value != NULL);
2123 char* buffer = (char *)value;
2124 TML_CHAR_TYPE *p, *ws = new TML_CHAR_TYPE[strlen(buffer) + 1];
2125 int assert_var = mbstowcs(ws, buffer, strlen(buffer) + 1);
2126 assert( assert_var >= 0 );
2127 for (p = ws; *p; p++) { // looking for control chars
2128 if (*p < (TML_CHAR_TYPE)' ')
2131 int length = strlen(buffer) + 1;
2132 assert_var = wcstombs(buffer, ws, length);
2133 assert( assert_var >= 0 );
2136 char *p = (char *) value;
2139 if (*p < ' ' /* || *p > '~' DTS 13944 */ )
2143 // make selection string a literal
2145 // 1) Scan string for quotes.
2146 // make room for start and end quotes
2148 int buflen = strlen((char *)value) + 3 ;
2149 char *buffer = new char[buflen] ;
2151 const char *src = (char *)value ;
2152 char *dest = buffer ;
2154 // make first character a quote
2162 if (dest >= (buffer + buflen - 2))
2165 char *newbuf = new char[buflen] ;
2166 int len = buflen - 1;
2167 *((char *) memcpy(newbuf, buffer, len) + len) = '\0';
2168 int depth = dest - buffer ;
2171 dest = buffer + depth ;
2174 *dest++ = '\\' ; // escape the quote
2178 if (*(src - 1) == '"')
2180 // if it ends with a quote, we escaped it, so remove the escape.
2182 *(dest - 1) = 0 ; // terminate string
2186 // otherwise add our own quote
2193 char *search_string = (char*)value;
2195 ON_DEBUG(printf("!! search on selection\n-->%s<--\n", (char*)value));
2197 f_search_text->Value(search_string);
2198 XmUpdateDisplay (window_system().toplevel());
2200 UAS_SearchScope *scope = f_scope_menu->current_scope();
2203 if (scope->search_zones().section())
2205 node_mgr().set_preferred_window(this);
2206 search_mgr().search_section(f_node_view_info->node_ptr()->id());
2207 #ifdef CURRENT_SECTION_DEBUG
2208 fprintf(stderr, "(DEBUG) search_section (before search)=%s\n",
2209 (char*)search_mgr().search_section());
2215 search_mgr().parse_and_search(search_string, scope);
2216 search_mgr().search_section(UAS_String(""));
2222 NodeWindowAgent::search_on_selectionCB(Widget, XtPointer client_data,
2223 XtPointer call_data)
2225 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
2226 XmPushButtonCallbackStruct* cdata =
2227 (XmPushButtonCallbackStruct *) call_data;
2229 get_selection_value(*agent->f_shell, XA_PRIMARY, agent,
2230 cdata->event->xbutton.time);
2233 // /////////////////////////////////////////////////////////////////
2234 // search text callbacks
2235 // /////////////////////////////////////////////////////////////////
2238 NodeWindowAgent::text_callback(WCallback *wcb)
2240 (void) (XmAnyCallbackStruct*)wcb->CallData();
2241 char *text = XmTextGetString(wcb->GetWidget());
2245 // Allow if debug resource is set, not ifdef DEBUG - 17:25 01/11/93 DJB
2246 UAS_SearchScope* scope = f_scope_menu->current_scope();
2247 if (scope != NULL && *text) // if context makes sense
2249 if (scope->search_zones().section())
2251 node_mgr().set_preferred_window(this);
2252 search_mgr().search_section(f_node_view_info->node_ptr()->id());
2253 #ifdef CURRENT_SECTION_DEBUG
2254 fprintf(stderr, "(DEBUG) search_section (before search)=%s\n",
2255 (char*)search_mgr().search_section());
2261 search_mgr().parse_and_search (text, scope);
2262 search_mgr().search_section (UAS_String(""));
2270 NodeWindowAgent::search_help (Widget, XtPointer client_data,
2271 XEvent *event, Boolean *)
2274 // Make sure the event is what we expect.
2275 if (event->type != EnterNotify && event->type != FocusIn &&
2276 event->type != LeaveNotify && event->type != FocusOut)
2279 NodeWindowAgent* agent = (NodeWindowAgent*)client_data;
2284 if (event->type == LeaveNotify || event->type == FocusOut)
2286 XmTextFieldSetString(agent->f_status_text, (char*)"");
2291 static String help_text = NULL;
2292 static String default_scope = NULL;
2294 if (help_text == NULL) {
2295 UAS_Pointer<UAS_String> str;
2297 str = new UAS_String(CATGETS(Set_AgentQHelp, 64, "Search %s"));
2298 help_text = (char*)*str;
2299 agent->f_textstore.insert_item(str);
2301 str = new UAS_String(CATGETS(Set_NodeWindowAgent, 3, "Information Library"));
2302 default_scope = (char*)*str;
2303 agent->f_textstore.insert_item(str);
2306 // Format the search help string.
2307 UAS_SearchScope *scope = agent->f_scope_menu->current_scope();
2310 snprintf (buffer, sizeof(buffer), help_text, (char *) scope->name());
2312 snprintf (buffer, sizeof(buffer), help_text, default_scope);
2314 // Finally, display it in the quick help field.
2315 XmTextFieldSetString(agent->f_status_text, buffer);
2319 // /////////////////////////////////////////////////////////////////
2321 // /////////////////////////////////////////////////////////////////
2324 section_historyCB(Widget, XtPointer, XtPointer)
2327 ON_DEBUG (puts ("history_display() called"));
2328 global_history_mgr().display();
2331 // /////////////////////////////////////////////////////////////////
2333 // /////////////////////////////////////////////////////////////////
2336 NodeWindowAgent::history_prevCB(Widget, XtPointer client_data, XtPointer)
2338 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
2339 UAS_Pointer<UAS_Common> doc_ptr = agent->f_history_list.previous();
2340 Xassert (doc_ptr != (UAS_Pointer<UAS_Common>)NULL);
2343 g_history_anchor = agent->f_history_list.previous_anchor();
2345 // Set the history_display flag which is checked in the display routine.
2346 if (!agent->f_locked)
2348 agent->f_history_display = TRUE;
2349 agent->record_history_position();
2350 agent->f_history_list.go_back();
2353 node_mgr().set_preferred_window (agent);
2354 doc_ptr->retrieve();
2357 // /////////////////////////////////////////////////////////////////
2359 // /////////////////////////////////////////////////////////////////
2362 NodeWindowAgent::history_nextCB(Widget, XtPointer client_data, XtPointer)
2364 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
2365 UAS_Pointer<UAS_Common> doc_ptr = agent->f_history_list.next();
2366 Xassert (doc_ptr != (UAS_Pointer<UAS_Common>)NULL);
2369 g_history_anchor = agent->f_history_list.next_anchor();
2372 // Set the history_display flag which is checked in the display routine.
2373 if (!agent->f_locked)
2375 agent->f_history_display = TRUE;
2376 agent->record_history_position();
2377 agent->f_history_list.go_forward();
2380 node_mgr().set_preferred_window (agent);
2381 doc_ptr->retrieve();
2385 // /////////////////////////////////////////////////////////////////
2386 // history preview callbacks
2387 // /////////////////////////////////////////////////////////////////
2390 NodeWindowAgent::preview_history_nextCB(Widget, XtPointer client_data,
2393 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
2394 agent->f_preview_document = agent->f_history_list.next();
2395 agent->f_preview_timeout =
2396 new WTimeOut (window_system().app_context(), 550,
2397 agent, (WTimeOutFunc) &NodeWindowAgent::preview);
2401 NodeWindowAgent::preview_history_prevCB(Widget, XtPointer client_data,
2404 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
2405 agent->f_preview_document = agent->f_history_list.previous();
2406 agent->f_preview_timeout =
2407 new WTimeOut (window_system().app_context(), 550,
2408 agent, (WTimeOutFunc) &NodeWindowAgent::preview);
2412 // /////////////////////////////////////////////////////////////////
2413 // initialize_history - add the current node to hist and set arrows
2414 // /////////////////////////////////////////////////////////////////
2417 NodeWindowAgent::initialize_history()
2419 // Add the new node to the history if it didn't come from the history
2420 // list itself. Currently this has the effect of truncating the list
2421 // at the user's current position in the list.
2422 if (!f_history_display)
2424 UAS_Pointer<UAS_Common> bogus;
2425 f_history_list.append (bogus = f_node_ptr);
2428 f_history_display = FALSE; // reset
2430 if (f_history_list.previous() != (UAS_Pointer<UAS_Common>)NULL) {
2431 XtSetSensitive(f_history_prev, True);
2432 XtSetSensitive(f_history_prev2, True);
2434 XtSetSensitive(f_history_prev, False);
2435 XtSetSensitive(f_history_prev2, False);
2438 if (f_history_list.next() != (UAS_Pointer<UAS_Common>)NULL) {
2439 XtSetSensitive(f_history_next, True);
2440 XtSetSensitive(f_history_next2, True);
2442 XtSetSensitive(f_history_next, False);
2443 XtSetSensitive(f_history_next2, False);
2447 // /////////////////////////////////////////////////////////////////
2448 // display_version - display the version dialog
2449 // /////////////////////////////////////////////////////////////////
2452 NodeWindowAgent::display_version()
2454 UAS_String version = CATGETS(Set_Version, 1, "");
2455 if (*(char*)version) {
2456 message_mgr().info_dialog ((char*)version);
2460 // /////////////////////////////////////////////////////////////////
2461 // display_search_history
2462 // /////////////////////////////////////////////////////////////////
2465 search_historyCB(Widget, XtPointer, XtPointer)
2467 search_mgr().search_history_list_view().display();
2471 open_urlCB(Widget, XtPointer client_data, XtPointer)
2473 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
2474 url_mgr().display(agent);
2477 // NOTE: There's got to be an easier way to attach callbacks!?
2478 // Maybe something in the resource file associated with the button?
2479 // There needs to be a central way to address things like a
2480 // search history list view just by knowing where it it. Maybe
2481 // we should be able to call it's notify proc with some kind
2482 // of message? Like some kind of real O-O or something!?
2486 // /////////////////////////////////////////////////////////////////
2487 // update_fonts - user has scaled fonts
2488 // /////////////////////////////////////////////////////////////////
2491 NodeWindowAgent::update_fonts (unsigned int serial_number)
2493 f_serial_number = serial_number ;
2494 // NOTE: do not call this from within ourselves,
2495 // it is to be called by the NodeMgr - jbm
2500 // /////////////////////////////////////////////////////////////////
2501 // initialize_controls - init ui controls based on current node
2502 // /////////////////////////////////////////////////////////////////
2505 NodeWindowAgent::initialize_controls()
2507 initialize_hierarchy();
2511 initialize_history();
2514 // SWM: Need to disable searching if the node we're displaying is
2515 // not searchable...
2517 XtSetSensitive(f_search_menu_button,
2518 f_node_view_info->node_ptr()->searchable());
2520 bool search_previous_sensitive = FALSE, search_next_sensitive = FALSE;
2522 if (f_node_view_info->node_ptr()->searchable() &&
2523 f_node_view_info->hit_entries() > 0) {
2524 if (f_node_view_info->search_hit_idx() > 0)
2525 search_previous_sensitive = TRUE;
2526 if (f_node_view_info->search_hit_idx() <
2527 f_node_view_info->hit_entries() - 1)
2528 search_next_sensitive = TRUE;
2531 XtSetSensitive(f_search_prev, search_previous_sensitive);
2532 XtSetSensitive(f_search_prev2, search_previous_sensitive);
2533 XtSetSensitive(f_search_next, search_next_sensitive);
2534 XtSetSensitive(f_search_next2, search_next_sensitive);
2536 XtSetSensitive(f_print2, True);
2537 XtSetSensitive(f_print_as, True);
2539 XtSetSensitive(f_detach_graphic, True);
2542 // See if next and previous exist and sensitize buttons accordingly.
2543 if (f_node_handle->node().next_node() != NULL)
2545 XtSetSensitive(f_node_next, True);
2546 XtSetSensitive(f_node_next2, True);
2550 XtSetSensitive(f_node_next, False);
2551 XtSetSensitive(f_node_next2, False);
2554 if (f_node_handle->node().previous_node() != NULL)
2556 XtSetSensitive(f_node_previous, True);
2557 XtSetSensitive(f_node_previous2, True);
2561 XtSetSensitive(f_node_previous, False);
2562 XtSetSensitive(f_node_previous2, False);
2567 /* -------- See if the current node is in the current hierarchy. -------- */
2568 for (i = 9; i >= 0; i--)
2570 if (!XtIsManaged (*f_title_button_list[i]))
2573 if (((NodeHandle *) f_title_button_list[i]->UserData())
2574 ->equals (*f_node_handle))
2576 f_title_option->MenuHistory (*f_title_button_list[i]);
2582 /* -------- Set up the title option menu for hierarchial path. -------- */
2584 ON_DEBUG(printf ("*** Unmanaging push buttons in option menu ***\n"));
2585 // f_title_menu->Unmanage();
2586 for (i = 0; i < 10; i++)
2587 f_title_button_list[i]->Unmanage();
2589 NodeHandle *current_node = new NodeHandle (*f_node_handle);
2592 while (current_node != NULL)
2594 // NOTE: WWL WXmString needs fixing to take a const char *, djb
2595 const char *current_name = current_node->node().node_name();
2597 f_title_button_list[i]->
2598 LabelString (WXmString ((char *)current_name));
2599 ON_DEBUG(printf ("*** Remanaging button %d -- %s***\n", i,
2601 f_title_button_list[i]->Manage();
2602 // Free old node associated with the button
2603 delete (NodeHandle *) f_title_button_list[i]->UserData();
2604 f_title_button_list[i]->UserData (current_node);
2607 // NOTE: This will need to be fixed, 7/8/92 djb
2608 fputs ("Unreasonable include file nesting!", stderr);
2609 fputs (" Section hierarchy too deep!!", stderr);
2613 current_node = current_node->node().parent_node();
2614 if (current_node != NULL)
2615 current_node = new NodeHandle (*current_node);
2618 // OPTION MENU BUGGY STUFF BELOW:
2619 // f_title_menu->Manage();
2620 // Work around Motif 1.1 (1.2 ~too?) bug
2621 WXmCascadeButtonGadget opb (XmOptionButtonGadget (*f_title_option));
2623 // Make the last item the visible one. See Motif docs.
2624 f_title_option->MenuHistory (*f_title_button_list[9]);
2626 // printf ("*** Done with option menu changes ***\n");
2628 display_tabs (*((ObjectId *) f_title_button_list[i+1]->UserData()));
2633 // /////////////////////////////////////////////////////////////////////////
2635 // /////////////////////////////////////////////////////////////////////////
2638 * ------------------------------------------------------------------------
2639 * Name: LibraryAgent::printCB
2643 * Called when the user hits "Print" quick button. Prints without
2644 * displaying the Print setup dialog.
2648 NodeWindowAgent::printCB(Widget w, XtPointer client_data, XtPointer)
2650 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
2652 // Get a handle to the AppPrintData allocated in the WindowSystem class
2654 AppPrintData* p = window_system().GetAppPrintData();
2656 // Need to put this single node on the print list so that
2657 // reset_ui() can determine the number of nodes being printed
2659 xList<UAS_Pointer<UAS_Common> > * print_list = new xList<UAS_Pointer<UAS_Common> >;
2660 UAS_Pointer<UAS_Common> bogus;
2661 bogus = agent->f_node_view_info->node_ptr();
2662 print_list->append(bogus);
2664 p->f_outline_element = NULL;
2665 p->f_print_list = print_list;
2667 CreatePrintSetup(w, p);
2669 // check if the DtPrintSetupBox ("Print...") has been called yet
2671 if(p->f_print_data->print_display == (Display*)NULL)
2674 // first time thru print setup, so get default data
2676 if (DtPrintFillSetupData(p->f_print_dialog, p->f_print_data)
2677 != DtPRINT_SUCCESS) {
2679 // NOTE: DtPrintFillSetupData() already posts an error
2680 // dialog on failure - no need to post our own.
2691 * ------------------------------------------------------------------------
2692 * Name: LibraryAgent::print_asCB
2696 * This is called for "Print..." and will always bring up the
2697 * print setup dialog.
2700 NodeWindowAgent::print_asCB(Widget w, XtPointer client_data, XtPointer)
2702 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
2704 AppPrintData* p = window_system().GetAppPrintData();
2706 // Need to put this single node on the print list so that
2707 // reset_ui() can determine the number of nodes being printed
2709 xList<UAS_Pointer<UAS_Common> > * print_list = new xList<UAS_Pointer<UAS_Common> >;
2710 UAS_Pointer<UAS_Common> bogus;
2711 bogus = agent->f_node_view_info->node_ptr();
2712 print_list->append(bogus);
2714 p->f_print_list = print_list;
2715 p->f_outline_element = NULL;
2717 CreatePrintSetup(w, p);
2719 XtManageChild(p->f_print_dialog); /* popup dialog each time */
2722 // /////////////////////////////////////////////////////////////////
2724 // /////////////////////////////////////////////////////////////////
2727 NodeWindowAgent::map_activate()
2730 UAS_Pointer<UAS_Common> bogus;
2731 map_mgr().display_centered_on (bogus = f_node_ptr);
2735 // /////////////////////////////////////////////////////////////////
2737 // /////////////////////////////////////////////////////////////////
2740 NodeWindowAgent::search_previousCB(Widget, XtPointer client_data, XtPointer)
2742 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
2743 agent->search_previous();
2747 NodeWindowAgent::search_previous()
2749 NodeViewInfo::trav_status_t status;
2750 status = f_node_view_info->
2751 adjust_current_search_hit(NodeViewInfo::PREV);
2753 if (status != NodeViewInfo::NOT_MOVED)
2756 if (! XtIsSensitive(f_search_next))
2758 XtSetSensitive(f_search_next, True);
2759 XtSetSensitive(f_search_next2, True);
2761 if (status == NodeViewInfo::REACH_LIMIT)
2763 XtSetSensitive(f_search_prev, False);
2764 XtSetSensitive(f_search_prev2, False);
2767 _DtCvUnit width, height;
2768 _DtCanvasResize((_DtCvHandle)f_help_dsp_area->canvas,
2769 _DtCvTRUE, &width, &height);
2771 _DtCanvasRender((_DtCvHandle)f_help_dsp_area->canvas, 0, 0,
2772 width, height, _DtCvRENDER_PARTIAL, _DtCvFALSE, NULL, NULL);
2774 _DtHelpSearchMoveTraversal((XtPointer)f_help_dsp_area,
2775 f_node_view_info->search_hit_idx());
2779 // /////////////////////////////////////////////////////////////////
2781 // /////////////////////////////////////////////////////////////////
2784 NodeWindowAgent::search_nextCB(Widget, XtPointer client_data, XtPointer)
2786 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
2787 agent->search_next();
2791 NodeWindowAgent::search_next()
2793 NodeViewInfo::trav_status_t status;
2794 status = f_node_view_info->
2795 adjust_current_search_hit(NodeViewInfo::NEXT);
2797 if (status != NodeViewInfo::NOT_MOVED)
2800 if (! XtIsSensitive(f_search_prev))
2802 XtSetSensitive(f_search_prev, True);
2803 XtSetSensitive(f_search_prev2, True);
2805 if (status == NodeViewInfo::REACH_LIMIT)
2807 XtSetSensitive(f_search_next, False);
2808 XtSetSensitive(f_search_next2, False);
2811 _DtCvUnit width, height;
2812 _DtCanvasResize((_DtCvHandle)f_help_dsp_area->canvas,
2813 _DtCvTRUE, &width, &height);
2815 _DtCanvasRender((_DtCvHandle)f_help_dsp_area->canvas, 0, 0,
2816 width, height, _DtCvRENDER_PARTIAL, _DtCvFALSE, NULL, NULL);
2818 _DtHelpSearchMoveTraversal((XtPointer)f_help_dsp_area,
2819 f_node_view_info->search_hit_idx());
2824 // /////////////////////////////////////////////////////////////////
2825 // display_search_scope
2826 // /////////////////////////////////////////////////////////////////
2829 scope_editorCB(Widget, XtPointer, XtPointer)
2831 search_scope_mgr().display();
2836 // /////////////////////////////////////////////////////////////////
2837 // routines for items on the debug menu
2838 // /////////////////////////////////////////////////////////////////
2841 NodeWindowAgent::document_id_display()
2848 // /////////////////////////////////////////////////////////////////
2849 // initialize_tabs - set up the tabs for this book
2850 // /////////////////////////////////////////////////////////////////
2853 NodeWindowAgent::initialize_tabs()
2855 List_Iterator<UAS_Pointer<UAS_Common> > tabs (g_tab_list);
2856 List_Iterator<BookTab *> btns (f_tab_btn_list);
2857 BookTab *current = NULL;
2858 bool changed = FALSE;
2859 static int old_count = -1;
2864 // Update exisiting tab buttons, adding new ones when necessary.
2867 // Only update the tab button if it has changed since last time.
2868 if (btns.item()->tab() == (UAS_Pointer<UAS_Common>)NULL ||
2869 btns.item()->tab() != tabs.item())
2871 ON_DEBUG (printf (" Updating\n"));
2872 current = btns.item();
2873 current->set_tab (tabs.item());
2881 ON_DEBUG (printf ("Creating a tab\n"));
2882 // Add a new button. The tabs have definitely changed.
2883 current = new BookTab (this, *f_tab_area, tabs.item());
2884 f_tab_btn_list.append (current);
2888 g_tab_list.remove (tabs); // remove item and increment iterator
2891 // Unset any remaining buttons.
2892 UAS_Pointer<UAS_Common> null_tab;
2893 for (; btns; btns++)
2895 if (btns.item()->tab() != (UAS_Pointer<UAS_Common>)NULL)
2897 ON_DEBUG (printf ("Emptying a tab\n"));
2898 btns.item()->set_tab (null_tab);
2906 ON_DEBUG (printf ("Tabs have changed (%d)\n", count));
2908 // Make the tab area appear or disappear as needed.
2909 if (count == 0 && (old_count > 0 || old_count == -1))
2910 f_frame->TopOffset (-12);
2911 else if (count > 0 && old_count <= 0)
2912 f_frame->TopOffset (-4);
2914 // Work around bogus Motif bug that prevents things from resizing
2915 // correctly if the tabs change but there's still the same number.
2916 if (old_count == count)
2918 current->Unmanage();
2928 // /////////////////////////////////////////////////////////////////
2929 // select_tab - if current node has a tab, select that tab
2930 // /////////////////////////////////////////////////////////////////
2933 NodeWindowAgent::select_tab()
2935 List_Iterator<BookTab *> btns (f_tab_btn_list);
2936 UAS_Pointer<UAS_Common> d;
2938 while (btns && XtIsManaged (*btns.item()))
2940 btns.item()->select_if_same (d = f_node_view_info->node_ptr());
2945 // /////////////////////////////////////////////////////////////////
2947 // /////////////////////////////////////////////////////////////////
2950 NodeWindowAgent::preview_init (UAS_Pointer<UAS_Common> &doc_ptr)
2952 // NOTE: Link preview timeout shouldn't be hardcoded! DJB 10/7/92
2953 f_preview_document = doc_ptr;
2955 new WTimeOut (window_system().app_context(), 550,
2956 this, (WTimeOutFunc) &NodeWindowAgent::preview);
2960 // /////////////////////////////////////////////////////////////////
2961 // preview - display the link preview
2962 // /////////////////////////////////////////////////////////////////
2965 NodeWindowAgent::preview (WTimeOut *)
2968 char preview_buffer[256];
2970 UAS_String pt = f_preview_document->title();
2971 *((char *) memcpy(title, (char *) pt, 127) + 127) = '\0';
2972 UAS_String bn = f_preview_document->book_name(UAS_SHORT_TITLE);
2973 const char *book_name = (char *) bn;
2974 if (book_name != NULL && *book_name != '\0')
2975 snprintf (preview_buffer, sizeof(preview_buffer),
2976 CATGETS(Set_Messages, 8, "Link to %s: %s"), book_name, title);
2978 snprintf (preview_buffer, sizeof(preview_buffer),
2979 CATGETS(Set_Messages, 9, "Link to %s"), title);
2980 XmTextFieldSetString(f_status_text, preview_buffer);
2981 f_preview_timeout = NULL;
2982 f_preview_document = NULL;
2986 // /////////////////////////////////////////////////////////////////
2988 // /////////////////////////////////////////////////////////////////
2991 NodeWindowAgent::unpreviewCB(Widget, XtPointer client_data, XtPointer)
2993 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
2998 NodeWindowAgent::unpreview()
3000 // Cancel document preview...
3001 if (f_preview_timeout != NULL)
3003 // If the timeout hasn't triggered delete it and clear the document.
3004 delete f_preview_timeout;
3005 // XXX SWM -- zero out the timeout
3006 f_preview_timeout = NULL;
3010 // If the timeout has already happened, just clear the preview area.
3011 XmTextFieldSetString(f_status_text, (char*)"");
3017 // /////////////////////////////////////////////////////////////////
3018 // create_annotation/bookmark - create a new user mark
3019 // /////////////////////////////////////////////////////////////////
3022 NodeWindowAgent::create_annotationCB(Widget, XtPointer client_data, XtPointer)
3024 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
3025 agent->make_bookmark(True);
3029 NodeWindowAgent::create_bookmarkCB(Widget, XtPointer client_data, XtPointer)
3031 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
3032 agent->make_bookmark(False);
3036 NodeWindowAgent::make_bookmark (Boolean edit, MarkCanvas* refmark)
3040 UAS_Pointer<UAS_Common> d;
3042 UAS_String bm_name, bm_anno;
3044 int status = -1; // default return status (fail)
3046 if (refmark == NULL)
3049 _DtCanvasGetSelection(f_help_dsp_area->canvas,
3050 _DtCvSELECTED_TEXT, ((_DtCvPointer *)(void*)&name));
3052 #ifdef BOOKMARK_DEBUG
3053 cerr << "Bookmark Name: [" << name << "]" << endl;
3056 //Xassert (name != NULL);
3059 message_mgr().error_dialog ((char*)UAS_String(CATGETS(Set_Messages, 10,
3060 "Dtinfo is unable to create this bookmark.")),
3065 // replace control char with a space
3066 for (unsigned char* p = (unsigned char*)name; *p; p++)
3067 *p = (*p < ' ') ? ' ' : *p;
3069 int len, next_mblen;
3070 for (len = 0, next_mblen = 0; len < 40 && name[len]; len += next_mblen)
3072 if ((next_mblen = mblen(name + len, MB_CUR_MAX)) < 0)
3074 else if (len + next_mblen > 40)
3084 bm_name = refmark->mark_ptr()->name();
3085 bm_anno = refmark->mark_ptr()->notes();
3088 #ifdef BOOKMARK_DEBUG
3089 cerr << "Creating mark <" << (char*)bm_name << ">" << endl;
3092 _DtCvSegPts **segs = NULL ;
3096 // find the selection segment and offset
3097 _DtCanvasGetSelectionPoints(f_help_dsp_area->canvas,
3099 &ret_x, &ret_y); // ret_x, ret_y
3101 // NOTE: have to allow for segments that are added in by the
3102 // style sheet -> check appflag1
3103 // also have to account for it at the other end as well
3105 if (segs == NULL || *segs == NULL)
3106 throw(CASTEXCEPT Exception());
3108 // sort segments in order of vcc offset
3109 _DtCvSegPts** segpts_iter;
3110 for (segpts_iter = segs; *segpts_iter; segpts_iter++) {
3111 _DtCvSegPts* *p = segpts_iter + 1;
3114 if ((NodeViewInfo::segment_to_vcc((*segpts_iter)->segment) >
3115 NodeViewInfo::segment_to_vcc((*p)->segment)))
3117 _DtCvSegPts* anon = *segpts_iter;
3124 #ifdef BOOKMARK_DEBUG
3125 for (segpts_iter = segs; *segpts_iter; segpts_iter++) {
3126 _DtCvSegPts& segpts = **segpts_iter;
3127 fprintf(stderr, "(DEBUG) offset=%d,len=%d\n",
3128 segpts.offset, segpts.len);
3132 MarkInfo markinfo(bm_name, bm_anno);
3134 _DtCvSegPts* prev_segpts = NULL;
3135 unsigned int vcc = 0;
3136 unsigned int length = 0;
3137 unsigned int offset = 0;
3140 for (i = 0; segs[i]; i++)
3142 _DtCvSegPts* segpts = segs[i];
3144 if (prev_segpts && prev_segpts->segment != segpts->segment) {
3146 // new segment, save the previous one
3147 markinfo.insert_item(UAS_Pointer<MarkUnitInfo>(
3148 new MarkUnitInfo(vcc, offset, length, prev_segpts->segment)));
3150 if (NodeViewInfo::segment_to_vcc(segpts->segment)==(unsigned int)-1)
3152 // ignore it, initialize
3153 vcc = length = offset = 0;
3158 offset = segpts->offset;
3159 vcc = NodeViewInfo::segment_to_vcc(segpts->segment);
3163 else if (prev_segpts) {
3164 if (segpts->offset > prev_segpts->offset + prev_segpts->len)
3165 length += segpts->offset - (prev_segpts->offset +
3169 offset = segpts->offset;
3170 vcc = NodeViewInfo::segment_to_vcc(segpts->segment);
3173 length += segpts->len;
3175 prev_segpts = segpts;
3179 markinfo.insert_item(UAS_Pointer<MarkUnitInfo>(
3180 new MarkUnitInfo(vcc, offset, length, prev_segpts->segment)));
3182 // remove bad (vcc < 0) MarkUnitInfo from markinfo
3183 MarkInfo bad_markinfo;
3184 for (i = 0; i < markinfo.length(); i++) {
3185 UAS_Pointer<MarkUnitInfo>& mui = markinfo[i];
3186 if (mui->vcc() == (unsigned int)-1)
3187 bad_markinfo.insert_item(mui);
3190 for (i = 0; i < bad_markinfo.length(); i++)
3191 markinfo.remove_item(bad_markinfo[i]);
3193 #ifdef BOOKMARK_DEBUG
3194 for (i = 0; i < markinfo.length(); i++)
3196 MarkUnitInfo& mui = *markinfo[i];
3197 fprintf(stderr, "(DEBUG) item%d: vcc=%d,offset=%d,length=%d\n",
3198 i, mui.vcc(), mui.offset(), mui.length());
3202 #ifdef BOOKMARK_DEBUG
3203 cerr << "selection at: ( " << ret_x << ", " << ret_y << ")" << endl;
3206 // find the offset of the first segment from the top of the node
3207 // NOTE - should really do it from the nearest locator
3209 if (markinfo.length() > 0)
3211 // persistent mark info should be a list of
3212 // vcc of the segment, internal offset, internal length
3214 UAS_Pointer<Mark> mark =
3215 mark_mgr().create_mark (d = f_node_ptr,
3216 AnchorCanvas(f_node_ptr->locator(),
3218 (char*)markinfo.name(),
3219 (char*)markinfo.anno());
3221 if (edit && (mark != (UAS_Pointer<Mark>)NULL))
3226 XtSetSensitive(f_create_bmrk, False);
3227 XtSetSensitive(f_create_anno, False);
3229 status = 0; // success
3231 else if (bad_markinfo.length() > 0)
3232 message_mgr().error_dialog (
3233 (char*)UAS_String(CATGETS(Set_NodeWindowAgent, 7,
3234 "The selected text is dynamically inserted and cannot\n"
3235 "be used alone to create a bookmark reference. Either\n"
3236 "select other text near the point, or include more of\n"
3237 "the surrounding text.")),
3240 throw(CASTEXCEPT Exception());
3245 message_mgr().error_dialog ((char*)UAS_String(CATGETS(Set_Messages, 10,
3246 "Dtinfo is unable to create this bookmark.")),
3252 for (int i = 0; segs[i]; i++)
3261 // /////////////////////////////////////////////////////////////////
3262 // selection_changed - do stuff based on the current selection
3263 // /////////////////////////////////////////////////////////////////
3266 NodeWindowAgent::selection_changed()
3268 #ifdef SELECTION_DEBUG
3269 cerr << "NodeWindowAgent::selection_changed()" << endl;
3271 SelectionChanged msg ;
3272 UAS_Sender<SelectionChanged>::send_message (msg);
3276 NodeWindowAgent::selection_contains_graphic()
3278 _DtCvStatus status ;
3279 _DtCvSegPts **segs ;
3282 _DtCanvasGetSelectionPoints(f_help_dsp_area->canvas, // canvas
3283 &segs, // returned segments
3284 NULL, NULL); // ret_x, ret_y
3286 if ((_DtCvSTATUS_OK == status) && (NULL != segs))
3288 for (int i = 0 ; segs[i] ; i++)
3289 if (_DtCvIsSegRegion(segs[i]->segment))
3299 NodeWindowAgent::receive (SelectionChanged &, void* /*client_data*/)
3301 #ifdef SELECTION_DEBUG
3302 cerr << "NodeWindowAgent::receive(<SelectionChanged>) --> " ;
3303 if (f_help_dsp_area->primary)
3304 cerr << "true" << endl;
3306 cerr << "false" << endl;
3307 if (f_help_dsp_area->text_selected)
3308 cerr << "text_selected: true" << endl;
3310 cerr << "text_selected: false" << endl;
3314 Boolean sensitivity = f_help_dsp_area->text_selected;
3316 // primary is the wrong flag to use here--it is always
3317 // true (except before the first time text has been selected),
3318 // so the create mark menu is always active.
3319 Boolean sensitivity = f_help_dsp_area->primary ;
3322 XtSetSensitive(f_create_bmrk, sensitivity);
3323 XtSetSensitive(f_create_anno, sensitivity);
3325 if (MarkCanvas::selected_mark() &&
3326 MarkCanvas::selected_mark()->agent() == this)
3328 #ifdef MOVE_MARK_DEBUG
3329 fprintf(stderr, "(DEBUG) agent=0x%x move_mark sensitivity=%d\n",
3330 (void*)this, sensitivity);
3332 XtSetSensitive(f_move_mark, sensitivity);
3336 // Update the move function if a Mark is selected somewhere.
3337 if (MarkCanvas::selected_mark() != NULL)
3338 f_move_mark->SetSensitive (sensitivity);
3344 XtSetSensitive(f_detach_graphic, selection_contains_graphic());
3346 XtSetSensitive(f_detach_graphic, False);
3351 // /////////////////////////////////////////////////////////////////
3352 // mark_selection_changed
3353 // /////////////////////////////////////////////////////////////////
3356 NodeWindowAgent::receive (MarkSelectionChanged &message, void* /*client_data*/)
3358 Boolean sensitivity;
3359 if (message.f_selection_type == MarkSelectionChanged::SELECT)
3362 sensitivity = False;
3364 // Update edit and delete controls based on mark selection.
3365 // We only consider marks that are selected in our viewport.
3366 if (MarkCanvas::selected_mark()->agent() == this)
3368 XtSetSensitive(f_edit_mark, sensitivity);
3369 XtSetSensitive(f_delete_mark, sensitivity);
3370 XtSetSensitive(f_move_mark,
3371 sensitivity && f_help_dsp_area->text_selected);
3374 select_mark_in_canvas(MarkCanvas::selected_mark(), message.f_move_to);
3376 deselect_mark_in_canvas(MarkCanvas::selected_mark());
3380 // Update the move function only if our viewport has the selection.d
3381 if (f_viewport_agent->selection_range() != NULL)
3382 f_move_mark->SetSensitive (sensitivity);
3387 NodeWindowAgent::deselect_mark_in_canvas(MarkCanvas *mark)
3392 _DtCvPointInfo point_info;
3394 point_info.client_data = mark; // this is how we
3397 _DtCanvasActivatePts (f_help_dsp_area->canvas, // canvas
3398 _DtCvACTIVATE_MARK_OFF, // mask
3399 &point_info, // mark identification
3406 NodeWindowAgent::select_mark_in_canvas(MarkCanvas *mark_to_show, bool show_it)
3408 #ifdef BOOKMARK_SELECT_DEBUG
3409 cerr << "select_mark_in_canvas" << endl;
3411 _DtCvUnit ret_x, ret_y, ret_baseline, ret_height ;
3413 _DtCvStatus status =
3414 _DtCanvasMoveTraversal(f_help_dsp_area->canvas, // canvas
3415 _DtCvTRAVERSAL_MARK, // traverse to id
3416 _DtCvFALSE, // no wrapping of traversal
3417 _DtCvTRUE, // render - what should this be?
3418 mark_to_show, // mark id
3424 _DtCvPointInfo point_info ;
3426 List_Iterator <MarkCanvas *> m (f_mark_list);
3430 point_info.client_data = m.item(); // this is how we
3433 _DtCanvasActivatePts (f_help_dsp_area->canvas, // canvas
3434 _DtCvACTIVATE_MARK_OFF, // mask
3435 &point_info, // mark identification
3441 point_info.client_data = mark_to_show;
3443 _DtCanvasActivatePts (f_help_dsp_area->canvas,
3444 _DtCvACTIVATE_MARK_ON, // mask
3445 &point_info, // info
3449 // if requested, attempt to bring it into focus
3451 // this may make more sense to move it into the canvas code, but I'm
3452 // first trying to do it from the application level
3454 if ((_DtCvSTATUS_OK == status) && show_it)
3456 if ((ret_y > (f_help_dsp_area->firstVisible + 10)) &&
3457 (ret_y <= (f_help_dsp_area->firstVisible + f_help_dsp_area->dispUseHeight)))
3459 /* already on screen */
3464 _DtCvUnit the_position = ret_y ;
3465 if ((the_position + f_help_dsp_area->dispUseHeight) > f_help_dsp_area->maxYpos)
3467 // avoid going beyond top of last page
3468 the_position = f_help_dsp_area->maxYpos - f_help_dsp_area->dispUseHeight ;
3472 the_position -= 2/3 * f_help_dsp_area->dispUseHeight ;
3474 if (the_position < 0)
3477 #ifdef BOOKMARK_JUMP_DEBUG
3478 cerr << "Clean and draw at: " << the_position << "\twas: " << f_help_dsp_area->firstVisible << endl;
3480 f_help_dsp_area->firstVisible = the_position ;
3482 // adjust the scrollbar
3484 XtSetArg(arg[0], XmNvalue, the_position);
3485 XtSetValues(f_help_dsp_area->vertScrollWid, arg, 1);
3487 // call the scrollbar notify callback because we adjusted it
3488 if (f_help_dsp_area->vScrollNotify)
3489 (f_help_dsp_area->vScrollNotify)(this, the_position);
3495 // /////////////////////////////////////////////////////////////////
3496 // edit_mark - edit the selected mark
3497 // /////////////////////////////////////////////////////////////////
3500 NodeWindowAgent::edit_markCB(Widget, XtPointer, XtPointer)
3502 Xassert (MarkCanvas::selected_mark() != NULL);
3503 MarkCanvas::selected_mark()->mark_ptr()->edit();
3507 // /////////////////////////////////////////////////////////////////
3508 // delete_mark - delete the selected mark
3509 // /////////////////////////////////////////////////////////////////
3511 NodeWindowAgent::delete_markCB(Widget, XtPointer client_data, XtPointer)
3513 NodeWindowAgent* agent = (NodeWindowAgent*)client_data;
3514 agent->delete_mark();
3518 NodeWindowAgent::delete_mark()
3520 Xassert (MarkCanvas::selected_mark() != NULL);
3523 MarkCanvas::selected_mark()->mark_ptr()->remove();
3525 XtSetSensitive(f_create_bmrk, False);
3526 XtSetSensitive(f_create_anno, False);
3530 message_mgr().error_dialog (
3531 (char*)UAS_String(CATGETS(Set_Messages, 11,
3532 "Dtinfo is unable to delete this bookmark.")),
3539 // /////////////////////////////////////////////////////////////////
3540 // move_mark - move the selected mark to the selected text region
3541 // /////////////////////////////////////////////////////////////////
3544 NodeWindowAgent::move_mark()
3546 // f_move_mark must be insensetive if there's no mark selected
3547 if (MarkCanvas::selected_mark() == NULL ||
3548 MarkCanvas::selected_mark()->agent() != this) {
3549 #ifdef BOOKMARK_DEBUG
3550 cerr << "bookmark not selected in this reading window" << endl;
3555 if (! (make_bookmark(False, MarkCanvas::selected_mark()) < 0))
3560 NodeWindowAgent::move_markCB(Widget, XtPointer client_data, XtPointer)
3562 NodeWindowAgent* agent = (NodeWindowAgent*)client_data;
3566 Xassert (MarkCanvas::selected_mark() != NULL);
3567 Xassert (f_viewport_agent->selection_range() != NULL);
3568 UAS_Pointer<Mark> mark_ptr = MarkTml::selected_mark()->mark_ptr();
3570 // Create a new mark based on the old one at the new location.
3573 f_viewport_agent->mark_creator (this); // 94/10/27 yuji bug fix for TC-530
3574 UAS_Pointer<UAS_Common> d;
3575 mark_mgr().move_mark (d = f_node_ptr,
3576 AnchorCanvas (f_viewport_agent->selection_range()),
3581 message_mgr().error_dialog (
3582 (char*)UAS_String(CATGETS(Set_Messages, 12,
3583 "Dtinfo is unable to remove this bookmark.")),
3591 NodeWindowAgent::set_min_size()
3593 Dimension width, height, vwidth, vheight;
3595 f_shell->Get (WArgList (XmNheight, (XtArgVal) &height,
3596 XmNwidth, &width, NULL));
3598 Widget wid = XtParent(XtParent(f_help_dsp_area->dispWid));
3600 WArgList (XmNheight, (XtArgVal) &vheight,
3601 XmNwidth, &vwidth, NULL)
3605 ON_DEBUG (printf ("shell size = %d x %d\n", width, height));
3606 ON_DEBUG (printf ("viewport size = %d x %d\n", vheight, vwidth));
3608 f_shell->Set (WArgList (XmNminHeight, height - vheight + 60,
3609 XmNminWidth, width - vwidth + 170, NULL));
3613 NodeWindowAgent::detach_graphicCB(Widget, XtPointer client_data, XtPointer)
3615 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
3616 agent->detach_graphic();
3620 NodeWindowAgent::dialog_mapped (Widget w, XtPointer client_data,
3621 XEvent *, Boolean *)
3623 XmUpdateDisplay (w);
3625 *((int *) client_data) = TRUE;
3630 NodeWindowAgent::detach_graphic()
3634 static Cursor pick_cursor;
3637 // Display an instructional dialog.
3639 info_dialog ((Widget)f_shell, (char*)"detach_msg",
3640 WArgList (XmNdialogType, XmDIALOG_INFORMATION, NULL));
3641 WXmDialogShell shell (info_dialog.Parent());
3643 String string = CATGETS(Set_Messages, 72, "Dtinfo: Detach Graphic");
3644 XtVaSetValues((Widget)shell, XmNtitle, string, NULL);
3645 info_dialog.MessageString (
3646 (char*)UAS_String(CATGETS(Set_Messages, 73, "Click on graphic")));
3647 XtUnmanageChild (info_dialog.OkPB());
3648 XtUnmanageChild (info_dialog.HelpPB());
3650 XtVaSetValues((Widget)info_dialog, XmNdefaultPosition, False, NULL);
3652 // Wait for the dialog to appear.
3654 info_dialog.Manage();
3655 XtAddEventHandler (info_dialog, ExposureMask, False,
3656 dialog_mapped, (XtPointer) &mapped);
3657 XtAppContext app_context = window_system().app_context();
3660 XtAppNextEvent (app_context, &event);
3661 XtDispatchEvent (&event);
3664 pick_cursor = XCreateFontCursor (window_system().display(), XC_crosshair);
3665 Widget target = XmTrackingEvent ((Widget)f_shell, pick_cursor, False, &event);
3667 if(target != NULL && target == f_help_dsp_area->dispWid)
3670 _DtCvElemType element;
3671 seg = xy_to_seg(event.xbutton.x, event.xbutton.y, &element);
3672 if (seg && element == _DtCvREGION_TYPE)
3674 SegClientData* pSCD = (SegClientData*)(seg->client_use);
3675 UAS_Pointer<Graphic> gr = (Graphic*)pSCD->GraphicHandle();
3677 if (!gr->is_detached())
3678 graphics_mgr().detach (f_node_view_info->node_ptr(), gr);
3683 info_dialog.Unmanage();
3684 XtDestroyWidget (info_dialog.Parent());
3687 // /////////////////////////////////////////////////////////////////
3689 // /////////////////////////////////////////////////////////////////
3692 NodeWindowAgent::show_locatorCB(Widget, XtPointer closure, XtPointer)
3694 NodeWindowAgent *agent = (NodeWindowAgent *)closure;
3695 agent->show_locator();
3699 NodeWindowAgent::show_locator()
3701 // initially this only gets the locator for the current section
3702 // and does not go into a section
3703 char buffer[BUFSIZ];
3704 //const char *locator = f_node_ptr->locator();
3705 UAS_String locator_str = f_node_ptr->id();
3706 const char *locator = (const char *)locator_str;
3707 snprintf (buffer, sizeof(buffer),
3708 CATGETS(Set_NodeWindowAgent, 4,
3709 "The locator for this section is %s"), locator);
3710 XmTextFieldSetString(f_status_text, buffer);
3711 XmTextFieldSetSelection(f_status_text,
3712 strlen(buffer) - strlen(locator),
3713 strlen(buffer), CurrentTime);
3717 // /////////////////////////////////////////////////////////////////////////
3719 // /////////////////////////////////////////////////////////////////////////
3722 prefsCB(Widget, XtPointer, XtPointer)
3724 pref_mgr().display();
3727 // /////////////////////////////////////////////////////////////////
3728 // list_marks - pop up the marks list
3729 // /////////////////////////////////////////////////////////////////
3732 mark_listCB(Widget, XtPointer, XtPointer)
3734 mark_mgr().display_mark_list();
3737 // /////////////////////////////////////////////////////////////////////////
3739 // /////////////////////////////////////////////////////////////////////////
3742 query_editorCB(Widget, XtPointer, XtPointer)
3745 search_mgr().display_editor();
3749 NodeWindowAgent::clear_searchCB(Widget, XtPointer client_data, XtPointer)
3751 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
3752 agent->clear_search_hits_activate();
3756 NodeWindowAgent::clear_search_hits_activate()
3758 f_node_view_info->clear_search_hits();
3760 _DtCvUnit width, height;
3763 status = _DtCanvasResize((_DtCvHandle)f_help_dsp_area->canvas,
3764 _DtCvTRUE, &width, &height);
3766 if (status == _DtCvSTATUS_OK)
3768 XClearArea(XtDisplay(f_help_dsp_area->dispWid),
3769 XtWindow(f_help_dsp_area->dispWid),
3772 _DtCanvasRender((_DtCvHandle)f_help_dsp_area->canvas, 0, 0,
3773 width, height, _DtCvRENDER_PARTIAL, _DtCvFALSE, NULL, NULL);
3776 else if (status == _DtCvSTATUS_NONE)
3777 fprintf(stderr, "(WARNING) re-layout did not occur.\n");
3778 else if (status == _DtCvSTATUS_BAD)
3779 fprintf(stderr, "(ERROR) there were problems during re-layout.\n");
3781 fprintf(stderr, "(ERROR) unknown code returned.\n");
3784 if (XtIsSensitive(f_search_next)) {
3785 XtSetSensitive(f_search_next, False);
3786 XtSetSensitive(f_search_next2, False);
3788 if (XtIsSensitive(f_search_prev)) {
3789 XtSetSensitive(f_search_prev, False);
3790 XtSetSensitive(f_search_prev2, False);
3793 if (XtIsSensitive(f_clear_search_hits))
3794 XtSetSensitive(f_clear_search_hits, False);
3801 extern void moncontrol(int) ;
3804 NodeWindowAgent::monitor(WCallback *wcb)
3806 moncontrol((int)wcb->CallData());
3812 // /////////////////////////////////////////////////////////////////
3814 // /////////////////////////////////////////////////////////////////
3817 NodeWindowAgent::display (UAS_Pointer<UAS_Common> &node_ptr)
3819 bool first_time = False;
3821 if (f_shell == NULL)
3828 f_viewport_agent->pre_display();
3831 // Clear the old DisplayData. This is necessary because we
3832 // are about to delete the value that it is set to.
3833 // f_viewport->DisplayData (NULL); not necessary, I think DJB
3835 // Grab the scrolled position of the old node and save it in the history.
3836 // If the node was displayed from the history, don't bother, because the
3837 // position has already been recorded since the history had to be advanced.
3838 if (!f_history_display && !g_style_sheet_update)
3839 record_history_position();
3842 int sameNode = f_node_view_info && f_node_view_info->node_ptr() == node_ptr;
3843 if (sameNode && !g_style_sheet_update && !f_history_display) {
3844 // extern char g_top_locator[];
3846 // need to change this to pass in the locator to SetTopic so the
3847 // Canvas knows where to scroll to when it displays
3848 f_viewport_agent->show_locator (0, g_top_locator);
3852 if (f_node_view_info) {
3853 _DtCvTopicInfo topic;
3854 memset(&topic, 0, sizeof(_DtCvTopicInfo));
3855 _DtCanvasSetTopic(f_help_dsp_area->canvas, &topic, _DtCvFALSE,
3858 // deleting this object causes massive error messages on novell
3860 delete f_node_view_info;
3861 f_node_view_info = NULL;
3865 // Create a new view for the specified node.
3867 // exporting the display area so that the CanvasRenderer has
3868 // access to it to load the fonts
3870 extern DtHelpDispAreaStruct *gHelpDisplayArea ;
3871 gHelpDisplayArea = f_help_dsp_area ;
3873 // if (f_node_view_info == NULL)
3875 // f_node_view_info = new NodeViewInfo(node_ptr);
3876 // f_node_view_info = node_mgr().load(node_ptr);
3879 f_node_view_info = node_mgr().load(node_ptr);
3882 XtAddCallback (f_help_dsp_area->dispWid,
3883 XmNdisarmCallback, selection_end_callback,
3886 XtAddCallback (f_help_dsp_area->dispWid,
3887 XmNdisarmCallback, disarm_callback, (XtPointer)this);
3890 UAS_Pointer<UAS_List<UAS_TextRun> >
3891 current_search_hits = search_mgr().current_hits();
3893 if (current_search_hits != (UAS_Pointer<UAS_List<UAS_TextRun> >)NULL)
3895 f_node_view_info->set_search_hits(current_search_hits);
3897 if (! XtIsSensitive(f_clear_search_hits))
3898 XtSetSensitive(f_clear_search_hits, True);
3901 f_node_view_info->comp_pixel_values(
3902 XtDisplay(f_help_dsp_area->dispWid),
3903 f_help_dsp_area->colormap
3907 _DtCvTopicInfo *topic = f_node_view_info->topic();
3910 initialize_controls();
3912 if (f_graphics_handler) {
3913 delete f_graphics_handler;
3914 f_graphics_handler = NULL;
3916 f_graphics_handler = new GraphicsHandler (this);
3917 // tell the pixmaps what viewport they are attached to
3918 //List_Iterator<UAS_Pointer<Graphic> > cursor(&f_node_view_info->graphics());
3919 //for (; cursor; cursor++)
3921 //cursor.item()->pixmap_graphic()->register_handler(f_graphics_handler);
3926 *((char *) memcpy(buffer, "Dtinfo: ", 8) + 8) = '\0';
3927 int slen = strlen(buffer);
3928 *((char *) memcpy(buffer + slen,
3929 f_node_view_info->node_ptr()->book_name (UAS_LONG_TITLE),
3931 f_shell->Title (buffer);
3932 f_shell->IconName (buffer);
3935 if (!g_style_sheet_update)
3940 set_min_size(); // NOTE: this really needs to happen before the popup!!
3941 XLowerWindow (XtDisplay (*f_tab_area), XtWindow (*f_tab_area));
3944 f_shell->DeIconify();
3947 if (first_time == TRUE) {
3948 XtUnmanageChild(f_form);
3949 XtRealizeWidget(f_form);
3950 XtManageChild(f_form);
3953 bool move_to_mark = TRUE;
3955 if (current_search_hits != (UAS_Pointer<UAS_List<UAS_TextRun> >)NULL
3956 && f_node_view_info->hit_entries() > 0)
3958 _DtHelpSearchMoveTraversal((XtPointer)f_help_dsp_area, 0);
3960 move_to_mark = FALSE;
3964 do_bookmarks(move_to_mark);
3966 if (first_time && *g_top_locator) // Try again... (really Canvas bug)
3968 node_mgr().set_preferred_window (this);
3970 bool locked = f_locked; // force display in this window
3973 node_ptr->retrieve();
3980 // reset sub-component specifier here at last
3984 _DtHelpCleanAndDrawWholeCanvas(f_help_dsp_area);
3988 NodeWindowAgent::do_bookmarks(bool move_to_mark)
3990 unsigned bookmark_errors = 0 ;
3991 xList<UAS_Pointer<Mark> > marks ;
3992 UAS_Pointer<UAS_Common> bogus ;
3993 bogus = f_node_view_info->node_ptr() ;
3994 mark_mgr().get_marks (bogus, marks);
3995 List_Iterator<UAS_Pointer<Mark> > i (marks);
3997 MarkCanvas *jump_to = NULL ;
3999 #ifdef BOOKMARK_DEBUG
4000 cerr << "id = : " << bogus->id() << endl;
4001 cerr << "** Marks: " << marks.length() << " **" << endl;
4006 MarkCanvas *mc = add_mark (i.item());
4007 if (g_view_mark() == i.item())
4012 #ifdef BOOKMARK_DEBUG
4013 cerr << "error adding bookmark " << i.item()->name() << endl;
4021 if (bookmark_errors > 0)
4023 message_mgr().error_dialog (
4024 (char*)UAS_String(CATGETS(Set_Messages, 10,
4025 "Dtinfo is unable to create this bookmark.")),
4028 #ifdef BOOKMARK_JUMP_DEBUG
4029 if (g_view_mark() != 0)
4030 cerr << "have jump" << endl;
4032 cerr << "have NO jump" << endl;
4035 show_mark (jump_to, move_to_mark);
4039 // /////////////////////////////////////////////////////////////////
4040 // clone - clone the current node
4041 // /////////////////////////////////////////////////////////////////
4044 NodeWindowAgent::cloneCB(Widget, XtPointer client_data, XtPointer)
4046 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
4047 node_mgr().force_new_window();
4048 agent->f_node_view_info->node_ptr()->retrieve();
4052 // /////////////////////////////////////////////////////////////////
4053 // initialize_hierarchy - init the ancestral hierarchy control
4054 // /////////////////////////////////////////////////////////////////
4057 NodeWindowAgent::initialize_hierarchy()
4059 List_Iterator<Ancestor *> i (f_ancestor_list);
4060 UAS_Pointer<UAS_Common> toc_ptr = f_node_view_info->node_ptr();
4063 // If there's no TOC document for this node, use the node title.
4064 UAS_String tt = f_node_view_info->node_ptr()->title();
4065 if (toc_ptr == (UAS_Pointer<UAS_Common>)NULL)
4068 i.item()->update ((char *) tt, NULL);
4071 Ancestor *a = new Ancestor (this, *f_title_menu,
4074 // Each time an entry is activated we must reset the hierarchy
4075 // control in case the node in this window does not change.
4076 ON_ACTIVATE (a->f_button, reset_hierarchy);
4077 f_ancestor_list.append (a);
4078 // Reset the iterator so that the rest are properly unmanaged.
4085 // See if the node is in the current hierarchy.
4086 while (i && XtIsManaged (i.item()->f_button))
4088 if (i.item()->f_toc_ptr == toc_ptr)
4090 // Found it -- set the menu history and return.
4091 f_current_ancestor = i.item();
4092 f_title_option->MenuHistory (f_current_ancestor->f_button);
4093 // Finish the traversal and get the tabs from here on up.
4094 while (i && XtIsManaged (i.item()->f_button))
4096 toc_ptr = i.item()->f_toc_ptr;
4097 UAS_List<UAS_Common> tabList = toc_ptr->book_tab_list();
4098 t = tabList.length();
4100 g_tab_list.insert (tabList[t]);
4108 // Didn't find it, so revise the current hierarchy.
4109 // The hierarcy list is stored from the last entry to the
4110 // first because we have to traverse the hierarchy from
4111 // top to bottom, but we can only traverse a list forward.
4112 // Therefore, the XmNpositionIndex of the button must be
4113 // set to 0 in the resource file so that new buttons are
4114 // always inserted at the beginning of the popup menu.
4117 while (toc_ptr != (UAS_Pointer<UAS_Common>)NULL)
4119 // Update existing entries until we run out, then start
4120 // adding new entries.
4121 UAS_String ttt = toc_ptr->title();
4124 i.item()->update ((char *) ttt, toc_ptr);
4130 new Ancestor (this, *f_title_menu, (char *) ttt, toc_ptr);
4131 ON_ACTIVATE (a->f_button, reset_hierarchy);
4132 f_ancestor_list.append (a);
4134 // 15 is the magic maximum TOC depth...
4137 message_mgr().error_dialog(
4138 (char*)UAS_String(CATGETS(Set_Messages, 13, "File a Bug")),
4143 // Push the tabs for each TOC entry onto the tab list.
4144 // The list is assumed to be empty at the start of this method.
4145 UAS_List<UAS_Common> tabList = toc_ptr->book_tab_list ();
4146 t = tabList.length();
4149 ON_DEBUG (puts ("Inserting in g_tab_list"));
4150 g_tab_list.insert (tabList[t]);
4153 toc_ptr = toc_ptr->parent();
4157 // Clear and unmanage the leftover buttons, if any.
4159 i.item()->update (NULL, NULL);
4161 // Set the menu history to the current node entry.
4163 // Work around Motif 1.2 bug
4164 WXmCascadeButtonGadget opb (XmOptionButtonGadget (*f_title_option));
4166 f_current_ancestor = i.item();
4167 f_title_option->MenuHistory (f_current_ancestor->f_button);
4173 NodeWindowAgent::reset_hierarchy()
4175 // If the MenuHistory of the title_menu doesn't match what we
4176 // set it to, then we must reset it.
4177 // This can happen if the window is locked and the user chooses
4178 // a node form the ancestral hierarchy, or if an entry in the
4179 // ancestral hierarchy is not a Node document.
4180 Widget actual = f_title_option->MenuHistory();
4181 Widget expected = f_current_ancestor->f_button;
4182 if (actual != expected)
4183 f_title_option->MenuHistory (expected);
4187 // /////////////////////////////////////////////////////////////////
4188 // path handling stuff
4189 // /////////////////////////////////////////////////////////////////
4192 NodeWindowAgent::initialize_path()
4194 UAS_Pointer<UAS_Common> path = f_node_view_info->node_ptr();
4196 if ((path != (UAS_Pointer<UAS_Common>)NULL)
4197 && (path->next() != (UAS_Pointer<UAS_Common>)NULL)) {
4198 XtSetSensitive(f_node_next, True);
4199 XtSetSensitive(f_node_next2, True);
4200 XtSetSensitive(f_node_next3, True);
4202 XtSetSensitive(f_node_next, False);
4203 XtSetSensitive(f_node_next2, False);
4204 XtSetSensitive(f_node_next3, False);
4207 if ((path != (UAS_Pointer<UAS_Common>)NULL) &&
4208 (path->previous() != (UAS_Pointer<UAS_Common>)NULL)) {
4209 XtSetSensitive(f_node_prev, True);
4210 XtSetSensitive(f_node_prev2, True);
4211 XtSetSensitive(f_node_prev3, True);
4213 XtSetSensitive(f_node_prev, False);
4214 XtSetSensitive(f_node_prev2, False);
4215 XtSetSensitive(f_node_prev3, False);
4220 NodeWindowAgent::refresh(const UAS_Pointer<Graphic>& pg)
4223 f_viewport_agent->refresh(pg);
4228 NodeWindowAgent::preview_nextCB(Widget, XtPointer client_data, XtPointer)
4230 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
4231 agent->f_preview_document = agent->f_node_view_info->node_ptr()->next();
4232 agent->f_preview_timeout =
4233 new WTimeOut (window_system().app_context(), 550,
4234 agent, (WTimeOutFunc) &NodeWindowAgent::preview);
4238 NodeWindowAgent::preview_previousCB(Widget, XtPointer client_data, XtPointer)
4240 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
4241 agent->f_preview_document = agent->f_node_view_info->node_ptr()->previous();
4242 agent->f_preview_timeout =
4243 new WTimeOut (window_system().app_context(), 550,
4244 agent, (WTimeOutFunc) &NodeWindowAgent::preview);
4249 NodeWindowAgent::node_nextCB(Widget, XtPointer client_data, XtPointer)
4251 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
4252 // If this callback is called, the node must have a next.
4253 node_mgr().set_preferred_window (agent);
4254 agent->f_node_view_info->node_ptr()->next()->retrieve();
4258 NodeWindowAgent::node_previousCB(Widget, XtPointer client_data, XtPointer)
4260 NodeWindowAgent *agent = (NodeWindowAgent *)client_data;
4261 // If this callback is called, the node must have a previous.
4262 node_mgr().set_preferred_window (agent);
4263 agent->f_node_view_info->node_ptr()->previous()->retrieve();
4267 // /////////////////////////////////////////////////////////////////
4269 // /////////////////////////////////////////////////////////////////
4272 NodeWindowAgent::add_quick_help (Widget w, const char* help_text)
4274 if (help_text == NULL || *help_text == '\0') {
4275 XtVaSetValues(w, XmNuserData, NULL, NULL);
4279 XtVaSetValues(w, XmNuserData, (void*)this, NULL);
4281 // Now add the event handlers to display the quick help.
4282 XtAddEventHandler (w, EnterWindowMask, False, quick_helpEH, (XtPointer)help_text);
4283 XtAddEventHandler (w, LeaveWindowMask, False, quick_helpEH, (XtPointer)help_text);
4284 XtAddEventHandler (w, FocusChangeMask, False, quick_helpEH, (XtPointer)help_text);
4288 // /////////////////////////////////////////////////////////////////
4290 // /////////////////////////////////////////////////////////////////
4293 NodeWindowAgent::quick_helpEH (Widget w, XtPointer client_data,
4294 XEvent *event, Boolean *)
4296 // Ok, now we can display the help text.
4299 NodeWindowAgent *agent;
4302 XtSetArg(args[n], XmNuserData, &agent); n++;
4303 XtGetValues(w, args, n);
4305 // display quick help if moving into widget or clear quick help
4306 // if moving out of widget.
4307 if (event->type == EnterNotify || event->type == FocusIn)
4308 XmTextFieldSetString(agent->f_status_text, (char*)client_data);
4309 else if (event->type == LeaveNotify || event->type != FocusOut)
4310 XmTextFieldSetString(agent->f_status_text, (char*)"");
4314 // /////////////////////////////////////////////////////////////////
4315 // record_history_position - save the scrolled node position
4316 // /////////////////////////////////////////////////////////////////
4318 // This routine recors the scrolled position of the currently
4319 // displayed node in the current position of the local hist list.
4322 NodeWindowAgent::record_history_position()
4325 // If the node isn't going to be replaced, forget it.
4326 if (f_locked || f_node_view_info == NULL)
4329 model_pos *top = f_viewport_agent->top_model_pos();
4330 if (top != NULL) // just in case
4333 range.set_start (*top);
4334 range.set_end (*top);
4335 f_history_list.set_anchor (new AnchorCanvas (&range));
4338 else // this shouldn't happen
4340 // Save the anchor, since expose events in the viewport with the
4341 // message dialog up will attempt to scroll to the (bogus) anchor.
4342 AnchorCanvas *save = g_history_anchor;
4343 g_history_anchor = NULL;
4344 message_mgr().info_dialog ("Can't get scroll position for history.",
4346 g_history_anchor = save;
4353 NodeWindowAgent::re_display()
4356 AnchorCanvas *save_anchor = g_history_anchor ;
4357 AnchorCanvas *anchor = NULL ;
4358 g_history_anchor = NULL ;
4359 // set up to display it at current position
4361 model_pos *top = f_viewport_agent->top_model_pos();
4362 if (top != NULL) // just in case
4364 range.set_start (*top);
4365 range.set_end (*top);
4366 // g_history anchor is set to NULL during display
4367 anchor = new AnchorCanvas(&range);
4368 g_history_anchor = anchor;
4371 else // this shouldn't happen
4373 // Save the anchor, since expose events in the viewport with the
4374 // message dialog up will attempt to scroll to the (bogus) anchor.
4375 AnchorCanvas *save = g_history_anchor;
4376 g_history_anchor = NULL;
4377 message_mgr().info_dialog ("Can't get scroll position for re-display.");
4378 g_history_anchor = save;
4382 bool lock_flag = f_locked ;
4383 f_locked = False ; // have to force it to happen regardless of lock
4388 node_mgr().set_preferred_window(this); // make re-display happen in this window
4389 f_node_view_info->node_ptr()->retrieve(); // same node
4391 f_locked = lock_flag ;
4397 g_history_anchor = save_anchor ;
4402 g_history_anchor = save_anchor;
4407 NodeWindowAgent::SetTopic(_DtCvTopicPtr topic)
4412 this routine was paraphrased from _DtHelpDisplayAreaSetList
4415 _DtHelpClearSelection(f_help_dsp_area);
4417 _DtCvUnit ret_width, ret_height, ret_y = 0;
4419 { // set topic with component SGML id set
4420 if (g_top_locator[0] != 0)
4421 topic->id_str = g_top_locator ;
4423 _DtCanvasSetTopic(f_help_dsp_area->canvas, topic, _DtCvFALSE,
4424 &ret_width, &ret_height, &ret_y);
4425 #ifdef CV_HYPER_DEBUG
4426 cerr << "top locator=" << topic->id_str << ' '
4427 << "firstVisible=" << ret_y << endl;
4429 // This statement was for debug purposes only and is no
4431 // if (status != _DtCvSTATUS_OK)
4432 // cerr << "(ERROR) _DtCanvasSetTopic failed, error# " << status << endl;
4435 f_vscrollbar_offset = ret_y ;
4438 SetMaxPositions (f_help_dsp_area, ret_width, ret_height);
4440 f_help_dsp_area->maxX = ret_width ;
4441 f_help_dsp_area->maxYpos = ret_height +
4442 f_help_dsp_area->marginHeight ;
4444 f_help_dsp_area->firstVisible = ret_y ;
4446 (void) _DtHelpSetScrollBars (f_help_dsp_area,
4447 f_help_dsp_area->dispWidth,
4448 f_help_dsp_area->dispHeight);
4451 // helper functions for create_canvas_mark
4452 // finds the next string segment after the
4455 // this is highly inefficient when we have to start
4456 // finding parents, as there are no up pointers in the tree so we walk
4457 // down from the top each time, but this should be rare, and probably
4458 // is more efficient in time (and definitely space) than keeping a
4459 // stack of the parents
4463 static _DtCvSegment *
4464 contains(_DtCvSegment *root, _DtCvSegment *segment)
4466 // need to find the parent container of
4467 // the given segment
4469 if (_DtCvIsSegContainer(root))
4471 _DtCvSegment *seglist = root->handle.container.seg_list ;
4474 if (seglist == segment)
4477 if (_DtCvIsSegContainer(seglist))
4479 _DtCvSegment *tseg = contains(seglist, segment);
4484 seglist = seglist->next_seg ;
4492 static _DtCvSegment *
4493 find_string_seg(_DtCvSegment *segment)
4495 // finds the next string segment moving
4496 // forward from (and counting) segment
4501 while (segment && !_DtCvIsSegString(segment))
4503 if (_DtCvIsSegContainer (segment))
4505 _DtCvSegment *rseg = find_string_seg(segment->handle.container.seg_list);
4509 segment = segment->next_seg ;
4516 next_string_segment(_DtCvSegment *root, _DtCvSegment *start)
4518 _DtCvSegment *rseg = 0;
4521 rseg = find_string_seg(start->next_seg); // recursive procedure
4529 start = contains(root, start);
4530 assert (_DtCvIsSegContainer (start));
4532 throw (CASTEXCEPT Exception());
4534 return next_string_segment(root, start);
4543 #define CURRENT_FORMAT "TML-1"
4545 inline unsigned min(unsigned a, unsigned b)
4547 return a < b ? a : b ;
4551 NodeWindowAgent::create_canvas_mark(_DtCvHandle canvas,
4552 NodeViewInfo *nvinfo,
4553 UAS_Pointer<Mark> &mark)
4555 if (canvas == NULL || nvinfo == NULL || mark == (UAS_Pointer<Mark>)NULL)
4558 const Anchor &anchor = mark->anchor();
4560 if (strcmp (anchor.format(), CURRENT_FORMAT) != 0)
4565 UAS_String location(anchor.location());
4567 UAS_String locator, marks_loc;
4568 location.split(';', locator, marks_loc);
4569 #ifdef BOOKMARK_DEBUG
4570 fprintf(stderr, "(DEBUG) marked section=\"%s\"\n", (char*)location);
4573 UAS_List<UAS_String> marks_loc_list;
4574 marks_loc_list = marks_loc.splitFields(',');
4577 for (i = 0; i < marks_loc_list.length(); i++)
4579 UAS_String& mark_loc = *marks_loc_list[i];
4580 unsigned int vcc, offset, length;
4582 sscanf((char*)mark_loc, "%u\t%u\t%u", &vcc, &offset, &length);
4584 markinfo.insert_item(UAS_Pointer<MarkUnitInfo>(
4585 new MarkUnitInfo(vcc, offset, length, NULL)));
4586 #ifdef BOOKMARK_DEBUG
4587 fprintf(stderr, "(DEBUG) marked position=(%u,%u,%u)\n",
4588 vcc, offset, length);
4592 if (markinfo.length() == 0)
4595 _DtCvSegPts **segs = new _DtCvSegPts*[markinfo.length() + 1];
4596 memset(segs, 0, (markinfo.length() + 1) * sizeof(_DtCvSegPts*));
4598 for (i = 0; i < markinfo.length(); i++)
4600 MarkUnitInfo& mui = *markinfo[i];
4602 segs[i] = new _DtCvSegPts;
4604 segs[i]->segment = nvinfo->get_segment(mui.vcc());
4605 segs[i]->offset = mui.offset() ;
4606 segs[i]->len = mui.length();
4609 MarkCanvas *mark_canvas =
4610 new MarkCanvas(mark, this, markinfo[0]->offset(), 0);
4612 // place the mark in the Canvas
4614 _DtCvPointInfo point_info;
4616 point_info.client_data = mark_canvas ;
4617 point_info.segs = segs ;
4619 #ifdef BOOKMARK_DEBUG
4620 _DtCvSegPts** iter = segs;
4621 for (; *iter; iter++) {
4622 cerr << "relative offset=" << (*iter)->offset << " " <<
4623 "len=" << (*iter)->len << " " <<
4624 (char*)(*iter)->segment->handle.string.string << endl;
4628 int ret_y1, ret_y2 ;
4630 _DtCvStatus status = _DtCanvasActivatePts(canvas,
4631 _DtCvACTIVATE_MARK /* | _DtCvACTIVATE_MARK_ON */,
4632 &point_info, &ret_y1, &ret_y2);
4633 (void) _DtCanvasProcessSelection(canvas, 0, 0, _DtCvSELECTION_CLEAR);
4635 #ifdef MARK_ON_DEBUG
4636 status = _DtCanvasActivatePts(canvas,
4637 _DtCvACTIVATE_MARK_ON, 0, 0, 0);
4641 for (i = 0; i < markinfo.length(); i++)
4646 #ifdef BOOKMARK_DEBUG
4647 if (status == _DtCvSTATUS_BAD)
4648 cerr << "Activate Pts --> bad return" << endl;
4650 cerr << "Activate Pts y1( " << ret_y1 << "), y2( " << ret_y2 << ")" << endl;
4653 if (status == _DtCvSTATUS_BAD) {
4654 delete mark_canvas ;
4658 mark_canvas->y_position (ret_y1);
4660 return mark_canvas ;
4665 find_segment_offset (_DtCvSegment *start, const _DtCvSegment *target,
4668 // find the offset of the target segment from the starting point
4669 // offset is accumulated recursively
4671 if (start == target)
4675 else if(start == NULL)
4680 Boolean found = False ;
4681 switch (start->type & _DtCvPRIMARY_MASK)
4683 case _DtCvCONTAINER:
4684 found = find_segment_offset (start->handle.container.seg_list,
4689 #ifdef BOOKMARK_DEBUG
4690 //cerr << "[" << offset << "]\t" << start->handle.string.string << endl;
4692 // do not count this string if it was added data
4693 if (!(start->type & _DtCvAPP_FLAG1))
4694 offset += strlen( (const char *)(start->handle.string.string) ) ;
4699 for (int i = 0; start->handle.table.cells[i] != NULL; i++)
4701 found = find_segment_offset (start->handle.table.cells[i],
4710 if (!found && start->next_seg)
4711 return find_segment_offset (start->next_seg, target, offset);
4718 NodeWindowAgent::link_to (const char *locator)
4720 UAS_String loc(locator);
4721 UAS_Pointer<UAS_Common> target =
4722 f_node_view_info->node_ptr()->create_relative (loc);
4724 // NOTE: create_relative may fail if the infolib associated with
4725 // has been removed. If so, do not try to retrieve.
4727 node_mgr().set_preferred_window (this);
4729 int len = MIN(strlen((char*)loc), 4096 - 1);
4730 *((char *) memcpy(g_top_locator, (char*)loc, len) + len) = '\0';
4732 target->retrieve() ;
4737 NodeWindowAgent::canvas_resize()
4740 cerr << "canvas_resize" << endl;
4743 layout_mark_icons();
4746 int g_blew_away_marks_too_bad_you_lose_dts_14590;
4748 NodeWindowAgent::layout_mark_icons()
4750 if (f_help_dsp_area == NULL)
4753 f_vscrollbar_offset = f_help_dsp_area->firstVisible;
4755 if (f_mark_list.length() == 0)
4758 /* -------- Delete any existing icons. -------- */
4760 g_blew_away_marks_too_bad_you_lose_dts_14590 = 1 ; // inform marks chooser
4762 // first we destroy all the icons
4764 while (f_mark_icon_list.length() > 0) {
4765 #ifdef BOOKMARK_DEBUG
4766 fprintf(stderr, "(DEBUG) still %d remain, removing icon...\n",
4767 f_mark_icon_list.length());
4769 List_Iterator<MarkIcon *> iter (f_mark_icon_list);
4771 f_mark_icon_list.remove(iter);
4774 List_Iterator <MarkIcon *> i (f_mark_icon_list);
4779 f_mark_icon_list.remove (i);
4783 /* -------- Now re-layout the icons from the list 'o Marks. -------- */
4785 // first we have to compute the new location of each MarkCanvas
4787 _DtCvMarkPos **return_positions = NULL;
4788 _DtCanvasGetMarkPositions(f_help_dsp_area->canvas,
4791 for (int mpi = 0 ; return_positions[mpi]; mpi++)
4793 _DtCvMarkPos *mark_pos = return_positions[mpi] ;
4794 #ifdef BOOKMARK_DEBUG
4795 cerr << "Recalc Mark Pos:" << mark_pos->y1 << endl;
4797 ((MarkCanvas*) mark_pos->client_data)->y_position (mark_pos->y1);
4801 free(return_positions);
4803 // The list of MarkCanvas objects is already in order of occurance
4804 // in the node, so we can just process them in order to create
4805 // the revised set of MarkIcons.
4808 List_Iterator <MarkCanvas *> m (f_mark_list);
4809 MarkIcon *mark_icon = NULL;
4810 //MarkCanvas *jump_to = NULL;
4814 if (g_view_mark() == m.item()->mark_ptr())
4816 g_view_mark() = NULL;
4817 // jump_to = m.item();
4820 MarkIcon *mi = NULL;
4821 List_Iterator<MarkIcon *> iter (f_mark_icon_list);
4826 if (mi && m.item()->y_position() > mi->ypos() - mi->Height()
4827 && m.item()->y_position() < mi->ypos() + mi->Height()) {
4828 mi->append(m.item());
4838 new MarkIcon (XtParent (XtParent (f_help_dsp_area->dispWid)),
4840 m.item()->y_position(), f_vscrollbar_offset);
4842 f_mark_icon_list.append (mark_icon);
4850 NodeWindowAgent::show_mark(MarkCanvas *jump_to, bool move_to)
4854 // Make sure the mark has an icon
4855 if (jump_to->mark_icon() != NULL)
4857 jump_to->select(move_to);
4861 message_mgr().warning_dialog (
4862 (char*)UAS_String(CATGETS(Set_Messages, 14,
4863 "The bookmark cannot be displayed.")),
4870 // /////////////////////////////////////////////////////////////////
4872 // /////////////////////////////////////////////////////////////////
4875 NodeWindowAgent::cleanup_marks()
4877 // Delete all items in these lists.
4878 List_Iterator<MarkIcon *> mi (f_mark_icon_list);
4882 f_mark_icon_list.remove (mi);
4885 List_Iterator<MarkCanvas *> mt (f_mark_list);
4889 f_mark_list.remove (mt);
4895 NodeWindowAgent::receive (MarkCreated &message, void* /*client_data*/)
4897 #ifdef BOOKMARK_DEBUG
4898 cerr << "receive <Mark Created>" << endl;
4900 // Make sure the Mark in question is dispalyed in this Viewport.
4901 if (message.f_mark_ptr->doc_ptr() != f_node_ptr) {
4902 // Nov 11 '94 yuji - Another doc_ptr may refer to the same contents.
4903 char *locator = strdup(message.f_mark_ptr->doc_ptr()->locator());
4904 if (strcmp(locator, f_node_ptr->locator())) {
4911 add_mark (message.f_mark_ptr);
4914 NodeWindowAgent::receive (MarkDeleted &message, void* /*client_data*/)
4916 #ifdef BOOKMARK_DEBUG
4917 cerr << "receive <Mark Deleted>" << endl;
4919 delete_mark_visuals (message.f_mark_ptr) ;
4923 // /////////////////////////////////////////////////////////////////
4924 // delete_mark - delete the MarkTml and maybe icon of a Mark
4925 // /////////////////////////////////////////////////////////////////
4928 NodeWindowAgent::delete_mark_visuals (UAS_Pointer<Mark> &mark_ptr)
4930 List_Iterator <MarkCanvas *> m (f_mark_list);
4932 // Try to find the corresponding MarkCanvas object in the mark list.
4935 if (mark_ptr == m.item()->mark_ptr())
4937 MarkCanvas *mark_canvas = m.item();
4939 // Deselect the Mark first if necessary.
4940 if (mark_canvas->selected())
4941 mark_canvas->deselect();
4944 // turn traversal off
4945 _DtCanvasMoveTraversal(f_help_dsp_area->canvas,
4946 _DtCvTRAVERSAL_OFF, // cmd
4948 _DtCvTRUE, // render
4952 // Remove It from the DtCanvas
4954 _DtCvPointInfo point_info ;
4955 point_info.client_data = mark_canvas; // this is how we
4959 _DtCanvasActivatePts (f_help_dsp_area->canvas, // canvas
4960 _DtCvDEACTIVATE, // mask
4961 &point_info, // mark identification
4966 // Disconnect the MarkCanvas from the MarkIcon.
4967 MarkIcon *mark_icon = mark_canvas->mark_icon();
4968 if (mark_icon != NULL)
4969 mark_icon->remove (mark_canvas);
4971 // Delete the MarkCanvas object and remove it from the list.
4972 f_mark_list.remove (m);
4975 // Delete the MarkIcon when no more Marks are associated with it.
4976 if (mark_icon && mark_icon->mark_count() == 0)
4978 f_mark_icon_list.remove (mark_icon);
4982 // turn traversal back on
4983 // turn traversal off
4984 _DtCanvasMoveTraversal(f_help_dsp_area->canvas,
4985 _DtCvTRAVERSAL_ON, // cmd
4987 _DtCvTRUE, // render
4995 // /////////////////////////////////////////////////////////////////
4997 // /////////////////////////////////////////////////////////////////
5000 NodeWindowAgent::add_mark (UAS_Pointer<Mark> &mark_ptr)
5002 MarkCanvas *mark_canvas = create_canvas_mark(f_help_dsp_area->canvas,
5005 if (mark_canvas == NULL)
5008 // Insert the mark into the Mark list.
5009 // The list is ordered by starting position of the Mark.
5010 List_Iterator<MarkCanvas *> m (f_mark_list);
5011 while (m && mark_canvas->offset() > m.item()->offset())
5014 f_mark_list.insert_before (m, mark_canvas);
5016 /* -------- Make an icon appear for the new Mark. -------- */
5018 // First see if there's already an overlapping icon at the proper position.
5019 // Start by finding the icons on either side of this one.
5021 List_Iterator<MarkIcon *> i (f_mark_icon_list);
5023 while (i && mark_canvas->offset() > i.item()->offset())
5028 unsigned int ypos = mark_canvas->y_position();
5030 MarkIcon *mi = NULL;
5031 List_Iterator<MarkIcon *> iter (f_mark_icon_list);
5036 if (mi && ypos > mi->ypos() - mi->Height()
5037 && ypos < mi->ypos() + mi->Height())
5039 // Add to the end of the icon Mark list.
5040 mi->append (mark_canvas);
5049 MarkIcon *mark_icon =
5050 new MarkIcon (XtParent (XtParent (f_help_dsp_area->dispWid)),
5052 mark_canvas, ypos, f_vscrollbar_offset);
5053 f_mark_icon_list.insert_before (i, mark_icon);
5056 #ifdef BOOKMARK_DEBUG
5058 _DtCvMarkPos **return_positions = NULL;
5059 _DtCanvasGetMarkPositions(f_help_dsp_area->canvas,
5062 for (int i = 0; return_positions[i]; i++)
5064 _DtCvMarkPos* mark_pos = return_positions[i];
5065 fprintf(stderr, "(DEBUG) _DtCvMarkPos %dth ypos=%d\n", i,
5069 free(return_positions);
5073 return mark_canvas ;
5076 // /////////////////////////////////////////////////////////////////
5077 // code to initiate a mark view
5078 // /////////////////////////////////////////////////////////////////
5080 class MarkViewer : public UAS_Receiver<ViewMark>
5084 { Mark::request (this); }
5086 void receive (ViewMark &message, void *client_data);
5090 MarkViewer::receive (ViewMark &message, void* /*client_data*/)
5092 // Slight hack... Set a global that tells the ViewportAgent to
5093 // select and jump to the specified mark when the corresponding
5094 // node is displayed (see "jump_to" below). 15:17 02-Dec-93 DJB
5097 g_view_mark() = message.f_mark_ptr;
5099 UAS_Pointer<UAS_Common>& section = message.f_mark_ptr->doc_ptr();
5100 if (section == (UAS_Pointer<UAS_Common>)NULL)
5101 throw(CASTEXCEPT Exception());
5103 section->retrieve();
5105 mcatch_noarg(demoException &)
5107 // this is a hack. what should happen, is that the catch_any below this
5108 // should only be catching a specific (or set of) exception so that others
5109 // can pass through - 14:32 06/ 1/94 - jbm
5114 message_mgr().info_dialog (
5115 (char*)UAS_String(CATGETS(Set_Messages, 15,
5116 "The bookcase is not accessible.")));
5121 static MarkViewer g_mark_viewer;
5125 NodeWindowAgent::receive (UAS_LibraryDestroyedMsg &msg, void* /*client_data*/)
5127 //cerr << "NodeWindowAgent::receive (UAS_LibraryDestroyedMsg)\n";
5128 UAS_Pointer<UAS_Common> myNode = f_node_view_info->node_ptr();
5131 // First, if we're displaying a node from the dead library,
5132 // just commit suicide.
5134 if (myNode != 0 && myNode->get_library() == msg.fLib) {
5135 myNode = 0; // Just to be safe.
5141 // We're not displaying a node from the dead library,
5142 // however, our local history list might contain such
5143 // entries. Need to search the list and blow them away NOW.
5145 f_history_list.library_removed (msg.fLib);
5147 if (f_history_list.previous() != (UAS_Pointer<UAS_Common>)NULL) {
5148 XtSetSensitive(f_history_prev, True);
5149 XtSetSensitive(f_history_prev2, True);
5151 XtSetSensitive(f_history_prev, False);
5152 XtSetSensitive(f_history_prev2, False);
5155 if (f_history_list.next() != (UAS_Pointer<UAS_Common>)NULL) {
5156 XtSetSensitive(f_history_next, True);
5157 XtSetSensitive(f_history_next2, True);
5159 XtSetSensitive(f_history_next, False);
5160 XtSetSensitive(f_history_next2, False);
5164 // find the segment that contains a graphic
5167 _DtCvSegment *find_graphic(_DtCvSegment *segment, const Graphic *gr)
5169 if (NULL == segment)
5172 switch (segment->type & _DtCvPRIMARY_MASK)
5174 SegClientData* pSCD;
5176 pSCD = (SegClientData*)segment->client_use;
5177 if (((Graphic*)pSCD->GraphicHandle())->locator() ==
5178 ((Graphic*)gr)->locator())
5181 case _DtCvCONTAINER:
5183 _DtCvSegment *found =
5184 find_graphic(segment->handle.container.seg_list, gr);
5190 return find_graphic (segment->next_seg, gr);
5194 NodeWindowAgent::detach(UAS_Pointer<Graphic> &gr)
5197 _DtCvSegment *grseg;
5199 // get graphic segment
5200 grseg = find_graphic(f_node_view_info->topic()->seg_list, gr);
5204 SegClientData* pSCD = (SegClientData*)(grseg->client_use);
5205 UAS_Pointer<Graphic> curr_gr = (Graphic*)pSCD->GraphicHandle();
5206 curr_gr->set_detached(TRUE);
5207 //curr_gr->set_agent(gr->get_agent());
5212 NodeWindowAgent::reattach(UAS_Pointer<Graphic> &gr)
5214 _DtCvSegment *grseg;
5216 // get graphic segment
5217 grseg = find_graphic(f_node_view_info->topic()->seg_list, gr);
5221 SegClientData* pSCD = (SegClientData*)(grseg->client_use);
5222 UAS_Pointer<Graphic> nodeview_gr = (Graphic*)pSCD->GraphicHandle();
5223 nodeview_gr->set_detached(FALSE);
5224 //curr_gr->set_agent(gr->get_agent());
5226 replace (nodeview_gr);
5230 NodeWindowAgent::replace(UAS_Pointer<Graphic> &gr)
5232 // have to find the graphic in the canvas, remove it from the canvas
5233 // and replace it with the detached graphic graphic.
5234 _DtCvSegment *grseg =
5235 find_graphic(f_node_view_info->topic()->seg_list, gr);
5241 _DtHelpDARegion *pReg = (_DtHelpDARegion*) grseg->handle.region.info ;
5242 DtHelpGraphicStruct *pGS = (DtHelpGraphicStruct *) pReg->handle ;
5244 pGS->pix = gr->graphic()->pixmap();
5245 pGS->width = gr->graphic()->width();
5246 pGS->height = gr->graphic()->height();
5248 grseg->handle.region.width = pGS->width ;
5249 grseg->handle.region.height = pGS->height ;
5251 // inform our canvas that it needs to re-render
5252 _DtCvUnit width = 0, height = 0;
5253 _DtCanvasResize((_DtCvHandle)f_help_dsp_area->canvas,
5254 _DtCvTRUE, &width, &height);
5255 // There's no C/RE APIs provided to set maxYpos correctly
5256 // after canvas reformatting contents, so dtinfo manually
5257 // does it for now...
5258 f_help_dsp_area->maxYpos = f_help_dsp_area->marginHeight + height;
5260 // now get the canvas wiped out
5261 XClearArea(XtDisplay(f_help_dsp_area->dispWid),
5262 XtWindow(f_help_dsp_area->dispWid),
5265 _DtHelpSetScrollBars(f_help_dsp_area, f_help_dsp_area->dispWidth,
5266 f_help_dsp_area->dispHeight);
5268 // _DtCanvasRender is supposed to re-render the canvas
5269 _DtCanvasRender((_DtCvHandle)f_help_dsp_area->canvas, 0, 0,
5270 width, height, _DtCvRENDER_PARTIAL, _DtCvFALSE, NULL, NULL);
5271 if (XtIsManaged(f_help_dsp_area->vertScrollWid))
5273 // reset the scrollbar offset
5275 XtSetArg(arg[0], XmNvalue, &f_vscrollbar_offset);
5276 XtGetValues(f_help_dsp_area->vertScrollWid, arg, 1);
5279 // mark icons need to be re-positioned
5280 layout_mark_icons();
5287 GraphicsHandler::GraphicsHandler(NodeWindowAgent *agent)
5290 graphics_mgr().UAS_Sender<DetachGraphic>::
5291 request((UAS_Receiver<DetachGraphic>*)this);
5292 graphics_mgr().UAS_Sender<ReAttachGraphic>::
5293 request((UAS_Receiver<ReAttachGraphic>*)this);
5296 GraphicsHandler::~GraphicsHandler()
5301 GraphicsHandler::display_graphic(UAS_Pointer<Graphic> &gr)
5303 UAS_Sender<DisplayGraphic>::send_message(DisplayGraphic(gr));
5307 GraphicsHandler::receive(DetachGraphic &message, void* /*client_data*/)
5309 UAS_Sender<DisplayGraphic>::request(message.agent());
5310 if(message.agent()->node_ptr()->id() ==
5311 f_agent->node_view_info()->node_ptr()->id())
5313 f_agent->detach(message.graphic());
5318 GraphicsHandler::receive(ReAttachGraphic &message, void* /*client_data*/)
5320 f_agent->reattach(message.graphic());