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 // Event table
31 BEGIN_EVENT_TABLE(ProgressStatusBar, wxStatusBar)
32 EVT_SIZE(ProgressStatusBar::OnSize)
34 
35 ProgressStatusBar::ProgressStatusBar(wxWindow *parent, wxWindowID id, long style, const wxString &name) : wxStatusBar(parent, id, style, name)
36 {
37  m_progress = new wxGauge(this, -1, 100, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL);
38  SetProgress(-1);
39 }
40 
42 {
43  if (m_progress)
44  {
45  delete m_progress;
46  };
47 }
48 
49 void ProgressStatusBar::OnSize(wxSizeEvent& event)
50 {
51  if (GetFieldsCount() > 0)
52  {
53  wxRect r;
54  GetFieldRect(GetFieldsCount() - 1, r);
55  r.Deflate(2, 2);
56  m_progress->SetSize(r);
57  };
58 }
59 
61 {
62  m_progressValue = progress;
63  m_progress->Show(m_progressValue >= 0);
64  // SetValue expects values >=0 and < max value, but we are using -1 to indicate that progress bar is hidden
65  m_progress->SetValue(m_progressValue < 0 ? 0 : m_progressValue);
66 };
67 
69 {
70  return m_progressValue;
71 };
definition of statusbar with progress indicator
class for showing a status bar with progress, the progress bar is always in the last field of the sta...
END_EVENT_TABLE()
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