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:
218 wxWindow *m_frame = nullptr;
220 wxSize m_ppi = wxSize(75, 75);
225 float m_maximaPercentage = -1;
230 float m_oldmaximaPercentage = -1;
231 networkState m_oldNetworkState = receive;
232 wxString m_stdToolTip;
233 wxString m_networkErrToolTip;
234 wxString m_noConnectionToolTip;
236 networkState m_networkState = offline;
238 bool m_icon_shows_receive = false;
240 bool m_icon_shows_transmit = false;
241 bool m_overlayIconIsSet = false;
243 wxPanel *m_statusTextPanel = nullptr;
245 wxStaticText *m_statusText = nullptr;
247 wxStaticBitmap *m_networkStatus = nullptr;
249 wxStaticBitmap *m_maximaStatus = nullptr;
251 bool m_aiChatAvailable = false;
253 wxStaticBitmap *m_aiStatus = nullptr;
256 AiStatus m_aiStatusState = AiStatus::None;
258 wxString m_aiStatusDetail;
260 wxBitmap m_bitmap_ai_active;
262 wxBitmap m_bitmap_ai_busy;
264 wxBitmap m_bitmap_ai_error;
266 wxBitmap m_network_error;
268 wxBitmap m_network_offline;
270 wxBitmap m_network_transmit;
272 wxBitmap m_network_idle;
274 wxBitmap m_network_idle_inactive;
276 wxBitmap m_network_receive;
278 wxBitmap m_network_transmit_receive;
280 wxTimer SendTimer;
282 wxTimer ReceiveTimer;
283
284 wxBitmap m_bitmap_waitForStart;
285 wxBitmap m_bitmap_process_wont_start;
286 wxBitmap m_bitmap_sending;
287 wxBitmap m_bitmap_waiting;
288 wxBitmap m_bitmap_waitingForPrompt;
289 wxBitmap m_bitmap_waitingForAuth;
290 wxBitmap m_bitmap_calculating;
291 wxBitmap m_bitmap_parsing;
292 wxBitmap m_bitmap_transferring;
293 wxBitmap m_bitmap_userinput;
294 wxBitmap m_bitmap_debugging;
295 wxBitmap m_bitmap_lispmode;
296 wxBitmap m_bitmap_disconnected;
297};
298
299#endif
300
The class that draws the status bar.
Definition: StatusBar.h:47
wxWindow * GetAiStatusElement()
The AI status icon, or nullptr if aiChatAvailable was false at construction time (the AI Chat feature...
Definition: StatusBar.h:103
void UpdateBitmaps()
Update the bitmaps to the Right size for the Resolution.
Definition: StatusBar.cpp:123
void UpdateAiStatus(AiStatus status, const wxString &detail=wxString())
Update the AI status icon.
Definition: StatusBar.cpp:375
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:461
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