moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kmplot / kmplot / MainDlg.h
blobcd718c7f63feb8fec60016276b95ce6aa4741a8d
1 /*
2 * KmPlot - a math. function plotter for the KDE-Desktop
4 * Copyright (C) 1998, 1999 Klaus-Dieter M�ler
5 * 2000, 2002 kd.moeller@t-online.de
7 * This file is part of the KDE Project.
8 * KmPlot is part of the KDE-EDU Project.
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25 /** @file MainDlg.h
26 * @brief Contains the main window class MainDlg. */
28 #ifndef MainDlg_included
29 #define MainDlg_included
31 // Qt includes
32 #include <qpicture.h>
34 // KDE includes
35 #include <kaction.h>
36 #include <kfiledialog.h>
37 #include <kpopupmenu.h>
38 #include <kstandarddirs.h>
39 #include <kparts/browserextension.h>
40 #include <kparts/part.h>
41 #include <kparts/factory.h>
43 #undef GrayScale
45 // local includes
46 #include "coordsconfigdialog.h"
47 #include "FktDlg.h"
48 #include "View.h"
49 #include "kminmax.h"
50 #include "kmplotio.h"
51 #include "MainDlgIface.h"
53 class KConfigDialog;
54 class KLineEdit;
55 class KRecentFilesAction;
56 class SettingsPageColor;
57 class SettingsPageFonts;
58 class SettingsPagePrecision;
59 class SettingsPageScaling;
60 class KConstantEditor;
61 class KToggleFullScreenAction;
62 class BrowserExtension;
65 /** @short This is the main window of KmPlot.
67 * Its central widget view contains the parser, accessable via its parser() function.
68 * @see View, View::m_parser, View::parser
70 class MainDlg : public KParts::ReadOnlyPart, virtual public MainDlgIface
72 Q_OBJECT
74 public:
75 /** @param sessionId used for the name of a temporary file.
76 * @param args containing a filename to be plot on startup.
77 * @param name
79 MainDlg(QWidget *parentWidget, const char *widgetName, QObject *parent, const char *name);
80 /// Cleaning up a bit.
81 virtual ~MainDlg();
82 /// This class needs access to private members, too.
83 friend class FktDlg;
84 /// This class needs access to private members, too.
85 friend class BezWnd;
87 /// Asks the user and returns true if modified data shall be dicarded.
88 bool checkModified();
89 /// Is set to true if a file from an old file format was loaded
90 static bool oldfileversion;
92 public slots:
93 /// Implement the color edit dialog
94 void editColors();
95 /// Implement the coordinate system edit dialog
96 void editAxes();
97 /// Implement the scaling edit dialog
98 void editScaling();
99 /// Implement the fonts edit dialog
100 void editFonts();
101 /// Implement the constants edit dialog
102 void editConstants();
103 /// Implement the dialog to enter a function plot and its options
104 void newFunction();
105 /// Implement the dialog to enter a parametric plot and its options
106 void newParametric();
107 /// Implement the dialog to enter a polar plot and its options
108 void newPolar();
109 /// Show/hide parameter slider windows
110 void toggleShowSlider0();
111 void toggleShowSlider1();
112 void toggleShowSlider2();
113 void toggleShowSlider3();
115 // ///I'm not sure it a delete-all-functions command is necessary
116 // void slotCleanWindow();
117 ///Save a plot i.e. save the function name and all the settings for the plot
118 void slotSave();
119 ///Save a plot and choose a name for it
120 void slotSaveas();
121 ///Call the dialog (an instance of FktDlg) to edit the functions and make changes on them
122 void slotEditPlots();
123 ///Print the current plot
124 void slotPrint();
125 ///Export the current plot as a png, svg or bmp picture
126 void slotExport();
127 ///Implement the Configure KmPlot dialog
128 void slotSettings();
129 /// Calls the common function names dialog.
130 /// @see BezWnd::hideEvent
131 void slotNames();
132 /// Change the coordinate systems, shows negative x-values and negative y-values.
133 void slotCoord1();
134 /// Change the coordinate systems, shows positive x-values and negative y-values.
135 void slotCoord2();
136 /// Change the coordinate systems, shows positive x-values and positive y-values.
137 void slotCoord3();
138 /// Tools menu
139 void getYValue();
140 void findMinimumValue();
141 void findMaximumValue();
142 void graphArea();
144 private:
145 /// Settings the standard and non standard actions of the application.
146 void setupActions();
147 /// Called when a file is opened. The filename is is m_url
148 virtual bool openFile();
149 /// Loading the constants by start
150 void loadConstants();
151 /// Loading the constants when closing the program
152 void saveConstants();
153 /// Returns true if any changes are done
154 bool isModified(){return m_modified;}
155 /// Toggle the slider with index num
156 void toggleShowSlider(int const num);
158 /// Cached dialog to edit all functions
159 FktDlg *fdlg;
160 /// Central widget of the KMainWindow instance. tralala
161 View *view;
162 ///The Recent Files action
163 KRecentFilesAction * m_recentFiles;
164 /// true == modifications not saved
165 bool m_modified;
166 ///An instance of the application config file
167 KConfig* m_config;
168 ///The KLineEdit which is in the toolbar
169 KLineEdit* m_quickEdit;
170 ///A Configure KmPlot dialog instance
171 KConfigDialog* m_settingsDialog;
172 ///The Precision page for the Configure KmPlot dialog
173 SettingsPagePrecision* m_generalSettings;
174 ///The Constants page for the Configure KmPlot constants
175 KConstantEditor* m_constantsSettings;
177 /// A dialog used by many tools-menu-items
178 KMinMax *minmaxdlg;
179 /// the popup menu shown when cling with the right mouse button on a graph in the graph widget
180 KPopupMenu *m_popupmenu;
181 /// Loads and saves the user's file.
182 KmPlotIO *kmplotio;
183 /// Set to true if the application is readonly
184 bool m_readonly;
185 /// MainDlg's parent widget
186 QWidget *m_parent;
187 /// Current file
188 KURL m_currentfile;
189 /// The axes config dialogs
190 CoordsConfigDialog* coordsDialog;
192 protected slots:
194 * When you click on a File->Open Recent file, it'll open
195 * @param url name of the url to open
197 void slotOpenRecent( const KURL &url );
198 ///Update settings when there is a change in the Configure KmPlot dialog
199 void updateSettings();
201 * Manages the LineEdit content after returnPressed() is emitted.
202 * @param f_str_const the content of the KLineEdit
204 void slotQuickEdit( const QString& f_str_const );
206 void setReadOnlyStatusBarText(const QString &);
208 /// slots for the settings-menu
209 void optionsConfigureKeys();
210 void optionsConfigureToolbars();
213 class KmPlotPartFactory : public KParts::Factory
215 Q_OBJECT
216 public:
217 KmPlotPartFactory();
218 virtual ~KmPlotPartFactory();
219 virtual KParts::Part* createPartObject( QWidget *parentWidget, const char *widgetName,
220 QObject *parent, const char *name,
221 const char *classname, const QStringList &args );
222 static KInstance* instance();
224 private:
225 static KInstance* s_instance;
226 static KAboutData* s_about;
229 class BrowserExtension : public KParts::BrowserExtension
231 Q_OBJECT
232 public:
233 BrowserExtension(MainDlg*);
235 public slots:
236 // Automatically detected by the host.
237 void print();
240 #endif // MainDlg_included