wxMaxima
ConfigDialogue.h
Go to the documentation of this file.
1 // -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
2 //
3 // Copyright (C) 2004-2015 Andrej Vodopivec <andrej.vodopivec@gmail.com>
4 // (C) 2012 Doug Ilijev <doug.ilijev@gmail.com>
5 //
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 //
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 //
21 // SPDX-License-Identifier: GPL-2.0+
22 
32 extern unsigned int view_refresh_svg_gz_len;
33 extern unsigned char view_refresh_svg_gz[];
34 
35 #include "precomp.h"
36 #include <wx/wx.h>
37 #include <wx/image.h>
38 #include <wx/grid.h>
39 #include <wx/hashmap.h>
40 #include <memory>
41 #include <wx/propdlg.h>
42 #include <wx/generic/propdlg.h>
43 #include <wx/spinctrl.h>
44 #include <wx/notebook.h>
45 
46 #include <wx/imaglist.h>
47 #include <wx/bookctrl.h>
48 #include <wx/artprov.h>
49 
50 #ifndef CONFIGDIALOGUE_H
51 #define CONFIGDIALOGUE_H
52 
53 #include "TextStyle.h"
54 #include "Configuration.h"
55 
56 enum
57 {
58  color_id,
59  listbox_styleFor,
60  checkbox_bold,
61  checkbox_italic,
62  checkbox_underlined,
63  button_defaultFont,
64  button_mathFont,
65  style_font_family,
66  language_id,
67  save_id,
68  load_id
69 };
70 
78 class ConfigDialogue : public wxPropertySheetDialog
79 {
80 public:
82  ConfigDialogue(wxWindow *parent, Configuration *cfg);
83 
86 
89  {
90  mathJaX_TeX = 0,
91  bitmap = 1,
92  mathML_mathJaX = 2,
93  svg = 3
94  };
95 
100  void OnChangeColor();
101 
107  void WriteSettings();
108 
109 private:
110  const int mMinPanelWidth = 640;
111  const int mMinPanelHeight = 720;
112 
113 private:
114  enum newVariables
115  {
116  MAXIMA_DEFAULT_LISP,
117  MAXIMA_IMAGESDIR,
118  MAXIMA_USERDIR,
119  MAXIMA_DIRECTORY,
120  MAXIMA_TEMPDIR,
121  MAXIMA_OBJDIR,
122  MAXIMA_DOC_PREFIX,
123  GCL_GC_PAGE_THRESH,
124  GCL_GC_ALLOC_MIN,
125  GCL_GC_PAGE_MAX,
126  GCL_MEM_MULTIPLE,
127  GCL_MULTIPROCESS_MEMORY_POOL,
128  LANG,
129  HOME,
130  VAR_DELETE
131  };
132  std::unique_ptr<struct NSVGrasterizer, decltype(std::free)*> m_svgRast{nullptr, std::free};
134  Configuration *m_configuration;
135 
136  WX_DECLARE_STRING_HASH_MAP(wxString, StringHash);
137  WX_DECLARE_STRING_HASH_MAP(long, Languages);
138  Languages m_languages;
143  class ExamplePanel : public wxPanel
144  {
145  public:
147  ExamplePanel(wxWindow *parent, int id, wxPoint pos, wxSize size) : wxPanel(parent, id, pos, size)
148  { Connect(wxEVT_PAINT, wxPaintEventHandler(ConfigDialogue::ExamplePanel::OnPaint)); };
149 
151  void SetStyle(const Style &style)
152  {
153  if (m_style.IsStyleEqualTo(style)) return;
154  m_style = style;
155  Refresh();
156  }
157 
158  private:
163  void OnPaint(wxPaintEvent &event);
164 
166  Style m_style;
167  };
168 
173  class ColorPanel : public wxPanel
174  {
175  public:
176  ColorPanel(ConfigDialogue *conf, wxWindow *parent,
177  int id, wxPoint pos, wxSize size, long style);
178 
179  void OnPaint(wxPaintEvent &WXUNUSED(event));
180 
181  void OnClick(wxMouseEvent& WXUNUSED(event));
182 
183  void SetColor(wxColor color)
184  {
185  m_color = color;
186  Refresh();
187  };
188  private:
189  ConfigDialogue *m_configDialogue;
190  wxColor m_color;
191  };
192 
193 
198  void SetCheckboxValues();
199 
201  int GetImageSize();
202 
204  wxBitmap GetImage(wxString name,
205  unsigned char *data, size_t len);
206 
208  wxWindow *CreateClipboardPanel();
209 
211  wxWindow *CreateRevertToDefaultsPanel();
212 
213  wxCheckBox *m_copyBitmap, *m_copyMathML, *m_copyMathMLHTML, *m_copyRTF, *m_copySVG;
214  #if wxUSE_ENH_METAFILE
215  wxCheckBox *m_copyEMF;
216  #endif
217 
219  wxWindow *CreateWorksheetPanel();
220 
222  wxWindow *CreateOptionsPanel();
223 
225  wxWindow *CreateExportPanel();
226 
228  wxWindow *CreateStylePanel();
229 
231  wxWindow *CreateMaximaPanel();
232 
234  wxWindow *CreateStartupPanel();
235 
236 protected:
237  wxGrid *m_maximaEnvVariables;
238  void OnImport(wxCommandEvent& event);
239  static void CopyConfig(wxConfigBase *src, wxConfigBase *dst, wxString dir = wxT("/"));
240  void OnReloadAll(wxCommandEvent& event);
241  void OnReloadStyles(wxCommandEvent& event);
242  void OnResetAllToDefaults(wxCommandEvent& event);
243  void OnExportAll(wxCommandEvent& event);
244  void OnResetStyles(wxCommandEvent& event);
245  void OnChangeMaximaEnvVar(wxGridEvent& event);
246  void OnMaximaEnvRightClick(wxGridEvent& event);
247  void OnMouseMotion_MaximaEnv(wxMouseEvent &event);
248  void OnNewEnvMenu(wxCommandEvent &event);
249  void OnClickMaximaEnvVal(int row);
250  void OnChangeMaximaCellClick(wxGridEvent& event);
251 
257  wxStaticText *m_mp;
258  StringHash m_maximaEnvDoc;
260  wxRadioButton *m_autodetectMaxima;
262  wxRadioButton *m_noAutodetectMaxima;
263  wxRadioButton *m_autodetectHelpBrowser;
264  wxRadioButton *m_noAutodetectHelpBrowser;
266  wxRadioButton *m_autodetectMathJaX;
268  wxRadioButton *m_noAutodetectMathJaX;
270  void OnTabChange(wxBookCtrlEvent &event);
271 
273  void OnStyleToEditChanged(wxCommandEvent &event);
274 
275  // begin wxGlade: ConfigDialogue::attributes
277  wxTextCtrl *m_startupCommands;
279  wxTextCtrl *m_wxStartupCommands;
280  wxTextCtrl *m_maximaUserLocation;
281  wxTextCtrl *m_helpBrowserUserLocation;
282  wxTextCtrl *m_documentclass;
283  wxTextCtrl *m_documentclassOptions;
284  wxTextCtrl *m_texPreamble;
285  wxCheckBox *m_autoSave;
286  wxButton *m_mpBrowse;
287  wxButton *m_wxMathMLBrowse;
288  wxTextCtrl *m_additionalParameters;
289  wxTextCtrl *m_mathJaxURL;
290  wxChoice *m_language;
291  wxTextCtrl *m_symbolPaneAdditionalChars;
292  wxCheckBox *m_abortOnError;
293  wxCheckBox *m_offerKnownAnswers;
294  wxCheckBox *m_restartOnReEvaluation;
295  wxCheckBox *m_wrapLatexMath;
296  wxCheckBox *m_usesvg;
297  wxCheckBox *m_antialiasLines;
298  wxSpinCtrl *m_defaultFramerate;
299  wxSpinCtrl *m_defaultPlotWidth;
300  wxSpinCtrl *m_defaultPlotHeight;
301  wxSpinCtrl *m_displayedDigits;
302  wxRadioButton *m_displayNDigits;
303  wxRadioButton *m_displayAllDigits;
304  wxRadioButton *m_linebreaksInLongNums;
305  wxRadioButton *m_automaticWxMathML;
306  wxRadioButton *m_userWxMathML;
307  wxSpinCtrl *m_maxClipbrdBitmapMegabytes;
308  wxTextCtrl *m_wxMathMLLocation;
312  wxCheckBox *m_usePartialForDiff;
314  wxCheckBox *m_exportContainsWXMX;
315  wxCheckBox *m_printBrackets;
316  wxChoice *m_exportWithMathJAX;
317  wxCheckBox *m_matchParens;
318  wxCheckBox *m_showMatchingParens;
319  wxChoice *m_showLength;
320  wxChoice *m_autosubscript;
321  wxRadioButton *m_enterEvaluates;
322  wxRadioButton *m_ctrlEnterEvaluates;
323  wxCheckBox *m_numpadEnterEvaluates;
324  wxCheckBox *m_saveImgFileName;
325  wxCheckBox *m_saveUntitled;
326  wxCheckBox *m_openHCaret;
327  wxCheckBox *m_insertAns;
328  wxCheckBox *m_autoIndent;
329  wxCheckBox *m_cursorJump;
330  wxCheckBox *m_hideBrackets;
331  wxCheckBox *m_indentMaths;
332  wxChoice *m_autoWrap;
333  wxSpinCtrl *m_labelWidth;
334  wxSpinCtrl *m_undoLimit;
335  wxSpinCtrl *m_recentItems;
336  wxSpinCtrl *m_bitmapScale;
337  wxSpinCtrlDouble *m_printScale;
338  wxCheckBox *m_fixReorderedIndices;
339  wxCheckBox *m_incrementalSearch;
340  wxCheckBox *m_notifyIfIdle;
341  wxChoice *m_showUserDefinedLabels;
342  wxButton *m_getDefaultFont;
343  wxButton *m_getMathFont;
344  wxButton *m_getStyleFont;
345  wxListBox *m_styleFor;
347  ColorPanel *m_styleColor;
348  wxCheckBox *m_boldCB;
349  wxCheckBox *m_italicCB;
350  wxCheckBox *m_underlinedCB;
351  wxCheckBox *m_fixedFontInTC;
352  wxCheckBox *m_unixCopy;
353  wxCheckBox *m_changeAsterisk;
354  wxCheckBox *m_hidemultiplicationSign;
355  wxCheckBox *m_latin2Greek;
356  wxCheckBox *m_useUnicodeMaths;
357  wxCheckBox *m_keepPercentWithSpecials;
358  wxBookCtrlBase *m_notebook;
359  wxButton *m_saveStyle, *m_loadStyle;
360  wxSpinCtrl *m_defaultPort;
361  ExamplePanel *m_examplePanel;
362  wxSpinCtrl *m_maxGnuplotMegabytes;
363  wxSpinCtrl *m_autosaveMinutes;
364  wxTextCtrl *m_autoMathJaxURL;
365  int m_maximaEmvRightClickRow = 0;
367  void MaximaLocationChanged(wxCommandEvent &unused);
368 
370  void UsesvgChanged(wxCommandEvent &event);
371 
373  void OnClose(wxCloseEvent &event);
374 
376  void OnMpBrowse(wxCommandEvent &event);
377 
378  void OnwxMathMLBrowse(wxCommandEvent &event);
379 
380  void OnHelpBrowserBrowse(wxCommandEvent& event);
381 
382  void OnIdle(wxIdleEvent &event);
383 
385  void OnFontButton(wxCommandEvent &event);
386 
388  void OnChangeStyle(wxCommandEvent &event);
389 
391  void OnChangeWarning(wxCommandEvent &event);
392 
394  void OnCheckbox(wxCommandEvent &event);
395 
397  void UpdateExample();
398 
400  void OnChangeFontFamily(wxCommandEvent &event);
401 
403  void LoadSave(wxCommandEvent &event);
404 
406  static TextStyle StyleForListIndex(int index);
408  static int StyleListIndexForStyle(TextStyle style);
410  TextStyle GetSelectedStyle() const;
411 
413  void UpdateButton(TextStyle style);
414 
419 
421  std::unique_ptr<wxImageList> m_imageList;
422 };
423 
424 #ifndef __WXMSW__
425 
426 #endif // __WXMSW__
427 
428 #endif // CONFIG_H
ConfigDialogue::MaximaLocationChanged
void MaximaLocationChanged(wxCommandEvent &unused)
Is called when the path to the maxima binary was changed.
Definition: ConfigDialogue.cpp:315
ConfigDialogue::ConfigDialogue
ConfigDialogue(wxWindow *parent, Configuration *cfg)
The constructor.
Definition: ConfigDialogue.cpp:153
ConfigDialogue::OnClose
void OnClose(wxCloseEvent &event)
Is called when the configuration dialog is closed.
Definition: ConfigDialogue.cpp:1709
TextStyle
TextStyle
Definition: TextStyle.h:307
ConfigDialogue::m_autodetectMathJaX
wxRadioButton * m_autodetectMathJaX
Autodetect the mathJaX location?
Definition: ConfigDialogue.h:266
ConfigDialogue::m_imageList
std::unique_ptr< wxImageList > m_imageList
A list containing the pictograms for the tabs.
Definition: ConfigDialogue.h:421
ConfigDialogue::OnFontButton
void OnFontButton(wxCommandEvent &event)
Starts the font selector dialog triggered by the math or default font buttons.
Definition: ConfigDialogue.cpp:1932
ConfigDialogue::StyleForListIndex
static TextStyle StyleForListIndex(int index)
Map the style list index to a style.
Definition: ConfigDialogue.cpp:1576
ConfigDialogue::GetSelectedStyle
TextStyle GetSelectedStyle() const
Get the style currently selected in the m_styleFor control.
Definition: ConfigDialogue.cpp:1594
ConfigDialogue::UsesvgChanged
void UsesvgChanged(wxCommandEvent &event)
Is called when the path to the maxima binary was changed.
Definition: ConfigDialogue.cpp:294
ConfigDialogue::OnChangeStyle
void OnChangeStyle(wxCommandEvent &event)
Called if a new item type that is to be styled is selected.
Definition: ConfigDialogue.cpp:1978
ConfigDialogue::m_styleColor
ColorPanel * m_styleColor
An example rectangle with the font color.
Definition: ConfigDialogue.h:347
TextStyle.h
ConfigDialogue::m_TeXExponentsAfterSubscript
wxCheckBox * m_TeXExponentsAfterSubscript
A checkbox that asks if TeX should put the exponents above or after the subscripts.
Definition: ConfigDialogue.h:310
ConfigDialogue::OnStyleToEditChanged
void OnStyleToEditChanged(wxCommandEvent &event)
Called if the user changes the style that is to be edited.
Definition: ConfigDialogue.cpp:1702
ConfigDialogue::m_exportContainsWXMX
wxCheckBox * m_exportContainsWXMX
A checkbox that asks if all newlines in text cells have to be passed to HTML.
Definition: ConfigDialogue.h:314
ConfigDialogue::WriteSettings
void WriteSettings()
Definition: ConfigDialogue.cpp:1721
ConfigDialogue::m_startupCommands
wxTextCtrl * m_startupCommands
A textbox containing maxima's startup commands.
Definition: ConfigDialogue.h:277
ConfigDialogue::m_noAutodetectMathJaX
wxRadioButton * m_noAutodetectMathJaX
The radio button that is set if m_autodetectMathJaX is unset.
Definition: ConfigDialogue.h:268
Style
Definition: TextStyle.h:130
ConfigDialogue::OnChangeWarning
void OnChangeWarning(wxCommandEvent &event)
A message dialog that appears if a change cannot be applied now.
Definition: ConfigDialogue.cpp:2145
ConfigDialogue::UpdateExample
void UpdateExample()
Sets the style example's style on style changes.
Definition: ConfigDialogue.cpp:2153
ConfigDialogue::m_startupFileName
wxString m_startupFileName
The name of maxima's startup file.
Definition: ConfigDialogue.h:253
ConfigDialogue::htmlExportFormats
htmlExportFormats
The export formats we support for HTML equations.
Definition: ConfigDialogue.h:88
ConfigDialogue::OnMpBrowse
void OnMpBrowse(wxCommandEvent &event)
Starts the file chooser that allows selecting where the maxima binary lies.
Definition: ConfigDialogue.cpp:1889
ConfigDialogue::OnChangeColor
void OnChangeColor()
Definition: ConfigDialogue.cpp:1969
ConfigDialogue::m_autodetectMaxima
wxRadioButton * m_autodetectMaxima
Autodetect the maxima location?
Definition: ConfigDialogue.h:260
ConfigDialogue::OnCheckbox
void OnCheckbox(wxCommandEvent &event)
Called if one of the checkboxes for bold, italic or underlined is toggled.
Definition: ConfigDialogue.cpp:2136
ConfigDialogue::OnTabChange
void OnTabChange(wxBookCtrlEvent &event)
Called if the currently active dialogue sheet is changed.
Definition: ConfigDialogue.cpp:2175
ConfigDialogue
Definition: ConfigDialogue.h:78
ConfigDialogue::m_mp
wxStaticText * m_mp
The text "Maxima Program" that can change color.
Definition: ConfigDialogue.h:257
ConfigDialogue::StyleListIndexForStyle
static int StyleListIndexForStyle(TextStyle style)
Map the style to the style list index.
Definition: ConfigDialogue.cpp:1585
Configuration
Definition: Configuration.h:83
ConfigDialogue::m_usePartialForDiff
wxCheckBox * m_usePartialForDiff
A checkbox that asks if TeX should use the \partial symbol for representing diff()
Definition: ConfigDialogue.h:312
ConfigDialogue::LoadSave
void LoadSave(wxCommandEvent &event)
A "export the configuration" dialog.
Definition: ConfigDialogue.cpp:2182
ConfigDialogue::~ConfigDialogue
~ConfigDialogue()
The destructor.
Definition: ConfigDialogue.cpp:290
ConfigDialogue::m_noAutodetectMaxima
wxRadioButton * m_noAutodetectMaxima
The radio button that is set if m_autodetectMaxima is unset.
Definition: ConfigDialogue.h:262
ConfigDialogue::m_wxStartupCommands
wxTextCtrl * m_wxStartupCommands
A textbox containing wxMaxima's startup commands.
Definition: ConfigDialogue.h:279
ConfigDialogue::m_mathFontSize
int m_mathFontSize
The size of the maths font.
Definition: ConfigDialogue.h:418
ConfigDialogue::m_fontSize
int m_fontSize
The size of the text font.
Definition: ConfigDialogue.h:416
ConfigDialogue::OnChangeFontFamily
void OnChangeFontFamily(wxCommandEvent &event)
Called if the font family is changed.
Definition: ConfigDialogue.cpp:1946
ConfigDialogue::m_wxStartupFileName
wxString m_wxStartupFileName
The name of wxMaxima's startup file.
Definition: ConfigDialogue.h:255
ConfigDialogue::UpdateButton
void UpdateButton(TextStyle style)
Sets the label for the font setting button given by the style (either TS_DEFAULT or TS_MATH)
Definition: ConfigDialogue.cpp:1599