• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdeprint
 

tdeprint

  • tdeprint
  • cups
kpimagepage.cpp
1 /*
2  * This file is part of the KDE libraries
3  * Copyright (c) 2001 Michael Goffioul <tdeprint@swing.be>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License version 2 as published by the Free Software Foundation.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  **/
19 
20 #include "kpimagepage.h"
21 #include "imageposition.h"
22 #include "imagepreview.h"
23 #include "driver.h"
24 
25 #include <tqcombobox.h>
26 #include <tqbuttongroup.h>
27 #include <tqradiobutton.h>
28 #include <tqgroupbox.h>
29 #include <tqpushbutton.h>
30 #include <tqapplication.h>
31 #include <tqimage.h>
32 #include <tqlabel.h>
33 #include <tqlayout.h>
34 #include <tqwhatsthis.h>
35 #include <tdelocale.h>
36 #include <knuminput.h>
37 #include <kseparator.h>
38 #include <kstandarddirs.h>
39 
40 KPImagePage::KPImagePage(DrMain *driver, TQWidget *parent, const char *name)
41 : KPrintDialogPage(parent, name)
42 {
43  //WhatsThis strings.... (added by pfeifle@kde.org)
44  TQString whatsThisBrightnessImagePage = i18n( " <qt> "
45  " <p><b>Brightness:</b> Slider to control the brightness value of all colors used.</p>"
46  " <p> The brightness value can range from 0 to 200. Values greater than 100 will "
47  " lighten the print. Values less than 100 will darken the print. </p> "
48  " <br> "
49  " <hr> "
50  " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
51  " with the CUPS commandline job option parameter:</em> "
52  " <pre>"
53  " -o brightness=... # use range from \"0\" to \"200\" "
54  " </pre> "
55  " </p> "
56  " </qt>" );
57 
58  TQString whatsThisHueImagePage = i18n( " <qt> "
59  " <p><b>Hue (Tint):</b> Slider to control the hue value for color rotation.</p>"
60  " <p> The hue value is a number from -360 to 360 and represents the color hue rotation. "
61  " The following table summarizes the change you will see for the base colors: "
62  " <center> "
63  " <table border=\"1\" width=\"70%\"> "
64  " <tr><th><b>Original</b></th> <th><b>hue=-45</b></th> <th><b>hue=45</b></th> </tr> "
65  " <tr><td>Red</td> <td>Purple</td> <td>Yellow-orange</td> </tr> "
66  " <tr><td>Green</td> <td>Yellow-green</td> <td>Blue-green</td> </tr> "
67  " <tr><td>Yellow</td> <td>Orange</td> <td>Green-yellow</td> </tr> "
68  " <tr><td>Blue</td> <td>Sky-blue</td> <td>Purple</td> </tr> "
69  " <tr><td>Magenta</td> <td>Indigo</td> <td>Crimson</td> </tr> "
70  " <tr><td>Cyan</td> <td>Blue-green</td> <td>Light-navy-blue</td> </tr> "
71  " </table> "
72  " </center> "
73  " <br> "
74  " <hr> "
75  " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
76  " with the CUPS commandline job option parameter:</em> "
77  " <pre>"
78  " -o hue=... # use range from \"-360\" to \"360\" "
79  " </pre>"
80  " </p> "
81  " </qt>" );
82 
83  TQString whatsThisSaturationImagePage = i18n( " <qt> "
84  " <p><b>Saturation:</b> Slider to control the saturation value for all colors used.</p>"
85  " <p> The saturation value adjusts the saturation of the colors in an image, similar to "
86  " the color knob on your television. The color saturation value.can range from 0 to 200."
87  " On inkjet printers, a higher saturation value uses more ink. On laserjet printers, a "
88  " higher saturation uses more toner. "
89  " A color saturation of 0 produces a black-and-white print, while a value of 200 will "
90  " make the colors extremely intense. </p>"
91  " <br> "
92  " <hr> "
93  " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
94  " with the CUPS commandline job option parameter:</em> "
95  " <pre>"
96  " -o saturation=... # use range from \"0\" to \"200\" "
97  " </pre>"
98  " </p> "
99  " </qt>" );
100 
101  TQString whatsThisGammaImagePage = i18n( " <qt> "
102  " <p><b>Gamma:</b> Slider to control the gamma value for color correction.</p>"
103  " <p> The gamma value can range from 1 to 3000. "
104  " A gamma values greater than 1000 lightens the print. A gamma value less than 1000 "
105  " darken the print. The default gamma is 1000. </p>"
106  " <p><b>Note:</b></p> the gamma value adjustment is not visible in the thumbnail "
107  " preview. </p> "
108  " <br> "
109  " <hr> "
110  " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
111  " with the CUPS commandline job option parameter:</em> "
112  " <pre>"
113  " -o gamma=... # use range from \"1\" to \"3000\" "
114  " </pre>"
115  " </p> "
116  " </qt>" );
117 
118  TQString whatsThisImagePage = i18n( " <qt> "
119  " <p><b>Image Printing Options</b></p> "
120  " <p>All options controlled on this page only apply to printing images. "
121  " Most image file formats are supported. To name a few: JPEG, TIFF, PNG, GIF, "
122  " PNM (PBM/PGM/PNM/PPM), Sun Raster, SGI RGB, Windows BMP."
123  " Options to influence color output of image printouts are: "
124  " <ul> "
125  " <li> Brightness </li>"
126  " <li> Hue </li>"
127  " <li> Saturation </li>"
128  " <li> Gamma </li>"
129  " </ul> "
130  " <p>For a more detailed explanation about Brightness, Hue, Saturation and Gamma settings, please "
131  " look at the 'WhatsThis' items provided for these controls. "
132  " </p> "
133  " </p> "
134  " </qt>" );
135 
136  TQString whatsThisColorationPreviewImagePage = i18n( " <qt> "
137  " <p><b>Coloration Preview Thumbnail</b></p> "
138  " <p>The coloration preview thumbnail indicates change of image coloration by different settings. "
139  " Options to influence output are: "
140  " <ul> "
141  " <li> Brightness </li>"
142  " <li> Hue (Tint) </li>"
143  " <li> Saturation </li>"
144  " <li> Gamma </li>"
145  " </ul> "
146  " </p> "
147  " <p>For a more detailed explanation about Brightness, Hue, Saturation and Gamma settings, please "
148  " look at the 'WhatsThis' items provided for these controls. "
149  " </p> "
150  " </qt>" );
151 
152  TQString whatsThisSizeImagePage = i18n( " <qt> "
153  " <p><b>Image Size:</b> Dropdown menu to control the image size on the printed paper. Dropdown "
154  " works in conjunction with slider below. Dropdown options are:.</p>"
155  " <ul> "
156  " <li> <b>Natural Image Size:</b> Image prints in its natural image size. If it does not fit onto "
157  " one sheet, the printout will be spread across multiple sheets. Note, that the slider is disabled "
158  " when selecting 'natural image size' in the dropdown menu. </li>"
159  " <li> <b>Resolution (ppi):</b> The resolution value slider covers a number range from 1 to 1200. "
160  " It specifies the resolution of the image in Pixels Per Inch (PPI). An image that is 3000x2400 pixels "
161  " will print 10x8 inches at 300 pixels per inch, for example, but 5x4 inches at 600 pixels per inch."
162  " If the specified resolution makes the image larger than the page, multiple pages will be printed. "
163  " Resolution defaults to 72 ppi. "
164  " </li>"
165  " <li> <b>% of Page Size:</b> The percent value slider covers numbers from 1 to 800. It specifies the size "
166  " in relation to the page (not the image). A scaling of 100 percent will fill the page as completely "
167  " as the image aspect ratio allows (doing auto-rotation of the image as needed). "
168  " A scaling of more than 100 will print the image across multiple "
169  " sheets. A scaling of 200 percent will print on up to 4 pages. </li>"
170  " Scaling in % of page size defaults to 100 %. "
171  " <li> <b>% of Natural Image Size:</b> The percent value slider moves from 1 to 800. It specifies "
172  " the printout size in relation "
173  " to the natural image size. A scaling of 100 percent will print the image at its natural size, while a "
174  " scaling of 50 percent will print the image at half its natural size. If the specified scaling makes "
175  " the image larger than the page, multiple pages will be printed. "
176  " Scaling in % of natural image size defaults to 100 %. "
177  " </ul> "
178  " <br> "
179  " <hr> "
180  " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
181  " with the CUPS commandline job option parameter:</em> "
182  " <pre>"
183  " -o natural-scaling=... # range in % is 1....800 "
184  " <br> "
185  " -o scaling=... # range in % is 1....800 "
186  " <br> "
187  " -o ppi=... # range in ppi is 1...1200 "
188  " </pre>"
189  " </p> "
190  " </qt>" );
191 
192  TQString whatsThisPreviewPositionImagePage = i18n( " <qt> "
193  " <p><b>Position Preview Thumbnail</b></p> "
194  " <p>This position preview thumbnail indicates the position of the image on the paper sheet. "
195  " <p>Click on horizontal and vertical radio buttons to move image alignment on paper around. Options are: "
196  " <ul> "
197  " <li> center </li>"
198  " <li> top </li>"
199  " <li> top-left </li>"
200  " <li> left </li>"
201  " <li> bottom-left </li>"
202  " <li> bottom </li>"
203  " <li> bottom-right</li>"
204  " <li> right </li>"
205  " <li> top-right </li>"
206  " </ul> "
207  " </p> "
208  " </qt>" );
209 
210  TQString whatsThisResetButtonImagePage = i18n( " <qt> "
211  " <p><b>Reset to Default Values</b> </p> "
212  " <p> Reset all coloration settings to default values. Default values are: "
213  " <ul> "
214  " <li> Brightness: 100 </li>"
215  " <li> Hue (Tint). 0 </li>"
216  " <li> Saturation: 100 </li>"
217  " <li> Gamma: 1000 </li>"
218  " </ul> "
219  " </p> "
220  " </qt>" );
221 
222  TQString whatsThisPositionImagePage = i18n( " <qt> "
223  " <p><b>Image Positioning:</b></p> "
224  " <p>Select a pair of radiobuttons to "
225  " move image to the position you want on the paper printout. Default "
226  " is 'center'. </p> "
227  " <br> "
228  " <hr> "
229  " <p><em><b>Additional hint for power users:</b> This TDEPrint GUI element matches "
230  " with the CUPS commandline job option parameter:</em> "
231  " <pre>"
232  " -o position=... # examples: \"top-left\" or \"bottom\" "
233  " </pre>"
234  " </p> "
235  " </qt>" );
236 
237  setTitle(i18n("Image"));
238 
239  TQGroupBox *colorbox = new TQGroupBox(0, TQt::Vertical, i18n("Color Settings"), this);
240  TQWhatsThis::add(this, whatsThisImagePage);
241  TQGroupBox *sizebox = new TQGroupBox(0, TQt::Vertical, i18n("Image Size"), this);
242  TQWhatsThis::add(sizebox, whatsThisSizeImagePage);
243  TQGroupBox *positionbox = new TQGroupBox(0, TQt::Vertical, i18n("Image Position"), this);
244  TQWhatsThis::add(positionbox, whatsThisPositionImagePage);
245 
246  m_brightness = new KIntNumInput(100, colorbox);
247  m_brightness->setLabel(i18n("&Brightness:"));
248  m_brightness->setRange(0, 200, 20, true);
249  TQWhatsThis::add(m_brightness, whatsThisBrightnessImagePage);
250 
251  m_hue = new KIntNumInput(m_brightness, 0, colorbox);
252  m_hue->setLabel(i18n("&Hue (Color rotation):"));
253  m_hue->setRange(-360, 360, 36, true);
254  TQWhatsThis::add(m_hue, whatsThisHueImagePage);
255 
256  m_saturation = new KIntNumInput(m_brightness, 100, colorbox);
257  m_saturation->setLabel(i18n("&Saturation:"));
258  m_saturation->setRange(0, 200, 20, true);
259  TQWhatsThis::add(m_saturation, whatsThisSaturationImagePage);
260 
261  m_gamma = new KIntNumInput(m_saturation, 1000, colorbox);
262  m_gamma->setLabel(i18n("&Gamma (Color correction):"));
263  m_gamma->setRange(1, 3000, 100, true);
264  TQWhatsThis::add(m_gamma, whatsThisGammaImagePage);
265 
266  connect(m_brightness, TQ_SIGNAL(valueChanged(int)), TQ_SLOT(slotImageSettingsChanged()));
267  connect(m_hue, TQ_SIGNAL(valueChanged(int)), TQ_SLOT(slotImageSettingsChanged()));
268  connect(m_saturation, TQ_SIGNAL(valueChanged(int)), TQ_SLOT(slotImageSettingsChanged()));
269  //connect(m_gamma, TQ_SIGNAL(valueChanged(int)), TQ_SLOT(slotImageSettingsChanged()));
270 
271  m_preview = new ImagePreview(colorbox);
272  bool useColor = (driver ? driver->get("colordevice") == "1" : true);
273  m_preview->setBlackAndWhite(!useColor);
274  TQWhatsThis::add(m_preview, whatsThisColorationPreviewImagePage);
275 
276  m_hue->setEnabled(useColor);
277  m_saturation->setEnabled(useColor);
278  TQImage img(locate("data", "tdeprint/preview.png"));
279  m_preview->setImage(img);
280 
281  KSeparator *sep = new KSeparator(TQt::Horizontal, colorbox);
282 
283  TQPushButton *defbtn = new TQPushButton(i18n("&Default Settings"), colorbox);
284  TQWhatsThis::add(defbtn, whatsThisResetButtonImagePage);
285  connect(defbtn, TQ_SIGNAL(clicked()), TQ_SLOT(slotDefaultClicked()));
286  slotDefaultClicked();
287 
288  m_sizetype = new TQComboBox(sizebox);
289  m_sizetype->insertItem(i18n("Natural Image Size"));
290  m_sizetype->insertItem(i18n("Resolution (ppi)"));
291  // xgettext:no-c-format
292  m_sizetype->insertItem(i18n("% of Page"));
293  // xgettext:no-c-format
294  m_sizetype->insertItem(i18n("% of Natural Image Size"));
295 
296  m_size = new KIntNumInput(sizebox);
297  m_size->setRange(1, 1200, 20, true);
298  m_size->setValue(72);
299 
300  connect(m_sizetype, TQ_SIGNAL(activated(int)), TQ_SLOT(slotSizeTypeChanged(int)));
301  m_sizetype->setCurrentItem(0);
302  slotSizeTypeChanged(0);
303 
304  TQLabel *lab = new TQLabel(i18n("&Image size type:"), sizebox);
305  lab->setBuddy(m_sizetype);
306 
307  m_position = new ImagePosition(positionbox);
308  TQWhatsThis::add(m_position, whatsThisPreviewPositionImagePage);
309 
310  TQRadioButton *bottom = new TQRadioButton(positionbox);
311  TQRadioButton *top = new TQRadioButton(positionbox);
312  TQRadioButton *vcenter = new TQRadioButton(positionbox);
313  TQRadioButton *left = new TQRadioButton(positionbox);
314  TQRadioButton *right = new TQRadioButton(positionbox);
315  TQRadioButton *hcenter = new TQRadioButton(positionbox);
316  TQSize sz = bottom->sizeHint();
317  bottom->setFixedSize(sz);
318  vcenter->setFixedSize(sz);
319  top->setFixedSize(sz);
320  left->setFixedSize(sz);
321  hcenter->setFixedSize(sz);
322  right->setFixedSize(sz);
323 
324  m_vertgrp = new TQButtonGroup(positionbox);
325  m_vertgrp->hide();
326 
327  m_horizgrp = new TQButtonGroup(positionbox);
328  m_horizgrp->hide();
329 
330  m_vertgrp->insert(top, 0);
331  m_vertgrp->insert(vcenter, 1);
332  m_vertgrp->insert(bottom, 2);
333  if ( TQApplication::reverseLayout() )
334  {
335  m_horizgrp->insert(left, 2);
336  m_horizgrp->insert(hcenter, 1);
337  m_horizgrp->insert(right, 0);
338  }
339  else
340  {
341  m_horizgrp->insert(left, 0);
342  m_horizgrp->insert(hcenter, 1);
343  m_horizgrp->insert(right, 2);
344  }
345  connect(m_vertgrp, TQ_SIGNAL(clicked(int)), TQ_SLOT(slotPositionChanged()));
346  connect(m_horizgrp, TQ_SIGNAL(clicked(int)), TQ_SLOT(slotPositionChanged()));
347  m_vertgrp->setButton(1);
348  m_horizgrp->setButton(1);
349  slotPositionChanged();
350 
351  TQGridLayout *l0 = new TQGridLayout(this, 2, 2, 0, 10);
352  l0->addMultiCellWidget(colorbox, 0, 0, 0, 1);
353  l0->addWidget(sizebox, 1, 0);
354  l0->addWidget(positionbox, 1, 1);
355  l0->setColStretch(0, 1);
356  TQGridLayout *l1 = new TQGridLayout(colorbox->layout(), 5, 2, 10);
357  l1->addWidget(m_brightness, 0, 0);
358  l1->addWidget(m_hue, 1, 0);
359  l1->addWidget(m_saturation, 2, 0);
360  l1->addWidget(sep, 3, 0);
361  l1->addWidget(m_gamma, 4, 0);
362  l1->addMultiCellWidget(m_preview, 0, 3, 1, 1);
363  l1->addWidget(defbtn, 4, 1);
364  TQVBoxLayout *l2 = new TQVBoxLayout(sizebox->layout(), 3);
365  l2->addStretch(1);
366  l2->addWidget(lab);
367  l2->addWidget(m_sizetype);
368  l2->addSpacing(10);
369  l2->addWidget(m_size);
370  l2->addStretch(1);
371  TQGridLayout *l3 = new TQGridLayout(positionbox->layout(), 2, 2, 10);
372  TQHBoxLayout *l4 = new TQHBoxLayout(0, 0, 10);
373  TQVBoxLayout *l5 = new TQVBoxLayout(0, 0, 10);
374  l3->addLayout(l4, 0, 1);
375  l3->addLayout(l5, 1, 0);
376  l3->addWidget(m_position, 1, 1);
377  l4->addWidget(left, TQt::AlignLeft);
378  l4->addWidget(hcenter, TQt::AlignCenter);
379  l4->addWidget(right, TQt::AlignRight);
380  l5->addWidget(top, TQt::AlignTop);
381  l5->addWidget(vcenter, TQt::AlignVCenter);
382  l5->addWidget(bottom, TQt::AlignBottom);
383 }
384 
385 KPImagePage::~KPImagePage()
386 {
387 }
388 
389 void KPImagePage::setOptions(const TQMap<TQString,TQString>& opts)
390 {
391  TQString value;
392  if (!(value=opts["brightness"]).isEmpty())
393  m_brightness->setValue(value.toInt());
394  if (!(value=opts["hue"]).isEmpty())
395  m_hue->setValue(value.toInt());
396  if (!(value=opts["saturation"]).isEmpty())
397  m_saturation->setValue(value.toInt());
398  if (!(value=opts["gamma"]).isEmpty())
399  m_gamma->setValue(value.toInt());
400 
401  int type = 0;
402  int ival(0);
403  if ((ival = opts["ppi"].toInt()) != 0)
404  type = 1;
405  else if ((ival = opts["scaling"].toInt()) != 0)
406  type = 2;
407  else if (!opts["natural-scaling"].isEmpty() && (ival = opts["natural-scaling"].toInt()) != 1)
408  type = 3;
409  m_sizetype->setCurrentItem(type);
410  slotSizeTypeChanged(type);
411  if (type != 0)
412  m_size->setValue(ival);
413 
414  if (!(value=opts["position"]).isEmpty())
415  {
416  m_position->setPosition(value.latin1());
417  int pos = m_position->position();
418  m_vertgrp->setButton(pos/3);
419  m_horizgrp->setButton(pos%3);
420  }
421 }
422 
423 void KPImagePage::getOptions(TQMap<TQString,TQString>& opts, bool incldef)
424 {
425  if (incldef || m_brightness->value() != 100)
426  opts["brightness"] = TQString::number(m_brightness->value());
427  if (m_hue->isEnabled())
428  {
429  if (incldef || m_hue->value() != 0)
430  opts["hue"] = TQString::number(m_hue->value());
431  if (incldef || m_saturation->value() != 100)
432  opts["saturation"] = TQString::number(m_saturation->value());
433  }
434  if (incldef || m_gamma->value() != 1000)
435  opts["gamma"] = TQString::number(m_gamma->value());
436 
437  TQString name;
438  if (incldef)
439  {
440  opts["ppi"] = "0";
441  opts["scaling"] = "0";
442  opts["natural-scaling"] = "1";
443  }
444  switch (m_sizetype->currentItem())
445  {
446  case 0: break;
447  case 1: name = "ppi"; break;
448  case 2: name = "scaling"; break;
449  case 3: name = "natural-scaling"; break;
450  }
451  if (!name.isEmpty())
452  opts[name] = TQString::number(m_size->value());
453 
454  if (incldef || m_position->position() != ImagePosition::Center)
455  opts["position"] = m_position->positionString();
456 }
457 
458 void KPImagePage::slotSizeTypeChanged(int t)
459 {
460  m_size->setEnabled(t > 0);
461  if (t > 0)
462  {
463  int minval, maxval, defval;
464  if (t == 1)
465  {
466  minval = 1;
467  maxval = 1200;
468  defval = 72;
469  }
470  else
471  {
472  minval = 1;
473  maxval = 800;
474  defval = 100;
475  }
476  m_size->setRange(minval, maxval);
477  m_size->setValue(defval);
478  }
479 }
480 
481 void KPImagePage::slotPositionChanged()
482 {
483  int h = m_horizgrp->id(m_horizgrp->selected()), v = m_vertgrp->id(m_vertgrp->selected());
484  m_position->setPosition(h, v);
485 }
486 
487 void KPImagePage::slotImageSettingsChanged()
488 {
489  int b = m_brightness->value(), h = m_hue->value(), s = m_saturation->value();
490  //int g = m_gamma->value();
491  int g = 1000;
492  m_preview->setParameters(b, h, s, g);
493 }
494 
495 void KPImagePage::slotDefaultClicked()
496 {
497  m_brightness->setValue(100);
498  m_hue->setValue(0);
499  m_saturation->setValue(100);
500  m_gamma->setValue(1000);
501 }
502 
503 #include "kpimagepage.moc"
KPrintDialogPage
This class is intended to be used as base class for customized print dialog page.
Definition: kprintdialogpage.h:91

tdeprint

Skip menu "tdeprint"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdeprint

Skip menu "tdeprint"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdeprint by doxygen 1.9.1
This website is maintained by Timothy Pearson.