wxMaxima
Loading...
Searching...
No Matches
wxMaximaFrame.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// (C) 2014-2015 Gunter Königsmann <wxMaxima@physikbuch.de>
6//
7// This program is free software; you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation; either version 2 of the License, or
10// (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17//
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21//
22// SPDX-License-Identifier: GPL-2.0+
23
30#ifndef WXMAXIMAFRAME_H
31#define WXMAXIMAFRAME_H
32
33#include "precomp.h"
34#include <array>
35#include <memory>
36#include <wx/wx.h>
37#include "EventIDs.h"
38#include <wx/dirctrl.h>
39#include <wx/filehistory.h>
40#include <wx/listbox.h>
41#include <wx/bmpbuttn.h>
42#include <wx/arrstr.h>
43#include <wx/aui/aui.h>
44#include <wx/notifmsg.h>
45#include <wx/wrapsizer.h>
48
49#include "wizards/ScrollingGenWizPanel.h"
50#include "worksheet/Worksheet.h"
53#include "RecentDocuments.h"
54#include "BuildConfig.h"
55#include "MainMenuBar.h"
56#include "sidebars/History.h"
58#include "sidebars/PerformanceSidebar.h"
59#include "StatusBar.h"
60#include "TrayIcon.h"
62#include "mcp/McpServer.h"
63#include "sidebars/AiChatSidebar.h"
64#include <list>
65#include <memory>
66
67
70class wxMaximaFrame : public wxFrame
71{
72public:
73 wxMaximaFrame(wxWindow *parent, int id, const wxString &title,
74 const wxPoint &pos = wxDefaultPosition,
75 const wxSize &size = wxDefaultSize,
76 long style = wxDEFAULT_FRAME_STYLE | wxSYSTEM_MENU | wxCAPTION);
77
80 virtual ~wxMaximaFrame();
81
87 void ShowToolBar(bool show);
88 static std::size_t CountWindows();
89
96
98 void PopulateRecentDocumentsMenu(wxMenu *menu, int firstEntry, const std::list<wxString> &items);
100 void PopulateRecentPackagesMenu(wxMenu *menu, int firstEntry, const std::list<wxString> &items);
101
107 bool IsPaneDisplayed(int id);
108
116 void ShowPane(int id, bool show = true);
118 bool IsXMLInspectorShown(){return m_manager.GetPane(wxS("XmlInspector")).IsShown();}
120 bool IsPerformanceMonitorShown(){return m_manager.GetPane(wxS("performance")).IsShown();}
123 {
124 m_manager.GetPane(wxS("XmlInspector")).Show(!IsXMLInspectorShown());
126 }
129 {
130 m_manager.GetPane(wxS("log"))
131 .Show(!m_manager.GetPane(wxS("log")).IsShown());
133 }
135 void ShowWizardPane(wxString title)
136 {
137 m_manager.GetPane("wizard").Show(true).Caption(title);
139 }
140 void HideWizardPane()
141 {
142 m_manager.GetPane("wizard").Show(false);
144 }
146 void TogglePaneVisibility(int id);
147
149 void AddToHistory(const wxString &cmd)
150 { m_history->AddToHistory(cmd); }
151
155 void EvaluationQueueLength(int length, int numberOfCommands = -1);
156
158 void AuiManagerUpdate();
159
166 void StatusMaximaBusy(StatusBar::MaximaStatus status){m_StatusMaximaBusy_next = status;}
168 StatusBar::MaximaStatus StatusMaximaBusy() const {return m_StatusMaximaBusy;}
169 void UpdateStatusMaximaBusy();
170
172 bool HasPendingStatusText() const {return m_newStatusText;}
174 void ClearPendingStatusText() {m_newStatusText = false;}
176 const wxString &GetLeftStatusText() const {return m_leftStatusText;}
177
179 void StatusSaveStart();
180
182 void StatusSaveFinished();
183
185 void StatusSaveFailed();
186
188 void StatusExportStart();
189
192
194 void StatusExportFailed();
195
196 Configuration &GetConfiguration() {return m_configuration;}
197
202 if (m_mcpServer)
203 m_mcpServer->ReconcileWithConfig(m_configuration);
204 }
205
209 if (m_aiChatSidebar)
211 }
212protected:
219 Configuration m_configuration;
221 std::unique_ptr<McpServer> m_mcpServer;
223 std::size_t m_bytesFromMaxima = 0;
225 long m_pid = -1;
227 long m_maximaPid = -1;
231 void OnNotificationClose(wxCommandEvent WXUNUSED(&event));
234#if wxUSE_TASKBARICON
240 std::unique_ptr<TrayIcon> m_trayIcon;
241#endif
245 wxMenu *m_demo_sub = NULL;
247 std::vector<wxMenu *> m_demoSubs;
249 wxMenu *m_viewMenu = NULL;
251 wxMenu *m_gentranMenu = NULL;
253 wxMenu *m_subst_Sub = NULL;
255 wxMenu * m_logexpand_Sub = NULL;
257 wxMenu *m_FileMenu = NULL;
259 wxMenu *m_EditMenu = NULL;
261 wxMenu *m_CellMenu = NULL;
263 wxMenu *m_Edit_Zoom_Sub = NULL;
265 wxMenu *m_Maxima_Panes_Sub = NULL;
267 wxMenu *m_EquationsMenu = NULL;
269 wxMenu *m_MaximaMenu = NULL;
271 wxMenu *m_matrix_menu = NULL;
273 wxMenu *m_SimplifyMenu = NULL;
275 wxMenu *m_Simplify_Gamma_Sub = NULL;
277 wxMenu *m_debugTypeMenu = NULL;
279 wxMenu *m_Simplify_Trig_Sub = NULL;
283 wxMenu *m_CalculusMenu = NULL;
284
286 wxMenu *m_PlotMenu = NULL;
288 wxMenu *m_listMenu = NULL;
290 wxMenu *m_NumericMenu = NULL;
292 wxMenu *m_HelpMenu = NULL;
296 void ReReadConfig();
298 void ReadConfig();
306 void DockAllSidebars(wxCommandEvent &ev);
307 void HideAllSidebars(wxCommandEvent &ev);
308
309 wxString wxMaximaManualLocation();
310public:
312 const std::unordered_map<int, wxString> &GetSidebarNames() const {return m_sidebarNames;}
313protected:
314 Worksheet *GetWorksheet() const {return m_worksheet;}
315private:
317 std::unordered_map<int, wxString> m_sidebarNames;
319 std::unordered_map<int, wxString> m_sidebarCaption;
321 std::size_t m_bytesFromMaxima_last = 0;
322 wxTimer m_bytesReadDisplayTimer;
324 bool m_StatusSaving = false;
327 StatusBar::MaximaStatus m_StatusMaximaBusy = StatusBar::wait_for_start;
328 StatusBar::MaximaStatus m_StatusMaximaBusy_next = StatusBar::wait_for_start;
331 bool m_newStatusText = false;
333 wxString m_leftStatusText;
335 bool m_forceStatusbarUpdate = false;
336
337 void SetupToolBar();
338
342 void SetupMenu();
343 void SetupFileMenu();
344 void SetupEditMenu();
345 void SetupViewMenu();
346 void SetupCellMenu();
347 void SetupMaximaMenu();
348 void SetupEquationsMenu();
349 void SetupMatrixMenu();
350 void SetupCalculusMenu();
351 void SetupSimplifyMenu();
352 void SetupListMenu();
353 void SetupPlotMenu();
354 void SetupNumericMenu();
355 void SetupHelpMenu();
356
357public:
358 void StatusText(const wxString &text, bool saveInLog = true);
359protected:
360 ScrollingGenWizPanel *m_wizard = NULL;
364 virtual wxSize DoGetBestClientSize() const;
367#ifdef USE_WEBVIEW
368 HelpBrowser *m_helpPane = NULL;
369#endif
375
377 wxString GetDemoFile(wxWindowID id) const;
378protected:
379 std::array<wxString, 10> m_statusTextHistory;
380 void OnMenuStatusText(wxMenuEvent &event);
381 std::unordered_map<wxWindowID, wxString> m_demoFilesIDs;
382
383 SymbolsSidebar *m_symbolsSidebar = NULL;
390
392 bool m_first = true;
393
394 bool ToolbarIsShown();
395protected:
397 wxAuiManager m_manager;
399 Worksheet * const m_worksheet = NULL;
401 History * const m_history = NULL;
408 RecentDocuments m_recentPackages;
409 wxMenu *m_recentDocumentsMenu = NULL;
410 wxMenu *m_unsavedDocumentsMenu = NULL;
411 wxMenu *m_recentPackagesMenu = NULL;
412 wxMenu *m_autoSubscriptMenu = NULL;
413 wxMenu *m_equationTypeMenuMenu = NULL;
414 wxMenu *m_roundedMatrixParensMenu = NULL;
415};
416
417#endif // WXMAXIMAFRAME_H
This file contains the definition of the class Buttonwrapsizer that allows to select arbitrary unicod...
This file declares the class StatSidebar, that provides some statistics buttons.
This file declares the class EventIDs that contains unique IDs for many events wxMaxima needs.
This file declares the class HelpBrowser.
This file contains the definition of the class History that handles the recently issued commands for ...
This file declares a (hopefully) flicker-free main menu bar.
The definition of the class RecentDocuments that provides a recent files mechanism that is extensible...
This file contains the definition of the class History that handles the recently issued commands for ...
This file declares the class wxMaximaFrame.
This file contains the definition of the class TableOfContents that handles the table of contents pan...
This file declares the class TrayIcon, a system tray/notification-area icon mirroring wxMaxima's busy...
This file defines the class Worksheet.
This file contains the definition of the class XmlInspector that handles the table of contents pane.
A sidebar to chat with an external AI about the current worksheet (follow-up to the MCP server,...
Definition: AiChatSidebar.h:58
void ReloadProviderFromConfig()
Re-reads Configuration for the selected provider/API key/model and rebuilds this sidebar's provider a...
Definition: AiChatSidebar.cpp:93
The configuration storage for the current worksheet.
Definition: Configuration.h:98
The class for the sidebar with the draw commands.
Definition: DrawSidebar.h:39
Definition: FindReplacePane.h:50
Definition: HelpBrowser.h:49
This class generates a pane containing the last commands that were issued.
Definition: History.h:56
void AddToHistory(const wxString &cmd)
Add a file to the recently opened files list.
Definition: History.cpp:263
A menu bar that flickers less on MS windows.
Definition: MainMenuBar.h:37
Definition: PerformanceSidebar.h:32
A class that maintains a list of recent documents.
Definition: RecentDocuments.h:42
Definition: ScrollingGenWizPanel.h:32
The class that draws the status bar.
Definition: StatusBar.h:47
MaximaStatus
Definition: StatusBar.h:84
Definition: SymbolsSidebar.h:46
This class generates a pane containing the table of contents.
Definition: TableOfContents.h:52
A "variables" sidepane.
Definition: VariablesPane.h:45
The canvas that contains the spreadsheet the whole program is about.
Definition: Worksheet.h:116
This class generates a pane displaying the communication between maxima and wxMaxima.
Definition: XmlInspector.h:40
The frame containing the menu and the sidebars.
Definition: wxMaximaFrame.h:71
wxMenu * m_FileMenu
The file menu.
Definition: wxMaximaFrame.h:257
void UpdateRecentDocuments()
Update the recent documents list.
Definition: wxMaximaFrame.cpp:2239
void StatusSaveFailed()
Set the status to "Saving has failed".
Definition: wxMaximaFrame.cpp:664
void RegisterAutoSaveFile()
Remember a temporary autosave file name.
Definition: wxMaximaFrame.cpp:2294
const std::unordered_map< int, wxString > & GetSidebarNames() const
Get the list of human-readable sidebarnames and IDs.
Definition: wxMaximaFrame.h:312
bool m_first
Do we expect the 1st prompt from maxima to appear?
Definition: wxMaximaFrame.h:392
AiChatSidebar * m_aiChatSidebar
The AI chat sidebar – see src/sidebars/AiChatSidebar.h.
Definition: wxMaximaFrame.h:216
virtual ~wxMaximaFrame()
The destructor.
Definition: wxMaximaFrame.cpp:676
wxMenu * m_EditMenu
The edit menu.
Definition: wxMaximaFrame.h:259
TableOfContents * m_tableOfContents
The table of contents pane.
Definition: wxMaximaFrame.h:218
FindReplacePane::FindReplaceData m_findPaneData
The data backing the dockable find/replace sidebar (GH #2249) – kept separate from wxMaxima::m_findDa...
Definition: wxMaximaFrame.h:374
void StatusSaveFinished()
Set the status to "Maxima has finished saving".
Definition: wxMaximaFrame.cpp:648
int m_commandsLeftInCurrentCell
The number of commands left in the current of the evaluation queue item.
Definition: wxMaximaFrame.h:389
void TogglePaneVisibility(int id)
Hides or unhides the pane with the given ID.
Definition: wxMaximaFrame.cpp:2374
void ReconcileMcpServer()
Starts/stops the MCP server (src/mcp/McpServer.h) to match the current configuration....
Definition: wxMaximaFrame.h:201
void ReReadConfig()
Re-read the configuration.
Definition: wxMaximaFrame.cpp:2264
wxMenu * m_Simplify_Complex_Sub
The complex submenu.
Definition: wxMaximaFrame.h:281
std::unique_ptr< McpServer > m_mcpServer
The (opt-in, off by default) MCP server – see ReconcileMcpServer().
Definition: wxMaximaFrame.h:221
bool IsXMLInspectorShown()
Is the XML inspector shown?
Definition: wxMaximaFrame.h:118
StatusBar::MaximaStatus StatusMaximaBusy() const
The status Maxima is currently displayed as being in.
Definition: wxMaximaFrame.h:168
void StatusExportStart()
Set the status to "Maxima is exporting".
Definition: wxMaximaFrame.cpp:652
void ClearPendingStatusText()
Mark the pending left-half status text as having been displayed.
Definition: wxMaximaFrame.h:174
virtual wxSize DoGetBestClientSize() const
The default size for the window.
Definition: wxMaximaFrame.cpp:550
wxMenu * m_PlotMenu
The plot menu.
Definition: wxMaximaFrame.h:286
PerformanceSidebar * m_performanceSidebar
The panel showing performance statistics.
Definition: wxMaximaFrame.h:405
wxMenu * m_Maxima_Panes_Sub
The panes submenu.
Definition: wxMaximaFrame.h:265
wxMenu * m_EquationsMenu
The equations menu.
Definition: wxMaximaFrame.h:267
bool m_updateEvaluationQueueLengthDisplay
Do we need to update the display showing the evaluation queue length?
Definition: wxMaximaFrame.h:387
wxMenu * m_gentranMenu
The gentran menu.
Definition: wxMaximaFrame.h:251
void ToggleXMLInspector()
Hide or unhide the XML inspector.
Definition: wxMaximaFrame.h:122
long m_drawDimensions_last
Are we inside a 2d or 3d draw command?
Definition: wxMaximaFrame.h:362
wxString m_tempfileName
The last name GetTempAutosavefileName() has returned.
Definition: wxMaximaFrame.h:229
wxMenu * m_Simplify_Trig_Sub
The trigonometric submenu.
Definition: wxMaximaFrame.h:279
void PopulateRecentPackagesMenu(wxMenu *menu, int firstEntry, const std::list< wxString > &items)
Used by UpdateRecentPackages for populating a menu.
Definition: wxMaximaFrame.cpp:2223
void ShowPane(int id, bool show=true)
Show or hide a sidebar.
Definition: wxMaximaFrame.cpp:2383
StatusBar * m_statusBar
The status bar.
Definition: wxMaximaFrame.h:233
XmlInspector * m_xmlInspector
A XmlInspector-like xml monitor.
Definition: wxMaximaFrame.h:403
void EvaluationQueueLength(int length, int numberOfCommands=-1)
Inform the user about the length of the evaluation queue.
Definition: wxMaximaFrame.cpp:560
wxMenu * m_demo_sub
The "demo" sub-menu.
Definition: wxMaximaFrame.h:245
wxMenu * m_listMenu
The list menu.
Definition: wxMaximaFrame.h:288
wxMenu * m_debugTypeMenu
Contains the menu for the debugger trigger settingxc.
Definition: wxMaximaFrame.h:277
void PopulateRecentDocumentsMenu(wxMenu *menu, int firstEntry, const std::list< wxString > &items)
Used by UpdateRecentDocuments for populating a menu.
Definition: wxMaximaFrame.cpp:2200
MainMenuBar * m_MenuBar
The menu bar.
Definition: wxMaximaFrame.h:243
bool IsPerformanceMonitorShown()
Is the performance monitor shown?
Definition: wxMaximaFrame.h:120
void OnNotificationClose(wxCommandEvent WXUNUSED(&event))
Issued if a notification is closed.
History *const m_history
The history pane.
Definition: wxMaximaFrame.h:401
wxMenu * m_Simplify_Gamma_Sub
The factorials and gamma submenu.
Definition: wxMaximaFrame.h:275
int m_EvaluationQueueLength
The current length of the evaluation queue of commands we still need to send to maxima.
Definition: wxMaximaFrame.h:385
void AuiManagerUpdate()
Updates the AUI manager and re-asserts the menu bar on GTK to prevent it from disappearing.
Definition: wxMaximaFrame.cpp:2353
void RemoveTempAutosavefile()
Remove an eventual temporary autosave file.
Definition: wxMaximaFrame.cpp:2301
wxMenu * m_CalculusMenu
The calculus menu.
Definition: wxMaximaFrame.h:283
void DockAllSidebars(wxCommandEvent &ev)
An instant single-window mode.
Definition: wxMaximaFrame.cpp:2330
void StatusSaveStart()
Set the status to "Maxima is saving".
Definition: wxMaximaFrame.cpp:643
wxMenu * m_viewMenu
The "view" menu.
Definition: wxMaximaFrame.h:249
void ReadConfig()
Read the configuration from the OS's configuration storage.
Definition: wxMaximaFrame.cpp:2259
wxMenu * m_SimplifyMenu
The simplify menu.
Definition: wxMaximaFrame.h:273
void ShowWizardPane(wxString title)
Show the pane the wizards are in.
Definition: wxMaximaFrame.h:135
long m_pid
The process id of maxima. Is determined by ReadFirstPrompt.
Definition: wxMaximaFrame.h:225
void StatusExportFailed()
Set the status to "Exporting has failed".
Definition: wxMaximaFrame.cpp:670
std::size_t m_bytesFromMaxima
How many bytes did maxima send us until now?
Definition: wxMaximaFrame.h:223
wxMenu * m_matrix_menu
The matrix menu.
Definition: wxMaximaFrame.h:271
const wxString & GetLeftStatusText() const
The pending text for the left half of the status bar.
Definition: wxMaximaFrame.h:176
wxMenu * m_MaximaMenu
The maxima menu.
Definition: wxMaximaFrame.h:269
wxMenu * m_subst_Sub
The subst submenu.
Definition: wxMaximaFrame.h:253
void ShowToolBar(bool show)
Shows or hides the toolbar.
Definition: wxMaximaFrame.cpp:2407
void ReloadAiChatProvider()
Re-reads the configured AI provider/API key/model for the AI chat sidebar. Call after the Options dia...
Definition: wxMaximaFrame.h:208
void StatusMaximaBusy(StatusBar::MaximaStatus status)
Set the status according to if maxima is calculating.
Definition: wxMaximaFrame.h:166
bool IsPaneDisplayed(int id)
true, if a Pane is currently enabled
Definition: wxMaximaFrame.cpp:2313
wxMenu * m_HelpMenu
The help menu.
Definition: wxMaximaFrame.h:292
void ToggleLogPane()
Toggle the visibility of the log pane.
Definition: wxMaximaFrame.h:128
wxAuiManager m_manager
The manager for dynamic screen layouts.
Definition: wxMaximaFrame.h:397
DrawSidebar * m_drawPane
The sidebar with the draw commands.
Definition: wxMaximaFrame.h:366
void StatusExportFinished()
Set the status to "Maxima has finished exporting".
Definition: wxMaximaFrame.cpp:658
wxMenu * m_Edit_Zoom_Sub
The zoom submenu.
Definition: wxMaximaFrame.h:263
wxMenu * m_NumericMenu
The numeric menu.
Definition: wxMaximaFrame.h:290
wxMenu * m_CellMenu
The cell menu.
Definition: wxMaximaFrame.h:261
Variablespane * m_variablesPane
The panel the user can display variable contents in.
Definition: wxMaximaFrame.h:214
std::vector< wxMenu * > m_demoSubs
The submenus for the various "demo" sub-submenus.
Definition: wxMaximaFrame.h:247
long m_maximaPid
The real process id of maxima (might be a child of m_pid).
Definition: wxMaximaFrame.h:227
Worksheet *const m_worksheet
The worksheet itself.
Definition: wxMaximaFrame.h:399
RecentDocuments m_recentDocuments
The panel the log and debug messages will appear on.
Definition: wxMaximaFrame.h:407
wxMenu * m_logexpand_Sub
The logexpand submenu.
Definition: wxMaximaFrame.h:255
bool HasPendingStatusText() const
True if StatusText() recorded a left-half status text not yet shown.
Definition: wxMaximaFrame.h:172
wxString GetDemoFile(wxWindowID id) const
Looks up which demo file belongs to a wxWindowID.
Definition: wxMaximaFrame.cpp:2136
void AddToHistory(const wxString &cmd)
Adds a command to the list of recently used maxima commands.
Definition: wxMaximaFrame.h:149