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 "BuildConfig.h"
59
60#include "cells/TextStyle.h"
61#include "worksheet/Worksheet.h"
62#include "../Configuration.h"
63#ifdef WXM_USE_AI_TOOLS
64#include "ai/AiProvider.h"
65#endif
66
67enum
68{
69 color_id,
70 listbox_styleFor,
71 checkbox_bold,
72 checkbox_italic,
73 checkbox_underlined,
74 checkbox_slanted,
75 checkbox_strikethrough,
76 button_defaultFont,
77 button_mathFont,
78 style_font_family,
79 language_id,
80 save_id,
81 load_id
82};
83
91class ConfigDialogue : public wxPropertySheetDialog
92{
93public:
95 explicit ConfigDialogue(wxWindow *parent);
96
99
102 {
103 mathJaX_TeX = 0,
104 bitmap = 1,
105 mathML_mathJaX = 2,
106 svg = 3
107 };
108
110 void OnChangeColor(wxColourPickerEvent& event);
111
117 void WriteSettings();
118
119private:
120 const int mMinPanelWidth = 500;
121 const int mMinPanelHeight = 500;
122
123private:
124 enum newVariables
125 {
126 MAXIMA_DEFAULT_LISP,
127 MAXIMA_IMAGESDIR,
128 MAXIMA_USERDIR,
129 MAXIMA_DIRECTORY,
130 MAXIMA_TEMPDIR,
131 MAXIMA_OBJDIR,
132 MAXIMA_DOC_PREFIX,
133 GCL_GC_PAGE_THRESH,
134 GCL_GC_ALLOC_MIN,
135 GCL_GC_PAGE_MAX,
136 GCL_MEM_MULTIPLE,
137 GCL_MULTIPROCESS_MEMORY_POOL,
138 LANG,
139 HOME,
140 VAR_DELETE
141 };
142 std::unique_ptr<struct wxm_NSVGrasterizer, decltype(std::free)*> m_svgRast{nullptr, std::free};
144 std::unique_ptr<Configuration> m_configuration;
145 Worksheet *m_sampleWorksheet = NULL;
146
147 typedef std::unordered_map <wxString, wxString, wxStringHash> StringHash;
148 typedef std::unordered_map <wxString, long, wxStringHash> Languages;
149
150 Languages m_languages;
155 class ExamplePanel : public wxPanel
156 {
157 public:
159 ExamplePanel(wxWindow *parent, int id, wxPoint pos, wxSize size) : wxPanel(parent, id, pos, size)
160 { Bind(wxEVT_PAINT, &ConfigDialogue::ExamplePanel::OnPaint, this); };
161
163 void SetStyle(const Style &style)
164 {
165 m_style = style;
166 Refresh();
167 }
168
169 private:
174 void OnPaint(wxPaintEvent &event);
175
177 Style m_style;
178 };
179
180
185 void SetCheckboxValues();
186
188 int GetImageSize();
189
191 wxWindow *CreateClipboardPanel();
192#ifdef WXM_USE_AI_TOOLS
193 wxWindow *CreateAiChatPanel();
194#endif
195
197 wxWindow *CreatePrintPanel();
198
200 wxWindow *CreateRevertToDefaultsPanel();
201
202#if wxUSE_ACCESSIBILITY
204 wxWindow *CreateAccessibilityPanel();
205
207 wxCheckBox *m_screenReaderMathML;
208#endif
209
210 wxCheckBox *m_copyBitmap, *m_copyMathML, *m_copyMathMLHTML, *m_copyRTF, *m_copySVG;
211#if wxUSE_ENH_METAFILE
212 wxCheckBox *m_copyEMF;
213#endif
214
216 wxWindow *CreateWorksheetPanel();
217
219 wxWindow *CreateOptionsPanel();
220
222 wxWindow *CreateExportPanel();
223
225 wxWindow *CreateStylePanel();
226
228 wxWindow *CreateMaximaPanel();
229
231 wxWindow *CreateStartupPanel();
232
233protected:
234 wxGrid *m_maximaEnvVariables;
235 void OnImport(wxCommandEvent& event);
236 static void CopyConfig(wxConfigBase *src, wxConfigBase *dst, wxString dir = wxS("/"));
237 void OnReloadAll(wxCommandEvent& event);
238 void OnReloadStyles(wxCommandEvent& event);
239 void OnResetAllToDefaults(wxCommandEvent& event);
240 void OnExportAll(wxCommandEvent& event);
241 void OnResetStyles(wxCommandEvent& event);
242 void OnChangeMaximaEnvVar(wxGridEvent& event);
243 void OnMaximaEnvRightClick(wxGridEvent& event);
244 void OnMouseMotion_MaximaEnv(wxMouseEvent &event);
245 void OnNewEnvMenu(wxCommandEvent &event);
246 void OnClickMaximaEnvVal(int row);
247 void OnChangeMaximaCellClick(wxGridEvent& event);
248
254 wxStaticText *m_mp;
255 StringHash m_maximaEnvDoc;
257 wxRadioButton *m_autodetectMaxima;
259 wxRadioButton *m_noAutodetectMaxima;
260 wxRadioButton *m_autodetectHelpBrowser;
261 wxRadioButton *m_noAutodetectHelpBrowser;
262 wxRadioButton *m_internalHelpBrowser;
263 wxCheckBox *m_singlePageManual;
264 wxRadioButton *m_maximaUsesInternalHelp;
265 wxRadioButton *m_maximaUsesHtmlHelp;
266 wxRadioButton *m_maximaUsesWxmaximaHelp;
268 wxRadioButton *m_autodetectMathJaX;
270 wxRadioButton *m_noAutodetectMathJaX;
271 wxRadioButton *m_useGnuplot;
272 wxRadioButton *m_useWgnuplot;
274 void OnTabChange(wxBookCtrlEvent &event);
275
277 void OnStyleToEditChanged(wxCommandEvent &event);
279 void OnAppearanceChanged(wxCommandEvent &event);
280
281 // begin wxGlade: ConfigDialogue::attributes
283 wxTextCtrl *m_startupCommands;
286 BinaryNameCtrl *m_maximaUserLocation;
287 BinaryNameCtrl *m_helpBrowserUserLocation;
288 wxTextCtrl *m_documentclass;
289 wxTextCtrl *m_documentclassOptions;
290 wxTextCtrl *m_texPreamble;
291 wxCheckBox *m_autoSave;
292 wxButton *m_wxMathMLBrowse;
293 wxTextCtrl *m_additionalParameters;
294 wxTextCtrl *m_mathJaxURL;
295 wxChoice *m_language;
296 wxTextCtrl *m_symbolPaneAdditionalChars;
297 wxCheckBox *m_abortOnError;
298 wxCheckBox *m_offerKnownAnswers;
299 wxCheckBox *m_restartOnReEvaluation;
300 wxCheckBox *m_wrapLatexMath;
301 wxCheckBox *m_usesvg;
302 wxCheckBox *m_antialiasLines;
303 wxSpinCtrlDouble *m_defaultFramerate;
304 wxSpinCtrl *m_defaultPlotWidth;
305 wxSpinCtrl *m_defaultPlotHeight;
306 wxSpinCtrl *m_displayedDigits;
307 wxSpinCtrl *m_printMargin_Top;
308 wxSpinCtrl *m_printMargin_Bot;
309 wxSpinCtrl *m_printMargin_Left;
310 wxSpinCtrl *m_printMargin_Right;
311 wxRadioButton *m_displayNDigits;
312 wxRadioButton *m_displayAllDigits;
313 wxRadioButton *m_linebreaksInLongNums;
314 wxSpinCtrl *m_maxClipbrdBitmapMegabytes;
321 wxCheckBox *m_printBrackets;
322 wxChoice *m_exportWithMathJAX;
323 wxCheckBox *m_matchParens;
324 wxCheckBox *m_showMatchingParens;
325 wxChoice *m_showLength;
326 wxChoice *m_autosubscript;
327 wxRadioBox *m_layoutStrategy;
328 wxRadioButton *m_enterEvaluates;
329 wxRadioButton *m_ctrlEnterEvaluates;
330 wxCheckBox *m_numpadEnterEvaluates;
331 wxCheckBox *m_saveImgFileName;
332 wxCheckBox *m_saveUntitled;
333 wxCheckBox *m_openHCaret;
334 wxCheckBox *m_insertAns;
335 wxCheckBox *m_autoIndent;
336 wxCheckBox *m_cursorJump;
337 wxCheckBox *m_hideBrackets;
338#ifdef __WXGTK__
341 wxCheckBox *m_overlayScrollbars;
342#endif
343 wxCheckBox *m_indentMaths;
344 wxChoice *m_autoWrap;
345 wxSpinCtrl *m_labelWidth;
346 wxSpinCtrl *m_recentItems;
347 wxSpinCtrl *m_bitmapScale;
348 wxSpinCtrlDouble *m_printScale;
349 wxCheckBox *m_fixReorderedIndices;
350 wxCheckBox *m_incrementalSearch;
351 wxCheckBox *m_notifyIfIdle;
352 wxCheckBox *m_findDialogDockable;
353 wxCheckBox *m_mcpServerEnabled;
354 wxSpinCtrl *m_mcpServerPort;
355#ifdef WXM_USE_AI_TOOLS
360 struct AiProviderUiRecord {
361 AiProviderKind kind;
364 wxString customId;
367 wxString displayName;
370 AiProviderShape shape = AiProviderShape::OpenAiCompatible;
371 wxString baseUrl;
372 wxString apiKey;
373 wxString model;
374 };
375 std::vector<AiProviderUiRecord> m_aiProviderRecords;
380 int m_aiActiveProviderRecordIndex = -1;
381 wxChoice *m_aiChatProviderChoice;
385 wxStaticBoxSizer *m_aiProviderDetailBox;
386 wxStaticText *m_aiBaseUrlLabel;
389 wxTextCtrl *m_aiBaseUrlCtrl;
390 wxStaticText *m_aiShapeLabel;
391 wxChoice *m_aiShapeChoice;
392 wxTextCtrl *m_aiKeyCtrl;
393 wxTextCtrl *m_aiModelCtrl;
394 wxHyperlinkCtrl *m_aiApiKeyLink;
395 wxHyperlinkCtrl *m_aiModelListLink;
398 wxButton *m_aiRemoveCustomProviderButton;
399 void OnAiProviderChoice(wxCommandEvent &event);
400 void OnAiRemoveCustomProvider(wxCommandEvent &event);
404 void StashAiProviderUiIntoRecord();
408 void LoadAiProviderRecordIntoUi(int index);
413 bool AddCustomAiProviderDialog();
417 void RebuildAiProviderChoice(int selectIndex);
418#endif
419 wxChoice *m_showUserDefinedLabels;
420 wxButton *m_getStyleFont;
423 wxListBox *m_styleFor;
425 wxColourPickerCtrl *m_styleColor;
426 wxCheckBox *m_boldCB;
427 wxCheckBox *m_italicCB;
428 wxCheckBox *m_slantedCB;
429 wxCheckBox *m_strikethroughCB;
430 wxCheckBox *m_underlinedCB;
431 wxCheckBox *m_fixedFontInTC;
432 wxCheckBox *m_unixCopy;
433 wxCheckBox *m_changeAsterisk;
434 wxCheckBox *m_hidemultiplicationSign;
435 wxCheckBox *m_latin2Greek;
436 wxCheckBox *m_useUnicodeMaths;
437 wxCheckBox *m_keepPercentWithSpecials;
438 wxBookCtrlBase *m_notebook;
439 wxButton *m_saveStyle, *m_loadStyle;
440 wxSpinCtrl *m_defaultPort;
441 ExamplePanel *m_examplePanel;
442 wxSpinCtrl *m_maxGnuplotMegabytes;
443 wxSpinCtrl *m_autosaveMinutes;
444 wxSpinCtrl *m_maxLayoutTime;
445 wxTextCtrl *m_autoMathJaxURL;
446 int m_maximaEmvRightClickRow = 0;
447
449 void UsesvgChanged(wxCommandEvent &event);
450
452 void OnClose(wxCloseEvent &event);
453
454 void OnwxMathMLBrowse(wxCommandEvent &event);
455
456 void OnIdle(wxIdleEvent &event);
457
459 void OnChangeStyle(wxCommandEvent &event);
460
462 void OnChangeWarning(wxCommandEvent &event);
463
465 void OnCheckbox(wxCommandEvent &event);
466
468 void UpdateExample();
469
471 void OnChangeFontFamily(wxCommandEvent &event);
472
474 void LoadSave(wxCommandEvent &event);
475
478
483
485#if wxCHECK_VERSION(3, 1, 6)
486 wxVector<wxBitmapBundle> m_imageList;
487#else
488 std::unique_ptr<wxImageList> m_imageList;
489#endif
490};
491
492#ifndef __WXMSW__
493
494#endif // __WXMSW__
495
496#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:82
AiProviderKind
Which AI service to talk to. Persisted as a plain int in Configuration; keep existing values stable a...
Definition: AiProvider.h:67
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:92
int m_mathFontSize
The size of the maths font.
Definition: ConfigDialogue.h:482
void OnCheckbox(wxCommandEvent &event)
Called if one of the checkboxes for bold, italic or underlined is toggled.
Definition: ConfigDialogue.cpp:3139
wxRadioButton * m_noAutodetectMathJaX
The radio button that is set if m_autodetectMathJaX is unset.
Definition: ConfigDialogue.h:270
wxCheckBox * m_exportContainsWXMX
A checkbox that asks if all newlines in text cells have to be passed to HTML.
Definition: ConfigDialogue.h:320
std::unique_ptr< wxImageList > m_imageList
A list containing the pictograms for the tabs.
Definition: ConfigDialogue.h:488
void OnStyleToEditChanged(wxCommandEvent &event)
Called if the user changes the style that is to be edited.
Definition: ConfigDialogue.cpp:2699
wxRadioButton * m_autodetectMathJaX
Autodetect the mathJaX location?
Definition: ConfigDialogue.h:268
wxRadioButton * m_autodetectMaxima
Autodetect the maxima location?
Definition: ConfigDialogue.h:257
void OnChangeWarning(wxCommandEvent &event)
A message dialog that appears if a change cannot be applied now.
Definition: ConfigDialogue.cpp:3156
void UpdateExample()
Sets the style example's style on style changes.
Definition: ConfigDialogue.cpp:3162
int m_fontSize
The size of the text font.
Definition: ConfigDialogue.h:480
wxCheckBox * m_usePartialForDiff
A checkbox that asks if TeX should use the \partial symbol for representing diff()
Definition: ConfigDialogue.h:318
void WriteSettings()
Stores the settings from the configuration dialog.
Definition: ConfigDialogue.cpp:2727
wxStaticText * m_mp
The text "Maxima Program" that can change color.
Definition: ConfigDialogue.h:254
wxColourPickerCtrl * m_styleColor
An example rectangle with the font color.
Definition: ConfigDialogue.h:425
wxChoice * m_appearanceChoice
Light / Dark / Follow-system selector (also picks which set the editor edits).
Definition: ConfigDialogue.h:422
void OnClose(wxCloseEvent &event)
Is called when the configuration dialog is closed.
Definition: ConfigDialogue.cpp:2716
wxString m_wxStartupFileName
The name of wxMaxima's startup file.
Definition: ConfigDialogue.h:252
wxTextCtrl * m_startupCommands
A textbox containing maxima's startup commands.
Definition: ConfigDialogue.h:283
void OnChangeStyle(wxCommandEvent &event)
Called if a new item type that is to be styled is selected.
Definition: ConfigDialogue.cpp:3003
TextStyle GetSelectedStyle() const
Get the style currently selected in the m_styleFor control.
Definition: ConfigDialogue.cpp:2528
void UsesvgChanged(wxCommandEvent &event)
Is called when the path to the maxima binary was changed.
Definition: ConfigDialogue.cpp:361
wxString m_startupFileName
The name of maxima's startup file.
Definition: ConfigDialogue.h:250
wxRadioButton * m_noAutodetectMaxima
The radio button that is set if m_autodetectMaxima is unset.
Definition: ConfigDialogue.h:259
wxTextCtrl * m_wxStartupCommands
A textbox containing wxMaxima's startup commands.
Definition: ConfigDialogue.h:285
htmlExportFormats
The export formats we support for HTML equations.
Definition: ConfigDialogue.h:102
~ConfigDialogue()
The destructor.
Definition: ConfigDialogue.cpp:349
void OnChangeFontFamily(wxCommandEvent &event)
Called if the font family is changed.
Definition: ConfigDialogue.cpp:2977
wxCheckBox * m_TeXExponentsAfterSubscript
A checkbox that asks if TeX should put the exponents above or after the subscripts.
Definition: ConfigDialogue.h:316
void OnAppearanceChanged(wxCommandEvent &event)
Light / Dark / Follow-system appearance changed: re-point the style editor.
Definition: ConfigDialogue.cpp:2705
void OnTabChange(wxBookCtrlEvent &event)
Called if the currently active dialogue sheet is changed.
Definition: ConfigDialogue.cpp:3182
void OnChangeColor(wxColourPickerEvent &event)
Called if the color of an item has been changed.
Definition: ConfigDialogue.cpp:2995
void LoadSave(wxCommandEvent &event)
A "export the configuration" dialog.
Definition: ConfigDialogue.cpp:3188
Text Style Definition.
Definition: TextStyle.h:67
The canvas that contains the spreadsheet the whole program is about.
Definition: Worksheet.h:116