NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
NumeReStatusbar.cpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2018 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19#include "NumeReStatusbar.hpp"
20
21// Constructor
22NumeReStatusbar::NumeReStatusbar(wxWindow* parent, wxWindowID id, long style) : wxStatusBar(parent, id, style)
23{
24 // Get the average width of a character in the current font
25 int charWidth = parent->GetCharWidth();
26 int paddingPix = 3;
27
28 // Define the sizes in chars or pixels
29 int barSizePix = 120;
30 int filetypeChars = 20;
31 int readEditChars = 15;
32 int lineColChars = 20;
33 int debuggerchars = 25;
34
35 // define status bar widths and styles
36 const int widths[] = {barSizePix, -1, filetypeChars * charWidth, readEditChars * charWidth, lineColChars * charWidth, debuggerchars * charWidth};
37 const int styles[] = {wxSB_SUNKEN, wxSB_RAISED, wxSB_RAISED, wxSB_RAISED, wxSB_RAISED, wxSB_RAISED};
38
39 // Set the number of fields and their styles
40 SetFieldsCount(WXSIZEOF(widths), widths);
41 SetStatusStyles(WXSIZEOF(styles), styles);
42
43 // Place the gauge as a busy indicator
44 m_busyIndicator = new wxGauge(this, wxID_ANY, 100, wxPoint(paddingPix, paddingPix), wxSize(barSizePix + paddingPix, GetSize().GetHeight() - 2*paddingPix), wxGA_HORIZONTAL | wxGA_SMOOTH);
45
46 // Set the indicator to zero
47 m_busyIndicator->SetValue(0);
48}
49
50// Switch to ready
52{
54 {
55 // Define the range, switch the indicator from zero to 100
56 m_busyIndicator->SetRange(100);
57 m_busyIndicator->SetValue(0);
58 m_busyIndicator->SetValue(100);
59 }
60}
61
62// Switch to busy
64{
65 // Let the gauge pulse
67 m_busyIndicator->Pulse();
68}
69
70// Update a status text
71void NumeReStatusbar::SetStatus(NumeReStatusbar::StatusField field, const wxString& sStatusText)
72{
73 if (sStatusText != GetStatusText((int)field))
74 SetStatusText(sStatusText, (int)field);
75}
76
77// Get a status text
79{
80 return GetStatusText((int)field);
81}
82
wxGauge * m_busyIndicator
void SetStatus(StatusField field, const wxString &sStatusText)
wxString GetStatus(StatusField field)
NumeReStatusbar(wxWindow *parent, wxWindowID id=wxID_ANY, long style=wxSTB_DEFAULT_STYLE)