Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ProgressStatusBar.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
2 
11 /*
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public
14  * License as published by the Free Software Foundation; either
15  * version 2 of the License, or (at your option) any later version.
16  *
17  * This software is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public
23  * License along with this software. If not, see
24  * <http://www.gnu.org/licenses/>.
25  *
26  */
27 
28 #include "ProgressStatusBar.h"
29 
30 ProgressStatusBar::ProgressStatusBar(wxWindow *parent, wxWindowID id, long style, const wxString &name) : wxStatusBar(parent, id, style, name)
31 {
32  m_progress = new wxGauge(this, -1, 100, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL);
33  SetProgress(-1);
34  Bind(wxEVT_SIZE, &ProgressStatusBar::OnSize, this);
35 }
36 
38 {
39  if (m_progress)
40  {
41  delete m_progress;
42  };
43 }
44 
45 void ProgressStatusBar::OnSize(wxSizeEvent& event)
46 {
47  if (GetFieldsCount() > 0)
48  {
49  wxRect r;
50  GetFieldRect(GetFieldsCount() - 1, r);
51  r.Deflate(2, 2);
52  m_progress->SetSize(r);
53  };
54 }
55 
57 {
58  m_progressValue = progress;
59  m_progress->Show(m_progressValue >= 0);
60  // SetValue expects values >=0 and < max value, but we are using -1 to indicate that progress bar is hidden
61  m_progress->SetValue(m_progressValue < 0 ? 0 : m_progressValue);
62 };
63 
65 {
66  return m_progressValue;
67 };
definition of statusbar with progress indicator
void OnSize(wxSizeEvent &event)
size change handler, correctly position gauge when size has changed
~ProgressStatusBar()
destructor, clean up all stuff
int GetProgress()
return current progress value, should be in range 0 - 100, or -1 if the progress gauge is hidden ...
void SetProgress(int progress)
update progress bar
ProgressStatusBar(wxWindow *parent, wxWindowID id, long style=wxST_SIZEGRIP, const wxString &name=wxT("statusBar"))
constructor, create the gauge internal