kpresenter

KPrMoveHelpLineDia.cpp

00001 // -*- Mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; -*-
00002 /* This file is part of the KDE project
00003    Copyright (C)  2002 Montel Laurent <lmontel@mandrakesoft.com>
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Library General Public
00007    License as published by the Free Software Foundation; either
00008    version 2 of the License, or (at your option) any later version.
00009 
00010    This library is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013    Library General Public License for more details.
00014 
00015    You should have received a copy of the GNU Library General Public License
00016    along with this library; see the file COPYING.LIB.  If not, write to
00017    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #include <klocale.h>
00022 #include <qvbox.h>
00023 #include <qlayout.h>
00024 #include <qlabel.h>
00025 #include <knuminput.h>
00026 #include <qbuttongroup.h>
00027 #include <qradiobutton.h>
00028 #include <KoUnit.h>
00029 #include <klineedit.h>
00030 #include <knumvalidator.h>
00031 #include <KoUnitWidgets.h>
00032 
00033 #include "KPrMoveHelpLineDia.h"
00034 #include "KPrDocument.h"
00035 
00036 
00037 KPrMoveHelpLineDia::KPrMoveHelpLineDia( QWidget *parent, double value, double limitTop, double limitBottom,
00038                                         KPrDocument *_doc, const char *name)
00039     : KDialogBase( parent, name , true, "", Ok | Cancel | User1, Ok, true )
00040 {
00041     m_doc=_doc;
00042     m_bRemoveLine = false;
00043 
00044     setButtonText( KDialogBase::User1, i18n("Remove") );
00045     setCaption( i18n("Change Help Line Position") );
00046     QVBox *page = makeVBoxMainWidget();
00047     new QLabel(i18n("Position:"), page);
00048     position= new KoUnitDoubleSpinBox( page, QMAX(0.00, limitTop), QMAX(0.00, limitBottom), 1, QMAX(0.00, value));
00049     position->setUnit(m_doc->unit() );
00050 
00051     connect( this, SIGNAL( user1Clicked() ), this ,SLOT( slotRemoveHelpLine() ));
00052     resize( 300,100 );
00053 }
00054 
00055 void KPrMoveHelpLineDia::slotRemoveHelpLine()
00056 {
00057     m_bRemoveLine = true;
00058     KDialogBase::slotOk();
00059 }
00060 
00061 double KPrMoveHelpLineDia::newPosition() const
00062 {
00063     return position->value();
00064 }
00065 
00066 
00067 KPrInsertHelpLineDia::KPrInsertHelpLineDia( QWidget *parent, const KoRect & _pageRect,
00068                                             KPrDocument *_doc, const char *name)
00069     : KDialogBase( parent, name , true, "", Ok|Cancel, Ok, true )
00070 {
00071     limitOfPage=_pageRect;
00072     m_doc=_doc;
00073     setCaption( i18n("Add New Help Line") );
00074     QVBox *page = makeVBoxMainWidget();
00075     QButtonGroup *group = new QButtonGroup( 1, QGroupBox::Horizontal,i18n("Orientation"), page );
00076     group->setRadioButtonExclusive( TRUE );
00077     group->layout();
00078     m_rbHoriz = new QRadioButton( i18n("Horizontal"), group );
00079     m_rbVert = new QRadioButton( i18n("Vertical"), group );
00080 
00081     connect( group , SIGNAL( clicked( int) ), this, SLOT( slotRadioButtonClicked() ));
00082 
00083     new QLabel(i18n("Position:"), page);
00084 
00085     position= new KoUnitDoubleSpinBox( page,QMAX(0.00, limitOfPage.top() ), QMAX(0.00, limitOfPage.bottom()),1,0.00 );
00086 
00087     position->setUnit( m_doc->unit() );
00088     m_rbHoriz->setChecked( true );
00089     resize( 300,100 );
00090 }
00091 
00092 double KPrInsertHelpLineDia::newPosition() const
00093 {
00094     return position->value();
00095 }
00096 
00097 bool KPrInsertHelpLineDia::addHorizontalHelpLine()
00098 {
00099     return m_rbHoriz->isChecked();
00100 }
00101 
00102 void KPrInsertHelpLineDia::slotRadioButtonClicked()
00103 {
00104     if ( m_rbHoriz->isChecked() )
00105     {
00106         position->setMinValue( QMAX(0.00, limitOfPage.top() ) );
00107         position->setMaxValue( QMAX(0.00, limitOfPage.bottom() ) );
00108     }
00109     else if ( m_rbVert->isChecked() )
00110     {
00111         position->setMinValue( QMAX(0.00, limitOfPage.left()) );
00112         position->setMaxValue( QMAX(0.00, limitOfPage.right()) );
00113     }
00114 }
00115 
00116 KPrInsertHelpPointDia::KPrInsertHelpPointDia( QWidget *parent, const KoRect & _pageRect,
00117                                               KPrDocument *_doc, double posX, double posY, const char *name)
00118     : KDialogBase( parent, name , true, "", Ok|Cancel| User1, Ok, true ),
00119       m_bRemovePoint( false )
00120 {
00121     limitOfPage=_pageRect;
00122     m_doc=_doc;
00123     setButtonText( KDialogBase::User1, i18n("Remove") );
00124     setCaption( i18n("Add New Help Point") );
00125     QVBox *page = makeVBoxMainWidget();
00126     QLabel *lab=new QLabel(i18n("X position:"), page);
00127     positionX= new KoUnitDoubleSpinBox( page, QMAX(0.00, limitOfPage.left()),QMAX(0.00, limitOfPage.right()),1,QMAX(0.00, posX) ) ;
00128     positionX->setUnit( m_doc->unit() );
00129 
00130 
00131     lab=new QLabel(i18n("Y position:"), page);
00132     positionY= new KoUnitDoubleSpinBox( page, QMAX(0.00, limitOfPage.top()),QMAX(0.00, limitOfPage.bottom()),1,  QMAX(0.00, posY) );
00133     positionY->setUnit( m_doc->unit() );
00134 
00135     showButton( KDialogBase::User1, (posX!=0.0 || posY!=0.0) );
00136 
00137     connect( this, SIGNAL( user1Clicked() ), this ,SLOT( slotRemoveHelpPoint() ));
00138 
00139     resize( 300,100 );
00140 }
00141 
00142 KoPoint KPrInsertHelpPointDia::newPosition() const
00143 {
00144     return KoPoint( positionX->value(),
00145                     positionY->value() );
00146 }
00147 
00148 void KPrInsertHelpPointDia::slotRemoveHelpPoint()
00149 {
00150     m_bRemovePoint = true;
00151     KDialogBase::slotOk();
00152 }
00153 
00154 #include "KPrMoveHelpLineDia.moc"
KDE Home | KDE Accessibility Home | Description of Access Keys