22 #include "kateprinter.h"
24 #include <kateconfig.h>
25 #include <katedocument.h>
26 #include <katefactory.h>
27 #include <katehighlight.h>
28 #include <katelinerange.h>
29 #include <katerenderer.h>
30 #include <kateschema.h>
31 #include <katetextline.h>
33 #include <tdeapplication.h>
34 #include <kcolorbutton.h>
37 #include <tdefontdialog.h>
43 #include <tqpainter.h>
44 #include <tqpopupmenu.h>
45 #include <tqpaintdevicemetrics.h>
46 #include <tqcheckbox.h>
47 #include <tqcombobox.h>
48 #include <tqgroupbox.h>
52 #include <tqlineedit.h>
53 #include <tqspinbox.h>
54 #include <tqstringlist.h>
55 #include <tqwhatsthis.h>
58 bool KatePrinter::print (KateDocument *doc)
64 printer.setDocName(doc->docName());
66 KatePrintTextSettings *kpts =
new KatePrintTextSettings(&printer, NULL);
67 kpts->enableSelection( doc->hasSelection() );
68 printer.addDialogPage( kpts );
69 printer.addDialogPage(
new KatePrintHeaderFooter(&printer, NULL) );
70 printer.addDialogPage(
new KatePrintLayout(&printer, NULL) );
72 if ( printer.setup( kapp->mainWidget(), i18n(
"Print %1").arg(printer.docName()) ) )
76 renderer.setPrinterFriendly(
true);
78 TQPainter paint( &printer );
79 TQPaintDeviceMetrics pdm( &printer );
86 uint pdmWidth = pdm.width();
90 uint maxWidth = pdmWidth;
91 uint headerWidth = pdmWidth;
95 bool pageStarted =
true;
98 bool selectionOnly = ( doc->hasSelection() &&
99 ( printer.option(
"app-kate-printselection") ==
"true" ) );
103 bool useGuide = ( printer.option(
"app-kate-printguide") ==
"true" );
107 bool printLineNumbers = ( printer.option(
"app-kate-printlinenumbers") ==
"true" );
108 uint lineNumberWidth( 0 );
112 TQString f = printer.option(
"app-kate-hffont");
114 headerFont.fromString( f );
116 bool useHeader = (printer.option(
"app-kate-useheader") ==
"true");
117 TQColor headerBgColor(printer.option(
"app-kate-headerbg"));
118 TQColor headerFgColor(printer.option(
"app-kate-headerfg"));
119 uint headerHeight( 0 );
120 TQStringList headerTagList;
121 bool headerDrawBg =
false;
123 bool useFooter = (printer.option(
"app-kate-usefooter") ==
"true");
124 TQColor footerBgColor(printer.option(
"app-kate-footerbg"));
125 TQColor footerFgColor(printer.option(
"app-kate-footerfg"));
126 uint footerHeight( 0 );
127 TQStringList footerTagList = 0;
128 bool footerDrawBg = 0;
131 renderer.config()->setSchema( KateFactory::self()->schemaManager()->number(
132 printer.option(
"app-kate-colorscheme") ) );
133 bool useBackground = ( printer.option(
"app-kate-usebackground") ==
"true" );
134 bool useBox = (printer.option(
"app-kate-usebox") ==
"true");
135 int boxWidth(printer.option(
"app-kate-boxwidth").toInt());
136 TQColor boxColor(printer.option(
"app-kate-boxcolor"));
137 int innerMargin = useBox ? printer.option(
"app-kate-boxmargin").toInt() : 6;
140 uint maxHeight = (useBox ? pdm.height()-innerMargin : pdm.height());
141 uint currentPage( 1 );
142 uint lastline = doc->lastLine();
145 KateHlItemDataList ilist;
148 doc->highlight()->getKateHlItemDataListCopy (renderer.config()->schema(), ilist);
159 firstline = doc->selStartLine();
160 selStartCol = doc->selStartCol();
161 lastline = doc->selEndLine();
162 selEndCol = doc->selEndCol();
164 lineCount = firstline;
167 if ( printLineNumbers )
170 TQString s( TQString(
"%1 ").arg( doc->numLines() ) );
173 lineNumberWidth = renderer.currentFontMetrics()->width( s );
175 int _adj = renderer.currentFontMetrics()->width(
"5" );
177 maxWidth -= (lineNumberWidth + _adj);
178 xstart += lineNumberWidth + _adj;
181 if ( useHeader || useFooter )
187 TQDateTime dt = TQDateTime::currentDateTime();
188 TQMap<TQString,TQString> tags;
191 tags[
"u"] = u.loginName();
198 tags[
"f"] = doc->url().fileName();
199 tags[
"U"] = doc->url().prettyURL();
202 TQString s( i18n(
"(Selection of) ") );
203 tags[
"f"].prepend( s );
204 tags[
"U"].prepend( s );
207 TQRegExp reTags(
"%([dDfUhuyY])" );
211 headerDrawBg = ( printer.option(
"app-kate-headerusebg") ==
"true" );
212 headerHeight = TQFontMetrics( headerFont ).height();
213 if ( useBox || headerDrawBg )
214 headerHeight += innerMargin * 2;
216 headerHeight += 1 + TQFontMetrics( headerFont ).leading();
218 TQString headerTags = printer.option(
"app-kate-headerformat");
219 int pos = reTags.search( headerTags );
223 rep = tags[reTags.cap( 1 )];
224 headerTags.replace( (uint)pos, 2, rep );
226 pos = reTags.search( headerTags, pos );
228 headerTagList = TQStringList::split(
'|', headerTags,
true);
230 if (!headerBgColor.isValid())
231 headerBgColor = TQt::lightGray;
232 if (!headerFgColor.isValid())
233 headerFgColor = TQt::black;
238 footerDrawBg = ( printer.option(
"app-kate-footerusebg") ==
"true" );
239 footerHeight = TQFontMetrics( headerFont ).height();
240 if ( useBox || footerDrawBg )
241 footerHeight += 2*innerMargin;
245 TQString footerTags = printer.option(
"app-kate-footerformat");
246 int pos = reTags.search( footerTags );
250 rep = tags[reTags.cap( 1 )];
251 footerTags.replace( (uint)pos, 2, rep );
253 pos = reTags.search( footerTags, pos );
256 footerTagList = TQStringList::split(
'|', footerTags,
true);
257 if (!footerBgColor.isValid())
258 footerBgColor = TQt::lightGray;
259 if (!footerFgColor.isValid())
260 footerFgColor = TQt::black;
262 maxHeight -= footerHeight;
270 xstart += innerMargin;
271 maxWidth -= innerMargin * 2;
277 if (!boxColor.isValid())
278 boxColor = TQt::black;
282 maxWidth -= ( ( boxWidth + innerMargin ) * 2 );
283 xstart += boxWidth + innerMargin;
285 maxHeight -= boxWidth;
295 int _w = pdmWidth - innerMargin * 2;
301 _w -= ( innerMargin * 2 );
306 guideHeight = ( innerMargin * 4 ) + 1;
309 TQString _title = i18n(
"Typographical Conventions for %1").arg(doc->highlight()->name());
310 guideHeight += paint.boundingRect( 0, 0, _w, 1000, TQt::AlignTop|TQt::AlignHCenter, _title ).height();
315 TQPtrListIterator<KateHlItemData> it( ilist );
319 while ( ( _d = it.current()) != 0 )
321 _widest = kMax( _widest, ((TQFontMetrics)(
324 renderer.config()->fontStruct()->myFontMetricsBI :
325 renderer.config()->fontStruct()->myFontMetricsBold :
327 renderer.config()->fontStruct()->myFontMetricsItalic :
328 renderer.config()->fontStruct()->myFontMetrics
329 ) ).width( _d->name ) );
333 guideCols = _w/( _widest + innerMargin );
335 guideHeight += renderer.fontHeight() * ( _items/guideCols );
336 if ( _items%guideCols )
337 guideHeight += renderer.fontHeight();
343 if ( headerTagList.grep(
"%P").count() || footerTagList.grep(
"%P").count() )
345 kdDebug(13020)<<
"'%P' found! calculating number of pages..."<<
endl;
347 uint _ph = maxHeight;
349 _ph -= ( headerHeight + innerMargin );
352 int _lpp = _ph / renderer.fontHeight();
357 _lt += (guideHeight + (renderer.fontHeight() /2)) / renderer.fontHeight();
359 for ( uint i = firstline; i < lastline; i++ )
361 _lw = renderer.textWidth( doc->kateTextLine( i ), -1 );
366 if ( (
int)_lt == _lpp )
379 TQStringList::Iterator it;
380 for ( it=headerTagList.begin(); it!=headerTagList.end(); ++it )
381 (*it).replace( re, TQString(
"%1" ).arg( _pages ) );
382 for ( it=footerTagList.begin(); it!=footerTagList.end(); ++it )
383 (*it).replace( re, TQString(
"%1" ).arg( _pages ) );
391 while ( lineCount <= lastline )
399 if ( y + renderer.fontHeight() >= (uint)(maxHeight) )
401 kdDebug(13020)<<
"Starting new page, "<<_count<<
" lines up to now."<<
endl;
413 paint.setPen(headerFgColor);
414 paint.setFont(headerFont);
416 paint.fillRect(0, 0, headerWidth, headerHeight, headerBgColor);
417 if (headerTagList.count() == 3)
419 int valign = ( (useBox||headerDrawBg||useBackground) ?
420 TQt::AlignVCenter : TQt::AlignTop );
421 int align = valign|TQt::AlignLeft;
422 int marg = ( useBox || headerDrawBg ) ? innerMargin : 0;
423 if ( useBox ) marg += boxWidth;
425 for (
int i=0; i<3; i++)
427 s = headerTagList[i];
428 if (s.find(
"%p") != -1) s.replace(
"%p", TQString::number(currentPage));
429 paint.drawText(marg, 0, headerWidth-(marg*2), headerHeight, align, s);
430 align = valign|(i == 0 ? TQt::AlignHCenter : TQt::AlignRight);
433 if ( ! ( headerDrawBg || useBox || useBackground ) )
435 paint.drawLine( 0, headerHeight-1, headerWidth, headerHeight-1 );
438 y += headerHeight + innerMargin;
443 if ( ! ( footerDrawBg || useBox || useBackground ) )
444 paint.drawLine( 0, maxHeight + innerMargin - 1, headerWidth, maxHeight + innerMargin - 1 );
446 paint.fillRect(0, maxHeight+innerMargin+boxWidth, headerWidth, footerHeight, footerBgColor);
447 if (footerTagList.count() == 3)
449 int align = TQt::AlignVCenter|TQt::AlignLeft;
450 int marg = ( useBox || footerDrawBg ) ? innerMargin : 0;
451 if ( useBox ) marg += boxWidth;
453 for (
int i=0; i<3; i++)
455 s = footerTagList[i];
456 if (s.find(
"%p") != -1) s.replace(
"%p", TQString::number(currentPage));
457 paint.drawText(marg, maxHeight+innerMargin, headerWidth-(marg*2), footerHeight, align, s);
458 align = TQt::AlignVCenter|(i == 0 ? TQt::AlignHCenter : TQt::AlignRight);
467 int _y = y, _h = maxHeight - y;
471 _h += 2 * innerMargin;
485 paint.fillRect( 0, _y, pdmWidth, _h, renderer.config()->backgroundColor());
490 paint.setPen(TQPen(boxColor, boxWidth));
491 paint.drawRect(0, 0, pdmWidth, pdm.height());
493 paint.drawLine(0, headerHeight, headerWidth, headerHeight);
498 paint.fillRect( 0, maxHeight+innerMargin, headerWidth, boxWidth, boxColor );
501 if ( useGuide && currentPage == 1 )
506 KateAttributeList _dsList;
507 KateHlManager::self()->getDefaults ( renderer.config()->schema(), _dsList );
508 paint.setPen( _dsList.at(0)->textColor() );
512 _marg += (2*boxWidth) + (2*innerMargin);
513 paint.fillRect( 0, y+guideHeight-innerMargin-boxWidth, headerWidth, boxWidth, boxColor );
518 _marg += 2*innerMargin;
519 paint.drawRect( _marg, y, pdmWidth-(2*_marg), guideHeight );
521 y += 1 + innerMargin;
524 paint.setFont( renderer.config()->fontStruct()->myFontBold );
526 paint.drawText( _marg, y, pdmWidth-(2*_marg), maxHeight - y,
527 TQt::AlignTop|TQt::AlignHCenter,
528 i18n(
"Typographical Conventions for %1").arg(doc->highlight()->name()), -1, &_r );
529 int _w = pdmWidth - (_marg*2) - (innerMargin*2);
530 int _x = _marg + innerMargin;
531 y += _r.height() + innerMargin;
532 paint.drawLine( _x, y, _x + _w, y );
533 y += 1 + innerMargin;
536 TQPtrListIterator<KateHlItemData> _it( ilist );
538 int _cw = _w/guideCols;
541 while ( ( _d = _it.current() ) != 0 )
543 paint.setPen( renderer.attribute(_i)->textColor() );
544 paint.setFont( renderer.attribute(_i)->font( *renderer.currentFont() ) );
545 paint.drawText(( _x + ((_i%guideCols)*_cw)), y, _cw, renderer.fontHeight(),
546 TQt::AlignVCenter|TQt::AlignLeft, _d->name, -1, &_r );
548 if ( _i && ! ( _i%guideCols ) ) y += renderer.fontHeight();
551 if ( _i%guideCols ) y += renderer.fontHeight();
552 y += ( useBox ? boxWidth : 1 ) + (innerMargin*2);
558 if ( printLineNumbers && ! startCol )
560 paint.setFont( renderer.config()->fontStruct()->font(
false,
false ) );
561 paint.setPen( renderer.config()->lineNumberColor() );
562 paint.drawText( (( useBox || useBackground ) ? innerMargin : 0), y,
563 lineNumberWidth, renderer.fontHeight(),
564 TQt::AlignRight, TQString(
"%1").arg( lineCount + 1 ) );
566 endCol = renderer.textWidth(doc->kateTextLine(lineCount), startCol, maxWidth, &needWrap);
568 if ( endCol < startCol )
584 bool inBlockSelection = ( doc->blockSelectionMode() && lineCount >= firstline && lineCount <= lastline );
585 if ( lineCount == firstline || inBlockSelection )
587 if ( startCol < selStartCol )
588 startCol = selStartCol;
590 if ( lineCount == lastline || inBlockSelection )
592 if ( endCol > selEndCol )
603 range.line = lineCount;
604 range.startCol = startCol;
605 range.endCol = endCol;
606 range.wrap = needWrap;
607 paint.translate(xstart, y);
608 renderer.paintTextLine(paint, &range, 0, maxWidth);
620 y += renderer.fontHeight();
636 KatePrintTextSettings::KatePrintTextSettings( KPrinter * , TQWidget *parent,
const char *name )
637 : KPrintDialogPage( parent,
name )
639 setTitle( i18n(
"Te&xt Settings") );
641 TQVBoxLayout *lo =
new TQVBoxLayout (
this );
644 cbSelection =
new TQCheckBox( i18n(
"Print &selected text only"),
this );
645 lo->addWidget( cbSelection );
647 cbLineNumbers =
new TQCheckBox( i18n(
"Print &line numbers"),
this );
648 lo->addWidget( cbLineNumbers );
650 cbGuide =
new TQCheckBox( i18n(
"Print syntax &guide"),
this );
651 lo->addWidget( cbGuide );
658 TQWhatsThis::add( cbSelection, i18n(
659 "<p>This option is only available if some text is selected in the document.</p>"
660 "<p>If available and enabled, only the selected text is printed.</p>") );
661 TQWhatsThis::add( cbLineNumbers, i18n(
662 "<p>If enabled, line numbers will be printed on the left side of the page(s).</p>") );
663 TQWhatsThis::add( cbGuide, i18n(
664 "<p>Print a box displaying typographical conventions for the document type, as "
665 "defined by the syntax highlighting being used.") );
668 void KatePrintTextSettings::getOptions( TQMap<TQString,TQString>& opts,
bool )
670 opts[
"app-kate-printselection"] = cbSelection->isChecked() ?
"true" :
"false";
671 opts[
"app-kate-printlinenumbers"] = cbLineNumbers->isChecked() ?
"true" :
"false";
672 opts[
"app-kate-printguide"] = cbGuide->isChecked() ?
"true" :
"false" ;
675 void KatePrintTextSettings::setOptions(
const TQMap<TQString,TQString>& opts )
678 v = opts[
"app-kate-printselection"];
680 cbSelection->setChecked( v ==
"true" );
681 v = opts[
"app-kate-printlinenumbers"];
683 cbLineNumbers->setChecked( v ==
"true" );
684 v = opts[
"app-kate-printguide"];
686 cbGuide->setChecked( v ==
"true" );
689 void KatePrintTextSettings::enableSelection(
bool enable )
691 cbSelection->setEnabled( enable );
697 KatePrintHeaderFooter::KatePrintHeaderFooter( KPrinter * , TQWidget *parent,
const char *name )
698 : KPrintDialogPage( parent,
name )
700 setTitle( i18n(
"Hea&der && Footer") );
702 TQVBoxLayout *lo =
new TQVBoxLayout (
this );
704 lo->setSpacing( sp );
707 TQHBoxLayout *lo1 =
new TQHBoxLayout ( lo );
708 cbEnableHeader =
new TQCheckBox( i18n(
"Pr&int header"),
this );
709 lo1->addWidget( cbEnableHeader );
710 cbEnableFooter =
new TQCheckBox( i18n(
"Pri&nt footer"),
this );
711 lo1->addWidget( cbEnableFooter );
714 TQHBoxLayout *lo2 =
new TQHBoxLayout( lo );
715 lo2->addWidget(
new TQLabel( i18n(
"Header/footer font:"),
this ) );
716 lFontPreview =
new TQLabel(
this );
717 lFontPreview->setFrameStyle( TQFrame::Panel|TQFrame::Sunken );
718 lo2->addWidget( lFontPreview );
719 lo2->setStretchFactor( lFontPreview, 1 );
720 TQPushButton *btnChooseFont =
new TQPushButton( i18n(
"Choo&se Font..."),
this );
721 lo2->addWidget( btnChooseFont );
722 connect( btnChooseFont, TQ_SIGNAL(clicked()),
this, TQ_SLOT(setHFFont()) );
724 gbHeader =
new TQGroupBox( 2, TQt::Horizontal, i18n(
"Header Properties"),
this );
725 lo->addWidget( gbHeader );
727 TQLabel *lHeaderFormat =
new TQLabel( i18n(
"&Format:"), gbHeader );
728 TQHBox *hbHeaderFormat =
new TQHBox( gbHeader );
729 hbHeaderFormat->setSpacing( sp );
730 leHeaderLeft =
new TQLineEdit( hbHeaderFormat );
731 leHeaderCenter =
new TQLineEdit( hbHeaderFormat );
732 leHeaderRight =
new TQLineEdit( hbHeaderFormat );
733 lHeaderFormat->setBuddy( leHeaderLeft );
734 new TQLabel( i18n(
"Colors:"), gbHeader );
735 TQHBox *hbHeaderColors =
new TQHBox( gbHeader );
736 hbHeaderColors->setSpacing( sp );
737 TQLabel *lHeaderFgCol =
new TQLabel( i18n(
"Foreground:"), hbHeaderColors );
739 lHeaderFgCol->setBuddy( kcbtnHeaderFg );
740 cbHeaderEnableBgColor =
new TQCheckBox( i18n(
"Bac&kground"), hbHeaderColors );
743 gbFooter =
new TQGroupBox( 2, TQt::Horizontal, i18n(
"Footer Properties"),
this );
744 lo->addWidget( gbFooter );
747 TQLabel *lFooterFormat =
new TQLabel( i18n(
"For&mat:"), gbFooter );
748 TQHBox *hbFooterFormat =
new TQHBox( gbFooter );
749 hbFooterFormat->setSpacing( sp );
750 leFooterLeft =
new TQLineEdit( hbFooterFormat );
751 leFooterCenter =
new TQLineEdit( hbFooterFormat );
752 leFooterRight =
new TQLineEdit( hbFooterFormat );
753 lFooterFormat->setBuddy( leFooterLeft );
755 new TQLabel( i18n(
"Colors:"), gbFooter );
756 TQHBox *hbFooterColors =
new TQHBox( gbFooter );
757 hbFooterColors->setSpacing( sp );
758 TQLabel *lFooterBgCol =
new TQLabel( i18n(
"Foreground:"), hbFooterColors );
760 lFooterBgCol->setBuddy( kcbtnFooterFg );
761 cbFooterEnableBgColor =
new TQCheckBox( i18n(
"&Background"), hbFooterColors );
767 connect( cbEnableHeader, TQ_SIGNAL(toggled(
bool)), gbHeader, TQ_SLOT(setEnabled(
bool)) );
768 connect( cbEnableFooter, TQ_SIGNAL(toggled(
bool)), gbFooter, TQ_SLOT(setEnabled(
bool)) );
769 connect( cbHeaderEnableBgColor, TQ_SIGNAL(toggled(
bool)), kcbtnHeaderBg, TQ_SLOT(setEnabled(
bool)) );
770 connect( cbFooterEnableBgColor, TQ_SIGNAL(toggled(
bool)), kcbtnFooterBg, TQ_SLOT(setEnabled(
bool)) );
773 cbEnableHeader->setChecked(
true );
774 leHeaderLeft->setText(
"%y" );
775 leHeaderCenter->setText(
"%f" );
776 leHeaderRight->setText(
"%p" );
777 kcbtnHeaderFg->setColor( TQColor(
"black") );
778 cbHeaderEnableBgColor->setChecked(
true );
779 kcbtnHeaderBg->setColor( TQColor(
"lightgrey") );
781 cbEnableFooter->setChecked(
true );
782 leFooterRight->setText(
"%U" );
783 kcbtnFooterFg->setColor( TQColor(
"black") );
784 cbFooterEnableBgColor->setChecked(
true );
785 kcbtnFooterBg->setColor( TQColor(
"lightgrey") );
788 TQString s = i18n(
"<p>Format of the page header. The following tags are supported:</p>");
790 "<ul><li><tt>%u</tt>: current user name</li>"
791 "<li><tt>%d</tt>: complete date/time in short format</li>"
792 "<li><tt>%D</tt>: complete date/time in long format</li>"
793 "<li><tt>%h</tt>: current time</li>"
794 "<li><tt>%y</tt>: current date in short format</li>"
795 "<li><tt>%Y</tt>: current date in long format</li>"
796 "<li><tt>%f</tt>: file name</li>"
797 "<li><tt>%U</tt>: full URL of the document</li>"
798 "<li><tt>%p</tt>: page number</li>"
800 "<u>Note:</u> Do <b>not</b> use the '|' (vertical bar) character.");
801 TQWhatsThis::add(leHeaderRight, s + s1 );
802 TQWhatsThis::add(leHeaderCenter, s + s1 );
803 TQWhatsThis::add(leHeaderLeft, s + s1 );
804 s = i18n(
"<p>Format of the page footer. The following tags are supported:</p>");
805 TQWhatsThis::add(leFooterRight, s + s1 );
806 TQWhatsThis::add(leFooterCenter, s + s1 );
807 TQWhatsThis::add(leFooterLeft, s + s1 );
812 void KatePrintHeaderFooter::getOptions(TQMap<TQString,TQString>& opts,
bool )
814 opts[
"app-kate-hffont"] = strFont;
816 opts[
"app-kate-useheader"] = (cbEnableHeader->isChecked() ?
"true" :
"false");
817 opts[
"app-kate-headerfg"] = kcbtnHeaderFg->color().name();
818 opts[
"app-kate-headerusebg"] = (cbHeaderEnableBgColor->isChecked() ?
"true" :
"false");
819 opts[
"app-kate-headerbg"] = kcbtnHeaderBg->color().name();
820 opts[
"app-kate-headerformat"] = leHeaderLeft->text() +
"|" + leHeaderCenter->text() +
"|" + leHeaderRight->text();
822 opts[
"app-kate-usefooter"] = (cbEnableFooter->isChecked() ?
"true" :
"false");
823 opts[
"app-kate-footerfg"] = kcbtnFooterFg->color().name();
824 opts[
"app-kate-footerusebg"] = (cbFooterEnableBgColor->isChecked() ?
"true" :
"false");
825 opts[
"app-kate-footerbg"] = kcbtnFooterBg->color().name();
826 opts[
"app-kate-footerformat"] = leFooterLeft->text() +
"|" + leFooterCenter->text() +
"|" + leFooterRight->text();
829 void KatePrintHeaderFooter::setOptions(
const TQMap<TQString,TQString>& opts )
832 v = opts[
"app-kate-hffont"];
837 if (!strFont.isEmpty())
838 f.fromString( strFont );
840 lFontPreview->setFont( f );
842 lFontPreview->setText( (f.family() +
", %1pt").arg( f.pointSize() ) );
844 v = opts[
"app-kate-useheader"];
846 cbEnableHeader->setChecked( v ==
"true" );
847 v = opts[
"app-kate-headerfg"];
849 kcbtnHeaderFg->setColor( TQColor( v ) );
850 v = opts[
"app-kate-headerusebg"];
852 cbHeaderEnableBgColor->setChecked( v ==
"true" );
853 v = opts[
"app-kate-headerbg"];
855 kcbtnHeaderBg->setColor( TQColor( v ) );
857 TQStringList tags = TQStringList::split(
'|', opts[
"app-kate-headerformat"],
"true");
858 if (tags.count() == 3)
860 leHeaderLeft->setText(tags[0]);
861 leHeaderCenter->setText(tags[1]);
862 leHeaderRight->setText(tags[2]);
865 v = opts[
"app-kate-usefooter"];
867 cbEnableFooter->setChecked( v ==
"true" );
868 v = opts[
"app-kate-footerfg"];
870 kcbtnFooterFg->setColor( TQColor( v ) );
871 v = opts[
"app-kate-footerusebg"];
873 cbFooterEnableBgColor->setChecked( v ==
"true" );
874 v = opts[
"app-kate-footerbg"];
876 kcbtnFooterBg->setColor( TQColor( v ) );
878 tags = TQStringList::split(
'|', opts[
"app-kate-footerformat"],
"true");
879 if (tags.count() == 3)
881 leFooterLeft->setText(tags[0]);
882 leFooterCenter->setText(tags[1]);
883 leFooterRight->setText(tags[2]);
887 void KatePrintHeaderFooter::setHFFont()
889 TQFont fnt( lFontPreview->font() );
894 strFont = fnt.toString();
896 lFontPreview->setFont( fnt );
897 lFontPreview->setText( (fnt.family() +
", %1pt").arg( fnt.pointSize() ) );
905 KatePrintLayout::KatePrintLayout( KPrinter * , TQWidget *parent,
const char *name )
906 : KPrintDialogPage( parent,
name )
908 setTitle( i18n(
"L&ayout") );
910 TQVBoxLayout *lo =
new TQVBoxLayout (
this );
913 TQHBox *hb =
new TQHBox(
this );
915 TQLabel *lSchema =
new TQLabel( i18n(
"&Schema:"), hb );
916 cmbSchema =
new TQComboBox(
false, hb );
917 lSchema->setBuddy( cmbSchema );
919 cbDrawBackground =
new TQCheckBox( i18n(
"Draw bac&kground color"),
this );
920 lo->addWidget( cbDrawBackground );
922 cbEnableBox =
new TQCheckBox( i18n(
"Draw &boxes"),
this );
923 lo->addWidget( cbEnableBox );
925 gbBoxProps =
new TQGroupBox( 2, TQt::Horizontal, i18n(
"Box Properties"),
this );
926 lo->addWidget( gbBoxProps );
928 TQLabel *lBoxWidth =
new TQLabel( i18n(
"W&idth:"), gbBoxProps );
929 sbBoxWidth =
new TQSpinBox( 1, 100, 1, gbBoxProps );
930 lBoxWidth->setBuddy( sbBoxWidth );
932 TQLabel *lBoxMargin =
new TQLabel( i18n(
"&Margin:"), gbBoxProps );
933 sbBoxMargin =
new TQSpinBox( 0, 100, 1, gbBoxProps );
934 lBoxMargin->setBuddy( sbBoxMargin );
936 TQLabel *lBoxColor =
new TQLabel( i18n(
"Co&lor:"), gbBoxProps );
938 lBoxColor->setBuddy( kcbtnBoxColor );
940 connect( cbEnableBox, TQ_SIGNAL(toggled(
bool)), gbBoxProps, TQ_SLOT(setEnabled(
bool)) );
944 sbBoxMargin->setValue( 6 );
945 gbBoxProps->setEnabled(
false );
946 cmbSchema->insertStringList (KateFactory::self()->schemaManager()->list ());
947 cmbSchema->setCurrentItem( 1 );
953 TQWhatsThis::add( cbDrawBackground, i18n(
954 "<p>If enabled, the background color of the editor will be used.</p>"
955 "<p>This may be useful if your color scheme is designed for a dark background.</p>") );
956 TQWhatsThis::add( cbEnableBox, i18n(
957 "<p>If enabled, a box as defined in the properties below will be drawn "
958 "around the contents of each page. The Header and Footer will be separated "
959 "from the contents with a line as well.</p>") );
960 TQWhatsThis::add( sbBoxWidth, i18n(
961 "The width of the box outline" ) );
962 TQWhatsThis::add( sbBoxMargin, i18n(
963 "The margin inside boxes, in pixels") );
964 TQWhatsThis::add( kcbtnBoxColor, i18n(
965 "The line color to use for boxes") );
968 void KatePrintLayout::getOptions(TQMap<TQString,TQString>& opts,
bool )
970 opts[
"app-kate-colorscheme"] = cmbSchema->currentText();
971 opts[
"app-kate-usebackground"] = cbDrawBackground->isChecked() ?
"true" :
"false";
972 opts[
"app-kate-usebox"] = cbEnableBox->isChecked() ?
"true" :
"false";
973 opts[
"app-kate-boxwidth"] = sbBoxWidth->cleanText();
974 opts[
"app-kate-boxmargin"] = sbBoxMargin->cleanText();
975 opts[
"app-kate-boxcolor"] = kcbtnBoxColor->color().name();
978 void KatePrintLayout::setOptions(
const TQMap<TQString,TQString>& opts )
981 v = opts[
"app-kate-colorscheme"];
983 cmbSchema->setCurrentItem( KateFactory::self()->schemaManager()->number( v ) );
984 v = opts[
"app-kate-usebackground"];
986 cbDrawBackground->setChecked( v ==
"true" );
987 v = opts[
"app-kate-usebox"];
989 cbEnableBox->setChecked( v ==
"true" );
990 v = opts[
"app-kate-boxwidth"];
992 sbBoxWidth->setValue( v.toInt() );
993 v = opts[
"app-kate-boxmargin"];
995 sbBoxMargin->setValue( v.toInt() );
996 v = opts[
"app-kate-boxcolor"];
998 kcbtnBoxColor->setColor( TQColor( v ) );
1002 #include "kateprinter.moc"
Handles all of the work of rendering the text (used for the views and printing)
static int getFont(TQFont &theFont, bool onlyFixed=false, TQWidget *parent=0L, bool makeFrame=true, TQButton::ToggleState *sizeIsRelativeState=0L)
static TDELocale * locale()
TQString formatDateTime(const TQDateTime &pDateTime, bool shortFormat=true, bool includeSecs=false) const
TQString formatDate(const TQDate &pDate, bool shortFormat=false) const
TQString formatTime(const TQTime &pTime, bool includeSecs, bool isDuration) const
kndbgstream & endl(kndbgstream &s)
kdbgstream kdDebug(int area=0)
TQString name(StdAccel id)