wxMaxima
Loading...
Searching...
No Matches
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
32extern unsigned int view_refresh_svg_gz_len;
33extern unsigned char view_refresh_svg_gz[];
34
35#include "precomp.h"
36#include <wx/wx.h>
37#include "BinaryNameCtrl.h"
38#include <wx/image.h>
39#include <wx/grid.h>
40#include <wx/hashmap.h>
41#include <wx/clrpicker.h>
42#include <memory>
43#include <wx/propdlg.h>
44#include <wx/generic/propdlg.h>
45#include <wx/spinctrl.h>
46#include <wx/notebook.h>
47
48#include <wx/imaglist.h>
49#include <wx/bookctrl.h>
50#include <wx/artprov.h>
51#include <unordered_map>
52#include <vector>
53#include <wx/hyperlink.h>
54
55#ifndef CONFIGDIALOGUE_H
56#define CONFIGDIALOGUE_H
57
58#include "cells/TextStyle.h"
59#include "worksheet/Worksheet.h"
60#include "../Configuration.h"
61#include "ai/AiProvider.h"
62
63enum
64{
65 color_id,
66 listbox_styleFor,
67 checkbox_bold,
68 checkbox_italic,
69 checkbox_underlined,
70 checkbox_slanted,
71 checkbox_strikethrough,
72 button_defaultFont,
73 button_mathFont,
74 style_font_family,
75 language_id,
76 save_id,
77 load_id
78};
79
87class ConfigDialogue : public wxPropertySheetDialog
88{
89public:
91 explicit ConfigDialogue(wxWindow *parent);
92
95
98 {
99 mathJaX_TeX = 0,
100 bitmap = 1,
101 mathML_mathJaX = 2,
102 svg = 3
103 };
104
106 void OnChangeColor(wxColourPickerEvent& event);
107
113 void WriteSettings();
114
115private:
116 const int mMinPanelWidth = 500;
117 const int mMinPanelHeight = 500;
118
119private:
120 enum newVariables
121 {
122 MAXIMA_DEFAULT_LISP,
123 MAXIMA_IMAGESDIR,
124 MAXIMA_USERDIR,
125 MAXIMA_DIRECTORY,
126 MAXIMA_TEMPDIR,
127 MAXIMA_OBJDIR,
128 MAXIMA_DOC_PREFIX,
129 GCL_GC_PAGE_THRESH,
130 GCL_GC_ALLOC_MIN,
131 GCL_GC_PAGE_MAX,
132 GCL_MEM_MULTIPLE,
133 GCL_MULTIPROCESS_MEMORY_POOL,
134 LANG,
135 HOME,
136 VAR_DELETE
137 };
138 std::unique_ptr<struct wxm_NSVGrasterizer, decltype(std::free)*> m_svgRast{nullptr, std::free};
140 std::unique_ptr<Configuration> m_configuration;
141 Worksheet *m_sampleWorksheet = NULL;
142
143 typedef std::unordered_map <wxString, wxString, wxStringHash> StringHash;
144 typedef std::unordered_map <wxString, long, wxStringHash> Languages;
145
146 Languages m_languages;
151 class ExamplePanel : public wxPanel
152 {
153 public:
155 ExamplePanel(wxWindow *parent, int id, wxPoint pos, wxSize size) : wxPanel(parent, id, pos, size)
156 { Bind(wxEVT_PAINT, &ConfigDialogue::ExamplePanel::OnPaint, this); };
157
159 void SetStyle(const Style &style)
160 {
161 m_style = style;
162 Refresh();
163 }
164
165 private:
170 void OnPaint(wxPaintEvent &event);
171
173 Style m_style;
174 };
175
176
181 void SetCheckboxValues();
182
184 int GetImageSize();
185
187 wxWindow *CreateClipboardPanel();
188 wxWindow *CreateAiChatPanel();
189
191 wxWindow *CreatePrintPanel();
192
194 wxWindow *CreateRevertToDefaultsPanel();
195
196#if wxUSE_ACCESSIBILITY
198 wxWindow *CreateAccessibilityPanel();
199
201 wxCheckBox *m_screenReaderMathML;
202#endif
203
204 wxCheckBox *m_copyBitmap, *m_copyMathML, *m_copyMathMLHTML, *m_copyRTF, *m_copySVG;
205#if wxUSE_ENH_METAFILE
206 wxCheckBox *m_copyEMF;
207#endif
208
210 wxWindow *CreateWorksheetPanel();
211
213 wxWindow *CreateOptionsPanel();
214
216 wxWindow *CreateExportPanel();
217
219 wxWindow *CreateStylePanel();
220
222 wxWindow *CreateMaximaPanel();
223
225 wxWindow *CreateStartupPanel();
226
227protected:
228 wxGrid *m_maximaEnvVariables;
229 void OnImport(wxCommandEvent& event);
230 static void CopyConfig(wxConfigBase *src, wxConfigBase *dst, wxString dir = wxS("/"));
231 void OnReloadAll(wxCommandEvent& event);
232 void OnReloadStyles(wxCommandEvent& event);
233 void OnResetAllToDefaults(wxCommandEvent& event);
234 void OnExportAll(wxCommandEvent& event);
235 void OnResetStyles(wxCommandEvent& event);
236 void OnChangeMaximaEnvVar(wxGridEvent& event);
237 void OnMaximaEnvRightClick(wxGridEvent& event);
238 void OnMouseMotion_MaximaEnv(wxMouseEvent &event);
239 void OnNewEnvMenu(wxCommandEvent &event);
240 void OnClickMaximaEnvVal(int row);
241 void OnChangeMaximaCellClick(wxGridEvent& event);
242
248 wxStaticText *m_mp;
249 StringHash m_maximaEnvDoc;
251 wxRadioButton *m_autodetectMaxima;
253 wxRadioButton *m_noAutodetectMaxima;
254 wxRadioButton *m_autodetectHelpBrowser;
255 wxRadioButton *m_noAutodetectHelpBrowser;
256 wxRadioButton *m_internalHelpBrowser;
257 wxCheckBox *m_singlePageManual;
258 wxRadioButton *m_maximaUsesInternalHelp;
259 wxRadioButton *m_maximaUsesHtmlHelp;
260 wxRadioButton *m_maximaUsesWxmaximaHelp;
262 wxRadioButton *m_autodetectMathJaX;
264 wxRadioButton *m_noAutodetectMathJaX;
265 wxRadioButton *m_useGnuplot;
266 wxRadioButton *m_useWgnuplot;
268 void OnTabChange(wxBookCtrlEvent &event);
269
271 void OnStyleToEditChanged(wxCommandEvent &event);
273 void OnAppearanceChanged(wxCommandEvent &event);
274
275 // begin wxGlade: ConfigDialogue::attributes
277 wxTextCtrl *m_startupCommands;
280 BinaryNameCtrl *m_maximaUserLocation;
281 BinaryNameCtrl *m_helpBrowserUserLocation;
282 wxTextCtrl *m_documentclass;
283 wxTextCtrl *m_documentclassOptions;
284 wxTextCtrl *m_texPreamble;
285 wxCheckBox *m_autoSave;
286 wxButton *m_wxMathMLBrowse;
287 wxTextCtrl *m_additionalParameters;
288 wxTextCtrl *m_mathJaxURL;
289 wxChoice *m_language;
290 wxTextCtrl *m_symbolPaneAdditionalChars;
291 wxCheckBox *m_abortOnError;
292 wxCheckBox *m_offerKnownAnswers;
293 wxCheckBox *m_restartOnReEvaluation;
294 wxCheckBox *m_wrapLatexMath;
295 wxCheckBox *m_usesvg;
296 wxCheckBox *m_antialiasLines;
297 wxSpinCtrlDouble *m_defaultFramerate;
298 wxSpinCtrl *m_defaultPlotWidth;
299 wxSpinCtrl *m_defaultPlotHeight;
300 wxSpinCtrl *m_displayedDigits;
301 wxSpinCtrl *m_printMargin_Top;
302 wxSpinCtrl *m_printMargin_Bot;
303 wxSpinCtrl *m_printMargin_Left;
304 wxSpinCtrl *m_printMargin_Right;
305 wxRadioButton *m_displayNDigits;
306 wxRadioButton *m_displayAllDigits;
307 wxRadioButton *m_linebreaksInLongNums;
308 wxSpinCtrl *m_maxClipbrdBitmapMegabytes;
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 wxRadioBox *m_layoutStrategy;
322 wxRadioButton *m_enterEvaluates;
323 wxRadioButton *m_ctrlEnterEvaluates;
324 wxCheckBox *m_numpadEnterEvaluates;
325 wxCheckBox *m_saveImgFileName;
326 wxCheckBox *m_saveUntitled;
327 wxCheckBox *m_openHCaret;
328 wxCheckBox *m_insertAns;
329 wxCheckBox *m_autoIndent;
330 wxCheckBox *m_cursorJump;
331 wxCheckBox *m_hideBrackets;
332#ifdef __WXGTK__
335 wxCheckBox *m_overlayScrollbars;
336#endif
337 wxCheckBox *m_indentMaths;
338 wxChoice *m_autoWrap;
339 wxSpinCtrl *m_labelWidth;
340 wxSpinCtrl *m_recentItems;
341 wxSpinCtrl *m_bitmapScale;
342 wxSpinCtrlDouble *m_printScale;
343 wxCheckBox *m_fixReorderedIndices;
344 wxCheckBox *m_incrementalSearch;
345 wxCheckBox *m_notifyIfIdle;
346 wxCheckBox *m_findDialogDockable;
347 wxCheckBox *m_mcpServerEnabled;
348 wxSpinCtrl *m_mcpServerPort;
354 AiProviderKind kind;
357 wxString customId;
360 wxString displayName;
363 AiProviderShape shape = AiProviderShape::OpenAiCompatible;
364 wxString baseUrl;
365 wxString apiKey;
366 wxString model;
367 };
368 std::vector<AiProviderUiRecord> m_aiProviderRecords;
374 wxChoice *m_aiChatProviderChoice;
378 wxStaticBoxSizer *m_aiProviderDetailBox;
379 wxStaticText *m_aiBaseUrlLabel;
382 wxTextCtrl *m_aiBaseUrlCtrl;
383 wxStaticText *m_aiShapeLabel;
384 wxChoice *m_aiShapeChoice;
385 wxTextCtrl *m_aiKeyCtrl;
386 wxTextCtrl *m_aiModelCtrl;
387 wxHyperlinkCtrl *m_aiApiKeyLink;
388 wxHyperlinkCtrl *m_aiModelListLink;
392 void OnAiProviderChoice(wxCommandEvent &event);
393 void OnAiRemoveCustomProvider(wxCommandEvent &event);
401 void LoadAiProviderRecordIntoUi(int index);
410 void RebuildAiProviderChoice(int selectIndex);
411 wxChoice *m_showUserDefinedLabels;
412 wxButton *m_getStyleFont;
415 wxListBox *m_styleFor;
417 wxColourPickerCtrl *m_styleColor;
418 wxCheckBox *m_boldCB;
419 wxCheckBox *m_italicCB;
420 wxCheckBox *m_slantedCB;
421 wxCheckBox *m_strikethroughCB;
422 wxCheckBox *m_underlinedCB;
423 wxCheckBox *m_fixedFontInTC;
424 wxCheckBox *m_unixCopy;
425 wxCheckBox *m_changeAsterisk;
426 wxCheckBox *m_hidemultiplicationSign;
427 wxCheckBox *m_latin2Greek;
428 wxCheckBox *m_useUnicodeMaths;
429 wxCheckBox *m_keepPercentWithSpecials;
430 wxBookCtrlBase *m_notebook;
431 wxButton *m_saveStyle, *m_loadStyle;
432 wxSpinCtrl *m_defaultPort;
433 ExamplePanel *m_examplePanel;
434 wxSpinCtrl *m_maxGnuplotMegabytes;
435 wxSpinCtrl *m_autosaveMinutes;
436 wxSpinCtrl *m_maxLayoutTime;
437 wxTextCtrl *m_autoMathJaxURL;
438 int m_maximaEmvRightClickRow = 0;
439
441 void UsesvgChanged(wxCommandEvent &event);
442
444 void OnClose(wxCloseEvent &event);
445
446 void OnwxMathMLBrowse(wxCommandEvent &event);
447
448 void OnIdle(wxIdleEvent &event);
449
451 void OnChangeStyle(wxCommandEvent &event);
452
454 void OnChangeWarning(wxCommandEvent &event);
455
457 void OnCheckbox(wxCommandEvent &event);
458
460 void UpdateExample();
461
463 void OnChangeFontFamily(wxCommandEvent &event);
464
466 void LoadSave(wxCommandEvent &event);
467
470
475
477#if wxCHECK_VERSION(3, 1, 6)
478 wxVector<wxBitmapBundle> m_imageList;
479#else
480 std::unique_ptr<wxImageList> m_imageList;
481#endif
482};
483
484#ifndef __WXMSW__
485
486#endif // __WXMSW__
487
488#endif // CONFIG_H
Talks to one of a handful of external AI chat APIs for the AI chat sidebar (AiChatSidebar).
AiProviderShape
Which request/response wire format a provider uses. The four built-in AiProviderKinds each hardcode o...
Definition: AiProvider.h:71
AiProviderKind
Which AI service to talk to. Persisted as a plain int in Configuration; keep existing values stable a...
Definition: AiProvider.h:58
This file declares all the wizards the draw sidepane needs.
This file declares everything needed for the text style system used to style all the elements on the ...
TextStyle
All text styles known to wxMaxima.
Definition: TextStyle.h:235
This file defines the class Worksheet.
A dialog that shows the program's license.
Definition: BinaryNameCtrl.h:40
The configuration dialog.
Definition: ConfigDialogue.h:88
void StashAiProviderUiIntoRecord()
Copies the on-screen key/model/(baseUrl/shape for Custom) fields back into m_aiProviderRecords[m_aiAc...
Definition: ConfigDialogue.cpp:2136
int m_mathFontSize
The size of the maths font.
Definition: ConfigDialogue.h:474
void OnCheckbox(wxCommandEvent &event)
Called if one of the checkboxes for bold, italic or underlined is toggled.
Definition: ConfigDialogue.cpp:3104
bool AddCustomAiProviderDialog()
Opens a small modal to create a new custom provider (name/shape/ baseUrl/model); on success appends i...
Definition: ConfigDialogue.cpp:2239
wxRadioButton * m_noAutodetectMathJaX
The radio button that is set if m_autodetectMathJaX is unset.
Definition: ConfigDialogue.h:264
wxCheckBox * m_exportContainsWXMX
A checkbox that asks if all newlines in text cells have to be passed to HTML.
Definition: ConfigDialogue.h:314
void LoadAiProviderRecordIntoUi(int index)
The inverse: populates the shared detail box from m_aiProviderRecords[index], showing/hiding the Cust...
Definition: ConfigDialogue.cpp:2154
std::unique_ptr< wxImageList > m_imageList
A list containing the pictograms for the tabs.
Definition: ConfigDialogue.h:480
void OnStyleToEditChanged(wxCommandEvent &event)
Called if the user changes the style that is to be edited.
Definition: ConfigDialogue.cpp:2670
wxRadioButton * m_autodetectMathJaX
Autodetect the mathJaX location?
Definition: ConfigDialogue.h:262
wxRadioButton * m_autodetectMaxima
Autodetect the maxima location?
Definition: ConfigDialogue.h:251
void OnChangeWarning(wxCommandEvent &event)
A message dialog that appears if a change cannot be applied now.
Definition: ConfigDialogue.cpp:3121
void UpdateExample()
Sets the style example's style on style changes.
Definition: ConfigDialogue.cpp:3127
int m_aiActiveProviderRecordIndex
Index into m_aiProviderRecords of whichever one m_aiKeyCtrl/ m_aiModelCtrl/... currently display,...
Definition: ConfigDialogue.h:373
wxStaticBoxSizer * m_aiProviderDetailBox
One reusable box showing whichever provider is currently selected, rather than all of them stacked at...
Definition: ConfigDialogue.h:378
int m_fontSize
The size of the text font.
Definition: ConfigDialogue.h:472
wxCheckBox * m_usePartialForDiff
A checkbox that asks if TeX should use the \partial symbol for representing diff()
Definition: ConfigDialogue.h:312
void WriteSettings()
Stores the settings from the configuration dialog.
Definition: ConfigDialogue.cpp:2698
wxStaticText * m_mp
The text "Maxima Program" that can change color.
Definition: ConfigDialogue.h:248
wxColourPickerCtrl * m_styleColor
An example rectangle with the font color.
Definition: ConfigDialogue.h:417
wxChoice * m_appearanceChoice
Light / Dark / Follow-system selector (also picks which set the editor edits).
Definition: ConfigDialogue.h:414
void OnClose(wxCloseEvent &event)
Is called when the configuration dialog is closed.
Definition: ConfigDialogue.cpp:2687
wxString m_wxStartupFileName
The name of wxMaxima's startup file.
Definition: ConfigDialogue.h:246
wxTextCtrl * m_aiBaseUrlCtrl
Editable only for a Custom record; shows (read-only, via Disable()) the fixed URL for a built-in one,...
Definition: ConfigDialogue.h:382
wxTextCtrl * m_startupCommands
A textbox containing maxima's startup commands.
Definition: ConfigDialogue.h:277
void OnChangeStyle(wxCommandEvent &event)
Called if a new item type that is to be styled is selected.
Definition: ConfigDialogue.cpp:2968
TextStyle GetSelectedStyle() const
Get the style currently selected in the m_styleFor control.
Definition: ConfigDialogue.cpp:2499
void UsesvgChanged(wxCommandEvent &event)
Is called when the path to the maxima binary was changed.
Definition: ConfigDialogue.cpp:356
wxString m_startupFileName
The name of maxima's startup file.
Definition: ConfigDialogue.h:244
wxRadioButton * m_noAutodetectMaxima
The radio button that is set if m_autodetectMaxima is unset.
Definition: ConfigDialogue.h:253
wxTextCtrl * m_wxStartupCommands
A textbox containing wxMaxima's startup commands.
Definition: ConfigDialogue.h:279
htmlExportFormats
The export formats we support for HTML equations.
Definition: ConfigDialogue.h:98
wxButton * m_aiRemoveCustomProviderButton
Shown only for a Custom record; deletes it (and its stored API key) outright rather than just clearin...
Definition: ConfigDialogue.h:391
void RebuildAiProviderChoice(int selectIndex)
Rebuilds m_aiChatProviderChoice's items from m_aiProviderRecords (plus the fixed "None (disabled)" an...
Definition: ConfigDialogue.cpp:2123
~ConfigDialogue()
The destructor.
Definition: ConfigDialogue.cpp:344
void OnChangeFontFamily(wxCommandEvent &event)
Called if the font family is changed.
Definition: ConfigDialogue.cpp:2942
wxCheckBox * m_TeXExponentsAfterSubscript
A checkbox that asks if TeX should put the exponents above or after the subscripts.
Definition: ConfigDialogue.h:310
void OnAppearanceChanged(wxCommandEvent &event)
Light / Dark / Follow-system appearance changed: re-point the style editor.
Definition: ConfigDialogue.cpp:2676
void OnTabChange(wxBookCtrlEvent &event)
Called if the currently active dialogue sheet is changed.
Definition: ConfigDialogue.cpp:3147
void OnChangeColor(wxColourPickerEvent &event)
Called if the color of an item has been changed.
Definition: ConfigDialogue.cpp:2960
void LoadSave(wxCommandEvent &event)
A "export the configuration" dialog.
Definition: ConfigDialogue.cpp:3153
Text Style Definition.
Definition: TextStyle.h:67
The canvas that contains the spreadsheet the whole program is about.
Definition: Worksheet.h:116
One entry per configurable provider – the four built-ins (in fixed order) plus any custom ones – kept...
Definition: ConfigDialogue.h:353
wxString customId
Only set when kind == AiProviderKind::Custom; matches AiCustomProviderConfig::id.
Definition: ConfigDialogue.h:357
AiProviderShape shape
Meaningful only when kind == Custom – a built-in's shape/URL are implied by its kind and never shown ...
Definition: ConfigDialogue.h:363
wxString displayName
Shown in m_aiChatProviderChoice; AiProviderKindName(kind) for a built-in, user-chosen for a custom on...
Definition: ConfigDialogue.h:360