1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
/* This file is part of the KDE project
Copyright (C) 2002 Montel Laurent <lmontel@mandrakesoft.com>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "kchartPageLayout.h"
#include "kchartPageLayout.moc"
#include "kchart_params.h"
#include <knumvalidator.h>
#include <tqlineedit.h>
#include <tqlayout.h>
#include <klocale.h>
#include <tqlabel.h>
#include <tqgroupbox.h>
namespace KChart
{
KChartPageLayout::KChartPageLayout( KChartParams* _params, TQWidget* parent, const char* name )
: KDialogBase( parent, name, TRUE,i18n("Page Layout"),KDialogBase::Ok | KDialogBase::Cancel | KDialogBase::User1 | KDialogBase::Apply , KDialogBase::Ok,true )
{
params=_params;
#if 0
TQWidget *page = new TQWidget( this );
#else
TQGroupBox* page = new TQGroupBox( 2, Qt::Horizontal, i18n("Margins"),
this );
#endif
setMainWidget(page);
// FIXME: The following code is strange, since it is written to
// use a grid layout with a standard TQWidget. However, with the
// TQGroupBox, it looks better, and since it actually works, there
// is no immediate need for rewriting. In the sake of clarity, it
// should be done though, and we should use the layout
// capabilities of the groupbox instead..
setButtonText( KDialogBase::User1, i18n("&Reset") );
TQGridLayout *grid = new TQGridLayout(page, 4, 2, KDialog::marginHint(), KDialog::spacingHint());
TQLabel *lab=new TQLabel(i18n("Left:"),page);
grid->addWidget(lab,0,0);
leftBorder=new TQLineEdit(page);
leftBorder->setValidator( new KIntValidator( 0,9999,leftBorder ) );
grid->addWidget(leftBorder,1,0);
lab=new TQLabel(i18n("Right:"),page);
grid->addWidget(lab,0,1);
rightBorder=new TQLineEdit(page);
rightBorder->setValidator( new KIntValidator( 0,9999,rightBorder ) );
grid->addWidget(rightBorder,1,1);
lab=new TQLabel(i18n("Top:"),page);
grid->addWidget(lab,2,0);
topBorder=new TQLineEdit(page);
topBorder->setValidator( new KIntValidator( 0,9999,topBorder ) );
grid->addWidget(topBorder,3,0);
lab=new TQLabel(i18n("Bottom:"),page);
grid->addWidget(lab,2,1);
bottomBorder=new TQLineEdit(page);
bottomBorder->setValidator( new KIntValidator( 0,9999,bottomBorder ) );
grid->addWidget(bottomBorder,3,1);
init();
connect( this, TQT_SIGNAL( okClicked() ), this, TQT_SLOT( slotOk() ) );
connect( this, TQT_SIGNAL( applyClicked() ), this, TQT_SLOT( slotApply() ) );
connect( this, TQT_SIGNAL( user1Clicked() ), this ,TQT_SLOT( slotReset() ));
}
void KChartPageLayout::init()
{
oldGlobalLeadingRight = params->globalLeadingRight();
oldGlobalLeadingLeft = params->globalLeadingLeft();
oldGlobalLeadingTop = params->globalLeadingTop();
oldGlobalLeadingBottom = params->globalLeadingBottom();
slotReset();
}
void KChartPageLayout::slotOk()
{
slotApply();
accept();
}
void KChartPageLayout::slotApply()
{
params->setGlobalLeading( leftBorder->text().toInt(),topBorder->text().toInt() , rightBorder->text().toInt(), bottomBorder->text().toInt() );
emit dataChanged();
}
void KChartPageLayout::slotReset()
{
rightBorder->setText(TQString::number(oldGlobalLeadingRight));
leftBorder->setText(TQString::number(oldGlobalLeadingLeft));
topBorder->setText(TQString::number(oldGlobalLeadingTop));
bottomBorder->setText(TQString::number(oldGlobalLeadingBottom));
}
} //KChart namespace
|