2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
24 * $TOG: PrintPanelAgentMotif.C /main/35 1997/08/01 15:17:10 samborn $
26 * (c) Copyright 1996 Digital Equipment Corporation.
27 * (c) Copyright 1996 Hewlett-Packard Company.
28 * (c) Copyright 1996 International Business Machines Corp.
29 * (c) Copyright 1996 Sun Microsystems, Inc.
30 * (c) Copyright 1996 Novell, Inc.
31 * (c) Copyright 1996 FUJITSU LIMITED.
32 * (c) Copyright 1996 Hitachi.
34 * Copyright (c) 1992 HAL Computer Systems International, Ltd.
35 * All rights reserved. Unpublished -- rights reserved under
36 * the Copyright Laws of the United States. USE OF A COPYRIGHT
37 * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
40 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
41 * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
42 * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
43 * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
46 * RESTRICTED RIGHTS LEGEND
47 * Use, duplication, or disclosure by the Government is subject
48 * to the restrictions as set forth in subparagraph (c)(l)(ii)
49 * of the Rights in Technical Data and Computer Software clause
50 * at DFARS 252.227-7013.
52 * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
59 //------------- Includes -----------------------------------
65 #define C_NodeViewInfo
74 #define C_PrintPanelAgent
78 #include <X11/IntrinsicP.h>
79 #include <X11/CoreP.h>
81 #include <Xm/MessageB.h>
85 #include <DtI/DisplayAreaP.h>
86 #include <DtI/DisplayAreaI.h>
90 #include "Other/XmStringLocalized.hh"
91 #include "Managers/CatMgr.hh"
93 #include "Registration.hh"
95 #include <WWL/WXmDialogShell.h>
96 #include <WWL/WXmForm.h>
97 #include <WWL/WXmFrame.h>
98 #include <WWL/WXmPushButton.h>
99 #include <WWL/WXmSeparator.h>
103 #define CLASS PrintPanelAgent
105 #include "create_macros.hh"
107 #include <sys/types.h>
108 #include <sys/stat.h>
114 #define AM WAutoManage
115 #define WXmToggleBtn WXmToggleButton
116 #define WXmPushBtn WXmPushButton
119 # define RCS_DEBUG(statement) cerr << statement << endl
121 # define RCS_DEBUG(statement)
124 //-------- External References ---------------------------------
126 extern Widget footer_book_name;
127 extern Widget footer_page_no;
128 extern DtHelpDispAreaStruct *gHelpDisplayArea;
130 //------------ Global Variables -----------------------------
132 Widget f_print_shell = NULL;
133 Widget f_scrollbar = NULL;
134 Widget f_dialog = NULL;
135 const char *f_printOrientation = NULL;
136 Boolean print_server_error = False;
138 //------------ Private Variables -----------------------------
140 // Prefixed with an l to distinguish from f_AppPrintData in
141 // AppPrintData class.
142 AppPrintData * l_AppPrintData;
144 static WXmForm f_print_panel;
145 static WXmLabel f_selected_field;
146 static WXmLabel f_to_print_field;
147 static WXmToggleButton f_print_nodes;
148 static WXmToggleButton f_print_hierarchy;
150 static Boolean print_hierarchy; // keep track of hierarchy vs section
152 #if 0 && defined(PRINTING_SUPPORTED)
153 static void PrintEverything(AppPrintData *p);
154 static void PrintOneUASCommon(UAS_Pointer<UAS_Common> &doc, Widget pshell, int *cur_pageP);
155 #endif /* PRINTING_SUPPORTED */
157 PrintPanelAgent::PrintPanelAgent()
159 RCS_DEBUG("PrintPanelAgent constructor entered.\n");
161 l_AppPrintData = new AppPrintData();
162 cout << "overloaded PrintPanelAgenct constructor called.\n";
164 RCS_DEBUG("PrintPanelAgent constructor exiting.\n");
167 PrintPanelAgent::PrintPanelAgent(AppPrintData *p)
170 cout << "overloaded PrintPanelAgenct constructor called.\n";
173 PrintPanelAgent::~PrintPanelAgent()
175 cout << "PrintPanelAgenct destructor called.\n";
179 * ------------------------------------------------------------------------
183 * Resets the number of nodes and what to print buttons.
190 reset_ui(AppPrintData *p)
192 RCS_DEBUG("reset_ui called.\n");
194 xList<UAS_Pointer<UAS_Common> > &print_list = *(p->f_print_list);
195 Xassert (print_list.length() > 0);
197 // Set up the "Number of Nodes" labels.
198 static char buffer[24];
200 snprintf (buffer, sizeof(buffer), "%d", print_list.length());
201 f_selected_field.LabelString (WXmString (buffer));
202 f_to_print_field.LabelString (WXmString (buffer));
204 // Set up "What to print" buttons based on command line
205 // value set in Window System
207 print_hierarchy = window_system().videoShell()->hierarchy;
209 f_print_hierarchy.Set(print_hierarchy);
210 f_print_nodes.Set(!print_hierarchy);
212 Boolean hierarchy_sensitive = False;
214 List_Iterator<UAS_Pointer<UAS_Common> > l (print_list);
216 // NOTE: Could fail if toc() is NULL.
217 UAS_List<UAS_Common> kids = l.item()->children();
218 if ((!strncmp(l.item()->locator(), "mmdb:", 5)) && print_list.length() == 1 && kids.length() > 0) {
219 hierarchy_sensitive = True;
222 // If one is insensitive, the other one must be as well.
223 f_print_nodes.SetSensitive (hierarchy_sensitive);
224 f_print_hierarchy.SetSensitive (hierarchy_sensitive);
230 * ------------------------------------------------------------------------
231 * Name: customizePrintSetupBox
234 * Adds application specific items to the passed print setup box.
242 customizePrintSetupBox(AppPrintData *p)
246 Widget print_dialog = p->f_print_dialog;
247 RCS_DEBUG("customizePrintSetupBox called.\n");
249 Widget how_many_frame, how_many_form, selected_label, print_panel;
250 Widget what_frame, what_form, selected_field, to_print_field;
253 // Create the app-specific top work area
255 f_print_panel = print_panel = XtVaCreateManagedWidget("workarea",
258 XmNorientation, XmHORIZONTAL,
263 how_many_frame = XtVaCreateManagedWidget("how_many_frame",
266 XmNleftAttachment, XmATTACH_FORM,
267 XmNrightAttachment, XmATTACH_POSITION,
268 XmNtopAttachment, XmATTACH_FORM,
269 XmNrightPosition, 49,
275 label = XmStringGenerate(CATGETS(Set_AgentLabel, 205, "Number of Sections"),
276 NULL, XmCHARSET_TEXT, NULL);
278 XtVaCreateManagedWidget("how_many_title",
281 XmNchildType, XmFRAME_TITLE_CHILD,
282 XmNlabelString, label,
287 how_many_form = XtVaCreateManagedWidget("how_many_frame",
292 label = XmStringGenerate(CATGETS(Set_AgentLabel, 206, "Selected:"),
293 NULL, XmCHARSET_TEXT, NULL);
295 selected_label = XtVaCreateManagedWidget("selected_label",
298 XmNlabelString, label,
299 XmNtopAttachment, XmATTACH_FORM,
300 XmNleftAttachment, XmATTACH_FORM,
306 f_selected_field = selected_field = XtVaCreateManagedWidget("selected_field",
309 XmNlabelString, label,
310 XmNalignment, XmALIGNMENT_END,
311 XmNrightAttachment, XmATTACH_FORM,
313 XmNtopAttachment, XmATTACH_FORM,
317 label = XmStringGenerate(CATGETS(Set_AgentLabel, 207, "To Be Printed:"),
318 NULL, XmCHARSET_TEXT, NULL);
320 XtVaCreateManagedWidget("to_print_label",
323 XmNlabelString, label,
324 XmNtopAttachment, XmATTACH_WIDGET,
325 XmNtopWidget, selected_label,
326 XmNleftAttachment, XmATTACH_FORM,
327 XmNbottomAttachment, XmATTACH_FORM,
334 f_to_print_field = to_print_field = XtVaCreateManagedWidget("to_print_field",
337 XmNalignment, XmALIGNMENT_END,
338 XmNtopAttachment, XmATTACH_WIDGET,
339 XmNtopWidget, selected_field,
341 XmNrightAttachment, XmATTACH_FORM,
343 XmNbottomAttachment, XmATTACH_FORM,
349 what_frame = XtVaCreateManagedWidget("what_frame",
352 XmNleftAttachment, XmATTACH_POSITION,
354 XmNrightAttachment, XmATTACH_FORM,
355 XmNtopAttachment, XmATTACH_FORM,
360 label = XmStringGenerate(CATGETS(Set_AgentLabel, 209, "What to Print"),
361 NULL, XmCHARSET_TEXT, NULL);
363 XtVaCreateManagedWidget("what_title",
366 XmNlabelString, label,
367 XmNchildType, XmFRAME_TITLE_CHILD,
371 what_form = XtVaCreateManagedWidget("what_form",
376 label = XmStringGenerate(CATGETS(Set_AgentLabel, 210, "Sections"),
377 NULL, XmCHARSET_TEXT, NULL);
379 f_print_nodes = print_nodes = XtVaCreateManagedWidget("print_nodes",
380 xmToggleButtonWidgetClass,
382 XmNlabelString, label,
384 XmNalignment, XmALIGNMENT_BEGINNING,
385 XmNindicatorType, XmONE_OF_MANY,
386 XmNleftAttachment, XmATTACH_FORM,
387 XmNrightAttachment, XmATTACH_FORM,
388 XmNtopAttachment, XmATTACH_FORM,
394 XtAddCallback(print_nodes, XmNvalueChangedCallback, ToggleWhatCB, p);
396 label = XmStringGenerate(CATGETS(Set_AgentLabel, 211, "Hierarchy"),
397 NULL, XmCHARSET_TEXT, NULL);
399 f_print_hierarchy = XtVaCreateManagedWidget("print_hierarchy",
400 xmToggleButtonWidgetClass,
402 XmNlabelString, label,
403 XmNalignment, XmALIGNMENT_BEGINNING,
404 XmNindicatorType, XmONE_OF_MANY,
405 XmNtopAttachment, XmATTACH_WIDGET,
406 XmNtopWidget, print_nodes,
407 XmNbottomAttachment, XmATTACH_FORM,
409 XmNleftAttachment, XmATTACH_FORM,
410 XmNrightAttachment, XmATTACH_FORM,
415 XtAddCallback(f_print_hierarchy, XmNvalueChangedCallback, ToggleWhatCB, p);
419 RCS_DEBUG("customizePrintSetupBox exiting.\n");
424 * ------------------------------------------------------------------------
429 * Called when the PDM is up, or down.
433 PdmNotifyCB(Widget pr_shell, XtPointer client_data, XtPointer call_data)
435 RCS_DEBUG("PdmNotifyCB called.\n");
437 #if 0 && defined(PRINTING_SUPPORTED)
440 XmPrintShellCallbackStruct* pr_cbs =
441 (XmPrintShellCallbackStruct*) call_data;
443 if ((pr_cbs->reason == XmCR_PDM_NONE) ||
444 (pr_cbs->reason == XmCR_PDM_START_ERROR) ||
445 (pr_cbs->reason == XmCR_PDM_START_VXAUTH) ||
446 (pr_cbs->reason == XmCR_PDM_START_PXAUTH))
448 msg = CATGETS(Set_PrintPanelAgent, 12, "Print Dialog Manager error - setup failed.");
449 message_mgr().error_dialog(msg);
452 RCS_DEBUG("PdmNotifyCB exiting.\n");
453 #endif /* PRINTING_SUPPORTED */
457 * ------------------------------------------------------------------------
458 * Name: CreatePrintShell
462 * Called when the user selects the "Print" or the "Setup..." button
467 CreatePrintShell(Widget widget, AppPrintData* p)
469 RCS_DEBUG("CreatePrintShell called.\n");
471 #if 0 && defined(PRINTING_SUPPORTED)
475 * create a print_shell if none available. the print dialog callback
476 * always provides valid printer context and print display initialized:
477 * XpInitContext called, attributes set.
479 if (!p->f_print_shell) {
481 p->f_print_shell = XmPrintSetup(widget,
482 XpGetScreenOfContext(p->f_print_data->print_display,
483 p->f_print_data->print_context),
484 (char*)"PrintShell", NULL, 0);
487 // set the global variable to this value so that the create_ui function in
488 // NodePrintAgent will know what to parent it's form to
489 f_print_shell = p->f_print_shell;
491 // set the print display in the window manager so the fontcache can connect
492 // to the correct display
493 window_system().setPrintDisplay(f_print_shell);
495 // XtAddCallback(p->f_print_shell, XmNpageSetupCallback, PageSetupCB, (XtPointer)p);
496 XtAddCallback(p->f_print_shell, XmNpdmNotificationCallback, PdmNotifyCB, (XtPointer)p);
498 // set default print medium if specified on command line
500 if (window_system().videoShell()->paper_size != NULL) {
501 snprintf(buf, sizeof(buf), "*default-medium: %s\n",
502 window_system().videoShell()->paper_size);
504 p->f_print_data->print_display,
505 p->f_print_data->print_context,
512 #endif /* PRINTING_SUPPORTED */
513 RCS_DEBUG("CreatePrintShell exiting.\n");
518 * ------------------------------------------------------------------------
523 * Called when the user presses the setup box "Setup..." button.
527 PrintSetupCB(Widget print_dialog, XtPointer client_data, XtPointer call_data)
529 RCS_DEBUG("PrintSetupCB called.\n");
531 #if 0 && defined(PRINTING_SUPPORTED)
534 AppPrintData *p = (AppPrintData*)client_data;
535 DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct*)call_data;
537 // copy the setup data into our space
539 if (p->f_print_data->print_display != NULL)
540 DtPrintFreeSetupData(p->f_print_data);
541 DtPrintCopySetupData(p->f_print_data, pbs->print_data);
543 // create a print shell if not already done
545 CreatePrintShell(print_dialog, p);
548 if (XmPrintPopupPDM(p->f_print_shell, print_dialog)
549 != XmPDM_NOTIFY_SUCCESS) {
550 /* post a message error dialog */
551 msg = CATGETS(Set_PrintPanelAgent, 6, "Unable to display the Print Dialog Manager");
552 message_mgr().error_dialog(msg);
553 RCS_DEBUG("XmPrintPopupPDM failed\n");
556 // Free the setup data - use fresh data when Print button pressed.
557 DtPrintFreeSetupData(p->f_print_data);
559 #endif /* PRINTING_SUPPORTED */
560 RCS_DEBUG("PrintSetupCB exiting.\n");
564 * ------------------------------------------------------------------------
569 * Called when the user cancels out of the Print Setup dialog.
570 * If gui-less printing, causes the program to exit.
574 CancelCB(Widget print_dialog, XtPointer client_data, XtPointer call_data)
577 // if gui-less command line printing, exit now that job is canceled
579 if (window_system().videoShell()->print_only) {
586 * ------------------------------------------------------------------------
587 * Name: CreatePrintSetup
591 * Creates a DtPrintSetupBox dialog.
595 CreatePrintSetup(Widget parent, AppPrintData* p)
597 RCS_DEBUG("CreatePrintSetup called.\n");
599 // Only create one PrintSetupBox
601 if (p->f_print_dialog == NULL)
606 // resources common to silent and noisy printing cases
608 XtSetArg(args[n], (char*)DtNcopies, window_system().videoShell()->copies); n++;
610 // set print to file if file name given
611 if ((char *)window_system().videoShell()->file_name != NULL) {
612 XtSetArg(args[n], (char*)DtNfileName, (char *)window_system().videoShell()->file_name); n++;
613 XtSetArg(args[n], (char*)DtNprintDestination, DtPRINT_TO_FILE); n++;
617 if ((char *)window_system().videoShell()->printer != NULL) {
618 XtSetArg(args[n], (char*)DtNprinterName, (char *)window_system().videoShell()->printer); n++;
621 // if silent printing we won't need a dialog
623 if (window_system().videoShell()->silent) {
625 // if parent widget is an application shell, use it, otherwise use
628 if (XtIsApplicationShell(parent)) {
630 DtCreatePrintSetupBox(parent, (char*)"PrintSetup", args, n);
634 DtCreatePrintSetupBox(XtParent(parent), (char*)"PrintSetup", args, n);
638 // not silent printing so we will need a dialog
642 // additional dialog resources
644 XmString title = XmStringCreateLocalized(
645 CATGETS(Set_PrintPanelAgent, 1, "Dtinfo: Print"));
647 XtSetArg(args[n], XmNdialogTitle, title); n++;
648 XtSetArg(args[n], (char*)DtNworkAreaLocation, DtWORK_AREA_BOTTOM); n++;
650 // if parent widget is an application shell, use it, otherwise use
653 if (XtIsApplicationShell(parent)) {
655 DtCreatePrintSetupDialog(parent, (char*)"PrintSetup", args, n);
659 DtCreatePrintSetupDialog(XtParent(parent), (char*)"PrintSetup", args, n);
661 // XmStringFree(title);
664 // customize the print setup box
666 customizePrintSetupBox(p);
670 XtAddCallback(p->f_print_dialog, DtNclosePrintDisplayCallback, PrintCloseDisplayCB,
673 XtAddCallback(p->f_print_dialog, DtNsetupCallback,
677 XtAddCallback(p->f_print_dialog, DtNprintCallback, PrintCB, (XtPointer)p);
678 XtAddCallback(p->f_print_dialog, DtNcancelCallback, CancelCB, (XtPointer)p);
680 // add context help for dialog
682 help_agent().add_activate_help(p->f_print_dialog, (char*)"print_panel_help");
685 // update message area
688 RCS_DEBUG("CreatePrintSetup exiting.\n");
693 * ------------------------------------------------------------------------
698 * Called when the user presses the setup box "Print" button.
702 PrintCB(Widget print_dialog, XtPointer client_data, XtPointer call_data)
704 RCS_DEBUG("PrintCB called.\n");
706 AppPrintData *p = (AppPrintData*)client_data;
707 DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct*)call_data;
710 * get the new printer data from the DtPrintSetupBox, and copy it
711 * into our AppPrint data
713 if (p->f_print_data->print_display != NULL)
714 DtPrintFreeSetupData(p->f_print_data);
715 DtPrintCopySetupData(p->f_print_data, pbs->print_data);
717 DoPrint(print_dialog, p);
719 RCS_DEBUG("PrintCB exiting.\n");
723 * ------------------------------------------------------------------------
728 * Called when the user hits "Print" quick button.
729 * not sure of this functions role in the "new order" ???? rCs
732 QuickPrintCB(Widget pr_button, XtPointer client_data, XtPointer call_data)
734 RCS_DEBUG("QuickPrintCB called.\n");
736 AppPrintData *p = (AppPrintData*)client_data;
738 CreatePrintSetup(pr_button, p);
741 // check if the DtPrintSetupBox ("Print...") has been called yet
743 if(p->f_print_data->print_display == (Display*)NULL)
746 // first time thru print setup, so get default data
748 if (DtPrintFillSetupData(p->f_print_dialog, p->f_print_data)
749 != DtPRINT_SUCCESS) {
750 // NOTE: DtPrintFillSetupData() already posts an error
751 // dialog on failure - no need to post our own.
752 RCS_DEBUG("DtPrintFillSetupData failed\n");
757 DoPrint(pr_button, p) ;
759 RCS_DEBUG("QuickPrintCB exiting.\n");
764 * ------------------------------------------------------------------------
765 * Name: FinishPrintToFile
769 * App-specific print data holder allocate function.
772 #if 0 && defined(PRINTING_SUPPORTED)
774 FinishPrintToFile(Display *display,
775 XPGetDocStatus status,
776 XPointer client_data)
780 RCS_DEBUG("FinishPrintToFile called.\n");
783 if (status != XPGetDocFinished) {
785 msg = CATGETS(Set_PrintPanelAgent, 8, "Error printing to file");
786 message_mgr().error_dialog(msg);
788 RCS_DEBUG("Something went wrong with XmPrintToFile...\n");
792 msg = CATGETS(Set_PrintPanelAgent, 9, "Print to file completed.");
793 message_mgr().info_dialog(msg);
795 RCS_DEBUG("XmPrintToFile completed OK\n");
797 RCS_DEBUG("FinishPrintToFile exiting.\n");
802 #endif /* PRINTING_SUPPORTED */
805 * ------------------------------------------------------------------------
810 * Routine used from the "Print" button and from the OK button of the
815 DoPrint(Widget widget, AppPrintData * p)
817 #if 0 && defined(PRINTING_SUPPORTED)
818 int save_data = XPSpool;
821 xList<UAS_Pointer<UAS_Common> > &print_list = *(p->f_print_list);
822 Xassert (print_list.length() > 0);
824 #endif /* PRINTING_SUPPORTED */
826 RCS_DEBUG("DoPrint called.\n");
828 #if 0 && defined(PRINTING_SUPPORTED)
829 // create print shell, if not done yet
830 CreatePrintShell(widget, p);
832 if (p->f_print_data->destination == DtPRINT_TO_FILE)
834 save_data = XPGetData;
837 // start job must precede XpGetDocumentData in XmPrintToFile
839 XpStartJob(XtDisplay(p->f_print_shell), save_data);
841 // maintain the sequence
842 // between startjob and getdocument
844 XFlush(XtDisplay(p->f_print_shell));
846 // setup print to file
848 if (p->f_print_data->destination == DtPRINT_TO_FILE)
850 if (!XmPrintToFile(XtDisplay(p->f_print_shell),
851 p->f_print_data->dest_info,
852 (XPFinishProc)FinishPrintToFile,
855 // Add real error message here.
856 // printf("XmPrintToFile: Unable to print to file %s\n",
857 // p->print_data->dest_info);
859 XpCancelJob(XtDisplay(p->f_print_shell), False);
861 // we can go back to the event loop as if we had never printed
866 if (!(window_system().videoShell()->silent)) {
868 XtRealizeWidget(p->f_print_shell);
869 XtPopup(p->f_print_shell, XtGrabNone);
874 XpEndJob(XtDisplay(p->f_print_shell));
876 // synch the print display (i am hoping this will get
877 // the xlib error handler called, if need be
879 XSync(XtDisplay(p->f_print_shell), False);
881 // if a print server error occurred then notify the user
883 if (print_server_error) {
885 print_server_error = False; // reset for next time
887 // Post an error dialog
889 msg = CATGETS(Set_PrintPanelAgent,
891 "Print Job Failed.\n\nThe X Print Server is Temporarily Out of Resources.");
892 message_mgr().error_dialog(msg);
896 if (!(window_system().videoShell()->silent)) {
897 XtPopdown(p->f_print_shell);
900 // if we are in print only mode flush the output
901 // buffer to force the print and then exit
903 if (window_system().videoShell()->print_only) {
905 XSync(XtDisplay(p->f_print_shell), False);
907 // call this function to avoid invoking destructors
911 // have the print manager destroy the print agent
912 // used to print this job
914 print_mgr().destroy_agent();
916 // destroy print shell as well
918 if (p->f_print_shell)
920 XtDestroyWidget(p->f_print_shell);
921 p->f_print_shell = (Widget)NULL ;
922 f_print_shell = (Widget)NULL ;
926 #endif /* PRINTING_SUPPORTED */
927 RCS_DEBUG("DoPrint exiting.\n");
931 #if 0 && defined(PRINTING_SUPPORTED)
933 * ------------------------------------------------------------------------
934 * Name: PrintEverything
938 * Called when the print shell receives the XP events. Contains the
939 * logic for printing all topics.
943 PrintEverything(AppPrintData *p)
947 RCS_DEBUG("PrintEverything called.\n");
949 xList<UAS_Pointer<UAS_Common> > &print_list = *(p->f_print_list);
950 Xassert (print_list.length() > 0);
953 Widget pshell = p->f_print_shell;
955 List_Iterator<UAS_Pointer<UAS_Common> > l (print_list);
959 PrintOneUASCommon(l.item(), pshell, &cur_page);
963 RCS_DEBUG("PrintEverything exiting.\n");
967 PrintOneUASCommon(UAS_Pointer<UAS_Common> &doc, Widget pshell, int *cur_pageP)
974 // Retrieve the topic from the doc
975 // The retrieve function will send a UAS_DocumentRetrievedMsg to the
976 // print manager which will render the canvas with the appropriate topic
978 doc->retrieve((void *)1);
980 // set print orientation to either landscape or portrait (if set)
982 #if 0 && defined(PRINTING_SUPPORTED)
983 if (f_printOrientation != NULL) {
984 snprintf(buf, sizeof(buf),
985 "*content-orientation: %s\n", f_printOrientation);
986 XpSetAttributes(XtDisplay(pshell), XpGetContext(XtDisplay(pshell)),
987 XPPageAttr, buf, XPAttrMerge);
989 #endif /* PRINTING_SUPPORTED */
991 for (gHelpDisplayArea->firstVisible = gHelpDisplayArea->nextNonVisible = 0;
992 gHelpDisplayArea->nextNonVisible >= 0;
993 gHelpDisplayArea->firstVisible = gHelpDisplayArea->nextNonVisible + 1)
997 #if 0 && defined(PRINTING_SUPPORTED)
998 XpStartPage(XtDisplay(pshell), XtWindow(pshell));
999 #endif /* PRINTING_SUPPORTED */
1001 snprintf(buf, sizeof(buf), "%d", *cur_pageP);
1002 label = XmStringCreateLocalized(buf);
1005 XtSetArg(args[n], XmNlabelString, label); n++;
1006 XtSetValues(footer_page_no, args, n);
1007 XmStringFree(label);
1009 // Process exposures so label is updated.
1010 XmUpdateDisplay(footer_page_no);
1012 // _DtHelpCleanAndDrawWholeCanvas((XtPointer)gHelpDisplayArea);
1014 #if 0 && defined(PRINTING_SUPPORTED)
1015 XpEndPage(XtDisplay(pshell));
1016 #endif /* PRINTING_SUPPORTED */
1019 // Print chidren if appropriate
1020 if (print_hierarchy)
1023 UAS_List<UAS_Common> kids = doc->children();
1025 for (i = 0; i < kids.length(); i++)
1027 PrintOneUASCommon(kids[i], pshell, cur_pageP);
1031 #endif /* PRINTING_SUPPORTED */
1034 * ------------------------------------------------------------------------
1035 * Name: PrintCloseDisplayCB
1039 * Called when the print setup box is about to close the print
1040 * display (in response to a new printer on a different display, or
1041 * when the setup box is destroyed).
1044 PrintCloseDisplayCB(
1046 XtPointer client_data,
1047 XtPointer call_data)
1049 RCS_DEBUG("PrintCloseDisplayCB called.\n");
1051 AppPrintData *p = (AppPrintData*)client_data;
1053 if (p->f_print_shell)
1055 XtDestroyWidget(p->f_print_shell);
1056 p->f_print_shell = (Widget)NULL ;
1057 f_print_shell = (Widget)NULL ;
1061 DtPrintFreeSetupData(p->f_print_data);
1063 // reset gHelpDisplayArea so that it will be recreated.
1064 // ??? should i also destroy the canvas here?
1065 gHelpDisplayArea = 0;
1067 RCS_DEBUG("PrintCloseDisplayCB exiting.\n");
1072 // /////////////////////////////////////////////////////////////////
1074 // /////////////////////////////////////////////////////////////////
1079 XtPointer client_data,
1080 XtPointer call_data)
1082 RCS_DEBUG("ToggleWhatCB called.\n");
1084 AppPrintData * p = (AppPrintData *)client_data;
1086 xList<UAS_Pointer<UAS_Common> > &print_list = *(p->f_print_list);
1088 static char buffer[24];
1089 WXmToggleButton other (NULL), active(widget);
1091 ON_DEBUG (printf ("PrintPanel::ToggleWhatCB (%p)\n", widget));
1093 Xassert ( (widget == (Widget)f_print_nodes) || (widget == (Widget)f_print_hierarchy));
1095 // Figure out which one is the other one (ie: not clicked on).
1096 if (active == f_print_nodes)
1098 other = f_print_hierarchy;
1102 other = f_print_nodes;
1108 if (active == f_print_nodes)
1110 snprintf (buffer, sizeof(buffer), "%d", print_list.length());
1111 print_hierarchy = False;
1113 else // active == f_print_hierarchy
1115 List_Iterator<UAS_Pointer<UAS_Common> > l (print_list);
1116 int subtree_size = l.item()->subtree_size ();
1118 if (subtree_size != 0)
1120 snprintf (buffer, sizeof(buffer), "%d", subtree_size);
1124 *((char *) memcpy(buffer, "?", 1) + 1) = '\0';
1126 print_hierarchy = True;
1133 f_to_print_field.LabelString (WXmString (buffer));
1135 RCS_DEBUG("ToggleWhatCBB exiting.\n");