summaryrefslogtreecommitdiffstats
path: root/kmplot/kmplot/MainDlg.h
blob: 8a34ef364b09b76e18ba3d92b4db206b7407d389 (plain)
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
/*
* KmPlot - a math. function plotter for the KDE-Desktop
*
* Copyright (C) 1998, 1999  Klaus-Dieter M�ler
*               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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

/** @file MainDlg.h
 * @brief Contains the main window class MainDlg. */

#ifndef MainDlg_included
#define MainDlg_included

// TQt includes
#include <tqpicture.h>

// KDE includes
#include <kaction.h>
#include <tdefiledialog.h>
#include <kpopupmenu.h>
#include <kstandarddirs.h>
#include <tdeparts/browserextension.h>
#include <tdeparts/part.h>
#include <tdeparts/factory.h>

#undef  GrayScale

// local includes
#include "coordsconfigdialog.h"
#include "FktDlg.h"
#include "View.h"
#include "kminmax.h"
#include "kmplotio.h"
#include "MainDlgIface.h"

class TDEConfigDialog;
class KLineEdit;
class TDERecentFilesAction;
class SettingsPageColor;
class SettingsPageFonts;
class SettingsPagePrecision;
class SettingsPageScaling;
class KConstantEditor;
class TDEToggleFullScreenAction;
class BrowserExtension;


/** @short This is the main window of KmPlot.
 *
 * Its central widget view contains the parser, accessable via its parser() function.
 * @see View, View::m_parser, View::parser
 */
class MainDlg : public KParts::ReadOnlyPart, virtual public MainDlgIface
{
	Q_OBJECT
  

public:
	/** Constuctor.
	 * @param parentWidget parent widget for this part
	 * @param parent parent object
	 * @param name name of this dialog
	 */
	MainDlg(TQWidget *parentWidget, const char *, TQObject *parent, const char *name);
	/// Cleaning up a bit.
	virtual ~MainDlg();
	/// This class needs access to private members, too.
	friend class FktDlg;
	/// This class needs access to private members, too.
	friend class BezWnd;

	/// Asks the user and returns true if modified data shall be dicarded.
	bool checkModified();
	/// Is set to true if a file from an old file format was loaded
	static bool oldfileversion;

public slots:
	/// Implement the color edit dialog
	void editColors();
	/// Implement the coordinate system edit dialog
	void editAxes();
	/// Implement the scaling edit dialog
	void editScaling();
	/// Implement the fonts edit dialog
	void editFonts();
	/// Implement the constants edit dialog
	void editConstants();
	/// Implement the dialog to enter a function plot and its options
	void newFunction();
	/// Implement the dialog to enter a parametric plot and its options
	void newParametric();
	/// Implement the dialog to enter a polar plot and its options
	void newPolar();
	/// Show/hide parameter slider windows
	void toggleShowSlider0();
	void toggleShowSlider1();
	void toggleShowSlider2();
	void toggleShowSlider3();
	
	// ///I'm not sure it a delete-all-functions command is necessary
	// void slotCleanWindow();
	///Save a plot i.e. save the function name and all the settings for the plot
	void slotSave();
	///Save a plot and choose a name for it
	void slotSaveas();
	///Call the dialog (an instance of FktDlg) to edit the functions and make changes on them
	void slotEditPlots();
	///Print the current plot
	void slotPrint();
	///Export the current plot as a png, svg or bmp picture
	void slotExport();
	///Implement the Configure KmPlot dialog
	void slotSettings();
	/// Calls the common function names dialog.
	/// @see BezWnd::hideEvent
	void slotNames();
	/// Change the coordinate systems, shows negative x-values and negative y-values.
	void slotCoord1();
	/// Change the coordinate systems, shows positive x-values and negative y-values.
	void slotCoord2();
	/// Change the coordinate systems, shows positive x-values and positive y-values.
	void slotCoord3();
	/// Tools menu
	void getYValue();
	void findMinimumValue();
	void findMaximumValue();
	void graphArea();
    void resetZoom();

private:
	/// Settings the standard and non standard actions of the application.
	void setupActions();
	/// Called when a file is opened. The filename is is m_url
	virtual bool openFile();
	/// Loading the constants by start
	void loadConstants();
	/// Loading the constants when closing the program
	void saveConstants();
	/// Returns true if any changes are done
	bool isModified(){return m_modified;}
	/// Toggle the slider with index num
	void toggleShowSlider(int const num);

	/// Cached dialog to edit all functions
	FktDlg *fdlg;
	/// Central widget of the TDEMainWindow instance. tralala
	View *view;
	///The Recent Files action
	TDERecentFilesAction * m_recentFiles;
	/// true == modifications not saved
	bool m_modified;
	///An instance of the application config file
	TDEConfig* m_config;
	///The KLineEdit which is in the toolbar
	KLineEdit* m_quickEdit;
	///A Configure KmPlot dialog instance
	TDEConfigDialog* m_settingsDialog;
	///The Precision page for the Configure KmPlot dialog
	SettingsPagePrecision* m_generalSettings;
	///The Constants page for the Configure KmPlot constants
	KConstantEditor* m_constantsSettings;

	/// A dialog used by many tools-menu-items
	KMinMax *minmaxdlg;
	/// the popup menu shown when cling with the right mouse button on a graph in the graph widget
	TDEPopupMenu *m_popupmenu;
	/// Loads and saves the user's file.
	KmPlotIO *kmplotio;
	/// Set to true if the application is readonly
	bool m_readonly;
	/// MainDlg's parent widget
	TQWidget *m_parent;
	/// Current file
	KURL m_currentfile;
	/// The axes config dialogs
	CoordsConfigDialog* coordsDialog;
    TDERadioAction * m_mnuNoZoom;

protected slots:
	/**
	* When you click on a File->Open Recent file, it'll open 
	* @param url name of the url to open
	*/
	void slotOpenRecent( const KURL &url );
	///Update settings when there is a change in the Configure KmPlot dialog
	void updateSettings();
	/**
	* Manages the LineEdit content after returnPressed() is emitted.
	 * @param f_str_const the content of the KLineEdit
	*/
	void slotQuickEdit( const TQString& f_str_const );

	void setReadOnlyStatusBarText(const TQString &);

	/// slots for the settings-menu
	void optionsConfigureKeys();
	void optionsConfigureToolbars();
};

class KmPlotPartFactory : public KParts::Factory
{
	Q_OBJECT
  
public:
	KmPlotPartFactory();
	virtual ~KmPlotPartFactory();
	virtual KParts::Part* createPartObject( TQWidget *parentWidget, const char *widgetName,
	                                        TQObject *parent, const char *name,
	                                        const char *classname, const TQStringList &args );
	static TDEInstance* instance();

private:
	static TDEInstance* s_instance;
	static TDEAboutData* s_about;
};

class BrowserExtension : public KParts::BrowserExtension
{
	Q_OBJECT
  
public:
	BrowserExtension(MainDlg*);

public slots:
	// Automatically detected by the host.
	void print();
};

#endif // MainDlg_included