kphpgl2page.cpp
00001 /* 00002 * This file is part of the KDE libraries 00003 * Copyright (c) 2001 Michael Goffioul <kdeprint@swing.be> 00004 * 00005 * This library is free software; you can redistribute it and/or 00006 * modify it under the terms of the GNU Library General Public 00007 * License version 2 as published by the Free Software Foundation. 00008 * 00009 * This library is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 * Library General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU Library General Public License 00015 * along with this library; see the file COPYING.LIB. If not, write to 00016 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 * Boston, MA 02110-1301, USA. 00018 **/ 00019 00020 #include "kphpgl2page.h" 00021 00022 #include <tqcheckbox.h> 00023 #include <tqgroupbox.h> 00024 #include <tqlayout.h> 00025 #include <tqwhatsthis.h> 00026 #include <klocale.h> 00027 #include <knuminput.h> 00028 00029 KPHpgl2Page::KPHpgl2Page(TQWidget *parent, const char *name) 00030 : KPrintDialogPage(parent, name) 00031 { 00032 //WhatsThis strings.... (added by pfeifle@kde.org) 00033 TQString whatsThisBlackplotHpgl2Page = i18n( " <qt> " 00034 " <b>Print in Black Only (Blackplot)</b> " 00035 " <p>The \'blackplot\' option specifies that all pens should plot in black-only:" 00036 " The default is to use the colors defined in the plot file, or the standard " 00037 " pen colors defined in the HP-GL/2 reference manual from Hewlett Packard. </p> " 00038 " <br> " 00039 " <hr> " 00040 " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches " 00041 " with the CUPS commandline job option parameter:</em> " 00042 " <pre>" 00043 " -o blackplot=true " 00044 " </pre> " 00045 " </p> " 00046 " </qt>" ); 00047 00048 TQString whatsThisFitplotHpgl2Page = i18n( " <qt> " 00049 " <b>Scale Print Image to Page Size</b> " 00050 " <p>The 'fitplot' option specifies that the HP-GL image should be scaled to fill " 00051 " exactly the page with the (elsewhere selected) media size. </p> " 00052 " <p>The default is 'fitplot is disabled'. The default will therefore use the absolute " 00053 " distances specified in the plot file. (You should be aware that HP-GL files are very " 00054 " often CAD drawings intended for large format plotters. On standard office printers " 00055 " they will therefore lead to the drawing printout being spread across multiple pages.) </p> " 00056 " <p><b>Note:</b>This feature depends upon an accurate plot size (PS) command in the " 00057 " HP-GL/2 file. If no plot size is given in the file the filter converting the HP-GL " 00058 " to PostScript assumes the plot is ANSI E size. </p> " 00059 " <br> " 00060 " <hr> " 00061 " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches with the CUPS commandline job option parameter:</em> " 00062 " <pre> " 00063 " -o fitplot=true " 00064 " </pre>" 00065 " </p> " 00066 " </qt>" ); 00067 00068 TQString whatsThisPenwidthHpgl2Page = i18n( " <qt> " 00069 " <b>Set Pen Width for HP-GL (if not defined in file)</b>. " 00070 " <p>The pen width value can be set here in case the original HP-GL file does not have it " 00071 " set. The pen width specifies the value in micrometers. The default value of 1000 produces " 00072 " lines that are 1000 micrometers == 1 millimeter in width. Specifying a pen width of 0 " 00073 " produces lines that are exactly 1 pixel wide. </p> " 00074 " <p><b>Note:</b> The penwidth option set here is ignored if the pen widths are set inside " 00075 " the plot file itself..</p> " 00076 " <br> " 00077 " <hr> " 00078 " <p><em><b>Additional hint for power users:</b> This KDEPrint GUI element matches with the CUPS commandline job option parameter:</em> " 00079 " <pre>" 00080 " -o penwidth=... # example: \"2000\" or \"500\" " 00081 " </pre>" 00082 " </p> " 00083 " </qt>" ); 00084 00085 TQString whatsThisAllOptionsHpgl2Page = i18n( " <qt> " 00086 " <b>HP-GL Print Options</b> " 00087 " <p>All options on this page are only applicable if you use KDEPrint to send HP-GL and " 00088 " HP-GL/2 files to one of your printers. </p> " 00089 " <p>HP-GL and HP-GL/2 are page description languages developed by Hewlett-Packard to drive " 00090 " Pen Plotting devices. </p> " 00091 " <p>KDEPrint can (with the help of CUPS) convert the HP-GL file format and print it " 00092 " on any installed printer. </p> " 00093 " <p><b>Note 1:</b> To print HP-GL files, start 'kprinter' and simply load the file into " 00094 " the running kprinter.</p>" 00095 " <p><b>Note 2:</b> The 'fitplot' parameter provided on this dialog does also work for " 00096 " printing PDF files (if your CUPS version is more recent than 1.1.22).</p> " 00097 " <br> " 00098 " <hr> " 00099 " <p><em><b>Additional hint for power users:</b> These KDEPrint GUI elements match with CUPS commandline job option parameters:</em> " 00100 " <pre>" 00101 " -o blackplot=... # examples: \"true\" or \"false\" " 00102 " <br> " 00103 " -o fitplot=... # examples: \"true\" or \"false\" " 00104 " <br> " 00105 " -o penwidth=... # examples: \"true\" or \"false\" " 00106 " </pre>" 00107 " </p> " 00108 " </qt>" ); 00109 00110 00111 setTitle("HP-GL/2"); 00112 00113 TQGroupBox *box = new TQGroupBox(0, Qt::Vertical, i18n("HP-GL/2 Options"), this); 00114 00115 m_blackplot = new TQCheckBox(i18n("&Use only black pen"), box); 00116 TQWhatsThis::add(m_blackplot, whatsThisBlackplotHpgl2Page); 00117 00118 m_fitplot = new TQCheckBox(i18n("&Fit plot to page"), box); 00119 TQWhatsThis::add(m_fitplot, whatsThisFitplotHpgl2Page); 00120 00121 m_penwidth = new KIntNumInput(1000, box); 00122 m_penwidth->setLabel(i18n("&Pen width:"), Qt::AlignLeft|Qt::AlignVCenter); 00123 m_penwidth->setSuffix(" [um]"); 00124 m_penwidth->setRange(0, 10000, 100, true); 00125 TQWhatsThis::add(m_penwidth, whatsThisPenwidthHpgl2Page); 00126 00127 TQVBoxLayout *l0 = new TQVBoxLayout(this, 0, 10); 00128 l0->addWidget(box); 00129 l0->addStretch(1); 00130 00131 TQVBoxLayout *l1 = new TQVBoxLayout(TQT_TQLAYOUT(box->layout()), 10); 00132 l1->addWidget(m_blackplot); 00133 l1->addWidget(m_fitplot); 00134 l1->addWidget(m_penwidth); 00135 TQWhatsThis::add(this, whatsThisAllOptionsHpgl2Page); 00136 } 00137 00138 KPHpgl2Page::~KPHpgl2Page() 00139 { 00140 } 00141 00142 void KPHpgl2Page::setOptions(const TQMap<TQString,TQString>& opts) 00143 { 00144 TQString value; 00145 if (opts.contains("blackplot") && ((value=opts["blackplot"]).isEmpty() || value == "true")) 00146 m_blackplot->setChecked(true); 00147 if (opts.contains("fitplot") && ((value=opts["fitplot"]).isEmpty() || value == "true")) 00148 m_fitplot->setChecked(true); 00149 if (!(value=opts["penwidth"]).isEmpty()) 00150 m_penwidth->setValue(value.toInt()); 00151 } 00152 00153 void KPHpgl2Page::getOptions(TQMap<TQString,TQString>& opts, bool incldef) 00154 { 00155 if (incldef || m_penwidth->value() != 1000) 00156 opts["penwidth"] = TQString::number(m_penwidth->value()); 00157 if (m_blackplot->isChecked()) 00158 opts["blackplot"] = "true"; 00159 else if (incldef) 00160 opts["blackplot"] = "false"; 00161 else 00162 opts.remove("blackplot"); 00163 if (m_fitplot->isChecked()) 00164 opts["fitplot"] = "true"; 00165 else if (incldef) 00166 opts["fitplot"] = "false"; 00167 else 00168 opts.remove("fitplot"); 00169 }