-
Notifications
You must be signed in to change notification settings - Fork 103
/
Copy pathConfigDialogue.h
399 lines (340 loc) · 12.1 KB
/
ConfigDialogue.h
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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
// -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
//
// Copyright (C) 2004-2015 Andrej Vodopivec <[email protected]>
// (C) 2012 Doug Ilijev <[email protected]>
//
// 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
//
// SPDX-License-Identifier: GPL-2.0+
/*!
\file
The configuration dialog.
This file contains the code for ConfigDialogue, the class that handles the preferences
dialog. The preferences themself will be read directly using
<code> config->Read </code>, instead, where needed or from Configuration.
*/
extern unsigned int view_refresh_svg_gz_len;
extern unsigned char view_refresh_svg_gz[];
#include "precomp.h"
#include <wx/wx.h>
#include "BinaryNameCtrl.h"
#include <wx/image.h>
#include <wx/grid.h>
#include <wx/hashmap.h>
#include <wx/clrpicker.h>
#include <memory>
#include <wx/propdlg.h>
#include <wx/generic/propdlg.h>
#include <wx/spinctrl.h>
#include <wx/notebook.h>
#include <wx/imaglist.h>
#include <wx/bookctrl.h>
#include <wx/artprov.h>
#include <unordered_map>
#ifndef CONFIGDIALOGUE_H
#define CONFIGDIALOGUE_H
#include "cells/TextStyle.h"
#include "../Worksheet.h"
#include "../Configuration.h"
enum
{
color_id,
listbox_styleFor,
checkbox_bold,
checkbox_italic,
checkbox_underlined,
checkbox_slanted,
checkbox_strikethrough,
button_defaultFont,
button_mathFont,
style_font_family,
language_id,
save_id,
load_id
};
/*! The configuration dialog
This class draws and handles the configuration dialog.
Code that needs to know the value of the preferences that are set here reads
them directly using <code> config->Read </code>, instead.
*/
class ConfigDialogue : public wxPropertySheetDialog
{
public:
//! The constructor
explicit ConfigDialogue(wxWindow *parent);
//! The destructor
~ConfigDialogue();
//! The export formats we support for HTML equations
enum htmlExportFormats
{
mathJaX_TeX = 0,
bitmap = 1,
mathML_mathJaX = 2,
svg = 3
};
/*! Called if the color of an item has been changed */
void OnChangeColor(wxColourPickerEvent& event);
/*! Stores the settings from the configuration dialog.
wxWidgets knows how to store the settings to gconf, the registry or wherever the current
system expects settings to be saved to.
*/
void WriteSettings();
private:
const int mMinPanelWidth = 500;
const int mMinPanelHeight = 500;
private:
enum newVariables
{
MAXIMA_DEFAULT_LISP,
MAXIMA_IMAGESDIR,
MAXIMA_USERDIR,
MAXIMA_DIRECTORY,
MAXIMA_TEMPDIR,
MAXIMA_OBJDIR,
MAXIMA_DOC_PREFIX,
GCL_GC_PAGE_THRESH,
GCL_GC_ALLOC_MIN,
GCL_GC_PAGE_MAX,
GCL_MEM_MULTIPLE,
GCL_MULTIPROCESS_MEMORY_POOL,
LANG,
HOME,
VAR_DELETE
};
std::unique_ptr<struct wxm_NSVGrasterizer, decltype(std::free)*> m_svgRast{nullptr, std::free};
//! The configuration storage
std::unique_ptr<Configuration> m_configuration;
Worksheet *m_sampleWorksheet = NULL;
typedef std::unordered_map <wxString, wxString, wxStringHash> StringHash;
typedef std::unordered_map <wxString, long, wxStringHash> Languages;
Languages m_languages;
/*! TheSample text that is shown by the style selector.
This is a piece of text that shows the user how the selected style will look.
*/
class ExamplePanel : public wxPanel
{
public:
//! The constructor
ExamplePanel(wxWindow *parent, int id, wxPoint pos, wxSize size) : wxPanel(parent, id, pos, size)
{ Connect(wxEVT_PAINT, wxPaintEventHandler(ConfigDialogue::ExamplePanel::OnPaint)); };
//! Sets the text style of the example
void SetStyle(const Style &style)
{
m_style = style;
Refresh();
}
private:
/*! Actually updates the formatting example
This function is called after ConfigDialogue::UpdateExample() changes the example's style.
*/
void OnPaint(wxPaintEvent &event);
//! The text style of this example
Style m_style;
};
/*! begin wxGlade: ConfigDialogue::methods
This method sets the window title, the tool tips etc.
*/
void SetCheckboxValues();
//! Calculates the size of the images for a configuration tab
int GetImageSize();
//! The panel that allows to choose which formats to put on the clipboard
wxWindow *CreateClipboardPanel();
//! The panel that allows to change the print settings
wxWindow *CreatePrintPanel();
//! The panel that allows to choose which formats to put on the clipboard
wxWindow *CreateRevertToDefaultsPanel();
wxCheckBox *m_copyBitmap, *m_copyMathML, *m_copyMathMLHTML, *m_copyRTF, *m_copySVG;
#if wxUSE_ENH_METAFILE
wxCheckBox *m_copyEMF;
#endif
//! The panel that allows to set the editing options
wxWindow *CreateWorksheetPanel();
//! A panel that allows to set general options
wxWindow *CreateOptionsPanel();
//! The panel that allows to set options affecting the export functionality
wxWindow *CreateExportPanel();
//! The panel that allows to change styles
wxWindow *CreateStylePanel();
//! The panel that allows to change maxima-specific configurations.
wxWindow *CreateMaximaPanel();
//! The panel that allows to specify startup commands
wxWindow *CreateStartupPanel();
protected:
wxGrid *m_maximaEnvVariables;
void OnImport(wxCommandEvent& event);
static void CopyConfig(wxConfigBase *src, wxConfigBase *dst, wxString dir = wxS("/"));
void OnReloadAll(wxCommandEvent& event);
void OnReloadStyles(wxCommandEvent& event);
void OnResetAllToDefaults(wxCommandEvent& event);
void OnExportAll(wxCommandEvent& event);
void OnResetStyles(wxCommandEvent& event);
void OnChangeMaximaEnvVar(wxGridEvent& event);
void OnMaximaEnvRightClick(wxGridEvent& event);
void OnMouseMotion_MaximaEnv(wxMouseEvent &event);
void OnNewEnvMenu(wxCommandEvent &event);
void OnClickMaximaEnvVal(int row);
void OnChangeMaximaCellClick(wxGridEvent& event);
//! The name of maxima's startup file.
wxString m_startupFileName;
//! The name of wxMaxima's startup file.
wxString m_wxStartupFileName;
//! The text "Maxima Program" that can change color.
wxStaticText *m_mp;
StringHash m_maximaEnvDoc;
//! Autodetect the maxima location?
wxRadioButton *m_autodetectMaxima;
//! The radio button that is set if m_autodetectMaxima is unset
wxRadioButton *m_noAutodetectMaxima;
wxRadioButton *m_autodetectHelpBrowser;
wxRadioButton *m_noAutodetectHelpBrowser;
wxRadioButton *m_internalHelpBrowser;
wxCheckBox *m_singlePageManual;
wxRadioButton *m_maximaUsesInternalHelp;
wxRadioButton *m_maximaUsesHtmlHelp;
wxRadioButton *m_maximaUsesWxmaximaHelp;
//! Autodetect the mathJaX location?
wxRadioButton *m_autodetectMathJaX;
//! The radio button that is set if m_autodetectMathJaX is unset
wxRadioButton *m_noAutodetectMathJaX;
wxRadioButton *m_useGnuplot;
wxRadioButton *m_useWgnuplot;
//! Called if the currently active dialogue sheet is changed.
void OnTabChange(wxBookCtrlEvent &event);
//! Called if the user changes the style that is to be edited.
void OnStyleToEditChanged(wxCommandEvent &event);
// begin wxGlade: ConfigDialogue::attributes
//! A textbox containing maxima's startup commands
wxTextCtrl *m_startupCommands;
//! A textbox containing wxMaxima's startup commands
wxTextCtrl *m_wxStartupCommands;
BinaryNameCtrl *m_maximaUserLocation;
BinaryNameCtrl *m_helpBrowserUserLocation;
wxTextCtrl *m_documentclass;
wxTextCtrl *m_documentclassOptions;
wxTextCtrl *m_texPreamble;
wxCheckBox *m_autoSave;
wxButton *m_wxMathMLBrowse;
wxTextCtrl *m_additionalParameters;
wxCheckBox *m_enableDynamicMemorySpace;
wxSpinCtrl *m_dynamicMemorySpace;
wxTextCtrl *m_mathJaxURL;
wxChoice *m_language;
wxTextCtrl *m_symbolPaneAdditionalChars;
wxCheckBox *m_abortOnError;
wxCheckBox *m_offerKnownAnswers;
wxCheckBox *m_restartOnReEvaluation;
wxCheckBox *m_wrapLatexMath;
wxCheckBox *m_usesvg;
wxCheckBox *m_antialiasLines;
wxSpinCtrl *m_defaultFramerate;
wxSpinCtrl *m_defaultPlotWidth;
wxSpinCtrl *m_defaultPlotHeight;
wxSpinCtrl *m_displayedDigits;
wxSpinCtrl *m_printMargin_Top;
wxSpinCtrl *m_printMargin_Bot;
wxSpinCtrl *m_printMargin_Left;
wxSpinCtrl *m_printMargin_Right;
wxRadioButton *m_displayNDigits;
wxRadioButton *m_displayAllDigits;
wxRadioButton *m_linebreaksInLongNums;
wxSpinCtrl *m_maxClipbrdBitmapMegabytes;
//! A checkbox that asks if TeX should put the exponents above or after the subscripts.
wxCheckBox *m_TeXExponentsAfterSubscript;
//! A checkbox that asks if TeX should use the \\partial symbol for representing diff()
wxCheckBox *m_usePartialForDiff;
//! A checkbox that asks if all newlines in text cells have to be passed to HTML.
wxCheckBox *m_exportContainsWXMX;
wxCheckBox *m_printBrackets;
wxChoice *m_exportWithMathJAX;
wxCheckBox *m_matchParens;
wxCheckBox *m_showMatchingParens;
wxChoice *m_showLength;
wxChoice *m_autosubscript;
wxRadioButton *m_enterEvaluates;
wxRadioButton *m_ctrlEnterEvaluates;
wxCheckBox *m_numpadEnterEvaluates;
wxCheckBox *m_saveImgFileName;
wxCheckBox *m_saveUntitled;
wxCheckBox *m_openHCaret;
wxCheckBox *m_insertAns;
wxCheckBox *m_autoIndent;
wxCheckBox *m_cursorJump;
wxCheckBox *m_hideBrackets;
wxCheckBox *m_indentMaths;
wxChoice *m_autoWrap;
wxSpinCtrl *m_labelWidth;
wxSpinCtrl *m_undoLimit;
wxSpinCtrl *m_recentItems;
wxSpinCtrl *m_bitmapScale;
wxSpinCtrlDouble *m_printScale;
wxCheckBox *m_fixReorderedIndices;
wxCheckBox *m_incrementalSearch;
wxCheckBox *m_notifyIfIdle;
wxChoice *m_showUserDefinedLabels;
wxButton *m_getStyleFont;
wxListBox *m_styleFor;
//! An example rectangle with the font color
wxColourPickerCtrl *m_styleColor;
wxCheckBox *m_boldCB;
wxCheckBox *m_italicCB;
wxCheckBox *m_slantedCB;
wxCheckBox *m_strikethroughCB;
wxCheckBox *m_underlinedCB;
wxCheckBox *m_fixedFontInTC;
wxCheckBox *m_unixCopy;
wxCheckBox *m_changeAsterisk;
wxCheckBox *m_hidemultiplicationSign;
wxCheckBox *m_latin2Greek;
wxCheckBox *m_useUnicodeMaths;
wxCheckBox *m_keepPercentWithSpecials;
wxBookCtrlBase *m_notebook;
wxButton *m_saveStyle, *m_loadStyle;
wxSpinCtrl *m_defaultPort;
ExamplePanel *m_examplePanel;
wxSpinCtrl *m_maxGnuplotMegabytes;
wxSpinCtrl *m_autosaveMinutes;
wxTextCtrl *m_autoMathJaxURL;
int m_maximaEmvRightClickRow = 0;
//! Is called when the path to the maxima binary was changed.
void UsesvgChanged(wxCommandEvent &event);
//! Is called when the configuration dialog is closed.
void OnClose(wxCloseEvent &event);
void OnwxMathMLBrowse(wxCommandEvent &event);
void OnIdle(wxIdleEvent &event);
//! Called if a new item type that is to be styled is selected
void OnChangeStyle(wxCommandEvent &event);
//! A message dialog that appears if a change cannot be applied now.
void OnChangeWarning(wxCommandEvent &event);
//! Called if one of the checkboxes for bold, italic or underlined is toggled
void OnCheckbox(wxCommandEvent &event);
//! Sets the style example's style on style changes.
void UpdateExample();
//! Called if the font family is changed.
void OnChangeFontFamily(wxCommandEvent &event);
//! A "export the configuration" dialog
void LoadSave(wxCommandEvent &event);
//! Get the style currently selected in the m_styleFor control
TextStyle GetSelectedStyle() const;
//! The size of the text font
int m_fontSize;
//! The size of the maths font.
int m_mathFontSize;
//! A list containing the pictograms for the tabs.
std::unique_ptr<wxImageList> m_imageList;
};
#ifndef __WXMSW__
#endif // __WXMSW__
#endif // CONFIG_H