24 #include <tdeapplication.h>
25 #include <tqcheckbox.h>
26 #include <kcolorbutton.h>
27 #include <tdeconfig.h>
30 #include <tdefontcombo.h>
31 #include <tdeglobalsettings.h>
33 #include <tdelocale.h>
34 #include <knuminput.h>
35 #include <tqpaintdevicemetrics.h>
36 #include <tqpainter.h>
38 #include <kstandarddirs.h>
40 #include "ds_appearance.h"
41 #include "printingwizard.h"
42 #include "printprogress.h"
43 #include "printstyle.h"
45 #include "detailledstyle.h"
47 using namespace KABPrinting;
49 const char *ConfigSectionName =
"DetailedPrintStyle";
50 const char *UseKDEFonts =
"UseKDEFonts";
51 const char *HeaderFont =
"HeaderFont";
52 const char *HeaderFontSize =
"HeaderFontSize";
53 const char *HeadlinesFont =
"HeadlineFont";
54 const char *HeadlinesFontSize =
"HeadlineFontSize";
55 const char *BodyFont =
"BodyFont";
56 const char *BodyFontSize =
"BodyFontSize";
57 const char *DetailsFont =
"DetailsFont";
58 const char *DetailsFontSize =
"DetailsFontSize";
59 const char *FixedFont =
"FixedFont";
60 const char *FixedFontSize =
"FixedFontSize";
61 const char *ColoredContactHeaders =
"UseColoredContactHeaders";
62 const char *ContactHeaderForeColor =
"ContactHeaderForeColor";
63 const char *ContactHeaderBGColor =
"ContactHeaderBGColor";
66 DetailledPrintStyle::DetailledPrintStyle(
PrintingWizard *parent,
const char *name )
68 mPageAppearance( new AppearancePage( parent,
"AppearancePage" ) ),
75 TQFont standard = TDEGlobalSettings::generalFont();
76 TQFont fixed = TDEGlobalSettings::fixedFont();
78 setPreview(
"detailed-style.png" );
80 addPage( mPageAppearance, i18n(
"Detailed Print Style - Appearance" ) );
82 config = kapp->config();
83 config->setGroup( ConfigSectionName );
85 kdeFonts = config->readBoolEntry( UseKDEFonts,
true );
86 mPageAppearance->cbStandardFonts->setChecked( kdeFonts );
88 font = config->readFontEntry( HeaderFont, &standard );
89 mPageAppearance->kfcHeaderFont->setCurrentFont( font.family() );
90 mPageAppearance->kisbHeaderFontSize->setValue( font.pointSize() );
92 font = config->readFontEntry( HeadlinesFont, &standard );
93 mPageAppearance->kfcHeadlineFont->setCurrentFont( font.family() );
94 mPageAppearance->kisbHeadlineFontSize->setValue( font.pointSize() );
96 font = config->readFontEntry( BodyFont, &standard );
97 mPageAppearance->kfcBodyFont->setCurrentFont( font.family() );
98 mPageAppearance->kisbBodyFontSize->setValue( font.pointSize() );
100 font = config->readFontEntry( DetailsFont, &standard );
101 mPageAppearance->kfcDetailsFont->setCurrentFont( font.family() );
102 mPageAppearance->kisbDetailsFontSize->setValue( font.pointSize() );
104 font = config->readFontEntry( FixedFont, &fixed );
105 mPageAppearance->kfcFixedFont->setCurrentFont( font.family() );
106 mPageAppearance->kisbFixedFontSize->setValue( font.pointSize() );
108 mPageAppearance->cbBackgroundColor->setChecked(
109 config->readBoolEntry( ColoredContactHeaders,
true ) );
110 mPageAppearance->kcbHeaderBGColor->setColor(
111 config->readColorEntry( ContactHeaderBGColor, &TQt::black ) );
112 mPageAppearance->kcbHeaderTextColor->setColor(
113 config->readColorEntry( ContactHeaderForeColor, &TQt::white ) );
115 mPageAppearance->layout()->setMargin( KDialog::marginHint() );
116 mPageAppearance->layout()->setSpacing( KDialog::spacingHint() );
119 DetailledPrintStyle::~DetailledPrintStyle()
125 void DetailledPrintStyle::print(
const TDEABC::Addressee::List &contacts,
PrintProgress *progress )
127 mPrintProgress = progress;
129 progress->
addMessage( i18n(
"Setting up fonts and colors" ) );
134 TQColor foreColor = TQt::black;
135 TQColor headerColor = TQt::white;
136 bool useHeaderColor =
true;
137 TQColor backColor = TQt::black;
141 TQFont header = TQFont(
"Helvetica", 12, TQFont::Normal);
142 TQFont headlines = TQFont(
"Helvetica", 12, TQFont::Normal,
true);
143 TQFont body = TQFont(
"Helvetica", 12, TQFont::Normal);
144 TQFont fixed = TQFont(
"Courier", 12, TQFont::Normal);
145 TQFont comment = TQFont(
"Helvetica", 10, TQFont::Normal);
148 TDEConfig *config = kapp->config();
149 config->setGroup( ConfigSectionName );
150 useKDEFonts = mPageAppearance->cbStandardFonts->isChecked();
151 config->writeEntry( UseKDEFonts, useKDEFonts );
154 useBGColor=mPageAppearance->cbBackgroundColor->isChecked();
155 config->writeEntry( ColoredContactHeaders, useBGColor );
159 headerColor = mPageAppearance->kcbHeaderTextColor->color();
160 backColor = mPageAppearance->kcbHeaderBGColor->color();
161 config->writeEntry( ContactHeaderForeColor, headerColor );
162 config->writeEntry( ContactHeaderBGColor, backColor );
165 if ( mPageAppearance->cbStandardFonts->isChecked() ) {
166 TQFont standard = TDEGlobalSettings::generalFont();
168 headlines = standard;
170 fixed = TDEGlobalSettings::fixedFont();
173 header.setFamily( mPageAppearance->kfcHeaderFont->currentText() );
174 header.setPointSize( mPageAppearance->kisbHeaderFontSize->value() );
175 config->writeEntry( HeaderFont, header );
178 headlines.setFamily( mPageAppearance->kfcHeadlineFont->currentText() );
179 headlines.setPointSize( mPageAppearance->kisbHeadlineFontSize->value() );
180 config->writeEntry( HeadlinesFont, headlines );
183 body.setFamily( mPageAppearance->kfcBodyFont->currentText() );
184 body.setPointSize( mPageAppearance->kisbBodyFontSize->value() );
185 config->writeEntry( BodyFont, body );
188 comment.setFamily( mPageAppearance->kfcDetailsFont->currentText() );
189 comment.setPointSize( mPageAppearance->kisbDetailsFontSize->value() );
190 config->writeEntry( DetailsFont, comment );
193 fixed.setFamily( mPageAppearance->kfcFixedFont->currentText() );
194 fixed.setPointSize( mPageAppearance->kisbFixedFontSize->value() );
195 config->writeEntry( FixedFont, fixed );
198 mPainter =
new KABEntryPainter;
199 mPainter->setForegroundColor( foreColor );
200 mPainter->setHeaderColor( headerColor );
201 mPainter->setBackgroundColor( backColor );
202 mPainter->setUseHeaderColor( useHeaderColor );
203 mPainter->setHeaderFont( header );
204 mPainter->setHeadLineFont( headlines );
205 mPainter->setBodyFont( body );
206 mPainter->setFixedFont( fixed );
207 mPainter->setCommentFont( comment );
209 KPrinter *printer = wizard()->printer();
212 progress->
addMessage( i18n(
"Setting up margins and spacing" ) );
218 int left, top, width, height;
220 painter.begin( printer );
221 printer->setFullPage(
true );
223 TQPaintDeviceMetrics metrics( printer );
225 left = TQMAX( printer->margins().width(), marginLeft );
226 top = TQMAX( printer->margins().height(), marginTop );
227 width = metrics.width() - left - TQMAX( printer->margins().width(), marginRight );
228 height = metrics.height() - top - TQMAX( printer->margins().height(), marginBottom );
230 painter.setViewport( left, top, width, height );
233 printEntries( contacts, printer, &painter,
234 TQRect( 0, 0, metrics.width(), metrics.height() ) );
242 bool DetailledPrintStyle::printEntries(
const TDEABC::Addressee::List &contacts,
245 const TQRect &window)
248 int ypos = 0, count = 0;
250 TDEABC::Addressee::List::ConstIterator it;
251 for ( it = contacts.begin(); it != contacts.end(); ++it ) {
252 if ( !(*it).isEmpty() ) {
254 if ( !mPainter->printAddressee( *it, window, painter, ypos,
true, &brect) ) {
263 mPainter->printAddressee( *it, window, painter, ypos,
false, &brect );
264 ypos += brect.height();
267 mPrintProgress->setProgress( (count++ * 100) / contacts.count() );
270 mPrintProgress->setProgress( 100 );
275 DetailledPrintStyleFactory::DetailledPrintStyleFactory(
PrintingWizard *parent,
281 PrintStyle *DetailledPrintStyleFactory::create()
const
283 return new DetailledPrintStyle( mParent, mName );
286 TQString DetailledPrintStyleFactory::description()
const
288 return i18n(
"Detailed Style" );
291 #include "detailledstyle.moc"
This defines a simple widget to display print progress information.
void addMessage(const TQString &)
Add a message to the message log.
void setProgress(int)
Set the progress to a certain amount.
The factories are used to have all object of the respective print style created in one place.
The class PrintStyle implements the abstract interface to the PrintingWizards style objects.
The PrintingWizard combines pages common for all print styles and those provided by the respective st...