diff --git a/include/wx/gauge.h b/include/wx/gauge.h index 2d2bc5a0d9..d89f089131 100644 --- a/include/wx/gauge.h +++ b/include/wx/gauge.h @@ -99,6 +99,13 @@ public: protected: virtual wxBorder GetDefaultBorder() const wxOVERRIDE { return wxBORDER_NONE; } + // Initialize m_appProgressIndicator if necessary, i.e. if this object has + // wxGA_PROGRESS style. This method is supposed to be called from the + // derived class Create() if it doesn't call the base class Create(), which + // already does it, after initializing the window style and range. + void InitProgressIndicatorIfNeeded(); + + // the max position int m_rangeMax; diff --git a/src/common/gaugecmn.cpp b/src/common/gaugecmn.cpp index f617e2cf7d..9e698d7dd2 100644 --- a/src/common/gaugecmn.cpp +++ b/src/common/gaugecmn.cpp @@ -104,6 +104,20 @@ wxCONSTRUCTOR_6( wxGauge, wxWindow*, Parent, wxWindowID, Id, int, Range, \ // wxGauge creation // ---------------------------------------------------------------------------- +void wxGaugeBase::InitProgressIndicatorIfNeeded() +{ + m_appProgressIndicator = NULL; + if ( HasFlag(wxGA_PROGRESS) ) + { + wxWindow* topParent = wxGetTopLevelParent(this); + if ( topParent != NULL ) + { + m_appProgressIndicator = + new wxAppProgressIndicator(topParent, GetRange()); + } + } +} + bool wxGaugeBase::Create(wxWindow *parent, wxWindowID id, int range, @@ -122,23 +136,15 @@ bool wxGaugeBase::Create(wxWindow *parent, SetValidator(validator); #endif // wxUSE_VALIDATORS - m_appProgressIndicator = NULL; - if ( (style & wxGA_PROGRESS) != 0 ) - { - wxWindow* topParent = wxGetTopLevelParent(this); - if ( topParent != NULL ) - { - m_appProgressIndicator = - new wxAppProgressIndicator(topParent, range); - } - } - SetRange(range); SetValue(0); + #if wxGAUGE_EMULATE_INDETERMINATE_MODE m_nDirection = wxRIGHT; #endif + InitProgressIndicatorIfNeeded(); + return true; } diff --git a/src/msw/gauge.cpp b/src/msw/gauge.cpp index d07096f086..8bf0645031 100644 --- a/src/msw/gauge.cpp +++ b/src/msw/gauge.cpp @@ -97,6 +97,8 @@ bool wxGauge::Create(wxWindow *parent, SetRange(range); + InitProgressIndicatorIfNeeded(); + return true; }