summaryrefslogtreecommitdiff
path: root/shared/taskbar.cpp
diff options
context:
space:
mode:
authorDaniel Wilhelm <daniel@wili.li>2014-04-18 17:08:42 +0200
committerDaniel Wilhelm <daniel@wili.li>2014-04-18 17:08:42 +0200
commitc32707148292d104c66276b43796d6057c8c7a5d (patch)
treebb83513f4aff24153e21a4ec92e34e4c27651b1f /shared/taskbar.cpp
parent3.9 (diff)
downloadFreeFileSync-c32707148292d104c66276b43796d6057c8c7a5d.tar.gz
FreeFileSync-c32707148292d104c66276b43796d6057c8c7a5d.tar.bz2
FreeFileSync-c32707148292d104c66276b43796d6057c8c7a5d.zip
3.10
Diffstat (limited to 'shared/taskbar.cpp')
-rw-r--r--shared/taskbar.cpp125
1 files changed, 58 insertions, 67 deletions
diff --git a/shared/taskbar.cpp b/shared/taskbar.cpp
index 61a1841b..f5f07c1e 100644
--- a/shared/taskbar.cpp
+++ b/shared/taskbar.cpp
@@ -12,17 +12,17 @@
#include <wx/msw/wrapwin.h> //includes "windows.h"
using namespace util;
+using namespace tbseven;
namespace
{
bool windows7TaskbarAvailable()
{
- OSVERSIONINFO osvi;
- ZeroMemory(&osvi, sizeof(OSVERSIONINFO));
+ OSVERSIONINFO osvi = {};
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
- if (GetVersionEx(&osvi))
+ if (::GetVersionEx(&osvi))
return osvi.dwMajorVersion > 6 ||
(osvi.dwMajorVersion == 6 && osvi.dwMinorVersion >= 1); //task bar progress available with Windows 7
//XP has majorVersion == 5, minorVersion == 1
@@ -45,86 +45,77 @@ const std::wstring& getTaskBarDllName()
return filename;
}
}
+//########################################################################################################
-struct TaskbarProgress::Pimpl
+class TaskbarProgress::Pimpl //throw (TaskbarNotAvailable)
{
- Pimpl() : tbHandle(0),
- assocWindow(NULL),
- init_(NULL),
- release_(NULL),
- setStatus_(NULL),
- setProgress_(NULL) {}
-
- TaskbarSeven::TBHandle tbHandle;
- void* assocWindow;
-
- TaskbarSeven::initFct init_;
- TaskbarSeven::releaseFct release_;
- TaskbarSeven::setStatusFct setStatus_;
- TaskbarSeven::setProgressFct setProgress_;
-};
-
-
-TaskbarProgress::TaskbarProgress(const wxTopLevelWindow& window) : pimpl_(new Pimpl)
-{
- if (!windows7TaskbarAvailable())
- throw TaskbarNotAvailable();
+public:
+ Pimpl(const wxTopLevelWindow& window) :
+ assocWindow(window.GetHWND()),
+ setStatus_(util::getDllFun<SetStatusFct>( getTaskBarDllName(), setStatusFctName)),
+ setProgress_(util::getDllFun<SetProgressFct>(getTaskBarDllName(), setProgressFctName))
+ {
+ if (!assocWindow || !setProgress_ || !setStatus_)
+ throw TaskbarNotAvailable();
- pimpl_->init_ = util::loadDllFunction<TaskbarSeven::initFct>( getTaskBarDllName(), TaskbarSeven::initFctName);
- pimpl_->release_ = util::loadDllFunction<TaskbarSeven::releaseFct>( getTaskBarDllName(), TaskbarSeven::releaseFctName);
- pimpl_->setProgress_ = util::loadDllFunction<TaskbarSeven::setProgressFct>(getTaskBarDllName(), TaskbarSeven::setProgressFctName);
- pimpl_->setStatus_ = util::loadDllFunction<TaskbarSeven::setStatusFct>( getTaskBarDllName(), TaskbarSeven::setStatusFctName);
+ if (!windows7TaskbarAvailable())
+ throw TaskbarNotAvailable();
+ }
- if ( !pimpl_->init_ ||
- !pimpl_->release_ ||
- !pimpl_->setProgress_ ||
- !pimpl_->setStatus_)
- throw TaskbarNotAvailable();
+ ~Pimpl()
+ {
+ setStatus(STATUS_NOPROGRESS);
+ }
- pimpl_->tbHandle = pimpl_->init_();
- if (pimpl_->tbHandle == 0)
- throw TaskbarNotAvailable();
+ void setStatus(Status status)
+ {
+ TaskBarStatus tbSevenStatus = tbseven::STATUS_NORMAL;
+ switch (status)
+ {
+ case TaskbarProgress::STATUS_NOPROGRESS:
+ tbSevenStatus = tbseven::STATUS_NOPROGRESS;
+ break;
+ case TaskbarProgress::STATUS_INDETERMINATE:
+ tbSevenStatus = tbseven::STATUS_INDETERMINATE;
+ break;
+ case TaskbarProgress::STATUS_NORMAL:
+ tbSevenStatus = tbseven::STATUS_NORMAL;
+ break;
+ case TaskbarProgress::STATUS_ERROR:
+ tbSevenStatus = tbseven::STATUS_ERROR;
+ break;
+ case TaskbarProgress::STATUS_PAUSED:
+ tbSevenStatus = tbseven::STATUS_PAUSED;
+ break;
+ }
+
+ setStatus_(assocWindow, tbSevenStatus);
+ }
- pimpl_->assocWindow = window.GetHWND();
-}
+ void setProgress(size_t current, size_t total)
+ {
+ setProgress_(assocWindow, current, total);
+ }
+private:
+ void* assocWindow;
+ const SetStatusFct setStatus_;
+ const SetProgressFct setProgress_;
+};
+//########################################################################################################
-TaskbarProgress::~TaskbarProgress()
-{
- setStatus(STATUS_NOPROGRESS);
- pimpl_->release_(pimpl_->tbHandle);
-}
+TaskbarProgress::TaskbarProgress(const wxTopLevelWindow& window) : pimpl_(new Pimpl(window)) {}
+TaskbarProgress::~TaskbarProgress() {} //std::auto_ptr ...
void TaskbarProgress::setStatus(Status status)
{
- TaskbarSeven::TaskBarStatus tbSevenStatus = TaskbarSeven::STATUS_NORMAL;
- switch (status)
- {
- case TaskbarProgress::STATUS_NOPROGRESS:
- tbSevenStatus = TaskbarSeven::STATUS_NOPROGRESS;
- break;
- case TaskbarProgress::STATUS_INDETERMINATE:
- tbSevenStatus = TaskbarSeven::STATUS_INDETERMINATE;
- break;
- case TaskbarProgress::STATUS_NORMAL:
- tbSevenStatus = TaskbarSeven::STATUS_NORMAL;
- break;
- case TaskbarProgress::STATUS_ERROR:
- tbSevenStatus = TaskbarSeven::STATUS_ERROR;
- break;
- case TaskbarProgress::STATUS_PAUSED:
- tbSevenStatus = TaskbarSeven::STATUS_PAUSED;
- break;
- }
-
- pimpl_->setStatus_(pimpl_->tbHandle, pimpl_->assocWindow, tbSevenStatus);
+ pimpl_->setStatus(status);
}
-
void TaskbarProgress::setProgress(size_t current, size_t total)
{
- pimpl_->setProgress_(pimpl_->tbHandle, pimpl_->assocWindow, current, total);
+ pimpl_->setProgress(current, total);
}
bgstack15