kpresenter

KPrMoveHelpLineDia.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2002 Montel Laurent <lmontel@mandrakesoft.com>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#include <tdelocale.h>
21#include <tqvbox.h>
22#include <tqlayout.h>
23#include <tqlabel.h>
24#include <knuminput.h>
25#include <tqbuttongroup.h>
26#include <tqradiobutton.h>
27#include <KoUnit.h>
28#include <klineedit.h>
29#include <knumvalidator.h>
30#include <KoUnitWidgets.h>
31
32#include "KPrMoveHelpLineDia.h"
33#include "KPrDocument.h"
34
35
36KPrMoveHelpLineDia::KPrMoveHelpLineDia( TQWidget *parent, double value, double limitTop, double limitBottom,
37 KPrDocument *_doc, const char *name)
38 : KDialogBase( parent, name , true, "", Ok | Cancel | User1, Ok, true )
39{
40 m_doc=_doc;
41 m_bRemoveLine = false;
42
43 setButtonText( KDialogBase::User1, i18n("Remove") );
44 setCaption( i18n("Change Help Line Position") );
45 TQVBox *page = makeVBoxMainWidget();
46 new TQLabel(i18n("Position:"), page);
47 position= new KoUnitDoubleSpinBox( page, TQMAX(0.00, limitTop), TQMAX(0.00, limitBottom), 1, TQMAX(0.00, value));
48 position->setUnit(m_doc->unit() );
49
50 connect( this, TQ_SIGNAL( user1Clicked() ), this ,TQ_SLOT( slotRemoveHelpLine() ));
51 resize( 300,100 );
52}
53
54void KPrMoveHelpLineDia::slotRemoveHelpLine()
55{
56 m_bRemoveLine = true;
57 KDialogBase::slotOk();
58}
59
60double KPrMoveHelpLineDia::newPosition() const
61{
62 return position->value();
63}
64
65
66KPrInsertHelpLineDia::KPrInsertHelpLineDia( TQWidget *parent, const KoRect & _pageRect,
67 KPrDocument *_doc, const char *name)
68 : KDialogBase( parent, name , true, "", Ok|Cancel, Ok, true )
69{
70 limitOfPage=_pageRect;
71 m_doc=_doc;
72 setCaption( i18n("Add New Help Line") );
73 TQVBox *page = makeVBoxMainWidget();
74 TQButtonGroup *group = new TQButtonGroup( 1, TQt::Horizontal,i18n("Orientation"), page );
75 group->setRadioButtonExclusive( true );
76 group->layout();
77 m_rbHoriz = new TQRadioButton( i18n("Horizontal"), group );
78 m_rbVert = new TQRadioButton( i18n("Vertical"), group );
79
80 connect( group , TQ_SIGNAL( clicked( int) ), this, TQ_SLOT( slotRadioButtonClicked() ));
81
82 new TQLabel(i18n("Position:"), page);
83
84 position= new KoUnitDoubleSpinBox( page,TQMAX(0.00, limitOfPage.top() ), TQMAX(0.00, limitOfPage.bottom()),1,0.00 );
85
86 position->setUnit( m_doc->unit() );
87 m_rbHoriz->setChecked( true );
88 resize( 300,100 );
89}
90
91double KPrInsertHelpLineDia::newPosition() const
92{
93 return position->value();
94}
95
96bool KPrInsertHelpLineDia::addHorizontalHelpLine()
97{
98 return m_rbHoriz->isChecked();
99}
100
101void KPrInsertHelpLineDia::slotRadioButtonClicked()
102{
103 if ( m_rbHoriz->isChecked() )
104 {
105 position->setMinValue( TQMAX(0.00, limitOfPage.top() ) );
106 position->setMaxValue( TQMAX(0.00, limitOfPage.bottom() ) );
107 }
108 else if ( m_rbVert->isChecked() )
109 {
110 position->setMinValue( TQMAX(0.00, limitOfPage.left()) );
111 position->setMaxValue( TQMAX(0.00, limitOfPage.right()) );
112 }
113}
114
115KPrInsertHelpPointDia::KPrInsertHelpPointDia( TQWidget *parent, const KoRect & _pageRect,
116 KPrDocument *_doc, double posX, double posY, const char *name)
117 : KDialogBase( parent, name , true, "", Ok|Cancel| User1, Ok, true ),
118 m_bRemovePoint( false )
119{
120 limitOfPage=_pageRect;
121 m_doc=_doc;
122 setButtonText( KDialogBase::User1, i18n("Remove") );
123 setCaption( i18n("Add New Help Point") );
124 TQVBox *page = makeVBoxMainWidget();
125 TQLabel *lab=new TQLabel(i18n("X position:"), page);
126 positionX= new KoUnitDoubleSpinBox( page, TQMAX(0.00, limitOfPage.left()),TQMAX(0.00, limitOfPage.right()),1,TQMAX(0.00, posX) ) ;
127 positionX->setUnit( m_doc->unit() );
128
129
130 lab=new TQLabel(i18n("Y position:"), page);
131 positionY= new KoUnitDoubleSpinBox( page, TQMAX(0.00, limitOfPage.top()),TQMAX(0.00, limitOfPage.bottom()),1, TQMAX(0.00, posY) );
132 positionY->setUnit( m_doc->unit() );
133
134 showButton( KDialogBase::User1, (posX!=0.0 || posY!=0.0) );
135
136 connect( this, TQ_SIGNAL( user1Clicked() ), this ,TQ_SLOT( slotRemoveHelpPoint() ));
137
138 resize( 300,100 );
139}
140
141KoPoint KPrInsertHelpPointDia::newPosition() const
142{
143 return KoPoint( positionX->value(),
144 positionY->value() );
145}
146
147void KPrInsertHelpPointDia::slotRemoveHelpPoint()
148{
149 m_bRemovePoint = true;
150 KDialogBase::slotOk();
151}
152
153#include "KPrMoveHelpLineDia.moc"