Revise progress releted API to be more usual.
- Add PulseProgress - Add SetProgressRange, instead of hard coding 100. Author: Chaobin Zhang git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77581 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
95c8ad1012
commit
2525b1988e
@ -21,7 +21,9 @@ class wxTaskBarButtonImpl : public wxTaskBarButton {
|
||||
public:
|
||||
virtual ~wxTaskBarButtonImpl();
|
||||
|
||||
virtual void SetProgressRange(int range) wxOVERRIDE;
|
||||
virtual void SetProgressValue(int value) wxOVERRIDE;
|
||||
virtual void PulseProgress() wxOVERRIDE;
|
||||
virtual void Show(bool show = true) wxOVERRIDE;
|
||||
virtual void Hide() wxOVERRIDE;
|
||||
virtual void SetThumbnailTooltip(const wxString& tooltip) wxOVERRIDE;
|
||||
@ -43,6 +45,8 @@ private:
|
||||
typedef wxVector<wxThumbBarButton*> wxThumbBarButtons;
|
||||
wxThumbBarButtons m_thumbBarButtons;
|
||||
|
||||
int m_progressRange;
|
||||
|
||||
bool m_hasShownThumbnailToolbar;
|
||||
};
|
||||
|
||||
|
@ -54,7 +54,9 @@ public:
|
||||
virtual ~wxTaskBarButton() { }
|
||||
|
||||
// Operations:
|
||||
virtual void SetProgressRange(int range) = 0;
|
||||
virtual void SetProgressValue(int value) = 0;
|
||||
virtual void PulseProgress() = 0;
|
||||
virtual void Show(bool show = true) = 0;
|
||||
virtual void Hide() = 0;
|
||||
virtual void SetThumbnailTooltip(const wxString& tooltip) = 0;
|
||||
|
@ -262,6 +262,13 @@ wxEND_EVENT_TABLE()
|
||||
|
||||
void MyFrame::OnSetProgressValue(wxScrollEvent& WXUNUSED(event))
|
||||
{
|
||||
static bool s_hasRangeSet = false;
|
||||
if ( !s_hasRangeSet )
|
||||
{
|
||||
MSWGetTaskBarButton()->SetProgressRange(100);
|
||||
s_hasRangeSet = true;
|
||||
}
|
||||
|
||||
MSWGetTaskBarButton()->SetProgressValue(m_slider->GetValue());
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,10 @@ wxThumbBarButton::wxThumbBarButton(int id,
|
||||
}
|
||||
|
||||
wxTaskBarButtonImpl::wxTaskBarButtonImpl(WXWidget parent)
|
||||
: m_hwnd(parent), m_taskbarList(NULL), m_hasShownThumbnailToolbar(false)
|
||||
: m_hwnd(parent),
|
||||
m_taskbarList(NULL),
|
||||
m_progressRange(0),
|
||||
m_hasShownThumbnailToolbar(false)
|
||||
{
|
||||
HRESULT hr = CoCreateInstance
|
||||
(
|
||||
@ -68,12 +71,21 @@ wxTaskBarButtonImpl::~wxTaskBarButtonImpl()
|
||||
m_thumbBarButtons.clear();
|
||||
}
|
||||
|
||||
void wxTaskBarButtonImpl::SetProgressRange(int range)
|
||||
{
|
||||
m_progressRange = range;
|
||||
if ( m_progressRange == 0 )
|
||||
SetProgressState(wxTASKBAR_BUTTON_NO_PROGRESS);
|
||||
}
|
||||
|
||||
void wxTaskBarButtonImpl::SetProgressValue(int value)
|
||||
{
|
||||
wxCHECK_RET( value >= 0 && value <= 100,
|
||||
wxT("Invalid value, must be in the range of [0, 100].") );
|
||||
m_taskbarList->SetProgressValue(m_hwnd, value, m_progressRange);
|
||||
}
|
||||
|
||||
m_taskbarList->SetProgressValue(m_hwnd, value, 100);
|
||||
void wxTaskBarButtonImpl::PulseProgress()
|
||||
{
|
||||
SetProgressState(wxTASKBAR_BUTTON_INDETERMINATE);
|
||||
}
|
||||
|
||||
void wxTaskBarButtonImpl::Show(bool show)
|
||||
|
Loading…
Reference in New Issue
Block a user