There a fair amount of Python code doing this but I don't understand Python.
Here is what I have done so far:
Code: Select all
// status bar constructor
m_statusbar = new wxStatusBar(this, wxID_ANY, wxST_SIZEGRIP | wxNO_BORDER);
m_statusbar->SetFieldsCount(5); // all fields will have text values except the second where I want the wxGauge
SetStatusBar(m_statusbar);
// place wxGauge on the status bar
wxRect rect;
m_statusbar->GetFieldRect(1, rect);
m_progress = new wxGauge(m_statusbar, ID_QUERY_PROGRESS, 0, rect.GetPosition(), rect.GetSize(), wxGA_SMOOTH);
// start timer
m_timer = nullptr;
m_timer = new wxTimer(this, ID_QUERY_PROGRESS_TIMER);
m_timer->Start(300);
// handle timer events
Bind(wxEVT_TIMER, &MyFrame::progressTimer, this, ID_TIMER);
void MyFrame::progressTimer(wxTimerEvent& WXUNUSED(evt))
{
m_progress->Pulse();
}
// handle re-sizing
Bind(wxEVT_SIZE, &MyFrame::sizeChanged, this, ID_PROGRESS);
void MyFrame::sizeChanged(wxSizeEvent& evt)
{
wxRect rect;
m_statusbar->GetFieldRect(1, rect);
m_progress->SetSize(rect);
evt.Skip();
}
1) The layout of the wxGauge is wrong. I want it in the second field, but it appears in the first.
2) The call to m_progress->Pulse() does not produce any change in the wxGauge. However, I am sure the event is firing.