*** empty log message ***

svn path=/trunk/boinc/; revision=4482
This commit is contained in:
Rom Walton 2004-11-03 21:06:12 +00:00
parent cd24ad3c4f
commit e694142975
3 changed files with 74 additions and 45 deletions

View File

@ -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();
}

View File

@ -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()

View File

@ -47,18 +47,6 @@ wxTaskBarIconEx::wxTaskBarIconEx(void)
if (RegisterWindowClass())
m_hWnd = CreateTaskBarWindow();
NOTIFYICONDATA notifyData;
memset(&notifyData, 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, &notifyData);
}
wxTaskBarIconEx::~wxTaskBarIconEx(void)
@ -86,10 +74,12 @@ bool wxTaskBarIconEx::SetIcon(const wxIcon& icon, const wxString& tooltip)
NOTIFYICONDATA notifyData;
memset(&notifyData, 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, &notifyData) != 0);
else
{
m_iconAdded = (Shell_NotifyIcon(NIM_ADD, & notifyData) != 0);
m_iconAdded = (Shell_NotifyIcon(NIM_ADD, &notifyData) != 0);
Shell_NotifyIcon(NIM_SETVERSION, &notifyData);
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, &notifyData);
return m_iconAdded;
}
}
@ -155,11 +147,11 @@ bool wxTaskBarIconEx::RemoveIcon(void)
NOTIFYICONDATA notifyData;
memset(&notifyData, 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;