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 #endif /* PRINTING_SUPPORTED */
156 static void PrintOneUASCommon(UAS_Pointer<UAS_Common> &doc, Widget pshell, int *cur_pageP);
158 PrintPanelAgent::PrintPanelAgent()
160 RCS_DEBUG("PrintPanelAgent constructor entered.\n");
162 l_AppPrintData = new AppPrintData();
163 cout << "overloaded PrintPanelAgenct constructor called.\n";
165 RCS_DEBUG("PrintPanelAgent constructor exiting.\n");
168 PrintPanelAgent::PrintPanelAgent(AppPrintData *p)
171 cout << "overloaded PrintPanelAgenct constructor called.\n";
174 PrintPanelAgent::~PrintPanelAgent()
176 cout << "PrintPanelAgenct destructor called.\n";
180 * ------------------------------------------------------------------------
184 * Resets the number of nodes and what to print buttons.
191 reset_ui(AppPrintData *p)
193 RCS_DEBUG("reset_ui called.\n");
195 xList<UAS_Pointer<UAS_Common> > &print_list = *(p->f_print_list);
196 Xassert (print_list.length() > 0);
198 // Set up the "Number of Nodes" labels.
199 static char buffer[24];
201 snprintf (buffer, sizeof(buffer), "%d", print_list.length());
202 f_selected_field.LabelString (WXmString (buffer));
203 f_to_print_field.LabelString (WXmString (buffer));
205 // Set up "What to print" buttons based on command line
206 // value set in Window System
208 print_hierarchy = window_system().videoShell()->hierarchy;
210 f_print_hierarchy.Set(print_hierarchy);
211 f_print_nodes.Set(!print_hierarchy);
213 Boolean hierarchy_sensitive = False;
215 List_Iterator<UAS_Pointer<UAS_Common> > l (print_list);
217 // NOTE: Could fail if toc() is NULL.
218 UAS_List<UAS_Common> kids = l.item()->children();
219 if ((!strncmp(l.item()->locator(), "mmdb:", 5)) && print_list.length() == 1 && kids.length() > 0) {
220 hierarchy_sensitive = True;
223 // If one is insensitive, the other one must be as well.
224 f_print_nodes.SetSensitive (hierarchy_sensitive);
225 f_print_hierarchy.SetSensitive (hierarchy_sensitive);
231 * ------------------------------------------------------------------------
232 * Name: customizePrintSetupBox
235 * Adds application specific items to the passed print setup box.
243 customizePrintSetupBox(AppPrintData *p)
247 Widget print_dialog = p->f_print_dialog;
248 RCS_DEBUG("customizePrintSetupBox called.\n");
250 Widget how_many_frame, how_many_form, selected_label, print_panel;
251 Widget what_frame, what_form, selected_field, to_print_field;
254 // Create the app-specific top work area
256 f_print_panel = print_panel = XtVaCreateManagedWidget("workarea",
259 XmNorientation, XmHORIZONTAL,
264 how_many_frame = XtVaCreateManagedWidget("how_many_frame",
267 XmNleftAttachment, XmATTACH_FORM,
268 XmNrightAttachment, XmATTACH_POSITION,
269 XmNtopAttachment, XmATTACH_FORM,
270 XmNrightPosition, 49,
276 label = XmStringGenerate(CATGETS(Set_AgentLabel, 205, "Number of Sections"),
277 NULL, XmCHARSET_TEXT, NULL);
279 XtVaCreateManagedWidget("how_many_title",
282 XmNchildType, XmFRAME_TITLE_CHILD,
283 XmNlabelString, label,
288 how_many_form = XtVaCreateManagedWidget("how_many_frame",
293 label = XmStringGenerate(CATGETS(Set_AgentLabel, 206, "Selected:"),
294 NULL, XmCHARSET_TEXT, NULL);
296 selected_label = XtVaCreateManagedWidget("selected_label",
299 XmNlabelString, label,
300 XmNtopAttachment, XmATTACH_FORM,
301 XmNleftAttachment, XmATTACH_FORM,
307 f_selected_field = selected_field = XtVaCreateManagedWidget("selected_field",
310 XmNlabelString, label,
311 XmNalignment, XmALIGNMENT_END,
312 XmNrightAttachment, XmATTACH_FORM,
314 XmNtopAttachment, XmATTACH_FORM,
318 label = XmStringGenerate(CATGETS(Set_AgentLabel, 207, "To Be Printed:"),
319 NULL, XmCHARSET_TEXT, NULL);
321 XtVaCreateManagedWidget("to_print_label",
324 XmNlabelString, label,
325 XmNtopAttachment, XmATTACH_WIDGET,
326 XmNtopWidget, selected_label,
327 XmNleftAttachment, XmATTACH_FORM,
328 XmNbottomAttachment, XmATTACH_FORM,
335 f_to_print_field = to_print_field = XtVaCreateManagedWidget("to_print_field",
338 XmNalignment, XmALIGNMENT_END,
339 XmNtopAttachment, XmATTACH_WIDGET,
340 XmNtopWidget, selected_field,
342 XmNrightAttachment, XmATTACH_FORM,
344 XmNbottomAttachment, XmATTACH_FORM,
350 what_frame = XtVaCreateManagedWidget("what_frame",
353 XmNleftAttachment, XmATTACH_POSITION,
355 XmNrightAttachment, XmATTACH_FORM,
356 XmNtopAttachment, XmATTACH_FORM,
361 label = XmStringGenerate(CATGETS(Set_AgentLabel, 209, "What to Print"),
362 NULL, XmCHARSET_TEXT, NULL);
364 XtVaCreateManagedWidget("what_title",
367 XmNlabelString, label,
368 XmNchildType, XmFRAME_TITLE_CHILD,
372 what_form = XtVaCreateManagedWidget("what_form",
377 label = XmStringGenerate(CATGETS(Set_AgentLabel, 210, "Sections"),
378 NULL, XmCHARSET_TEXT, NULL);
380 f_print_nodes = print_nodes = XtVaCreateManagedWidget("print_nodes",
381 xmToggleButtonWidgetClass,
383 XmNlabelString, label,
385 XmNalignment, XmALIGNMENT_BEGINNING,
386 XmNindicatorType, XmONE_OF_MANY,
387 XmNleftAttachment, XmATTACH_FORM,
388 XmNrightAttachment, XmATTACH_FORM,
389 XmNtopAttachment, XmATTACH_FORM,
395 XtAddCallback(print_nodes, XmNvalueChangedCallback, ToggleWhatCB, p);
397 label = XmStringGenerate(CATGETS(Set_AgentLabel, 211, "Hierarchy"),
398 NULL, XmCHARSET_TEXT, NULL);
400 f_print_hierarchy = XtVaCreateManagedWidget("print_hierarchy",
401 xmToggleButtonWidgetClass,
403 XmNlabelString, label,
404 XmNalignment, XmALIGNMENT_BEGINNING,
405 XmNindicatorType, XmONE_OF_MANY,
406 XmNtopAttachment, XmATTACH_WIDGET,
407 XmNtopWidget, print_nodes,
408 XmNbottomAttachment, XmATTACH_FORM,
410 XmNleftAttachment, XmATTACH_FORM,
411 XmNrightAttachment, XmATTACH_FORM,
416 XtAddCallback(f_print_hierarchy, XmNvalueChangedCallback, ToggleWhatCB, p);
420 RCS_DEBUG("customizePrintSetupBox exiting.\n");
425 * ------------------------------------------------------------------------
430 * Called when the PDM is up, or down.
434 PdmNotifyCB(Widget pr_shell, XtPointer client_data, XtPointer call_data)
436 RCS_DEBUG("PdmNotifyCB called.\n");
438 #if 0 && defined(PRINTING_SUPPORTED)
441 XmPrintShellCallbackStruct* pr_cbs =
442 (XmPrintShellCallbackStruct*) call_data;
444 if ((pr_cbs->reason == XmCR_PDM_NONE) ||
445 (pr_cbs->reason == XmCR_PDM_START_ERROR) ||
446 (pr_cbs->reason == XmCR_PDM_START_VXAUTH) ||
447 (pr_cbs->reason == XmCR_PDM_START_PXAUTH))
449 msg = CATGETS(Set_PrintPanelAgent, 12, "Print Dialog Manager error - setup failed.");
450 message_mgr().error_dialog(msg);
453 RCS_DEBUG("PdmNotifyCB exiting.\n");
454 #endif /* PRINTING_SUPPORTED */
458 * ------------------------------------------------------------------------
459 * Name: CreatePrintShell
463 * Called when the user selects the "Print" or the "Setup..." button
468 CreatePrintShell(Widget widget, AppPrintData* p)
470 RCS_DEBUG("CreatePrintShell called.\n");
472 #if 0 && defined(PRINTING_SUPPORTED)
476 * create a print_shell if none available. the print dialog callback
477 * always provides valid printer context and print display initialized:
478 * XpInitContext called, attributes set.
480 if (!p->f_print_shell) {
482 p->f_print_shell = XmPrintSetup(widget,
483 XpGetScreenOfContext(p->f_print_data->print_display,
484 p->f_print_data->print_context),
485 (char*)"PrintShell", NULL, 0);
488 // set the global variable to this value so that the create_ui function in
489 // NodePrintAgent will know what to parent it's form to
490 f_print_shell = p->f_print_shell;
492 // set the print display in the window manager so the fontcache can connect
493 // to the correct display
494 window_system().setPrintDisplay(f_print_shell);
496 // XtAddCallback(p->f_print_shell, XmNpageSetupCallback, PageSetupCB, (XtPointer)p);
497 XtAddCallback(p->f_print_shell, XmNpdmNotificationCallback, PdmNotifyCB, (XtPointer)p);
499 // set default print medium if specified on command line
501 if (window_system().videoShell()->paper_size != NULL) {
502 snprintf(buf, sizeof(buf), "*default-medium: %s\n",
503 window_system().videoShell()->paper_size);
505 p->f_print_data->print_display,
506 p->f_print_data->print_context,
513 #endif /* PRINTING_SUPPORTED */
514 RCS_DEBUG("CreatePrintShell exiting.\n");
519 * ------------------------------------------------------------------------
524 * Called when the user presses the setup box "Setup..." button.
528 PrintSetupCB(Widget print_dialog, XtPointer client_data, XtPointer call_data)
530 RCS_DEBUG("PrintSetupCB called.\n");
532 #if 0 && defined(PRINTING_SUPPORTED)
535 AppPrintData *p = (AppPrintData*)client_data;
536 DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct*)call_data;
538 // copy the setup data into our space
540 if (p->f_print_data->print_display != NULL)
541 DtPrintFreeSetupData(p->f_print_data);
542 DtPrintCopySetupData(p->f_print_data, pbs->print_data);
544 // create a print shell if not already done
546 CreatePrintShell(print_dialog, p);
549 if (XmPrintPopupPDM(p->f_print_shell, print_dialog)
550 != XmPDM_NOTIFY_SUCCESS) {
551 /* post a message error dialog */
552 msg = CATGETS(Set_PrintPanelAgent, 6, "Unable to display the Print Dialog Manager");
553 message_mgr().error_dialog(msg);
554 RCS_DEBUG("XmPrintPopupPDM failed\n");
557 // Free the setup data - use fresh data when Print button pressed.
558 DtPrintFreeSetupData(p->f_print_data);
560 #endif /* PRINTING_SUPPORTED */
561 RCS_DEBUG("PrintSetupCB exiting.\n");
565 * ------------------------------------------------------------------------
570 * Called when the user cancels out of the Print Setup dialog.
571 * If gui-less printing, causes the program to exit.
575 CancelCB(Widget print_dialog, XtPointer client_data, XtPointer call_data)
578 // if gui-less command line printing, exit now that job is canceled
580 if (window_system().videoShell()->print_only) {
587 * ------------------------------------------------------------------------
588 * Name: CreatePrintSetup
592 * Creates a DtPrintSetupBox dialog.
596 CreatePrintSetup(Widget parent, AppPrintData* p)
598 RCS_DEBUG("CreatePrintSetup called.\n");
600 // Only create one PrintSetupBox
602 if (p->f_print_dialog == NULL)
607 // resources common to silent and noisy printing cases
609 XtSetArg(args[n], (char*)DtNcopies, window_system().videoShell()->copies); n++;
611 // set print to file if file name given
612 if ((char *)window_system().videoShell()->file_name != NULL) {
613 XtSetArg(args[n], (char*)DtNfileName, (char *)window_system().videoShell()->file_name); n++;
614 XtSetArg(args[n], (char*)DtNprintDestination, DtPRINT_TO_FILE); n++;
618 if ((char *)window_system().videoShell()->printer != NULL) {
619 XtSetArg(args[n], (char*)DtNprinterName, (char *)window_system().videoShell()->printer); n++;
622 // if silent printing we won't need a dialog
624 if (window_system().videoShell()->silent) {
626 // if parent widget is an application shell, use it, otherwise use
629 if (XtIsApplicationShell(parent)) {
631 DtCreatePrintSetupBox(parent, (char*)"PrintSetup", args, n);
635 DtCreatePrintSetupBox(XtParent(parent), (char*)"PrintSetup", args, n);
639 // not silent printing so we will need a dialog
643 // additional dialog resources
645 XmString title = XmStringCreateLocalized(
646 CATGETS(Set_PrintPanelAgent, 1, "Dtinfo: Print"));
648 XtSetArg(args[n], XmNdialogTitle, title); n++;
649 XtSetArg(args[n], (char*)DtNworkAreaLocation, DtWORK_AREA_BOTTOM); n++;
651 // if parent widget is an application shell, use it, otherwise use
654 if (XtIsApplicationShell(parent)) {
656 DtCreatePrintSetupDialog(parent, (char*)"PrintSetup", args, n);
660 DtCreatePrintSetupDialog(XtParent(parent), (char*)"PrintSetup", args, n);
662 // XmStringFree(title);
665 // customize the print setup box
667 customizePrintSetupBox(p);
671 XtAddCallback(p->f_print_dialog, DtNclosePrintDisplayCallback, PrintCloseDisplayCB,
674 XtAddCallback(p->f_print_dialog, DtNsetupCallback,
678 XtAddCallback(p->f_print_dialog, DtNprintCallback, PrintCB, (XtPointer)p);
679 XtAddCallback(p->f_print_dialog, DtNcancelCallback, CancelCB, (XtPointer)p);
681 // add context help for dialog
683 help_agent().add_activate_help(p->f_print_dialog, (char*)"print_panel_help");
686 // update message area
689 RCS_DEBUG("CreatePrintSetup exiting.\n");
694 * ------------------------------------------------------------------------
699 * Called when the user presses the setup box "Print" button.
703 PrintCB(Widget print_dialog, XtPointer client_data, XtPointer call_data)
705 RCS_DEBUG("PrintCB called.\n");
707 AppPrintData *p = (AppPrintData*)client_data;
708 DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct*)call_data;
711 * get the new printer data from the DtPrintSetupBox, and copy it
712 * into our AppPrint data
714 if (p->f_print_data->print_display != NULL)
715 DtPrintFreeSetupData(p->f_print_data);
716 DtPrintCopySetupData(p->f_print_data, pbs->print_data);
718 DoPrint(print_dialog, p);
720 RCS_DEBUG("PrintCB exiting.\n");
724 * ------------------------------------------------------------------------
729 * Called when the user hits "Print" quick button.
730 * not sure of this functions role in the "new order" ???? rCs
733 QuickPrintCB(Widget pr_button, XtPointer client_data, XtPointer call_data)
735 RCS_DEBUG("QuickPrintCB called.\n");
737 AppPrintData *p = (AppPrintData*)client_data;
739 CreatePrintSetup(pr_button, p);
742 // check if the DtPrintSetupBox ("Print...") has been called yet
744 if(p->f_print_data->print_display == (Display*)NULL)
747 // first time thru print setup, so get default data
749 if (DtPrintFillSetupData(p->f_print_dialog, p->f_print_data)
750 != DtPRINT_SUCCESS) {
751 // NOTE: DtPrintFillSetupData() already posts an error
752 // dialog on failure - no need to post our own.
753 RCS_DEBUG("DtPrintFillSetupData failed\n");
758 DoPrint(pr_button, p) ;
760 RCS_DEBUG("QuickPrintCB exiting.\n");
765 * ------------------------------------------------------------------------
766 * Name: FinishPrintToFile
770 * App-specific print data holder allocate function.
773 #if 0 && defined(PRINTING_SUPPORTED)
775 FinishPrintToFile(Display *display,
776 XPGetDocStatus status,
777 XPointer client_data)
781 RCS_DEBUG("FinishPrintToFile called.\n");
784 if (status != XPGetDocFinished) {
786 msg = CATGETS(Set_PrintPanelAgent, 8, "Error printing to file");
787 message_mgr().error_dialog(msg);
789 RCS_DEBUG("Something went wrong with XmPrintToFile...\n");
793 msg = CATGETS(Set_PrintPanelAgent, 9, "Print to file completed.");
794 message_mgr().info_dialog(msg);
796 RCS_DEBUG("XmPrintToFile completed OK\n");
798 RCS_DEBUG("FinishPrintToFile exiting.\n");
803 #endif /* PRINTING_SUPPORTED */
806 * ------------------------------------------------------------------------
811 * Routine used from the "Print" button and from the OK button of the
816 DoPrint(Widget widget, AppPrintData * p)
818 #if 0 && defined(PRINTING_SUPPORTED)
819 int save_data = XPSpool;
822 xList<UAS_Pointer<UAS_Common> > &print_list = *(p->f_print_list);
823 Xassert (print_list.length() > 0);
825 #endif /* PRINTING_SUPPORTED */
827 RCS_DEBUG("DoPrint called.\n");
829 #if 0 && defined(PRINTING_SUPPORTED)
830 // create print shell, if not done yet
831 CreatePrintShell(widget, p);
833 if (p->f_print_data->destination == DtPRINT_TO_FILE)
835 save_data = XPGetData;
838 // start job must precede XpGetDocumentData in XmPrintToFile
840 XpStartJob(XtDisplay(p->f_print_shell), save_data);
842 // maintain the sequence
843 // between startjob and getdocument
845 XFlush(XtDisplay(p->f_print_shell));
847 // setup print to file
849 if (p->f_print_data->destination == DtPRINT_TO_FILE)
851 if (!XmPrintToFile(XtDisplay(p->f_print_shell),
852 p->f_print_data->dest_info,
853 (XPFinishProc)FinishPrintToFile,
856 // Add real error message here.
857 // printf("XmPrintToFile: Unable to print to file %s\n",
858 // p->print_data->dest_info);
860 XpCancelJob(XtDisplay(p->f_print_shell), False);
862 // we can go back to the event loop as if we had never printed
867 if (!(window_system().videoShell()->silent)) {
869 XtRealizeWidget(p->f_print_shell);
870 XtPopup(p->f_print_shell, XtGrabNone);
875 XpEndJob(XtDisplay(p->f_print_shell));
877 // synch the print display (i am hoping this will get
878 // the xlib error handler called, if need be
880 XSync(XtDisplay(p->f_print_shell), False);
882 // if a print server error occurred then notify the user
884 if (print_server_error) {
886 print_server_error = False; // reset for next time
888 // Post an error dialog
890 msg = CATGETS(Set_PrintPanelAgent,
892 "Print Job Failed.\n\nThe X Print Server is Temporarily Out of Resources.");
893 message_mgr().error_dialog(msg);
897 if (!(window_system().videoShell()->silent)) {
898 XtPopdown(p->f_print_shell);
901 // if we are in print only mode flush the output
902 // buffer to force the print and then exit
904 if (window_system().videoShell()->print_only) {
906 XSync(XtDisplay(p->f_print_shell), False);
908 // call this function to avoid invoking destructors
912 // have the print manager destroy the print agent
913 // used to print this job
915 print_mgr().destroy_agent();
917 // destroy print shell as well
919 if (p->f_print_shell)
921 XtDestroyWidget(p->f_print_shell);
922 p->f_print_shell = (Widget)NULL ;
923 f_print_shell = (Widget)NULL ;
927 #endif /* PRINTING_SUPPORTED */
928 RCS_DEBUG("DoPrint exiting.\n");
932 #if 0 && defined(PRINTING_SUPPORTED)
934 * ------------------------------------------------------------------------
935 * Name: PrintEverything
939 * Called when the print shell receives the XP events. Contains the
940 * logic for printing all topics.
944 PrintEverything(AppPrintData *p)
948 RCS_DEBUG("PrintEverything called.\n");
950 xList<UAS_Pointer<UAS_Common> > &print_list = *(p->f_print_list);
951 Xassert (print_list.length() > 0);
954 Widget pshell = p->f_print_shell;
956 List_Iterator<UAS_Pointer<UAS_Common> > l (print_list);
960 PrintOneUASCommon(l.item(), pshell, &cur_page);
964 RCS_DEBUG("PrintEverything exiting.\n");
966 #endif /* PRINTING_SUPPORTED */
969 PrintOneUASCommon(UAS_Pointer<UAS_Common> &doc, Widget pshell, int *cur_pageP)
976 // Retrieve the topic from the doc
977 // The retrieve function will send a UAS_DocumentRetrievedMsg to the
978 // print manager which will render the canvas with the appropriate topic
980 doc->retrieve((void *)1);
982 // set print orientation to either landscape or portrait (if set)
984 #if 0 && defined(PRINTING_SUPPORTED)
985 if (f_printOrientation != NULL) {
986 snprintf(buf, sizeof(buf),
987 "*content-orientation: %s\n", f_printOrientation);
988 XpSetAttributes(XtDisplay(pshell), XpGetContext(XtDisplay(pshell)),
989 XPPageAttr, buf, XPAttrMerge);
991 #endif /* PRINTING_SUPPORTED */
993 for (gHelpDisplayArea->firstVisible = gHelpDisplayArea->nextNonVisible = 0;
994 gHelpDisplayArea->nextNonVisible >= 0;
995 gHelpDisplayArea->firstVisible = gHelpDisplayArea->nextNonVisible + 1)
999 #if 0 && defined(PRINTING_SUPPORTED)
1000 XpStartPage(XtDisplay(pshell), XtWindow(pshell));
1001 #endif /* PRINTING_SUPPORTED */
1003 snprintf(buf, sizeof(buf), "%d", *cur_pageP);
1004 label = XmStringCreateLocalized(buf);
1007 XtSetArg(args[n], XmNlabelString, label); n++;
1008 XtSetValues(footer_page_no, args, n);
1009 XmStringFree(label);
1011 // Process exposures so label is updated.
1012 XmUpdateDisplay(footer_page_no);
1014 // _DtHelpCleanAndDrawWholeCanvas((XtPointer)gHelpDisplayArea);
1016 #if 0 && defined(PRINTING_SUPPORTED)
1017 XpEndPage(XtDisplay(pshell));
1018 #endif /* PRINTING_SUPPORTED */
1021 // Print chidren if appropriate
1022 if (print_hierarchy)
1025 UAS_List<UAS_Common> kids = doc->children();
1027 for (i = 0; i < kids.length(); i++)
1029 PrintOneUASCommon(kids[i], pshell, cur_pageP);
1035 * ------------------------------------------------------------------------
1036 * Name: PrintCloseDisplayCB
1040 * Called when the print setup box is about to close the print
1041 * display (in response to a new printer on a different display, or
1042 * when the setup box is destroyed).
1045 PrintCloseDisplayCB(
1047 XtPointer client_data,
1048 XtPointer call_data)
1050 RCS_DEBUG("PrintCloseDisplayCB called.\n");
1052 AppPrintData *p = (AppPrintData*)client_data;
1054 if (p->f_print_shell)
1056 XtDestroyWidget(p->f_print_shell);
1057 p->f_print_shell = (Widget)NULL ;
1058 f_print_shell = (Widget)NULL ;
1062 DtPrintFreeSetupData(p->f_print_data);
1064 // reset gHelpDisplayArea so that it will be recreated.
1065 // ??? should i also destroy the canvas here?
1066 gHelpDisplayArea = 0;
1068 RCS_DEBUG("PrintCloseDisplayCB exiting.\n");
1073 // /////////////////////////////////////////////////////////////////
1075 // /////////////////////////////////////////////////////////////////
1080 XtPointer client_data,
1081 XtPointer call_data)
1083 RCS_DEBUG("ToggleWhatCB called.\n");
1085 AppPrintData * p = (AppPrintData *)client_data;
1087 xList<UAS_Pointer<UAS_Common> > &print_list = *(p->f_print_list);
1089 static char buffer[24];
1090 WXmToggleButton other (NULL), active(widget);
1092 ON_DEBUG (printf ("PrintPanel::ToggleWhatCB (%p)\n", widget));
1094 Xassert ( (widget == (Widget)f_print_nodes) || (widget == (Widget)f_print_hierarchy));
1096 // Figure out which one is the other one (ie: not clicked on).
1097 if (active == f_print_nodes)
1099 other = f_print_hierarchy;
1103 other = f_print_nodes;
1109 if (active == f_print_nodes)
1111 snprintf (buffer, sizeof(buffer), "%d", print_list.length());
1112 print_hierarchy = False;
1114 else // active == f_print_hierarchy
1116 List_Iterator<UAS_Pointer<UAS_Common> > l (print_list);
1117 int subtree_size = l.item()->subtree_size ();
1119 if (subtree_size != 0)
1121 snprintf (buffer, sizeof(buffer), "%d", subtree_size);
1125 *((char *) memcpy(buffer, "?", 1) + 1) = '\0';
1127 print_hierarchy = True;
1134 f_to_print_field.LabelString (WXmString (buffer));
1136 RCS_DEBUG("ToggleWhatCBB exiting.\n");