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
Foundation , Inc . , 59 Temple Place - Suite 330 , Boston , MA 02111 - 1307 , USA .
*/
2009-10-07 16:45:14 +00:00
# include "StdAfx.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"
2009-08-27 15:42:24 +00:00
# include <algorithm>
2009-02-10 18:37:48 +00:00
extern CRainmeter * Rainmeter ;
using namespace Gdiplus ;
* 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
std : : map < std : : wstring , std : : wstring > CConfigParser : : c_MonitorVariables ;
2009-02-10 18:37:48 +00:00
/*
* * CConfigParser
* *
* * The constructor
* *
*/
CConfigParser : : CConfigParser ( )
{
2009-07-30 15:19:47 +00:00
m_Parser = MathParser_Create ( NULL ) ;
2009-02-10 18:37:48 +00:00
}
/*
* * ~ CConfigParser
* *
* * The destructor
* *
*/
CConfigParser : : ~ CConfigParser ( )
{
2009-07-30 15:19:47 +00:00
MathParser_Destroy ( m_Parser ) ;
2009-02-10 18:37:48 +00:00
}
/*
* * Initialize
* *
* *
*/
* 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
void CConfigParser : : Initialize ( LPCTSTR filename , CRainmeter * pRainmeter , CMeterWindow * meterWindow )
2009-02-10 18:37:48 +00:00
{
m_Filename = filename ;
2009-07-26 21:08:46 +00:00
m_Variables . clear ( ) ;
2009-08-26 17:37:15 +00:00
m_Measures . clear ( ) ;
2009-09-18 15:30:51 +00:00
m_Keys . clear ( ) ;
m_Values . clear ( ) ;
2009-09-19 07:15:28 +00:00
m_Sections . clear ( ) ;
2009-08-26 17:37:15 +00:00
2009-09-18 15:30:51 +00:00
// Set the default variables. Do this before the ini file is read so that the paths can be used with @include
* 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
SetDefaultVariables ( pRainmeter , meterWindow ) ;
// Set the SCREENAREA/WORKAREA variables
if ( c_MonitorVariables . empty ( ) )
{
SetMultiMonitorVariables ( true ) ;
}
// Set the SCREENAREA/WORKAREA variables for present monitor
SetAutoSelectedMonitorVariables ( meterWindow ) ;
2010-04-02 01:35:53 +00:00
if ( meterWindow )
{
GetIniFileMappingList ( ) ;
}
* 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
ReadIniFile ( m_Filename ) ;
ReadVariables ( ) ;
2010-04-02 01:35:53 +00:00
m_IniFileMappings . clear ( ) ;
* 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
}
/*
* * SetDefaultVariables
* *
* *
*/
void CConfigParser : : SetDefaultVariables ( CRainmeter * pRainmeter , CMeterWindow * meterWindow )
{
2009-07-26 21:08:46 +00:00
if ( pRainmeter )
{
2009-08-27 15:42:24 +00:00
SetVariable ( L " PROGRAMPATH " , pRainmeter - > GetPath ( ) ) ;
SetVariable ( L " SETTINGSPATH " , pRainmeter - > GetSettingsPath ( ) ) ;
SetVariable ( L " SKINSPATH " , pRainmeter - > GetSkinPath ( ) ) ;
SetVariable ( L " PLUGINSPATH " , pRainmeter - > GetPluginPath ( ) ) ;
* 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
SetVariable ( L " CURRENTPATH " , CRainmeter : : ExtractPath ( m_Filename ) ) ;
2009-08-27 15:42:24 +00:00
SetVariable ( L " ADDONSPATH " , pRainmeter - > GetPath ( ) + L " Addons \\ " ) ;
2009-07-26 21:08:46 +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 )
{
SetVariable ( L " CURRENTCONFIG " , meterWindow - > GetSkinName ( ) ) ;
}
2009-02-10 18:37:48 +00:00
}
/*
* * ReadVariables
* *
* *
*/
void CConfigParser : : ReadVariables ( )
{
2009-08-26 17:37:15 +00:00
std : : vector < std : : wstring > listVariables = GetKeys ( L " Variables " ) ;
2009-02-10 18:37:48 +00:00
2010-03-30 22:37:05 +00:00
for ( size_t i = 0 ; i < listVariables . size ( ) ; + + i )
2009-02-10 18:37:48 +00:00
{
2009-08-27 16:04:06 +00:00
SetVariable ( listVariables [ i ] , ReadString ( L " Variables " , listVariables [ i ] . c_str ( ) , L " " , false ) ) ;
2009-02-10 18:37:48 +00:00
}
2009-08-26 17:37:15 +00:00
}
/**
* * Sets a new value for the variable . The DynamicVariables must be set to 1 in the
* * meter / measure for the changes to be applied .
* *
* * \ param strVariable
* * \ param strValue
*/
void CConfigParser : : SetVariable ( const std : : wstring & strVariable , const std : : wstring & strValue )
{
2009-09-18 15:30:51 +00:00
// DebugLog(L"Variable: %s=%s (size=%i)", strVariable.c_str(), strValue.c_str(), m_Variables.size());
2009-08-27 15:42:24 +00:00
std : : wstring strTmp ( strVariable ) ;
std : : transform ( strTmp . begin ( ) , strTmp . end ( ) , strTmp . begin ( ) , : : tolower ) ;
m_Variables [ strTmp ] = strValue ;
2009-02-10 18:37:48 +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
/*
* * ResetVariables
* *
* *
*/
void CConfigParser : : ResetVariables ( CRainmeter * pRainmeter , CMeterWindow * meterWindow )
{
m_Variables . clear ( ) ;
// Set the default variables. Do this before the ini file is read so that the paths can be used with @include
SetDefaultVariables ( pRainmeter , meterWindow ) ;
// Set the SCREENAREA/WORKAREA variables
if ( c_MonitorVariables . empty ( ) )
{
SetMultiMonitorVariables ( true ) ;
}
// Set the SCREENAREA/WORKAREA variables for present monitor
SetAutoSelectedMonitorVariables ( meterWindow ) ;
ReadVariables ( ) ;
}
/*
* * SetMultiMonitorVariables
* *
* * Sets new values for the SCREENAREA / WORKAREA variables .
* *
*/
void CConfigParser : : SetMultiMonitorVariables ( bool reset )
{
TCHAR buffer [ 256 ] ;
RECT workArea , scrArea ;
if ( ! reset & & c_MonitorVariables . empty ( ) )
{
reset = true ; // Set all variables
}
SystemParametersInfo ( SPI_GETWORKAREA , 0 , & workArea , 0 ) ;
swprintf ( buffer , L " %i " , workArea . left ) ;
SetMonitorVariable ( L " WORKAREAX " , buffer ) ;
SetMonitorVariable ( L " PWORKAREAX " , buffer ) ;
swprintf ( buffer , L " %i " , workArea . top ) ;
SetMonitorVariable ( L " WORKAREAY " , buffer ) ;
SetMonitorVariable ( L " PWORKAREAY " , buffer ) ;
swprintf ( buffer , L " %i " , workArea . right - workArea . left ) ;
SetMonitorVariable ( L " WORKAREAWIDTH " , buffer ) ;
SetMonitorVariable ( L " PWORKAREAWIDTH " , buffer ) ;
swprintf ( buffer , L " %i " , workArea . bottom - workArea . top ) ;
SetMonitorVariable ( L " WORKAREAHEIGHT " , buffer ) ;
SetMonitorVariable ( L " PWORKAREAHEIGHT " , buffer ) ;
if ( reset )
{
scrArea . left = 0 ;
scrArea . top = 0 ;
scrArea . right = GetSystemMetrics ( SM_CXSCREEN ) ;
scrArea . bottom = GetSystemMetrics ( SM_CYSCREEN ) ;
swprintf ( buffer , L " %i " , scrArea . left ) ;
SetMonitorVariable ( L " SCREENAREAX " , buffer ) ;
SetMonitorVariable ( L " PSCREENAREAX " , buffer ) ;
swprintf ( buffer , L " %i " , scrArea . top ) ;
SetMonitorVariable ( L " SCREENAREAY " , buffer ) ;
SetMonitorVariable ( L " PSCREENAREAY " , buffer ) ;
swprintf ( buffer , L " %i " , scrArea . right - scrArea . left ) ;
SetMonitorVariable ( L " SCREENAREAWIDTH " , buffer ) ;
SetMonitorVariable ( L " PSCREENAREAWIDTH " , buffer ) ;
swprintf ( buffer , L " %i " , scrArea . bottom - scrArea . top ) ;
SetMonitorVariable ( L " SCREENAREAHEIGHT " , buffer ) ;
SetMonitorVariable ( L " PSCREENAREAHEIGHT " , buffer ) ;
swprintf ( buffer , L " %i " , GetSystemMetrics ( SM_XVIRTUALSCREEN ) ) ;
SetMonitorVariable ( L " VSCREENAREAX " , buffer ) ;
swprintf ( buffer , L " %i " , GetSystemMetrics ( SM_YVIRTUALSCREEN ) ) ;
SetMonitorVariable ( L " VSCREENAREAY " , buffer ) ;
swprintf ( buffer , L " %i " , GetSystemMetrics ( SM_CXVIRTUALSCREEN ) ) ;
SetMonitorVariable ( L " VSCREENAREAWIDTH " , buffer ) ;
swprintf ( buffer , L " %i " , GetSystemMetrics ( SM_CYVIRTUALSCREEN ) ) ;
SetMonitorVariable ( L " VSCREENAREAHEIGHT " , buffer ) ;
}
2010-03-20 19:40:30 +00:00
if ( CSystem : : GetMonitorCount ( ) > 0 )
* 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
{
2010-03-20 19:40:30 +00:00
const MULTIMONITOR_INFO & multimonInfo = CSystem : : GetMultiMonitorInfo ( ) ;
* 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
const std : : vector < MONITOR_INFO > & monitors = multimonInfo . monitors ;
2010-03-30 22:37:05 +00:00
for ( size_t i = 0 ; i < monitors . size ( ) ; + + 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
{
TCHAR buffer2 [ 256 ] ;
const RECT work = ( monitors [ i ] . active ) ? monitors [ i ] . work : workArea ;
swprintf ( buffer , L " %i " , work . left ) ;
swprintf ( buffer2 , L " WORKAREAX@%i " , i + 1 ) ;
SetMonitorVariable ( buffer2 , buffer ) ;
swprintf ( buffer , L " %i " , work . top ) ;
swprintf ( buffer2 , L " WORKAREAY@%i " , i + 1 ) ;
SetMonitorVariable ( buffer2 , buffer ) ;
swprintf ( buffer , L " %i " , work . right - work . left ) ;
swprintf ( buffer2 , L " WORKAREAWIDTH@%i " , i + 1 ) ;
SetMonitorVariable ( buffer2 , buffer ) ;
swprintf ( buffer , L " %i " , work . bottom - work . top ) ;
swprintf ( buffer2 , L " WORKAREAHEIGHT@%i " , i + 1 ) ;
SetMonitorVariable ( buffer2 , buffer ) ;
if ( reset )
{
const RECT screen = ( monitors [ i ] . active ) ? monitors [ i ] . screen : scrArea ;
swprintf ( buffer , L " %i " , screen . left ) ;
swprintf ( buffer2 , L " SCREENAREAX@%i " , i + 1 ) ;
SetMonitorVariable ( buffer2 , buffer ) ;
swprintf ( buffer , L " %i " , screen . top ) ;
swprintf ( buffer2 , L " SCREENAREAY@%i " , i + 1 ) ;
SetMonitorVariable ( buffer2 , buffer ) ;
swprintf ( buffer , L " %i " , screen . right - screen . left ) ;
swprintf ( buffer2 , L " SCREENAREAWIDTH@%i " , i + 1 ) ;
SetMonitorVariable ( buffer2 , buffer ) ;
swprintf ( buffer , L " %i " , screen . bottom - screen . top ) ;
swprintf ( buffer2 , L " SCREENAREAHEIGHT@%i " , i + 1 ) ;
SetMonitorVariable ( buffer2 , buffer ) ;
}
}
}
}
/**
* * Sets a new value for the SCREENAREA / WORKAREA variable .
* *
* * \ param strVariable
* * \ param strValue
*/
void CConfigParser : : SetMonitorVariable ( const std : : wstring & strVariable , const std : : wstring & strValue )
{
// DebugLog(L"MonitorVariable: %s=%s (size=%i)", strVariable.c_str(), strValue.c_str(), c_MonitorVariables.size());
std : : wstring strTmp ( strVariable ) ;
std : : transform ( strTmp . begin ( ) , strTmp . end ( ) , strTmp . begin ( ) , : : tolower ) ;
c_MonitorVariables [ strTmp ] = strValue ;
}
/*
* * SetAutoSelectedMonitorVariables
* *
* * Sets new SCREENAREA / WORKAREA variables for present monitor .
* *
*/
void CConfigParser : : SetAutoSelectedMonitorVariables ( CMeterWindow * meterWindow )
{
if ( meterWindow )
{
2010-03-20 19:40:30 +00:00
if ( CSystem : : GetMonitorCount ( ) > 0 )
* 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
{
TCHAR buffer [ 256 ] ;
int w1 , w2 , s1 , s2 ;
2010-03-20 19:40:30 +00:00
const MULTIMONITOR_INFO & multimonInfo = CSystem : : GetMultiMonitorInfo ( ) ;
* 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
const std : : vector < MONITOR_INFO > & monitors = multimonInfo . monitors ;
if ( meterWindow - > GetXScreenDefined ( ) )
{
int screenIndex = meterWindow - > GetXScreen ( ) ;
if ( screenIndex > = 0 & & ( screenIndex = = 0 | | screenIndex < = ( int ) monitors . size ( ) & &
screenIndex ! = multimonInfo . primary & & monitors [ screenIndex - 1 ] . active ) )
{
if ( screenIndex = = 0 )
{
s1 = w1 = multimonInfo . vsL ;
s2 = w2 = multimonInfo . 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 ;
}
swprintf ( buffer , L " %i " , w1 ) ;
SetVariable ( L " WORKAREAX " , buffer ) ;
swprintf ( buffer , L " %i " , w2 ) ;
SetVariable ( L " WORKAREAWIDTH " , buffer ) ;
swprintf ( buffer , L " %i " , s1 ) ;
SetVariable ( L " SCREENAREAX " , buffer ) ;
swprintf ( buffer , L " %i " , s2 ) ;
SetVariable ( L " SCREENAREAWIDTH " , buffer ) ;
}
}
if ( meterWindow - > GetYScreenDefined ( ) )
{
int screenIndex = meterWindow - > GetYScreen ( ) ;
if ( screenIndex > = 0 & & ( screenIndex = = 0 | | screenIndex < = ( int ) monitors . size ( ) & &
screenIndex ! = multimonInfo . primary & & monitors [ screenIndex - 1 ] . active ) )
{
if ( screenIndex = = 0 )
{
s1 = w1 = multimonInfo . vsL ;
s2 = w2 = multimonInfo . vsW ;
}
else
{
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 ;
}
swprintf ( buffer , L " %i " , w1 ) ;
SetVariable ( L " WORKAREAY " , buffer ) ;
swprintf ( buffer , L " %i " , w2 ) ;
SetVariable ( L " WORKAREAHEIGHT " , buffer ) ;
swprintf ( buffer , L " %i " , s1 ) ;
SetVariable ( L " SCREENAREAY " , buffer ) ;
swprintf ( buffer , L " %i " , s2 ) ;
SetVariable ( L " SCREENAREAHEIGHT " , buffer ) ;
}
}
}
}
}
2009-09-18 15:30:51 +00:00
/**
* * Replaces environment and internal variables in the given string .
* *
* * \ param result The string where the variables are returned . The string is modified .
*/
void CConfigParser : : ReplaceVariables ( std : : wstring & result )
{
CRainmeter : : ExpandEnvironmentVariables ( result ) ;
* 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#)
size_t start = 0 ;
size_t end = std : : wstring : : npos ;
size_t pos = std : : wstring : : npos ;
bool loop = true ;
do
{
pos = result . find ( L ' # ' , start ) ;
if ( pos ! = std : : wstring : : npos )
{
end = result . find ( L ' # ' , pos + 1 ) ;
if ( end ! = std : : wstring : : npos )
{
std : : wstring strTmp ( result . begin ( ) + pos + 1 , result . begin ( ) + end ) ;
std : : transform ( strTmp . begin ( ) , strTmp . end ( ) , strTmp . begin ( ) , : : tolower ) ;
2010-03-30 22:37:05 +00:00
std : : map < std : : wstring , std : : wstring > : : const_iterator iter = m_Variables . find ( strTmp ) ;
2009-09-18 15:30:51 +00:00
if ( iter ! = m_Variables . end ( ) )
{
// Variable found, replace it with the value
result . replace ( result . begin ( ) + pos , result . begin ( ) + end + 1 , ( * iter ) . second ) ;
start = pos + ( * iter ) . second . length ( ) ;
}
else
{
2010-03-30 22:37:05 +00:00
std : : map < std : : wstring , std : : wstring > : : const_iterator iter2 = c_MonitorVariables . find ( strTmp ) ;
* 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 ( iter2 ! = c_MonitorVariables . end ( ) )
{
// SCREENAREA/WORKAREA variable found, replace it with the value
result . replace ( result . begin ( ) + pos , result . begin ( ) + end + 1 , ( * iter2 ) . second ) ;
start = pos + ( * iter2 ) . second . length ( ) ;
}
else
{
start = end ;
}
2009-09-18 15:30:51 +00:00
}
}
else
{
loop = false ;
}
}
else
{
loop = false ;
}
} while ( loop ) ;
}
2009-02-10 18:37:48 +00:00
/*
* * ReadString
* *
* *
*/
2009-09-04 16:37:51 +00:00
const std : : wstring & CConfigParser : : ReadString ( LPCTSTR section , LPCTSTR key , LPCTSTR defValue , bool bReplaceMeasures )
2009-02-10 18:37:48 +00:00
{
static std : : wstring result ;
2009-09-04 16:37:51 +00:00
if ( section = = NULL )
{
section = L " " ;
}
if ( key = = NULL )
{
key = L " " ;
}
if ( defValue = = NULL )
{
defValue = L " " ;
}
2009-09-04 17:40:02 +00:00
std : : wstring strDefault = defValue ;
// If the template is defined read the value first from there.
if ( ! m_StyleTemplate . empty ( ) )
{
strDefault = GetValue ( m_StyleTemplate , key , strDefault ) ;
}
result = GetValue ( section , key , strDefault ) ;
2009-09-04 16:37:51 +00:00
if ( result = = defValue )
2009-02-10 18:37:48 +00:00
{
2009-09-04 16:37:51 +00:00
return result ;
2009-08-26 17:37:15 +00:00
}
2009-02-10 18:37:48 +00:00
// Check Litestep vars
if ( Rainmeter & & ! Rainmeter - > GetDummyLitestep ( ) )
{
std : : string ansi = ConvertToAscii ( result . c_str ( ) ) ;
char buffer [ 4096 ] ; // lets hope the buffer is large enough...
if ( ansi . size ( ) < 4096 )
{
VarExpansion ( buffer , ansi . c_str ( ) ) ;
result = ConvertToWide ( buffer ) ;
}
}
2009-09-18 15:30:51 +00:00
ReplaceVariables ( result ) ;
2009-02-10 18:37:48 +00:00
2009-08-26 17:37:15 +00:00
// Check for measures ([Measure])
2009-08-26 19:29:49 +00:00
if ( ! m_Measures . empty ( ) & & bReplaceMeasures )
2009-08-26 17:37:15 +00:00
{
2009-09-18 15:30:51 +00:00
size_t start = 0 ;
size_t end = std : : wstring : : npos ;
size_t pos = std : : wstring : : npos ;
2009-09-12 11:11:40 +00:00
size_t pos2 = std : : wstring : : npos ;
2009-09-18 15:30:51 +00:00
bool loop = true ;
2009-08-26 17:37:15 +00:00
do
{
pos = result . find ( L ' [ ' , start ) ;
if ( pos ! = std : : wstring : : npos )
{
2009-09-12 11:11:40 +00:00
end = result . find ( L ' ] ' , pos + 1 ) ;
2009-08-26 17:37:15 +00:00
if ( end ! = std : : wstring : : npos )
{
2009-09-12 11:11:40 +00:00
pos2 = result . find ( L ' [ ' , pos + 1 ) ;
if ( pos2 = = std : : wstring : : npos | | end < pos2 )
2009-08-26 17:37:15 +00:00
{
2009-09-12 11:11:40 +00:00
std : : wstring var ( result . begin ( ) + pos + 1 , result . begin ( ) + end ) ;
2010-03-30 22:37:05 +00:00
std : : map < std : : wstring , CMeasure * > : : const_iterator iter = m_Measures . find ( var ) ;
2009-09-12 11:11:40 +00:00
if ( iter ! = m_Measures . end ( ) )
{
2010-02-03 08:01:50 +00:00
std : : wstring value = ( * iter ) . second - > GetStringValue ( false , 1 , 5 , false ) ;
2009-09-12 11:11:40 +00:00
// Measure found, replace it with the value
result . replace ( result . begin ( ) + pos , result . begin ( ) + end + 1 , value ) ;
start = pos + value . length ( ) ;
}
else
{
start = end ;
}
2009-08-26 17:37:15 +00:00
}
else
{
2009-09-12 11:11:40 +00:00
start = pos2 ;
2009-08-26 17:37:15 +00:00
}
}
else
{
loop = false ;
}
}
else
{
loop = false ;
}
} while ( loop ) ;
}
2009-02-10 18:37:48 +00:00
return result ;
}
2009-08-26 17:37:15 +00:00
void CConfigParser : : AddMeasure ( CMeasure * pMeasure )
{
if ( pMeasure )
{
m_Measures [ pMeasure - > GetName ( ) ] = pMeasure ;
}
}
2009-02-10 18:37:48 +00:00
double CConfigParser : : ReadFloat ( LPCTSTR section , LPCTSTR key , double defValue )
{
TCHAR buffer [ 256 ] ;
swprintf ( buffer , L " %f " , defValue ) ;
const std : : wstring & result = ReadString ( section , key , buffer ) ;
2010-02-08 14:12:47 +00:00
return ParseDouble ( result , defValue ) ;
2009-02-10 18:37:48 +00:00
}
2009-07-27 11:48:57 +00:00
std : : vector < Gdiplus : : REAL > CConfigParser : : ReadFloats ( LPCTSTR section , LPCTSTR key )
{
std : : vector < Gdiplus : : REAL > result ;
std : : wstring tmp = ReadString ( section , key , L " " ) ;
if ( ! tmp . empty ( ) & & tmp [ tmp . length ( ) - 1 ] ! = L ' ; ' )
{
tmp + = L " ; " ;
}
// Tokenize and parse the floats
std : : vector < std : : wstring > tokens = Tokenize ( tmp , L " ; " ) ;
2010-03-30 22:37:05 +00:00
for ( size_t i = 0 ; i < tokens . size ( ) ; + + i )
2009-07-27 11:48:57 +00:00
{
2010-02-08 14:12:47 +00:00
result . push_back ( ( Gdiplus : : REAL ) ParseDouble ( tokens [ i ] , 0 ) ) ;
2009-07-27 11:48:57 +00:00
}
return result ;
}
2009-02-10 18:37:48 +00:00
int CConfigParser : : ReadInt ( LPCTSTR section , LPCTSTR key , int defValue )
{
TCHAR buffer [ 256 ] ;
swprintf ( buffer , L " %i " , defValue ) ;
const std : : wstring & result = ReadString ( section , key , buffer ) ;
2010-02-08 14:12:47 +00:00
return ( int ) ParseDouble ( result , defValue , true ) ;
2009-02-10 18:37:48 +00:00
}
2009-07-30 15:19:47 +00:00
// Works as ReadFloat except if the value is surrounded by parenthesis in which case it tries to evaluate the formula
double CConfigParser : : ReadFormula ( LPCTSTR section , LPCTSTR key , double defValue )
{
TCHAR buffer [ 256 ] ;
swprintf ( buffer , L " %f " , defValue ) ;
const std : : wstring & result = ReadString ( section , key , buffer ) ;
// Formulas must be surrounded by parenthesis
if ( ! result . empty ( ) & & result [ 0 ] = = L ' ( ' & & result [ result . size ( ) - 1 ] = = L ' ) ' )
{
double resultValue = defValue ;
char * errMsg = MathParser_Parse ( m_Parser , ConvertToAscii ( result . substr ( 1 , result . size ( ) - 2 ) . c_str ( ) ) . c_str ( ) , & resultValue ) ;
if ( errMsg ! = NULL )
{
DebugLog ( ConvertToWide ( errMsg ) . c_str ( ) ) ;
}
return resultValue ;
}
2010-02-08 14:12:47 +00:00
return ParseDouble ( result , defValue ) ;
2009-07-30 15:19:47 +00:00
}
2010-03-18 19:48:14 +00:00
// Returns an int if the formula was read successfully, -1 for failure.
// Pass a pointer to a double.
int CConfigParser : : ReadFormula ( std : : wstring & result , double * resultValue )
{
// Formulas must be surrounded by parenthesis
if ( ! result . empty ( ) & & result [ 0 ] = = L ' ( ' & & result [ result . size ( ) - 1 ] = = L ' ) ' )
{
char * errMsg = MathParser_Parse ( m_Parser , ConvertToAscii ( result . substr ( 1 , result . size ( ) - 2 ) . c_str ( ) ) . c_str ( ) , resultValue ) ;
if ( errMsg ! = NULL )
{
DebugLog ( ConvertToWide ( errMsg ) . c_str ( ) ) ;
return - 1 ;
}
return 1 ;
}
return - 1 ;
}
2009-02-10 18:37:48 +00:00
Color CConfigParser : : ReadColor ( LPCTSTR section , LPCTSTR key , Color defValue )
{
TCHAR buffer [ 256 ] ;
swprintf ( buffer , L " %i, %i, %i, %i " , defValue . GetR ( ) , defValue . GetG ( ) , defValue . GetB ( ) , defValue . GetA ( ) ) ;
const std : : wstring & result = ReadString ( section , key , buffer ) ;
return ParseColor ( result . c_str ( ) ) ;
}
2009-07-27 11:48:57 +00:00
/*
* * Tokenize
* *
* * Splits the string from the delimiters
* *
* * http : //www.digitalpeer.com/id/simple
*/
std : : vector < std : : wstring > CConfigParser : : Tokenize ( const std : : wstring & str , const std : : wstring delimiters )
{
std : : vector < std : : wstring > tokens ;
std : : wstring : : size_type lastPos = str . find_first_not_of ( L " ; " , 0 ) ; // skip delimiters at beginning.
std : : wstring : : size_type pos = str . find_first_of ( delimiters , lastPos ) ; // find first "non-delimiter".
while ( std : : wstring : : npos ! = pos | | std : : wstring : : npos ! = lastPos )
{
tokens . push_back ( str . substr ( lastPos , pos - lastPos ) ) ; // found a token, add it to the vector.
lastPos = str . find_first_not_of ( delimiters , pos ) ; // skip delimiters. Note the "not_of"
pos = str . find_first_of ( delimiters , lastPos ) ; // find next "non-delimiter"
}
return tokens ;
}
2010-02-08 14:12:47 +00:00
/*
* * ParseDouble
* *
* * This is a helper method that parses the floating - point value from the given string .
* * If the given string is invalid format or causes overflow / underflow , returns given default value .
* *
*/
double CConfigParser : : ParseDouble ( const std : : wstring & string , double defValue , bool rejectExp )
{
2010-02-27 09:51:48 +00:00
std : : wstring : : size_type pos ;
// Ignore inline comments which start with ';'
if ( ( pos = string . find_first_of ( L ' ; ' ) ) ! = std : : wstring : : npos )
{
std : : wstring temp ( string , 0 , pos ) ;
return ParseDouble ( temp , defValue , rejectExp ) ;
}
2010-02-08 14:12:47 +00:00
if ( rejectExp )
{
2010-02-27 09:51:48 +00:00
// Reject if the given string includes the exponential part
if ( string . find_last_of ( L " dDeE " ) ! = std : : wstring : : npos )
2010-02-08 14:12:47 +00:00
{
return defValue ;
}
}
2010-02-27 09:51:48 +00:00
if ( ( pos = string . find_first_not_of ( L " \t \r \n " ) ) ! = std : : wstring : : npos )
2010-02-08 14:12:47 +00:00
{
// Trim white-space
2010-02-27 09:51:48 +00:00
std : : wstring temp ( string , pos , string . find_last_not_of ( L " \t \r \n " ) - pos + 1 ) ;
2010-02-08 14:12:47 +00:00
WCHAR * end = NULL ;
errno = 0 ;
double resultValue = wcstod ( temp . c_str ( ) , & end ) ;
if ( end & & * end = = L ' \0 ' & & errno ! = ERANGE )
{
return resultValue ;
}
}
return defValue ;
}
2009-02-10 18:37:48 +00:00
/*
* * ParseColor
* *
* * This is a 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 .
* *
*/
Color CConfigParser : : ParseColor ( LPCTSTR string )
{
int R , G , B , A ;
if ( wcschr ( string , L ' , ' ) ! = NULL )
{
WCHAR * parseSz = _wcsdup ( string ) ;
WCHAR * token ;
token = wcstok ( parseSz , L " , " ) ;
if ( token ! = NULL )
{
R = _wtoi ( token ) ;
2010-02-08 14:12:47 +00:00
R = max ( R , 0 ) ;
R = min ( R , 255 ) ;
2009-02-10 18:37:48 +00:00
}
else
{
R = 255 ;
}
token = wcstok ( NULL , L " , " ) ;
if ( token ! = NULL )
{
G = _wtoi ( token ) ;
2010-02-08 14:12:47 +00:00
G = max ( G , 0 ) ;
G = min ( G , 255 ) ;
2009-02-10 18:37:48 +00:00
}
else
{
G = 255 ;
}
token = wcstok ( NULL , L " , " ) ;
if ( token ! = NULL )
{
B = _wtoi ( token ) ;
2010-02-08 14:12:47 +00:00
B = max ( B , 0 ) ;
B = min ( B , 255 ) ;
2009-02-10 18:37:48 +00:00
}
else
{
B = 255 ;
}
token = wcstok ( NULL , L " , " ) ;
if ( token ! = NULL )
{
A = _wtoi ( token ) ;
2010-02-08 14:12:47 +00:00
A = max ( A , 0 ) ;
A = min ( A , 255 ) ;
2009-02-10 18:37:48 +00:00
}
else
{
A = 255 ;
}
free ( parseSz ) ;
}
else
{
const WCHAR * start = string ;
if ( wcsncmp ( string , L " 0x " , 2 ) = = 0 )
{
start = string + 2 ;
}
2010-02-08 14:12:47 +00:00
if ( wcslen ( string ) > 6 & & ! iswspace ( string [ 6 ] ) )
2009-02-10 18:37:48 +00:00
{
swscanf ( string , L " %02x%02x%02x%02x " , & R , & G , & B , & A ) ;
}
else
{
swscanf ( string , L " %02x%02x%02x " , & R , & G , & B ) ;
A = 255 ; // Opaque
}
}
return Color ( A , R , G , B ) ;
}
2009-08-26 17:37:15 +00:00
//==============================================================================
/**
* * Reads the given ini file and fills the m_Values and m_Keys maps .
* *
* * \ param iniFile The ini file to be read .
*/
2009-09-18 15:30:51 +00:00
void CConfigParser : : ReadIniFile ( const std : : wstring & iniFile , 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?
{
MessageBox ( NULL , L " It looks like you've made an infinite \n loop with the @include statements. \n Please check your skin. " , L " Rainmeter " , MB_OK | MB_ICONERROR ) ;
return ;
}
2009-08-26 17:37:15 +00:00
2010-04-02 01:35:53 +00:00
// Avoid "IniFileMapping"
std : : wstring iniRead = GetAlternateFileName ( iniFile ) ;
bool alternate = false ;
if ( ! iniRead . empty ( ) )
{
// Copy iniFile to temporary directory
if ( CRainmeter : : CopyFiles ( iniFile , iniRead ) )
{
if ( CRainmeter : : GetDebug ( ) ) DebugLog ( L " Reading file: %s (Alternate: %s) " , iniFile . c_str ( ) , iniRead . c_str ( ) ) ;
alternate = true ;
}
else // copy failed
{
DeleteFile ( iniRead . c_str ( ) ) ;
}
}
if ( ! alternate )
{
if ( CRainmeter : : GetDebug ( ) ) DebugLog ( L " Reading file: %s " , iniFile . c_str ( ) ) ;
iniRead = iniFile ;
}
2009-08-26 17:37:15 +00:00
// Get all the sections (i.e. different meters)
WCHAR * items = new WCHAR [ MAX_LINE_LENGTH ] ;
int size = MAX_LINE_LENGTH ;
// Get all the sections
while ( true )
{
items [ 0 ] = 0 ;
2010-04-02 01:35:53 +00:00
int res = GetPrivateProfileString ( NULL , NULL , NULL , items , size , iniRead . c_str ( ) ) ;
if ( res = = 0 ) // File not found
{
delete [ ] items ;
if ( alternate ) DeleteFile ( iniRead . c_str ( ) ) ;
return ;
}
2009-09-04 16:37:51 +00:00
if ( res < size - 2 ) break ; // Fits in the buffer
2009-08-26 17:37:15 +00:00
delete [ ] items ;
size * = 2 ;
items = new WCHAR [ size ] ;
2010-04-07 16:12:02 +00:00
}
2009-08-26 17:37:15 +00:00
// Read the sections
2010-04-07 16:12:02 +00:00
std : : list < std : : wstring > sections ;
2009-08-26 17:37:15 +00:00
WCHAR * pos = items ;
while ( wcslen ( pos ) > 0 )
{
2009-08-27 15:42:24 +00:00
std : : wstring strTmp ( pos ) ;
std : : transform ( strTmp . begin ( ) , strTmp . end ( ) , strTmp . begin ( ) , : : tolower ) ;
2009-09-18 15:30:51 +00:00
if ( m_Keys . find ( strTmp ) = = m_Keys . end ( ) )
{
m_Keys [ strTmp ] = std : : vector < std : : wstring > ( ) ;
2009-09-19 07:15:28 +00:00
m_Sections . push_back ( pos ) ;
2009-09-18 15:30:51 +00:00
}
2010-04-07 16:12:02 +00:00
sections . push_back ( pos ) ;
2009-08-26 17:37:15 +00:00
pos = pos + wcslen ( pos ) + 1 ;
}
// Read the keys and values
int bufferSize = MAX_LINE_LENGTH ;
2009-09-12 11:11:40 +00:00
WCHAR * buffer = new WCHAR [ bufferSize ] ;
2009-08-26 17:37:15 +00:00
2010-04-07 16:12:02 +00:00
std : : list < std : : wstring > : : const_iterator iter = sections . begin ( ) ;
for ( ; iter ! = sections . end ( ) ; + + iter )
2009-08-26 17:37:15 +00:00
{
while ( true )
{
items [ 0 ] = 0 ;
2010-04-07 16:12:02 +00:00
int res = GetPrivateProfileString ( ( * iter ) . c_str ( ) , NULL , NULL , items , size , iniRead . c_str ( ) ) ;
2009-09-04 16:37:51 +00:00
if ( res < size - 2 ) break ; // Fits in the buffer
2009-08-26 17:37:15 +00:00
delete [ ] items ;
size * = 2 ;
items = new WCHAR [ size ] ;
2010-04-07 16:12:02 +00:00
}
2009-08-26 17:37:15 +00:00
WCHAR * pos = items ;
while ( wcslen ( pos ) > 0 )
{
std : : wstring strKey = pos ;
while ( true )
{
buffer [ 0 ] = 0 ;
2010-04-07 16:12:02 +00:00
int res = GetPrivateProfileString ( ( * iter ) . c_str ( ) , strKey . c_str ( ) , L " " , buffer , bufferSize , iniRead . c_str ( ) ) ;
2009-09-04 16:37:51 +00:00
if ( res < bufferSize - 2 ) break ; // Fits in the buffer
2009-08-26 17:37:15 +00:00
delete [ ] buffer ;
bufferSize * = 2 ;
2009-09-04 16:37:51 +00:00
buffer = new WCHAR [ bufferSize ] ;
2010-04-07 16:12:02 +00:00
}
2009-08-26 17:37:15 +00:00
2009-09-18 15:30:51 +00:00
if ( wcsnicmp ( strKey . c_str ( ) , L " @include " , 8 ) = = 0 )
{
std : : wstring strIncludeFile = buffer ;
ReplaceVariables ( strIncludeFile ) ;
if ( strIncludeFile . find ( L ' : ' ) = = std : : wstring : : npos )
{
// It's a relative path so add the current path as a prefix
strIncludeFile = CRainmeter : : ExtractPath ( iniFile ) + strIncludeFile ;
}
ReadIniFile ( strIncludeFile , depth + 1 ) ;
}
else
{
2010-04-07 16:12:02 +00:00
SetValue ( ( * iter ) , strKey , buffer ) ;
2009-09-18 15:30:51 +00:00
}
2009-08-26 17:37:15 +00:00
pos = pos + wcslen ( pos ) + 1 ;
}
}
delete [ ] buffer ;
delete [ ] items ;
2010-04-02 01:35:53 +00:00
if ( alternate ) DeleteFile ( iniRead . c_str ( ) ) ;
2009-08-26 17:37:15 +00:00
}
//==============================================================================
/**
* * Sets the value for the key under the given section .
* *
* * \ param strSection The name of the section .
* * \ param strKey The name of the key .
* * \ param strValue The value for the key .
*/
void CConfigParser : : SetValue ( const std : : wstring & strSection , const std : : wstring & strKey , const std : : wstring & strValue )
{
2009-09-18 15:30:51 +00:00
// DebugLog(L"[%s] %s=%s (size: %i)", strSection.c_str(), strKey.c_str(), strValue.c_str(), m_Values.size());
2009-08-27 15:42:24 +00:00
std : : wstring strTmpSection ( strSection ) ;
std : : wstring strTmpKey ( strKey ) ;
std : : transform ( strTmpSection . begin ( ) , strTmpSection . end ( ) , strTmpSection . begin ( ) , : : tolower ) ;
std : : transform ( strTmpKey . begin ( ) , strTmpKey . end ( ) , strTmpKey . begin ( ) , : : tolower ) ;
stdext : : hash_map < std : : wstring , std : : vector < std : : wstring > > : : iterator iter = m_Keys . find ( strTmpSection ) ;
2009-08-26 17:37:15 +00:00
if ( iter ! = m_Keys . end ( ) )
{
std : : vector < std : : wstring > & array = ( * iter ) . second ;
2009-08-27 15:42:24 +00:00
array . push_back ( strTmpKey ) ;
2009-08-26 17:37:15 +00:00
}
2009-08-27 15:42:24 +00:00
m_Values [ strTmpSection + L " :: " + strTmpKey ] = strValue ;
2009-08-26 17:37:15 +00:00
}
//==============================================================================
/**
* * Returns the value for the key under the given section .
* *
* * \ param strSection The name of the section .
* * \ param strKey The name of the key .
* * \ param strDefault The default value for the key .
* * \ return The value for the key .
*/
const std : : wstring & CConfigParser : : GetValue ( const std : : wstring & strSection , const std : : wstring & strKey , const std : : wstring & strDefault )
{
2009-08-27 15:42:24 +00:00
std : : wstring strTmp ( strSection + L " :: " + strKey ) ;
std : : transform ( strTmp . begin ( ) , strTmp . end ( ) , strTmp . begin ( ) , : : tolower ) ;
2010-03-30 22:37:05 +00:00
stdext : : hash_map < std : : wstring , std : : wstring > : : const_iterator iter = m_Values . find ( strTmp ) ;
2009-08-26 17:37:15 +00:00
if ( iter ! = m_Values . end ( ) )
{
return ( * iter ) . second ;
}
return strDefault ;
}
//==============================================================================
/**
* * Returns the list of sections in the ini file .
* *
* * \ return A list of sections in the ini file .
*/
2009-09-19 07:15:28 +00:00
const std : : vector < std : : wstring > & CConfigParser : : GetSections ( )
2009-08-26 17:37:15 +00:00
{
2009-09-19 07:15:28 +00:00
return m_Sections ;
2009-08-26 17:37:15 +00:00
}
//==============================================================================
/**
* * Returns a list of keys under the given section .
* *
* * \ param strSection The name of the section .
* * \ return A list of keys under the given section .
*/
std : : vector < std : : wstring > CConfigParser : : GetKeys ( const std : : wstring & strSection )
{
2009-08-27 15:42:24 +00:00
std : : wstring strTmp ( strSection ) ;
std : : transform ( strTmp . begin ( ) , strTmp . end ( ) , strTmp . begin ( ) , : : tolower ) ;
2010-03-30 22:37:05 +00:00
stdext : : hash_map < std : : wstring , std : : vector < std : : wstring > > : : const_iterator iter = m_Keys . find ( strTmp ) ;
2009-08-26 17:37:15 +00:00
if ( iter ! = m_Keys . end ( ) )
{
return ( * iter ) . second ;
}
return std : : vector < std : : wstring > ( ) ;
}
2010-04-02 01:35:53 +00:00
void CConfigParser : : GetIniFileMappingList ( )
{
HKEY hKey ;
LONG ret ;
ret = RegOpenKeyEx ( HKEY_LOCAL_MACHINE , L " SOFTWARE \\ Microsoft \\ Windows NT \\ CurrentVersion \\ IniFileMapping " , 0 , KEY_ENUMERATE_SUB_KEYS , & hKey ) ;
if ( ret = = ERROR_SUCCESS )
{
WCHAR buffer [ MAX_PATH ] ;
DWORD index = 0 , cch = MAX_PATH ;
while ( true )
{
ret = RegEnumKeyEx ( hKey , index + + , buffer , & cch , NULL , NULL , NULL , NULL ) ;
if ( ret = = ERROR_NO_MORE_ITEMS ) break ;
if ( ret = = ERROR_SUCCESS )
{
m_IniFileMappings . push_back ( buffer ) ;
}
cch = MAX_PATH ;
}
RegCloseKey ( hKey ) ;
}
}
std : : wstring CConfigParser : : GetAlternateFileName ( const std : : wstring & iniFile )
{
std : : wstring alternate ;
if ( ! m_IniFileMappings . empty ( ) )
{
std : : wstring : : size_type pos = iniFile . find_last_of ( L ' \\ ' ) ;
std : : wstring filename ;
if ( pos ! = std : : wstring : : npos )
{
filename = iniFile . substr ( pos + 1 ) ;
}
else
{
filename = iniFile ;
}
for ( size_t i = 0 ; i < m_IniFileMappings . size ( ) ; + + i )
{
if ( wcsicmp ( m_IniFileMappings [ i ] . c_str ( ) , filename . c_str ( ) ) = = 0 )
{
WCHAR buffer [ 4096 ] ;
GetTempPath ( 4096 , buffer ) ;
alternate = buffer ;
if ( GetTempFileName ( alternate . c_str ( ) , L " cfg " , 0 , buffer ) ! = 0 )
{
alternate = buffer ;
std : : wstring tmp = GetAlternateFileName ( alternate ) ;
if ( tmp . empty ( ) )
{
return alternate ;
}
else // alternate is reserved
{
DeleteFile ( alternate . c_str ( ) ) ;
return tmp ;
}
}
else // failed
{
DebugLog ( L " Unable to create a temporary file to: %s " , alternate . c_str ( ) ) ;
alternate . clear ( ) ;
break ;
}
}
}
}
return alternate ;
}