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
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>
102 #define CLASS PrintPanelAgent
104 #include "create_macros.hh"
106 #include <sys/types.h>
107 #include <sys/stat.h>
113 #define AM WAutoManage
114 #define WXmToggleBtn WXmToggleButton
115 #define WXmPushBtn WXmPushButton
118 # define RCS_DEBUG(statement) cerr << statement << endl
120 # define RCS_DEBUG(statement)
123 //-------- External References ---------------------------------
125 extern Widget footer_book_name;
126 extern Widget footer_page_no;
127 extern DtHelpDispAreaStruct *gHelpDisplayArea;
129 //------------ Global Variables -----------------------------
131 Widget f_print_shell = NULL;
132 Widget f_scrollbar = NULL;
133 Widget f_dialog = NULL;
134 const char *f_printOrientation = NULL;
135 Boolean print_server_error = False;
137 //------------ Private Variables -----------------------------
139 // Prefixed with an l to distinguish from f_AppPrintData in
140 // AppPrintData class.
141 AppPrintData * l_AppPrintData;
143 static WXmForm f_print_panel;
144 static WXmLabel f_selected_field;
145 static WXmLabel f_to_print_field;
146 static WXmToggleButton f_print_nodes;
147 static WXmToggleButton f_print_hierarchy;
149 static Boolean print_hierarchy; // keep track of hierarchy vs section
151 static void PrintEverything(AppPrintData *p);
152 static void PrintOneUASCommon(UAS_Pointer<UAS_Common> &doc, Widget pshell, int *cur_pageP);
154 PrintPanelAgent::PrintPanelAgent()
156 RCS_DEBUG("PrintPanelAgent constructor entered.\n");
158 l_AppPrintData = new AppPrintData();
159 cout << "overloaded PrintPanelAgenct constructor called.\n";
161 RCS_DEBUG("PrintPanelAgent constructor exiting.\n");
164 PrintPanelAgent::PrintPanelAgent(AppPrintData *p)
167 cout << "overloaded PrintPanelAgenct constructor called.\n";
170 PrintPanelAgent::~PrintPanelAgent()
172 cout << "PrintPanelAgenct destructor called.\n";
176 * ------------------------------------------------------------------------
180 * Resets the number of nodes and what to print buttons.
187 reset_ui(AppPrintData *p)
189 RCS_DEBUG("reset_ui called.\n");
191 xList<UAS_Pointer<UAS_Common> > &print_list = *(p->f_print_list);
192 Xassert (print_list.length() > 0);
194 // Set up the "Number of Nodes" labels.
195 static char buffer[24];
197 sprintf (buffer, "%d", print_list.length());
198 f_selected_field.LabelString (WXmString (buffer));
199 f_to_print_field.LabelString (WXmString (buffer));
201 // Set up "What to print" buttons based on command line
202 // value set in Window System
204 print_hierarchy = window_system().videoShell()->hierarchy;
206 f_print_hierarchy.Set(print_hierarchy);
207 f_print_nodes.Set(!print_hierarchy);
209 Boolean hierarchy_sensitive = False;
211 List_Iterator<UAS_Pointer<UAS_Common> > l (print_list);
213 // NOTE: Could fail if toc() is NULL.
214 UAS_List<UAS_Common> kids = l.item()->children();
215 if ((!strncmp(l.item()->locator(), "mmdb:", 5)) && print_list.length() == 1 && kids.length() > 0) {
216 hierarchy_sensitive = True;
219 // If one is insensitive, the other one must be as well.
220 f_print_nodes.SetSensitive (hierarchy_sensitive);
221 f_print_hierarchy.SetSensitive (hierarchy_sensitive);
227 * ------------------------------------------------------------------------
228 * Name: customizePrintSetupBox
231 * Adds application specific items to the passed print setup box.
239 customizePrintSetupBox(AppPrintData *p)
243 Widget print_dialog = p->f_print_dialog;
244 RCS_DEBUG("customizePrintSetupBox called.\n");
246 Widget row, how_many_frame, how_many_title, how_many_form, selected_label, print_panel;
247 Widget to_print_label, what_frame, what_title, what_form, selected_field, to_print_field;
250 // Create the app-specific top work area
252 f_print_panel = print_panel = XtVaCreateManagedWidget("workarea",
255 XmNorientation, XmHORIZONTAL,
260 how_many_frame = XtVaCreateManagedWidget("how_many_frame",
263 XmNleftAttachment, XmATTACH_FORM,
264 XmNrightAttachment, XmATTACH_POSITION,
265 XmNtopAttachment, XmATTACH_FORM,
266 XmNrightPosition, 49,
272 label = XmStringGenerate(CATGETS(Set_AgentLabel, 205, "Number of Sections"),
273 NULL, XmCHARSET_TEXT, NULL);
275 how_many_title = XtVaCreateManagedWidget("how_many_title",
278 XmNchildType, XmFRAME_TITLE_CHILD,
279 XmNlabelString, label,
284 how_many_form = XtVaCreateManagedWidget("how_many_frame",
289 label = XmStringGenerate(CATGETS(Set_AgentLabel, 206, "Selected:"),
290 NULL, XmCHARSET_TEXT, NULL);
292 selected_label = XtVaCreateManagedWidget("selected_label",
295 XmNlabelString, label,
296 XmNtopAttachment, XmATTACH_FORM,
297 XmNleftAttachment, XmATTACH_FORM,
303 f_selected_field = selected_field = XtVaCreateManagedWidget("selected_field",
306 XmNlabelString, label,
307 XmNalignment, XmALIGNMENT_END,
308 XmNrightAttachment, XmATTACH_FORM,
310 XmNtopAttachment, XmATTACH_FORM,
314 label = XmStringGenerate(CATGETS(Set_AgentLabel, 207, "To Be Printed:"),
315 NULL, XmCHARSET_TEXT, NULL);
317 to_print_label = XtVaCreateManagedWidget("to_print_label",
320 XmNlabelString, label,
321 XmNtopAttachment, XmATTACH_WIDGET,
322 XmNtopWidget, selected_label,
323 XmNleftAttachment, XmATTACH_FORM,
324 XmNbottomAttachment, XmATTACH_FORM,
331 f_to_print_field = to_print_field = XtVaCreateManagedWidget("to_print_field",
334 XmNalignment, XmALIGNMENT_END,
335 XmNtopAttachment, XmATTACH_WIDGET,
336 XmNtopWidget, selected_field,
338 XmNrightAttachment, XmATTACH_FORM,
340 XmNbottomAttachment, XmATTACH_FORM,
346 what_frame = XtVaCreateManagedWidget("what_frame",
349 XmNleftAttachment, XmATTACH_POSITION,
351 XmNrightAttachment, XmATTACH_FORM,
352 XmNtopAttachment, XmATTACH_FORM,
357 label = XmStringGenerate(CATGETS(Set_AgentLabel, 209, "What to Print"),
358 NULL, XmCHARSET_TEXT, NULL);
360 what_title = XtVaCreateManagedWidget("what_title",
363 XmNlabelString, label,
364 XmNchildType, XmFRAME_TITLE_CHILD,
368 what_form = XtVaCreateManagedWidget("what_form",
373 label = XmStringGenerate(CATGETS(Set_AgentLabel, 210, "Sections"),
374 NULL, XmCHARSET_TEXT, NULL);
376 f_print_nodes = print_nodes = XtVaCreateManagedWidget("print_nodes",
377 xmToggleButtonWidgetClass,
379 XmNlabelString, label,
381 XmNalignment, XmALIGNMENT_BEGINNING,
382 XmNindicatorType, XmONE_OF_MANY,
383 XmNleftAttachment, XmATTACH_FORM,
384 XmNrightAttachment, XmATTACH_FORM,
385 XmNtopAttachment, XmATTACH_FORM,
391 XtAddCallback(print_nodes, XmNvalueChangedCallback, ToggleWhatCB, p);
393 label = XmStringGenerate(CATGETS(Set_AgentLabel, 211, "Hierarchy"),
394 NULL, XmCHARSET_TEXT, NULL);
396 f_print_hierarchy = XtVaCreateManagedWidget("print_hierarchy",
397 xmToggleButtonWidgetClass,
399 XmNlabelString, label,
400 XmNalignment, XmALIGNMENT_BEGINNING,
401 XmNindicatorType, XmONE_OF_MANY,
402 XmNtopAttachment, XmATTACH_WIDGET,
403 XmNtopWidget, print_nodes,
404 XmNbottomAttachment, XmATTACH_FORM,
406 XmNleftAttachment, XmATTACH_FORM,
407 XmNrightAttachment, XmATTACH_FORM,
412 XtAddCallback(f_print_hierarchy, XmNvalueChangedCallback, ToggleWhatCB, p);
416 RCS_DEBUG("customizePrintSetupBox exiting.\n");
421 * ------------------------------------------------------------------------
426 * Called when the PDM is up, or down.
430 PdmNotifyCB(Widget pr_shell, XtPointer client_data, XtPointer call_data)
432 RCS_DEBUG("PdmNotifyCB called.\n");
435 XmPrintShellCallbackStruct* pr_cbs =
436 (XmPrintShellCallbackStruct*) call_data;
437 AppPrintData * p = (AppPrintData *) client_data ;
439 if ((pr_cbs->reason == XmCR_PDM_NONE) ||
440 (pr_cbs->reason == XmCR_PDM_START_ERROR) ||
441 (pr_cbs->reason == XmCR_PDM_START_VXAUTH) ||
442 (pr_cbs->reason == XmCR_PDM_START_PXAUTH))
444 msg = CATGETS(Set_PrintPanelAgent, 12, "Print Dialog Manager error - setup failed.");
445 message_mgr().error_dialog(msg);
448 RCS_DEBUG("PdmNotifyCB exiting.\n");
453 * ------------------------------------------------------------------------
454 * Name: CreatePrintShell
458 * Called when the user selects the "Print" or the "Setup..." button
463 CreatePrintShell(Widget widget, AppPrintData* p)
467 RCS_DEBUG("CreatePrintShell called.\n");
470 * create a print_shell if none available. the print dialog callback
471 * always provides valid printer context and print display initialized:
472 * XpInitContext called, attributes set.
474 if (!p->f_print_shell) {
476 p->f_print_shell = XmPrintSetup(widget,
477 XpGetScreenOfContext(p->f_print_data->print_display,
478 p->f_print_data->print_context),
479 "PrintShell", NULL, 0);
482 // set the global variable to this value so that the create_ui function in
483 // NodePrintAgent will know what to parent it's form to
484 f_print_shell = p->f_print_shell;
486 // set the print display in the window manager so the fontcache can connect
487 // to the correct display
488 window_system().setPrintDisplay(f_print_shell);
490 // XtAddCallback(p->f_print_shell, XmNpageSetupCallback, PageSetupCB, (XtPointer)p);
491 XtAddCallback(p->f_print_shell, XmNpdmNotificationCallback, PdmNotifyCB, (XtPointer)p);
493 // set default print medium if specified on command line
495 if (window_system().videoShell()->paper_size != NULL) {
496 sprintf(buf, "*default-medium: %s\n", window_system().videoShell()->paper_size);
498 p->f_print_data->print_display,
499 p->f_print_data->print_context,
507 RCS_DEBUG("CreatePrintShell exiting.\n");
512 * ------------------------------------------------------------------------
517 * Called when the user presses the setup box "Setup..." button.
521 PrintSetupCB(Widget print_dialog, XtPointer client_data, XtPointer call_data)
525 RCS_DEBUG("PrintSetupCB called.\n");
528 AppPrintData *p = (AppPrintData*)client_data;
529 DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct*)call_data;
531 // copy the setup data into our space
533 if (p->f_print_data->print_display != NULL)
534 DtPrintFreeSetupData(p->f_print_data);
535 DtPrintCopySetupData(p->f_print_data, pbs->print_data);
537 // create a print shell if not already done
539 CreatePrintShell(print_dialog, p);
542 if (XmPrintPopupPDM(p->f_print_shell, print_dialog)
543 != XmPDM_NOTIFY_SUCCESS) {
544 /* post a message error dialog */
545 msg = CATGETS(Set_PrintPanelAgent, 6, "Unable to display the Print Dialog Manager");
546 message_mgr().error_dialog(msg);
547 RCS_DEBUG("XmPrintPopupPDM failed\n");
550 // Free the setup data - use fresh data when Print button pressed.
551 DtPrintFreeSetupData(p->f_print_data);
553 RCS_DEBUG("PrintSetupCB exiting.\n");
557 * ------------------------------------------------------------------------
562 * Called when the user cancels out of the Print Setup dialog.
563 * If gui-less printing, causes the program to exit.
567 CancelCB(Widget print_dialog, XtPointer client_data, XtPointer call_data)
570 // if gui-less command line printing, exit now that job is canceled
572 if (window_system().videoShell()->print_only) {
579 * ------------------------------------------------------------------------
580 * Name: CreatePrintSetup
584 * Creates a DtPrintSetupBox dialog.
588 CreatePrintSetup(Widget parent, AppPrintData* p)
590 RCS_DEBUG("CreatePrintSetup called.\n");
592 // Only create one PrintSetupBox
594 if (p->f_print_dialog == NULL)
599 // resources common to silent and noisy printing cases
601 XtSetArg(args[n], DtNcopies, window_system().videoShell()->copies); n++;
603 // set print to file if file name given
604 if ((char *)window_system().videoShell()->file_name != NULL) {
605 XtSetArg(args[n], DtNfileName, (char *)window_system().videoShell()->file_name); n++;
606 XtSetArg(args[n], DtNprintDestination, DtPRINT_TO_FILE); n++;
610 if ((char *)window_system().videoShell()->printer != NULL) {
611 XtSetArg(args[n], DtNprinterName, (char *)window_system().videoShell()->printer); n++;
614 // if silent printing we won't need a dialog
616 if (window_system().videoShell()->silent) {
618 // if parent widget is an application shell, use it, otherwise use
621 if (XtIsApplicationShell(parent)) {
623 DtCreatePrintSetupBox(parent, "PrintSetup", args, n);
627 DtCreatePrintSetupBox(XtParent(parent), "PrintSetup", args, n);
631 // not silent printing so we will need a dialog
635 // additional dialog resources
637 XmString title = XmStringCreateLocalized(
638 CATGETS(Set_PrintPanelAgent, 1, "Dtinfo: Print"));
640 XtSetArg(args[n], XmNdialogTitle, title); n++;
641 XtSetArg(args[n], DtNworkAreaLocation, DtWORK_AREA_BOTTOM); n++;
643 // if parent widget is an application shell, use it, otherwise use
646 if (XtIsApplicationShell(parent)) {
648 DtCreatePrintSetupDialog(parent, "PrintSetup", args, n);
652 DtCreatePrintSetupDialog(XtParent(parent), "PrintSetup", args, n);
654 // XmStringFree(title);
657 // customize the print setup box
659 customizePrintSetupBox(p);
663 XtAddCallback(p->f_print_dialog, DtNclosePrintDisplayCallback, PrintCloseDisplayCB,
666 XtAddCallback(p->f_print_dialog, DtNsetupCallback,
670 XtAddCallback(p->f_print_dialog, DtNprintCallback, PrintCB, (XtPointer)p);
671 XtAddCallback(p->f_print_dialog, DtNcancelCallback, CancelCB, (XtPointer)p);
673 // add context help for dialog
675 help_agent().add_activate_help(p->f_print_dialog, "print_panel_help");
678 // update message area
681 RCS_DEBUG("CreatePrintSetup exiting.\n");
686 * ------------------------------------------------------------------------
691 * Called when the user presses the setup box "Print" button.
695 PrintCB(Widget print_dialog, XtPointer client_data, XtPointer call_data)
697 RCS_DEBUG("PrintCB called.\n");
699 AppPrintData *p = (AppPrintData*)client_data;
700 DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct*)call_data;
703 * get the new printer data from the DtPrintSetupBox, and copy it
704 * into our AppPrint data
706 if (p->f_print_data->print_display != NULL)
707 DtPrintFreeSetupData(p->f_print_data);
708 DtPrintCopySetupData(p->f_print_data, pbs->print_data);
710 DoPrint(print_dialog, p);
712 RCS_DEBUG("PrintCB exiting.\n");
716 * ------------------------------------------------------------------------
721 * Called when the user hits "Print" quick button.
722 * not sure of this functions role in the "new order" ???? rCs
725 QuickPrintCB(Widget pr_button, XtPointer client_data, XtPointer call_data)
729 RCS_DEBUG("QuickPrintCB called.\n");
731 AppPrintData *p = (AppPrintData*)client_data;
733 CreatePrintSetup(pr_button, p);
736 // check if the DtPrintSetupBox ("Print...") has been called yet
738 if(p->f_print_data->print_display == (Display*)NULL)
741 // first time thru print setup, so get default data
743 if (DtPrintFillSetupData(p->f_print_dialog, p->f_print_data)
744 != DtPRINT_SUCCESS) {
745 // NOTE: DtPrintFillSetupData() already posts an error
746 // dialog on failure - no need to post our own.
747 RCS_DEBUG("DtPrintFillSetupData failed\n");
752 DoPrint(pr_button, p) ;
754 RCS_DEBUG("QuickPrintCB exiting.\n");
759 * ------------------------------------------------------------------------
760 * Name: FinishPrintToFile
764 * App-specific print data holder allocate function.
768 FinishPrintToFile(Display *display,
770 XPGetDocStatus status,
771 XPointer client_data)
775 RCS_DEBUG("FinishPrintToFile called.\n");
778 if (status != XPGetDocFinished) {
780 msg = CATGETS(Set_PrintPanelAgent, 8, "Error printing to file");
781 message_mgr().error_dialog(msg);
783 RCS_DEBUG("Something went wrong with XmPrintToFile...\n");
787 msg = CATGETS(Set_PrintPanelAgent, 9, "Print to file completed.");
788 message_mgr().info_dialog(msg);
790 RCS_DEBUG("XmPrintToFile completed OK\n");
792 RCS_DEBUG("FinishPrintToFile exiting.\n");
799 * ------------------------------------------------------------------------
804 * Routine used from the "Print" button and from the OK button of the
809 DoPrint(Widget widget, AppPrintData * p)
811 int save_data = XPSpool;
814 xList<UAS_Pointer<UAS_Common> > &print_list = *(p->f_print_list);
815 Xassert (print_list.length() > 0);
817 RCS_DEBUG("DoPrint called.\n");
819 // create print shell, if not done yet
820 CreatePrintShell(widget, p);
822 if (p->f_print_data->destination == DtPRINT_TO_FILE)
824 save_data = XPGetData;
827 // start job must precede XpGetDocumentData in XmPrintToFile
829 XpStartJob(XtDisplay(p->f_print_shell), save_data);
831 // maintain the sequence
832 // between startjob and getdocument
834 XFlush(XtDisplay(p->f_print_shell));
836 // setup print to file
838 if (p->f_print_data->destination == DtPRINT_TO_FILE)
840 if (!XmPrintToFile(XtDisplay(p->f_print_shell),
841 p->f_print_data->dest_info,
842 (XPFinishProc)FinishPrintToFile,
845 // Add real error message here.
846 // printf("XmPrintToFile: Unable to print to file %s\n",
847 // p->print_data->dest_info);
849 XpCancelJob(XtDisplay(p->f_print_shell), False);
851 // we can go back to the event loop as if we had never printed
856 if (!(window_system().videoShell()->silent)) {
858 XtRealizeWidget(p->f_print_shell);
859 XtPopup(p->f_print_shell, XtGrabNone);
864 XpEndJob(XtDisplay(p->f_print_shell));
866 // synch the print display (i am hoping this will get
867 // the xlib error handler called, if need be
869 XSync(XtDisplay(p->f_print_shell), False);
871 // if a print server error occured then notify the user
873 if (print_server_error) {
875 print_server_error = False; // reset for next time
877 // Post an error dialog
879 msg = CATGETS(Set_PrintPanelAgent,
881 "Print Job Failed.\n\nThe X Print Server is Temporarily Out of Resources.");
882 message_mgr().error_dialog(msg);
886 if (!(window_system().videoShell()->silent)) {
887 XtPopdown(p->f_print_shell);
890 // if we are in print only mode flush the output
891 // buffer to force the print and then exit
893 if (window_system().videoShell()->print_only) {
895 XSync(XtDisplay(p->f_print_shell), False);
897 // call this function to avoid invoking destructors
901 // have the print manager destroy the print agent
902 // used to print this job
904 print_mgr().destroy_agent();
906 // destroy print shell as well
908 if (p->f_print_shell)
910 XtDestroyWidget(p->f_print_shell);
911 p->f_print_shell = (Widget)NULL ;
912 f_print_shell = (Widget)NULL ;
916 RCS_DEBUG("DoPrint exiting.\n");
921 * ------------------------------------------------------------------------
922 * Name: PrintEverything
926 * Called when the print shell receives the XP events. Contains the
927 * logic for printing all topics.
931 PrintEverything(AppPrintData *p)
935 RCS_DEBUG("PrintEverything called.\n");
937 xList<UAS_Pointer<UAS_Common> > &print_list = *(p->f_print_list);
938 Xassert (print_list.length() > 0);
941 Widget pshell = p->f_print_shell;
943 List_Iterator<UAS_Pointer<UAS_Common> > l (print_list);
947 PrintOneUASCommon(l.item(), pshell, &cur_page);
951 RCS_DEBUG("PrintEverything exiting.\n");
955 PrintOneUASCommon(UAS_Pointer<UAS_Common> &doc, Widget pshell, int *cur_pageP)
962 // Retrieve the topic from the doc
963 // The retrieve function will send a UAS_DocumentRetrievedMsg to the
964 // print manager which will render the canvas with the appropriate topic
966 doc->retrieve((void *)1);
968 // set print orientation to either landscape or portrait (if set)
970 if (f_printOrientation != NULL) {
971 sprintf(buf, "*content-orientation: %s\n", f_printOrientation);
972 XpSetAttributes(XtDisplay(pshell), XpGetContext(XtDisplay(pshell)), XPPageAttr, buf, XPAttrMerge);
975 for (gHelpDisplayArea->firstVisible = gHelpDisplayArea->nextNonVisible = 0;
976 gHelpDisplayArea->nextNonVisible >= 0;
977 gHelpDisplayArea->firstVisible = gHelpDisplayArea->nextNonVisible + 1)
981 XpStartPage(XtDisplay(pshell), XtWindow(pshell));
983 sprintf(buf, "%d", *cur_pageP);
984 label = XmStringCreateLocalized(buf);
987 XtSetArg(args[n], XmNlabelString, label); n++;
988 XtSetValues(footer_page_no, args, n);
991 // Process exposures so label is updated.
992 XmUpdateDisplay(footer_page_no);
994 // _DtHelpCleanAndDrawWholeCanvas((XtPointer)gHelpDisplayArea);
996 XpEndPage(XtDisplay(pshell));
999 // Print chidren if appropriate
1000 if (print_hierarchy)
1003 UAS_List<UAS_Common> kids = doc->children();
1005 for (i = 0; i < kids.length(); i++)
1007 PrintOneUASCommon(kids[i], pshell, cur_pageP);
1013 * ------------------------------------------------------------------------
1014 * Name: PrintCloseDisplayCB
1018 * Called when the print setup box is about to close the print
1019 * display (in response to a new printer on a different display, or
1020 * when the setup box is destroyed).
1023 PrintCloseDisplayCB(
1025 XtPointer client_data,
1026 XtPointer call_data)
1028 RCS_DEBUG("PrintCloseDisplayCB called.\n");
1030 DtPrintSetupCallbackStruct *pbs = (DtPrintSetupCallbackStruct*)call_data;
1031 AppPrintData *p = (AppPrintData*)client_data;
1033 if (p->f_print_shell)
1035 XtDestroyWidget(p->f_print_shell);
1036 p->f_print_shell = (Widget)NULL ;
1037 f_print_shell = (Widget)NULL ;
1041 DtPrintFreeSetupData(p->f_print_data);
1043 // reset gHelpDisplayArea so that it will be recreated.
1044 // ??? should i also destroy the canvas here?
1045 gHelpDisplayArea = 0;
1047 RCS_DEBUG("PrintCloseDisplayCB exiting.\n");
1052 // /////////////////////////////////////////////////////////////////
1054 // /////////////////////////////////////////////////////////////////
1059 XtPointer client_data,
1060 XtPointer call_data)
1062 RCS_DEBUG("ToggleWhatCB called.\n");
1064 XmToggleButtonCallbackStruct * cbs = (XmToggleButtonCallbackStruct *) call_data;
1065 AppPrintData * p = (AppPrintData *)client_data;
1067 xList<UAS_Pointer<UAS_Common> > &print_list = *(p->f_print_list);
1069 static char buffer[24];
1070 WXmToggleButton other (NULL), active(widget);
1072 ON_DEBUG (printf ("PrintPanel::ToggleWhatCB (%p)\n", widget));
1074 Xassert ( (widget == (Widget)f_print_nodes) || (widget == (Widget)f_print_hierarchy));
1076 // Figure out which one is the other one (ie: not clicked on).
1077 if (active == f_print_nodes)
1079 other = f_print_hierarchy;
1083 other = f_print_nodes;
1089 if (active == f_print_nodes)
1091 sprintf (buffer, "%d", print_list.length());
1092 print_hierarchy = False;
1094 else // active == f_print_hierarchy
1096 List_Iterator<UAS_Pointer<UAS_Common> > l (print_list);
1097 int subtree_size = l.item()->subtree_size ();
1099 if (subtree_size != 0)
1101 sprintf (buffer, "%d", subtree_size);
1105 strcpy (buffer, "?");
1107 print_hierarchy = True;
1114 f_to_print_field.LabelString (WXmString (buffer));
1116 RCS_DEBUG("ToggleWhatCBB exiting.\n");