aboutsummaryrefslogtreecommitdiff
path: root/Src/external_dependencies/openmpt-trunk/mptrack/UpdateToolTip.cpp
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/external_dependencies/openmpt-trunk/mptrack/UpdateToolTip.cpp
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/external_dependencies/openmpt-trunk/mptrack/UpdateToolTip.cpp')
-rw-r--r--Src/external_dependencies/openmpt-trunk/mptrack/UpdateToolTip.cpp90
1 files changed, 90 insertions, 0 deletions
diff --git a/Src/external_dependencies/openmpt-trunk/mptrack/UpdateToolTip.cpp b/Src/external_dependencies/openmpt-trunk/mptrack/UpdateToolTip.cpp
new file mode 100644
index 00000000..2045f40e
--- /dev/null
+++ b/Src/external_dependencies/openmpt-trunk/mptrack/UpdateToolTip.cpp
@@ -0,0 +1,90 @@
+/*
+ * UpdateToolTip.cpp
+ * -----------------
+ * Purpose: Implementation of the update tooltip in the main toolbar.
+ * Notes : (currently none)
+ * Authors: OpenMPT Devs
+ * The OpenMPT source code is released under the BSD license. Read LICENSE for more details.
+ */
+
+
+#include "stdafx.h"
+#include "Mptrack.h"
+#include "Mainfrm.h"
+
+
+OPENMPT_NAMESPACE_BEGIN
+
+
+BEGIN_MESSAGE_MAP(UpdateToolTip, CToolTipCtrl)
+ ON_WM_LBUTTONUP()
+ ON_NOTIFY_REFLECT(TTN_POP, &UpdateToolTip::OnPop)
+ ON_NOTIFY_REFLECT(TTN_SHOW, &UpdateToolTip::OnShow)
+ ON_NOTIFY_REFLECT(TTN_LINKCLICK, &UpdateToolTip::OnLinkClick)
+END_MESSAGE_MAP()
+
+
+bool UpdateToolTip::ShowUpdate(CWnd &parent, const CString &newVersion, const CString &infoURL, const CRect rectClient, const CPoint ptScreen, const int buttonID)
+{
+ if(m_hWnd)
+ DestroyWindow();
+ Create(&parent, TTS_NOPREFIX | TTS_BALLOON | TTS_CLOSE | TTS_NOFADE);
+
+ m_infoURL = infoURL;
+
+ CString message = MPT_CFORMAT("OpenMPT {} has been released.\n<a>Click here to see what's new.</a>")(newVersion);
+ TOOLINFO ti{};
+ ti.cbSize = TTTOOLINFO_V1_SIZE;
+ ti.uFlags = TTF_TRACK | TTF_PARSELINKS;
+ ti.hwnd = parent;
+ ti.lpszText = message.GetBuffer();
+ ti.uId = buttonID;
+ ti.rect = rectClient;
+ if(!SendMessage(TTM_ADDTOOL, 0, reinterpret_cast<LPARAM>(&ti)))
+ return false;
+
+ SetTitle(TTI_INFO, _T("Update Available"));
+ SendMessage(TTM_TRACKPOSITION, 0, static_cast<LPARAM>(MAKELONG(ptScreen.x, ptScreen.y)));
+ SendMessage(TTM_TRACKACTIVATE, TRUE, reinterpret_cast<LPARAM>(&ti));
+ return true;
+}
+
+
+void UpdateToolTip::SetResult(PopAction action)
+{
+ m_popAction = action;
+ SendMessage(TTM_TRACKACTIVATE, FALSE, 0);
+ if(action != PopAction::CloseButton)
+ CMainFrame::GetMainFrame()->SendMessage(WM_MOD_UPDATENOTIFY, static_cast<WPARAM>(action));
+}
+
+
+void UpdateToolTip::OnLButtonUp(UINT nFlags, CPoint point)
+{
+ CToolTipCtrl::OnLButtonUp(nFlags, point);
+ if(m_popAction == PopAction::Undetermined)
+ SetResult(PopAction::ClickBubble);
+}
+
+
+void UpdateToolTip::OnPop(NMHDR *pNMHDR, LRESULT *)
+{
+ if(pNMHDR->idFrom == UINT_PTR(-1))
+ SetResult(PopAction::CloseButton);
+}
+
+
+void UpdateToolTip::OnShow(NMHDR *, LRESULT *)
+{
+ m_popAction = PopAction::Undetermined;
+}
+
+
+void UpdateToolTip::OnLinkClick(NMHDR *, LRESULT *)
+{
+ CTrackApp::OpenURL(m_infoURL);
+ SetResult(PopAction::ClickLink);
+}
+
+
+OPENMPT_NAMESPACE_END