2009-02-10 18:37:48 +00:00
|
|
|
/*
|
|
|
|
Copyright (C) 2004 Kimmo Pekkola
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU General Public License
|
|
|
|
as published by the Free Software Foundation; either version 2
|
|
|
|
of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
2012-01-23 06:36:15 +00:00
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2009-02-10 18:37:48 +00:00
|
|
|
*/
|
|
|
|
|
2009-10-07 16:45:14 +00:00
|
|
|
#include "StdAfx.h"
|
2013-06-13 14:00:24 +00:00
|
|
|
#include "../Common/MathParser.h"
|
2013-06-12 18:14:55 +00:00
|
|
|
#include "../Common/PathUtil.h"
|
2009-02-10 18:37:48 +00:00
|
|
|
#include "ConfigParser.h"
|
|
|
|
#include "Litestep.h"
|
|
|
|
#include "Rainmeter.h"
|
2010-03-20 19:40:30 +00:00
|
|
|
#include "System.h"
|
2011-02-07 08:02:12 +00:00
|
|
|
#include "Measure.h"
|
2012-08-01 17:52:50 +00:00
|
|
|
#include "Meter.h"
|
2011-09-24 13:10:31 +00:00
|
|
|
#include "resource.h"
|
2009-02-10 18:37:48 +00:00
|
|
|
|
|
|
|
using namespace Gdiplus;
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
std::unordered_map<std::wstring, std::wstring> ConfigParser::c_MonitorVariables;
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
/*
|
|
|
|
** The constructor
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
ConfigParser::ConfigParser() :
|
2011-01-29 00:11:01 +00:00
|
|
|
m_LastReplaced(false),
|
2011-11-01 04:56:46 +00:00
|
|
|
m_LastDefaultUsed(false),
|
2011-11-26 02:49:52 +00:00
|
|
|
m_LastValueDefined(false),
|
2012-08-15 18:17:57 +00:00
|
|
|
m_CurrentSection(),
|
|
|
|
m_MeterWindow()
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** The destructor
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
ConfigParser::~ConfigParser()
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void ConfigParser::Initialize(const std::wstring& filename, MeterWindow* meterWindow, LPCTSTR skinSection, const std::wstring* resourcePath)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2012-08-15 18:17:57 +00:00
|
|
|
m_MeterWindow = meterWindow;
|
|
|
|
|
2009-08-26 17:37:15 +00:00
|
|
|
m_Measures.clear();
|
2009-09-19 07:15:28 +00:00
|
|
|
m_Sections.clear();
|
2011-11-08 10:32:57 +00:00
|
|
|
m_Values.clear();
|
|
|
|
m_BuiltInVariables.clear();
|
|
|
|
m_Variables.clear();
|
2009-08-26 17:37:15 +00:00
|
|
|
|
2011-11-01 04:56:46 +00:00
|
|
|
m_StyleTemplate.clear();
|
|
|
|
m_LastReplaced = false;
|
|
|
|
m_LastDefaultUsed = false;
|
|
|
|
m_LastValueDefined = false;
|
|
|
|
|
2013-05-31 14:28:39 +00:00
|
|
|
m_CurrentSection = nullptr;
|
2012-07-18 10:41:58 +00:00
|
|
|
m_SectionInsertPos = m_Sections.end();
|
2011-11-26 02:49:52 +00:00
|
|
|
|
2010-08-24 01:07:29 +00:00
|
|
|
// Set the built-in variables. Do this before the ini file is read so that the paths can be used with @include
|
2012-05-21 11:19:25 +00:00
|
|
|
SetBuiltInVariables(filename, resourcePath, meterWindow);
|
2010-08-24 01:07:29 +00:00
|
|
|
ResetMonitorVariables(meterWindow);
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
System::UpdateIniFileMappingList();
|
2010-04-02 01:35:53 +00:00
|
|
|
|
2012-06-01 13:06:36 +00:00
|
|
|
ReadIniFile(filename, skinSection);
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
ReadVariables();
|
2011-07-06 09:00:44 +00:00
|
|
|
|
2011-07-15 16:54:47 +00:00
|
|
|
// Clear and minimize
|
2011-12-04 22:18:40 +00:00
|
|
|
m_FoundSections.clear();
|
|
|
|
m_ListVariables.clear();
|
2012-07-18 10:41:58 +00:00
|
|
|
m_SectionInsertPos = m_Sections.end();
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void ConfigParser::SetBuiltInVariables(const std::wstring& filename, const std::wstring* resourcePath, MeterWindow* meterWindow)
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
{
|
2012-05-24 11:15:46 +00:00
|
|
|
auto insertVariable = [&](const WCHAR* name, std::wstring value)
|
|
|
|
{
|
|
|
|
return m_BuiltInVariables.insert(std::make_pair(name, value));
|
|
|
|
};
|
|
|
|
|
2013-06-13 14:20:27 +00:00
|
|
|
insertVariable(L"PROGRAMPATH", GetRainmeter().GetPath());
|
|
|
|
insertVariable(L"PROGRAMDRIVE", GetRainmeter().GetDrive());
|
|
|
|
insertVariable(L"SETTINGSPATH", GetRainmeter().GetSettingsPath());
|
|
|
|
insertVariable(L"SKINSPATH", GetRainmeter().GetSkinPath());
|
|
|
|
insertVariable(L"PLUGINSPATH", GetRainmeter().GetPluginPath());
|
2013-06-12 18:14:55 +00:00
|
|
|
insertVariable(L"CURRENTPATH", PathUtil::GetFolderFromFilePath(filename));
|
2013-06-13 14:20:27 +00:00
|
|
|
insertVariable(L"ADDONSPATH", GetRainmeter().GetAddonPath());
|
2012-05-20 13:12:13 +00:00
|
|
|
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
if (meterWindow)
|
|
|
|
{
|
2012-06-01 13:06:36 +00:00
|
|
|
insertVariable(L"CURRENTFILE", meterWindow->GetFileName());
|
|
|
|
insertVariable(L"CURRENTCONFIG", meterWindow->GetFolderPath());
|
2013-09-15 12:05:06 +00:00
|
|
|
insertVariable(L"ROOTCONFIG", meterWindow->GetRootName());
|
2012-06-01 13:06:36 +00:00
|
|
|
insertVariable(L"ROOTCONFIGPATH", meterWindow->GetRootPath());
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
}
|
2011-11-26 02:49:52 +00:00
|
|
|
|
2012-05-24 11:15:46 +00:00
|
|
|
insertVariable(L"CRLF", L"\n");
|
2011-11-26 02:49:52 +00:00
|
|
|
|
2012-05-24 11:15:46 +00:00
|
|
|
m_CurrentSection = &(insertVariable(L"CURRENTSECTION", L"").first->second); // shortcut
|
2012-05-21 13:41:07 +00:00
|
|
|
|
|
|
|
if (resourcePath)
|
|
|
|
{
|
|
|
|
SetVariable(L"@", *resourcePath);
|
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2010-08-24 01:07:29 +00:00
|
|
|
** Sets all user-defined variables.
|
2009-02-10 18:37:48 +00:00
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void ConfigParser::ReadVariables()
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-11-12 15:36:05 +00:00
|
|
|
std::list<std::wstring>::const_iterator iter = m_ListVariables.begin();
|
2011-11-08 10:32:57 +00:00
|
|
|
for ( ; iter != m_ListVariables.end(); ++iter)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-11-08 10:32:57 +00:00
|
|
|
SetVariable((*iter), ReadString(L"Variables", (*iter).c_str(), L"", false));
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2009-08-26 17:37:15 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void ConfigParser::SetVariable(std::wstring strVariable, const std::wstring& strValue)
|
2009-08-26 17:37:15 +00:00
|
|
|
{
|
2012-09-21 19:30:44 +00:00
|
|
|
StrToUpperC(strVariable);
|
|
|
|
m_Variables[strVariable] = strValue;
|
2011-12-09 03:28:19 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void ConfigParser::SetBuiltInVariable(const std::wstring& strVariable, const std::wstring& strValue)
|
2012-09-21 19:30:44 +00:00
|
|
|
{
|
|
|
|
m_BuiltInVariables[strVariable] = strValue;
|
2010-08-24 01:07:29 +00:00
|
|
|
}
|
|
|
|
|
2012-04-06 12:29:41 +00:00
|
|
|
/*
|
2013-05-31 14:28:39 +00:00
|
|
|
** Gets a value for the variable. Returns nullptr if not found.
|
2011-03-29 19:21:57 +00:00
|
|
|
**
|
2010-08-24 01:07:29 +00:00
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
const std::wstring* ConfigParser::GetVariable(const std::wstring& strVariable)
|
2010-08-24 01:07:29 +00:00
|
|
|
{
|
2012-05-19 15:16:04 +00:00
|
|
|
const std::wstring strTmp = StrToUpper(strVariable);
|
2010-08-24 01:07:29 +00:00
|
|
|
|
|
|
|
// #1: Built-in variables
|
2011-02-18 16:26:58 +00:00
|
|
|
std::unordered_map<std::wstring, std::wstring>::const_iterator iter = m_BuiltInVariables.find(strTmp);
|
2010-08-24 01:07:29 +00:00
|
|
|
if (iter != m_BuiltInVariables.end())
|
|
|
|
{
|
2012-08-05 13:12:36 +00:00
|
|
|
return &(*iter).second;
|
2010-08-24 01:07:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// #2: Monitor variables
|
|
|
|
iter = c_MonitorVariables.find(strTmp);
|
|
|
|
if (iter != c_MonitorVariables.end())
|
|
|
|
{
|
2012-08-05 13:12:36 +00:00
|
|
|
return &(*iter).second;
|
2010-08-24 01:07:29 +00:00
|
|
|
}
|
|
|
|
|
2010-08-24 01:13:27 +00:00
|
|
|
// #3: User-defined variables
|
2010-08-24 01:07:29 +00:00
|
|
|
iter = m_Variables.find(strTmp);
|
|
|
|
if (iter != m_Variables.end())
|
|
|
|
{
|
2012-08-05 13:12:36 +00:00
|
|
|
return &(*iter).second;
|
2010-08-24 01:07:29 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:28:39 +00:00
|
|
|
return nullptr;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2012-08-01 17:52:50 +00:00
|
|
|
/*
|
2012-08-05 12:51:58 +00:00
|
|
|
** Gets the value of a section variable. Returns true if strValue is set.
|
|
|
|
** The selector is stripped from strVariable.
|
|
|
|
**
|
2012-08-01 17:52:50 +00:00
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
bool ConfigParser::GetSectionVariable(std::wstring& strVariable, std::wstring& strValue)
|
2012-08-01 17:52:50 +00:00
|
|
|
{
|
2012-08-05 12:51:58 +00:00
|
|
|
size_t colonPos = strVariable.find_last_of(L':');
|
|
|
|
if (colonPos == std::wstring::npos)
|
2012-08-01 17:52:50 +00:00
|
|
|
{
|
2012-08-05 12:51:58 +00:00
|
|
|
return false;
|
2012-08-01 17:52:50 +00:00
|
|
|
}
|
|
|
|
|
2012-08-05 12:51:58 +00:00
|
|
|
const std::wstring selector = strVariable.substr(colonPos + 1);
|
|
|
|
const WCHAR* selectorSz = selector.c_str();
|
|
|
|
strVariable.resize(colonPos);
|
2012-08-01 17:52:50 +00:00
|
|
|
|
2012-08-07 21:11:01 +00:00
|
|
|
bool isKeySelector = (!selector.empty() && iswalpha(selectorSz[0]));
|
|
|
|
|
|
|
|
if (isKeySelector)
|
2012-08-05 12:51:58 +00:00
|
|
|
{
|
|
|
|
// [Meter:X], [Meter:Y], [Meter:W], [Meter:H]
|
2013-05-31 14:18:52 +00:00
|
|
|
Meter* meter = m_MeterWindow->GetMeter(strVariable);
|
2012-08-01 17:52:50 +00:00
|
|
|
if (meter)
|
|
|
|
{
|
2012-08-05 12:51:58 +00:00
|
|
|
WCHAR buffer[32];
|
|
|
|
if (_wcsicmp(selectorSz, L"X") == 0)
|
2012-08-01 17:52:50 +00:00
|
|
|
{
|
|
|
|
_itow_s(meter->GetX(), buffer, 10);
|
|
|
|
}
|
2012-08-05 12:51:58 +00:00
|
|
|
else if (_wcsicmp(selectorSz, L"Y") == 0)
|
2012-08-01 17:52:50 +00:00
|
|
|
{
|
|
|
|
_itow_s(meter->GetY(), buffer, 10);
|
|
|
|
}
|
2012-08-05 12:51:58 +00:00
|
|
|
else if (_wcsicmp(selectorSz, L"W") == 0)
|
2012-08-01 17:52:50 +00:00
|
|
|
{
|
|
|
|
_itow_s(meter->GetW(), buffer, 10);
|
|
|
|
}
|
2012-08-05 12:51:58 +00:00
|
|
|
else if (_wcsicmp(selectorSz, L"H") == 0)
|
2012-08-01 17:52:50 +00:00
|
|
|
{
|
|
|
|
_itow_s(meter->GetH(), buffer, 10);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
strValue = buffer;
|
|
|
|
return true;
|
2012-08-05 12:51:58 +00:00
|
|
|
}
|
|
|
|
}
|
2012-08-07 21:11:01 +00:00
|
|
|
|
|
|
|
// Number: [Measure:], [Measure:dec]
|
|
|
|
// Percentual: [Measure:%], [Measure:%, dec]
|
|
|
|
// Scale: [Measure:/scale], [Measure:/scale, dec]
|
|
|
|
// Max/Min: [Measure:MaxValue], [Measure:MaxValue:/scale, dec] ('%' cannot be used)
|
|
|
|
enum VALUETYPE
|
|
|
|
{
|
|
|
|
RAW = 0,
|
|
|
|
PERCENTUAL = 1,
|
|
|
|
MAX = 2,
|
|
|
|
MIN = 3
|
|
|
|
} valueType = RAW;
|
|
|
|
|
|
|
|
if (isKeySelector)
|
2012-08-05 12:51:58 +00:00
|
|
|
{
|
2012-08-07 21:11:01 +00:00
|
|
|
if (_wcsicmp(selectorSz, L"MaxValue") == 0)
|
|
|
|
{
|
|
|
|
valueType = MAX;
|
|
|
|
}
|
|
|
|
else if (_wcsicmp(selectorSz, L"MinValue") == 0)
|
2012-08-01 17:52:50 +00:00
|
|
|
{
|
2012-08-07 21:11:01 +00:00
|
|
|
valueType = MIN;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2012-08-01 17:52:50 +00:00
|
|
|
|
2012-08-07 21:11:01 +00:00
|
|
|
selectorSz = L"";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
colonPos = strVariable.find_last_of(L':');
|
|
|
|
if (colonPos != std::wstring::npos)
|
|
|
|
{
|
|
|
|
do
|
2012-08-05 12:51:58 +00:00
|
|
|
{
|
2012-08-07 21:11:01 +00:00
|
|
|
const WCHAR* keySelectorSz = strVariable.c_str() + colonPos + 1;
|
2012-08-01 17:52:50 +00:00
|
|
|
|
2012-08-07 21:11:01 +00:00
|
|
|
if (_wcsicmp(keySelectorSz, L"MaxValue") == 0)
|
2012-08-01 21:47:10 +00:00
|
|
|
{
|
2012-08-07 21:11:01 +00:00
|
|
|
valueType = MAX;
|
2012-08-01 21:47:10 +00:00
|
|
|
}
|
2012-08-07 21:11:01 +00:00
|
|
|
else if (_wcsicmp(keySelectorSz, L"MinValue") == 0)
|
2012-08-01 21:47:10 +00:00
|
|
|
{
|
2012-08-07 21:11:01 +00:00
|
|
|
valueType = MIN;
|
2012-08-01 21:47:10 +00:00
|
|
|
}
|
2012-08-05 12:51:58 +00:00
|
|
|
else
|
2012-08-01 21:47:10 +00:00
|
|
|
{
|
2012-08-07 21:11:01 +00:00
|
|
|
// Section name contains ':' ?
|
|
|
|
break;
|
2012-08-01 21:47:10 +00:00
|
|
|
}
|
2012-08-07 21:11:01 +00:00
|
|
|
|
|
|
|
strVariable.resize(colonPos);
|
2012-08-01 17:52:50 +00:00
|
|
|
}
|
2012-08-07 21:11:01 +00:00
|
|
|
while (0);
|
|
|
|
}
|
|
|
|
}
|
2012-08-01 17:52:50 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
Measure* measure = m_MeterWindow->GetMeasure(strVariable);
|
2012-08-07 21:11:01 +00:00
|
|
|
if (measure)
|
|
|
|
{
|
2013-03-08 17:39:17 +00:00
|
|
|
int scale = 1;
|
2012-08-01 22:18:58 +00:00
|
|
|
|
2012-08-07 21:11:01 +00:00
|
|
|
const WCHAR* decimalsSz = wcschr(selectorSz, L',');
|
|
|
|
if (decimalsSz)
|
|
|
|
{
|
|
|
|
++decimalsSz;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*selectorSz == L'%') // Percentual
|
|
|
|
{
|
|
|
|
if (valueType == MAX || valueType == MIN) // '%' cannot be used with MAX/MIN value
|
2012-08-01 17:52:50 +00:00
|
|
|
{
|
2012-08-07 21:11:01 +00:00
|
|
|
return false;
|
2012-08-01 17:52:50 +00:00
|
|
|
}
|
2012-08-01 22:18:58 +00:00
|
|
|
|
2012-08-07 21:11:01 +00:00
|
|
|
valueType = PERCENTUAL;
|
|
|
|
}
|
|
|
|
else if (*selectorSz == L'/') // Scale
|
|
|
|
{
|
|
|
|
errno = 0;
|
|
|
|
scale = _wtoi(selectorSz + 1);
|
2013-03-08 17:39:17 +00:00
|
|
|
if (errno == EINVAL || scale == 0) // Invalid scale value
|
2012-08-07 21:11:01 +00:00
|
|
|
{
|
2013-03-08 17:39:17 +00:00
|
|
|
return false;
|
2012-08-07 21:11:01 +00:00
|
|
|
}
|
2012-08-01 17:52:50 +00:00
|
|
|
}
|
2012-08-07 21:11:01 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (decimalsSz)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
decimalsSz = selectorSz;
|
|
|
|
}
|
|
|
|
|
|
|
|
double value = (valueType == PERCENTUAL) ? measure->GetRelativeValue() * 100.0
|
|
|
|
: (valueType == MAX) ? measure->GetMaxValue() / scale
|
|
|
|
: (valueType == MIN) ? measure->GetMinValue() / scale
|
|
|
|
: measure->GetValue() / scale;
|
|
|
|
int decimals = 10;
|
|
|
|
|
|
|
|
if (decimalsSz)
|
|
|
|
{
|
|
|
|
while (iswspace(*decimalsSz)) ++decimalsSz;
|
|
|
|
|
|
|
|
if (*decimalsSz)
|
|
|
|
{
|
|
|
|
decimals = _wtoi(decimalsSz);
|
|
|
|
decimals = max(0, decimals);
|
|
|
|
decimals = min(32, decimals);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-31 14:28:39 +00:00
|
|
|
decimalsSz = nullptr;
|
2012-08-07 21:11:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
WCHAR format[32];
|
|
|
|
WCHAR buffer[128];
|
|
|
|
_snwprintf_s(format, _TRUNCATE, L"%%.%if", decimals);
|
|
|
|
int bufferLen = _snwprintf_s(buffer, _TRUNCATE, format, value);
|
|
|
|
|
|
|
|
if (!decimalsSz)
|
|
|
|
{
|
|
|
|
// Remove trailing zeros if decimal count was not specified.
|
|
|
|
measure->RemoveTrailingZero(buffer, bufferLen);
|
|
|
|
bufferLen = (int)wcslen(buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
strValue.assign(buffer, bufferLen);
|
|
|
|
return true;
|
2012-08-01 17:52:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void ConfigParser::ResetMonitorVariables(MeterWindow* meterWindow)
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
{
|
|
|
|
// Set the SCREENAREA/WORKAREA variables
|
|
|
|
if (c_MonitorVariables.empty())
|
|
|
|
{
|
|
|
|
SetMultiMonitorVariables(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the SCREENAREA/WORKAREA variables for present monitor
|
|
|
|
SetAutoSelectedMonitorVariables(meterWindow);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Sets new values for the SCREENAREA/WORKAREA variables.
|
2011-03-29 19:21:57 +00:00
|
|
|
**
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void ConfigParser::SetMultiMonitorVariables(bool reset)
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
{
|
2012-09-21 19:30:44 +00:00
|
|
|
auto setMonitorVariable = [&](const WCHAR* variable, const WCHAR* value)
|
|
|
|
{
|
|
|
|
c_MonitorVariables[variable] = value;
|
|
|
|
};
|
|
|
|
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
if (!reset && c_MonitorVariables.empty())
|
|
|
|
{
|
|
|
|
reset = true; // Set all variables
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
const size_t numOfMonitors = System::GetMonitorCount(); // intentional
|
|
|
|
const MultiMonitorInfo& monitorsInfo = System::GetMultiMonitorInfo();
|
2013-02-08 16:52:41 +00:00
|
|
|
const std::vector<MonitorInfo>& monitors = monitorsInfo.monitors;
|
|
|
|
|
|
|
|
WCHAR buffer[32];
|
|
|
|
const RECT workArea = monitors[monitorsInfo.primary - 1].work;
|
|
|
|
const RECT scrArea = monitors[monitorsInfo.primary - 1].screen;
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
|
2011-11-09 08:52:32 +00:00
|
|
|
_itow_s(workArea.left, buffer, 10);
|
2012-09-21 19:30:44 +00:00
|
|
|
setMonitorVariable(L"WORKAREAX", buffer);
|
|
|
|
setMonitorVariable(L"PWORKAREAX", buffer);
|
2011-11-09 08:52:32 +00:00
|
|
|
_itow_s(workArea.top, buffer, 10);
|
2012-09-21 19:30:44 +00:00
|
|
|
setMonitorVariable(L"WORKAREAY", buffer);
|
|
|
|
setMonitorVariable(L"PWORKAREAY", buffer);
|
2011-11-09 08:52:32 +00:00
|
|
|
_itow_s(workArea.right - workArea.left, buffer, 10);
|
2012-09-21 19:30:44 +00:00
|
|
|
setMonitorVariable(L"WORKAREAWIDTH", buffer);
|
|
|
|
setMonitorVariable(L"PWORKAREAWIDTH", buffer);
|
2011-11-09 08:52:32 +00:00
|
|
|
_itow_s(workArea.bottom - workArea.top, buffer, 10);
|
2012-09-21 19:30:44 +00:00
|
|
|
setMonitorVariable(L"WORKAREAHEIGHT", buffer);
|
|
|
|
setMonitorVariable(L"PWORKAREAHEIGHT", buffer);
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
|
|
|
|
if (reset)
|
|
|
|
{
|
2011-11-09 08:52:32 +00:00
|
|
|
_itow_s(scrArea.left, buffer, 10);
|
2012-09-21 19:30:44 +00:00
|
|
|
setMonitorVariable(L"SCREENAREAX", buffer);
|
|
|
|
setMonitorVariable(L"PSCREENAREAX", buffer);
|
2011-11-09 08:52:32 +00:00
|
|
|
_itow_s(scrArea.top, buffer, 10);
|
2012-09-21 19:30:44 +00:00
|
|
|
setMonitorVariable(L"SCREENAREAY", buffer);
|
|
|
|
setMonitorVariable(L"PSCREENAREAY", buffer);
|
2011-11-09 08:52:32 +00:00
|
|
|
_itow_s(scrArea.right - scrArea.left, buffer, 10);
|
2012-09-21 19:30:44 +00:00
|
|
|
setMonitorVariable(L"SCREENAREAWIDTH", buffer);
|
|
|
|
setMonitorVariable(L"PSCREENAREAWIDTH", buffer);
|
2011-11-09 08:52:32 +00:00
|
|
|
_itow_s(scrArea.bottom - scrArea.top, buffer, 10);
|
2012-09-21 19:30:44 +00:00
|
|
|
setMonitorVariable(L"SCREENAREAHEIGHT", buffer);
|
|
|
|
setMonitorVariable(L"PSCREENAREAHEIGHT", buffer);
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
|
2013-02-08 16:52:41 +00:00
|
|
|
_itow_s(monitorsInfo.vsL, buffer, 10);
|
2012-09-21 19:30:44 +00:00
|
|
|
setMonitorVariable(L"VSCREENAREAX", buffer);
|
2013-02-08 16:52:41 +00:00
|
|
|
_itow_s(monitorsInfo.vsT, buffer, 10);
|
2012-09-21 19:30:44 +00:00
|
|
|
setMonitorVariable(L"VSCREENAREAY", buffer);
|
2013-02-08 16:52:41 +00:00
|
|
|
_itow_s(monitorsInfo.vsW, buffer, 10);
|
2012-09-21 19:30:44 +00:00
|
|
|
setMonitorVariable(L"VSCREENAREAWIDTH", buffer);
|
2013-02-08 16:52:41 +00:00
|
|
|
_itow_s(monitorsInfo.vsH, buffer, 10);
|
2012-09-21 19:30:44 +00:00
|
|
|
setMonitorVariable(L"VSCREENAREAHEIGHT", buffer);
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
}
|
|
|
|
|
2013-02-08 16:52:41 +00:00
|
|
|
int i = 1;
|
|
|
|
for (auto iter = monitors.cbegin(); iter != monitors.cend(); ++iter, ++i)
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
{
|
2013-02-08 16:52:41 +00:00
|
|
|
WCHAR buffer2[64];
|
|
|
|
|
|
|
|
const RECT work = ((*iter).active) ? (*iter).work : workArea;
|
|
|
|
|
|
|
|
_itow_s(work.left, buffer, 10);
|
|
|
|
_snwprintf_s(buffer2, _TRUNCATE, L"WORKAREAX@%i", i);
|
|
|
|
setMonitorVariable(buffer2, buffer);
|
|
|
|
_itow_s(work.top, buffer, 10);
|
|
|
|
_snwprintf_s(buffer2, _TRUNCATE, L"WORKAREAY@%i", i);
|
|
|
|
setMonitorVariable(buffer2, buffer);
|
|
|
|
_itow_s(work.right - work.left, buffer, 10);
|
|
|
|
_snwprintf_s(buffer2, _TRUNCATE, L"WORKAREAWIDTH@%i", i);
|
|
|
|
setMonitorVariable(buffer2, buffer);
|
|
|
|
_itow_s(work.bottom - work.top, buffer, 10);
|
|
|
|
_snwprintf_s(buffer2, _TRUNCATE, L"WORKAREAHEIGHT@%i", i);
|
|
|
|
setMonitorVariable(buffer2, buffer);
|
|
|
|
|
|
|
|
if (reset)
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
{
|
2013-02-08 16:52:41 +00:00
|
|
|
const RECT screen = ((*iter).active) ? (*iter).screen : scrArea;
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
|
2013-02-08 16:52:41 +00:00
|
|
|
_itow_s(screen.left, buffer, 10);
|
|
|
|
_snwprintf_s(buffer2, _TRUNCATE, L"SCREENAREAX@%i", i);
|
2012-09-21 19:30:44 +00:00
|
|
|
setMonitorVariable(buffer2, buffer);
|
2013-02-08 16:52:41 +00:00
|
|
|
_itow_s(screen.top, buffer, 10);
|
|
|
|
_snwprintf_s(buffer2, _TRUNCATE, L"SCREENAREAY@%i", i);
|
2012-09-21 19:30:44 +00:00
|
|
|
setMonitorVariable(buffer2, buffer);
|
2013-02-08 16:52:41 +00:00
|
|
|
_itow_s(screen.right - screen.left, buffer, 10);
|
|
|
|
_snwprintf_s(buffer2, _TRUNCATE, L"SCREENAREAWIDTH@%i", i);
|
2012-09-21 19:30:44 +00:00
|
|
|
setMonitorVariable(buffer2, buffer);
|
2013-02-08 16:52:41 +00:00
|
|
|
_itow_s(screen.bottom - screen.top, buffer, 10);
|
|
|
|
_snwprintf_s(buffer2, _TRUNCATE, L"SCREENAREAHEIGHT@%i", i);
|
2012-09-21 19:30:44 +00:00
|
|
|
setMonitorVariable(buffer2, buffer);
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Sets new SCREENAREA/WORKAREA variables for present monitor.
|
2011-03-29 19:21:57 +00:00
|
|
|
**
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void ConfigParser::SetAutoSelectedMonitorVariables(MeterWindow* meterWindow)
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
{
|
|
|
|
if (meterWindow)
|
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
const int numOfMonitors = (int)System::GetMonitorCount();
|
|
|
|
const MultiMonitorInfo& monitorsInfo = System::GetMultiMonitorInfo();
|
2013-02-08 16:52:41 +00:00
|
|
|
const std::vector<MonitorInfo>& monitors = monitorsInfo.monitors;
|
|
|
|
|
2010-12-13 09:00:02 +00:00
|
|
|
WCHAR buffer[32];
|
2013-02-08 16:52:41 +00:00
|
|
|
int w1, w2, s1, s2;
|
|
|
|
int screenIndex;
|
2010-08-24 01:07:29 +00:00
|
|
|
|
2013-02-08 16:52:41 +00:00
|
|
|
// Set X / WIDTH
|
|
|
|
screenIndex = monitorsInfo.primary;
|
|
|
|
if (meterWindow->GetXScreenDefined())
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
{
|
2013-02-08 16:52:41 +00:00
|
|
|
int i = meterWindow->GetXScreen();
|
|
|
|
if (i >= 0 && (i == 0 || i <= numOfMonitors && monitors[i - 1].active))
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
{
|
2013-02-08 16:52:41 +00:00
|
|
|
screenIndex = i;
|
2010-08-24 01:07:29 +00:00
|
|
|
}
|
2013-02-08 16:52:41 +00:00
|
|
|
}
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
|
2013-02-08 16:52:41 +00:00
|
|
|
if (screenIndex == 0)
|
|
|
|
{
|
|
|
|
s1 = w1 = monitorsInfo.vsL;
|
|
|
|
s2 = w2 = monitorsInfo.vsW;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
w1 = monitors[screenIndex - 1].work.left;
|
|
|
|
w2 = monitors[screenIndex - 1].work.right - monitors[screenIndex - 1].work.left;
|
|
|
|
s1 = monitors[screenIndex - 1].screen.left;
|
|
|
|
s2 = monitors[screenIndex - 1].screen.right - monitors[screenIndex - 1].screen.left;
|
|
|
|
}
|
2010-08-24 01:07:29 +00:00
|
|
|
|
2013-02-08 16:52:41 +00:00
|
|
|
_itow_s(w1, buffer, 10);
|
|
|
|
SetBuiltInVariable(L"WORKAREAX", buffer);
|
|
|
|
_itow_s(w2, buffer, 10);
|
|
|
|
SetBuiltInVariable(L"WORKAREAWIDTH", buffer);
|
|
|
|
_itow_s(s1, buffer, 10);
|
|
|
|
SetBuiltInVariable(L"SCREENAREAX", buffer);
|
|
|
|
_itow_s(s2, buffer, 10);
|
|
|
|
SetBuiltInVariable(L"SCREENAREAWIDTH", buffer);
|
|
|
|
|
|
|
|
// Set Y / HEIGHT
|
|
|
|
screenIndex = monitorsInfo.primary;
|
|
|
|
if (meterWindow->GetYScreenDefined())
|
|
|
|
{
|
|
|
|
int i = meterWindow->GetYScreen();
|
|
|
|
if (i >= 0 && (i == 0 || i <= numOfMonitors && monitors[i - 1].active))
|
2010-08-24 01:07:29 +00:00
|
|
|
{
|
2013-02-08 16:52:41 +00:00
|
|
|
screenIndex = i;
|
2010-08-24 01:07:29 +00:00
|
|
|
}
|
2013-02-08 16:52:41 +00:00
|
|
|
}
|
2010-08-24 01:07:29 +00:00
|
|
|
|
2013-02-08 16:52:41 +00:00
|
|
|
if (screenIndex == 0)
|
|
|
|
{
|
|
|
|
s1 = w1 = monitorsInfo.vsL;
|
|
|
|
s2 = w2 = monitorsInfo.vsW;
|
2010-08-24 01:07:29 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-02-08 16:52:41 +00:00
|
|
|
w1 = monitors[screenIndex - 1].work.top;
|
|
|
|
w2 = monitors[screenIndex - 1].work.bottom - monitors[screenIndex - 1].work.top;
|
|
|
|
s1 = monitors[screenIndex - 1].screen.top;
|
|
|
|
s2 = monitors[screenIndex - 1].screen.bottom - monitors[screenIndex - 1].screen.top;
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
}
|
2013-02-08 16:52:41 +00:00
|
|
|
|
|
|
|
_itow_s(w1, buffer, 10);
|
|
|
|
SetBuiltInVariable(L"WORKAREAY", buffer);
|
|
|
|
_itow_s(w2, buffer, 10);
|
|
|
|
SetBuiltInVariable(L"WORKAREAHEIGHT", buffer);
|
|
|
|
_itow_s(s1, buffer, 10);
|
|
|
|
SetBuiltInVariable(L"SCREENAREAY", buffer);
|
|
|
|
_itow_s(s2, buffer, 10);
|
|
|
|
SetBuiltInVariable(L"SCREENAREAHEIGHT", buffer);
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-06 12:29:41 +00:00
|
|
|
/*
|
2009-09-18 15:30:51 +00:00
|
|
|
** Replaces environment and internal variables in the given string.
|
2011-03-29 19:21:57 +00:00
|
|
|
**
|
2009-09-18 15:30:51 +00:00
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
bool ConfigParser::ReplaceVariables(std::wstring& result)
|
2009-09-18 15:30:51 +00:00
|
|
|
{
|
2010-06-01 14:55:52 +00:00
|
|
|
bool replaced = false;
|
|
|
|
|
2013-06-12 18:14:55 +00:00
|
|
|
PathUtil::ExpandEnvironmentVariables(result);
|
2009-09-18 15:30:51 +00:00
|
|
|
|
* Changed the way to get the information of the multiple display monitors.
This change brings the order of monitors close to the order of "Display Properties" due to using EnumDisplayDevices and EnumDisplaySettings instead of EnumDisplayMonitors. (If EnumDisplayDevices failed, EnumDisplayMonitors is used as before.)
-----
* Added the "Display Monitor" submenu in [Skins Menu]-[Position].
These menus convert the present position to the relative position from the specified monitor.
(But the meter window doesn't move to the specified monitor area immediately. Only converts.)
- "Use default: Primary monitor" removes the @-directive from WindowX/Y.
- @0(@1, @2, ...) adds the specified monitor number to WindowX/Y. @0 means "The Virtual Screen". (http://msdn.microsoft.com/en-us/library/dd145136%28VS.85%29.aspx)
- If "Auto-select based on window position" is checked, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this menu is unchecked. This setting can be manually made in either the [Rainmeter] (all configs) or individual config sections of Rainmeter.ini.
AutoSelectScreen
If set to 1, the WindowX and WindowY "@n" settings are made automatically based on the position of the meter's window. If a monitor is selected directly using "Display Monitor" in the Rainmeter / skin context menu, this setting is reset to 0.
-----
* Added the variables for multiple display monitors and the virtual screen.
All X/Y positions are represented in the virtual screen coordinates.
The following variables are for the virtual screen.
#VSCREENAREAX# is the X-position of the left-side of the virtual screen.
#VSCREENAREAY# is the Y-position of the top-side of the virtual screen.
#VSCREENAREAWIDTH# is the width of the virtual screen.
#VSCREENAREAHEIGHT# is the height of the virtual screen.
The following variables are for the PRESENT monitor.
Note that these variables automatically change by the WindowX and WindowY "@n" settings. If "@n" is not set, these variables return the value of the primary monitor.
#WORKAREAX# is the X-position of the left-side of the work area.
#WORKAREAY# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH# is the width of the work area.
#WORKAREAHEIGHT# is the height of the work area.
#SCREENAREAX# is the X-position of the left-side of the monitor screen.
#SCREENAREAY# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH# is the width of the display resolution.
#SCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the PRIMARY monitor.
#PWORKAREAX# is the X-position of the left-side of the work area.
#PWORKAREAY# is the Y-position of the top-side of the work area.
#PWORKAREAWIDTH# is the width of the work area.
#PWORKAREAHEIGHT# is the height of the work area.
#PSCREENAREAX# is the X-position of the left-side of the monitor screen. (maybe, always 0)
#PSCREENAREAY# is the Y-position of the top-side of the monitor screen. (maybe, always 0)
#PSCREENAREAWIDTH# is the width of the display resolution.
#PSCREENAREAHEIGHT# is the height of the display resolution.
The following variables are for the SPECIFIED monitor. (@n = @1, @2, ...)
#WORKAREAX@n# is the X-position of the left-side of the work area.
#WORKAREAY@n# is the Y-position of the top-side of the work area.
#WORKAREAWIDTH@n# is the width of the work area.
#WORKAREAHEIGHT@n# is the height of the work area.
#SCREENAREAX@n# is the X-position of the left-side of the monitor screen.
#SCREENAREAY@n# is the Y-position of the top-side of the monitor screen.
#SCREENAREAWIDTH@n# is the width of the display resolution.
#SCREENAREAHEIGHT@n# is the height of the display resolution.
-----
* Other related changes:
- Fixed the problem that the primary monitor isn't recognized correctly.
- Fixed the problem that the information of the multiple display monitors is refreshed excessively.
- For DynamicVariables, when display setting or workarea size has been changed, all variables are now updated to apply changed WORKAREA/SCREENAREA variables.
- Fixed the problem that the "On Desktop" window isn't dragged correctly when the top-left corner of the virtual screen has negative coordinates.
- Changed the way to stick the "On Desktop" window. ("SysListView32/FolderView" is used instead of "Progman/Program Manager".)
-----
* Other changes:
- When the meter window is draggable and isn't dragged, LeftMouseUpAction is now executed.
- Added MouseDoubleClickAction (LeftMouseDoubleClickAction, RightMouseDoubleClickAction, MiddleMouseDoubleClickAction). If MouseDoubleClickAction is empty when mouse button is double-clicked, MouseDownAction is executed instead.
- Fixed the problem that the Meter's hit-test code checks outside the area.
- Changed the way to set the #CURRENTCONFIG#. (CMeterWindow::GetSkinName() is now used instead of parsing the path.)
2009-12-18 05:58:37 +00:00
|
|
|
if (c_MonitorVariables.empty())
|
|
|
|
{
|
|
|
|
SetMultiMonitorVariables(true);
|
|
|
|
}
|
|
|
|
|
2009-09-18 15:30:51 +00:00
|
|
|
// Check for variables (#VAR#)
|
2011-11-10 13:44:19 +00:00
|
|
|
size_t start = 0, end;
|
2009-09-18 15:30:51 +00:00
|
|
|
bool loop = true;
|
|
|
|
|
2011-03-29 19:21:57 +00:00
|
|
|
do
|
2009-09-18 15:30:51 +00:00
|
|
|
{
|
2011-11-10 13:44:19 +00:00
|
|
|
start = result.find(L'#', start);
|
|
|
|
if (start != std::wstring::npos)
|
2009-09-18 15:30:51 +00:00
|
|
|
{
|
2011-11-10 13:44:19 +00:00
|
|
|
size_t si = start + 1;
|
|
|
|
end = result.find(L'#', si);
|
2009-09-18 15:30:51 +00:00
|
|
|
if (end != std::wstring::npos)
|
|
|
|
{
|
2011-11-10 13:44:19 +00:00
|
|
|
size_t ei = end - 1;
|
2011-11-26 02:49:52 +00:00
|
|
|
if (si != ei && result[si] == L'*' && result[ei] == L'*')
|
2009-09-18 15:30:51 +00:00
|
|
|
{
|
2011-11-10 13:44:19 +00:00
|
|
|
result.erase(ei, 1);
|
|
|
|
result.erase(si, 1);
|
|
|
|
start = ei;
|
2009-09-18 15:30:51 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-10 13:44:19 +00:00
|
|
|
std::wstring strVariable = result.substr(si, end - si);
|
2012-08-05 13:12:36 +00:00
|
|
|
const std::wstring* value = GetVariable(strVariable);
|
|
|
|
if (value)
|
2011-07-29 17:18:21 +00:00
|
|
|
{
|
|
|
|
// Variable found, replace it with the value
|
2012-08-05 13:12:36 +00:00
|
|
|
result.replace(start, end - start + 1, *value);
|
|
|
|
start += (*value).length();
|
2011-07-29 17:18:21 +00:00
|
|
|
replaced = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
start = end;
|
|
|
|
}
|
2009-09-18 15:30:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
loop = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
loop = false;
|
|
|
|
}
|
2011-11-08 10:32:57 +00:00
|
|
|
}
|
|
|
|
while (loop);
|
2010-06-01 14:55:52 +00:00
|
|
|
|
|
|
|
return replaced;
|
2009-09-18 15:30:51 +00:00
|
|
|
}
|
|
|
|
|
2012-04-06 12:29:41 +00:00
|
|
|
/*
|
2010-06-01 14:55:52 +00:00
|
|
|
** Replaces measures in the given string.
|
2011-03-29 19:21:57 +00:00
|
|
|
**
|
2009-02-10 18:37:48 +00:00
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
bool ConfigParser::ReplaceMeasures(std::wstring& result)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2010-06-01 14:55:52 +00:00
|
|
|
bool replaced = false;
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-08-04 18:27:21 +00:00
|
|
|
size_t start = 0;
|
|
|
|
while ((start = result.find(L'[', start)) != std::wstring::npos)
|
2012-08-01 17:52:50 +00:00
|
|
|
{
|
2012-08-04 18:27:21 +00:00
|
|
|
size_t si = start + 1;
|
|
|
|
size_t end = result.find(L']', si);
|
|
|
|
if (end == std::wstring::npos)
|
2009-08-26 17:37:15 +00:00
|
|
|
{
|
2012-08-04 18:27:21 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
size_t next = result.find(L'[', si);
|
|
|
|
if (next == std::wstring::npos || end < next)
|
|
|
|
{
|
|
|
|
size_t ei = end - 1;
|
|
|
|
if (si != ei && result[si] == L'*' && result[ei] == L'*')
|
2009-08-26 17:37:15 +00:00
|
|
|
{
|
2012-08-04 18:27:21 +00:00
|
|
|
result.erase(ei, 1);
|
|
|
|
result.erase(si, 1);
|
|
|
|
start = ei;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
std::wstring var = result.substr(si, end - si);
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
Measure* measure = GetMeasure(var);
|
2012-08-04 18:27:21 +00:00
|
|
|
if (measure)
|
|
|
|
{
|
2013-04-10 15:59:41 +00:00
|
|
|
const WCHAR* value = measure->GetStringOrFormattedValue(AUTOSCALE_OFF, 1, -1, false);
|
2012-08-04 18:27:21 +00:00
|
|
|
size_t valueLen = wcslen(value);
|
|
|
|
|
|
|
|
// Measure found, replace it with the value
|
|
|
|
result.replace(start, end - start + 1, value, valueLen);
|
|
|
|
start += valueLen;
|
|
|
|
replaced = true;
|
|
|
|
}
|
|
|
|
else
|
2009-08-26 17:37:15 +00:00
|
|
|
{
|
2012-08-04 18:27:21 +00:00
|
|
|
std::wstring value;
|
2012-08-05 12:51:58 +00:00
|
|
|
if (GetSectionVariable(var, value))
|
2012-08-01 17:52:50 +00:00
|
|
|
{
|
2012-08-05 12:51:58 +00:00
|
|
|
// Replace section variable with the value.
|
2012-08-04 18:27:21 +00:00
|
|
|
result.replace(start, end - start + 1, value);
|
|
|
|
start += value.length();
|
|
|
|
replaced = true;
|
2012-08-01 17:52:50 +00:00
|
|
|
}
|
|
|
|
else
|
2009-08-26 17:37:15 +00:00
|
|
|
{
|
2012-08-04 18:27:21 +00:00
|
|
|
start = end;
|
2009-08-26 17:37:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-11-08 10:32:57 +00:00
|
|
|
}
|
2012-08-01 17:52:50 +00:00
|
|
|
else
|
|
|
|
{
|
2012-08-04 18:27:21 +00:00
|
|
|
start = next;
|
2012-08-01 17:52:50 +00:00
|
|
|
}
|
2009-08-26 17:37:15 +00:00
|
|
|
}
|
2012-08-01 17:52:50 +00:00
|
|
|
|
2010-06-01 14:55:52 +00:00
|
|
|
return replaced;
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
const std::wstring& ConfigParser::ReadString(LPCTSTR section, LPCTSTR key, LPCTSTR defValue, bool bReplaceMeasures)
|
2010-06-01 14:55:52 +00:00
|
|
|
{
|
|
|
|
static std::wstring result;
|
|
|
|
|
2010-11-04 00:17:42 +00:00
|
|
|
// Clear last status
|
|
|
|
m_LastReplaced = false;
|
|
|
|
m_LastDefaultUsed = false;
|
2011-11-01 04:56:46 +00:00
|
|
|
m_LastValueDefined = false;
|
2010-11-04 00:17:42 +00:00
|
|
|
|
2011-10-30 01:39:19 +00:00
|
|
|
const std::wstring strSection = section;
|
|
|
|
const std::wstring strKey = key;
|
2011-11-05 09:01:06 +00:00
|
|
|
const std::wstring strDefault = defValue;
|
2010-06-01 14:55:52 +00:00
|
|
|
|
2011-11-05 09:01:06 +00:00
|
|
|
const std::wstring& strValue = GetValue(strSection, strKey, strDefault);
|
|
|
|
if (&strValue == &strDefault)
|
2010-06-01 14:55:52 +00:00
|
|
|
{
|
2012-07-17 18:26:55 +00:00
|
|
|
bool foundStyleValue = false;
|
|
|
|
|
2011-11-05 09:01:06 +00:00
|
|
|
// If the template is defined read the value from there.
|
2012-07-17 18:26:55 +00:00
|
|
|
std::vector<std::wstring>::const_reverse_iterator iter = m_StyleTemplate.rbegin();
|
|
|
|
for ( ; iter != m_StyleTemplate.rend(); ++iter)
|
2010-11-04 00:17:42 +00:00
|
|
|
{
|
2012-07-17 18:26:55 +00:00
|
|
|
const std::wstring& strStyleValue = GetValue((*iter), strKey, strDefault);
|
2010-11-04 00:17:42 +00:00
|
|
|
|
2013-05-30 14:19:42 +00:00
|
|
|
//LogDebugF(L"StyleTemplate: [%s] %s (from [%s]) : strDefault=%s (0x%p), strStyleValue=%s (0x%p)",
|
2012-07-17 18:26:55 +00:00
|
|
|
// section, key, (*iter).c_str(), strDefault.c_str(), &strDefault, strStyleValue.c_str(), &strStyleValue);
|
2010-11-04 00:17:42 +00:00
|
|
|
|
2012-07-17 18:26:55 +00:00
|
|
|
if (&strStyleValue != &strDefault)
|
|
|
|
{
|
|
|
|
result = strStyleValue;
|
|
|
|
foundStyleValue = true;
|
|
|
|
break;
|
2010-11-04 00:17:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-17 18:26:55 +00:00
|
|
|
if (!foundStyleValue)
|
2010-11-04 00:17:42 +00:00
|
|
|
{
|
2011-11-05 09:01:06 +00:00
|
|
|
result = strDefault;
|
|
|
|
m_LastDefaultUsed = true;
|
2013-07-12 20:14:48 +00:00
|
|
|
return result;
|
2010-11-04 00:17:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-05 09:01:06 +00:00
|
|
|
result = strValue;
|
2010-06-01 14:55:52 +00:00
|
|
|
}
|
|
|
|
|
2011-11-08 17:21:29 +00:00
|
|
|
if (!result.empty())
|
2010-06-01 14:55:52 +00:00
|
|
|
{
|
2011-11-01 04:56:46 +00:00
|
|
|
m_LastValueDefined = true;
|
2010-06-01 14:55:52 +00:00
|
|
|
|
2011-11-26 02:49:52 +00:00
|
|
|
if (result.size() >= 3)
|
2011-11-24 00:30:56 +00:00
|
|
|
{
|
2011-11-26 02:49:52 +00:00
|
|
|
if (result.find(L'#') != std::wstring::npos)
|
|
|
|
{
|
2013-02-06 10:09:17 +00:00
|
|
|
m_CurrentSection->assign(strSection); // Set temporarily
|
2011-11-26 02:49:52 +00:00
|
|
|
|
|
|
|
if (ReplaceVariables(result))
|
|
|
|
{
|
|
|
|
m_LastReplaced = true;
|
|
|
|
}
|
2011-11-24 00:30:56 +00:00
|
|
|
|
2013-02-06 10:09:17 +00:00
|
|
|
m_CurrentSection->clear(); // Reset
|
2011-11-26 02:49:52 +00:00
|
|
|
}
|
|
|
|
else
|
2011-11-24 00:30:56 +00:00
|
|
|
{
|
2013-06-12 18:14:55 +00:00
|
|
|
PathUtil::ExpandEnvironmentVariables(result);
|
2011-11-24 00:30:56 +00:00
|
|
|
}
|
2010-12-20 08:57:37 +00:00
|
|
|
|
2011-11-26 02:49:52 +00:00
|
|
|
if (bReplaceMeasures && ReplaceMeasures(result))
|
|
|
|
{
|
|
|
|
m_LastReplaced = true;
|
|
|
|
}
|
2011-11-01 04:56:46 +00:00
|
|
|
}
|
2010-06-01 14:55:52 +00:00
|
|
|
}
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
bool ConfigParser::IsKeyDefined(LPCTSTR section, LPCTSTR key)
|
2010-12-04 15:07:28 +00:00
|
|
|
{
|
|
|
|
ReadString(section, key, L"", false);
|
|
|
|
return !m_LastDefaultUsed;
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
bool ConfigParser::IsValueDefined(LPCTSTR section, LPCTSTR key)
|
2010-12-11 05:27:01 +00:00
|
|
|
{
|
2011-11-26 02:49:52 +00:00
|
|
|
ReadString(section, key, L"", false);
|
|
|
|
return m_LastValueDefined;
|
2010-12-11 05:27:01 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
void ConfigParser::AddMeasure(Measure* pMeasure)
|
2009-08-26 17:37:15 +00:00
|
|
|
{
|
|
|
|
if (pMeasure)
|
|
|
|
{
|
2012-05-19 15:16:04 +00:00
|
|
|
m_Measures[StrToUpper(pMeasure->GetOriginalName())] = pMeasure;
|
2009-08-26 17:37:15 +00:00
|
|
|
}
|
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
Measure* ConfigParser::GetMeasure(const std::wstring& name)
|
2010-08-10 18:23:10 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
std::unordered_map<std::wstring, Measure*>::const_iterator iter = m_Measures.find(StrToUpper(name));
|
2011-01-23 14:24:34 +00:00
|
|
|
if (iter != m_Measures.end())
|
2010-08-10 18:23:10 +00:00
|
|
|
{
|
2011-01-23 14:24:34 +00:00
|
|
|
return (*iter).second;
|
2010-08-10 18:23:10 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:28:39 +00:00
|
|
|
return nullptr;
|
2010-08-10 18:23:10 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
std::vector<Gdiplus::REAL> ConfigParser::ReadFloats(LPCTSTR section, LPCTSTR key)
|
2009-07-27 11:48:57 +00:00
|
|
|
{
|
|
|
|
std::vector<Gdiplus::REAL> result;
|
2013-02-06 10:09:17 +00:00
|
|
|
const std::wstring& str = ReadString(section, key, L"");
|
|
|
|
if (!str.empty())
|
2009-07-27 11:48:57 +00:00
|
|
|
{
|
2011-02-03 18:03:29 +00:00
|
|
|
// Tokenize and parse the floats
|
2013-02-06 10:09:17 +00:00
|
|
|
const WCHAR delimiter = L';';
|
|
|
|
size_t lastPos, pos = 0;
|
|
|
|
do
|
2011-02-03 18:03:29 +00:00
|
|
|
{
|
2013-02-06 10:09:17 +00:00
|
|
|
lastPos = str.find_first_not_of(delimiter, pos);
|
|
|
|
if (lastPos == std::wstring::npos) break;
|
|
|
|
|
|
|
|
pos = str.find_first_of(delimiter, lastPos + 1);
|
|
|
|
|
|
|
|
result.push_back((Gdiplus::REAL)ParseDouble(str.substr(lastPos, pos - lastPos).c_str(), 0.0)); // (pos != std::wstring::npos) ? pos - lastPos : pos
|
|
|
|
if (pos == std::wstring::npos) break;
|
|
|
|
|
|
|
|
++pos;
|
2011-02-03 18:03:29 +00:00
|
|
|
}
|
2013-02-06 10:09:17 +00:00
|
|
|
while (true);
|
2009-07-27 11:48:57 +00:00
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
int ConfigParser::ReadInt(LPCTSTR section, LPCTSTR key, int defValue)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2010-11-16 20:12:27 +00:00
|
|
|
const std::wstring& result = ReadString(section, key, L"");
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2012-04-06 12:16:54 +00:00
|
|
|
if (!m_LastDefaultUsed)
|
|
|
|
{
|
|
|
|
const WCHAR* string = result.c_str();
|
|
|
|
if (*string == L'(')
|
|
|
|
{
|
|
|
|
double dblValue;
|
|
|
|
const WCHAR* errMsg = MathParser::CheckedParse(string, &dblValue);
|
|
|
|
if (!errMsg)
|
|
|
|
{
|
|
|
|
return (int)dblValue;
|
|
|
|
}
|
|
|
|
|
2013-06-29 16:59:18 +00:00
|
|
|
LogErrorF(m_MeterWindow, L"Formula: %s in key \"%s\" in [%s]", errMsg, key, section);
|
2012-04-06 12:16:54 +00:00
|
|
|
}
|
|
|
|
else if (*string)
|
|
|
|
{
|
|
|
|
errno = 0;
|
2013-05-31 14:28:39 +00:00
|
|
|
int intValue = wcstol(string, nullptr, 10);
|
2012-04-06 12:16:54 +00:00
|
|
|
if (errno != ERANGE)
|
|
|
|
{
|
|
|
|
return intValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return defValue;
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
uint32_t ConfigParser::ReadUInt(LPCTSTR section, LPCTSTR key, uint32_t defValue)
|
2011-07-08 22:50:02 +00:00
|
|
|
{
|
|
|
|
const std::wstring& result = ReadString(section, key, L"");
|
|
|
|
|
2012-04-06 12:16:54 +00:00
|
|
|
if (!m_LastDefaultUsed)
|
|
|
|
{
|
|
|
|
const WCHAR* string = result.c_str();
|
|
|
|
if (*string == L'(')
|
|
|
|
{
|
|
|
|
double dblValue;
|
|
|
|
const WCHAR* errMsg = MathParser::CheckedParse(string, &dblValue);
|
|
|
|
if (!errMsg)
|
|
|
|
{
|
2012-04-08 14:00:17 +00:00
|
|
|
return (uint32_t)dblValue;
|
2012-04-06 12:16:54 +00:00
|
|
|
}
|
|
|
|
|
2013-06-29 16:59:18 +00:00
|
|
|
LogErrorF(m_MeterWindow, L"Formula: %s in key \"%s\" in [%s]", errMsg, key, section);
|
2012-04-06 12:16:54 +00:00
|
|
|
}
|
|
|
|
else if (*string)
|
|
|
|
{
|
|
|
|
errno = 0;
|
2013-05-31 14:28:39 +00:00
|
|
|
uint32_t uintValue = wcstoul(string, nullptr, 10);
|
2012-04-06 12:16:54 +00:00
|
|
|
if (errno != ERANGE)
|
|
|
|
{
|
|
|
|
return uintValue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return defValue;
|
2011-07-08 22:50:02 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
uint64_t ConfigParser::ReadUInt64(LPCTSTR section, LPCTSTR key, uint64_t defValue)
|
2012-04-08 14:00:17 +00:00
|
|
|
{
|
|
|
|
const std::wstring& result = ReadString(section, key, L"");
|
|
|
|
|
|
|
|
if (!m_LastDefaultUsed)
|
|
|
|
{
|
|
|
|
const WCHAR* string = result.c_str();
|
|
|
|
if (*string == L'(')
|
|
|
|
{
|
|
|
|
double dblValue;
|
|
|
|
const WCHAR* errMsg = MathParser::CheckedParse(string, &dblValue);
|
|
|
|
if (!errMsg)
|
|
|
|
{
|
|
|
|
return (uint64_t)dblValue;
|
|
|
|
}
|
|
|
|
|
2013-06-29 16:59:18 +00:00
|
|
|
LogErrorF(m_MeterWindow, L"Formula: %s in key \"%s\" in [%s]", errMsg, key, section);
|
2012-04-08 14:00:17 +00:00
|
|
|
}
|
|
|
|
else if (*string)
|
|
|
|
{
|
|
|
|
errno = 0;
|
2013-05-31 14:28:39 +00:00
|
|
|
uint64_t uint64Value = _wcstoui64(string, nullptr, 10);
|
2012-04-08 14:00:17 +00:00
|
|
|
if (errno != ERANGE)
|
|
|
|
{
|
|
|
|
return uint64Value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return defValue;
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
double ConfigParser::ReadFloat(LPCTSTR section, LPCTSTR key, double defValue)
|
2009-07-30 15:19:47 +00:00
|
|
|
{
|
2010-11-16 20:12:27 +00:00
|
|
|
const std::wstring& result = ReadString(section, key, L"");
|
2009-07-30 15:19:47 +00:00
|
|
|
|
2012-04-06 12:16:54 +00:00
|
|
|
if (!m_LastDefaultUsed)
|
2009-07-30 15:19:47 +00:00
|
|
|
{
|
2012-04-06 12:16:54 +00:00
|
|
|
double value;
|
|
|
|
const WCHAR* string = result.c_str();
|
|
|
|
if (*string == L'(')
|
2009-07-30 15:19:47 +00:00
|
|
|
{
|
2012-04-06 12:16:54 +00:00
|
|
|
const WCHAR* errMsg = MathParser::CheckedParse(string, &value);
|
|
|
|
if (!errMsg)
|
|
|
|
{
|
|
|
|
return value;
|
|
|
|
}
|
2009-07-30 15:19:47 +00:00
|
|
|
|
2013-06-29 16:59:18 +00:00
|
|
|
LogErrorF(m_MeterWindow, L"Formula: %s in key \"%s\" in [%s]", errMsg, key, section);
|
2012-04-06 12:16:54 +00:00
|
|
|
}
|
|
|
|
else if (*string)
|
|
|
|
{
|
|
|
|
errno = 0;
|
2013-05-31 14:28:39 +00:00
|
|
|
value = wcstod(string, nullptr);
|
2012-04-06 12:16:54 +00:00
|
|
|
if (errno != ERANGE)
|
|
|
|
{
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
}
|
2009-07-30 15:19:47 +00:00
|
|
|
}
|
2010-02-08 14:12:47 +00:00
|
|
|
|
2012-04-06 12:16:54 +00:00
|
|
|
return defValue;
|
2009-07-30 15:19:47 +00:00
|
|
|
}
|
|
|
|
|
2011-07-07 23:25:45 +00:00
|
|
|
// Returns true if the formula was read successfully, false for failure.
|
2013-05-31 14:18:52 +00:00
|
|
|
bool ConfigParser::ParseFormula(const std::wstring& formula, double* resultValue)
|
2010-03-18 19:48:14 +00:00
|
|
|
{
|
|
|
|
// Formulas must be surrounded by parenthesis
|
2012-03-22 21:16:41 +00:00
|
|
|
if (!formula.empty() && formula[0] == L'(' && formula[formula.size() - 1] == L')')
|
2010-03-18 19:48:14 +00:00
|
|
|
{
|
2012-04-06 12:16:54 +00:00
|
|
|
const WCHAR* string = formula.c_str();
|
|
|
|
const WCHAR* errMsg = MathParser::CheckedParse(string, resultValue);
|
2013-05-31 14:28:39 +00:00
|
|
|
if (errMsg != nullptr)
|
2010-03-18 19:48:14 +00:00
|
|
|
{
|
2013-06-29 16:59:18 +00:00
|
|
|
LogErrorF(m_MeterWindow, L"Formula: %s: %s", errMsg, string);
|
2011-07-07 23:25:45 +00:00
|
|
|
return false;
|
2010-03-18 19:48:14 +00:00
|
|
|
}
|
|
|
|
|
2011-07-07 23:25:45 +00:00
|
|
|
return true;
|
2010-03-18 19:48:14 +00:00
|
|
|
}
|
|
|
|
|
2011-07-07 23:25:45 +00:00
|
|
|
return false;
|
2010-03-18 19:48:14 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
ARGB ConfigParser::ReadColor(LPCTSTR section, LPCTSTR key, ARGB defValue)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2010-11-16 20:12:27 +00:00
|
|
|
const std::wstring& result = ReadString(section, key, L"");
|
2009-02-10 18:37:48 +00:00
|
|
|
|
2010-11-16 20:12:27 +00:00
|
|
|
return (m_LastDefaultUsed) ? defValue : ParseColor(result.c_str());
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
Rect ConfigParser::ReadRect(LPCTSTR section, LPCTSTR key, const Rect& defValue)
|
2010-12-04 15:07:28 +00:00
|
|
|
{
|
|
|
|
const std::wstring& result = ReadString(section, key, L"");
|
|
|
|
|
|
|
|
return (m_LastDefaultUsed) ? defValue : ParseRect(result.c_str());
|
|
|
|
}
|
|
|
|
|
2013-05-31 14:18:52 +00:00
|
|
|
RECT ConfigParser::ReadRECT(LPCTSTR section, LPCTSTR key, const RECT& defValue)
|
2010-12-04 15:07:28 +00:00
|
|
|
{
|
|
|
|
const std::wstring& result = ReadString(section, key, L"");
|
|
|
|
|
2011-11-24 00:30:56 +00:00
|
|
|
RECT r;
|
|
|
|
if (m_LastDefaultUsed)
|
|
|
|
{
|
|
|
|
r = defValue;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
r = ParseRECT(result.c_str());
|
|
|
|
}
|
|
|
|
return r;
|
2010-12-04 15:07:28 +00:00
|
|
|
}
|
|
|
|
|
2009-07-27 11:48:57 +00:00
|
|
|
/*
|
2013-02-06 10:09:17 +00:00
|
|
|
** Splits the string from the delimiters.
|
|
|
|
** Now trims empty element in vector and white-space in each string.
|
2009-07-27 11:48:57 +00:00
|
|
|
**
|
2013-02-06 10:09:17 +00:00
|
|
|
** Modified from http://www.digitalpeer.com/id/simple
|
2009-07-27 11:48:57 +00:00
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
std::vector<std::wstring> ConfigParser::Tokenize(const std::wstring& str, const std::wstring& delimiters)
|
2009-07-27 11:48:57 +00:00
|
|
|
{
|
|
|
|
std::vector<std::wstring> tokens;
|
2011-03-29 19:21:57 +00:00
|
|
|
|
2013-02-06 10:09:17 +00:00
|
|
|
size_t lastPos, pos = 0;
|
|
|
|
do
|
2009-07-27 11:48:57 +00:00
|
|
|
{
|
2013-02-06 10:09:17 +00:00
|
|
|
lastPos = str.find_first_not_of(delimiters, pos);
|
|
|
|
if (lastPos == std::wstring::npos) break;
|
2009-07-27 11:48:57 +00:00
|
|
|
|
2013-02-06 10:09:17 +00:00
|
|
|
pos = str.find_first_of(delimiters, lastPos + 1);
|
|
|
|
std::wstring token = str.substr(lastPos, pos - lastPos); // len = (pos != std::wstring::npos) ? pos - lastPos : pos
|
2009-07-27 11:48:57 +00:00
|
|
|
|
2013-02-06 10:09:17 +00:00
|
|
|
size_t pos2 = token.find_first_not_of(L" \t\r\n");
|
|
|
|
if (pos2 != std::wstring::npos)
|
2011-11-04 12:48:03 +00:00
|
|
|
{
|
2013-02-06 10:09:17 +00:00
|
|
|
size_t lastPos2 = token.find_last_not_of(L" \t\r\n");
|
|
|
|
if (pos2 != 0 || lastPos2 != (token.size() - 1))
|
2011-11-04 12:48:03 +00:00
|
|
|
{
|
2013-02-06 10:09:17 +00:00
|
|
|
// Trim white-space
|
|
|
|
token.assign(token, pos2, lastPos2 - pos2 + 1);
|
2011-11-04 12:48:03 +00:00
|
|
|
}
|
2013-02-06 10:09:17 +00:00
|
|
|
tokens.push_back(token);
|
2011-11-04 12:48:03 +00:00
|
|
|
}
|
2013-02-06 10:09:17 +00:00
|
|
|
|
|
|
|
if (pos == std::wstring::npos) break;
|
|
|
|
++pos;
|
2011-11-04 12:48:03 +00:00
|
|
|
}
|
2013-02-06 10:09:17 +00:00
|
|
|
while (true);
|
|
|
|
|
|
|
|
return tokens;
|
2011-11-04 12:48:03 +00:00
|
|
|
}
|
|
|
|
|
2010-02-08 14:12:47 +00:00
|
|
|
/*
|
2012-04-06 12:16:54 +00:00
|
|
|
** Helper method that parses the floating-point value from the given string.
|
2010-02-08 14:12:47 +00:00
|
|
|
** If the given string is invalid format or causes overflow/underflow, returns given default value.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
double ConfigParser::ParseDouble(LPCTSTR string, double defValue)
|
2010-02-08 14:12:47 +00:00
|
|
|
{
|
2012-04-06 12:16:54 +00:00
|
|
|
assert(string);
|
|
|
|
|
|
|
|
double value;
|
|
|
|
if (*string == L'(')
|
|
|
|
{
|
|
|
|
const WCHAR* errMsg = MathParser::CheckedParse(string, &value);
|
|
|
|
if (!errMsg)
|
|
|
|
{
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2013-05-30 14:19:42 +00:00
|
|
|
LogErrorF(L"Formula: %s: %s", errMsg, string);
|
2012-04-06 12:16:54 +00:00
|
|
|
}
|
|
|
|
else if (*string)
|
2010-02-27 09:51:48 +00:00
|
|
|
{
|
2011-11-26 02:49:52 +00:00
|
|
|
errno = 0;
|
2013-05-31 14:28:39 +00:00
|
|
|
double value = wcstod(string, nullptr);
|
2011-11-26 02:49:52 +00:00
|
|
|
if (errno != ERANGE)
|
|
|
|
{
|
2012-04-06 12:16:54 +00:00
|
|
|
return value;
|
2011-11-26 02:49:52 +00:00
|
|
|
}
|
2010-02-27 09:51:48 +00:00
|
|
|
}
|
2012-04-06 12:16:54 +00:00
|
|
|
|
2011-11-26 02:49:52 +00:00
|
|
|
return defValue;
|
|
|
|
}
|
2010-02-27 09:51:48 +00:00
|
|
|
|
2011-11-26 02:49:52 +00:00
|
|
|
/*
|
2012-04-06 12:16:54 +00:00
|
|
|
** Helper method that parses the integer value from the given string.
|
2011-11-26 02:49:52 +00:00
|
|
|
** If the given string is invalid format or causes overflow/underflow, returns given default value.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
int ConfigParser::ParseInt(LPCTSTR string, int defValue)
|
2011-11-26 02:49:52 +00:00
|
|
|
{
|
2012-04-06 12:16:54 +00:00
|
|
|
assert(string);
|
|
|
|
|
|
|
|
if (*string == L'(')
|
|
|
|
{
|
|
|
|
double dblValue;
|
|
|
|
const WCHAR* errMsg = MathParser::CheckedParse(string, &dblValue);
|
|
|
|
if (!errMsg)
|
|
|
|
{
|
|
|
|
return (int)dblValue;
|
|
|
|
}
|
|
|
|
|
2013-05-30 14:19:42 +00:00
|
|
|
LogErrorF(L"Formula: %s: %s", errMsg, string);
|
2012-04-06 12:16:54 +00:00
|
|
|
}
|
|
|
|
else if (*string)
|
2010-02-08 14:12:47 +00:00
|
|
|
{
|
2011-11-26 02:49:52 +00:00
|
|
|
errno = 0;
|
2013-05-31 14:28:39 +00:00
|
|
|
int intValue = wcstol(string, nullptr, 10);
|
2011-11-26 02:49:52 +00:00
|
|
|
if (errno != ERANGE)
|
2010-02-08 14:12:47 +00:00
|
|
|
{
|
2012-04-06 12:16:54 +00:00
|
|
|
return intValue;
|
2010-02-08 14:12:47 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-06 12:16:54 +00:00
|
|
|
|
2011-11-26 02:49:52 +00:00
|
|
|
return defValue;
|
|
|
|
}
|
2010-02-08 14:12:47 +00:00
|
|
|
|
2011-11-26 02:49:52 +00:00
|
|
|
/*
|
2012-04-06 12:16:54 +00:00
|
|
|
** Helper method that parses the unsigned integer value from the given string.
|
2011-11-26 02:49:52 +00:00
|
|
|
** If the given string is invalid format or causes overflow/underflow, returns given default value.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
uint32_t ConfigParser::ParseUInt(LPCTSTR string, uint32_t defValue)
|
2011-11-26 02:49:52 +00:00
|
|
|
{
|
2012-04-06 12:16:54 +00:00
|
|
|
assert(string);
|
|
|
|
|
|
|
|
if (*string == L'(')
|
|
|
|
{
|
|
|
|
double dblValue;
|
|
|
|
const WCHAR* errMsg = MathParser::CheckedParse(string, &dblValue);
|
|
|
|
if (!errMsg)
|
|
|
|
{
|
2012-04-08 14:00:17 +00:00
|
|
|
return (uint32_t)dblValue;
|
2012-04-06 12:16:54 +00:00
|
|
|
}
|
|
|
|
|
2013-05-30 14:19:42 +00:00
|
|
|
LogErrorF(L"Formula: %s: %s", errMsg, string);
|
2012-04-06 12:16:54 +00:00
|
|
|
}
|
|
|
|
else if (*string)
|
2010-02-08 14:12:47 +00:00
|
|
|
{
|
|
|
|
errno = 0;
|
2013-05-31 14:28:39 +00:00
|
|
|
uint32_t uintValue = wcstoul(string, nullptr, 10);
|
2011-11-26 02:49:52 +00:00
|
|
|
if (errno != ERANGE)
|
2010-02-08 14:12:47 +00:00
|
|
|
{
|
2012-04-06 12:16:54 +00:00
|
|
|
return uintValue;
|
2010-02-08 14:12:47 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-06 12:16:54 +00:00
|
|
|
|
2010-02-08 14:12:47 +00:00
|
|
|
return defValue;
|
|
|
|
}
|
|
|
|
|
2012-04-08 14:00:17 +00:00
|
|
|
/*
|
|
|
|
** Helper method that parses the 64bit unsigned integer value from the given string.
|
|
|
|
** If the given string is invalid format or causes overflow/underflow, returns given default value.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
uint64_t ConfigParser::ParseUInt64(LPCTSTR string, uint64_t defValue)
|
2012-04-08 14:00:17 +00:00
|
|
|
{
|
|
|
|
assert(string);
|
|
|
|
|
|
|
|
if (*string == L'(')
|
|
|
|
{
|
|
|
|
double dblValue;
|
|
|
|
const WCHAR* errMsg = MathParser::CheckedParse(string, &dblValue);
|
|
|
|
if (!errMsg)
|
|
|
|
{
|
|
|
|
return (uint64_t)dblValue;
|
|
|
|
}
|
|
|
|
|
2013-05-30 14:19:42 +00:00
|
|
|
LogErrorF(L"Formula: %s: %s", errMsg, string);
|
2012-04-08 14:00:17 +00:00
|
|
|
}
|
|
|
|
else if (*string)
|
|
|
|
{
|
|
|
|
errno = 0;
|
2013-05-31 14:28:39 +00:00
|
|
|
uint64_t uint64Value = _wcstoui64(string, nullptr, 10);
|
2012-04-08 14:00:17 +00:00
|
|
|
if (errno != ERANGE)
|
|
|
|
{
|
|
|
|
return uint64Value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return defValue;
|
|
|
|
}
|
|
|
|
|
2009-02-10 18:37:48 +00:00
|
|
|
/*
|
2012-04-06 12:16:54 +00:00
|
|
|
** Helper template that parses four comma separated values from the given string.
|
2009-02-10 18:37:48 +00:00
|
|
|
**
|
|
|
|
*/
|
2012-04-06 12:16:54 +00:00
|
|
|
template <typename T>
|
|
|
|
bool ParseInt4(LPCTSTR string, T& v1, T& v2, T& v3, T& v4)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2011-07-07 23:25:45 +00:00
|
|
|
if (wcschr(string, L','))
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
WCHAR* parseSz = _wcsdup(string);
|
|
|
|
WCHAR* token;
|
|
|
|
|
|
|
|
token = wcstok(parseSz, L",");
|
2011-07-07 23:25:45 +00:00
|
|
|
if (token)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
v1 = ConfigParser::ParseInt(token, 0);
|
2011-11-24 00:30:56 +00:00
|
|
|
|
2013-05-31 14:28:39 +00:00
|
|
|
token = wcstok(nullptr, L",");
|
2011-11-24 00:30:56 +00:00
|
|
|
if (token)
|
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
v2 = ConfigParser::ParseInt(token, 0);
|
2011-11-24 00:30:56 +00:00
|
|
|
|
2013-05-31 14:28:39 +00:00
|
|
|
token = wcstok(nullptr, L",");
|
2011-11-24 00:30:56 +00:00
|
|
|
if (token)
|
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
v3 = ConfigParser::ParseInt(token, 0);
|
2011-11-24 00:30:56 +00:00
|
|
|
|
2013-05-31 14:28:39 +00:00
|
|
|
token = wcstok(nullptr, L",");
|
2011-11-24 00:30:56 +00:00
|
|
|
if (token)
|
|
|
|
{
|
2013-05-31 14:18:52 +00:00
|
|
|
v4 = ConfigParser::ParseInt(token, 0);
|
2011-11-24 00:30:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
free(parseSz);
|
2012-04-06 12:16:54 +00:00
|
|
|
return true;
|
2011-03-29 19:21:57 +00:00
|
|
|
}
|
2012-04-06 12:16:54 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
** Helper method that parses the color values from the given string.
|
|
|
|
** The color can be supplied as three/four comma separated values or as one
|
|
|
|
** hex-value.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
ARGB ConfigParser::ParseColor(LPCTSTR string)
|
2012-04-06 12:16:54 +00:00
|
|
|
{
|
|
|
|
int R = 255, G = 255, B = 255, A = 255;
|
|
|
|
|
|
|
|
if (!ParseInt4(string, R, G, B, A))
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
if (wcsncmp(string, L"0x", 2) == 0)
|
|
|
|
{
|
2011-07-07 23:25:45 +00:00
|
|
|
string += 2; // skip prefix
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
|
|
|
|
2011-07-07 23:25:45 +00:00
|
|
|
size_t len = wcslen(string);
|
|
|
|
if (len >= 8 && !iswspace(string[6]))
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
swscanf(string, L"%02x%02x%02x%02x", &R, &G, &B, &A);
|
2011-03-29 19:21:57 +00:00
|
|
|
}
|
2011-07-07 23:25:45 +00:00
|
|
|
else if (len >= 6)
|
2009-02-10 18:37:48 +00:00
|
|
|
{
|
|
|
|
swscanf(string, L"%02x%02x%02x", &R, &G, &B);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-24 00:30:56 +00:00
|
|
|
return Color::MakeARGB(A, R, G, B);
|
2009-02-10 18:37:48 +00:00
|
|
|
}
|
2009-08-26 17:37:15 +00:00
|
|
|
|
2010-12-04 15:07:28 +00:00
|
|
|
/*
|
2012-04-06 12:16:54 +00:00
|
|
|
** Helper method that parses the Gdiplus::Rect values from the given string.
|
2010-12-04 15:07:28 +00:00
|
|
|
** The rect can be supplied as four comma separated values (X/Y/Width/Height).
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
Rect ConfigParser::ParseRect(LPCTSTR string)
|
2010-12-04 15:07:28 +00:00
|
|
|
{
|
|
|
|
Rect r;
|
2010-12-05 15:34:37 +00:00
|
|
|
ParseInt4(string, r.X, r.Y, r.Width, r.Height);
|
2010-12-04 15:07:28 +00:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-04-06 12:16:54 +00:00
|
|
|
** Helper method that parses the RECT values from the given string.
|
2010-12-04 15:07:28 +00:00
|
|
|
** The rect can be supplied as four comma separated values (left/top/right/bottom).
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
RECT ConfigParser::ParseRECT(LPCTSTR string)
|
2010-12-04 15:07:28 +00:00
|
|
|
{
|
|
|
|
RECT r = {0};
|
2010-12-05 15:34:37 +00:00
|
|
|
ParseInt4(string, r.left, r.top, r.right, r.bottom);
|
2010-12-04 15:07:28 +00:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2012-04-06 12:29:41 +00:00
|
|
|
/*
|
2009-08-26 17:37:15 +00:00
|
|
|
** Reads the given ini file and fills the m_Values and m_Keys maps.
|
2011-03-29 19:21:57 +00:00
|
|
|
**
|
2009-08-26 17:37:15 +00:00
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void ConfigParser::ReadIniFile(const std::wstring& iniFile, LPCTSTR skinSection, int depth)
|
2009-08-26 17:37:15 +00:00
|
|
|
{
|
2009-09-18 15:30:51 +00:00
|
|
|
if (depth > 100) // Is 100 enough to assume the include loop never ends?
|
|
|
|
{
|
2013-06-13 14:20:27 +00:00
|
|
|
GetRainmeter().ShowMessage(nullptr, GetString(ID_STR_INCLUDEINFINITELOOP), MB_OK | MB_ICONERROR);
|
2009-09-18 15:30:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2009-08-26 17:37:15 +00:00
|
|
|
|
2010-07-22 00:31:59 +00:00
|
|
|
// Verify whether the file exists
|
|
|
|
if (_waccess(iniFile.c_str(), 0) == -1)
|
|
|
|
{
|
2013-06-29 16:59:18 +00:00
|
|
|
LogErrorF(m_MeterWindow, L"Unable to read file: %s", iniFile.c_str());
|
2010-07-22 00:31:59 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-04-02 01:35:53 +00:00
|
|
|
// Avoid "IniFileMapping"
|
2013-05-31 14:18:52 +00:00
|
|
|
std::wstring iniRead = System::GetTemporaryFile(iniFile);
|
2011-11-08 17:21:29 +00:00
|
|
|
bool temporary = (!iniRead.empty() && (iniRead.size() != 1 || iniRead[0] != L'?'));
|
2010-04-02 01:35:53 +00:00
|
|
|
|
2010-08-03 15:10:42 +00:00
|
|
|
if (temporary)
|
2010-04-02 01:35:53 +00:00
|
|
|
{
|
2013-06-29 16:59:18 +00:00
|
|
|
if (GetRainmeter().GetDebug()) LogDebugF(m_MeterWindow, L"Reading file: %s (Temp: %s)", iniFile.c_str(), iniRead.c_str());
|
2010-04-02 01:35:53 +00:00
|
|
|
}
|
2010-08-03 15:10:42 +00:00
|
|
|
else
|
2010-04-02 01:35:53 +00:00
|
|
|
{
|
2013-06-29 16:59:18 +00:00
|
|
|
if (GetRainmeter().GetDebug()) LogDebugF(m_MeterWindow, L"Reading file: %s", iniFile.c_str());
|
2010-04-02 01:35:53 +00:00
|
|
|
iniRead = iniFile;
|
|
|
|
}
|
|
|
|
|
2009-08-26 17:37:15 +00:00
|
|
|
// Get all the sections (i.e. different meters)
|
2011-07-06 09:00:44 +00:00
|
|
|
std::list<std::wstring> sections;
|
2011-12-04 22:18:40 +00:00
|
|
|
std::unordered_set<std::wstring> unique;
|
2011-12-09 03:28:19 +00:00
|
|
|
std::wstring key, value; // buffer
|
2011-12-04 22:18:40 +00:00
|
|
|
|
2011-07-07 10:48:42 +00:00
|
|
|
DWORD itemsSize = MAX_LINE_LENGTH;
|
|
|
|
WCHAR* items = new WCHAR[itemsSize];
|
2013-05-31 14:28:39 +00:00
|
|
|
WCHAR* pos = nullptr;
|
|
|
|
WCHAR* epos = nullptr;
|
2009-08-26 17:37:15 +00:00
|
|
|
|
2013-05-31 14:28:39 +00:00
|
|
|
if (skinSection == nullptr)
|
2009-08-26 17:37:15 +00:00
|
|
|
{
|
2011-07-06 09:00:44 +00:00
|
|
|
// Get all the sections
|
2011-11-08 10:32:57 +00:00
|
|
|
do
|
2010-04-02 01:35:53 +00:00
|
|
|
{
|
2011-07-06 09:00:44 +00:00
|
|
|
items[0] = 0;
|
2011-07-08 22:50:02 +00:00
|
|
|
DWORD res = GetPrivateProfileSectionNames(items, itemsSize, iniRead.c_str());
|
2011-07-06 09:00:44 +00:00
|
|
|
if (res == 0) // File not found
|
|
|
|
{
|
|
|
|
delete [] items;
|
2013-05-31 14:18:52 +00:00
|
|
|
if (temporary) System::RemoveFile(iniRead);
|
2011-07-06 09:00:44 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-07-07 10:48:42 +00:00
|
|
|
if (res < itemsSize - 2) // Fits in the buffer
|
2011-07-06 09:00:44 +00:00
|
|
|
{
|
|
|
|
epos = items + res;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2010-04-02 01:35:53 +00:00
|
|
|
delete [] items;
|
2011-07-07 10:48:42 +00:00
|
|
|
itemsSize *= 2;
|
|
|
|
items = new WCHAR[itemsSize];
|
2010-11-24 13:43:20 +00:00
|
|
|
}
|
2011-11-08 10:32:57 +00:00
|
|
|
while (true);
|
2009-08-26 17:37:15 +00:00
|
|
|
|
2011-07-06 09:00:44 +00:00
|
|
|
// Read the sections
|
|
|
|
pos = items;
|
|
|
|
while (pos < epos)
|
2010-11-24 13:43:20 +00:00
|
|
|
{
|
2011-07-06 09:00:44 +00:00
|
|
|
if (*pos)
|
2010-11-24 13:43:20 +00:00
|
|
|
{
|
2011-12-09 03:28:19 +00:00
|
|
|
value = pos; // section name
|
2012-05-19 15:16:04 +00:00
|
|
|
StrToUpperC(key.assign(value));
|
2011-12-09 03:28:19 +00:00
|
|
|
if (unique.insert(key).second)
|
2011-07-06 09:00:44 +00:00
|
|
|
{
|
2011-12-09 03:28:19 +00:00
|
|
|
if (m_FoundSections.insert(key).second)
|
2011-12-04 22:18:40 +00:00
|
|
|
{
|
2012-07-18 10:41:58 +00:00
|
|
|
m_Sections.insert(m_SectionInsertPos, value);
|
2011-12-04 22:18:40 +00:00
|
|
|
}
|
2011-12-09 03:28:19 +00:00
|
|
|
sections.push_back(value);
|
2011-07-06 09:00:44 +00:00
|
|
|
}
|
2011-12-09 03:28:19 +00:00
|
|
|
pos += value.size() + 1;
|
2011-07-06 09:00:44 +00:00
|
|
|
}
|
|
|
|
else // Empty string
|
|
|
|
{
|
|
|
|
++pos;
|
2010-11-24 13:43:20 +00:00
|
|
|
}
|
|
|
|
}
|
2011-07-06 09:00:44 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Special case: Read only "Rainmeter" and specified section from "Rainmeter.ini"
|
2011-11-12 15:36:05 +00:00
|
|
|
const std::wstring strRainmeter = L"Rainmeter";
|
2012-06-01 13:06:36 +00:00
|
|
|
const std::wstring strFolder = skinSection;
|
2011-11-12 15:36:05 +00:00
|
|
|
|
|
|
|
sections.push_back(strRainmeter);
|
2012-06-01 13:06:36 +00:00
|
|
|
sections.push_back(strFolder);
|
2011-07-06 09:00:44 +00:00
|
|
|
|
2011-07-07 10:48:42 +00:00
|
|
|
if (depth == 0) // Add once
|
2009-09-18 15:30:51 +00:00
|
|
|
{
|
2011-11-12 15:36:05 +00:00
|
|
|
m_Sections.push_back(strRainmeter);
|
2012-06-01 13:06:36 +00:00
|
|
|
m_Sections.push_back(strFolder);
|
2009-09-18 15:30:51 +00:00
|
|
|
}
|
2009-08-26 17:37:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Read the keys and values
|
2012-07-23 12:42:14 +00:00
|
|
|
for (auto it = sections.cbegin(); it != sections.cend(); ++it)
|
2009-08-26 17:37:15 +00:00
|
|
|
{
|
2011-12-04 22:18:40 +00:00
|
|
|
unique.clear();
|
|
|
|
|
2012-07-23 12:42:14 +00:00
|
|
|
const WCHAR* sectionName = (*it).c_str();
|
2011-11-16 16:47:20 +00:00
|
|
|
bool isVariables = (_wcsicmp(sectionName, L"Variables") == 0);
|
2013-05-31 14:28:39 +00:00
|
|
|
bool isMetadata = (skinSection == nullptr && !isVariables && _wcsicmp(sectionName, L"Metadata") == 0);
|
2012-07-18 10:41:58 +00:00
|
|
|
bool resetInsertPos = true;
|
2011-07-06 09:00:44 +00:00
|
|
|
|
2011-07-07 10:48:42 +00:00
|
|
|
// Read all "key=value" from the section
|
2011-11-08 10:32:57 +00:00
|
|
|
do
|
2009-08-26 17:37:15 +00:00
|
|
|
{
|
|
|
|
items[0] = 0;
|
2011-11-16 16:47:20 +00:00
|
|
|
DWORD res = GetPrivateProfileSection(sectionName, items, itemsSize, iniRead.c_str());
|
2011-07-07 10:48:42 +00:00
|
|
|
if (res < itemsSize - 2) // Fits in the buffer
|
2010-11-24 13:43:20 +00:00
|
|
|
{
|
|
|
|
epos = items + res;
|
|
|
|
break;
|
|
|
|
}
|
2009-08-26 17:37:15 +00:00
|
|
|
|
|
|
|
delete [] items;
|
2011-07-07 10:48:42 +00:00
|
|
|
itemsSize *= 2;
|
|
|
|
items = new WCHAR[itemsSize];
|
2010-04-07 16:12:02 +00:00
|
|
|
}
|
2011-11-08 10:32:57 +00:00
|
|
|
while (true);
|
2009-08-26 17:37:15 +00:00
|
|
|
|
2010-11-24 13:43:20 +00:00
|
|
|
pos = items;
|
|
|
|
while (pos < epos)
|
2009-08-26 17:37:15 +00:00
|
|
|
{
|
2010-11-24 13:43:20 +00:00
|
|
|
if (*pos)
|
2009-08-26 17:37:15 +00:00
|
|
|
{
|
2011-11-12 15:36:05 +00:00
|
|
|
size_t len = wcslen(pos);
|
|
|
|
WCHAR* sep = wmemchr(pos, L'=', len);
|
2013-05-31 14:28:39 +00:00
|
|
|
if (sep != nullptr && sep != pos)
|
2010-11-24 13:43:20 +00:00
|
|
|
{
|
2011-11-12 15:36:05 +00:00
|
|
|
size_t clen = sep - pos; // key's length
|
2010-11-24 13:43:20 +00:00
|
|
|
|
2012-05-19 15:16:04 +00:00
|
|
|
StrToUpperC(key.assign(pos, clen));
|
2011-12-04 22:18:40 +00:00
|
|
|
if (unique.insert(key).second)
|
2010-11-24 13:43:20 +00:00
|
|
|
{
|
2011-11-12 15:36:05 +00:00
|
|
|
++sep;
|
|
|
|
clen = len - (clen + 1); // value's length
|
|
|
|
|
2011-07-07 10:48:42 +00:00
|
|
|
// Trim surrounded quotes from value
|
2011-12-04 22:18:40 +00:00
|
|
|
if (clen >= 2 && (sep[0] == L'"' || sep[0] == L'\'') && sep[clen - 1] == sep[0])
|
2011-07-07 10:48:42 +00:00
|
|
|
{
|
2011-11-12 15:36:05 +00:00
|
|
|
clen -= 2;
|
|
|
|
++sep;
|
2011-07-07 10:48:42 +00:00
|
|
|
}
|
|
|
|
|
2012-05-19 18:18:52 +00:00
|
|
|
if (wcsncmp(key.c_str(), L"@INCLUDE", 8) == 0)
|
2011-07-07 10:48:42 +00:00
|
|
|
{
|
2011-12-09 03:28:19 +00:00
|
|
|
if (clen > 0)
|
2011-07-07 10:48:42 +00:00
|
|
|
{
|
2011-12-09 03:28:19 +00:00
|
|
|
value.assign(sep, clen);
|
|
|
|
ReadVariables();
|
|
|
|
ReplaceVariables(value);
|
2013-06-12 18:14:55 +00:00
|
|
|
if (!PathUtil::IsAbsolute(value))
|
2011-12-09 03:28:19 +00:00
|
|
|
{
|
2012-05-21 11:19:25 +00:00
|
|
|
// Relative to the ini folder
|
2013-06-12 18:14:55 +00:00
|
|
|
value.insert(0, PathUtil::GetFolderFromFilePath(iniFile));
|
2011-12-09 03:28:19 +00:00
|
|
|
}
|
2012-07-18 10:41:58 +00:00
|
|
|
|
|
|
|
if (resetInsertPos)
|
|
|
|
{
|
2012-07-23 12:42:14 +00:00
|
|
|
auto jt = it;
|
2012-07-20 09:33:52 +00:00
|
|
|
if (++jt == sections.end()) // Special case: @include was used in the last section of the current file
|
2012-07-18 10:41:58 +00:00
|
|
|
{
|
2012-07-20 09:33:52 +00:00
|
|
|
// Set the insertion place to the last
|
|
|
|
m_SectionInsertPos = m_Sections.end();
|
|
|
|
resetInsertPos = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Find the appropriate insertion place
|
2012-07-23 12:42:14 +00:00
|
|
|
for (jt = m_Sections.cbegin(); jt != m_Sections.cend(); ++jt)
|
2012-07-18 10:41:58 +00:00
|
|
|
{
|
2012-07-23 12:42:14 +00:00
|
|
|
if (_wcsicmp((*jt).c_str(), sectionName) == 0)
|
2012-07-20 09:33:52 +00:00
|
|
|
{
|
2012-07-23 12:42:14 +00:00
|
|
|
m_SectionInsertPos = ++jt;
|
2012-07-20 09:33:52 +00:00
|
|
|
resetInsertPos = false;
|
|
|
|
break;
|
|
|
|
}
|
2012-07-18 10:41:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-06-01 13:06:36 +00:00
|
|
|
ReadIniFile(value, skinSection, depth + 1);
|
2011-07-07 10:48:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-05 09:01:06 +00:00
|
|
|
if (!isMetadata) // Uncache Metadata's key-value pair in the skin
|
|
|
|
{
|
2011-12-09 03:28:19 +00:00
|
|
|
value.assign(sep, clen);
|
2012-07-23 12:42:14 +00:00
|
|
|
SetValue((*it), key, value);
|
2011-07-07 23:25:45 +00:00
|
|
|
|
2011-12-04 22:18:40 +00:00
|
|
|
if (isVariables)
|
|
|
|
{
|
|
|
|
m_ListVariables.push_back(key);
|
|
|
|
}
|
2011-07-07 23:25:45 +00:00
|
|
|
}
|
2011-07-07 10:48:42 +00:00
|
|
|
}
|
2010-11-24 13:43:20 +00:00
|
|
|
}
|
2009-09-18 15:30:51 +00:00
|
|
|
}
|
2011-07-07 10:48:42 +00:00
|
|
|
pos += len + 1;
|
2009-09-18 15:30:51 +00:00
|
|
|
}
|
2010-11-24 13:43:20 +00:00
|
|
|
else // Empty string
|
2009-09-18 15:30:51 +00:00
|
|
|
{
|
2010-11-24 13:43:20 +00:00
|
|
|
++pos;
|
2009-09-18 15:30:51 +00:00
|
|
|
}
|
2009-08-26 17:37:15 +00:00
|
|
|
}
|
|
|
|
}
|
2011-12-04 22:18:40 +00:00
|
|
|
|
2009-08-26 17:37:15 +00:00
|
|
|
delete [] items;
|
2013-05-31 14:18:52 +00:00
|
|
|
if (temporary) System::RemoveFile(iniRead);
|
2009-08-26 17:37:15 +00:00
|
|
|
}
|
|
|
|
|
2012-04-06 12:29:41 +00:00
|
|
|
/*
|
2009-08-26 17:37:15 +00:00
|
|
|
** Sets the value for the key under the given section.
|
2011-03-29 19:21:57 +00:00
|
|
|
**
|
2009-08-26 17:37:15 +00:00
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void ConfigParser::SetValue(const std::wstring& strSection, const std::wstring& strKey, const std::wstring& strValue)
|
2009-08-26 17:37:15 +00:00
|
|
|
{
|
2013-05-30 14:19:42 +00:00
|
|
|
// LogDebugF(L"[%s] %s=%s (size: %i)", strSection.c_str(), strKey.c_str(), strValue.c_str(), (int)m_Values.size());
|
2009-09-18 15:30:51 +00:00
|
|
|
|
2011-12-04 22:18:40 +00:00
|
|
|
std::wstring strTmp;
|
|
|
|
strTmp.reserve(strSection.size() + 1 + strKey.size());
|
2011-12-09 19:49:06 +00:00
|
|
|
strTmp = strSection;
|
2011-12-04 22:18:40 +00:00
|
|
|
strTmp += L'~';
|
2011-07-07 23:25:45 +00:00
|
|
|
strTmp += strKey;
|
2010-11-25 22:00:34 +00:00
|
|
|
|
2012-05-19 15:16:04 +00:00
|
|
|
m_Values[StrToUpperC(strTmp)] = strValue;
|
2009-08-26 17:37:15 +00:00
|
|
|
}
|
|
|
|
|
2012-04-06 12:29:41 +00:00
|
|
|
/*
|
2011-07-27 10:42:35 +00:00
|
|
|
** Deletes the value for the key under the given section.
|
|
|
|
**
|
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
void ConfigParser::DeleteValue(const std::wstring& strSection, const std::wstring& strKey)
|
2011-07-27 10:42:35 +00:00
|
|
|
{
|
2011-12-04 22:18:40 +00:00
|
|
|
std::wstring strTmp;
|
|
|
|
strTmp.reserve(strSection.size() + 1 + strKey.size());
|
2011-12-09 19:49:06 +00:00
|
|
|
strTmp = strSection;
|
2011-12-04 22:18:40 +00:00
|
|
|
strTmp += L'~';
|
2011-07-27 10:42:35 +00:00
|
|
|
strTmp += strKey;
|
|
|
|
|
2012-05-19 15:16:04 +00:00
|
|
|
std::unordered_map<std::wstring, std::wstring>::const_iterator iter = m_Values.find(StrToUpperC(strTmp));
|
2011-07-27 14:18:02 +00:00
|
|
|
if (iter != m_Values.end())
|
2011-07-27 10:42:35 +00:00
|
|
|
{
|
2011-07-27 14:18:02 +00:00
|
|
|
m_Values.erase(iter);
|
2011-07-27 10:42:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-06 12:29:41 +00:00
|
|
|
/*
|
2009-08-26 17:37:15 +00:00
|
|
|
** Returns the value for the key under the given section.
|
2011-03-29 19:21:57 +00:00
|
|
|
**
|
2009-08-26 17:37:15 +00:00
|
|
|
*/
|
2013-05-31 14:18:52 +00:00
|
|
|
const std::wstring& ConfigParser::GetValue(const std::wstring& strSection, const std::wstring& strKey, const std::wstring& strDefault)
|
2009-08-26 17:37:15 +00:00
|
|
|
{
|
2011-12-04 22:18:40 +00:00
|
|
|
std::wstring strTmp;
|
|
|
|
strTmp.reserve(strSection.size() + 1 + strKey.size());
|
2011-12-09 19:49:06 +00:00
|
|
|
strTmp = strSection;
|
2011-12-04 22:18:40 +00:00
|
|
|
strTmp += L'~';
|
2010-11-25 22:00:34 +00:00
|
|
|
strTmp += strKey;
|
2009-08-27 15:42:24 +00:00
|
|
|
|
2012-05-19 15:16:04 +00:00
|
|
|
std::unordered_map<std::wstring, std::wstring>::const_iterator iter = m_Values.find(StrToUpperC(strTmp));
|
2011-12-04 22:18:40 +00:00
|
|
|
return (iter != m_Values.end()) ? (*iter).second : strDefault;
|
2009-08-26 17:37:15 +00:00
|
|
|
}
|