25#include <KoPageLayoutDia.h>
26#include <KoPageLayoutColumns.h>
27#include <KoPageLayoutSize.h>
28#include <KoPageLayoutHeader.h>
30#include <KoUnitWidgets.h>
33#include <kiconloader.h>
34#include <tdemessagebox.h>
39#include <tqlineedit.h>
40#include <tqbuttongroup.h>
41#include <tqradiobutton.h>
42#include <tqcheckbox.h>
44#include <tqvgroupbox.h>
45#include <tqhbuttongroup.h>
53 : TQGroupBox( i18n( "Page Preview" ), parent, name )
57 setMinimumSize( 150, 150 );
69 double resolutionX = POINT_TO_INCH( static_cast<double>(KoGlobal::dpiX()) );
70 double resolutionY = POINT_TO_INCH( static_cast<double>(KoGlobal::dpiY()) );
72 m_pageWidth = layout. ptWidth * resolutionX;
73 m_pageHeight = layout. ptHeight * resolutionY;
75 double zh = 110.0 / m_pageHeight;
76 double zw = 110.0 / m_pageWidth;
77 double z = TQMIN( zw, zh );
82 m_textFrameX = layout. ptLeft * resolutionX * z;
83 m_textFrameY = layout. ptTop * resolutionY * z;
84 m_textFrameWidth = m_pageWidth - ( layout. ptLeft + layout. ptRight ) * resolutionX * z;
85 m_textFrameHeight = m_pageHeight - ( layout. ptTop + layout. ptBottom ) * resolutionY * z;
91void KoPagePreview::setPageColumns( const KoColumns &_columns )
93 columns = _columns.columns;
98void KoPagePreview::drawContents( TQPainter *painter )
100 double cw = m_textFrameWidth;
102 cw/= static_cast<double>(columns);
104 painter->setBrush( white );
105 painter->setPen( TQPen( black ) );
107 int x= static_cast<int>( ( width() - m_pageWidth ) * 0.5 );
108 int y= static_cast<int>( ( height() - m_pageHeight ) * 0.5 );
109 int w= static_cast<int>(m_pageWidth);
110 int h= static_cast<int>(m_pageHeight);
112 painter->drawRect( x, y, w, h );
114 painter->setBrush( TQBrush( black, HorPattern ) );
115 if ( m_textFrameWidth == m_pageWidth || m_textFrameHeight == m_pageHeight )
116 painter->setPen( NoPen );
118 painter->setPen( lightGray );
120 for ( int i = 0; i < columns; ++i )
121 painter->drawRect( x + static_cast<int>(m_textFrameX) + static_cast<int>(i * cw),
122 y + static_cast<int>(m_textFrameY), static_cast<int>(cw),
123 static_cast<int>(m_textFrameHeight) );
146 m_column.columns = 1;
148 if ( tabs & FORMAT_AND_BORDERS ) setupTab1( true );
149 if ( tabs & HEADER_AND_FOOTER ) setupTab2( hf );
151 setFocusPolicy( TQWidget::StrongFocus );
174 if ( tabs & FORMAT_AND_BORDERS ) setupTab1( !( tabs & DISABLE_BORDERS ) );
175 if ( tabs & HEADER_AND_FOOTER ) setupTab2( hf );
176 if ( tabs & COLUMNS ) setupTab3();
177 if ( tabs & KW_HEADER_AND_FOOTER ) setupTab4(kwhf);
179 setFocusPolicy( TQWidget::StrongFocus );
194 if ( dlg->exec() == TQDialog::Accepted ) {
196 if ( tabs & FORMAT_AND_BORDERS ) layout = dlg-> layout();
197 if ( tabs & HEADER_AND_FOOTER ) hf = dlg-> headFoot();
213 if ( dlg->exec() == TQDialog::Accepted ) {
215 if ( tabs & FORMAT_AND_BORDERS ) layout = dlg-> layout();
216 if ( tabs & HEADER_AND_FOOTER ) hf = dlg-> headFoot();
217 if ( tabs & COLUMNS ) columns = dlg->columns();
218 if ( tabs & KW_HEADER_AND_FOOTER ) _kwhf = dlg->headerFooter();
237 hf.headLeft = eHeadLeft->text();
238 hf.headMid = eHeadMid->text();
239 hf.headRight = eHeadRight->text();
240 hf.footLeft = eFootLeft->text();
241 hf.footMid = eFootMid->text();
242 hf.footRight = eFootRight->text();
253void KoPageLayoutDia::setupTab1( bool enableBorders )
255 TQWidget *tab1 = addPage(i18n( "Page Size && &Margins" ));
256 TQHBoxLayout *lay = new TQHBoxLayout(tab1);
257 m_pageSizeTab = new KoPageLayoutSize(tab1, m_layout, m_unit, m_column, !(flags & DISABLE_UNIT), enableBorders );
258 lay->addWidget(m_pageSizeTab);
259 m_pageSizeTab->show();
260 connect (m_pageSizeTab, TQ_SIGNAL( propertyChange( KoPageLayout&)),
264void KoPageLayoutDia::sizeUpdated( KoPageLayout &layout) {
278void KoPageLayoutDia::setupTab2( const KoHeadFoot& hf )
280 TQWidget *tab2 = addPage(i18n( "H&eader && Footer" ));
284 TQGroupBox *gHead = new TQGroupBox( 0, TQt::Vertical, i18n( "Head Line" ), tab2 );
287 TQGridLayout *headGrid = new TQGridLayout( gHead->layout(), 2, 3 );
289 TQLabel *lHeadLeft = new TQLabel( i18n( "Left:" ), gHead );
290 headGrid->addWidget( lHeadLeft, 0, 0 );
292 eHeadLeft = new TQLineEdit( gHead );
293 headGrid->addWidget( eHeadLeft, 1, 0 );
294 eHeadLeft->setText( hf.headLeft );
296 TQLabel *lHeadMid = new TQLabel( i18n( "Mid:" ), gHead );
297 headGrid->addWidget( lHeadMid, 0, 1 );
299 eHeadMid = new TQLineEdit( gHead );
300 headGrid->addWidget( eHeadMid, 1, 1 );
301 eHeadMid->setText( hf.headMid );
303 TQLabel *lHeadRight = new TQLabel( i18n( "Right:" ), gHead );
304 headGrid->addWidget( lHeadRight, 0, 2 );
306 eHeadRight = new TQLineEdit( gHead );
307 headGrid->addWidget( eHeadRight, 1, 2 );
308 eHeadRight->setText( hf.headRight );
310 grid2->addMultiCellWidget( gHead, 0, 1, 0, 1 );
313 TQGroupBox *gFoot = new TQGroupBox( 0, TQt::Vertical, i18n( "Foot Line" ), tab2 );
316 TQGridLayout *footGrid = new TQGridLayout( gFoot->layout(), 2, 3 );
318 TQLabel *lFootLeft = new TQLabel( i18n( "Left:" ), gFoot );
319 footGrid->addWidget( lFootLeft, 0, 0 );
321 eFootLeft = new TQLineEdit( gFoot );
322 footGrid->addWidget( eFootLeft, 1, 0 );
323 eFootLeft->setText( hf.footLeft );
325 TQLabel *lFootMid = new TQLabel( i18n( "Mid:" ), gFoot );
326 footGrid->addWidget( lFootMid, 0, 1 );
328 eFootMid = new TQLineEdit( gFoot );
329 footGrid->addWidget( eFootMid, 1, 1 );
330 eFootMid->setText( hf.footMid );
332 TQLabel *lFootRight = new TQLabel( i18n( "Right:" ), gFoot );
333 footGrid->addWidget( lFootRight, 0, 2 );
335 eFootRight = new TQLineEdit( gFoot );
336 footGrid->addWidget( eFootRight, 1, 2 );
337 eFootRight->setText( hf.footRight );
339 grid2->addMultiCellWidget( gFoot, 2, 3, 0, 1 );
341 TQLabel *lMacros2 = new TQLabel( i18n( "You can insert several tags in the text:" ), tab2 );
342 grid2->addMultiCellWidget( lMacros2, 4, 4, 0, 1 );
344 TQLabel *lMacros3 = new TQLabel( i18n( "<qt><ul><li><sheet> The sheet name</li>"
345 "<li><page> The current page</li>"
346 "<li><pages> The total number of pages</li>"
347 "<li><name> The filename or URL</li>"
348 "<li><file> The filename with complete path or the URL</li></ul></qt>"), tab2 );
349 grid2->addMultiCellWidget( lMacros3, 5, 6, 0, 0, TQt::AlignTop );
351 TQLabel *lMacros4 = new TQLabel( i18n( "<qt><ul><li><time> The current time</li>"
352 "<li><date> The current date</li>"
353 "<li><author> Your full name</li>"
354 "<li><org> Your organization</li>"
355 "<li><email> Your email address</li></ul></qt>"), tab2 );
356 grid2->addMultiCellWidget( lMacros4, 5, 6, 1, 1, TQt::AlignTop );
360void KoPageLayoutDia::setupTab3()
362 TQWidget *tab3 = addPage(i18n( "Col&umns" ));
363 TQHBoxLayout *lay = new TQHBoxLayout(tab3);
365 m_columnsTab->layout()->setMargin(0);
366 lay->addWidget(m_columnsTab);
367 m_columnsTab->show();
368 connect (m_columnsTab, TQ_SIGNAL( propertyChange( KoColumns&)),
369 this, TQ_SLOT (columnsUpdated( KoColumns&)));
372void KoPageLayoutDia::columnsUpdated( KoColumns &columns) {
373 m_column.columns = columns.columns;
374 m_column.ptColumnSpacing = columns.ptColumnSpacing;
382 TQWidget *tab4 = addPage(i18n( "H&eader && Footer" ));
383 TQHBoxLayout *lay = new TQHBoxLayout(tab4);
385 m_headerTab->layout()->setMargin(0);
386 lay->addWidget(m_headerTab);
395void KoPageLayoutDia::slotOk()
402#include <KoPageLayoutDia.moc>
TQFrame * addPage(const TQString &itemName, const TQString &header=TQString::null, const TQPixmap &pixmap=TQPixmap())
This class is a widget that shows the KoColumns data structure and allows the user to change it.
void setLayout(KoPageLayout &layout) Update the page preview widget with the param layout.
With this dialog the user can specify the layout of the paper during printing.
static bool pageLayout(KoPageLayout &, KoHeadFoot &, int tabs, KoUnit::Unit &unit, TQWidget *parent=0) Show page layout dialog.
KoPageLayoutDia(TQWidget *parent, const char *name, const KoPageLayout &layout, const KoHeadFoot &headfoot, int flags, KoUnit::Unit unit, bool modal=true) Constructor.
KoUnit::Unit unit() const Returns the unit.
const KoPageLayout & layout() const Returns the layout.
~KoPageLayoutDia() Destructor.
KoHeadFoot headFoot() const Returns the header and footer information.
static TDE_DEPRECATED KoPageLayout standardLayout() Retrieves a standard page layout.
This class is a widget that shows the KoPageLayout data structure and allows the user to change it.
void setColumns(KoColumns &columns) Update the page preview widget with the param columns.
~KoPagePreview() destructor
KoPagePreview(TQWidget *, const char *, const KoPageLayout &) constructor
void setPageLayout(const KoPageLayout &) set page layout
Unit Length units supported by KOffice.
This structure defines the page layout, including its size in pt, its format (e.g.
KoFormat format Page format.
double ptRight Right margin in pt.
double ptHeight Page height in pt.
KoOrientation orientation Page orientation.
double ptLeft Left margin in pt.
double ptBottom Bottom margin in pt.
double ptWidth Page width in pt.
static KOFFICECORE_EXPORT KoPageLayout standardLayout()
double ptTop Top margin in pt.
|