00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "KoLayoutTab.h"
00021 #include "KoTextFormat.h"
00022
00023 #include <knuminput.h>
00024
00025 #include <q3buttongroup.h>
00026 #include <QCheckBox>
00027 #include <QSpinBox>
00028
00029 #include "KoLayoutTab.moc"
00030
00031 KoLayoutTab::KoLayoutTab( bool withSubSuperScript, QWidget* parent, const char* name, Qt::WFlags fl )
00032 : KoLayoutTabBase( parent )
00033 {
00034 if ( !withSubSuperScript ) positionButtonGroup->hide();
00035
00036 connect( positionButtonGroup, SIGNAL( clicked( int ) ), this, SLOT( slotSubSuperScriptChanged( int ) ) );
00037 connect( offsetSpinBox, SIGNAL( valueChanged( int ) ), this, SIGNAL( offsetChanged( int ) ) );
00038 connect( relativeSizeKDoubleSpinBox, SIGNAL( valueChanged( double ) ), this, SLOT( slotRelativeSizeChanged( double ) ) );
00039 connect( hyphenateCheckBox, SIGNAL( toggled( bool ) ), this, SIGNAL( hyphenationChanged( bool ) ) );
00040 }
00041
00042 KoLayoutTab::~KoLayoutTab()
00043 {
00044 }
00045
00046 KoTextFormat::VerticalAlignment KoLayoutTab::getSubSuperScript() const
00047 {
00048 switch ( positionButtonGroup->selectedId() )
00049 {
00050 case 0:
00051 return KoTextFormat::AlignNormal;
00052 case 1:
00053 return KoTextFormat::AlignSubScript;
00054 case 2:
00055 return KoTextFormat::AlignSuperScript;
00056 case 3:
00057 return KoTextFormat::AlignCustom;
00058 default:
00059 return KoTextFormat::AlignNormal;
00060 }
00061 }
00062
00063 int KoLayoutTab::getOffsetFromBaseline() const
00064 {
00065 switch ( positionButtonGroup->selectedId() )
00066 {
00067 case 0:
00068 return 0;
00069 case 1:
00070 return 0;
00071 case 2:
00072 return 0;
00073 case 3:
00074 return offsetSpinBox->value();
00075 default:
00076 return 0;
00077 }
00078 }
00079
00080 double KoLayoutTab::getRelativeTextSize() const
00081 {
00082 switch ( positionButtonGroup->selectedId() )
00083 {
00084 case 0:
00085 return 1.0;
00086 case 1:
00087 return relativeSizeKDoubleSpinBox->value() / 100;
00088 case 2:
00089 return relativeSizeKDoubleSpinBox->value() / 100;
00090 case 3:
00091 return relativeSizeKDoubleSpinBox->value() / 100;
00092 default:
00093 return 1.0;
00094 }
00095 }
00096
00097 bool KoLayoutTab::getAutoHyphenation() const
00098 {
00099 return hyphenateCheckBox->isOn();
00100 }
00101
00102 void KoLayoutTab::setSubSuperScript( KoTextFormat::VerticalAlignment subSuperScript, int offset, double relativeSize )
00103 {
00104 switch ( static_cast< int >( subSuperScript ) )
00105 {
00106 case 0:
00107 positionButtonGroup->setButton( 0 );
00108 break;
00109 case 1:
00110 positionButtonGroup->setButton( 1 );
00111 relativeSizeKDoubleSpinBox->setValue( relativeSize * 100 );
00112 break;
00113 case 2:
00114 positionButtonGroup->setButton( 2 );
00115 relativeSizeKDoubleSpinBox->setValue( relativeSize * 100 );
00116 break;
00117 case 3:
00118 positionButtonGroup->setButton( 3 );
00119 offsetSpinBox->setValue( offset );
00120 relativeSizeKDoubleSpinBox->setValue( relativeSize * 100 );
00121 break;
00122 default:
00123 positionButtonGroup->setButton( 0 );
00124 break;
00125 }
00126 slotSubSuperScriptChanged( static_cast< int >( subSuperScript ) );
00127 }
00128
00129 void KoLayoutTab::setAutoHyphenation( bool state )
00130 {
00131 hyphenateCheckBox->setChecked( state );
00132 }
00133
00134 void KoLayoutTab::slotSubSuperScriptChanged( int item )
00135 {
00136 if ( item == 1 || item == 2 ) offsetSpinBox->setValue( 0 );
00137 emit subSuperScriptChanged();
00138 if ( item ) {
00139 emit relativeSizeChanged( relativeSizeKDoubleSpinBox->value() / 100 );
00140 emit offsetChanged( offsetSpinBox->value() );
00141 }
00142 }
00143
00144 void KoLayoutTab::slotRelativeSizeChanged( double relativeSize )
00145 {
00146 emit relativeSizeChanged( relativeSize / 100 );
00147 }