Code cleanup & cosmetics.

This commit is contained in:
spx 2010-10-19 22:03:32 +00:00
parent 71ce46442e
commit db4fac0877
5 changed files with 109 additions and 96 deletions

View File

@ -76,6 +76,10 @@ CMeter::CMeter(CMeterWindow* meterWindow)
*/ */
CMeter::~CMeter() CMeter::~CMeter()
{ {
if (m_ToolTipHandle != NULL)
{
DestroyWindow(m_ToolTipHandle);
}
} }
/* /*
@ -199,8 +203,8 @@ RECT CMeter::GetMeterRect()
meterRect.left = GetX(); meterRect.left = GetX();
meterRect.top = GetY(); meterRect.top = GetY();
meterRect.right = GetX() + m_W; meterRect.right = meterRect.left + m_W;
meterRect.bottom = GetY() + m_H; meterRect.bottom = meterRect.top + m_H;
return meterRect; return meterRect;
} }
@ -220,6 +224,41 @@ bool CMeter::HitTest(int x, int y)
return false; return false;
} }
/*
** Show
**
** Shows the meter and tooltip.
**
*/
void CMeter::Show()
{
m_Hidden = false;
if (m_ToolTipHandle != NULL)
{
if (!m_ToolTipHidden)
{
SendMessage(m_ToolTipHandle, TTM_ACTIVATE, TRUE, NULL);
}
}
}
/*
** Hide
**
** Hides the meter and tooltip.
**
*/
void CMeter::Hide()
{
m_Hidden = true;
if (m_ToolTipHandle != NULL)
{
SendMessage(m_ToolTipHandle, TTM_ACTIVATE, FALSE, NULL);
}
}
/* /*
** ReadConfig ** ReadConfig
** **

View File

@ -43,48 +43,46 @@ public:
bool HasDynamicVariables() { return m_DynamicVariables; } bool HasDynamicVariables() { return m_DynamicVariables; }
virtual int GetH() { return m_Hidden ? 0 : m_H; }; virtual int GetH() { return m_Hidden ? 0 : m_H; }
virtual int GetW() { return m_Hidden ? 0 : m_W; }; virtual int GetW() { return m_Hidden ? 0 : m_W; }
virtual int GetX(bool abs = false); virtual int GetX(bool abs = false);
virtual int GetY(bool abs = false); virtual int GetY(bool abs = false);
RECT GetMeterRect(); RECT GetMeterRect();
void SetX(int x) { m_X = x; m_RelativeX = POSITION_ABSOLUTE; }; void SetX(int x) { m_X = x; m_RelativeX = POSITION_ABSOLUTE; }
void SetY(int y) { m_Y = y; m_RelativeY = POSITION_ABSOLUTE; }; void SetY(int y) { m_Y = y; m_RelativeY = POSITION_ABSOLUTE; }
std::wstring& GetRightMouseDownAction() { return m_RightMouseDownAction; }; std::wstring& GetRightMouseDownAction() { return m_RightMouseDownAction; }
std::wstring& GetRightMouseUpAction() { return m_RightMouseUpAction; }; std::wstring& GetRightMouseUpAction() { return m_RightMouseUpAction; }
std::wstring& GetRightMouseDoubleClickAction() { return m_RightMouseDoubleClickAction; }; std::wstring& GetRightMouseDoubleClickAction() { return m_RightMouseDoubleClickAction; }
std::wstring& GetLeftMouseDownAction() { return m_LeftMouseDownAction; }; std::wstring& GetLeftMouseDownAction() { return m_LeftMouseDownAction; }
std::wstring& GetLeftMouseUpAction() { return m_LeftMouseUpAction; }; std::wstring& GetLeftMouseUpAction() { return m_LeftMouseUpAction; }
std::wstring& GetLeftMouseDoubleClickAction() { return m_LeftMouseDoubleClickAction; }; std::wstring& GetLeftMouseDoubleClickAction() { return m_LeftMouseDoubleClickAction; }
std::wstring& GetMiddleMouseDownAction() { return m_MiddleMouseDownAction; }; std::wstring& GetMiddleMouseDownAction() { return m_MiddleMouseDownAction; }
std::wstring& GetMiddleMouseUpAction() { return m_MiddleMouseUpAction; }; std::wstring& GetMiddleMouseUpAction() { return m_MiddleMouseUpAction; }
std::wstring& GetMiddleMouseDoubleClickAction() { return m_MiddleMouseDoubleClickAction; }; std::wstring& GetMiddleMouseDoubleClickAction() { return m_MiddleMouseDoubleClickAction; }
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(CMeasure* measure);
void SetAllMeasures(std::vector<CMeasure*> measures); void SetAllMeasures(std::vector<CMeasure*> measures);
std::wstring CMeter::ReplaceMeasures(std::wstring source); std::wstring CMeter::ReplaceMeasures(std::wstring source);
const std::wstring& GetToolTipText() { return m_ToolTipText; }; const std::wstring& GetToolTipText() { return m_ToolTipText; }
HWND GetToolTipHandle() { return m_ToolTipHandle; }; bool HasToolTip() { return m_ToolTipHandle != NULL; }
void SetToolTipHandle(HWND handle) { m_ToolTipHandle = handle; }; void SetToolTipHidden(bool b) { m_ToolTipHidden = b; }
void SetToolTipHidden(bool b) { m_ToolTipHidden = b; };
bool IsToolTipHidden() { return m_ToolTipHidden; };
void CreateToolTip(CMeterWindow* meterWindow); void CreateToolTip(CMeterWindow* meterWindow);
void UpdateToolTip(); void UpdateToolTip();
bool HasMouseAction() { return m_HasMouseAction; }; bool HasMouseAction() { return m_HasMouseAction; }
bool HasMouseActionCursor() { return m_MouseActionCursor; }; bool HasMouseActionCursor() { return m_MouseActionCursor; }
void SetMouseActionCursor(bool b) { m_MouseActionCursor = b; }; void SetMouseActionCursor(bool b) { m_MouseActionCursor = b; }
void Hide() { m_Hidden = true; }; virtual void Hide();
void Show() { m_Hidden = false; }; virtual void Show();
bool IsHidden() { return m_Hidden; }; bool IsHidden() { return m_Hidden; }
const Gdiplus::Matrix& GetTransformationMatrix() { return m_Transformation; } const Gdiplus::Matrix& GetTransformationMatrix() { return m_Transformation; }
@ -93,8 +91,8 @@ public:
void SetMouseOver(bool over) { m_MouseOver = over; } void SetMouseOver(bool over) { m_MouseOver = over; }
bool IsMouseOver() { return m_MouseOver; } bool IsMouseOver() { return m_MouseOver; }
void SetName(const WCHAR* name) { m_Name = name; }; void SetName(const WCHAR* name) { m_Name = name; }
const WCHAR* GetName() { return m_Name.c_str(); }; const WCHAR* GetName() { return m_Name.c_str(); }
static CMeter* Create(const WCHAR* meter, CMeterWindow* meterWindow); static CMeter* Create(const WCHAR* meter, CMeterWindow* meterWindow);

View File

@ -333,11 +333,6 @@ void CMeterWindow::Refresh(bool init, bool all)
std::list<CMeter*>::iterator j = m_Meters.begin(); std::list<CMeter*>::iterator j = m_Meters.begin();
for( ; j != m_Meters.end(); ++j) for( ; j != m_Meters.end(); ++j)
{ {
if ((*j)->GetToolTipHandle() != NULL)
{
DestroyWindow((*j)->GetToolTipHandle());
(*j)->SetToolTipHandle(NULL);
}
delete (*j); delete (*j);
} }
m_Meters.clear(); m_Meters.clear();
@ -978,13 +973,6 @@ void CMeterWindow::ShowMeter(const WCHAR* name, bool group)
} }
(*j)->Show(); (*j)->Show();
if ((*j)->GetToolTipHandle() != NULL)
{
if (!(*j)->IsToolTipHidden())
{
SendMessage((*j)->GetToolTipHandle(), TTM_ACTIVATE, TRUE, NULL);
}
}
m_ResetRegion = true; // Need to recalculate the window region m_ResetRegion = true; // Need to recalculate the window region
if (!group) return; if (!group) return;
} }
@ -1015,10 +1003,6 @@ void CMeterWindow::HideMeter(const WCHAR* name, bool group)
} }
(*j)->Hide(); (*j)->Hide();
if ((*j)->GetToolTipHandle() != NULL)
{
SendMessage((*j)->GetToolTipHandle(), TTM_ACTIVATE, FALSE, NULL);
}
m_ResetRegion = true; // Need to recalculate the windowregion m_ResetRegion = true; // Need to recalculate the windowregion
if (!group) return; if (!group) return;
} }
@ -1051,18 +1035,10 @@ void CMeterWindow::ToggleMeter(const WCHAR* name, bool group)
if ((*j)->IsHidden()) if ((*j)->IsHidden())
{ {
(*j)->Show(); (*j)->Show();
if ((*j)->GetToolTipHandle() != NULL)
{
SendMessage((*j)->GetToolTipHandle(), TTM_ACTIVATE, TRUE, NULL);
}
} }
else else
{ {
(*j)->Hide(); (*j)->Hide();
if ((*j)->GetToolTipHandle() != NULL)
{
SendMessage((*j)->GetToolTipHandle(), TTM_ACTIVATE, FALSE, NULL);
}
} }
m_ResetRegion = true; // Need to recalculate the window region m_ResetRegion = true; // Need to recalculate the window region
if (!group) return; if (!group) return;
@ -2495,7 +2471,7 @@ void CMeterWindow::Update(bool nodraw)
} }
// Update tooltips // Update tooltips
if ((*j)->GetToolTipHandle() == NULL) if (!(*j)->HasToolTip())
{ {
if (!(*j)->GetToolTipText().empty()) if (!(*j)->GetToolTipText().empty())
{ {

View File

@ -144,7 +144,7 @@ public:
int Initialize(CRainmeter& Rainmeter); int Initialize(CRainmeter& Rainmeter);
CRainmeter* GetMainObject() { return m_Rainmeter; }; CRainmeter* GetMainObject() { return m_Rainmeter; }
void RunBang(BANGCOMMAND bang, const WCHAR* arg); void RunBang(BANGCOMMAND bang, const WCHAR* arg);
@ -164,17 +164,17 @@ public:
void ChangeZPos(ZPOSITION zPos, bool all = false); void ChangeZPos(ZPOSITION zPos, bool all = false);
void FadeWindow(int from, int to); void FadeWindow(int from, int to);
Gdiplus::Bitmap* GetDoubleBuffer() { return m_DoubleBuffer; }; Gdiplus::Bitmap* GetDoubleBuffer() { return m_DoubleBuffer; }
HWND GetWindow() { return m_Window; }; HWND GetWindow() { return m_Window; }
CConfigParser& GetParser() { return m_Parser; }; CConfigParser& GetParser() { return m_Parser; }
const std::wstring& GetSkinAuthor() { return m_Author; }; const std::wstring& GetSkinAuthor() { return m_Author; }
const std::wstring& GetSkinName() { return m_SkinName; }; const std::wstring& GetSkinName() { return m_SkinName; }
const std::wstring& GetSkinIniFile() { return m_SkinIniFile; }; const std::wstring& GetSkinIniFile() { return m_SkinIniFile; }
std::list<CMeasure*>& GetMeasures() { return m_Measures; }; std::list<CMeasure*>& GetMeasures() { return m_Measures; }
std::list<CMeter*>& GetMeters() { return m_Meters; }; std::list<CMeter*>& GetMeters() { return m_Meters; }
ZPOSITION GetWindowZPosition() { return m_WindowZPosition; } ZPOSITION GetWindowZPosition() { return m_WindowZPosition; }
bool GetXPercentage() { return m_WindowXPercentage; } bool GetXPercentage() { return m_WindowXPercentage; }
@ -205,7 +205,7 @@ public:
std::wstring MakePathAbsolute(std::wstring path); std::wstring MakePathAbsolute(std::wstring path);
Gdiplus::PrivateFontCollection* GetPrivateFontCollection(){ return m_FontCollection; } Gdiplus::PrivateFontCollection* GetPrivateFontCollection() { return m_FontCollection; }
protected: protected:
static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);

View File

@ -142,39 +142,39 @@ public:
int Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath); int Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath);
void Quit(HINSTANCE dllInst); void Quit(HINSTANCE dllInst);
CConfigParser* GetCurrentParser() { return m_CurrentParser; }; CConfigParser* GetCurrentParser() { return m_CurrentParser; }
void SetCurrentParser(CConfigParser* parser) { m_CurrentParser = parser; }; void SetCurrentParser(CConfigParser* parser) { m_CurrentParser = parser; }
CTrayWindow* GetTrayWindow() { return m_TrayWindow; }; CTrayWindow* GetTrayWindow() { return m_TrayWindow; }
CMeterWindow* GetMeterWindow(const std::wstring& config); CMeterWindow* GetMeterWindow(const std::wstring& config);
CMeterWindow* GetMeterWindow(HWND hwnd); CMeterWindow* GetMeterWindow(HWND hwnd);
void GetMeterWindowsByLoadOrder(std::multimap<int, CMeterWindow*>& windows, const std::wstring& group = L""); void GetMeterWindowsByLoadOrder(std::multimap<int, CMeterWindow*>& windows, const std::wstring& group = L"");
std::map<std::wstring, CMeterWindow*>& GetAllMeterWindows() { return m_Meters; }; std::map<std::wstring, CMeterWindow*>& GetAllMeterWindows() { return m_Meters; }
const std::vector<CONFIG>& GetAllConfigs() { return m_ConfigStrings; }; const std::vector<CONFIG>& GetAllConfigs() { return m_ConfigStrings; }
const std::vector<std::wstring>& GetAllThemes() { return m_Themes; }; const std::vector<std::wstring>& GetAllThemes() { return m_Themes; }
void ActivateConfig(int configIndex, int iniIndex); void ActivateConfig(int configIndex, int iniIndex);
bool DeactivateConfig(CMeterWindow* meterWindow, int configIndex); bool DeactivateConfig(CMeterWindow* meterWindow, int configIndex);
const std::wstring& GetPath() { return m_Path; }; const std::wstring& GetPath() { return m_Path; }
const std::wstring& GetIniFile() { return m_IniFile; }; const std::wstring& GetIniFile() { return m_IniFile; }
const std::wstring& GetLogFile() { return m_LogFile; }; const std::wstring& GetLogFile() { return m_LogFile; }
const std::wstring& GetSkinPath() { return m_SkinPath; }; const std::wstring& GetSkinPath() { return m_SkinPath; }
const std::wstring& GetPluginPath() { return m_PluginPath; }; const std::wstring& GetPluginPath() { return m_PluginPath; }
std::wstring GetSettingsPath() { return ExtractPath(m_IniFile); }; std::wstring GetSettingsPath() { return ExtractPath(m_IniFile); }
const std::wstring& GetConfigEditor() { return m_ConfigEditor; }; const std::wstring& GetConfigEditor() { return m_ConfigEditor; }
const std::wstring& GetLogViewer() { return m_LogViewer; }; const std::wstring& GetLogViewer() { return m_LogViewer; }
const std::wstring& GetStatsDate() { return m_StatsDate; }; const std::wstring& GetStatsDate() { return m_StatsDate; }
HINSTANCE GetInstance() { return m_Instance; }; HINSTANCE GetInstance() { return m_Instance; }
static void SetDummyLitestep(bool Dummy) { c_DummyLitestep = Dummy; }; static void SetDummyLitestep(bool Dummy) { c_DummyLitestep = Dummy; }
static bool GetDummyLitestep() { return c_DummyLitestep; }; static bool GetDummyLitestep() { return c_DummyLitestep; }
static void SetCommandLine(LPCTSTR CmdLine) { c_CmdLine = CmdLine;}; static void SetCommandLine(LPCTSTR CmdLine) { c_CmdLine = CmdLine;}
static LPCTSTR GetCommandLine() { return c_CmdLine.c_str(); }; static LPCTSTR GetCommandLine() { return c_CmdLine.c_str(); }
static GlobalConfig& GetGlobalConfig() { return c_GlobalConfig; }; static GlobalConfig& GetGlobalConfig() { return c_GlobalConfig; }
static bool GetDebug() { return c_Debug; } static bool GetDebug() { return c_Debug; }
@ -186,10 +186,10 @@ public:
void WriteStats(bool bForce); void WriteStats(bool bForce);
void ResetStats(); void ResetStats();
BOOL GetDisableVersionCheck() { return m_DisableVersionCheck; }; BOOL GetDisableVersionCheck() { return m_DisableVersionCheck; }
BOOL GetNewVersion() { return m_NewVersion; }; BOOL GetNewVersion() { return m_NewVersion; }
void SetDisableVersionCheck(BOOL check) { m_DisableVersionCheck = check; }; void SetDisableVersionCheck(BOOL check) { m_DisableVersionCheck = check; }
void SetNewVersion(BOOL NewVer) { m_NewVersion = NewVer; }; void SetNewVersion(BOOL NewVer) { m_NewVersion = NewVer; }
bool GetLogging() { return m_Logging; } bool GetLogging() { return m_Logging; }
void StartLogging(); void StartLogging();
@ -204,12 +204,12 @@ public:
bool IsMenuActive() { return m_MenuActive; } bool IsMenuActive() { return m_MenuActive; }
void ShowContextMenu(POINT pos, CMeterWindow* meterWindow); void ShowContextMenu(POINT pos, CMeterWindow* meterWindow);
std::wstring GetTrayExecuteL() { return m_TrayExecuteL; }; std::wstring GetTrayExecuteL() { return m_TrayExecuteL; }
std::wstring GetTrayExecuteR() { return m_TrayExecuteR; }; std::wstring GetTrayExecuteR() { return m_TrayExecuteR; }
std::wstring GetTrayExecuteM() { return m_TrayExecuteM; }; std::wstring GetTrayExecuteM() { return m_TrayExecuteM; }
std::wstring GetTrayExecuteDR() { return m_TrayExecuteDR; }; std::wstring GetTrayExecuteDR() { return m_TrayExecuteDR; }
std::wstring GetTrayExecuteDL() { return m_TrayExecuteDL; }; std::wstring GetTrayExecuteDL() { return m_TrayExecuteDL; }
std::wstring GetTrayExecuteDM() { return m_TrayExecuteDM; }; std::wstring GetTrayExecuteDM() { return m_TrayExecuteDM; }
BOOL ExecuteBang(const std::wstring& bang, const std::wstring& arg, CMeterWindow* meterWindow); BOOL ExecuteBang(const std::wstring& bang, const std::wstring& arg, CMeterWindow* meterWindow);
std::wstring ParseCommand(const WCHAR* command, CMeterWindow* meterWindow); std::wstring ParseCommand(const WCHAR* command, CMeterWindow* meterWindow);