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

tdeprint

ippreportdlg.cpp
00001 /*
00002  *  This file is part of the KDE libraries
00003  *  Copyright (c) 2001 Michael Goffioul <tdeprint@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 "ippreportdlg.h"
00021 #include "ipprequest.h"
00022 #include "kprinter.h"
00023 
00024 #include <tdelocale.h>
00025 #include <kguiitem.h>
00026 #include <tdemessagebox.h>
00027 #include <kdebug.h>
00028 #include <ktextedit.h>
00029 #include <tqsimplerichtext.h>
00030 #include <tqpainter.h>
00031 #include <tqpaintdevicemetrics.h>
00032 
00033 IppReportDlg::IppReportDlg(TQWidget *parent, const char *name)
00034 : KDialogBase(parent, name, true, i18n("IPP Report"), Close|User1, Close, false, KGuiItem(i18n("&Print"), "document-print"))
00035 {
00036     m_edit = new KTextEdit(this);
00037     m_edit->setReadOnly(true);
00038     setMainWidget(m_edit);
00039     resize(540, 500);
00040     setFocusProxy(m_edit);
00041     setButtonGuiItem(User1, KGuiItem(i18n("&Print"),"document-print"));
00042 }
00043 
00044 void IppReportDlg::slotUser1()
00045 {
00046     KPrinter    printer;
00047     printer.setFullPage(true);
00048     printer.setDocName(caption());
00049     if (printer.setup(this))
00050     {
00051         TQPainter   painter(&printer);
00052         TQPaintDeviceMetrics    metrics(&printer);
00053 
00054         // report is printed using TQSimpleRichText
00055         TQSimpleRichText    rich(m_edit->text(), font());
00056         rich.setWidth(&painter, metrics.width());
00057         int margin = (int)(1.5 / 2.54 * metrics.logicalDpiY()); // 1.5 cm
00058         TQRect  r(margin, margin, metrics.width()-2*margin, metrics.height()-2*margin);
00059         int hh = rich.height(), page(1);
00060         while (1)
00061         {
00062             rich.draw(&painter, margin, margin, r, colorGroup());
00063             TQString    s = caption() + ": " + TQString::number(page);
00064             TQRect  br = painter.fontMetrics().boundingRect(s);
00065             painter.drawText(r.right()-br.width()-5, r.top()-br.height()-4, br.width()+5, br.height()+4, Qt::AlignRight|Qt::AlignTop, s);
00066             r.moveBy(0, r.height()-10);
00067             painter.translate(0, -(r.height()-10));
00068             if (r.top() < hh)
00069             {
00070                 printer.newPage();
00071                 page++;
00072             }
00073             else
00074                 break;
00075         }
00076     }
00077 }
00078 
00079 void IppReportDlg::report(IppRequest *req, int group, const TQString& caption)
00080 {
00081     TQString    str_report;
00082     TQTextStream    t(&str_report, IO_WriteOnly);
00083 
00084     if (req->htmlReport(group, t))
00085     {
00086         IppReportDlg    dlg;
00087         if (!caption.isEmpty())
00088             dlg.setCaption(caption);
00089         dlg.m_edit->setText(str_report);
00090         dlg.exec();
00091     }
00092     else
00093         KMessageBox::error(0, i18n("Internal error: unable to generate HTML report."));
00094 }
00095 
00096 #include "ippreportdlg.moc"

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.7.6.1
This website is maintained by Timothy Pearson.