mirror of
https://github.com/chibicitiberiu/rainmeter-studio.git
synced 2024-02-24 04:33:31 +00:00
Changed ToolTip function to allow using %1, %2 etc. as appropriate for various meter types:
Line, String: %1, %2, %3, ... Histogram: %1, %2 Others: %1
This commit is contained in:
parent
1343a3ae9e
commit
eee8d9bb1c
@ -28,8 +28,8 @@ LANGUAGE LANG_FINNISH, SUBLANG_DEFAULT
|
|||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 1,3,0,520
|
FILEVERSION 1,3,0,530
|
||||||
PRODUCTVERSION 1,3,0,520
|
PRODUCTVERSION 1,3,0,530
|
||||||
FILEFLAGSMASK 0x17L
|
FILEFLAGSMASK 0x17L
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
@ -45,12 +45,12 @@ BEGIN
|
|||||||
BLOCK "040b04b0"
|
BLOCK "040b04b0"
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "FileDescription", "Rainmeter - A Customizable Resource Meter"
|
VALUE "FileDescription", "Rainmeter - A Customizable Resource Meter"
|
||||||
VALUE "FileVersion", "1, 3, 0, 520"
|
VALUE "FileVersion", "1, 3, 0, 530"
|
||||||
VALUE "InternalName", "Rainmeter"
|
VALUE "InternalName", "Rainmeter"
|
||||||
VALUE "LegalCopyright", "Copyright (C) 2010 - Rainy"
|
VALUE "LegalCopyright", "Copyright (C) 2010 - Rainy"
|
||||||
VALUE "OriginalFilename", "Rainmeter.exe"
|
VALUE "OriginalFilename", "Rainmeter.exe"
|
||||||
VALUE "ProductName", "Rainmeter"
|
VALUE "ProductName", "Rainmeter"
|
||||||
VALUE "ProductVersion", "1, 3, 0, 520"
|
VALUE "ProductVersion", "1, 3, 0, 530"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
@ -490,6 +490,80 @@ bool CMeter::Update()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** SetAllMeasures
|
||||||
|
**
|
||||||
|
** Creates a vector containing all the defined measures (Histogram)
|
||||||
|
*/
|
||||||
|
void CMeter::SetAllMeasures(CMeasure* measure)
|
||||||
|
{
|
||||||
|
m_AllMeasures.clear();
|
||||||
|
m_AllMeasures.push_back(m_Measure);
|
||||||
|
m_AllMeasures.push_back(measure);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMeter::SetAllMeasures(std::vector<CMeasure*> measures)
|
||||||
|
{
|
||||||
|
m_AllMeasures.clear();
|
||||||
|
m_AllMeasures.push_back(m_Measure);
|
||||||
|
|
||||||
|
std::vector<CMeasure*>::const_iterator i = measures.begin();
|
||||||
|
for( ; i != measures.end(); ++i)
|
||||||
|
{
|
||||||
|
m_AllMeasures.push_back(*i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
** ReplaceMeasures
|
||||||
|
**
|
||||||
|
** Replaces %1, %2 etc with the corresponding measure value
|
||||||
|
*/
|
||||||
|
std::wstring CMeter::ReplaceMeasures(std::wstring source)
|
||||||
|
{
|
||||||
|
std::vector<std::wstring> stringValues;
|
||||||
|
|
||||||
|
if (!m_AllMeasures.empty())
|
||||||
|
{
|
||||||
|
stringValues.push_back(m_AllMeasures.front()->GetStringValue(true, 1, 0, false));
|
||||||
|
// Get the values for the other measures
|
||||||
|
for (size_t i = 1; i < m_AllMeasures.size(); ++i)
|
||||||
|
{
|
||||||
|
stringValues.push_back(m_AllMeasures[i]->GetStringValue(true, 1, 0, false));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (m_Measure != NULL)
|
||||||
|
{
|
||||||
|
stringValues.push_back(m_Measure->GetStringValue(true, 1, 0, false));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
WCHAR buffer[256];
|
||||||
|
// Create the actual text (i.e. replace %1, %2, .. with the measure texts)
|
||||||
|
|
||||||
|
for (size_t i = 0; i < stringValues.size(); ++i)
|
||||||
|
{
|
||||||
|
wsprintf(buffer, L"%%%i", i + 1);
|
||||||
|
|
||||||
|
size_t start = 0;
|
||||||
|
size_t pos = std::wstring::npos;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
pos = source.find(buffer, start);
|
||||||
|
if (pos != std::wstring::npos)
|
||||||
|
{
|
||||||
|
source.replace(source.begin() + pos, source.begin() + pos + wcslen(buffer), stringValues[i]);
|
||||||
|
start = pos + stringValues[i].length();
|
||||||
|
}
|
||||||
|
} while(pos != std::wstring::npos);
|
||||||
|
}
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** CreateToolTip
|
** CreateToolTip
|
||||||
**
|
**
|
||||||
@ -535,7 +609,9 @@ void CMeter::CreateToolTip(CMeterWindow* meterWindow)
|
|||||||
ti.uFlags = TTF_SUBCLASS;
|
ti.uFlags = TTF_SUBCLASS;
|
||||||
ti.hwnd = m_MeterWindow->GetWindow();
|
ti.hwnd = m_MeterWindow->GetWindow();
|
||||||
ti.hinst = m_MeterWindow->GetMainObject()->GetInstance();
|
ti.hinst = m_MeterWindow->GetMainObject()->GetInstance();
|
||||||
ti.lpszText = (PTSTR) m_ToolTipText.c_str();
|
|
||||||
|
std::wstring text = ReplaceMeasures(m_ToolTipText);
|
||||||
|
ti.lpszText = (PTSTR) text.c_str();
|
||||||
ti.rect = GetMeterRect();
|
ti.rect = GetMeterRect();
|
||||||
|
|
||||||
SendMessage(hwndTT, TTM_ADDTOOL, NULL, (LPARAM) (LPTOOLINFO) &ti);
|
SendMessage(hwndTT, TTM_ADDTOOL, NULL, (LPARAM) (LPTOOLINFO) &ti);
|
||||||
@ -571,8 +647,8 @@ void CMeter::CreateToolTip(CMeterWindow* meterWindow)
|
|||||||
hIcon = (HICON) LoadImage(NULL, m_ToolTipIcon.c_str(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
|
hIcon = (HICON) LoadImage(NULL, m_ToolTipIcon.c_str(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
text = ReplaceMeasures(m_ToolTipTitle);
|
||||||
SendMessage(hwndTT, TTM_SETTITLE, (WPARAM) hIcon, (LPARAM) m_ToolTipTitle.c_str());
|
SendMessage(hwndTT, TTM_SETTITLE, (WPARAM) hIcon, (LPARAM) text.c_str());
|
||||||
DestroyIcon(hIcon);
|
DestroyIcon(hIcon);
|
||||||
}
|
}
|
||||||
if (IsHidden())
|
if (IsHidden())
|
||||||
@ -597,7 +673,8 @@ void CMeter::UpdateToolTip()
|
|||||||
|
|
||||||
SendMessage(hwndTT, TTM_GETTOOLINFO, NULL, (LPARAM) (LPTOOLINFO) &ti);
|
SendMessage(hwndTT, TTM_GETTOOLINFO, NULL, (LPARAM) (LPTOOLINFO) &ti);
|
||||||
|
|
||||||
ti.lpszText = (PTSTR) m_ToolTipText.c_str();
|
std::wstring text = ReplaceMeasures(m_ToolTipText);
|
||||||
|
ti.lpszText = (PTSTR) text.c_str();
|
||||||
ti.rect = GetMeterRect();
|
ti.rect = GetMeterRect();
|
||||||
|
|
||||||
SendMessage(hwndTT, TTM_SETTOOLINFO, NULL, (LPARAM) (LPTOOLINFO) &ti);
|
SendMessage(hwndTT, TTM_SETTOOLINFO, NULL, (LPARAM) (LPTOOLINFO) &ti);
|
||||||
@ -632,8 +709,8 @@ void CMeter::UpdateToolTip()
|
|||||||
hIcon = (HICON) LoadImage(NULL, m_ToolTipIcon.c_str(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
|
hIcon = (HICON) LoadImage(NULL, m_ToolTipIcon.c_str(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
text = ReplaceMeasures(m_ToolTipTitle);
|
||||||
SendMessage(hwndTT, TTM_SETTITLE, (WPARAM) hIcon, (LPARAM) m_ToolTipTitle.c_str());
|
SendMessage(hwndTT, TTM_SETTITLE, (WPARAM) hIcon, (LPARAM) text.c_str());
|
||||||
DestroyIcon(hIcon);
|
DestroyIcon(hIcon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,6 +64,11 @@ public:
|
|||||||
std::wstring& GetMouseOverAction() { return m_MouseOverAction; };
|
std::wstring& GetMouseOverAction() { return m_MouseOverAction; };
|
||||||
std::wstring& GetMouseLeaveAction() { return m_MouseLeaveAction; };
|
std::wstring& GetMouseLeaveAction() { return m_MouseLeaveAction; };
|
||||||
|
|
||||||
|
void SetAllMeasures(CMeasure* measure);
|
||||||
|
void SetAllMeasures(std::vector<CMeasure*> measures);
|
||||||
|
|
||||||
|
std::wstring CMeter::ReplaceMeasures(std::wstring source);
|
||||||
|
|
||||||
std::wstring& GetToolTipText() { return m_ToolTipText; };
|
std::wstring& GetToolTipText() { return m_ToolTipText; };
|
||||||
HWND GetToolTipHandle() { return m_ToolTipHandle; };
|
HWND GetToolTipHandle() { return m_ToolTipHandle; };
|
||||||
void SetToolTipHandle(HWND handle) { m_ToolTipHandle = handle; };
|
void SetToolTipHandle(HWND handle) { m_ToolTipHandle = handle; };
|
||||||
@ -113,6 +118,7 @@ protected:
|
|||||||
std::wstring m_Name; // Name of the meter
|
std::wstring m_Name; // Name of the meter
|
||||||
std::wstring m_MeasureName; // Name of the measure this is bound to
|
std::wstring m_MeasureName; // Name of the measure this is bound to
|
||||||
CMeasure* m_Measure; // Pointer to the measure this meter is bound to
|
CMeasure* m_Measure; // Pointer to the measure this meter is bound to
|
||||||
|
std::vector<CMeasure*> m_AllMeasures;
|
||||||
int m_X; // X-position of the meter
|
int m_X; // X-position of the meter
|
||||||
int m_Y; // Y-position of the meter
|
int m_Y; // Y-position of the meter
|
||||||
int m_W; // Width of the meter
|
int m_W; // Width of the meter
|
||||||
|
@ -569,6 +569,7 @@ void CMeterHistogram::BindMeasure(std::list<CMeasure*>& measures)
|
|||||||
if(_wcsicmp((*i)->GetName(), m_SecondaryMeasureName.c_str()) == 0)
|
if(_wcsicmp((*i)->GetName(), m_SecondaryMeasureName.c_str()) == 0)
|
||||||
{
|
{
|
||||||
m_SecondaryMeasure = (*i);
|
m_SecondaryMeasure = (*i);
|
||||||
|
CMeter::SetAllMeasures(m_SecondaryMeasure);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -374,4 +374,5 @@ void CMeterLine::BindMeasure(std::list<CMeasure*>& measures)
|
|||||||
throw CError(std::wstring(L"The meter [") + m_Name + L"] cannot be bound with [" + (*j) + L"]!", __LINE__, __FILE__);
|
throw CError(std::wstring(L"The meter [") + m_Name + L"] cannot be bound with [" + (*j) + L"]!", __LINE__, __FILE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CMeter::SetAllMeasures(m_Measures);
|
||||||
}
|
}
|
||||||
|
@ -617,6 +617,7 @@ void CMeterString::BindMeasure(std::list<CMeasure*>& measures)
|
|||||||
throw CError(std::wstring(L"The meter [") + m_Name + L"] cannot be bound with [" + (*j) + L"]!", __LINE__, __FILE__);
|
throw CError(std::wstring(L"The meter [") + m_Name + L"] cannot be bound with [" + (*j) + L"]!", __LINE__, __FILE__);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CMeter::SetAllMeasures(m_Measures);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1985,11 +1985,6 @@ bool CMeterWindow::ReadSkin()
|
|||||||
}
|
}
|
||||||
|
|
||||||
meter->ReadConfig(strSection.c_str());
|
meter->ReadConfig(strSection.c_str());
|
||||||
|
|
||||||
if (!meter->GetToolTipText().empty())
|
|
||||||
{
|
|
||||||
meter->CreateToolTip(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (CError& error)
|
catch (CError& error)
|
||||||
@ -2021,13 +2016,18 @@ bool CMeterWindow::ReadSkin()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Bind the meters to the measures
|
// Bind the meters to the measures and create tooltips
|
||||||
std::list<CMeter*>::const_iterator j = m_Meters.begin();
|
std::list<CMeter*>::const_iterator j = m_Meters.begin();
|
||||||
for( ; j != m_Meters.end(); ++j)
|
for( ; j != m_Meters.end(); ++j)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
(*j)->BindMeasure(m_Measures);
|
(*j)->BindMeasure(m_Measures);
|
||||||
|
|
||||||
|
if (!(*j)->GetToolTipText().empty())
|
||||||
|
{
|
||||||
|
(*j)->CreateToolTip(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (CError& error)
|
catch (CError& error)
|
||||||
{
|
{
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
const int revision_number = 520;
|
const int revision_number = 530;
|
||||||
const bool revision_beta = true;
|
const bool revision_beta = true;
|
Loading…
Reference in New Issue
Block a user