Intergrate wxAppProgressIndicator into wxGuage.
Update the progress bar of taskbar button if wxGuage has wxGA_PROGRESS style. Author: Chaobin Zhang git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77631 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -29,6 +29,10 @@
|
|||||||
// QT only, display current completed percentage (text default format "%p%")
|
// QT only, display current completed percentage (text default format "%p%")
|
||||||
#define wxGA_TEXT 0x0040
|
#define wxGA_TEXT 0x0040
|
||||||
|
|
||||||
|
#if wxUSE_TASKBARBUTTON
|
||||||
|
#define wxGA_PROGRESS 0x0010
|
||||||
|
#endif
|
||||||
|
|
||||||
// GTK and Mac always have native implementation of the indeterminate mode
|
// GTK and Mac always have native implementation of the indeterminate mode
|
||||||
// wxMSW has native implementation only if comctl32.dll >= 6.00
|
// wxMSW has native implementation only if comctl32.dll >= 6.00
|
||||||
#if !defined(__WXGTK20__) && !defined(__WXMAC__)
|
#if !defined(__WXGTK20__) && !defined(__WXMAC__)
|
||||||
|
@@ -15,6 +15,10 @@
|
|||||||
|
|
||||||
extern WXDLLIMPEXP_DATA_CORE(const char) wxGaugeNameStr[];
|
extern WXDLLIMPEXP_DATA_CORE(const char) wxGaugeNameStr[];
|
||||||
|
|
||||||
|
#if wxUSE_TASKBARBUTTON
|
||||||
|
class WXDLLIMPEXP_FWD_CORE wxAppProgressIndicator;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Group box
|
// Group box
|
||||||
class WXDLLIMPEXP_CORE wxGauge : public wxGaugeBase
|
class WXDLLIMPEXP_CORE wxGauge : public wxGaugeBase
|
||||||
{
|
{
|
||||||
@@ -33,6 +37,10 @@ public:
|
|||||||
(void)Create(parent, id, range, pos, size, style, validator, name);
|
(void)Create(parent, id, range, pos, size, style, validator, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_TASKBARBUTTON
|
||||||
|
virtual ~wxGauge();
|
||||||
|
#endif
|
||||||
|
|
||||||
bool Create(wxWindow *parent,
|
bool Create(wxWindow *parent,
|
||||||
wxWindowID id,
|
wxWindowID id,
|
||||||
int range,
|
int range,
|
||||||
@@ -69,6 +77,10 @@ private:
|
|||||||
void SetIndeterminateMode();
|
void SetIndeterminateMode();
|
||||||
void SetDeterminateMode();
|
void SetDeterminateMode();
|
||||||
|
|
||||||
|
#if wxUSE_TASKBARBUTTON
|
||||||
|
wxAppProgressIndicator* m_appProgressIndicator;
|
||||||
|
#endif
|
||||||
|
|
||||||
DECLARE_DYNAMIC_CLASS_NO_COPY(wxGauge)
|
DECLARE_DYNAMIC_CLASS_NO_COPY(wxGauge)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -130,17 +130,17 @@ private:
|
|||||||
class WXDLLIMPEXP_CORE wxAppProgressIndicator
|
class WXDLLIMPEXP_CORE wxAppProgressIndicator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxAppProgressIndicator(wxTopLevelWindow *parent, int maxValue);
|
wxAppProgressIndicator(WXWidget parent, int maxValue);
|
||||||
virtual ~wxAppProgressIndicator();
|
virtual ~wxAppProgressIndicator();
|
||||||
bool Update(int value);
|
void SetValue(int value);
|
||||||
bool Pulse();
|
void SetRange(int range);
|
||||||
|
void Pulse();
|
||||||
|
void Reset();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Init();
|
|
||||||
|
|
||||||
wxTopLevelWindow *m_parent;
|
|
||||||
int m_maxValue;
|
int m_maxValue;
|
||||||
wxScopedPtr<wxTaskBarButton> m_taskBarButton;
|
WXWidget m_parent;
|
||||||
|
wxTaskBarButton* m_taskBarButton;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum WXDLLIMPEXP_CORE wxTaskBarJumpListItemType
|
enum WXDLLIMPEXP_CORE wxTaskBarJumpListItemType
|
||||||
|
@@ -33,8 +33,6 @@ enum
|
|||||||
RestoreThumbnailClipBtn,
|
RestoreThumbnailClipBtn,
|
||||||
AddThumbBarButtonBtn,
|
AddThumbBarButtonBtn,
|
||||||
RemoveThumbBarButtonBtn,
|
RemoveThumbBarButtonBtn,
|
||||||
ShowProgressDialogBtn,
|
|
||||||
PulseProgressDialogBtn,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@@ -121,8 +119,6 @@ private:
|
|||||||
void OnAddThubmBarButton(wxCommandEvent& WXUNUSED(event));
|
void OnAddThubmBarButton(wxCommandEvent& WXUNUSED(event));
|
||||||
void OnRemoveThubmBarButton(wxCommandEvent& WXUNUSED(event));
|
void OnRemoveThubmBarButton(wxCommandEvent& WXUNUSED(event));
|
||||||
void OnThumbnailToolbarBtnClicked(wxCommandEvent& event);
|
void OnThumbnailToolbarBtnClicked(wxCommandEvent& event);
|
||||||
void OnShowProgressDialog(wxCommandEvent& WXUNUSED(event));
|
|
||||||
void OnPulseProgressDialog(wxCommandEvent& WXUNUSED(event));
|
|
||||||
|
|
||||||
wxSlider *m_slider;
|
wxSlider *m_slider;
|
||||||
wxRadioBox *m_visibilityRadioBox;
|
wxRadioBox *m_visibilityRadioBox;
|
||||||
@@ -286,16 +282,6 @@ MyFrame::MyFrame(const wxString& title)
|
|||||||
ttbSizer->Add(addThumbBarButtonBtn, 1, wxEXPAND | wxALL, 2);
|
ttbSizer->Add(addThumbBarButtonBtn, 1, wxEXPAND | wxALL, 2);
|
||||||
ttbSizer->Add(showThumbnailToolbarBtn, 1, wxEXPAND | wxALL, 2);
|
ttbSizer->Add(showThumbnailToolbarBtn, 1, wxEXPAND | wxALL, 2);
|
||||||
|
|
||||||
// wxAppProgressIndicator section.
|
|
||||||
wxStaticBoxSizer *indicatorSizer =
|
|
||||||
new wxStaticBoxSizer(wxVERTICAL, panel, wxT("wxAppProgressIndicator"));
|
|
||||||
wxButton *showProgressDialogBtn =
|
|
||||||
new wxButton(panel, ShowProgressDialogBtn, wxT("Show Progress dialog"));
|
|
||||||
wxButton *pulseProgressDialigBtn =
|
|
||||||
new wxButton(panel, PulseProgressDialogBtn, wxT("Pulse Progress dialog"));
|
|
||||||
indicatorSizer->Add(showProgressDialogBtn, 1, wxEXPAND | wxALL, 2);
|
|
||||||
indicatorSizer->Add(pulseProgressDialigBtn, 1, wxEXPAND | wxALL, 2);
|
|
||||||
|
|
||||||
gs->Add(spvSizer, 0, wxEXPAND);
|
gs->Add(spvSizer, 0, wxEXPAND);
|
||||||
gs->Add(m_visibilityRadioBox, 0, wxEXPAND);
|
gs->Add(m_visibilityRadioBox, 0, wxEXPAND);
|
||||||
gs->Add(sttSizer, 0, wxEXPAND);
|
gs->Add(sttSizer, 0, wxEXPAND);
|
||||||
@@ -303,7 +289,6 @@ MyFrame::MyFrame(const wxString& title)
|
|||||||
gs->Add(soiSizer, 0, wxEXPAND);
|
gs->Add(soiSizer, 0, wxEXPAND);
|
||||||
gs->Add(stcSizer, 0, wxEXPAND);
|
gs->Add(stcSizer, 0, wxEXPAND);
|
||||||
gs->Add(ttbSizer, 0, wxEXPAND);
|
gs->Add(ttbSizer, 0, wxEXPAND);
|
||||||
gs->Add(indicatorSizer, 0, wxEXPAND);
|
|
||||||
|
|
||||||
wxStaticText *text = new wxStaticText(
|
wxStaticText *text = new wxStaticText(
|
||||||
panel, wxID_ANY, wxT("Welcome to wxTaskBarButton sample"));
|
panel, wxID_ANY, wxT("Welcome to wxTaskBarButton sample"));
|
||||||
@@ -328,8 +313,6 @@ wxBEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
EVT_BUTTON(RestoreThumbnailClipBtn, MyFrame::OnSetOrRestoreThumbnailClip)
|
EVT_BUTTON(RestoreThumbnailClipBtn, MyFrame::OnSetOrRestoreThumbnailClip)
|
||||||
EVT_BUTTON(AddThumbBarButtonBtn, MyFrame::OnAddThubmBarButton)
|
EVT_BUTTON(AddThumbBarButtonBtn, MyFrame::OnAddThubmBarButton)
|
||||||
EVT_BUTTON(RemoveThumbBarButtonBtn, MyFrame::OnRemoveThubmBarButton)
|
EVT_BUTTON(RemoveThumbBarButtonBtn, MyFrame::OnRemoveThubmBarButton)
|
||||||
EVT_BUTTON(ShowProgressDialogBtn, MyFrame::OnShowProgressDialog)
|
|
||||||
EVT_BUTTON(PulseProgressDialogBtn, MyFrame::OnPulseProgressDialog)
|
|
||||||
EVT_BUTTON(ThumbnailToolbarBtn_0, MyFrame::OnThumbnailToolbarBtnClicked)
|
EVT_BUTTON(ThumbnailToolbarBtn_0, MyFrame::OnThumbnailToolbarBtnClicked)
|
||||||
EVT_BUTTON(ThumbnailToolbarBtn_1, MyFrame::OnThumbnailToolbarBtnClicked)
|
EVT_BUTTON(ThumbnailToolbarBtn_1, MyFrame::OnThumbnailToolbarBtnClicked)
|
||||||
EVT_BUTTON(ThumbnailToolbarBtn_2, MyFrame::OnThumbnailToolbarBtnClicked)
|
EVT_BUTTON(ThumbnailToolbarBtn_2, MyFrame::OnThumbnailToolbarBtnClicked)
|
||||||
@@ -447,43 +430,3 @@ void MyFrame::OnThumbnailToolbarBtnClicked(wxCommandEvent& event)
|
|||||||
{
|
{
|
||||||
wxLogMessage("Thumbnail Toolbar Button %d is clicked.", event.GetId());
|
wxLogMessage("Thumbnail Toolbar Button %d is clicked.", event.GetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyFrame::OnShowProgressDialog(wxCommandEvent& WXUNUSED(event))
|
|
||||||
{
|
|
||||||
const int PROGRESS_COUNT = 100;
|
|
||||||
wxProgressDialog dlg(
|
|
||||||
"Progress in progress",
|
|
||||||
"Please wait, starting...",
|
|
||||||
PROGRESS_COUNT,
|
|
||||||
NULL,
|
|
||||||
wxPD_AUTO_HIDE
|
|
||||||
);
|
|
||||||
wxAppProgressIndicator indicator(this, PROGRESS_COUNT);
|
|
||||||
for ( int i = 0; i <= PROGRESS_COUNT; i++ )
|
|
||||||
{
|
|
||||||
if ( !dlg.Update(i) )
|
|
||||||
break;
|
|
||||||
indicator.Update(i);
|
|
||||||
wxMilliSleep(50);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyFrame::OnPulseProgressDialog(wxCommandEvent& WXUNUSED(event))
|
|
||||||
{
|
|
||||||
const int PROGRESS_COUNT = 100;
|
|
||||||
wxProgressDialog dlg(
|
|
||||||
"Progress in progress",
|
|
||||||
"Please wait, starting...",
|
|
||||||
PROGRESS_COUNT,
|
|
||||||
NULL,
|
|
||||||
wxPD_AUTO_HIDE
|
|
||||||
);
|
|
||||||
wxAppProgressIndicator indicator(this, PROGRESS_COUNT);
|
|
||||||
for ( int i = 0; i <= PROGRESS_COUNT; i++ )
|
|
||||||
{
|
|
||||||
if ( !dlg.Pulse() )
|
|
||||||
break;
|
|
||||||
indicator.Pulse();
|
|
||||||
wxMilliSleep(50);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -121,7 +121,8 @@ protected:
|
|||||||
|
|
||||||
// the checkboxes for styles
|
// the checkboxes for styles
|
||||||
wxCheckBox *m_chkVert,
|
wxCheckBox *m_chkVert,
|
||||||
*m_chkSmooth;
|
*m_chkSmooth,
|
||||||
|
*m_chkProgress;
|
||||||
|
|
||||||
// the gauge itself and the sizer it is in
|
// the gauge itself and the sizer it is in
|
||||||
wxGauge *m_gauge;
|
wxGauge *m_gauge;
|
||||||
@@ -186,7 +187,8 @@ GaugeWidgetsPage::GaugeWidgetsPage(WidgetsBookCtrl *book,
|
|||||||
m_timer = (wxTimer *)NULL;
|
m_timer = (wxTimer *)NULL;
|
||||||
|
|
||||||
m_chkVert =
|
m_chkVert =
|
||||||
m_chkSmooth = (wxCheckBox *)NULL;
|
m_chkSmooth =
|
||||||
|
m_chkProgress = (wxCheckBox *)NULL;
|
||||||
|
|
||||||
m_gauge = (wxGauge *)NULL;
|
m_gauge = (wxGauge *)NULL;
|
||||||
m_sizerGauge = (wxSizer *)NULL;
|
m_sizerGauge = (wxSizer *)NULL;
|
||||||
@@ -203,6 +205,7 @@ void GaugeWidgetsPage::CreateContent()
|
|||||||
|
|
||||||
m_chkVert = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("&Vertical"));
|
m_chkVert = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("&Vertical"));
|
||||||
m_chkSmooth = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("&Smooth"));
|
m_chkSmooth = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("&Smooth"));
|
||||||
|
m_chkProgress = CreateCheckBoxAndAddToSizer(sizerLeft, wxT("&Progress"));
|
||||||
|
|
||||||
sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
|
sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer
|
||||||
|
|
||||||
@@ -275,6 +278,7 @@ void GaugeWidgetsPage::Reset()
|
|||||||
{
|
{
|
||||||
m_chkVert->SetValue(false);
|
m_chkVert->SetValue(false);
|
||||||
m_chkSmooth->SetValue(false);
|
m_chkSmooth->SetValue(false);
|
||||||
|
m_chkProgress->SetValue(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GaugeWidgetsPage::CreateGauge()
|
void GaugeWidgetsPage::CreateGauge()
|
||||||
@@ -289,6 +293,11 @@ void GaugeWidgetsPage::CreateGauge()
|
|||||||
if ( m_chkSmooth->GetValue() )
|
if ( m_chkSmooth->GetValue() )
|
||||||
flags |= wxGA_SMOOTH;
|
flags |= wxGA_SMOOTH;
|
||||||
|
|
||||||
|
#if wxUSE_TASKBARBUTTON
|
||||||
|
if ( m_chkProgress->GetValue() )
|
||||||
|
flags |= wxGA_PROGRESS;
|
||||||
|
#endif
|
||||||
|
|
||||||
int val = 0;
|
int val = 0;
|
||||||
if ( m_gauge )
|
if ( m_gauge )
|
||||||
{
|
{
|
||||||
@@ -431,7 +440,8 @@ void GaugeWidgetsPage::OnUpdateUIRangeButton(wxUpdateUIEvent& event)
|
|||||||
|
|
||||||
void GaugeWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
|
void GaugeWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
|
||||||
{
|
{
|
||||||
event.Enable( m_chkVert->GetValue() || m_chkSmooth->GetValue() );
|
event.Enable( m_chkVert->GetValue() || m_chkSmooth->GetValue() ||
|
||||||
|
m_chkProgress->GetValue() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void GaugeWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
|
void GaugeWidgetsPage::OnCheckOrRadioBox(wxCommandEvent& WXUNUSED(event))
|
||||||
|
@@ -77,6 +77,9 @@ wxFLAGS_MEMBER(wxHSCROLL)
|
|||||||
wxFLAGS_MEMBER(wxGA_HORIZONTAL)
|
wxFLAGS_MEMBER(wxGA_HORIZONTAL)
|
||||||
wxFLAGS_MEMBER(wxGA_VERTICAL)
|
wxFLAGS_MEMBER(wxGA_VERTICAL)
|
||||||
wxFLAGS_MEMBER(wxGA_SMOOTH)
|
wxFLAGS_MEMBER(wxGA_SMOOTH)
|
||||||
|
#if wxUSE_TASKBARBUTTON
|
||||||
|
wxFLAGS_MEMBER(wxGA_PROGRESS)
|
||||||
|
#endif
|
||||||
wxEND_FLAGS( wxGaugeStyle )
|
wxEND_FLAGS( wxGaugeStyle )
|
||||||
|
|
||||||
wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxGauge, wxControl, "wx/gauge.h")
|
wxIMPLEMENT_DYNAMIC_CLASS_XTI(wxGauge, wxControl, "wx/gauge.h")
|
||||||
|
@@ -34,6 +34,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/msw/private.h"
|
#include "wx/msw/private.h"
|
||||||
|
#include "wx/taskbarbutton.h"
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// constants
|
// constants
|
||||||
@@ -91,14 +92,42 @@ bool wxGauge::Create(wxWindow *parent,
|
|||||||
if ( !MSWCreateControl(PROGRESS_CLASS, wxEmptyString, pos, size) )
|
if ( !MSWCreateControl(PROGRESS_CLASS, wxEmptyString, pos, size) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
SetRange(range);
|
|
||||||
|
|
||||||
// in case we need to emulate indeterminate mode...
|
// in case we need to emulate indeterminate mode...
|
||||||
m_nDirection = wxRIGHT;
|
m_nDirection = wxRIGHT;
|
||||||
|
|
||||||
|
#if wxUSE_TASKBARBUTTON
|
||||||
|
m_appProgressIndicator = NULL;
|
||||||
|
if ( (style & wxGA_PROGRESS) != 0 )
|
||||||
|
{
|
||||||
|
wxWindow* topParent = GetParent();
|
||||||
|
while (topParent != NULL && topParent->GetParent() != NULL)
|
||||||
|
{
|
||||||
|
topParent = topParent->GetParent();
|
||||||
|
}
|
||||||
|
if ( topParent != NULL )
|
||||||
|
{
|
||||||
|
m_appProgressIndicator =
|
||||||
|
new wxAppProgressIndicator(topParent->GetHandle(), range);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SetRange(range);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_TASKBARBUTTON
|
||||||
|
wxGauge::~wxGauge()
|
||||||
|
{
|
||||||
|
if ( m_appProgressIndicator )
|
||||||
|
{
|
||||||
|
delete m_appProgressIndicator;
|
||||||
|
m_appProgressIndicator = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
WXDWORD wxGauge::MSWGetStyle(long style, WXDWORD *exstyle) const
|
WXDWORD wxGauge::MSWGetStyle(long style, WXDWORD *exstyle) const
|
||||||
{
|
{
|
||||||
WXDWORD msStyle = wxControl::MSWGetStyle(style, exstyle);
|
WXDWORD msStyle = wxControl::MSWGetStyle(style, exstyle);
|
||||||
@@ -146,6 +175,11 @@ void wxGauge::SetRange(int r)
|
|||||||
// fall back to PBM_SETRANGE (limited to 16 bits)
|
// fall back to PBM_SETRANGE (limited to 16 bits)
|
||||||
::SendMessage(GetHwnd(), PBM_SETRANGE, 0, MAKELPARAM(0, r));
|
::SendMessage(GetHwnd(), PBM_SETRANGE, 0, MAKELPARAM(0, r));
|
||||||
#endif // PBM_SETRANGE32/!PBM_SETRANGE32
|
#endif // PBM_SETRANGE32/!PBM_SETRANGE32
|
||||||
|
|
||||||
|
#if wxUSE_TASKBARBUTTON
|
||||||
|
if ( m_appProgressIndicator )
|
||||||
|
m_appProgressIndicator->SetRange(m_rangeMax);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxGauge::SetValue(int pos)
|
void wxGauge::SetValue(int pos)
|
||||||
@@ -159,6 +193,17 @@ void wxGauge::SetValue(int pos)
|
|||||||
m_gaugePos = pos;
|
m_gaugePos = pos;
|
||||||
|
|
||||||
::SendMessage(GetHwnd(), PBM_SETPOS, pos, 0);
|
::SendMessage(GetHwnd(), PBM_SETPOS, pos, 0);
|
||||||
|
|
||||||
|
#if wxUSE_TASKBARBUTTON
|
||||||
|
if ( m_appProgressIndicator )
|
||||||
|
{
|
||||||
|
m_appProgressIndicator->SetValue(pos);
|
||||||
|
if ( pos == 0 )
|
||||||
|
{
|
||||||
|
m_appProgressIndicator->Reset();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,6 +267,11 @@ void wxGauge::Pulse()
|
|||||||
// emulate indeterminate mode
|
// emulate indeterminate mode
|
||||||
wxGaugeBase::Pulse();
|
wxGaugeBase::Pulse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxUSE_TASKBARBUTTON
|
||||||
|
if ( m_appProgressIndicator )
|
||||||
|
m_appProgressIndicator->Pulse();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // wxUSE_GAUGE
|
#endif // wxUSE_GAUGE
|
||||||
|
@@ -910,45 +910,42 @@ wxThumbBarButton* wxTaskBarButtonImpl::GetThumbBarButtonByIndex(size_t index)
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxAppProgressIndicator Implementation.
|
// wxAppProgressIndicator Implementation.
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
wxAppProgressIndicator::wxAppProgressIndicator(wxTopLevelWindow *parent,
|
wxAppProgressIndicator::wxAppProgressIndicator(WXWidget parent, int maxValue)
|
||||||
int maxValue)
|
|
||||||
: m_parent(parent),
|
: m_parent(parent),
|
||||||
m_maxValue(maxValue)
|
m_maxValue(maxValue)
|
||||||
{
|
{
|
||||||
|
m_taskBarButton = new wxTaskBarButtonImpl(m_parent);
|
||||||
|
Reset();
|
||||||
|
SetRange(m_maxValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxAppProgressIndicator::~wxAppProgressIndicator()
|
wxAppProgressIndicator::~wxAppProgressIndicator()
|
||||||
{
|
{
|
||||||
m_taskBarButton->SetProgressState(wxTASKBAR_BUTTON_NO_PROGRESS);
|
m_taskBarButton->SetProgressState(wxTASKBAR_BUTTON_NO_PROGRESS);
|
||||||
|
delete m_taskBarButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxAppProgressIndicator::Update(int value)
|
void wxAppProgressIndicator::SetValue(int value)
|
||||||
{
|
{
|
||||||
wxASSERT_MSG( value <= m_maxValue, wxT("invalid progress value") );
|
wxASSERT_MSG( value <= m_maxValue, wxT("invalid progress value") );
|
||||||
Init();
|
|
||||||
|
|
||||||
m_taskBarButton->SetProgressValue(value);
|
m_taskBarButton->SetProgressValue(value);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxAppProgressIndicator::Pulse()
|
void wxAppProgressIndicator::SetRange(int range)
|
||||||
|
{
|
||||||
|
m_maxValue = range;
|
||||||
|
m_taskBarButton->SetProgressRange(range);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxAppProgressIndicator::Pulse()
|
||||||
{
|
{
|
||||||
Init();
|
|
||||||
m_taskBarButton->PulseProgress();
|
m_taskBarButton->PulseProgress();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxAppProgressIndicator::Init()
|
void wxAppProgressIndicator::Reset()
|
||||||
{
|
{
|
||||||
if ( m_taskBarButton.get() == NULL )
|
m_taskBarButton->SetProgressState(wxTASKBAR_BUTTON_NO_PROGRESS);
|
||||||
{
|
|
||||||
// Sleep 100 milliseconds to wait for creation of taskbar button.
|
|
||||||
// TODO(zhchbin): Do not use sleep since it will block the UI thread.
|
|
||||||
// Currently it is used to make sure the API works correctlly.
|
|
||||||
wxMilliSleep(100);
|
|
||||||
m_taskBarButton.reset(new wxTaskBarButtonImpl(m_parent->GetHandle()));
|
|
||||||
m_taskBarButton->SetProgressRange(m_maxValue);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user