mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Tweaks
* Replaced if-else with switch-case
This commit is contained in:
parent
2ea8710f58
commit
e96b02d3dc
@ -2779,12 +2779,13 @@ void CMeterWindow::UpdateWindow(int alpha, bool reset)
|
||||
*/
|
||||
LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (wParam == TIMER_METER)
|
||||
switch (wParam)
|
||||
{
|
||||
case TIMER_METER:
|
||||
Update(false);
|
||||
}
|
||||
else if (wParam == TIMER_MOUSE)
|
||||
{
|
||||
break;
|
||||
|
||||
case TIMER_MOUSE:
|
||||
if (!Rainmeter->IsMenuActive() && !m_Dragging)
|
||||
{
|
||||
ShowWindowIfAppropriate();
|
||||
@ -2822,72 +2823,77 @@ LRESULT CMeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (wParam == TIMER_TRANSITION)
|
||||
{
|
||||
// Redraw only if there is active transition still going
|
||||
bool bActiveTransition = false;
|
||||
std::vector<CMeter*>::const_iterator j = m_Meters.begin();
|
||||
for ( ; j != m_Meters.end(); ++j)
|
||||
break;
|
||||
|
||||
case TIMER_TRANSITION:
|
||||
{
|
||||
if ((*j)->HasActiveTransition())
|
||||
// Redraw only if there is active transition still going
|
||||
bool bActiveTransition = false;
|
||||
std::vector<CMeter*>::const_iterator j = m_Meters.begin();
|
||||
for ( ; j != m_Meters.end(); ++j)
|
||||
{
|
||||
bActiveTransition = true;
|
||||
break;
|
||||
if ((*j)->HasActiveTransition())
|
||||
{
|
||||
bActiveTransition = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (bActiveTransition)
|
||||
{
|
||||
Redraw();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Stop the transition timer
|
||||
KillTimer(m_Window, TIMER_TRANSITION);
|
||||
m_ActiveTransition = false;
|
||||
}
|
||||
}
|
||||
else if (wParam == TIMER_FADE)
|
||||
{
|
||||
ULONGLONG ticks = CSystem::GetTickCount64();
|
||||
if (m_FadeStartTime == 0)
|
||||
{
|
||||
m_FadeStartTime = ticks;
|
||||
}
|
||||
|
||||
if (ticks - m_FadeStartTime > (ULONGLONG)m_FadeDuration)
|
||||
{
|
||||
KillTimer(m_Window, TIMER_FADE);
|
||||
m_FadeStartTime = 0;
|
||||
if (m_FadeEndValue == 0)
|
||||
if (bActiveTransition)
|
||||
{
|
||||
ShowWindow(m_Window, SW_HIDE);
|
||||
Redraw();
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateWindow(m_FadeEndValue, false);
|
||||
// Stop the transition timer
|
||||
KillTimer(m_Window, TIMER_TRANSITION);
|
||||
m_ActiveTransition = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
double value = (double)(__int64)(ticks - m_FadeStartTime);
|
||||
value /= m_FadeDuration;
|
||||
value *= m_FadeEndValue - m_FadeStartValue;
|
||||
value += m_FadeStartValue;
|
||||
value = min(value, 255);
|
||||
value = max(value, 0);
|
||||
break;
|
||||
|
||||
UpdateWindow((int)value, false);
|
||||
case TIMER_FADE:
|
||||
{
|
||||
ULONGLONG ticks = CSystem::GetTickCount64();
|
||||
if (m_FadeStartTime == 0)
|
||||
{
|
||||
m_FadeStartTime = ticks;
|
||||
}
|
||||
|
||||
if (ticks - m_FadeStartTime > (ULONGLONG)m_FadeDuration)
|
||||
{
|
||||
KillTimer(m_Window, TIMER_FADE);
|
||||
m_FadeStartTime = 0;
|
||||
if (m_FadeEndValue == 0)
|
||||
{
|
||||
ShowWindow(m_Window, SW_HIDE);
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateWindow(m_FadeEndValue, false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
double value = (double)(__int64)(ticks - m_FadeStartTime);
|
||||
value /= m_FadeDuration;
|
||||
value *= m_FadeEndValue - m_FadeStartValue;
|
||||
value += m_FadeStartValue;
|
||||
value = min(value, 255);
|
||||
value = max(value, 0);
|
||||
|
||||
UpdateWindow((int)value, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (wParam == TIMER_DEACTIVATE)
|
||||
{
|
||||
break;
|
||||
|
||||
case TIMER_DEACTIVATE:
|
||||
if (m_FadeStartTime == 0)
|
||||
{
|
||||
KillTimer(m_Window, TIMER_DEACTIVATE);
|
||||
Rainmeter->DeleteMeterWindow(this, true); // "delete this;"
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -3308,184 +3314,189 @@ LRESULT CMeterWindow::OnMouseHScrollMove(UINT uMsg, WPARAM wParam, LPARAM lParam
|
||||
*/
|
||||
LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
if (wParam == IDM_SKIN_EDITSKIN)
|
||||
switch (wParam)
|
||||
{
|
||||
case IDM_SKIN_EDITSKIN:
|
||||
Rainmeter->EditSkinFile(m_FolderPath, m_FileName);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_REFRESH)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SKIN_REFRESH:
|
||||
Refresh(false);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_OPENSKINSFOLDER)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SKIN_OPENSKINSFOLDER:
|
||||
Rainmeter->OpenSkinFolder(m_FolderPath);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_MANAGESKIN)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SKIN_MANAGESKIN:
|
||||
CDialogManage::OpenSkin(this);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_VERYTOPMOST)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SKIN_VERYTOPMOST:
|
||||
SetWindowZPosition(ZPOSITION_ONTOPMOST);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_TOPMOST)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SKIN_TOPMOST:
|
||||
SetWindowZPosition(ZPOSITION_ONTOP);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_BOTTOM)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SKIN_BOTTOM:
|
||||
SetWindowZPosition(ZPOSITION_ONBOTTOM);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_NORMAL)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SKIN_NORMAL:
|
||||
SetWindowZPosition(ZPOSITION_NORMAL);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_ONDESKTOP)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SKIN_ONDESKTOP:
|
||||
SetWindowZPosition(ZPOSITION_ONDESKTOP);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_KEEPONSCREEN)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SKIN_KEEPONSCREEN:
|
||||
SetKeepOnScreen(!m_KeepOnScreen);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_CLICKTHROUGH)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SKIN_CLICKTHROUGH:
|
||||
SetClickThrough(!m_ClickThrough);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_DRAGGABLE)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SKIN_DRAGGABLE:
|
||||
SetWindowDraggable(!m_WindowDraggable);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_HIDEONMOUSE)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SKIN_HIDEONMOUSE:
|
||||
SetWindowHide((m_WindowHide == HIDEMODE_NONE) ? HIDEMODE_HIDE : HIDEMODE_NONE);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_TRANSPARENCY_FADEIN)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SKIN_TRANSPARENCY_FADEIN:
|
||||
SetWindowHide((m_WindowHide == HIDEMODE_NONE) ? HIDEMODE_FADEIN : HIDEMODE_NONE);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_TRANSPARENCY_FADEOUT)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SKIN_TRANSPARENCY_FADEOUT:
|
||||
SetWindowHide((m_WindowHide == HIDEMODE_NONE) ? HIDEMODE_FADEOUT : HIDEMODE_NONE);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_REMEMBERPOSITION)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SKIN_REMEMBERPOSITION:
|
||||
SetSavePosition(!m_SavePosition);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_SNAPTOEDGES)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SKIN_SNAPTOEDGES:
|
||||
SetSnapEdges(!m_SnapEdges);
|
||||
}
|
||||
else if (wParam >= IDM_SKIN_TRANSPARENCY_0 && wParam <= IDM_SKIN_TRANSPARENCY_90)
|
||||
{
|
||||
m_AlphaValue = (int)(255.0 - (wParam - IDM_SKIN_TRANSPARENCY_0) * (230.0 / (IDM_SKIN_TRANSPARENCY_90 - IDM_SKIN_TRANSPARENCY_0)));
|
||||
UpdateWindow(m_AlphaValue, false);
|
||||
WriteOptions(OPTION_ALPHAVALUE);
|
||||
}
|
||||
else if (wParam == IDM_CLOSESKIN)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_CLOSESKIN:
|
||||
Rainmeter->DeactivateSkin(this, -1);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_FROMRIGHT)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SKIN_FROMRIGHT:
|
||||
m_WindowXFromRight = !m_WindowXFromRight;
|
||||
|
||||
ScreenToWindow();
|
||||
WriteOptions(OPTION_POSITION);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_FROMBOTTOM)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SKIN_FROMBOTTOM:
|
||||
m_WindowYFromBottom = !m_WindowYFromBottom;
|
||||
|
||||
ScreenToWindow();
|
||||
WriteOptions(OPTION_POSITION);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_XPERCENTAGE)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SKIN_XPERCENTAGE:
|
||||
m_WindowXPercentage = !m_WindowXPercentage;
|
||||
|
||||
ScreenToWindow();
|
||||
WriteOptions(OPTION_POSITION);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_YPERCENTAGE)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SKIN_YPERCENTAGE:
|
||||
m_WindowYPercentage = !m_WindowYPercentage;
|
||||
|
||||
ScreenToWindow();
|
||||
WriteOptions(OPTION_POSITION);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_MONITOR_AUTOSELECT)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SKIN_MONITOR_AUTOSELECT:
|
||||
m_AutoSelectScreen = !m_AutoSelectScreen;
|
||||
|
||||
ScreenToWindow();
|
||||
WriteOptions(OPTION_POSITION | OPTION_AUTOSELECTSCREEN);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_MONITOR_PRIMARY || wParam >= ID_MONITOR_FIRST && wParam <= ID_MONITOR_LAST)
|
||||
{
|
||||
const MultiMonitorInfo& multimonInfo = CSystem::GetMultiMonitorInfo();
|
||||
const std::vector<MonitorInfo>& monitors = multimonInfo.monitors;
|
||||
break;
|
||||
|
||||
int screenIndex;
|
||||
bool screenDefined;
|
||||
if (wParam == IDM_SKIN_MONITOR_PRIMARY)
|
||||
default:
|
||||
if (wParam >= IDM_SKIN_TRANSPARENCY_0 && wParam <= IDM_SKIN_TRANSPARENCY_90)
|
||||
{
|
||||
screenIndex = multimonInfo.primary;
|
||||
screenDefined = false;
|
||||
m_AlphaValue = (int)(255.0 - (wParam - IDM_SKIN_TRANSPARENCY_0) * (230.0 / (IDM_SKIN_TRANSPARENCY_90 - IDM_SKIN_TRANSPARENCY_0)));
|
||||
UpdateWindow(m_AlphaValue, false);
|
||||
WriteOptions(OPTION_ALPHAVALUE);
|
||||
}
|
||||
else if (wParam == IDM_SKIN_MONITOR_PRIMARY || wParam >= ID_MONITOR_FIRST && wParam <= ID_MONITOR_LAST)
|
||||
{
|
||||
const MultiMonitorInfo& monitorsInfo = CSystem::GetMultiMonitorInfo();
|
||||
const std::vector<MonitorInfo>& monitors = monitorsInfo.monitors;
|
||||
|
||||
int screenIndex;
|
||||
bool screenDefined;
|
||||
if (wParam == IDM_SKIN_MONITOR_PRIMARY)
|
||||
{
|
||||
screenIndex = monitorsInfo.primary;
|
||||
screenDefined = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
screenIndex = (wParam & 0x0ffff) - ID_MONITOR_FIRST;
|
||||
screenDefined = true;
|
||||
}
|
||||
|
||||
if (screenIndex >= 0 && (screenIndex == 0 || screenIndex <= (int)monitors.size() && monitors[screenIndex-1].active))
|
||||
{
|
||||
m_AutoSelectScreen = false;
|
||||
|
||||
m_WindowXScreen = m_WindowYScreen = screenIndex;
|
||||
m_WindowXScreenDefined = m_WindowYScreenDefined = screenDefined;
|
||||
|
||||
m_Parser.ResetMonitorVariables(this); // Set present monitor variables
|
||||
ScreenToWindow();
|
||||
WriteOptions(OPTION_POSITION | OPTION_AUTOSELECTSCREEN);
|
||||
}
|
||||
}
|
||||
else if (wParam >= IDM_SKIN_CUSTOMCONTEXTMENU_FIRST && wParam <= IDM_SKIN_CUSTOMCONTEXTMENU_LAST)
|
||||
{
|
||||
std::wstring action;
|
||||
|
||||
int position = (int)wParam - IDM_SKIN_CUSTOMCONTEXTMENU_FIRST + 1;
|
||||
if (position == 1)
|
||||
{
|
||||
action = m_Parser.ReadString(L"Rainmeter", L"ContextAction", L"", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
WCHAR buffer[128];
|
||||
|
||||
_snwprintf_s(buffer, _TRUNCATE, L"ContextAction%i", position);
|
||||
action = m_Parser.ReadString(L"Rainmeter", buffer, L"", false);
|
||||
}
|
||||
|
||||
if (!action.empty())
|
||||
{
|
||||
Rainmeter->ExecuteCommand(action.c_str(), this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
screenIndex = (wParam & 0x0ffff) - ID_MONITOR_FIRST;
|
||||
screenDefined = true;
|
||||
}
|
||||
// Forward to tray window, which handles all the other commands
|
||||
HWND tray = Rainmeter->GetTrayWindow()->GetWindow();
|
||||
|
||||
if (screenIndex >= 0 && (screenIndex == 0 || screenIndex <= (int)monitors.size() && monitors[screenIndex-1].active))
|
||||
{
|
||||
m_AutoSelectScreen = false;
|
||||
|
||||
m_WindowXScreen = m_WindowYScreen = screenIndex;
|
||||
m_WindowXScreenDefined = m_WindowYScreenDefined = screenDefined;
|
||||
|
||||
m_Parser.ResetMonitorVariables(this); // Set present monitor variables
|
||||
ScreenToWindow();
|
||||
WriteOptions(OPTION_POSITION | OPTION_AUTOSELECTSCREEN);
|
||||
}
|
||||
}
|
||||
else if (wParam >= IDM_SKIN_CUSTOMCONTEXTMENU_FIRST && wParam <= IDM_SKIN_CUSTOMCONTEXTMENU_LAST)
|
||||
{
|
||||
std::wstring action;
|
||||
|
||||
int position = (int)wParam - IDM_SKIN_CUSTOMCONTEXTMENU_FIRST + 1;
|
||||
if (position == 1)
|
||||
{
|
||||
action = m_Parser.ReadString(L"Rainmeter", L"ContextAction", L"", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
WCHAR buffer[128];
|
||||
|
||||
_snwprintf_s(buffer, _TRUNCATE, L"ContextAction%i", position);
|
||||
action = m_Parser.ReadString(L"Rainmeter", buffer, L"", false);
|
||||
}
|
||||
|
||||
if (!action.empty())
|
||||
{
|
||||
Rainmeter->ExecuteCommand(action.c_str(), this);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Forward to tray window, which handles all the other commands
|
||||
HWND tray = Rainmeter->GetTrayWindow()->GetWindow();
|
||||
|
||||
if (wParam == IDM_QUIT)
|
||||
{
|
||||
PostMessage(tray, WM_COMMAND, wParam, lParam);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessage(tray, WM_COMMAND, wParam, lParam);
|
||||
if (wParam == IDM_QUIT)
|
||||
{
|
||||
PostMessage(tray, WM_COMMAND, wParam, lParam);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendMessage(tray, WM_COMMAND, wParam, lParam);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -995,7 +995,7 @@ LRESULT CALLBACK CSystem::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
||||
ClearMultiMonitorInfo();
|
||||
CConfigParser::ClearMultiMonitorVariables();
|
||||
case WM_SETTINGCHANGE:
|
||||
if (uMsg == WM_DISPLAYCHANGE || (uMsg == WM_SETTINGCHANGE && wParam == SPI_SETWORKAREA))
|
||||
if (uMsg == WM_DISPLAYCHANGE || (/*uMsg == WM_SETTINGCHANGE &&*/ wParam == SPI_SETWORKAREA))
|
||||
{
|
||||
if (uMsg == WM_SETTINGCHANGE) // SPI_SETWORKAREA
|
||||
{
|
||||
|
@ -464,156 +464,170 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
if (wParam == IDM_MANAGE)
|
||||
switch (wParam)
|
||||
{
|
||||
case IDM_MANAGE:
|
||||
CDialogManage::Open();
|
||||
}
|
||||
else if (wParam == IDM_ABOUT)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_ABOUT:
|
||||
CDialogAbout::Open();
|
||||
}
|
||||
else if (wParam == IDM_SHOW_HELP)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SHOW_HELP:
|
||||
RunFile(RAINMETER_HELP);
|
||||
}
|
||||
else if (wParam == IDM_NEW_VERSION)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_NEW_VERSION:
|
||||
RunFile(RAINMETER_OFFICIAL);
|
||||
}
|
||||
else if (wParam == IDM_REFRESH)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_REFRESH:
|
||||
PostMessage(Rainmeter->GetWindow(), WM_RAINMETER_DELAYED_REFRESH_ALL, (WPARAM)NULL, (LPARAM)NULL);
|
||||
}
|
||||
else if (wParam == IDM_SHOWLOGFILE)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_SHOWLOGFILE:
|
||||
Rainmeter->ShowLogFile();
|
||||
}
|
||||
else if (wParam == IDM_STARTLOG)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_STARTLOG:
|
||||
Rainmeter->StartLogging();
|
||||
}
|
||||
else if (wParam == IDM_STOPLOG)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_STOPLOG:
|
||||
Rainmeter->StopLogging();
|
||||
}
|
||||
else if (wParam == IDM_DELETELOGFILE)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_DELETELOGFILE:
|
||||
Rainmeter->DeleteLogFile();
|
||||
}
|
||||
else if (wParam == IDM_DEBUGLOG)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_DEBUGLOG:
|
||||
Rainmeter->SetDebug(!Rainmeter->GetDebug());
|
||||
}
|
||||
else if (wParam == IDM_DISABLEDRAG)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_DISABLEDRAG:
|
||||
Rainmeter->SetDisableDragging(!Rainmeter->GetDisableDragging());
|
||||
}
|
||||
else if (wParam == IDM_EDITCONFIG)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_EDITCONFIG:
|
||||
Rainmeter->EditSettings();
|
||||
}
|
||||
else if (wParam == IDM_QUIT)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_QUIT:
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
else if (wParam == IDM_OPENSKINSFOLDER)
|
||||
{
|
||||
break;
|
||||
|
||||
case IDM_OPENSKINSFOLDER:
|
||||
Rainmeter->OpenSkinFolder();
|
||||
}
|
||||
else
|
||||
{
|
||||
UINT mID = wParam & 0x0FFFF;
|
||||
break;
|
||||
|
||||
if (mID >= ID_THEME_FIRST && mID <= ID_THEME_LAST)
|
||||
default:
|
||||
{
|
||||
int pos = mID - ID_THEME_FIRST;
|
||||
UINT mID = wParam & 0x0FFFF;
|
||||
|
||||
const std::vector<std::wstring>& layouts = Rainmeter->GetAllLayouts();
|
||||
if (pos >= 0 && pos < (int)layouts.size())
|
||||
if (mID >= ID_THEME_FIRST && mID <= ID_THEME_LAST)
|
||||
{
|
||||
Rainmeter->LoadLayout(layouts[pos]);
|
||||
}
|
||||
}
|
||||
else if (mID >= ID_CONFIG_FIRST && mID <= ID_CONFIG_LAST)
|
||||
{
|
||||
std::pair<int, int> indexes = Rainmeter->GetMeterWindowIndex(mID);
|
||||
if (indexes.first != -1 && indexes.second != -1)
|
||||
{
|
||||
Rainmeter->ToggleSkin(indexes.first, indexes.second);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Forward the message to correct window
|
||||
int index = (int)(wParam >> 16);
|
||||
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
|
||||
int pos = mID - ID_THEME_FIRST;
|
||||
|
||||
if (index < (int)windows.size())
|
||||
{
|
||||
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
|
||||
for ( ; iter != windows.end(); ++iter)
|
||||
const std::vector<std::wstring>& layouts = Rainmeter->GetAllLayouts();
|
||||
if (pos >= 0 && pos < (int)layouts.size())
|
||||
{
|
||||
--index;
|
||||
if (index < 0)
|
||||
Rainmeter->LoadLayout(layouts[pos]);
|
||||
}
|
||||
}
|
||||
else if (mID >= ID_CONFIG_FIRST && mID <= ID_CONFIG_LAST)
|
||||
{
|
||||
std::pair<int, int> indexes = Rainmeter->GetMeterWindowIndex(mID);
|
||||
if (indexes.first != -1 && indexes.second != -1)
|
||||
{
|
||||
Rainmeter->ToggleSkin(indexes.first, indexes.second);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Forward the message to correct window
|
||||
int index = (int)(wParam >> 16);
|
||||
const std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
|
||||
|
||||
if (index < (int)windows.size())
|
||||
{
|
||||
std::map<std::wstring, CMeterWindow*>::const_iterator iter = windows.begin();
|
||||
for ( ; iter != windows.end(); ++iter)
|
||||
{
|
||||
CMeterWindow* meterWindow = (*iter).second;
|
||||
SendMessage(meterWindow->GetWindow(), WM_COMMAND, mID, NULL);
|
||||
break;
|
||||
--index;
|
||||
if (index < 0)
|
||||
{
|
||||
CMeterWindow* meterWindow = (*iter).second;
|
||||
SendMessage(meterWindow->GetWindow(), WM_COMMAND, mID, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break; // Don't send WM_COMMANDS any further
|
||||
|
||||
case WM_TRAY_NOTIFYICON:
|
||||
{
|
||||
UINT uMouseMsg = (UINT)lParam;
|
||||
std::wstring bang;
|
||||
LPCWSTR bang;
|
||||
|
||||
// Check TrayExecute actions
|
||||
switch (uMouseMsg)
|
||||
{
|
||||
case WM_MBUTTONDOWN:
|
||||
bang = Rainmeter->GetTrayExecuteM();
|
||||
bang = Rainmeter->GetTrayExecuteM().c_str();
|
||||
break;
|
||||
|
||||
case WM_RBUTTONDOWN:
|
||||
bang = Rainmeter->GetTrayExecuteR();
|
||||
bang = Rainmeter->GetTrayExecuteR().c_str();
|
||||
break;
|
||||
|
||||
case WM_MBUTTONDBLCLK:
|
||||
bang = Rainmeter->GetTrayExecuteDM();
|
||||
bang = Rainmeter->GetTrayExecuteDM().c_str();
|
||||
break;
|
||||
|
||||
case WM_RBUTTONDBLCLK:
|
||||
bang = Rainmeter->GetTrayExecuteDR();
|
||||
bang = Rainmeter->GetTrayExecuteDR().c_str();
|
||||
break;
|
||||
|
||||
default:
|
||||
bang = L"";
|
||||
break;
|
||||
}
|
||||
|
||||
if (!bang.empty() &&
|
||||
if (*bang &&
|
||||
!IsCtrlKeyDown()) // Ctrl is pressed, so only run default action
|
||||
{
|
||||
Rainmeter->ExecuteCommand(bang.c_str(), NULL);
|
||||
Rainmeter->ExecuteCommand(bang, NULL);
|
||||
tray->m_TrayContextMenuEnabled = (uMouseMsg != WM_RBUTTONDOWN);
|
||||
break;
|
||||
}
|
||||
else if (uMouseMsg == WM_RBUTTONDOWN)
|
||||
|
||||
// Run default UI action
|
||||
switch (uMouseMsg)
|
||||
{
|
||||
case WM_RBUTTONDOWN:
|
||||
tray->m_TrayContextMenuEnabled = true;
|
||||
}
|
||||
else if (uMouseMsg == WM_RBUTTONUP)
|
||||
{
|
||||
break;
|
||||
|
||||
case WM_RBUTTONUP:
|
||||
if (tray->m_TrayContextMenuEnabled)
|
||||
{
|
||||
POINT pos = CSystem::GetCursorPosition();
|
||||
Rainmeter->ShowContextMenu(pos, NULL);
|
||||
}
|
||||
}
|
||||
else if (uMouseMsg == WM_LBUTTONUP || uMouseMsg == WM_LBUTTONDBLCLK)
|
||||
{
|
||||
break;
|
||||
|
||||
case WM_LBUTTONUP:
|
||||
case WM_LBUTTONDBLCLK:
|
||||
CDialogManage::Open();
|
||||
}
|
||||
else if (uMouseMsg == NIN_BALLOONUSERCLICK)
|
||||
{
|
||||
break;
|
||||
|
||||
case NIN_BALLOONUSERCLICK:
|
||||
if (tray->m_Notification == TRAY_NOTIFICATION_WELCOME)
|
||||
{
|
||||
CDialogManage::Open();
|
||||
@ -622,12 +636,13 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
{
|
||||
RunFile(RAINMETER_OFFICIAL);
|
||||
}
|
||||
tray->m_Notification = TRAY_NOTIFICATION_NONE;
|
||||
break;
|
||||
|
||||
case NIN_BALLOONHIDE:
|
||||
case NIN_BALLOONTIMEOUT:
|
||||
tray->m_Notification = TRAY_NOTIFICATION_NONE;
|
||||
}
|
||||
else if (uMouseMsg == NIN_BALLOONHIDE || uMouseMsg == NIN_BALLOONTIMEOUT)
|
||||
{
|
||||
tray->m_Notification = TRAY_NOTIFICATION_NONE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -644,40 +659,37 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
|
||||
SendMessage((HWND)lParam, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
|
||||
};
|
||||
|
||||
if (wParam == RAINMETER_QUERY_ID_SKINS_PATH)
|
||||
switch (wParam)
|
||||
{
|
||||
case RAINMETER_QUERY_ID_SKINS_PATH:
|
||||
sendCopyData(Rainmeter->GetSkinPath());
|
||||
return 0;
|
||||
}
|
||||
else if (wParam == RAINMETER_QUERY_ID_SETTINGS_PATH)
|
||||
{
|
||||
|
||||
case RAINMETER_QUERY_ID_SETTINGS_PATH:
|
||||
sendCopyData(Rainmeter->GetSettingsPath());
|
||||
return 0;
|
||||
}
|
||||
else if (wParam == RAINMETER_QUERY_ID_PLUGINS_PATH)
|
||||
{
|
||||
|
||||
case RAINMETER_QUERY_ID_PLUGINS_PATH:
|
||||
sendCopyData(Rainmeter->GetPluginPath());
|
||||
return 0;
|
||||
}
|
||||
else if (wParam == RAINMETER_QUERY_ID_PROGRAM_PATH)
|
||||
{
|
||||
|
||||
case RAINMETER_QUERY_ID_PROGRAM_PATH:
|
||||
sendCopyData(Rainmeter->GetPath());
|
||||
return 0;
|
||||
}
|
||||
else if (wParam == RAINMETER_QUERY_ID_LOG_PATH)
|
||||
{
|
||||
|
||||
case RAINMETER_QUERY_ID_LOG_PATH:
|
||||
sendCopyData(Rainmeter->GetLogFile());
|
||||
return 0;
|
||||
}
|
||||
else if (wParam == RAINMETER_QUERY_ID_CONFIG_EDITOR)
|
||||
{
|
||||
|
||||
case RAINMETER_QUERY_ID_CONFIG_EDITOR:
|
||||
sendCopyData(Rainmeter->GetSkinEditor());
|
||||
return 0;
|
||||
}
|
||||
else if (wParam == RAINMETER_QUERY_ID_IS_DEBUGGING)
|
||||
{
|
||||
BOOL debug = Rainmeter->GetDebug();
|
||||
SendMessage((HWND)lParam, WM_QUERY_RAINMETER_RETURN, (WPARAM)hWnd, (LPARAM)debug);
|
||||
|
||||
case RAINMETER_QUERY_ID_IS_DEBUGGING:
|
||||
{
|
||||
BOOL debug = Rainmeter->GetDebug();
|
||||
SendMessage((HWND)lParam, WM_QUERY_RAINMETER_RETURN, (WPARAM)hWnd, (LPARAM)debug);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user