mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
This commit is contained in:
236
Application/Application.cpp
Normal file
236
Application/Application.cpp
Normal file
@@ -0,0 +1,236 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Application/Application.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: Application.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.8 2004/06/05 10:50:40 rainy
|
||||
Fixed exports.
|
||||
|
||||
Revision 1.7 2002/07/01 15:22:29 rainy
|
||||
The existance of Litestep is not checked anymore.
|
||||
|
||||
Revision 1.6 2002/05/04 08:08:47 rainy
|
||||
!Bangs can be executed from the exe.
|
||||
|
||||
Revision 1.5 2002/03/31 09:50:56 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.4 2002/01/16 16:03:52 rainy
|
||||
The quotes are removed from the commandline.
|
||||
|
||||
Revision 1.3 2001/09/01 12:55:42 rainy
|
||||
Added RainmeterRefresh declaration.
|
||||
|
||||
Revision 1.2 2001/08/25 17:04:45 rainy
|
||||
Removed all Tray stuff.
|
||||
The correct instance is now given to the DLL.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable : 4996)
|
||||
|
||||
#include "resource.h"
|
||||
#include "..\Library\Rainmeter.h"
|
||||
|
||||
/*
|
||||
** Protos
|
||||
*/
|
||||
BOOL InitApplication(HINSTANCE hInstance, const WCHAR* WinClass);
|
||||
HWND InitInstance(HINSTANCE hInstance, const WCHAR* WinClass, const WCHAR* WinName);
|
||||
LONG APIENTRY MainWndProc(HWND, UINT, UINT, LONG);
|
||||
void Bang(HWND hWnd, const WCHAR* command);
|
||||
|
||||
/*
|
||||
** Stuff from the DLL
|
||||
*/
|
||||
extern "C" EXPORT_PLUGIN int initModuleEx(HWND ParentWnd, HINSTANCE dllInst, LPCSTR);
|
||||
extern "C" EXPORT_PLUGIN void quitModule(HINSTANCE dllInst);
|
||||
extern "C" EXPORT_PLUGIN void Initialize(bool DummyLS, LPCTSTR CmdLine);
|
||||
extern "C++" CRainmeter* Rainmeter;
|
||||
|
||||
/*
|
||||
** WinMain
|
||||
**
|
||||
** The Main-function
|
||||
**
|
||||
*/
|
||||
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPCTSTR lpCmdLine, int nCmdShow)
|
||||
{
|
||||
MSG msg;
|
||||
WCHAR* WinClass = L"DummyRainWClass";
|
||||
WCHAR* WinName = L"Rainmeter control window";
|
||||
HWND hWnd;
|
||||
|
||||
if(!hPrevInstance)
|
||||
{
|
||||
if (!InitApplication(hInstance, WinClass)) return FALSE;
|
||||
}
|
||||
|
||||
hWnd=InitInstance(hInstance, WinClass, WinName);
|
||||
if(!hWnd) return FALSE;
|
||||
|
||||
if (lpCmdLine[0] == '!')
|
||||
{
|
||||
// It's a !bang
|
||||
Bang(hWnd, lpCmdLine);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Remove quotes from the commandline
|
||||
WCHAR Path[256];
|
||||
Path[0] = 0;
|
||||
int Pos = 0;
|
||||
if(lpCmdLine)
|
||||
{
|
||||
for(int i = 0; i <= wcslen(lpCmdLine); i++)
|
||||
{
|
||||
if(lpCmdLine[i] != L'\"') Path[Pos++] = lpCmdLine[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize from exe
|
||||
Initialize(true, Path);
|
||||
|
||||
// Check that the DLL is available
|
||||
HMODULE module = GetModuleHandle(L"Rainmeter.dll");
|
||||
if(module == NULL)
|
||||
{
|
||||
MessageBox(NULL, L"Unable to load Rainmeter.dll", L"Rainmeter", MB_OK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Initialize the DLL
|
||||
initModuleEx(hWnd, module, NULL);
|
||||
|
||||
// Run the standard window message loop
|
||||
while(GetMessage(&msg, NULL, 0, 0))
|
||||
{
|
||||
TranslateMessage(&msg);
|
||||
DispatchMessage(&msg);
|
||||
}
|
||||
|
||||
return (int)msg.wParam;
|
||||
}
|
||||
|
||||
/*
|
||||
** InitApplication
|
||||
**
|
||||
** Creates the windowclass
|
||||
**
|
||||
*/
|
||||
BOOL InitApplication(HINSTANCE hInstance, const WCHAR* WinClass)
|
||||
{
|
||||
WNDCLASS wc;
|
||||
|
||||
wc.style = 0;
|
||||
wc.lpfnWndProc = (WNDPROC) MainWndProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = hInstance;
|
||||
wc.hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_RAINMETER));
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = WinClass;
|
||||
|
||||
return RegisterClass(&wc);
|
||||
}
|
||||
|
||||
/*
|
||||
** InitInstance
|
||||
**
|
||||
** Creates the window. This is just an invisible window. The real window
|
||||
** is created by the DLL.
|
||||
**
|
||||
*/
|
||||
HWND InitInstance(HINSTANCE hInstance, const WCHAR* WinClass, const WCHAR* WinName)
|
||||
{
|
||||
return CreateWindowEx(
|
||||
WS_EX_TOOLWINDOW,
|
||||
WinClass,
|
||||
WinName,
|
||||
WS_POPUP,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
NULL,
|
||||
NULL,
|
||||
hInstance,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
** Bang
|
||||
**
|
||||
** Sends bangs to the DLL
|
||||
**
|
||||
*/
|
||||
void Bang(HWND hWnd, const WCHAR* command)
|
||||
{
|
||||
// Check if Rainlendar is running
|
||||
HWND wnd = FindWindow(L"RainmeterMeterWindow", NULL);
|
||||
|
||||
if (wnd != NULL)
|
||||
{
|
||||
COPYDATASTRUCT copyData;
|
||||
|
||||
copyData.dwData = 1;
|
||||
copyData.cbData = (DWORD)((wcslen(command) + 1) * sizeof(WCHAR));
|
||||
copyData.lpData = (void*)command;
|
||||
|
||||
// Send the bang to the Rainlendar window
|
||||
SendMessage(wnd, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)©Data);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox(hWnd, L"Rainmeter is not running.\nUnable to send the !bang to it.", L"Rainmeter", MB_OK);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** MainWndProc
|
||||
**
|
||||
** The main window procedure
|
||||
**
|
||||
*/
|
||||
LONG APIENTRY MainWndProc(HWND hWnd, UINT message, UINT wParam, LONG lParam)
|
||||
{
|
||||
switch(message) {
|
||||
|
||||
case WM_DESTROY:
|
||||
{
|
||||
quitModule(NULL);
|
||||
PostQuitMessage(0);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
return (LONG)DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
157
Application/Application.dsp
Normal file
157
Application/Application.dsp
Normal file
@@ -0,0 +1,157 @@
|
||||
# Microsoft Developer Studio Project File - Name="Application" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=Application - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Application.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Application.mak" CFG="Application - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Application - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "Application - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "Application - Win32 Release 64" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName "Application"
|
||||
# PROP Scc_LocalPath ".."
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Application - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "x32/Release"
|
||||
# PROP Intermediate_Dir "x32/Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40b /d "NDEBUG"
|
||||
# ADD RSC /l 0x40b /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /entry:"wWinMainCRTStartup" /subsystem:windows /machine:I386 /out:"../TestBench/x32/Release/Rainmeter.exe"
|
||||
|
||||
!ELSEIF "$(CFG)" == "Application - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "x32/Debug"
|
||||
# PROP Intermediate_Dir "x32/Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40b /d "_DEBUG"
|
||||
# ADD RSC /l 0x40b /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /entry:"wWinMainCRTStartup" /subsystem:windows /debug /machine:I386 /out:"../TestBench/x32/Debug/Rainmeter.exe" /pdbtype:sept
|
||||
|
||||
!ELSEIF "$(CFG)" == "Application - Win32 Release 64"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Application___Win32_Release_64"
|
||||
# PROP BASE Intermediate_Dir "Application___Win32_Release_64"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "x64/Release"
|
||||
# PROP Intermediate_Dir "x64/Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /FD /GL /EHsc /Wp64 /GA /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40b /d "NDEBUG"
|
||||
# ADD RSC /l 0x40b /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /entry:"wWinMainCRTStartup" /subsystem:windows /machine:I386 /out:"../TestBench/x32/Release/Rainmeter.exe"
|
||||
# ADD LINK32 bufferoverflowU.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /entry:"wWinMainCRTStartup" /subsystem:windows /machine:IX86 /out:"../TestBench/x64/Release/Rainmeter.exe" /machine:AMD64 /LTCG
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Application - Win32 Release"
|
||||
# Name "Application - Win32 Debug"
|
||||
# Name "Application - Win32 Release 64"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Application.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Application.rc
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Rainmeter.ico
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Help\History.htm
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\Todo.txt
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
72
Application/Application.rc
Normal file
72
Application/Application.rc
Normal file
@@ -0,0 +1,72 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Finnish resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FIN)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_FINNISH, SUBLANG_DEFAULT
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_RAINMETER ICON DISCARDABLE "Rainmeter.ico"
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // Finnish resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
280
Application/Application.vcproj
Normal file
280
Application/Application.vcproj
Normal file
@@ -0,0 +1,280 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="Application"
|
||||
SccProjectName="Application"
|
||||
SccLocalPath="..">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release 64|Win32"
|
||||
OutputDirectory=".\x64/Release"
|
||||
IntermediateDirectory=".\x64/Release"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="1">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/GL /EHsc /Wp64 /GA "
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;UNICODE"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\x64/Release/Application.pch"
|
||||
AssemblerListingLocation=".\x64/Release/"
|
||||
ObjectFile=".\x64/Release/"
|
||||
ProgramDataBaseFileName=".\x64/Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/machine:AMD64 /LTCG "
|
||||
AdditionalDependencies="bufferoverflowU.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../TestBench/x64/Release/Rainmeter.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x64/Release/Rainmeter.pdb"
|
||||
SubSystem="2"
|
||||
EntryPointSymbol="wWinMainCRTStartup"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x64/Release/Application.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1035"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\x32/Debug"
|
||||
IntermediateDirectory=".\x32/Debug"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="1">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;UNICODE"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Debug/Application.pch"
|
||||
AssemblerListingLocation=".\x32/Debug/"
|
||||
ObjectFile=".\x32/Debug/"
|
||||
ProgramDataBaseFileName=".\x32/Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="../TestBench/x32/Debug/Rainmeter.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Debug/Rainmeter.pdb"
|
||||
SubSystem="2"
|
||||
EntryPointSymbol="wWinMainCRTStartup"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Debug/Application.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1035"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\x32/Release"
|
||||
IntermediateDirectory=".\x32/Release"
|
||||
ConfigurationType="1"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="1">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;UNICODE"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Release/Application.pch"
|
||||
AssemblerListingLocation=".\x32/Release/"
|
||||
ObjectFile=".\x32/Release/"
|
||||
ProgramDataBaseFileName=".\x32/Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="../TestBench/x32/Release/Rainmeter.exe"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Release/Rainmeter.pdb"
|
||||
SubSystem="2"
|
||||
EntryPointSymbol="wWinMainCRTStartup"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Release/Application.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1035"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat">
|
||||
<File
|
||||
RelativePath="Application.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions=""
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions=""/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="Application.rc">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl">
|
||||
<File
|
||||
RelativePath="resource.h">
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
|
||||
<File
|
||||
RelativePath="Rainmeter.ico">
|
||||
</File>
|
||||
</Filter>
|
||||
<File
|
||||
RelativePath="..\Help\History.htm">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\Todo.txt">
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
BIN
Application/Rainmeter.ico
Normal file
BIN
Application/Rainmeter.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 96 KiB |
21
Application/resource.h
Normal file
21
Application/resource.h
Normal file
@@ -0,0 +1,21 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by Host.rc
|
||||
//
|
||||
#define IDI_RAINMETER 103
|
||||
#define IDR_TRAYMENU 104
|
||||
#define ID_TRAYMENU_REFRESH 40001
|
||||
#define ID_TRAYMENU_QUIT 40002
|
||||
#define ID_TRAYMENU_SHOW 40003
|
||||
#define ID_TRAYMENU_HIDE 40010
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 105
|
||||
#define _APS_NEXT_COMMAND_VALUE 40011
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
430
Library/AboutDialog.cpp
Normal file
430
Library/AboutDialog.cpp
Normal file
@@ -0,0 +1,430 @@
|
||||
/*
|
||||
Copyright (C) 2000 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/AboutDialog.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: AboutDialog.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.6 2004/08/13 15:43:19 rainy
|
||||
Added update check.
|
||||
|
||||
Revision 1.5 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.4 2004/03/13 16:13:50 rainy
|
||||
Added support for multiple configs.
|
||||
|
||||
Revision 1.3 2003/12/05 15:50:09 Rainy
|
||||
Multi-instance changes.
|
||||
|
||||
Revision 1.2 2002/12/23 14:26:33 rainy
|
||||
Made the dialog resizable.
|
||||
|
||||
Revision 1.1 2002/07/01 15:35:55 rainy
|
||||
Intial version
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4786)
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "Rainmeter.h"
|
||||
#include "MeterWindow.h"
|
||||
#include "Measure.h"
|
||||
#include "resource.h"
|
||||
#include "AboutDialog.h"
|
||||
#include <commctrl.h>
|
||||
|
||||
extern CRainmeter* Rainmeter;
|
||||
|
||||
INT_PTR CALLBACK AboutProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam);
|
||||
HWND g_DialogWin = NULL;
|
||||
|
||||
struct PLUGIN_INFO
|
||||
{
|
||||
std::wstring name;
|
||||
UINT version;
|
||||
std::wstring author;
|
||||
};
|
||||
std::vector<PLUGIN_INFO> g_Plugins;
|
||||
|
||||
HWND OpenAboutDialog(HWND hwndOwner, HINSTANCE instance)
|
||||
{
|
||||
if (g_DialogWin == NULL)
|
||||
{
|
||||
g_DialogWin = CreateDialog(instance, MAKEINTRESOURCE(IDD_ABOUT_DIALOG), hwndOwner, AboutProc);
|
||||
}
|
||||
ShowWindow(g_DialogWin, SW_SHOWNORMAL);
|
||||
UpdateAboutStatistics();
|
||||
|
||||
return g_DialogWin;
|
||||
}
|
||||
|
||||
void UpdateAboutStatistics()
|
||||
{
|
||||
if (g_DialogWin != NULL && IsWindowVisible(g_DialogWin))
|
||||
{
|
||||
HWND widget;
|
||||
widget = GetDlgItem(g_DialogWin, IDC_CONFIG_TAB);
|
||||
int selected = TabCtrl_GetCurSel(widget);
|
||||
int current = 0;
|
||||
|
||||
widget = GetDlgItem(g_DialogWin, IDC_STATISTICS);
|
||||
SendMessage(widget, WM_SETREDRAW, 0, 0);
|
||||
|
||||
std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
|
||||
|
||||
std::map<std::wstring, CMeterWindow*>::iterator iter = windows.begin();
|
||||
for( ; iter != windows.end(); iter++)
|
||||
{
|
||||
if (current == selected)
|
||||
{
|
||||
int count = ListView_GetItemCount(widget);
|
||||
|
||||
CMeterWindow* meterWindow = (*iter).second;
|
||||
std::list<CMeasure*>& measures = meterWindow->GetMeasures();
|
||||
|
||||
int index = 0;
|
||||
std::list<CMeasure*>::iterator i = measures.begin();
|
||||
for( ; i != measures.end(); i++)
|
||||
{
|
||||
const WCHAR* name = (*i)->GetName();
|
||||
const WCHAR* val = (*i)->GetStats();
|
||||
|
||||
std::wstring range;
|
||||
WCHAR buffer[256];
|
||||
double minVal = (*i)->GetMinValue();
|
||||
double maxVal = (*i)->GetMaxValue();
|
||||
CMeasure::GetScaledValue(1, minVal, buffer);
|
||||
range = buffer;
|
||||
range += L" - ";
|
||||
CMeasure::GetScaledValue(1, maxVal, buffer);
|
||||
range += buffer;
|
||||
|
||||
if (name && wcslen(name) > 0)
|
||||
{
|
||||
if (index < count)
|
||||
{
|
||||
ListView_SetItemText(widget, index, 0, (WCHAR*)name);
|
||||
}
|
||||
else
|
||||
{
|
||||
LVITEM vitem;
|
||||
vitem.mask = LVIF_TEXT;
|
||||
vitem.iItem = 0;
|
||||
vitem.iSubItem = 0;
|
||||
vitem.pszText = (WCHAR*)name;
|
||||
ListView_InsertItem(widget, &vitem);
|
||||
}
|
||||
|
||||
if (val && wcslen(val) > 0)
|
||||
{
|
||||
ListView_SetItemText(widget, index, 1, (WCHAR*)val);
|
||||
}
|
||||
ListView_SetItemText(widget, index, 2, (WCHAR*)range.c_str());
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
current++;
|
||||
}
|
||||
|
||||
SendMessage(widget, WM_SETREDRAW, 1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateWidgets(HWND window)
|
||||
{
|
||||
HWND widget;
|
||||
widget = GetDlgItem(g_DialogWin, IDC_CONFIG_TAB);
|
||||
int selected = TabCtrl_GetCurSel(widget);
|
||||
int count = TabCtrl_GetItemCount(widget);
|
||||
|
||||
widget = GetDlgItem(g_DialogWin, IDC_STATISTICS);
|
||||
ListView_DeleteAllItems(widget);
|
||||
|
||||
if (count == selected + 1)
|
||||
{
|
||||
LVCOLUMN lvc;
|
||||
lvc.mask = LVCF_TEXT;
|
||||
lvc.pszText = L"Plugin";
|
||||
ListView_SetColumn(widget, 0, &lvc);
|
||||
lvc.pszText = L"Version";
|
||||
ListView_SetColumn(widget, 1, &lvc);
|
||||
lvc.pszText = L"Author";
|
||||
ListView_SetColumn(widget, 2, &lvc);
|
||||
|
||||
// Update the list of plugins
|
||||
std::vector<PLUGIN_INFO>::iterator iter = g_Plugins.begin();
|
||||
LVITEM vitem;
|
||||
vitem.mask = LVIF_TEXT;
|
||||
|
||||
int i = 0;
|
||||
for ( ; iter != g_Plugins.end(); iter++)
|
||||
{
|
||||
if (!(*iter).name.empty())
|
||||
{
|
||||
vitem.iItem = i;
|
||||
vitem.iSubItem = 0;
|
||||
vitem.pszText = (WCHAR*)(*iter).name.c_str();
|
||||
ListView_InsertItem(widget, &vitem);
|
||||
}
|
||||
|
||||
if ((*iter).version != 0)
|
||||
{
|
||||
WCHAR buffer[256];
|
||||
swprintf(buffer, L"%i.%i", (*iter).version / 1000, (*iter).version % 1000);
|
||||
ListView_SetItemText(widget, i, 1, buffer);
|
||||
}
|
||||
|
||||
ListView_SetItemText(widget, i, 2, (WCHAR*)(*iter).author.c_str());
|
||||
|
||||
i++;
|
||||
}
|
||||
|
||||
if (g_Plugins.size() > 0)
|
||||
{
|
||||
ListView_SetItemState(widget, 0, LVIS_SELECTED, LVIS_SELECTED);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LVCOLUMN lvc;
|
||||
lvc.mask = LVCF_TEXT;
|
||||
lvc.pszText = L"Measure";
|
||||
ListView_SetColumn(widget, 0, &lvc);
|
||||
lvc.pszText = L"Value";
|
||||
ListView_SetColumn(widget, 1, &lvc);
|
||||
lvc.pszText = L"Range";
|
||||
ListView_SetColumn(widget, 2, &lvc);
|
||||
}
|
||||
}
|
||||
|
||||
typedef LPCTSTR (*GETPLUGINAUTHOR)();
|
||||
typedef UINT (*GETPLUGINVERSION)();
|
||||
|
||||
void ScanPlugins()
|
||||
{
|
||||
WIN32_FIND_DATA fileData; // Data structure describes the file found
|
||||
HANDLE hSearch; // Search handle returned by FindFirstFile
|
||||
|
||||
std::wstring files = CRainmeter::FixPath(L"*.dll", PATH_FOLDER_PLUGIN, L"");
|
||||
|
||||
g_Plugins.clear();
|
||||
|
||||
// Start searching for .ini files in the given directory.
|
||||
hSearch = FindFirstFile(files.c_str(), &fileData);
|
||||
do
|
||||
{
|
||||
if(hSearch == INVALID_HANDLE_VALUE) break; // No more files found
|
||||
|
||||
PLUGIN_INFO info;
|
||||
info.name = fileData.cFileName;
|
||||
info.version = 0;
|
||||
|
||||
// Try to get the version and author
|
||||
std::wstring tmpSz = CRainmeter::FixPath(fileData.cFileName, PATH_FOLDER_PLUGIN, L"");
|
||||
HMODULE dll = LoadLibrary(tmpSz.c_str());
|
||||
if (dll)
|
||||
{
|
||||
GETPLUGINAUTHOR GetAuthorFunc = (GETPLUGINAUTHOR)GetProcAddress(dll, "GetPluginAuthor");
|
||||
if (GetAuthorFunc)
|
||||
{
|
||||
LPCTSTR author = GetAuthorFunc();
|
||||
if (author && wcslen(author) > 0)
|
||||
{
|
||||
info.author = author;
|
||||
}
|
||||
}
|
||||
|
||||
GETPLUGINVERSION GetVersionFunc = (GETPLUGINVERSION)GetProcAddress(dll, "GetPluginVersion");
|
||||
if (GetVersionFunc)
|
||||
{
|
||||
info.version = GetVersionFunc();
|
||||
}
|
||||
FreeLibrary(dll);
|
||||
}
|
||||
|
||||
g_Plugins.push_back(info);
|
||||
}
|
||||
while(FindNextFile(hSearch, &fileData));
|
||||
|
||||
FindClose(hSearch);
|
||||
}
|
||||
|
||||
void RepositionControls(HWND hwndDlg)
|
||||
{
|
||||
RECT r, br, ar, sr, wr;
|
||||
HWND widget;
|
||||
|
||||
GetClientRect(hwndDlg, &r);
|
||||
GetClientRect(GetDlgItem(hwndDlg, IDOK), &br);
|
||||
GetClientRect(GetDlgItem(hwndDlg, IDC_STATIC_ABOUT), &ar);
|
||||
GetClientRect(GetDlgItem(hwndDlg, IDC_VERSION_STRING), &sr);
|
||||
|
||||
// Reposition the statistics widgets
|
||||
widget = GetDlgItem(hwndDlg, IDC_STATIC_ABOUT);
|
||||
SetWindowPos(widget, NULL, 0, 0, r.right - 22, ar.bottom, SWP_NOMOVE | SWP_NOZORDER);
|
||||
widget = GetDlgItem(hwndDlg, IDC_VERSION_STRING);
|
||||
SetWindowPos(widget, NULL, 0, 0, r.right - 44, sr.bottom, SWP_NOMOVE | SWP_NOZORDER);
|
||||
widget = GetDlgItem(hwndDlg, IDC_BUILD_STRING);
|
||||
SetWindowPos(widget, NULL, 0, 0, r.right - 44, sr.bottom, SWP_NOMOVE | SWP_NOZORDER);
|
||||
widget = GetDlgItem(hwndDlg, IDC_URL_STRING);
|
||||
SetWindowPos(widget, NULL, 0, 0, r.right - 44, sr.bottom, SWP_NOMOVE | SWP_NOZORDER);
|
||||
|
||||
widget = GetDlgItem(hwndDlg, IDC_CHECK_FOR_UPDATE);
|
||||
GetClientRect(widget, &wr);
|
||||
MapWindowPoints(widget, hwndDlg, (LPPOINT)&wr, 2);
|
||||
SetWindowPos(widget, NULL, (r.right - (wr.right - wr.left)) / 2, wr.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
|
||||
|
||||
widget = GetDlgItem(hwndDlg, IDC_CONFIG_TAB);
|
||||
SetWindowPos(widget, NULL, 0, 0, r.right - 22, r.bottom - 175, SWP_NOMOVE | SWP_NOZORDER);
|
||||
widget = GetDlgItem(hwndDlg, IDC_STATISTICS);
|
||||
SetWindowPos(widget, NULL, 0, 0, r.right - 44, r.bottom - 210, SWP_NOMOVE | SWP_NOZORDER);
|
||||
widget = GetDlgItem(hwndDlg, IDOK);
|
||||
SetWindowPos(widget, NULL, (r.right - br.right) / 2, r.bottom - br.bottom - 11, br.right, br.bottom, SWP_NOZORDER);
|
||||
}
|
||||
|
||||
BOOL OnInitAboutDialog(HWND window)
|
||||
{
|
||||
WCHAR tmpSz[256];
|
||||
HWND widget;
|
||||
|
||||
widget = GetDlgItem(window, IDC_VERSION_STRING);
|
||||
swprintf(tmpSz, L"%s version %s", APPNAME, APPVERSION);
|
||||
SetWindowText(widget, tmpSz);
|
||||
|
||||
widget = GetDlgItem(window, IDC_BUILD_STRING);
|
||||
swprintf(tmpSz, L"Build on %s", ConvertToWide(__DATE__).c_str());
|
||||
SetWindowText(widget, tmpSz);
|
||||
|
||||
// Add tabs for each config
|
||||
widget = GetDlgItem(window, IDC_CONFIG_TAB);
|
||||
TCITEM tie;
|
||||
tie.mask = TCIF_TEXT;
|
||||
std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
|
||||
std::map<std::wstring, CMeterWindow*>::iterator iter = windows.begin();
|
||||
int i = 0;
|
||||
for( ; iter != windows.end(); iter++)
|
||||
{
|
||||
CMeterWindow* meterWindow = (*iter).second;
|
||||
|
||||
tie.pszText = (WCHAR*)meterWindow->GetSkinName().c_str();
|
||||
TabCtrl_InsertItem(widget, i++, &tie);
|
||||
}
|
||||
tie.pszText = L"Plugins";
|
||||
TabCtrl_InsertItem(widget, i, &tie);
|
||||
|
||||
// Add columns to the list view
|
||||
widget = GetDlgItem(window, IDC_STATISTICS);
|
||||
|
||||
ListView_SetExtendedListViewStyleEx(widget, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
|
||||
|
||||
LVCOLUMN lvc;
|
||||
lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;
|
||||
lvc.iSubItem = 0;
|
||||
lvc.pszText = L"Measure";
|
||||
lvc.cx = 150;
|
||||
lvc.fmt = LVCFMT_LEFT; // left-aligned column
|
||||
ListView_InsertColumn(widget, 0, &lvc);
|
||||
lvc.iSubItem = 1;
|
||||
lvc.cx = 130;
|
||||
lvc.pszText = L"Value";
|
||||
ListView_InsertColumn(widget, 1, &lvc);
|
||||
lvc.iSubItem = 1;
|
||||
lvc.cx = 130;
|
||||
lvc.pszText = L"Range";
|
||||
ListView_InsertColumn(widget, 2, &lvc);
|
||||
|
||||
CheckDlgButton(window, IDC_CHECK_FOR_UPDATE, Rainmeter->GetCheckUpdate() ? BST_CHECKED : BST_UNCHECKED);
|
||||
|
||||
ScanPlugins();
|
||||
UpdateWidgets(window);
|
||||
RepositionControls(window);
|
||||
|
||||
g_DialogWin = window;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
INT_PTR CALLBACK AboutProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
switch (message)
|
||||
{
|
||||
case WM_INITDIALOG:
|
||||
return OnInitAboutDialog(hwndDlg);
|
||||
|
||||
case WM_WINDOWPOSCHANGING:
|
||||
{
|
||||
WINDOWPOS* pos = (WINDOWPOS*)lParam;
|
||||
|
||||
pos->cx = max(280, pos->cx);
|
||||
pos->cy = max(280, pos->cy);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_SIZE:
|
||||
RepositionControls(hwndDlg);
|
||||
break;
|
||||
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
LPNMHDR lpnmhdr = (LPNMHDR)lParam;
|
||||
if (lpnmhdr->code == TCN_SELCHANGE)
|
||||
{
|
||||
UpdateWidgets(hwndDlg);
|
||||
UpdateAboutStatistics();
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_CLOSE:
|
||||
Rainmeter->SaveSettings();
|
||||
DestroyWindow(hwndDlg);
|
||||
g_DialogWin = NULL;
|
||||
return TRUE;
|
||||
|
||||
case WM_COMMAND:
|
||||
switch (LOWORD(wParam))
|
||||
{
|
||||
case IDC_CHECK_FOR_UPDATE:
|
||||
if (IsDlgButtonChecked(hwndDlg, IDC_CHECK_FOR_UPDATE))
|
||||
{
|
||||
Rainmeter->SetCheckUpdate(TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
Rainmeter->SetCheckUpdate(FALSE);
|
||||
}
|
||||
break;
|
||||
|
||||
case IDOK:
|
||||
Rainmeter->SaveSettings();
|
||||
DestroyWindow(hwndDlg);
|
||||
g_DialogWin = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
42
Library/AboutDialog.h
Normal file
42
Library/AboutDialog.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
Copyright (C) 2000 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/AboutDialog.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: AboutDialog.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.2 2004/03/13 16:13:50 rainy
|
||||
Added support for multiple configs.
|
||||
|
||||
Revision 1.1 2002/07/01 15:35:54 rainy
|
||||
Intial version
|
||||
|
||||
*/
|
||||
|
||||
#ifndef _ABOUTDIALOG_H_
|
||||
#define _ABOUTDIALOG_H_
|
||||
|
||||
#include "MeterWindow.h"
|
||||
|
||||
HWND OpenAboutDialog(HWND hwndOwner, HINSTANCE instance);
|
||||
void UpdateAboutStatistics();
|
||||
|
||||
#endif
|
||||
|
||||
354
Library/ConfigParser.cpp
Normal file
354
Library/ConfigParser.cpp
Normal file
@@ -0,0 +1,354 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/ConfigParser.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: ConfigParser.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.1 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4786)
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "ConfigParser.h"
|
||||
#include "Litestep.h"
|
||||
#include "Rainmeter.h"
|
||||
#include <TCHAR.H>
|
||||
|
||||
extern CRainmeter* Rainmeter;
|
||||
|
||||
using namespace Gdiplus;
|
||||
|
||||
/*
|
||||
** CConfigParser
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CConfigParser::CConfigParser()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CConfigParser
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CConfigParser::~CConfigParser()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
** Initialize
|
||||
**
|
||||
**
|
||||
*/
|
||||
void CConfigParser::Initialize(LPCTSTR filename)
|
||||
{
|
||||
m_Filename = filename;
|
||||
ReadVariables();
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadVariables
|
||||
**
|
||||
**
|
||||
*/
|
||||
void CConfigParser::ReadVariables()
|
||||
{
|
||||
DWORD size;
|
||||
TCHAR* buffer;
|
||||
TCHAR* variable;
|
||||
int bufferSize = 4096;
|
||||
bool loop;
|
||||
|
||||
m_Variables.clear();
|
||||
do
|
||||
{
|
||||
loop = false;
|
||||
buffer = new TCHAR[bufferSize];
|
||||
|
||||
size = GetPrivateProfileString(L"Variables", NULL, L"", buffer, bufferSize, m_Filename.c_str());
|
||||
|
||||
if (size == bufferSize - 1)
|
||||
{
|
||||
// Buffer too small, increase it and retry
|
||||
delete [] buffer;
|
||||
bufferSize *= 2;
|
||||
loop = true;
|
||||
}
|
||||
|
||||
} while(loop);
|
||||
|
||||
if (size > 0)
|
||||
{
|
||||
variable = new TCHAR[bufferSize];
|
||||
|
||||
// Read all variables
|
||||
WCHAR* pos = buffer;
|
||||
while(wcslen(pos) > 0)
|
||||
{
|
||||
do
|
||||
{
|
||||
loop = false;
|
||||
size = GetPrivateProfileString(L"Variables", pos, L"", variable, bufferSize, m_Filename.c_str());
|
||||
|
||||
if (size == bufferSize - 1)
|
||||
{
|
||||
// Buffer too small, increase it and retry
|
||||
delete [] variable;
|
||||
bufferSize *= 2;
|
||||
variable = new TCHAR[bufferSize];
|
||||
loop = true;
|
||||
}
|
||||
|
||||
} while(loop);
|
||||
|
||||
if (wcslen(variable) > 0)
|
||||
{
|
||||
m_Variables[pos] = variable;
|
||||
}
|
||||
|
||||
pos = pos + wcslen(pos) + 1;
|
||||
}
|
||||
|
||||
delete [] variable;
|
||||
}
|
||||
delete [] buffer;
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadString
|
||||
**
|
||||
**
|
||||
*/
|
||||
const std::wstring& CConfigParser::ReadString(LPCTSTR section, LPCTSTR key, LPCTSTR defValue)
|
||||
{
|
||||
static std::wstring result;
|
||||
DWORD size;
|
||||
TCHAR* buffer;
|
||||
int bufferSize = 4096;
|
||||
bool loop;
|
||||
|
||||
do
|
||||
{
|
||||
loop = false;
|
||||
buffer = new TCHAR[bufferSize];
|
||||
buffer[0] = 0;
|
||||
|
||||
size = GetPrivateProfileString(section, key, defValue, buffer, bufferSize, m_Filename.c_str());
|
||||
|
||||
if (size == bufferSize - 1)
|
||||
{
|
||||
// Buffer too small, increase it and retry
|
||||
delete [] buffer;
|
||||
bufferSize *= 2;
|
||||
loop = true;
|
||||
}
|
||||
|
||||
} while(loop);
|
||||
|
||||
result = buffer;
|
||||
|
||||
delete [] buffer;
|
||||
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
if (result.find(L'%') != std::wstring::npos)
|
||||
{
|
||||
WCHAR buffer[4096]; // lets hope the buffer is large enough...
|
||||
|
||||
// Expand the environment variables
|
||||
DWORD ret = ExpandEnvironmentStrings(result.c_str(), buffer, 4096);
|
||||
if (ret != 0 && ret < 4096)
|
||||
{
|
||||
result = buffer;
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugLog(L"Unable to expand the environment strings.");
|
||||
}
|
||||
}
|
||||
|
||||
// Check for variables (#VAR#)
|
||||
size_t start = 0;
|
||||
size_t end = std::wstring::npos;
|
||||
size_t pos = std::wstring::npos;
|
||||
loop = true;
|
||||
|
||||
do
|
||||
{
|
||||
pos = result.find(L'#', start);
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
size_t end = result.find(L'#', pos + 1);
|
||||
if (end != std::wstring::npos)
|
||||
{
|
||||
std::wstring var(result.begin() + pos + 1, result.begin() + end);
|
||||
|
||||
std::map<std::wstring, std::wstring>::iterator iter = m_Variables.find(var);
|
||||
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
|
||||
{
|
||||
start = end;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
loop = false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
loop = false;
|
||||
}
|
||||
} while(loop);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
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);
|
||||
|
||||
return wcstod(result.c_str(), NULL);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
return _wtoi(result.c_str());
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
/*
|
||||
** 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);
|
||||
}
|
||||
else
|
||||
{
|
||||
R = 255;
|
||||
}
|
||||
token = wcstok( NULL, L",");
|
||||
if (token != NULL)
|
||||
{
|
||||
G = _wtoi(token);
|
||||
}
|
||||
else
|
||||
{
|
||||
G = 255;
|
||||
}
|
||||
token = wcstok( NULL, L",");
|
||||
if (token != NULL)
|
||||
{
|
||||
B = _wtoi(token);
|
||||
}
|
||||
else
|
||||
{
|
||||
B = 255;
|
||||
}
|
||||
token = wcstok( NULL, L",");
|
||||
if (token != NULL)
|
||||
{
|
||||
A = _wtoi(token);
|
||||
}
|
||||
else
|
||||
{
|
||||
A = 255;
|
||||
}
|
||||
free(parseSz);
|
||||
}
|
||||
else
|
||||
{
|
||||
const WCHAR* start = string;
|
||||
|
||||
if (wcsncmp(string, L"0x", 2) == 0)
|
||||
{
|
||||
start = string + 2;
|
||||
}
|
||||
|
||||
if (wcslen(string) > 6 && !isspace(string[6]))
|
||||
{
|
||||
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);
|
||||
}
|
||||
61
Library/ConfigParser.h
Normal file
61
Library/ConfigParser.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/ConfigParser.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: ConfigParser.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.1 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __CONFIGPARSER_H__
|
||||
#define __CONFIGPARSER_H__
|
||||
|
||||
#include <windows.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <gdiplus.h>
|
||||
|
||||
class CConfigParser
|
||||
{
|
||||
public:
|
||||
CConfigParser();
|
||||
~CConfigParser();
|
||||
|
||||
void Initialize(LPCTSTR filename);
|
||||
|
||||
const std::wstring& ReadString(LPCTSTR section, LPCTSTR key, LPCTSTR defValue);
|
||||
double ReadFloat(LPCTSTR section, LPCTSTR key, double defValue);
|
||||
int ReadInt(LPCTSTR section, LPCTSTR key, int defValue);
|
||||
Gdiplus::Color ReadColor(LPCTSTR section, LPCTSTR key, Gdiplus::Color defValue);
|
||||
|
||||
std::wstring& GetFilename() { return m_Filename; }
|
||||
|
||||
private:
|
||||
void ReadVariables();
|
||||
Gdiplus::Color ParseColor(LPCTSTR string);
|
||||
|
||||
std::map<std::wstring, std::wstring> m_Variables;
|
||||
std::wstring m_Filename;
|
||||
};
|
||||
|
||||
#endif
|
||||
75
Library/Error.cpp
Normal file
75
Library/Error.cpp
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/Error.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: Error.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.3 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.2 2001/10/14 07:30:04 rainy
|
||||
Changed from a static storage to a real class.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "Error.h"
|
||||
#include <stdio.h>
|
||||
|
||||
const WCHAR* CError::c_ErrorStrings[] =
|
||||
{
|
||||
L"User defined error",
|
||||
L"Out of memory",
|
||||
L"Null parameter",
|
||||
L"Unable to register windowclass",
|
||||
L"Unable to create window"
|
||||
};
|
||||
|
||||
/*
|
||||
** GetString
|
||||
**
|
||||
** Returns the error string
|
||||
**
|
||||
*/
|
||||
const std::wstring& CError::GetString()
|
||||
{
|
||||
static WCHAR Buffer[16];
|
||||
|
||||
if (m_Error != ERROR_USER)
|
||||
{
|
||||
m_String = c_ErrorStrings[m_Error];
|
||||
// if (m_File)
|
||||
// {
|
||||
// swprintf(Buffer, L"%i", m_Line);
|
||||
//
|
||||
// m_String += L"\n(";
|
||||
// m_String += m_File;
|
||||
// m_String += L" : ";
|
||||
// m_String += Buffer;
|
||||
// m_String += L")";
|
||||
// }
|
||||
}
|
||||
|
||||
return m_String;
|
||||
}
|
||||
73
Library/Error.h
Normal file
73
Library/Error.h
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/Error.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: Error.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.3 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.2 2001/10/14 07:30:04 rainy
|
||||
Changed from a static storage to a real class.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __ERROR_H__
|
||||
#define __ERROR_H__
|
||||
|
||||
#include <windows.h>
|
||||
#include <string>
|
||||
|
||||
class CError
|
||||
{
|
||||
public:
|
||||
// Few predefined errors
|
||||
enum RAINERROR
|
||||
{
|
||||
ERROR_USER,
|
||||
ERROR_OUT_OF_MEM,
|
||||
ERROR_NULL_PARAMETER,
|
||||
ERROR_REGISTER_WINDOWCLASS,
|
||||
ERROR_CREATE_WINDOW
|
||||
};
|
||||
|
||||
CError(const std::wstring& String) { m_Error = ERROR_USER; m_String = String; m_File = NULL; };
|
||||
CError(const WCHAR* String ) { m_Error = ERROR_USER; m_String = String; m_File = NULL; };
|
||||
CError(const std::wstring& String, int Line, const char* File) { m_Error = ERROR_USER; m_String = String; m_Line = Line; m_File = File; };
|
||||
CError(const WCHAR* String, int Line, const char* File) { m_Error = ERROR_USER; m_String = String; m_Line = Line; m_File = File; };
|
||||
CError(RAINERROR Error) { m_Error = Error; m_File = NULL; };
|
||||
CError(RAINERROR Error, int Line, const char* File) { m_Error = Error; m_Line = Line; m_File = File; };
|
||||
|
||||
const std::wstring& GetString();
|
||||
|
||||
private:
|
||||
std::wstring m_String;
|
||||
int m_Line;
|
||||
const char* m_File;
|
||||
RAINERROR m_Error;
|
||||
|
||||
static const WCHAR* c_ErrorStrings[];
|
||||
};
|
||||
|
||||
#endif
|
||||
57
Library/Export.h
Normal file
57
Library/Export.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/Export.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: Export.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.1 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __EXPORT_H__
|
||||
#define __EXPORT_H__
|
||||
|
||||
#ifdef LIBRARY_EXPORTS
|
||||
#define EXPORT_PLUGIN __declspec(dllexport)
|
||||
#else
|
||||
#define EXPORT_PLUGIN __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
// log level constants
|
||||
#define LOG_ERROR 1
|
||||
#define LOG_WARNING 2
|
||||
#define LOG_NOTICE 3
|
||||
#define LOG_DEBUG 4
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
EXPORT_PLUGIN BOOL LSLog(int nLevel, LPCTSTR pszModule, LPCTSTR pszMessage);
|
||||
EXPORT_PLUGIN LPCTSTR ReadConfigString(LPCTSTR section, LPCTSTR key, LPCTSTR defValue);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
449
Library/Library.dsp
Normal file
449
Library/Library.dsp
Normal file
@@ -0,0 +1,449 @@
|
||||
# Microsoft Developer Studio Project File - Name="Library" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=Library - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Library.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "Library.mak" CFG="Library - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Library - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "Library - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "Library - Win32 Release 64" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName "Library"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Library - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "x32/Release"
|
||||
# PROP Intermediate_Dir "x32/Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBRARY_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GR /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "LIBRARY_EXPORTS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40b /d "NDEBUG"
|
||||
# ADD RSC /l 0x40b /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 comctl32.lib Wininet.lib Winmm.lib gdiplus.lib Iphlpapi.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"../TestBench/x32/Release/Rainmeter.dll"
|
||||
|
||||
!ELSEIF "$(CFG)" == "Library - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "x32/Debug"
|
||||
# PROP Intermediate_Dir "x32/Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBRARY_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GR /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "LIBRARY_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40b /d "_DEBUG"
|
||||
# ADD RSC /l 0x40b /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 comctl32.lib Wininet.lib Winmm.lib gdiplus.lib Iphlpapi.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"../TestBench/x32/Debug/Rainmeter.dll" /pdbtype:sept
|
||||
|
||||
!ELSEIF "$(CFG)" == "Library - Win32 Release 64"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Library___Win32_Release_64"
|
||||
# PROP BASE Intermediate_Dir "Library___Win32_Release_64"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "x64/Release"
|
||||
# PROP Intermediate_Dir "x64/Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /GR /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "LIBRARY_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GR /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "LIBRARY_EXPORTS" /FD /GL /EHsc /Wp64 /GA /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40b /d "NDEBUG"
|
||||
# ADD RSC /l 0x40b /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 comctl32.lib Wininet.lib Winmm.lib gdiplus.lib Iphlpapi.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"../TestBench/x32/Release/Rainmeter.dll"
|
||||
# ADD LINK32 bufferoverflowU.lib comctl32.lib Wininet.lib Winmm.lib gdiplus.lib Iphlpapi.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:IX86 /out:"../TestBench/x64/Release/Rainmeter.dll" /machine:AMD64 /LTCG
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Library - Win32 Release"
|
||||
# Name "Library - Win32 Debug"
|
||||
# Name "Library - Win32 Release 64"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\AboutDialog.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ConfigParser.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Error.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Library.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Litestep.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Measure.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureCalc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureCPU.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureDiskSpace.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureMemory.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureNet.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureNetIn.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureNetOut.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureNetTotal.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasurePhysicalMemory.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasurePlugin.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureRegistry.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureTime.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureUptime.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureVirtualMemory.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Meter.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeterBar.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeterBitmap.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeterButton.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeterHistogram.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeterImage.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeterLine.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeterRotator.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeterRoundLine.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeterString.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeterWindow.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Rainmeter.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\TrayWindow.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\UpdateCheck.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\AboutDialog.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ConfigParser.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Error.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Export.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Litestep.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Measure.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureCalc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureCPU.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureDiskSpace.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureMemory.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureNet.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureNetIn.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureNetOut.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureNetTotal.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasurePhysicalMemory.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasurePlugin.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureRegistry.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureTime.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureUptime.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeasureVirtualMemory.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Meter.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeterBar.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeterBitmap.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeterButton.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeterHistogram.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeterImage.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeterLine.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeterRotator.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeterRoundLine.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeterString.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\MeterWindow.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Rainmeter.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\TrayWindow.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\UpdateCheck.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Res\tray.ico
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "CCalc"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\ccalc-0.5.1\lexer.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\ccalc-0.5.1\lexer.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\ccalc-0.5.1\mparser.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\ccalc-0.5.1\mparser.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\ccalc-0.5.1\pack.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\ccalc-0.5.1\strmap.c"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\ccalc-0.5.1\strmap.h"
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=".\ccalc-0.5.1\wininit.c"
|
||||
# End Source File
|
||||
# End Group
|
||||
# End Target
|
||||
# End Project
|
||||
204
Library/Library.rc
Normal file
204
Library/Library.rc
Normal file
@@ -0,0 +1,204 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Finnish resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_FIN)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_FINNISH, SUBLANG_DEFAULT
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
IDR_CONTEXT_MENU MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "Context"
|
||||
BEGIN
|
||||
MENUITEM "About...", ID_CONTEXT_ABOUT
|
||||
MENUITEM "Help", ID_CONTEXT_SHOW_HELP
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Edit Settings...", ID_CONTEXT_EDITCONFIG
|
||||
MENUITEM "Refresh All", ID_CONTEXT_REFRESH
|
||||
MENUITEM "Show Log File", ID_CONTEXT_SHOWLOGFILE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Exit", ID_CONTEXT_QUIT
|
||||
END
|
||||
END
|
||||
|
||||
IDR_SKIN_MENU MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "Skin Menu"
|
||||
BEGIN
|
||||
POPUP "Position"
|
||||
BEGIN
|
||||
MENUITEM "Stay Topmost", ID_CONTEXT_SKINMENU_VERYTOPMOST
|
||||
|
||||
MENUITEM "Topmost", ID_CONTEXT_SKINMENU_TOPMOST
|
||||
|
||||
MENUITEM "Normal", ID_CONTEXT_SKINMENU_NORMAL
|
||||
|
||||
MENUITEM "Bottom", ID_CONTEXT_SKINMENU_BOTTOM
|
||||
|
||||
MENUITEM "On Desktop", ID_CONTEXT_SKINMENU_ONDESKTOP
|
||||
|
||||
END
|
||||
POPUP "Transparency"
|
||||
BEGIN
|
||||
MENUITEM "0%", ID_CONTEXT_SKINMENU_TRANSPARENCY_0
|
||||
|
||||
MENUITEM "10%", ID_CONTEXT_SKINMENU_TRANSPARENCY_10
|
||||
|
||||
MENUITEM "20%", ID_CONTEXT_SKINMENU_TRANSPARENCY_20
|
||||
|
||||
MENUITEM "30%", ID_CONTEXT_SKINMENU_TRANSPARENCY_30
|
||||
|
||||
MENUITEM "40%", ID_CONTEXT_SKINMENU_TRANSPARENCY_40
|
||||
|
||||
MENUITEM "50%", ID_CONTEXT_SKINMENU_TRANSPARENCY_50
|
||||
|
||||
MENUITEM "60%", ID_CONTEXT_SKINMENU_TRANSPARENCY_60
|
||||
|
||||
MENUITEM "70%", ID_CONTEXT_SKINMENU_TRANSPARENCY_70
|
||||
|
||||
MENUITEM "80%", ID_CONTEXT_SKINMENU_TRANSPARENCY_80
|
||||
|
||||
MENUITEM "90%", ID_CONTEXT_SKINMENU_TRANSPARENCY_90
|
||||
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Fade in", ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN
|
||||
|
||||
MENUITEM "FadeOut", ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT
|
||||
|
||||
END
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Hide on Mouse Over", ID_CONTEXT_SKINMENU_HIDEONMOUSE
|
||||
|
||||
MENUITEM "Draggable", ID_CONTEXT_SKINMENU_DRAGGABLE
|
||||
|
||||
MENUITEM "Save Position", ID_CONTEXT_SKINMENU_REMEMBERPOSITION
|
||||
|
||||
MENUITEM "Snap to Edges", ID_CONTEXT_SKINMENU_SNAPTOEDGES
|
||||
|
||||
MENUITEM "Click Through", ID_CONTEXT_SKINMENU_CLICKTHROUGH
|
||||
|
||||
MENUITEM "Keep on screen", ID_CONTEXT_SKINMENU_KEEPONSCREEN
|
||||
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Edit Skin...", ID_CONTEXT_SKINMENU_EDITSKIN
|
||||
MENUITEM "Refresh Skin", ID_CONTEXT_SKINMENU_REFRESH
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "Close skin", ID_CONTEXT_CLOSESKIN
|
||||
END
|
||||
END
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_ABOUT_DIALOG DIALOG DISCARDABLE 0, 0, 234, 225
|
||||
STYLE DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME
|
||||
CAPTION "Rainmeter"
|
||||
FONT 8, "MS Sans Serif"
|
||||
BEGIN
|
||||
CONTROL "List1",IDC_STATISTICS,"SysListView32",LVS_REPORT |
|
||||
LVS_SINGLESEL | LVS_NOSORTHEADER | WS_BORDER |
|
||||
WS_TABSTOP,14,98,206,98
|
||||
CTEXT "Get the latest version at: http://www.iki.fi/rainy",
|
||||
IDC_URL_STRING,19,43,201,8
|
||||
CTEXT "Rainmeter version 0.0",IDC_VERSION_STRING,19,17,201,8
|
||||
CONTROL "Tab1",IDC_CONFIG_TAB,"SysTabControl32",0x0,7,81,220,120
|
||||
GROUPBOX "About",IDC_STATIC_ABOUT,7,7,220,69
|
||||
CTEXT "(build on ??? ?? ????)",IDC_BUILD_STRING,19,30,201,8
|
||||
DEFPUSHBUTTON "OK",IDOK,91,204,50,14
|
||||
CONTROL "Check for update on startup",IDC_CHECK_FOR_UPDATE,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,67,56,104,10
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_ABOUT_DIALOG, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 227
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 218
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_TRAY ICON DISCARDABLE "res\\tray.ico"
|
||||
#endif // Finnish resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
1294
Library/Library.vcproj
Normal file
1294
Library/Library.vcproj
Normal file
File diff suppressed because it is too large
Load Diff
580
Library/Litestep.cpp
Normal file
580
Library/Litestep.cpp
Normal file
@@ -0,0 +1,580 @@
|
||||
/*
|
||||
Copyright (C) 2002 Kimmo Pekkola + few lsapi developers
|
||||
|
||||
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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/Litestep.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: Litestep.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.4 2004/07/11 17:10:01 rainy
|
||||
Added ResetLoggingFlag.
|
||||
|
||||
Revision 1.3 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.6 2004/01/28 18:05:29 rainy
|
||||
Todo is shown/hidden with OK.
|
||||
|
||||
Revision 1.5 2003/12/20 22:16:06 rainy
|
||||
Added DebugLog
|
||||
|
||||
Revision 1.4 2002/09/08 14:14:54 rainy
|
||||
The name of the log file is the same as the module's name.
|
||||
|
||||
Revision 1.3 2002/09/06 21:44:51 rainy
|
||||
Added logging functions.
|
||||
|
||||
Revision 1.2 2002/08/24 11:10:07 rainy
|
||||
Added support for logging.
|
||||
|
||||
Revision 1.1 2002/05/30 18:27:42 rainy
|
||||
Initial version
|
||||
|
||||
*/
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "Litestep.h"
|
||||
#include "Error.h"
|
||||
#include <shellapi.h>
|
||||
#include <crtdbg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
typedef BOOL (*FPADDBANGCOMMAND)(LPCSTR command, BangCommand f);
|
||||
FPADDBANGCOMMAND fpAddBangCommand = NULL;
|
||||
|
||||
typedef HRGN (*FPBITMAPTOREGION)(HBITMAP hBmp, COLORREF cTransparentColor, COLORREF cTolerance, int xoffset, int yoffset);
|
||||
FPBITMAPTOREGION fpBitmapToRegion = NULL;
|
||||
|
||||
typedef HWND (*FPGETLITESTEPWND)(void);
|
||||
FPGETLITESTEPWND fpGetLitestepWnd = NULL;
|
||||
|
||||
typedef BOOL (*FPGETRCSTRING)(LPCSTR lpKeyName, LPSTR value, LPCSTR defStr, int maxLen);
|
||||
FPGETRCSTRING fpGetRCString = NULL;
|
||||
|
||||
typedef int (*FPGETRCINT)(LPCSTR lpKeyName, int nDefault);
|
||||
FPGETRCINT fpGetRCInt = NULL;
|
||||
|
||||
typedef HINSTANCE (*FPLSEXECUTE)(HWND Owner, LPCSTR szCommand, int nShowCmd);
|
||||
FPLSEXECUTE fpLSExecute = NULL;
|
||||
|
||||
typedef BOOL (*FPREMOVEBANGCOMMAND)(LPCSTR command);
|
||||
FPREMOVEBANGCOMMAND fpRemoveBangCommand = NULL;
|
||||
|
||||
typedef void (*FPTRANSPARENTBLTLS)(HDC dc, int nXDest, int nYDest, int nWidth, int nHeight, HDC tempDC, int nXSrc, int nYSrc, COLORREF colorTransparent);
|
||||
FPTRANSPARENTBLTLS fpTransparentBltLS = NULL;
|
||||
|
||||
typedef void (*FPVAREXPANSION)(LPSTR buffer, LPCSTR value);
|
||||
FPVAREXPANSION fpVarExpansion = NULL;
|
||||
|
||||
typedef BOOL (WINAPI *FPLSLOG)(int nLevel, LPCSTR pszModule, LPCSTR pszMessage);
|
||||
FPLSLOG fpLSLog = NULL;
|
||||
|
||||
static int logFound = 0;
|
||||
|
||||
void ResetLoggingFlag()
|
||||
{
|
||||
logFound = 0;
|
||||
}
|
||||
|
||||
void InitalizeLitestep()
|
||||
{
|
||||
// Use lsapi's methods instead of the stubs
|
||||
HINSTANCE h = LoadLibrary(L"lsapi.dll");
|
||||
if (h != NULL)
|
||||
{
|
||||
fpAddBangCommand = (FPADDBANGCOMMAND)GetProcAddress(h, "AddBangCommand");
|
||||
fpBitmapToRegion = (FPBITMAPTOREGION)GetProcAddress(h, "BitmapToRegion");
|
||||
fpGetLitestepWnd = (FPGETLITESTEPWND)GetProcAddress(h, "GetLitestepWnd");
|
||||
fpGetRCString = (FPGETRCSTRING)GetProcAddress(h, "GetRCString");
|
||||
fpGetRCInt = (FPGETRCINT)GetProcAddress(h, "GetRCInt");
|
||||
fpLSExecute = (FPLSEXECUTE)GetProcAddress(h, "LSExecute");
|
||||
fpRemoveBangCommand = (FPREMOVEBANGCOMMAND)GetProcAddress(h, "RemoveBangCommand");
|
||||
fpTransparentBltLS = (FPTRANSPARENTBLTLS)GetProcAddress(h, "TransparentBltLS");
|
||||
fpVarExpansion = (FPVAREXPANSION)GetProcAddress(h, "VarExpansion");
|
||||
fpLSLog = (FPLSLOG)GetProcAddress(h, "_LSLog@12");
|
||||
}
|
||||
}
|
||||
|
||||
BOOL AddBangCommand(LPCSTR command, BangCommand f)
|
||||
{
|
||||
// Use the lsapi.dll version of the method if possible
|
||||
if (fpAddBangCommand) return fpAddBangCommand(command, f);
|
||||
|
||||
// The stub implementation
|
||||
return true;
|
||||
}
|
||||
|
||||
HWND GetLitestepWnd(void)
|
||||
{
|
||||
// Use the lsapi.dll version of the method if possible
|
||||
if (fpGetLitestepWnd) return fpGetLitestepWnd();
|
||||
|
||||
// The stub implementation
|
||||
return NULL;
|
||||
}
|
||||
|
||||
BOOL RemoveBangCommand(LPCSTR command)
|
||||
{
|
||||
// Use the lsapi.dll version of the method if possible
|
||||
if (fpRemoveBangCommand) return fpRemoveBangCommand(command);
|
||||
|
||||
// The stub implementation
|
||||
return true;
|
||||
}
|
||||
|
||||
BOOL GetRCString(LPCSTR lpKeyName, LPSTR value, LPCSTR defStr, int maxLen)
|
||||
{
|
||||
// Use the lsapi.dll version of the method if possible
|
||||
if (fpGetRCString) return fpGetRCString(lpKeyName, value, defStr, maxLen);
|
||||
|
||||
// The stub implementation
|
||||
return false;
|
||||
}
|
||||
|
||||
int GetRCInt(LPCSTR lpKeyName, int nDefault)
|
||||
{
|
||||
// Use the lsapi.dll version of the method if possible
|
||||
if (fpGetRCInt) return fpGetRCInt(lpKeyName, nDefault);
|
||||
|
||||
// The stub implementation
|
||||
return nDefault;
|
||||
}
|
||||
|
||||
void VarExpansion(LPSTR buffer, LPCSTR value)
|
||||
{
|
||||
// Use the lsapi.dll version of the method if possible
|
||||
if (fpVarExpansion)
|
||||
{
|
||||
fpVarExpansion(buffer, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
// The stub implementation
|
||||
if (buffer != value)
|
||||
{
|
||||
strcpy(buffer, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HRGN BitmapToRegion(HBITMAP hbm, COLORREF clrTransp, COLORREF clrTolerance, int xoffset, int yoffset)
|
||||
{
|
||||
// Use the lsapi.dll version of the method if possible
|
||||
if (fpBitmapToRegion) return fpBitmapToRegion(hbm, clrTransp, clrTolerance, xoffset, yoffset);
|
||||
|
||||
// start with a completely transparent rgn
|
||||
// this is more correct as no bmp, should render a transparent background
|
||||
HRGN hRgn = CreateRectRgn(0, 0, 0, 0);
|
||||
|
||||
if (hbm)
|
||||
{
|
||||
// create a dc for the 32 bit dib
|
||||
HDC hdcMem = CreateCompatibleDC(NULL);
|
||||
if (hdcMem)
|
||||
{
|
||||
VOID *pbits32;
|
||||
HBITMAP hbm32;
|
||||
BITMAP bm;
|
||||
// get the size
|
||||
GetObject(hbm, sizeof(BITMAP), &bm);
|
||||
|
||||
BITMAPINFOHEADER bmpInfo32;
|
||||
bmpInfo32.biSize = sizeof(BITMAPINFOHEADER);
|
||||
bmpInfo32.biWidth = bm.bmWidth;
|
||||
bmpInfo32.biHeight = bm.bmHeight;
|
||||
bmpInfo32.biPlanes = 1;
|
||||
bmpInfo32.biBitCount = 32;
|
||||
bmpInfo32.biCompression = BI_RGB;
|
||||
bmpInfo32.biSizeImage = 0;
|
||||
bmpInfo32.biXPelsPerMeter = 0;
|
||||
bmpInfo32.biYPelsPerMeter = 0;
|
||||
bmpInfo32.biClrUsed = 0;
|
||||
bmpInfo32.biClrImportant = 0;
|
||||
|
||||
hbm32 = CreateDIBSection(hdcMem, (BITMAPINFO *) & bmpInfo32, DIB_RGB_COLORS, &pbits32, NULL, 0);
|
||||
if (hbm32)
|
||||
{
|
||||
HBITMAP hbmOld32 = (HBITMAP)SelectObject(hdcMem, hbm32);
|
||||
|
||||
// Create a DC just to copy the bitmap into the memory D
|
||||
HDC hdcTmp = CreateCompatibleDC(hdcMem);
|
||||
if (hdcTmp)
|
||||
{
|
||||
// Get how many bytes per row we have for the bitmap bits (rounded up to 32 bits
|
||||
int y = 0;
|
||||
BITMAP bm32;
|
||||
GetObject(hbm32, sizeof(bm32), &bm32);
|
||||
while (bm32.bmWidthBytes % 4)
|
||||
bm32.bmWidthBytes++;
|
||||
|
||||
// get the limits for the colors
|
||||
BYTE clrHiR = ( 0xff - GetRValue( clrTolerance ) > GetRValue( clrTransp ) ) ? GetRValue( clrTransp ) + GetRValue( clrTolerance ) : 0xff;
|
||||
BYTE clrHiG = ( 0xff - GetGValue( clrTolerance ) > GetGValue( clrTransp ) ) ? GetGValue( clrTransp ) + GetGValue( clrTolerance ) : 0xff;
|
||||
BYTE clrHiB = ( 0xff - GetBValue( clrTolerance ) > GetBValue( clrTransp ) ) ? GetBValue( clrTransp ) + GetBValue( clrTolerance ) : 0xff;
|
||||
BYTE clrLoR = ( GetRValue( clrTolerance ) < GetRValue( clrTransp ) ) ? GetRValue( clrTransp ) - GetRValue( clrTolerance ) : 0x00;
|
||||
BYTE clrLoG = ( GetGValue( clrTolerance ) < GetGValue( clrTransp ) ) ? GetGValue( clrTransp ) - GetGValue( clrTolerance ) : 0x00;
|
||||
BYTE clrLoB = ( GetBValue( clrTolerance ) < GetBValue( clrTransp ) ) ? GetBValue( clrTransp ) - GetBValue( clrTolerance ) : 0x00;
|
||||
|
||||
// Copy the bitmap into the memory D
|
||||
HBITMAP hbmOld = (HBITMAP)SelectObject(hdcTmp, hbm);
|
||||
|
||||
BitBlt(hdcMem, 0, 0, bm.bmWidth, bm.bmHeight, hdcTmp, 0, 0, SRCCOPY);
|
||||
|
||||
// Scan each bitmap row from bottom to top (the bitmap is inverted vertically
|
||||
BYTE *p;
|
||||
BYTE *p32 = (BYTE *)bm32.bmBits + (bm32.bmHeight - 1) * bm32.bmWidthBytes;
|
||||
while (y < bm.bmHeight)
|
||||
{
|
||||
int x = 0;
|
||||
while ( x < bm.bmWidth )
|
||||
{
|
||||
int x0 = 0;
|
||||
// loop through all transparent pixels...
|
||||
while ( x < bm.bmWidth )
|
||||
{
|
||||
p = p32 + 4 * x;
|
||||
|
||||
// if the pixel is non-transparent
|
||||
{
|
||||
bool isOpaque = *p < clrLoB || *p > clrHiB;
|
||||
p++;
|
||||
isOpaque |= *p < clrLoG || *p > clrHiG;
|
||||
p++;
|
||||
isOpaque |= *p < clrLoR || *p > clrHiR;
|
||||
if (isOpaque)
|
||||
break;
|
||||
}
|
||||
|
||||
x++;
|
||||
}
|
||||
// set first non transparent pixel
|
||||
x0 = x;
|
||||
// loop through all non transparent pixels
|
||||
while ( x < bm.bmWidth )
|
||||
{
|
||||
p = p32 + 4 * x;
|
||||
// if the pixel is transparent, then break
|
||||
if (*p >= clrLoB && *p <= clrHiB)
|
||||
{
|
||||
p++;
|
||||
if (*p >= clrLoG && *p <= clrHiG)
|
||||
{
|
||||
p++;
|
||||
if (*p >= clrLoR && *p <= clrHiR)
|
||||
break;
|
||||
}
|
||||
}
|
||||
x++;
|
||||
}
|
||||
// if found one or more non-transparent pixels in a row, add them to the rgn...
|
||||
if ((x - x0) > 0)
|
||||
{
|
||||
HRGN hTempRgn = CreateRectRgn(x0 + xoffset, y + yoffset, x + xoffset, y + 1 + yoffset);
|
||||
CombineRgn(hRgn, hRgn, hTempRgn, RGN_OR);
|
||||
DeleteObject(hTempRgn);
|
||||
}
|
||||
x++;
|
||||
}
|
||||
y++;
|
||||
p32 -= bm32.bmWidthBytes;
|
||||
}
|
||||
// Clean up
|
||||
SelectObject(hdcTmp, hbmOld);
|
||||
DeleteDC(hdcTmp);
|
||||
}
|
||||
SelectObject(hdcMem, hbmOld32);
|
||||
DeleteObject(hbm32);
|
||||
}
|
||||
DeleteDC(hdcMem);
|
||||
}
|
||||
}
|
||||
return hRgn;
|
||||
}
|
||||
|
||||
HINSTANCE LSExecute(HWND Owner, LPCTSTR szCommand, int nShowCmd)
|
||||
{
|
||||
// Use the lsapi.dll version of the method if possible
|
||||
if (fpLSExecute)
|
||||
{
|
||||
std::string asc = ConvertToAscii(szCommand);
|
||||
return fpLSExecute(Owner, asc.c_str(), nShowCmd);
|
||||
}
|
||||
|
||||
// The stub implementation (some of this code is taken from lsapi.cpp)
|
||||
if (szCommand == NULL || wcslen(szCommand) == 0) return NULL;
|
||||
|
||||
std::wstring args;
|
||||
std::wstring command = szCommand;
|
||||
|
||||
size_t notwhite = command.find_first_not_of(L" \t\n");
|
||||
command.erase(0, notwhite);
|
||||
|
||||
size_t quotePos = command.find(L"\"");
|
||||
if (quotePos == 0)
|
||||
{
|
||||
size_t quotePos2 = command.find(L"\"", quotePos + 1);
|
||||
if (quotePos2 != std::wstring::npos)
|
||||
{
|
||||
args = command.substr(quotePos2 + 1);
|
||||
command = command.substr(quotePos + 1, quotePos2 - quotePos - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
command.erase(0, quotePos + 1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t spacePos = command.find(L" ");
|
||||
if (spacePos != std::wstring::npos)
|
||||
{
|
||||
args = command.substr(spacePos + 1);
|
||||
command = command.substr(0, spacePos);
|
||||
}
|
||||
}
|
||||
|
||||
DWORD type = GetFileAttributes(command.c_str());
|
||||
if (type & FILE_ATTRIBUTE_DIRECTORY && type != 0xFFFFFFFF)
|
||||
{
|
||||
HINSTANCE instance = ShellExecute(Owner, L"open", command.c_str(), NULL, NULL, nShowCmd ? nShowCmd : SW_SHOWNORMAL);
|
||||
return instance;
|
||||
}
|
||||
|
||||
std::wstring dir;
|
||||
size_t dirPos = command.rfind(L"\\");
|
||||
if (dirPos != std::wstring::npos)
|
||||
{
|
||||
dir = command.substr(0, dirPos);
|
||||
}
|
||||
|
||||
SHELLEXECUTEINFO si;
|
||||
memset(&si, 0, sizeof(si));
|
||||
si.cbSize = sizeof(SHELLEXECUTEINFO);
|
||||
si.hwnd = Owner;
|
||||
si.lpVerb = L"open";
|
||||
si.lpFile = command.c_str();
|
||||
si.lpParameters = args.c_str();
|
||||
si.lpDirectory = dir.c_str();
|
||||
si.nShow = nShowCmd ? nShowCmd : SW_SHOWNORMAL;
|
||||
si.fMask = SEE_MASK_DOENVSUBST | SEE_MASK_FLAG_NO_UI;
|
||||
ShellExecuteEx(&si);
|
||||
return si.hInstApp;
|
||||
}
|
||||
|
||||
void TransparentBltLS(HDC hdcDst, int nXDest, int nYDest, int nWidth, int nHeight, HDC hdcSrc, int nXSrc, int nYSrc, COLORREF colorTransparent)
|
||||
{
|
||||
// Use the lsapi.dll version of the method if possible
|
||||
if (fpTransparentBltLS)
|
||||
{
|
||||
fpTransparentBltLS(hdcDst, nXDest, nYDest, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, colorTransparent);
|
||||
}
|
||||
else
|
||||
{
|
||||
HDC hdcMem, hdcMask, hdcDstCpy;
|
||||
HBITMAP hbmMask, hbmMem, hbmDstCpy;
|
||||
HBITMAP hbmOldMem, hbmOldMask, hbmOldDstCpy;
|
||||
|
||||
// create a destination compatble dc containing
|
||||
// a copy of the destination dc
|
||||
hdcDstCpy = CreateCompatibleDC(hdcDst);
|
||||
hbmDstCpy = CreateCompatibleBitmap(hdcDst, nWidth, nHeight);
|
||||
hbmOldDstCpy = (HBITMAP)SelectObject(hdcDstCpy, hbmDstCpy);
|
||||
|
||||
BitBlt(hdcDstCpy, 0, 0, nWidth, nHeight, hdcDst, nXDest, nYDest, SRCCOPY);
|
||||
|
||||
// create a destination compatble dc containing
|
||||
// a copy of the source dc
|
||||
hdcMem = CreateCompatibleDC(hdcDst);
|
||||
hbmMem = CreateCompatibleBitmap(hdcDst, nWidth, nHeight);
|
||||
hbmOldMem = (HBITMAP)SelectObject(hdcMem, hbmMem);
|
||||
|
||||
BitBlt(hdcMem, 0, 0, nWidth, nHeight, hdcSrc, nXSrc, nYSrc, SRCCOPY);
|
||||
|
||||
// the transparent color should be selected as
|
||||
// bkcolor into the memory dc
|
||||
SetBkColor(hdcMem, colorTransparent);
|
||||
|
||||
// Create monochrome bitmap for the mask
|
||||
hdcMask = CreateCompatibleDC(hdcDst);
|
||||
hbmMask = CreateBitmap(nWidth, nHeight, 1, 1, NULL);
|
||||
hbmOldMask = (HBITMAP)SelectObject(hdcMask, hbmMask);
|
||||
|
||||
// Create the mask from the memory dc
|
||||
BitBlt(hdcMask, 0, 0, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY);
|
||||
|
||||
// Set the background in hdcMem to black. Using SRCPAINT with black
|
||||
// and any other color results in the other color, thus making
|
||||
// black the transparent color
|
||||
SetBkColor(hdcMem, RGB(0, 0, 0));
|
||||
SetTextColor(hdcMem, RGB(255, 255, 255));
|
||||
|
||||
BitBlt(hdcMem, 0, 0, nWidth, nHeight, hdcMask, 0, 0, SRCAND);
|
||||
|
||||
// Set the foreground to black. See comment above.
|
||||
SetBkColor(hdcDst, RGB(255, 255, 255));
|
||||
SetTextColor(hdcDst, RGB(0, 0, 0));
|
||||
|
||||
BitBlt(hdcDstCpy, 0, 0, nWidth, nHeight, hdcMask, 0, 0, SRCAND);
|
||||
|
||||
// Combine the foreground with the background
|
||||
BitBlt(hdcDstCpy, 0, 0, nWidth, nHeight, hdcMem, 0, 0, SRCPAINT);
|
||||
|
||||
// now we have created the image we want to blt
|
||||
// in the destination copy dc
|
||||
BitBlt(hdcDst, nXDest, nYDest, nWidth, nHeight, hdcDstCpy, 0, 0, SRCCOPY);
|
||||
|
||||
SelectObject(hdcMask, hbmOldMask);
|
||||
DeleteObject(hbmMask);
|
||||
DeleteDC(hdcMask);
|
||||
|
||||
SelectObject(hdcMem, hbmOldMem);
|
||||
DeleteObject(hbmMem);
|
||||
DeleteDC(hdcMem);
|
||||
|
||||
SelectObject(hdcDstCpy, hbmOldDstCpy);
|
||||
DeleteObject(hbmDstCpy);
|
||||
DeleteDC(hdcDstCpy);
|
||||
}
|
||||
}
|
||||
|
||||
std::string ConvertToAscii(LPCTSTR str)
|
||||
{
|
||||
std::string szAscii;
|
||||
|
||||
if (str)
|
||||
{
|
||||
size_t len = (wcslen(str) + 1);
|
||||
char* tmpSz = new char[len * 2];
|
||||
WideCharToMultiByte(CP_ACP, 0, str, -1, tmpSz, (int)len * 2, NULL, FALSE);
|
||||
szAscii = tmpSz;
|
||||
delete tmpSz;
|
||||
}
|
||||
return szAscii;
|
||||
}
|
||||
|
||||
std::wstring ConvertToWide(LPCSTR str)
|
||||
{
|
||||
std::wstring szWide;
|
||||
|
||||
if (str)
|
||||
{
|
||||
size_t len = strlen(str) + 1;
|
||||
WCHAR* wideSz = new WCHAR[len * 2];
|
||||
MultiByteToWideChar(CP_ACP, 0, str, (int)len, wideSz, (int)len * 2);
|
||||
szWide = wideSz;
|
||||
delete wideSz;
|
||||
}
|
||||
return szWide;
|
||||
}
|
||||
|
||||
BOOL LSLog(int nLevel, LPCTSTR pszModule, LPCTSTR pszMessage)
|
||||
{
|
||||
// Add timestamp
|
||||
static DWORD startTime = 0;
|
||||
|
||||
if (startTime == 0)
|
||||
{
|
||||
startTime = GetTickCount();
|
||||
}
|
||||
DWORD time = GetTickCount();
|
||||
WCHAR buffer[MAX_PATH];
|
||||
swprintf(buffer, L"(%02i:%02i:%02i.%03i) ", (time - startTime) / (1000 * 60* 60), ((time - startTime) / (1000 * 60)) % 60, ((time - startTime) / 1000) % 60, (time - startTime) % 1000);
|
||||
|
||||
std::wstring message(buffer);
|
||||
message += pszMessage;
|
||||
|
||||
#ifdef _DEBUG
|
||||
_RPT0(_CRT_WARN, ConvertToAscii(message.c_str()).c_str());
|
||||
_RPT0(_CRT_WARN, "\n");
|
||||
#endif
|
||||
|
||||
// Use the lsapi.dll version of the method if possible
|
||||
if (fpLSLog)
|
||||
{
|
||||
std::string asc = ConvertToAscii(message.c_str());
|
||||
std::string mod = ConvertToAscii(pszModule);
|
||||
return fpLSLog(nLevel, mod.c_str(), asc.c_str());
|
||||
}
|
||||
|
||||
// The stub implementation
|
||||
FILE* logFile;
|
||||
GetModuleFileName(NULL, buffer, MAX_PATH);
|
||||
|
||||
std::wstring logfile(buffer);
|
||||
logfile.replace(logfile.length() - 4, 4, L".log");
|
||||
|
||||
if (logFound == 0)
|
||||
{
|
||||
// Check if the file exists
|
||||
logFile = _wfopen(logfile.c_str(), L"r");
|
||||
if (logFile)
|
||||
{
|
||||
logFound = 1;
|
||||
fclose(logFile);
|
||||
|
||||
// Clear the file
|
||||
logFile = _wfopen(logfile.c_str(), L"w");
|
||||
fputwc(0xFEFF, logFile);
|
||||
fclose(logFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
logFound = 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (logFound == 1)
|
||||
{
|
||||
logFile = _wfopen(logfile.c_str(), L"a+");
|
||||
if (logFile)
|
||||
{
|
||||
switch(nLevel)
|
||||
{
|
||||
case 1:
|
||||
fputws(L"ERROR: ", logFile);
|
||||
break;
|
||||
case 2:
|
||||
fputws(L"WARNING: ", logFile);
|
||||
break;
|
||||
case 3:
|
||||
fputws(L"NOTICE: ", logFile);
|
||||
break;
|
||||
case 4:
|
||||
fputws(L"DEBUG: ", logFile);
|
||||
break;
|
||||
}
|
||||
fputws(message.c_str(), logFile);
|
||||
fputws(L"\n", logFile);
|
||||
fclose(logFile);
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void DebugLog(const WCHAR* format, ... )
|
||||
{
|
||||
WCHAR buffer[4096];
|
||||
va_list args;
|
||||
va_start( args, format );
|
||||
_vsnwprintf( buffer, 4096, format, args );
|
||||
LSLog(LOG_DEBUG, L"Rainmeter", buffer);
|
||||
va_end(args);
|
||||
};
|
||||
85
Library/Litestep.h
Normal file
85
Library/Litestep.h
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
Copyright (C) 2002 Kimmo Pekkola + few lsapi developers
|
||||
|
||||
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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/Litestep.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: Litestep.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.5 2004/07/11 17:10:01 rainy
|
||||
Added ResetLoggingFlag.
|
||||
|
||||
Revision 1.4 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.3 2003/03/22 20:39:20 rainy
|
||||
LsLog is exported.
|
||||
|
||||
Revision 1.2 2003/02/10 18:12:17 rainy
|
||||
Added LSLog and LSSetVariable
|
||||
|
||||
Revision 1.1 2002/07/01 15:35:54 rainy
|
||||
Intial version
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __LITESTEP_H__
|
||||
#define __LITESTEP_H__
|
||||
|
||||
#include <windows.h>
|
||||
#include <comdef.h>
|
||||
#include <string>
|
||||
#include "Export.h"
|
||||
|
||||
#define magicDWord 0x49474541
|
||||
#define LM_GETREVID 9265
|
||||
#define LM_REGISTERMESSAGE 9263
|
||||
#define LM_UNREGISTERMESSAGE 9264
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define DEBUGLOG DebugLog
|
||||
#else
|
||||
#define DEBUGLOG //
|
||||
#endif
|
||||
|
||||
|
||||
typedef void (BangCommand)(HWND sender, LPCSTR args);
|
||||
|
||||
// Call this if you want to use lsapi.dll's functions instead of stubs
|
||||
void InitalizeLitestep();
|
||||
|
||||
// The stubs
|
||||
BOOL AddBangCommand(LPCSTR command, BangCommand f);
|
||||
HRGN BitmapToRegion(HBITMAP hBmp, COLORREF cTransparentColor, COLORREF cTolerance, int xoffset, int yoffset);
|
||||
HWND GetLitestepWnd(void);
|
||||
BOOL GetRCString(LPCSTR lpKeyName, LPSTR value, LPCSTR defStr, int maxLen);
|
||||
int GetRCInt(LPCSTR lpKeyName, int nDefault);
|
||||
HINSTANCE LSExecute(HWND Owner, LPCTSTR szCommand, int nShowCmd);
|
||||
BOOL RemoveBangCommand(LPCSTR command);
|
||||
void TransparentBltLS (HDC dc, int nXDest, int nYDest, int nWidth, int nHeight, HDC tempDC, int nXSrc, int nYSrc, COLORREF colorTransparent);
|
||||
void VarExpansion(LPSTR buffer, LPCSTR value);
|
||||
void LSSetVariable(const BSTR name, const BSTR value);
|
||||
void DebugLog(const WCHAR* message, ... );
|
||||
|
||||
void ResetLoggingFlag();
|
||||
|
||||
std::string ConvertToAscii(LPCTSTR str);
|
||||
std::wstring ConvertToWide(LPCSTR str);
|
||||
|
||||
#endif
|
||||
691
Library/Measure.cpp
Normal file
691
Library/Measure.cpp
Normal file
@@ -0,0 +1,691 @@
|
||||
/*
|
||||
Copyright (C) 2000 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/Measure.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: Measure.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.19 2004/07/11 17:14:20 rainy
|
||||
Fixed string generation when num of decimals is 0.
|
||||
|
||||
Revision 1.18 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.17 2004/03/13 16:15:01 rainy
|
||||
GetStats returns only the value
|
||||
|
||||
Revision 1.16 2003/12/05 15:50:09 Rainy
|
||||
Multi-instance changes.
|
||||
|
||||
Revision 1.15 2003/02/10 18:13:49 rainy
|
||||
Added median filter to max value.
|
||||
|
||||
Revision 1.14 2002/12/23 14:26:21 rainy
|
||||
Stats are gathered a bit different way now.
|
||||
|
||||
Revision 1.13 2002/05/05 10:49:16 rainy
|
||||
Disabled measures return 0.
|
||||
|
||||
Revision 1.12 2002/05/04 08:12:33 rainy
|
||||
Measure update is not tied to the update rate directly anymore.
|
||||
|
||||
Revision 1.11 2002/04/26 18:24:16 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.10 2002/04/01 15:39:09 rainy
|
||||
Fixed IfBelow and IfAbove actions.
|
||||
Added NetTotal measure.
|
||||
|
||||
Revision 1.9 2002/03/31 09:58:54 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.8 2001/12/23 10:18:52 rainy
|
||||
Added Time and removed Perfmon.
|
||||
|
||||
Revision 1.7 2001/10/28 10:23:59 rainy
|
||||
GetStringValue uses consts.
|
||||
Added IfAbove/Below actions.
|
||||
Added Plugin and Registry Measures.
|
||||
|
||||
Revision 1.6 2001/10/14 07:32:03 rainy
|
||||
Minor monifications to remove few warnings with VC.NET.
|
||||
In error situations CError is thrown instead just a boolean value.
|
||||
|
||||
Revision 1.5 2001/09/26 16:27:15 rainy
|
||||
Changed the interfaces a bit.
|
||||
|
||||
Revision 1.4 2001/09/01 13:00:41 rainy
|
||||
Slight changes in the interface. The value is now measured only once if possible.
|
||||
Added support for logging the max value.
|
||||
|
||||
Revision 1.3 2001/08/19 09:15:41 rainy
|
||||
Invert was moved here from the meter.
|
||||
|
||||
Revision 1.2 2001/08/12 15:47:00 Rainy
|
||||
Adjusted Update()'s interface.
|
||||
Added GetStringValue() method.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "Measure.h"
|
||||
#include "MeasureCPU.h"
|
||||
#include "MeasureMemory.h"
|
||||
#include "MeasurePhysicalMemory.h"
|
||||
#include "MeasureVirtualMemory.h"
|
||||
#include "MeasureNetIn.h"
|
||||
#include "MeasureNetOut.h"
|
||||
#include "MeasureNetTotal.h"
|
||||
#include "MeasureDiskSpace.h"
|
||||
#include "MeasureUptime.h"
|
||||
#include "MeasurePlugin.h"
|
||||
#include "MeasureRegistry.h"
|
||||
#include "MeasureTime.h"
|
||||
#include "MeasureCalc.h"
|
||||
#include "Rainmeter.h"
|
||||
#include "Error.h"
|
||||
#include "Litestep.h"
|
||||
#include <algorithm>
|
||||
|
||||
const int MEDIAN_SIZE = 7;
|
||||
|
||||
extern CRainmeter* Rainmeter;
|
||||
|
||||
/*
|
||||
** CMeasure
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeasure::CMeasure(CMeterWindow* meterWindow)
|
||||
{
|
||||
m_Invert = false;
|
||||
m_LogMaxValue = false;
|
||||
m_MinValue = 0.0;
|
||||
m_MaxValue = 1.0;
|
||||
m_Value = 0.0;
|
||||
m_IfAboveValue = 0.0;
|
||||
m_IfBelowValue = 0.0;
|
||||
m_IfEqualValue = 0.0;
|
||||
m_IfAboveCommited = false;
|
||||
m_IfBelowCommited = false;
|
||||
m_IfEqualCommited = false;
|
||||
m_Disabled = false;
|
||||
m_UpdateDivider = 1;
|
||||
m_UpdateCounter = 0;
|
||||
m_MedianPos = 0;
|
||||
m_AveragePos = 0;
|
||||
m_AverageSize = 0;
|
||||
m_MeterWindow = meterWindow;
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeasure
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeasure::~CMeasure()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Reads the common configs for all Measures. The inherited classes
|
||||
** must call the base implementation if they overwrite this method.
|
||||
**
|
||||
*/
|
||||
void CMeasure::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
m_Invert = 0!=parser.ReadInt(section, L"InvertMeasure", 0);
|
||||
m_Disabled = 0!=parser.ReadInt(section, L"Disabled", 0);
|
||||
m_UpdateDivider = parser.ReadInt(section, L"UpdateDivider", 1);
|
||||
m_UpdateCounter = m_UpdateDivider;
|
||||
|
||||
m_MinValue = parser.ReadFloat(section, L"MinValue", m_MinValue);
|
||||
m_MaxValue = parser.ReadFloat(section, L"MaxValue", m_MaxValue);
|
||||
|
||||
// The ifabove/ifbelow define actions that are ran when the value goes above/below the given number.
|
||||
|
||||
m_IfAboveValue = parser.ReadFloat(section, L"IfAboveValue", 0.0);
|
||||
m_IfAboveAction = parser.ReadString(section, L"IfAboveAction", L"");
|
||||
|
||||
m_IfBelowValue = parser.ReadFloat(section, L"IfBelowValue", 0.0);
|
||||
m_IfBelowAction = parser.ReadString(section, L"IfBelowAction", L"");
|
||||
|
||||
m_IfEqualValue = parser.ReadFloat(section, L"IfEqualValue", 0.0);
|
||||
m_IfEqualAction = parser.ReadString(section, L"IfEqualAction", L"");
|
||||
|
||||
m_AverageSize = parser.ReadInt(section, L"AverageSize", 0);
|
||||
|
||||
std::wstring subs;
|
||||
subs = parser.ReadString(section, L"Substitute", L"");
|
||||
if (!ParseSubstitute(subs))
|
||||
{
|
||||
DebugLog(L"WebParser: Incorrect substitute string: %s", subs.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** CheckSubstitute
|
||||
**
|
||||
** Substitutes part of the text
|
||||
*/
|
||||
const WCHAR* CMeasure::CheckSubstitute(const WCHAR* buffer)
|
||||
{
|
||||
static std::wstring str;
|
||||
|
||||
if (!m_Substitute.empty())
|
||||
{
|
||||
str = buffer;
|
||||
|
||||
for (int i = 0; i < m_Substitute.size(); i = i + 2)
|
||||
{
|
||||
if (str.empty() && m_Substitute[i].empty())
|
||||
{
|
||||
// Empty result and empty substitute -> use second
|
||||
str = m_Substitute[i + 1];
|
||||
}
|
||||
else if (m_Substitute[i].size() > 0)
|
||||
{
|
||||
size_t start = 0;
|
||||
size_t pos = std::wstring::npos;
|
||||
|
||||
do
|
||||
{
|
||||
pos = str.find(m_Substitute[i], start);
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
str.replace(str.begin() + pos, str.begin() + pos + m_Substitute[i].size(), m_Substitute[i + 1]);
|
||||
start = pos + m_Substitute[i + 1].size();
|
||||
}
|
||||
} while(pos != std::wstring::npos);
|
||||
}
|
||||
}
|
||||
|
||||
return str.c_str();
|
||||
}
|
||||
else
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** ParseSubstitute
|
||||
**
|
||||
** Reads the buffer for "Name":"Value"-pairs separated with comma and
|
||||
** fills the map with the parsed data.
|
||||
*/
|
||||
bool CMeasure::ParseSubstitute(std::wstring buffer)
|
||||
{
|
||||
if (buffer.empty()) return true;
|
||||
|
||||
// Add quotes since they are removed by the GetProfileString
|
||||
buffer = L"\"" + buffer + L"\"";
|
||||
|
||||
std::wstring word1;
|
||||
std::wstring word2;
|
||||
std::wstring sep;
|
||||
|
||||
while (!buffer.empty())
|
||||
{
|
||||
word1 = ExtractWord(buffer);
|
||||
sep = ExtractWord(buffer);
|
||||
if (sep != L":") return false;
|
||||
word2 = ExtractWord(buffer);
|
||||
|
||||
m_Substitute.push_back(word1);
|
||||
m_Substitute.push_back(word2);
|
||||
|
||||
sep = ExtractWord(buffer);
|
||||
if (!sep.empty() && sep != L",") return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
** ExtractWord
|
||||
**
|
||||
** Returns the first word from the buffer. The word can be inside quotes.
|
||||
** If not, the separators are ' ', '\t', ',' and ':'. Whitespaces are removed
|
||||
** and buffer _will_ be modified.
|
||||
*/
|
||||
std::wstring CMeasure::ExtractWord(std::wstring& buffer)
|
||||
{
|
||||
std::wstring::size_type end = 0;
|
||||
std::wstring ret;
|
||||
|
||||
if (buffer.empty()) return ret;
|
||||
|
||||
// Remove whitespaces
|
||||
std::wstring::size_type notwhite = buffer.find_first_not_of(L" \t\n");
|
||||
buffer.erase(0, notwhite);
|
||||
|
||||
if (buffer[0] == L'\"')
|
||||
{
|
||||
end = 1; // Skip the '"'
|
||||
// Quotes around the word
|
||||
while (buffer[end] != L'\"' && end < buffer.size()) end++;
|
||||
|
||||
if (buffer[end] == L'\"')
|
||||
{
|
||||
ret = buffer.substr(1, end - 1);
|
||||
buffer.erase(0, end + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
// End of string reached
|
||||
ret = buffer.substr(end);
|
||||
buffer.erase(0, end);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
end = 0;
|
||||
while ((buffer[end] != L',') && (buffer[end] != L':') && (buffer[end] != L' ') && (buffer[end] != L'\t') && end < buffer.size()) end++;
|
||||
|
||||
if (end == buffer.size())
|
||||
{
|
||||
// End of line reached
|
||||
ret = buffer;
|
||||
buffer.erase(0, end);
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = buffer.substr(0, end + 1); // The separator is also returned!
|
||||
buffer.erase(0, end + 1);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** PreUpdate
|
||||
**
|
||||
** The base implementation of the update method. This includes the code
|
||||
** that is common for all measures. This is called every time the measure
|
||||
** is updated. The inherited classes must call the base implementation if
|
||||
** they overwrite this method. If this method returns false, the update
|
||||
** needs not to be done.
|
||||
**
|
||||
*/
|
||||
bool CMeasure::PreUpdate()
|
||||
{
|
||||
if (IsDisabled())
|
||||
{
|
||||
m_Value = 0.0; // Disable measures return 0 as value
|
||||
return false;
|
||||
}
|
||||
|
||||
// Only update the counter if the divider
|
||||
m_UpdateCounter++;
|
||||
if (m_UpdateCounter < m_UpdateDivider) return false;
|
||||
m_UpdateCounter = 0;
|
||||
|
||||
// If we're logging the maximum value of the measure, check if
|
||||
// the new value is greater than the old one, and update if necessary.
|
||||
if(m_LogMaxValue)
|
||||
{
|
||||
if (m_MedianMaxValues.empty())
|
||||
{
|
||||
m_MedianMaxValues.resize(MEDIAN_SIZE, 0);
|
||||
m_MedianMinValues.resize(MEDIAN_SIZE, 0);
|
||||
}
|
||||
|
||||
m_MedianMaxValues[m_MedianPos] = m_Value;
|
||||
m_MedianMinValues[m_MedianPos] = m_Value;
|
||||
m_MedianPos++;
|
||||
m_MedianPos %= MEDIAN_SIZE;
|
||||
|
||||
std::vector<double> medianArray;
|
||||
|
||||
medianArray = m_MedianMaxValues;
|
||||
std::sort(medianArray.begin(), medianArray.end());
|
||||
m_MaxValue = max(m_MaxValue, medianArray[MEDIAN_SIZE / 2]);
|
||||
|
||||
medianArray = m_MedianMinValues;
|
||||
std::sort(medianArray.begin(), medianArray.end());
|
||||
m_MinValue = min(m_MinValue, medianArray[MEDIAN_SIZE / 2]);
|
||||
}
|
||||
|
||||
if (m_MeterWindow)
|
||||
{
|
||||
// Check the IfEqualValue
|
||||
if(!m_IfEqualAction.empty())
|
||||
{
|
||||
if((int)m_Value == (int)m_IfEqualValue)
|
||||
{
|
||||
if(!m_IfEqualCommited)
|
||||
{
|
||||
Rainmeter->ExecuteCommand(m_IfEqualAction.c_str(), m_MeterWindow);
|
||||
m_IfEqualCommited = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_IfEqualCommited = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Check the IfAboveValue
|
||||
if(!m_IfAboveAction.empty())
|
||||
{
|
||||
if(m_Value > m_IfAboveValue)
|
||||
{
|
||||
if(!m_IfAboveCommited)
|
||||
{
|
||||
Rainmeter->ExecuteCommand(m_IfAboveAction.c_str(), m_MeterWindow);
|
||||
m_IfAboveCommited = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_IfAboveCommited = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Check the IfBelowValue
|
||||
if(!m_IfBelowAction.empty())
|
||||
{
|
||||
if(m_Value < m_IfBelowValue)
|
||||
{
|
||||
if(!m_IfBelowCommited)
|
||||
{
|
||||
Rainmeter->ExecuteCommand(m_IfBelowAction.c_str(), m_MeterWindow);
|
||||
m_IfBelowCommited = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_IfBelowCommited = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
** PostUpdate
|
||||
**
|
||||
** Does post measuring things to the value. All measures must call this
|
||||
** after they have set the m_Value.
|
||||
**
|
||||
*/
|
||||
bool CMeasure::PostUpdate()
|
||||
{
|
||||
if (m_AverageSize > 0)
|
||||
{
|
||||
if (m_AverageValues.size() == 0)
|
||||
{
|
||||
m_AverageValues.resize(m_AverageSize, m_Value);
|
||||
}
|
||||
m_AverageValues[m_AveragePos] = m_Value;
|
||||
|
||||
m_AveragePos++;
|
||||
m_AveragePos %= m_AverageValues.size();
|
||||
|
||||
// Calculate the average value
|
||||
m_Value = 0;
|
||||
for (int i = 0; i < m_AverageValues.size(); i++)
|
||||
{
|
||||
m_Value += m_AverageValues[i];
|
||||
}
|
||||
m_Value = m_Value / (double)m_AverageValues.size();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
** GetValue
|
||||
**
|
||||
** Returns the value of the measure.
|
||||
**
|
||||
*/
|
||||
double CMeasure::GetValue()
|
||||
{
|
||||
// Invert if so requested
|
||||
if (m_Invert)
|
||||
{
|
||||
return m_MaxValue - m_Value + m_MinValue;
|
||||
}
|
||||
|
||||
return m_Value;
|
||||
}
|
||||
|
||||
/*
|
||||
** GetRelativeValue
|
||||
**
|
||||
** Returns the relative value of the measure (0.0 - 1.0).
|
||||
**
|
||||
*/
|
||||
double CMeasure::GetRelativeValue()
|
||||
{
|
||||
double value = GetValue();
|
||||
|
||||
value = min(m_MaxValue, value);
|
||||
value = max(m_MinValue, value);
|
||||
|
||||
value -= m_MinValue;
|
||||
|
||||
return value / GetValueRange();
|
||||
}
|
||||
|
||||
/*
|
||||
** GetValueRange
|
||||
**
|
||||
** Returns the value range.
|
||||
**
|
||||
*/
|
||||
double CMeasure::GetValueRange()
|
||||
{
|
||||
return m_MaxValue - m_MinValue;
|
||||
}
|
||||
|
||||
/*
|
||||
** GetStringValue
|
||||
**
|
||||
** This method returns the value as text string. The actual value is
|
||||
** get with GetValue() so we don't have to worry about m_Invert.
|
||||
**
|
||||
** autoScale If true, scale the value automatically to some sensible range.
|
||||
** scale The scale to use if autoScale is false.
|
||||
** decimals Number of decimals used in the value.
|
||||
** percentual Return the value as % from the maximum value.
|
||||
*/
|
||||
const WCHAR* CMeasure::GetStringValue(bool autoScale, double scale, int decimals, bool percentual)
|
||||
{
|
||||
static WCHAR buffer[MAX_LINE_LENGTH];
|
||||
static WCHAR buffer2[MAX_LINE_LENGTH];
|
||||
double theValue = GetValue();
|
||||
|
||||
if(percentual)
|
||||
{
|
||||
swprintf(buffer, L"%i", (UINT)(100.0 * GetRelativeValue()));
|
||||
}
|
||||
else if(autoScale)
|
||||
{
|
||||
GetScaledValue(decimals, theValue, buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(decimals == 0)
|
||||
{
|
||||
double val = theValue * (1.0 / scale);
|
||||
val = (val + ( (val >= 0) ? 0.5 : -0.5 ) );
|
||||
swprintf(buffer, L"%i", (UINT)val);
|
||||
}
|
||||
else
|
||||
{
|
||||
swprintf(buffer2, L"%%.%if", decimals);
|
||||
swprintf(buffer, buffer2, theValue * (1.0 / scale));
|
||||
}
|
||||
}
|
||||
|
||||
return CheckSubstitute(buffer);
|
||||
}
|
||||
|
||||
void CMeasure::GetScaledValue(int decimals, double theValue, WCHAR* buffer)
|
||||
{
|
||||
WCHAR format[16];
|
||||
double value = 0;
|
||||
|
||||
if(decimals == 0)
|
||||
{
|
||||
wcscpy(format, L"%.0f");
|
||||
}
|
||||
else
|
||||
{
|
||||
swprintf(format, L"%%.%if", decimals);
|
||||
}
|
||||
|
||||
if(theValue > 1000.0 * 1000.0 * 1000.0 * 1000.0)
|
||||
{
|
||||
wcscat(format, L" T");
|
||||
value = theValue / 1024.0 / 1024.0 / 1024.0 / 1024.0;
|
||||
}
|
||||
else if(theValue > 1000.0 * 1000.0 * 1000.0)
|
||||
{
|
||||
wcscat(format, L" G");
|
||||
value = theValue / 1024.0 / 1024.0 / 1024.0;
|
||||
}
|
||||
else if(theValue > 1000.0 * 1000.0)
|
||||
{
|
||||
wcscat(format, L" M");
|
||||
value = theValue / 1024.0 / 1024.0;
|
||||
}
|
||||
else if(theValue > 1000.0)
|
||||
{
|
||||
wcscat(format, L" k");
|
||||
value = theValue / 1024.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = theValue;
|
||||
}
|
||||
swprintf(buffer, format, value);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** GetStats
|
||||
**
|
||||
** Returns the stats as string. The stats are shown in the About dialog.
|
||||
*/
|
||||
const WCHAR* CMeasure::GetStats()
|
||||
{
|
||||
static std::wstring value;
|
||||
|
||||
value = GetStringValue(true, 1, 1, false);
|
||||
|
||||
return value.c_str();
|
||||
}
|
||||
|
||||
/*
|
||||
** Create
|
||||
**
|
||||
** Creates the given measure. This is the factory method for the measures.
|
||||
** If new measures are implemented this method needs to be updated.
|
||||
**
|
||||
*/
|
||||
CMeasure* CMeasure::Create(const WCHAR* measure, CMeterWindow* meterWindow)
|
||||
{
|
||||
// Comparson is caseinsensitive
|
||||
|
||||
if(_wcsicmp(L"", measure) == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
else if(_wcsicmp(L"CPU", measure) == 0)
|
||||
{
|
||||
return new CMeasureCPU(meterWindow);
|
||||
}
|
||||
else if(_wcsicmp(L"Memory", measure) == 0)
|
||||
{
|
||||
return new CMeasureMemory(meterWindow);
|
||||
}
|
||||
else if(_wcsicmp(L"NetIn", measure) == 0)
|
||||
{
|
||||
return new CMeasureNetIn(meterWindow);
|
||||
}
|
||||
else if(_wcsicmp(L"NetOut", measure) == 0)
|
||||
{
|
||||
return new CMeasureNetOut(meterWindow);
|
||||
}
|
||||
else if(_wcsicmp(L"NetTotal", measure) == 0)
|
||||
{
|
||||
return new CMeasureNetTotal(meterWindow);
|
||||
}
|
||||
else if(_wcsicmp(L"PhysicalMemory", measure) == 0)
|
||||
{
|
||||
return new CMeasurePhysicalMemory(meterWindow);
|
||||
}
|
||||
else if(_wcsicmp(L"SwapMemory", measure) == 0)
|
||||
{
|
||||
return new CMeasureVirtualMemory(meterWindow);
|
||||
}
|
||||
else if(_wcsicmp(L"FreeDiskSpace", measure) == 0)
|
||||
{
|
||||
return new CMeasureDiskSpace(meterWindow);
|
||||
}
|
||||
else if(_wcsicmp(L"Uptime", measure) == 0)
|
||||
{
|
||||
return new CMeasureUptime(meterWindow);
|
||||
}
|
||||
else if(_wcsicmp(L"Time", measure) == 0)
|
||||
{
|
||||
return new CMeasureTime(meterWindow);
|
||||
}
|
||||
else if(_wcsicmp(L"Plugin", measure) == 0)
|
||||
{
|
||||
return new CMeasurePlugin(meterWindow);
|
||||
}
|
||||
else if(_wcsicmp(L"Registry", measure) == 0)
|
||||
{
|
||||
return new CMeasureRegistry(meterWindow);
|
||||
}
|
||||
else if(_wcsicmp(L"Calc", measure) == 0)
|
||||
{
|
||||
return new CMeasureCalc(meterWindow);
|
||||
}
|
||||
|
||||
// Error
|
||||
throw CError(std::wstring(L"No such measure: ") + measure, __LINE__, __FILE__);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
** ExecuteBang
|
||||
**
|
||||
** Executes a custom bang
|
||||
*/
|
||||
void CMeasure::ExecuteBang(const WCHAR* args)
|
||||
{
|
||||
DebugLog(L"[%s] Doesn't support this bang: %s", m_Name.c_str(), args);
|
||||
}
|
||||
152
Library/Measure.h
Normal file
152
Library/Measure.h
Normal file
@@ -0,0 +1,152 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/Measure.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: Measure.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.13 2004/07/11 17:14:20 rainy
|
||||
Fixed string generation when num of decimals is 0.
|
||||
|
||||
Revision 1.12 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.11 2003/02/10 18:13:49 rainy
|
||||
Added median filter to max value.
|
||||
|
||||
Revision 1.10 2002/12/23 14:26:21 rainy
|
||||
Stats are gathered a bit different way now.
|
||||
|
||||
Revision 1.9 2002/05/04 08:12:32 rainy
|
||||
Measure update is not tied to the update rate directly anymore.
|
||||
|
||||
Revision 1.8 2002/04/26 18:24:16 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.7 2002/03/31 09:58:54 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.6 2001/10/28 10:24:06 rainy
|
||||
GetStringValue uses consts.
|
||||
Added IfAbove/Below actions.
|
||||
Added Plugin and Registry Measures.
|
||||
|
||||
Revision 1.5 2001/09/26 16:27:15 rainy
|
||||
Changed the interfaces a bit.
|
||||
|
||||
Revision 1.4 2001/09/01 13:00:41 rainy
|
||||
Slight changes in the interface. The value is now measured only once if possible.
|
||||
Added support for logging the max value.
|
||||
|
||||
Revision 1.3 2001/08/19 09:15:41 rainy
|
||||
Invert was moved here from the meter.
|
||||
|
||||
Revision 1.2 2001/08/12 15:47:00 Rainy
|
||||
Adjusted Update()'s interface.
|
||||
Added GetStringValue() method.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __MEASURE_H__
|
||||
#define __MEASURE_H__
|
||||
|
||||
#include "MeterWindow.h"
|
||||
#include "Litestep.h"
|
||||
|
||||
class CMeter;
|
||||
|
||||
class CMeasure
|
||||
{
|
||||
public:
|
||||
CMeasure(CMeterWindow* meterWindow);
|
||||
virtual ~CMeasure();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual bool Update() = 0;
|
||||
|
||||
virtual const WCHAR* GetStats();
|
||||
|
||||
void SetName(const WCHAR* name) { m_Name = name; m_ANSIName = ConvertToAscii(name); };
|
||||
const WCHAR* GetName() { return m_Name.c_str(); };
|
||||
const char* GetANSIName() { return m_ANSIName.c_str(); };
|
||||
|
||||
void Disable() { m_Disabled = true; };
|
||||
void Enable() { m_Disabled = false; };
|
||||
bool IsDisabled() { return m_Disabled; };
|
||||
|
||||
virtual void ExecuteBang(const WCHAR* args);
|
||||
|
||||
double GetValue();
|
||||
double GetRelativeValue();
|
||||
double GetValueRange();
|
||||
double GetMinValue() { return m_MinValue; };
|
||||
double GetMaxValue() { return m_MaxValue; };
|
||||
|
||||
virtual const WCHAR* GetStringValue(bool autoScale, double scale, int decimals, bool percentual);
|
||||
static void GetScaledValue(int decimals, double theValue, WCHAR* buffer);
|
||||
|
||||
static CMeasure* Create(const WCHAR* measure, CMeterWindow* meterWindow);
|
||||
|
||||
protected:
|
||||
virtual bool PreUpdate();
|
||||
virtual bool PostUpdate();
|
||||
|
||||
bool ParseSubstitute(std::wstring buffer);
|
||||
std::wstring ExtractWord(std::wstring& buffer);
|
||||
const WCHAR* CheckSubstitute(const WCHAR* buffer);
|
||||
|
||||
bool m_Invert; // If true, the value should be inverted
|
||||
bool m_LogMaxValue; // If true, The maximum & minimum values are logged
|
||||
double m_MinValue; // The minimum value (so far)
|
||||
double m_MaxValue; // The maximum value (so far)
|
||||
double m_Value; // The current value
|
||||
std::wstring m_Name; // Name of this Measure
|
||||
std::string m_ANSIName; // Name of this Measure in ANSI
|
||||
|
||||
std::vector<std::wstring> m_Substitute; // Vec of substitute strings
|
||||
|
||||
std::vector<double> m_MedianMaxValues; // The values for the median filtering
|
||||
std::vector<double> m_MedianMinValues; // The values for the median filtering
|
||||
UINT m_MedianPos; // Position in the median array, where the new value is placed
|
||||
|
||||
std::vector<double> m_AverageValues;
|
||||
UINT m_AveragePos;
|
||||
UINT m_AverageSize;
|
||||
|
||||
double m_IfEqualValue; // The limit for the IfEqual action
|
||||
double m_IfAboveValue; // The limit for the IfAbove action
|
||||
double m_IfBelowValue; // The limit for the IfBelow action
|
||||
std::wstring m_IfEqualAction; // The IfEqual action
|
||||
std::wstring m_IfAboveAction; // The IfAbove action
|
||||
std::wstring m_IfBelowAction; // The IfBelow action
|
||||
bool m_IfEqualCommited; // True when the IfEqual action is executed.
|
||||
bool m_IfAboveCommited; // True when the IfAbove action is executed.
|
||||
bool m_IfBelowCommited; // True when the IfBelow action is executed.
|
||||
bool m_Disabled; // Status of the measure
|
||||
UINT m_UpdateDivider; // Divider for the update
|
||||
UINT m_UpdateCounter; // Current update counter
|
||||
|
||||
CMeterWindow* m_MeterWindow;
|
||||
};
|
||||
|
||||
#endif
|
||||
212
Library/MeasureCPU.cpp
Normal file
212
Library/MeasureCPU.cpp
Normal file
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureCPU.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureCPU.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.10 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.9 2002/04/26 18:24:16 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.8 2002/03/31 09:58:54 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.7 2002/01/16 16:07:00 rainy
|
||||
Fixed a bug with the CPU meter in 9x.
|
||||
|
||||
Revision 1.6 2001/10/28 10:22:49 rainy
|
||||
Changed the IsNT() function return value check
|
||||
|
||||
Revision 1.5 2001/09/26 16:27:15 rainy
|
||||
Changed the interfaces a bit.
|
||||
|
||||
Revision 1.4 2001/09/01 13:00:10 rainy
|
||||
Slight changes in the interface. The value is now measured only once if possible.
|
||||
|
||||
Revision 1.3 2001/08/19 09:15:21 rainy
|
||||
Added support for value invert.
|
||||
|
||||
Revision 1.2 2001/08/12 15:46:34 Rainy
|
||||
Adjusted Update()'s interface.
|
||||
Fixed a bug that prevent more than one CPU meter.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeasureCPU.h"
|
||||
#include "Rainmeter.h"
|
||||
|
||||
#define SystemBasicInformation 0
|
||||
#define SystemPerformanceInformation 2
|
||||
#define SystemTimeInformation 3
|
||||
|
||||
#define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + (double)((x).LowPart))
|
||||
|
||||
// ntdll!NtQuerySystemInformation (NT specific!)
|
||||
//
|
||||
// The function copies the system information of the
|
||||
// specified type into a buffer
|
||||
//
|
||||
// NTSYSAPI
|
||||
// NTSTATUS
|
||||
// NTAPI
|
||||
// NtQuerySystemInformation(
|
||||
// IN UINT SystemInformationClass, // information type
|
||||
// OUT PVOID SystemInformation, // pointer to buffer
|
||||
// IN ULONG SystemInformationLength, // buffer size in bytes
|
||||
// OUT PULONG ReturnLength OPTIONAL // pointer to a 32-bit
|
||||
// // variable that receives
|
||||
// // the number of bytes
|
||||
// // written to the buffer
|
||||
// );
|
||||
|
||||
/*
|
||||
** CMeasureCPU
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeasureCPU::CMeasureCPU(CMeterWindow* meterWindow) : CMeasure(meterWindow)
|
||||
{
|
||||
m_CPUFromRegistry = false;
|
||||
m_MaxValue = 100.0;
|
||||
m_MinValue = 0.0;
|
||||
m_FirstTime = true;
|
||||
|
||||
m_NtQuerySystemInformation = NULL;
|
||||
m_OldIdleTime.QuadPart = 0;
|
||||
m_OldSystemTime.QuadPart = 0;
|
||||
|
||||
m_NtQuerySystemInformation = (PROCNTQSI)GetProcAddress(
|
||||
GetModuleHandle(L"ntdll"),
|
||||
"NtQuerySystemInformation"
|
||||
);
|
||||
|
||||
GetSystemInfo(&m_SystemInfo);
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeasureCPU
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeasureCPU::~CMeasureCPU()
|
||||
{
|
||||
if(m_CPUFromRegistry)
|
||||
{
|
||||
// Stop the counter if it was started
|
||||
HKEY hkey;
|
||||
DWORD dwDataSize;
|
||||
DWORD dwType;
|
||||
DWORD dwDummy;
|
||||
|
||||
RegOpenKeyEx(HKEY_DYN_DATA, L"PerfStats\\StopStat", 0, KEY_ALL_ACCESS, &hkey);
|
||||
dwDataSize = sizeof(dwDummy);
|
||||
RegQueryValueEx(hkey, L"KERNEL\\CPUUsage", NULL, &dwType, (LPBYTE)&dwDummy, &dwDataSize);
|
||||
RegCloseKey(hkey);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the current CPU utilization value. On NT the value is taken
|
||||
** from the performance counters and on 9x we'll use the registry.
|
||||
**
|
||||
*/
|
||||
bool CMeasureCPU::Update()
|
||||
{
|
||||
if (!CMeasure::PreUpdate()) return false;
|
||||
|
||||
if (CRainmeter::IsNT() != PLATFORM_9X)
|
||||
{
|
||||
if (m_NtQuerySystemInformation)
|
||||
{
|
||||
// This code is 'borrowed' from http://www.codepile.com/tric21.shtml
|
||||
double dbIdleTime;
|
||||
double dbSystemTime;
|
||||
LONG status;
|
||||
|
||||
// get new system time
|
||||
status = m_NtQuerySystemInformation(SystemTimeInformation, &m_SysTimeInfo, sizeof(m_SysTimeInfo), 0);
|
||||
if (status != NO_ERROR) return false;
|
||||
|
||||
// get new CPU's idle time
|
||||
status = m_NtQuerySystemInformation(SystemPerformanceInformation,&m_SysPerfInfo,sizeof(m_SysPerfInfo),NULL);
|
||||
if (status != NO_ERROR) return false;
|
||||
|
||||
// if it's a first call - skip it
|
||||
if(!m_FirstTime)
|
||||
{
|
||||
// CurrentValue = NewValue - OldValue
|
||||
dbIdleTime = Li2Double(m_SysPerfInfo.liIdleTime) - Li2Double(m_OldIdleTime);
|
||||
dbSystemTime = Li2Double(m_SysTimeInfo.liKeSystemTime) - Li2Double(m_OldSystemTime);
|
||||
|
||||
// CurrentCpuIdle = IdleTime / SystemTime
|
||||
dbIdleTime = dbIdleTime / dbSystemTime;
|
||||
|
||||
// CurrentCpuUsage% = 100 - (CurrentCpuIdle * 100) / NumberOfProcessors
|
||||
dbIdleTime = 100.0 - dbIdleTime * 100.0 / (double)m_SystemInfo.dwNumberOfProcessors + 0.5;
|
||||
|
||||
m_Value = min(dbIdleTime, 100.0);
|
||||
m_Value = max(m_Value, 0.0);
|
||||
}
|
||||
|
||||
// store new CPU's idle and system time
|
||||
m_OldIdleTime = m_SysPerfInfo.liIdleTime;
|
||||
m_OldSystemTime = m_SysTimeInfo.liKeSystemTime;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// It's a wintendo!
|
||||
HKEY hkey;
|
||||
DWORD dwDataSize;
|
||||
DWORD dwType;
|
||||
DWORD dwCpuUsage;
|
||||
|
||||
if(m_FirstTime)
|
||||
{
|
||||
RegOpenKeyEx(HKEY_DYN_DATA, L"PerfStats\\StartStat", 0, KEY_ALL_ACCESS, &hkey);
|
||||
dwDataSize = sizeof(dwCpuUsage);
|
||||
RegQueryValueEx(hkey, L"KERNEL\\CPUUsage", NULL, &dwType, (LPBYTE)&dwCpuUsage, &dwDataSize);
|
||||
RegCloseKey(hkey);
|
||||
}
|
||||
|
||||
RegOpenKeyEx(HKEY_DYN_DATA, L"PerfStats\\StatData", 0, KEY_ALL_ACCESS, &hkey);
|
||||
dwDataSize = sizeof(dwCpuUsage);
|
||||
RegQueryValueEx(hkey, L"KERNEL\\CPUUsage", NULL, &dwType, (LPBYTE)&dwCpuUsage, &dwDataSize);
|
||||
RegCloseKey(hkey);
|
||||
|
||||
m_Value = dwCpuUsage;
|
||||
m_CPUFromRegistry = true;
|
||||
}
|
||||
|
||||
m_FirstTime = false;
|
||||
|
||||
return PostUpdate();
|
||||
}
|
||||
109
Library/MeasureCPU.h
Normal file
109
Library/MeasureCPU.h
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureCPU.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureCPU.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.7 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.6 2002/04/26 18:24:16 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.5 2002/01/16 16:07:00 rainy
|
||||
Fixed a bug with the CPU meter in 9x.
|
||||
|
||||
Revision 1.4 2001/09/26 16:27:15 rainy
|
||||
Changed the interfaces a bit.
|
||||
|
||||
Revision 1.3 2001/09/01 13:00:10 rainy
|
||||
Slight changes in the interface. The value is now measured only once if possible.
|
||||
|
||||
Revision 1.2 2001/08/12 15:46:33 Rainy
|
||||
Adjusted Update()'s interface.
|
||||
Fixed a bug that prevent more than one CPU meter.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __MEASURECPU_H__
|
||||
#define __MEASURECPU_H__
|
||||
|
||||
#include "Measure.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DWORD dwUnknown1;
|
||||
ULONG uKeMaximumIncrement;
|
||||
ULONG uPageSize;
|
||||
ULONG uMmNumberOfPhysicalPages;
|
||||
ULONG uMmLowestPhysicalPage;
|
||||
ULONG uMmHighestPhysicalPage;
|
||||
ULONG uAllocationGranularity;
|
||||
PVOID pLowestUserAddress;
|
||||
PVOID pMmHighestUserAddress;
|
||||
ULONG uKeActiveProcessors;
|
||||
BYTE bKeNumberProcessors;
|
||||
BYTE bUnknown2;
|
||||
WORD wUnknown3;
|
||||
} SYSTEM_BASIC_INFORMATION;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LARGE_INTEGER liIdleTime;
|
||||
DWORD dwSpare[76];
|
||||
} SYSTEM_PERFORMANCE_INFORMATION;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
LARGE_INTEGER liKeBootTime;
|
||||
LARGE_INTEGER liKeSystemTime;
|
||||
LARGE_INTEGER liExpTimeZoneBias;
|
||||
ULONG uCurrentTimeZoneId;
|
||||
DWORD dwReserved;
|
||||
} SYSTEM_TIME_INFORMATION;
|
||||
|
||||
typedef LONG (WINAPI *PROCNTQSI)(UINT,PVOID,ULONG,PULONG);
|
||||
|
||||
class CMeasureCPU : public CMeasure
|
||||
{
|
||||
public:
|
||||
CMeasureCPU(CMeterWindow* meterWindow);
|
||||
virtual ~CMeasureCPU();
|
||||
|
||||
virtual bool Update();
|
||||
|
||||
protected:
|
||||
bool m_CPUFromRegistry;
|
||||
bool m_FirstTime;
|
||||
|
||||
PROCNTQSI m_NtQuerySystemInformation;
|
||||
|
||||
SYSTEM_PERFORMANCE_INFORMATION m_SysPerfInfo;
|
||||
SYSTEM_TIME_INFORMATION m_SysTimeInfo;
|
||||
SYSTEM_INFO m_SystemInfo;
|
||||
LARGE_INTEGER m_OldIdleTime;
|
||||
LARGE_INTEGER m_OldSystemTime;
|
||||
};
|
||||
|
||||
#endif
|
||||
129
Library/MeasureCalc.cpp
Normal file
129
Library/MeasureCalc.cpp
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureCalc.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureCalc.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.2 2004/07/11 17:14:39 rainy
|
||||
MeterWindow holds the counter now.
|
||||
|
||||
Revision 1.1 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeasureCalc.h"
|
||||
#include "Rainmeter.h"
|
||||
|
||||
hqStrMap* CMeasureCalc::c_VarMap = NULL;
|
||||
int CMeasureCalc::m_Loop = 0;
|
||||
|
||||
/*
|
||||
** CMeasureCalc
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeasureCalc::CMeasureCalc(CMeterWindow* meterWindow) : CMeasure(meterWindow)
|
||||
{
|
||||
m_Parser = MathParser_Create(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeasureCalc
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeasureCalc::~CMeasureCalc()
|
||||
{
|
||||
MathParser_Destroy(m_Parser);
|
||||
|
||||
if (c_VarMap)
|
||||
{
|
||||
StrMap_Destroy(c_VarMap);
|
||||
c_VarMap = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the calculation
|
||||
**
|
||||
*/
|
||||
bool CMeasureCalc::Update()
|
||||
{
|
||||
if (!CMeasure::PreUpdate()) return false;
|
||||
|
||||
m_Parser->Parameters = c_VarMap;
|
||||
|
||||
char* errMsg = MathParser_Parse(m_Parser, ConvertToAscii(m_Formula.c_str()).c_str(), &m_Value);
|
||||
if (errMsg != NULL)
|
||||
{
|
||||
DebugLog(ConvertToWide(errMsg).c_str());
|
||||
}
|
||||
|
||||
return PostUpdate();
|
||||
}
|
||||
|
||||
void CMeasureCalc::UpdateVariableMap(CMeterWindow& meterWindow)
|
||||
{
|
||||
// Delete the old map
|
||||
if (c_VarMap)
|
||||
{
|
||||
StrMap_Destroy(c_VarMap);
|
||||
c_VarMap = NULL;
|
||||
}
|
||||
|
||||
// Create the variable map
|
||||
c_VarMap = Strmap_Create(sizeof(double), 0);
|
||||
|
||||
std::list<CMeasure*>& measures = meterWindow.GetMeasures();
|
||||
|
||||
std::list<CMeasure*>::iterator iter = measures.begin();
|
||||
for( ; iter != measures.end(); iter++)
|
||||
{
|
||||
const char* name = (*iter)->GetANSIName();
|
||||
double val = (*iter)->GetValue();
|
||||
|
||||
StrMap_AddString(c_VarMap, name, &val);
|
||||
}
|
||||
|
||||
// Add the counter
|
||||
double counter = meterWindow.GetUpdateCounter();
|
||||
StrMap_AddString(c_VarMap, "Counter", &counter);
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Reads the measure specific configs.
|
||||
**
|
||||
*/
|
||||
void CMeasureCalc::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
CMeasure::ReadConfig(parser, section);
|
||||
|
||||
m_Formula = parser.ReadString(section, L"Formula", L"");
|
||||
}
|
||||
55
Library/MeasureCalc.h
Normal file
55
Library/MeasureCalc.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureCalc.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureCalc.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.1 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __MEASURECALC_H__
|
||||
#define __MEASURECALC_H__
|
||||
|
||||
#include "Measure.h"
|
||||
#include "ccalc-0.5.1/mparser.h"
|
||||
|
||||
class CMeasureCalc : public CMeasure
|
||||
{
|
||||
public:
|
||||
CMeasureCalc(CMeterWindow* meterWindow);
|
||||
virtual ~CMeasureCalc();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual bool Update();
|
||||
|
||||
static void UpdateVariableMap(CMeterWindow& meterWindow);
|
||||
|
||||
private:
|
||||
std::wstring m_Formula;
|
||||
hqMathParser* m_Parser;
|
||||
|
||||
static hqStrMap* c_VarMap;
|
||||
static int m_Loop;
|
||||
};
|
||||
|
||||
#endif
|
||||
175
Library/MeasureDiskSpace.cpp
Normal file
175
Library/MeasureDiskSpace.cpp
Normal file
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureDiskSpace.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureDiskSpace.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.11 2004/07/11 17:15:06 rainy
|
||||
Also removable drives are ignored.
|
||||
|
||||
Revision 1.10 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.9 2004/03/13 16:16:12 rainy
|
||||
CDROMs are ignored
|
||||
|
||||
Revision 1.8 2002/04/26 18:24:16 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.7 2002/03/31 09:58:54 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.6 2001/10/28 10:22:20 rainy
|
||||
GetStringValue uses consts.
|
||||
|
||||
Revision 1.5 2001/10/14 07:31:03 rainy
|
||||
Minor monifications to remove few warnings with VC.NET
|
||||
|
||||
Revision 1.4 2001/09/26 16:27:15 rainy
|
||||
Changed the interfaces a bit.
|
||||
|
||||
Revision 1.3 2001/09/01 13:00:10 rainy
|
||||
Slight changes in the interface. The value is now measured only once if possible.
|
||||
|
||||
Revision 1.2 2001/08/19 09:15:08 rainy
|
||||
Added support for value invert.
|
||||
Also the CMeasure's ReadConfig is executed.
|
||||
|
||||
Revision 1.1 2001/08/12 15:35:08 Rainy
|
||||
Inital Version
|
||||
|
||||
|
||||
*/
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeasureDiskSpace.h"
|
||||
#include "Rainmeter.h"
|
||||
|
||||
/*
|
||||
** CMeasureDiskSpace
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeasureDiskSpace::CMeasureDiskSpace(CMeterWindow* meterWindow) : CMeasure(meterWindow)
|
||||
{
|
||||
m_Total = false;
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeasureDiskSpace
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeasureDiskSpace::~CMeasureDiskSpace()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the current disk free space value.
|
||||
**
|
||||
*/
|
||||
bool CMeasureDiskSpace::Update()
|
||||
{
|
||||
if (!CMeasure::PreUpdate()) return false;
|
||||
|
||||
ULARGE_INTEGER i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes;
|
||||
|
||||
UINT type = GetDriveType(m_Drive.c_str());
|
||||
if (type != DRIVE_CDROM && type != DRIVE_REMOVABLE) // Ignore CD-ROMS and removable drives
|
||||
{
|
||||
if(GetDiskFreeSpaceEx(m_Drive.c_str(), &i64FreeBytesToCaller, &i64TotalBytes, &i64FreeBytes))
|
||||
{
|
||||
LARGE_INTEGER tmpInt;
|
||||
if (m_Total)
|
||||
{
|
||||
tmpInt.QuadPart = i64TotalBytes.QuadPart;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpInt.QuadPart = i64FreeBytes.QuadPart;
|
||||
}
|
||||
m_Value = (double)tmpInt.QuadPart;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Value = 0;
|
||||
}
|
||||
|
||||
if (m_Label)
|
||||
{
|
||||
WCHAR volumeName[MAX_PATH];
|
||||
GetVolumeInformation(m_Drive.c_str(), volumeName, MAX_PATH, NULL, NULL, NULL, NULL, 0);
|
||||
m_LabelName = volumeName;
|
||||
}
|
||||
|
||||
return PostUpdate();
|
||||
}
|
||||
|
||||
/*
|
||||
** GetStringValue
|
||||
**
|
||||
** Returns the time as string.
|
||||
**
|
||||
*/
|
||||
const WCHAR* CMeasureDiskSpace::GetStringValue(bool autoScale, double scale, int decimals, bool percentual)
|
||||
{
|
||||
if (m_Label)
|
||||
{
|
||||
return CheckSubstitute(m_LabelName.c_str());
|
||||
}
|
||||
|
||||
return CMeasure::GetStringValue(autoScale, scale, decimals, percentual);
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Reads the measure specific configs.
|
||||
**
|
||||
*/
|
||||
void CMeasureDiskSpace::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
CMeasure::ReadConfig(parser, section);
|
||||
|
||||
m_Drive = parser.ReadString(section, L"Drive", L"C:\\");
|
||||
m_Total = (1 == parser.ReadInt(section, L"Total", 0));
|
||||
m_Label = (1 == parser.ReadInt(section, L"Label", 0));
|
||||
|
||||
// Set the m_MaxValue
|
||||
ULARGE_INTEGER i64FreeBytesToCaller, i64TotalBytes, i64FreeBytes;
|
||||
|
||||
UINT type = GetDriveType(m_Drive.c_str());
|
||||
if (type != DRIVE_CDROM && type != DRIVE_REMOVABLE) // Ignore CD-ROMS and removable drives
|
||||
{
|
||||
if(GetDiskFreeSpaceEx(m_Drive.c_str(), &i64FreeBytesToCaller, &i64TotalBytes, &i64FreeBytes))
|
||||
{
|
||||
LARGE_INTEGER tmpInt;
|
||||
tmpInt.QuadPart = i64TotalBytes.QuadPart;
|
||||
m_MaxValue = (double)tmpInt.QuadPart;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
71
Library/MeasureDiskSpace.h
Normal file
71
Library/MeasureDiskSpace.h
Normal file
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureDiskSpace.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureDiskSpace.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.7 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.6 2004/03/13 16:16:12 rainy
|
||||
CDROMs are ignored
|
||||
|
||||
Revision 1.5 2002/04/26 18:24:16 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.4 2001/10/28 10:22:20 rainy
|
||||
GetStringValue uses consts.
|
||||
|
||||
Revision 1.3 2001/09/26 16:27:15 rainy
|
||||
Changed the interfaces a bit.
|
||||
|
||||
Revision 1.2 2001/09/01 13:00:10 rainy
|
||||
Slight changes in the interface. The value is now measured only once if possible.
|
||||
|
||||
Revision 1.1 2001/08/12 15:35:08 Rainy
|
||||
Inital Version
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __MEASUREDISKSPACE_H__
|
||||
#define __MEASUREDISKSPACE_H__
|
||||
|
||||
#include "Measure.h"
|
||||
|
||||
class CMeasureDiskSpace : public CMeasure
|
||||
{
|
||||
public:
|
||||
CMeasureDiskSpace(CMeterWindow* meterWindow);
|
||||
virtual ~CMeasureDiskSpace();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual bool Update();
|
||||
virtual const WCHAR* GetStringValue(bool autoScale, double scale, int decimals, bool percentual);
|
||||
|
||||
private:
|
||||
std::wstring m_Drive;
|
||||
std::wstring m_LabelName;
|
||||
bool m_Total;
|
||||
bool m_Label;
|
||||
};
|
||||
|
||||
#endif
|
||||
117
Library/MeasureMemory.cpp
Normal file
117
Library/MeasureMemory.cpp
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureMemory.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureMemory.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.8 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.7 2002/04/26 18:24:16 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.6 2002/03/31 09:58:54 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.5 2001/09/26 16:27:15 rainy
|
||||
Changed the interfaces a bit.
|
||||
|
||||
Revision 1.4 2001/09/01 13:00:10 rainy
|
||||
Slight changes in the interface. The value is now measured only once if possible.
|
||||
|
||||
Revision 1.3 2001/08/19 09:15:21 rainy
|
||||
Added support for value invert.
|
||||
|
||||
Revision 1.2 2001/08/12 15:45:45 Rainy
|
||||
Adjusted Update()'s interface.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeasureMemory.h"
|
||||
|
||||
/*
|
||||
** CMeasureMemory
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeasureMemory::CMeasureMemory(CMeterWindow* meterWindow) : CMeasure(meterWindow)
|
||||
{
|
||||
m_Total = false;
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeasureMemory
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeasureMemory::~CMeasureMemory()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the current total memory value.
|
||||
**
|
||||
*/
|
||||
bool CMeasureMemory::Update()
|
||||
{
|
||||
if (!CMeasure::PreUpdate()) return false;
|
||||
|
||||
MEMORYSTATUSEX stat;
|
||||
stat.dwLength = sizeof(MEMORYSTATUSEX);
|
||||
GlobalMemoryStatusEx(&stat); // Doesn't measure values > 4GB. Should use GlobalMemoryStatusEx instead, but that requires Win2k.
|
||||
if (m_Total)
|
||||
{
|
||||
m_Value = (double)(__int64)(stat.ullTotalPageFile + stat.ullTotalPhys);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Value = (double)(__int64)(stat.ullTotalPageFile + stat.ullTotalPhys - stat.ullAvailPageFile - stat.ullAvailPhys);
|
||||
}
|
||||
|
||||
return PostUpdate();
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Reads the measure specific configs.
|
||||
**
|
||||
*/
|
||||
void CMeasureMemory::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
CMeasure::ReadConfig(parser, section);
|
||||
|
||||
m_Total = (1 == parser.ReadInt(section, L"Total", 0));
|
||||
|
||||
MEMORYSTATUSEX stat;
|
||||
stat.dwLength = sizeof(MEMORYSTATUSEX);
|
||||
GlobalMemoryStatusEx(&stat);
|
||||
m_MaxValue = (double)(__int64)(stat.ullTotalPageFile + stat.ullTotalPhys);
|
||||
}
|
||||
|
||||
63
Library/MeasureMemory.h
Normal file
63
Library/MeasureMemory.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureMemory.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureMemory.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.6 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.5 2002/04/26 18:24:16 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.4 2001/09/26 16:27:15 rainy
|
||||
Changed the interfaces a bit.
|
||||
|
||||
Revision 1.3 2001/09/01 13:00:10 rainy
|
||||
Slight changes in the interface. The value is now measured only once if possible.
|
||||
|
||||
Revision 1.2 2001/08/12 15:45:45 Rainy
|
||||
Adjusted Update()'s interface.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __MEASUREMEMORY_H__
|
||||
#define __MEASUREMEMORY_H__
|
||||
|
||||
#include "Measure.h"
|
||||
|
||||
class CMeasureMemory : public CMeasure
|
||||
{
|
||||
public:
|
||||
CMeasureMemory(CMeterWindow* meterWindow);
|
||||
virtual ~CMeasureMemory();
|
||||
|
||||
virtual bool Update();
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
bool m_Total;
|
||||
};
|
||||
|
||||
#endif
|
||||
471
Library/MeasureNet.cpp
Normal file
471
Library/MeasureNet.cpp
Normal file
@@ -0,0 +1,471 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureNet.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureNet.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.10 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.9 2003/12/05 15:50:09 Rainy
|
||||
Multi-instance changes.
|
||||
|
||||
Revision 1.8 2003/02/10 18:13:34 rainy
|
||||
Changed the way stats are gathered.
|
||||
|
||||
Revision 1.7 2002/12/23 14:26:07 rainy
|
||||
Added cumulative statistics measuring.
|
||||
|
||||
Revision 1.6 2002/07/01 15:34:23 rainy
|
||||
Now it is possible to select the NIC.
|
||||
|
||||
Revision 1.5 2002/04/26 18:24:16 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.4 2002/04/01 15:38:25 rainy
|
||||
Some on the implementation from NetIn/Out is moved here.
|
||||
Added TrafficAction and TrafficValue.
|
||||
|
||||
Revision 1.3 2002/03/31 09:58:54 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.2 2001/08/12 15:45:34 Rainy
|
||||
Changed UpdateTable() to be a class method.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeasureNet.h"
|
||||
#include "Rainmeter.h"
|
||||
|
||||
MIB_IFTABLE* CMeasureNet::c_Table = NULL;
|
||||
UINT CMeasureNet::c_NumOfTables = 0;
|
||||
std::vector<LARGE_INTEGER> CMeasureNet::c_StatValues;
|
||||
std::vector<DWORD> CMeasureNet::c_OldStatValues;
|
||||
|
||||
extern CRainmeter* Rainmeter;
|
||||
|
||||
/*
|
||||
** CMeasureNet
|
||||
**
|
||||
** The constructor. This is the base class for the net-meters.
|
||||
**
|
||||
*/
|
||||
CMeasureNet::CMeasureNet(CMeterWindow* meterWindow) : CMeasure(meterWindow)
|
||||
{
|
||||
m_TrafficValue = 0;
|
||||
m_CurrentTraffic = 0;
|
||||
m_Interface = 0;
|
||||
m_Cumulative = false;
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeasureNet
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeasureNet::~CMeasureNet()
|
||||
{
|
||||
delete [] c_Table;
|
||||
c_Table = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Checks if Action should be executed.
|
||||
**
|
||||
*/
|
||||
bool CMeasureNet::Update()
|
||||
{
|
||||
if (!CMeasure::PreUpdate()) return false;
|
||||
|
||||
if (m_MeterWindow)
|
||||
{
|
||||
if (!m_TrafficAction.empty())
|
||||
{
|
||||
if (m_CurrentTraffic > m_TrafficValue)
|
||||
{
|
||||
m_CurrentTraffic = 0;
|
||||
Rainmeter->ExecuteCommand(m_TrafficAction.c_str(), m_MeterWindow);
|
||||
}
|
||||
|
||||
m_CurrentTraffic += m_Value;
|
||||
}
|
||||
}
|
||||
|
||||
return PostUpdate();
|
||||
}
|
||||
|
||||
/*
|
||||
** UpdateIFTable
|
||||
**
|
||||
** Reads the tables for all net interfaces
|
||||
**
|
||||
*/
|
||||
void CMeasureNet::UpdateIFTable()
|
||||
{
|
||||
if(c_Table == NULL)
|
||||
{
|
||||
// Gotta reserve few bytes for the tables
|
||||
DWORD value;
|
||||
if(GetNumberOfInterfaces(&value) == NO_ERROR)
|
||||
{
|
||||
c_NumOfTables = value;
|
||||
|
||||
if(c_NumOfTables > 0)
|
||||
{
|
||||
DWORD size = sizeof(MIB_IFTABLE) + sizeof(MIB_IFROW) * c_NumOfTables;
|
||||
c_Table = (MIB_IFTABLE*)new char[size];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(c_Table)
|
||||
{
|
||||
DWORD size = sizeof(MIB_IFTABLE) + sizeof(MIB_IFROW) * c_NumOfTables;
|
||||
if(GetIfTable(c_Table, &size, false) != NO_ERROR)
|
||||
{
|
||||
delete [] c_Table;
|
||||
c_Table = (MIB_IFTABLE*)new char[size];
|
||||
if(GetIfTable(c_Table, &size, false) != NO_ERROR)
|
||||
{
|
||||
// Something's wrong. Unable to get the table.
|
||||
delete [] c_Table;
|
||||
c_Table = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** GetNetOctets
|
||||
**
|
||||
** Reads the amount of octets. This is the same for in, out and total.
|
||||
** the net-parameter informs which inherited class called this method.
|
||||
**
|
||||
*/
|
||||
DWORD CMeasureNet::GetNetOctets(NET net)
|
||||
{
|
||||
DWORD value = 0;
|
||||
|
||||
if (m_Interface == 0)
|
||||
{
|
||||
// Get all interfaces
|
||||
for(UINT i = 0; i < c_NumOfTables; i++)
|
||||
{
|
||||
// Ignore the loopback
|
||||
if(strcmp((char*)c_Table->table[i].bDescr, "MS TCP Loopback interface") != 0)
|
||||
{
|
||||
switch (net)
|
||||
{
|
||||
case NET_IN:
|
||||
value += c_Table->table[i].dwInOctets;
|
||||
break;
|
||||
|
||||
case NET_OUT:
|
||||
value += c_Table->table[i].dwOutOctets;
|
||||
break;
|
||||
|
||||
case NET_TOTAL:
|
||||
value += c_Table->table[i].dwInOctets;
|
||||
value += c_Table->table[i].dwOutOctets;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get the selected interface
|
||||
if (m_Interface <= c_NumOfTables)
|
||||
{
|
||||
switch (net)
|
||||
{
|
||||
case NET_IN:
|
||||
value += c_Table->table[m_Interface - 1].dwInOctets;
|
||||
break;
|
||||
|
||||
case NET_OUT:
|
||||
value += c_Table->table[m_Interface - 1].dwOutOctets;
|
||||
break;
|
||||
|
||||
case NET_TOTAL:
|
||||
value += c_Table->table[m_Interface - 1].dwInOctets;
|
||||
value += c_Table->table[m_Interface - 1].dwOutOctets;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
** GetNetStatsValue
|
||||
**
|
||||
** Returns the stats value of the interface
|
||||
**
|
||||
*/
|
||||
LARGE_INTEGER CMeasureNet::GetNetStatsValue(NET net)
|
||||
{
|
||||
LARGE_INTEGER value;
|
||||
value.QuadPart = 0;
|
||||
|
||||
if (m_Interface == 0)
|
||||
{
|
||||
// Get all interfaces
|
||||
for(int i = 0; i < c_StatValues.size() / 2; i++)
|
||||
{
|
||||
switch (net)
|
||||
{
|
||||
case NET_IN:
|
||||
value.QuadPart += c_StatValues[i * 2 + 0].QuadPart;
|
||||
break;
|
||||
|
||||
case NET_OUT:
|
||||
value.QuadPart += c_StatValues[i * 2 + 1].QuadPart;
|
||||
break;
|
||||
|
||||
case NET_TOTAL:
|
||||
value.QuadPart += c_StatValues[i * 2 + 0].QuadPart;
|
||||
value.QuadPart += c_StatValues[i * 2 + 1].QuadPart;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Get the selected interface
|
||||
if (m_Interface <= c_StatValues.size() / 2)
|
||||
{
|
||||
switch (net)
|
||||
{
|
||||
case NET_IN:
|
||||
value.QuadPart += c_StatValues[m_Interface * 2 + 0].QuadPart;
|
||||
break;
|
||||
|
||||
case NET_OUT:
|
||||
value.QuadPart += c_StatValues[m_Interface * 2 + 1].QuadPart;
|
||||
break;
|
||||
|
||||
case NET_TOTAL:
|
||||
value.QuadPart += c_StatValues[m_Interface * 2 + 0].QuadPart;
|
||||
value.QuadPart += c_StatValues[m_Interface * 2 + 1].QuadPart;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Reads the measure specific configs. This is the same for in, out and total.
|
||||
** the net-parameter informs which inherited class called this method.
|
||||
**
|
||||
*/
|
||||
void CMeasureNet::ReadConfig(CConfigParser& parser, const WCHAR* section, NET net)
|
||||
{
|
||||
double value;
|
||||
const WCHAR* netName = NULL;
|
||||
|
||||
if (net == NET_IN)
|
||||
{
|
||||
netName = L"NetInSpeed";
|
||||
value = CRainmeter::GetGlobalConfig().netInSpeed;
|
||||
}
|
||||
else if (net == NET_OUT)
|
||||
{
|
||||
netName = L"NetOutSpeed";
|
||||
value = CRainmeter::GetGlobalConfig().netOutSpeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
netName = L"NetTotalSpeed";
|
||||
value = CRainmeter::GetGlobalConfig().netInSpeed + CRainmeter::GetGlobalConfig().netOutSpeed;
|
||||
}
|
||||
|
||||
double maxValue = parser.ReadFloat(section, L"MaxValue", -1);
|
||||
if (maxValue == -1)
|
||||
{
|
||||
maxValue = parser.ReadFloat(section, netName, -1);
|
||||
if (maxValue == -1)
|
||||
{
|
||||
maxValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
m_Interface = parser.ReadInt(section, L"Interface", 0);
|
||||
m_Cumulative = 0!=parser.ReadInt(section, L"Cumulative", 0);
|
||||
|
||||
m_TrafficValue = parser.ReadFloat(section, L"TrafficValue", 0.0);
|
||||
m_TrafficAction = parser.ReadString(section, L"TrafficAction", L"");
|
||||
|
||||
if (maxValue == 0)
|
||||
{
|
||||
m_MaxValue = 1;
|
||||
m_LogMaxValue = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_MaxValue = maxValue / 8;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** UpdateStats
|
||||
**
|
||||
** Updates the statistics.
|
||||
**
|
||||
*/
|
||||
void CMeasureNet::UpdateStats()
|
||||
{
|
||||
if (c_Table)
|
||||
{
|
||||
// Fill the vectors
|
||||
while (c_StatValues.size() < c_Table->dwNumEntries * 2)
|
||||
{
|
||||
LARGE_INTEGER value;
|
||||
value.QuadPart = 0;
|
||||
c_StatValues.push_back(value);
|
||||
}
|
||||
|
||||
while (c_OldStatValues.size() < c_Table->dwNumEntries * 2)
|
||||
{
|
||||
c_OldStatValues.push_back(0);
|
||||
}
|
||||
|
||||
for (UINT i = 0; i < c_Table->dwNumEntries; i++)
|
||||
{
|
||||
DWORD in, out;
|
||||
|
||||
in = c_Table->table[i].dwInOctets;
|
||||
out = c_Table->table[i].dwOutOctets;
|
||||
|
||||
if (c_OldStatValues[i * 2 + 0] != 0 && c_OldStatValues[i * 2 + 1] != 0)
|
||||
{
|
||||
if (in > c_OldStatValues[i * 2 + 0])
|
||||
{
|
||||
c_StatValues[i * 2 + 0].QuadPart += in - c_OldStatValues[i * 2 + 0];
|
||||
}
|
||||
if (out > c_OldStatValues[i * 2 + 1])
|
||||
{
|
||||
c_StatValues[i * 2 + 1].QuadPart += out - c_OldStatValues[i * 2 + 1];
|
||||
}
|
||||
}
|
||||
|
||||
c_OldStatValues[i * 2 + 0] = in;
|
||||
c_OldStatValues[i * 2 + 1] = out;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** ResetStats
|
||||
**
|
||||
** Resets the statistics.
|
||||
**
|
||||
*/
|
||||
void CMeasureNet::ResetStats()
|
||||
{
|
||||
if (c_Table)
|
||||
{
|
||||
for (int i = 0; i < c_StatValues.size(); i++)
|
||||
{
|
||||
LARGE_INTEGER value;
|
||||
value.QuadPart = 0;
|
||||
c_StatValues[i] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadStats
|
||||
**
|
||||
** Reads statistics.
|
||||
**
|
||||
*/
|
||||
void CMeasureNet::ReadStats(const std::wstring& iniFile)
|
||||
{
|
||||
WCHAR buffer[256];
|
||||
int count = GetPrivateProfileInt(L"Statistics", L"NetStatsCount", 0, iniFile.c_str());
|
||||
|
||||
c_StatValues.clear();
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
LARGE_INTEGER value;
|
||||
|
||||
wsprintf(buffer, L"NetStatsInHigh%i", i + 1);
|
||||
value.HighPart = (DWORD)GetPrivateProfileInt(L"Statistics", buffer, 0, iniFile.c_str());
|
||||
wsprintf(buffer, L"NetStatsInLow%i", i + 1);
|
||||
value.LowPart = (DWORD)GetPrivateProfileInt(L"Statistics", buffer, 0, iniFile.c_str());
|
||||
c_StatValues.push_back(value);
|
||||
|
||||
wsprintf(buffer, L"NetStatsOutHigh%i", i + 1);
|
||||
value.HighPart = (DWORD)GetPrivateProfileInt(L"Statistics", buffer, 0, iniFile.c_str());
|
||||
wsprintf(buffer, L"NetStatsOutLow%i", i + 1);
|
||||
value.LowPart = (DWORD)GetPrivateProfileInt(L"Statistics", buffer, 0, iniFile.c_str());
|
||||
c_StatValues.push_back(value);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** WriteStats
|
||||
**
|
||||
** Writes statistics.
|
||||
**
|
||||
*/
|
||||
void CMeasureNet::WriteStats(const std::wstring& iniFile)
|
||||
{
|
||||
WCHAR buffer[256];
|
||||
WCHAR buffer2[256];
|
||||
|
||||
wsprintf(buffer, L"%i", c_StatValues.size() / 2);
|
||||
WritePrivateProfileString(L"Statistics", L"NetStatsCount", buffer, iniFile.c_str());
|
||||
|
||||
for (int i = 0; i < c_StatValues.size() / 2; i++)
|
||||
{
|
||||
wsprintf(buffer2, L"NetStatsInHigh%i", i + 1);
|
||||
wsprintf(buffer, L"%u", c_StatValues[i * 2].HighPart);
|
||||
WritePrivateProfileString(L"Statistics", buffer2, buffer, iniFile.c_str());
|
||||
|
||||
wsprintf(buffer2, L"NetStatsInLow%i", i + 1);
|
||||
wsprintf(buffer, L"%u", c_StatValues[i * 2].LowPart);
|
||||
WritePrivateProfileString(L"Statistics", buffer2, buffer, iniFile.c_str());
|
||||
|
||||
wsprintf(buffer2, L"NetStatsOutHigh%i", i + 1);
|
||||
wsprintf(buffer, L"%u", c_StatValues[i * 2 + 1].HighPart);
|
||||
WritePrivateProfileString(L"Statistics", buffer2, buffer, iniFile.c_str());
|
||||
|
||||
wsprintf(buffer2, L"NetStatsOutLow%i", i + 1);
|
||||
wsprintf(buffer, L"%u", c_StatValues[i * 2 + 1].LowPart);
|
||||
WritePrivateProfileString(L"Statistics", buffer2, buffer, iniFile.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
96
Library/MeasureNet.h
Normal file
96
Library/MeasureNet.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureNet.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureNet.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.8 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.7 2003/02/10 18:13:34 rainy
|
||||
Changed the way stats are gathered.
|
||||
|
||||
Revision 1.6 2002/12/23 14:26:07 rainy
|
||||
Added cumulative statistics measuring.
|
||||
|
||||
Revision 1.5 2002/07/01 15:34:23 rainy
|
||||
Now it is possible to select the NIC.
|
||||
|
||||
Revision 1.4 2002/04/26 18:24:16 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.3 2002/04/01 15:38:25 rainy
|
||||
Some on the implementation from NetIn/Out is moved here.
|
||||
Added TrafficAction and TrafficValue.
|
||||
|
||||
Revision 1.2 2001/08/12 15:45:34 Rainy
|
||||
Changed UpdateTable() to be a class method.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __MEASURENET_H__
|
||||
#define __MEASURENET_H__
|
||||
|
||||
#include "Measure.h"
|
||||
#include <Iphlpapi.h>
|
||||
|
||||
class CMeasureNet : public CMeasure
|
||||
{
|
||||
public:
|
||||
enum NET {
|
||||
NET_IN,
|
||||
NET_OUT,
|
||||
NET_TOTAL
|
||||
};
|
||||
|
||||
CMeasureNet(CMeterWindow* meterWindow);
|
||||
virtual ~CMeasureNet();
|
||||
|
||||
virtual bool Update();
|
||||
|
||||
static void UpdateIFTable();
|
||||
|
||||
static void UpdateStats();
|
||||
static void ResetStats();
|
||||
static void ReadStats(const std::wstring& iniFile);
|
||||
static void WriteStats(const std::wstring& iniFile);
|
||||
|
||||
protected:
|
||||
void ReadConfig(CConfigParser& parser, const WCHAR* section, CMeasureNet::NET net);
|
||||
DWORD GetNetOctets(NET net);
|
||||
LARGE_INTEGER GetNetStatsValue(NET net);
|
||||
|
||||
double m_CurrentTraffic;
|
||||
double m_TrafficValue;
|
||||
UINT m_Interface;
|
||||
bool m_Cumulative;
|
||||
std::wstring m_TrafficAction;
|
||||
|
||||
static std::vector<DWORD> c_OldStatValues;
|
||||
static std::vector<LARGE_INTEGER> c_StatValues;
|
||||
static MIB_IFTABLE* c_Table;
|
||||
static UINT c_NumOfTables;
|
||||
};
|
||||
|
||||
#endif
|
||||
160
Library/MeasureNetIn.cpp
Normal file
160
Library/MeasureNetIn.cpp
Normal file
@@ -0,0 +1,160 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureNetIn.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureNetIn.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.16 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.15 2003/12/05 15:50:10 Rainy
|
||||
Multi-instance changes.
|
||||
|
||||
Revision 1.14 2003/02/10 18:13:34 rainy
|
||||
Changed the way stats are gathered.
|
||||
|
||||
Revision 1.13 2002/12/23 14:26:07 rainy
|
||||
Added cumulative statistics measuring.
|
||||
|
||||
Revision 1.12 2002/07/01 15:34:39 rainy
|
||||
The measuring is done in the base class.
|
||||
|
||||
Revision 1.11 2002/04/26 18:24:16 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.10 2002/04/01 15:37:25 rainy
|
||||
Moved part of the implementation to the base class.
|
||||
|
||||
Revision 1.9 2002/03/31 09:58:54 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.8 2001/12/23 10:17:56 rainy
|
||||
The firstTime is now a member variable.
|
||||
|
||||
Revision 1.7 2001/10/28 10:21:58 rainy
|
||||
Changes in the GetStat()
|
||||
|
||||
Revision 1.6 2001/10/14 07:29:39 rainy
|
||||
Minor monifications to remove few warnings with VC.NET
|
||||
|
||||
Revision 1.5 2001/09/26 16:27:15 rainy
|
||||
Changed the interfaces a bit.
|
||||
|
||||
Revision 1.4 2001/09/01 13:00:10 rainy
|
||||
Slight changes in the interface. The value is now measured only once if possible.
|
||||
|
||||
Revision 1.3 2001/08/19 09:14:55 rainy
|
||||
Added support for value invert.
|
||||
Also the CMeasure's ReadConfig is executed.
|
||||
|
||||
Revision 1.2 2001/08/12 15:44:49 Rainy
|
||||
Adjusted Update()'s interface.
|
||||
Net throughput is now measured in bytes per second and not bits.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeasureNetIn.h"
|
||||
|
||||
/*
|
||||
** CMeasureNet
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeasureNetIn::CMeasureNetIn(CMeterWindow* meterWindow) : CMeasureNet(meterWindow)
|
||||
{
|
||||
m_FirstTime = true;
|
||||
m_InOctets = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeasureNet
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeasureNetIn::~CMeasureNetIn()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the current net in value.
|
||||
**
|
||||
*/
|
||||
bool CMeasureNetIn::Update()
|
||||
{
|
||||
if (!CMeasureNet::PreUpdate()) return false;
|
||||
|
||||
if(c_Table == NULL) return false;
|
||||
|
||||
if (m_Cumulative)
|
||||
{
|
||||
m_Value = (double)GetNetStatsValue(NET_IN).QuadPart;
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD value = 0;
|
||||
|
||||
if (!m_FirstTime)
|
||||
{
|
||||
value = GetNetOctets(NET_IN);
|
||||
if (value > m_InOctets)
|
||||
{
|
||||
DWORD tmpValue = value;
|
||||
value -= m_InOctets;
|
||||
m_InOctets = tmpValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_InOctets = value;
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_InOctets = GetNetOctets(NET_IN);
|
||||
m_FirstTime = false;
|
||||
}
|
||||
|
||||
m_Value = value;
|
||||
}
|
||||
|
||||
return PostUpdate();
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Reads the measure specific configs.
|
||||
**
|
||||
*/
|
||||
void CMeasureNetIn::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
CMeasure::ReadConfig(parser, section);
|
||||
CMeasureNet::ReadConfig(parser, section, NET_IN);
|
||||
}
|
||||
|
||||
77
Library/MeasureNetIn.h
Normal file
77
Library/MeasureNetIn.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureNetIn.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureNetIn.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.10 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.9 2003/02/10 18:13:34 rainy
|
||||
Changed the way stats are gathered.
|
||||
|
||||
Revision 1.8 2002/12/23 14:26:07 rainy
|
||||
Added cumulative statistics measuring.
|
||||
|
||||
Revision 1.7 2002/04/26 18:24:16 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.6 2002/04/01 15:37:25 rainy
|
||||
Moved part of the implementation to the base class.
|
||||
|
||||
Revision 1.5 2001/12/23 10:17:56 rainy
|
||||
The firstTime is now a member variable.
|
||||
|
||||
Revision 1.4 2001/09/26 16:27:15 rainy
|
||||
Changed the interfaces a bit.
|
||||
|
||||
Revision 1.3 2001/09/01 13:00:10 rainy
|
||||
Slight changes in the interface. The value is now measured only once if possible.
|
||||
|
||||
Revision 1.2 2001/08/12 15:44:49 Rainy
|
||||
Adjusted Update()'s interface.
|
||||
Net throughput is now measured in bytes per second and not bits.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __METERNET_H__
|
||||
#define __METERNET_H__
|
||||
|
||||
#include "MeasureNet.h"
|
||||
|
||||
class CMeasureNetIn : public CMeasureNet
|
||||
{
|
||||
public:
|
||||
CMeasureNetIn(CMeterWindow* meterWindow);
|
||||
virtual ~CMeasureNetIn();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual bool Update();
|
||||
|
||||
private:
|
||||
bool m_FirstTime;
|
||||
DWORD m_InOctets;
|
||||
};
|
||||
|
||||
#endif
|
||||
159
Library/MeasureNetOut.cpp
Normal file
159
Library/MeasureNetOut.cpp
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureNetOut.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureNetOut.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.16 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.15 2003/12/05 15:50:10 Rainy
|
||||
Multi-instance changes.
|
||||
|
||||
Revision 1.14 2003/02/10 18:13:34 rainy
|
||||
Changed the way stats are gathered.
|
||||
|
||||
Revision 1.13 2002/12/23 14:26:07 rainy
|
||||
Added cumulative statistics measuring.
|
||||
|
||||
Revision 1.12 2002/07/01 15:34:39 rainy
|
||||
The measuring is done in the base class.
|
||||
|
||||
Revision 1.11 2002/04/26 18:24:16 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.10 2002/04/01 15:37:25 rainy
|
||||
Moved part of the implementation to the base class.
|
||||
|
||||
Revision 1.9 2002/03/31 09:58:54 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.8 2001/12/23 10:17:56 rainy
|
||||
The firstTime is now a member variable.
|
||||
|
||||
Revision 1.7 2001/10/28 10:21:58 rainy
|
||||
Changes in the GetStat()
|
||||
|
||||
Revision 1.6 2001/10/14 07:29:39 rainy
|
||||
Minor monifications to remove few warnings with VC.NET
|
||||
|
||||
Revision 1.5 2001/09/26 16:27:14 rainy
|
||||
Changed the interfaces a bit.
|
||||
|
||||
Revision 1.4 2001/09/01 13:00:10 rainy
|
||||
Slight changes in the interface. The value is now measured only once if possible.
|
||||
|
||||
Revision 1.3 2001/08/19 09:14:55 rainy
|
||||
Added support for value invert.
|
||||
Also the CMeasure's ReadConfig is executed.
|
||||
|
||||
Revision 1.2 2001/08/12 15:44:49 Rainy
|
||||
Adjusted Update()'s interface.
|
||||
Net throughput is now measured in bytes per second and not bits.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeasureNetOut.h"
|
||||
|
||||
/*
|
||||
** CMeasureNetOut
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeasureNetOut::CMeasureNetOut(CMeterWindow* meterWindow) : CMeasureNet(meterWindow)
|
||||
{
|
||||
m_FirstTime = true;
|
||||
m_OutOctets = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeasureNetOut
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeasureNetOut::~CMeasureNetOut()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the current net out value.
|
||||
**
|
||||
*/
|
||||
bool CMeasureNetOut::Update()
|
||||
{
|
||||
if (!CMeasureNet::PreUpdate()) return false;
|
||||
|
||||
if(c_Table == NULL) return false;
|
||||
|
||||
if (m_Cumulative)
|
||||
{
|
||||
m_Value = (double)GetNetStatsValue(NET_OUT).QuadPart;
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD value = 0;
|
||||
|
||||
if (!m_FirstTime)
|
||||
{
|
||||
value = GetNetOctets(NET_OUT);
|
||||
if (value > m_OutOctets)
|
||||
{
|
||||
DWORD tmpValue = value;
|
||||
value -= m_OutOctets;
|
||||
m_OutOctets = tmpValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_OutOctets = value;
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_OutOctets = GetNetOctets(NET_OUT);
|
||||
m_FirstTime = false;
|
||||
}
|
||||
|
||||
m_Value = value;
|
||||
}
|
||||
|
||||
return PostUpdate();
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Reads the measure specific configs.
|
||||
**
|
||||
*/
|
||||
void CMeasureNetOut::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
CMeasure::ReadConfig(parser, section);
|
||||
CMeasureNet::ReadConfig(parser, section, NET_OUT);
|
||||
}
|
||||
77
Library/MeasureNetOut.h
Normal file
77
Library/MeasureNetOut.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureNetOut.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureNetOut.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.10 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.9 2003/02/10 18:13:34 rainy
|
||||
Changed the way stats are gathered.
|
||||
|
||||
Revision 1.8 2002/12/23 14:26:07 rainy
|
||||
Added cumulative statistics measuring.
|
||||
|
||||
Revision 1.7 2002/04/26 18:24:15 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.6 2002/04/01 15:37:25 rainy
|
||||
Moved part of the implementation to the base class.
|
||||
|
||||
Revision 1.5 2001/12/23 10:17:56 rainy
|
||||
The firstTime is now a member variable.
|
||||
|
||||
Revision 1.4 2001/09/26 16:27:14 rainy
|
||||
Changed the interfaces a bit.
|
||||
|
||||
Revision 1.3 2001/09/01 13:00:09 rainy
|
||||
Slight changes in the interface. The value is now measured only once if possible.
|
||||
|
||||
Revision 1.2 2001/08/12 15:44:49 Rainy
|
||||
Adjusted Update()'s interface.
|
||||
Net throughput is now measured in bytes per second and not bits.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __METERNETOUT_H__
|
||||
#define __METERNETOUT_H__
|
||||
|
||||
#include "MeasureNet.h"
|
||||
|
||||
class CMeasureNetOut : public CMeasureNet
|
||||
{
|
||||
public:
|
||||
CMeasureNetOut(CMeterWindow* meterWindow);
|
||||
virtual ~CMeasureNetOut();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual bool Update();
|
||||
|
||||
private:
|
||||
bool m_FirstTime;
|
||||
DWORD m_OutOctets;
|
||||
};
|
||||
|
||||
#endif
|
||||
131
Library/MeasureNetTotal.cpp
Normal file
131
Library/MeasureNetTotal.cpp
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureNetTotal.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureNetTotal.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.7 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.6 2003/12/05 15:50:10 Rainy
|
||||
Multi-instance changes.
|
||||
|
||||
Revision 1.5 2003/02/10 18:13:34 rainy
|
||||
Changed the way stats are gathered.
|
||||
|
||||
Revision 1.4 2002/12/23 14:26:07 rainy
|
||||
Added cumulative statistics measuring.
|
||||
|
||||
Revision 1.3 2002/07/01 15:34:38 rainy
|
||||
The measuring is done in the base class.
|
||||
|
||||
Revision 1.2 2002/04/26 18:24:15 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.1 2002/04/01 15:35:27 rainy
|
||||
Initial version.
|
||||
|
||||
|
||||
*/
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeasureNetTotal.h"
|
||||
|
||||
/*
|
||||
** CMeasureNetTotal
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeasureNetTotal::CMeasureNetTotal(CMeterWindow* meterWindow) : CMeasureNet(meterWindow)
|
||||
{
|
||||
m_FirstTime = true;
|
||||
m_TotalOctets = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeasureNetTotal
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeasureNetTotal::~CMeasureNetTotal()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the current net total value.
|
||||
**
|
||||
*/
|
||||
bool CMeasureNetTotal::Update()
|
||||
{
|
||||
if (!CMeasureNet::PreUpdate()) return false;
|
||||
|
||||
if(c_Table == NULL) return false;
|
||||
|
||||
if (m_Cumulative)
|
||||
{
|
||||
m_Value = (double)GetNetStatsValue(NET_TOTAL).QuadPart;
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD value = 0;
|
||||
|
||||
if (!m_FirstTime)
|
||||
{
|
||||
value = GetNetOctets(NET_TOTAL);
|
||||
if (value > m_TotalOctets)
|
||||
{
|
||||
DWORD tmpValue = value;
|
||||
value -= m_TotalOctets;
|
||||
m_TotalOctets = tmpValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_TotalOctets = value;
|
||||
value = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_TotalOctets = GetNetOctets(NET_TOTAL);
|
||||
m_FirstTime = false;
|
||||
}
|
||||
|
||||
m_Value = value;
|
||||
}
|
||||
|
||||
return PostUpdate();
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Reads the measure specific configs.
|
||||
**
|
||||
*/
|
||||
void CMeasureNetTotal::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
CMeasure::ReadConfig(parser, section);
|
||||
CMeasureNet::ReadConfig(parser, section, NET_TOTAL);
|
||||
}
|
||||
62
Library/MeasureNetTotal.h
Normal file
62
Library/MeasureNetTotal.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureNetTotal.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureNetTotal.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.5 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.4 2003/02/10 18:13:34 rainy
|
||||
Changed the way stats are gathered.
|
||||
|
||||
Revision 1.3 2002/12/23 14:26:06 rainy
|
||||
Added cumulative statistics measuring.
|
||||
|
||||
Revision 1.2 2002/04/26 18:24:15 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.1 2002/04/01 15:35:27 rainy
|
||||
Initial version.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __METERNETTOTAL_H__
|
||||
#define __METERNETTOTAL_H__
|
||||
|
||||
#include "MeasureNet.h"
|
||||
|
||||
class CMeasureNetTotal : public CMeasureNet
|
||||
{
|
||||
public:
|
||||
CMeasureNetTotal(CMeterWindow* meterWindow);
|
||||
virtual ~CMeasureNetTotal();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual bool Update();
|
||||
|
||||
private:
|
||||
bool m_FirstTime;
|
||||
DWORD m_TotalOctets;
|
||||
};
|
||||
|
||||
#endif
|
||||
117
Library/MeasurePhysicalMemory.cpp
Normal file
117
Library/MeasurePhysicalMemory.cpp
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasurePhysicalMemory.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasurePhysicalMemory.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.8 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.7 2002/04/26 18:24:15 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.6 2002/03/31 09:58:54 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.5 2001/09/26 16:27:14 rainy
|
||||
Changed the interfaces a bit.
|
||||
|
||||
Revision 1.4 2001/09/01 13:00:09 rainy
|
||||
Slight changes in the interface. The value is now measured only once if possible.
|
||||
|
||||
Revision 1.3 2001/08/19 09:14:20 rainy
|
||||
Added support for value invert.
|
||||
|
||||
Revision 1.2 2001/08/12 15:43:32 Rainy
|
||||
Adjusted Update()'s interface.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeasurePhysicalMemory.h"
|
||||
|
||||
/*
|
||||
** CMeasurePhysicalMemory
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeasurePhysicalMemory::CMeasurePhysicalMemory(CMeterWindow* meterWindow) : CMeasure(meterWindow)
|
||||
{
|
||||
m_Total = false;
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeasurePhysicalMemory
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeasurePhysicalMemory::~CMeasurePhysicalMemory()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the current physical memory value.
|
||||
**
|
||||
*/
|
||||
bool CMeasurePhysicalMemory::Update()
|
||||
{
|
||||
if (!CMeasure::PreUpdate()) return false;
|
||||
|
||||
MEMORYSTATUSEX stat;
|
||||
stat.dwLength = sizeof(MEMORYSTATUSEX);
|
||||
GlobalMemoryStatusEx(&stat);
|
||||
if (m_Total)
|
||||
{
|
||||
m_Value = (double)(__int64)stat.ullTotalPhys;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Value = (double)(__int64)(stat.ullTotalPhys - stat.ullAvailPhys);
|
||||
}
|
||||
|
||||
return PostUpdate();
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Reads the measure specific configs.
|
||||
**
|
||||
*/
|
||||
void CMeasurePhysicalMemory::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
CMeasure::ReadConfig(parser, section);
|
||||
|
||||
m_Total = (1 == parser.ReadInt(section, L"Total", 0));
|
||||
|
||||
MEMORYSTATUSEX stat;
|
||||
stat.dwLength = sizeof(MEMORYSTATUSEX);
|
||||
GlobalMemoryStatusEx(&stat);
|
||||
m_MaxValue = (double)(__int64)stat.ullTotalPhys;
|
||||
}
|
||||
|
||||
63
Library/MeasurePhysicalMemory.h
Normal file
63
Library/MeasurePhysicalMemory.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasurePhysicalMemory.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasurePhysicalMemory.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.6 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.5 2002/04/26 18:24:15 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.4 2001/09/26 16:27:14 rainy
|
||||
Changed the interfaces a bit.
|
||||
|
||||
Revision 1.3 2001/09/01 13:00:09 rainy
|
||||
Slight changes in the interface. The value is now measured only once if possible.
|
||||
|
||||
Revision 1.2 2001/08/12 15:43:31 Rainy
|
||||
Adjusted Update()'s interface.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __MEASUREPHYSICALMEMORY_H__
|
||||
#define __MEASUREPHYSICALMEMORY_H__
|
||||
|
||||
#include "Measure.h"
|
||||
|
||||
class CMeasurePhysicalMemory : public CMeasure
|
||||
{
|
||||
public:
|
||||
CMeasurePhysicalMemory(CMeterWindow* meterWindow);
|
||||
virtual ~CMeasurePhysicalMemory();
|
||||
|
||||
virtual bool Update();
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
bool m_Total;
|
||||
};
|
||||
|
||||
#endif
|
||||
241
Library/MeasurePlugin.cpp
Normal file
241
Library/MeasurePlugin.cpp
Normal file
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasurePlugin.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasurePlugin.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.7 2004/07/11 17:15:14 rainy
|
||||
no message
|
||||
|
||||
Revision 1.6 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.5 2002/07/01 15:34:57 rainy
|
||||
Added GetStringValue.
|
||||
|
||||
Revision 1.4 2002/04/26 18:24:15 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.3 2002/03/31 09:58:54 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.2 2001/12/23 10:17:02 rainy
|
||||
The plugins get unique ID automatically.
|
||||
The plugins are also loaded from the Rainmeter's folder.
|
||||
|
||||
Revision 1.1 2001/10/28 09:07:19 rainy
|
||||
Inital version
|
||||
|
||||
*/
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeasurePlugin.h"
|
||||
#include "Rainmeter.h"
|
||||
#include "Error.h"
|
||||
|
||||
extern CRainmeter* Rainmeter;
|
||||
|
||||
/*
|
||||
** CMeasureMemory
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeasurePlugin::CMeasurePlugin(CMeterWindow* meterWindow) : CMeasure(meterWindow)
|
||||
{
|
||||
m_Plugin = NULL;
|
||||
m_ID = 0;
|
||||
m_MaxValue = 0;
|
||||
|
||||
InitializeFunc = NULL;
|
||||
UpdateFunc = NULL;
|
||||
UpdateFunc2 = NULL;
|
||||
FinalizeFunc = NULL;
|
||||
GetStringFunc = NULL;
|
||||
ExecuteBangFunc = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeasureMemory
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeasurePlugin::~CMeasurePlugin()
|
||||
{
|
||||
if (m_Plugin)
|
||||
{
|
||||
if(FinalizeFunc) FinalizeFunc(m_Plugin, m_ID);
|
||||
FreeLibrary(m_Plugin);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Gets the current value from the plugin
|
||||
**
|
||||
*/
|
||||
bool CMeasurePlugin::Update()
|
||||
{
|
||||
if (!CMeasure::PreUpdate()) return false;
|
||||
|
||||
WCHAR buffer[MAX_PATH];
|
||||
GetCurrentDirectory(MAX_PATH, buffer);
|
||||
|
||||
SetCurrentDirectory(Rainmeter->FixPath(L"", PATH_FOLDER_CURRENT_SKIN, m_MeterWindow->GetSkinName()).c_str());
|
||||
|
||||
if(UpdateFunc)
|
||||
{
|
||||
// Update the plugin
|
||||
m_Value = UpdateFunc(m_ID);
|
||||
}
|
||||
else if(UpdateFunc2)
|
||||
{
|
||||
// Update the plugin
|
||||
m_Value = UpdateFunc2(m_ID);
|
||||
}
|
||||
|
||||
SetCurrentDirectory(buffer);
|
||||
|
||||
return PostUpdate();
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Reads the configs and loads & initializes the plugin
|
||||
**
|
||||
*/
|
||||
void CMeasurePlugin::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
static UINT id = 1;
|
||||
|
||||
CMeasure::ReadConfig(parser, section);
|
||||
|
||||
m_PluginName = parser.ReadString(section, L"Plugin", L"");
|
||||
|
||||
size_t pos = m_PluginName.rfind(L".");
|
||||
if (pos == std::wstring::npos)
|
||||
{
|
||||
m_PluginName += L".dll";
|
||||
}
|
||||
|
||||
pos = m_PluginName.rfind(L'\\');
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
m_PluginName = L"..\\" + m_PluginName;
|
||||
}
|
||||
m_PluginName = Rainmeter->FixPath(m_PluginName, PATH_FOLDER_PLUGIN, L"");
|
||||
|
||||
m_Plugin = LoadLibrary(m_PluginName.c_str());
|
||||
|
||||
if(m_Plugin == NULL)
|
||||
{
|
||||
// Try to load from Rainmeter's folder
|
||||
pos = m_PluginName.rfind(L'\\');
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
std::wstring pluginName = Rainmeter->GetPath() + m_PluginName.substr(pos + 1);
|
||||
m_Plugin = LoadLibrary(pluginName.c_str());
|
||||
}
|
||||
|
||||
if (m_Plugin == NULL)
|
||||
{
|
||||
throw CError(std::wstring(L"Rainmeter plugin ") + m_PluginName + L" not found!", __LINE__, __FILE__);
|
||||
}
|
||||
}
|
||||
|
||||
InitializeFunc = (INITIALIZE)GetProcAddress(m_Plugin, "Initialize");
|
||||
FinalizeFunc = (FINALIZE)GetProcAddress(m_Plugin, "Finalize");
|
||||
UpdateFunc = (UPDATE)GetProcAddress(m_Plugin, "Update");
|
||||
UpdateFunc2 = (UPDATE2)GetProcAddress(m_Plugin, "Update2");
|
||||
GetStringFunc = (GETSTRING)GetProcAddress(m_Plugin, "GetString");
|
||||
ExecuteBangFunc = (EXECUTEBANG)GetProcAddress(m_Plugin, "ExecuteBang");
|
||||
|
||||
if (UpdateFunc == NULL && UpdateFunc2 == NULL && GetStringFunc == NULL)
|
||||
{
|
||||
FreeLibrary(m_Plugin);
|
||||
throw CError(std::wstring(L"Rainmeter plugin ") + m_PluginName + L" doesn't export Update or GetString function!", __LINE__, __FILE__);
|
||||
}
|
||||
|
||||
// Initialize the plugin
|
||||
m_ID = id++;
|
||||
if(InitializeFunc)
|
||||
{
|
||||
WCHAR buffer[MAX_PATH];
|
||||
GetCurrentDirectory(MAX_PATH, buffer);
|
||||
|
||||
SetCurrentDirectory(Rainmeter->FixPath(L"", PATH_FOLDER_CURRENT_SKIN, m_MeterWindow->GetSkinName()).c_str());
|
||||
|
||||
double maxValue;
|
||||
maxValue = InitializeFunc(m_Plugin, parser.GetFilename().c_str(), section, m_ID);
|
||||
|
||||
SetCurrentDirectory(buffer);
|
||||
|
||||
std::wstring szMaxValue = parser.ReadString(section, L"MaxValue", L"NotSet");
|
||||
if (szMaxValue == L"NotSet")
|
||||
{
|
||||
m_MaxValue = maxValue;
|
||||
}
|
||||
}
|
||||
|
||||
if(m_MaxValue == 0)
|
||||
{
|
||||
m_MaxValue = 1;
|
||||
m_LogMaxValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** GetStringValue
|
||||
**
|
||||
** Gets the string value from the plugin.
|
||||
**
|
||||
*/
|
||||
const WCHAR* CMeasurePlugin::GetStringValue(bool autoScale, double scale, int decimals, bool percentual)
|
||||
{
|
||||
if(GetStringFunc)
|
||||
{
|
||||
const WCHAR* ret = GetStringFunc(m_ID, 0);
|
||||
if (ret) return CheckSubstitute(ret);
|
||||
}
|
||||
|
||||
return CMeasure::GetStringValue(autoScale, scale, decimals, percentual);
|
||||
}
|
||||
|
||||
/*
|
||||
** ExecuteBang
|
||||
**
|
||||
** Sends a bang to the plugin
|
||||
**
|
||||
*/
|
||||
void CMeasurePlugin::ExecuteBang(const WCHAR* args)
|
||||
{
|
||||
if (ExecuteBangFunc)
|
||||
{
|
||||
ExecuteBangFunc(args, m_ID);
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugLog(L"[%s] Doesn't support bangs.", m_Name.c_str());
|
||||
}
|
||||
}
|
||||
79
Library/MeasurePlugin.h
Normal file
79
Library/MeasurePlugin.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasurePlugin.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasurePlugin.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.5 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.4 2002/07/01 15:34:57 rainy
|
||||
Added GetStringValue.
|
||||
|
||||
Revision 1.3 2002/04/26 18:24:15 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.2 2001/12/23 10:17:02 rainy
|
||||
The plugins get unique ID automatically.
|
||||
The plugins are also loaded from the Rainmeter's folder.
|
||||
|
||||
Revision 1.1 2001/10/28 09:07:19 rainy
|
||||
Inital version
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __MEASUREPLUGIN_H__
|
||||
#define __MEASUREPLUGIN_H__
|
||||
|
||||
#include "Measure.h"
|
||||
|
||||
typedef UINT (*INITIALIZE)(HMODULE, LPCTSTR, LPCTSTR, UINT);
|
||||
typedef VOID (*FINALIZE)(HMODULE, UINT);
|
||||
typedef UINT (*UPDATE)(UINT);
|
||||
typedef double (*UPDATE2)(UINT);
|
||||
typedef LPCTSTR (*GETSTRING)(UINT, UINT);
|
||||
typedef void (*EXECUTEBANG)(LPCTSTR, UINT);
|
||||
|
||||
class CMeasurePlugin : public CMeasure
|
||||
{
|
||||
public:
|
||||
CMeasurePlugin(CMeterWindow* meterWindow);
|
||||
virtual ~CMeasurePlugin();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual bool Update();
|
||||
virtual const WCHAR* GetStringValue(bool autoScale, double scale, int decimals, bool percentual);
|
||||
virtual void ExecuteBang(const WCHAR* args);
|
||||
|
||||
private:
|
||||
std::wstring m_PluginName;
|
||||
HMODULE m_Plugin;
|
||||
UINT m_ID;
|
||||
|
||||
INITIALIZE InitializeFunc;
|
||||
FINALIZE FinalizeFunc;
|
||||
UPDATE UpdateFunc;
|
||||
UPDATE2 UpdateFunc2;
|
||||
GETSTRING GetStringFunc;
|
||||
EXECUTEBANG ExecuteBangFunc;
|
||||
};
|
||||
|
||||
#endif
|
||||
201
Library/MeasureRegistry.cpp
Normal file
201
Library/MeasureRegistry.cpp
Normal file
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureRegistry.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureRegistry.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.6 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.5 2002/05/04 08:13:06 rainy
|
||||
Added support for multi_sz
|
||||
|
||||
Revision 1.4 2002/04/27 10:28:57 rainy
|
||||
Added possibility to use other HKEYs also.
|
||||
|
||||
Revision 1.3 2002/04/26 18:24:15 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.2 2002/03/31 09:58:54 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.1 2001/10/28 09:07:18 rainy
|
||||
Inital version
|
||||
|
||||
*/
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeasureRegistry.h"
|
||||
#include "Rainmeter.h"
|
||||
#include "Error.h"
|
||||
|
||||
/*
|
||||
** CMeasureRegistry
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeasureRegistry::CMeasureRegistry(CMeterWindow* meterWindow) : CMeasure(meterWindow)
|
||||
{
|
||||
m_RegKey = NULL;
|
||||
m_HKey = NULL;
|
||||
m_MaxValue = 0.0;
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeasureRegistry
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeasureRegistry::~CMeasureRegistry()
|
||||
{
|
||||
if(m_RegKey) RegCloseKey(m_RegKey);
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Gets the current value from the registry
|
||||
**
|
||||
*/
|
||||
bool CMeasureRegistry::Update()
|
||||
{
|
||||
if (!CMeasure::PreUpdate()) return false;
|
||||
|
||||
if(m_RegKey != NULL)
|
||||
{
|
||||
DWORD size = 4096;
|
||||
WCHAR data[4096];
|
||||
DWORD type = 0;
|
||||
|
||||
if(RegQueryValueEx(m_RegKey,
|
||||
m_RegValueName.c_str(),
|
||||
NULL,
|
||||
(LPDWORD)&type,
|
||||
(LPBYTE)&data,
|
||||
(LPDWORD)&size) == ERROR_SUCCESS)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case REG_DWORD:
|
||||
m_Value = *((LPDWORD)&data);
|
||||
m_StringValue.erase();
|
||||
break;
|
||||
|
||||
case REG_SZ:
|
||||
case REG_EXPAND_SZ:
|
||||
case REG_MULTI_SZ:
|
||||
m_Value = 0.0;
|
||||
m_StringValue = data;
|
||||
break;
|
||||
|
||||
case REG_QWORD:
|
||||
m_Value = (double)((LARGE_INTEGER*)&data)->QuadPart;
|
||||
m_StringValue.erase();
|
||||
break;
|
||||
|
||||
default: // Other types are not supported
|
||||
m_Value = 0.0;
|
||||
m_StringValue.erase();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return PostUpdate();
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Reads the measure specific configs.
|
||||
**
|
||||
*/
|
||||
void CMeasureRegistry::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
CMeasure::ReadConfig(parser, section);
|
||||
|
||||
std::wstring keyname;
|
||||
keyname = parser.ReadString(section, L"RegHKey", L"HKEY_CURRENT_USER");
|
||||
|
||||
if(_wcsicmp(keyname.c_str(), L"HKEY_CLASSES_ROOT") == 0)
|
||||
{
|
||||
m_HKey = HKEY_CLASSES_ROOT;
|
||||
}
|
||||
else if(_wcsicmp(keyname.c_str(), L"HKEY_CURRENT_CONFIG") == 0)
|
||||
{
|
||||
m_HKey = HKEY_CURRENT_CONFIG;
|
||||
}
|
||||
else if(_wcsicmp(keyname.c_str(), L"HKEY_CURRENT_USER") == 0)
|
||||
{
|
||||
m_HKey = HKEY_CURRENT_USER;
|
||||
}
|
||||
else if(_wcsicmp(keyname.c_str(), L"HKEY_LOCAL_MACHINE") == 0)
|
||||
{
|
||||
m_HKey = HKEY_LOCAL_MACHINE;
|
||||
}
|
||||
else if(_wcsicmp(keyname.c_str(), L"HKEY_CLASSES_ROOT") == 0)
|
||||
{
|
||||
m_HKey = HKEY_CLASSES_ROOT;
|
||||
}
|
||||
else if(_wcsicmp(keyname.c_str(), L"HKEY_PERFORMANCE_DATA") == 0)
|
||||
{
|
||||
m_HKey = HKEY_PERFORMANCE_DATA;
|
||||
}
|
||||
else if(_wcsicmp(keyname.c_str(), L"HKEY_DYN_DATA") == 0)
|
||||
{
|
||||
m_HKey = HKEY_DYN_DATA;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw CError(std::wstring(L"No such HKEY: ") + keyname, __LINE__, __FILE__);
|
||||
}
|
||||
|
||||
m_RegKeyName = parser.ReadString(section, L"RegKey", L"");
|
||||
m_RegValueName = parser.ReadString(section, L"RegValue", L"");
|
||||
|
||||
if (m_MaxValue == 0.0)
|
||||
{
|
||||
m_MaxValue = 1.0;
|
||||
m_LogMaxValue = true;
|
||||
}
|
||||
|
||||
// Try to open the key
|
||||
RegOpenKeyEx(m_HKey, m_RegKeyName.c_str(), 0, KEY_READ, &m_RegKey);
|
||||
}
|
||||
|
||||
/*
|
||||
** GetStringValue
|
||||
**
|
||||
** If the measured registry value is a string display it. Otherwise convert the
|
||||
** value to string as normal.
|
||||
**
|
||||
*/
|
||||
const WCHAR* CMeasureRegistry::GetStringValue(bool autoScale, double scale, int decimals, bool percentual)
|
||||
{
|
||||
if (m_StringValue.empty())
|
||||
{
|
||||
return CMeasure::GetStringValue(autoScale, scale, decimals, percentual);
|
||||
}
|
||||
|
||||
return CheckSubstitute(m_StringValue.c_str());
|
||||
}
|
||||
|
||||
62
Library/MeasureRegistry.h
Normal file
62
Library/MeasureRegistry.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureRegistry.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureRegistry.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.4 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.3 2002/04/27 10:28:57 rainy
|
||||
Added possibility to use other HKEYs also.
|
||||
|
||||
Revision 1.2 2002/04/26 18:24:15 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.1 2001/10/28 09:07:18 rainy
|
||||
Inital version
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __MEASUREREGISTRY_H__
|
||||
#define __MEASUREREGISTRY_H__
|
||||
|
||||
#include "Measure.h"
|
||||
|
||||
class CMeasureRegistry : public CMeasure
|
||||
{
|
||||
public:
|
||||
CMeasureRegistry(CMeterWindow* meterWindow);
|
||||
virtual ~CMeasureRegistry();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual bool Update();
|
||||
virtual const WCHAR* GetStringValue(bool autoScale, double scale, int decimals, bool percentual);
|
||||
|
||||
private:
|
||||
std::wstring m_RegKeyName;
|
||||
std::wstring m_RegValueName;
|
||||
std::wstring m_StringValue;
|
||||
HKEY m_RegKey;
|
||||
HKEY m_HKey;
|
||||
};
|
||||
|
||||
#endif
|
||||
273
Library/MeasureTime.cpp
Normal file
273
Library/MeasureTime.cpp
Normal file
@@ -0,0 +1,273 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureTime.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureTime.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.7 2004/07/11 17:15:36 rainy
|
||||
Fixed localtime calculation.
|
||||
|
||||
Revision 1.6 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.5 2004/03/13 16:17:42 rainy
|
||||
Added timezones
|
||||
|
||||
Revision 1.4 2003/02/10 18:13:14 rainy
|
||||
Returns the time in secs as value.
|
||||
|
||||
Revision 1.3 2002/04/26 18:24:15 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.2 2002/03/31 09:58:54 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.1 2001/12/23 10:11:08 rainy
|
||||
Initial version.
|
||||
|
||||
*/
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeasureTime.h"
|
||||
#include "Rainmeter.h"
|
||||
#include <time.h>
|
||||
|
||||
int GetYearDay(int year, int month, int day)
|
||||
{
|
||||
int yearDay = 0;
|
||||
UINT dates[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
|
||||
|
||||
for (int i = 0; i < month - 1; i++)
|
||||
{
|
||||
yearDay += dates[i];
|
||||
}
|
||||
|
||||
if (month > 2 && ((((year % 4) == 0) && ((year % 100) != 0)) || (year % 400) == 0))
|
||||
{
|
||||
yearDay++;
|
||||
}
|
||||
|
||||
yearDay += day;
|
||||
|
||||
return yearDay - 1;
|
||||
}
|
||||
|
||||
/*
|
||||
** CMeasureTime
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeasureTime::CMeasureTime(CMeterWindow* meterWindow) : CMeasure(meterWindow)
|
||||
{
|
||||
/* Set time zone from TZ environment variable. If TZ is not set,
|
||||
* the operating system is queried to obtain the default value
|
||||
* for the variable.
|
||||
*/
|
||||
_tzset();
|
||||
|
||||
m_DeltaTime.QuadPart = 0;
|
||||
m_Time.QuadPart = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeasureTime
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeasureTime::~CMeasureTime()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the current time
|
||||
**
|
||||
*/
|
||||
bool CMeasureTime::Update()
|
||||
{
|
||||
if (!CMeasure::PreUpdate()) return false;
|
||||
|
||||
FILETIME ftUTCTime;
|
||||
GetSystemTimeAsFileTime(&ftUTCTime);
|
||||
|
||||
// Modify the ltime to match the current timezone
|
||||
// This way we can use the value also for the clock
|
||||
m_Time.HighPart = ftUTCTime.dwHighDateTime;
|
||||
m_Time.LowPart = ftUTCTime.dwLowDateTime;
|
||||
|
||||
m_Time.QuadPart += m_DeltaTime.QuadPart;
|
||||
m_Value = (double)(m_Time.QuadPart / 10000000);
|
||||
|
||||
if (m_Format.size() != 0)
|
||||
{
|
||||
// If there is some date format, parse the value from it instead
|
||||
WCHAR tmpSz[MAX_LINE_LENGTH];
|
||||
SYSTEMTIME sysToday;
|
||||
FILETIME ftToday;
|
||||
|
||||
ftToday.dwHighDateTime = m_Time.HighPart;
|
||||
ftToday.dwLowDateTime = m_Time.LowPart;
|
||||
|
||||
FileTimeToSystemTime(&ftToday, &sysToday);
|
||||
|
||||
if (wcsicmp(L"locale-time", m_Format.c_str()) == 0)
|
||||
{
|
||||
GetTimeFormat(LOCALE_USER_DEFAULT, 0, &sysToday, NULL, tmpSz, MAX_LINE_LENGTH);
|
||||
}
|
||||
else if (wcsicmp(L"locale-date", m_Format.c_str()) == 0)
|
||||
{
|
||||
GetDateFormat(LOCALE_USER_DEFAULT, 0, &sysToday, NULL, tmpSz, MAX_LINE_LENGTH);
|
||||
}
|
||||
else
|
||||
{
|
||||
struct tm today;
|
||||
today.tm_isdst = 0;
|
||||
today.tm_hour = sysToday.wHour;
|
||||
today.tm_mday = sysToday.wDay;
|
||||
today.tm_min = sysToday.wMinute;
|
||||
today.tm_mon = sysToday.wMonth - 1;
|
||||
today.tm_sec = sysToday.wSecond;
|
||||
today.tm_wday = sysToday.wDayOfWeek;
|
||||
today.tm_yday = GetYearDay(sysToday.wYear, sysToday.wMonth, sysToday.wDay);
|
||||
today.tm_year = sysToday.wYear - 1900;
|
||||
|
||||
wcsftime(tmpSz, MAX_LINE_LENGTH, m_Format.c_str(), &today);
|
||||
}
|
||||
|
||||
m_Value = wcstod(tmpSz, NULL);
|
||||
}
|
||||
|
||||
return PostUpdate();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** GetStringValue
|
||||
**
|
||||
** Returns the time as string.
|
||||
**
|
||||
*/
|
||||
const WCHAR* CMeasureTime::GetStringValue(bool autoScale, double scale, int decimals, bool percentual)
|
||||
{
|
||||
static WCHAR tmpSz[MAX_LINE_LENGTH];
|
||||
struct tm today;
|
||||
|
||||
SYSTEMTIME sysToday;
|
||||
FILETIME ftToday;
|
||||
ftToday.dwHighDateTime = m_Time.HighPart;
|
||||
ftToday.dwLowDateTime = m_Time.LowPart;
|
||||
|
||||
FileTimeToSystemTime(&ftToday, &sysToday);
|
||||
|
||||
today.tm_isdst = 0;
|
||||
today.tm_hour = sysToday.wHour;
|
||||
today.tm_mday = sysToday.wDay;
|
||||
today.tm_min = sysToday.wMinute;
|
||||
today.tm_mon = sysToday.wMonth - 1;
|
||||
today.tm_sec = sysToday.wSecond;
|
||||
today.tm_wday = sysToday.wDayOfWeek;
|
||||
today.tm_yday = GetYearDay(sysToday.wYear, sysToday.wMonth, sysToday.wDay);
|
||||
today.tm_year = sysToday.wYear - 1900;
|
||||
|
||||
// Create the string
|
||||
if (m_Format.size() > 0)
|
||||
{
|
||||
if (wcsicmp(L"locale-time", m_Format.c_str()) == 0)
|
||||
{
|
||||
GetTimeFormat(LOCALE_USER_DEFAULT, 0, &sysToday, NULL, tmpSz, MAX_LINE_LENGTH);
|
||||
}
|
||||
else if (wcsicmp(L"locale-date", m_Format.c_str()) == 0)
|
||||
{
|
||||
GetDateFormat(LOCALE_USER_DEFAULT, 0, &sysToday, NULL, tmpSz, MAX_LINE_LENGTH);
|
||||
}
|
||||
else
|
||||
{
|
||||
wcsftime(tmpSz, MAX_LINE_LENGTH, m_Format.c_str(), &today);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wcsftime(tmpSz, MAX_LINE_LENGTH, L"%H:%M:%S", &today);
|
||||
}
|
||||
|
||||
return CheckSubstitute(tmpSz);
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Reads the measure specific configs.
|
||||
**
|
||||
*/
|
||||
void CMeasureTime::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
CMeasure::ReadConfig(parser, section);
|
||||
|
||||
m_Format = parser.ReadString(section, L"Format", L"");
|
||||
|
||||
std::wstring timezone;
|
||||
timezone = parser.ReadString(section, L"TimeZone", L"local");
|
||||
bool dst = 1 == parser.ReadInt(section, L"DaylightSavingTime", 1);
|
||||
|
||||
SYSTEMTIME sysLocalTime, sysUTCTime;
|
||||
GetLocalTime(&sysLocalTime);
|
||||
GetSystemTime(&sysUTCTime);
|
||||
|
||||
if (wcsicmp(L"local", timezone.c_str()) == 0)
|
||||
{
|
||||
FILETIME ftLocalTime, ftUTCTime;
|
||||
SystemTimeToFileTime(&sysLocalTime, &ftLocalTime);
|
||||
SystemTimeToFileTime(&sysUTCTime, &ftUTCTime);
|
||||
|
||||
LARGE_INTEGER largeInt1, largeInt2;
|
||||
largeInt1.HighPart = ftLocalTime.dwHighDateTime;
|
||||
largeInt1.LowPart = ftLocalTime.dwLowDateTime;
|
||||
largeInt2.HighPart = ftUTCTime.dwHighDateTime;
|
||||
largeInt2.LowPart = ftUTCTime.dwLowDateTime;
|
||||
|
||||
m_DeltaTime.QuadPart = largeInt1.QuadPart - largeInt2.QuadPart;
|
||||
}
|
||||
else
|
||||
{
|
||||
double zone = wcstod(timezone.c_str(), NULL);
|
||||
|
||||
struct tm* today;
|
||||
time_t now;
|
||||
time(&now);
|
||||
today = localtime(&now);
|
||||
|
||||
if (dst && today->tm_isdst)
|
||||
{
|
||||
// Add DST
|
||||
TIME_ZONE_INFORMATION tzi;
|
||||
GetTimeZoneInformation(&tzi);
|
||||
|
||||
m_DeltaTime.QuadPart = ((zone * 3600) - tzi.DaylightBias * 60) * 10000000.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_DeltaTime.QuadPart = (zone * 3600) * 10000000.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
63
Library/MeasureTime.h
Normal file
63
Library/MeasureTime.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureTime.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureTime.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.5 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.4 2004/03/13 16:17:42 rainy
|
||||
Added timezones
|
||||
|
||||
Revision 1.3 2003/02/10 18:13:14 rainy
|
||||
Returns the time in secs as value.
|
||||
|
||||
Revision 1.2 2002/04/26 18:24:15 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.1 2001/12/23 10:11:08 rainy
|
||||
Initial version.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __MEASURETIME_H__
|
||||
#define __MEASURETIME_H__
|
||||
|
||||
#include "Measure.h"
|
||||
|
||||
class CMeasureTime : public CMeasure
|
||||
{
|
||||
public:
|
||||
CMeasureTime(CMeterWindow* meterWindow);
|
||||
virtual ~CMeasureTime();
|
||||
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
virtual bool Update();
|
||||
virtual const WCHAR* GetStringValue(bool autoScale, double scale, int decimals, bool percentual);
|
||||
|
||||
private:
|
||||
std::wstring m_Format;
|
||||
LARGE_INTEGER m_DeltaTime;
|
||||
LARGE_INTEGER m_Time;
|
||||
};
|
||||
|
||||
#endif
|
||||
128
Library/MeasureUptime.cpp
Normal file
128
Library/MeasureUptime.cpp
Normal file
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureUptime.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureUptime.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.7 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.6 2002/04/26 18:24:15 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.5 2002/03/31 09:58:54 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.4 2001/12/23 10:16:10 rainy
|
||||
The static variable is set to zero in destructor.
|
||||
|
||||
Revision 1.3 2001/10/28 10:20:49 rainy
|
||||
GetStringValue uses consts
|
||||
|
||||
Revision 1.2 2001/09/26 16:27:14 rainy
|
||||
Changed the interfaces a bit.
|
||||
|
||||
Revision 1.1 2001/09/01 12:56:25 rainy
|
||||
Initial version.
|
||||
|
||||
*/
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeasureUptime.h"
|
||||
#include "Rainmeter.h"
|
||||
#include <time.h>
|
||||
|
||||
/*
|
||||
** CMeasureUptime
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeasureUptime::CMeasureUptime(CMeterWindow* meterWindow) : CMeasure(meterWindow)
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeasureUptime
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeasureUptime::~CMeasureUptime()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Reads the measure specific configs.
|
||||
**
|
||||
*/
|
||||
void CMeasureUptime::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
CMeasure::ReadConfig(parser, section);
|
||||
|
||||
m_Format = parser.ReadString(section, L"Format", L"%4!i!d %3!i!:%2!02i!");
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the current uptime
|
||||
**
|
||||
*/
|
||||
bool CMeasureUptime::Update()
|
||||
{
|
||||
if (!CMeasure::PreUpdate()) return false;
|
||||
|
||||
DWORD ticks = GetTickCount();
|
||||
m_Value = ticks / 1000;
|
||||
|
||||
return PostUpdate();
|
||||
}
|
||||
|
||||
/*
|
||||
** GetStringValue
|
||||
**
|
||||
** Returns the uptime as string.
|
||||
**
|
||||
*/
|
||||
const WCHAR* CMeasureUptime::GetStringValue(bool autoScale, double scale, int decimals, bool percentual)
|
||||
{
|
||||
static WCHAR buffer[MAX_LINE_LENGTH];
|
||||
|
||||
size_t value = (size_t)m_Value;
|
||||
size_t time[4];
|
||||
|
||||
time[0] = value % 60;
|
||||
time[1] = (value / 60) % 60;
|
||||
time[2] = (value / (60 * 60));
|
||||
time[3] = (value / (60 * 60 * 24));
|
||||
|
||||
if (m_Format.find(L"%4") != std::wstring::npos)
|
||||
{
|
||||
time[2] %= 24;
|
||||
}
|
||||
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_STRING | FORMAT_MESSAGE_ARGUMENT_ARRAY, m_Format.c_str(), 0, 0, buffer, MAX_LINE_LENGTH, (char**)time);
|
||||
|
||||
return CheckSubstitute(buffer);
|
||||
}
|
||||
61
Library/MeasureUptime.h
Normal file
61
Library/MeasureUptime.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureUptime.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureUptime.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.5 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.4 2002/04/26 18:24:15 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.3 2001/10/28 10:20:49 rainy
|
||||
GetStringValue uses consts
|
||||
|
||||
Revision 1.2 2001/09/26 16:27:14 rainy
|
||||
Changed the interfaces a bit.
|
||||
|
||||
Revision 1.1 2001/09/01 12:56:25 rainy
|
||||
Initial version.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __MEASUREUPTIME_H__
|
||||
#define __MEASUREUPTIME_H__
|
||||
|
||||
#include "Measure.h"
|
||||
|
||||
class CMeasureUptime : public CMeasure
|
||||
{
|
||||
public:
|
||||
CMeasureUptime(CMeterWindow* meterWindow);
|
||||
virtual ~CMeasureUptime();
|
||||
|
||||
virtual bool Update();
|
||||
virtual const WCHAR* GetStringValue(bool autoScale, double scale, int decimals, bool percentual);
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
std::wstring m_Format;
|
||||
};
|
||||
|
||||
#endif
|
||||
118
Library/MeasureVirtualMemory.cpp
Normal file
118
Library/MeasureVirtualMemory.cpp
Normal file
@@ -0,0 +1,118 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureVirtualMemory.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureVirtualMemory.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.8 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.7 2002/04/26 18:24:15 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.6 2002/03/31 09:58:54 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.5 2001/09/26 16:27:14 rainy
|
||||
Changed the interfaces a bit.
|
||||
|
||||
Revision 1.4 2001/09/01 13:00:09 rainy
|
||||
Slight changes in the interface. The value is now measured only once if possible.
|
||||
|
||||
Revision 1.3 2001/08/19 09:14:20 rainy
|
||||
Added support for value invert.
|
||||
|
||||
Revision 1.2 2001/08/12 15:43:24 Rainy
|
||||
Adjusted Update()'s interface.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeasureVirtualMemory.h"
|
||||
|
||||
/*
|
||||
** CMeasureVirtualMemory
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeasureVirtualMemory::CMeasureVirtualMemory(CMeterWindow* meterWindow) : CMeasure(meterWindow)
|
||||
{
|
||||
m_Total = false;
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeasureVirtualMemory
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeasureVirtualMemory::~CMeasureVirtualMemory()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the current virtual memory value.
|
||||
**
|
||||
*/
|
||||
bool CMeasureVirtualMemory::Update()
|
||||
{
|
||||
if (!CMeasure::PreUpdate()) return false;
|
||||
|
||||
MEMORYSTATUSEX stat;
|
||||
stat.dwLength = sizeof(MEMORYSTATUSEX);
|
||||
GlobalMemoryStatusEx(&stat); // Doesn't measure values > 4GB. Should use GlobalMemoryStatusEx instead, but that requires Win2k.
|
||||
if (m_Total)
|
||||
{
|
||||
m_Value = (double)(__int64)stat.ullTotalPageFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Value = (double)(__int64)(stat.ullTotalPageFile - stat.ullAvailPageFile);
|
||||
}
|
||||
|
||||
|
||||
return PostUpdate();
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Reads the measure specific configs.
|
||||
**
|
||||
*/
|
||||
void CMeasureVirtualMemory::ReadConfig(CConfigParser& parser, const WCHAR* section)
|
||||
{
|
||||
CMeasure::ReadConfig(parser, section);
|
||||
|
||||
m_Total = (1 == parser.ReadInt(section, L"Total", 0));
|
||||
|
||||
MEMORYSTATUSEX stat;
|
||||
stat.dwLength = sizeof(MEMORYSTATUSEX);
|
||||
GlobalMemoryStatusEx(&stat);
|
||||
m_MaxValue = (double)(__int64)stat.ullTotalPageFile;
|
||||
}
|
||||
|
||||
63
Library/MeasureVirtualMemory.h
Normal file
63
Library/MeasureVirtualMemory.h
Normal file
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeasureVirtualMemory.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeasureVirtualMemory.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.6 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.5 2002/04/26 18:24:15 rainy
|
||||
Modified the Update method to support disabled measures.
|
||||
|
||||
Revision 1.4 2001/09/26 16:27:13 rainy
|
||||
Changed the interfaces a bit.
|
||||
|
||||
Revision 1.3 2001/09/01 13:00:09 rainy
|
||||
Slight changes in the interface. The value is now measured only once if possible.
|
||||
|
||||
Revision 1.2 2001/08/12 15:43:24 Rainy
|
||||
Adjusted Update()'s interface.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __MEASUREVIRTUALMEMORY_H__
|
||||
#define __MEASUREVIRTUALMEMORY_H__
|
||||
|
||||
#include "Measure.h"
|
||||
|
||||
class CMeasureVirtualMemory : public CMeasure
|
||||
{
|
||||
public:
|
||||
CMeasureVirtualMemory(CMeterWindow* meterWindow);
|
||||
virtual ~CMeasureVirtualMemory();
|
||||
|
||||
virtual bool Update();
|
||||
virtual void ReadConfig(CConfigParser& parser, const WCHAR* section);
|
||||
|
||||
private:
|
||||
bool m_Total;
|
||||
};
|
||||
|
||||
#endif
|
||||
500
Library/Meter.cpp
Normal file
500
Library/Meter.cpp
Normal file
@@ -0,0 +1,500 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/Meter.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: Meter.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.17 2004/07/11 17:15:56 rainy
|
||||
Added relative coordinates.
|
||||
|
||||
Revision 1.16 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.15 2004/03/13 16:17:56 rainy
|
||||
Added rotator
|
||||
|
||||
Revision 1.14 2003/02/10 18:12:45 rainy
|
||||
Now uses GDI+
|
||||
|
||||
Revision 1.13 2002/12/23 14:25:45 rainy
|
||||
Fixed color reading.
|
||||
|
||||
Revision 1.12 2002/07/01 15:33:00 rainy
|
||||
Added LINE meter.
|
||||
|
||||
Revision 1.11 2002/05/04 08:12:51 rainy
|
||||
Actions can be defined per meter.
|
||||
|
||||
Revision 1.10 2002/04/27 10:28:14 rainy
|
||||
Added an error message if the meter is not bound to anything.
|
||||
|
||||
Revision 1.9 2002/04/26 18:22:38 rainy
|
||||
Added possibility to hide the meter.
|
||||
Added support for Image meter.
|
||||
|
||||
Revision 1.8 2002/03/31 09:58:54 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.7 2001/12/23 10:15:25 rainy
|
||||
Added ParseColor().
|
||||
|
||||
Revision 1.6 2001/10/14 07:32:15 rainy
|
||||
In error situations CError is thrown instead just a boolean value.
|
||||
|
||||
Revision 1.5 2001/09/26 16:26:53 rainy
|
||||
Changed the interfaces a bit.
|
||||
|
||||
Revision 1.4 2001/09/01 12:59:16 rainy
|
||||
Added support for Uptime measure.
|
||||
W and H default to 1.
|
||||
|
||||
Revision 1.3 2001/08/19 09:13:38 rainy
|
||||
Invert moved to the measures.
|
||||
Added PerfMon measure.
|
||||
|
||||
Revision 1.2 2001/08/12 15:41:41 Rainy
|
||||
Adjusted Update()'s interface.
|
||||
Added invert measure.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "Error.h"
|
||||
#include "Meter.h"
|
||||
#include "MeterBitmap.h"
|
||||
#include "MeterBar.h"
|
||||
#include "MeterHistogram.h"
|
||||
#include "MeterString.h"
|
||||
#include "MeterImage.h"
|
||||
#include "MeterLine.h"
|
||||
#include "MeterRoundLine.h"
|
||||
#include "MeterRotator.h"
|
||||
#include "MeterButton.h"
|
||||
#include "Measure.h"
|
||||
#include "Rainmeter.h"
|
||||
|
||||
using namespace Gdiplus;
|
||||
|
||||
int CMeter::c_OldX = 0;
|
||||
int CMeter::c_OldY = 0;
|
||||
|
||||
/*
|
||||
** CMeter
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeter::CMeter(CMeterWindow* meterWindow)
|
||||
{
|
||||
m_Measure = NULL;
|
||||
m_X = 0;
|
||||
m_Y = 0;
|
||||
m_W = 0;
|
||||
m_H = 0;
|
||||
m_RelativeMeter = NULL;
|
||||
m_Hidden = false;
|
||||
m_SolidBevel = BEVELTYPE_NONE;
|
||||
m_MouseOver = false;
|
||||
m_UpdateDivider = 1;
|
||||
m_UpdateCounter = 0;
|
||||
m_RelativeX = POSITION_ABSOLUTE;
|
||||
m_RelativeY = POSITION_ABSOLUTE;
|
||||
m_MeterWindow = NULL;
|
||||
m_SolidAngle = 0.0;
|
||||
m_MeterWindow = meterWindow;
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeter
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeter::~CMeter()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
** Initialize
|
||||
**
|
||||
** Initializes the meter. The base implementation just stores the pointer.
|
||||
** Usually this method is overwritten by the inherited classes, which load
|
||||
** bitmaps and such things during initialization.
|
||||
**
|
||||
*/
|
||||
void CMeter::Initialize()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
** GetX
|
||||
**
|
||||
** Returns the X-position of the meter.
|
||||
**
|
||||
*/
|
||||
int CMeter::GetX(bool abs)
|
||||
{
|
||||
if (m_RelativeX != POSITION_ABSOLUTE && m_MeterWindow)
|
||||
{
|
||||
if (m_RelativeMeter == NULL)
|
||||
{
|
||||
std::list<CMeter*>& meters = m_MeterWindow->GetMeters();
|
||||
std::list<CMeter*>::iterator iter = meters.begin();
|
||||
|
||||
// Find this meter
|
||||
for ( ; iter != meters.end(); iter++)
|
||||
{
|
||||
if (*iter == this && iter != meters.begin())
|
||||
{
|
||||
iter--;
|
||||
m_RelativeMeter = (*iter);
|
||||
if (m_RelativeX == POSITION_RELATIVE_TL)
|
||||
{
|
||||
return m_RelativeMeter->GetX(true) + m_X;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_RelativeMeter->GetX(true) + m_RelativeMeter->GetW() + m_X;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_RelativeX == POSITION_RELATIVE_TL)
|
||||
{
|
||||
return m_RelativeMeter->GetX(true) + m_X;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_RelativeMeter->GetX(true) + m_RelativeMeter->GetW() + m_X;
|
||||
}
|
||||
}
|
||||
}
|
||||
return m_X;
|
||||
}
|
||||
|
||||
/*
|
||||
** GetY
|
||||
**
|
||||
** Returns the Y-position of the meter.
|
||||
**
|
||||
*/
|
||||
int CMeter::GetY(bool abs)
|
||||
{
|
||||
if (m_RelativeY != POSITION_ABSOLUTE && m_MeterWindow)
|
||||
{
|
||||
if (m_RelativeMeter == NULL)
|
||||
{
|
||||
std::list<CMeter*>& meters = m_MeterWindow->GetMeters();
|
||||
std::list<CMeter*>::iterator iter = meters.begin();
|
||||
|
||||
// Find this meter
|
||||
for ( ; iter != meters.end(); iter++)
|
||||
{
|
||||
if (*iter == this && iter != meters.begin())
|
||||
{
|
||||
iter--;
|
||||
m_RelativeMeter = (*iter);
|
||||
if (m_RelativeY == POSITION_RELATIVE_TL)
|
||||
{
|
||||
return m_RelativeMeter->GetY() + m_Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_RelativeMeter->GetY() + m_RelativeMeter->GetH() + m_Y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_RelativeY == POSITION_RELATIVE_TL)
|
||||
{
|
||||
return m_RelativeMeter->GetY() + m_Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
return m_RelativeMeter->GetY() + m_RelativeMeter->GetH() + m_Y;
|
||||
}
|
||||
}
|
||||
}
|
||||
return m_Y;
|
||||
}
|
||||
|
||||
/*
|
||||
** HitTest
|
||||
**
|
||||
** Checks if the given point is inside the meter.
|
||||
**
|
||||
*/
|
||||
bool CMeter::HitTest(int x, int y)
|
||||
{
|
||||
if (x >= GetX() && x <= GetX() + GetW() && y >= GetY() && y <= GetY() + GetH())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Reads the meter-specific configs from the ini-file. The base implementation
|
||||
** reads the common settings for all meters. The inherited classes must call
|
||||
** the base implementation if they overwrite this method.
|
||||
**
|
||||
*/
|
||||
void CMeter::ReadConfig(const WCHAR* section)
|
||||
{
|
||||
CConfigParser& parser = m_MeterWindow->GetParser();
|
||||
|
||||
const std::wstring& x = parser.ReadString(section, L"X", L"0");
|
||||
if (x.size() > 0)
|
||||
{
|
||||
m_X = _wtoi(x.c_str());
|
||||
if (x[x.size() - 1] == L'r')
|
||||
{
|
||||
m_RelativeX = POSITION_RELATIVE_TL;
|
||||
}
|
||||
else if (x[x.size() - 1] == L'R')
|
||||
{
|
||||
m_RelativeX = POSITION_RELATIVE_BR;
|
||||
}
|
||||
}
|
||||
|
||||
const std::wstring& y = parser.ReadString(section, L"Y", L"0");
|
||||
if (y.size() > 0)
|
||||
{
|
||||
m_Y = _wtoi(y.c_str());
|
||||
if (y[y.size() - 1] == L'r')
|
||||
{
|
||||
m_RelativeY = POSITION_RELATIVE_TL;
|
||||
}
|
||||
else if (y[y.size() - 1] == L'R')
|
||||
{
|
||||
m_RelativeY = POSITION_RELATIVE_BR;
|
||||
}
|
||||
}
|
||||
|
||||
m_W = parser.ReadInt(section, L"W", 1);
|
||||
m_H = parser.ReadInt(section, L"H", 1);
|
||||
|
||||
m_Hidden = 0!=parser.ReadInt(section, L"Hidden", 0);
|
||||
m_SolidBevel = (BEVELTYPE)parser.ReadInt(section, L"BevelType", m_SolidBevel);
|
||||
|
||||
m_SolidColor = parser.ReadColor(section, L"SolidColor", Color(0, 0, 0, 0));
|
||||
m_SolidColor2 = parser.ReadColor(section, L"SolidColor2", m_SolidColor);
|
||||
m_SolidAngle = (Gdiplus::REAL)parser.ReadFloat(section, L"GradientAngle", 0.0);
|
||||
|
||||
m_RightMouseDownAction = parser.ReadString(section, L"RightMouseDownAction", L"");
|
||||
m_LeftMouseDownAction = parser.ReadString(section, L"LeftMouseDownAction", L"");
|
||||
m_RightMouseUpAction = parser.ReadString(section, L"RightMouseUpAction", L"");
|
||||
m_LeftMouseUpAction = parser.ReadString(section, L"LeftMouseUpAction", L"");
|
||||
m_MouseOverAction = parser.ReadString(section, L"MouseOverAction", L"");
|
||||
m_MouseLeaveAction = parser.ReadString(section, L"MouseLeaveAction", L"");
|
||||
|
||||
m_MeasureName = parser.ReadString(section, L"MeasureName", L"");
|
||||
|
||||
m_UpdateDivider = parser.ReadInt(section, L"UpdateDivider", 1);
|
||||
m_UpdateCounter = m_UpdateDivider;
|
||||
|
||||
if (m_W == 0 || m_H == 0)
|
||||
{
|
||||
throw CError(std::wstring(L"The meter ") + section + L" has zero dimensions.", __LINE__, __FILE__);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** BindMeasure
|
||||
**
|
||||
** Binds this meter to the given measure. The same measure can be bound to
|
||||
** several meters but one meter and only be bound to one measure.
|
||||
**
|
||||
*/
|
||||
void CMeter::BindMeasure(std::list<CMeasure*>& measures)
|
||||
{
|
||||
// The meter is not bound to anything
|
||||
if (m_MeasureName.empty())
|
||||
{
|
||||
throw CError(std::wstring(L"The meter [") + m_Name + L"] is not bound to anything!", __LINE__, __FILE__);
|
||||
}
|
||||
|
||||
// Go through the list and check it there is a measure for us
|
||||
std::list<CMeasure*>::iterator i = measures.begin();
|
||||
for( ; i != measures.end(); i++)
|
||||
{
|
||||
if(_wcsicmp((*i)->GetName(), m_MeasureName.c_str()) == 0)
|
||||
{
|
||||
m_Measure = (*i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Error :)
|
||||
throw CError(std::wstring(L"The meter [") + m_Name + L"] cannot be bound with [" + m_MeasureName + L"]!", __LINE__, __FILE__);
|
||||
}
|
||||
|
||||
/*
|
||||
** Create
|
||||
**
|
||||
** Creates the given meter. This is the factory method for the meters.
|
||||
** If new meters are implemented this method needs to be updated.
|
||||
**
|
||||
*/
|
||||
CMeter* CMeter::Create(const WCHAR* meter, CMeterWindow* meterWindow)
|
||||
{
|
||||
if(_wcsicmp(L"HISTOGRAM", meter) == 0)
|
||||
{
|
||||
return new CMeterHistogram(meterWindow);
|
||||
}
|
||||
else if(_wcsicmp(L"STRING", meter) == 0)
|
||||
{
|
||||
return new CMeterString(meterWindow);
|
||||
}
|
||||
else if(_wcsicmp(L"BAR", meter) == 0)
|
||||
{
|
||||
return new CMeterBar(meterWindow);
|
||||
}
|
||||
else if(_wcsicmp(L"BITMAP", meter) == 0)
|
||||
{
|
||||
return new CMeterBitmap(meterWindow);
|
||||
}
|
||||
else if(_wcsicmp(L"IMAGE", meter) == 0)
|
||||
{
|
||||
return new CMeterImage(meterWindow);
|
||||
}
|
||||
else if(_wcsicmp(L"LINE", meter) == 0)
|
||||
{
|
||||
return new CMeterLine(meterWindow);
|
||||
}
|
||||
else if(_wcsicmp(L"ROUNDLINE", meter) == 0)
|
||||
{
|
||||
return new CMeterRoundLine(meterWindow);
|
||||
}
|
||||
else if(_wcsicmp(L"ROTATOR", meter) == 0)
|
||||
{
|
||||
return new CMeterRotator(meterWindow);
|
||||
}
|
||||
else if(_wcsicmp(L"BUTTON", meter) == 0)
|
||||
{
|
||||
return new CMeterButton(meterWindow);
|
||||
}
|
||||
|
||||
// Error
|
||||
throw CError(std::wstring(L"No such meter: ") + meter, __LINE__, __FILE__);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the value(s) from the measures. Derived classes should
|
||||
** only update if this returns true;
|
||||
*/
|
||||
bool CMeter::Update()
|
||||
{
|
||||
// Only update the meter's value when the divider is equal to the counter
|
||||
m_UpdateCounter++;
|
||||
if (m_UpdateCounter < m_UpdateDivider) return false;
|
||||
m_UpdateCounter = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
** Draw
|
||||
**
|
||||
** Draws the solid background & bevel if such are defined
|
||||
*/
|
||||
bool CMeter::Draw()
|
||||
{
|
||||
if (IsHidden()) return false;
|
||||
|
||||
if (m_SolidColor.GetA() != 0 || m_SolidColor2.GetA() != 0)
|
||||
{
|
||||
Graphics graphics(m_MeterWindow->GetDoubleBuffer());
|
||||
|
||||
int x = GetX();
|
||||
int y = GetY();
|
||||
|
||||
if (m_SolidColor.GetValue() == m_SolidColor2.GetValue())
|
||||
{
|
||||
SolidBrush solid(m_SolidColor);
|
||||
graphics.FillRectangle(&solid, x, y, m_W, m_H);
|
||||
}
|
||||
else
|
||||
{
|
||||
Rect r(x, y, m_W, m_H);
|
||||
LinearGradientBrush gradient(r, m_SolidColor, m_SolidColor2, m_SolidAngle, TRUE);
|
||||
graphics.FillRectangle(&gradient, r);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_SolidBevel != BEVELTYPE_NONE)
|
||||
{
|
||||
Graphics graphics(m_MeterWindow->GetDoubleBuffer());
|
||||
|
||||
int x = GetX();
|
||||
int y = GetY();
|
||||
|
||||
Pen light(Color(255, 255, 255, 255));
|
||||
Pen dark(Color(255, 0, 0, 0));
|
||||
|
||||
if (m_SolidBevel == BEVELTYPE_DOWN)
|
||||
{
|
||||
light.SetColor(Color(255, 0, 0, 0));
|
||||
dark.SetColor(Color(255, 255, 255, 255));
|
||||
}
|
||||
|
||||
// The bevel is drawn outside the meter
|
||||
Rect rect(x - 2, y - 2, m_W + 4, m_H + 4);
|
||||
DrawBevel(graphics, rect, light, dark);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
** DrawBevel
|
||||
**
|
||||
** Draws a bevel inside the given area
|
||||
*/
|
||||
void CMeter::DrawBevel(Graphics& graphics, Rect& rect, Pen& light, Pen& dark)
|
||||
{
|
||||
int l = rect.GetLeft();
|
||||
int r = rect.GetRight() - 1;
|
||||
int t = rect.GetTop();
|
||||
int b = rect.GetBottom() - 1;
|
||||
|
||||
graphics.DrawLine(&light, l, t, l, b);
|
||||
graphics.DrawLine(&light, l, t, r, t);
|
||||
graphics.DrawLine(&light, l + 1, t + 1, l + 1, b - 1);
|
||||
graphics.DrawLine(&light, l + 1, t + 1, r - 1, l + 1);
|
||||
graphics.DrawLine(&dark, l, b, r, b);
|
||||
graphics.DrawLine(&dark, r, t, r, b);
|
||||
graphics.DrawLine(&dark, l + 1, b - 1, r - 1, b - 1);
|
||||
graphics.DrawLine(&dark, r - 1, t + 1, r - 1, b - 1);
|
||||
}
|
||||
170
Library/Meter.h
Normal file
170
Library/Meter.h
Normal file
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/Meter.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: Meter.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.12 2004/07/11 17:15:56 rainy
|
||||
Added relative coordinates.
|
||||
|
||||
Revision 1.11 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.10 2003/02/10 18:12:45 rainy
|
||||
Now uses GDI+
|
||||
|
||||
Revision 1.9 2002/07/01 15:33:00 rainy
|
||||
Added LINE meter.
|
||||
|
||||
Revision 1.8 2002/05/04 08:12:51 rainy
|
||||
Actions can be defined per meter.
|
||||
|
||||
Revision 1.7 2002/04/26 18:22:03 rainy
|
||||
Added possibility to hide the meter.
|
||||
|
||||
Revision 1.6 2002/03/31 09:58:54 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.5 2001/12/23 10:15:25 rainy
|
||||
Added ParseColor().
|
||||
|
||||
Revision 1.4 2001/09/26 16:26:53 rainy
|
||||
Changed the interfaces a bit.
|
||||
|
||||
Revision 1.3 2001/08/19 09:13:25 rainy
|
||||
Invert moved to the measures.
|
||||
|
||||
Revision 1.2 2001/08/12 15:41:41 Rainy
|
||||
Adjusted Update()'s interface.
|
||||
Added invert measure.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __METER_H__
|
||||
#define __METER_H__
|
||||
|
||||
#include <windows.h>
|
||||
#include <list>
|
||||
#include <gdiplus.h>
|
||||
#include "Litestep.h"
|
||||
#include "MeterWindow.h"
|
||||
|
||||
class CMeasure;
|
||||
|
||||
class CMeter
|
||||
{
|
||||
public:
|
||||
CMeter(CMeterWindow* meterWindow);
|
||||
virtual ~CMeter();
|
||||
|
||||
virtual void ReadConfig(const WCHAR* section);
|
||||
virtual void Initialize();
|
||||
virtual bool Update();
|
||||
virtual bool Draw();
|
||||
virtual void BindMeasure(std::list<CMeasure*>& measures);
|
||||
|
||||
virtual int GetH() { return m_Hidden ? 0 : m_H; };
|
||||
virtual int GetW() { return m_Hidden ? 0 : m_W; };
|
||||
virtual int GetX(bool abs = false);
|
||||
virtual int GetY(bool abs = false);
|
||||
|
||||
void SetX(int x) { m_X = x; m_RelativeX = POSITION_ABSOLUTE; };
|
||||
void SetY(int y) { m_Y = y; m_RelativeY = POSITION_ABSOLUTE; };
|
||||
|
||||
std::wstring& GetRightMouseDownAction() { return m_RightMouseDownAction; };
|
||||
std::wstring& GetRightMouseUpAction() { return m_RightMouseUpAction; };
|
||||
std::wstring& GetLeftMouseDownAction() { return m_LeftMouseDownAction; };
|
||||
std::wstring& GetLeftMouseUpAction() { return m_LeftMouseUpAction; };
|
||||
std::wstring& GetMouseOverAction() { return m_MouseOverAction; };
|
||||
std::wstring& GetMouseLeaveAction() { return m_MouseLeaveAction; };
|
||||
|
||||
void Hide() { m_Hidden = true; };
|
||||
void Show() { m_Hidden = false; };
|
||||
bool IsHidden() { return m_Hidden; };
|
||||
|
||||
virtual bool HitTest(int x, int y);
|
||||
|
||||
void SetMouseOver(bool over) { m_MouseOver = over; }
|
||||
bool IsMouseOver() { return m_MouseOver; }
|
||||
|
||||
void SetName(const WCHAR* name) { m_Name = name; };
|
||||
const WCHAR* GetName() { return m_Name.c_str(); };
|
||||
|
||||
static CMeter* Create(const WCHAR* meter, CMeterWindow* meterWindow);
|
||||
static WCHAR* ConvertToWide(const char* string);
|
||||
|
||||
static void DrawBevel(Gdiplus::Graphics& graphics, Gdiplus::Rect& rect, Gdiplus::Pen& light, Gdiplus::Pen& dark);
|
||||
|
||||
protected:
|
||||
|
||||
enum METER_ALIGNMENT
|
||||
{
|
||||
ALIGN_LEFT,
|
||||
ALIGN_RIGHT,
|
||||
ALIGN_CENTER
|
||||
};
|
||||
|
||||
enum METER_POSITION
|
||||
{
|
||||
POSITION_ABSOLUTE,
|
||||
POSITION_RELATIVE_TL,
|
||||
POSITION_RELATIVE_BR
|
||||
};
|
||||
|
||||
std::wstring m_Name; // Name of the meter
|
||||
std::wstring m_MeasureName; // Name of the measure this is bound to
|
||||
CMeasure* m_Measure; // Pointer to the measure this meter is bound to
|
||||
int m_X; // X-position of the meter
|
||||
int m_Y; // Y-position of the meter
|
||||
int m_W; // Width of the meter
|
||||
int m_H; // Height of the meter
|
||||
bool m_Hidden; // Status of the meter
|
||||
CMeter* m_RelativeMeter;
|
||||
|
||||
static int c_OldX;
|
||||
static int c_OldY;
|
||||
|
||||
std::wstring m_RightMouseDownAction; // Actions for left and right mouse buttons
|
||||
std::wstring m_RightMouseUpAction;
|
||||
std::wstring m_LeftMouseDownAction;
|
||||
std::wstring m_LeftMouseUpAction;
|
||||
std::wstring m_MouseOverAction;
|
||||
std::wstring m_MouseLeaveAction;
|
||||
|
||||
bool m_MouseOver;
|
||||
METER_POSITION m_RelativeX;
|
||||
METER_POSITION m_RelativeY;
|
||||
|
||||
UINT m_UpdateDivider; // Divider for the update
|
||||
UINT m_UpdateCounter; // Current update counter
|
||||
|
||||
BEVELTYPE m_SolidBevel;
|
||||
Gdiplus::Color m_SolidColor;
|
||||
Gdiplus::Color m_SolidColor2;
|
||||
Gdiplus::REAL m_SolidAngle;
|
||||
|
||||
CMeterWindow* m_MeterWindow;
|
||||
};
|
||||
|
||||
#endif
|
||||
303
Library/MeterBar.cpp
Normal file
303
Library/MeterBar.cpp
Normal file
@@ -0,0 +1,303 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeterBar.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeterBar.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.11 2004/07/11 17:16:11 rainy
|
||||
Added BarBorder.
|
||||
|
||||
Revision 1.10 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.9 2003/02/10 18:12:45 rainy
|
||||
Now uses GDI+
|
||||
|
||||
Revision 1.8 2002/07/01 15:32:51 rainy
|
||||
Removed include to lsapi.h
|
||||
|
||||
Revision 1.7 2002/05/04 08:13:41 rainy
|
||||
Fixed vertical bar drawing.
|
||||
|
||||
Revision 1.6 2002/04/26 18:22:03 rainy
|
||||
Added possibility to hide the meter.
|
||||
|
||||
Revision 1.5 2002/03/31 09:58:54 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.4 2001/12/23 10:14:51 rainy
|
||||
Hex color values are now also supported.
|
||||
|
||||
Revision 1.3 2001/10/14 07:32:33 rainy
|
||||
In error situations CError is thrown instead just a boolean value.
|
||||
|
||||
Revision 1.2 2001/09/26 16:26:24 rainy
|
||||
Small adjustement to the interfaces.
|
||||
|
||||
Revision 1.1 2001/09/01 12:56:25 rainy
|
||||
Initial version.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4786)
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeterBar.h"
|
||||
#include "Measure.h"
|
||||
#include "Error.h"
|
||||
#include "Litestep.h"
|
||||
#include "Rainmeter.h"
|
||||
|
||||
using namespace Gdiplus;
|
||||
|
||||
extern CRainmeter* Rainmeter;
|
||||
|
||||
/*
|
||||
** CMeterBar
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeterBar::CMeterBar(CMeterWindow* meterWindow) : CMeter(meterWindow)
|
||||
{
|
||||
m_Color = 0;
|
||||
m_Bitmap = NULL;
|
||||
m_Value = 0.0;
|
||||
m_Border = 0;
|
||||
m_Flip = false;
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeterBar
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeterBar::~CMeterBar()
|
||||
{
|
||||
if(m_Bitmap != NULL) delete m_Bitmap;
|
||||
}
|
||||
|
||||
/*
|
||||
** Initialize
|
||||
**
|
||||
** Load the image or create the brush. If image is used get the dimensions
|
||||
** of the meter from it.
|
||||
**
|
||||
*/
|
||||
void CMeterBar::Initialize()
|
||||
{
|
||||
CMeter::Initialize();
|
||||
|
||||
// Load the bitmaps if defined
|
||||
if(!m_ImageName.empty())
|
||||
{
|
||||
m_Bitmap = new Bitmap(m_ImageName.c_str());
|
||||
Status status = m_Bitmap->GetLastStatus();
|
||||
if(Ok != status)
|
||||
{
|
||||
throw CError(std::wstring(L"Bitmap image not found: ") + m_ImageName, __LINE__, __FILE__);
|
||||
}
|
||||
|
||||
m_W = m_Bitmap->GetWidth();
|
||||
m_H = m_Bitmap->GetHeight();
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Read the meter-specific configs from the ini-file.
|
||||
**
|
||||
*/
|
||||
void CMeterBar::ReadConfig(const WCHAR* section)
|
||||
{
|
||||
// Read common configs
|
||||
CMeter::ReadConfig(section);
|
||||
|
||||
CConfigParser& parser = m_MeterWindow->GetParser();
|
||||
|
||||
m_Color = parser.ReadColor(section, L"BarColor", Color::Green);
|
||||
|
||||
m_ImageName = parser.ReadString(section, L"BarImage", L"");
|
||||
m_ImageName = Rainmeter->FixPath(m_ImageName, PATH_FOLDER_CURRENT_SKIN, m_MeterWindow->GetSkinName());
|
||||
|
||||
m_Border = parser.ReadInt(section, L"BarBorder", 0);
|
||||
|
||||
m_Flip = parser.ReadInt(section, L"Flip", 0) == 1;
|
||||
|
||||
std::wstring orientation;
|
||||
orientation = parser.ReadString(section, L"BarOrientation", L"VERTICAL");
|
||||
|
||||
if(_wcsicmp(L"VERTICAL", orientation.c_str()) == 0)
|
||||
{
|
||||
m_Orientation = VERTICAL;
|
||||
}
|
||||
else if(_wcsicmp(L"HORIZONTAL", orientation.c_str()) == 0)
|
||||
{
|
||||
m_Orientation = HORIZONTAL;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw CError(std::wstring(L"No such BarOrientation: ") + orientation, __LINE__, __FILE__);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the value(s) from the measures.
|
||||
**
|
||||
*/
|
||||
bool CMeterBar::Update()
|
||||
{
|
||||
if (CMeter::Update() && m_Measure)
|
||||
{
|
||||
m_Value = m_Measure->GetRelativeValue();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
** Draw
|
||||
**
|
||||
** Draws the meter on the double buffer
|
||||
**
|
||||
*/
|
||||
bool CMeterBar::Draw()
|
||||
{
|
||||
if(!CMeter::Draw()) return false;
|
||||
|
||||
int x = GetX();
|
||||
int y = GetY();
|
||||
|
||||
Graphics graphics(m_MeterWindow->GetDoubleBuffer());
|
||||
|
||||
if(m_Orientation == VERTICAL)
|
||||
{
|
||||
int size = (int)((m_H - 2 * m_Border) * m_Value);
|
||||
size = min(m_H - 2 * m_Border, size);
|
||||
size = max(0, size);
|
||||
|
||||
if (m_Bitmap)
|
||||
{
|
||||
if (m_Flip)
|
||||
{
|
||||
if (m_Border > 0)
|
||||
{
|
||||
Rect r2(x, y, m_W, m_Border);
|
||||
graphics.DrawImage(m_Bitmap, r2, 0, 0, m_W, m_Border, UnitPixel);
|
||||
r2.Y = y + size + m_Border;
|
||||
graphics.DrawImage(m_Bitmap, r2, 0, m_H - m_Border, m_W, m_Border, UnitPixel);
|
||||
}
|
||||
|
||||
// Blit the image
|
||||
Rect r(x, y + m_Border, m_W, size);
|
||||
graphics.DrawImage(m_Bitmap, r, 0, m_Border, m_W, size, UnitPixel);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_Border > 0)
|
||||
{
|
||||
Rect r2(x, y + m_H - size - 2 * m_Border, m_W, m_Border);
|
||||
graphics.DrawImage(m_Bitmap, r2, 0, 0, m_W, m_Border, UnitPixel);
|
||||
r2.Y = y + m_H - m_Border;
|
||||
graphics.DrawImage(m_Bitmap, r2, 0, m_H - m_Border, m_W, m_Border, UnitPixel);
|
||||
}
|
||||
|
||||
// Blit the image
|
||||
Rect r(x, y + m_H - size - m_Border, m_W, size);
|
||||
graphics.DrawImage(m_Bitmap, r, 0, m_H - size - m_Border, m_W, size, UnitPixel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SolidBrush brush(m_Color);
|
||||
if (m_Flip)
|
||||
{
|
||||
Rect r(x, y, m_W, size);
|
||||
graphics.FillRectangle(&brush, r);
|
||||
}
|
||||
else
|
||||
{
|
||||
Rect r(x, y + m_H - size, m_W, size);
|
||||
graphics.FillRectangle(&brush, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int size = (int)((m_W - 2 * m_Border) * m_Value);
|
||||
size = min(m_W - 2 * m_Border, size);
|
||||
size = max(0, size);
|
||||
|
||||
if (m_Bitmap)
|
||||
{
|
||||
if (m_Flip)
|
||||
{
|
||||
if (m_Border > 0)
|
||||
{
|
||||
Rect r2(x + m_W - size - 2 * m_Border, y, m_Border, m_H);
|
||||
graphics.DrawImage(m_Bitmap, r2, 0, 0, m_Border, m_H, UnitPixel);
|
||||
r2.X = x + m_W - m_Border;
|
||||
graphics.DrawImage(m_Bitmap, r2, m_W - m_Border, 0, m_Border, m_H, UnitPixel);
|
||||
}
|
||||
|
||||
// Blit the image
|
||||
Rect r(x + m_W - size - m_Border, y, size, m_H);
|
||||
graphics.DrawImage(m_Bitmap, r, m_W - size - m_Border, 0, size, m_H, UnitPixel);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_Border > 0)
|
||||
{
|
||||
Rect r2(x, y, m_Border, m_H);
|
||||
graphics.DrawImage(m_Bitmap, r2, 0, 0, m_Border, m_H, UnitPixel);
|
||||
r2.X = x + size + m_Border;
|
||||
graphics.DrawImage(m_Bitmap, r2, m_W - m_Border, 0, m_Border, m_H, UnitPixel);
|
||||
}
|
||||
|
||||
// Blit the image
|
||||
Rect r(x + m_Border, y, size, m_H);
|
||||
graphics.DrawImage(m_Bitmap, r, m_Border, 0, size, m_H, UnitPixel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SolidBrush brush(m_Color);
|
||||
if (m_Flip)
|
||||
{
|
||||
Rect r(x + m_W - size, y, size, m_H);
|
||||
graphics.FillRectangle(&brush, r);
|
||||
}
|
||||
else
|
||||
{
|
||||
Rect r(x, y, size, m_H);
|
||||
graphics.FillRectangle(&brush, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
79
Library/MeterBar.h
Normal file
79
Library/MeterBar.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeterBar.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeterBar.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.6 2004/07/11 17:16:11 rainy
|
||||
Added BarBorder.
|
||||
|
||||
Revision 1.5 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.4 2003/02/10 18:12:45 rainy
|
||||
Now uses GDI+
|
||||
|
||||
Revision 1.3 2002/03/31 09:58:54 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.2 2001/09/26 16:26:23 rainy
|
||||
Small adjustement to the interfaces.
|
||||
|
||||
Revision 1.1 2001/09/01 12:56:25 rainy
|
||||
Initial version.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __METERBAR_H__
|
||||
#define __METERBAR_H__
|
||||
|
||||
#include "Meter.h"
|
||||
#include "MeterWindow.h"
|
||||
|
||||
class CMeterBar : public CMeter
|
||||
{
|
||||
public:
|
||||
CMeterBar(CMeterWindow* meterWindow);
|
||||
virtual ~CMeterBar();
|
||||
|
||||
virtual void ReadConfig(const WCHAR* section);
|
||||
virtual void Initialize();
|
||||
virtual bool Update();
|
||||
virtual bool Draw();
|
||||
|
||||
private:
|
||||
enum ORIENTATION
|
||||
{
|
||||
HORIZONTAL,
|
||||
VERTICAL
|
||||
};
|
||||
|
||||
Gdiplus::Color m_Color; // Color of the bar
|
||||
Gdiplus::Bitmap* m_Bitmap; // The bar bitmap
|
||||
ORIENTATION m_Orientation; // Orientation (i.e. the growth direction)
|
||||
std::wstring m_ImageName; // Name of the bar-image
|
||||
double m_Value;
|
||||
int m_Border;
|
||||
bool m_Flip;
|
||||
};
|
||||
|
||||
#endif
|
||||
393
Library/MeterBitmap.cpp
Normal file
393
Library/MeterBitmap.cpp
Normal file
@@ -0,0 +1,393 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeterBitmap.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeterBitmap.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.11 2004/07/11 17:16:55 rainy
|
||||
Bitmap must have at least one frame.
|
||||
|
||||
Revision 1.10 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.9 2003/02/10 18:12:45 rainy
|
||||
Now uses GDI+
|
||||
|
||||
Revision 1.8 2002/07/01 15:32:51 rainy
|
||||
Removed include to lsapi.h
|
||||
|
||||
Revision 1.7 2002/04/26 18:22:02 rainy
|
||||
Added possibility to hide the meter.
|
||||
|
||||
Revision 1.6 2002/03/31 20:32:29 rainy
|
||||
Added ZeroFrame, which uses the first frame only for value 0.
|
||||
|
||||
Revision 1.5 2002/03/31 09:58:54 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.4 2001/12/23 10:15:04 rainy
|
||||
Added one sanity check.
|
||||
|
||||
Revision 1.3 2001/10/14 07:32:33 rainy
|
||||
In error situations CError is thrown instead just a boolean value.
|
||||
|
||||
Revision 1.2 2001/09/26 16:26:23 rainy
|
||||
Small adjustement to the interfaces.
|
||||
|
||||
Revision 1.1 2001/09/01 12:56:25 rainy
|
||||
Initial version.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4786)
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeterBitmap.h"
|
||||
#include "Measure.h"
|
||||
#include "Error.h"
|
||||
#include "Rainmeter.h"
|
||||
|
||||
using namespace Gdiplus;
|
||||
|
||||
extern CRainmeter* Rainmeter;
|
||||
|
||||
/*
|
||||
** CMeterBitmap
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeterBitmap::CMeterBitmap(CMeterWindow* meterWindow) : CMeter(meterWindow)
|
||||
{
|
||||
m_Bitmap = NULL;
|
||||
m_FrameCount = 1;
|
||||
m_ZeroFrame = false;
|
||||
m_Align = ALIGN_LEFT;
|
||||
m_Extend = false;
|
||||
m_Separation = 0;
|
||||
m_Digits = 0;
|
||||
m_Value = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeterBitmap
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeterBitmap::~CMeterBitmap()
|
||||
{
|
||||
if(m_Bitmap != NULL) delete m_Bitmap;
|
||||
}
|
||||
|
||||
/*
|
||||
** Initialize
|
||||
**
|
||||
** Load the image and get the dimensions of the meter from it.
|
||||
**
|
||||
*/
|
||||
void CMeterBitmap::Initialize()
|
||||
{
|
||||
CMeter::Initialize();
|
||||
|
||||
// Load the bitmaps if defined
|
||||
if(!m_ImageName.empty())
|
||||
{
|
||||
m_Bitmap = new Bitmap(m_ImageName.c_str());
|
||||
Status status = m_Bitmap->GetLastStatus();
|
||||
if(Ok != status)
|
||||
{
|
||||
throw CError(std::wstring(L"Bitmap image not found: ") + m_ImageName, __LINE__, __FILE__);
|
||||
}
|
||||
|
||||
m_W = m_Bitmap->GetWidth();
|
||||
m_H = m_Bitmap->GetHeight();
|
||||
|
||||
if(m_H > m_W)
|
||||
{
|
||||
m_H = m_H / m_FrameCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_W = m_W / m_FrameCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** HitTest
|
||||
**
|
||||
** Checks if the given point is inside the meter.
|
||||
**
|
||||
*/
|
||||
bool CMeterBitmap::HitTest(int x, int y)
|
||||
{
|
||||
if (m_Extend)
|
||||
{
|
||||
int value = (int)m_Value;
|
||||
value = max(0, value); // Only positive integers are supported
|
||||
|
||||
int tmpValue = value;
|
||||
|
||||
// Calc the number of numbers
|
||||
int numOfNums = 0;
|
||||
|
||||
if (m_Digits > 0)
|
||||
{
|
||||
numOfNums = m_Digits;
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
numOfNums ++;
|
||||
if (m_FrameCount == 1)
|
||||
{
|
||||
tmpValue /= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpValue /= m_FrameCount;
|
||||
}
|
||||
} while (tmpValue > 0);
|
||||
}
|
||||
|
||||
Rect rect(GetX(), GetY(), m_W * numOfNums + (numOfNums - 1) * m_Separation, m_H);
|
||||
|
||||
if (m_Align == ALIGN_CENTER)
|
||||
{
|
||||
rect.Offset(-rect.Width / 2, 0);
|
||||
}
|
||||
else if (m_Align == ALIGN_RIGHT)
|
||||
{
|
||||
rect.Offset(-rect.Width, 0);
|
||||
}
|
||||
|
||||
if (rect.Contains(x, y))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return CMeter::HitTest(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Read the meter-specific configs from the ini-file.
|
||||
**
|
||||
*/
|
||||
void CMeterBitmap::ReadConfig(const WCHAR* section)
|
||||
{
|
||||
// Read common configs
|
||||
CMeter::ReadConfig(section);
|
||||
|
||||
CConfigParser& parser = m_MeterWindow->GetParser();
|
||||
|
||||
m_ImageName = parser.ReadString(section, L"BitmapImage", L"");
|
||||
m_ImageName = Rainmeter->FixPath(m_ImageName, PATH_FOLDER_CURRENT_SKIN, m_MeterWindow->GetSkinName());
|
||||
|
||||
m_FrameCount = parser.ReadInt(section, L"BitmapFrames", 1);
|
||||
m_ZeroFrame = 0!=parser.ReadInt(section, L"BitmapZeroFrame", 0);
|
||||
|
||||
m_Separation = parser.ReadInt(section, L"BitmapSeparation", 0);
|
||||
m_Extend = 0!=parser.ReadInt(section, L"BitmapExtend", 0);
|
||||
m_Digits = parser.ReadInt(section, L"BitmapDigits", 0);
|
||||
|
||||
std::wstring align;
|
||||
align = parser.ReadString(section, L"BitmapAlign", L"LEFT");
|
||||
|
||||
if(_wcsicmp(align.c_str(), L"LEFT") == 0)
|
||||
{
|
||||
m_Align = ALIGN_LEFT;
|
||||
}
|
||||
else if(_wcsicmp(align.c_str(), L"RIGHT") == 0)
|
||||
{
|
||||
m_Align = ALIGN_RIGHT;
|
||||
}
|
||||
else if(_wcsicmp(align.c_str(), L"CENTER") == 0)
|
||||
{
|
||||
m_Align = ALIGN_CENTER;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw CError(std::wstring(L"No such BitmapAlign: ") + align, __LINE__, __FILE__);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the value(s) from the measures.
|
||||
**
|
||||
*/
|
||||
bool CMeterBitmap::Update()
|
||||
{
|
||||
if (CMeter::Update() && m_Measure)
|
||||
{
|
||||
if (m_Extend)
|
||||
{
|
||||
m_Value = m_Measure->GetValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Value = m_Measure->GetRelativeValue();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
** Draw
|
||||
**
|
||||
** Draws the meter on the double buffer
|
||||
**
|
||||
*/
|
||||
bool CMeterBitmap::Draw()
|
||||
{
|
||||
if(!CMeter::Draw()) return false;
|
||||
|
||||
int newY, newX;
|
||||
|
||||
if(m_FrameCount == 0 || m_Bitmap == NULL) return false; // Unable to continue
|
||||
|
||||
int x = GetX();
|
||||
int y = GetY();
|
||||
|
||||
if (m_Extend)
|
||||
{
|
||||
int value = (int)m_Value;
|
||||
value = max(0, value); // Only positive integers are supported
|
||||
|
||||
int tmpValue = value;
|
||||
// Calc the number of numbers
|
||||
int numOfNums = 0;
|
||||
|
||||
if (m_Digits > 0)
|
||||
{
|
||||
numOfNums = m_Digits;
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
numOfNums ++;
|
||||
if (m_FrameCount == 1)
|
||||
{
|
||||
tmpValue /= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
tmpValue /= m_FrameCount;
|
||||
}
|
||||
} while (tmpValue > 0);
|
||||
}
|
||||
|
||||
// Blit the images
|
||||
int offset;
|
||||
Graphics graphics(m_MeterWindow->GetDoubleBuffer());
|
||||
|
||||
if (m_Align == ALIGN_RIGHT)
|
||||
{
|
||||
offset = 0;
|
||||
}
|
||||
else if (m_Align == ALIGN_CENTER)
|
||||
{
|
||||
offset = numOfNums * (m_W + m_Separation) / 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = numOfNums * (m_W + m_Separation);
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
offset = offset - (m_W + m_Separation);
|
||||
|
||||
Rect r(x + offset, y, m_W, m_H);
|
||||
|
||||
if(m_Bitmap->GetHeight() > m_Bitmap->GetWidth())
|
||||
{
|
||||
newX = 0;
|
||||
newY = m_H * (value % m_FrameCount);
|
||||
}
|
||||
else
|
||||
{
|
||||
newX = m_W * (value % m_FrameCount);
|
||||
newY = 0;
|
||||
}
|
||||
|
||||
graphics.DrawImage(m_Bitmap, r, newX, newY, m_W, m_H, UnitPixel);
|
||||
if (m_FrameCount == 1)
|
||||
{
|
||||
value /= 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
value /= m_FrameCount;
|
||||
}
|
||||
numOfNums--;
|
||||
} while (numOfNums > 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
int frame = 0;
|
||||
|
||||
if (m_ZeroFrame)
|
||||
{
|
||||
// Use the first frame only if the value is zero
|
||||
if (m_Value > 0)
|
||||
{
|
||||
frame = (int)(m_Value * (m_FrameCount - 1));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Select the correct frame linearly
|
||||
frame = (int)(m_Value * m_FrameCount);
|
||||
}
|
||||
|
||||
if(m_Bitmap->GetHeight() > m_Bitmap->GetWidth())
|
||||
{
|
||||
newX = 0;
|
||||
newY = frame * m_H;
|
||||
}
|
||||
else
|
||||
{
|
||||
newX = frame * m_W;
|
||||
newY = 0;
|
||||
}
|
||||
|
||||
// Blit the image
|
||||
Graphics graphics(m_MeterWindow->GetDoubleBuffer());
|
||||
Rect r(x, y, m_W, m_H);
|
||||
graphics.DrawImage(m_Bitmap, r, newX, newY, m_W, m_H, UnitPixel);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
77
Library/MeterBitmap.h
Normal file
77
Library/MeterBitmap.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeterBitmap.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeterBitmap.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.6 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.5 2003/02/10 18:12:45 rainy
|
||||
Now uses GDI+
|
||||
|
||||
Revision 1.4 2002/03/31 20:32:29 rainy
|
||||
Added ZeroFrame, which uses the first frame only for value 0.
|
||||
|
||||
Revision 1.3 2002/03/31 09:58:54 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.2 2001/09/26 16:26:23 rainy
|
||||
Small adjustement to the interfaces.
|
||||
|
||||
Revision 1.1 2001/09/01 12:56:25 rainy
|
||||
Initial version.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __METERBITMAP_H__
|
||||
#define __METERBITMAP_H__
|
||||
|
||||
#include "Meter.h"
|
||||
#include "MeterWindow.h"
|
||||
|
||||
class CMeterBitmap : public CMeter
|
||||
{
|
||||
public:
|
||||
CMeterBitmap(CMeterWindow* meterWindow);
|
||||
virtual ~CMeterBitmap();
|
||||
|
||||
virtual bool HitTest(int x, int y);
|
||||
|
||||
virtual void ReadConfig(const WCHAR* section);
|
||||
virtual void Initialize();
|
||||
virtual bool Update();
|
||||
virtual bool Draw();
|
||||
|
||||
private:
|
||||
bool m_ZeroFrame; // If true, the first frame is only shown when the measured value is zero
|
||||
int m_FrameCount; // Number of frames in the bitmap
|
||||
Gdiplus::Bitmap* m_Bitmap; // Handle to the bitmap
|
||||
std::wstring m_ImageName; // Name of the image
|
||||
METER_ALIGNMENT m_Align; // Alignment of the bitmaps
|
||||
bool m_Extend; // If true, bitmaps extend horizontally and are used like numbers
|
||||
int m_Separation;
|
||||
int m_Digits;
|
||||
double m_Value;
|
||||
};
|
||||
|
||||
#endif
|
||||
370
Library/MeterButton.cpp
Normal file
370
Library/MeterButton.cpp
Normal file
@@ -0,0 +1,370 @@
|
||||
/*
|
||||
Copyright (C) 2005 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeterButton.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeterButton.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4786)
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeterButton.h"
|
||||
#include "Measure.h"
|
||||
#include "Rainmeter.h"
|
||||
#include "Error.h"
|
||||
|
||||
extern CRainmeter* Rainmeter;
|
||||
|
||||
using namespace Gdiplus;
|
||||
|
||||
enum BUTTON_STATE
|
||||
{
|
||||
BUTTON_STATE_NORMAL,
|
||||
BUTTON_STATE_DOWN,
|
||||
BUTTON_STATE_HOVER
|
||||
};
|
||||
|
||||
/*
|
||||
** CMeterButton
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeterButton::CMeterButton(CMeterWindow* meterWindow) : CMeter(meterWindow)
|
||||
{
|
||||
for (int i = 0; i < BUTTON_FRAMES; i++)
|
||||
{
|
||||
m_Bitmaps[i] = NULL;;
|
||||
}
|
||||
m_Bitmap = NULL;
|
||||
m_State = BUTTON_STATE_NORMAL;
|
||||
m_Clicked = false;
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeterButton
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeterButton::~CMeterButton()
|
||||
{
|
||||
for (int i = 0; i < BUTTON_FRAMES; i++)
|
||||
{
|
||||
if (m_Bitmaps[i] != NULL) delete m_Bitmaps[i];
|
||||
}
|
||||
|
||||
if (m_Bitmap != NULL) delete m_Bitmap;
|
||||
}
|
||||
|
||||
/*
|
||||
** Initialize
|
||||
**
|
||||
** Load the image and get the dimensions of the meter from it.
|
||||
**
|
||||
*/
|
||||
void CMeterButton::Initialize()
|
||||
{
|
||||
CMeter::Initialize();
|
||||
|
||||
// Load the bitmaps if defined
|
||||
if(!m_ImageName.empty())
|
||||
{
|
||||
m_Bitmap = new Bitmap(m_ImageName.c_str());
|
||||
Status status = m_Bitmap->GetLastStatus();
|
||||
if(Ok != status)
|
||||
{
|
||||
throw CError(std::wstring(L"Bitmap image not found: ") + m_ImageName, __LINE__, __FILE__);
|
||||
}
|
||||
|
||||
m_W = m_Bitmap->GetWidth();
|
||||
m_H = m_Bitmap->GetHeight();
|
||||
|
||||
if(m_H > m_W)
|
||||
{
|
||||
m_H = m_H / BUTTON_FRAMES;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_W = m_W / BUTTON_FRAMES;
|
||||
}
|
||||
|
||||
// Separate the frames
|
||||
Graphics desktopGraphics(GetDesktopWindow());
|
||||
|
||||
for (int i = 0; i < BUTTON_FRAMES; i++)
|
||||
{
|
||||
Bitmap bitmapPart(m_W, m_H, PixelFormat32bppARGB);
|
||||
Graphics graphics(&bitmapPart);
|
||||
Rect r(0, 0, m_W, m_H);
|
||||
|
||||
if(m_Bitmap->GetHeight() > m_Bitmap->GetWidth())
|
||||
{
|
||||
graphics.DrawImage(m_Bitmap, r, 0, m_H * i, m_W, m_H, UnitPixel);
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics.DrawImage(m_Bitmap, r, m_W * i, 0, m_W, m_H, UnitPixel);
|
||||
}
|
||||
m_Bitmaps[i] = new CachedBitmap(&bitmapPart, &graphics);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Read the meter-specific configs from the ini-file.
|
||||
**
|
||||
*/
|
||||
void CMeterButton::ReadConfig(const WCHAR* section)
|
||||
{
|
||||
// Read common configs
|
||||
CMeter::ReadConfig(section);
|
||||
|
||||
CConfigParser& parser = m_MeterWindow->GetParser();
|
||||
|
||||
m_ImageName = parser.ReadString(section, L"ButtonImage", L"");
|
||||
m_ImageName = Rainmeter->FixPath(m_ImageName, PATH_FOLDER_CURRENT_SKIN, m_MeterWindow->GetSkinName());
|
||||
|
||||
m_Command = parser.ReadString(section, L"ButtonCommand", L"");
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the value(s) from the measures.
|
||||
**
|
||||
*/
|
||||
bool CMeterButton::Update()
|
||||
{
|
||||
return CMeter::Update();
|
||||
}
|
||||
|
||||
/*
|
||||
** Draw
|
||||
**
|
||||
** Draws the meter on the double buffer
|
||||
**
|
||||
*/
|
||||
bool CMeterButton::Draw()
|
||||
{
|
||||
if(!CMeter::Draw()) return false;
|
||||
|
||||
if (m_Bitmaps[m_State] == NULL) return false; // Unable to continue
|
||||
|
||||
int x = GetX();
|
||||
int y = GetY();
|
||||
|
||||
// Blit the image
|
||||
Graphics graphics(m_MeterWindow->GetDoubleBuffer());
|
||||
graphics.DrawCachedBitmap(m_Bitmaps[m_State], x, y);
|
||||
|
||||
// TEST
|
||||
/* HDC desktopDC = GetDC(GetDesktopWindow());
|
||||
HDC dc = CreateCompatibleDC(desktopDC);
|
||||
HBITMAP bm = CreateCompatibleBitmap(desktopDC, 200, 200);
|
||||
ReleaseDC(GetDesktopWindow(), desktopDC);
|
||||
HBITMAP oldBM = (HBITMAP)SelectObject(dc, bm);
|
||||
|
||||
Graphics dgfx(GetDesktopWindow());
|
||||
Bitmap nbg(200, 200, PixelFormat32bppARGB);
|
||||
Bitmap nbm(L"button.png");
|
||||
|
||||
Graphics gfx1(&nbg);
|
||||
Graphics gfx2(dc);
|
||||
|
||||
CachedBitmap cbm1(&nbm, &gfx1);
|
||||
CachedBitmap cbm2(&nbm, &gfx2);
|
||||
|
||||
Rect r(0, 0, nbm.GetWidth(), nbm.GetHeight());
|
||||
int i;
|
||||
|
||||
SolidBrush solid(Color(255, 155, 123, 232));
|
||||
|
||||
DWORD time = GetTickCount();
|
||||
for (i = 0; i < 1000000; i++)
|
||||
{
|
||||
gfx1.DrawImage(&nbm, r, 0, 0, nbm.GetWidth(), nbm.GetHeight(), UnitPixel);
|
||||
// gfx1.FillRectangle(&solid, 0, 0, nbm.GetWidth(), nbm.GetHeight()); // 2156
|
||||
}
|
||||
DebugLog("Bitmap 2 Bitmap: %i", GetTickCount() - time); // 469
|
||||
|
||||
time = GetTickCount();
|
||||
for (i = 0; i < 1000000; i++)
|
||||
{
|
||||
gfx1.DrawCachedBitmap(&cbm1, 0, 0);
|
||||
}
|
||||
DebugLog("CachedBitmap 2 Bitmap: %i", GetTickCount() - time); // 125
|
||||
|
||||
time = GetTickCount();
|
||||
for (i = 0; i < 1000000; i++)
|
||||
{
|
||||
gfx2.DrawImage(&nbm, r, 0, 0, nbm.GetWidth(), nbm.GetHeight(), UnitPixel);
|
||||
// gfx2.FillRectangle(&solid, 0, 0, nbm.GetWidth(), nbm.GetHeight()); // 797
|
||||
}
|
||||
DebugLog("Bitmap 2 CachedBitmap: %i", GetTickCount() - time); // 469
|
||||
|
||||
time = GetTickCount();
|
||||
for (i = 0; i < 1000000; i++)
|
||||
{
|
||||
gfx2.DrawCachedBitmap(&cbm1, 0, 0);
|
||||
}
|
||||
DebugLog("CachedBitmap 2 CachedBitmap: %i", GetTickCount() - time); // 109
|
||||
|
||||
time = GetTickCount();
|
||||
for (i = 0; i < 1000000; i++)
|
||||
{
|
||||
gfx2.DrawCachedBitmap(&cbm2, 0, 0);
|
||||
}
|
||||
DebugLog("CachedBitmap 2 CachedBitmap 2: %i", GetTickCount() - time); // 125
|
||||
|
||||
SelectObject(dc, oldBM);
|
||||
DeleteDC(dc);
|
||||
DeleteObject(bm);
|
||||
*/
|
||||
// ~TEST
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
** BindMeasure
|
||||
**
|
||||
** Overridden method. The Image meters need not to be bound on anything
|
||||
**
|
||||
*/
|
||||
void CMeterButton::BindMeasure(std::list<CMeasure*>& measures)
|
||||
{
|
||||
try
|
||||
{
|
||||
CMeter::BindMeasure(measures);
|
||||
}
|
||||
catch(CError)
|
||||
{
|
||||
// Do nothing (ignore errors)
|
||||
}
|
||||
}
|
||||
|
||||
bool CMeterButton::MouseUp(POINT pos, CMeterWindow* window)
|
||||
{
|
||||
int x = GetX();
|
||||
int y = GetY();
|
||||
|
||||
if (m_State == BUTTON_STATE_DOWN)
|
||||
{
|
||||
if (m_Clicked &&
|
||||
pos.x >= x && pos.x <= x + m_W &&
|
||||
pos.y >= y && pos.y <= y + m_H)
|
||||
{
|
||||
Color color;
|
||||
m_Bitmap->GetPixel(pos.x - x + m_W * m_State, pos.y - y, &color);
|
||||
|
||||
if (color.GetA() > 0)
|
||||
{
|
||||
// Do a delayed execute or ortherwise !RainmeterRefresh crashes
|
||||
PostMessage(window->GetWindow(), WM_DELAYED_EXECUTE, (WPARAM)NULL, (LPARAM)m_Command.c_str());
|
||||
}
|
||||
}
|
||||
m_State = BUTTON_STATE_NORMAL;
|
||||
m_Clicked = false;
|
||||
return true;
|
||||
}
|
||||
m_Clicked = false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMeterButton::MouseDown(POINT pos)
|
||||
{
|
||||
int x = GetX();
|
||||
int y = GetY();
|
||||
|
||||
if (pos.x >= x && pos.x <= x + m_W &&
|
||||
pos.y >= y && pos.y <= y + m_H)
|
||||
{
|
||||
Color color;
|
||||
m_Bitmap->GetPixel(pos.x - x + m_W * m_State, pos.y - y, &color);
|
||||
|
||||
if (color.GetA() > 0)
|
||||
{
|
||||
m_State = BUTTON_STATE_DOWN;
|
||||
m_Clicked = true;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CMeterButton::MouseMove(POINT pos)
|
||||
{
|
||||
int x = GetX();
|
||||
int y = GetY();
|
||||
|
||||
if (m_Clicked == true)
|
||||
{
|
||||
if (pos.x >= x && pos.x <= x + m_W &&
|
||||
pos.y >= y && pos.y <= y + m_H)
|
||||
{
|
||||
Color color;
|
||||
m_Bitmap->GetPixel(pos.x - x + m_W * m_State, pos.y - y, &color);
|
||||
|
||||
if (color.GetA() > 0)
|
||||
{
|
||||
if (m_State == BUTTON_STATE_NORMAL)
|
||||
{
|
||||
m_State = BUTTON_STATE_DOWN;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_State == BUTTON_STATE_DOWN)
|
||||
{
|
||||
m_State = BUTTON_STATE_NORMAL;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pos.x >= x && pos.x <= x + m_W &&
|
||||
pos.y >= y && pos.y <= y + m_H)
|
||||
{
|
||||
if (m_State == BUTTON_STATE_NORMAL)
|
||||
{
|
||||
m_State = BUTTON_STATE_HOVER;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_State == BUTTON_STATE_HOVER)
|
||||
{
|
||||
m_State = BUTTON_STATE_NORMAL;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
60
Library/MeterButton.h
Normal file
60
Library/MeterButton.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright (C) 2005 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeterButton.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeterButton.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __METERBUTTON_H__
|
||||
#define __METERBUTTON_H__
|
||||
|
||||
#include "Meter.h"
|
||||
#include "MeterWindow.h"
|
||||
|
||||
#define BUTTON_FRAMES 3
|
||||
|
||||
class CMeterButton : public CMeter
|
||||
{
|
||||
public:
|
||||
CMeterButton(CMeterWindow* meterWindow);
|
||||
virtual ~CMeterButton();
|
||||
|
||||
virtual void ReadConfig(const WCHAR* section);
|
||||
virtual void Initialize();
|
||||
virtual bool Update();
|
||||
virtual bool Draw();
|
||||
virtual void BindMeasure(std::list<CMeasure*>& measures);
|
||||
|
||||
bool MouseMove(POINT pos);
|
||||
bool MouseUp(POINT pos, CMeterWindow* window);
|
||||
bool MouseDown(POINT pos);
|
||||
|
||||
private:
|
||||
Gdiplus::Bitmap* m_Bitmap; // The bitmap
|
||||
Gdiplus::CachedBitmap* m_Bitmaps[BUTTON_FRAMES]; // The cached bitmaps
|
||||
std::wstring m_ImageName; // Name of the image
|
||||
std::wstring m_Command; // Command to be executed
|
||||
int m_State;
|
||||
bool m_Clicked;
|
||||
};
|
||||
|
||||
#endif
|
||||
496
Library/MeterHistogram.cpp
Normal file
496
Library/MeterHistogram.cpp
Normal file
@@ -0,0 +1,496 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeterHistogram.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeterHistogram.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.17 2004/07/11 17:17:23 rainy
|
||||
Fixed a crash bug with max value.
|
||||
|
||||
Revision 1.16 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.15 2003/02/10 18:12:45 rainy
|
||||
Now uses GDI+
|
||||
|
||||
Revision 1.14 2002/07/01 15:32:51 rainy
|
||||
Removed include to lsapi.h
|
||||
|
||||
Revision 1.13 2002/05/04 08:14:11 rainy
|
||||
Histogram now draws the lines one pixel higher.
|
||||
|
||||
Revision 1.12 2002/04/26 18:28:17 rainy
|
||||
The meter is not updated if both measures are disabled.
|
||||
|
||||
Revision 1.11 2002/04/26 18:22:02 rainy
|
||||
Added possibility to hide the meter.
|
||||
|
||||
Revision 1.10 2002/03/31 09:58:53 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.9 2001/12/23 10:14:51 rainy
|
||||
Hex color values are now also supported.
|
||||
|
||||
Revision 1.8 2001/10/28 10:19:40 rainy
|
||||
Fixed a bug with secondary measure not set correctly
|
||||
|
||||
Revision 1.7 2001/10/14 07:32:33 rainy
|
||||
In error situations CError is thrown instead just a boolean value.
|
||||
|
||||
Revision 1.6 2001/09/26 16:26:37 rainy
|
||||
Small adjustement to the interfaces.
|
||||
Implemented BindMeasure()
|
||||
|
||||
Revision 1.5 2001/09/01 12:58:48 rainy
|
||||
Removed MaxValues (i.e. they aren't stored anymore).
|
||||
Fixed a bug in bitmap histogram placement.
|
||||
|
||||
Revision 1.4 2001/08/25 17:07:28 rainy
|
||||
Added support for background images behind the curves.
|
||||
|
||||
Revision 1.3 2001/08/19 09:13:13 rainy
|
||||
Invert moved to the measures.
|
||||
|
||||
Revision 1.2 2001/08/12 15:38:54 Rainy
|
||||
Adjusted Update()'s interface.
|
||||
Added invert for the secondary measure.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4786)
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeterHistogram.h"
|
||||
#include "Measure.h"
|
||||
#include "Error.h"
|
||||
#include "Rainmeter.h"
|
||||
|
||||
using namespace Gdiplus;
|
||||
|
||||
extern CRainmeter* Rainmeter;
|
||||
|
||||
/*
|
||||
** CMeterHistogram
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeterHistogram::CMeterHistogram(CMeterWindow* meterWindow) : CMeter(meterWindow)
|
||||
{
|
||||
m_SecondaryMeasure = NULL;
|
||||
m_PrimaryColor = 0;
|
||||
m_SecondaryColor = 0;
|
||||
m_BothColor = 0;
|
||||
m_MeterPos = 0;
|
||||
m_PrimaryBitmap = NULL;
|
||||
m_SecondaryBitmap = NULL;
|
||||
m_BothBitmap = NULL;
|
||||
m_PrimaryValues = NULL;
|
||||
m_SecondaryValues = NULL;
|
||||
m_Autoscale = false;
|
||||
m_Flip = false;
|
||||
m_MaxPrimaryValue = 1.0;
|
||||
m_MinPrimaryValue = 0.0;
|
||||
m_MaxSecondaryValue = 1.0;
|
||||
m_MinSecondaryValue = 0.0;
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeterHistogram
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeterHistogram::~CMeterHistogram()
|
||||
{
|
||||
if (m_PrimaryBitmap) delete m_PrimaryBitmap;
|
||||
if (m_SecondaryBitmap) delete m_SecondaryBitmap;
|
||||
if (m_BothBitmap) delete m_BothBitmap;
|
||||
if (m_PrimaryValues) delete [] m_PrimaryValues;
|
||||
if (m_SecondaryValues) delete [] m_SecondaryValues;
|
||||
}
|
||||
|
||||
/*
|
||||
** Initialize
|
||||
**
|
||||
** Load the images and calculate the dimensions of the meter from them.
|
||||
** Or create the brushes if solid color histogram is used.
|
||||
**
|
||||
*/
|
||||
void CMeterHistogram::Initialize()
|
||||
{
|
||||
CMeter::Initialize();
|
||||
|
||||
// Load the bitmaps if defined
|
||||
if(!m_PrimaryImageName.empty())
|
||||
{
|
||||
m_PrimaryBitmap = new Bitmap(m_PrimaryImageName.c_str());
|
||||
Status status = m_PrimaryBitmap->GetLastStatus();
|
||||
if(Ok != status)
|
||||
{
|
||||
throw CError(std::wstring(L"PrimaryImage not found: ") + m_PrimaryImageName, __LINE__, __FILE__);
|
||||
}
|
||||
|
||||
m_W = m_PrimaryBitmap->GetWidth();
|
||||
m_H = m_PrimaryBitmap->GetHeight();
|
||||
}
|
||||
|
||||
if(!m_SecondaryImageName.empty())
|
||||
{
|
||||
m_SecondaryBitmap = new Bitmap(m_SecondaryImageName.c_str());
|
||||
Status status = m_SecondaryBitmap->GetLastStatus();
|
||||
if(Ok != status)
|
||||
{
|
||||
throw CError(std::wstring(L"SecondaryImage not found: ") + m_SecondaryImageName, __LINE__, __FILE__);
|
||||
}
|
||||
}
|
||||
|
||||
if(!m_BothImageName.empty())
|
||||
{
|
||||
m_BothBitmap = new Bitmap(m_BothImageName.c_str());
|
||||
Status status = m_BothBitmap->GetLastStatus();
|
||||
if(Ok != status)
|
||||
{
|
||||
throw CError(std::wstring(L"BothImage not found: ") + m_BothImageName, __LINE__, __FILE__);
|
||||
}
|
||||
}
|
||||
|
||||
// A sanity check
|
||||
if (m_SecondaryMeasure && !m_PrimaryImageName.empty() && (m_BothImageName.empty() || m_SecondaryImageName.empty()))
|
||||
{
|
||||
throw CError(std::wstring(L"You need to define SecondaryImage and BothImage also!"), __LINE__, __FILE__);
|
||||
}
|
||||
|
||||
// Create buffers for values
|
||||
m_PrimaryValues = new double[m_W];
|
||||
memset(m_PrimaryValues, 0, sizeof(double) * m_W);
|
||||
if (m_SecondaryMeasure)
|
||||
{
|
||||
m_SecondaryValues = new double[m_W];
|
||||
memset(m_SecondaryValues, 0, sizeof(double) * m_W);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Read the meter-specific configs from the ini-file.
|
||||
**
|
||||
*/
|
||||
void CMeterHistogram::ReadConfig(const WCHAR* section)
|
||||
{
|
||||
// Read common configs
|
||||
CMeter::ReadConfig(section);
|
||||
|
||||
CConfigParser& parser = m_MeterWindow->GetParser();
|
||||
|
||||
m_PrimaryColor = parser.ReadColor(section, L"PrimaryColor", Color::Green);
|
||||
m_SecondaryColor = parser.ReadColor(section, L"SecondaryColor", Color::Red);
|
||||
m_BothColor = parser.ReadColor(section, L"BothColor", Color::Yellow);
|
||||
|
||||
m_SecondaryMeasureName = parser.ReadString(section, L"SecondaryMeasureName", L"");
|
||||
|
||||
m_PrimaryImageName = parser.ReadString(section, L"PrimaryImage", L"");
|
||||
m_PrimaryImageName = Rainmeter->FixPath(m_PrimaryImageName, PATH_FOLDER_CURRENT_SKIN, m_MeterWindow->GetSkinName());
|
||||
|
||||
m_SecondaryImageName = parser.ReadString(section, L"SecondaryImage", L"");
|
||||
m_SecondaryImageName = Rainmeter->FixPath(m_SecondaryImageName, PATH_FOLDER_CURRENT_SKIN, m_MeterWindow->GetSkinName());
|
||||
|
||||
m_BothImageName = parser.ReadString(section, L"BothImage", L"");
|
||||
m_BothImageName = Rainmeter->FixPath(m_BothImageName, PATH_FOLDER_CURRENT_SKIN, m_MeterWindow->GetSkinName());
|
||||
|
||||
m_Autoscale = 0!=parser.ReadInt(section, L"AutoScale", 0);
|
||||
m_Flip = 0!=parser.ReadInt(section, L"Flip", 0);
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the value(s) from the measures.
|
||||
**
|
||||
*/
|
||||
bool CMeterHistogram::Update()
|
||||
{
|
||||
if (CMeter::Update() && m_Measure)
|
||||
{
|
||||
// Gather values
|
||||
m_PrimaryValues[m_MeterPos] = m_Measure->GetValue();
|
||||
|
||||
if (m_SecondaryMeasure != NULL)
|
||||
{
|
||||
m_SecondaryValues[m_MeterPos] = m_SecondaryMeasure->GetValue();
|
||||
}
|
||||
|
||||
m_MeterPos++;
|
||||
m_MeterPos %= m_W;
|
||||
|
||||
m_MaxPrimaryValue = m_Measure->GetMaxValue();
|
||||
m_MinPrimaryValue = m_Measure->GetMinValue();
|
||||
m_MaxSecondaryValue = 0;
|
||||
m_MinSecondaryValue = 0;
|
||||
if (m_SecondaryMeasure)
|
||||
{
|
||||
m_MaxSecondaryValue = m_SecondaryMeasure->GetMaxValue();
|
||||
m_MinSecondaryValue = m_SecondaryMeasure->GetMinValue();
|
||||
}
|
||||
|
||||
if (m_Autoscale)
|
||||
{
|
||||
// Go through all values and find the max
|
||||
|
||||
int i;
|
||||
double newValue = 0;
|
||||
for (i = 0; i != m_W; i++)
|
||||
{
|
||||
newValue = max(newValue, m_PrimaryValues[i]);
|
||||
}
|
||||
|
||||
// Scale the value up to nearest power of 2
|
||||
m_MaxPrimaryValue = 2;
|
||||
while(m_MaxPrimaryValue < newValue && m_MaxPrimaryValue != 0)
|
||||
{
|
||||
m_MaxPrimaryValue *= 2;
|
||||
}
|
||||
|
||||
if (m_SecondaryMeasure)
|
||||
{
|
||||
for (i = 0; i != m_W; i++)
|
||||
{
|
||||
newValue = max(newValue, m_SecondaryValues[i]);
|
||||
}
|
||||
|
||||
// Scale the value up to nearest power of 2
|
||||
m_MaxSecondaryValue = 2;
|
||||
while(m_MaxSecondaryValue < newValue && m_MaxSecondaryValue != 0)
|
||||
{
|
||||
m_MaxSecondaryValue *= 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
** Draw
|
||||
**
|
||||
** Draws the meter on the double buffer
|
||||
**
|
||||
*/
|
||||
bool CMeterHistogram::Draw()
|
||||
{
|
||||
if(!CMeter::Draw()) return false;
|
||||
|
||||
Graphics graphics(m_MeterWindow->GetDoubleBuffer());
|
||||
Pen primaryPen(m_PrimaryColor);
|
||||
Pen secondaryPen(m_SecondaryColor);
|
||||
Pen bothPen(m_BothColor);
|
||||
|
||||
int x = GetX();
|
||||
int y = GetY();
|
||||
|
||||
for (int i = 0; i < m_W; i++)
|
||||
{
|
||||
double value;
|
||||
|
||||
if (m_MaxPrimaryValue == 0.0)
|
||||
{
|
||||
value = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = m_PrimaryValues[(i + m_MeterPos) % m_W] / m_MaxPrimaryValue;
|
||||
}
|
||||
value -= m_MinPrimaryValue;
|
||||
int primaryBarHeight = (int)(m_H * value);
|
||||
primaryBarHeight = min(m_H, primaryBarHeight);
|
||||
primaryBarHeight = max(0, primaryBarHeight);
|
||||
|
||||
if (m_SecondaryMeasure != NULL)
|
||||
{
|
||||
if (m_MaxSecondaryValue == 0.0)
|
||||
{
|
||||
value = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
value = m_SecondaryValues[(i + m_MeterPos) % m_W] / m_MaxSecondaryValue;
|
||||
}
|
||||
value -= m_MinSecondaryValue;
|
||||
int secondaryBarHeight = (int)(m_H * value);
|
||||
secondaryBarHeight = min(m_H, secondaryBarHeight);
|
||||
secondaryBarHeight = max(0, secondaryBarHeight);
|
||||
|
||||
// Check which measured value is higher
|
||||
int bothBarHeight;
|
||||
if (secondaryBarHeight > primaryBarHeight)
|
||||
{
|
||||
bothBarHeight = primaryBarHeight;
|
||||
}
|
||||
else
|
||||
{
|
||||
bothBarHeight = secondaryBarHeight;
|
||||
}
|
||||
|
||||
// Draw image/color for the both lines
|
||||
if (m_PrimaryBitmap)
|
||||
{
|
||||
if (m_Flip)
|
||||
{
|
||||
Rect r(x + i, y + bothBarHeight, 1, -bothBarHeight);
|
||||
graphics.DrawImage(m_BothBitmap, r, i, m_H - bothBarHeight, 1, bothBarHeight, UnitPixel);
|
||||
}
|
||||
else
|
||||
{
|
||||
Rect r(x + i, y + m_H - bothBarHeight, 1, bothBarHeight);
|
||||
graphics.DrawImage(m_BothBitmap, r, i, m_H - bothBarHeight, 1, bothBarHeight, UnitPixel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_Flip)
|
||||
{
|
||||
graphics.DrawLine(&bothPen, x + i, y, x + i, y + bothBarHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics.DrawLine(&bothPen, x + i, y + m_H, x + i, y + m_H - bothBarHeight);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw the image/color for the rest
|
||||
if (secondaryBarHeight > primaryBarHeight)
|
||||
{
|
||||
if (m_SecondaryBitmap)
|
||||
{
|
||||
if (m_Flip)
|
||||
{
|
||||
Rect r(x + i, y + secondaryBarHeight, 1, -(secondaryBarHeight - bothBarHeight));
|
||||
graphics.DrawImage(m_SecondaryBitmap, r, i, m_H - secondaryBarHeight, 1, secondaryBarHeight - bothBarHeight, UnitPixel);
|
||||
}
|
||||
else
|
||||
{
|
||||
Rect r(x + i, y + m_H - secondaryBarHeight, 1, secondaryBarHeight - bothBarHeight);
|
||||
graphics.DrawImage(m_SecondaryBitmap, r, i, m_H - secondaryBarHeight, 1, secondaryBarHeight - bothBarHeight, UnitPixel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_Flip)
|
||||
{
|
||||
graphics.DrawLine(&secondaryPen, x + i, y + bothBarHeight, x + i, y + secondaryBarHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics.DrawLine(&secondaryPen, x + i, y + m_H - bothBarHeight, x + i, y + m_H - secondaryBarHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_PrimaryBitmap)
|
||||
{
|
||||
if (m_Flip)
|
||||
{
|
||||
Rect r(x + i, y + primaryBarHeight, 1, -(primaryBarHeight - bothBarHeight));
|
||||
graphics.DrawImage(m_PrimaryBitmap, r, i, m_H - primaryBarHeight, 1, primaryBarHeight - bothBarHeight, UnitPixel);
|
||||
}
|
||||
else
|
||||
{
|
||||
Rect r(x + i, y + m_H - primaryBarHeight, 1, primaryBarHeight - bothBarHeight);
|
||||
graphics.DrawImage(m_PrimaryBitmap, r, i, m_H - primaryBarHeight, 1, primaryBarHeight - bothBarHeight, UnitPixel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_Flip)
|
||||
{
|
||||
graphics.DrawLine(&primaryPen, x + i, y, x + i, y + primaryBarHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics.DrawLine(&primaryPen, x + i, y + m_H - bothBarHeight, x + i, y + m_H - primaryBarHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_PrimaryBitmap)
|
||||
{
|
||||
if (m_Flip)
|
||||
{
|
||||
Rect r(x + i, y + primaryBarHeight, 1, -primaryBarHeight);
|
||||
graphics.DrawImage(m_PrimaryBitmap, r, i, m_H - primaryBarHeight, 1, primaryBarHeight, UnitPixel);
|
||||
}
|
||||
else
|
||||
{
|
||||
Rect r(x + i, y + m_H - primaryBarHeight, 1, primaryBarHeight);
|
||||
graphics.DrawImage(m_PrimaryBitmap, r, i, m_H - primaryBarHeight, 1, primaryBarHeight, UnitPixel);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_Flip)
|
||||
{
|
||||
graphics.DrawLine(&primaryPen, x + i, y, x + i, y + primaryBarHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics.DrawLine(&primaryPen, x + i, y + m_H, x + i, y + m_H - primaryBarHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
** BindMeasure
|
||||
**
|
||||
** Overwritten method to handle the secondary measure binding.
|
||||
**
|
||||
*/
|
||||
void CMeterHistogram::BindMeasure(std::list<CMeasure*>& measures)
|
||||
{
|
||||
CMeter::BindMeasure(measures);
|
||||
|
||||
if(!m_SecondaryMeasureName.empty())
|
||||
{
|
||||
// Go through the list and check it there is a secondary measure for us
|
||||
std::list<CMeasure*>::iterator i = measures.begin();
|
||||
for( ; i != measures.end(); i++)
|
||||
{
|
||||
if(_wcsicmp((*i)->GetName(), m_SecondaryMeasureName.c_str()) == 0)
|
||||
{
|
||||
m_SecondaryMeasure = (*i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
throw CError(std::wstring(L"The meter [") + m_Name + L"] cannot be bound with [" + m_SecondaryMeasureName + L"]!", __LINE__, __FILE__);
|
||||
}
|
||||
}
|
||||
102
Library/MeterHistogram.h
Normal file
102
Library/MeterHistogram.h
Normal file
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeterHistogram.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeterHistogram.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.9 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.8 2003/02/10 18:12:45 rainy
|
||||
Now uses GDI+
|
||||
|
||||
Revision 1.7 2002/03/31 09:58:53 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.6 2001/09/26 16:26:23 rainy
|
||||
Small adjustement to the interfaces.
|
||||
|
||||
Revision 1.5 2001/09/01 12:58:48 rainy
|
||||
Removed MaxValues (i.e. they aren't stored anymore).
|
||||
Fixed a bug in bitmap histogram placement.
|
||||
|
||||
Revision 1.4 2001/08/25 17:07:28 rainy
|
||||
Added support for background images behind the curves.
|
||||
|
||||
Revision 1.3 2001/08/19 09:13:13 rainy
|
||||
Invert moved to the measures.
|
||||
|
||||
Revision 1.2 2001/08/12 15:38:54 Rainy
|
||||
Adjusted Update()'s interface.
|
||||
Added invert for the secondary measure.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __METERHISTOGRAM_H__
|
||||
#define __METERHISTOGRAM_H__
|
||||
|
||||
#include "Meter.h"
|
||||
#include "MeterWindow.h"
|
||||
|
||||
class CMeterHistogram : public CMeter
|
||||
{
|
||||
public:
|
||||
CMeterHistogram(CMeterWindow* meterWindow);
|
||||
virtual ~CMeterHistogram();
|
||||
|
||||
virtual void ReadConfig(const WCHAR* section);
|
||||
virtual void Initialize();
|
||||
virtual bool Update();
|
||||
virtual bool Draw();
|
||||
virtual void BindMeasure(std::list<CMeasure*>& measures);
|
||||
|
||||
private:
|
||||
std::wstring m_SecondaryMeasureName; // Name of the secondary measure
|
||||
CMeasure* m_SecondaryMeasure; // Pointer ot the secondary measure
|
||||
Gdiplus::Color m_PrimaryColor; // Color of the primary histogram
|
||||
Gdiplus::Color m_SecondaryColor; // Color of the secondary histogram
|
||||
Gdiplus::Color m_BothColor; // Color when the both histograms overlap
|
||||
|
||||
int m_MeterPos; // Position of the meter (i.e. where the new value should be placed)
|
||||
bool m_Autoscale;
|
||||
bool m_Flip;
|
||||
|
||||
std::wstring m_PrimaryImageName; // Name of the primary image for bitmap histograms
|
||||
std::wstring m_SecondaryImageName; // Name of the secondary image for bitmap histograms
|
||||
std::wstring m_BothImageName; // Name of the image for overlapping histograms
|
||||
|
||||
Gdiplus::Bitmap* m_PrimaryBitmap; // The primary bitmap
|
||||
Gdiplus::Bitmap* m_SecondaryBitmap; // The secondary bitmap
|
||||
Gdiplus::Bitmap* m_BothBitmap; // The overlap bitmap
|
||||
|
||||
double* m_PrimaryValues;
|
||||
double* m_SecondaryValues;
|
||||
|
||||
double m_MaxPrimaryValue;
|
||||
double m_MinPrimaryValue;
|
||||
double m_MaxSecondaryValue;
|
||||
double m_MinSecondaryValue;
|
||||
};
|
||||
|
||||
#endif
|
||||
289
Library/MeterImage.cpp
Normal file
289
Library/MeterImage.cpp
Normal file
@@ -0,0 +1,289 @@
|
||||
/*
|
||||
Copyright (C) 2002 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeterImage.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeterImage.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.7 2004/08/13 15:44:57 rainy
|
||||
Loading images don't lock the file anymore.
|
||||
|
||||
Revision 1.6 2004/07/11 17:17:48 rainy
|
||||
The image is not locked anymore on disk.
|
||||
|
||||
Revision 1.5 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.4 2003/12/05 15:50:10 Rainy
|
||||
Multi-instance changes.
|
||||
|
||||
Revision 1.3 2003/02/10 18:12:45 rainy
|
||||
Now uses GDI+
|
||||
|
||||
Revision 1.2 2002/07/01 15:32:50 rainy
|
||||
Removed include to lsapi.h
|
||||
|
||||
Revision 1.1 2002/04/27 10:28:31 rainy
|
||||
Intial version.
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4786)
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeterImage.h"
|
||||
#include "Measure.h"
|
||||
#include "Error.h"
|
||||
#include "Rainmeter.h"
|
||||
|
||||
extern CRainmeter* Rainmeter;
|
||||
|
||||
using namespace Gdiplus;
|
||||
|
||||
/*
|
||||
** CMeterImage
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeterImage::CMeterImage(CMeterWindow* meterWindow) : CMeter(meterWindow)
|
||||
{
|
||||
m_Bitmap = NULL;
|
||||
m_DimensionsDefined = false;
|
||||
m_hBuffer = NULL;
|
||||
m_Modified.dwHighDateTime = 0;
|
||||
m_Modified.dwLowDateTime = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeterImage
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeterImage::~CMeterImage()
|
||||
{
|
||||
if(m_Bitmap != NULL) delete m_Bitmap;
|
||||
|
||||
if (m_hBuffer)
|
||||
{
|
||||
::GlobalFree(m_hBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Initialize
|
||||
**
|
||||
** Load the image and get the dimensions of the meter from it.
|
||||
**
|
||||
*/
|
||||
void CMeterImage::Initialize()
|
||||
{
|
||||
CMeter::Initialize();
|
||||
|
||||
LoadImage(true);
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Loads the image from disk
|
||||
**
|
||||
*/
|
||||
void CMeterImage::LoadImage(bool bLoadAlways)
|
||||
{
|
||||
// Load the bitmap if defined
|
||||
if (!m_ImageName.empty())
|
||||
{
|
||||
std::wstring filename = m_ImageName;
|
||||
|
||||
// Check extension and if it is missing, add .png
|
||||
size_t pos = filename.find_last_of(L"\\");
|
||||
if (pos == std::wstring::npos) pos = 0;
|
||||
if (std::wstring::npos == filename.find(L'.', pos))
|
||||
{
|
||||
filename += L".png";
|
||||
}
|
||||
|
||||
// Read the bitmap to memory so that it's not locked by GDI+
|
||||
HANDLE fileHandle = CreateFile(filename.c_str(), GENERIC_READ, NULL, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (fileHandle != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
// Compare the timestamp and filename to check if the file has been changed (don't load if it's not)
|
||||
FILETIME tmpTime;
|
||||
GetFileTime(fileHandle, NULL, NULL, &tmpTime);
|
||||
if (bLoadAlways || CompareFileTime(&tmpTime, &m_Modified) != 0)
|
||||
{
|
||||
m_Modified = tmpTime;
|
||||
|
||||
DWORD imageSize = GetFileSize(fileHandle, 0);
|
||||
|
||||
if (imageSize != -1)
|
||||
{
|
||||
if (m_hBuffer)
|
||||
{
|
||||
::GlobalFree(m_hBuffer);
|
||||
}
|
||||
|
||||
m_hBuffer = ::GlobalAlloc(GMEM_MOVEABLE, imageSize);
|
||||
if (m_hBuffer)
|
||||
{
|
||||
void* pBuffer = ::GlobalLock(m_hBuffer);
|
||||
if (pBuffer)
|
||||
{
|
||||
DWORD readBytes;
|
||||
ReadFile(fileHandle, pBuffer, imageSize, &readBytes, NULL);
|
||||
::GlobalUnlock(m_hBuffer);
|
||||
|
||||
IStream* pStream = NULL;
|
||||
if (::CreateStreamOnHGlobal(m_hBuffer, FALSE, &pStream) == S_OK)
|
||||
{
|
||||
if (m_Bitmap) delete m_Bitmap;
|
||||
|
||||
m_Bitmap = Bitmap::FromStream(pStream);
|
||||
if (m_Bitmap)
|
||||
{
|
||||
Status status = m_Bitmap->GetLastStatus();
|
||||
if(Ok != status)
|
||||
{
|
||||
DebugLog(L"Unable to create bitmap: %s", filename.c_str());
|
||||
delete m_Bitmap;
|
||||
m_Bitmap = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
pStream->Release();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CloseHandle(fileHandle);
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugLog(L"Unable to load image: %s", filename.c_str());
|
||||
}
|
||||
|
||||
if (m_Bitmap)
|
||||
{
|
||||
if (!m_DimensionsDefined)
|
||||
{
|
||||
m_W = m_Bitmap->GetWidth();
|
||||
m_H = m_Bitmap->GetHeight();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Read the meter-specific configs from the ini-file.
|
||||
**
|
||||
*/
|
||||
void CMeterImage::ReadConfig(const WCHAR* section)
|
||||
{
|
||||
// Read common configs
|
||||
CMeter::ReadConfig(section);
|
||||
|
||||
CConfigParser& parser = m_MeterWindow->GetParser();
|
||||
|
||||
m_ImageName = parser.ReadString(section, L"ImageName", L"");
|
||||
m_ImageName = Rainmeter->FixPath(m_ImageName, PATH_FOLDER_CURRENT_SKIN, m_MeterWindow->GetSkinName());
|
||||
|
||||
if (-1 != parser.ReadInt(section, L"W", -1) && -1 != parser.ReadInt(section, L"H", -1))
|
||||
{
|
||||
m_DimensionsDefined = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the value(s) from the measures.
|
||||
**
|
||||
*/
|
||||
bool CMeterImage::Update()
|
||||
{
|
||||
if (CMeter::Update() && m_Measure)
|
||||
{
|
||||
std::wstring val = m_Measure->GetStringValue(false, 1, 0, false);
|
||||
if (!val.empty())
|
||||
{
|
||||
// Load the new image
|
||||
val = Rainmeter->FixPath(val, PATH_FOLDER_CURRENT_SKIN, m_MeterWindow->GetSkinName());
|
||||
if (val != m_ImageName)
|
||||
{
|
||||
m_ImageName = val;
|
||||
LoadImage(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
LoadImage(false);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
** Draw
|
||||
**
|
||||
** Draws the meter on the double buffer
|
||||
**
|
||||
*/
|
||||
bool CMeterImage::Draw()
|
||||
{
|
||||
if(!CMeter::Draw()) return false;
|
||||
|
||||
if (m_Bitmap != NULL)
|
||||
{
|
||||
Graphics graphics(m_MeterWindow->GetDoubleBuffer());
|
||||
|
||||
// Copy the image over the doublebuffer
|
||||
int x = GetX();
|
||||
int y = GetY();
|
||||
Rect r(x, y, m_W, m_H);
|
||||
graphics.DrawImage(m_Bitmap, r, 0, 0, m_Bitmap->GetWidth(), m_Bitmap->GetHeight(), UnitPixel);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
** BindMeasure
|
||||
**
|
||||
** Overridden method. The Image meters need not to be bound on anything
|
||||
**
|
||||
*/
|
||||
void CMeterImage::BindMeasure(std::list<CMeasure*>& measures)
|
||||
{
|
||||
try
|
||||
{
|
||||
CMeter::BindMeasure(measures);
|
||||
}
|
||||
catch(CError)
|
||||
{
|
||||
// Do nothing (ignore errors)
|
||||
}
|
||||
}
|
||||
|
||||
75
Library/MeterImage.h
Normal file
75
Library/MeterImage.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
Copyright (C) 2002 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeterImage.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeterImage.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.5 2004/07/11 17:17:48 rainy
|
||||
The image is not locked anymore on disk.
|
||||
|
||||
Revision 1.4 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.3 2003/12/05 15:50:10 Rainy
|
||||
Multi-instance changes.
|
||||
|
||||
Revision 1.2 2003/02/10 18:12:45 rainy
|
||||
Now uses GDI+
|
||||
|
||||
Revision 1.1 2002/04/27 10:28:31 rainy
|
||||
Intial version.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __METERIMAGE_H__
|
||||
#define __METERIMAGE_H__
|
||||
|
||||
#include "Meter.h"
|
||||
#include "MeterWindow.h"
|
||||
|
||||
namespace Gdiplus
|
||||
{
|
||||
class Bitmap;
|
||||
};
|
||||
|
||||
class CMeterImage : public CMeter
|
||||
{
|
||||
public:
|
||||
CMeterImage(CMeterWindow* meterWindow);
|
||||
virtual ~CMeterImage();
|
||||
|
||||
virtual void ReadConfig(const WCHAR* section);
|
||||
virtual void Initialize();
|
||||
virtual bool Update();
|
||||
virtual bool Draw();
|
||||
virtual void BindMeasure(std::list<CMeasure*>& measures);
|
||||
|
||||
private:
|
||||
void LoadImage(bool bLoadAlways);
|
||||
|
||||
Gdiplus::Bitmap* m_Bitmap; // The bitmap
|
||||
std::wstring m_ImageName; // Name of the image
|
||||
bool m_DimensionsDefined;
|
||||
HGLOBAL m_hBuffer;
|
||||
FILETIME m_Modified;
|
||||
};
|
||||
|
||||
#endif
|
||||
380
Library/MeterLine.cpp
Normal file
380
Library/MeterLine.cpp
Normal file
@@ -0,0 +1,380 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeterLine.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeterLine.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.5 2004/07/11 17:18:07 rainy
|
||||
Relative coordinate support.
|
||||
|
||||
Revision 1.4 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.3 2004/03/13 16:18:16 rainy
|
||||
Limits negative coords
|
||||
|
||||
Revision 1.2 2003/02/10 18:12:44 rainy
|
||||
Now uses GDI+
|
||||
|
||||
Revision 1.1 2002/07/01 15:35:54 rainy
|
||||
Intial version
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4786)
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeterLine.h"
|
||||
#include "Measure.h"
|
||||
#include "Error.h"
|
||||
#include <crtdbg.h>
|
||||
#include <gdiplus.h>
|
||||
|
||||
using namespace Gdiplus;
|
||||
|
||||
/*
|
||||
** CMeterLine
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeterLine::CMeterLine(CMeterWindow* meterWindow) : CMeter(meterWindow)
|
||||
{
|
||||
m_Autoscale = false;
|
||||
m_AntiAlias = false;
|
||||
m_HorizontalLines = false;
|
||||
m_HorizontalColor = 0;
|
||||
m_CurrentPos = 0;
|
||||
m_Flip = false;
|
||||
m_LineWidth = 1.0;
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeterLine
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeterLine::~CMeterLine()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
** Initialize
|
||||
**
|
||||
** create the buffer for the lines
|
||||
**
|
||||
*/
|
||||
void CMeterLine::Initialize()
|
||||
{
|
||||
CMeter::Initialize();
|
||||
|
||||
std::vector<Color>::iterator i = m_Colors.begin();
|
||||
for ( ; i != m_Colors.end(); i++)
|
||||
{
|
||||
m_AllValues.push_back(std::vector<double>());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Read the meter-specific configs from the ini-file.
|
||||
**
|
||||
*/
|
||||
void CMeterLine::ReadConfig(const WCHAR* section)
|
||||
{
|
||||
int i;
|
||||
WCHAR tmpName[256];
|
||||
|
||||
// Read common configs
|
||||
CMeter::ReadConfig(section);
|
||||
|
||||
CConfigParser& parser = m_MeterWindow->GetParser();
|
||||
|
||||
int lineCount = parser.ReadInt(section, L"LineCount", 1);
|
||||
|
||||
for (i = 0; i < lineCount; i++)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
wcscpy(tmpName, L"LineColor");
|
||||
}
|
||||
else
|
||||
{
|
||||
swprintf(tmpName, L"LineColor%i", i + 1);
|
||||
}
|
||||
|
||||
m_Colors.push_back(parser.ReadColor(section, tmpName, Color::White));
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
wcscpy(tmpName, L"Scale");
|
||||
}
|
||||
else
|
||||
{
|
||||
swprintf(tmpName, L"Scale%i", i + 1);
|
||||
}
|
||||
|
||||
m_ScaleValues.push_back(parser.ReadFloat(section, tmpName, 1.0));
|
||||
|
||||
if (i != 0)
|
||||
{
|
||||
swprintf(tmpName, L"MeasureName%i", i + 1);
|
||||
m_MeasureNames.push_back(parser.ReadString(section, tmpName, L""));
|
||||
}
|
||||
}
|
||||
|
||||
m_Flip = 0!=parser.ReadInt(section, L"Flip", 0);
|
||||
m_Autoscale = 0!=parser.ReadInt(section, L"AutoScale", 0);
|
||||
m_AntiAlias = 0!=parser.ReadInt(section, L"AntiAlias", 0);
|
||||
m_LineWidth = parser.ReadFloat(section, L"LineWidth", 1.0);
|
||||
m_HorizontalLines = 0!=parser.ReadInt(section, L"HorizontalLines", 0);
|
||||
m_HorizontalColor = parser.ReadColor(section, L"HorizontalColor", Color::Black);
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the value(s) from the measures.
|
||||
**
|
||||
*/
|
||||
bool CMeterLine::Update()
|
||||
{
|
||||
if (CMeter::Update() && m_Measure)
|
||||
{
|
||||
// Collect the values
|
||||
if (!m_Measure->IsDisabled())
|
||||
{
|
||||
double value = m_Measure->GetValue();
|
||||
|
||||
if (m_AllValues[0].size() < m_W)
|
||||
{
|
||||
m_AllValues[0].push_back(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_AllValues[0][m_CurrentPos] = value;
|
||||
}
|
||||
}
|
||||
|
||||
int counter = 1;
|
||||
std::vector<CMeasure*>::iterator i = m_Measures.begin();
|
||||
for ( ; i != m_Measures.end(); i++)
|
||||
{
|
||||
double value = (*i)->GetValue();
|
||||
|
||||
if (m_AllValues[counter].size() < m_W)
|
||||
{
|
||||
m_AllValues[counter].push_back(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_AllValues[counter][m_CurrentPos] = value;
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
|
||||
m_CurrentPos++;
|
||||
if (m_CurrentPos >= m_W)
|
||||
{
|
||||
m_CurrentPos = 0;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
** Draw
|
||||
**
|
||||
** Draws the meter on the double buffer
|
||||
**
|
||||
*/
|
||||
bool CMeterLine::Draw()
|
||||
{
|
||||
if(!CMeter::Draw()) return false;
|
||||
|
||||
double maxValue = 0.0;
|
||||
int counter = 0;
|
||||
|
||||
// Find the maximum value
|
||||
if (m_Autoscale)
|
||||
{
|
||||
double newValue = 0;
|
||||
std::vector< std::vector<double> >::iterator i = m_AllValues.begin();
|
||||
counter = 0;
|
||||
for (; i != m_AllValues.end(); i++)
|
||||
{
|
||||
std::vector<double>::iterator j = (*i).begin();
|
||||
for (; j != (*i).end(); j++)
|
||||
{
|
||||
newValue = max(newValue, (*j) * m_ScaleValues[counter]);
|
||||
}
|
||||
counter++;
|
||||
}
|
||||
|
||||
// Scale the value up to nearest power of 2
|
||||
maxValue = 2;
|
||||
while(maxValue < newValue && maxValue != 0)
|
||||
{
|
||||
maxValue *= 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_Measure)
|
||||
{
|
||||
maxValue = m_Measure->GetMaxValue();
|
||||
|
||||
std::vector<CMeasure*>::iterator i = m_Measures.begin();
|
||||
for (; i != m_Measures.end(); i++)
|
||||
{
|
||||
maxValue = max(maxValue, (*i)->GetMaxValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (maxValue == 0.0)
|
||||
{
|
||||
maxValue = 1.0;
|
||||
}
|
||||
|
||||
Graphics graphics(m_MeterWindow->GetDoubleBuffer()); //GDI+
|
||||
if (m_AntiAlias)
|
||||
{
|
||||
graphics.SetSmoothingMode(SmoothingModeAntiAlias);
|
||||
}
|
||||
|
||||
int x = GetX();
|
||||
int y = GetY();
|
||||
|
||||
// Draw the horizontal lines
|
||||
if (m_HorizontalLines)
|
||||
{
|
||||
// Calc the max number of lines we should draw
|
||||
int maxLines = m_H / 4; // one line per 4 pixels is max
|
||||
int numOfLines;
|
||||
|
||||
// Check the highest power of 2 that fits in maxLines
|
||||
int power = 2;
|
||||
while(power < maxLines)
|
||||
{
|
||||
power *= 2;
|
||||
}
|
||||
|
||||
numOfLines = ((int)maxValue % power) + 1;
|
||||
|
||||
Pen pen(m_HorizontalColor);
|
||||
|
||||
REAL Y;
|
||||
for (int j = 0; j < numOfLines; j++)
|
||||
{
|
||||
Y = (REAL)((j + 1) * m_H / (numOfLines + 1));
|
||||
Y = y + m_H - Y - 1;
|
||||
graphics.DrawLine(&pen, (REAL)x, Y, (REAL)(x + m_W - 1), Y); // GDI+
|
||||
}
|
||||
}
|
||||
|
||||
// Draw all the lines
|
||||
counter = 0;
|
||||
std::vector< std::vector<double> >::iterator i = m_AllValues.begin();
|
||||
for (; i != m_AllValues.end(); i++)
|
||||
{
|
||||
// Draw a line
|
||||
int X = x;
|
||||
REAL Y = 0;
|
||||
REAL oldY = 0;
|
||||
int pos = m_CurrentPos;
|
||||
if (pos >= m_W) pos = 0;
|
||||
|
||||
Pen pen(m_Colors[counter], (REAL)m_LineWidth);
|
||||
|
||||
for (int j = 0; j < m_W; j++)
|
||||
{
|
||||
if (pos < (*i).size())
|
||||
{
|
||||
Y = (REAL)((*i)[pos] * m_ScaleValues[counter] * (m_H - 1) / maxValue);
|
||||
Y = min(Y, m_H - 1);
|
||||
Y = max(Y, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Y = 0;
|
||||
}
|
||||
|
||||
if (m_Flip)
|
||||
{
|
||||
Y = y + Y;
|
||||
}
|
||||
else
|
||||
{
|
||||
Y = y + m_H - Y - 1;
|
||||
}
|
||||
|
||||
if (j != 0)
|
||||
{
|
||||
graphics.DrawLine(&pen, (REAL)X - 1, oldY, (REAL)X, Y); // GDI+
|
||||
}
|
||||
oldY = Y;
|
||||
|
||||
X++;
|
||||
pos++;
|
||||
if (pos >= m_W) pos = 0;
|
||||
}
|
||||
|
||||
counter++;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
** BindMeasure
|
||||
**
|
||||
** Overwritten method to handle the other measure bindings.
|
||||
**
|
||||
*/
|
||||
void CMeterLine::BindMeasure(std::list<CMeasure*>& measures)
|
||||
{
|
||||
CMeter::BindMeasure(measures);
|
||||
|
||||
std::vector<std::wstring>::iterator j = m_MeasureNames.begin();
|
||||
for (; j != m_MeasureNames.end(); j++)
|
||||
{
|
||||
// Go through the list and check it there is a secondary measure for us
|
||||
std::list<CMeasure*>::iterator i = measures.begin();
|
||||
for( ; i != measures.end(); i++)
|
||||
{
|
||||
if(_wcsicmp((*i)->GetName(), (*j).c_str()) == 0)
|
||||
{
|
||||
m_Measures.push_back(*i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == measures.end())
|
||||
{
|
||||
throw CError(std::wstring(L"The meter [") + m_Name + L"] cannot be bound with [" + (*j) + L"]!", __LINE__, __FILE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
72
Library/MeterLine.h
Normal file
72
Library/MeterLine.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
Copyright (C) 2002 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeterLine.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeterLine.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.3 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.2 2003/02/10 18:12:44 rainy
|
||||
Now uses GDI+
|
||||
|
||||
Revision 1.1 2002/07/01 15:35:54 rainy
|
||||
Intial version
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __METERLINE_H__
|
||||
#define __METERLINE_H__
|
||||
|
||||
#include "Meter.h"
|
||||
#include "MeterWindow.h"
|
||||
|
||||
class CMeterLine : public CMeter
|
||||
{
|
||||
public:
|
||||
CMeterLine(CMeterWindow* meterWindow);
|
||||
virtual ~CMeterLine();
|
||||
|
||||
virtual void ReadConfig(const WCHAR* section);
|
||||
virtual void Initialize();
|
||||
virtual bool Update();
|
||||
virtual bool Draw();
|
||||
virtual void BindMeasure(std::list<CMeasure*>& measures);
|
||||
|
||||
private:
|
||||
std::vector<std::wstring> m_MeasureNames; // Name of the other measures
|
||||
std::vector<CMeasure*> m_Measures; // Pointer ot the other measures
|
||||
|
||||
std::vector<Gdiplus::Color> m_Colors; // Color of the histograms
|
||||
std::vector<double> m_ScaleValues; // The scale values for the measures
|
||||
|
||||
bool m_Autoscale; // If true, the meter is automatically adjusted to show all values
|
||||
bool m_AntiAlias; // If true, the line is antialiased
|
||||
bool m_HorizontalLines; // If true, horizontal lines will ba drawn on the meter
|
||||
bool m_Flip;
|
||||
double m_LineWidth;
|
||||
Gdiplus::Color m_HorizontalColor; // Color of the horizontal lines
|
||||
|
||||
std::vector< std::vector<double> > m_AllValues; // All the values to be drawn
|
||||
int m_CurrentPos; // Place of the current value
|
||||
};
|
||||
|
||||
#endif
|
||||
192
Library/MeterRotator.cpp
Normal file
192
Library/MeterRotator.cpp
Normal file
@@ -0,0 +1,192 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeterRotator.cpp,v 1.2 2005/07/12 16:31:49 rainy Exp $
|
||||
|
||||
$Log: MeterRotator.cpp,v $
|
||||
Revision 1.2 2005/07/12 16:31:49 rainy
|
||||
*** empty log message ***
|
||||
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.4 2004/08/13 15:46:43 rainy
|
||||
Added LineStart.
|
||||
Reminder->Remainder.
|
||||
|
||||
Revision 1.3 2004/07/11 17:18:07 rainy
|
||||
Relative coordinate support.
|
||||
|
||||
Revision 1.2 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.1 2004/03/13 16:18:43 rainy
|
||||
Initial version
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4786)
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeterRotator.h"
|
||||
#include "Measure.h"
|
||||
#include "Error.h"
|
||||
#include "Litestep.h"
|
||||
#include "Rainmeter.h"
|
||||
|
||||
using namespace Gdiplus;
|
||||
|
||||
extern CRainmeter* Rainmeter;
|
||||
|
||||
/*
|
||||
** CMeterRotator
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeterRotator::CMeterRotator(CMeterWindow* meterWindow) : CMeter(meterWindow)
|
||||
{
|
||||
m_Bitmap = NULL;
|
||||
m_Value = 0.0;
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeterRotator
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeterRotator::~CMeterRotator()
|
||||
{
|
||||
if(m_Bitmap != NULL) delete m_Bitmap;
|
||||
}
|
||||
|
||||
/*
|
||||
** Initialize
|
||||
**
|
||||
** Load the image & configs.
|
||||
**
|
||||
*/
|
||||
void CMeterRotator::Initialize()
|
||||
{
|
||||
CMeter::Initialize();
|
||||
|
||||
// Load the bitmaps if defined
|
||||
if(!m_ImageName.empty())
|
||||
{
|
||||
m_Bitmap = new Bitmap(m_ImageName.c_str());
|
||||
Status status = m_Bitmap->GetLastStatus();
|
||||
if(Ok != status)
|
||||
{
|
||||
throw CError(std::wstring(L"Bitmap image not found: ") + m_ImageName, __LINE__, __FILE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Read the meter-specific configs from the ini-file.
|
||||
**
|
||||
*/
|
||||
void CMeterRotator::ReadConfig(const WCHAR* section)
|
||||
{
|
||||
// Read common configs
|
||||
CMeter::ReadConfig(section);
|
||||
|
||||
CConfigParser& parser = m_MeterWindow->GetParser();
|
||||
|
||||
m_ImageName = parser.ReadString(section, L"ImageName", L"");
|
||||
m_ImageName = Rainmeter->FixPath(m_ImageName, PATH_FOLDER_CURRENT_SKIN, m_MeterWindow->GetSkinName());
|
||||
|
||||
m_OffsetX = parser.ReadFloat(section, L"OffsetX", 0.0);
|
||||
m_OffsetY = parser.ReadFloat(section, L"OffsetY", 0.0);
|
||||
m_StartAngle = parser.ReadFloat(section, L"StartAngle", 0.0);
|
||||
m_RotationAngle = parser.ReadFloat(section, L"RotationAngle", 6.2832);
|
||||
|
||||
m_ValueRemainder = parser.ReadInt(section, L"ValueReminder", 0); // Typo
|
||||
m_ValueRemainder = parser.ReadInt(section, L"ValueRemainder", m_ValueRemainder);
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the value(s) from the measures.
|
||||
**
|
||||
*/
|
||||
bool CMeterRotator::Update()
|
||||
{
|
||||
if (CMeter::Update() && m_Measure)
|
||||
{
|
||||
if (m_ValueRemainder > 0)
|
||||
{
|
||||
LARGE_INTEGER time;
|
||||
time.QuadPart = m_Measure->GetValue();
|
||||
m_Value = time.QuadPart % m_ValueRemainder;
|
||||
m_Value /= (double)m_ValueRemainder;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Value = m_Measure->GetRelativeValue();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Draw
|
||||
**
|
||||
** Draws the meter on the double buffer
|
||||
**
|
||||
*/
|
||||
bool CMeterRotator::Draw()
|
||||
{
|
||||
if(!CMeter::Draw()) return false;
|
||||
|
||||
// Calculate the center for rotation
|
||||
int x = GetX();
|
||||
int y = GetY();
|
||||
|
||||
REAL cx = (REAL)(x + m_W / 2.0);
|
||||
REAL cy = (REAL)(y + m_H / 2.0);
|
||||
|
||||
// Calculate the rotation
|
||||
REAL angle = (REAL)(m_RotationAngle * m_Value + m_StartAngle);
|
||||
|
||||
Graphics graphics(m_MeterWindow->GetDoubleBuffer());
|
||||
|
||||
angle = angle * 180.0f / 3.14159265f; // Convert to degrees
|
||||
|
||||
graphics.TranslateTransform(cx, cy);
|
||||
graphics.RotateTransform(angle);
|
||||
graphics.TranslateTransform((REAL)-m_OffsetX, (REAL)-m_OffsetY);
|
||||
|
||||
if(m_Bitmap)
|
||||
{
|
||||
UINT width = m_Bitmap->GetWidth();
|
||||
UINT height = m_Bitmap->GetHeight();
|
||||
|
||||
// Blit the image
|
||||
graphics.DrawImage(m_Bitmap, 0, 0, width, height);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
65
Library/MeterRotator.h
Normal file
65
Library/MeterRotator.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeterRotator.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeterRotator.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.3 2004/08/13 15:46:43 rainy
|
||||
Added LineStart.
|
||||
Reminder->Remainder.
|
||||
|
||||
Revision 1.2 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.1 2004/03/13 16:18:43 rainy
|
||||
Initial version
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __METERROTATOR_H__
|
||||
#define __METERROTATOR_H__
|
||||
|
||||
#include "Meter.h"
|
||||
#include "MeterWindow.h"
|
||||
|
||||
class CMeterRotator : public CMeter
|
||||
{
|
||||
public:
|
||||
CMeterRotator(CMeterWindow* meterWindow);
|
||||
virtual ~CMeterRotator();
|
||||
|
||||
virtual void ReadConfig(const WCHAR* section);
|
||||
virtual void Initialize();
|
||||
virtual bool Update();
|
||||
virtual bool Draw();
|
||||
|
||||
private:
|
||||
Gdiplus::Bitmap* m_Bitmap; // The bar bitmap
|
||||
std::wstring m_ImageName; // Name of the image
|
||||
double m_OffsetX;
|
||||
double m_OffsetY;
|
||||
double m_StartAngle;
|
||||
double m_RotationAngle;
|
||||
UINT m_ValueRemainder;
|
||||
double m_Value;
|
||||
};
|
||||
|
||||
#endif
|
||||
197
Library/MeterRoundLine.cpp
Normal file
197
Library/MeterRoundLine.cpp
Normal file
@@ -0,0 +1,197 @@
|
||||
/*
|
||||
Copyright (C) 2002 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeterRoundLine.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeterRoundLine.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.5 2004/08/13 15:46:50 rainy
|
||||
Reminder->Remainder.
|
||||
|
||||
Revision 1.4 2004/07/11 17:18:07 rainy
|
||||
Relative coordinate support.
|
||||
|
||||
Revision 1.3 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.2 2003/02/10 18:12:44 rainy
|
||||
Now uses GDI+
|
||||
|
||||
Revision 1.1 2002/12/26 18:15:41 rainy
|
||||
Initial version
|
||||
|
||||
*/
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeterRoundLine.h"
|
||||
#include "Measure.h"
|
||||
#include "Error.h"
|
||||
#include <crtdbg.h>
|
||||
#include <math.h>
|
||||
#include <gdiplus.h>
|
||||
|
||||
using namespace Gdiplus;
|
||||
#define PI 3.14159265
|
||||
|
||||
/*
|
||||
** CMeterRoundLine
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeterRoundLine::CMeterRoundLine(CMeterWindow* meterWindow) : CMeter(meterWindow)
|
||||
{
|
||||
m_AntiAlias = false;
|
||||
m_LineWidth = 1.0;
|
||||
m_LineLength = 20;
|
||||
m_LineStart = -1.0;
|
||||
m_StartAngle = 0.0;
|
||||
m_RotationAngle = 0.0;
|
||||
m_ValueRemainder = 0;
|
||||
m_Solid = false;
|
||||
m_Value = 0.0;
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeterRoundLine
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeterRoundLine::~CMeterRoundLine()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Read the meter-specific configs from the ini-file.
|
||||
**
|
||||
*/
|
||||
void CMeterRoundLine::ReadConfig(const WCHAR* section)
|
||||
{
|
||||
// Read common configs
|
||||
CMeter::ReadConfig(section);
|
||||
|
||||
CConfigParser& parser = m_MeterWindow->GetParser();
|
||||
|
||||
m_LineWidth = parser.ReadFloat(section, L"LineWidth", 1.0);
|
||||
m_LineLength = parser.ReadFloat(section, L"LineLength", 20.0);
|
||||
m_LineStart = parser.ReadFloat(section, L"LineStart", -1.0);
|
||||
m_StartAngle = parser.ReadFloat(section, L"StartAngle", 0.0);
|
||||
m_RotationAngle = parser.ReadFloat(section, L"RotationAngle", 6.2832);
|
||||
m_AntiAlias = 0!=parser.ReadInt(section, L"AntiAlias", 0);
|
||||
m_ValueRemainder = parser.ReadInt(section, L"ValueReminder", 0); // Typo
|
||||
m_ValueRemainder = parser.ReadInt(section, L"ValueRemainder", m_ValueRemainder);
|
||||
m_LineColor = parser.ReadColor(section, L"LineColor", Color::Black);
|
||||
m_Solid = 0!=parser.ReadInt(section, L"Solid", 0);
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the value(s) from the measures.
|
||||
**
|
||||
*/
|
||||
bool CMeterRoundLine::Update()
|
||||
{
|
||||
if (CMeter::Update() && m_Measure)
|
||||
{
|
||||
if (m_ValueRemainder > 0)
|
||||
{
|
||||
LARGE_INTEGER time;
|
||||
time.QuadPart = m_Measure->GetValue();
|
||||
m_Value = time.QuadPart % m_ValueRemainder;
|
||||
m_Value /= (double)m_ValueRemainder;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Value = m_Measure->GetRelativeValue();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Draw
|
||||
**
|
||||
** Draws the meter on the double buffer
|
||||
**
|
||||
*/
|
||||
bool CMeterRoundLine::Draw()
|
||||
{
|
||||
if(!CMeter::Draw()) return false;
|
||||
|
||||
Graphics graphics(m_MeterWindow->GetDoubleBuffer()); //GDI+
|
||||
if (m_AntiAlias)
|
||||
{
|
||||
graphics.SetSmoothingMode(SmoothingModeAntiAlias);
|
||||
}
|
||||
|
||||
// Calculate the center of for the line
|
||||
int x = GetX();
|
||||
int y = GetY();
|
||||
REAL cx = (REAL)(x + m_W / 2.0);
|
||||
REAL cy = (REAL)(y + m_H / 2.0);
|
||||
|
||||
if (m_Solid)
|
||||
{
|
||||
if (m_LineStart > 0.0)
|
||||
{
|
||||
// Create clipping region
|
||||
GraphicsPath path;
|
||||
path.AddEllipse(REAL(cx - m_LineStart), REAL(cy - m_LineStart), REAL(m_LineStart * 2), REAL(m_LineStart * 2));
|
||||
graphics.SetClip(&path, CombineModeExclude);
|
||||
}
|
||||
|
||||
// Calculate the center of for the line
|
||||
SolidBrush solidBrush(m_LineColor);
|
||||
graphics.FillPie(&solidBrush, (REAL)(cx - m_LineLength), (REAL)(cy - m_LineLength), (REAL)(m_LineLength * 2.0), (REAL)(m_LineLength * 2.0), (REAL)(m_StartAngle * 180.0 / PI), (REAL)(m_RotationAngle * m_Value * 180.0 / PI));
|
||||
}
|
||||
else
|
||||
{
|
||||
REAL x, y;
|
||||
|
||||
Pen pen(m_LineColor, (REAL)m_LineWidth);
|
||||
|
||||
// Calculate the end point of the line
|
||||
double angle = m_RotationAngle * m_Value + m_StartAngle;
|
||||
|
||||
x = (REAL)cos(angle);
|
||||
y = (REAL)sin(angle);
|
||||
|
||||
// Set the length
|
||||
x = x * (REAL)m_LineLength + cx;
|
||||
y = y * (REAL)m_LineLength + cy;
|
||||
|
||||
if (m_LineStart > 0.0)
|
||||
{
|
||||
cx = (REAL)cos(angle) * (REAL)m_LineStart + cx;
|
||||
cy = (REAL)sin(angle) * (REAL)m_LineStart + cy;
|
||||
}
|
||||
|
||||
graphics.DrawLine(&pen, cx, cy, x, y);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
67
Library/MeterRoundLine.h
Normal file
67
Library/MeterRoundLine.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
Copyright (C) 2002 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeterRoundLine.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeterRoundLine.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.4 2004/08/13 15:46:50 rainy
|
||||
Reminder->Remainder.
|
||||
|
||||
Revision 1.3 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.2 2003/02/10 18:12:44 rainy
|
||||
Now uses GDI+
|
||||
|
||||
Revision 1.1 2002/12/26 17:51:50 rainy
|
||||
Initial version
|
||||
*/
|
||||
|
||||
#ifndef __METERROUNDLINE_H__
|
||||
#define __METERROUNDLINE_H__
|
||||
|
||||
#include "Meter.h"
|
||||
#include "MeterWindow.h"
|
||||
|
||||
class CMeterRoundLine : public CMeter
|
||||
{
|
||||
public:
|
||||
CMeterRoundLine(CMeterWindow* meterWindow);
|
||||
virtual ~CMeterRoundLine();
|
||||
|
||||
virtual void ReadConfig(const WCHAR* section);
|
||||
virtual bool Update();
|
||||
virtual bool Draw();
|
||||
|
||||
private:
|
||||
bool m_AntiAlias; // If true, the line is antialiased
|
||||
bool m_Solid;
|
||||
double m_LineWidth;
|
||||
double m_LineLength;
|
||||
double m_LineStart;
|
||||
double m_StartAngle;
|
||||
double m_RotationAngle;
|
||||
UINT m_ValueRemainder;
|
||||
Gdiplus::Color m_LineColor;
|
||||
double m_Value;
|
||||
};
|
||||
|
||||
#endif
|
||||
498
Library/MeterString.cpp
Normal file
498
Library/MeterString.cpp
Normal file
@@ -0,0 +1,498 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeterString.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeterString.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.11 2004/07/11 17:18:32 rainy
|
||||
Fixed width calculation.
|
||||
|
||||
Revision 1.10 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.9 2003/02/10 18:12:44 rainy
|
||||
Now uses GDI+
|
||||
|
||||
Revision 1.8 2002/07/01 15:32:20 rainy
|
||||
Added NumOfDecimals
|
||||
|
||||
Revision 1.7 2002/04/26 18:22:02 rainy
|
||||
Added possibility to hide the meter.
|
||||
|
||||
Revision 1.6 2002/03/31 09:58:53 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.5 2001/12/23 10:14:33 rainy
|
||||
Hex color values are now also supported.
|
||||
|
||||
Revision 1.4 2001/10/14 07:32:32 rainy
|
||||
In error situations CError is thrown instead just a boolean value.
|
||||
|
||||
Revision 1.3 2001/09/26 16:26:23 rainy
|
||||
Small adjustement to the interfaces.
|
||||
|
||||
Revision 1.2 2001/09/01 12:57:33 rainy
|
||||
Added support for percentual measuring.
|
||||
|
||||
Revision 1.1 2001/08/12 15:35:08 Rainy
|
||||
Inital Version
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4786)
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "MeterString.h"
|
||||
#include "Rainmeter.h"
|
||||
#include "Measure.h"
|
||||
#include "Error.h"
|
||||
|
||||
using namespace Gdiplus;
|
||||
|
||||
/*
|
||||
** CMeterString
|
||||
**
|
||||
** The constructor
|
||||
**
|
||||
*/
|
||||
CMeterString::CMeterString(CMeterWindow* meterWindow) : CMeter(meterWindow)
|
||||
{
|
||||
m_Color = RGB(255, 255, 255);
|
||||
m_AutoScale = true;
|
||||
m_Align = ALIGN_LEFT;
|
||||
m_Font = NULL;
|
||||
m_FontFamily = NULL;
|
||||
m_Style = NORMAL;
|
||||
m_FontSize = 10;
|
||||
m_Scale = 1.0;
|
||||
m_NoDecimals = true;
|
||||
m_Percentual = true;
|
||||
m_AntiAlias = false;
|
||||
m_ClipString = false;
|
||||
m_NumOfDecimals = -1;
|
||||
m_DimensionsDefined = false;
|
||||
m_Angle = 0.0;
|
||||
}
|
||||
|
||||
/*
|
||||
** ~CMeterString
|
||||
**
|
||||
** The destructor
|
||||
**
|
||||
*/
|
||||
CMeterString::~CMeterString()
|
||||
{
|
||||
if(m_Font) delete m_Font;
|
||||
if(m_FontFamily) delete m_FontFamily;
|
||||
}
|
||||
|
||||
/*
|
||||
** GetX
|
||||
**
|
||||
** Returns the X-coordinate of the meter
|
||||
**
|
||||
*/
|
||||
int CMeterString::GetX(bool abs)
|
||||
{
|
||||
int x = CMeter::GetX();
|
||||
|
||||
if (!abs)
|
||||
{
|
||||
switch(m_Align)
|
||||
{
|
||||
case ALIGN_CENTER:
|
||||
x = x - (m_W / 2);
|
||||
break;
|
||||
|
||||
case ALIGN_RIGHT:
|
||||
x -= m_W;
|
||||
break;
|
||||
|
||||
case ALIGN_LEFT:
|
||||
// This is already correct
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
** Initialize
|
||||
**
|
||||
** Create the font that is used to draw the text.
|
||||
**
|
||||
*/
|
||||
void CMeterString::Initialize()
|
||||
{
|
||||
CMeter::Initialize();
|
||||
|
||||
m_FontFamily = new FontFamily(m_FontFace.c_str());
|
||||
Status status = m_FontFamily->GetLastStatus();
|
||||
if(Ok != status)
|
||||
{
|
||||
delete m_FontFamily;
|
||||
m_FontFamily = NULL;
|
||||
}
|
||||
|
||||
FontStyle style = FontStyleRegular;
|
||||
|
||||
switch(m_Style)
|
||||
{
|
||||
case ITALIC:
|
||||
style = FontStyleItalic;
|
||||
break;
|
||||
|
||||
case BOLD:
|
||||
style = FontStyleBold;
|
||||
break;
|
||||
|
||||
case BOLDITALIC:
|
||||
style = FontStyleBoldItalic;
|
||||
break;
|
||||
}
|
||||
|
||||
// Adjust the font size with screen DPI
|
||||
HDC dc = GetDC(GetDesktopWindow());
|
||||
int dpi = GetDeviceCaps(dc, LOGPIXELSX);
|
||||
ReleaseDC(GetDesktopWindow(), dc);
|
||||
|
||||
REAL size = (REAL)m_FontSize * (96.0 / (REAL)dpi);
|
||||
|
||||
if (m_FontFamily)
|
||||
{
|
||||
m_Font = new Gdiplus::Font(m_FontFamily, size, style);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Font = new Gdiplus::Font(FontFamily::GenericSansSerif(), size, style);
|
||||
}
|
||||
|
||||
status = m_Font->GetLastStatus();
|
||||
if(Ok != status)
|
||||
{
|
||||
throw CError(std::wstring(L"Unable to create font: ") + m_FontFace, __LINE__, __FILE__);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** ReadConfig
|
||||
**
|
||||
** Read the meter-specific configs from the ini-file.
|
||||
**
|
||||
*/
|
||||
void CMeterString::ReadConfig(const WCHAR* section)
|
||||
{
|
||||
WCHAR tmpName[256];
|
||||
|
||||
// Read common configs
|
||||
CMeter::ReadConfig(section);
|
||||
|
||||
CConfigParser& parser = m_MeterWindow->GetParser();
|
||||
|
||||
// Check for extra measures
|
||||
int i = 2;
|
||||
bool loop = true;
|
||||
do
|
||||
{
|
||||
swprintf(tmpName, L"MeasureName%i", i);
|
||||
std::wstring measure = parser.ReadString(section, tmpName, L"");
|
||||
if (!measure.empty())
|
||||
{
|
||||
m_MeasureNames.push_back(measure);
|
||||
}
|
||||
else
|
||||
{
|
||||
loop = false;
|
||||
}
|
||||
i++;
|
||||
} while(loop);
|
||||
|
||||
m_Color = parser.ReadColor(section, L"FontColor", Color::Black);
|
||||
|
||||
m_Prefix = parser.ReadString(section, L"Prefix", L"");
|
||||
m_Postfix = parser.ReadString(section, L"Postfix", L"");
|
||||
m_Text = parser.ReadString(section, L"Text", L"");
|
||||
|
||||
m_AntiAlias = 0!=parser.ReadInt(section, L"AntiAlias", 0);
|
||||
m_Percentual = 0!=parser.ReadInt(section, L"Percentual", 0);
|
||||
m_AutoScale = 0!=parser.ReadInt(section, L"AutoScale", 0);
|
||||
m_ClipString = 0!=parser.ReadInt(section, L"ClipString", 0);
|
||||
|
||||
m_FontSize = parser.ReadInt(section, L"FontSize", 10);
|
||||
m_NumOfDecimals = parser.ReadInt(section, L"NumOfDecimals", -1);
|
||||
|
||||
m_Angle = parser.ReadFloat(section, L"Angle", 0.0);
|
||||
|
||||
std::wstring scale;
|
||||
scale = parser.ReadString(section, L"Scale", L"1");
|
||||
|
||||
if (wcschr(scale.c_str(), '.') == NULL)
|
||||
{
|
||||
m_NoDecimals = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_NoDecimals = false;
|
||||
}
|
||||
m_Scale = wcstod(scale.c_str(), NULL);
|
||||
|
||||
m_FontFace = parser.ReadString(section, L"FontFace", L"Arial");
|
||||
|
||||
std::wstring align;
|
||||
align = parser.ReadString(section, L"StringAlign", L"LEFT");
|
||||
|
||||
if(_wcsicmp(align.c_str(), L"LEFT") == 0)
|
||||
{
|
||||
m_Align = ALIGN_LEFT;
|
||||
}
|
||||
else if(_wcsicmp(align.c_str(), L"RIGHT") == 0)
|
||||
{
|
||||
m_Align = ALIGN_RIGHT;
|
||||
}
|
||||
else if(_wcsicmp(align.c_str(), L"CENTER") == 0)
|
||||
{
|
||||
m_Align = ALIGN_CENTER;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw CError(std::wstring(L"No such StringAlign: ") + align, __LINE__, __FILE__);
|
||||
}
|
||||
|
||||
std::wstring style;
|
||||
style = parser.ReadString(section, L"StringStyle", L"NORMAL");
|
||||
|
||||
if(_wcsicmp(style.c_str(), L"NORMAL") == 0)
|
||||
{
|
||||
m_Style = NORMAL;
|
||||
}
|
||||
else if(_wcsicmp(style.c_str(), L"BOLD") == 0)
|
||||
{
|
||||
m_Style = BOLD;
|
||||
}
|
||||
else if(_wcsicmp(style.c_str(), L"ITALIC") == 0)
|
||||
{
|
||||
m_Style = ITALIC;
|
||||
}
|
||||
else if(_wcsicmp(style.c_str(), L"BOLDITALIC") == 0)
|
||||
{
|
||||
m_Style = BOLDITALIC;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw CError(std::wstring(L"No such StringStyle: ") + style, __LINE__, __FILE__);
|
||||
}
|
||||
|
||||
if (-1 != parser.ReadInt(section, L"W", -1) && -1 != parser.ReadInt(section, L"H", -1))
|
||||
{
|
||||
m_DimensionsDefined = true;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
** Update
|
||||
**
|
||||
** Updates the value(s) from the measures.
|
||||
**
|
||||
*/
|
||||
bool CMeterString::Update()
|
||||
{
|
||||
if (CMeter::Update())
|
||||
{
|
||||
std::vector<std::wstring> stringValues;
|
||||
|
||||
int decimals = (m_NoDecimals && !m_AutoScale) ? 0 : 1;
|
||||
if (m_NumOfDecimals != -1) decimals = m_NumOfDecimals;
|
||||
|
||||
if (m_Measure) stringValues.push_back(m_Measure->GetStringValue(m_AutoScale, m_Scale, decimals, m_Percentual));
|
||||
|
||||
// Get the values for the other measures
|
||||
for (int i = 0; i < m_Measures.size(); i++)
|
||||
{
|
||||
stringValues.push_back(m_Measures[i]->GetStringValue(m_AutoScale, m_Scale, decimals, m_Percentual));
|
||||
}
|
||||
|
||||
// Create the text
|
||||
m_String = m_Prefix;
|
||||
if (m_Text.empty())
|
||||
{
|
||||
if (stringValues.size() > 0)
|
||||
{
|
||||
m_String += stringValues[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
WCHAR buffer[256];
|
||||
// Create the actual text (i.e. replace %1, %2, .. with the measure texts)
|
||||
std::wstring tmpText = m_Text;
|
||||
|
||||
for (int i = 0; i < stringValues.size(); i++)
|
||||
{
|
||||
wsprintf(buffer, L"%%%i", i + 1);
|
||||
|
||||
size_t start = 0;
|
||||
size_t pos = std::wstring::npos;
|
||||
|
||||
do
|
||||
{
|
||||
pos = tmpText.find(buffer, start);
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
tmpText.replace(tmpText.begin() + pos, tmpText.begin() + pos + wcslen(buffer), stringValues[i]);
|
||||
start = pos + stringValues[i].length();
|
||||
}
|
||||
} while(pos != std::wstring::npos);
|
||||
}
|
||||
|
||||
m_String += tmpText;
|
||||
}
|
||||
m_String += m_Postfix;
|
||||
|
||||
if (!m_DimensionsDefined)
|
||||
{
|
||||
// Calculate the text size
|
||||
RectF rect;
|
||||
DrawString(&rect);
|
||||
m_W = (int)rect.Width;
|
||||
m_H = (int)rect.Height;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
** Draw
|
||||
**
|
||||
** Draws the meter on the double buffer
|
||||
**
|
||||
*/
|
||||
bool CMeterString::Draw()
|
||||
{
|
||||
if(!CMeter::Draw()) return false;
|
||||
|
||||
return DrawString(NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
** DrawString
|
||||
**
|
||||
** Draws the string or calculates it's size
|
||||
**
|
||||
*/
|
||||
bool CMeterString::DrawString(RectF* rect)
|
||||
{
|
||||
Graphics graphics(m_MeterWindow->GetDoubleBuffer());
|
||||
StringFormat stringFormat;
|
||||
|
||||
if (m_AntiAlias)
|
||||
{
|
||||
graphics.SetTextRenderingHint(TextRenderingHintAntiAlias);
|
||||
}
|
||||
else
|
||||
{
|
||||
graphics.SetTextRenderingHint(TextRenderingHintSingleBitPerPixelGridFit);
|
||||
}
|
||||
|
||||
switch(m_Align)
|
||||
{
|
||||
case ALIGN_CENTER:
|
||||
stringFormat.SetAlignment(StringAlignmentCenter);
|
||||
break;
|
||||
|
||||
case ALIGN_RIGHT:
|
||||
stringFormat.SetAlignment(StringAlignmentFar);
|
||||
break;
|
||||
|
||||
case ALIGN_LEFT:
|
||||
stringFormat.SetAlignment(StringAlignmentNear);
|
||||
break;
|
||||
}
|
||||
|
||||
int x = GetX();
|
||||
int y = GetY();
|
||||
|
||||
if (rect)
|
||||
{
|
||||
PointF pos(x, y);
|
||||
graphics.MeasureString(m_String.c_str(), -1, m_Font, pos, rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
RectF rc((REAL)x, (REAL)y, (REAL)m_W, (REAL)m_H);
|
||||
SolidBrush solidBrush(m_Color);
|
||||
|
||||
if (m_ClipString)
|
||||
{
|
||||
stringFormat.SetTrimming(StringTrimmingEllipsisCharacter);
|
||||
}
|
||||
else
|
||||
{
|
||||
stringFormat.SetTrimming(StringTrimmingNone);
|
||||
stringFormat.SetFormatFlags(StringFormatFlagsNoClip | StringFormatFlagsNoWrap);
|
||||
}
|
||||
|
||||
double angle = m_Angle * 180.0f / 3.14159265f; // Convert to degrees
|
||||
graphics.TranslateTransform(CMeter::GetX(), y);
|
||||
graphics.RotateTransform(angle);
|
||||
graphics.TranslateTransform(-CMeter::GetX(), -y);
|
||||
|
||||
graphics.DrawString(m_String.c_str(), -1, m_Font, rc, &stringFormat, &solidBrush);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
** BindMeasure
|
||||
**
|
||||
** Overridden method. The string meters need not to be bound on anything
|
||||
**
|
||||
*/
|
||||
void CMeterString::BindMeasure(std::list<CMeasure*>& measures)
|
||||
{
|
||||
if (m_MeasureName.empty()) return; // Allow NULL measure binding
|
||||
|
||||
CMeter::BindMeasure(measures);
|
||||
|
||||
std::vector<std::wstring>::iterator j = m_MeasureNames.begin();
|
||||
for (; j != m_MeasureNames.end(); j++)
|
||||
{
|
||||
// Go through the list and check it there is a secondary measures for us
|
||||
std::list<CMeasure*>::iterator i = measures.begin();
|
||||
for( ; i != measures.end(); i++)
|
||||
{
|
||||
if(_wcsicmp((*i)->GetName(), (*j).c_str()) == 0)
|
||||
{
|
||||
m_Measures.push_back(*i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i == measures.end())
|
||||
{
|
||||
throw CError(std::wstring(L"The meter [") + m_Name + L"] cannot be bound with [" + (*j) + L"]!", __LINE__, __FILE__);
|
||||
}
|
||||
}
|
||||
}
|
||||
125
Library/MeterString.h
Normal file
125
Library/MeterString.h
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeterString.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeterString.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.9 2004/07/11 17:18:32 rainy
|
||||
Fixed width calculation.
|
||||
|
||||
Revision 1.8 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.7 2003/02/10 18:12:44 rainy
|
||||
Now uses GDI+
|
||||
|
||||
Revision 1.6 2002/07/01 15:32:20 rainy
|
||||
Added NumOfDecimals
|
||||
|
||||
Revision 1.5 2002/03/31 09:58:53 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.4 2001/09/26 16:26:23 rainy
|
||||
Small adjustement to the interfaces.
|
||||
|
||||
Revision 1.3 2001/09/01 12:57:33 rainy
|
||||
Added support for percentual measuring.
|
||||
|
||||
Revision 1.2 2001/08/19 09:12:44 rainy
|
||||
no message
|
||||
|
||||
Revision 1.1 2001/08/12 15:35:07 Rainy
|
||||
Inital Version
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __METERSTRING_H__
|
||||
#define __METERSTRING_H__
|
||||
|
||||
#include "Meter.h"
|
||||
#include "MeterWindow.h"
|
||||
namespace Gdiplus
|
||||
{
|
||||
class Font;
|
||||
}
|
||||
|
||||
class CMeterString : public CMeter
|
||||
{
|
||||
public:
|
||||
CMeterString(CMeterWindow* meterWindow);
|
||||
virtual ~CMeterString();
|
||||
|
||||
virtual int GetX(bool abs = false);
|
||||
|
||||
virtual void ReadConfig(const WCHAR* section);
|
||||
virtual void Initialize();
|
||||
virtual bool Update();
|
||||
virtual bool Draw();
|
||||
virtual void BindMeasure(std::list<CMeasure*>& measures);
|
||||
|
||||
private:
|
||||
enum TEXTSTYLE
|
||||
{
|
||||
NORMAL,
|
||||
BOLD,
|
||||
ITALIC,
|
||||
BOLDITALIC
|
||||
};
|
||||
|
||||
bool DrawString(Gdiplus::RectF* rect);
|
||||
|
||||
Gdiplus::Color m_Color; // The color of the text
|
||||
std::wstring m_Postfix; // The postfix of the text
|
||||
std::wstring m_Prefix; // The prefix of the text
|
||||
std::wstring m_Text; // The text
|
||||
std::wstring m_FontFace; // name of the font face
|
||||
bool m_AutoScale; // true, if the value should be autoscaled
|
||||
METER_ALIGNMENT m_Align; // Alignment of the text
|
||||
TEXTSTYLE m_Style; // Style of the text
|
||||
int m_FontSize; // Size of the fonts
|
||||
double m_Scale; // Scaling if autoscale is not used
|
||||
bool m_NoDecimals; // Number of decimals to use
|
||||
bool m_Percentual; // True, if the value should be given as %
|
||||
bool m_AntiAlias; // True, the text is antialiased
|
||||
bool m_ClipString; // True, the text is clipped in borders (adds ellipsis to the end of the string)
|
||||
Gdiplus::Font* m_Font; // The font
|
||||
Gdiplus::FontFamily* m_FontFamily; // The font family
|
||||
int m_NumOfDecimals; // Number of decimals to be displayed
|
||||
bool m_DimensionsDefined;
|
||||
Gdiplus::REAL m_Angle;
|
||||
|
||||
std::wstring m_String;
|
||||
|
||||
std::vector<std::wstring> m_MeasureNames;
|
||||
std::vector<CMeasure*> m_Measures;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
E eksa 10^18
|
||||
P peta 10^15
|
||||
T tera 10^12
|
||||
G giga 10^9
|
||||
M mega 10^6
|
||||
k kilo 10^3
|
||||
*/
|
||||
2830
Library/MeterWindow.cpp
Normal file
2830
Library/MeterWindow.cpp
Normal file
File diff suppressed because it is too large
Load Diff
364
Library/MeterWindow.h
Normal file
364
Library/MeterWindow.h
Normal file
@@ -0,0 +1,364 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/MeterWindow.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: MeterWindow.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.21 2004/07/11 17:19:29 rainy
|
||||
Changed messageboxes to logs.
|
||||
Mouse leave checks transparent pixels.
|
||||
Added !RainmeterToggleConfig.
|
||||
|
||||
Revision 1.20 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.19 2004/03/13 16:19:17 rainy
|
||||
Added support for multiple configs
|
||||
|
||||
Revision 1.18 2003/12/05 15:50:10 Rainy
|
||||
Multi-instance changes.
|
||||
|
||||
Revision 1.17 2003/02/10 18:10:56 rainy
|
||||
no message
|
||||
|
||||
Revision 1.16 2002/12/23 14:25:21 rainy
|
||||
Separated skin and other settings.
|
||||
Stats are now written in ini file.
|
||||
|
||||
Revision 1.15 2002/07/01 15:27:36 rainy
|
||||
AlwaysOnTop gets now three values.
|
||||
Added Toggle().
|
||||
Added RainmeterCurrentConfig and RainmeterCurrentConfigIni.
|
||||
The ini file's timestamp is checked before it is overwritten.
|
||||
AboutBox is now in separate source file.
|
||||
Added SnapEdges.
|
||||
|
||||
Revision 1.14 2002/05/05 10:48:15 rainy
|
||||
The last message is stored into a membervariable.
|
||||
|
||||
Revision 1.13 2002/05/04 08:14:45 rainy
|
||||
Configs store also the names of the ini-files.
|
||||
|
||||
Revision 1.12 2002/04/27 10:27:42 rainy
|
||||
Added hide/show to meters and enable/disable to measures
|
||||
|
||||
Revision 1.11 2002/03/31 09:58:53 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.10 2001/12/23 10:14:09 rainy
|
||||
Added support for different configs.
|
||||
The position of the window is now remembered.
|
||||
|
||||
Revision 1.9 2001/10/28 10:15:21 rainy
|
||||
Added left and right mouse up actions.
|
||||
IsNT() can now identify different OS more precisely.
|
||||
|
||||
Revision 1.8 2001/10/14 07:26:21 rainy
|
||||
Added m_StatsDate
|
||||
|
||||
Revision 1.7 2001/09/26 16:25:44 rainy
|
||||
Added support for statistics.
|
||||
Meters and Measures are now stored here.
|
||||
|
||||
Revision 1.6 2001/09/01 12:57:13 rainy
|
||||
Added support for Bar and Bitmap meters.
|
||||
|
||||
Revision 1.5 2001/08/25 18:08:34 rainy
|
||||
Added mousebutton actions.
|
||||
The About dialog has now the build date.
|
||||
|
||||
Revision 1.4 2001/08/25 17:14:00 rainy
|
||||
Pointer to CRainmeter is now stored in a member variable.
|
||||
Added few more methods.
|
||||
|
||||
Revision 1.3 2001/08/19 09:10:18 rainy
|
||||
Added GetWindow() and OnGetRevID().
|
||||
|
||||
Revision 1.2 2001/08/12 15:37:39 Rainy
|
||||
ToggleWindowIfNecessary is now ShowWindowIfAppropriate.
|
||||
Added method for mouseover messages.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __METERWINDOW_H__
|
||||
#define __METERWINDOW_H__
|
||||
|
||||
#pragma warning(disable: 4786)
|
||||
|
||||
#include <windows.h>
|
||||
#include <gdiplus.h>
|
||||
#include <string>
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include "ConfigParser.h"
|
||||
#include "Export.h"
|
||||
|
||||
#define BEGIN_MESSAGEPROC switch(uMsg) {
|
||||
#define MESSAGE(handler, msg) case msg: return Window?Window->handler(wParam, lParam):DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
#define REJECT_MESSAGE(msg) case msg: return 0;
|
||||
#define END_MESSAGEPROC } return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
|
||||
#define WM_DELAYED_EXECUTE WM_APP
|
||||
|
||||
enum MOUSE
|
||||
{
|
||||
MOUSE_LMB_DOWN,
|
||||
MOUSE_LMB_UP,
|
||||
MOUSE_RMB_DOWN,
|
||||
MOUSE_RMB_UP,
|
||||
MOUSE_OVER,
|
||||
MOUSE_LEAVE
|
||||
};
|
||||
|
||||
enum ZPOSITION
|
||||
{
|
||||
ZPOSITION_ONDESKTOP = -2,
|
||||
ZPOSITION_ONBOTTOM = -1,
|
||||
ZPOSITION_NORMAL = 0,
|
||||
ZPOSITION_ONTOP = 1,
|
||||
ZPOSITION_ONTOPMOST = 2
|
||||
};
|
||||
|
||||
enum BGMODE
|
||||
{
|
||||
BGMODE_IMAGE = 0,
|
||||
BGMODE_COPY,
|
||||
BGMODE_SOLID,
|
||||
BGMODE_SCALED_IMAGE
|
||||
};
|
||||
|
||||
enum HIDEMODE
|
||||
{
|
||||
HIDEMODE_NONE = 0,
|
||||
HIDEMODE_HIDE,
|
||||
HIDEMODE_FADEIN,
|
||||
HIDEMODE_FADEOUT
|
||||
};
|
||||
|
||||
enum BEVELTYPE
|
||||
{
|
||||
BEVELTYPE_NONE,
|
||||
BEVELTYPE_UP,
|
||||
BEVELTYPE_DOWN
|
||||
};
|
||||
|
||||
enum BANGCOMMAND
|
||||
{
|
||||
BANG_REFRESH,
|
||||
BANG_REDRAW,
|
||||
BANG_TOGGLEMETER,
|
||||
BANG_SHOWMETER,
|
||||
BANG_HIDEMETER,
|
||||
BANG_TOGGLEMEASURE,
|
||||
BANG_ENABLEMEASURE,
|
||||
BANG_DISABLEMEASURE,
|
||||
BANG_SHOW,
|
||||
BANG_HIDE,
|
||||
BANG_TOGGLE,
|
||||
BANG_MOVE,
|
||||
BANG_ZPOS,
|
||||
BANG_LSHOOK,
|
||||
BANG_ABOUT,
|
||||
BANG_MOVEMETER,
|
||||
BANG_PLUGIN
|
||||
};
|
||||
|
||||
enum PATH_FOLDER
|
||||
{
|
||||
PATH_FOLDER_INI,
|
||||
PATH_FOLDER_SKINS,
|
||||
PATH_FOLDER_CURRENT_SKIN,
|
||||
PATH_FOLDER_PLUGIN
|
||||
};
|
||||
|
||||
class CRainmeter;
|
||||
class CMeasure;
|
||||
class CMeter;
|
||||
|
||||
class CMeterWindow
|
||||
{
|
||||
public:
|
||||
CMeterWindow(std::wstring& config, std::wstring& iniFile);
|
||||
~CMeterWindow();
|
||||
|
||||
int Initialize(CRainmeter& Rainmeter);
|
||||
|
||||
void RunBang(BANGCOMMAND bang, const WCHAR* arg);
|
||||
|
||||
void MoveMeter(int x, int y, const WCHAR* name);
|
||||
void HideMeter(const WCHAR* name);
|
||||
void ShowMeter(const WCHAR* name);
|
||||
void ToggleMeter(const WCHAR* name);
|
||||
void DisableMeasure(const WCHAR* name);
|
||||
void EnableMeasure(const WCHAR* name);
|
||||
void ToggleMeasure(const WCHAR* name);
|
||||
void Refresh(bool init);
|
||||
void Redraw();
|
||||
|
||||
void MoveWindow(int x, int y);
|
||||
void ChangeZPos(ZPOSITION zPos);
|
||||
|
||||
Gdiplus::Bitmap* GetDoubleBuffer() { return m_DoubleBuffer; };
|
||||
HWND GetWindow() { return m_Window; };
|
||||
|
||||
CConfigParser& GetParser() { return m_Parser; };
|
||||
|
||||
const std::wstring& GetSkinAuthor() { return m_Author; };
|
||||
const std::wstring& GetSkinName() { return m_SkinName; };
|
||||
const std::wstring& GetSkinIniFile() { return m_SkinIniFile; };
|
||||
|
||||
std::list<CMeasure*>& GetMeasures() { return m_Measures; };
|
||||
std::list<CMeter*>& GetMeters() { return m_Meters; };
|
||||
|
||||
ZPOSITION GetWindowZPosition() { return m_WindowZPosition; }
|
||||
bool GetNativeTransparency() { return m_NativeTransparency; }
|
||||
bool GetClickThrough() { return m_ClickThrough; }
|
||||
bool GetKeepOnScreen() { return m_KeepOnScreen; }
|
||||
bool GetWindowDraggable() { return m_WindowDraggable; }
|
||||
bool GetSavePosition() { return m_SavePosition; }
|
||||
bool GetSnapEdges() { return m_SnapEdges; }
|
||||
HIDEMODE GetWindowHide() { return m_WindowHide; }
|
||||
int GetAlphaValue() { return m_AlphaValue; }
|
||||
int GetUpdateCounter() { return m_UpdateCounter; }
|
||||
|
||||
void AddMeasureBang(const WCHAR* bang, int index, CMeasure* measure);
|
||||
|
||||
LRESULT OnCopyData(WPARAM wParam, LPARAM lParam);
|
||||
|
||||
protected:
|
||||
static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
LRESULT OnPaint(WPARAM wParam, LPARAM lParam);
|
||||
LRESULT OnMove(WPARAM wParam, LPARAM lParam);
|
||||
LRESULT OnCreate(WPARAM wParam, LPARAM lParam);
|
||||
LRESULT OnDestroy(WPARAM wParam, LPARAM lParam);
|
||||
LRESULT OnTimer(WPARAM wParam, LPARAM lParam);
|
||||
LRESULT OnCommand(WPARAM wParam, LPARAM lParam);
|
||||
LRESULT OnNcHitTest(WPARAM wParam, LPARAM lParam);
|
||||
LRESULT OnWindowPosChanging(WPARAM wParam, LPARAM lParam);
|
||||
LRESULT OnMouseMove(WPARAM wParam, LPARAM lParam);
|
||||
LRESULT OnMouseLeave(WPARAM wParam, LPARAM lParam);
|
||||
LRESULT OnContextMenu(WPARAM wParam, LPARAM lParam);
|
||||
LRESULT OnLeftButtonDown(WPARAM wParam, LPARAM lParam);
|
||||
LRESULT OnRightButtonDown(WPARAM wParam, LPARAM lParam);
|
||||
LRESULT OnLeftButtonUp(WPARAM wParam, LPARAM lParam);
|
||||
LRESULT OnRightButtonUp(WPARAM wParam, LPARAM lParam);
|
||||
LRESULT OnDelayedExecute(WPARAM wParam, LPARAM lParam);
|
||||
|
||||
private:
|
||||
void CreateRegion(bool clear);
|
||||
void GetSkinFolders(const std::wstring& folder);
|
||||
Gdiplus::Bitmap* GrabDesktop(int x, int y, int w, int h);
|
||||
void SnapToWindow(CMeterWindow* window, LPWINDOWPOS wp);
|
||||
void MapCoordsToScreen(int& x, int& y, int w, int h);
|
||||
|
||||
void Update(bool nodraw);
|
||||
void UpdateTransparency(int alpha, bool reset);
|
||||
void ReadConfig();
|
||||
void WriteConfig();
|
||||
void ReadSkin();
|
||||
void InitializeMeters();
|
||||
void ShowWindowIfAppropriate();
|
||||
bool DoAction(int x, int y, MOUSE mouse, bool test);
|
||||
bool ResizeWindow(bool reset);
|
||||
void FadeWindow(int from, int to);
|
||||
|
||||
CConfigParser m_Parser;
|
||||
|
||||
Gdiplus::Bitmap* m_DoubleBuffer;
|
||||
Gdiplus::Bitmap* m_Background; // The background bitmap
|
||||
SIZE m_BackgroundSize;
|
||||
|
||||
HWND m_Window; // Handle to the Rainmeter window
|
||||
HINSTANCE m_User32Library;
|
||||
BOOL m_ChildWindow;
|
||||
|
||||
std::wstring m_RightMouseDownAction; // Action to run when right mouse is pressed
|
||||
std::wstring m_LeftMouseDownAction; // Action to run when left mouse is pressed
|
||||
std::wstring m_RightMouseUpAction; // Action to run when right mouse is released
|
||||
std::wstring m_LeftMouseUpAction; // Action to run when left mouse is released
|
||||
std::wstring m_MouseOverAction; // Action to run when mouse goes over the window
|
||||
std::wstring m_MouseLeaveAction; // Action to run when mouse leaves the window
|
||||
std::wstring m_OnRefreshAction; // Action to run when window is initialized
|
||||
|
||||
bool m_MouseOver;
|
||||
|
||||
std::wstring m_Author; // Skin's author
|
||||
std::wstring m_BackgroundName; // Name of the background image
|
||||
Gdiplus::Rect m_BackgroundMargins;
|
||||
Gdiplus::Rect m_DragMargins;
|
||||
int m_WindowX; // Window's X-position
|
||||
int m_WindowY; // Window's Y-position
|
||||
int m_WindowW; // Window's width
|
||||
int m_WindowH; // Window's Height
|
||||
bool m_WindowDraggable; // True, if window can be moved
|
||||
int m_WindowUpdate; // Measure update frequency
|
||||
HIDEMODE m_WindowHide; // If true, the window is hidden when mouse is over it
|
||||
bool m_WindowStartHidden; // If true, the window is hidden at startup
|
||||
bool m_SavePosition; // If true, the window's position is saved
|
||||
bool m_SnapEdges; // If true, the window snaps to the edges of the screen when moved
|
||||
bool m_NativeTransparency; // If true, use the W2k/XP native transparency
|
||||
int m_AlphaValue; // The 'from' transparency value 0 - 255
|
||||
int m_FadeDuration; // Time it takes to fade the window
|
||||
bool m_MeasuresToVariables; // If true, Measured values are transformed to Litestep's eVars
|
||||
bool m_AllowNegativeCoordinates; // If true, Negative coordinates are OK
|
||||
ZPOSITION m_WindowZPosition; // Window's Z-position
|
||||
bool m_DynamicWindowSize; //
|
||||
bool m_ClickThrough; //
|
||||
bool m_KeepOnScreen; //
|
||||
|
||||
BGMODE m_BackgroundMode; // The background mode
|
||||
Gdiplus::Color m_SolidColor; // Color of the solid background
|
||||
Gdiplus::Color m_SolidColor2; // Color of the solid background
|
||||
Gdiplus::REAL m_SolidAngle; //
|
||||
BEVELTYPE m_SolidBevel; // The type of the bevel
|
||||
|
||||
DWORD m_FadeStartTime;
|
||||
int m_FadeStartValue;
|
||||
int m_FadeEndValue;
|
||||
int m_TransparencyValue;
|
||||
|
||||
bool m_Refreshing; // This is true, when the meter is refreshing
|
||||
|
||||
bool m_Hidden; // True, if Rainmeter is hidden
|
||||
bool m_ResetRegion; // If true, the window region is recalculated during the next update
|
||||
|
||||
std::list<CMeasure*> m_Measures; // All the measures
|
||||
std::list<CMeter*> m_Meters; // All the meters
|
||||
|
||||
std::wstring m_SkinName; // Name of the current skin folder
|
||||
std::wstring m_SkinIniFile; // Name of the current skin iniFile
|
||||
|
||||
std::wstring m_ConfigEditor;
|
||||
|
||||
UINT m_Message; // The current window message
|
||||
|
||||
int m_UpdateCounter;
|
||||
|
||||
CRainmeter* m_Rainmeter; // Pointer to the main object
|
||||
|
||||
static int m_InstanceCount;
|
||||
};
|
||||
|
||||
#endif
|
||||
1880
Library/Rainmeter.cpp
Normal file
1880
Library/Rainmeter.cpp
Normal file
File diff suppressed because it is too large
Load Diff
291
Library/Rainmeter.h
Normal file
291
Library/Rainmeter.h
Normal file
@@ -0,0 +1,291 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/Rainmeter.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: Rainmeter.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.19 2004/08/13 15:48:34 rainy
|
||||
no message
|
||||
|
||||
Revision 1.18 2004/07/11 17:19:57 rainy
|
||||
Whole skin folder is recursively scanned.
|
||||
|
||||
Revision 1.17 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
Revision 1.16 2004/03/13 16:20:41 rainy
|
||||
Improved multiconfig support
|
||||
|
||||
Revision 1.15 2003/12/05 15:50:10 Rainy
|
||||
Multi-instance changes.
|
||||
|
||||
Revision 1.14 2003/02/10 18:10:48 rainy
|
||||
Added support for the new bangs.
|
||||
|
||||
Revision 1.13 2002/07/01 15:01:18 rainy
|
||||
Wharfdata is not used anymore.
|
||||
Added Toggle.
|
||||
|
||||
Revision 1.12 2002/05/04 08:10:25 rainy
|
||||
Added interfaces for the new bangs.
|
||||
commandline is now stored in stl string.
|
||||
|
||||
Revision 1.11 2002/04/27 10:27:13 rainy
|
||||
Added bangs to hide/show meters and measures
|
||||
|
||||
Revision 1.10 2002/04/26 18:22:02 rainy
|
||||
Added possibility to hide the meter.
|
||||
|
||||
Revision 1.9 2002/03/31 09:58:53 rainy
|
||||
Added some comments
|
||||
|
||||
Revision 1.8 2002/01/16 16:05:25 rainy
|
||||
Version 0.6
|
||||
|
||||
Revision 1.7 2001/12/23 10:11:32 rainy
|
||||
Refresh gets another parameter.
|
||||
|
||||
Revision 1.6 2001/09/26 16:23:23 rainy
|
||||
Changed the version number
|
||||
|
||||
Revision 1.5 2001/09/01 12:56:44 rainy
|
||||
Added refresh bang.
|
||||
|
||||
Revision 1.4 2001/08/25 18:07:57 rainy
|
||||
Version is now 0.4.
|
||||
|
||||
Revision 1.3 2001/08/25 17:06:24 rainy
|
||||
Changed few methods to inlines.
|
||||
Now the wharf data is stored fully.
|
||||
|
||||
Revision 1.2 2001/08/19 09:03:28 rainy
|
||||
Added VERSION string.
|
||||
|
||||
Revision 1.1.1.1 2001/08/11 10:58:19 Rainy
|
||||
Added to CVS.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __RAINMETER_H__
|
||||
#define __RAINMETER_H__
|
||||
|
||||
#include <windows.h>
|
||||
#include "Litestep.h"
|
||||
#include "MeterWindow.h"
|
||||
#include "TrayWindow.h"
|
||||
#include <map>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#define MAX_LINE_LENGTH 4096
|
||||
|
||||
#define MAKE_VER(major, minor) major * 1000 + minor
|
||||
|
||||
#define APPNAME L"Rainmeter"
|
||||
#ifdef _WIN64
|
||||
#define APPVERSION L"0.14.1 (64-bit)"
|
||||
#else
|
||||
#define APPVERSION L"0.14.1 (32-bit)"
|
||||
#endif
|
||||
#define RAINMETER_VERSION MAKE_VER(14, 1)
|
||||
|
||||
enum PLATFORM
|
||||
{
|
||||
PLATFORM_9X,
|
||||
PLATFORM_NT4,
|
||||
PLATFORM_2K,
|
||||
PLATFORM_XP
|
||||
};
|
||||
|
||||
void RainmeterActivateConfig(HWND, const char* arg);
|
||||
void RainmeterDeactivateConfig(HWND, const char* arg);
|
||||
void RainmeterToggleConfig(HWND, const char* arg);
|
||||
void RainmeterRefresh(HWND, const char* arg);
|
||||
void RainmeterRedraw(HWND, const char* arg);
|
||||
void RainmeterToggleMeasure(HWND, const char* arg);
|
||||
void RainmeterEnableMeasure(HWND, const char* arg);
|
||||
void RainmeterDisableMeasure(HWND, const char* arg);
|
||||
void RainmeterToggleMeter(HWND, const char* arg);
|
||||
void RainmeterShowMeter(HWND, const char* arg);
|
||||
void RainmeterHideMeter(HWND, const char* arg);
|
||||
void RainmeterShow(HWND, const char* arg);
|
||||
void RainmeterHide(HWND, const char* arg);
|
||||
void RainmeterToggle(HWND, const char* arg);
|
||||
void RainmeterMove(HWND, const char* arg);
|
||||
void RainmeterZPos(HWND, const char* arg);
|
||||
void RainmeterLsHook(HWND, const char* arg);
|
||||
void RainmeterAbout(HWND, const char* arg);
|
||||
void RainmeterResetStats(HWND, const char* arg);
|
||||
void RainmeterMoveMeter(HWND, const char* arg);
|
||||
void RainmeterPluginBang(HWND, const char* arg);
|
||||
|
||||
void BangWithArgs(BANGCOMMAND bang, const WCHAR* arg, int numOfArgs);
|
||||
|
||||
struct GlobalConfig
|
||||
{
|
||||
double netInSpeed;
|
||||
double netOutSpeed;
|
||||
};
|
||||
|
||||
class CRainmeter
|
||||
{
|
||||
public:
|
||||
struct CONFIG
|
||||
{
|
||||
std::wstring config;
|
||||
std::vector<std::wstring> iniFiles;
|
||||
std::vector<UINT> commands;
|
||||
int active;
|
||||
};
|
||||
|
||||
struct CONFIGMENU
|
||||
{
|
||||
std::wstring name;
|
||||
size_t index;
|
||||
std::vector<CONFIGMENU> children;
|
||||
};
|
||||
|
||||
|
||||
CRainmeter();
|
||||
~CRainmeter();
|
||||
|
||||
int Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath);
|
||||
void Quit(HINSTANCE dllInst);
|
||||
|
||||
CConfigParser* GetCurrentParser() { return m_CurrentParser; };
|
||||
void SetCurrentParser(CConfigParser* parser) { m_CurrentParser = parser; };
|
||||
|
||||
CTrayWindow* GetTrayWindow() { return m_TrayWindow; };
|
||||
|
||||
CMeterWindow* GetMeterWindow(const std::wstring& config);
|
||||
std::map<std::wstring, CMeterWindow*>& GetAllMeterWindows() { return m_Meters; };
|
||||
const std::vector<CONFIG>& GetAllConfigs() { return m_ConfigStrings; };
|
||||
|
||||
void ActivateConfig(int configIndex, int iniIndex);
|
||||
bool DeactivateConfig(CMeterWindow* meterWindow, int configIndex);
|
||||
|
||||
const std::wstring& GetPath() { return m_Path; };
|
||||
const std::wstring& GetIniFile() { return m_IniFile; };
|
||||
const std::wstring& GetSkinPath() { return m_SkinPath; };
|
||||
const std::wstring& GetPluginPath() { return m_PluginPath; };
|
||||
|
||||
const std::wstring& GetConfigEditor() { return m_ConfigEditor; };
|
||||
const std::wstring& GetStatsDate() { return m_StatsDate; };
|
||||
|
||||
HINSTANCE GetInstance() { return m_Instance; };
|
||||
|
||||
static void SetDummyLitestep(bool Dummy) { c_DummyLitestep = Dummy; };
|
||||
static bool GetDummyLitestep() { return c_DummyLitestep; };
|
||||
static void SetCommandLine(LPCTSTR CmdLine) { c_CmdLine = CmdLine;};
|
||||
static LPCTSTR GetCommandLine() { return c_CmdLine.c_str(); };
|
||||
static GlobalConfig& GetGlobalConfig() { return c_GlobalConfig; };
|
||||
|
||||
void ReloadSettings();
|
||||
void SaveSettings();
|
||||
|
||||
void UpdateStats();
|
||||
void ReadStats();
|
||||
void WriteStats();
|
||||
void ResetStats();
|
||||
|
||||
BOOL GetCheckUpdate() { return m_CheckUpdate; };
|
||||
void SetCheckUpdate(BOOL check) { m_CheckUpdate = check; };
|
||||
|
||||
void ShowContextMenu(POINT pos, CMeterWindow* meterWindow);
|
||||
|
||||
std::wstring GetTrayExecuteL() { return m_TrayExecuteL; };
|
||||
std::wstring GetTrayExecuteR() { return m_TrayExecuteR; };
|
||||
std::wstring GetTrayExecuteM() { return m_TrayExecuteM; };
|
||||
std::wstring GetTrayExecuteDR() { return m_TrayExecuteDR; };
|
||||
std::wstring GetTrayExecuteDL() { return m_TrayExecuteDL; };
|
||||
std::wstring GetTrayExecuteDM() { return m_TrayExecuteDM; };
|
||||
|
||||
BOOL ExecuteBang(const std::wstring& bang, const std::wstring& arg, CMeterWindow* meterWindow);
|
||||
std::wstring ParseCommand(const WCHAR* command, CMeterWindow* meterWindow);
|
||||
void ExecuteCommand(const WCHAR* command, CMeterWindow* meterWindow);
|
||||
static std::wstring FixPath(const std::wstring& path, PATH_FOLDER folder, const std::wstring& currentSkin);
|
||||
|
||||
static PLATFORM IsNT();
|
||||
|
||||
private:
|
||||
void CreateMeterWindow(std::wstring config, std::wstring iniFile);
|
||||
bool DeleteMeterWindow(CMeterWindow* meterWindow);
|
||||
void ScanForConfigs(std::wstring& path);
|
||||
void ReadGeneralSettings(std::wstring& path);
|
||||
bool SetActiveConfig(std::wstring& skinName, std::wstring& skinIni);
|
||||
void Refresh(const WCHAR* arg);
|
||||
HMENU CreateSkinMenu(CMeterWindow* meterWindow, int index);
|
||||
void ChangeSkinIndex(HMENU subMenu, int index);
|
||||
int ScanForConfigsRecursive(std::wstring& path, std::wstring base, int index, std::vector<CONFIGMENU>& menu);
|
||||
HMENU CreateConfigMenu(std::vector<CONFIGMENU>& configMenuData);
|
||||
|
||||
CTrayWindow* m_TrayWindow;
|
||||
|
||||
std::vector<CONFIG> m_ConfigStrings; // All configs found in the given folder
|
||||
std::vector<CONFIGMENU> m_ConfigMenu;
|
||||
std::map<std::wstring, CMeterWindow*> m_Meters; // The meter windows
|
||||
|
||||
std::wstring m_Path; // Path to the main folder
|
||||
std::wstring m_IniFile; // The main ini file
|
||||
std::wstring m_SkinPath; // Path to the folder where the skins are
|
||||
std::wstring m_PluginPath; // Path to the folder where the plugins are
|
||||
|
||||
std::wstring m_StatsDate; // The date when stats gathering started
|
||||
|
||||
std::wstring m_TrayExecuteL;
|
||||
std::wstring m_TrayExecuteR;
|
||||
std::wstring m_TrayExecuteM;
|
||||
std::wstring m_TrayExecuteDL;
|
||||
std::wstring m_TrayExecuteDR;
|
||||
std::wstring m_TrayExecuteDM;
|
||||
|
||||
BOOL m_CheckUpdate;
|
||||
|
||||
BOOL m_DesktopWorkAreaChanged;
|
||||
RECT m_DesktopWorkArea;
|
||||
|
||||
std::wstring m_ConfigEditor;
|
||||
|
||||
CConfigParser* m_CurrentParser;
|
||||
|
||||
HINSTANCE m_Instance;
|
||||
|
||||
ULONG_PTR m_GDIplusToken;
|
||||
|
||||
static bool c_DummyLitestep; // true, if not a Litestep plugin
|
||||
static std::wstring c_CmdLine; // The command line arguments
|
||||
static GlobalConfig c_GlobalConfig;
|
||||
};
|
||||
|
||||
#ifdef LIBRARY_EXPORTS
|
||||
#define EXPORT_PLUGIN __declspec(dllexport)
|
||||
#else
|
||||
#define EXPORT_PLUGIN __declspec(dllimport)
|
||||
#endif
|
||||
|
||||
extern "C"
|
||||
{
|
||||
EXPORT_PLUGIN int initModuleEx(HWND ParentWnd, HINSTANCE dllInst, LPCSTR szPath);
|
||||
EXPORT_PLUGIN void quitModule(HINSTANCE dllInst);
|
||||
EXPORT_PLUGIN void Initialize(bool DummyLS, LPCTSTR CmdLine);
|
||||
}
|
||||
|
||||
#endif
|
||||
BIN
Library/Res/tray.ico
Normal file
BIN
Library/Res/tray.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
643
Library/TrayWindow.cpp
Normal file
643
Library/TrayWindow.cpp
Normal file
@@ -0,0 +1,643 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/TrayWindow.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: TrayWindow.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.2 2004/07/11 17:19:57 rainy
|
||||
Whole skin folder is recursively scanned.
|
||||
|
||||
Revision 1.1 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
*/
|
||||
|
||||
#define _WIN32_IE 0x0600
|
||||
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include "TrayWindow.h"
|
||||
#include "Resource.h"
|
||||
#include "Litestep.h"
|
||||
#include "Rainmeter.h"
|
||||
#include "AboutDialog.h"
|
||||
#include "Error.h"
|
||||
#include <io.h>
|
||||
#include <ShellAPI.h>
|
||||
|
||||
#define TRAYTIMER 3
|
||||
|
||||
extern CRainmeter* Rainmeter;
|
||||
|
||||
using namespace Gdiplus;
|
||||
|
||||
CTrayWindow::CTrayWindow(HINSTANCE instance)
|
||||
{
|
||||
WNDCLASS wc;
|
||||
|
||||
wc.style = 0;
|
||||
wc.lpfnWndProc = (WNDPROC)WndProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = instance;
|
||||
wc.hIcon = NULL;
|
||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
|
||||
wc.lpszMenuName = NULL;
|
||||
wc.lpszClassName = L"RainmeterTrayClass";
|
||||
|
||||
RegisterClass(&wc);
|
||||
|
||||
m_Window = CreateWindowEx(
|
||||
WS_EX_TOOLWINDOW,
|
||||
L"RainmeterTrayClass",
|
||||
NULL,
|
||||
WS_POPUP,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
CW_USEDEFAULT,
|
||||
NULL,
|
||||
NULL,
|
||||
instance,
|
||||
this);
|
||||
|
||||
m_Instance = instance;
|
||||
m_Measure = NULL;
|
||||
m_TrayIcon = NULL;
|
||||
|
||||
m_MeterType = TRAY_METER_TYPE_HISTOGRAM;
|
||||
m_TrayColor1 = Color(0, 100, 0);
|
||||
m_TrayColor2 = Color(0, 255, 0);
|
||||
|
||||
m_Bitmap = NULL;
|
||||
|
||||
#ifndef _WIN64
|
||||
SetWindowLong(m_Window, GWL_USERDATA, magicDWord);
|
||||
#endif
|
||||
|
||||
m_TrayPos = 0;
|
||||
memset(m_TrayValues, 0, sizeof(double) * TRAYICON_SIZE);
|
||||
}
|
||||
|
||||
CTrayWindow::~CTrayWindow()
|
||||
{
|
||||
KillTimer(m_Window, TRAYTIMER);
|
||||
RemoveTrayIcon();
|
||||
|
||||
if (m_Bitmap) delete m_Bitmap;
|
||||
if (m_Measure) delete m_Measure;
|
||||
|
||||
for (int i = 0; i < m_TrayIcons.size(); i++)
|
||||
{
|
||||
DestroyIcon(m_TrayIcons[i]);
|
||||
}
|
||||
m_TrayIcons.clear();
|
||||
|
||||
if (m_Window) DestroyWindow(m_Window);
|
||||
}
|
||||
|
||||
BOOL CTrayWindow::AddTrayIcon()
|
||||
{
|
||||
BOOL res = FALSE;
|
||||
NOTIFYICONDATA tnid;
|
||||
|
||||
if (m_TrayIcon)
|
||||
{
|
||||
DestroyIcon(m_TrayIcon);
|
||||
m_TrayIcon = NULL;
|
||||
}
|
||||
|
||||
m_TrayIcon = CreateTrayIcon(0);
|
||||
|
||||
if (m_TrayIcon)
|
||||
{
|
||||
tnid.cbSize = sizeof(NOTIFYICONDATA);
|
||||
tnid.hWnd = m_Window;
|
||||
tnid.uID = IDI_TRAY;
|
||||
tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP;
|
||||
tnid.uCallbackMessage = WM_NOTIFYICON;
|
||||
tnid.hIcon = m_TrayIcon;
|
||||
lstrcpyn(tnid.szTip, L"Rainmeter", sizeof(tnid.szTip));
|
||||
|
||||
res = Shell_NotifyIcon(NIM_ADD, &tnid);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
BOOL CTrayWindow::RemoveTrayIcon()
|
||||
{
|
||||
BOOL res = FALSE;
|
||||
|
||||
if (m_TrayIcon)
|
||||
{
|
||||
NOTIFYICONDATA tnid;
|
||||
|
||||
tnid.cbSize = sizeof(NOTIFYICONDATA);
|
||||
tnid.hWnd = m_Window;
|
||||
tnid.uID = IDI_TRAY;
|
||||
tnid.uFlags = 0;
|
||||
|
||||
res = Shell_NotifyIcon(NIM_DELETE, &tnid);
|
||||
|
||||
DestroyIcon(m_TrayIcon);
|
||||
m_TrayIcon = NULL;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
BOOL CTrayWindow::ModifyTrayIcon(double value)
|
||||
{
|
||||
BOOL res = FALSE;
|
||||
NOTIFYICONDATA tnid;
|
||||
|
||||
if (m_TrayIcon)
|
||||
{
|
||||
DestroyIcon(m_TrayIcon);
|
||||
m_TrayIcon = NULL;
|
||||
}
|
||||
|
||||
m_TrayIcon = CreateTrayIcon(value);
|
||||
|
||||
tnid.cbSize = sizeof(NOTIFYICONDATA);
|
||||
tnid.hWnd = m_Window;
|
||||
tnid.uID = IDI_TRAY;
|
||||
tnid.uFlags = NIF_ICON;
|
||||
tnid.hIcon = m_TrayIcon;
|
||||
|
||||
res = Shell_NotifyIcon(NIM_MODIFY, &tnid);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
BOOL CTrayWindow::ShowBalloonHelp()
|
||||
{
|
||||
BOOL res = FALSE;
|
||||
|
||||
NOTIFYICONDATA nid;
|
||||
memset(&nid, 0, sizeof(NOTIFYICONDATA));
|
||||
|
||||
nid.hWnd = m_Window;
|
||||
nid.uID = IDI_TRAY;
|
||||
nid.cbSize=sizeof(NOTIFYICONDATA);
|
||||
nid.uFlags = NIF_INFO;
|
||||
nid.uTimeout = 30000;
|
||||
nid.dwInfoFlags = 4; // NIIF_USER;
|
||||
nid.hIcon = LoadIcon(m_Instance, MAKEINTRESOURCE(IDI_TRAY));
|
||||
wcscpy(nid.szInfo, L"There aren't any configs active at the moment. Open the context menu from Rainmeter's tray icon and select a config you want to use.");
|
||||
wcscpy(nid.szInfoTitle, L"Rainmeter");
|
||||
res = Shell_NotifyIcon(NIM_MODIFY, &nid);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
HICON CTrayWindow::CreateTrayIcon(double value)
|
||||
{
|
||||
if (m_Measure == NULL)
|
||||
{
|
||||
return LoadIcon(m_Instance, MAKEINTRESOURCE(IDI_TRAY));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_MeterType == TRAY_METER_TYPE_HISTOGRAM)
|
||||
{
|
||||
m_TrayValues[m_TrayPos] = value;
|
||||
m_TrayPos = (m_TrayPos + 1) % TRAYICON_SIZE;
|
||||
|
||||
Bitmap trayBitmap(TRAYICON_SIZE, TRAYICON_SIZE);
|
||||
Graphics graphics(&trayBitmap);
|
||||
graphics.SetSmoothingMode(SmoothingModeAntiAlias);
|
||||
|
||||
Point points[TRAYICON_SIZE + 2];
|
||||
points[0].X = 0;
|
||||
points[0].Y = TRAYICON_SIZE;
|
||||
points[TRAYICON_SIZE + 1].X = TRAYICON_SIZE - 1;
|
||||
points[TRAYICON_SIZE + 1].Y = TRAYICON_SIZE;
|
||||
|
||||
for (int i = 0; i < TRAYICON_SIZE; i++)
|
||||
{
|
||||
points[i + 1].X = i;
|
||||
points[i + 1].Y = (int)(TRAYICON_SIZE * (1.0 - m_TrayValues[(m_TrayPos + i) % TRAYICON_SIZE]));
|
||||
}
|
||||
|
||||
SolidBrush brush(m_TrayColor1);
|
||||
graphics.FillRectangle(&brush, 0, 0, TRAYICON_SIZE, TRAYICON_SIZE);
|
||||
|
||||
SolidBrush brush2(m_TrayColor2);
|
||||
graphics.FillPolygon(&brush2, points, TRAYICON_SIZE + 2);
|
||||
|
||||
HICON icon;
|
||||
trayBitmap.GetHICON(&icon);
|
||||
return icon;
|
||||
}
|
||||
else if (m_MeterType == TRAY_METER_TYPE_BITMAP && (m_Bitmap || m_TrayIcons.size() > 0))
|
||||
{
|
||||
if (m_TrayIcons.size() > 0)
|
||||
{
|
||||
size_t frame = 0;
|
||||
size_t frameCount = m_TrayIcons.size();
|
||||
|
||||
// Select the correct frame linearly
|
||||
frame = (size_t)(value * frameCount);
|
||||
frame = min((frameCount - 1), frame);
|
||||
|
||||
return CopyIcon(m_TrayIcons[frame]);
|
||||
}
|
||||
else
|
||||
{
|
||||
int frame = 0;
|
||||
int frameCount = 0;
|
||||
int newX, newY;
|
||||
|
||||
if (m_Bitmap->GetWidth() > m_Bitmap->GetHeight())
|
||||
{
|
||||
frameCount = m_Bitmap->GetWidth() / TRAYICON_SIZE;
|
||||
}
|
||||
else
|
||||
{
|
||||
frameCount = m_Bitmap->GetHeight() / TRAYICON_SIZE;
|
||||
}
|
||||
|
||||
// Select the correct frame linearly
|
||||
frame = (int)(value * frameCount);
|
||||
frame = min((frameCount - 1), frame);
|
||||
|
||||
if (m_Bitmap->GetWidth() > m_Bitmap->GetHeight())
|
||||
{
|
||||
newX = frame * TRAYICON_SIZE;
|
||||
newY = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
newX = 0;
|
||||
newY = frame * TRAYICON_SIZE;
|
||||
}
|
||||
|
||||
Bitmap trayBitmap(TRAYICON_SIZE, TRAYICON_SIZE);
|
||||
Graphics graphics(&trayBitmap);
|
||||
graphics.SetSmoothingMode(SmoothingModeAntiAlias);
|
||||
|
||||
// Blit the image
|
||||
Rect r(0, 0, TRAYICON_SIZE, TRAYICON_SIZE);
|
||||
graphics.DrawImage(m_Bitmap, r, newX, newY, TRAYICON_SIZE, TRAYICON_SIZE, UnitPixel);
|
||||
|
||||
HICON icon;
|
||||
trayBitmap.GetHICON(&icon);
|
||||
return icon;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void CTrayWindow::ReadConfig(CConfigParser& parser)
|
||||
{
|
||||
for (int i = 0; i < m_TrayIcons.size(); i++)
|
||||
{
|
||||
DestroyIcon(m_TrayIcons[i]);
|
||||
}
|
||||
m_TrayIcons.clear();
|
||||
|
||||
std::wstring measureName = parser.ReadString(L"TrayMeasure", L"Measure", L"");
|
||||
|
||||
CConfigParser* oldParser = Rainmeter->GetCurrentParser();
|
||||
Rainmeter->SetCurrentParser(&parser);
|
||||
if (!measureName.empty())
|
||||
{
|
||||
m_Measure = CMeasure::Create(measureName.c_str(), NULL);
|
||||
m_Measure->SetName(L"TrayMeasure");
|
||||
m_Measure->ReadConfig(parser, L"TrayMeasure");
|
||||
}
|
||||
Rainmeter->SetCurrentParser(oldParser);
|
||||
|
||||
m_MeterType = TRAY_METER_TYPE_NONE;
|
||||
|
||||
std::wstring type = parser.ReadString(L"TrayMeasure", L"TrayMeter", L"HISTOGRAM");
|
||||
if (wcsicmp(type.c_str(), L"HISTOGRAM") == 0)
|
||||
{
|
||||
m_MeterType = TRAY_METER_TYPE_HISTOGRAM;
|
||||
m_TrayColor1 = parser.ReadColor(L"TrayMeasure", L"TrayColor1", Color(0, 100, 0));
|
||||
m_TrayColor2 = parser.ReadColor(L"TrayMeasure", L"TrayColor2", Color(0, 255, 0));
|
||||
}
|
||||
else if (wcsicmp(type.c_str(), L"BITMAP") == 0)
|
||||
{
|
||||
m_MeterType = TRAY_METER_TYPE_BITMAP;
|
||||
|
||||
std::wstring imageName = parser.ReadString(L"TrayMeasure", L"TrayBitmap", L"");
|
||||
|
||||
// Load the bitmaps if defined
|
||||
if (!imageName.empty())
|
||||
{
|
||||
imageName = Rainmeter->FixPath(imageName, PATH_FOLDER_SKINS, L"");
|
||||
|
||||
if (imageName.size() > 3)
|
||||
{
|
||||
std::wstring extension = imageName.substr(imageName.size() - 3);
|
||||
if (extension == L"ico" || extension == L"ICO")
|
||||
{
|
||||
int count = 1;
|
||||
HICON hIcon = NULL;
|
||||
|
||||
// Load the icons
|
||||
do
|
||||
{
|
||||
WCHAR buffer[MAX_PATH];
|
||||
wsprintf(buffer, imageName.c_str(), count++);
|
||||
|
||||
hIcon = (HICON)LoadImage(NULL, buffer, IMAGE_ICON, TRAYICON_SIZE, TRAYICON_SIZE, LR_LOADFROMFILE);
|
||||
if (hIcon) m_TrayIcons.push_back(hIcon);
|
||||
if (imageName == buffer) break;
|
||||
} while(hIcon != NULL);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_TrayIcons.size() == 0)
|
||||
{
|
||||
// No icons found so load as bitmap
|
||||
if (m_Bitmap)
|
||||
{
|
||||
delete m_Bitmap;
|
||||
}
|
||||
m_Bitmap = new Bitmap(imageName.c_str());
|
||||
Status status = m_Bitmap->GetLastStatus();
|
||||
if(Ok != status)
|
||||
{
|
||||
DebugLog(L"Bitmap image not found: %s", imageName.c_str());
|
||||
delete m_Bitmap;
|
||||
m_Bitmap = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugLog(L"No such TrayMeter: %s", type.c_str());
|
||||
}
|
||||
|
||||
int trayIcon = parser.ReadInt(L"Rainmeter", L"TrayIcon", 1);
|
||||
if (trayIcon != 0)
|
||||
{
|
||||
AddTrayIcon();
|
||||
SetTimer(m_Window, TRAYTIMER, 1000, NULL); // Update the tray once per sec
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LRESULT CALLBACK CTrayWindow::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static CTrayWindow* tray = NULL;
|
||||
|
||||
if(uMsg == WM_CREATE)
|
||||
{
|
||||
tray=(CTrayWindow*)((LPCREATESTRUCT)lParam)->lpCreateParams;
|
||||
}
|
||||
|
||||
switch(uMsg)
|
||||
{
|
||||
case WM_COMMAND:
|
||||
if (Rainmeter && tray)
|
||||
{
|
||||
if(wParam == ID_CONTEXT_ABOUT)
|
||||
{
|
||||
OpenAboutDialog(tray->GetWindow(), Rainmeter->GetInstance());
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SHOW_HELP)
|
||||
{
|
||||
std::wstring help = Rainmeter->GetPath();
|
||||
help += L"Rainmeter.chm";
|
||||
LSExecute(NULL, help.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_REFRESH)
|
||||
{
|
||||
// Read skins and settings
|
||||
Rainmeter->ReloadSettings();
|
||||
|
||||
// Refresh all
|
||||
RainmeterRefresh(tray->GetWindow(), NULL);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_SHOWLOGFILE)
|
||||
{
|
||||
// Check if the file exists
|
||||
std::wstring log = Rainmeter->GetPath();
|
||||
log += L"Rainmeter.log";
|
||||
if (_waccess(log.c_str(), 0) != -1)
|
||||
{
|
||||
std::wstring command = L"Notepad.exe ";
|
||||
command += log;
|
||||
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
int res = MessageBox(tray->GetWindow(), L"The log file doesn't exist.\nDo you want to create it?", L"Rainmeter", MB_YESNO | MB_ICONQUESTION);
|
||||
if (res == IDYES)
|
||||
{
|
||||
HANDLE file = CreateFile(log.c_str(), GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (file != INVALID_HANDLE_VALUE)
|
||||
{
|
||||
CloseHandle(file);
|
||||
ResetLoggingFlag(); // Re-enable logging
|
||||
|
||||
std::wstring message;
|
||||
message = L"Created file: ";
|
||||
message += log;
|
||||
message += L"\nDelete it to disable Rainmeter's logging";
|
||||
MessageBox(tray->GetWindow(), message.c_str(), L"Rainmeter", MB_OK | MB_ICONINFORMATION);
|
||||
|
||||
std::wstring command = L"Notepad.exe ";
|
||||
command += log;
|
||||
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::wstring message;
|
||||
message = L"Unable to create the file: ";
|
||||
message += log;
|
||||
MessageBox(tray->GetWindow(), message.c_str(), L"Rainmeter", MB_OK | MB_ICONERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_EDITCONFIG)
|
||||
{
|
||||
std::wstring command = Rainmeter->GetConfigEditor();
|
||||
command += L" \"";
|
||||
command += Rainmeter->GetIniFile();
|
||||
LSExecute(tray->GetWindow(), command.c_str(), SW_SHOWNORMAL);
|
||||
}
|
||||
else if(wParam == ID_CONTEXT_QUIT)
|
||||
{
|
||||
if (Rainmeter->GetDummyLitestep()) PostQuitMessage(0);
|
||||
quitModule(Rainmeter->GetInstance());
|
||||
}
|
||||
else if((wParam & 0x0ffff) >= ID_CONFIG_FIRST)
|
||||
{
|
||||
wParam = wParam & 0x0ffff;
|
||||
|
||||
// Check which config was selected
|
||||
const std::vector<CRainmeter::CONFIG>& configs = Rainmeter->GetAllConfigs();
|
||||
|
||||
for (int i = 0; i < configs.size(); i++)
|
||||
{
|
||||
for (int j = 0; j < configs[i].commands.size(); j++)
|
||||
{
|
||||
if (configs[i].commands[j] == wParam)
|
||||
{
|
||||
if (configs[i].active == j + 1)
|
||||
{
|
||||
CMeterWindow* meterWindow = Rainmeter->GetMeterWindow(configs[i].config);
|
||||
Rainmeter->DeactivateConfig(meterWindow, i);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (configs[i].active != 0)
|
||||
{
|
||||
CMeterWindow* meterWindow = Rainmeter->GetMeterWindow(configs[i].config);
|
||||
if (meterWindow)
|
||||
{
|
||||
Rainmeter->DeactivateConfig(meterWindow, i);
|
||||
}
|
||||
}
|
||||
Rainmeter->ActivateConfig(i, j);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Forward the message to correct window
|
||||
int index = (int)(wParam >> 16);
|
||||
std::map<std::wstring, CMeterWindow*>& windows = Rainmeter->GetAllMeterWindows();
|
||||
|
||||
if (index < windows.size())
|
||||
{
|
||||
std::map<std::wstring, CMeterWindow*>::iterator iter = windows.begin();
|
||||
for( ; iter != windows.end(); iter++)
|
||||
{
|
||||
index--;
|
||||
if (index < 0)
|
||||
{
|
||||
CMeterWindow* meterWindow = (*iter).second;
|
||||
SendMessage(meterWindow->GetWindow(), WM_COMMAND, wParam & 0x0FFFF, NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0; // Don't send WM_COMMANDS any further
|
||||
|
||||
case WM_NOTIFYICON:
|
||||
{
|
||||
UINT uMouseMsg = (UINT)lParam;
|
||||
|
||||
std::wstring bang;
|
||||
|
||||
switch(uMouseMsg)
|
||||
{
|
||||
case WM_LBUTTONDOWN:
|
||||
bang = Rainmeter->GetTrayExecuteL();
|
||||
break;
|
||||
|
||||
case WM_MBUTTONDOWN:
|
||||
bang = Rainmeter->GetTrayExecuteM();
|
||||
break;
|
||||
|
||||
case WM_RBUTTONDOWN:
|
||||
bang = Rainmeter->GetTrayExecuteR();
|
||||
break;
|
||||
|
||||
case WM_LBUTTONDBLCLK:
|
||||
bang = Rainmeter->GetTrayExecuteDL();
|
||||
break;
|
||||
|
||||
case WM_MBUTTONDBLCLK:
|
||||
bang = Rainmeter->GetTrayExecuteDM();
|
||||
break;
|
||||
|
||||
case WM_RBUTTONDBLCLK:
|
||||
bang = Rainmeter->GetTrayExecuteDR();
|
||||
break;
|
||||
}
|
||||
|
||||
if (!bang.empty())
|
||||
{
|
||||
std::wstring arg;
|
||||
size_t pos = bang.find(L' ');
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
arg = bang;
|
||||
arg.erase(0, pos + 1);
|
||||
bang = bang.substr(0, pos);
|
||||
}
|
||||
Rainmeter->ExecuteBang(bang, arg, NULL);
|
||||
}
|
||||
else if (uMouseMsg == WM_RBUTTONDOWN)
|
||||
{
|
||||
POINT point;
|
||||
GetCursorPos(&point);
|
||||
SetForegroundWindow(tray->m_Window);
|
||||
Rainmeter->ShowContextMenu(point, NULL);
|
||||
SetForegroundWindow(tray->m_Window);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_TIMER:
|
||||
if (tray && tray->m_Measure)
|
||||
{
|
||||
tray->m_Measure->Update();
|
||||
tray->ModifyTrayIcon(tray->m_Measure->GetRelativeValue());
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
if (Rainmeter->GetDummyLitestep()) PostQuitMessage(0);
|
||||
break;
|
||||
|
||||
case LM_GETREVID:
|
||||
if(lParam != NULL)
|
||||
{
|
||||
char* Buffer=(char*)lParam;
|
||||
if(wParam==0)
|
||||
{
|
||||
sprintf(Buffer, "Rainmeter.dll: %s", APPVERSION);
|
||||
}
|
||||
else if(wParam==1)
|
||||
{
|
||||
sprintf(Buffer, "Rainmeter.dll: %s %s, Rainy", APPVERSION, __DATE__);
|
||||
}
|
||||
else
|
||||
{
|
||||
Buffer[0] = 0;
|
||||
}
|
||||
|
||||
return strlen(Buffer);
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
return DefWindowProc(hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
83
Library/TrayWindow.h
Normal file
83
Library/TrayWindow.h
Normal file
@@ -0,0 +1,83 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/TrayWindow.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: TrayWindow.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.1 2004/06/05 10:55:54 rainy
|
||||
Too much changes to be listed in here...
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __TRAYWINDOW_H__
|
||||
#define __TRAYWINDOW_H__
|
||||
|
||||
#pragma warning(disable: 4786)
|
||||
|
||||
#include <windows.h>
|
||||
#include "Measure.h"
|
||||
|
||||
#define WM_NOTIFYICON WM_USER + 101
|
||||
#define TRAYICON_SIZE 16
|
||||
|
||||
enum TRAY_METER_TYPE
|
||||
{
|
||||
TRAY_METER_TYPE_NONE,
|
||||
TRAY_METER_TYPE_HISTOGRAM,
|
||||
TRAY_METER_TYPE_BITMAP
|
||||
};
|
||||
|
||||
class CTrayWindow
|
||||
{
|
||||
public:
|
||||
CTrayWindow(HINSTANCE instance);
|
||||
~CTrayWindow();
|
||||
|
||||
void ReadConfig(CConfigParser& parser);
|
||||
HWND GetWindow() { return m_Window; }
|
||||
BOOL ShowBalloonHelp();
|
||||
|
||||
protected:
|
||||
static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
|
||||
|
||||
private:
|
||||
BOOL AddTrayIcon();
|
||||
BOOL RemoveTrayIcon();
|
||||
BOOL ModifyTrayIcon(double value);
|
||||
HICON CreateTrayIcon(double value);
|
||||
|
||||
HICON m_TrayIcon;
|
||||
HWND m_Window;
|
||||
HINSTANCE m_Instance;
|
||||
CMeasure* m_Measure;
|
||||
|
||||
TRAY_METER_TYPE m_MeterType;
|
||||
Gdiplus::Color m_TrayColor1;
|
||||
Gdiplus::Color m_TrayColor2;
|
||||
Gdiplus::Bitmap* m_Bitmap;
|
||||
|
||||
std::vector<HICON> m_TrayIcons;
|
||||
|
||||
double m_TrayValues[TRAYICON_SIZE];
|
||||
int m_TrayPos;
|
||||
};
|
||||
|
||||
#endif
|
||||
107
Library/UpdateCheck.cpp
Normal file
107
Library/UpdateCheck.cpp
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/UpdateCheck.cpp,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: UpdateCheck.cpp,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.1 2004/08/13 15:44:02 rainy
|
||||
Initial version.
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4786)
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include <windows.h>
|
||||
#include "Litestep.h"
|
||||
#include "Rainmeter.h"
|
||||
#include <string>
|
||||
#include <Wininet.h>
|
||||
#include <process.h>
|
||||
|
||||
void CheckVersion(void* dummy)
|
||||
{
|
||||
int version = 0;
|
||||
|
||||
HINTERNET hRootHandle = InternetOpen(L"Rainmeter",
|
||||
INTERNET_OPEN_TYPE_PRECONFIG,
|
||||
NULL,
|
||||
NULL,
|
||||
0);
|
||||
if (hRootHandle == NULL)
|
||||
{
|
||||
DebugLog(L"CheckUpdate: InternetOpen failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
HINTERNET hUrlDump = InternetOpenUrl(hRootHandle, L"http://www.ipi.fi/~rainy/Rainmeter/version", NULL, NULL, INTERNET_FLAG_RESYNCHRONIZE, 0);
|
||||
if (hUrlDump)
|
||||
{
|
||||
DWORD dwSize;
|
||||
char buffer[16]; // 16 should be enough for the version number
|
||||
buffer[0] = 0;
|
||||
if (InternetReadFile(hUrlDump, (LPVOID)buffer, 16, &dwSize))
|
||||
{
|
||||
// Add a null terminator to the end of the buffer (just in case...).
|
||||
std::string verStr = buffer;
|
||||
size_t pos = verStr.find('.');
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
std::string verStr1 = verStr.substr(pos + 1);
|
||||
version = atoi(verStr1.c_str()) * 1000;
|
||||
pos = verStr.find('.', pos + 1);
|
||||
if (pos != std::wstring::npos)
|
||||
{
|
||||
std::string verStr1 = verStr.substr(pos + 1);
|
||||
version += atoi(verStr1.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
if (version > RAINMETER_VERSION)
|
||||
{
|
||||
if (IDYES == MessageBox(NULL, L"A new version of Rainmeter is available at http://www.iki.fi/rainy.\nDo you want to go there now?", APPNAME, MB_YESNO | MB_ICONQUESTION))
|
||||
{
|
||||
LSExecute(NULL, L"http://www.iki.fi/rainy/Rainmeter.html", SW_SHOWNORMAL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugLog(L"CheckUpdate: No new version available.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugLog(L"CheckUpdate: InternetReadFile failed.");
|
||||
}
|
||||
InternetCloseHandle(hUrlDump);
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugLog(L"CheckUpdate: InternetOpenUrl failed.");
|
||||
}
|
||||
|
||||
InternetCloseHandle(hRootHandle);
|
||||
}
|
||||
|
||||
void CheckUpdate()
|
||||
{
|
||||
_beginthread(CheckVersion, 0, NULL );
|
||||
}
|
||||
35
Library/UpdateCheck.h
Normal file
35
Library/UpdateCheck.h
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Library/UpdateCheck.h,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: UpdateCheck.h,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.1 2004/08/13 15:44:02 rainy
|
||||
Initial version.
|
||||
|
||||
*/
|
||||
|
||||
#ifndef __UPDATE_CHECK_H__
|
||||
#define __UPDATE_CHECK_H__
|
||||
|
||||
void CheckUpdate();
|
||||
|
||||
#endif
|
||||
284
Library/ccalc-0.5.1/lexer.c
Normal file
284
Library/ccalc-0.5.1/lexer.c
Normal file
@@ -0,0 +1,284 @@
|
||||
/*
|
||||
Universal lexical analiser implementation
|
||||
*/
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include "lexer.h"
|
||||
|
||||
//#define MY_DEBUG 1
|
||||
|
||||
#ifdef MY_DEBUG
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
/* Uppercase translation table for the Win1251 charset */
|
||||
const char Win1251UpcaseTbl[] =
|
||||
"\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017"
|
||||
"\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
|
||||
" !\042#$%&'()*+,-./0123456789:;<=>?"
|
||||
"@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
|
||||
"`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~\177"
|
||||
"\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217"
|
||||
"\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237"
|
||||
"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257"
|
||||
"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277"
|
||||
"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317"
|
||||
"\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337"
|
||||
"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317"
|
||||
"\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337";
|
||||
|
||||
char Win1251RusLetters[] =
|
||||
"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317"
|
||||
"\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337"
|
||||
"\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357"
|
||||
"\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377";
|
||||
|
||||
|
||||
hqCharType Win1251NameTbl[256];
|
||||
int win1251nametbl_initialized = 0;
|
||||
|
||||
int FindSymbol( SymbolRec **SymTable, const char *str, int *nchars );
|
||||
|
||||
// initializations
|
||||
|
||||
void InitCharTypeTable( hqCharType *CharTypeTable, int CharTypes )
|
||||
{
|
||||
int ch;
|
||||
#ifdef MY_DEBUG
|
||||
printf( "CharTypeTable = 0x%X; CharTypes = %d\n", (unsigned)CharTypeTable,
|
||||
CharTypes );
|
||||
#endif
|
||||
memset( CharTypeTable, CH_UNKNOWN, 256 * sizeof(hqCharType) );
|
||||
|
||||
CharTypeTable[0] = CH_FINAL;
|
||||
|
||||
if (CharTypes & CH_SEPARAT) {
|
||||
CharTypeTable[' '] = CH_SEPARAT;
|
||||
CharTypeTable[9] = CH_SEPARAT;
|
||||
CharTypeTable[13] = CH_SEPARAT;
|
||||
CharTypeTable[10] = CH_SEPARAT;
|
||||
}
|
||||
|
||||
if (CharTypes & CH_QUOTE) {
|
||||
CharTypeTable['\''] = CH_QUOTE;
|
||||
}
|
||||
|
||||
if (CharTypes & CH_LETTER) {
|
||||
for (ch='A'; ch<='Z'; ch++)
|
||||
CharTypeTable[ch] = CH_LETTER;
|
||||
for (ch='a'; ch<='z'; ch++)
|
||||
CharTypeTable[ch] = CH_LETTER;
|
||||
CharTypeTable['_'] = CH_LETTER;
|
||||
}
|
||||
|
||||
if (CharTypes & CH_DIGIT) {
|
||||
for (ch='0'; ch<='9'; ch++)
|
||||
CharTypeTable[ch] = CH_DIGIT;
|
||||
}
|
||||
}
|
||||
|
||||
void TypeTableAddChars( hqCharType *CharTypeTable, char *Symbols,
|
||||
hqCharType CharType )
|
||||
{
|
||||
while (*Symbols)
|
||||
CharTypeTable[ (uchar) *Symbols++] = CharType;
|
||||
}
|
||||
|
||||
void UpcaseWin1251Str( char *Str )
|
||||
{
|
||||
while (( *Str = Win1251UpcaseTbl[ (uchar) *Str ] ))
|
||||
++Str;
|
||||
}
|
||||
|
||||
|
||||
// hqLexer implementation
|
||||
|
||||
#define CHARTYPEPP lexer->CharTypeTable[ (uchar) *++(lexer->SS) ]
|
||||
#define CHARTYPE lexer->CharTypeTable[ (uchar) *lexer->SS ]
|
||||
|
||||
int Lexer_SetParseString( hqLexer *lexer, const char *str )
|
||||
{
|
||||
lexer->PrevTokenType = TOK_NONE;
|
||||
if ( !str || !*str )
|
||||
return 0;
|
||||
|
||||
lexer->SS = str;
|
||||
lexer->CharType = CHARTYPE;
|
||||
return 1;
|
||||
}
|
||||
|
||||
hqTokenType Lexer_GetNextToken( hqLexer *lexer )
|
||||
{
|
||||
hqTokenType result = TOK_ERROR;
|
||||
|
||||
next_token:
|
||||
|
||||
while ( lexer->CharType == CH_SEPARAT )
|
||||
lexer->CharType = CHARTYPEPP;
|
||||
|
||||
switch ( lexer->CharType ) {
|
||||
case CH_FINAL:
|
||||
result = TOK_FINAL;
|
||||
break;
|
||||
case CH_LETTER:
|
||||
lexer->Name = lexer->SS;
|
||||
do {
|
||||
lexer->CharType = CHARTYPEPP;
|
||||
} while (lexer->CharType <= CH_DIGIT);
|
||||
lexer->NameLen = lexer->SS - lexer->Name;
|
||||
result = TOK_NAME;
|
||||
break;
|
||||
case CH_DIGIT: {
|
||||
char *NewSS, ch = *lexer->SS, nch = *(lexer->SS+1);
|
||||
int intreaded = 0;
|
||||
// Readind hex number
|
||||
if ( ch == '0' && nch == 'x' ) {
|
||||
lexer->IntValue = strtol( lexer->SS, &NewSS, 16 );
|
||||
intreaded = 1;
|
||||
}
|
||||
// Readind oct number
|
||||
if ( ch == '0' && nch >= '0' && nch <= '9' ) {
|
||||
lexer->IntValue = strtol( lexer->SS, &NewSS, 8 );
|
||||
intreaded = 1;
|
||||
}
|
||||
|
||||
if (intreaded == 1) {
|
||||
if ( lexer->SS != NewSS ) {
|
||||
lexer->SS = NewSS;
|
||||
if (lexer->NoIntegers) {
|
||||
lexer->ExtValue = lexer->IntValue;
|
||||
result = TOK_FLOAT;
|
||||
} else
|
||||
result = TOK_INT;
|
||||
lexer->CharType = CHARTYPE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Readind dec number
|
||||
lexer->ExtValue = strtod( lexer->SS, &NewSS );
|
||||
if ( lexer->SS != NewSS ) {;
|
||||
lexer->SS = NewSS;
|
||||
if ( !lexer->NoIntegers
|
||||
&& lexer->ExtValue<=INT_MAX
|
||||
&& lexer->ExtValue>=INT_MAX
|
||||
&& (double)( lexer->IntValue = (uchar) lexer->ExtValue )
|
||||
== lexer->ExtValue ) {
|
||||
result = TOK_INT;
|
||||
} else
|
||||
result = TOK_FLOAT;
|
||||
lexer->CharType = CHARTYPE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CH_SYMBOL: {
|
||||
int nchars;
|
||||
int i = FindSymbol( lexer->SymTable, lexer->SS, &nchars );
|
||||
if (i >= 0) {
|
||||
lexer->SS += nchars;
|
||||
if (i == lexer->cssn) {
|
||||
char comend = *lexer->ComEnd;
|
||||
char comendpp = *(lexer->ComEnd+1);
|
||||
while ( *lexer->SS ) {
|
||||
if ( *lexer->SS == comend
|
||||
&&
|
||||
( comendpp == '\0' || *(lexer->SS+1) == comendpp )
|
||||
) {
|
||||
++lexer->SS;
|
||||
if (comendpp != '\0')
|
||||
++lexer->SS;
|
||||
lexer->CharType = CHARTYPE;
|
||||
goto next_token;
|
||||
}
|
||||
++lexer->SS;
|
||||
}
|
||||
break;
|
||||
}
|
||||
lexer->CharType = CHARTYPE;
|
||||
lexer->IntValue = i;
|
||||
result = TOK_SYMBOL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CH_QUOTE:
|
||||
lexer->Name = ++(lexer->SS);
|
||||
while ( lexer->CharTypeTable[ (uchar)*lexer->SS ] != CH_QUOTE
|
||||
&& *(lexer->SS) != '\0' )
|
||||
++lexer->SS;
|
||||
if ( CHARTYPE == CH_QUOTE ) {
|
||||
lexer->NameLen = lexer->SS - lexer->Name;
|
||||
++lexer->SS;
|
||||
lexer->CharType = CHARTYPE;
|
||||
result = TOK_STRING;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return lexer->PrevTokenType = result;
|
||||
}
|
||||
|
||||
const char* Lexer_GetCurrentPos( hqLexer *lexer )
|
||||
{
|
||||
return lexer->SS;
|
||||
}
|
||||
|
||||
// misc functions
|
||||
|
||||
void PrepareSymTable( SymbolRec **SymTable, char *symbols )
|
||||
{
|
||||
int i = 0, nchars = 1;
|
||||
memset( SymTable, 0, 256 * sizeof(void*) );
|
||||
while (*symbols) {
|
||||
if (*symbols=='\033') {
|
||||
nchars = *++symbols;
|
||||
++symbols;
|
||||
} else {
|
||||
SymbolRec **RecList = SymTable + *symbols;
|
||||
SymbolRec *Rec = *RecList;
|
||||
int count = 0;
|
||||
while ( Rec ) {
|
||||
++count;
|
||||
if ( Rec->More )
|
||||
++Rec;
|
||||
else
|
||||
break;
|
||||
}
|
||||
if ( Rec ) {
|
||||
*RecList = (SymbolRec*)
|
||||
realloc( *RecList, (count+1)*sizeof(SymbolRec) );
|
||||
Rec = *RecList + count;
|
||||
(Rec-1)->More = 1;
|
||||
} else {
|
||||
*RecList = (SymbolRec*) malloc( sizeof(SymbolRec) );
|
||||
Rec = *RecList;
|
||||
}
|
||||
strncpy( Rec->Sym, symbols, 4 );
|
||||
Rec->Len = (char) nchars;
|
||||
Rec->Index = (char) i;
|
||||
Rec->More = 0;
|
||||
symbols += nchars;
|
||||
++i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int FindSymbol( SymbolRec **SymTable, const char *str, int *nchars )
|
||||
{
|
||||
SymbolRec *Rec = SymTable[ (int)*str ];
|
||||
while ( Rec ) {
|
||||
if ( (Rec->Len == 1 && Rec->Sym[0] == str[0])
|
||||
||
|
||||
(Rec->Len == 2 && Rec->Sym[0] == str[0] && Rec->Sym[1] == str[1])
|
||||
||
|
||||
(Rec->Len == 3 && Rec->Sym[0] == str[0] && Rec->Sym[1] == str[1]
|
||||
&& Rec->Sym[2] == str[2])
|
||||
) {
|
||||
*nchars = Rec->Len;
|
||||
return Rec->Index;
|
||||
}
|
||||
Rec = ( Rec->More ) ? Rec + 1 : NULL;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
79
Library/ccalc-0.5.1/lexer.h
Normal file
79
Library/ccalc-0.5.1/lexer.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/*
|
||||
Universal lexical analiser by hq_software
|
||||
*/
|
||||
|
||||
#ifndef __LEXER_HPP__
|
||||
#define __LEXER_HPP__
|
||||
|
||||
#include "pack.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef unsigned char uchar;
|
||||
|
||||
typedef enum {
|
||||
CH_LETTER = 0x01, CH_DIGIT = 0x02, CH_SEPARAT = 0x04,
|
||||
CH_SYMBOL = 0x08, CH_QUOTE = 0x10,
|
||||
CH_UNKNOWN= 0x7E, CH_FINAL = 0x7F
|
||||
} hqCharType;
|
||||
|
||||
typedef enum {
|
||||
TOK_ERROR, TOK_NONE, TOK_FINAL, TOK_INT, TOK_FLOAT, TOK_SYMBOL,
|
||||
TOK_NAME, TOK_STRING
|
||||
} hqTokenType;
|
||||
|
||||
#pragma pack(push,1)
|
||||
|
||||
typedef struct {
|
||||
char Sym[4];
|
||||
char Len;
|
||||
char Index;
|
||||
char More;
|
||||
} SymbolRec;
|
||||
|
||||
typedef struct {
|
||||
// input params
|
||||
const char *SS;
|
||||
hqCharType *CharTypeTable;
|
||||
SymbolRec **SymTable;
|
||||
int NoIntegers;
|
||||
int cssn; // Comment Start Symbol Number. -1 if none
|
||||
char *ComEnd; // End of comment
|
||||
// output params
|
||||
const char *Name;
|
||||
size_t NameLen;
|
||||
double ExtValue;
|
||||
int IntValue;
|
||||
hqTokenType PrevTokenType;
|
||||
hqCharType CharType;
|
||||
} hqLexer;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
/* Main "API" */
|
||||
|
||||
int Lexer_SetParseString( hqLexer *lexer, const char *str );
|
||||
hqTokenType Lexer_GetNextToken( hqLexer *lexer );
|
||||
const char* Lexer_GetCurrentPos( hqLexer *lexer );
|
||||
|
||||
/* Misc */
|
||||
|
||||
void UpcaseWin1251Str( char *Str );
|
||||
void InitCharTypeTable( hqCharType *CharTypeTable, int CharTypes );
|
||||
|
||||
void TypeTableAddChars( hqCharType *CharTypeTable, char *Symbols,
|
||||
hqCharType CharType );
|
||||
|
||||
void PrepareSymTable( SymbolRec **SymTable, char *symbols );
|
||||
|
||||
//int IsEngWin1251RusName( char *Str );
|
||||
|
||||
extern char const Win1251UpcaseTbl[];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __LEXER_HPP__ */
|
||||
679
Library/ccalc-0.5.1/mparser.c
Normal file
679
Library/ccalc-0.5.1/mparser.c
Normal file
@@ -0,0 +1,679 @@
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "mparser.h"
|
||||
|
||||
//#define MY_DEBUG 1
|
||||
|
||||
#ifndef M_E
|
||||
# define M_E 2.7182818284590452354
|
||||
#endif
|
||||
#ifndef M_PI
|
||||
# define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
const double DblErR = -1.68736462823243E308;
|
||||
const double DblNiN = -1.68376462823243E308;
|
||||
|
||||
#if (defined(__WIN32) || defined(__WIN32__)) && defined(RUSSIAN)
|
||||
|
||||
char eBrackets [] = "#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!";
|
||||
char eSyntax [] = "#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!";
|
||||
char eInternal [] = "#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!";
|
||||
char eExtraOp [] = "#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!";
|
||||
char eInfinity [] = "#<23><><EFBFBD>-<2D><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!";
|
||||
char eInvArg [] = "#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!";
|
||||
char eUnknFunc [] = "# %s - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>/<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!";
|
||||
char eExtrnFunc[] = "#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!";
|
||||
char eLogicErr [] = "#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!";
|
||||
char eCalcErr [] = "#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!";
|
||||
char eUnexpEnd [] = "#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!";
|
||||
char eExpVarRet[] = "#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> return!";
|
||||
char eExpAssign[] = "#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!";
|
||||
char eValSizErr[] = "#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!";
|
||||
char eInvPrmCnt[] = "#<23><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!"
|
||||
|
||||
#else
|
||||
|
||||
char eBrackets [] = "#Brackets not match!";
|
||||
char eSyntax [] = "#Syntax error!";
|
||||
char eInternal [] = "#Internal error!";
|
||||
char eExtraOp [] = "#Extra operation!";
|
||||
char eInfinity [] = "#Infinity somewhere!";
|
||||
char eInvArg [] = "#Invalid argument!";
|
||||
char eUnknFunc [] = "# %s - Unknown function/variable!";
|
||||
char eExtrnFunc[] = "#External function error!";
|
||||
char eLogicErr [] = "#Logical expression error!";
|
||||
char eCalcErr [] = "#Calculation error!";
|
||||
char eUnexpEnd [] = "#Unexpected end of script!";
|
||||
char eExpVarRet[] = "#Variable name or return expected!";
|
||||
char eExpAssign[] = "#Assignment expected!";
|
||||
char eValSizErr[] = "#Value too big for operation!";
|
||||
char eInvPrmCnt[] = "#Invalid parameters count for function call!";
|
||||
|
||||
#endif /* __WIN32__ */
|
||||
|
||||
static double _neg_(double);
|
||||
static double _frac_(double);
|
||||
static double _trunc_(double);
|
||||
static double _sgn_(double);
|
||||
static double _neg_(double);
|
||||
static double _floor_(double);
|
||||
static double _ceil_(double);
|
||||
static char* _round_( int paramcnt, double *args, hqStrMap *strparams, double *result );
|
||||
|
||||
const Operation BrOp = { OP_OBR };
|
||||
const Operation NegOp = { OP_FUNC_ONEARG, (void*)&_neg_, 0, NULL };
|
||||
|
||||
const char OpPriorities[OP_FUNC_MULTIARG+1] = {
|
||||
5, 5, 5, 2, 2, 2, 2, 2, -1, -1, 0,
|
||||
3, 3, 4, 4, 4, 4,
|
||||
5, 5, 5, 5, 2, 2, 2, 1, 2, 0, 2,
|
||||
-1, 6, 6 };
|
||||
|
||||
char MathSymbols[] =
|
||||
"\033\002" "<<" ">>" "**" "<>" ">=" "<=" "&&" "||" "/*" ":="
|
||||
"\033\001" "(+-*/%$^~&|=><?:),;";
|
||||
|
||||
char StdSymbols[] = "+-/*^~()<>%$,?:=&|;";
|
||||
|
||||
hqCharType MathCharTypeTable[256];
|
||||
int initializations_performed = 0;
|
||||
|
||||
char func_names[] =
|
||||
"ATAN\000COS\000SIN\000TAN\000ABS\000"
|
||||
"EXP\000LN\000LG\000SQRT\000FRAC\000"
|
||||
"TRUNC\000FLOOR\000CEIL\000ROUND\000ASIN\000"
|
||||
"ACOS\000SGN\000NEG\000E\000PI\000";
|
||||
|
||||
/* Indexes of some functions in func_names[] array */
|
||||
#define FUNC_ROUND 13
|
||||
#define FUNC_E 18
|
||||
#define FUNC_PI 19
|
||||
|
||||
static char* CalcToObr( hqMathParser *parser );
|
||||
static char* Calc( hqMathParser *parser );
|
||||
static char* MathParser_ParseScript( hqMathParser* parser, double *result );
|
||||
static char* MathParser_ParseFormula( hqMathParser* parser, double *result );
|
||||
|
||||
double (*func_addresses[]) () = {
|
||||
&atan, &cos, &sin, &tan, &fabs,
|
||||
&exp, &log, &log10, &sqrt, &_frac_,
|
||||
&_trunc_, &_floor_, _ceil_, (double(*)(double)) &_round_, &asin,
|
||||
&acos, &_sgn_, &_neg_, NULL, NULL };
|
||||
|
||||
hqStrMap *IntFunctions;
|
||||
|
||||
SymbolRec *MathSymTable[256];
|
||||
|
||||
char errbuf[256];
|
||||
|
||||
// hqMathParser implementation
|
||||
|
||||
hqMathParser* MathParser_Create( char *MoreLetters )
|
||||
{
|
||||
hqMathParser *parser = calloc( 1, sizeof(hqMathParser) );
|
||||
if (!initializations_performed) {
|
||||
// init character tables
|
||||
InitCharTypeTable( MathCharTypeTable,
|
||||
CH_LETTER | CH_DIGIT | CH_SEPARAT | CH_QUOTE );
|
||||
TypeTableAddChars( MathCharTypeTable, StdSymbols, CH_SYMBOL );
|
||||
if (MoreLetters)
|
||||
TypeTableAddChars( MathCharTypeTable, MoreLetters, CH_LETTER );
|
||||
// init function maps
|
||||
PrepareSymTable( MathSymTable, MathSymbols );
|
||||
IntFunctions = Strmap_CreateFromChain( sizeof(void*),
|
||||
(char*)func_names,
|
||||
func_addresses );
|
||||
initializations_performed = 1;
|
||||
}
|
||||
parser->Lexer.NoIntegers = 1;
|
||||
parser->Lexer.SymTable = MathSymTable;
|
||||
parser->Lexer.CharTypeTable = MathCharTypeTable;
|
||||
parser->Lexer.cssn = 8;
|
||||
parser->Lexer.ComEnd = "*/";
|
||||
return parser;
|
||||
}
|
||||
|
||||
void MathParser_Destroy( hqMathParser* parser )
|
||||
{
|
||||
free( parser );
|
||||
}
|
||||
|
||||
static char* PrepareFormula( hqMathParser* parser )
|
||||
{
|
||||
int BrCnt = 0;
|
||||
const char *SS = parser->Lexer.SS;
|
||||
|
||||
// Brackets Matching
|
||||
while ( (!parser->script && *SS) || (parser->script && *SS != ';') ) {
|
||||
if (*SS=='(')
|
||||
++BrCnt;
|
||||
else if (*SS==')' && --BrCnt<0)
|
||||
goto brkerr;
|
||||
++SS;
|
||||
}
|
||||
if (BrCnt != 0)
|
||||
brkerr: return eBrackets;
|
||||
|
||||
parser->OpTop = 0;
|
||||
parser->ValTop = -1;
|
||||
parser->OpStack[0].OperType = OP_OBR;
|
||||
parser->ObrDist = 2;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* MathParser_Parse( hqMathParser* parser, const char *Formula, double *result )
|
||||
{
|
||||
if (!Formula || !*Formula) {
|
||||
*result = 0.0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
parser->script = *Formula == '#' && *(Formula+1) == '!'
|
||||
&& MathCharTypeTable[ (uchar)*(Formula+2) ] == CH_SEPARAT;
|
||||
|
||||
if ( parser->script )
|
||||
Formula += 3;
|
||||
|
||||
Lexer_SetParseString( &parser->Lexer, Formula );
|
||||
|
||||
return ( parser->script )
|
||||
?
|
||||
MathParser_ParseScript( parser, result )
|
||||
:
|
||||
MathParser_ParseFormula( parser, result );
|
||||
}
|
||||
|
||||
static char* MathParser_ParseFormula( hqMathParser* parser, double *result )
|
||||
{
|
||||
char *ErrorMsg;
|
||||
hqTokenType ToTi;
|
||||
|
||||
if ( (ErrorMsg = PrepareFormula( parser )) != NULL )
|
||||
return ErrorMsg;
|
||||
|
||||
ToTi = Lexer_GetNextToken( &parser->Lexer );
|
||||
for (;;) {
|
||||
--parser->ObrDist;
|
||||
switch (ToTi) {
|
||||
case TOK_ERROR:
|
||||
return eSyntax;
|
||||
case TOK_FINAL:
|
||||
formulaend: if ( (ErrorMsg = CalcToObr( parser )) != NULL )
|
||||
return ErrorMsg;
|
||||
goto getout;
|
||||
case TOK_FLOAT:
|
||||
parser->ValStack[++parser->ValTop] = parser->Lexer.ExtValue;
|
||||
break;
|
||||
case TOK_SYMBOL:
|
||||
switch ( parser->Lexer.IntValue ) {
|
||||
case OP_OBR: // (
|
||||
parser->OpStack[++parser->OpTop] = BrOp;
|
||||
parser->ObrDist = 2;
|
||||
break;
|
||||
case OP_CBR: // )
|
||||
if ( (ErrorMsg = CalcToObr( parser )) != NULL )
|
||||
return ErrorMsg;
|
||||
break;
|
||||
case OP_COMMA: { // ,
|
||||
Operation *pOp;
|
||||
if ( (ErrorMsg = CalcToObr( parser )) != NULL )
|
||||
return ErrorMsg;
|
||||
if ( (pOp = &parser->OpStack[parser->OpTop])->OperType
|
||||
== OP_FUNC_MULTIARG ) {
|
||||
parser->OpStack[++parser->OpTop] = BrOp;
|
||||
parser->ObrDist = 2;
|
||||
} else
|
||||
return eSyntax;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
Operation Op;
|
||||
Op.OperType = (OperType_t) parser->Lexer.IntValue;
|
||||
switch (Op.OperType) {
|
||||
case OP_FORMULAEND:
|
||||
if (parser->script)
|
||||
goto formulaend;
|
||||
else
|
||||
return eSyntax;
|
||||
case OP_ADD:
|
||||
if (parser->ObrDist >= 1)
|
||||
goto next_tok;
|
||||
break;
|
||||
case OP_SUB:
|
||||
if (parser->ObrDist >= 1) {
|
||||
parser->OpStack[++parser->OpTop] = NegOp;
|
||||
goto next_tok;
|
||||
}
|
||||
break;
|
||||
case OP_LOGIC:
|
||||
case OP_LOGIC_SEP:
|
||||
parser->ObrDist = 2;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
while ( OpPriorities[ Op.OperType ]
|
||||
<=
|
||||
OpPriorities[ parser->OpStack[parser->OpTop].OperType ] ) {
|
||||
if ( (ErrorMsg = Calc( parser )) != NULL )
|
||||
return ErrorMsg;
|
||||
}
|
||||
parser->OpStack[++parser->OpTop] = Op;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TOK_NAME: {
|
||||
Operation Op;
|
||||
double *value, dblval;
|
||||
void **func;
|
||||
int funcnum, /*i,*/ namelen = parser->Lexer.NameLen;
|
||||
|
||||
// const char *SS = parser->Lexer.Name;
|
||||
// for (i = namelen; i>0; --i)
|
||||
// *SS++ = Win1251UpcaseTbl[ (int) (uchar) *SS ];
|
||||
|
||||
funcnum = StrMap_LenIndexOf( IntFunctions,
|
||||
parser->Lexer.Name,
|
||||
parser->Lexer.NameLen,
|
||||
(void**) &func );
|
||||
if ( funcnum >= 0 ) {
|
||||
Op.Func = *func;
|
||||
switch ( funcnum ) {
|
||||
case FUNC_E:
|
||||
parser->ValStack[++parser->ValTop] = M_E;
|
||||
break;
|
||||
case FUNC_PI:
|
||||
parser->ValStack[++parser->ValTop] = M_PI;
|
||||
break;
|
||||
case FUNC_ROUND:
|
||||
Op.OperType = OP_FUNC_MULTIARG;
|
||||
Op.PrevValTop = parser->ValTop;
|
||||
Op.StrParams = NULL;
|
||||
parser->OpStack[++parser->OpTop] = Op;
|
||||
break;
|
||||
default:// Internal function
|
||||
Op.OperType = OP_FUNC_ONEARG;
|
||||
parser->OpStack[++parser->OpTop] = Op;
|
||||
}
|
||||
} else if (parser->Parameters
|
||||
&&
|
||||
StrMap_LenIndexOf( parser->Parameters,
|
||||
parser->Lexer.Name,
|
||||
parser->Lexer.NameLen,
|
||||
(void**) &value ) >= 0
|
||||
) {
|
||||
if (*value==DblErR) {
|
||||
return eInternal;
|
||||
} else
|
||||
parser->ValStack[++parser->ValTop] = *value;
|
||||
} else if (parser->ExtFunctions
|
||||
&&
|
||||
StrMap_LenIndexOf( parser->ExtFunctions,
|
||||
parser->Lexer.Name,
|
||||
parser->Lexer.NameLen,
|
||||
(void**) &func ) >= 0
|
||||
) {
|
||||
Op.Func = *func;
|
||||
Op.OperType = OP_FUNC_MULTIARG;
|
||||
Op.PrevValTop = parser->ValTop;
|
||||
Op.StrParams = NULL;
|
||||
parser->OpStack[++parser->OpTop] = Op;
|
||||
} else if (parser->VarParams
|
||||
&&
|
||||
StrMap_LenIndexOf( parser->VarParams,
|
||||
parser->Lexer.Name,
|
||||
parser->Lexer.NameLen,
|
||||
(void**) &value ) >= 0
|
||||
) {
|
||||
if (*value==DblErR) {
|
||||
return eInternal;
|
||||
} else
|
||||
parser->ValStack[++parser->ValTop] = *value;
|
||||
} else if (parser->MoreParams
|
||||
&&
|
||||
(*parser->MoreParams)( parser->Lexer.Name,
|
||||
parser->Lexer.NameLen,
|
||||
&dblval,
|
||||
parser->ParamFuncParam )
|
||||
) {
|
||||
parser->ValStack[++parser->ValTop] = dblval;
|
||||
} else {
|
||||
char buf[256];
|
||||
strncpy( buf, parser->Lexer.Name, parser->Lexer.NameLen );
|
||||
buf[ parser->Lexer.NameLen ] = '\0';
|
||||
sprintf( errbuf, eUnknFunc, buf );
|
||||
return errbuf;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TOK_STRING: {
|
||||
Operation *pOp;
|
||||
if (parser->OpTop < 1)
|
||||
return eSyntax;
|
||||
if ( (pOp = &parser->OpStack[parser->OpTop-1])->OperType
|
||||
== OP_FUNC_MULTIARG ) {
|
||||
if (!pOp->StrParams)
|
||||
pOp->StrParams = Strmap_Create( 0, 0 );
|
||||
StrMap_AddStrLen( pOp->StrParams,
|
||||
parser->Lexer.Name,
|
||||
parser->Lexer.NameLen, NULL );
|
||||
parser->ValStack[++parser->ValTop] = DblNiN;
|
||||
} else
|
||||
return eSyntax;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return eSyntax;
|
||||
}
|
||||
next_tok:
|
||||
ToTi = Lexer_GetNextToken( &parser->Lexer );
|
||||
} // forever
|
||||
|
||||
getout:
|
||||
if (parser->OpTop != -1 || parser->ValTop != 0)
|
||||
return eInternal;
|
||||
|
||||
*result = parser->ValStack[0];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char* MathParser_ParseScript( hqMathParser* parser, double *result )
|
||||
{
|
||||
char *ErrorMsg = NULL;
|
||||
hqTokenType ToTi;
|
||||
int expectvar = 1, was_return = 0;
|
||||
const char *varname = NULL;
|
||||
int varnamelen = 0;
|
||||
|
||||
parser->VarParams = Strmap_Create( sizeof(double), 0 );
|
||||
|
||||
ToTi = Lexer_GetNextToken( &parser->Lexer );
|
||||
for (;;) {
|
||||
switch (ToTi) {
|
||||
case TOK_FINAL:
|
||||
ErrorMsg = eUnexpEnd;
|
||||
goto getout;
|
||||
case TOK_NAME: {
|
||||
if (!expectvar) {
|
||||
ErrorMsg = eExpVarRet;
|
||||
goto getout;
|
||||
} else {
|
||||
// int i;
|
||||
// const char *SS = parser->Lexer.Name;
|
||||
|
||||
varnamelen = parser->Lexer.NameLen;
|
||||
|
||||
// for (i = varnamelen; i>0; --i)
|
||||
// *SS++ = Win1251UpcaseTbl[ (int) (uchar) *SS ];
|
||||
}
|
||||
varname = parser->Lexer.Name;
|
||||
|
||||
was_return = strncmp( varname, "RETURN", varnamelen ) == 0;
|
||||
if ( was_return ) {
|
||||
ErrorMsg = MathParser_ParseFormula( parser, result );
|
||||
goto getout;
|
||||
}
|
||||
expectvar = 0;
|
||||
break;
|
||||
}
|
||||
case TOK_SYMBOL: {
|
||||
double *value;
|
||||
|
||||
if ( parser->Lexer.IntValue != OP_ASSIGN || expectvar ) {
|
||||
ErrorMsg = eExpAssign;
|
||||
goto getout;
|
||||
}
|
||||
ErrorMsg = MathParser_ParseFormula( parser, result );
|
||||
if (ErrorMsg)
|
||||
goto getout;
|
||||
|
||||
if ( StrMap_LenIndexOf( parser->VarParams,
|
||||
varname, varnamelen,
|
||||
(void**) &value ) >= 0 )
|
||||
*value = *result;
|
||||
else
|
||||
StrMap_AddStrLen( parser->VarParams, varname, varnamelen,
|
||||
result );
|
||||
expectvar = 1;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
ErrorMsg = eSyntax;
|
||||
goto getout;
|
||||
}
|
||||
ToTi = Lexer_GetNextToken( &parser->Lexer );
|
||||
} // forever
|
||||
|
||||
getout:
|
||||
StrMap_Destroy( parser->VarParams );
|
||||
parser->VarParams = NULL;
|
||||
return ErrorMsg;
|
||||
}
|
||||
|
||||
static char* Calc( hqMathParser *parser )
|
||||
{
|
||||
double Res, ValR;
|
||||
Operation Op = parser->OpStack[parser->OpTop--];
|
||||
|
||||
// multi-argument external or internal fucntion
|
||||
if ( Op.OperType == OP_FUNC_MULTIARG ) {
|
||||
int paramcnt = parser->ValTop - Op.PrevValTop;
|
||||
char *ErrorMsg;
|
||||
#ifdef MY_DEBUG
|
||||
printf( "ValTop = %d, OpTop = %d, PrevValTop = %d\n",
|
||||
parser->ValTop, parser->OpTop, Op.PrevValTop );
|
||||
#endif
|
||||
parser->ValTop = Op.PrevValTop;
|
||||
ErrorMsg = (*(MultiArgFunc)Op.Func)( paramcnt,
|
||||
&parser->ValStack[parser->ValTop+1],
|
||||
Op.StrParams, &Res );
|
||||
if (ErrorMsg)
|
||||
return ErrorMsg;
|
||||
if (Op.StrParams)
|
||||
StrMap_Destroy( Op.StrParams );
|
||||
parser->ValStack[++parser->ValTop] = Res;
|
||||
#ifdef MY_DEBUG
|
||||
printf("ValTop = %d, OpTop = %d\n", parser->ValTop, parser->OpTop );
|
||||
#endif
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (Op.OperType==OP_LOGIC)
|
||||
return NULL;
|
||||
|
||||
// get right arg
|
||||
if (parser->ValTop<0)
|
||||
return eExtraOp;
|
||||
ValR = parser->ValStack[parser->ValTop--];
|
||||
|
||||
// one arg operations
|
||||
if (Op.OperType==OP_NOT) {
|
||||
if (ValR >= INT_MIN && ValR <= INT_MAX)
|
||||
Res = ~((int) ValR);
|
||||
else
|
||||
return eValSizErr;
|
||||
} else if (Op.OperType==OP_FUNC_ONEARG) {
|
||||
Res = (*(OneArgFunc)Op.Func)( ValR );
|
||||
} else {
|
||||
// get left arg
|
||||
double ValL;
|
||||
if (parser->ValTop<0)
|
||||
return eExtraOp;
|
||||
ValL = parser->ValStack[parser->ValTop--];
|
||||
switch (Op.OperType) {
|
||||
// Binary
|
||||
case OP_SHL:
|
||||
if (ValL >= INT_MIN && ValL <= INT_MAX && ValR >= INT_MIN && ValR <= INT_MAX)
|
||||
Res = (int) ValL << (int) ValR;
|
||||
else
|
||||
return eValSizErr;
|
||||
break;
|
||||
case OP_SHR:
|
||||
if (ValL >= INT_MIN && ValL <= INT_MAX && ValR >= INT_MIN && ValR <= INT_MAX)
|
||||
Res = (int) ValL >> (int) ValR;
|
||||
else
|
||||
return eValSizErr;
|
||||
break;
|
||||
case OP_POW:
|
||||
Res = pow( ValL, ValR ); break;
|
||||
// Logical
|
||||
case OP_LOGIC_NEQ:
|
||||
Res = ValL != ValR; break;
|
||||
case OP_LOGIC_GEQ:
|
||||
Res = ValL >= ValR; break;
|
||||
case OP_LOGIC_LEQ:
|
||||
Res = ValL <= ValR; break;
|
||||
case OP_LOGIC_AND:
|
||||
Res = ValL && ValR; break;
|
||||
case OP_LOGIC_OR:
|
||||
Res = ValL || ValR; break;
|
||||
// Arithmetic
|
||||
case OP_ADD:
|
||||
Res = ValL + ValR; break;
|
||||
case OP_SUB:
|
||||
Res = ValL - ValR; break;
|
||||
case OP_MUL:
|
||||
Res = ValL * ValR; break;
|
||||
case OP_DIV:
|
||||
if (ValR == 0.0)
|
||||
return eInfinity;
|
||||
Res = ValL / ValR;
|
||||
break;
|
||||
case OP_MOD:
|
||||
Res = fmod(ValL, ValR); break;
|
||||
case OP_UNK:
|
||||
if (ValL<=0)
|
||||
Res = 0.0;
|
||||
else if (ValR==0.0)
|
||||
return eInfinity;
|
||||
else
|
||||
Res = ceil(ValL / ValR);
|
||||
break;
|
||||
// Bitwise
|
||||
case OP_XOR:
|
||||
if (ValL >= INT_MIN && ValL <= INT_MAX && ValR >= INT_MIN && ValR <= INT_MAX)
|
||||
Res = (int) ValL ^ (int) ValR;
|
||||
else
|
||||
return eValSizErr;
|
||||
break;
|
||||
case OP_AND:
|
||||
if (ValL >= INT_MIN && ValL <= INT_MAX && ValR >= INT_MIN && ValR <= INT_MAX)
|
||||
Res = (int) ValL & (int) ValR;
|
||||
else
|
||||
return eValSizErr;
|
||||
break;
|
||||
case OP_OR:
|
||||
if (ValL >= INT_MIN && ValL <= INT_MAX && ValR >= INT_MIN && ValR <= INT_MAX)
|
||||
Res = (int) ValL | (int) ValR;
|
||||
else
|
||||
return eValSizErr;
|
||||
break;
|
||||
// Logical
|
||||
case OP_EQU:
|
||||
Res = ValL == ValR; break;
|
||||
case OP_GREATER:
|
||||
Res = ValL > ValR; break;
|
||||
case OP_LESS:
|
||||
Res = ValL < ValR; break;
|
||||
case OP_LOGIC_SEP: {
|
||||
// needs three arguments
|
||||
double ValLL;
|
||||
if (parser->OpTop < 0
|
||||
|| parser->OpStack[parser->OpTop--].OperType != OP_LOGIC)
|
||||
return eLogicErr;
|
||||
ValLL = parser->ValStack[ parser->ValTop-- ];
|
||||
Res = ValLL ? ValL : ValR;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return eInternal;
|
||||
}
|
||||
}
|
||||
parser->ValStack[++parser->ValTop] = Res;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static char* CalcToObr( hqMathParser *parser )
|
||||
{
|
||||
while ( parser->OpStack[parser->OpTop].OperType != OP_OBR ) {
|
||||
char *ErrorMsg;
|
||||
if ( (ErrorMsg = Calc( parser )) != NULL )
|
||||
return ErrorMsg;
|
||||
}
|
||||
--parser->OpTop;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* misc functions */
|
||||
|
||||
static double _frac_( double x )
|
||||
{
|
||||
double y;
|
||||
return modf(x, &y);
|
||||
}
|
||||
|
||||
static double _trunc_( double x )
|
||||
{
|
||||
return (x >= 0.0) ? floor(x) : ceil(x);
|
||||
}
|
||||
|
||||
static double _sgn_( double x )
|
||||
{
|
||||
return (x > 0) ? 1 : (x < 0) ? -1 : 0;
|
||||
}
|
||||
|
||||
static double _neg_( double x )
|
||||
{
|
||||
return -x;
|
||||
}
|
||||
|
||||
static double _floor_( double x )
|
||||
{
|
||||
return floor(x);
|
||||
}
|
||||
|
||||
static double _ceil_( double x )
|
||||
{
|
||||
return ceil(x);
|
||||
}
|
||||
|
||||
/* "Advanced" round function; second argument - sharpness */
|
||||
static char* _round_( int paramcnt, double *args, hqStrMap *strparams, double *result )
|
||||
{
|
||||
int i, sharpness;
|
||||
double x, coef;
|
||||
|
||||
if (paramcnt == 1)
|
||||
sharpness = 0;
|
||||
else if (paramcnt == 2)
|
||||
sharpness = (int) args[1];
|
||||
else
|
||||
return eInvPrmCnt;
|
||||
|
||||
x = args[0];
|
||||
if (sharpness < 0) {
|
||||
coef = 0.1;
|
||||
sharpness = -sharpness;
|
||||
} else
|
||||
coef = 10;
|
||||
|
||||
for (i = 0; i < sharpness; i++)
|
||||
x *= coef;
|
||||
|
||||
x = (x + ( (x >= 0) ? 0.5 : -0.5 ) );
|
||||
if (x >= 0.0)
|
||||
x = floor(x);
|
||||
else
|
||||
x = ceil(x);
|
||||
|
||||
for (i = 0; i < sharpness; i++)
|
||||
x /= coef;
|
||||
|
||||
*result = x;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
80
Library/ccalc-0.5.1/mparser.h
Normal file
80
Library/ccalc-0.5.1/mparser.h
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
Math parser for CCalc library.
|
||||
*/
|
||||
#include "strmap.h"
|
||||
#include "lexer.h"
|
||||
#include "pack.h"
|
||||
|
||||
//#define RUSSIAN 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define MAX_STACK_SIZE 32
|
||||
|
||||
extern const double DblErR;
|
||||
extern const double DblNiN;
|
||||
|
||||
typedef enum {
|
||||
// Binary
|
||||
OP_SHL, OP_SHR, OP_POW,
|
||||
OP_LOGIC_NEQ, OP_LOGIC_GEQ, OP_LOGIC_LEQ,
|
||||
OP_LOGIC_AND, OP_LOGIC_OR, // Logical
|
||||
OP_COMSTART, OP_ASSIGN, // For internal needs
|
||||
OP_OBR, // Special
|
||||
OP_ADD, OP_SUB, OP_MUL, OP_DIV, OP_MOD, OP_UNK, // Arithmetic
|
||||
OP_XOR, OP_NOT, OP_AND, OP_OR, // Bitwise
|
||||
OP_EQU, OP_GREATER, OP_LESS,
|
||||
OP_LOGIC, OP_LOGIC_SEP, OP_CBR, OP_COMMA, // Logical
|
||||
OP_FORMULAEND, // For script
|
||||
OP_FUNC_ONEARG, OP_FUNC_MULTIARG // Special
|
||||
} OperType_t;
|
||||
|
||||
typedef struct {
|
||||
char *str;
|
||||
double value;
|
||||
} Parameter;
|
||||
|
||||
typedef double (*OneArgFunc) ( double arg );
|
||||
typedef char* (*MultiArgFunc) ( int paramcnt, double *args,
|
||||
hqStrMap *strparams, double *result );
|
||||
typedef int (*PrmSrchFunc) ( const char *str, int len, double *value,
|
||||
void *param );
|
||||
|
||||
#pragma pack(push,1)
|
||||
|
||||
typedef struct {
|
||||
OperType_t OperType;
|
||||
void *Func;
|
||||
char PrevValTop;
|
||||
hqStrMap *StrParams;
|
||||
} Operation;
|
||||
|
||||
typedef struct {
|
||||
/* public */
|
||||
hqStrMap *Parameters; // List of numeric veriables
|
||||
hqStrMap *ExtFunctions; // List of multi-argument external functions
|
||||
PrmSrchFunc MoreParams; // Function for calculating unhandled parameters
|
||||
void *ParamFuncParam; // Parameter given to this function
|
||||
/* private */
|
||||
Operation OpStack[MAX_STACK_SIZE];
|
||||
double ValStack[MAX_STACK_SIZE];
|
||||
int OpTop, ValTop;
|
||||
int ObrDist;
|
||||
hqLexer Lexer;
|
||||
int script;
|
||||
hqStrMap *VarParams;
|
||||
} hqMathParser;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
/* API */
|
||||
|
||||
hqMathParser* MathParser_Create( char *MoreLetters );
|
||||
void MathParser_Destroy( hqMathParser* parser );
|
||||
char* MathParser_Parse( hqMathParser* parser, const char *Formula, double *result );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
23
Library/ccalc-0.5.1/pack.h
Normal file
23
Library/ccalc-0.5.1/pack.h
Normal file
@@ -0,0 +1,23 @@
|
||||
/* Definitions for packing structures */
|
||||
#ifndef __PACK_H__
|
||||
#define __PACK_H__
|
||||
|
||||
#if defined(__BORLANDC__) && (__BORLANDC <= 0x520)
|
||||
# define PACK_START #pragma option -a1
|
||||
#elif (defined(__GNUC__) && (__GNUC__ <= 2) && (__GNUC_MINOR__ < 95)) \
|
||||
|| (defined(__WATCOMC__) && (__WATCOMC__ < 1100))
|
||||
# define PACK_START #pragma pack(1)
|
||||
#else
|
||||
# define PACK_START #pragma pack(push,1)
|
||||
#endif
|
||||
|
||||
#if defined(__BORLANDC__) && (__BORLANDC <= 0x520)
|
||||
# define PACK_STOP #pragma option -a.
|
||||
#elif (defined(__GNUC__) && (__GNUC__ <= 2) && (__GNUC_MINOR__ < 95)) \
|
||||
|| (defined(__WATCOMC__) && (__WATCOMC__ < 1100))
|
||||
# define PACK_STOP #pragma pack()
|
||||
#else
|
||||
# define PACK_STOP #pragma pack(pop)
|
||||
#endif
|
||||
|
||||
#endif /* __PACK_H__ */
|
||||
129
Library/ccalc-0.5.1/strmap.c
Normal file
129
Library/ccalc-0.5.1/strmap.c
Normal file
@@ -0,0 +1,129 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "strmap.h"
|
||||
|
||||
hqStrMap* create_instance( int extrabytes, int dup )
|
||||
{
|
||||
hqStrMap* strmap = calloc( 1, sizeof(hqStrMap) );
|
||||
strmap->FDoDuplicate = dup;
|
||||
strmap->FExtraLen = extrabytes;
|
||||
strmap->FRecordLen = sizeof(char*) + sizeof(int) + extrabytes;
|
||||
strmap->FList = NULL;
|
||||
return strmap;
|
||||
}
|
||||
|
||||
hqStrMap* Strmap_Create( int extrabytes, int dup )
|
||||
{
|
||||
return create_instance( extrabytes, dup );
|
||||
}
|
||||
|
||||
void Strmap_FillFromChain( hqStrMap* strmap, char *strchain, void *data )
|
||||
{
|
||||
while ( *strchain ) {
|
||||
size_t len = strlen( strchain );
|
||||
StrMap_AddStrLen( strmap, strchain, len, data );
|
||||
strchain += len+1;
|
||||
data = (char*)data + strmap->FExtraLen;
|
||||
}
|
||||
}
|
||||
|
||||
hqStrMap* Strmap_CreateFromChain( int extrabytes, char *strchain, void *data )
|
||||
{
|
||||
hqStrMap* strmap = create_instance( extrabytes, 0 );
|
||||
Strmap_FillFromChain( strmap, strchain, data );
|
||||
StrMap_ShrinkMem( strmap );
|
||||
return strmap;
|
||||
}
|
||||
|
||||
void StrMap_Destroy( hqStrMap* strmap )
|
||||
{
|
||||
if ( strmap->FDoDuplicate )
|
||||
StrMap_TrimClear( strmap, 0 );
|
||||
if ( strmap->FList )
|
||||
free( strmap->FList );
|
||||
|
||||
free(strmap);
|
||||
}
|
||||
|
||||
void StrMap_AddString( hqStrMap* strmap, const char *str, void *data )
|
||||
{
|
||||
StrMap_AddStrLen( strmap, str, strlen(str), data );
|
||||
}
|
||||
|
||||
void StrMap_AddStrLen( hqStrMap* strmap, const char *str, size_t len, void *data )
|
||||
{
|
||||
const char *Rec;
|
||||
if ( strmap->FCount >= strmap->FCapacity ) {
|
||||
int delta = (strmap->FCapacity > 64) ? strmap->FCapacity / 4 : 16;
|
||||
StrMap_SetCapacity( strmap, strmap->FCapacity + delta );
|
||||
}
|
||||
Rec = strmap->FList + strmap->FCount * strmap->FRecordLen;
|
||||
*(const char**)Rec = str;
|
||||
*(int*)(Rec + sizeof(char*)) = len;
|
||||
if (data) {
|
||||
void *recdata = (void*)(Rec + sizeof(char*) + sizeof(int));
|
||||
memcpy( recdata, data, strmap->FExtraLen );
|
||||
}
|
||||
++ strmap->FCount;
|
||||
}
|
||||
|
||||
void StrMap_ShrinkMem( hqStrMap* strmap )
|
||||
{
|
||||
StrMap_SetCapacity( strmap, strmap->FCount );
|
||||
}
|
||||
|
||||
void StrMap_Trim( hqStrMap* strmap, int NewCount )
|
||||
{
|
||||
strmap->FCount = NewCount;
|
||||
}
|
||||
|
||||
void StrMap_TrimClear( hqStrMap* strmap, int NewCount )
|
||||
{
|
||||
int i;
|
||||
char *Rec = strmap->FList + NewCount * strmap->FRecordLen;
|
||||
for (i=NewCount; i < strmap->FCount; i++) {
|
||||
free( *(char**)Rec );
|
||||
Rec += strmap->FRecordLen;
|
||||
}
|
||||
strmap->FCount = NewCount;
|
||||
}
|
||||
|
||||
void StrMap_SetCapacity( hqStrMap* strmap, int NewCapacity )
|
||||
{
|
||||
strmap->FCapacity = NewCapacity;
|
||||
if ( strmap->FCount > strmap->FCapacity )
|
||||
strmap->FCount = strmap->FCapacity;
|
||||
strmap->FList = (char*) realloc( strmap->FList,
|
||||
strmap->FCapacity * strmap->FRecordLen );
|
||||
}
|
||||
|
||||
int StrMap_IndexOf( hqStrMap* strmap, const char *str, void **data )
|
||||
{
|
||||
return StrMap_LenIndexOf( strmap, str, strlen(str), data );
|
||||
}
|
||||
|
||||
int StrMap_LenIndexOf( hqStrMap* strmap, const char *str, size_t len, void **data )
|
||||
{
|
||||
int i;
|
||||
char *Rec = strmap->FList;
|
||||
for (i=0; i<strmap->FCount; i++) {
|
||||
int recLen = *(int*)(Rec + sizeof(char*));
|
||||
if (recLen==len && strncmp( str, *(char**)Rec, recLen )==0 ) {
|
||||
*data = (Rec + sizeof(char*) + sizeof(int));
|
||||
return i;
|
||||
}
|
||||
Rec += strmap->FRecordLen;
|
||||
}
|
||||
*data = NULL;
|
||||
return -1;
|
||||
}
|
||||
|
||||
char* StrMap_GetString( hqStrMap* strmap, int index, int *len, void **data )
|
||||
{
|
||||
char *Rec = strmap->FList + index * strmap->FRecordLen;
|
||||
*len = *(int*)(Rec + sizeof(char*));
|
||||
if (data!=NULL && strmap->FExtraLen>0)
|
||||
*data = (Rec + sizeof(char*) + sizeof(int));
|
||||
return *(char**)Rec;
|
||||
}
|
||||
|
||||
37
Library/ccalc-0.5.1/strmap.h
Normal file
37
Library/ccalc-0.5.1/strmap.h
Normal file
@@ -0,0 +1,37 @@
|
||||
#include "pack.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#pragma pack(push,1)
|
||||
|
||||
typedef struct {
|
||||
int FCount, FCapacity;
|
||||
int FExtraLen, FRecordLen;
|
||||
int FDoDuplicate;
|
||||
char *FList;
|
||||
} hqStrMap;
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
/* API */
|
||||
|
||||
hqStrMap* Strmap_Create( int extrabytes, int dup );
|
||||
hqStrMap* Strmap_CreateFromChain( int extrabytes, char *strchain, void *data );
|
||||
void StrMap_Destroy( hqStrMap* strmap );
|
||||
|
||||
void StrMap_AddString( hqStrMap* strmap, const char *str, void *data );
|
||||
void StrMap_AddStrLen( hqStrMap* strmap, const char *str, size_t len, void *data );
|
||||
void StrMap_ShrinkMem( hqStrMap* strmap );
|
||||
void StrMap_Trim( hqStrMap* strmap, int NewCount );
|
||||
void StrMap_TrimClear( hqStrMap* strmap, int NewCount );
|
||||
void StrMap_SetCapacity( hqStrMap* strmap, int NewCapacity );
|
||||
int StrMap_IndexOf( hqStrMap* strmap, const char *str, void **data );
|
||||
int StrMap_LenIndexOf( hqStrMap* strmap, const char *str, size_t len, void **data );
|
||||
char* StrMap_GetString( hqStrMap* strmap, int index, int *len, void **data );
|
||||
void Strmap_FillFromChain( hqStrMap* strmap, char *strchain, void *data );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
6
Library/ccalc-0.5.1/wininit.c
Normal file
6
Library/ccalc-0.5.1/wininit.c
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <windows.h>
|
||||
|
||||
extern int WINAPI dll_entry (HANDLE h, DWORD reason, void *ptr)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
63
Library/resource.h
Normal file
63
Library/resource.h
Normal file
@@ -0,0 +1,63 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by Library.rc
|
||||
//
|
||||
#define IDR_CONTEXT_MENU 101
|
||||
#define IDD_ABOUT_DIALOG 102
|
||||
#define IDR_SKIN_MENU 102
|
||||
#define IDI_TRAY 108
|
||||
#define IDC_STATISTICS 1000
|
||||
#define IDC_BUILD_STRING 1001
|
||||
#define IDC_VERSION_STRING 1002
|
||||
#define IDC_STATISTICS_STRING 1003
|
||||
#define IDC_STATIC_ABOUT 1004
|
||||
#define IDC_URL_STRING 1005
|
||||
#define IDC_CONFIG_TAB 1006
|
||||
#define IDC_AUTHOR_STRING 1007
|
||||
#define IDC_CHECK_FOR_UPDATE 1009
|
||||
#define ID_CONTEXT_REFRESH 4001
|
||||
#define ID_CONTEXT_QUIT 4002
|
||||
#define ID_CONTEXT_ABOUT 4004
|
||||
#define ID_CONTEXT_CONFIGS_DEFAULT 4006
|
||||
#define ID_CONTEXT_EDITCONFIG 4008
|
||||
#define ID_CONTEXT_CLOSESKIN 4009
|
||||
#define ID_CONTEXT_SKINMENU_TOPMOST 4010
|
||||
#define ID_CONTEXT_SKINMENU_NORMAL 4011
|
||||
#define ID_CONTEXT_SKINMENU_BOTTOM 4012
|
||||
#define ID_CONTEXT_SKINMENU_TRANSPARENCY_0 4014
|
||||
#define ID_CONTEXT_SKINMENU_TRANSPARENCY_10 4015
|
||||
#define ID_CONTEXT_SKINMENU_TRANSPARENCY_20 4016
|
||||
#define ID_CONTEXT_SKINMENU_TRANSPARENCY_30 4017
|
||||
#define ID_CONTEXT_SKINMENU_TRANSPARENCY_40 4018
|
||||
#define ID_CONTEXT_SKINMENU_TRANSPARENCY_50 4019
|
||||
#define ID_CONTEXT_SKINMENU_TRANSPARENCY_60 4020
|
||||
#define ID_CONTEXT_SKINMENU_TRANSPARENCY_70 4021
|
||||
#define ID_CONTEXT_SKINMENU_TRANSPARENCY_80 4022
|
||||
#define ID_CONTEXT_SKINMENU_TRANSPARENCY_90 4023
|
||||
#define ID_CONTEXT_SKINMENU_REFRESH 4024
|
||||
#define ID_CONTEXT_SKINMENU_HIDEONMOUSE 4025
|
||||
#define ID_CONTEXT_SKINMENU_DRAGGABLE 4026
|
||||
#define ID_CONTEXT_SKINMENU_REMEMBERPOSITION 4027
|
||||
#define ID_CONTEXT_SKINMENU_SNAPTOEDGES 4028
|
||||
#define ID_CONTEXT_SKINMENU_CLICKTHROUGH 4029
|
||||
#define ID_CONTEXT_SKINMENU_EDITSKIN 4030
|
||||
#define ID_CONTEXT_SKINMENU_VERYTOPMOST 4031
|
||||
#define ID_CONTEXT_SKINMENU_ONDESKTOP 4032
|
||||
#define ID_CONTEXT_SHOW_HELP 4034
|
||||
#define ID_CONTEXT_SHOWLOGFILE 4035
|
||||
#define ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEIN 4037
|
||||
#define ID_CONTEXT_SKINMENU_TRANSPARENCY_FADEOUT 4038
|
||||
#define ID_CONTEXT_SKINMENU_KEEPONSCREEN 4039
|
||||
#define ID_CONFIG_EDIT 30000
|
||||
#define ID_CONFIG_FIRST 30001
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 109
|
||||
#define _APS_NEXT_COMMAND_VALUE 4040
|
||||
#define _APS_NEXT_CONTROL_VALUE 1010
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
362
Plugins/PluginAdvancedCPU/AdvancedCPU.cpp
Normal file
362
Plugins/PluginAdvancedCPU/AdvancedCPU.cpp
Normal file
@@ -0,0 +1,362 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include <windows.h>
|
||||
#include "AdvancedCPU.h"
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include "..\..\Library\Export.h" // Rainmeter's exported functions
|
||||
|
||||
//ULONGLONG GetPerfData(PCTSTR ObjectName, PCTSTR InstanceName, PCTSTR CounterName);
|
||||
void UpdateProcesses();
|
||||
|
||||
struct CPUMeasure
|
||||
{
|
||||
std::vector< std::wstring > includes;
|
||||
std::vector< std::wstring > excludes;
|
||||
int topProcess;
|
||||
std::wstring topProcessName;
|
||||
LONGLONG topProcessValue;
|
||||
};
|
||||
|
||||
struct ProcessValues
|
||||
{
|
||||
std::wstring name;
|
||||
LONGLONG oldValue;
|
||||
LONGLONG newValue;
|
||||
bool found;
|
||||
};
|
||||
|
||||
static CPerfTitleDatabase g_CounterTitles( PERF_TITLE_COUNTER );
|
||||
std::vector< ProcessValues > g_Processes;
|
||||
static std::map<UINT, CPUMeasure*> g_CPUMeasures;
|
||||
|
||||
void SplitName(WCHAR* names, std::vector< std::wstring >& splittedNames)
|
||||
{
|
||||
WCHAR* token;
|
||||
|
||||
token = wcstok(names, L";");
|
||||
while(token != NULL)
|
||||
{
|
||||
splittedNames.push_back(token);
|
||||
token = wcstok(NULL, L";");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
The return value can also be 0, which means that Rainmeter will
|
||||
track the maximum value automatically. The parameters for this
|
||||
function are:
|
||||
|
||||
instance The instance of this DLL
|
||||
iniFile The name of the ini-file (usually Rainmeter.ini)
|
||||
section The name of the section in the ini-file for this measure
|
||||
id The identifier for the measure. This is used to identify the measures that use the same plugin.
|
||||
*/
|
||||
UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
WCHAR buffer[4096];
|
||||
CPUMeasure* measure = new CPUMeasure;
|
||||
measure->topProcess = 0;
|
||||
measure->topProcessValue = 0;
|
||||
|
||||
LPCTSTR data = ReadConfigString(section, L"CPUInclude", L"");
|
||||
if (data)
|
||||
{
|
||||
wcsncpy(buffer, data, 4096);
|
||||
buffer[4095] = 0;
|
||||
SplitName(buffer, measure->includes);
|
||||
}
|
||||
|
||||
data = ReadConfigString(section, L"CPUExclude", L"");
|
||||
if (data)
|
||||
{
|
||||
wcsncpy(buffer, data, 4096);
|
||||
buffer[4095] = 0;
|
||||
SplitName(buffer, measure->excludes);
|
||||
}
|
||||
|
||||
measure->topProcess = 0;
|
||||
data = ReadConfigString(section, L"TopProcess", L"0");
|
||||
if (data)
|
||||
{
|
||||
measure->topProcess = _wtoi(data);
|
||||
}
|
||||
|
||||
g_CPUMeasures[id] = measure;
|
||||
|
||||
return 10000000; // The values are 100 * 100000
|
||||
}
|
||||
|
||||
bool CheckProcess(CPUMeasure* measure, const std::wstring& name)
|
||||
{
|
||||
if (measure->includes.empty())
|
||||
{
|
||||
for (int i = 0; i < measure->excludes.size(); i++)
|
||||
{
|
||||
if (wcsicmp(measure->excludes[i].c_str(), name.c_str()) == 0)
|
||||
{
|
||||
return false; // Exclude
|
||||
}
|
||||
}
|
||||
return true; // Include
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < measure->includes.size(); i++)
|
||||
{
|
||||
if (wcsicmp(measure->includes[i].c_str(), name.c_str()) == 0)
|
||||
{
|
||||
return true; // Include
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when new value should be measured.
|
||||
The function returns the new value.
|
||||
*/
|
||||
double Update2(UINT id)
|
||||
{
|
||||
static DWORD oldTime = 0;
|
||||
|
||||
// Only update twice per second
|
||||
DWORD time = GetTickCount();
|
||||
if (oldTime == 0 || time - oldTime > 500)
|
||||
{
|
||||
UpdateProcesses();
|
||||
oldTime = time;
|
||||
}
|
||||
|
||||
LONGLONG newValue = 0;
|
||||
|
||||
std::map<UINT, CPUMeasure*>::iterator i = g_CPUMeasures.find(id);
|
||||
if(i != g_CPUMeasures.end())
|
||||
{
|
||||
CPUMeasure* measure = (*i).second;
|
||||
|
||||
if(measure)
|
||||
{
|
||||
for (int i = 0; i < g_Processes.size(); i++)
|
||||
{
|
||||
// Check process include/exclude
|
||||
if (CheckProcess(measure, g_Processes[i].name))
|
||||
{
|
||||
if (g_Processes[i].oldValue != 0)
|
||||
{
|
||||
if (measure->topProcess == 0)
|
||||
{
|
||||
// Add all values together
|
||||
newValue += g_Processes[i].newValue - g_Processes[i].oldValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Find the top process
|
||||
if (newValue < g_Processes[i].newValue - g_Processes[i].oldValue)
|
||||
{
|
||||
newValue = g_Processes[i].newValue - g_Processes[i].oldValue;
|
||||
measure->topProcessName = g_Processes[i].name;
|
||||
measure->topProcessValue = newValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// LONGLONG newValue = 0;
|
||||
// ULONGLONG longvalue = 0;
|
||||
//
|
||||
// if (measure->includes.empty())
|
||||
// {
|
||||
// // First get the total CPU value
|
||||
// longvalue = GetPerfData(L"Processor", L"_Total", L"% Processor Time");
|
||||
// newValue = longvalue;
|
||||
//
|
||||
// // Then substract the excluded processes
|
||||
// std::vector< std::wstring >::iterator j = measure->excludes.begin();
|
||||
// for( ; j != measure->excludes.end(); j++)
|
||||
// {
|
||||
// longvalue = GetPerfData(L"Process", (*j).c_str(), L"% Processor Time");
|
||||
// newValue += longvalue; // Adding means actually substraction
|
||||
// }
|
||||
//
|
||||
// // Compare with the old value
|
||||
// if(measure->oldValue != 0)
|
||||
// {
|
||||
// int val = 10000000 - (UINT)(newValue - measure->oldValue);
|
||||
// if (val < 0) val = 0;
|
||||
// value = val;
|
||||
// }
|
||||
// measure->oldValue = newValue;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// // Add the included processes
|
||||
// std::vector< std::wstring >::iterator j = measure->includes.begin();
|
||||
// for( ; j != measure->includes.end(); j++)
|
||||
// {
|
||||
// longvalue = GetPerfData(L"Process", (*j).c_str(), L"% Processor Time");
|
||||
// newValue += longvalue;
|
||||
// }
|
||||
//
|
||||
// // Compare with the old value
|
||||
// if(measure->oldValue != 0)
|
||||
// {
|
||||
// value = (UINT)(newValue - measure->oldValue);
|
||||
// }
|
||||
// measure->oldValue = newValue;
|
||||
//
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
return (double)newValue;
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when the value should be
|
||||
returned as a string.
|
||||
*/
|
||||
LPCTSTR GetString(UINT id, UINT flags)
|
||||
{
|
||||
std::map<UINT, CPUMeasure*>::iterator i = g_CPUMeasures.find(id);
|
||||
if(i != g_CPUMeasures.end())
|
||||
{
|
||||
CPUMeasure* measure = (*i).second;
|
||||
|
||||
if (measure->topProcess == 2)
|
||||
{
|
||||
return measure->topProcessName.c_str();
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
If the measure needs to free resources before quitting.
|
||||
The plugin can export Finalize function, which is called
|
||||
when Rainmeter quits (or refreshes).
|
||||
*/
|
||||
void Finalize(HMODULE instance, UINT id)
|
||||
{
|
||||
// delete the measure
|
||||
std::map<UINT, CPUMeasure*>::iterator i = g_CPUMeasures.find(id);
|
||||
if(i != g_CPUMeasures.end())
|
||||
{
|
||||
delete (*i).second;
|
||||
g_CPUMeasures.erase(i);
|
||||
}
|
||||
|
||||
CPerfSnapshot::CleanUp();
|
||||
}
|
||||
|
||||
/*
|
||||
This updates the process status
|
||||
*/
|
||||
void UpdateProcesses()
|
||||
{
|
||||
CPerfObject* pPerfObj;
|
||||
CPerfObjectInstance* pObjInst;
|
||||
CPerfCounter* pPerfCntr;
|
||||
BYTE data[256];
|
||||
WCHAR name[256];
|
||||
|
||||
std::vector< ProcessValues > newProcesses;
|
||||
|
||||
CPerfSnapshot snapshot(&g_CounterTitles);
|
||||
CPerfObjectList objList(&snapshot, &g_CounterTitles);
|
||||
|
||||
if(snapshot.TakeSnapshot(L"Process"))
|
||||
{
|
||||
pPerfObj = objList.GetPerfObject(L"Process");
|
||||
|
||||
if(pPerfObj)
|
||||
{
|
||||
for(pObjInst = pPerfObj->GetFirstObjectInstance();
|
||||
pObjInst != NULL;
|
||||
pObjInst = pPerfObj->GetNextObjectInstance())
|
||||
{
|
||||
if(pObjInst->GetObjectInstanceName(name, 256))
|
||||
{
|
||||
if (wcscmp(name, L"_Total") == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
pPerfCntr = pObjInst->GetCounterByName(L"% Processor Time");
|
||||
if(pPerfCntr != NULL)
|
||||
{
|
||||
pPerfCntr->GetData(data, 256, NULL);
|
||||
|
||||
if(pPerfCntr->GetSize() == 8)
|
||||
{
|
||||
ProcessValues values;
|
||||
values.name = name;
|
||||
values.oldValue = 0;
|
||||
|
||||
// Check if we can find the old value
|
||||
for (int i = 0; i < g_Processes.size(); i++)
|
||||
{
|
||||
if (!g_Processes[i].found && g_Processes[i].name == name)
|
||||
{
|
||||
values.oldValue = g_Processes[i].newValue;
|
||||
g_Processes[i].found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
values.newValue = *(ULONGLONG*)data;
|
||||
values.found = false;
|
||||
newProcesses.push_back(values);
|
||||
|
||||
// LSLog(LOG_DEBUG, L"Rainmeter", name); // DEBUG
|
||||
}
|
||||
|
||||
delete pPerfCntr;
|
||||
}
|
||||
}
|
||||
delete pObjInst;
|
||||
}
|
||||
delete pPerfObj;
|
||||
}
|
||||
}
|
||||
|
||||
g_Processes = newProcesses;
|
||||
}
|
||||
|
||||
|
||||
UINT GetPluginVersion()
|
||||
{
|
||||
return 1005;
|
||||
}
|
||||
|
||||
LPCTSTR GetPluginAuthor()
|
||||
{
|
||||
return L"Rainy (rainy@iki.fi)";
|
||||
}
|
||||
|
||||
42
Plugins/PluginAdvancedCPU/AdvancedCPU.h
Normal file
42
Plugins/PluginAdvancedCPU/AdvancedCPU.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
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.
|
||||
*/
|
||||
|
||||
#ifndef __ADVANCEDCPU_H__
|
||||
#define __ADVANCEDCPU_H__
|
||||
|
||||
#include "../PluginPerfMon/titledb.h"
|
||||
#include "../PluginPerfMon/perfsnap.h"
|
||||
#include "../PluginPerfMon/objlist.h"
|
||||
#include "../PluginPerfMon/perfobj.h"
|
||||
#include "../PluginPerfMon/objinst.h"
|
||||
#include "../PluginPerfMon/perfcntr.h"
|
||||
|
||||
#pragma warning ( disable: 4786 )
|
||||
|
||||
/* The exported functions */
|
||||
extern "C"
|
||||
{
|
||||
__declspec( dllexport ) UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id);
|
||||
__declspec( dllexport ) void Finalize(HMODULE instance, UINT id);
|
||||
__declspec( dllexport ) double Update2(UINT id);
|
||||
__declspec( dllexport ) UINT GetPluginVersion();
|
||||
__declspec( dllexport ) LPCTSTR GetString(UINT id, UINT flags);
|
||||
__declspec( dllexport ) LPCTSTR GetPluginAuthor();
|
||||
}
|
||||
|
||||
#endif
|
||||
157
Plugins/PluginAdvancedCPU/PluginAdvancedCPU.dsp
Normal file
157
Plugins/PluginAdvancedCPU/PluginAdvancedCPU.dsp
Normal file
@@ -0,0 +1,157 @@
|
||||
# Microsoft Developer Studio Project File - Name="PluginAdvancedCPU" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=PluginAdvancedCPU - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "PluginAdvancedCPU.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "PluginAdvancedCPU.mak" CFG="PluginAdvancedCPU - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "PluginAdvancedCPU - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginAdvancedCPU - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginAdvancedCPU - Win32 Release 64" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName "PluginAdvancedCPU"
|
||||
# PROP Scc_LocalPath ".."
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "PluginAdvancedCPU - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "x32/Release"
|
||||
# PROP Intermediate_Dir "x32/Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PluginAdvancedCPU_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginAdvancedCPU_EXPORTS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40b /d "NDEBUG"
|
||||
# ADD RSC /l 0x40b /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"../../TestBench/x32/Release/Plugins/AdvancedCPU.dll"
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginAdvancedCPU - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "x32/Debug"
|
||||
# PROP Intermediate_Dir "x32/Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PluginAdvancedCPU_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginAdvancedCPU_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40b /d "_DEBUG"
|
||||
# ADD RSC /l 0x40b /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"../../TestBench/x32/Debug/Plugins/AdvancedCPU.dll" /pdbtype:sept
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginAdvancedCPU - Win32 Release 64"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "PluginAdvancedCPU___Win32_Release_64"
|
||||
# PROP BASE Intermediate_Dir "PluginAdvancedCPU___Win32_Release_64"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "x64/Release"
|
||||
# PROP Intermediate_Dir "x64/Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginAdvancedCPU_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PluginAdvancedCPU_EXPORTS" /FD /GL /EHsc /Wp64 /GA /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40b /d "NDEBUG"
|
||||
# ADD RSC /l 0x40b /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"../../TestBench/x32/Release/Plugins/AdvancedCPU.dll"
|
||||
# ADD LINK32 bufferoverflowU.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:IX86 /out:"../../TestBench/x64/Release/Plugins/AdvancedCPU.dll" /machine:AMD64 /LTCG
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "PluginAdvancedCPU - Win32 Release"
|
||||
# Name "PluginAdvancedCPU - Win32 Debug"
|
||||
# Name "PluginAdvancedCPU - Win32 Release 64"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\AdvancedCPU.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\AdvancedCPU.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\PluginPerfMon\MakePtr.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\PluginPerfMon\ObjInst.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\PluginPerfMon\ObjList.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\PluginPerfMon\PerfCntr.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\PluginPerfMon\PerfObj.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\PluginPerfMon\PerfSnap.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\PluginPerfMon\Titledb.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
388
Plugins/PluginAdvancedCPU/PluginAdvancedCPU.vcproj
Normal file
388
Plugins/PluginAdvancedCPU/PluginAdvancedCPU.vcproj
Normal file
@@ -0,0 +1,388 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="PluginAdvancedCPU"
|
||||
SccProjectName="PluginAdvancedCPU"
|
||||
SccLocalPath="..">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release 64|Win32"
|
||||
OutputDirectory=".\x64/Release"
|
||||
IntermediateDirectory=".\x64/Release"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="1">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/GL /EHsc /Wp64 /GA "
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\x64/Release/PluginAdvancedCPU.pch"
|
||||
AssemblerListingLocation=".\x64/Release/"
|
||||
ObjectFile=".\x64/Release/"
|
||||
ProgramDataBaseFileName=".\x64/Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/machine:AMD64 /LTCG "
|
||||
AdditionalDependencies="bufferoverflowU.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../../TestBench/x64/Release/Plugins/AdvancedCPU.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x64/Release/AdvancedCPU.pdb"
|
||||
ImportLibrary=".\x64/Release/AdvancedCPU.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x64/Release/PluginAdvancedCPU.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1035"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\x32/Release"
|
||||
IntermediateDirectory=".\x32/Release"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="1">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Release/PluginAdvancedCPU.pch"
|
||||
AssemblerListingLocation=".\x32/Release/"
|
||||
ObjectFile=".\x32/Release/"
|
||||
ProgramDataBaseFileName=".\x32/Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="../../TestBench/x32/Release/Plugins/AdvancedCPU.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Release/AdvancedCPU.pdb"
|
||||
ImportLibrary=".\x32/Release/AdvancedCPU.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Release/PluginAdvancedCPU.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1035"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\x32/Debug"
|
||||
IntermediateDirectory=".\x32/Debug"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="1">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Debug/PluginAdvancedCPU.pch"
|
||||
AssemblerListingLocation=".\x32/Debug/"
|
||||
ObjectFile=".\x32/Debug/"
|
||||
ProgramDataBaseFileName=".\x32/Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="../../TestBench/x32/Debug/Plugins/AdvancedCPU.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Debug/AdvancedCPU.pdb"
|
||||
ImportLibrary=".\x32/Debug/AdvancedCPU.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Debug/PluginAdvancedCPU.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1035"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="AdvancedCPU.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="AdvancedCPU.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\PluginPerfMon\MakePtr.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\PluginPerfMon\ObjInst.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\PluginPerfMon\ObjList.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\PluginPerfMon\PerfCntr.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\PluginPerfMon\PerfObj.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\PluginPerfMon\PerfSnap.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\PluginPerfMon\Titledb.cpp">
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PluginAdvancedCPU_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
140
Plugins/PluginExample/ExamplePlugin.c
Normal file
140
Plugins/PluginExample/ExamplePlugin.c
Normal file
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
Copyright (C) 2001 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.
|
||||
*/
|
||||
/*
|
||||
$Header: /home/cvsroot/Rainmeter/Plugins/PluginExample/ExamplePlugin.c,v 1.1.1.1 2005/07/10 18:51:06 rainy Exp $
|
||||
|
||||
$Log: ExamplePlugin.c,v $
|
||||
Revision 1.1.1.1 2005/07/10 18:51:06 rainy
|
||||
no message
|
||||
|
||||
Revision 1.3 2004/06/05 10:49:50 rainy
|
||||
Added new interface.
|
||||
Uses config parser.
|
||||
|
||||
Revision 1.2 2001/12/23 10:04:51 rainy
|
||||
Added ID to the interface.
|
||||
|
||||
Revision 1.1 2001/10/28 09:05:05 rainy
|
||||
Inital version
|
||||
|
||||
*/
|
||||
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#include <windows.h>
|
||||
#include <math.h>
|
||||
#include "..\..\Library\Export.h" // Rainmeter's exported functions
|
||||
|
||||
/* The exported functions */
|
||||
__declspec( dllexport ) UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id);
|
||||
__declspec( dllexport ) void Finalize(HMODULE instance, UINT id);
|
||||
__declspec( dllexport ) UINT Update(UINT id);
|
||||
__declspec( dllexport ) UINT GetPluginVersion();
|
||||
__declspec( dllexport ) LPCTSTR GetPluginAuthor();
|
||||
|
||||
/* Couple of globals */
|
||||
static UINT g_Phase = 100;
|
||||
static UINT g_CurrentPhase = 0;
|
||||
|
||||
/*
|
||||
This function is called when the measure is initialized.
|
||||
The function must return the maximum value that can be measured.
|
||||
The return value can also be 0, which means that Rainmeter will
|
||||
track the maximum value automatically. The parameters for this
|
||||
function are:
|
||||
|
||||
instance The instance of this DLL
|
||||
iniFile The name of the ini-file (usually Rainmeter.ini)
|
||||
section The name of the section in the ini-file for this measure
|
||||
id The identifier for the measure. This is used to identify the measures that use the same plugin.
|
||||
*/
|
||||
UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
|
||||
{
|
||||
/*
|
||||
Read our own settings from the ini-file
|
||||
The ReadConfigString can be used for this purpose. Plugins
|
||||
can also read the config some other way (e.g. with
|
||||
GetPrivateProfileInt, but in that case the variables
|
||||
do not work.
|
||||
*/
|
||||
LPCTSTR data = ReadConfigString(section, L"PhaseShift", L"0");
|
||||
if (data)
|
||||
{
|
||||
g_CurrentPhase = _wtoi(data);
|
||||
}
|
||||
|
||||
data = ReadConfigString(section, L"Phase", L"100");
|
||||
if (data)
|
||||
{
|
||||
g_Phase = _wtoi(data);
|
||||
}
|
||||
|
||||
return 1000; /* We'll return values from 0 to 1000 */
|
||||
}
|
||||
|
||||
/*
|
||||
This function is called when new value should be measured.
|
||||
The function returns the new value.
|
||||
*/
|
||||
UINT Update(UINT id)
|
||||
{
|
||||
/*
|
||||
This measure doesn't measure anything. It's just an
|
||||
example how to create Rainmeter plugins. We'll just
|
||||
return sine curve so that the meter shows something.
|
||||
*/
|
||||
|
||||
double value = 6.283185 * ((double)g_CurrentPhase / (double)g_Phase);
|
||||
value = sin(value);
|
||||
|
||||
g_CurrentPhase++;
|
||||
if(g_CurrentPhase > g_Phase)
|
||||
{
|
||||
g_CurrentPhase = 0;
|
||||
}
|
||||
|
||||
return (UINT)((value + 1.0) * 500.0);
|
||||
}
|
||||
|
||||
/*
|
||||
If the measure needs to free resources before quitting.
|
||||
The plugin can export Finalize function, which is called
|
||||
when Rainmeter quits (or refreshes).
|
||||
*/
|
||||
void Finalize(HMODULE instance, UINT id)
|
||||
{
|
||||
/* Nothing to do here */
|
||||
}
|
||||
|
||||
/*
|
||||
Returns the version number of the plugin. The value
|
||||
can be calculated like this: Major * 1000 + Minor.
|
||||
So, e.g. 2.31 would be 2031.
|
||||
*/
|
||||
UINT GetPluginVersion()
|
||||
{
|
||||
return 1001;
|
||||
}
|
||||
|
||||
/*
|
||||
Returns the author of the plugin for the about dialog.
|
||||
*/
|
||||
LPCTSTR GetPluginAuthor()
|
||||
{
|
||||
return L"Rainy (rainy@iki.fi)";
|
||||
}
|
||||
125
Plugins/PluginExample/PluginExample.dsp
Normal file
125
Plugins/PluginExample/PluginExample.dsp
Normal file
@@ -0,0 +1,125 @@
|
||||
# Microsoft Developer Studio Project File - Name="PluginExample" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
|
||||
|
||||
CFG=PluginExample - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "PluginExample.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "PluginExample.mak" CFG="PluginExample - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "PluginExample - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginExample - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE "PluginExample - Win32 Release 64" (based on "Win32 (x86) Dynamic-Link Library")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName "PluginExample"
|
||||
# PROP Scc_LocalPath "."
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "PluginExample - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "x32/Release"
|
||||
# PROP Intermediate_Dir "x32/Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PLUGINEXAMPLE_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PLUGINEXAMPLE_EXPORTS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40b /d "NDEBUG"
|
||||
# ADD RSC /l 0x40b /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"../../TestBench/x32/Release/Plugins/ExamplePlugin.dll"
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginExample - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "x32/Debug"
|
||||
# PROP Intermediate_Dir "x32/Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "PLUGINEXAMPLE_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PLUGINEXAMPLE_EXPORTS" /YX /FD /GZ /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40b /d "_DEBUG"
|
||||
# ADD RSC /l 0x40b /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"../../TestBench/x32/Debug/Plugins/ExamplePlugin.dll" /pdbtype:sept
|
||||
|
||||
!ELSEIF "$(CFG)" == "PluginExample - Win32 Release 64"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "PluginExample___Win32_Release_64"
|
||||
# PROP BASE Intermediate_Dir "PluginExample___Win32_Release_64"
|
||||
# PROP BASE Ignore_Export_Lib 0
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "x64/Release"
|
||||
# PROP Intermediate_Dir "x64/Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PLUGINEXAMPLE_EXPORTS" /YX /FD /c
|
||||
# ADD CPP /nologo /MD /W3 /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_UNICODE" /D "UNICODE" /D "_USRDLL" /D "PLUGINEXAMPLE_EXPORTS" /FD /GL /EHsc /Wp64 /GA /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x40b /d "NDEBUG"
|
||||
# ADD RSC /l 0x40b /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"../../TestBench/x32/Release/Plugins/ExamplePlugin.dll"
|
||||
# ADD LINK32 bufferoverflowU.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:IX86 /out:"../../TestBench/x64/Release/Plugins/ExamplePlugin.dll" /machine:AMD64 /LTCG
|
||||
# SUBTRACT LINK32 /pdb:none
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "PluginExample - Win32 Release"
|
||||
# Name "PluginExample - Win32 Debug"
|
||||
# Name "PluginExample - Win32 Release 64"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ExamplePlugin.c
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
232
Plugins/PluginExample/PluginExample.vcproj
Normal file
232
Plugins/PluginExample/PluginExample.vcproj
Normal file
@@ -0,0 +1,232 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="7.10"
|
||||
Name="PluginExample"
|
||||
SccProjectName="PluginExample"
|
||||
SccLocalPath=".">
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"/>
|
||||
</Platforms>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory=".\x32/Release"
|
||||
IntermediateDirectory=".\x32/Release"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="1">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;UNICODE;_USRDLL;PLUGINEXAMPLE_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Release/PluginExample.pch"
|
||||
AssemblerListingLocation=".\x32/Release/"
|
||||
ObjectFile=".\x32/Release/"
|
||||
ProgramDataBaseFileName=".\x32/Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="../../TestBench/x32/Release/Plugins/ExamplePlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Release/ExamplePlugin.pdb"
|
||||
ImportLibrary=".\x32/Release/ExamplePlugin.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Release/PluginExample.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1035"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory=".\x32/Debug"
|
||||
IntermediateDirectory=".\x32/Debug"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="1">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;UNICODE;_USRDLL;PLUGINEXAMPLE_EXPORTS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="2"
|
||||
PrecompiledHeaderFile=".\x32/Debug/PluginExample.pch"
|
||||
AssemblerListingLocation=".\x32/Debug/"
|
||||
ObjectFile=".\x32/Debug/"
|
||||
ProgramDataBaseFileName=".\x32/Debug/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"
|
||||
DebugInformationFormat="4"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="../../TestBench/x32/Debug/Plugins/ExamplePlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
GenerateDebugInformation="TRUE"
|
||||
ProgramDatabaseFile=".\x32/Debug/ExamplePlugin.pdb"
|
||||
ImportLibrary=".\x32/Debug/ExamplePlugin.lib"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x32/Debug/PluginExample.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1035"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release 64|Win32"
|
||||
OutputDirectory=".\x64/Release"
|
||||
IntermediateDirectory=".\x64/Release"
|
||||
ConfigurationType="2"
|
||||
UseOfMFC="0"
|
||||
ATLMinimizesCRunTimeLibraryUsage="FALSE"
|
||||
CharacterSet="1">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalOptions="/GL /EHsc /Wp64 /GA "
|
||||
Optimization="2"
|
||||
InlineFunctionExpansion="1"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;UNICODE;_USRDLL;PLUGINEXAMPLE_EXPORTS"
|
||||
StringPooling="TRUE"
|
||||
RuntimeLibrary="2"
|
||||
EnableFunctionLevelLinking="TRUE"
|
||||
PrecompiledHeaderFile=".\x64/Release/PluginExample.pch"
|
||||
AssemblerListingLocation=".\x64/Release/"
|
||||
ObjectFile=".\x64/Release/"
|
||||
ProgramDataBaseFileName=".\x64/Release/"
|
||||
WarningLevel="3"
|
||||
SuppressStartupBanner="TRUE"/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalOptions="/machine:AMD64 /LTCG "
|
||||
AdditionalDependencies="bufferoverflowU.lib odbc32.lib odbccp32.lib"
|
||||
OutputFile="../../TestBench/x64/Release/Plugins/ExamplePlugin.dll"
|
||||
LinkIncremental="1"
|
||||
SuppressStartupBanner="TRUE"
|
||||
ProgramDatabaseFile=".\x64/Release/ExamplePlugin.pdb"
|
||||
ImportLibrary=".\x64/Release/ExamplePlugin.lib"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
MkTypLibCompatible="TRUE"
|
||||
SuppressStartupBanner="TRUE"
|
||||
TargetEnvironment="1"
|
||||
TypeLibraryName=".\x64/Release/PluginExample.tlb"
|
||||
HeaderFileName=""/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="NDEBUG"
|
||||
Culture="1035"/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCWebDeploymentTool"/>
|
||||
<Tool
|
||||
Name="VCManagedWrapperGeneratorTool"/>
|
||||
<Tool
|
||||
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<File
|
||||
RelativePath="ExamplePlugin.c">
|
||||
<FileConfiguration
|
||||
Name="Release|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PLUGINEXAMPLE_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Debug|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PLUGINEXAMPLE_EXPORTS;$(NoInherit)"
|
||||
BasicRuntimeChecks="3"/>
|
||||
</FileConfiguration>
|
||||
<FileConfiguration
|
||||
Name="Release 64|Win32">
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_UNICODE;UNICODE;_USRDLL;PLUGINEXAMPLE_EXPORTS;$(NoInherit)"/>
|
||||
</FileConfiguration>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
10
Plugins/PluginPerfMon/MakePtr.h
Normal file
10
Plugins/PluginPerfMon/MakePtr.h
Normal file
@@ -0,0 +1,10 @@
|
||||
// MakePtr is a macro that allows you to easily add two values (including
|
||||
// pointers) together without dealing with C's pointer arithmetic. It
|
||||
// essentially treats the last two parameters as DWORDs. The first
|
||||
// parameter is used to typecast the result to the appropriate pointer type.
|
||||
#ifdef _WIN64
|
||||
#define MakePtr(cast, ptr, addValue) (cast)( (DWORD64)(ptr) + (DWORD64)(addValue))
|
||||
#else
|
||||
#define MakePtr(cast, ptr, addValue) (cast)( (DWORD)(ptr) + (DWORD)(addValue))
|
||||
#endif
|
||||
|
||||
138
Plugins/PluginPerfMon/ObjInst.cpp
Normal file
138
Plugins/PluginPerfMon/ObjInst.cpp
Normal file
@@ -0,0 +1,138 @@
|
||||
//====================================
|
||||
// File: OBJINST.CPP
|
||||
// Author: Matt Pietrek
|
||||
// From: Microsoft Systems Journal
|
||||
// "Under the Hood", April 1996
|
||||
//====================================
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <winperf.h>
|
||||
#include <stdlib.h>
|
||||
#pragma hdrstop
|
||||
#include "titledb.h"
|
||||
#include "objinst.h"
|
||||
#include "perfcntr.h"
|
||||
#include "makeptr.h"
|
||||
|
||||
CPerfObjectInstance::CPerfObjectInstance(
|
||||
PPERF_INSTANCE_DEFINITION const pPerfInstDef,
|
||||
PPERF_COUNTER_DEFINITION const pPerfCntrDef,
|
||||
DWORD nCounters, CPerfTitleDatabase * const pPerfCounterTitles,
|
||||
BOOL fDummy)
|
||||
{
|
||||
m_pPerfInstDef = pPerfInstDef;
|
||||
m_pPerfCntrDef = pPerfCntrDef;
|
||||
m_nCounters = nCounters;
|
||||
m_pPerfCounterTitles = pPerfCounterTitles;
|
||||
|
||||
m_fDummy = fDummy;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfObjectInstance::GetObjectInstanceName(
|
||||
PTSTR pszObjInstName, DWORD nSize )
|
||||
{
|
||||
if ( m_fDummy )
|
||||
{
|
||||
*pszObjInstName = 0; // Return an empty string
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ( nSize < (m_pPerfInstDef->NameLength / sizeof(TCHAR)) )
|
||||
return FALSE;
|
||||
|
||||
PWSTR pszName = MakePtr(PWSTR, m_pPerfInstDef, m_pPerfInstDef->NameOffset);
|
||||
|
||||
#ifdef UNICODE
|
||||
lstrcpy( pszObjInstName, pszName );
|
||||
#else
|
||||
wcstombs( pszObjInstName, pszName, nSize );
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::MakeCounter( PPERF_COUNTER_DEFINITION const pCounterDef )
|
||||
{
|
||||
// Look up the name of this counter in the title database
|
||||
PTSTR pszName = m_pPerfCounterTitles->GetTitleStringFromIndex(
|
||||
pCounterDef->CounterNameTitleIndex );
|
||||
|
||||
DWORD nInstanceDefSize = m_fDummy ? 0 : m_pPerfInstDef->ByteLength;
|
||||
|
||||
// Create a new CPerfCounter. The caller is responsible for deleting it.
|
||||
return new CPerfCounter(pszName,
|
||||
pCounterDef->CounterType,
|
||||
MakePtr( PBYTE, m_pPerfInstDef,
|
||||
nInstanceDefSize +
|
||||
pCounterDef->CounterOffset ),
|
||||
pCounterDef->CounterSize );
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::GetCounterByIndex( DWORD index )
|
||||
{
|
||||
PPERF_COUNTER_DEFINITION pCurrentCounter;
|
||||
|
||||
if ( index >= m_nCounters )
|
||||
return 0;
|
||||
|
||||
pCurrentCounter = m_pPerfCntrDef;
|
||||
|
||||
// Find the correct PERF_COUNTER_DEFINITION by looping
|
||||
for ( DWORD i = 0; i < index; i++ )
|
||||
{
|
||||
pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION,
|
||||
pCurrentCounter,
|
||||
pCurrentCounter->ByteLength );
|
||||
}
|
||||
|
||||
if ( pCurrentCounter->ByteLength == 0 )
|
||||
return 0;
|
||||
|
||||
return MakeCounter( pCurrentCounter );
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::GetFirstCounter( void )
|
||||
{
|
||||
m_currentCounter = 0;
|
||||
return GetCounterByIndex( m_currentCounter );
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::GetNextCounter( void )
|
||||
{
|
||||
m_currentCounter++;
|
||||
return GetCounterByIndex( m_currentCounter );
|
||||
}
|
||||
|
||||
CPerfCounter *
|
||||
CPerfObjectInstance::GetCounterByName( PCTSTR const pszName )
|
||||
{
|
||||
DWORD cntrIdx = m_pPerfCounterTitles->GetIndexFromTitleString(pszName);
|
||||
if ( cntrIdx == 0 )
|
||||
return 0;
|
||||
|
||||
PPERF_COUNTER_DEFINITION pCurrentCounter = m_pPerfCntrDef;
|
||||
|
||||
// Find the correct PERF_COUNTER_DEFINITION by looping and comparing
|
||||
for ( DWORD i = 0; i < m_nCounters; i++ )
|
||||
{
|
||||
if ( pCurrentCounter->CounterNameTitleIndex == cntrIdx )
|
||||
return MakeCounter( pCurrentCounter );
|
||||
|
||||
// Nope. Not this one. Advance to the next counter
|
||||
pCurrentCounter = MakePtr( PPERF_COUNTER_DEFINITION,
|
||||
pCurrentCounter,
|
||||
pCurrentCounter->ByteLength );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
59
Plugins/PluginPerfMon/ObjInst.h
Normal file
59
Plugins/PluginPerfMon/ObjInst.h
Normal file
@@ -0,0 +1,59 @@
|
||||
#ifndef __Obinst_h__
|
||||
#define __Objinst_h__
|
||||
|
||||
#ifndef _WINDOWS_
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#ifndef _WINPERF_
|
||||
#include <winperf.h>
|
||||
#endif
|
||||
|
||||
class CPerfTitleDatabase;
|
||||
class CPerfCounter;
|
||||
|
||||
class CPerfObjectInstance
|
||||
{
|
||||
public:
|
||||
|
||||
CPerfObjectInstance(
|
||||
PPERF_INSTANCE_DEFINITION const pPerfInstDef,
|
||||
PPERF_COUNTER_DEFINITION const pPerfCntrDef, DWORD nCounters,
|
||||
CPerfTitleDatabase * const pPerfTitleDatabase, BOOL fDummy );
|
||||
|
||||
~CPerfObjectInstance( void ){ }
|
||||
|
||||
BOOL GetObjectInstanceName( PTSTR pszObjInstName, DWORD nSize );
|
||||
|
||||
// Functions that return CPerfCounter pointers. Caller is
|
||||
// responsible for deleting the CPerfCounter * when done with it.
|
||||
|
||||
CPerfCounter * GetFirstCounter( void );
|
||||
|
||||
CPerfCounter * GetNextCounter( void );
|
||||
|
||||
CPerfCounter * GetCounterByName( PCTSTR const pszName );
|
||||
|
||||
protected:
|
||||
|
||||
PPERF_INSTANCE_DEFINITION m_pPerfInstDef;
|
||||
|
||||
unsigned m_nCounters;
|
||||
|
||||
unsigned m_currentCounter;
|
||||
|
||||
PPERF_COUNTER_DEFINITION m_pPerfCntrDef;
|
||||
|
||||
CPerfTitleDatabase * m_pPerfCounterTitles;
|
||||
|
||||
CPerfCounter * MakeCounter( PPERF_COUNTER_DEFINITION const pCounter );
|
||||
|
||||
CPerfCounter * GetCounterByIndex( DWORD index );
|
||||
|
||||
CPerfTitleDatabase *m_pCounterTitleDatabase;
|
||||
|
||||
BOOL m_fDummy; // FALSE normally, TRUE when an object with no instances
|
||||
};
|
||||
|
||||
typedef CPerfObjectInstance * PCPerfObjectInstance;
|
||||
|
||||
#endif
|
||||
84
Plugins/PluginPerfMon/ObjList.cpp
Normal file
84
Plugins/PluginPerfMon/ObjList.cpp
Normal file
@@ -0,0 +1,84 @@
|
||||
//====================================
|
||||
// File: OBJLIST.CPP
|
||||
// Author: Matt Pietrek
|
||||
// From: Microsoft Systems Journal
|
||||
// "Under the Hood", April 1996
|
||||
//====================================
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <winperf.h>
|
||||
#include <stdlib.h>
|
||||
#pragma hdrstop
|
||||
#include "titledb.h"
|
||||
#include "objlist.h"
|
||||
#include "perfobj.h"
|
||||
#include "makeptr.h"
|
||||
|
||||
CPerfObjectList::CPerfObjectList(
|
||||
CPerfSnapshot * const pPerfSnapshot,
|
||||
CPerfTitleDatabase * const pPerfTitleDatabase )
|
||||
{
|
||||
m_pPerfSnapshot = pPerfSnapshot;
|
||||
m_pPerfCounterTitles = pPerfTitleDatabase;
|
||||
}
|
||||
|
||||
CPerfObject *
|
||||
CPerfObjectList::GetFirstPerfObject( void )
|
||||
{
|
||||
m_currentObjectListIndex = 0;
|
||||
if ( m_currentObjectListIndex >= m_pPerfSnapshot->GetNumObjectTypes() )
|
||||
return 0;
|
||||
|
||||
m_pCurrObjectType =
|
||||
(PPERF_OBJECT_TYPE)m_pPerfSnapshot->GetPostHeaderPointer();
|
||||
|
||||
return new CPerfObject( m_pCurrObjectType, m_pPerfCounterTitles );
|
||||
}
|
||||
|
||||
CPerfObject *
|
||||
CPerfObjectList::GetNextPerfObject( void )
|
||||
{
|
||||
// Are we at the last object in the list? Return NULL if so.
|
||||
if ( ++m_currentObjectListIndex >= m_pPerfSnapshot->GetNumObjectTypes() )
|
||||
return 0;
|
||||
|
||||
// Advance to the next PERF_OBJECT_TYPE structure
|
||||
m_pCurrObjectType = MakePtr(PPERF_OBJECT_TYPE,
|
||||
m_pCurrObjectType,
|
||||
m_pCurrObjectType->TotalByteLength );
|
||||
|
||||
return new CPerfObject( m_pCurrObjectType, m_pPerfCounterTitles );
|
||||
}
|
||||
|
||||
CPerfObject *
|
||||
CPerfObjectList::GetPerfObject( PCTSTR const pszObjListName )
|
||||
{
|
||||
DWORD objListIdx
|
||||
= m_pPerfCounterTitles->GetIndexFromTitleString( pszObjListName );
|
||||
if ( 0 == objListIdx )
|
||||
return 0;
|
||||
|
||||
// Point at first PERF_OBJECT_TYPE, and loop through the list, looking
|
||||
// for one that matches.
|
||||
PPERF_OBJECT_TYPE pCurrObjectType =
|
||||
(PPERF_OBJECT_TYPE)m_pPerfSnapshot->GetPostHeaderPointer();
|
||||
|
||||
for ( unsigned i=0; i < m_pPerfSnapshot->GetNumObjectTypes(); i++ )
|
||||
{
|
||||
// Is this the one that matches?
|
||||
if ( pCurrObjectType->ObjectNameTitleIndex == objListIdx )
|
||||
return new CPerfObject(pCurrObjectType, m_pPerfCounterTitles);
|
||||
|
||||
// Nope... try the next object type
|
||||
pCurrObjectType = MakePtr( PPERF_OBJECT_TYPE,
|
||||
pCurrObjectType,
|
||||
pCurrObjectType->TotalByteLength );
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
46
Plugins/PluginPerfMon/ObjList.h
Normal file
46
Plugins/PluginPerfMon/ObjList.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef __Objlist_h__
|
||||
#define __Objlist_h__
|
||||
|
||||
#ifndef _WINDOWS_
|
||||
#include <windows.h>
|
||||
#endif
|
||||
#ifndef _WINPERF_
|
||||
#include <winperf.h>
|
||||
#endif
|
||||
#ifndef __Perfsnap_h__
|
||||
#include "perfsnap.h"
|
||||
#endif
|
||||
|
||||
class CPerfObject;
|
||||
|
||||
class CPerfObjectList
|
||||
{
|
||||
public:
|
||||
|
||||
CPerfObjectList(CPerfSnapshot * const pPerfSnapshot,
|
||||
CPerfTitleDatabase * const pPerfTitleDatabase );
|
||||
|
||||
~CPerfObjectList( void ){ };
|
||||
|
||||
// Functions that return CPerfObject pointers. Caller is responsible
|
||||
// for deleting the CPerfObject * when done with it.
|
||||
|
||||
CPerfObject * GetFirstPerfObject( void );
|
||||
|
||||
CPerfObject * GetNextPerfObject( void );
|
||||
|
||||
CPerfObject * GetPerfObject( PCTSTR const pszObjListName );
|
||||
|
||||
protected:
|
||||
|
||||
CPerfSnapshot * m_pPerfSnapshot;
|
||||
|
||||
CPerfTitleDatabase * m_pPerfCounterTitles;
|
||||
|
||||
unsigned m_currentObjectListIndex;
|
||||
|
||||
PPERF_OBJECT_TYPE m_pCurrObjectType; // current first/next object ptr
|
||||
};
|
||||
|
||||
typedef CPerfObjectList * PCPerfObjectList;
|
||||
#endif
|
||||
124
Plugins/PluginPerfMon/PerfCntr.cpp
Normal file
124
Plugins/PluginPerfMon/PerfCntr.cpp
Normal file
@@ -0,0 +1,124 @@
|
||||
//====================================
|
||||
// File: PERFCNTR.CPP
|
||||
// Author: Matt Pietrek
|
||||
// From: Microsoft Systems Journal
|
||||
// "Under the Hood", APRIL 1996
|
||||
//====================================
|
||||
#pragma warning(disable: 4996)
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#include <winperf.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <malloc.h>
|
||||
#include <tchar.h>
|
||||
#pragma hdrstop
|
||||
#include "perfcntr.h"
|
||||
|
||||
CPerfCounter::CPerfCounter( PTSTR const pszName, DWORD type,
|
||||
PBYTE const pData, DWORD cbData )
|
||||
{
|
||||
m_pszName = _tcsdup( pszName );
|
||||
m_type = type;
|
||||
m_cbData = cbData;
|
||||
m_pData = new BYTE[m_cbData];
|
||||
memcpy( m_pData, pData, m_cbData );
|
||||
}
|
||||
|
||||
CPerfCounter::~CPerfCounter( void )
|
||||
{
|
||||
free( m_pszName );
|
||||
delete []m_pData;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfCounter::GetData( PBYTE pBuffer, DWORD cbBuffer, DWORD *pType )
|
||||
{
|
||||
if ( cbBuffer < m_cbData ) // Make sure the buffer is big enough
|
||||
return FALSE;
|
||||
|
||||
memcpy( pBuffer, m_pData, m_cbData ); // copy the data
|
||||
|
||||
if ( pType ) // If the user wants the type, give it to them
|
||||
*pType = m_type;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL
|
||||
CPerfCounter::Format( PTSTR pszBuffer, DWORD nSize, BOOL fHex )
|
||||
{
|
||||
// Do better formatting!!! Check length!!!
|
||||
|
||||
PTSTR pszPrefix = TEXT("");
|
||||
TCHAR szTemp[512];
|
||||
|
||||
// First, ascertain the basic type (number, counter, text, or zero)
|
||||
switch ( m_type & 0x00000C00 )
|
||||
{
|
||||
case PERF_TYPE_ZERO:
|
||||
{
|
||||
wsprintf( pszBuffer, TEXT("ZERO") ); return TRUE;
|
||||
}
|
||||
case PERF_TYPE_TEXT:
|
||||
{
|
||||
wsprintf( pszBuffer, TEXT("text counter") ); return TRUE;
|
||||
}
|
||||
case PERF_TYPE_COUNTER:
|
||||
{
|
||||
switch( m_type & 0x00070000 )
|
||||
{
|
||||
case PERF_COUNTER_RATE:
|
||||
pszPrefix = TEXT("counter rate "); break;
|
||||
case PERF_COUNTER_FRACTION:
|
||||
pszPrefix = TEXT("counter fraction "); break;
|
||||
case PERF_COUNTER_BASE:
|
||||
pszPrefix = TEXT("counter base "); break;
|
||||
case PERF_COUNTER_ELAPSED:
|
||||
pszPrefix = TEXT("counter elapsed "); break;
|
||||
case PERF_COUNTER_QUEUELEN:
|
||||
pszPrefix = TEXT("counter queuelen "); break;
|
||||
case PERF_COUNTER_HISTOGRAM:
|
||||
pszPrefix = TEXT("counter histogram "); break;
|
||||
default:
|
||||
pszPrefix = TEXT("counter value "); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PTSTR pszFmt = fHex ? TEXT("%s%Xh") : TEXT("%s%u");
|
||||
|
||||
switch ( m_cbData )
|
||||
{
|
||||
case 1: wsprintf(szTemp, pszFmt, pszPrefix, *(PBYTE)m_pData);
|
||||
break;
|
||||
case 2: wsprintf(szTemp, pszFmt, pszPrefix, *(PWORD)m_pData);
|
||||
break;
|
||||
case 4: wsprintf(szTemp, pszFmt, pszPrefix, *(PDWORD)m_pData);
|
||||
break;
|
||||
case 8: // Danger! Assumes little-endian (X86) byte ordering
|
||||
wsprintf( szTemp, TEXT("%s%X%X"), pszPrefix,
|
||||
*(PDWORD)(m_pData+4), *(PDWORD)m_pData ); break;
|
||||
break;
|
||||
|
||||
default: wsprintf( szTemp, TEXT("<unhandled size %u>"), m_cbData );
|
||||
}
|
||||
|
||||
switch ( m_type & 0x70000000 )
|
||||
{
|
||||
case PERF_DISPLAY_SECONDS:
|
||||
_tcscat( szTemp, TEXT(" secs") ); break;
|
||||
case PERF_DISPLAY_PERCENT:
|
||||
_tcscat( szTemp, TEXT(" %") ); break;
|
||||
case PERF_DISPLAY_PER_SEC:
|
||||
_tcscat( szTemp, TEXT(" /sec") ); break;
|
||||
}
|
||||
|
||||
lstrcpyn( pszBuffer, szTemp, nSize );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
35
Plugins/PluginPerfMon/PerfCntr.h
Normal file
35
Plugins/PluginPerfMon/PerfCntr.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef __Perfcntr_h__
|
||||
#define __Perfcntr_h__
|
||||
|
||||
class CPerfCounter
|
||||
{
|
||||
public:
|
||||
|
||||
CPerfCounter( PTSTR const pszName, DWORD type,
|
||||
PBYTE const pData, DWORD cbData );
|
||||
|
||||
~CPerfCounter( void );
|
||||
|
||||
PTSTR GetName( void ) { return m_pszName; }
|
||||
|
||||
DWORD GetType( void ) { return m_type; }
|
||||
|
||||
DWORD GetSize( void ) { return m_cbData; }
|
||||
|
||||
BOOL GetData( PBYTE pBuffer, DWORD cbBuffer, DWORD *pType );
|
||||
|
||||
BOOL Format( PTSTR pszBuffer, DWORD nSize, BOOL fHex = FALSE );
|
||||
|
||||
protected:
|
||||
|
||||
PTSTR m_pszName;
|
||||
|
||||
DWORD m_type;
|
||||
|
||||
PBYTE m_pData;
|
||||
|
||||
DWORD m_cbData;
|
||||
};
|
||||
|
||||
typedef CPerfCounter * PCPerfCounter;
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user