From: <sag...@us...> - 2015-05-24 22:10:43
|
Revision: 5155 http://sourceforge.net/p/modplug/code/5155 Author: saga-games Date: 2015-05-24 22:10:36 +0000 (Sun, 24 May 2015) Log Message: ----------- [Ref] Clean up tooltip-related code Modified Paths: -------------- trunk/OpenMPT/mptrack/CleanupSong.cpp trunk/OpenMPT/mptrack/CleanupSong.h trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp trunk/OpenMPT/mptrack/dlg_misc.cpp Modified: trunk/OpenMPT/mptrack/CleanupSong.cpp =================================================================== --- trunk/OpenMPT/mptrack/CleanupSong.cpp 2015-05-24 21:48:08 UTC (rev 5154) +++ trunk/OpenMPT/mptrack/CleanupSong.cpp 2015-05-24 22:10:36 UTC (rev 5155) @@ -10,7 +10,7 @@ #include "stdafx.h" -#include "moddoc.h" +#include "Moddoc.h" #include "Mainfrm.h" #include "modsmp_ctrl.h" #include "CleanupSong.h" @@ -91,8 +91,7 @@ ON_COMMAND(IDC_CHK_REMOVE_PLUGINS, OnVerifyMutualExclusive) ON_COMMAND(IDC_CHK_RESET_VARIABLES, OnVerifyMutualExclusive) - ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, &CModCleanupDlg::OnToolTipNotify) - ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, &CModCleanupDlg::OnToolTipNotify) + ON_NOTIFY_EX(TTN_NEEDTEXT, 0, OnToolTipNotify) //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -171,13 +170,6 @@ } -void CModCleanupDlg::OnCancel() -//----------------------------- -{ - CDialog::OnCancel(); -} - - void CModCleanupDlg::OnVerifyMutualExclusive() //-------------------------------------------- { @@ -258,19 +250,12 @@ } -BOOL CModCleanupDlg::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult) -//---------------------------------------------------------------------------- +BOOL CModCleanupDlg::OnToolTipNotify(UINT, NMHDR *pNMHDR, LRESULT *) +//------------------------------------------------------------------ { - MPT_UNREFERENCED_PARAMETER(id); - MPT_UNREFERENCED_PARAMETER(pResult); - - // need to handle both ANSI and UNICODE versions of the message - TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR; - TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR; - CStringA strTipText = ""; + TOOLTIPTEXT* pTTT = (TOOLTIPTEXTA*)pNMHDR; UINT_PTR nID = pNMHDR->idFrom; - if (pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) || - pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND)) + if (pTTT->uFlags & TTF_IDISHWND) { // idFrom is actually the HWND of the tool nID = ::GetDlgCtrlID((HWND)nID); @@ -280,66 +265,56 @@ { // patterns case IDC_CHK_CLEANUP_PATTERNS: - strTipText = "Remove all unused patterns and rearrange them."; + pTTT->lpszText = _T("Remove all unused patterns and rearrange them."); break; case IDC_CHK_REMOVE_PATTERNS: - strTipText = "Remove all patterns."; + pTTT->lpszText = _T("Remove all patterns."); break; case IDC_CHK_REARRANGE_PATTERNS: - strTipText = "Number the patterns given by their order in the sequence."; + pTTT->lpszText = _T("Number the patterns given by their order in the sequence."); break; // orders case IDC_CHK_REMOVE_ORDERS: - strTipText = "Reset the order list."; + pTTT->lpszText = _T("Reset the order list."); break; case IDC_CHK_MERGE_SEQUENCES: - strTipText = "Merge multiple sequences into one."; + pTTT->lpszText = _T("Merge multiple sequences into one."); break; // samples case IDC_CHK_CLEANUP_SAMPLES: - strTipText = "Remove all unused samples."; + pTTT->lpszText = _T("Remove all unused samples."); break; case IDC_CHK_REMOVE_SAMPLES: - strTipText = "Remove all samples."; + pTTT->lpszText = _T("Remove all samples."); break; case IDC_CHK_REARRANGE_SAMPLES: - strTipText = "Reorder sample list by removing empty samples."; + pTTT->lpszText = _T("Reorder sample list by removing empty samples."); break; case IDC_CHK_OPTIMIZE_SAMPLES: - strTipText = "Remove unused data after the sample loop end."; + pTTT->lpszText = _T("Remove unused data after the sample loop end."); break; // instruments case IDC_CHK_CLEANUP_INSTRUMENTS: - strTipText = "Remove all unused instruments."; + pTTT->lpszText = _T("Remove all unused instruments."); break; case IDC_CHK_REMOVE_INSTRUMENTS: - strTipText = "Remove all instruments and convert them to samples."; + pTTT->lpszText = _T("Remove all instruments and convert them to samples."); break; // plugins case IDC_CHK_CLEANUP_PLUGINS: - strTipText = "Remove all unused plugins."; + pTTT->lpszText = _T("Remove all unused plugins."); break; case IDC_CHK_REMOVE_PLUGINS: - strTipText = "Remove all plugins."; + pTTT->lpszText = _T("Remove all plugins."); break; // misc case IDC_CHK_SAMPLEPACK: - strTipText = "Convert the module to .IT and reset song / sample / instrument variables"; + pTTT->lpszText = _T("Convert the module to .IT and reset song / sample / instrument variables"); break; + default: + pTTT->lpszText = _T(""); + break; } - - if (pNMHDR->code == TTN_NEEDTEXTA) - { - //strncpy_s(pTTTA->szText, sizeof(pTTTA->szText), strTipText, - // strTipText.GetLength() + 1); - mpt::String::CopyN(pTTTA->szText, strTipText); - } - else - { - ::MultiByteToWideChar(CP_ACP , 0, strTipText, strTipText.GetLength() + 1, - pTTTW->szText, CountOf(pTTTW->szText)); - } - return TRUE; } @@ -626,14 +601,10 @@ } } - if(sample.nLength > loopLength + 2) + if(sample.nLength > loopLength && loopLength >= 2) { - SmpLength lmax = loopLength + 2; - if(lmax < sample.nLength && lmax >= 2) - { - modDoc.GetSampleUndo().PrepareUndo(smp, sundo_delete, "Trim Unused Data", lmax, sample.nLength); - ctrlSmp::ResizeSample(sample, lmax, sndFile); - } + modDoc.GetSampleUndo().PrepareUndo(smp, sundo_delete, "Trim Unused Data", loopLength, sample.nLength); + ctrlSmp::ResizeSample(sample, loopLength, sndFile); } // Convert stereo samples with identical channels to mono Modified: trunk/OpenMPT/mptrack/CleanupSong.h =================================================================== --- trunk/OpenMPT/mptrack/CleanupSong.h 2015-05-24 21:48:08 UTC (rev 5154) +++ trunk/OpenMPT/mptrack/CleanupSong.h 2015-05-24 22:10:36 UTC (rev 5155) @@ -78,7 +78,6 @@ //{{AFX_VIRTUAL(CModCleanupDlg) virtual BOOL OnInitDialog(); virtual void OnOK(); - virtual void OnCancel(); //}}AFX_VIRTUAL BOOL OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult); Modified: trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp 2015-05-24 21:48:08 UTC (rev 5154) +++ trunk/OpenMPT/mptrack/MIDIMappingDialog.cpp 2015-05-24 22:10:36 UTC (rev 5155) @@ -70,8 +70,7 @@ ON_NOTIFY(UDN_DELTAPOS, IDC_SPINMOVEMAPPING, OnDeltaposSpinmovemapping) ON_BN_CLICKED(IDC_CHECK_PATRECORD, OnBnClickedCheckPatRecord) - ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, &CMIDIMappingDialog::OnToolTipNotify) - ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, &CMIDIMappingDialog::OnToolTipNotify) + ON_NOTIFY_EX(TTN_NEEDTEXT, 0, OnToolTipNotify) END_MESSAGE_MAP() @@ -461,19 +460,13 @@ } -BOOL CMIDIMappingDialog::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult) -//-------------------------------------------------------------------------------- +BOOL CMIDIMappingDialog::OnToolTipNotify(UINT, NMHDR * pNMHDR, LRESULT *) +//----------------------------------------------------------------------- { - MPT_UNREFERENCED_PARAMETER(id); - MPT_UNREFERENCED_PARAMETER(pResult); - - // need to handle both ANSI and UNICODE versions of the message - TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR; - TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR; - const char *strTipText = ""; + TOOLTIPTEXT *pTTT = (TOOLTIPTEXTA*)pNMHDR; + const TCHAR *text = _T(""); UINT_PTR nID = pNMHDR->idFrom; - if(pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) || - pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND)) + if(pTTT->uFlags & TTF_IDISHWND) { // idFrom is actually the HWND of the tool nID = ::GetDlgCtrlID((HWND)nID); @@ -482,32 +475,23 @@ switch(nID) { case IDC_CHECKCAPTURE: - strTipText = "The event is not passed to any further MIDI mappings or recording facilities."; + text = _T("The event is not passed to any further MIDI mappings or recording facilities."); break; case IDC_CHECKACTIVE: - strTipText = "The MIDI mapping is enabled and can be procssed."; + text = _T("The MIDI mapping is enabled and can be procssed."); break; case IDC_CHECK_PATRECORD: - strTipText = "Parameter changes are recorded into patterns as Parameter Control events."; + text = _T("Parameter changes are recorded into patterns as Parameter Control events."); break; case IDC_CHECK_MIDILEARN: - strTipText = "Listens to incoming MIDI data to automatically fill in the appropriate data."; + text = _T("Listens to incoming MIDI data to automatically fill in the appropriate data."); break; case IDC_SPINMOVEMAPPING: - strTipText = "Change the processing order of the current selected MIDI mapping."; + text = _T("Change the processing order of the current selected MIDI mapping."); break; } - if(pNMHDR->code == TTN_NEEDTEXTA) - { - // 80 chars max?! - mpt::String::CopyN(pTTTA->szText, strTipText); - } else - { - ::MultiByteToWideChar(CP_ACP , 0, strTipText, strlen(strTipText) + 1, - pTTTW->szText, CountOf(pTTTW->szText)); - } - + mpt::String::CopyN(pTTT->szText, text); return TRUE; } Modified: trunk/OpenMPT/mptrack/dlg_misc.cpp =================================================================== --- trunk/OpenMPT/mptrack/dlg_misc.cpp 2015-05-24 21:48:08 UTC (rev 5154) +++ trunk/OpenMPT/mptrack/dlg_misc.cpp 2015-05-24 22:10:36 UTC (rev 5155) @@ -33,8 +33,7 @@ ON_CBN_SELCHANGE(IDC_COMBO1, UpdateDialog) ON_COMMAND(IDC_CHECK_PT1X, OnPTModeChanged) - ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, &CModTypeDlg::OnToolTipNotify) - ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, &CModTypeDlg::OnToolTipNotify) + ON_NOTIFY_EX(TTN_NEEDTEXT, 0, OnToolTipNotify) //}}AFX_MSG_MAP @@ -363,19 +362,13 @@ } -BOOL CModTypeDlg::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult) -//------------------------------------------------------------------------- +BOOL CModTypeDlg::OnToolTipNotify(UINT, NMHDR *pNMHDR, LRESULT *) +//--------------------------------------------------------------- { - MPT_UNREFERENCED_PARAMETER(id); - MPT_UNREFERENCED_PARAMETER(pResult); - - // need to handle both ANSI and UNICODE versions of the message - TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR; - TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR; - CStringA strTipText = ""; + TOOLTIPTEXT *pTTT = (TOOLTIPTEXTA*)pNMHDR; + const TCHAR *text = _T(""); UINT_PTR nID = pNMHDR->idFrom; - if(pNMHDR->code == TTN_NEEDTEXTA && (pTTTA->uFlags & TTF_IDISHWND) || - pNMHDR->code == TTN_NEEDTEXTW && (pTTTW->uFlags & TTF_IDISHWND)) + if(pTTT->uFlags & TTF_IDISHWND) { // idFrom is actually the HWND of the tool nID = ::GetDlgCtrlID((HWND)nID); @@ -384,56 +377,47 @@ switch(nID) { case IDC_CHECK1: - strTipText = "Note slides always slide the same amount, not depending on the sample frequency."; + text = _T("Note slides always slide the same amount, not depending on the sample frequency."); break; case IDC_CHECK2: - strTipText = "Old ScreamTracker 3 volume slide behaviour (not recommended)."; + text = _T("Old ScreamTracker 3 volume slide behaviour (not recommended)."); break; case IDC_CHECK3: - strTipText = "Play some effects like in early versions of Impulse Tracker (not recommended)."; + text = _T("Play some effects like in early versions of Impulse Tracker (not recommended)."); break; case IDC_CHECK4: - strTipText = "Gxx and Exx/Fxx won't share effect memory. Gxx resets instrument envelopes."; + text = _T("Gxx and Exx/Fxx won't share effect memory. Gxx resets instrument envelopes."); break; case IDC_CHECK5: - strTipText = "The resonant filter's frequency range is increased from about 5KHz to 10KHz."; + text = _T("The resonant filter's frequency range is increased from about 5KHz to 10KHz."); break; case IDC_CHECK6: - strTipText = "The instrument settings of the external ITI files will be ignored."; + text = _T("The instrument settings of the external ITI files will be ignored."); break; case IDC_CHECK_PT1X: - strTipText = "Ignore pan fx, use on-the-fly sample swapping, enforce Amiga frequency limits."; + text = _T("Ignore pan fx, use on-the-fly sample swapping, enforce Amiga frequency limits."); break; case IDC_COMBO_MIXLEVELS: - strTipText = "Mixing method of sample and VST levels."; + text = _T("Mixing method of sample and VST levels."); break; case IDC_CHK_COMPATPLAY: - strTipText = "Play commands as the original tracker would play them (recommended)"; + text = _T("Play commands as the original tracker would play them (recommended)"); break; case IDC_CHK_MIDICCBUG: - strTipText = "Emulate an old bug which sent wrong volume messages to VSTis (not recommended)"; + text = _T("Emulate an old bug which sent wrong volume messages to VSTis (not recommended)"); break; case IDC_CHK_OLDRANDOM: - strTipText = "Use old (buggy) random volume / panning variation algorithm (not recommended)"; + text = _T("Use old (buggy) random volume / panning variation algorithm (not recommended)"); break; case IDC_CHK_OLDPITCH: - strTipText = "Use old (imprecise) portamento logic for instrument plugins (not recommended)"; + text = _T("Use old (imprecise) portamento logic for instrument plugins (not recommended)"); break; case IDC_CHK_FT2VOLRAMP: - strTipText = "Use Fasttracker 2 style super soft volume ramping (recommended for true compatible playback)"; + text = _T("Use Fasttracker 2 style super soft volume ramping (recommended for true compatible playback)"); break; } - if(pNMHDR->code == TTN_NEEDTEXTA) - { - // 80 chars max?! - mpt::String::CopyN(pTTTA->szText, strTipText); - } else - { - ::MultiByteToWideChar(CP_ACP , 0, strTipText, strTipText.GetLength() + 1, - pTTTW->szText, CountOf(pTTTW->szText)); - } - + mpt::String::CopyN(pTTT->szText, text); return TRUE; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |