Move wxAppProgressIndicator into its own header.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77641 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Bryan Petty
2014-09-10 14:58:12 +00:00
parent 30bfbd3fe0
commit db13dbc1f6
8 changed files with 187 additions and 77 deletions

102
src/msw/appprog.cpp Normal file
View File

@@ -0,0 +1,102 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/msw/appprog.cpp
// Purpose: Implementation of wxAppProgressIndicator.
// Author: Chaobin Zhang <zhchbin@gmail.com>
// Created: 2014-09-05
// Copyright: (c) 2014 wxWidgets development team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/toplevel.h"
#endif
#include "wx/appprog.h"
#include "wx/msw/taskbarbutton.h"
// ----------------------------------------------------------------------------
// wxAppProgressIndicator Implementation.
// ----------------------------------------------------------------------------
wxAppProgressIndicator::wxAppProgressIndicator(wxWindow* parent, int maxValue)
: m_maxValue(maxValue)
{
#if wxUSE_TASKBARBUTTON
if ( parent == NULL )
{
for ( wxWindowList::const_iterator it = wxTopLevelWindows.begin();
it != wxTopLevelWindows.end();
++it )
{
m_taskBarButtons.push_back(new wxTaskBarButtonImpl(*it));
}
}
else
{
m_taskBarButtons.push_back(new wxTaskBarButtonImpl(parent));
}
Reset();
SetRange(m_maxValue);
#endif // wxUSE_TASKBARBUTTON
}
wxAppProgressIndicator::~wxAppProgressIndicator()
{
#if wxUSE_TASKBARBUTTON
Reset();
for ( size_t i = 0; i < m_taskBarButtons.size(); ++i )
{
delete m_taskBarButtons[i];
}
#endif // wxUSE_TASKBARBUTTON
}
void wxAppProgressIndicator::SetValue(int value)
{
wxASSERT_MSG( value <= m_maxValue, wxT("invalid progress value") );
#if wxUSE_TASKBARBUTTON
for ( size_t i = 0; i < m_taskBarButtons.size(); ++i )
{
m_taskBarButtons[i]->SetProgressValue(value);
}
#endif // wxUSE_TASKBARBUTTON
}
void wxAppProgressIndicator::SetRange(int range)
{
m_maxValue = range;
#if wxUSE_TASKBARBUTTON
for ( size_t i = 0; i < m_taskBarButtons.size(); ++i )
{
m_taskBarButtons[i]->SetProgressRange(range);
}
#endif // wxUSE_TASKBARBUTTON
}
void wxAppProgressIndicator::Pulse()
{
#if wxUSE_TASKBARBUTTON
for ( size_t i = 0; i < m_taskBarButtons.size(); ++i )
{
m_taskBarButtons[i]->PulseProgress();
}
#endif // wxUSE_TASKBARBUTTON
}
void wxAppProgressIndicator::Reset()
{
#if wxUSE_TASKBARBUTTON
for ( size_t i = 0; i < m_taskBarButtons.size(); ++i )
{
m_taskBarButtons[i]->SetProgressState(wxTASKBAR_BUTTON_NO_PROGRESS);
}
#endif // wxUSE_TASKBARBUTTON
}

View File

@@ -33,8 +33,8 @@
#include "wx/msw/wrapcctl.h" // include <commctrl.h> "properly"
#endif
#include "wx/appprog.h"
#include "wx/msw/private.h"
#include "wx/taskbarbutton.h"
// ----------------------------------------------------------------------------
// constants
@@ -95,7 +95,6 @@ bool wxGauge::Create(wxWindow *parent,
// in case we need to emulate indeterminate mode...
m_nDirection = wxRIGHT;
#if wxUSE_TASKBARBUTTON
m_appProgressIndicator = NULL;
if ( (style & wxGA_PROGRESS) != 0 )
{
@@ -106,7 +105,6 @@ bool wxGauge::Create(wxWindow *parent,
new wxAppProgressIndicator(topParent, range);
}
}
#endif
SetRange(range);
@@ -115,9 +113,7 @@ bool wxGauge::Create(wxWindow *parent,
wxGauge::~wxGauge()
{
#if wxUSE_TASKBARBUTTON
delete m_appProgressIndicator;
#endif
}
WXDWORD wxGauge::MSWGetStyle(long style, WXDWORD *exstyle) const
@@ -168,10 +164,8 @@ void wxGauge::SetRange(int r)
::SendMessage(GetHwnd(), PBM_SETRANGE, 0, MAKELPARAM(0, r));
#endif // PBM_SETRANGE32/!PBM_SETRANGE32
#if wxUSE_TASKBARBUTTON
if ( m_appProgressIndicator )
m_appProgressIndicator->SetRange(m_rangeMax);
#endif
}
void wxGauge::SetValue(int pos)
@@ -186,7 +180,6 @@ void wxGauge::SetValue(int pos)
::SendMessage(GetHwnd(), PBM_SETPOS, pos, 0);
#if wxUSE_TASKBARBUTTON
if ( m_appProgressIndicator )
{
m_appProgressIndicator->SetValue(pos);
@@ -195,7 +188,6 @@ void wxGauge::SetValue(int pos)
m_appProgressIndicator->Reset();
}
}
#endif
}
}
@@ -260,10 +252,8 @@ void wxGauge::Pulse()
wxGaugeBase::Pulse();
}
#if wxUSE_TASKBARBUTTON
if ( m_appProgressIndicator )
m_appProgressIndicator->Pulse();
#endif
if ( m_appProgressIndicator )
m_appProgressIndicator->Pulse();
}
#endif // wxUSE_GAUGE

View File

@@ -938,46 +938,6 @@ wxThumbBarButton* wxTaskBarButtonImpl::GetThumbBarButtonByIndex(size_t index)
return m_thumbBarButtons[index];
}
// ----------------------------------------------------------------------------
// wxAppProgressIndicator Implementation.
// ----------------------------------------------------------------------------
wxAppProgressIndicator::wxAppProgressIndicator(wxWindow* parent, int maxValue)
: m_maxValue(maxValue),
m_taskBarButton(new wxTaskBarButtonImpl(parent))
{
Reset();
SetRange(m_maxValue);
}
wxAppProgressIndicator::~wxAppProgressIndicator()
{
m_taskBarButton->SetProgressState(wxTASKBAR_BUTTON_NO_PROGRESS);
delete m_taskBarButton;
}
void wxAppProgressIndicator::SetValue(int value)
{
wxASSERT_MSG( value <= m_maxValue, wxT("invalid progress value") );
m_taskBarButton->SetProgressValue(value);
}
void wxAppProgressIndicator::SetRange(int range)
{
m_maxValue = range;
m_taskBarButton->SetProgressRange(range);
}
void wxAppProgressIndicator::Pulse()
{
m_taskBarButton->PulseProgress();
}
void wxAppProgressIndicator::Reset()
{
m_taskBarButton->SetProgressState(wxTASKBAR_BUTTON_NO_PROGRESS);
}
// ----------------------------------------------------------------------------
// wxTaskBarJumpListItem Implementation.
// ----------------------------------------------------------------------------