From e69414297525569bdc487fda25773a1e66d8802e Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Wed, 3 Nov 2004 21:06:12 +0000 Subject: [PATCH] *** empty log message *** svn path=/trunk/boinc/; revision=4482 --- clientgui/BOINCTaskBar.cpp | 73 ++++++++++++++++++++++++++----------- clientgui/BOINCTaskBar.h | 8 +++- clientgui/msw/taskbarex.cpp | 38 ++++++++----------- 3 files changed, 74 insertions(+), 45 deletions(-) diff --git a/clientgui/BOINCTaskBar.cpp b/clientgui/BOINCTaskBar.cpp index 6ea754f0e0..10f3b7b56b 100644 --- a/clientgui/BOINCTaskBar.cpp +++ b/clientgui/BOINCTaskBar.cpp @@ -44,8 +44,13 @@ BEGIN_EVENT_TABLE (CTaskBarIcon, wxTaskBarIconEx) EVT_MENU(wxID_EXIT, CTaskBarIcon::OnExit) EVT_CLOSE(CTaskBarIcon::OnClose) EVT_TASKBAR_MOVE(CTaskBarIcon::OnMouseMove) - EVT_TASKBAR_RIGHT_DOWN(CTaskBarIcon::OnRButtonDown) EVT_TASKBAR_LEFT_DCLICK(CTaskBarIcon::OnLButtonDClick) + +#ifdef __WXMSW__ + EVT_TASKBAR_CONTEXT_MENU(CTaskBarIcon::OnContextMenu) +#else + EVT_TASKBAR_RIGHT_DOWN(CTaskBarIcon::OnRButtonDown) +#endif END_EVENT_TABLE () @@ -212,7 +217,53 @@ void CTaskBarIcon::OnMouseMove( wxTaskBarIconEvent& event ) } +void CTaskBarIcon::OnLButtonDClick( wxTaskBarIconEvent& event ) +{ + ResetTaskBar(); + + CMainFrame* pFrame = wxGetApp().GetFrame(); + wxASSERT(NULL != pFrame); + wxASSERT(wxDynamicCast(pFrame, CMainFrame)); + + if ( NULL != pFrame ) + pFrame->Show(); +} + + +#ifdef __WXMSW__ + + +void CTaskBarIcon::OnContextMenu( wxTaskBarIconExEvent& event ) +{ + CreateContextMenu(); +} + + +#else + + void CTaskBarIcon::OnRButtonDown( wxTaskBarIconEvent& event ) +{ + CreateContextMenu(); +} + + +#endif + + +void CTaskBarIcon::ResetTaskBar() +{ +#ifdef __WXMSW___ + SetBalloon( iconTaskBarIcon, wxT(""), wxT("") ); +#else + SetIcon( iconTaskBarIcon, wxT("") ); +#endif + + dtLastMouseCaptureTime = wxDateTime::Now(); +} + + +void CTaskBarIcon::CreateContextMenu() { ResetTaskBar(); @@ -277,23 +328,3 @@ void CTaskBarIcon::OnRButtonDown( wxTaskBarIconEvent& event ) delete menu; } - -void CTaskBarIcon::OnLButtonDClick( wxTaskBarIconEvent& event ) -{ - ResetTaskBar(); - - CMainFrame* pFrame = wxGetApp().GetFrame(); - wxASSERT(NULL != pFrame); - wxASSERT(wxDynamicCast(pFrame, CMainFrame)); - - if ( NULL != pFrame ) - pFrame->Show(); -} - - -void CTaskBarIcon::ResetTaskBar() -{ - SetBalloon( iconTaskBarIcon, wxT(""), wxT("") ); - dtLastMouseCaptureTime = wxDateTime::Now(); -} - diff --git a/clientgui/BOINCTaskBar.h b/clientgui/BOINCTaskBar.h index 8f7546e5e1..45343e22b8 100644 --- a/clientgui/BOINCTaskBar.h +++ b/clientgui/BOINCTaskBar.h @@ -52,15 +52,21 @@ public: void OnClose( wxCloseEvent& event ); void OnMouseMove( wxTaskBarIconEvent& event ); - void OnRButtonDown( wxTaskBarIconEvent& event ); void OnLButtonDClick( wxTaskBarIconEvent& event ); +#ifdef __WXMSW__ + void OnContextMenu( wxTaskBarIconExEvent& event ); +#else + void OnRButtonDown( wxTaskBarIconEvent& event ); +#endif + private: wxIcon iconTaskBarIcon; wxDateTime dtLastMouseCaptureTime; void ResetTaskBar(); + void CreateContextMenu(); DECLARE_EVENT_TABLE() diff --git a/clientgui/msw/taskbarex.cpp b/clientgui/msw/taskbarex.cpp index 01186cf7d3..6948400a7f 100644 --- a/clientgui/msw/taskbarex.cpp +++ b/clientgui/msw/taskbarex.cpp @@ -47,18 +47,6 @@ wxTaskBarIconEx::wxTaskBarIconEx(void) if (RegisterWindowClass()) m_hWnd = CreateTaskBarWindow(); - - - NOTIFYICONDATA notifyData; - - memset(¬ifyData, 0, sizeof(notifyData)); - notifyData.cbSize = sizeof(notifyData); - notifyData.hWnd = (HWND) m_hWnd; - notifyData.uID = 99; - notifyData.uCallbackMessage = sm_taskbarMsg; - notifyData.uVersion = 0x0500; - - Shell_NotifyIcon(NIM_SETVERSION, ¬ifyData); } wxTaskBarIconEx::~wxTaskBarIconEx(void) @@ -86,10 +74,12 @@ bool wxTaskBarIconEx::SetIcon(const wxIcon& icon, const wxString& tooltip) NOTIFYICONDATA notifyData; memset(¬ifyData, 0, sizeof(notifyData)); - notifyData.cbSize = sizeof(notifyData); - notifyData.hWnd = (HWND) m_hWnd; + notifyData.cbSize = sizeof(notifyData); + notifyData.hWnd = (HWND) m_hWnd; + notifyData.uID = 99; notifyData.uCallbackMessage = sm_taskbarMsg; - notifyData.uFlags = NIF_MESSAGE ; + notifyData.uFlags = NIF_MESSAGE; + notifyData.uVersion = NOTIFYICON_VERSION; if (icon.Ok()) { @@ -103,13 +93,13 @@ bool wxTaskBarIconEx::SetIcon(const wxIcon& icon, const wxString& tooltip) lstrcpyn(notifyData.szTip, WXSTRINGCAST tooltip, sizeof(notifyData.szTip)); } - notifyData.uID = 99; if (m_iconAdded) - return (Shell_NotifyIcon(NIM_MODIFY, & notifyData) != 0); + return (Shell_NotifyIcon(NIM_MODIFY, ¬ifyData) != 0); else { - m_iconAdded = (Shell_NotifyIcon(NIM_ADD, & notifyData) != 0); + m_iconAdded = (Shell_NotifyIcon(NIM_ADD, ¬ifyData) != 0); + Shell_NotifyIcon(NIM_SETVERSION, ¬ifyData); return m_iconAdded; } } @@ -129,6 +119,7 @@ bool wxTaskBarIconEx::SetBalloon(const wxIcon& icon, const wxString title, const notifyData.uFlags = NIF_MESSAGE | NIF_INFO; notifyData.dwInfoFlags = iconballoon | NIIF_NOSOUND; notifyData.uTimeout = timeout; + notifyData.uVersion = NOTIFYICON_VERSION; lstrcpyn(notifyData.szInfo, WXSTRINGCAST message, sizeof(notifyData.szInfo)); lstrcpyn(notifyData.szInfoTitle, WXSTRINGCAST title, sizeof(notifyData.szInfoTitle)); @@ -143,6 +134,7 @@ bool wxTaskBarIconEx::SetBalloon(const wxIcon& icon, const wxString title, const else { m_iconAdded = (Shell_NotifyIcon(NIM_ADD, & notifyData) != 0); + Shell_NotifyIcon(NIM_SETVERSION, ¬ifyData); return m_iconAdded; } } @@ -155,11 +147,11 @@ bool wxTaskBarIconEx::RemoveIcon(void) NOTIFYICONDATA notifyData; memset(¬ifyData, 0, sizeof(notifyData)); - notifyData.cbSize = sizeof(notifyData); - notifyData.hWnd = (HWND) m_hWnd; - notifyData.uCallbackMessage = sm_taskbarMsg; - notifyData.uFlags = NIF_MESSAGE; - notifyData.hIcon = 0 ; // hIcon; + notifyData.cbSize = sizeof(notifyData); + notifyData.hWnd = (HWND) m_hWnd; + notifyData.uCallbackMessage = sm_taskbarMsg; + notifyData.uFlags = NIF_MESSAGE; + notifyData.hIcon = 0 ; // hIcon; notifyData.uID = 99; m_iconAdded = FALSE;