1) Added MattKing's code for supporting the middle mouse button in [Rainmeter] and [MeasureName].

MiddleMouseUpAction | MiddleMouseDownAction

2) Updated the manual entries for the middle mouse functionality

3) Added  spx268's code to fix a problem with BUTTON and dynamic variables addressed in:

http://code.google.com/p/rainmeter/issues/detail?id=108
This commit is contained in:
jsmorley 2009-09-07 16:37:58 +00:00
parent 11528ab3cc
commit 48bee2c6fe
6 changed files with 123 additions and 18 deletions

View File

@ -264,8 +264,10 @@ void CMeter::ReadConfig(const WCHAR* section)
m_RightMouseDownAction = parser.ReadString(section, L"RightMouseDownAction", L""); m_RightMouseDownAction = parser.ReadString(section, L"RightMouseDownAction", L"");
m_LeftMouseDownAction = parser.ReadString(section, L"LeftMouseDownAction", L""); m_LeftMouseDownAction = parser.ReadString(section, L"LeftMouseDownAction", L"");
m_MiddleMouseDownAction = parser.ReadString(section, L"MiddleMouseDownAction", L"");
m_RightMouseUpAction = parser.ReadString(section, L"RightMouseUpAction", L""); m_RightMouseUpAction = parser.ReadString(section, L"RightMouseUpAction", L"");
m_LeftMouseUpAction = parser.ReadString(section, L"LeftMouseUpAction", L""); m_LeftMouseUpAction = parser.ReadString(section, L"LeftMouseUpAction", L"");
m_MiddleMouseUpAction = parser.ReadString(section, L"MiddleMouseUpAction", L"");
m_MouseOverAction = parser.ReadString(section, L"MouseOverAction", L""); m_MouseOverAction = parser.ReadString(section, L"MouseOverAction", L"");
m_MouseLeaveAction = parser.ReadString(section, L"MouseLeaveAction", L""); m_MouseLeaveAction = parser.ReadString(section, L"MouseLeaveAction", L"");

View File

@ -54,6 +54,8 @@ public:
std::wstring& GetRightMouseUpAction() { return m_RightMouseUpAction; }; std::wstring& GetRightMouseUpAction() { return m_RightMouseUpAction; };
std::wstring& GetLeftMouseDownAction() { return m_LeftMouseDownAction; }; std::wstring& GetLeftMouseDownAction() { return m_LeftMouseDownAction; };
std::wstring& GetLeftMouseUpAction() { return m_LeftMouseUpAction; }; std::wstring& GetLeftMouseUpAction() { return m_LeftMouseUpAction; };
std::wstring& GetMiddleMouseDownAction() { return m_MiddleMouseDownAction; };
std::wstring& GetMiddleMouseUpAction() { return m_MiddleMouseUpAction; };
std::wstring& GetMouseOverAction() { return m_MouseOverAction; }; std::wstring& GetMouseOverAction() { return m_MouseOverAction; };
std::wstring& GetMouseLeaveAction() { return m_MouseLeaveAction; }; std::wstring& GetMouseLeaveAction() { return m_MouseLeaveAction; };
@ -111,6 +113,8 @@ protected:
std::wstring m_RightMouseUpAction; std::wstring m_RightMouseUpAction;
std::wstring m_LeftMouseDownAction; std::wstring m_LeftMouseDownAction;
std::wstring m_LeftMouseUpAction; std::wstring m_LeftMouseUpAction;
std::wstring m_MiddleMouseDownAction;
std::wstring m_MiddleMouseUpAction;
std::wstring m_MouseOverAction; std::wstring m_MouseOverAction;
std::wstring m_MouseLeaveAction; std::wstring m_MouseLeaveAction;

View File

@ -37,6 +37,7 @@ using namespace Gdiplus;
CMeterImage::CMeterImage(CMeterWindow* meterWindow) : CMeter(meterWindow) CMeterImage::CMeterImage(CMeterWindow* meterWindow) : CMeter(meterWindow)
{ {
m_Bitmap = NULL; m_Bitmap = NULL;
m_NeedsUpdate = false;
m_WidthDefined = false; m_WidthDefined = false;
m_HeightDefined = false; m_HeightDefined = false;
m_PreserveAspectRatio = false; m_PreserveAspectRatio = false;
@ -71,7 +72,7 @@ void CMeterImage::Initialize()
{ {
CMeter::Initialize(); CMeter::Initialize();
LoadImage(true); if (!m_DynamicVariables) LoadImage(true);
} }
/* /*
@ -197,8 +198,6 @@ void CMeterImage::ReadConfig(const WCHAR* section)
CConfigParser& parser = m_MeterWindow->GetParser(); CConfigParser& parser = m_MeterWindow->GetParser();
m_ImageName = parser.ReadString(section, L"ImageName", L"");
m_Path = parser.ReadString(section, L"Path", L""); m_Path = parser.ReadString(section, L"Path", L"");
if (!m_Path.empty()) if (!m_Path.empty())
{ {
@ -207,7 +206,19 @@ void CMeterImage::ReadConfig(const WCHAR* section)
m_Path += L"\\"; m_Path += L"\\";
} }
} }
m_ImageName = m_MeterWindow->MakePathAbsolute(m_Path + m_ImageName);
if (!m_Measure)
{
std::wstring oldImageName = m_ImageName;
m_ImageName = parser.ReadString(section, L"ImageName", L"");
m_ImageName = m_MeterWindow->MakePathAbsolute(m_Path + m_ImageName);
if (m_DynamicVariables)
{
m_NeedsUpdate = (oldImageName != m_ImageName);
}
}
m_PreserveAspectRatio = 0!=parser.ReadInt(section, L"PreserveAspectRatio", 0); m_PreserveAspectRatio = 0!=parser.ReadInt(section, L"PreserveAspectRatio", 0);
@ -229,24 +240,31 @@ void CMeterImage::ReadConfig(const WCHAR* section)
*/ */
bool CMeterImage::Update() bool CMeterImage::Update()
{ {
if (CMeter::Update() && m_Measure) if (CMeter::Update())
{ {
std::wstring val = m_Measure->GetStringValue(false, 1, 0, false); if (m_Measure) //read from the measure
if (!val.empty())
{ {
// Load the new image std::wstring val = m_Measure->GetStringValue(false, 1, 0, false);
val = m_MeterWindow->MakePathAbsolute(m_Path + val); if (!val.empty())
if (val != m_ImageName)
{ {
m_ImageName = val; val = m_MeterWindow->MakePathAbsolute(m_Path + val);
LoadImage(true); if (val != m_ImageName)
} {
else m_ImageName = val;
{ LoadImage(true);
LoadImage(false); }
else
{
LoadImage(false);
}
} }
return true;
}
else if (m_DynamicVariables) //read from the skin
{
LoadImage(m_NeedsUpdate);
return true;
} }
return true;
} }
return false; return false;
} }

View File

@ -45,6 +45,7 @@ private:
Gdiplus::Bitmap* m_Bitmap; // The bitmap Gdiplus::Bitmap* m_Bitmap; // The bitmap
std::wstring m_ImageName; // Name of the image std::wstring m_ImageName; // Name of the image
std::wstring m_Path; std::wstring m_Path;
bool m_NeedsUpdate;
bool m_WidthDefined; bool m_WidthDefined;
bool m_HeightDefined; bool m_HeightDefined;
bool m_PreserveAspectRatio; // If true, aspect ratio of the image is preserved when the image is scaled bool m_PreserveAspectRatio; // If true, aspect ratio of the image is preserved when the image is scaled

View File

@ -1401,8 +1401,10 @@ void CMeterWindow::ReadSkin()
m_RightMouseDownAction = m_Parser.ReadString(L"Rainmeter", L"RightMouseDownAction", L""); m_RightMouseDownAction = m_Parser.ReadString(L"Rainmeter", L"RightMouseDownAction", L"");
m_LeftMouseDownAction = m_Parser.ReadString(L"Rainmeter", L"LeftMouseDownAction", L""); m_LeftMouseDownAction = m_Parser.ReadString(L"Rainmeter", L"LeftMouseDownAction", L"");
m_MiddleMouseDownAction = m_Parser.ReadString(L"Rainmeter", L"MiddleMouseDownAction", L"");
m_RightMouseUpAction = m_Parser.ReadString(L"Rainmeter", L"RightMouseUpAction", L""); m_RightMouseUpAction = m_Parser.ReadString(L"Rainmeter", L"RightMouseUpAction", L"");
m_LeftMouseUpAction = m_Parser.ReadString(L"Rainmeter", L"LeftMouseUpAction", L""); m_LeftMouseUpAction = m_Parser.ReadString(L"Rainmeter", L"LeftMouseUpAction", L"");
m_MiddleMouseUpAction = m_Parser.ReadString(L"Rainmeter", L"MiddleMouseUpAction", L"");
m_MouseOverAction = m_Parser.ReadString(L"Rainmeter", L"MouseOverAction", L""); m_MouseOverAction = m_Parser.ReadString(L"Rainmeter", L"MouseOverAction", L"");
m_MouseLeaveAction = m_Parser.ReadString(L"Rainmeter", L"MouseLeaveAction", L""); m_MouseLeaveAction = m_Parser.ReadString(L"Rainmeter", L"MouseLeaveAction", L"");
m_OnRefreshAction = m_Parser.ReadString(L"Rainmeter", L"OnRefreshAction", L""); m_OnRefreshAction = m_Parser.ReadString(L"Rainmeter", L"OnRefreshAction", L"");
@ -2931,6 +2933,56 @@ LRESULT CMeterWindow::OnRightButtonUp(WPARAM wParam, LPARAM lParam)
return 0; return 0;
} }
/*
** OnMiddleButtonDown
**
** Runs the action when middle mouse button is down
**
*/
LRESULT CMeterWindow::OnMiddleButtonDown(WPARAM wParam, LPARAM lParam)
{
POINT pos;
pos.x = (SHORT)LOWORD(lParam);
pos.y = (SHORT)HIWORD(lParam);
if (m_Message == WM_NCMBUTTONDOWN)
{
// Transform the point to client rect
RECT rect;
GetWindowRect(m_Window, &rect);
pos.x = pos.x - rect.left;
pos.y = pos.y - rect.top;
}
DoAction(pos.x, pos.y, MOUSE_MMB_DOWN, false);
return 0;
}
/*
** OnMiddleButtonUp
**
** Runs the action when middle mouse button is up
**
*/
LRESULT CMeterWindow::OnMiddleButtonUp(WPARAM wParam, LPARAM lParam)
{
POINT pos;
pos.x = (SHORT)LOWORD(lParam);
pos.y = (SHORT)HIWORD(lParam);
if (m_Message == WM_NCMBUTTONUP)
{
// Transform the point to client rect
RECT rect;
GetWindowRect(m_Window, &rect);
pos.x = pos.x - rect.left;
pos.y = pos.y - rect.top;
}
DoAction(pos.x, pos.y, MOUSE_MMB_UP, false);
return 0;
}
/* /*
** OnContextMenu ** OnContextMenu
** **
@ -3016,6 +3068,24 @@ bool CMeterWindow::DoAction(int x, int y, MOUSE mouse, bool test)
} }
break; break;
case MOUSE_MMB_DOWN:
if (!((*j)->GetMiddleMouseDownAction().empty()))
{
if (!test) m_Rainmeter->ExecuteCommand((*j)->GetMiddleMouseDownAction().c_str(), this);
return true;
}
break;
case MOUSE_MMB_UP:
if (!((*j)->GetMiddleMouseUpAction().empty()))
{
if (!test) m_Rainmeter->ExecuteCommand((*j)->GetMiddleMouseUpAction().c_str(), this);
return true;
}
break;
case MOUSE_OVER: case MOUSE_OVER:
if (!(*j)->IsMouseOver()) if (!(*j)->IsMouseOver())
{ {
@ -3220,6 +3290,10 @@ LRESULT CALLBACK CMeterWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
MESSAGE(OnLeftButtonDown, WM_LBUTTONDOWN) MESSAGE(OnLeftButtonDown, WM_LBUTTONDOWN)
MESSAGE(OnLeftButtonUp, WM_LBUTTONUP) MESSAGE(OnLeftButtonUp, WM_LBUTTONUP)
MESSAGE(OnLeftButtonUp, WM_NCLBUTTONUP) MESSAGE(OnLeftButtonUp, WM_NCLBUTTONUP)
MESSAGE(OnMiddleButtonDown, WM_NCMBUTTONDOWN)
MESSAGE(OnMiddleButtonDown, WM_MBUTTONDOWN)
MESSAGE(OnMiddleButtonUp, WM_MBUTTONUP)
MESSAGE(OnMiddleButtonUp, WM_NCMBUTTONUP)
MESSAGE(OnWindowPosChanging, WM_WINDOWPOSCHANGING) MESSAGE(OnWindowPosChanging, WM_WINDOWPOSCHANGING)
MESSAGE(OnCopyData, WM_COPYDATA) MESSAGE(OnCopyData, WM_COPYDATA)
MESSAGE(OnDelayedExecute, WM_DELAYED_EXECUTE) MESSAGE(OnDelayedExecute, WM_DELAYED_EXECUTE)

View File

@ -44,6 +44,8 @@ enum MOUSE
MOUSE_LMB_UP, MOUSE_LMB_UP,
MOUSE_RMB_DOWN, MOUSE_RMB_DOWN,
MOUSE_RMB_UP, MOUSE_RMB_UP,
MOUSE_MMB_DOWN,
MOUSE_MMB_UP,
MOUSE_OVER, MOUSE_OVER,
MOUSE_LEAVE MOUSE_LEAVE
}; };
@ -193,12 +195,14 @@ protected:
LRESULT OnContextMenu(WPARAM wParam, LPARAM lParam); LRESULT OnContextMenu(WPARAM wParam, LPARAM lParam);
LRESULT OnLeftButtonDown(WPARAM wParam, LPARAM lParam); LRESULT OnLeftButtonDown(WPARAM wParam, LPARAM lParam);
LRESULT OnRightButtonDown(WPARAM wParam, LPARAM lParam); LRESULT OnRightButtonDown(WPARAM wParam, LPARAM lParam);
LRESULT OnMiddleButtonDown(WPARAM wParam, LPARAM lParam);
LRESULT OnLeftButtonUp(WPARAM wParam, LPARAM lParam); LRESULT OnLeftButtonUp(WPARAM wParam, LPARAM lParam);
LRESULT OnRightButtonUp(WPARAM wParam, LPARAM lParam); LRESULT OnRightButtonUp(WPARAM wParam, LPARAM lParam);
LRESULT OnMiddleButtonUp(WPARAM wParam, LPARAM lParam);
LRESULT OnDelayedExecute(WPARAM wParam, LPARAM lParam); LRESULT OnDelayedExecute(WPARAM wParam, LPARAM lParam);
LRESULT OnDelayedRefresh(WPARAM wParam, LPARAM lParam); LRESULT OnDelayedRefresh(WPARAM wParam, LPARAM lParam);
LRESULT OnDelayedQuit(WPARAM wParam, LPARAM lParam); LRESULT OnDelayedQuit(WPARAM wParam, LPARAM lParam);
LRESULT OnSettingChange(WPARAM wParam, LPARAM lParam); LRESULT OnSettingChange(WPARAM wParam, LPARAM lParam);
private: private:
@ -232,8 +236,10 @@ private:
std::wstring m_RightMouseDownAction; // Action to run when right mouse is pressed std::wstring m_RightMouseDownAction; // Action to run when right mouse is pressed
std::wstring m_LeftMouseDownAction; // Action to run when left mouse is pressed std::wstring m_LeftMouseDownAction; // Action to run when left mouse is pressed
std::wstring m_MiddleMouseDownAction; // Action to run when middle mouse is pressed
std::wstring m_RightMouseUpAction; // Action to run when right mouse is released std::wstring m_RightMouseUpAction; // Action to run when right mouse is released
std::wstring m_LeftMouseUpAction; // Action to run when left mouse is released std::wstring m_LeftMouseUpAction; // Action to run when left mouse is released
std::wstring m_MiddleMouseUpAction; // Action to run when middle mouse is released
std::wstring m_MouseOverAction; // Action to run when mouse goes over the window std::wstring m_MouseOverAction; // Action to run when mouse goes over the window
std::wstring m_MouseLeaveAction; // Action to run when mouse leaves the window std::wstring m_MouseLeaveAction; // Action to run when mouse leaves the window
std::wstring m_OnRefreshAction; // Action to run when window is initialized std::wstring m_OnRefreshAction; // Action to run when window is initialized