diff --git a/Library/AboutDialog.cpp b/Library/AboutDialog.cpp index 37a4ec26..4ecf3d4f 100644 --- a/Library/AboutDialog.cpp +++ b/Library/AboutDialog.cpp @@ -108,7 +108,7 @@ void UpdateAboutDialog() { int sel = 3; - std::map& windows = Rainmeter->GetAllMeterWindows(); + const std::map& windows = Rainmeter->GetAllMeterWindows(); std::map::const_iterator iter = windows.begin(); for( ; iter != windows.end(); ++iter) { @@ -181,7 +181,7 @@ void UpdateAboutStatistics(LPCTSTR entryName) { int current = 3; - std::map& windows = Rainmeter->GetAllMeterWindows(); + const std::map& windows = Rainmeter->GetAllMeterWindows(); std::map::const_iterator iter = windows.begin(); for( ; iter != windows.end(); ++iter) { @@ -192,7 +192,7 @@ void UpdateAboutStatistics(LPCTSTR entryName) int count = ListView_GetItemCount(widget); CMeterWindow* meterWindow = (*iter).second; - std::list& measures = meterWindow->GetMeasures(); + const std::list& measures = meterWindow->GetMeasures(); int index = 0; std::list::const_iterator i = measures.begin(); @@ -440,7 +440,7 @@ BOOL OnInitAboutDialog(HWND window) // Add entries for each config widget = GetDlgItem(window, IDC_ABOUT_ENTRIES); - std::map& windows = Rainmeter->GetAllMeterWindows(); + const std::map& windows = Rainmeter->GetAllMeterWindows(); std::map::const_iterator iter = windows.begin(); for( ; iter != windows.end(); ++iter) { diff --git a/Library/Group.cpp b/Library/Group.cpp index 07f403c4..756cb21a 100644 --- a/Library/Group.cpp +++ b/Library/Group.cpp @@ -25,22 +25,25 @@ ** ** */ -void CGroup::InitializeGroup(const std::wstring& group) +void CGroup::InitializeGroup(const std::wstring& groups) { - if (group != m_OldGroup) + if (groups != m_OldGroups) { - m_OldGroup = group; - m_Group.clear(); + m_OldGroups = groups; + m_Groups.clear(); - std::vector vGroup = CConfigParser::Tokenize(group, L"|"); - - std::vector::const_iterator iter = vGroup.begin(); - for ( ; iter != vGroup.end(); ++iter) + if (!groups.empty()) { - std::wstring group = CreateGroup(*iter); - if (!group.empty()) + std::vector vGroups = CConfigParser::Tokenize(groups, L"|"); + + std::vector::const_iterator iter = vGroups.begin(); + for ( ; iter != vGroups.end(); ++iter) { - m_Group.insert(group); + std::wstring group = CreateGroup(*iter); + if (!group.empty()) + { + m_Groups.insert(group); + } } } } @@ -53,7 +56,7 @@ void CGroup::InitializeGroup(const std::wstring& group) */ bool CGroup::BelongsToGroup(const std::wstring& group) { - return (m_Group.find(CreateGroup(group)) != m_Group.end()); + return (m_Groups.find(CreateGroup(group)) != m_Groups.end()); } std::wstring CGroup::CreateGroup(const std::wstring& str) diff --git a/Library/Group.h b/Library/Group.h index 0d4e0dcc..c715a0ed 100644 --- a/Library/Group.h +++ b/Library/Group.h @@ -21,7 +21,6 @@ #pragma warning(disable: 4786) -#include #include #include @@ -29,19 +28,18 @@ class CGroup { public: bool BelongsToGroup(const std::wstring& group); - const std::set& GetGroup() { return m_Group; } protected: CGroup() {} virtual ~CGroup() {} - void InitializeGroup(const std::wstring& group); + void InitializeGroup(const std::wstring& groups); private: std::wstring CreateGroup(const std::wstring& str); - std::set m_Group; - std::wstring m_OldGroup; + std::set m_Groups; + std::wstring m_OldGroups; }; diff --git a/Library/Measure.cpp b/Library/Measure.cpp index df4765b1..c6699134 100644 --- a/Library/Measure.cpp +++ b/Library/Measure.cpp @@ -173,14 +173,15 @@ void CMeasure::ReadConfig(CConfigParser& parser, const WCHAR* section) (subs[0] != L'\'' || subs[subs.length() - 1] != L'\"')) { // Add quotes since they are removed by the GetProfileString - subs = L"\"" + subs + L"\""; + subs.insert(0, L"\""); + subs.append(L"\""); } if (!ParseSubstitute(subs)) { LogWithArgs(LOG_WARNING, L"Incorrect substitute string: %s", subs.c_str()); } - std::wstring group = parser.ReadString(section, L"Group", L""); + const std::wstring& group = parser.ReadString(section, L"Group", L""); InitializeGroup(group); } diff --git a/Library/MeasureCalc.cpp b/Library/MeasureCalc.cpp index b68070f0..7e3422fe 100644 --- a/Library/MeasureCalc.cpp +++ b/Library/MeasureCalc.cpp @@ -102,7 +102,7 @@ void CMeasureCalc::UpdateVariableMap(CMeterWindow& meterWindow) // Create the variable map c_VarMap = Strmap_Create(sizeof(double), 0); - std::list& measures = meterWindow.GetMeasures(); + const std::list& measures = meterWindow.GetMeasures(); std::list::const_iterator iter = measures.begin(); for( ; iter != measures.end(); ++iter) @@ -199,11 +199,11 @@ void CMeasureCalc::FormulaReplace() */ bool CMeasureCalc::IsDelimiter(WCHAR ch) { - const WCHAR symbols[] = L" \t\n()+-/*^~<>%$,?:=&|;"; + const WCHAR* symbols = L" \t\n()+-/*^~<>%$,?:=&|;"; - for (size_t i = 0, len = wcslen(symbols); i < len; ++i) + for (const WCHAR* sch = symbols; *sch != L'\0'; ++sch) { - if (ch == symbols[i]) + if (ch == *sch) { return true; } diff --git a/Library/MeasureRegistry.cpp b/Library/MeasureRegistry.cpp index d6f6b6a1..4d9ae858 100644 --- a/Library/MeasureRegistry.cpp +++ b/Library/MeasureRegistry.cpp @@ -117,8 +117,7 @@ void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section) { CMeasure::ReadConfig(parser, section); - std::wstring keyname = parser.ReadString(section, L"RegHKey", L"HKEY_CURRENT_USER"); - + const std::wstring& keyname = parser.ReadString(section, L"RegHKey", L"HKEY_CURRENT_USER"); if(_wcsicmp(keyname.c_str(), L"HKEY_CLASSES_ROOT") == 0) { m_HKey = HKEY_CLASSES_ROOT; diff --git a/Library/MeasureTime.cpp b/Library/MeasureTime.cpp index e10028c3..f81c6348 100644 --- a/Library/MeasureTime.cpp +++ b/Library/MeasureTime.cpp @@ -115,9 +115,8 @@ bool CMeasureTime::Update() m_Time.LowPart = ftUTCTime.dwLowDateTime; m_Time.QuadPart += m_DeltaTime.QuadPart; - m_Value = (double)(m_Time.QuadPart / 10000000); - if (m_Format.size() != 0) + if (m_Format.size() > 0) { // If there is some date format, parse the value from it instead WCHAR tmpSz[MAX_LINE_LENGTH]; @@ -157,6 +156,10 @@ bool CMeasureTime::Update() m_Value = wcstod(tmpSz, NULL); } + else + { + m_Value = (double)(m_Time.QuadPart / 10000000); + } return PostUpdate(); } @@ -229,14 +232,12 @@ void CMeasureTime::ReadConfig(CConfigParser& parser, const WCHAR* section) m_Format = parser.ReadString(section, L"Format", L""); std::wstring timezone = parser.ReadString(section, L"TimeZone", L"local"); - bool dst = 1 == parser.ReadInt(section, L"DaylightSavingTime", 1); - - SYSTEMTIME sysLocalTime, sysUTCTime; - GetLocalTime(&sysLocalTime); - GetSystemTime(&sysUTCTime); - if (_wcsicmp(L"local", timezone.c_str()) == 0) { + SYSTEMTIME sysLocalTime, sysUTCTime; + GetLocalTime(&sysLocalTime); + GetSystemTime(&sysUTCTime); + FILETIME ftLocalTime, ftUTCTime; SystemTimeToFileTime(&sysLocalTime, &ftLocalTime); SystemTimeToFileTime(&sysUTCTime, &ftUTCTime); @@ -252,6 +253,7 @@ void CMeasureTime::ReadConfig(CConfigParser& parser, const WCHAR* section) else { double zone = wcstod(timezone.c_str(), NULL); + bool dst = 1 == parser.ReadInt(section, L"DaylightSavingTime", 1); struct tm* today; time_t now; diff --git a/Library/Meter.cpp b/Library/Meter.cpp index d9eee503..1e55bb07 100644 --- a/Library/Meter.cpp +++ b/Library/Meter.cpp @@ -105,7 +105,7 @@ int CMeter::GetX(bool abs) { if (m_RelativeMeter == NULL) { - std::list& meters = m_MeterWindow->GetMeters(); + const std::list& meters = m_MeterWindow->GetMeters(); std::list::const_iterator iter = meters.begin(); // Find this meter @@ -153,7 +153,7 @@ int CMeter::GetY(bool abs) { if (m_RelativeMeter == NULL) { - std::list& meters = m_MeterWindow->GetMeters(); + const std::list& meters = m_MeterWindow->GetMeters(); std::list::const_iterator iter = meters.begin(); // Find this meter @@ -431,7 +431,7 @@ void CMeter::ReadConfig(const WCHAR* section) LogWithArgs(LOG_WARNING, L"The transformation matrix has incorrect number of values: %s", parser.ReadString(section, L"TransformationMatrix", L"").c_str()); } - std::wstring group = parser.ReadString(section, L"Group", L""); + const std::wstring& group = parser.ReadString(section, L"Group", L""); InitializeGroup(group); } @@ -585,7 +585,7 @@ void CMeter::ReadMeasureNames(CConfigParser& parser, const WCHAR* section, std:: do { _snwprintf_s(tmpName, _TRUNCATE, L"MeasureName%i", i); - std::wstring measure = parser.ReadString(section, tmpName, L""); + const std::wstring& measure = parser.ReadString(section, tmpName, L""); if (!measure.empty()) { measureNames.push_back(measure); diff --git a/Library/MeterBar.cpp b/Library/MeterBar.cpp index fdac2eac..3ea09bba 100644 --- a/Library/MeterBar.cpp +++ b/Library/MeterBar.cpp @@ -121,8 +121,7 @@ void CMeterBar::ReadConfig(const WCHAR* section) m_Flip = parser.ReadInt(section, L"Flip", 0) == 1; - std::wstring orientation = parser.ReadString(section, L"BarOrientation", L"VERTICAL"); - + const std::wstring& orientation = parser.ReadString(section, L"BarOrientation", L"VERTICAL"); if(_wcsicmp(L"VERTICAL", orientation.c_str()) == 0) { m_Orientation = VERTICAL; diff --git a/Library/MeterBitmap.cpp b/Library/MeterBitmap.cpp index 2c6eb1d4..dfc1b29d 100644 --- a/Library/MeterBitmap.cpp +++ b/Library/MeterBitmap.cpp @@ -197,8 +197,7 @@ void CMeterBitmap::ReadConfig(const WCHAR* section) m_TransitionFrameCount = parser.ReadInt(section, L"BitmapTransitionFrames", 0); - std::wstring align = parser.ReadString(section, L"BitmapAlign", L"LEFT"); - + const std::wstring& align = parser.ReadString(section, L"BitmapAlign", L"LEFT"); if(_wcsicmp(align.c_str(), L"LEFT") == 0) { m_Align = ALIGN_LEFT; diff --git a/Library/MeterString.cpp b/Library/MeterString.cpp index 650bffa7..4a1236a5 100644 --- a/Library/MeterString.cpp +++ b/Library/MeterString.cpp @@ -333,7 +333,7 @@ void CMeterString::ReadConfig(const WCHAR* section) m_Angle = (Gdiplus::REAL)parser.ReadFloat(section, L"Angle", 0.0); - std::wstring autoscale = parser.ReadString(section, L"AutoScale", L"0"); + const std::wstring& autoscale = parser.ReadString(section, L"AutoScale", L"0"); int autoscaleValue = _wtoi(autoscale.c_str()); if (autoscaleValue == 0) { @@ -351,7 +351,7 @@ void CMeterString::ReadConfig(const WCHAR* section) } } - std::wstring scale = parser.ReadString(section, L"Scale", L"1"); + const std::wstring& scale = parser.ReadString(section, L"Scale", L"1"); if (scale.find(L'.') == std::wstring::npos) { m_NoDecimals = true; @@ -362,7 +362,7 @@ void CMeterString::ReadConfig(const WCHAR* section) } m_Scale = wcstod(scale.c_str(), NULL); - std::wstring align = parser.ReadString(section, L"StringAlign", L"LEFT"); + const std::wstring& align = parser.ReadString(section, L"StringAlign", L"LEFT"); if(_wcsicmp(align.c_str(), L"LEFT") == 0) { m_Align = ALIGN_LEFT; @@ -384,7 +384,7 @@ void CMeterString::ReadConfig(const WCHAR* section) throw CError(error, __LINE__, __FILE__); } - std::wstring stringCase = parser.ReadString(section, L"StringCase", L"NONE"); + const std::wstring& stringCase = parser.ReadString(section, L"StringCase", L"NONE"); if(_wcsicmp(stringCase.c_str(), L"NONE") == 0) { m_textCase = TEXTCASE_NONE; @@ -410,7 +410,7 @@ void CMeterString::ReadConfig(const WCHAR* section) throw CError(error, __LINE__, __FILE__); } - std::wstring style = parser.ReadString(section, L"StringStyle", L"NORMAL"); + const std::wstring& style = parser.ReadString(section, L"StringStyle", L"NORMAL"); if(_wcsicmp(style.c_str(), L"NORMAL") == 0) { m_Style = NORMAL; @@ -436,7 +436,7 @@ void CMeterString::ReadConfig(const WCHAR* section) throw CError(error, __LINE__, __FILE__); } - std::wstring effect = parser.ReadString(section, L"StringEffect", L"NONE"); + const std::wstring& effect = parser.ReadString(section, L"StringEffect", L"NONE"); if(_wcsicmp(effect.c_str(), L"NONE") == 0) { m_Effect = EFFECT_NONE; diff --git a/Library/MeterString.h b/Library/MeterString.h index 5cb04d09..9328f006 100644 --- a/Library/MeterString.h +++ b/Library/MeterString.h @@ -68,7 +68,7 @@ private: TEXTCASE_NONE, TEXTCASE_UPPER, TEXTCASE_LOWER, - TEXTCASE_PROPER, + TEXTCASE_PROPER }; bool DrawString(Gdiplus::Graphics& graphics, Gdiplus::RectF* rect); diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 148db206..b0ab8e0f 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -3783,7 +3783,7 @@ LRESULT CMeterWindow::OnWindowPosChanging(UINT uMsg, WPARAM wParam, LPARAM lPara } // Snap to other windows - std::map& windows = Rainmeter->GetAllMeterWindows(); + const std::map& windows = Rainmeter->GetAllMeterWindows(); std::map::const_iterator iter = windows.begin(); for( ; iter != windows.end(); ++iter) { @@ -4710,7 +4710,7 @@ LRESULT CMeterWindow::OnCopyData(UINT uMsg, WPARAM wParam, LPARAM lParam) { // Check that we're still alive bool found = false; - std::map& meters = Rainmeter->GetAllMeterWindows(); + const std::map& meters = Rainmeter->GetAllMeterWindows(); std::map::const_iterator iter = meters.begin(); for ( ; iter != meters.end(); ++iter) diff --git a/Library/System.cpp b/Library/System.cpp index 717c3655..06538be7 100644 --- a/Library/System.cpp +++ b/Library/System.cpp @@ -980,7 +980,7 @@ LRESULT CALLBACK CSystem::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP if (Rainmeter) { // Deliver WM_DISPLAYCHANGE / WM_SETTINGCHANGE message to all meter windows - std::map& windows = Rainmeter->GetAllMeterWindows(); + const std::map& windows = Rainmeter->GetAllMeterWindows(); std::map::const_iterator iter = windows.begin(); for( ; iter != windows.end(); ++iter) { diff --git a/Library/TrayWindow.cpp b/Library/TrayWindow.cpp index 8f871830..ec332352 100644 --- a/Library/TrayWindow.cpp +++ b/Library/TrayWindow.cpp @@ -530,7 +530,7 @@ LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA { // Forward the message to correct window int index = (int)(wParam >> 16); - std::map& windows = Rainmeter->GetAllMeterWindows(); + const std::map& windows = Rainmeter->GetAllMeterWindows(); if (index < (int)windows.size()) {