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 <array>
43#include <memory>
44#include <wx/propdlg.h>
45#include <wx/generic/propdlg.h>
46#include <wx/spinctrl.h>
47#include <wx/notebook.h>
48
49#include <wx/imaglist.h>
50#include <wx/bookctrl.h>
51#include <wx/artprov.h>
52#include <unordered_map>
53#include <vector>
54#include <wx/hyperlink.h>
55#include <wx/scrolwin.h>
56
57#ifndef CONFIGDIALOGUE_H
58#define CONFIGDIALOGUE_H
59
60#include "BuildConfig.h"
61
62#include "cells/TextStyle.h"
63#include "worksheet/Worksheet.h"
64#include "../Configuration.h"
67#include "UiLanguages.h"
68#include "WorksheetPreview.h"
69#ifdef WXM_USE_AI_TOOLS
70#include "ai/AiProvider.h"
71#endif
72
73enum
74{
75 color_id,
76 listbox_styleFor,
77 checkbox_bold,
78 checkbox_italic,
79 checkbox_underlined,
80 checkbox_slanted,
81 checkbox_strikethrough,
82 button_defaultFont,
83 button_mathFont,
84 style_font_family,
85 language_id,
86 save_id,
87 load_id
88};
89
97class ConfigDialogue : public wxPropertySheetDialog
98{
99public:
101 explicit ConfigDialogue(wxWindow *parent);
102
104 ~ConfigDialogue() override;
105
108 {
109 mathJaX_TeX = 0,
110 bitmap = 1,
111 mathML_mathJaX = 2,
112 svg = 3
113 };
114
116 void OnChangeColor(wxColourPickerEvent& event);
117
123 void WriteSettings();
124
125private:
126 const int mMinPanelWidth = 500;
127 const int mMinPanelHeight = 500;
128
129private:
130 enum newVariables
131 {
132 MAXIMA_DEFAULT_LISP,
133 MAXIMA_IMAGESDIR,
134 MAXIMA_USERDIR,
135 MAXIMA_DIRECTORY,
136 MAXIMA_TEMPDIR,
137 MAXIMA_OBJDIR,
138 MAXIMA_DOC_PREFIX,
139 GCL_GC_PAGE_THRESH,
140 GCL_GC_ALLOC_MIN,
141 GCL_GC_PAGE_MAX,
142 GCL_MEM_MULTIPLE,
143 GCL_MULTIPROCESS_MEMORY_POOL,
144 LANG,
145 HOME,
146 VAR_DELETE
147 };
149 std::unique_ptr<Configuration> m_configuration;
150 Worksheet *m_sampleWorksheet = nullptr;
158 Worksheet *m_worksheetPreview = nullptr;
166 std::unique_ptr<Configuration> m_worksheetPreviewConfiguration;
168 std::array<CellPtr<GroupCell>,
169 static_cast<size_t>(wxm::WorksheetPreview::Topic::count)> m_worksheetPreviewHeadings;
171 wxm::WorksheetPreview::Topic m_worksheetPreviewTopic =
172 wxm::WorksheetPreview::Topic::labels;
174 void ApplySettingsToPreview();
180 void UpdateWorksheetPreview(wxm::WorksheetPreview::Topic topic);
181
182 using StringHash = std::unordered_map<wxString, wxString, wxStringHash>;
184 std::vector<wxm::UiLanguage> m_languages;
189 class ExamplePanel : public wxPanel
190 {
191 public:
193 ExamplePanel(wxWindow *parent, int id) : wxPanel(parent, id)
194 { Bind(wxEVT_PAINT, &ConfigDialogue::ExamplePanel::OnPaint, this); };
195
197 void SetStyle(const Style &style)
198 {
199 m_style = style;
200 Refresh();
201 }
202
203 private:
208 void OnPaint(wxPaintEvent &event);
209
211 Style m_style;
212 };
213
214
219 void SetCheckboxValues();
220
222 int GetImageSize();
223
231 wxWindow *CreateAiPanel();
232#ifdef WXM_USE_AI_TOOLS
234 void AddAiProviderControls(wxStaticBoxSizer *box);
235#endif
236
238 wxWindow *CreatePrintPanel();
239
241 wxWindow *CreateRevertToDefaultsPanel();
242
244 ToolBarSectionsPanel *m_toolBarSections = nullptr;
245
246#if wxUSE_ACCESSIBILITY
248 wxWindow *CreateAccessibilityPanel();
249
251 wxCheckBox *m_screenReaderMathML;
252#endif
253
254
256 wxWindow *CreateWorksheetPanel();
257
259 wxWindow *CreateOptionsPanel();
260
262 wxWindow *CreateExportPanel();
263
265 wxWindow *CreateStylePanel();
266
268 wxWindow *CreateMaximaPanel();
269
271 wxWindow *CreateStartupPanel();
272
273protected:
274 wxGrid *m_maximaEnvVariables;
275 void OnImport(wxCommandEvent& event);
276 static void CopyConfig(wxConfigBase *src, wxConfigBase *dst, const wxString& dir = wxS("/"));
277 void OnReloadAll(wxCommandEvent& event);
278 void OnReloadStyles(wxCommandEvent& event);
279 void OnResetAllToDefaults(wxCommandEvent& event);
280 void OnExportAll(wxCommandEvent& event);
281 void OnResetStyles(wxCommandEvent& event);
282 void OnChangeMaximaEnvVar(wxGridEvent& event);
283 void OnMaximaEnvRightClick(wxGridEvent& event);
284 void OnMouseMotion_MaximaEnv(wxMouseEvent &event);
285 void OnNewEnvMenu(wxCommandEvent &event);
286 void OnClickMaximaEnvVal(int row);
287 void OnChangeMaximaCellClick(wxGridEvent& event);
288
294 wxStaticText *m_mp;
295 StringHash m_maximaEnvDoc;
297 wxRadioButton *m_autodetectMaxima;
299 wxRadioButton *m_noAutodetectMaxima;
300 wxRadioButton *m_autodetectHelpBrowser;
301 wxRadioButton *m_noAutodetectHelpBrowser;
302 wxRadioButton *m_internalHelpBrowser;
303 wxCheckBox *m_singlePageManual;
307 wxRadioButton *m_autodetectMathJaX;
309 wxRadioButton *m_noAutodetectMathJaX;
310 wxRadioButton *m_useGnuplot;
311 wxRadioButton *m_useWgnuplot;
313 void OnTabChange(wxBookCtrlEvent &event);
314
316 void OnStyleToEditChanged(wxCommandEvent &event);
318 void OnAppearanceChanged(wxCommandEvent &event);
319
320 // begin wxGlade: ConfigDialogue::attributes
322 wxTextCtrl *m_startupCommands;
325 BinaryNameCtrl *m_maximaUserLocation;
326 BinaryNameCtrl *m_helpBrowserUserLocation;
327 wxTextCtrl *m_documentclass;
328 wxTextCtrl *m_documentclassOptions;
329 wxTextCtrl *m_texPreamble;
330 wxCheckBox *m_autoSave;
331 wxButton *m_wxMathMLBrowse;
332 wxTextCtrl *m_additionalParameters;
333 wxTextCtrl *m_mathJaxURL;
334 wxChoice *m_language;
337 wxCheckBox *m_abortOnError;
338 wxCheckBox *m_offerKnownAnswers;
339 wxCheckBox *m_restartOnReEvaluation;
340 wxCheckBox *m_wrapLatexMath;
341 wxCheckBox *m_usesvg;
342 wxCheckBox *m_antialiasLines;
343 wxSpinCtrlDouble *m_defaultFramerate;
344 wxSpinCtrl *m_defaultPlotWidth;
345 wxSpinCtrl *m_defaultPlotHeight;
346 wxSpinCtrl *m_displayedDigits;
347 wxSpinCtrl *m_printMargin_Top;
348 wxSpinCtrl *m_printMargin_Bot;
349 wxSpinCtrl *m_printMargin_Left;
350 wxSpinCtrl *m_printMargin_Right;
351 wxRadioButton *m_displayNDigits;
352 wxRadioButton *m_displayAllDigits;
353 wxRadioButton *m_linebreaksInLongNums;
355 wxCheckBox *m_digitGrouping;
366 wxCheckBox *m_printBrackets;
367 wxChoice *m_exportWithMathJAX;
368 wxCheckBox *m_matchParens;
369 wxCheckBox *m_showMatchingParens;
370 wxChoice *m_showLength;
371 wxChoice *m_autosubscript;
372 wxRadioBox *m_layoutStrategy;
376 wxRadioBox *m_imageBackdrop;
377 wxRadioButton *m_enterEvaluates;
378 wxRadioButton *m_ctrlEnterEvaluates;
379 wxCheckBox *m_numpadEnterEvaluates;
380 wxCheckBox *m_saveImgFileName;
381 wxCheckBox *m_saveUntitled;
382 wxCheckBox *m_openHCaret;
383 wxCheckBox *m_insertAns;
384 wxCheckBox *m_autoIndent;
385 wxCheckBox *m_cursorJump;
388 wxCheckBox *m_hideBrackets;
389#ifdef __WXGTK__
392 wxCheckBox *m_overlayScrollbars;
393#endif
394 wxCheckBox *m_indentMaths;
395 wxChoice *m_autoWrap;
396 wxSpinCtrl *m_labelWidth;
397 wxSpinCtrl *m_recentItems;
398 wxSpinCtrl *m_bitmapScale;
399 wxSpinCtrlDouble *m_printScale;
400 wxCheckBox *m_fixReorderedIndices;
401 wxCheckBox *m_incrementalSearch;
402 wxCheckBox *m_notifyIfIdle;
403 wxCheckBox *m_findDialogDockable;
404 wxCheckBox *m_mcpServerEnabled;
405 wxSpinCtrl *m_mcpServerPort;
406#ifdef WXM_USE_AI_TOOLS
411 struct AiProviderUiRecord {
412 AiProviderKind kind = AiProviderKind::None;
415 wxString customId;
418 wxString displayName;
421 AiProviderShape shape = AiProviderShape::OpenAiCompatible;
422 wxString baseUrl;
430 wxString apiKey;
432 bool forgetApiKey = false;
433 wxString model;
436 wxString username;
437 };
438 std::vector<AiProviderUiRecord> m_aiProviderRecords;
443 int m_aiActiveProviderRecordIndex = -1;
453 wxScrolled<wxPanel> *m_aiChatPanel = nullptr;
454 wxChoice *m_aiChatProviderChoice;
458 wxStaticBoxSizer *m_aiProviderDetailBox;
459 wxStaticText *m_aiBaseUrlLabel;
462 wxTextCtrl *m_aiBaseUrlCtrl;
463 wxStaticText *m_aiShapeLabel;
464 wxChoice *m_aiShapeChoice;
468 wxStaticText *m_aiUsernameLabel;
469 wxTextCtrl *m_aiUsernameCtrl;
471 wxStaticText *m_aiKeyLabel;
472 wxTextCtrl *m_aiKeyCtrl;
480 wxComboBox *m_aiModelCtrl;
481 wxButton *m_aiRefreshModelsButton;
484 wxStaticText *m_aiModelFetchStatus;
492 std::shared_ptr<bool> m_aiUiAlive;
493 wxHyperlinkCtrl *m_aiApiKeyLink;
494 wxHyperlinkCtrl *m_aiModelListLink;
497 wxButton *m_aiRemoveCustomProviderButton;
499 wxButton *m_aiForgetKeyButton;
500 void OnAiForgetKey(wxCommandEvent &event);
502 void UpdateAiKeyHint(const AiProviderUiRecord &rec);
504 static wxString AiApiKeyToUse(const AiProviderUiRecord &rec);
508 void RelayoutAiChatPanel();
509 void OnAiProviderChoice(wxCommandEvent &event);
511 void OnAiUsernameChanged(wxCommandEvent &event);
514 void UpdateAiCredentialLabel();
515 void OnAiRemoveCustomProvider(wxCommandEvent &event);
516 void OnAiRefreshModels(wxCommandEvent &event);
527 void StartAiModelFetch();
531 void StashAiProviderUiIntoRecord();
535 void LoadAiProviderRecordIntoUi(int index);
540 bool AddCustomAiProviderDialog();
544 void RebuildAiProviderChoice(int selectIndex);
545#endif
546 wxChoice *m_showUserDefinedLabels;
547 wxButton *m_getStyleFont;
550 wxListBox *m_styleFor;
552 wxColourPickerCtrl *m_styleColor;
553 wxCheckBox *m_boldCB;
554 wxCheckBox *m_italicCB;
555 wxCheckBox *m_slantedCB;
556 wxCheckBox *m_strikethroughCB;
557 wxCheckBox *m_underlinedCB;
558 wxCheckBox *m_fixedFontInTC;
559 wxCheckBox *m_unixCopy;
560 wxCheckBox *m_changeAsterisk;
561 wxCheckBox *m_hidemultiplicationSign;
562 wxCheckBox *m_latin2Greek;
563 wxCheckBox *m_keepPercentWithSpecials;
564 wxBookCtrlBase *m_notebook;
565 wxButton *m_saveStyle, *m_loadStyle;
566 wxSpinCtrl *m_defaultPort;
567 ExamplePanel *m_examplePanel;
568 wxSpinCtrl *m_maxGnuplotMegabytes;
569 wxSpinCtrl *m_autosaveMinutes;
570 wxSpinCtrl *m_maxLayoutTime;
571 wxTextCtrl *m_autoMathJaxURL;
572 int m_maximaEmvRightClickRow = 0;
573
575 void UsesvgChanged(wxCommandEvent &event);
576
578 void OnClose(wxCloseEvent &event);
579
580 void OnwxMathMLBrowse(wxCommandEvent &event);
581
582 void OnIdle(wxIdleEvent &event);
583
585 void OnChangeStyle(wxCommandEvent &event);
586
588 void OnChangeWarning(wxCommandEvent &event);
589
591 void OnCheckbox(wxCommandEvent &event);
592
594 void UpdateExample();
595
597 void OnChangeFontFamily(wxCommandEvent &event);
598
600 void LoadSave(wxCommandEvent &event);
601
604
614 TextStyle m_selectedStyle = TS_CODE_DEFAULT;
615
620
622 wxVector<wxBitmapBundle> m_imageList;
623};
624
625#ifndef __WXMSW__
626
627#endif // __WXMSW__
628
629#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:86
AiProviderKind
Which AI service to talk to. Persisted as a plain int in Configuration; keep existing values stable a...
Definition: AiProvider.h:70
This file declares all the wizards the draw sidepane needs.
The configuration dialogue's list of extra symbols and symbol shortcuts.
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:230
The configuration dialogue's "Toolbar" tab.
The languages wxMaxima's user interface can be switched to (GH #849).
Declares the sample worksheet the configuration dialog's "Worksheet" tab shows to preview what its di...
This file defines the class Worksheet.
A dialog that shows the program's license.
Definition: BinaryNameCtrl.h:40
The configuration dialog.
Definition: ConfigDialogue.h:98
int m_mathFontSize
The size of the maths font.
Definition: ConfigDialogue.h:619
void OnCheckbox(wxCommandEvent &event)
Called if one of the checkboxes for bold, italic or underlined is toggled.
Definition: ConfigDialogue.cpp:3489
wxCheckBox * m_digitGrouping
Separate the digit groups of numbers by a small gap? (GH #192)
Definition: ConfigDialogue.h:355
wxRadioButton * m_noAutodetectMathJaX
The radio button that is set if m_autodetectMathJaX is unset.
Definition: ConfigDialogue.h:309
wxCheckBox * m_exportContainsWXMX
A checkbox that asks if all newlines in text cells have to be passed to HTML.
Definition: ConfigDialogue.h:363
void OnStyleToEditChanged(wxCommandEvent &event)
Called if the user changes the style that is to be edited.
Definition: ConfigDialogue.cpp:3051
wxCheckBox * m_maximaHelpInConsole
Does Maxima answer ?, ?? and describe() on the console?
Definition: ConfigDialogue.h:305
wxRadioBox * m_oversizedMatrices
How to show a matrix too large for the window.
Definition: ConfigDialogue.h:374
wxRadioButton * m_autodetectMathJaX
Autodetect the mathJaX location?
Definition: ConfigDialogue.h:307
wxRadioButton * m_autodetectMaxima
Autodetect the maxima location?
Definition: ConfigDialogue.h:297
void OnChangeWarning(wxCommandEvent &event)
A message dialog that appears if a change cannot be applied now.
Definition: ConfigDialogue.cpp:3506
void UpdateExample()
Sets the style example's style on style changes.
Definition: ConfigDialogue.cpp:3512
wxSpinCtrl * m_digitGroupingMinDigits
How many digits a number needs before its digits are grouped.
Definition: ConfigDialogue.h:357
int m_fontSize
The size of the text font.
Definition: ConfigDialogue.h:617
wxCheckBox * m_htmlExportSelfContained
Embed images and the .wxmx into the exported .html file.
Definition: ConfigDialogue.h:365
wxCheckBox * m_usePartialForDiff
A checkbox that asks if TeX should use the \partial symbol for representing diff()
Definition: ConfigDialogue.h:361
void WriteSettings()
Stores the settings from the configuration dialog.
Definition: ConfigDialogue.cpp:3085
wxStaticText * m_mp
The text "Maxima Program" that can change color.
Definition: ConfigDialogue.h:294
wxColourPickerCtrl * m_styleColor
An example rectangle with the font color.
Definition: ConfigDialogue.h:552
wxVector< wxBitmapBundle > m_imageList
A list containing the pictograms for the tabs.
Definition: ConfigDialogue.h:622
wxChoice * m_appearanceChoice
Light / Dark / Follow-system selector (also picks which set the editor edits).
Definition: ConfigDialogue.h:549
void OnClose(wxCloseEvent &event)
Is called when the configuration dialog is closed.
Definition: ConfigDialogue.cpp:3074
wxCheckBox * m_arrowKeysSkipOutput
Up/Down skip over a cell's output instead of selecting it (GH #2382)
Definition: ConfigDialogue.h:387
~ConfigDialogue() override
The destructor.
Definition: ConfigDialogue.cpp:264
wxString m_wxStartupFileName
The name of wxMaxima's startup file.
Definition: ConfigDialogue.h:292
TextStyle m_selectedStyle
The style the style editor's controls currently show and edit.
Definition: ConfigDialogue.h:614
wxRadioBox * m_imageBackdrop
What is drawn behind transparent parts of images.
Definition: ConfigDialogue.h:376
SymbolShortcutsPanel * m_symbolShortcuts
The extra symbols and every symbol's keyboard shortcut.
Definition: ConfigDialogue.h:336
wxTextCtrl * m_startupCommands
A textbox containing maxima's startup commands.
Definition: ConfigDialogue.h:322
void OnChangeStyle(wxCommandEvent &event)
Called if a new item type that is to be styled is selected.
Definition: ConfigDialogue.cpp:3353
TextStyle GetSelectedStyle() const
Get the style currently being edited (see m_selectedStyle)
Definition: ConfigDialogue.cpp:2877
void UsesvgChanged(wxCommandEvent &event)
Is called when the path to the maxima binary was changed.
Definition: ConfigDialogue.cpp:336
wxString m_startupFileName
The name of maxima's startup file.
Definition: ConfigDialogue.h:290
wxRadioButton * m_noAutodetectMaxima
The radio button that is set if m_autodetectMaxima is unset.
Definition: ConfigDialogue.h:299
wxTextCtrl * m_wxStartupCommands
A textbox containing wxMaxima's startup commands.
Definition: ConfigDialogue.h:324
htmlExportFormats
The export formats we support for HTML equations.
Definition: ConfigDialogue.h:108
void OnChangeFontFamily(wxCommandEvent &event)
Called if the font family is changed.
Definition: ConfigDialogue.cpp:3327
wxCheckBox * m_TeXExponentsAfterSubscript
A checkbox that asks if TeX should put the exponents above or after the subscripts.
Definition: ConfigDialogue.h:359
void OnAppearanceChanged(wxCommandEvent &event)
Light / Dark / Follow-system appearance changed: re-point the style editor.
Definition: ConfigDialogue.cpp:3063
void OnTabChange(wxBookCtrlEvent &event)
Called if the currently active dialogue sheet is changed.
Definition: ConfigDialogue.cpp:3533
void OnChangeColor(wxColourPickerEvent &event)
Called if the color of an item has been changed.
Definition: ConfigDialogue.cpp:3345
void LoadSave(wxCommandEvent &event)
A "export the configuration" dialog.
Definition: ConfigDialogue.cpp:3539
Text Style Definition.
Definition: TextStyle.h:67
The extra symbols of the Symbols sidebar, and the keyboard shortcuts of every symbol (GH #2578).
Definition: SymbolShortcutsPanel.h:50
Lets the user reorder the main toolbar's sections and show or hide them.
Definition: ToolBarSectionsPanel.h:47
The canvas that contains the spreadsheet the whole program is about.
Definition: Worksheet.h:122
Definition: CellPointers.h:36
Topic
What part of the preview a setting affects.
Definition: WorksheetPreview.h:51