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:
49 StatusBar(wxWindow *parent, int id);
50 virtual ~StatusBar();
53 {
54 idle,
55 error,
56 offline,
57 receive,
58 transmit
59 };
60
62 void UpdateBitmaps();
63
65 void NetworkStatus(networkState status);
66
67 wxWindow *GetNetworkStatusElement()
68 { return m_networkStatus; }
69
70 wxWindow *GetStatusTextElement()
71 { return m_statusTextPanel; }
72
73 wxWindow *GetMaximaStatusElement()
74 { return m_maximaStatus; }
75
77 void SetMaximaCPUPercentage(float percentage)
78 {
79 m_maximaPercentage = percentage;
80 NetworkStatus(m_oldNetworkState);
81 }
82
84 {
85 wait_for_start,
86 process_wont_start,
87 sending,
88 waiting,
89 waitingForPrompt,
90 waitingForAuth,
91 calculating,
92 parsing,
93 transferring,
94 userinput,
95 maximaerror,
100 disconnected
101 };
102
103 void UpdateStatusMaximaBusy(MaximaStatus status, std::size_t bytesFromMaxima);
119 wxBitmap GetTrayIconBitmap(MaximaStatus status) const {
120 switch (status) {
121 case wait_for_start:
122 return m_bitmap_waitForStart;
123 case process_wont_start:
124 case maximaerror:
125 return m_bitmap_process_wont_start;
126 case sending:
127 return m_bitmap_sending;
128 case waiting:
129 return m_bitmap_waiting;
130 case waitingForPrompt:
131 return m_bitmap_waitingForPrompt;
132 case waitingForAuth:
133 return m_bitmap_waitingForAuth;
134 case calculating:
135 return m_bitmap_calculating;
136 case parsing:
137 return m_bitmap_parsing;
138 case transferring:
139 return m_bitmap_transferring;
140 case userinput:
141 return m_bitmap_userinput;
142 case debugging:
143 return m_bitmap_debugging;
144 case lispmode:
145 return m_bitmap_lispmode;
146 case disconnected:
147 return m_bitmap_disconnected;
148 default:
149 return m_bitmap_waiting;
150 }
151 }
158 void SetStatusText(wxString statusText){
159 if (m_statusText->GetLabel() != statusText)
160 m_statusText->SetLabel(statusText);
161 }
162protected:
163 void StatusMsgDClick(wxMouseEvent &ev);
164 void OnSize(wxSizeEvent &event);
165 void OnTimerEvent(wxTimerEvent &event);
166
167 void HandleTimerEvent();
168
169private:
170 std::unique_ptr<struct wxm_NSVGrasterizer, decltype(std::free)*> m_svgRast{nullptr, std::free};
172 wxSize m_ppi = wxSize(75, 75);
177 float m_maximaPercentage = -1;
182 float m_oldmaximaPercentage = -1;
183 networkState m_oldNetworkState = receive;
184 wxString m_stdToolTip;
185 wxString m_networkErrToolTip;
186 wxString m_noConnectionToolTip;
188 networkState m_networkState = offline;
190 bool m_icon_shows_receive = false;
192 bool m_icon_shows_transmit = false;
193 bool m_overlayIconIsSet = false;
195 wxPanel *m_statusTextPanel = NULL;
197 wxStaticText *m_statusText = NULL;
199 wxStaticBitmap *m_networkStatus = NULL;
201 wxStaticBitmap *m_maximaStatus = NULL;
203 wxBitmap m_network_error;
205 wxBitmap m_network_offline;
207 wxBitmap m_network_transmit;
209 wxBitmap m_network_idle;
211 wxBitmap m_network_idle_inactive;
213 wxBitmap m_network_receive;
215 wxBitmap m_network_transmit_receive;
217 wxTimer SendTimer;
219 wxTimer ReceiveTimer;
220
221 wxBitmap m_bitmap_waitForStart;
222 wxBitmap m_bitmap_process_wont_start;
223 wxBitmap m_bitmap_sending;
224 wxBitmap m_bitmap_waiting;
225 wxBitmap m_bitmap_waitingForPrompt;
226 wxBitmap m_bitmap_waitingForAuth;
227 wxBitmap m_bitmap_calculating;
228 wxBitmap m_bitmap_parsing;
229 wxBitmap m_bitmap_transferring;
230 wxBitmap m_bitmap_userinput;
231 wxBitmap m_bitmap_debugging;
232 wxBitmap m_bitmap_lispmode;
233 wxBitmap m_bitmap_disconnected;
234};
235
236#endif
237
The class that draws the status bar.
Definition: StatusBar.h:47
void UpdateBitmaps()
Update the bitmaps to the Right size for the Resolution.
Definition: StatusBar.cpp:117
networkState
The network states that can be passed to NetworkStatus()
Definition: StatusBar.h:53
void SetMaximaCPUPercentage(float percentage)
Inform the status bar how many percents of the available CPU power maxima uses.
Definition: StatusBar.h:77
void SetStatusText(wxString statusText)
Set the left status text.
Definition: StatusBar.h:158
wxBitmap GetTrayIconBitmap(MaximaStatus status) const
The exact bitmap m_maximaStatus itself would show for this status – i.e.
Definition: StatusBar.h:119
void NetworkStatus(networkState status)
Informs the status bar about networking events.
Definition: StatusBar.cpp:427
MaximaStatus
Definition: StatusBar.h:84
@ debugging
Maxima's Lisp is stopped in a debugger (e.g. sbcl's LDB).
Definition: StatusBar.h:97
@ lispmode
Maxima's reader is in Lisp mode (after to_lisp() / a MAXIMA> prompt).
Definition: StatusBar.h:99