wxMaxima
Loading...
Searching...
No Matches
StatusBar.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) 2009-2015 Andrej Vodopivec <andrej.vodopivec@gmail.com>
4// (C) 2014-2015 Gunter Königsmann <wxMaxima@physikbuch.de>
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
28#include "precomp.h"
29#include <wx/wx.h>
30#include <wx/bitmap.h>
31#include <wx/image.h>
32#include <wx/timer.h>
33#include <wx/statbmp.h>
34#include <wx/statusbr.h>
35#include <wx/stattext.h>
36#include <memory>
37
38#ifndef STATUSBAR_H
39#define STATUSBAR_H
40
41extern unsigned char GO_NEXT_SVG_GZ[];
42extern size_t GO_NEXT_SVG_GZ_SIZE;
43
46class StatusBar : public wxStatusBar
47{
48public:
57 StatusBar(wxWindow *parent, int id, bool aiChatAvailable = false);
58 virtual ~StatusBar();
61 {
62 idle,
63 error,
64 offline,
65 receive,
66 transmit
67 };
68
70 enum class AiStatus
71 {
73 None,
75 Active,
78 Busy,
80 Error
81 };
82
84 void UpdateBitmaps();
85
87 void NetworkStatus(networkState status);
88
89 wxWindow *GetNetworkStatusElement()
90 { return m_networkStatus; }
91
92 wxWindow *GetStatusTextElement()
93 { return m_statusTextPanel; }
94
95 wxWindow *GetMaximaStatusElement()
96 { return m_maximaStatus; }
97
104 { return m_aiStatus; }
105
113 void UpdateAiStatus(AiStatus status, const wxString &detail = wxString());
114
116 void SetMaximaCPUPercentage(float percentage)
117 {
118 m_maximaPercentage = percentage;
119 NetworkStatus(m_oldNetworkState);
120 }
121
123 {
124 wait_for_start,
125 process_wont_start,
126 sending,
127 waiting,
128 waitingForPrompt,
129 waitingForAuth,
130 calculating,
131 parsing,
132 transferring,
133 userinput,
134 maximaerror,
139 disconnected
140 };
141
142 void UpdateStatusMaximaBusy(MaximaStatus status, std::size_t bytesFromMaxima);
158 wxBitmap GetTrayIconBitmap(MaximaStatus status) const {
159 switch (status) {
160 case wait_for_start:
161 return m_bitmap_waitForStart;
162 case process_wont_start:
163 case maximaerror:
164 return m_bitmap_process_wont_start;
165 case sending:
166 return m_bitmap_sending;
167 case waiting:
168 return m_bitmap_waiting;
169 case waitingForPrompt:
170 return m_bitmap_waitingForPrompt;
171 case waitingForAuth:
172 return m_bitmap_waitingForAuth;
173 case calculating:
174 return m_bitmap_calculating;
175 case parsing:
176 return m_bitmap_parsing;
177 case transferring:
178 return m_bitmap_transferring;
179 case userinput:
180 return m_bitmap_userinput;
181 case debugging:
182 return m_bitmap_debugging;
183 case lispmode:
184 return m_bitmap_lispmode;
185 case disconnected:
186 return m_bitmap_disconnected;
187 default:
188 return m_bitmap_waiting;
189 }
190 }
197 void SetStatusText(wxString statusText){
198 if (m_statusText->GetLabel() != statusText)
199 m_statusText->SetLabel(statusText);
200 }
201protected:
202 void StatusMsgDClick(wxMouseEvent &ev);
203 void OnSize(wxSizeEvent &event);
204 void OnTimerEvent(wxTimerEvent &event);
205
206 void HandleTimerEvent();
207
208private:
209 std::unique_ptr<struct wxm_NSVGrasterizer, decltype(std::free)*> m_svgRast{nullptr, std::free};
211 wxSize m_ppi = wxSize(75, 75);
216 float m_maximaPercentage = -1;
221 float m_oldmaximaPercentage = -1;
222 networkState m_oldNetworkState = receive;
223 wxString m_stdToolTip;
224 wxString m_networkErrToolTip;
225 wxString m_noConnectionToolTip;
227 networkState m_networkState = offline;
229 bool m_icon_shows_receive = false;
231 bool m_icon_shows_transmit = false;
232 bool m_overlayIconIsSet = false;
234 wxPanel *m_statusTextPanel = NULL;
236 wxStaticText *m_statusText = NULL;
238 wxStaticBitmap *m_networkStatus = NULL;
240 wxStaticBitmap *m_maximaStatus = NULL;
242 bool m_aiChatAvailable = false;
244 wxStaticBitmap *m_aiStatus = NULL;
247 AiStatus m_aiStatusState = AiStatus::None;
249 wxString m_aiStatusDetail;
251 wxBitmap m_bitmap_ai_active;
253 wxBitmap m_bitmap_ai_busy;
255 wxBitmap m_bitmap_ai_error;
257 wxBitmap m_network_error;
259 wxBitmap m_network_offline;
261 wxBitmap m_network_transmit;
263 wxBitmap m_network_idle;
265 wxBitmap m_network_idle_inactive;
267 wxBitmap m_network_receive;
269 wxBitmap m_network_transmit_receive;
271 wxTimer SendTimer;
273 wxTimer ReceiveTimer;
274
275 wxBitmap m_bitmap_waitForStart;
276 wxBitmap m_bitmap_process_wont_start;
277 wxBitmap m_bitmap_sending;
278 wxBitmap m_bitmap_waiting;
279 wxBitmap m_bitmap_waitingForPrompt;
280 wxBitmap m_bitmap_waitingForAuth;
281 wxBitmap m_bitmap_calculating;
282 wxBitmap m_bitmap_parsing;
283 wxBitmap m_bitmap_transferring;
284 wxBitmap m_bitmap_userinput;
285 wxBitmap m_bitmap_debugging;
286 wxBitmap m_bitmap_lispmode;
287 wxBitmap m_bitmap_disconnected;
288};
289
290#endif
291
The class that draws the status bar.
Definition: StatusBar.h:47
wxWindow * GetAiStatusElement()
The AI status icon, or NULL if aiChatAvailable was false at construction time (the AI Chat feature is...
Definition: StatusBar.h:103
void UpdateBitmaps()
Update the bitmaps to the Right size for the Resolution.
Definition: StatusBar.cpp:126
void UpdateAiStatus(AiStatus status, const wxString &detail=wxString())
Update the AI status icon.
Definition: StatusBar.cpp:409
networkState
The network states that can be passed to NetworkStatus()
Definition: StatusBar.h:61
void SetMaximaCPUPercentage(float percentage)
Inform the status bar how many percents of the available CPU power maxima uses.
Definition: StatusBar.h:116
AiStatus
The states the AI status icon (4th status bar field) can be in.
Definition: StatusBar.h:71
@ Active
A provider is configured and the last request (if any) succeeded.
@ None
No AI provider is configured – the icon is hidden entirely.
@ Error
A provider is configured, but the last request to it failed.
@ Busy
A request to the provider is currently in flight – mirrors how m_maximaStatus shows a "calculating" i...
void SetStatusText(wxString statusText)
Set the left status text.
Definition: StatusBar.h:197
wxBitmap GetTrayIconBitmap(MaximaStatus status) const
The exact bitmap m_maximaStatus itself would show for this status – i.e.
Definition: StatusBar.h:158
void NetworkStatus(networkState status)
Informs the status bar about networking events.
Definition: StatusBar.cpp:495
MaximaStatus
Definition: StatusBar.h:123
@ debugging
Maxima's Lisp is stopped in a debugger (e.g. sbcl's LDB).
Definition: StatusBar.h:136
@ lispmode
Maxima's reader is in Lisp mode (after to_lisp() / a MAXIMA> prompt).
Definition: StatusBar.h:138
detail namespace with internal helper functions
Definition: json.hpp:249