📄 cpi_playlistwindow.c
字号:
CPLI_WriteTag(hItem);
}
SetCursor(LoadCursor(NULL, IDC_ARROW));
CPIC_SetIndicatorValue("status", NULL);
return;
}
// We want to get the subitem's rect in the co-ordinate space of the dialog
hWndList = CLV_GetHWND(globals.m_hPlaylistViewControl);
CLV_GetItemSubRect(globals.m_hPlaylistViewControl, &rSubItem, iItem, iSubItem);
ClientToScreen(hWndList, (POINT*)&rSubItem);
ClientToScreen(hWndList, ((POINT*)&rSubItem)+1);
ScreenToClient(IF_GetHWnd(windows.m_hifPlaylist), (POINT*)&rSubItem);
ScreenToClient(IF_GetHWnd(windows.m_hifPlaylist), ((POINT*)&rSubItem)+1);
if(iSubItem == PLAYLIST_GENRE)
{
int iRectHeight = rSubItem.bottom-rSubItem.top;
int iListHeight = iRectHeight<<3;
InflateRect(&rSubItem, 2, 2);
pcClass = "COMBOBOX";
uiControlID = IDC_PL_FLOATINGCOMBO;
dwStyle = CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL;
rSubItem.bottom += (rSubItem.bottom-rSubItem.top)<<3;
}
else
{
InflateRect(&rSubItem, 2, 2);
pcClass = "EDIT";
dwStyle = ES_AUTOHSCROLL;
uiControlID = IDC_PL_FLOATINGEDIT;
if(iSubItem == PLAYLIST_TRACKNUM || iSubItem == PLAYLIST_YEAR)
dwStyle |= ES_NUMBER;
}
// Setup window class and style (the Genre window will be a combo)
globals.m_bIP_InhibitUpdates = TRUE;
windows.wnd_playlist_IPEdit = CreateWindow( pcClass,
"",
WS_CHILD
| WS_BORDER
| WS_CLIPSIBLINGS
| dwStyle,
rSubItem.left, rSubItem.top,
rSubItem.right-rSubItem.left, rSubItem.bottom-rSubItem.top,
IF_GetHWnd(windows.m_hifPlaylist),
(HMENU)uiControlID,
GetModuleHandle(NULL), NULL);
SetWindowPos(windows.wnd_playlist_IPEdit, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
ShowWindow(windows.wnd_playlist_IPEdit, SW_SHOW);
SetFocus(windows.wnd_playlist_IPEdit);
// Setup the font in the control
SendMessage(windows.wnd_playlist_IPEdit, WM_SETFONT, (WPARAM)glb_pSkin->mpl_hfFont, MAKELPARAM(TRUE, 0));
// Hook the listview window (so that we can dismiss on VScroll)
globals.m_hhkListView_Posted = SetWindowsHookEx(WH_GETMESSAGE, exp_ListViewHookProc_Posted, NULL, GetCurrentThreadId());
// Add the genre items to the list
if(iSubItem == PLAYLIST_GENRE)
{
int iGenreIDX;
for(iGenreIDX = 0; iGenreIDX < CIC_NUMGENRES; iGenreIDX++)
{
int iNewItemIDX = SendMessage(windows.wnd_playlist_IPEdit,
CB_ADDSTRING,
0L,
(LPARAM)glb_pcGenres[iGenreIDX]);
SendMessage(windows.wnd_playlist_IPEdit, CB_SETITEMDATA, (WPARAM)iNewItemIDX, (LPARAM)iGenreIDX);
}
}
// Setup the initial string
globals.m_iInPlaceSubItem = iSubItem;
{
switch(iSubItem)
{
case PLAYLIST_TITLE:
SendMessage(windows.wnd_playlist_IPEdit, WM_SETTEXT, 0L, (LPARAM)CPLI_GetTrackName(hClickedItem));
if(!options.support_id3v2)
SendMessage(windows.wnd_playlist_IPEdit, EM_LIMITTEXT, 30, 0);
break;
case PLAYLIST_ARTIST:
SendMessage(windows.wnd_playlist_IPEdit, WM_SETTEXT, 0L, (LPARAM)CPLI_GetArtist(hClickedItem));
if(!options.support_id3v2)
SendMessage(windows.wnd_playlist_IPEdit, EM_LIMITTEXT, 30, 0);
break;
case PLAYLIST_ALBUM:
SendMessage(windows.wnd_playlist_IPEdit, WM_SETTEXT, 0L, (LPARAM)CPLI_GetAlbum(hClickedItem));
if(!options.support_id3v2)
SendMessage(windows.wnd_playlist_IPEdit, EM_LIMITTEXT, 30, 0);
break;
case PLAYLIST_YEAR:
SendMessage(windows.wnd_playlist_IPEdit, WM_SETTEXT, 0L, (LPARAM)CPLI_GetYear(hClickedItem));
if(!options.support_id3v2)
SendMessage(windows.wnd_playlist_IPEdit, EM_LIMITTEXT, 4, 0);
break;
case PLAYLIST_TRACKNUM:
{
char cTrackNum[33];
unsigned char iTrackNum;
iTrackNum = CPLI_GetTrackNum(hClickedItem);
if(iTrackNum != CIC_INVALIDTRACKNUM && iTrackNum != 0)
SendMessage(windows.wnd_playlist_IPEdit, WM_SETTEXT, 0L, (LPARAM)itoa(iTrackNum, cTrackNum, 10));
}
SendMessage(windows.wnd_playlist_IPEdit, EM_LIMITTEXT, 3, 0);
break;
case PLAYLIST_COMMENT:
SendMessage(windows.wnd_playlist_IPEdit, WM_SETTEXT, 0L, (LPARAM)CPLI_GetComment(hClickedItem));
if(!options.support_id3v2)
SendMessage(windows.wnd_playlist_IPEdit, EM_LIMITTEXT, 28, 0);
break;
case PLAYLIST_GENRE:
SendMessage(windows.wnd_playlist_IPEdit, CB_SELECTSTRING, (WPARAM)-1, (LPARAM)CPLI_GetGenre(hClickedItem));
break;
}
}
globals.m_bIP_InhibitUpdates = FALSE;
}
//
//
//
BOOL CPlaylistWindow_OffsetSelectedItems(const int iOffset)
{
int iNumItemsInList;
int iStartItem, iTermItem, iItemInc, iItemIDX;
int iScanStartItem, iScanTermItem;
CP_HPLAYLISTITEM hActive;
int iNewFocusItemIDX;
if(iOffset == 0)
return FALSE;
// Determine which direction to move in list
iNumItemsInList = CLV_GetItemCount(globals.m_hPlaylistViewControl);
if(iOffset < 0)
{
iStartItem = 0;
iTermItem = iNumItemsInList;
iItemInc = 1;
iScanStartItem = 0;
iScanTermItem = -iOffset;
}
else
{
iStartItem = iNumItemsInList-1;
iTermItem = -1;
iItemInc = -1;
iScanStartItem = iNumItemsInList-1;
iScanTermItem = iScanStartItem-iOffset;
}
// Ensure that the selection can move intact (ie there are no selected items that could
// be "scrolled off" the list
for(iItemIDX = iScanStartItem; iItemIDX != iScanTermItem; iItemIDX += iItemInc)
{
if(CLV_IsItemSelected(globals.m_hPlaylistViewControl, iItemIDX))
return FALSE;
}
iNewFocusItemIDX = CLV_GetFocusItem(globals.m_hPlaylistViewControl) + iOffset;
CLV_SetFocusItem(globals.m_hPlaylistViewControl, iNewFocusItemIDX);
CLV_EnsureVisible(globals.m_hPlaylistViewControl, iNewFocusItemIDX);
// Go through all the items scanning the -ve offset item and swapping it
// in if needed
for(iItemIDX = iStartItem; iItemIDX != iTermItem; iItemIDX += iItemInc)
{
// Work out the item to probe
const int iProbeItemIDX = iItemIDX - iOffset;
CP_HPLAYLISTITEM hItem, hItem_Probe, hReindexCursor;
CP_HPLAYLISTITEM hReindexStart, hReindexEnd;
int iReindexItemIDX;
// If this probe item is unselected (or out of bounds) - set the current item's selection
// to unselected and try the next item
if(iProbeItemIDX < 0 || iProbeItemIDX >= iNumItemsInList
|| CLV_IsItemSelected(globals.m_hPlaylistViewControl, iProbeItemIDX) == FALSE)
{
CLV_SetItemSelected(globals.m_hPlaylistViewControl, iItemIDX, FALSE);
continue;
}
// The probe item is selected - move that item over to this item
// - If the item is moving down it needs to be inserted after - otherwise it
// needs to be inserted before
hItem = (CP_HPLAYLISTITEM)CLV_GetItemData(globals.m_hPlaylistViewControl, iItemIDX);
hItem_Probe = (CP_HPLAYLISTITEM)CLV_GetItemData(globals.m_hPlaylistViewControl, iProbeItemIDX);
if(iOffset > 0)
{
// Get start reindex item
hReindexStart = CPLI_Next(hItem_Probe);
if(hReindexStart == NULL)
hReindexStart = CPL_GetFirstItem(globals.m_hPlaylist);
CPL_InsertItemAfter(globals.m_hPlaylist, hItem, hItem_Probe);
// Get end reindex item
hReindexEnd = CPLI_Next(hItem_Probe);
// Perform reindexing
iReindexItemIDX = iProbeItemIDX;
for(hReindexCursor = hReindexStart; hReindexCursor != hReindexEnd; hReindexCursor = CPLI_Next(hReindexCursor))
{
CPLI_SetCookie(hReindexCursor, iReindexItemIDX);
CPL_cb_OnItemUpdated(hReindexCursor);
iReindexItemIDX++;
}
}
else
{
// Get start reindex item
hReindexStart = CPLI_Prev(hItem_Probe);
if(hReindexStart == NULL)
hReindexStart = CPL_GetLastItem(globals.m_hPlaylist);
CPL_InsertItemBefore(globals.m_hPlaylist, hItem, hItem_Probe);
// Get end reindex item
hReindexEnd = CPLI_Prev(hItem_Probe);
// Perform reindexing
iReindexItemIDX = iProbeItemIDX;
for(hReindexCursor = hReindexStart; hReindexCursor != hReindexEnd; hReindexCursor = CPLI_Prev(hReindexCursor))
{
CPLI_SetCookie(hReindexCursor, iReindexItemIDX);
CPL_cb_OnItemUpdated(hReindexCursor);
iReindexItemIDX--;
}
}
// Set the item's selection
CLV_SetItemSelected(globals.m_hPlaylistViewControl, iItemIDX, TRUE);
}
// Set the "active" item in the list
hActive = CPL_GetActiveItem(globals.m_hPlaylist);
return TRUE;
}
//
//
//
void CPlaylistWindow_CB_onMouseMove(CP_HINTERFACE hInterface, const POINTS _ptMouse, const unsigned short iFlags)
{
POINT ptMouse;
int iHitItem;
ptMouse.x = _ptMouse.x;
ptMouse.y = _ptMouse.y;
// Which item is this over?
ClientToScreen(IF_GetHWnd(windows.m_hifPlaylist), &ptMouse);
ScreenToClient(CLV_GetHWND(globals.m_hPlaylistViewControl), &ptMouse);
iHitItem = CLV_GetNearestItem(globals.m_hPlaylistViewControl, &ptMouse);
// Perform drag
if(iHitItem != CPC_INVALIDITEM && iHitItem != globals.main_drag_anchor_point)
{
BOOL bDragResult;
bDragResult = CPlaylistWindow_OffsetSelectedItems(iHitItem - globals.main_drag_anchor_point);
if(bDragResult == TRUE)
globals.main_drag_anchor_point = iHitItem;
}
}
//
//
//
void CPlaylistWindow_CB_onMouseButton_LUp(CP_HINTERFACE hInterface, const POINTS ptMouse, const unsigned short iFlags)
{
IF_ReleaseMouseCapture(windows.m_hifPlaylist);
}
//
//
//
void CPlaylistWindow_WM_COMMAND_IDC_PL_FLOATINGEDIT(WPARAM wParam, LPARAM lParam)
{
if(HIWORD(wParam) == EN_KILLFOCUS)
{
// Floating combo control looses focus - destroy it (after breaking out of kill focus context)
IF_PostAppMessage(windows.m_hifPlaylist, CPPLM_DESTROYINPLACE, 0L, 0L);
}
else if(HIWORD(wParam) == EN_CHANGE && globals.m_bIP_InhibitUpdates == FALSE)
{
int iSearchItemIDX;
char* pcEditText;
DWORD dwTextLen;
// Get the text from the control
dwTextLen = SendMessage(windows.wnd_playlist_IPEdit, WM_GETTEXTLENGTH, 0L, 0L) + 1;
pcEditText = (char*)malloc( dwTextLen * sizeof(char));
SendMessage(windows.wnd_playlist_IPEdit, WM_GETTEXT, (WPARAM)dwTextLen, (LPARAM)pcEditText);
// Update all of the selected items
iSearchItemIDX = CLV_GetNextSelectedItem(globals.m_hPlaylistViewControl, CPC_INVALIDITEM);
for(;iSearchItemIDX != -1; iSearchItemIDX = CLV_GetNextSelectedItem(globals.m_hPlaylistViewControl, iSearchItemIDX))
{
CP_HPLAYLISTITEM hPlaylistItem = (CP_HPLAYLISTITEM)CLV_GetItemData(globals.m_hPlaylistViewControl, iSearchItemIDX);
switch(globals.m_iInPlaceSubItem)
{
case PLAYLIST_TITLE:
CPLI_SetTrackName(hPlaylistItem, pcEditText);
break;
case PLAYLIST_ARTIST:
CPLI_SetArtist(hPlaylistItem, pcEditText);
break;
case PLAYLIST_ALBUM:
CPLI_SetAlbum(hPlaylistItem, pcEditText);
break;
case PLAYLIST_YEAR:
CPLI_SetYear(hPlaylistItem, pcEditText);
break;
case PLAYLIST_TRACKNUM:
CPLI_SetTrackNum_AsText(hPlaylistItem, pcEditText);
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -