20#include <KoPageLayoutDia.h>
21#include <KoPageLayoutSize.h>
23#include <KoUnitWidgets.h>
26#include <kiconloader.h>
27#include <tdemessagebox.h>
32#include <tqradiobutton.h>
34#include <tqvgroupbox.h>
35#include <tqhbuttongroup.h>
38 : TQWidget(parent), m_blockSignals(false) {
45 TQWidget* unitFrame = new TQWidget( this );
46 grid1->addWidget( unitFrame, 0, 0, TQt::AlignLeft );
50 TQLabel *lpgUnit = new TQLabel( i18n( "Unit:" ), unitFrame );
51 unitLayout->addWidget( lpgUnit, 0, TQt::AlignRight | TQt::AlignVCenter );
54 TQComboBox *cpgUnit = new TQComboBox( false, unitFrame, "cpgUnit" );
55 lpgUnit->setBuddy( cpgUnit );
56 cpgUnit->insertStringList( KoUnit::listOfUnitName() );
57 cpgUnit->setCurrentItem( unit );
58 unitLayout->addWidget( cpgUnit, 0, TQt::AlignLeft | TQt::AlignVCenter );
59 connect( cpgUnit, TQ_SIGNAL( activated( int ) ), this, TQ_SLOT( setUnitInt( int ) ) );
64 TQLabel *lpgUnit = new TQLabel( i18n( "All values are given in %1.").arg(str), this );
65 grid1->addWidget( lpgUnit, 0, 0, TQt::AlignLeft );
69 TQVGroupBox *formatFrame = new TQVGroupBox( i18n( "Page Size" ), this );
70 grid1->addWidget( formatFrame, 1, 0 );
72 TQHBox *formatPageSize = new TQHBox( formatFrame );
76 TQLabel *lpgFormat = new TQLabel( i18n( "&Size:" ), formatPageSize );
79 cpgFormat = new TQComboBox( false, formatPageSize, "cpgFormat" );
80 cpgFormat->insertStringList( KoPageFormat::allFormats() );
81 lpgFormat->setBuddy( cpgFormat );
82 connect( cpgFormat, TQ_SIGNAL( activated( int ) ), this, TQ_SLOT( formatChanged( int ) ) );
85 formatPageSize->setStretchFactor( new TQWidget( formatPageSize ), 10 );
87 TQHBox *formatCustomSize = new TQHBox( formatFrame );
91 TQLabel *lpgWidth = new TQLabel( i18n( "&Width:" ), formatCustomSize );
95 lpgWidth->setBuddy( epgWidth );
96 if ( m_layout.format != PG_CUSTOM )
97 epgWidth->setEnabled( false );
98 connect( epgWidth, TQ_SIGNAL( valueChangedPt( double) ), this, TQ_SLOT( widthChanged( double) ) );
101 TQLabel *lpgHeight = new TQLabel( i18n( "&Height:" ), formatCustomSize );
105 lpgHeight->setBuddy( epgHeight );
106 if ( m_layout.format != PG_CUSTOM )
107 epgHeight->setEnabled( false );
108 connect( epgHeight, TQ_SIGNAL( valueChangedPt( double ) ), this, TQ_SLOT( heightChanged( double) ) );
111 m_orientGroup = new TQHButtonGroup( i18n( "Orientation" ), this );
113 grid1->addWidget( m_orientGroup, 2, 0 );
115 TQLabel* lbPortrait = new TQLabel( m_orientGroup );
116 lbPortrait->setPixmap( TQPixmap( UserIcon( "koPortrait" ) ) );
117 lbPortrait->setMaximumWidth( lbPortrait->pixmap()->width() );
118 new TQRadioButton( i18n( "&Portrait"), m_orientGroup );
120 TQLabel* lbLandscape = new TQLabel( m_orientGroup );
121 lbLandscape->setPixmap( TQPixmap( UserIcon( "koLandscape" ) ) );
122 lbLandscape->setMaximumWidth( lbLandscape->pixmap()->width() );
123 new TQRadioButton( i18n( "La&ndscape"), m_orientGroup );
125 connect( m_orientGroup, TQ_SIGNAL (clicked ( int)), this, TQ_SLOT( orientationChanged( int) ));
128 TQVGroupBox *marginsFrame = new TQVGroupBox( i18n( "Margins" ), this );
129 marginsFrame->setColumnLayout( 0, TQt::Vertical );
131 grid1->addWidget( marginsFrame, 3, 0 );
133 TQGridLayout *marginsLayout = new TQGridLayout( marginsFrame->layout(), 3, 3,
138 marginsLayout->addWidget( ebrLeft, 1, 0 );
139 connect( ebrLeft, TQ_SIGNAL( valueChangedPt( double ) ), this, TQ_SLOT( leftChanged( double ) ) );
143 marginsLayout->addWidget( ebrRight, 1, 2 );
144 connect( ebrRight, TQ_SIGNAL( valueChangedPt( double ) ), this, TQ_SLOT( rightChanged( double ) ) );
148 marginsLayout->addWidget( ebrTop, 0, 1 , TQt::AlignCenter );
149 connect( ebrTop, TQ_SIGNAL( valueChangedPt( double ) ), this, TQ_SLOT( topChanged( double ) ) );
153 marginsLayout->addWidget( ebrBottom, 2, 1, TQt::AlignCenter );
154 connect( ebrBottom, TQ_SIGNAL( valueChangedPt( double ) ), this, TQ_SLOT( bottomChanged( double ) ) );
158 grid1->addMultiCellWidget( pgPreview, 1, 3, 1, 1 );
161 TQWidget* spacer1 = new TQWidget( this );
162 TQWidget* spacer2 = new TQWidget( this );
163 spacer1->setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding,
164 TQSizePolicy::Expanding ) );
165 spacer2->setSizePolicy( TQSizePolicy( TQSizePolicy::Expanding,
166 TQSizePolicy::Expanding ) );
167 grid1->addWidget( spacer1, 4, 0 );
168 grid1->addWidget( spacer2, 4, 1 );
172 pgPreview->setPageColumns( columns );
178 ebrLeft->setEnabled( on );
179 ebrRight->setEnabled( on );
180 ebrTop->setEnabled( on );
181 ebrBottom->setEnabled( on );
184 m_layout.ptLeft = on?ebrLeft->value():0;
185 m_layout.ptRight = on?ebrRight->value():0;
186 m_layout.ptTop = on?ebrTop->value():0;
187 m_layout.ptBottom = on?ebrBottom->value():0;
194void KoPageLayoutSize::updatePreview() {
198void KoPageLayoutSize::setValues() {
200 cpgFormat->setCurrentItem( m_layout.format );
202 m_orientGroup->setButton( m_layout.orientation == PG_PORTRAIT ? 0: 1 );
210 m_blockSignals = true;
212 epgWidth->setUnit( m_unit );
214 epgWidth->changeValue( m_layout.ptWidth );
216 epgHeight->setUnit( m_unit );
218 epgHeight->changeValue( m_layout.ptHeight );
222 ebrLeft->setUnit( m_unit );
223 ebrLeft->changeValue( m_layout.ptLeft );
224 ebrLeft->setMinMaxStep( 0, m_layout.ptWidth, dStep );
226 ebrRight->setUnit( m_unit );
227 ebrRight->changeValue( m_layout.ptRight );
228 ebrRight->setMinMaxStep( 0, m_layout.ptWidth, dStep );
230 ebrTop->setUnit( m_unit );
231 ebrTop->changeValue( m_layout.ptTop );
232 ebrTop->setMinMaxStep( 0, m_layout.ptHeight, dStep );
234 ebrBottom->setUnit( m_unit );
235 ebrBottom->changeValue( m_layout.ptBottom );
236 ebrBottom->setMinMaxStep( 0, m_layout.ptHeight, dStep );
238 m_blockSignals = false;
241void KoPageLayoutSize::setUnitInt( int unit ) {
245void KoPageLayoutSize::formatChanged( int format ) {
246 if ( ( KoFormat )format == m_layout.format )
248 m_layout.format = ( KoFormat )format;
249 bool enable = (KoFormat) format == PG_CUSTOM;
250 epgWidth->setEnabled( enable );
251 epgHeight->setEnabled( enable );
253 if ( m_layout.format != PG_CUSTOM ) {
254 m_layout.ptWidth = MM_TO_POINT( KoPageFormat::width(
255 m_layout.format, m_layout.orientation ) );
256 m_layout.ptHeight = MM_TO_POINT( KoPageFormat::height(
257 m_layout.format, m_layout.orientation ) );
260 epgWidth->changeValue( m_layout.ptWidth );
261 epgHeight->changeValue( m_layout.ptHeight );
267void KoPageLayoutSize::orientationChanged( int which) {
268 m_layout.orientation = which == 0 ? PG_PORTRAIT : PG_LANDSCAPE;
271 double val = epgWidth->value();
272 epgWidth->changeValue(epgHeight->value());
273 epgHeight->changeValue(val);
275 m_blockSignals = true;
276 val = ebrTop->value();
277 if(m_layout.orientation == PG_PORTRAIT) {
278 ebrTop->changeValue(ebrRight->value());
279 ebrRight->changeValue(ebrBottom->value());
280 ebrBottom->changeValue(ebrLeft->value());
281 ebrLeft->changeValue(val);
283 ebrTop->changeValue(ebrLeft->value());
284 ebrLeft->changeValue(ebrBottom->value());
285 ebrBottom->changeValue(ebrRight->value());
286 ebrRight->changeValue(val);
288 m_blockSignals = false;
293void KoPageLayoutSize::widthChanged( double width) {
294 if(m_blockSignals) return;
295 m_layout.ptWidth = width;
299void KoPageLayoutSize::heightChanged( double height) {
300 if(m_blockSignals) return;
301 m_layout.ptHeight = height;
305void KoPageLayoutSize::leftChanged( double left ) {
306 if(m_blockSignals) return;
307 m_layout.ptLeft = left;
311void KoPageLayoutSize::rightChanged( double right) {
312 if(m_blockSignals) return;
313 m_layout.ptRight = right;
317void KoPageLayoutSize::topChanged( double top) {
318 if(m_blockSignals) return;
319 m_layout.ptTop = top;
323void KoPageLayoutSize::bottomChanged( double bottom) {
324 if(m_blockSignals) return;
325 m_layout.ptBottom = bottom;
331 if ( m_layout.ptLeft + m_layout.ptRight > m_layout.ptWidth ) {
333 i18n( "The page width is smaller than the left and right margins."),
334 i18n( "Page Layout Problem") );
337 if ( m_layout.ptTop + m_layout.ptBottom > m_layout.ptHeight ) {
339 i18n( "The page height is smaller than the top and bottom margins."),
340 i18n( "Page Layout Problem") );
347 pgPreview->setPageColumns(columns);
350#include <KoPageLayoutSize.moc>
static void error(TQWidget *parent, const TQString &text, const TQString &caption=TQString::null, int options=Notify)
void setEnableBorders(bool on) Enable the user to edit the page border size.
void setColumns(KoColumns &columns) Update the page preview widget with the param columns.
KoPageLayoutSize(TQWidget *parent, const KoPageLayout &layout, KoUnit::Unit unit, const KoColumns &columns, bool unitChooser, bool enableBorders) Contructor.
void setUnit(KoUnit::Unit unit) Set a new unit for the widget updating the widgets.
void propertyChange(KoPageLayout &layout) Emitted whenever the user changed something in the dialog.
void setPageLayout(const KoPageLayout &) set page layout
Spin box for double precision numbers with unit display.
static double fromUserValue(double value, Unit unit) This method is the one to use to read a value from a dialog.
static TQString unitDescription(Unit _unit) Get the full (translated) description of a unit.
Unit Length units supported by KOffice.
This structure defines the page layout, including its size in pt, its format (e.g.
|