F:/KPlato/koffice/libs/kotext/KoLayoutTab.cpp

Aller à la documentation de ce fichier.
00001 /* This file is part of the KDE project
00002    Copyright (C)  2001, 2002 Montel Laurent <lmontel@mandrakesoft.com>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library is distributed in the hope that it will be useful,
00010    but WITHOUT ANY WARRANTY; without even the implied warranty of
00011    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012    Library General Public License for more details.
00013 
00014    You should have received a copy of the GNU Library General Public License
00015    along with this library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
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/*, name, fl*/ )
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;       // subscript has a default
00071     case 2:
00072         return 0;       // superscript has got a default
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 }

Généré le Wed Nov 22 23:41:08 2006 pour KPlato par  doxygen 1.5.1-p1