mirror of https://github.com/BOINC/boinc.git
*** empty log message ***
svn path=/trunk/boinc/; revision=4472
This commit is contained in:
parent
a326d68c33
commit
c66aaf9c50
|
@ -153,6 +153,9 @@
|
|||
<File
|
||||
RelativePath=".\BOINCListCtrl.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\BOINCTaskBar.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\BOINCTaskCtrl.cpp">
|
||||
</File>
|
||||
|
@ -305,7 +308,7 @@
|
|||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\TaskBarIcon.cpp">
|
||||
RelativePath=".\msw\taskbarex.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\lib\util.C">
|
||||
|
@ -371,6 +374,9 @@
|
|||
<File
|
||||
RelativePath=".\BOINCListCtrl.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\BOINCTaskBar.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\BOINCTaskCtrl.h">
|
||||
</File>
|
||||
|
@ -420,7 +426,7 @@
|
|||
RelativePath=".\stdwx.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\TaskBarIcon.h">
|
||||
RelativePath=".\msw\taskbarex.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\lib\util.h">
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "MainFrame.h"
|
||||
#include "MainDocument.h"
|
||||
#ifndef NOTASKBAR
|
||||
#include "TaskBarIcon.h"
|
||||
#include "BOINCTaskBar.h"
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
@ -22,12 +22,12 @@
|
|||
//
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma implementation "TaskBarIcon.h"
|
||||
#pragma implementation "BOINCTaskBar.h"
|
||||
#endif
|
||||
|
||||
#include "stdwx.h"
|
||||
#include "BOINCGUIApp.h"
|
||||
#include "TaskBarIcon.h"
|
||||
#include "BOINCTaskBar.h"
|
||||
#include "DlgAbout.h"
|
||||
#include "Events.h"
|
||||
|
|
@ -21,11 +21,11 @@
|
|||
// Revision History:
|
||||
//
|
||||
|
||||
#ifndef _TASKBARICON_H_
|
||||
#define _TASKBARICON_H_
|
||||
#ifndef _BOINCTASKBAR_H_
|
||||
#define _BOINCTASKBAR_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "TaskBarIcon.cpp"
|
||||
#pragma interface "BOINCTaskBar.cpp"
|
||||
#endif
|
||||
|
||||
|
|
@ -0,0 +1,341 @@
|
|||
/////////////////////////////////////////////////////////////////////////
|
||||
// File: taskbar.cpp
|
||||
// Purpose: Implements wxTaskBarIconEx class for manipulating icons on
|
||||
// the Windows task bar.
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 24/3/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c)
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "taskbarex.h"
|
||||
#endif
|
||||
|
||||
#include "stdwx.h"
|
||||
#include "msw/taskbarex.h"
|
||||
|
||||
LRESULT APIENTRY wxTaskBarIconExWindowProc( HWND hWnd, unsigned msg, UINT wParam, LONG lParam );
|
||||
|
||||
wxChar *wxTaskBarExWindowClass = (wxChar*) wxT("wxTaskBarExWindowClass");
|
||||
|
||||
wxList wxTaskBarIconEx::sm_taskBarIcons;
|
||||
bool wxTaskBarIconEx::sm_registeredClass = FALSE;
|
||||
UINT wxTaskBarIconEx::sm_taskbarMsg = 0;
|
||||
|
||||
DEFINE_EVENT_TYPE( wxEVT_TASKBAR_CONTEXT_MENU )
|
||||
|
||||
BEGIN_EVENT_TABLE(wxTaskBarIconEx, wxEvtHandler)
|
||||
EVT_TASKBAR_MOVE (wxTaskBarIconEx::_OnMouseMove)
|
||||
EVT_TASKBAR_LEFT_DOWN (wxTaskBarIconEx::_OnLButtonDown)
|
||||
EVT_TASKBAR_LEFT_UP (wxTaskBarIconEx::_OnLButtonUp)
|
||||
EVT_TASKBAR_RIGHT_DOWN (wxTaskBarIconEx::_OnRButtonDown)
|
||||
EVT_TASKBAR_RIGHT_UP (wxTaskBarIconEx::_OnRButtonUp)
|
||||
EVT_TASKBAR_LEFT_DCLICK (wxTaskBarIconEx::_OnLButtonDClick)
|
||||
EVT_TASKBAR_RIGHT_DCLICK (wxTaskBarIconEx::_OnRButtonDClick)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxTaskBarIconEx, wxEvtHandler)
|
||||
|
||||
|
||||
wxTaskBarIconEx::wxTaskBarIconEx(void)
|
||||
{
|
||||
m_hWnd = 0;
|
||||
m_iconAdded = FALSE;
|
||||
|
||||
AddObject(this);
|
||||
|
||||
if (RegisterWindowClass())
|
||||
m_hWnd = CreateTaskBarWindow();
|
||||
}
|
||||
|
||||
wxTaskBarIconEx::~wxTaskBarIconEx(void)
|
||||
{
|
||||
RemoveObject(this);
|
||||
|
||||
if (m_iconAdded)
|
||||
{
|
||||
RemoveIcon();
|
||||
}
|
||||
|
||||
if (m_hWnd)
|
||||
{
|
||||
::DestroyWindow((HWND) m_hWnd);
|
||||
m_hWnd = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Operations
|
||||
bool wxTaskBarIconEx::SetIcon(const wxIcon& icon, const wxString& tooltip)
|
||||
{
|
||||
if (!IsOK())
|
||||
return FALSE;
|
||||
|
||||
NOTIFYICONDATA notifyData;
|
||||
|
||||
memset(¬ifyData, 0, sizeof(notifyData));
|
||||
notifyData.cbSize = sizeof(notifyData);
|
||||
notifyData.hWnd = (HWND) m_hWnd;
|
||||
notifyData.uCallbackMessage = sm_taskbarMsg;
|
||||
notifyData.uFlags = NIF_MESSAGE ;
|
||||
if (icon.Ok())
|
||||
{
|
||||
notifyData.uFlags |= NIF_ICON;
|
||||
notifyData.hIcon = (HICON) icon.GetHICON();
|
||||
}
|
||||
|
||||
if (((const wxChar*) tooltip != NULL) && (tooltip != wxT("")))
|
||||
{
|
||||
notifyData.uFlags |= NIF_TIP ;
|
||||
lstrcpyn(notifyData.szTip, WXSTRINGCAST tooltip, sizeof(notifyData.szTip));
|
||||
}
|
||||
|
||||
notifyData.uID = 99;
|
||||
|
||||
if (m_iconAdded)
|
||||
return (Shell_NotifyIcon(NIM_MODIFY, & notifyData) != 0);
|
||||
else
|
||||
{
|
||||
m_iconAdded = (Shell_NotifyIcon(NIM_ADD, & notifyData) != 0);
|
||||
return m_iconAdded;
|
||||
}
|
||||
}
|
||||
|
||||
bool wxTaskBarIconEx::RemoveIcon(void)
|
||||
{
|
||||
if (!m_iconAdded)
|
||||
return FALSE;
|
||||
|
||||
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.uID = 99;
|
||||
m_iconAdded = FALSE;
|
||||
|
||||
return (Shell_NotifyIcon(NIM_DELETE, & notifyData) != 0);
|
||||
}
|
||||
|
||||
bool wxTaskBarIconEx::PopupMenu(wxMenu *menu) //, int x, int y);
|
||||
{
|
||||
// OK, so I know this isn't thread-friendly, but
|
||||
// what to do? We need this check.
|
||||
|
||||
static bool s_inPopup = FALSE;
|
||||
|
||||
if (s_inPopup)
|
||||
return FALSE;
|
||||
|
||||
s_inPopup = TRUE;
|
||||
|
||||
bool rval = FALSE;
|
||||
wxWindow* win;
|
||||
int x, y;
|
||||
wxGetMousePosition(&x, &y);
|
||||
|
||||
// is wxFrame the best window type to use???
|
||||
win = new wxFrame(NULL, -1, wxEmptyString, wxPoint(x,y), wxSize(-1,-1), 0);
|
||||
win->PushEventHandler(this);
|
||||
|
||||
// Remove from record of top-level windows, or will confuse wxWindows
|
||||
// if we try to exit right now.
|
||||
wxTopLevelWindows.DeleteObject(win);
|
||||
|
||||
menu->UpdateUI();
|
||||
|
||||
// Work around a WIN32 bug
|
||||
::SetForegroundWindow ((HWND) win->GetHWND ());
|
||||
|
||||
rval = win->PopupMenu(menu, 0, 0);
|
||||
|
||||
// Work around a WIN32 bug
|
||||
::PostMessage ((HWND) win->GetHWND(),WM_NULL,0,0L);
|
||||
|
||||
win->PopEventHandler(FALSE);
|
||||
win->Destroy();
|
||||
delete win;
|
||||
|
||||
s_inPopup = FALSE;
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
||||
// Overridables
|
||||
void wxTaskBarIconEx::OnMouseMove(wxEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
void wxTaskBarIconEx::OnLButtonDown(wxEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
void wxTaskBarIconEx::OnLButtonUp(wxEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
void wxTaskBarIconEx::OnRButtonDown(wxEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
void wxTaskBarIconEx::OnRButtonUp(wxEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
void wxTaskBarIconEx::OnLButtonDClick(wxEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
void wxTaskBarIconEx::OnRButtonDClick(wxEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
void wxTaskBarIconEx::_OnMouseMove(wxEvent& e) { OnMouseMove(e); }
|
||||
void wxTaskBarIconEx::_OnLButtonDown(wxEvent& e) { OnLButtonDown(e); }
|
||||
void wxTaskBarIconEx::_OnLButtonUp(wxEvent& e) { OnLButtonUp(e); }
|
||||
void wxTaskBarIconEx::_OnRButtonDown(wxEvent& e) { OnRButtonDown(e); }
|
||||
void wxTaskBarIconEx::_OnRButtonUp(wxEvent& e) { OnRButtonUp(e); }
|
||||
void wxTaskBarIconEx::_OnLButtonDClick(wxEvent& e) { OnLButtonDClick(e); }
|
||||
void wxTaskBarIconEx::_OnRButtonDClick(wxEvent& e) { OnRButtonDClick(e); }
|
||||
|
||||
|
||||
wxTaskBarIconEx* wxTaskBarIconEx::FindObjectForHWND(WXHWND hWnd)
|
||||
{
|
||||
wxNode*node = sm_taskBarIcons.First();
|
||||
while (node)
|
||||
{
|
||||
wxTaskBarIconEx* obj = (wxTaskBarIconEx*) node->Data();
|
||||
if (obj->GetHWND() == hWnd)
|
||||
return obj;
|
||||
node = node->Next();
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void wxTaskBarIconEx::AddObject(wxTaskBarIconEx* obj)
|
||||
{
|
||||
sm_taskBarIcons.Append(obj);
|
||||
}
|
||||
|
||||
void wxTaskBarIconEx::RemoveObject(wxTaskBarIconEx* obj)
|
||||
{
|
||||
sm_taskBarIcons.DeleteObject(obj);
|
||||
}
|
||||
|
||||
bool wxTaskBarIconEx::RegisterWindowClass()
|
||||
{
|
||||
if (sm_registeredClass)
|
||||
return TRUE;
|
||||
|
||||
// Also register the taskbar message here
|
||||
sm_taskbarMsg = ::RegisterWindowMessage(wxT("wxTaskBarIconExMessage"));
|
||||
|
||||
WNDCLASS wc;
|
||||
bool rc;
|
||||
|
||||
HINSTANCE hInstance = GetModuleHandle(NULL);
|
||||
|
||||
/*
|
||||
* set up and register window class
|
||||
*/
|
||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||
wc.lpfnWndProc = (WNDPROC) wxTaskBarIconExWindowProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = 0;
|
||||
wc.hCursor = 0;
|
||||
wc.hbrBackground = 0;
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = wxTaskBarExWindowClass ;
|
||||
rc = (::RegisterClass( &wc ) != 0);
|
||||
|
||||
sm_registeredClass = (rc != 0);
|
||||
|
||||
return( (rc != 0) );
|
||||
}
|
||||
|
||||
WXHWND wxTaskBarIconEx::CreateTaskBarWindow()
|
||||
{
|
||||
HINSTANCE hInstance = GetModuleHandle(NULL);
|
||||
|
||||
HWND hWnd = CreateWindowEx (0, wxTaskBarExWindowClass,
|
||||
wxT("wxTaskBarExWindow"),
|
||||
WS_OVERLAPPED,
|
||||
0,
|
||||
0,
|
||||
10,
|
||||
10,
|
||||
NULL,
|
||||
(HMENU) 0,
|
||||
hInstance,
|
||||
NULL);
|
||||
|
||||
return (WXHWND) hWnd;
|
||||
}
|
||||
|
||||
long wxTaskBarIconEx::WindowProc( WXHWND hWnd, unsigned int msg, unsigned int wParam, long lParam )
|
||||
{
|
||||
wxEventType eventType = 0;
|
||||
|
||||
if (msg != sm_taskbarMsg)
|
||||
return DefWindowProc((HWND) hWnd, msg, wParam, lParam);
|
||||
|
||||
switch (lParam)
|
||||
{
|
||||
case WM_LBUTTONDOWN:
|
||||
eventType = wxEVT_TASKBAR_LEFT_DOWN;
|
||||
break;
|
||||
|
||||
case WM_LBUTTONUP:
|
||||
eventType = wxEVT_TASKBAR_LEFT_UP;
|
||||
break;
|
||||
|
||||
case WM_RBUTTONDOWN:
|
||||
eventType = wxEVT_TASKBAR_RIGHT_DOWN;
|
||||
break;
|
||||
|
||||
case WM_RBUTTONUP:
|
||||
eventType = wxEVT_TASKBAR_RIGHT_UP;
|
||||
break;
|
||||
|
||||
case WM_LBUTTONDBLCLK:
|
||||
eventType = wxEVT_TASKBAR_LEFT_DCLICK;
|
||||
break;
|
||||
|
||||
case WM_RBUTTONDBLCLK:
|
||||
eventType = wxEVT_TASKBAR_RIGHT_DCLICK;
|
||||
break;
|
||||
|
||||
case WM_MOUSEMOVE:
|
||||
eventType = wxEVT_TASKBAR_MOVE;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (eventType) {
|
||||
wxTaskBarIconExEvent event(eventType, this);
|
||||
|
||||
ProcessEvent(event);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
LRESULT APIENTRY wxTaskBarIconExWindowProc( HWND hWnd, unsigned msg, UINT wParam, LONG lParam )
|
||||
{
|
||||
wxTaskBarIconEx* obj = wxTaskBarIconEx::FindObjectForHWND((WXHWND) hWnd);
|
||||
if (obj)
|
||||
return obj->WindowProc((WXHWND) hWnd, msg, wParam, lParam);
|
||||
else
|
||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||
}
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
/////////////////////////////////////////////////////////////////////////
|
||||
// File: wx/msw/taskbar.h
|
||||
// Purpose: Defines wxTaskBarIcon class for manipulating icons on the
|
||||
// Windows task bar.
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 24/3/98
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _TASKBAREX_H_
|
||||
#define _TASKBAREX_H_
|
||||
|
||||
#if defined(__GNUG__) && !defined(__APPLE__)
|
||||
#pragma interface "taskbarex.cpp"
|
||||
#endif
|
||||
|
||||
#include <wx/event.h>
|
||||
#include <wx/list.h>
|
||||
#include <wx/icon.h>
|
||||
|
||||
class wxTaskBarIconEx: public wxEvtHandler {
|
||||
DECLARE_DYNAMIC_CLASS(wxTaskBarIconEx)
|
||||
public:
|
||||
wxTaskBarIconEx(void);
|
||||
virtual ~wxTaskBarIconEx(void);
|
||||
|
||||
// Accessors
|
||||
inline WXHWND GetHWND() const { return m_hWnd; }
|
||||
inline bool IsOK() const { return (m_hWnd != 0) ; }
|
||||
inline bool IsIconInstalled() const { return m_iconAdded; }
|
||||
|
||||
// Operations
|
||||
bool SetIcon(const wxIcon& icon, const wxString& tooltip = wxEmptyString);
|
||||
bool RemoveIcon(void);
|
||||
bool PopupMenu(wxMenu *menu); //, int x, int y);
|
||||
|
||||
// Overridables
|
||||
virtual void OnMouseMove(wxEvent&);
|
||||
virtual void OnLButtonDown(wxEvent&);
|
||||
virtual void OnLButtonUp(wxEvent&);
|
||||
virtual void OnRButtonDown(wxEvent&);
|
||||
virtual void OnRButtonUp(wxEvent&);
|
||||
virtual void OnLButtonDClick(wxEvent&);
|
||||
virtual void OnRButtonDClick(wxEvent&);
|
||||
|
||||
// Implementation
|
||||
static wxTaskBarIconEx* FindObjectForHWND(WXHWND hWnd);
|
||||
static void AddObject(wxTaskBarIconEx* obj);
|
||||
static void RemoveObject(wxTaskBarIconEx* obj);
|
||||
static bool RegisterWindowClass();
|
||||
static WXHWND CreateTaskBarWindow();
|
||||
long WindowProc( WXHWND hWnd, unsigned int msg, unsigned int wParam, long lParam );
|
||||
|
||||
// Data members
|
||||
protected:
|
||||
WXHWND m_hWnd;
|
||||
bool m_iconAdded;
|
||||
static wxList sm_taskBarIcons;
|
||||
static bool sm_registeredClass;
|
||||
static unsigned int sm_taskbarMsg;
|
||||
|
||||
// non-virtual default event handlers to forward events to the virtuals
|
||||
void _OnMouseMove(wxEvent&);
|
||||
void _OnLButtonDown(wxEvent&);
|
||||
void _OnLButtonUp(wxEvent&);
|
||||
void _OnRButtonDown(wxEvent&);
|
||||
void _OnRButtonUp(wxEvent&);
|
||||
void _OnLButtonDClick(wxEvent&);
|
||||
void _OnRButtonDClick(wxEvent&);
|
||||
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
};
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTaskBarIcon events
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxTaskBarIconExEvent : public wxEvent
|
||||
{
|
||||
public:
|
||||
wxTaskBarIconExEvent(wxEventType evtType, wxTaskBarIconEx *tbIcon)
|
||||
: wxEvent(-1, evtType)
|
||||
{
|
||||
SetEventObject(tbIcon);
|
||||
}
|
||||
|
||||
virtual wxEvent *Clone() const { return new wxTaskBarIconExEvent(*this); }
|
||||
};
|
||||
|
||||
|
||||
BEGIN_DECLARE_EVENT_TYPES()
|
||||
DECLARE_EVENT_TYPE( wxEVT_TASKBAR_CONTEXT_MENU, 1557 )
|
||||
END_DECLARE_EVENT_TYPES()
|
||||
|
||||
#define EVT_TASKBAR_CONTEXT_MENU(fn) DECLARE_EVENT_TABLE_ENTRY(wxEVT_TASKBAR_CONTEXT_MENU, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL),
|
||||
|
||||
|
||||
#endif
|
||||
// _TASKBAR_H_
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -25,8 +25,6 @@
|
|||
#define __STDWX_H__
|
||||
|
||||
|
||||
#ifdef __WIN32__
|
||||
|
||||
// Modify the following defines if you have to target a platform prior to the ones specified below.
|
||||
// Refer to MSDN for the latest info on corresponding values for different platforms.
|
||||
#ifndef WINVER // Allow use of features specific to Windows 95 and Windows NT 4 or later.
|
||||
|
@ -45,7 +43,6 @@
|
|||
#define _WIN32_IE 0x0501 // Change this to the appropriate value to target IE 6.0 or later.
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
#include "wx/wxprec.h"
|
||||
|
|
Loading…
Reference in New Issue