A bit of work on app's UI and integration between .net and native.

This commit is contained in:
2014-07-23 13:47:09 +03:00
parent 731475f8c8
commit 8541cce5f4
76 changed files with 5412 additions and 407 deletions

View File

@ -160,7 +160,7 @@ MeterWindow::MeterWindow(const std::wstring& folderPath, const std::wstring& fil
WNDCLASSEX wc = {sizeof(WNDCLASSEX)};
wc.style = CS_NOCLOSE | CS_DBLCLKS;
wc.lpfnWndProc = InitialWndProc;
wc.hInstance = GetRainmeter().GetModuleInstance();
wc.hInstance = Rainmeter::GetInstance().GetModuleInstance();
wc.hCursor = nullptr; // The cursor should be controlled by using SetCursor() when needed.
wc.lpszClassName = METERWINDOW_CLASS_NAME;
RegisterClassEx(&wc);
@ -179,7 +179,7 @@ MeterWindow::~MeterWindow()
if (!m_OnCloseAction.empty())
{
GetRainmeter().ExecuteCommand(m_OnCloseAction.c_str(), this);
Rainmeter::GetInstance().ExecuteCommand(m_OnCloseAction.c_str(), this);
}
Dispose(false);
@ -188,7 +188,7 @@ MeterWindow::~MeterWindow()
if (c_InstanceCount == 0)
{
UnregisterClass(METERWINDOW_CLASS_NAME, GetRainmeter().GetModuleInstance());
UnregisterClass(METERWINDOW_CLASS_NAME, Rainmeter::GetInstance().GetModuleInstance());
if (c_DwmInstance)
{
@ -287,7 +287,7 @@ void MeterWindow::Initialize()
CW_USEDEFAULT,
nullptr,
nullptr,
GetRainmeter().GetModuleInstance(),
Rainmeter::GetInstance().GetModuleInstance(),
this);
setlocale(LC_NUMERIC, "C");
@ -383,8 +383,8 @@ void MeterWindow::Deactivate()
if (m_State == STATE_CLOSING) return;
m_State = STATE_CLOSING;
GetRainmeter().RemoveMeterWindow(this);
GetRainmeter().AddUnmanagedMeterWindow(this);
Rainmeter::GetInstance().RemoveMeterWindow(this);
Rainmeter::GetInstance().AddUnmanagedMeterWindow(this);
HideFade();
SetTimer(m_Window, TIMER_DEACTIVATE, m_FadeDuration + 50, nullptr);
@ -399,7 +399,7 @@ void MeterWindow::Refresh(bool init, bool all)
if (m_State == STATE_CLOSING) return;
m_State = STATE_REFRESHING;
GetRainmeter().SetCurrentParser(&m_Parser);
Rainmeter::GetInstance().SetCurrentParser(&m_Parser);
LogNoticeF(this, L"Refreshing skin");
@ -414,7 +414,7 @@ void MeterWindow::Refresh(bool init, bool all)
if (!ReadSkin())
{
GetRainmeter().DeactivateSkin(this, -1);
Rainmeter::GetInstance().DeactivateSkin(this, -1);
return;
}
@ -461,13 +461,13 @@ void MeterWindow::Refresh(bool init, bool all)
SetTimer(m_Window, TIMER_MOUSE, INTERVAL_MOUSE, nullptr);
GetRainmeter().SetCurrentParser(nullptr);
Rainmeter::GetInstance().SetCurrentParser(nullptr);
m_State = STATE_RUNNING;
if (!m_OnRefreshAction.empty())
{
GetRainmeter().ExecuteCommand(m_OnRefreshAction.c_str(), this);
Rainmeter::GetInstance().ExecuteCommand(m_OnRefreshAction.c_str(), this);
}
}
@ -625,7 +625,7 @@ void MeterWindow::ChangeZPos(ZPOSITION zPos, bool all)
break;
case ZPOSITION_NORMAL:
if (all || !GetRainmeter().IsNormalStayDesktop()) break;
if (all || !Rainmeter::GetInstance().IsNormalStayDesktop()) break;
case ZPOSITION_ONDESKTOP:
if (System::GetShowDesktop())
{
@ -676,7 +676,7 @@ void MeterWindow::ChangeZPos(ZPOSITION zPos, bool all)
*/
void MeterWindow::ChangeSingleZPos(ZPOSITION zPos, bool all)
{
if (zPos == ZPOSITION_NORMAL && GetRainmeter().IsNormalStayDesktop() && (!all || System::GetShowDesktop()))
if (zPos == ZPOSITION_NORMAL && Rainmeter::GetInstance().IsNormalStayDesktop() && (!all || System::GetShowDesktop()))
{
m_WindowZPosition = zPos;
@ -1884,7 +1884,7 @@ void MeterWindow::ReadOptions()
const WCHAR* section = m_FolderPath.c_str();
ConfigParser parser;
parser.Initialize(GetRainmeter().GetIniFile(), nullptr, section);
parser.Initialize(Rainmeter::GetInstance().GetIniFile(), nullptr, section);
INT writeFlags = 0;
auto addWriteFlag = [&](INT flag)
@ -1962,7 +1962,7 @@ void MeterWindow::ReadOptions()
*/
void MeterWindow::WriteOptions(INT setting)
{
const WCHAR* iniFile = GetRainmeter().GetIniFile().c_str();
const WCHAR* iniFile = Rainmeter::GetInstance().GetIniFile().c_str();
if (*iniFile)
{
@ -2063,7 +2063,7 @@ bool MeterWindow::ReadSkin()
if (_waccess(iniFile.c_str(), 0) == -1)
{
std::wstring message = GetFormattedString(ID_STR_UNABLETOREFRESHSKIN, m_FolderPath.c_str(), m_FileName.c_str());
GetRainmeter().ShowMessage(m_Window, message.c_str(), MB_OK | MB_ICONEXCLAMATION);
Rainmeter::GetInstance().ShowMessage(m_Window, message.c_str(), MB_OK | MB_ICONEXCLAMATION);
return false;
}
@ -2076,7 +2076,7 @@ bool MeterWindow::ReadSkin()
m_Parser.Initialize(iniFile, this, nullptr, &resourcePath);
m_Canvas = Gfx::Canvas::Create(
m_UseD2D && GetRainmeter().GetUseD2D() ? Gfx::Renderer::PreferD2D : Gfx::Renderer::GDIP);
m_UseD2D && Rainmeter::GetInstance().GetUseD2D() ? Gfx::Renderer::PreferD2D : Gfx::Renderer::GDIP);
m_Canvas->SetAccurateText(m_Parser.ReadBool(L"Rainmeter", L"AccurateText", false));
// Gotta have some kind of buffer during initialization
@ -2096,7 +2096,7 @@ bool MeterWindow::ReadSkin()
}
std::wstring text = GetFormattedString(ID_STR_NEWVERSIONREQUIRED, m_FolderPath.c_str(), m_FileName.c_str(), buffer);
GetRainmeter().ShowMessage(m_Window, text.c_str(), MB_OK | MB_ICONEXCLAMATION);
Rainmeter::GetInstance().ShowMessage(m_Window, text.c_str(), MB_OK | MB_ICONEXCLAMATION);
return false;
}
@ -2234,7 +2234,7 @@ bool MeterWindow::ReadSkin()
do
{
// Try program folder first
std::wstring szFontFile = GetRainmeter().GetPath() + L"Fonts\\";
std::wstring szFontFile = Rainmeter::GetInstance().GetPath() + L"Fonts\\";
szFontFile += localFont;
if (!m_FontCollection->AddFile(szFontFile.c_str()))
{
@ -2310,7 +2310,7 @@ bool MeterWindow::ReadSkin()
if (m_Meters.empty())
{
std::wstring text = GetFormattedString(ID_STR_NOMETERSINSKIN, m_FolderPath.c_str(), m_FileName.c_str());
GetRainmeter().ShowMessage(m_Window, text.c_str(), MB_OK | MB_ICONEXCLAMATION);
Rainmeter::GetInstance().ShowMessage(m_Window, text.c_str(), MB_OK | MB_ICONEXCLAMATION);
return false;
}
@ -2794,7 +2794,7 @@ void MeterWindow::Update(bool refresh)
// If our option is to disable when in an RDP session, then check if in an RDP session.
// Only redraw if we are not in a remote session
if (GetRainmeter().IsRedrawable())
if (Rainmeter::GetInstance().IsRedrawable())
{
Redraw();
}
@ -2805,7 +2805,7 @@ void MeterWindow::Update(bool refresh)
if (!m_OnUpdateAction.empty())
{
GetRainmeter().ExecuteCommand(m_OnUpdateAction.c_str(), this);
Rainmeter::GetInstance().ExecuteCommand(m_OnUpdateAction.c_str(), this);
}
}
@ -2862,7 +2862,7 @@ LRESULT MeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
break;
case TIMER_MOUSE:
if (!GetRainmeter().IsMenuActive() && !m_Dragging)
if (!Rainmeter::GetInstance().IsMenuActive() && !m_Dragging)
{
ShowWindowIfAppropriate();
@ -2967,7 +2967,7 @@ LRESULT MeterWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam)
if (m_FadeStartTime == 0)
{
KillTimer(m_Window, TIMER_DEACTIVATE);
GetRainmeter().RemoveUnmanagedMeterWindow(this);
Rainmeter::GetInstance().RemoveUnmanagedMeterWindow(this);
delete this;
}
break;
@ -3392,7 +3392,7 @@ LRESULT MeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
switch (wParam)
{
case IDM_SKIN_EDITSKIN:
GetRainmeter().EditSkinFile(m_FolderPath, m_FileName);
Rainmeter::GetInstance().EditSkinFile(m_FolderPath, m_FileName);
break;
case IDM_SKIN_REFRESH:
@ -3400,7 +3400,7 @@ LRESULT MeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
break;
case IDM_SKIN_OPENSKINSFOLDER:
GetRainmeter().OpenSkinFolder(m_FolderPath);
Rainmeter::GetInstance().OpenSkinFolder(m_FolderPath);
break;
case IDM_SKIN_MANAGESKIN:
@ -3466,7 +3466,7 @@ LRESULT MeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
case IDM_CLOSESKIN:
if (m_State != STATE_CLOSING)
{
GetRainmeter().DeactivateSkin(this, -1);
Rainmeter::GetInstance().DeactivateSkin(this, -1);
}
break;
@ -3556,13 +3556,13 @@ LRESULT MeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
if (!action.empty())
{
GetRainmeter().ExecuteCommand(action.c_str(), this);
Rainmeter::GetInstance().ExecuteCommand(action.c_str(), this);
}
}
else
{
// Forward to tray window, which handles all the other commands
HWND tray = GetRainmeter().GetTrayWindow()->GetWindow();
HWND tray = Rainmeter::GetInstance().GetTrayWindow()->GetWindow();
if (wParam == IDM_QUIT)
{
@ -3780,7 +3780,7 @@ LRESULT MeterWindow::OnExitSizeMove(UINT uMsg, WPARAM wParam, LPARAM lParam)
*/
LRESULT MeterWindow::OnNcHitTest(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (m_WindowDraggable && !GetRainmeter().GetDisableDragging())
if (m_WindowDraggable && !Rainmeter::GetInstance().GetDisableDragging())
{
POINT pos;
pos.x = GET_X_LPARAM(lParam);
@ -3820,7 +3820,7 @@ LRESULT MeterWindow::OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lParam
if (m_State != STATE_REFRESHING)
{
if (m_WindowZPosition == ZPOSITION_NORMAL && GetRainmeter().IsNormalStayDesktop() && System::GetShowDesktop())
if (m_WindowZPosition == ZPOSITION_NORMAL && Rainmeter::GetInstance().IsNormalStayDesktop() && System::GetShowDesktop())
{
if (!(wp->flags & (SWP_NOOWNERZORDER | SWP_NOACTIVATE)))
{
@ -3865,7 +3865,7 @@ LRESULT MeterWindow::OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lParam
}
// Snap to other windows
for (auto iter = GetRainmeter().GetAllMeterWindows().cbegin(); iter != GetRainmeter().GetAllMeterWindows().cend(); ++iter)
for (auto iter = Rainmeter::GetInstance().GetAllMeterWindows().cbegin(); iter != Rainmeter::GetInstance().GetAllMeterWindows().cend(); ++iter)
{
if ((*iter).second != this)
{
@ -4348,14 +4348,14 @@ LRESULT MeterWindow::OnSetWindowFocus(UINT uMsg, WPARAM wParam, LPARAM lParam)
case WM_SETFOCUS:
if (!m_OnFocusAction.empty())
{
GetRainmeter().ExecuteCommand(m_OnFocusAction.c_str(), this);
Rainmeter::GetInstance().ExecuteCommand(m_OnFocusAction.c_str(), this);
}
break;
case WM_KILLFOCUS:
if (!m_OnUnfocusAction.empty())
{
GetRainmeter().ExecuteCommand(m_OnUnfocusAction.c_str(), this);
Rainmeter::GetInstance().ExecuteCommand(m_OnUnfocusAction.c_str(), this);
}
break;
}
@ -4398,7 +4398,7 @@ LRESULT MeterWindow::OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam)
}
}
GetRainmeter().ShowContextMenu(pos, this);
Rainmeter::GetInstance().ShowContextMenu(pos, this);
return 0;
}
@ -4439,7 +4439,7 @@ bool MeterWindow::DoAction(int x, int y, MOUSEACTION action, bool test)
{
if (!test)
{
GetRainmeter().ExecuteCommand(command.c_str(), this);
Rainmeter::GetInstance().ExecuteCommand(command.c_str(), this);
}
return true;
@ -4475,7 +4475,7 @@ bool MeterWindow::DoMoveAction(int x, int y, MOUSEACTION action)
if (!m_Mouse.GetOverAction().empty())
{
UINT currCounter = m_MouseMoveCounter;
GetRainmeter().ExecuteCommand(m_Mouse.GetOverAction().c_str(), this);
Rainmeter::GetInstance().ExecuteCommand(m_Mouse.GetOverAction().c_str(), this);
return (currCounter == m_MouseMoveCounter);
}
}
@ -4512,7 +4512,7 @@ bool MeterWindow::DoMoveAction(int x, int y, MOUSEACTION action)
if (!mouse.GetOverAction().empty())
{
UINT currCounter = m_MouseMoveCounter;
GetRainmeter().ExecuteCommand(mouse.GetOverAction().c_str(), this);
Rainmeter::GetInstance().ExecuteCommand(mouse.GetOverAction().c_str(), this);
return (currCounter == m_MouseMoveCounter);
}
}
@ -4538,7 +4538,7 @@ bool MeterWindow::DoMoveAction(int x, int y, MOUSEACTION action)
const Mouse& mouse = (*j)->GetMouse();
if (!mouse.GetLeaveAction().empty())
{
GetRainmeter().ExecuteCommand(mouse.GetLeaveAction().c_str(), this);
Rainmeter::GetInstance().ExecuteCommand(mouse.GetLeaveAction().c_str(), this);
return true;
}
}
@ -4561,7 +4561,7 @@ bool MeterWindow::DoMoveAction(int x, int y, MOUSEACTION action)
if (!m_Mouse.GetOverAction().empty())
{
UINT currCounter = m_MouseMoveCounter;
GetRainmeter().ExecuteCommand(m_Mouse.GetOverAction().c_str(), this);
Rainmeter::GetInstance().ExecuteCommand(m_Mouse.GetOverAction().c_str(), this);
return (currCounter == m_MouseMoveCounter);
}
}
@ -4581,7 +4581,7 @@ bool MeterWindow::DoMoveAction(int x, int y, MOUSEACTION action)
if (!m_Mouse.GetLeaveAction().empty())
{
GetRainmeter().ExecuteCommand(m_Mouse.GetLeaveAction().c_str(), this);
Rainmeter::GetInstance().ExecuteCommand(m_Mouse.GetLeaveAction().c_str(), this);
return true;
}
}
@ -4658,7 +4658,7 @@ LRESULT MeterWindow::OnWake(UINT uMsg, WPARAM wParam, LPARAM lParam)
{
if (wParam == PBT_APMRESUMEAUTOMATIC && !m_OnWakeAction.empty())
{
GetRainmeter().ExecuteCommand(m_OnWakeAction.c_str(), this);
Rainmeter::GetInstance().ExecuteCommand(m_OnWakeAction.c_str(), this);
}
return 0;
@ -4783,10 +4783,10 @@ LRESULT MeterWindow::OnCopyData(UINT uMsg, WPARAM wParam, LPARAM lParam)
if (pCopyDataStruct && (pCopyDataStruct->dwData == 1) && (pCopyDataStruct->cbData > 0))
{
if (GetRainmeter().HasMeterWindow(this))
if (Rainmeter::GetInstance().HasMeterWindow(this))
{
const WCHAR* command = (const WCHAR*)pCopyDataStruct->lpData;
GetRainmeter().ExecuteCommand(command, this);
Rainmeter::GetInstance().ExecuteCommand(command, this);
}
else
{
@ -4841,8 +4841,8 @@ void MeterWindow::MakePathAbsolute(std::wstring& path)
else
{
std::wstring absolute;
absolute.reserve(GetRainmeter().GetSkinPath().size() + m_FolderPath.size() + 1 + path.size());
absolute = GetRainmeter().GetSkinPath();
absolute.reserve(Rainmeter::GetInstance().GetSkinPath().size() + m_FolderPath.size() + 1 + path.size());
absolute = Rainmeter::GetInstance().GetSkinPath();
absolute += m_FolderPath;
absolute += L'\\';
absolute += path;
@ -4852,7 +4852,7 @@ void MeterWindow::MakePathAbsolute(std::wstring& path)
std::wstring MeterWindow::GetFilePath()
{
std::wstring file = GetRainmeter().GetSkinPath() + m_FolderPath;
std::wstring file = Rainmeter::GetInstance().GetSkinPath() + m_FolderPath;
file += L'\\';
file += m_FileName;
return file;
@ -4871,7 +4871,7 @@ std::wstring MeterWindow::GetRootName()
std::wstring MeterWindow::GetRootPath()
{
std::wstring path = GetRainmeter().GetSkinPath();
std::wstring path = Rainmeter::GetInstance().GetSkinPath();
std::wstring::size_type loc;
if ((loc = m_FolderPath.find_first_of(L'\\')) != std::wstring::npos)