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 "BuildConfig.h"
64#ifdef WXM_USE_AI_TOOLS
65#include "sidebars/AiChatSidebar.h"
66#include "sidebars/AiConnectionMonitor.h"
67#endif
68#include <list>
69#include <memory>
70
71
74class wxMaximaFrame : public wxFrame
75{
76public:
77 wxMaximaFrame(wxWindow *parent, int id, const wxString &title,
78 const wxPoint &pos = wxDefaultPosition,
79 const wxSize &size = wxDefaultSize,
80 long style = wxDEFAULT_FRAME_STYLE | wxSYSTEM_MENU | wxCAPTION);
81
84 virtual ~wxMaximaFrame();
85
91 void ShowToolBar(bool show);
92 static std::size_t CountWindows();
93
100
102 void PopulateRecentDocumentsMenu(wxMenu *menu, int firstEntry, const std::list<wxString> &items);
104 void PopulateRecentPackagesMenu(wxMenu *menu, int firstEntry, const std::list<wxString> &items);
105
111 bool IsPaneDisplayed(int id);
112
120 void ShowPane(int id, bool show = true);
135 void LogHelpMenuContents() const;
137 bool IsXMLInspectorShown(){return m_manager.GetPane(wxS("XmlInspector")).IsShown();}
139 bool IsPerformanceMonitorShown(){return m_manager.GetPane(wxS("performance")).IsShown();}
142 {
143 m_manager.GetPane(wxS("XmlInspector")).Show(!IsXMLInspectorShown());
145 }
148 {
149 m_manager.GetPane(wxS("log"))
150 .Show(!m_manager.GetPane(wxS("log")).IsShown());
152 }
154 void ShowWizardPane(const wxString &title);
162 bool FitWizardPane();
163 void HideWizardPane()
164 {
165 m_manager.GetPane("wizard").Show(false);
167 }
169 void TogglePaneVisibility(int id);
170
172 void AddToHistory(const wxString &cmd)
173 { m_history->AddToHistory(cmd); }
174
178 void EvaluationQueueLength(int length, int numberOfCommands = -1);
179
181 void AuiManagerUpdate();
182
189 void StatusMaximaBusy(StatusBar::MaximaStatus status){m_StatusMaximaBusy_next = status;}
191 StatusBar::MaximaStatus StatusMaximaBusy() const {return m_StatusMaximaBusy;}
192 void UpdateStatusMaximaBusy();
193
195 bool HasPendingStatusText() const {return m_newStatusText;}
197 void ClearPendingStatusText() {m_newStatusText = false;}
199 const wxString &GetLeftStatusText() const {return m_leftStatusText;}
200
202 void StatusSaveStart();
203
205 void StatusSaveFinished();
206
208 void StatusSaveFailed();
209
211 void StatusExportStart();
212
215
217 void StatusExportFailed();
218
219 Configuration &GetConfiguration() {return m_configuration;}
220
225 if (m_mcpServer)
226 m_mcpServer->ReconcileWithConfig(m_configuration);
227 }
228
229#ifdef WXM_USE_AI_TOOLS
232 void ReloadAiChatProvider() {
233 if (m_aiChatSidebar)
234 m_aiChatSidebar->ReloadProviderFromConfig();
235 }
236#endif
237
238protected:
241#ifdef WXM_USE_AI_TOOLS
243 AiChatSidebar *m_aiChatSidebar = nullptr;
246 AiConnectionMonitor *m_aiConnectionMonitor = nullptr;
247#endif
250 Configuration m_configuration;
252 std::unique_ptr<McpServer> m_mcpServer;
254 std::size_t m_bytesFromMaxima = 0;
256 long m_pid = -1;
258 long m_maximaPid = -1;
262 void OnNotificationClose(wxCommandEvent WXUNUSED(&event));
265#if wxUSE_TASKBARICON
271 std::unique_ptr<TrayIcon> m_trayIcon;
272#endif
276 wxMenu *m_demo_sub = nullptr;
278 std::vector<wxMenu *> m_demoSubs;
280 wxMenu *m_viewMenu = nullptr;
282 wxMenu *m_gentranMenu = nullptr;
284 wxMenu *m_subst_Sub = nullptr;
286 wxMenu * m_logexpand_Sub = nullptr;
288 wxMenu *m_FileMenu = nullptr;
290 wxMenu *m_EditMenu = nullptr;
292 wxMenu *m_CellMenu = nullptr;
294 wxMenu *m_Edit_Zoom_Sub = nullptr;
296 wxMenu *m_Maxima_Panes_Sub = nullptr;
298 wxMenu *m_EquationsMenu = nullptr;
300 wxMenu *m_MaximaMenu = nullptr;
302 wxMenu *m_matrix_menu = nullptr;
304 wxMenu *m_SimplifyMenu = nullptr;
306 wxMenu *m_Simplify_Gamma_Sub = nullptr;
308 wxMenu *m_debugTypeMenu = nullptr;
310 wxMenu *m_Simplify_Trig_Sub = nullptr;
312 wxMenu *m_Simplify_Complex_Sub = nullptr;
314 wxMenu *m_CalculusMenu = nullptr;
315
317 wxMenu *m_PlotMenu = nullptr;
319 wxMenu *m_listMenu = nullptr;
321 wxMenu *m_NumericMenu = nullptr;
323 wxMenu *m_HelpMenu = nullptr;
327 void ReReadConfig();
329 void ReadConfig();
337 void DockAllSidebars(wxCommandEvent &ev);
338 void HideAllSidebars(wxCommandEvent &ev);
339
340 wxString wxMaximaManualLocation();
341public:
343 const std::unordered_map<int, wxString> &GetSidebarNames() const {return m_sidebarNames;}
344
353 std::vector<McpSidebarInfo> McpSidebarList() const;
358 bool McpSetSidebarVisible(const wxString &name, bool show);
359protected:
360 Worksheet *GetWorksheet() const {return m_worksheet;}
361private:
363 std::unordered_map<int, wxString> m_sidebarNames;
365 std::unordered_map<int, wxString> m_sidebarCaption;
367 std::size_t m_bytesFromMaxima_last = 0;
368 wxTimer m_bytesReadDisplayTimer;
370 bool m_StatusSaving = false;
373 StatusBar::MaximaStatus m_StatusMaximaBusy = StatusBar::wait_for_start;
374 StatusBar::MaximaStatus m_StatusMaximaBusy_next = StatusBar::wait_for_start;
377 bool m_newStatusText = false;
379 wxString m_leftStatusText;
381 bool m_forceStatusbarUpdate = false;
382
383 void SetupToolBar();
384
388 void SetupMenu();
389 void SetupFileMenu();
390 void SetupEditMenu();
391 void SetupViewMenu();
392 void SetupCellMenu();
393 void SetupMaximaMenu();
394 void SetupEquationsMenu();
395 void SetupMatrixMenu();
396 void SetupCalculusMenu();
397 void SetupSimplifyMenu();
398 void SetupListMenu();
399 void SetupPlotMenu();
400 void SetupNumericMenu();
401 void SetupHelpMenu();
402
403public:
404 void StatusText(const wxString &text, bool saveInLog = true);
405protected:
406 ScrollingGenWizPanel *m_wizard = nullptr;
412 virtual wxSize DoGetBestClientSize() const;
415#ifdef USE_WEBVIEW
416 HelpBrowser *m_helpPane = nullptr;
417#endif
423
425 wxString GetDemoFile(wxWindowID id) const;
426protected:
427 std::array<wxString, 10> m_statusTextHistory;
428 void OnMenuStatusText(wxMenuEvent &event);
429 std::unordered_map<wxWindowID, wxString> m_demoFilesIDs;
430
431 SymbolsSidebar *m_symbolsSidebar = nullptr;
438
440 bool m_first = true;
441
442 bool ToolbarIsShown();
443protected:
445 wxAuiManager m_manager;
447 Worksheet * const m_worksheet = nullptr;
449 History * const m_history = nullptr;
456 RecentDocuments m_recentPackages;
457 wxMenu *m_recentDocumentsMenu = nullptr;
458 wxMenu *m_unsavedDocumentsMenu = nullptr;
459 wxMenu *m_recentPackagesMenu = nullptr;
460 wxMenu *m_autoSubscriptMenu = nullptr;
461 wxMenu *m_equationTypeMenuMenu = nullptr;
462 wxMenu *m_roundedMatrixParensMenu = nullptr;
463};
464
465#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:60
A sidebar that shows the raw HTTP traffic between wxMaxima and the configured AI provider – the AI Ch...
Definition: AiConnectionMonitor.h:45
The configuration storage for the current worksheet.
Definition: Configuration.h:101
The class for the sidebar with the draw commands.
Definition: DrawSidebar.h:39
Definition: FindReplacePane.h:51
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:123
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:121
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:75
wxMenu * m_FileMenu
The file menu.
Definition: wxMaximaFrame.h:288
void UpdateRecentDocuments()
Update the recent documents list.
Definition: wxMaximaFrame.cpp:2302
void StatusSaveFailed()
Set the status to "Saving has failed".
Definition: wxMaximaFrame.cpp:740
void RegisterAutoSaveFile()
Remember a temporary autosave file name.
Definition: wxMaximaFrame.cpp:2357
const std::unordered_map< int, wxString > & GetSidebarNames() const
Get the list of human-readable sidebarnames and IDs.
Definition: wxMaximaFrame.h:343
bool m_first
Do we expect the 1st prompt from maxima to appear?
Definition: wxMaximaFrame.h:440
virtual ~wxMaximaFrame()
The destructor.
Definition: wxMaximaFrame.cpp:752
bool m_placeFloatingWizard
Whether the floating wizard still needs a position: see ShowWizardPane()
Definition: wxMaximaFrame.h:408
wxMenu * m_EditMenu
The edit menu.
Definition: wxMaximaFrame.h:290
TableOfContents * m_tableOfContents
The table of contents pane.
Definition: wxMaximaFrame.h:249
void LogHelpMenuContents() const
Logs every entry of the Help menu, as wx and (on Windows) the OS see it.
Definition: wxMaximaFrame.cpp:2542
FindReplacePane::FindReplaceData m_findPaneData
The data backing the dockable find/replace sidebar (GH #2249) – kept separate from wxMaxima::m_findDa...
Definition: wxMaximaFrame.h:422
void StatusSaveFinished()
Set the status to "Maxima has finished saving".
Definition: wxMaximaFrame.cpp:724
bool FitWizardPane()
Make the wizard pane at least as large as the wizard it shows.
Definition: wxMaximaFrame.cpp:2420
int m_commandsLeftInCurrentCell
The number of commands left in the current of the evaluation queue item.
Definition: wxMaximaFrame.h:437
void TogglePaneVisibility(int id)
Hides or unhides the pane with the given ID.
Definition: wxMaximaFrame.cpp:2533
void ReconcileMcpServer()
Starts/stops the MCP server (src/mcp/McpServer.h) to match the current configuration....
Definition: wxMaximaFrame.h:224
void UpdateHelpMenuChecks()
Check the Help menu's radio items that match the configuration.
Definition: wxMaximaFrame.cpp:2567
void ReReadConfig()
Re-read the configuration.
Definition: wxMaximaFrame.cpp:2327
bool McpSetSidebarVisible(const wxString &name, bool show)
Show or hide one sidebar by the untranslated name McpSidebarList() reports, for the MCP server's show...
Definition: wxMaximaFrame.cpp:2637
wxMenu * m_Simplify_Complex_Sub
The complex submenu.
Definition: wxMaximaFrame.h:312
std::unique_ptr< McpServer > m_mcpServer
The (opt-in, off by default) MCP server – see ReconcileMcpServer().
Definition: wxMaximaFrame.h:252
bool IsXMLInspectorShown()
Is the XML inspector shown?
Definition: wxMaximaFrame.h:137
StatusBar::MaximaStatus StatusMaximaBusy() const
The status Maxima is currently displayed as being in.
Definition: wxMaximaFrame.h:191
void StatusExportStart()
Set the status to "Maxima is exporting".
Definition: wxMaximaFrame.cpp:728
void ClearPendingStatusText()
Mark the pending left-half status text as having been displayed.
Definition: wxMaximaFrame.h:197
virtual wxSize DoGetBestClientSize() const
The default size for the window.
Definition: wxMaximaFrame.cpp:626
wxMenu * m_PlotMenu
The plot menu.
Definition: wxMaximaFrame.h:317
PerformanceSidebar * m_performanceSidebar
The panel showing performance statistics.
Definition: wxMaximaFrame.h:453
wxMenu * m_Maxima_Panes_Sub
The panes submenu.
Definition: wxMaximaFrame.h:296
wxMenu * m_EquationsMenu
The equations menu.
Definition: wxMaximaFrame.h:298
bool m_updateEvaluationQueueLengthDisplay
Do we need to update the display showing the evaluation queue length?
Definition: wxMaximaFrame.h:435
wxMenu * m_gentranMenu
The gentran menu.
Definition: wxMaximaFrame.h:282
void ToggleXMLInspector()
Hide or unhide the XML inspector.
Definition: wxMaximaFrame.h:141
long m_drawDimensions_last
Are we inside a 2d or 3d draw command?
Definition: wxMaximaFrame.h:410
wxString m_tempfileName
The last name GetTempAutosavefileName() has returned.
Definition: wxMaximaFrame.h:260
wxMenu * m_Simplify_Trig_Sub
The trigonometric submenu.
Definition: wxMaximaFrame.h:310
void PopulateRecentPackagesMenu(wxMenu *menu, int firstEntry, const std::list< wxString > &items)
Used by UpdateRecentPackages for populating a menu.
Definition: wxMaximaFrame.cpp:2286
void ShowPane(int id, bool show=true)
Show or hide a sidebar.
Definition: wxMaximaFrame.cpp:2580
StatusBar * m_statusBar
The status bar.
Definition: wxMaximaFrame.h:264
XmlInspector * m_xmlInspector
A XmlInspector-like xml monitor.
Definition: wxMaximaFrame.h:451
void EvaluationQueueLength(int length, int numberOfCommands=-1)
Inform the user about the length of the evaluation queue.
Definition: wxMaximaFrame.cpp:636
wxMenu * m_demo_sub
The "demo" sub-menu.
Definition: wxMaximaFrame.h:276
wxMenu * m_listMenu
The list menu.
Definition: wxMaximaFrame.h:319
wxMenu * m_debugTypeMenu
Contains the menu for the debugger trigger settingxc.
Definition: wxMaximaFrame.h:308
void PopulateRecentDocumentsMenu(wxMenu *menu, int firstEntry, const std::list< wxString > &items)
Used by UpdateRecentDocuments for populating a menu.
Definition: wxMaximaFrame.cpp:2263
MainMenuBar * m_MenuBar
The menu bar.
Definition: wxMaximaFrame.h:274
bool IsPerformanceMonitorShown()
Is the performance monitor shown?
Definition: wxMaximaFrame.h:139
void OnNotificationClose(wxCommandEvent WXUNUSED(&event))
Issued if a notification is closed.
History *const m_history
The history pane.
Definition: wxMaximaFrame.h:449
wxMenu * m_Simplify_Gamma_Sub
The factorials and gamma submenu.
Definition: wxMaximaFrame.h:306
int m_EvaluationQueueLength
The current length of the evaluation queue of commands we still need to send to maxima.
Definition: wxMaximaFrame.h:433
void AuiManagerUpdate()
Updates the AUI manager and re-asserts the menu bar on GTK to prevent it from disappearing.
Definition: wxMaximaFrame.cpp:2512
void RemoveTempAutosavefile()
Remove an eventual temporary autosave file.
Definition: wxMaximaFrame.cpp:2364
wxMenu * m_CalculusMenu
The calculus menu.
Definition: wxMaximaFrame.h:314
void DockAllSidebars(wxCommandEvent &ev)
An instant single-window mode.
Definition: wxMaximaFrame.cpp:2483
void StatusSaveStart()
Set the status to "Maxima is saving".
Definition: wxMaximaFrame.cpp:719
wxMenu * m_viewMenu
The "view" menu.
Definition: wxMaximaFrame.h:280
void ReadConfig()
Read the configuration from the OS's configuration storage.
Definition: wxMaximaFrame.cpp:2322
wxMenu * m_SimplifyMenu
The simplify menu.
Definition: wxMaximaFrame.h:304
long m_pid
The process id of maxima. Is determined by ReadFirstPrompt.
Definition: wxMaximaFrame.h:256
void StatusExportFailed()
Set the status to "Exporting has failed".
Definition: wxMaximaFrame.cpp:746
std::size_t m_bytesFromMaxima
How many bytes did maxima send us until now?
Definition: wxMaximaFrame.h:254
wxMenu * m_matrix_menu
The matrix menu.
Definition: wxMaximaFrame.h:302
const wxString & GetLeftStatusText() const
The pending text for the left half of the status bar.
Definition: wxMaximaFrame.h:199
wxMenu * m_MaximaMenu
The maxima menu.
Definition: wxMaximaFrame.h:300
wxMenu * m_subst_Sub
The subst submenu.
Definition: wxMaximaFrame.h:284
void ShowWizardPane(const wxString &title)
Show the pane the wizards are in.
Definition: wxMaximaFrame.cpp:2393
void ShowToolBar(bool show)
Shows or hides the toolbar.
Definition: wxMaximaFrame.cpp:2655
void StatusMaximaBusy(StatusBar::MaximaStatus status)
Set the status according to if maxima is calculating.
Definition: wxMaximaFrame.h:189
bool IsPaneDisplayed(int id)
true, if a Pane is currently enabled
Definition: wxMaximaFrame.cpp:2376
wxMenu * m_HelpMenu
The help menu.
Definition: wxMaximaFrame.h:323
void ToggleLogPane()
Toggle the visibility of the log pane.
Definition: wxMaximaFrame.h:147
wxAuiManager m_manager
The manager for dynamic screen layouts.
Definition: wxMaximaFrame.h:445
DrawSidebar * m_drawPane
The sidebar with the draw commands.
Definition: wxMaximaFrame.h:414
void StatusExportFinished()
Set the status to "Maxima has finished exporting".
Definition: wxMaximaFrame.cpp:734
wxMenu * m_Edit_Zoom_Sub
The zoom submenu.
Definition: wxMaximaFrame.h:294
wxMenu * m_NumericMenu
The numeric menu.
Definition: wxMaximaFrame.h:321
wxMenu * m_CellMenu
The cell menu.
Definition: wxMaximaFrame.h:292
Variablespane * m_variablesPane
The panel the user can display variable contents in.
Definition: wxMaximaFrame.h:240
std::vector< McpSidebarInfo > McpSidebarList() const
Every dockable sidebar, with its current visibility – what the MCP server's list_sidebars tool report...
Definition: wxMaximaFrame.cpp:2604
std::vector< wxMenu * > m_demoSubs
The submenus for the various "demo" sub-submenus.
Definition: wxMaximaFrame.h:278
long m_maximaPid
The real process id of maxima (might be a child of m_pid).
Definition: wxMaximaFrame.h:258
Worksheet *const m_worksheet
The worksheet itself.
Definition: wxMaximaFrame.h:447
RecentDocuments m_recentDocuments
The panel the log and debug messages will appear on.
Definition: wxMaximaFrame.h:455
wxMenu * m_logexpand_Sub
The logexpand submenu.
Definition: wxMaximaFrame.h:286
bool HasPendingStatusText() const
True if StatusText() recorded a left-half status text not yet shown.
Definition: wxMaximaFrame.h:195
wxString GetDemoFile(wxWindowID id) const
Looks up which demo file belongs to a wxWindowID.
Definition: wxMaximaFrame.cpp:2203
void AddToHistory(const wxString &cmd)
Adds a command to the list of recently used maxima commands.
Definition: wxMaximaFrame.h:172