1 /**************************************************************************\
2  *
3  *  This file is part of the Coin 3D visualization library.
4  *  Copyright (C) by Kongsberg Oil & Gas Technologies.
5  *
6  *  This library is free software; you can redistribute it and/or
7  *  modify it under the terms of the GNU General Public License
8  *  ("GPL") version 2 as published by the Free Software Foundation.
9  *  See the file LICENSE.GPL at the root directory of this source
10  *  distribution for additional information about the GNU GPL.
11  *
12  *  For using Coin with software that can not be combined with the GNU
13  *  GPL, and for taking advantage of the additional benefits of our
14  *  support services, please contact Kongsberg Oil & Gas Technologies
15  *  about acquiring a Coin Professional Edition License.
16  *
17  *  See http://www.coin3d.org/ for more information.
18  *
19  *  Kongsberg Oil & Gas Technologies, Bygdoy Alle 5, 0257 Oslo, NORWAY.
20  *  http://www.sim.no/  sales@sim.no  coin-support@coin3d.org
21  *
22 \**************************************************************************/
23 
24 // $Id$
25 
26 #ifndef SOXT_PRINTDIALOG_H
27 #define SOXT_PRINTDIALOG_H
28 
29 #include <X11/Intrinsic.h>
30 #include <Xm/Xm.h>
31 
32 #include <Inventor/misc/SoCallbackList.h>
33 
34 #include <Inventor/Xt/SoXtComponent.h>
35 
36 class SoGLRenderAction;
37 class SoXtPrintDialog;
38 class SoPath;
39 class SoNode;
40 
41 // *************************************************************************
42 
43 typedef void SoXtPrintDialogCB(void * userdata, SoXtPrintDialog * dialog);
44 
45 class SOXT_DLL_API SoXtPrintDialog : public SoXtComponent {
46   SOXT_OBJECT_HEADER(SoXtPrintDialog, SoXtComponent);
47 
48 public:
49   SoXtPrintDialog(
50     Widget parent = NULL,
51     const char * const name = NULL,
52     SbBool embed = TRUE);
53   SoXtPrintDialog(
54     SoGLRenderAction * const action,
55     Widget parent = NULL,
56     const char * const name = NULL,
57     SbBool embed = TRUE);
58   ~SoXtPrintDialog(void);
59 
60   void setSceneGraph(SoPath * path);
61   void setSceneGraph(SoNode * root);
62 
63   SoNode * getSceneGraph(void);
64   SoPath * getSceneGraphPath(void);
65 
66   void setGLRenderAction(const SoGLRenderAction * const action);
67   SoGLRenderAction * getGLRenderAction(void);
68 
69   void setPrintSize(const SbVec2f & size);
70   void setPrintSize(const SbVec2s size);
71 
72   void setBeforePrintCallback(
73     SoXtPrintDialogCB * callback, void * user = NULL);
74   void setAfterPrintCallback(
75     SoXtPrintDialogCB * callback, void * user = NULL);
76 
77 protected:
78   SoXtPrintDialog(
79     Widget parent,
80     const char * const name,
81     SbBool embed,
82     SbBool build);
83 
84   virtual const char * getDefaultWidgetName(void) const;
85   virtual const char * getDefaultTitle(void) const;
86   virtual const char * getDefaultIconTitle(void) const;
87 
88   SoNode * rootNode;
89   SoPath * rootPath;
90   SbBool printDone;
91   SbBool highQuality;
92   SbBool portraitFormat;
93   SbBool printerOutput, postScriptOutput;
94   SbBool nodeMostRecent;
95   SbBool WYSIWYGflag;
96   Widget messageWidget, printButton, quitButton;
97   Widget messageLabelWidget, fileFormatWidget;
98   Widget toPrinterWidget, toPostScriptFileWidget, toRGBFileWidget;
99   Widget printerHorizSize, printerVertSize;
100   Widget postScriptHorizSize, postScriptVertSize;
101   Widget rgbHorizSize, rgbVertSize;
102   Widget printerDPIField, postScriptDPIField;
103   Widget rgbFilenameWidget, postScriptFilenameWidget;
104   SbPList * printers;
105   char * defaultPrinter;
106   int whichPrinter;
107   SbVec2f printSize;
108   SbVec2s printRes;
109   SoCallbackList beforeList, afterList;
110   SbBool alreadyUpdated;
111 
112   void print(void);
113   void getPrinterList(void);
114   void printToPostScript(SoNode *, char *, int, int);
115 
116   void buildToPrinterWidget(Widget parent);
117   void buildToPostScriptFileWidget(Widget parent);
118   void buildToRGBFileWidget(Widget parent);
119   void placeBottomOfDialog(SoXtPrintDialog *);
120   void buildRadioButton(char *,  char *, char *, int, int,
121     Widget, XtCallbackProc);
122   void buildSizeFields(char *, int, Widget, Widget &, Widget &,
123     XtCallbackProc, XtCallbackProc);
124   void buildDPIField(int, Widget, Widget &, XtCallbackProc);
125   void updateTextports(void);
126 
127 // callbacks
128   static void qualityCB(Widget, SoXtPrintDialog *, XmAnyCallbackStruct *);
129   static void pageFormatCB(Widget, SoXtPrintDialog *, XmAnyCallbackStruct *);
130   static void fileFormatCB(Widget, SoXtPrintDialog *, XmAnyCallbackStruct *);
131   static void printerHorizSizeCB(
132     Widget, SoXtPrintDialog *, XmAnyCallbackStruct *);
133   static void printerVertSizeCB(
134     Widget, SoXtPrintDialog *, XmAnyCallbackStruct *);
135   static void postScriptHorizSizeCB(
136     Widget, SoXtPrintDialog *, XmAnyCallbackStruct *);
137   static void postScriptVertSizeCB(
138     Widget, SoXtPrintDialog *, XmAnyCallbackStruct *);
139   static void rgbHorizSizeCB(
140     Widget, SoXtPrintDialog *, XmAnyCallbackStruct *);
141   static void rgbVertSizeCB(Widget, SoXtPrintDialog *, XmAnyCallbackStruct *);
142   static void printerDPICB(Widget, SoXtPrintDialog *, XmAnyCallbackStruct *);
143   static void postScriptDPICB(
144     Widget, SoXtPrintDialog *, XmAnyCallbackStruct *);
145   static void outputCB(Widget, SoXtPrintDialog *, XmAnyCallbackStruct *);
146   static void printCB(Widget, SoXtPrintDialog *, XmAnyCallbackStruct *);
147   static void quitCB(Widget, SoXtPrintDialog *, XmAnyCallbackStruct *);
148   static void listPick(Widget, SoXtPrintDialog *, XmAnyCallbackStruct *);
149 
150   Widget styleButton;
151   int currentStyle;
152 
153 private:
154   void constructor(SbBool build);
155   Widget buildWidget(Widget parent);
156 
157 }; // class SoXtPrintDialog
158 
159 // *************************************************************************
160 
161 #endif // ! SOXT_PRINTDIALOG_H
162