wxMaxima
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 <memory>
36 
37 #ifndef STATUSBAR_H
38 #define STATUSBAR_H
39 
42 class StatusBar : public wxStatusBar
43 {
44 public:
45  StatusBar(wxWindow *parent, int id);
46  ~StatusBar();
49  {
50  idle,
51  error,
52  offline,
53  receive,
54  transmit
55  };
56 
58  void UpdateBitmaps();
59 
61  void NetworkStatus(networkState status);
62 
63  wxStaticBitmap *GetNetworkStatusElement()
64  { return m_networkStatus; }
65 
67  void SetMaximaCPUPercentage(float percentage)
68  {
69  m_maximaPercentage = percentage;
70  NetworkStatus(m_oldNetworkState);
71  }
72 protected:
73  void OnSize(wxSizeEvent &event);
74  void OnTimerEvent(wxTimerEvent &event);
75 
76  void HandleTimerEvent();
77 
78 private:
79  std::unique_ptr<struct NSVGrasterizer, decltype(std::free)*> m_svgRast{nullptr, std::free};
81  wxSize m_ppi;
86  float m_maximaPercentage;
91  float m_oldmaximaPercentage;
92  networkState m_oldNetworkState;
93  wxString m_stdToolTip;
94  wxString m_networkErrToolTip;
95  wxString m_noConnectionToolTip;
97  networkState m_networkState;
99  bool m_icon_shows_receive;
101  bool m_icon_shows_transmit;
102 
103  wxBitmap GetImage(wxString name,
104  unsigned char *data_128, size_t len_128
105  );
106 
108  wxStaticBitmap *m_networkStatus;
110  wxBitmap m_network_error;
112  wxBitmap m_network_offline;
114  wxBitmap m_network_transmit;
116  wxBitmap m_network_idle;
118  wxBitmap m_network_idle_inactive;
120  wxBitmap m_network_receive;
122  wxBitmap m_network_transmit_receive;
124  wxTimer SendTimer;
126  wxTimer ReceiveTimer;
127 };
128 
129 #endif
130 
StatusBar::NetworkStatus
void NetworkStatus(networkState status)
Informs the status bar about networking events.
Definition: StatusBar.cpp:161
StatusBar::SetMaximaCPUPercentage
void SetMaximaCPUPercentage(float percentage)
Inform the status bar how many percents of the available CPU power maxima uses.
Definition: StatusBar.h:67
StatusBar
Definition: StatusBar.h:42
StatusBar::networkState
networkState
The network states that can be passed to NetworkStatus()
Definition: StatusBar.h:48
StatusBar::UpdateBitmaps
void UpdateBitmaps()
Update the bitmaps to the Right size for the Resolution.
Definition: StatusBar.cpp:70