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

tdeprint

  • tdeprint
  • cups
ippreportdlg.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 "ippreportdlg.h"
21 #include "ipprequest.h"
22 #include "kprinter.h"
23 
24 #include <tdelocale.h>
25 #include <kguiitem.h>
26 #include <tdemessagebox.h>
27 #include <kdebug.h>
28 #include <ktextedit.h>
29 #include <tqsimplerichtext.h>
30 #include <tqpainter.h>
31 #include <tqpaintdevicemetrics.h>
32 
33 IppReportDlg::IppReportDlg(TQWidget *parent, const char *name)
34 : KDialogBase(parent, name, true, i18n("IPP Report"), Close|User1, Close, false, KGuiItem(i18n("&Print"), "document-print"))
35 {
36  m_edit = new KTextEdit(this);
37  m_edit->setReadOnly(true);
38  setMainWidget(m_edit);
39  resize(540, 500);
40  setFocusProxy(m_edit);
41  setButtonGuiItem(User1, KGuiItem(i18n("&Print"),"document-print"));
42 }
43 
44 void IppReportDlg::slotUser1()
45 {
46  KPrinter printer;
47  printer.setFullPage(true);
48  printer.setDocName(caption());
49  if (printer.setup(this))
50  {
51  TQPainter painter(&printer);
52  TQPaintDeviceMetrics metrics(&printer);
53 
54  // report is printed using TQSimpleRichText
55  TQSimpleRichText rich(m_edit->text(), font());
56  rich.setWidth(&painter, metrics.width());
57  int margin = (int)(1.5 / 2.54 * metrics.logicalDpiY()); // 1.5 cm
58  TQRect r(margin, margin, metrics.width()-2*margin, metrics.height()-2*margin);
59  int hh = rich.height(), page(1);
60  while (1)
61  {
62  rich.draw(&painter, margin, margin, r, colorGroup());
63  TQString s = caption() + ": " + TQString::number(page);
64  TQRect br = painter.fontMetrics().boundingRect(s);
65  painter.drawText(r.right()-br.width()-5, r.top()-br.height()-4, br.width()+5, br.height()+4, TQt::AlignRight|TQt::AlignTop, s);
66  r.moveBy(0, r.height()-10);
67  painter.translate(0, -(r.height()-10));
68  if (r.top() < hh)
69  {
70  printer.newPage();
71  page++;
72  }
73  else
74  break;
75  }
76  }
77 }
78 
79 void IppReportDlg::report(IppRequest *req, int group, const TQString& caption)
80 {
81  TQString str_report;
82  TQTextStream t(&str_report, IO_WriteOnly);
83 
84  if (req->htmlReport(group, t))
85  {
86  IppReportDlg dlg;
87  if (!caption.isEmpty())
88  dlg.setCaption(caption);
89  dlg.m_edit->setText(str_report);
90  dlg.exec();
91  }
92  else
93  KMessageBox::error(0, i18n("Internal error: unable to generate HTML report."));
94 }
95 
96 #include "ippreportdlg.moc"
KPrinter
This class is the main interface to access the TDE print framework.
Definition: kprinter.h:89
KPrinter::newPage
bool newPage()
See TQPrinter::newPage().
Definition: kprinter.cpp:912
KPrinter::setup
bool setup(TQWidget *parent=0, const TQString &caption=TQString::null, bool forceExpand=false)
Sets up the KPrinter object using the print dialog, returns true if the user clicked OK.
Definition: kprinter.cpp:219
KPrinter::setFullPage
void setFullPage(bool)
See TQPrinter::setFullPage().
Definition: kprinter.cpp:812
KPrinter::setDocName
void setDocName(const TQString &)
See TQPrinter::setDocName().
Definition: kprinter.cpp:800

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.