From: <sag...@us...> - 2015-05-23 15:10:20
|
Revision: 5143 http://sourceforge.net/p/modplug/code/5143 Author: saga-games Date: 2015-05-23 15:10:15 +0000 (Sat, 23 May 2015) Log Message: ----------- [Imp] Main bar: Add dropdown menus to "New" and "MIDI Record" buttons to select file type and MIDI device respectively. Modified Paths: -------------- trunk/OpenMPT/mptrack/Mainbar.cpp trunk/OpenMPT/mptrack/Mainbar.h trunk/OpenMPT/mptrack/resource.h Modified: trunk/OpenMPT/mptrack/Mainbar.cpp =================================================================== --- trunk/OpenMPT/mptrack/Mainbar.cpp 2015-05-23 11:19:36 UTC (rev 5142) +++ trunk/OpenMPT/mptrack/Mainbar.cpp 2015-05-23 15:10:15 UTC (rev 5143) @@ -223,8 +223,13 @@ }; +enum { MAX_MIDI_DEVICES = 256}; + BEGIN_MESSAGE_MAP(CMainToolBar, CToolBarEx) ON_WM_VSCROLL() + //ON_NOTIFY(TBN_DROPDOWN, OnTbnDropDownToolBar) + ON_NOTIFY_REFLECT(TBN_DROPDOWN, OnTbnDropDownToolBar) + ON_COMMAND_RANGE(ID_SELECT_MIDI_DEVICE, ID_SELECT_MIDI_DEVICE + MAX_MIDI_DEVICES, OnSelectMIDIDevice) END_MESSAGE_MAP() @@ -247,9 +252,15 @@ if (!SetButtons(MainButtons, CountOf(MainButtons))) return FALSE; CRect temp; - GetItemRect(0,&temp); + GetItemRect(0, temp); SetSizes(CSize(temp.Width(), temp.Height()), CSize(16, 16)); + // Dropdown menus for New and MIDI buttons + DWORD dwExStyle = GetToolBarCtrl().SendMessage(TB_GETEXTENDEDSTYLE) | TBSTYLE_EX_DRAWDDARROWS; + GetToolBarCtrl().SendMessage(TB_SETEXTENDEDSTYLE, 0, dwExStyle); + SetButtonStyle(CommandToIndex(ID_FILE_NEW), GetButtonStyle(CommandToIndex(ID_FILE_NEW)) | TBSTYLE_DROPDOWN); + SetButtonStyle(CommandToIndex(ID_MIDI_RECORD), GetButtonStyle(CommandToIndex(ID_MIDI_RECORD)) | TBSTYLE_DROPDOWN); + nCurrentSpeed = 6; nCurrentTempo = 125; nCurrentRowsPerBeat = 4; @@ -574,6 +585,51 @@ } +void CMainToolBar::OnTbnDropDownToolBar(NMHDR *pNMHDR, LRESULT *pResult) +//---------------------------------------------------------------------- +{ + NMTOOLBAR *pToolBar = reinterpret_cast<NMTOOLBAR *>(pNMHDR); + ClientToScreen(&(pToolBar->rcButton)); + + switch(pToolBar->iItem) + { + case ID_FILE_NEW: + CMainFrame::GetMainFrame()->GetFileMenu()->GetSubMenu(0)->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pToolBar->rcButton.left, pToolBar->rcButton.bottom, this); + break; + case ID_MIDI_RECORD: + // Show a list of MIDI devices + { + HMENU hMenu = ::CreatePopupMenu(); + MIDIINCAPS mic; + UINT ndevs = midiInGetNumDevs(); + UINT current = TrackerSettings::Instance().m_nMidiDevice; + for(UINT i = 0; i < ndevs; i++) + { + mic.szPname[0] = 0; + if(midiInGetDevCaps(i, &mic, sizeof(mic)) == MMSYSERR_NOERROR) + { + ::AppendMenu(hMenu, MF_STRING | (i == current ? MF_CHECKED : 0), ID_SELECT_MIDI_DEVICE + i, mic.szPname); + } + } + ::TrackPopupMenu(hMenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON, pToolBar->rcButton.left, pToolBar->rcButton.bottom, 0, m_hWnd, NULL); + ::DestroyMenu(hMenu); + } + break; + } + + *pResult = 0; +} + + +void CMainToolBar::OnSelectMIDIDevice(UINT id) +//-------------------------------------------- +{ + CMainFrame::GetMainFrame()->midiCloseDevice(); + TrackerSettings::Instance().m_nMidiDevice = id - ID_SELECT_MIDI_DEVICE; + CMainFrame::GetMainFrame()->midiOpenDevice(); +} + + void CMainToolBar::SetRowsPerBeat(ROWINDEX nNewRPB) //------------------------------------------------- { Modified: trunk/OpenMPT/mptrack/Mainbar.h =================================================================== --- trunk/OpenMPT/mptrack/Mainbar.h 2015-05-23 11:19:36 UTC (rev 5142) +++ trunk/OpenMPT/mptrack/Mainbar.h 2015-05-23 15:10:15 UTC (rev 5143) @@ -109,6 +109,8 @@ protected: //{{AFX_MSG(CMainToolBar) afx_msg void OnVScroll(UINT, UINT, CScrollBar *); + afx_msg void OnTbnDropDownToolBar(NMHDR* pNMHDR, LRESULT* pResult); + afx_msg void OnSelectMIDIDevice(UINT id); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; Modified: trunk/OpenMPT/mptrack/resource.h =================================================================== --- trunk/OpenMPT/mptrack/resource.h 2015-05-23 11:19:36 UTC (rev 5142) +++ trunk/OpenMPT/mptrack/resource.h 2015-05-23 15:10:15 UTC (rev 5143) @@ -1107,6 +1107,8 @@ // From here: Command range [ID_EQSLIDER_BASE, ID_EQSLIDER_BASE + MAX_EQ_BANDS] #define ID_EQMENU_BASE 32950 // From here: Command range [ID_EQMENU_BASE, ID_EQMENU_BASE + EQ_MAX_FREQS] +#define ID_SELECT_MIDI_DEVICE 33000 +// From here: Command range [ID_SELECT_MIDI_DEVICE, ID_SELECT_MIDI_DEVICE + MAX_MIDI_DEVICES] #define ID_EDIT_SPLITRECSELECT 33900 #define ID_REARRANGE_SAMPLES 33901 #define ID_CHANNEL_MANAGER 33905 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |