Commit 3d229ae2 authored by Matthias Messmer's avatar Matthias Messmer

New born function edit dialog(s)

svn path=/trunk/kdeedu/kmplot/; revision=295258
parent 114959db
......@@ -16,7 +16,7 @@
</general>
<kdevcustomproject>
<run>
<mainprogram>KmPlot</mainprogram>
<mainprogram>kmplot</mainprogram>
<directoryradio>executable</directoryradio>
<customdirectory>/</customdirectory>
<programargs/>
......
......@@ -25,11 +25,16 @@
// Qt includes
#include <qpushbutton.h>
#include <qpopupmenu.h>
// KDE includes
#include <kpushbutton.h>
// locale includes
#include "FktDlg.h"
#include "FktDlg.moc"
#include "MainDlg.h"
#include "keditfunction.h"
#define Inherited FktDlgData
......@@ -55,6 +60,11 @@ FktDlg::FktDlg( QWidget* parent, const char* name ) : Inherited( parent, name )
le_fktstr->selectAll();
}
le_fktstr->setFocus();
QPopupMenu *menu_types = new QPopupMenu( this );
menu_types->insertItem( i18n( "function" ), this, SLOT( onEditFunction() ) );
menu_types->insertItem( i18n( "parametric" ), this, SLOT( onEditParametric() ) );
menu_types->insertItem( i18n( "polar" ), this, SLOT( onEditPolar() ) );
PushButtonApply->setPopup( menu_types );
}
FktDlg::~FktDlg()
......@@ -220,3 +230,24 @@ void FktDlg::onHasSelection()
PushButtonDel->setEnabled( has_selection );
PushButtonAttr->setEnabled( has_selection );
}
void FktDlg::onEditFunction()
{
if( !editFunction ) editFunction = new KEditFunction( &ps, this );
editFunction->setType( KEditFunction::Function );
editFunction->show();
}
void FktDlg::onEditParametric()
{
if( !editFunction ) editFunction = new KEditFunction( &ps, this );
editFunction->setType( KEditFunction::Parametric );
editFunction->show();
}
void FktDlg::onEditPolar()
{
if( !editFunction ) editFunction = new KEditFunction( &ps, this );
editFunction->setType( KEditFunction::Polar );
editFunction->show();
}
......@@ -30,16 +30,20 @@
#ifndef FktDlg_included
#define FktDlg_included
// locale includes
#include "FktDlgData.h"
#include "AttrDlg.h"
#include "misc.h"
// Qt includes
#include <qvaluelist.h>
// KDE includes
#include <kapplication.h>
#include <klocale.h>
// locale includes
#include "FktDlgData.h"
#include "AttrDlg.h"
#include "misc.h"
class KEditFunction;
/** This widget class handles the users function input.
* Equations can be added, edited, and removed.
* An attribute settings dialog can be requested.
......@@ -68,12 +72,16 @@ protected slots:
void onattr();
void onapply();
void onHasSelection();
void onEditFunction();
void onEditParametric();
void onEditPolar();
private:
int getIx( const QString f_str );
void updateView();
int chflg;
int errflg;
KEditFunction *editFunction;
};
#endif // FktDlg_included
......@@ -9,7 +9,7 @@
<x>0</x>
<y>0</y>
<width>363</width>
<height>445</height>
<height>447</height>
</rect>
</property>
<property name="minimumSize">
......@@ -88,10 +88,10 @@
<cstring>PushButtonApply</cstring>
</property>
<property name="text">
<string>&amp;Add</string>
<string>&amp;New</string>
</property>
<property name="accel">
<string>Alt+A</string>
<string>Alt+N</string>
</property>
<property name="default">
<bool>true</bool>
......
......@@ -418,7 +418,6 @@ void MainDlg::bezeichnungen()
bez = new BezWnd( this, "bez" );
if ( view_bezeichnungen->isChecked() )
{
bez->move( 200, 200 );
bez->show();
}
else
......
bin_PROGRAMS = kmplot
kmplot_SOURCES = SwDlgData.ui SkalDlgData.ui RstDlgData.ui KoordDlgData.ui KOptDlgData.ui FktDlgData.ui BezWndData.ui AttrDlgData.ui xparser.cpp parser.cpp misc.cpp main.cpp diagr.cpp View.cpp SwDlg.cpp SkalDlg.cpp RstDlg.cpp MainDlg.cpp KoordDlg.cpp KOptDlg.cpp FktDlg.cpp BezWnd.cpp AttrDlg.cpp kprinterdlg.cpp settings.kcfgc settingspagecolor.ui settingspagecoords.ui settingspagefonts.ui settingspagescaling.ui
kmplot_SOURCES = SwDlgData.ui SkalDlgData.ui RstDlgData.ui KoordDlgData.ui KOptDlgData.ui FktDlgData.ui BezWndData.ui AttrDlgData.ui xparser.cpp parser.cpp misc.cpp main.cpp diagr.cpp View.cpp SwDlg.cpp SkalDlg.cpp RstDlg.cpp MainDlg.cpp KoordDlg.cpp KOptDlg.cpp FktDlg.cpp BezWnd.cpp AttrDlg.cpp kprinterdlg.cpp settings.kcfgc settingspagecolor.ui settingspagecoords.ui settingspagefonts.ui settingspagescaling.ui qeditfunction.ui keditfunction.cpp
kmplot_LDADD = $(LIB_KFILE) $(LIB_KDEUI) $(LIB_KDECORE) $(LIB_QT) $(LIBSOCKET) $(LIB_KDEPRINT)
EXTRA_DIST = kmplot.desktop AttrDlg.cpp AttrDlg.h BezWnd.cpp BezWnd.h FktDlg.cpp FktDlg.h KOptDlg.cpp KOptDlg.h KoordDlg.cpp KoordDlg.h MainDlg.cpp MainDlg.h RstDlg.cpp RstDlg.h SkalDlg.cpp SkalDlg.h SwDlg.cpp SwDlg.h View.cpp View.h diagr.cpp diagr.h main.cpp main.h misc.cpp misc.h parser.cpp parser.h xparser.cpp xparser.h AttrDlgData.ui BezWndData.ui FktDlgData.ui KOptDlgData.ui KoordDlgData.ui RstDlgData.ui SkalDlgData.ui SwDlgData.ui kprinterdlg.cpp kprinterdlg.h settingspagecolor.ui settingspagecoords.ui settingspagefonts.ui settingspagescaling.ui
EXTRA_DIST = kmplot.desktop AttrDlg.cpp AttrDlg.h BezWnd.cpp BezWnd.h FktDlg.cpp FktDlg.h KOptDlg.cpp KOptDlg.h KoordDlg.cpp KoordDlg.h MainDlg.cpp MainDlg.h RstDlg.cpp RstDlg.h SkalDlg.cpp SkalDlg.h SwDlg.cpp SwDlg.h View.cpp View.h diagr.cpp diagr.h main.cpp main.h misc.cpp misc.h parser.cpp parser.h xparser.cpp xparser.h AttrDlgData.ui BezWndData.ui FktDlgData.ui KOptDlgData.ui KoordDlgData.ui RstDlgData.ui SkalDlgData.ui SwDlgData.ui kprinterdlg.cpp kprinterdlg.h settingspagecolor.ui settingspagecoords.ui settingspagefonts.ui settingspagescaling.ui qeditfunction.ui keditfunction.h keditfunction.cpp
xdg_apps_DATA = kmplot.desktop
......
/*
* KmPlot - a math. function plotter for the KDE-Desktop
*
* Copyright (C) 1998, 1999 Klaus-Dieter Mller
* 2000, 2002 kd.moeller@t-online.de
*
* This file is part of the KDE Project.
* KmPlot is part of the KDE-EDU Project.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
// Qt includes
#include <qcheckbox.h>
// KDE includes
#include <klineedit.h>
// local includes
#include "keditfunction.h"
#include "keditfunction.moc"
#include "xparser.h"
KEditFunction::KEditFunction( XParser* parser, QWidget* parent, const char* name ) :
QEditFunction( parent, name )
{
m_parser = parser;
}
void KEditFunction::setType( const FunctionType t )
{
m_type = t;
switch( t )
{
case Function:
this->setCaption( "Edit Function Plot" );
kLineEditXFunction->hide();
checkBoxDerivative1->show();
checkBoxDerivative2->show();
break;
case Parametric:
this->setCaption( "Edit Parametric Plot" );
kLineEditXFunction->show();
checkBoxDerivative1->hide();
checkBoxDerivative2->hide();
break;
case Polar:
this->setCaption( "Edit Polar Plot" );
}
updateGeometry();
}
void KEditFunction::accept()
{
int index;
if( kLineEditXFunction->isVisible() )
{
index = m_parser->addfkt( kLineEditXFunction->text() );
if( index == -1 )
{
m_parser->errmsg();
this->raise();
kLineEditXFunction->setFocus();
kLineEditXFunction->selectAll();
return;
}
}
if( kLineEditYFunction->isVisible() )
{
index = m_parser->addfkt( kLineEditYFunction->text() );
if( index == -1 )
{
m_parser->errmsg();
this->raise();
kLineEditYFunction->setFocus();
kLineEditYFunction->selectAll();
return;
}
}
QEditFunction::accept();
}
/*
* KmPlot - a math. function plotter for the KDE-Desktop
*
* Copyright (C) 1998, 1999 Klaus-Dieter Möller
* 2000, 2002 kd.moeller@t-online.de
*
* This file is part of the KDE Project.
* KmPlot is part of the KDE-EDU Project.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef KEDITFUNCTION_H
#define KEDITFUNCTION_H
#include "qeditfunction.h"
class XParser;
class KEditFunction : public QEditFunction
{
Q_OBJECT
public:
KEditFunction( XParser* parser, QWidget* parent = NULL, const char* name = NULL );
virtual ~KEditFunction() {};
enum FunctionType { Function, Parametric, Polar };
void setType( const FunctionType t );
private:
FunctionType m_type;
XParser* m_parser;
protected:
virtual void accept();
};
#endif
<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
<class>QEditFunction</class>
<widget class="QDialog">
<property name="name">
<cstring>QEditFunction</cstring>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>263</width>
<height>372</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy>
<hsizetype>1</hsizetype>
<vsizetype>1</vsizetype>
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="caption">
<string>Edit Function</string>
</property>
<property name="sizeGripEnabled">
<bool>true</bool>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QGroupBox">
<property name="name">
<cstring>groupBox1</cstring>
</property>
<property name="title">
<string>Definition</string>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="KLineEdit">
<property name="name">
<cstring>kLineEditXFunction</cstring>
</property>
</widget>
<widget class="KLineEdit">
<property name="name">
<cstring>kLineEditYFunction</cstring>
</property>
</widget>
</vbox>
</widget>
<widget class="QButtonGroup">
<property name="name">
<cstring>buttonGroup1</cstring>
</property>
<property name="title">
<string>Extensions</string>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="QCheckBox">
<property name="name">
<cstring>checkBoxHide</cstring>
</property>
<property name="text">
<string>Hide</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>checkBoxDerivative1</cstring>
</property>
<property name="text">
<string>show 1st Derivative</string>
</property>
</widget>
<widget class="QCheckBox">
<property name="name">
<cstring>checkBoxDerivative2</cstring>
</property>
<property name="text">
<string>show 2nd Derivative</string>
</property>
</widget>
</vbox>
</widget>
<widget class="QGroupBox">
<property name="name">
<cstring>groupBox2</cstring>
</property>
<property name="title">
<string>Plot range</string>
</property>
<vbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<widget class="KLineEdit">
<property name="name">
<cstring>min</cstring>
</property>
</widget>
<widget class="KLineEdit">
<property name="name">
<cstring>max</cstring>
</property>
</widget>
</vbox>
</widget>
<widget class="QLayoutWidget">
<property name="name">
<cstring>Layout1</cstring>
</property>
<hbox>
<property name="name">
<cstring>unnamed</cstring>
</property>
<property name="margin">
<number>0</number>
</property>
<property name="spacing">
<number>6</number>
</property>
<widget class="QPushButton">
<property name="name">
<cstring>buttonHelp</cstring>
</property>
<property name="text">
<string>&amp;Help</string>
</property>
<property name="accel">
<string>F1</string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
<spacer>
<property name="name">
<cstring>Horizontal Spacing2</cstring>
</property>
<property name="orientation">
<enum>Horizontal</enum>
</property>
<property name="sizeType">
<enum>Expanding</enum>
</property>
<property name="sizeHint">
<size>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
<widget class="QPushButton">
<property name="name">
<cstring>buttonOk</cstring>
</property>
<property name="text">
<string>&amp;OK</string>
</property>
<property name="accel">
<string></string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
<widget class="QPushButton">
<property name="name">
<cstring>buttonCancel</cstring>
</property>
<property name="text">
<string>&amp;Cancel</string>
</property>
<property name="accel">
<string></string>
</property>
<property name="autoDefault">
<bool>true</bool>
</property>
</widget>
</hbox>
</widget>
</vbox>
</widget>
<connections>
<connection>
<sender>buttonOk</sender>
<signal>clicked()</signal>
<receiver>QEditFunction</receiver>
<slot>accept()</slot>
</connection>
<connection>
<sender>buttonCancel</sender>
<signal>clicked()</signal>
<receiver>QEditFunction</receiver>
<slot>reject()</slot>
</connection>
</connections>
<layoutdefaults spacing="6" margin="11"/>
<includehints>
<includehint>klineedit.h</includehint>
<includehint>klineedit.h</includehint>
<includehint>klineedit.h</includehint>
<includehint>klineedit.h</includehint>
</includehints>
</UI>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment