F:/KPlato/koffice/libs/kotext/KoDecorationTab.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 "KoDecorationTab.h"
00021 #include <KoGlobal.h>
00022 
00023 #include <kcolorbutton.h>
00024 #include <kpushbutton.h>
00025 #include <knuminput.h>
00026 #include <klocale.h>
00027 
00028 #include <q3buttongroup.h>
00029 
00030 #include "KoDecorationTab.moc"
00031 
00032 KoDecorationTab::KoDecorationTab( QWidget* parent )
00033     : KoDecorationTabBase( parent )
00034 {
00035     shadowDistanceKDoubleNumInput->setRange(0, 9, 0.5, false);
00036 
00037     connect( textKColorButton, SIGNAL( changed( const QColor& ) ), this, SIGNAL( fontColorChanged( const QColor& ) ) );
00038     connect( backgroundKColorButton, SIGNAL( changed( const QColor& ) ), this, SIGNAL( backgroundColorChanged( const QColor& ) ) );
00039     connect( shadowKColorButton, SIGNAL( changed( const QColor& ) ), this, SIGNAL( shadowColorChanged( const QColor& ) ) );
00040     connect( shadowDistanceKDoubleNumInput, SIGNAL( valueChanged( double ) ), this, SIGNAL( shadowDistanceChanged( double ) ) );
00041     connect( shadowDirectionButtonGroup, SIGNAL( clicked( int ) ), this, SIGNAL( shadowDirectionChanged( int ) ) );
00042 }
00043 
00044 KoDecorationTab::~KoDecorationTab()
00045 {
00046 }
00047 
00048 QColor KoDecorationTab::getTextColor() const
00049 {
00050     return textKColorButton->color();
00051 }
00052 
00053 QColor KoDecorationTab::getBackgroundColor() const
00054 {
00055     return backgroundKColorButton->color();
00056 }
00057 
00058 double KoDecorationTab::getShadowDistanceX() const
00059 {
00060     short int sd = shadowDirectionButtonGroup->selectedId();
00061     double dist = shadowDistanceKDoubleNumInput->value();
00062     return shadowDistanceX( sd, dist );
00063 }
00064 
00065 double KoDecorationTab::getShadowDistanceY() const
00066 {
00067     short int sd = shadowDirectionButtonGroup->selectedId();
00068     double dist = shadowDistanceKDoubleNumInput->value();
00069     return shadowDistanceY( sd, dist );
00070 }
00071 
00072 QColor KoDecorationTab::getShadowColor() const
00073 {
00074     return shadowKColorButton->color();
00075 }
00076 
00077 void KoDecorationTab::setTextColor( const QColor &color )
00078 {
00079     textKColorButton->setColor( color );
00080 }
00081 
00082 void KoDecorationTab::setBackgroundColor( const QColor &color )
00083 {
00084         backgroundKColorButton->setColor( color );
00085 }
00086 
00087 void KoDecorationTab::setShadow( double shadowDistanceX, double shadowDistanceY, const QColor& shadowColor )
00088 {
00089     short int sd = SD_RIGHT_UP;
00090     double dist = 0.0;
00091 
00092     if ( shadowDistanceX > 0 ) // right
00093         if ( shadowDistanceY == 0 )
00094             sd = SD_RIGHT;
00095         else
00096             sd = shadowDistanceY > 0 ? SD_RIGHT_BOTTOM : SD_RIGHT_UP;
00097     else if ( shadowDistanceX == 0 ) // top/bottom
00098         sd = shadowDistanceY > 0 ? SD_BOTTOM : SD_UP;
00099     else // left
00100         if ( shadowDistanceY == 0 )
00101             sd = SD_LEFT;
00102         else
00103             sd = shadowDistanceY > 0 ? SD_LEFT_BOTTOM : SD_LEFT_UP;
00104 
00105     shadowDirectionButtonGroup->setButton( sd );
00106 
00107     dist = qMax( QABS(shadowDistanceX), QABS(shadowDistanceY) );
00108     shadowDistanceKDoubleNumInput->setValue( dist );
00109 
00110     shadowKColorButton->setColor( shadowColor.isValid() ? shadowColor: Qt::gray  );
00111 
00112 }
00113 
00114 double KoDecorationTab::shadowDistanceX( short int sd, double dist ) const
00115 {
00116     switch ( sd )
00117     {
00118     case SD_LEFT_BOTTOM:
00119     case SD_LEFT:
00120     case SD_LEFT_UP:
00121         return - dist;
00122     case SD_UP:
00123     case SD_BOTTOM:
00124         return 0;
00125     case SD_RIGHT_UP:
00126     case SD_RIGHT:
00127     case SD_RIGHT_BOTTOM:
00128         return dist;
00129     }
00130     return 0;
00131 }
00132 
00133 double KoDecorationTab::shadowDistanceY( short int sd, double dist ) const
00134 {
00135     switch ( sd )
00136     {
00137     case SD_LEFT_UP:
00138     case SD_UP:
00139     case SD_RIGHT_UP:
00140         return - dist;
00141     case SD_LEFT:
00142     case SD_RIGHT:
00143         return 0;
00144     case SD_LEFT_BOTTOM:
00145     case SD_BOTTOM:
00146     case SD_RIGHT_BOTTOM:
00147         return dist;
00148     }
00149     return 0;
00150 }

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