diff --git a/Library/Meter.cpp b/Library/Meter.cpp index 6395b528..74b5b991 100644 --- a/Library/Meter.cpp +++ b/Library/Meter.cpp @@ -76,6 +76,10 @@ CMeter::CMeter(CMeterWindow* meterWindow) */ CMeter::~CMeter() { + if (m_ToolTipHandle != NULL) + { + DestroyWindow(m_ToolTipHandle); + } } /* @@ -199,8 +203,8 @@ RECT CMeter::GetMeterRect() meterRect.left = GetX(); meterRect.top = GetY(); - meterRect.right = GetX() + m_W; - meterRect.bottom = GetY() + m_H; + meterRect.right = meterRect.left + m_W; + meterRect.bottom = meterRect.top + m_H; return meterRect; } @@ -220,6 +224,41 @@ bool CMeter::HitTest(int x, int y) 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 ** diff --git a/Library/Meter.h b/Library/Meter.h index 45c64226..0f16c7c8 100644 --- a/Library/Meter.h +++ b/Library/Meter.h @@ -43,48 +43,46 @@ public: bool HasDynamicVariables() { return m_DynamicVariables; } - virtual int GetH() { return m_Hidden ? 0 : m_H; }; - virtual int GetW() { return m_Hidden ? 0 : m_W; }; + 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); RECT GetMeterRect(); - void SetX(int x) { m_X = x; m_RelativeX = POSITION_ABSOLUTE; }; - void SetY(int y) { m_Y = y; m_RelativeY = POSITION_ABSOLUTE; }; + 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& GetRightMouseDoubleClickAction() { return m_RightMouseDoubleClickAction; }; - std::wstring& GetLeftMouseDownAction() { return m_LeftMouseDownAction; }; - std::wstring& GetLeftMouseUpAction() { return m_LeftMouseUpAction; }; - std::wstring& GetLeftMouseDoubleClickAction() { return m_LeftMouseDoubleClickAction; }; - std::wstring& GetMiddleMouseDownAction() { return m_MiddleMouseDownAction; }; - std::wstring& GetMiddleMouseUpAction() { return m_MiddleMouseUpAction; }; - std::wstring& GetMiddleMouseDoubleClickAction() { return m_MiddleMouseDoubleClickAction; }; - std::wstring& GetMouseOverAction() { return m_MouseOverAction; }; - std::wstring& GetMouseLeaveAction() { return m_MouseLeaveAction; }; + std::wstring& GetRightMouseDownAction() { return m_RightMouseDownAction; } + std::wstring& GetRightMouseUpAction() { return m_RightMouseUpAction; } + std::wstring& GetRightMouseDoubleClickAction() { return m_RightMouseDoubleClickAction; } + std::wstring& GetLeftMouseDownAction() { return m_LeftMouseDownAction; } + std::wstring& GetLeftMouseUpAction() { return m_LeftMouseUpAction; } + std::wstring& GetLeftMouseDoubleClickAction() { return m_LeftMouseDoubleClickAction; } + std::wstring& GetMiddleMouseDownAction() { return m_MiddleMouseDownAction; } + std::wstring& GetMiddleMouseUpAction() { return m_MiddleMouseUpAction; } + std::wstring& GetMiddleMouseDoubleClickAction() { return m_MiddleMouseDoubleClickAction; } + std::wstring& GetMouseOverAction() { return m_MouseOverAction; } + std::wstring& GetMouseLeaveAction() { return m_MouseLeaveAction; } void SetAllMeasures(CMeasure* measure); void SetAllMeasures(std::vector measures); std::wstring CMeter::ReplaceMeasures(std::wstring source); - const std::wstring& GetToolTipText() { return m_ToolTipText; }; - HWND GetToolTipHandle() { return m_ToolTipHandle; }; - void SetToolTipHandle(HWND handle) { m_ToolTipHandle = handle; }; - void SetToolTipHidden(bool b) { m_ToolTipHidden = b; }; - bool IsToolTipHidden() { return m_ToolTipHidden; }; + const std::wstring& GetToolTipText() { return m_ToolTipText; } + bool HasToolTip() { return m_ToolTipHandle != NULL; } + void SetToolTipHidden(bool b) { m_ToolTipHidden = b; } void CreateToolTip(CMeterWindow* meterWindow); void UpdateToolTip(); - bool HasMouseAction() { return m_HasMouseAction; }; - bool HasMouseActionCursor() { return m_MouseActionCursor; }; - void SetMouseActionCursor(bool b) { m_MouseActionCursor = b; }; + bool HasMouseAction() { return m_HasMouseAction; } + bool HasMouseActionCursor() { return m_MouseActionCursor; } + void SetMouseActionCursor(bool b) { m_MouseActionCursor = b; } - void Hide() { m_Hidden = true; }; - void Show() { m_Hidden = false; }; - bool IsHidden() { return m_Hidden; }; + virtual void Hide(); + virtual void Show(); + bool IsHidden() { return m_Hidden; } const Gdiplus::Matrix& GetTransformationMatrix() { return m_Transformation; } @@ -93,8 +91,8 @@ public: 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(); }; + void SetName(const WCHAR* name) { m_Name = name; } + const WCHAR* GetName() { return m_Name.c_str(); } static CMeter* Create(const WCHAR* meter, CMeterWindow* meterWindow); diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index 205e21d8..d69cbb4e 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -333,11 +333,6 @@ void CMeterWindow::Refresh(bool init, bool all) std::list::iterator j = m_Meters.begin(); for( ; j != m_Meters.end(); ++j) { - if ((*j)->GetToolTipHandle() != NULL) - { - DestroyWindow((*j)->GetToolTipHandle()); - (*j)->SetToolTipHandle(NULL); - } delete (*j); } m_Meters.clear(); @@ -978,13 +973,6 @@ void CMeterWindow::ShowMeter(const WCHAR* name, bool group) } (*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 if (!group) return; } @@ -1015,10 +1003,6 @@ void CMeterWindow::HideMeter(const WCHAR* name, bool group) } (*j)->Hide(); - if ((*j)->GetToolTipHandle() != NULL) - { - SendMessage((*j)->GetToolTipHandle(), TTM_ACTIVATE, FALSE, NULL); - } m_ResetRegion = true; // Need to recalculate the windowregion if (!group) return; } @@ -1051,18 +1035,10 @@ void CMeterWindow::ToggleMeter(const WCHAR* name, bool group) if ((*j)->IsHidden()) { (*j)->Show(); - if ((*j)->GetToolTipHandle() != NULL) - { - SendMessage((*j)->GetToolTipHandle(), TTM_ACTIVATE, TRUE, NULL); - } } else { (*j)->Hide(); - if ((*j)->GetToolTipHandle() != NULL) - { - SendMessage((*j)->GetToolTipHandle(), TTM_ACTIVATE, FALSE, NULL); - } } m_ResetRegion = true; // Need to recalculate the window region if (!group) return; @@ -2495,7 +2471,7 @@ void CMeterWindow::Update(bool nodraw) } // Update tooltips - if ((*j)->GetToolTipHandle() == NULL) + if (!(*j)->HasToolTip()) { if (!(*j)->GetToolTipText().empty()) { diff --git a/Library/MeterWindow.h b/Library/MeterWindow.h index 5ebc70a5..e783e77c 100644 --- a/Library/MeterWindow.h +++ b/Library/MeterWindow.h @@ -144,7 +144,7 @@ public: int Initialize(CRainmeter& Rainmeter); - CRainmeter* GetMainObject() { return m_Rainmeter; }; + CRainmeter* GetMainObject() { return m_Rainmeter; } void RunBang(BANGCOMMAND bang, const WCHAR* arg); @@ -164,17 +164,17 @@ public: void ChangeZPos(ZPOSITION zPos, bool all = false); void FadeWindow(int from, int to); - Gdiplus::Bitmap* GetDoubleBuffer() { return m_DoubleBuffer; }; - HWND GetWindow() { return m_Window; }; + Gdiplus::Bitmap* GetDoubleBuffer() { return m_DoubleBuffer; } + 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& GetSkinName() { return m_SkinName; }; - const std::wstring& GetSkinIniFile() { return m_SkinIniFile; }; + const std::wstring& GetSkinAuthor() { return m_Author; } + const std::wstring& GetSkinName() { return m_SkinName; } + const std::wstring& GetSkinIniFile() { return m_SkinIniFile; } - std::list& GetMeasures() { return m_Measures; }; - std::list& GetMeters() { return m_Meters; }; + std::list& GetMeasures() { return m_Measures; } + std::list& GetMeters() { return m_Meters; } ZPOSITION GetWindowZPosition() { return m_WindowZPosition; } bool GetXPercentage() { return m_WindowXPercentage; } @@ -205,7 +205,7 @@ public: std::wstring MakePathAbsolute(std::wstring path); - Gdiplus::PrivateFontCollection* GetPrivateFontCollection(){ return m_FontCollection; } + Gdiplus::PrivateFontCollection* GetPrivateFontCollection() { return m_FontCollection; } protected: static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); diff --git a/Library/Rainmeter.h b/Library/Rainmeter.h index f1a11b33..c94b3188 100644 --- a/Library/Rainmeter.h +++ b/Library/Rainmeter.h @@ -142,39 +142,39 @@ public: int Initialize(HWND Parent, HINSTANCE Instance, LPCSTR szPath); void Quit(HINSTANCE dllInst); - CConfigParser* GetCurrentParser() { return m_CurrentParser; }; - void SetCurrentParser(CConfigParser* parser) { m_CurrentParser = parser; }; + CConfigParser* GetCurrentParser() { return m_CurrentParser; } + 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(HWND hwnd); void GetMeterWindowsByLoadOrder(std::multimap& windows, const std::wstring& group = L""); - std::map& GetAllMeterWindows() { return m_Meters; }; - const std::vector& GetAllConfigs() { return m_ConfigStrings; }; - const std::vector& GetAllThemes() { return m_Themes; }; + std::map& GetAllMeterWindows() { return m_Meters; } + const std::vector& GetAllConfigs() { return m_ConfigStrings; } + const std::vector& GetAllThemes() { return m_Themes; } 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& GetLogFile() { return m_LogFile; }; - const std::wstring& GetSkinPath() { return m_SkinPath; }; - const std::wstring& GetPluginPath() { return m_PluginPath; }; - std::wstring GetSettingsPath() { return ExtractPath(m_IniFile); }; + const std::wstring& GetPath() { return m_Path; } + const std::wstring& GetIniFile() { return m_IniFile; } + const std::wstring& GetLogFile() { return m_LogFile; } + const std::wstring& GetSkinPath() { return m_SkinPath; } + const std::wstring& GetPluginPath() { return m_PluginPath; } + std::wstring GetSettingsPath() { return ExtractPath(m_IniFile); } - const std::wstring& GetConfigEditor() { return m_ConfigEditor; }; - const std::wstring& GetLogViewer() { return m_LogViewer; }; - const std::wstring& GetStatsDate() { return m_StatsDate; }; + const std::wstring& GetConfigEditor() { return m_ConfigEditor; } + const std::wstring& GetLogViewer() { return m_LogViewer; } + 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 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; }; + 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; } static bool GetDebug() { return c_Debug; } @@ -186,10 +186,10 @@ public: void WriteStats(bool bForce); void ResetStats(); - BOOL GetDisableVersionCheck() { return m_DisableVersionCheck; }; - BOOL GetNewVersion() { return m_NewVersion; }; - void SetDisableVersionCheck(BOOL check) { m_DisableVersionCheck = check; }; - void SetNewVersion(BOOL NewVer) { m_NewVersion = NewVer; }; + BOOL GetDisableVersionCheck() { return m_DisableVersionCheck; } + BOOL GetNewVersion() { return m_NewVersion; } + void SetDisableVersionCheck(BOOL check) { m_DisableVersionCheck = check; } + void SetNewVersion(BOOL NewVer) { m_NewVersion = NewVer; } bool GetLogging() { return m_Logging; } void StartLogging(); @@ -204,12 +204,12 @@ public: bool IsMenuActive() { return m_MenuActive; } 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; }; + 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);