You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
387 lines
12 KiB
387 lines
12 KiB
15 years ago
|
/*
|
||
|
* khexedit - Versatile hex editor
|
||
|
* Copyright (C) 1999 Espen Sand, espensa@online.no
|
||
|
*
|
||
|
* This program is free software; you can redistribute it and/or modify
|
||
|
* it under the terms of the GNU General Public License as published by
|
||
|
* the Free Software Foundation; either version 2 of the License, or
|
||
|
* (at your option) any later version.
|
||
|
*
|
||
|
* This program is distributed in the hope that it will be useful,
|
||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
* GNU General Public License for more details.
|
||
|
*
|
||
|
* You should have received a copy of the GNU General Public License
|
||
|
* along with this program; if not, write to the Free Software
|
||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
*
|
||
|
*/
|
||
|
|
||
13 years ago
|
#include <tqlayout.h>
|
||
15 years ago
|
#include <tqbuttongroup.h>
|
||
|
#include <tqspinbox.h>
|
||
|
#include <tqlabel.h>
|
||
|
#include <tqcheckbox.h>
|
||
|
#include <tqstringlist.h>
|
||
|
#include <tqcombobox.h>
|
||
15 years ago
|
|
||
12 years ago
|
#include <tdelocale.h>
|
||
15 years ago
|
|
||
|
|
||
|
#include "printdialogpage.h"
|
||
|
|
||
13 years ago
|
LayoutDialogPage::LayoutDialogPage( TQWidget *parent, const char *name )
|
||
|
: KPrintDialogPage( parent, name )
|
||
15 years ago
|
{
|
||
|
mConfig = 0;
|
||
|
setTitle( i18n( "Page Layout" ) );
|
||
|
setupLayoutPage();
|
||
|
|
||
|
readConfiguration();
|
||
|
}
|
||
|
|
||
|
|
||
|
LayoutDialogPage::~LayoutDialogPage( void )
|
||
|
{
|
||
|
writeConfiguration();
|
||
|
|
||
|
delete mConfig; mConfig = 0;
|
||
|
}
|
||
|
|
||
|
|
||
|
void LayoutDialogPage::setupLayoutPage( void )
|
||
|
{
|
||
15 years ago
|
TQString text;
|
||
|
TQVBoxLayout *topLayout = new TQVBoxLayout( this, 0, 6 /*KDialog::mSpacingSize*/ );
|
||
15 years ago
|
if( topLayout == 0 ) { return; }
|
||
|
|
||
|
text = i18n("Margins [millimeter]");
|
||
15 years ago
|
TQButtonGroup *group = new TQButtonGroup( text, this );
|
||
15 years ago
|
if( group == 0 ) { return; }
|
||
|
topLayout->addWidget( group );
|
||
|
|
||
15 years ago
|
TQGridLayout *gbox = new TQGridLayout( group, 3, 6, 6 /*KDialog::mSpacingSize*/ );
|
||
15 years ago
|
if( gbox == 0 ) { return; }
|
||
|
gbox->addRowSpacing( 0, group->fontMetrics().height() );
|
||
|
gbox->setColStretch( 5, 10 );
|
||
|
|
||
15 years ago
|
TQString name[4];
|
||
15 years ago
|
int i;
|
||
|
|
||
|
name[0] = i18n("&Top:");
|
||
|
name[1] = i18n("&Bottom:");
|
||
|
name[2] = i18n("&Left:");
|
||
|
name[3] = i18n("&Right:");
|
||
|
|
||
|
for( i=0; i<4; i++ )
|
||
|
{
|
||
15 years ago
|
mLayout.marginSpin[i] = new TQSpinBox( group );
|
||
15 years ago
|
mLayout.marginSpin[i]->setFixedHeight(
|
||
13 years ago
|
mLayout.marginSpin[i]->sizeHint().height() );
|
||
15 years ago
|
mLayout.marginSpin[i]->setMinimumWidth(
|
||
|
mLayout.marginSpin[i]->fontMetrics().width("M")*10 );
|
||
|
mLayout.marginSpin[i]->setRange( 0, INT_MAX );
|
||
|
|
||
15 years ago
|
TQLabel *label = new TQLabel( mLayout.marginSpin[i], name[i], group );
|
||
13 years ago
|
label->setFixedHeight( mLayout.marginSpin[i]->sizeHint().height() );
|
||
|
label->setFixedWidth( label->sizeHint().width() );
|
||
15 years ago
|
|
||
|
if( i < 2 )
|
||
|
{
|
||
|
gbox->addWidget( label, i+1, 0, AlignLeft );
|
||
|
gbox->addWidget( mLayout.marginSpin[i], i+1, 1, AlignLeft );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
gbox->addWidget( label, i-1, 3, AlignLeft );
|
||
|
gbox->addWidget( mLayout.marginSpin[i], i-1, 4, AlignLeft );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
text = i18n("Draw h&eader above text");
|
||
15 years ago
|
mLayout.headerCheck = new TQCheckBox( text, this );
|
||
13 years ago
|
mLayout.headerCheck->setFixedSize( mLayout.headerCheck->sizeHint() );
|
||
15 years ago
|
connect( mLayout.headerCheck, TQT_SIGNAL( toggled(bool)),
|
||
|
TQT_SLOT( slotDrawHeader(bool)));
|
||
15 years ago
|
topLayout->addWidget( mLayout.headerCheck, 0, AlignLeft );
|
||
|
|
||
15 years ago
|
gbox = new TQGridLayout( 5, 6, 0 );
|
||
15 years ago
|
if( gbox == 0 ) { return; }
|
||
|
topLayout->addLayout( gbox );
|
||
|
|
||
|
gbox->setColStretch ( 5, 10 );
|
||
|
gbox->addColSpacing( 1, 6 /*KDialog::mSpacingSize*/ );
|
||
|
gbox->addColSpacing( 3, 6 /*KDialog::mSpacingSize*/ );
|
||
|
gbox->addRowSpacing( 2, 6 /*KDialog::mSpacingSize*/ );
|
||
|
|
||
|
name[0] = i18n("Left:");
|
||
|
name[1] = i18n("Center:");
|
||
|
name[2] = i18n("Right:");
|
||
|
name[3] = i18n("Border:");
|
||
|
|
||
15 years ago
|
TQStringList textList;
|
||
15 years ago
|
textList.append(i18n("None"));
|
||
|
textList.append(i18n("Date & Time"));
|
||
|
textList.append(i18n("Page Number"));
|
||
|
textList.append(i18n("Filename"));
|
||
|
|
||
15 years ago
|
TQStringList lineList;
|
||
15 years ago
|
lineList.append(i18n("None"));
|
||
|
lineList.append(i18n("Single Line"));
|
||
|
lineList.append(i18n("Rectangle"));
|
||
|
|
||
|
for( i=0; i<4; i++ )
|
||
|
{
|
||
15 years ago
|
mLayout.headerCombo[i] = new TQComboBox( false, this );
|
||
15 years ago
|
mLayout.headerCombo[i]->setFixedHeight(
|
||
13 years ago
|
mLayout.headerCombo[i]->sizeHint().height() );
|
||
15 years ago
|
mLayout.headerCombo[i]->setMinimumWidth(
|
||
|
mLayout.headerCombo[i]->fontMetrics().width("M")*10 );
|
||
|
|
||
15 years ago
|
mLayout.headerLabel[i] = new TQLabel( mLayout.headerCombo[i], name[i],
|
||
15 years ago
|
this );
|
||
|
mLayout.headerLabel[i]->setFixedHeight(
|
||
13 years ago
|
mLayout.headerLabel[i]->sizeHint().height() );
|
||
15 years ago
|
mLayout.headerLabel[i]->setFixedWidth(
|
||
13 years ago
|
mLayout.headerLabel[i]->sizeHint().width() );
|
||
15 years ago
|
|
||
|
if( i<3 )
|
||
|
{
|
||
|
mLayout.headerCombo[i]->insertStringList( textList );
|
||
|
gbox->addWidget( mLayout.headerLabel[i], 0, i*2, AlignLeft );
|
||
|
gbox->addWidget( mLayout.headerCombo[i], 1, i*2, AlignLeft );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
mLayout.headerCombo[i]->insertStringList( lineList );
|
||
|
gbox->addWidget( mLayout.headerLabel[i], 3, 0, AlignLeft );
|
||
|
gbox->addWidget( mLayout.headerCombo[i], 4, 0, AlignLeft );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
text = i18n("Draw &footer below text");
|
||
15 years ago
|
mLayout.footerCheck = new TQCheckBox( text, this );
|
||
13 years ago
|
mLayout.footerCheck->setFixedSize( mLayout.footerCheck->sizeHint() );
|
||
15 years ago
|
connect( mLayout.footerCheck, TQT_SIGNAL( toggled(bool)),
|
||
|
TQT_SLOT( slotDrawFooter(bool)));
|
||
15 years ago
|
topLayout->addWidget( mLayout.footerCheck, 0, AlignLeft );
|
||
|
|
||
15 years ago
|
gbox = new TQGridLayout( 5, 6, 0 );
|
||
15 years ago
|
if( gbox == 0 ) { return; }
|
||
|
topLayout->addLayout( gbox );
|
||
|
|
||
|
gbox->setColStretch ( 5, 10 );
|
||
|
gbox->addColSpacing( 1, 6 /*KDialog::mSpacingSize*/ );
|
||
|
gbox->addColSpacing( 3, 6 /*KDialog::mSpacingSize*/ );
|
||
|
gbox->addRowSpacing( 2, 6 /*KDialog::mSpacingSize*/ );
|
||
|
|
||
|
for( i=0; i<4; i++ )
|
||
|
{
|
||
15 years ago
|
mLayout.footerCombo[i] = new TQComboBox( false, this );
|
||
15 years ago
|
mLayout.footerCombo[i]->setFixedHeight(
|
||
13 years ago
|
mLayout.footerCombo[i]->sizeHint().height() );
|
||
15 years ago
|
mLayout.footerCombo[i]->setMinimumWidth(
|
||
|
mLayout.footerCombo[i]->fontMetrics().width("M")*10 );
|
||
|
|
||
15 years ago
|
mLayout.footerLabel[i] = new TQLabel( mLayout.footerCombo[i], name[i],
|
||
15 years ago
|
this );
|
||
|
mLayout.footerLabel[i]->setFixedHeight(
|
||
13 years ago
|
mLayout.footerLabel[i]->sizeHint().height() );
|
||
15 years ago
|
mLayout.footerLabel[i]->setFixedWidth(
|
||
13 years ago
|
mLayout.footerLabel[i]->sizeHint().width() );
|
||
15 years ago
|
|
||
|
if( i<3 )
|
||
|
{
|
||
|
mLayout.footerCombo[i]->insertStringList( textList );
|
||
|
gbox->addWidget( mLayout.footerLabel[i], 0, i*2, AlignLeft );
|
||
|
gbox->addWidget( mLayout.footerCombo[i], 1, i*2, AlignLeft );
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
mLayout.footerCombo[i]->insertStringList( lineList );
|
||
|
gbox->addWidget( mLayout.footerLabel[i], 3, 0, AlignLeft );
|
||
|
gbox->addWidget( mLayout.footerCombo[i], 4, 0, AlignLeft );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
for( i=0; i<4; i++ )
|
||
|
{
|
||
|
mLayout.marginSpin[i]->setValue( 15 );
|
||
|
}
|
||
|
mLayout.headerCheck->setChecked( true );
|
||
|
slotDrawHeader( true );
|
||
|
mLayout.footerCheck->setChecked( true );
|
||
|
slotDrawFooter( true );
|
||
|
|
||
|
topLayout->addStretch(10);
|
||
|
}
|
||
|
|
||
|
|
||
|
void LayoutDialogPage::readConfiguration( void )
|
||
|
{
|
||
|
if( mConfig != 0 ) { return; }
|
||
|
|
||
15 years ago
|
mConfig = new KSimpleConfig( TQString("hexprinter") );
|
||
15 years ago
|
if( mConfig == 0 ) { return; }
|
||
|
|
||
|
mConfig->setGroup( "PageLayout" );
|
||
|
int val = mConfig->readNumEntry( "MarginTop", 15 );
|
||
|
mLayout.marginSpin[0]->setValue( val );
|
||
|
val = mConfig->readNumEntry( "MarginBottom", 15 );
|
||
|
mLayout.marginSpin[1]->setValue( val );
|
||
|
val = mConfig->readNumEntry( "MarginLeft", 15 );
|
||
|
mLayout.marginSpin[2]->setValue( val );
|
||
|
val = mConfig->readNumEntry( "MarginRight", 15 );
|
||
|
mLayout.marginSpin[3]->setValue( val );
|
||
|
bool state = mConfig->readBoolEntry( "DrawHeader", true );
|
||
|
mLayout.headerCheck->setChecked( state );
|
||
|
slotDrawHeader( state );
|
||
|
state = mConfig->readBoolEntry( "DrawFooter", true );
|
||
|
mLayout.footerCheck->setChecked( state );
|
||
|
slotDrawFooter( state );
|
||
|
|
||
|
mLayout.headerCombo[0]->setCurrentItem(
|
||
|
headerTextIndex( mConfig->readEntry("HeaderLeft","DateTime")));
|
||
|
mLayout.headerCombo[1]->setCurrentItem(
|
||
|
headerTextIndex( mConfig->readEntry("HeaderCenter")));
|
||
|
mLayout.headerCombo[2]->setCurrentItem(
|
||
|
headerTextIndex( mConfig->readEntry("HeaderRight","FileName")));
|
||
|
mLayout.headerCombo[3]->setCurrentItem(
|
||
|
headerLineIndex( mConfig->readEntry("HeaderLine","SingleLine")));
|
||
|
|
||
|
mLayout.footerCombo[0]->setCurrentItem(
|
||
|
headerTextIndex( mConfig->readEntry("FooterLeft")));
|
||
|
mLayout.footerCombo[1]->setCurrentItem(
|
||
|
headerTextIndex( mConfig->readEntry("FooterCenter","PageNumber")));
|
||
|
mLayout.footerCombo[2]->setCurrentItem(
|
||
|
headerTextIndex( mConfig->readEntry("FooterRight")));
|
||
|
mLayout.footerCombo[3]->setCurrentItem(
|
||
|
headerLineIndex( mConfig->readEntry("FooterLine","SingleLine")));
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
void LayoutDialogPage::writeConfiguration( void )
|
||
|
{
|
||
|
if( mConfig == 0 )
|
||
|
{
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
mConfig->setGroup( "PageLayout" );
|
||
|
mConfig->writeEntry( "MarginTop", mLayout.marginSpin[0]->value() );
|
||
|
mConfig->writeEntry( "MarginBottom", mLayout.marginSpin[1]->value() );
|
||
|
mConfig->writeEntry( "MarginLeft", mLayout.marginSpin[2]->value() );
|
||
|
mConfig->writeEntry( "MarginRight", mLayout.marginSpin[3]->value() );
|
||
|
mConfig->writeEntry( "DrawHeader", mLayout.headerCheck->isChecked() );
|
||
|
mConfig->writeEntry( "DrawFooter", mLayout.footerCheck->isChecked() );
|
||
|
|
||
|
mConfig->writeEntry( "HeaderLeft",
|
||
|
headerText( mLayout.headerCombo[0]->currentItem() ) );
|
||
|
mConfig->writeEntry( "HeaderCenter",
|
||
|
headerText( mLayout.headerCombo[1]->currentItem() ) );
|
||
|
mConfig->writeEntry( "HeaderRight",
|
||
|
headerText( mLayout.headerCombo[2]->currentItem() ) );
|
||
|
mConfig->writeEntry( "HeaderLine",
|
||
|
headerLine( mLayout.headerCombo[3]->currentItem() ) );
|
||
|
|
||
|
mConfig->writeEntry( "FooterLeft",
|
||
|
headerText( mLayout.footerCombo[0]->currentItem() ) );
|
||
|
mConfig->writeEntry( "FooterCenter",
|
||
|
headerText( mLayout.footerCombo[1]->currentItem() ) );
|
||
|
mConfig->writeEntry( "FooterRight",
|
||
|
headerText( mLayout.footerCombo[2]->currentItem() ) );
|
||
|
mConfig->writeEntry( "FooterLine",
|
||
|
headerLine( mLayout.footerCombo[3]->currentItem() ) );
|
||
|
|
||
|
mConfig->sync();
|
||
|
}
|
||
|
|
||
|
|
||
15 years ago
|
TQString LayoutDialogPage::headerText( uint index )
|
||
15 years ago
|
{
|
||
15 years ago
|
static const TQString text[4] = {"None","DateTime","PageNumber","FileName"};
|
||
15 years ago
|
return( text[ index > 3 ? 0 : index ] );
|
||
|
}
|
||
|
|
||
|
|
||
15 years ago
|
int LayoutDialogPage::headerTextIndex( const TQString & headerText )
|
||
15 years ago
|
{
|
||
15 years ago
|
static const TQString text[4] = {"None","DateTime","PageNumber","FileName"};
|
||
15 years ago
|
if( headerText != 0 )
|
||
|
{
|
||
|
for( int i=0; i<4; i++ )
|
||
|
{
|
||
|
if( headerText == text[i] ) { return( i ); }
|
||
|
}
|
||
|
}
|
||
|
return( 0 );
|
||
|
}
|
||
|
|
||
|
|
||
15 years ago
|
TQString LayoutDialogPage::headerLine( uint index )
|
||
15 years ago
|
{
|
||
15 years ago
|
static const TQString text[3] = {"None","SingleLine","Rectangle"};
|
||
15 years ago
|
return( text[ index > 2 ? 0 : index ] );
|
||
|
}
|
||
|
|
||
|
|
||
15 years ago
|
int LayoutDialogPage::headerLineIndex( const TQString & headerLine )
|
||
15 years ago
|
{
|
||
15 years ago
|
static const TQString text[3] = {"None","SingleLine","Rectangle"};
|
||
15 years ago
|
if( headerLine != 0 )
|
||
|
{
|
||
|
for( int i=0; i<3; i++ )
|
||
|
{
|
||
|
if( headerLine == text[i] ) { return( i ); }
|
||
|
}
|
||
|
}
|
||
|
return( 0 );
|
||
|
}
|
||
|
|
||
|
|
||
|
void LayoutDialogPage::slotDrawHeader( bool state )
|
||
|
{
|
||
|
for( int i=0; i<4; i++ )
|
||
|
{
|
||
|
mLayout.headerLabel[i]->setEnabled( state );
|
||
|
mLayout.headerCombo[i]->setEnabled( state );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
void LayoutDialogPage::slotDrawFooter( bool state )
|
||
|
{
|
||
|
for( int i=0; i<4; i++ )
|
||
|
{
|
||
|
mLayout.footerLabel[i]->setEnabled( state );
|
||
|
mLayout.footerCombo[i]->setEnabled( state );
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
15 years ago
|
void LayoutDialogPage::getOptions( TQMap<TQString,TQString>& opts, bool /*incldef*/ )
|
||
15 years ago
|
{
|
||
15 years ago
|
opts[ "kde-khexedit-topmarginmm" ] = TQString::number( mLayout.marginSpin[0]->value() );
|
||
|
opts[ "kde-khexedit-bottommarginmm" ] = TQString::number( mLayout.marginSpin[1]->value() );
|
||
|
opts[ "kde-khexedit-leftmarginmm" ] = TQString::number( mLayout.marginSpin[2]->value() );
|
||
|
opts[ "kde-khexedit-rightmarginmm" ] = TQString::number( mLayout.marginSpin[3]->value() );
|
||
15 years ago
|
|
||
|
opts[ "kde-khexedit-headercheck" ] = (mLayout.headerCheck->isChecked() ? "true" : "false");
|
||
15 years ago
|
opts[ "kde-khexedit-headercombo0" ] = TQString::number( mLayout.headerCombo[0]->currentItem() );
|
||
|
opts[ "kde-khexedit-headercombo1" ] = TQString::number( mLayout.headerCombo[1]->currentItem() );
|
||
|
opts[ "kde-khexedit-headercombo2" ] = TQString::number( mLayout.headerCombo[2]->currentItem() );
|
||
|
opts[ "kde-khexedit-headercombo3" ] = TQString::number( mLayout.headerCombo[3]->currentItem() );
|
||
15 years ago
|
|
||
|
opts[ "kde-khexedit-footercheck" ] = (mLayout.footerCheck->isChecked() ? "true" : "false");
|
||
15 years ago
|
opts[ "kde-khexedit-footercombo0" ] = TQString::number( mLayout.footerCombo[0]->currentItem() );
|
||
|
opts[ "kde-khexedit-footercombo1" ] = TQString::number( mLayout.footerCombo[1]->currentItem() );
|
||
|
opts[ "kde-khexedit-footercombo2" ] = TQString::number( mLayout.footerCombo[2]->currentItem() );
|
||
|
opts[ "kde-khexedit-footercombo3" ] = TQString::number( mLayout.footerCombo[3]->currentItem() );
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
|
#include "printdialogpage.moc"
|