1
0

Pledit.cpp 49 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723
  1. #include <windowsx.h>
  2. #include "Main.h"
  3. #include "ipc_pe.h"
  4. #include "buildType.h"
  5. #include "../Plugins/General/gen_ml/ml_ipc.h"
  6. #include "../Plugins/General/gen_ml/ml.h"
  7. #include "../Plugins/General/gen_ml/menufucker.h"
  8. #include "api.h"
  9. #include "ExplorerFindFile.h"
  10. #include "../nu/AutoWide.h"
  11. #include "../nu/AutoWideFn.h"
  12. #include "resource.h"
  13. int pledit_disp_offs;
  14. static int pledit_delta_carryover;
  15. void plEditRefresh(void)
  16. {
  17. if (config_pe_open) InvalidateRect(hPLWindow, NULL, FALSE);
  18. }
  19. void plEditSelect(int song)
  20. {
  21. if (hPLWindow) SendMessageW(hPLWindow, WM_USER, 666, song);
  22. }
  23. int pe_startuphack, eq_startuphack;
  24. void pleditDlg(HWND hwnd, int init_state)
  25. {
  26. if (!hPLWindow) return ;
  27. int toggle = Ipc_WindowToggle(IPC_CB_WND_PE, !config_pe_open);
  28. KillTimer(hPLWindow, 3);
  29. if (!toggle) return;
  30. if (!config_pe_open)
  31. {
  32. CheckMenuItem(main_menu, WINAMP_OPTIONS_PLEDIT, MF_CHECKED);
  33. if (pe_startuphack == 1)
  34. {
  35. if(!GetParent(hPLWindow))
  36. SetTimer(hPLWindow, 3, 10, NULL);
  37. config_pe_open = 1;
  38. }
  39. else
  40. {
  41. if(!init_state && !config_minimized) ShowWindow(hPLWindow, SW_SHOWNA);
  42. SendMessageW(hPLWindow, WM_USER, 666, PlayList_getPosition());
  43. config_pe_open = 1;
  44. // works around a quirk with Bento docked to the right-hand edge
  45. // where the pledit is left docked on reverting to classic skin (dro)
  46. if(!GetParent(hPLWindow)) set_aot(1);
  47. }
  48. }
  49. else
  50. {
  51. if (GetForegroundWindow() == hPLWindow || IsChild(hPLWindow, GetForegroundWindow()))
  52. {
  53. SendMessageW(hMainWindow, WM_COMMAND, WINAMP_NEXT_WINDOW, 0);
  54. }
  55. CheckMenuItem(main_menu, WINAMP_OPTIONS_PLEDIT, MF_UNCHECKED);
  56. ShowWindow(hPLWindow, SW_HIDE);
  57. config_pe_open = 0;
  58. }
  59. draw_eqplbut(config_eq_open, 0, config_pe_open, 0);
  60. return ;
  61. }
  62. int playlist_open(HWND hwnd)
  63. {
  64. if (!(loadpls(hwnd, -1))) return 0;
  65. PlayList_setposition(0);
  66. if (config_shuffle) PlayList_randpos(-100000);
  67. PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
  68. {
  69. RECT r = {0, 0, config_pe_width, config_pe_height - 37};
  70. InvalidateRect(hPLWindow, &r, FALSE);
  71. }
  72. return 1;
  73. }
  74. static wchar_t entryFN[FILENAME_SIZE];
  75. static BOOL CALLBACK entryProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  76. {
  77. switch (uMsg)
  78. {
  79. case WM_INITDIALOG:
  80. {
  81. SetDlgItemTextW(hwndDlg, IDC_OLD, entryFN);
  82. SetDlgItemTextW(hwndDlg, IDC_NEW, entryFN);
  83. // show ctrl+e window and restore last position as applicable
  84. POINT pt = {ctrle_rect.left, ctrle_rect.top};
  85. if (!windowOffScreen(hwndDlg, pt))
  86. SetWindowPos(hwndDlg, HWND_TOP, ctrle_rect.left, ctrle_rect.top, 0, 0, SWP_NOSIZE | SWP_NOSENDCHANGING);
  87. return TRUE;
  88. }
  89. case WM_COMMAND:
  90. switch (LOWORD(wParam))
  91. {
  92. case IDOK:
  93. GetDlgItemTextW(hwndDlg, IDC_NEW, entryFN, FILENAME_SIZE);
  94. GetWindowRect(hwndDlg, &ctrle_rect);
  95. EndDialog(hwndDlg, 1);
  96. return 0;
  97. case IDCANCEL:
  98. GetWindowRect(hwndDlg, &ctrle_rect);
  99. EndDialog(hwndDlg, 0);
  100. return 0;
  101. }
  102. return 0;
  103. }
  104. return 0;
  105. }
  106. void PE_Cmd(windowCommand *wc)
  107. {
  108. if (wc == NULL) return ;
  109. switch (wc->cmd)
  110. {
  111. case PLCMD_ADD:
  112. DoTrackPopup(GetSubMenu(GetSubMenu(top_menu, 2), 1), wc->align, wc->x, wc->y, hPLWindow);
  113. break;
  114. case PLCMD_REM:
  115. DoTrackPopup(GetSubMenu(GetSubMenu(top_menu, 2), 2), wc->align, wc->x, wc->y, hPLWindow);
  116. break;
  117. case PLCMD_SEL:
  118. DoTrackPopup(GetSubMenu(GetSubMenu(top_menu, 2), 3), wc->align, wc->x, wc->y, hPLWindow);
  119. break;
  120. case PLCMD_MISC:
  121. DoTrackPopup(GetSubMenu(GetSubMenu(top_menu, 2), 0), wc->align, wc->x, wc->y, hPLWindow);
  122. break;
  123. case PLCMD_LIST:
  124. DoTrackPopup(GetSubMenu(GetSubMenu(top_menu, 2), 4), wc->align, wc->x, wc->y, hPLWindow);
  125. break;
  126. }
  127. }
  128. static librarySendToMenuStruct mySendTo;
  129. static HMENU ratingMenu;
  130. static int PE_OnRButtonUp(HWND hwnd, int x, int y, UINT flags)
  131. {
  132. POINT p;
  133. GetCursorPos(&p);
  134. if ((flags & MK_LBUTTON)) return 1;
  135. if (peui_isrbuttoncaptured()) return 1;
  136. if (config_pe_height != 14 && config_pe_width >= 350 &&
  137. (x >= config_pe_width - 150 - 75 && y >= config_pe_height - 26 && x <= config_pe_width - 150 && y <= config_pe_height - 8))
  138. {
  139. extern HMENU g_submenus_vis;
  140. DoTrackPopup(g_submenus_vis, TPM_LEFTALIGN | TPM_RIGHTBUTTON, p.x, p.y, hwnd);
  141. }
  142. else if (config_pe_height != 14 &&
  143. (x >= 14 && y >= config_pe_height - 30 && x <= 32 && y <= config_pe_height - 12))
  144. {
  145. DoTrackPopup(GetSubMenu(GetSubMenu(top_menu, 2), 1), TPM_LEFTALIGN | TPM_RIGHTBUTTON, p.x, p.y, hwnd);
  146. }
  147. else if (config_pe_height != 14 &&
  148. (x >= 43 && y >= config_pe_height - 30 && x <= 64 && y <= config_pe_height - 12))
  149. {
  150. DoTrackPopup(GetSubMenu(GetSubMenu(top_menu, 2), 2), TPM_LEFTALIGN | TPM_RIGHTBUTTON, p.x, p.y, hwnd);
  151. }
  152. else if (config_pe_height != 14 &&
  153. (x >= 72 && y >= config_pe_height - 30 && x <= 93 && y <= config_pe_height - 12))
  154. {
  155. DoTrackPopup(GetSubMenu(GetSubMenu(top_menu, 2), 3), TPM_LEFTALIGN | TPM_RIGHTBUTTON, p.x, p.y, hwnd);
  156. }
  157. else if (config_pe_height != 14 &&
  158. (x >= 101 && y >= config_pe_height - 30 && x <= 122 && y <= config_pe_height - 12))
  159. {
  160. DoTrackPopup(GetSubMenu(GetSubMenu(top_menu, 2), 0), TPM_LEFTALIGN | TPM_RIGHTBUTTON, p.x, p.y, hwnd);
  161. }
  162. else if (config_pe_height != 14 &&
  163. (x >= config_pe_width - 44 && y >= config_pe_height - 30 && x <= config_pe_width - 44 + 22 && y <= config_pe_height - 12))
  164. {
  165. DoTrackPopup(GetSubMenu(GetSubMenu(top_menu, 2), 4), TPM_LEFTALIGN | TPM_RIGHTBUTTON, p.x, p.y, hwnd);
  166. }
  167. else if (config_pe_height != 14 && y >= 20 && y <= config_pe_height - 38 && x >= 12 && x <= config_pe_width - 20)
  168. { // right click in list box
  169. int wh = (y - 22) / pe_fontheight + pledit_disp_offs;
  170. int s = (flags & MK_CONTROL);
  171. if (!s && !PlayList_getselect(wh))
  172. {
  173. int x, t = PlayList_getlength();
  174. for (x = 0; x < t; x ++)
  175. PlayList_setselect(x, 0);
  176. }
  177. if (PlayList_getselect(wh) && s)
  178. PlayList_setselect(wh, 0);
  179. else
  180. {
  181. int y = wh - pledit_disp_offs;
  182. if (y < PlayList_getlength() - pledit_disp_offs && y < (config_pe_height - 38 - 20 - 2) / pe_fontheight)
  183. {
  184. PlayList_setselect(wh, 1);
  185. }
  186. }
  187. // ensures the selection is shown before the menu is displayed
  188. {
  189. RECT r1 = {12, 22, config_pe_width - 20, config_pe_height - 38};
  190. InvalidateRect(hwnd, &r1, FALSE);
  191. UpdateWindow(hwnd);
  192. }
  193. #ifdef WINAMP_FINAL_BUILD
  194. if (!PlayList_gethidden(wh) && !PlayList_hasanycurtain(wh))
  195. #endif
  196. {
  197. LRESULT IPC_LIBRARY_SENDTOMENU = wa_register_ipc((WPARAM)&"LibrarySendToMenu");
  198. HMENU menu = 0, ourmenu = GetSubMenu(GetSubMenu(top_menu, 2), 5);
  199. memset(&mySendTo, 0, sizeof(mySendTo));
  200. if (IPC_LIBRARY_SENDTOMENU > 65536 && SendMessageW(hMainWindow, WM_WA_IPC, (WPARAM)0, IPC_LIBRARY_SENDTOMENU) == 0xffffffff)
  201. {
  202. MENUITEMINFOW mii = {sizeof(mii), MIIM_SUBMENU | MIIM_TYPE, MFT_STRING, };
  203. mii.hSubMenu = menu = CreatePopupMenu();
  204. mii.dwTypeData = getStringW(IDS_SENDTO_STR,NULL,0);
  205. mii.cch = (UINT)wcslen(mii.dwTypeData);
  206. InsertMenuItemW(ourmenu, 1, TRUE, &mii);
  207. mySendTo.mode = 1;
  208. mySendTo.hwnd = hwnd;
  209. mySendTo.data_type = ML_TYPE_FILENAMESW;
  210. mySendTo.build_hMenu = menu;
  211. }
  212. {
  213. HMENU tmenu = NULL;
  214. int nitems = GetMenuItemCount(ourmenu);
  215. for (int i = 0; i < nitems; i++)
  216. {
  217. // test for it being a popup
  218. if(GetMenuItemID(ourmenu, i) == -1)
  219. {
  220. if((tmenu = GetSubMenu(ourmenu, i)))
  221. {
  222. // and if so then see what the last popup menu item is
  223. if(GetMenuItemID(tmenu, GetMenuItemCount(tmenu)-1) == ID_PL_RATING0)
  224. {
  225. ratingMenu = tmenu;
  226. break;
  227. }
  228. }
  229. }
  230. }
  231. }
  232. menufucker_t mf = {sizeof(mf),MENU_PLAYLIST,ourmenu,0x3000,0x4000,0};
  233. pluginMessage message_build = {(int)wa_register_ipc((WPARAM)&"menufucker_build"),(intptr_t)&mf,0};
  234. sendMlIpc(ML_IPC_SEND_PLUGIN_MESSAGE,(WPARAM)&message_build);
  235. int ret = DoTrackPopup(ourmenu, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_RETURNCMD, p.x, p.y, hwnd);
  236. ratingMenu = NULL;
  237. pluginMessage message_result = {(int)wa_register_ipc((WPARAM)&"menufucker_result"),(intptr_t)&mf,ret,0};
  238. sendMlIpc(ML_IPC_SEND_PLUGIN_MESSAGE,(WPARAM)&message_result);
  239. if (menu)
  240. {
  241. if (mySendTo.mode == 2)
  242. {
  243. mySendTo.menu_id = ret;
  244. if (SendMessageW(hMainWindow, WM_WA_IPC, (WPARAM)&mySendTo, IPC_LIBRARY_SENDTOMENU) == 0xffffffff)
  245. {
  246. size_t buf_size = 4096;
  247. wchar_t *buf = (wchar_t*)malloc(buf_size*sizeof(wchar_t));
  248. size_t buf_pos = 0;
  249. int i, l = PlayList_getlength();
  250. for (i = 0;i < l;i++)
  251. {
  252. if (PlayList_getselect(i)
  253. #ifdef WINAMP_FINAL_BUILD
  254. && !PlayList_gethidden(i) && !PlayList_hasanycurtain(i)
  255. #endif
  256. )
  257. {
  258. wchar_t itrFilename[FILENAME_SIZE] = {0};
  259. PlayList_getitem(i, itrFilename, NULL);
  260. size_t newsize = buf_pos + wcslen(itrFilename) + 1;
  261. if (newsize < buf_size)
  262. {
  263. size_t old_buf_size = buf_size;
  264. buf_size = newsize + 4096;
  265. wchar_t *new_buf = (wchar_t*)realloc(buf, buf_size*sizeof(wchar_t));
  266. if (!new_buf)
  267. {
  268. new_buf = (wchar_t*)malloc(buf_size*sizeof(wchar_t));
  269. if (new_buf)
  270. {
  271. memcpy(new_buf, buf, old_buf_size*sizeof(wchar_t));
  272. free(buf);
  273. buf = new_buf;
  274. }
  275. }
  276. else buf = new_buf;
  277. }
  278. StringCchCopyW(buf + buf_pos, buf_size - buf_pos, itrFilename);
  279. buf_pos = newsize;
  280. }
  281. }
  282. if (buf_pos)
  283. {
  284. buf[buf_pos] = 0;
  285. mySendTo.mode = 3;
  286. mySendTo.data = buf;
  287. mySendTo.data_type = ML_TYPE_FILENAMESW;
  288. SendMessageW(hMainWindow, WM_WA_IPC, (WPARAM)&mySendTo, IPC_LIBRARY_SENDTOMENU);
  289. }
  290. free(buf);
  291. ret = 0;
  292. }
  293. }
  294. // remove sendto
  295. DeleteMenu(ourmenu, 1, MF_BYPOSITION);
  296. }
  297. if (mySendTo.mode)
  298. {
  299. mySendTo.mode = 4;
  300. SendMessageW(hMainWindow, WM_WA_IPC, (WPARAM)&mySendTo, IPC_LIBRARY_SENDTOMENU); // cleanup
  301. memset(&mySendTo, 0, sizeof(mySendTo));
  302. }
  303. if (ret) SendMessageW(hwnd, WM_COMMAND, ret, 0);
  304. }
  305. }
  306. else
  307. {
  308. DoTrackPopup(main_menu, TPM_LEFTALIGN | TPM_RIGHTBUTTON, p.x, p.y, hMainWindow);
  309. }
  310. return 1;
  311. }
  312. static int PE_OnLButtonUp(HWND hwnd, int x, int y, UINT flags)
  313. {
  314. ReleaseCapture();
  315. peui_handlemouseevent(hwnd, x, y, -1, flags);
  316. return 1;
  317. }
  318. static int PE_OnLButtonDown(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
  319. {
  320. SetCapture(hwnd);
  321. peui_handlemouseevent(hwnd, x, y, 1, keyFlags);
  322. SetFocus(hwnd);
  323. return 1;
  324. }
  325. static int PE_OnMouseMove(HWND hwnd, int x, int y, UINT keyFlags)
  326. {
  327. peui_handlemouseevent(hwnd, x, y, 0, keyFlags);
  328. return 1;
  329. }
  330. static BOOL PE_OnNCActivate(HWND hwnd, BOOL fActive, HWND hwndActDeact, BOOL fMinimized)
  331. {
  332. if (fActive == FALSE)
  333. {
  334. draw_pe_tbar(hwnd, NULL, config_hilite ? 0 : 1);
  335. peui_reset(hwnd);
  336. }
  337. else
  338. {
  339. draw_pe_tbar(hwnd, NULL, 1);
  340. }
  341. return TRUE;
  342. }
  343. static int PE_OnLButtonDblClk(HWND hwnd, BOOL fDoubleClick, int x, int y, UINT keyFlags)
  344. {
  345. if (y <= 14 && x < config_pe_width - 20)
  346. {
  347. SendMessageW(hMainWindow, WM_COMMAND, WINAMP_OPTIONS_WINDOWSHADE_PL, 0);
  348. }
  349. else if (config_pe_height != 14)
  350. {
  351. if (x >= 12 && y >= 20 && x <= config_pe_width - 20 && y <= config_pe_height - 38)
  352. {
  353. int t = (y - 22) / pe_fontheight;
  354. if (t < PlayList_getlength() - pledit_disp_offs && t < (config_pe_height - 38 - 20 - 2) / pe_fontheight)
  355. {
  356. t += pledit_disp_offs;
  357. PlayList_setposition(t);
  358. PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
  359. StartPlaying();
  360. SetForegroundWindow(hwnd);
  361. }
  362. }
  363. else if (x >= config_pe_width - 44 && y >= config_pe_height - 30 && x < config_pe_width - 44 + 22 && y < config_pe_height - 12)
  364. {
  365. InvalidateRect(hwnd, NULL, 0);
  366. SendMessageW(hwnd, WM_COMMAND, ID_PE_OPEN, 0);
  367. }
  368. else if (x >= 101 && y >= config_pe_height - 30 && x < 122 && y < config_pe_height - 12)
  369. {
  370. {
  371. POINT p = {122, config_pe_height - 30};
  372. ClientToScreen(hwnd, &p);
  373. DoTrackPopup(GetSubMenu(GetSubMenu(GetSubMenu(top_menu, 2), 0), 2), TPM_LEFTALIGN, p.x, p.y, hwnd);
  374. }
  375. peui_reset(hwnd);
  376. }
  377. else if (x >= 72 && y >= config_pe_height - 30 && x < 93 && y < config_pe_height - 12)
  378. {
  379. peui_reset(hwnd);
  380. SendMessageW(hwnd, WM_COMMAND, ID_PE_SELECTALL, 0);
  381. }
  382. else if (x >= 43 && y >= config_pe_height - 30 && x < 64 && y < config_pe_height - 12)
  383. {
  384. peui_reset(hwnd);
  385. SendMessageW(hwnd, WM_COMMAND, IDC_PLAYLIST_REMOVEMP3, 0);
  386. }
  387. else if (x >= 14 && y >= config_pe_height - 30 && x < 35 && y < config_pe_height - 12)
  388. {
  389. peui_reset(hwnd);
  390. SendMessageW(hwnd, WM_COMMAND, IDC_PLAYLIST_ADDMP3, 0);
  391. }
  392. }
  393. return 1;
  394. }
  395. int setCurrentRating(int rating)
  396. {
  397. LRESULT ret = sendMlIpc(ML_IPC_SETRATING, rating);
  398. if (!ret && !got_ml)
  399. {
  400. wchar_t fn[FILENAME_SIZE] = {0};
  401. if (!PlayList_getitem2W(PlayList_getPosition(), fn, NULL))
  402. {
  403. wchar_t buf[64] = {0};
  404. if (rating > 0)
  405. StringCchPrintfW(buf, 64, L"%d", rating);
  406. else
  407. buf[0] = 0;
  408. if(config_noml_ratings_prompt)
  409. {
  410. config_noml_ratings = (LPMessageBox(hMainWindow, IDS_NOML_SAVE_RATING, IDS_NOML_SAVE_RATING_TITLE, MB_YESNO | MB_ICONQUESTION) == IDYES);
  411. config_noml_ratings_prompt = 0;
  412. }
  413. if (config_noml_ratings)
  414. {
  415. in_set_extended_fileinfoW(fn, L"rating", buf);
  416. in_write_extended_fileinfo();
  417. }
  418. }
  419. }
  420. SendMessageW(hMainWindow,WM_TIMER,UPDATE_DISPLAY_TIMER+4,0);
  421. return ret;
  422. }
  423. int setPlRating(int rating)
  424. {
  425. int r = 0;
  426. int i, l = PlayList_getlength();
  427. for (i = 0;i < l;i++)
  428. {
  429. if (PlayList_getselect(i))
  430. {
  431. pl_set_rating psr;
  432. psr.plentry = i;
  433. psr.rating = rating;
  434. r |= sendMlIpc(ML_IPC_PL_SETRATING, (WPARAM) & psr);
  435. if (!r && !got_ml)
  436. {
  437. wchar_t buf[64] = {0};
  438. if (rating > 0)
  439. StringCchPrintfW(buf, 64, L"%d", rating);
  440. else
  441. buf[0] = 0;
  442. if(config_noml_ratings_prompt)
  443. {
  444. config_noml_ratings = (LPMessageBox(hMainWindow, IDS_NOML_SAVE_RATING, IDS_NOML_SAVE_RATING_TITLE, MB_YESNO | MB_ICONQUESTION) == IDYES);
  445. config_noml_ratings_prompt = 0;
  446. }
  447. wchar_t fn[FILENAME_SIZE] = {0};
  448. if (config_noml_ratings && !PlayList_getitem2W(i, fn, NULL))
  449. {
  450. in_set_extended_fileinfoW(fn, L"rating", buf);
  451. in_write_extended_fileinfo();
  452. }
  453. }
  454. g_need_titleupd = 1; // force a title update (%rating% may be in the ATF string)
  455. PlayList_updateitem(i);
  456. }
  457. }
  458. plEditRefresh();
  459. SendMessageW(hMainWindow,WM_TIMER,UPDATE_DISPLAY_TIMER+4,0);
  460. return r;
  461. }
  462. LRESULT CALLBACK PE_WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  463. {
  464. static int se_lp, se_a, se_t;
  465. if (uMsg == g_scrollMsg)
  466. {
  467. wParam <<= 16; uMsg = WM_MOUSEWHEEL;
  468. }
  469. switch (uMsg)
  470. {
  471. case WM_SHOWWINDOW:
  472. if (wParam == TRUE && lParam == SW_PARENTOPENING && !config_pe_open)
  473. return 0;
  474. break;
  475. case WM_DISPLAYCHANGE:
  476. InvalidateRect(hwnd, NULL, TRUE);
  477. break;
  478. case WM_INITMENUPOPUP:
  479. if (wParam && (HMENU)wParam == mySendTo.build_hMenu && mySendTo.mode == 1)
  480. {
  481. int IPC_LIBRARY_SENDTOMENU = wa_register_ipc((WPARAM)&"LibrarySendToMenu");
  482. if (IPC_LIBRARY_SENDTOMENU > 65536 && SendMessageW(hMainWindow, WM_WA_IPC, (WPARAM)&mySendTo, IPC_LIBRARY_SENDTOMENU) == 0xffffffff)
  483. mySendTo.mode = 2;
  484. }
  485. // handles the ratings menu and is localised happy now
  486. // (compared to the IDS_RATEITEM_STR based code) - DO 26/09/07
  487. else if (wParam && (HMENU)wParam == ratingMenu)
  488. {
  489. int darating = -1, firstrating = -1;
  490. for (int i = 0; i < PlayList_getlength(); i++)
  491. {
  492. int rating = 0;
  493. wchar_t fn[FILENAME_SIZE] = {0};
  494. if (PlayList_getselect2(i, fn)
  495. #ifdef WINAMP_FINAL_BUILD
  496. && !PlayList_gethidden(i) && !PlayList_hasanycurtain(i)
  497. #endif
  498. )
  499. {
  500. rating = sendMlIpc(ML_IPC_GET_FILE_RATINGW, (WPARAM)fn);
  501. if (!i) firstrating = rating;
  502. // deal with no ml being present and querying the rating of a file from the tag (if possible)
  503. // as well as getting a zero rating which could mean that it's not present in the library
  504. if (!rating && !got_ml)
  505. {
  506. wchar_t buf[64] = {0};
  507. in_get_extended_fileinfoW(fn, L"rating", buf, 64);
  508. rating = _wtoi(buf);
  509. if (!i) firstrating = rating;
  510. }
  511. if (darating == -1)
  512. {
  513. darating = rating;
  514. }
  515. else
  516. {
  517. if (darating != rating) darating = -2;
  518. }
  519. }
  520. }
  521. if (darating == -2) darating = firstrating;
  522. CheckMenuItem(ratingMenu, ID_PL_RATING5, (darating == 5) ? MF_CHECKED : MF_UNCHECKED);
  523. CheckMenuItem(ratingMenu, ID_PL_RATING4, (darating == 4) ? MF_CHECKED : MF_UNCHECKED);
  524. CheckMenuItem(ratingMenu, ID_PL_RATING3, (darating == 3) ? MF_CHECKED : MF_UNCHECKED);
  525. CheckMenuItem(ratingMenu, ID_PL_RATING2, (darating == 2) ? MF_CHECKED : MF_UNCHECKED);
  526. CheckMenuItem(ratingMenu, ID_PL_RATING1, (darating == 1) ? MF_CHECKED : MF_UNCHECKED);
  527. CheckMenuItem(ratingMenu, ID_PL_RATING0, (darating == 0) ? MF_CHECKED : MF_UNCHECKED);
  528. // set this so we don't re-process until the menu is re-loaded completely
  529. ratingMenu = NULL;
  530. }
  531. return 0;
  532. HANDLE_MSG(hwnd, WM_QUERYNEWPALETTE, Main_OnQueryNewPalette);
  533. HANDLE_MSG(hwnd, WM_PALETTECHANGED, Main_OnPaletteChanged);
  534. HANDLE_MSG(hwnd, WM_LBUTTONUP, PE_OnLButtonUp);
  535. HANDLE_MSG(hwnd, WM_RBUTTONUP, PE_OnRButtonUp);
  536. HANDLE_MSG(hwnd, WM_LBUTTONDOWN, PE_OnLButtonDown);
  537. HANDLE_MSG(hwnd, WM_MOUSEMOVE, PE_OnMouseMove);
  538. HANDLE_MSG(hwnd, WM_NCACTIVATE, PE_OnNCActivate);
  539. HANDLE_MSG(hwnd, WM_LBUTTONDBLCLK, PE_OnLButtonDblClk);
  540. case WM_SYSCOMMAND:
  541. if ((wParam & 0xfff0) == SC_SCREENSAVE || (wParam & 0xfff0) == SC_MONITORPOWER)
  542. return SendMessageW(hMainWindow, uMsg, wParam, lParam);
  543. break;
  544. case WM_CLOSE:
  545. WASABI_API_APP->main_shutdown();
  546. return 0;
  547. case WM_PAINT:
  548. draw_paint_pe(hwnd);
  549. return 0;
  550. case WM_PRINTCLIENT:
  551. draw_printclient_pe(hwnd, (HDC)wParam, lParam);
  552. return 0;
  553. case WM_GETMINMAXINFO:
  554. {
  555. MINMAXINFO *p = (MINMAXINFO *)lParam;
  556. p->ptMaxTrackSize.x = 16384;
  557. p->ptMaxTrackSize.y = 16384;
  558. }
  559. return 0;
  560. case WM_NOTIFY:
  561. {
  562. LPTOOLTIPTEXT tt = (LPTOOLTIPTEXT)lParam;
  563. /*if(tt->hdr.hwndFrom = hPL2TooltipWindow)
  564. {
  565. switch (tt->hdr.code)
  566. {
  567. case TTN_SHOW:*/
  568. /*if(tt->hdr.idFrom == 17)
  569. {
  570. POINT pt = {0};
  571. GetCursorPos(&pt);
  572. ScreenToClient(hPLWindow,&pt);
  573. RECT rc = {0};
  574. EstPLWindowRect(&rc);
  575. rc.left += 12;
  576. int t = (pt.y - 20) / pe_fontheight;
  577. if (t < 0) t = 0;
  578. else if (t > (config_pe_height - 38 - 20 - 2) / pe_fontheight) t = PlayList_getlength();
  579. rc.top += 22+(pe_fontheight*t);
  580. SendMessageW(tt->hdr.hwndFrom,TTM_ADJUSTRECT,TRUE,(LPARAM)&rc);
  581. SetWindowPos(tt->hdr.hwndFrom,HWND_TOPMOST,rc.left,rc.top,0,0,SWP_NOSIZE|SWP_NOACTIVATE);
  582. return TRUE;
  583. }
  584. else*/
  585. /*{
  586. SetWindowPos(tt->hdr.hwndFrom,HWND_TOPMOST,0,0,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE);
  587. }
  588. break;
  589. }
  590. }
  591. else*/ if(tt->hdr.hwndFrom = hPLTooltipWindow)
  592. {
  593. switch (tt->hdr.code)
  594. {
  595. case TTN_SHOW:
  596. SetWindowPos(tt->hdr.hwndFrom,HWND_TOPMOST,0,0,0,0,SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE);
  597. break;
  598. }
  599. }
  600. }
  601. break;
  602. case WM_SIZE:
  603. if (wParam == SIZE_RESTORED)
  604. {
  605. // changed to this as it's a cleaner approach to the earlier option
  606. // this will better handle playlist size changes (especially on skin
  607. // change) without causing the current item to be returned to view
  608. // unlike my prior commit from 30/05/08 (so this acts more natural).
  609. RECT r = {0, 0, config_pe_width, config_pe_height - 37};
  610. int num_songs = (config_pe_height - 38 - 20 - 2) / pe_fontheight;
  611. int t = PlayList_getlength();
  612. if (pledit_disp_offs >= t - num_songs) pledit_disp_offs = t - num_songs;
  613. InvalidateRect(hwnd, &r, FALSE);
  614. }
  615. return 0;
  616. case WM_WINDOWPOSCHANGED:
  617. if (GetParent(hwnd)) // fix the stupid pl bug?
  618. {
  619. WINDOWPOS *lpwp = (WINDOWPOS*)lParam;
  620. config_pe_width = lpwp->cx;
  621. if (config_pe_height != 14)
  622. {
  623. config_pe_height = lpwp->cy;
  624. if (hPLVisWindow)
  625. {
  626. int x, y, w, h;
  627. x = config_pe_width - 150 - 75 + 2;
  628. y = config_pe_height - 26;
  629. w = (config_pe_width >= 350 && config_pe_height != 14 ? 72 : 0);
  630. h = 16;
  631. SetWindowPos(hPLVisWindow, 0, x, y, w, h, SWP_NOZORDER | SWP_NOACTIVATE);
  632. }
  633. }
  634. break;
  635. } else {
  636. // update the position of the tooltips on window resize
  637. set_pl_wnd_tooltip();
  638. }
  639. break;
  640. case WM_CREATE:
  641. hPLWindow = hwnd;
  642. SetTimer(hwnd, 1, 100, NULL);
  643. draw_reinit_plfont(0);
  644. SetWindowLongPtrW(hwnd, GWLP_USERDATA, (config_keeponscreen&2) ? 0x49474541 : 0);
  645. if (NULL != WASABI_API_APP) WASABI_API_APP->app_registerGlobalWindow(hwnd);
  646. {
  647. if (!config_embedwnd_freesize) config_pe_width -= config_pe_width % 25;
  648. if (config_pe_width < 275) config_pe_width = 275;
  649. if (config_pe_height != 14)
  650. {
  651. if (!config_embedwnd_freesize) config_pe_height -= config_pe_height % 29;
  652. if (config_pe_height < 116) config_pe_height = 116;
  653. config_pe_height_ws = 0;
  654. }
  655. else
  656. {
  657. if (!config_embedwnd_freesize) config_pe_height_ws -= config_pe_height_ws % 29;
  658. if (config_pe_height_ws < 116) config_pe_height_ws = 116;
  659. }
  660. SetWindowLong(hwnd, GWL_STYLE, GetWindowLongW(hwnd, GWL_STYLE)&~(WS_CAPTION));
  661. SetWindowPos(hwnd, 0, config_pe_wx, config_pe_wy, config_pe_width, config_pe_height, SWP_NOACTIVATE | SWP_NOZORDER);
  662. HACCEL hAccel = LoadAcceleratorsW(language_pack_instance, MAKEINTRESOURCEW(IDR_ACCELERATOR_PL));
  663. if (!hAccel && language_pack_instance != hMainInstance) hAccel = LoadAcceleratorsW(hMainInstance, MAKEINTRESOURCEW(IDR_ACCELERATOR_PL));
  664. if (hAccel) WASABI_API_APP->app_addAccelerators(hwnd, &hAccel, 1, TRANSLATE_MODE_NORMAL);
  665. }
  666. return 0;
  667. case WM_DESTROY:
  668. KillTimer(hwnd, 1);
  669. KillTimer(hwnd, 3);
  670. if (pe_init)
  671. draw_pe_kill();
  672. if (NULL != WASABI_API_APP) WASABI_API_APP->app_unregisterGlobalWindow(hwnd);
  673. return 0;
  674. case WM_TIMER:
  675. if (wParam == 3)
  676. {
  677. KillTimer(hwnd, 3);
  678. if (!IsMinimized(hMainWindow))
  679. {
  680. ShowWindow(hwnd, SW_SHOWNA);
  681. }
  682. SendMessageW(hwnd, WM_USER, 666, PlayList_getPosition());
  683. // works around a quirk with Bento docked to the right-hand edge
  684. // where the pledit is left docked on reverting to classic skin (dro)
  685. if(!GetParent(hwnd)) set_aot(1);
  686. }
  687. else if (wParam == 1)
  688. {
  689. static int a;
  690. if (!a && config_pe_height != 14 && config_pe_open && (config_riol == 0 || config_riol == 4) && !peui_isrbuttoncaptured())
  691. {
  692. int start, end, view_start, pl_len;
  693. a = 1;
  694. start = pledit_disp_offs;
  695. end = start + (config_pe_height - 38 - 20 - 2) / pe_fontheight;
  696. if (start < 0) start = 0;
  697. pl_len = PlayList_getlength();
  698. if (end > pl_len || config_riol == 4) end = pl_len;
  699. view_start = start;
  700. while (start < end)
  701. {
  702. if (!PlayList_getcached(start))
  703. {
  704. RECT r1 = {12, 20 + (start - pledit_disp_offs) * pe_fontheight,
  705. config_pe_width - 20, 20 + (start + 1 - pledit_disp_offs) * pe_fontheight};
  706. PlayList_updateitem(start);
  707. if (PlayList_getcached(start))
  708. {
  709. InvalidateRect(hwnd, &r1, FALSE);
  710. if(config_riol == 4)
  711. InvalidateRect(hwnd, NULL, FALSE);
  712. break;
  713. }
  714. }
  715. start++;
  716. // if we got to the end of the viewable area / playlist contents
  717. // then we loop to the start so we can try to read all the titles
  718. // and back to the point just before the current top of list point
  719. if(config_riol == 4 && start == end && end == pl_len){
  720. start = 0;
  721. end = view_start;
  722. }
  723. }
  724. a = 0;
  725. }
  726. }
  727. return 0;
  728. case WM_USER:
  729. switch (wParam)
  730. {
  731. case 666:
  732. {
  733. RECT r = {12, 22, config_pe_width - 3, config_pe_height - 37};
  734. int num_songs = (config_pe_height - 38 - 20 - 2) / pe_fontheight;
  735. int p = (lParam & ((1 << 30) - 1)), t;
  736. int brep = !(lParam & (1 << 30));
  737. int needrepaint = 1;
  738. t = PlayList_getlength();
  739. if (config_pe_height == 14)
  740. {
  741. RECT r2 = {0, 0, config_pe_width, 14};
  742. r = r2;
  743. num_songs = (config_pe_height_ws - 38 - 20 - 2) / pe_fontheight;
  744. }
  745. if (p >= pledit_disp_offs + num_songs || p < pledit_disp_offs)
  746. {
  747. if (brep)
  748. {
  749. pledit_disp_offs = max(p - num_songs / 2, 0);
  750. if (pledit_disp_offs + num_songs > t)
  751. pledit_disp_offs = t - num_songs;
  752. }
  753. else needrepaint = 0;
  754. }
  755. if (brep)
  756. {
  757. if (num_songs >= t || pledit_disp_offs < 0)
  758. {
  759. pledit_disp_offs = 0;
  760. }
  761. }
  762. if (needrepaint && IsWindowVisible(hwnd)) InvalidateRect(hwnd, &r, FALSE);
  763. }
  764. break;
  765. case IPC_PE_GETDIRTY:
  766. return plmodified;
  767. case IPC_PE_SETCLEAN:
  768. plmodified = 0;
  769. break;
  770. case IPC_PE_GETNEXTSELECTED:
  771. return PlayList_GetNextSelected(lParam);
  772. case IPC_PE_GETSELECTEDCOUNT:
  773. return PlayList_GetSelectedCount();
  774. case IPC_PE_GETCURINDEX:
  775. return PlayList_getPosition();
  776. case IPC_PE_GETINDEXTOTAL:
  777. return PlayList_getlength();
  778. case IPC_PE_DELETEINDEX:
  779. {
  780. if (lParam < PlayList_getlength())
  781. {
  782. PlayList_deleteitem(lParam);
  783. }
  784. InvalidateRect(hwnd, NULL, FALSE);
  785. if (!g_has_deleted_current)
  786. {
  787. PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
  788. draw_songname(FileTitle, &ui_songposition, playing ? in_getlength() : PlayList_getcurrentlength());
  789. }
  790. break;
  791. }
  792. case IPC_PE_SWAPINDEX:
  793. {
  794. PlayList_swap(lParam & 0xFFFF, (lParam & 0xFFFF0000) >> 16);
  795. InvalidateRect(hwnd, NULL, FALSE);
  796. if (!g_has_deleted_current)
  797. {
  798. PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
  799. draw_songname(FileTitle, &ui_songposition, playing ? in_getlength() : PlayList_getcurrentlength());
  800. }
  801. break;
  802. }
  803. case IPC_PE_GETIDXFROMPOINT:
  804. {
  805. POINT *p = (POINT *) lParam;
  806. int t;
  807. if (config_pe_height == 14) return PlayList_getlength();
  808. else
  809. {
  810. t = (p->y - 20) / pe_fontheight;
  811. if (t < 0) t = 0;
  812. else if (t > (config_pe_height - 38 - 20 - 2) / pe_fontheight) t = PlayList_getlength();
  813. else t += pledit_disp_offs;
  814. }
  815. return t;
  816. }
  817. case IPC_PE_SAVEEND:
  818. se_a = PlayList_getlength();
  819. PlayList_saveend(se_t = (int)lParam);
  820. se_lp = PlayList_getPosition();
  821. break;
  822. case IPC_PE_RESTOREEND:
  823. PlayList_restoreend();
  824. if (se_t <= PlayList_getPosition())
  825. {
  826. PlayList_setposition(se_lp + PlayList_getlength() - se_a);
  827. if (!g_has_deleted_current)
  828. {
  829. PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
  830. draw_songname(FileTitle, &ui_songposition, playing ? in_getlength() : PlayList_getcurrentlength());
  831. }
  832. }
  833. plEditRefresh();
  834. break;
  835. case IPC_PE_GETINDEXTITLE:
  836. if (lParam)
  837. {
  838. fileinfo2 *fi = (fileinfo2 *)lParam;
  839. return PlayList_getitem3(fi->fileindex, fi->filetitle, fi->filelength);
  840. }
  841. break;
  842. case IPC_PE_GETINDEXTITLEW:
  843. if (lParam)
  844. {
  845. fileinfo2W *fi = (fileinfo2W *)lParam;
  846. return PlayList_getitem3W(fi->fileindex, fi->filetitle, fi->filelength);
  847. }
  848. break;
  849. case IPC_PE_GETINDEXINFO_INPROC:
  850. if (lParam)
  851. {
  852. fileinfo *fi = (fileinfo *)lParam;
  853. char tempfile[FILENAME_SIZE]="";
  854. PlayList_getitem2(fi->index, tempfile, NULL);
  855. StringCbCopyA(fi->file, MAX_PATH, tempfile);
  856. }
  857. break;
  858. case IPC_PE_GETINDEXINFOW_INPROC:
  859. if (lParam)
  860. {
  861. fileinfoW *fi = (fileinfoW *)lParam;
  862. wchar_t tempfile[FILENAME_SIZE]=L"";
  863. PlayList_getitem2W(fi->index, tempfile, NULL);
  864. StringCbCopyW(fi->file, sizeof(fi->file), tempfile);
  865. }
  866. break;
  867. }
  868. return 0;
  869. case WM_COPYDATA:
  870. {
  871. COPYDATASTRUCT *cds = (COPYDATASTRUCT *)lParam;
  872. switch (cds->dwData)
  873. {
  874. case IPC_PE_INSERTFILENAME:
  875. {
  876. fileinfo *f = (fileinfo *)(cds->lpData);
  877. if (f && *f->file)
  878. {
  879. int oldposition = PlayList_getPosition();
  880. int oldSize = PlayList_getlength();
  881. PlayList_saveend(f->index);
  882. PlayList_appendthing(AutoWideFn(f->file), 0, 0);
  883. PlayList_restoreend();
  884. if (oldposition >= f->index)
  885. {
  886. oldposition += (PlayList_getlength() - oldSize);
  887. PlayList_setposition(oldposition);
  888. }
  889. InvalidateRect(hwnd, NULL, FALSE);
  890. if (!g_has_deleted_current)
  891. {
  892. PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
  893. draw_songname(FileTitle, &ui_songposition, playing ? in_getlength() : PlayList_getcurrentlength());
  894. }
  895. }
  896. return TRUE;
  897. }
  898. case IPC_PE_INSERTFILENAMEW:
  899. {
  900. fileinfoW *f = (fileinfoW *)(cds->lpData);
  901. if (f && *f->file)
  902. {
  903. int oldposition = PlayList_getPosition();
  904. int oldSize = PlayList_getlength();
  905. PlayList_saveend(f->index);
  906. PlayList_appendthing(f->file, 0, 0);
  907. PlayList_restoreend();
  908. if (oldposition >= f->index)
  909. {
  910. oldposition += (PlayList_getlength() - oldSize);
  911. PlayList_setposition(oldposition);
  912. }
  913. InvalidateRect(hwnd, NULL, FALSE);
  914. if (!g_has_deleted_current)
  915. {
  916. PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
  917. draw_songname(FileTitle, &ui_songposition, playing ? in_getlength() : PlayList_getcurrentlength());
  918. }
  919. }
  920. return TRUE;
  921. }
  922. case IPC_PE_GETINDEXINFO:
  923. {
  924. callbackinfo *i = (callbackinfo *)(cds->lpData);
  925. if (i && i->callback)
  926. {
  927. COPYDATASTRUCT cdsr;
  928. fileinfo f;
  929. cdsr.dwData = IPC_PE_GETINDEXINFORESULT;
  930. char tempfile[FILENAME_SIZE]="";
  931. PlayList_getitem2(i->index, tempfile, NULL);
  932. StringCbCopyA(f.file, sizeof(f.file), tempfile);
  933. f.index = i->index;
  934. cdsr.lpData = (void *) & f;
  935. cdsr.cbData = sizeof(fileinfo);
  936. SendMessageW(i->callback, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cdsr);
  937. return 0;
  938. }
  939. return TRUE;
  940. }
  941. case IPC_PE_GETINDEXINFO_TITLE:
  942. {
  943. callbackinfo *i = (callbackinfo *)(cds->lpData);
  944. if (i && i->callback)
  945. {
  946. COPYDATASTRUCT cdsr;
  947. fileinfo f;
  948. cdsr.dwData = IPC_PE_GETINDEXINFORESULT_TITLE;
  949. PlayList_getitem3(i->index, f.file, NULL);
  950. f.index = i->index;
  951. cdsr.lpData = (void *) & f;
  952. cdsr.cbData = sizeof(fileinfo);
  953. SendMessageW(i->callback, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cdsr);
  954. return 0;
  955. }
  956. return TRUE;
  957. }
  958. }
  959. }
  960. return FALSE;
  961. case WM_COMMAND:
  962. switch (LOWORD(wParam))
  963. {
  964. case ID_PE_SHOWPLAYING:
  965. plEditSelect(PlayList_getPosition());
  966. return 0;
  967. case WINAMP_OPTIONS_WINDOWSHADE:
  968. SendMessageW(hMainWindow, WM_COMMAND, WINAMP_OPTIONS_WINDOWSHADE_PL, 0);
  969. return 0;
  970. case ID_PE_FFOD:
  971. {
  972. int x, v;
  973. wchar_t fn[FILENAME_SIZE] = {0};
  974. v = PlayList_getlength();
  975. for (x = 0; x < v; x++)
  976. {
  977. if (PlayList_getselect(x)
  978. #ifdef WINAMP_FINAL_BUILD
  979. && !PlayList_gethidden(x) && !PlayList_hasanycurtain(x)
  980. #endif
  981. )
  982. {
  983. if (!PlayList_getitem2W(x, fn, NULL))
  984. {
  985. // show the playlist file entry of the selected item(s) if there were any
  986. explorerFindFileManager->AddFile(fn);
  987. }
  988. }
  989. }
  990. explorerFindFileManager->ShowFiles();
  991. return 0;
  992. }
  993. case ID_PE_BOOKMARK:
  994. {
  995. int x, v;
  996. wchar_t fn[FILENAME_SIZE] = {0}, ft[FILETITLE_SIZE] = {0};
  997. v = PlayList_getlength();
  998. for (x = 0; x < v; x++)
  999. {
  1000. if (PlayList_getselect(x)
  1001. #ifdef WINAMP_FINAL_BUILD
  1002. && !PlayList_gethidden(x) && !PlayList_hasanycurtain(x)
  1003. #endif
  1004. )
  1005. {
  1006. PlayList_getitem2W(x, fn, ft);
  1007. Bookmark_additem(fn, ft);
  1008. }
  1009. }
  1010. }
  1011. return 0;
  1012. case ID_PE_EXTINFO:
  1013. {
  1014. wchar_t ft[FILETITLE_SIZE] = {0};
  1015. RECT r = {0, 0, config_pe_width, config_pe_height - 37};
  1016. int v = PlayList_getlength();
  1017. for (int x = 0; x < v; x++)
  1018. {
  1019. if (PlayList_getselect(x)
  1020. #ifdef WINAMP_FINAL_BUILD
  1021. && !PlayList_gethidden(x) && !PlayList_hasanycurtain(x)
  1022. #endif
  1023. )
  1024. {
  1025. wchar_t fn[FILENAME_SIZE] = {0};
  1026. PlayList_getitem(x, fn, ft);
  1027. SendMessageW(hMainWindow, WM_WA_IPC, (WPARAM)fn, IPC_FILE_TAG_MAY_UPDATEW);
  1028. PlayList_setitem(x, fn, PlayList_gettitle(fn, 1));
  1029. PlayList_setlastlen(x);
  1030. }
  1031. }
  1032. InvalidateRect(hwnd, &r, FALSE);
  1033. }
  1034. return 0;
  1035. case ID_PE_PRINT:
  1036. doHtmlPlaylist();
  1037. return 0;
  1038. case WINAMP_NEXT_WINDOW:
  1039. return SendMessageW(hMainWindow, uMsg, wParam, lParam);
  1040. case ID_PE_OPEN:
  1041. {
  1042. //int isvisible = IsWindowVisible(hwnd);
  1043. if (!playlist_open(/*isvisible ? hwnd :*/ (g_dialog_box_parent ? g_dialog_box_parent : hMainWindow))) break;
  1044. }
  1045. return 0;
  1046. case ID_PE_EDIT_SEL:
  1047. if (PlayList_GetNextSelected(-1) != -1)
  1048. {
  1049. extern INT_PTR CALLBACK EditInfo(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  1050. LPDialogBoxW(IDD_EDIT_INFO, hwnd, EditInfo);
  1051. }
  1052. return 0;
  1053. case ID_PE_ID3:
  1054. {
  1055. int x, v;
  1056. wchar_t ft[FILETITLE_SIZE] = {0};
  1057. v = PlayList_getlength();
  1058. for (x = 0; x < v; x++)
  1059. {
  1060. if (PlayList_getselect(x)
  1061. #ifdef WINAMP_FINAL_BUILD
  1062. && !PlayList_gethidden(x) && !PlayList_hasanycurtain(x)
  1063. #endif
  1064. )
  1065. {
  1066. wchar_t fn[FILENAME_SIZE] = {0};
  1067. PlayList_getitem(x, fn, ft);
  1068. if (in_infobox(hwnd, fn)) break;
  1069. PlayList_setitem(x, fn, PlayList_gettitle(fn, 1));
  1070. PlayList_setlastlen(x);
  1071. }
  1072. }
  1073. {
  1074. RECT r = {0, 0, config_pe_width, config_pe_height - 37};
  1075. InvalidateRect(hwnd, &r, FALSE);
  1076. }
  1077. }
  1078. return 0;
  1079. case ID_PE_CLEAR:
  1080. PlayList_delete();
  1081. PlayList_randpos(0);
  1082. {
  1083. RECT r = {0, 0, config_pe_width, config_pe_height - 37};
  1084. InvalidateRect(hwnd, &r, FALSE);
  1085. }
  1086. return 0;
  1087. case IDC_SELECTINV:
  1088. {
  1089. int x, v;
  1090. v = PlayList_getlength();
  1091. for (x = 0; x < v; x ++)
  1092. {
  1093. PlayList_setselect(x, !PlayList_getselect(x));
  1094. }
  1095. {
  1096. RECT r = {0, 0, config_pe_width, config_pe_height - 37};
  1097. InvalidateRect(hwnd, &r, FALSE);
  1098. }
  1099. }
  1100. return 0;
  1101. case ID_PE_SELECTALL:
  1102. {
  1103. int x, v;
  1104. v = PlayList_getlength();
  1105. for (x = 0; x < v; x ++)
  1106. {
  1107. PlayList_setselect(x, 1);
  1108. }
  1109. {
  1110. RECT r = {0, 0, config_pe_width, config_pe_height - 37};
  1111. InvalidateRect(hwnd, &r, FALSE);
  1112. }
  1113. }
  1114. return 0;
  1115. case ID_PE_NONE:
  1116. {
  1117. int x, v;
  1118. v = PlayList_getlength();
  1119. for (x = 0; x < v; x ++)
  1120. {
  1121. PlayList_setselect(x, 0);
  1122. }
  1123. {
  1124. RECT r = {0, 0, config_pe_width, config_pe_height - 37};
  1125. InvalidateRect(hwnd, &r, FALSE);
  1126. }
  1127. }
  1128. return 0;
  1129. case ID_PE_ENTRY:
  1130. {
  1131. int x, v;
  1132. wchar_t ft[FILETITLE_SIZE] = {0};
  1133. v = PlayList_getlength();
  1134. for (x = 0; x < v; x ++)
  1135. {
  1136. if (PlayList_getselect(x)
  1137. #ifdef WINAMP_FINAL_BUILD
  1138. && !PlayList_gethidden(x) && !PlayList_hasanycurtain(x)
  1139. #endif
  1140. )
  1141. {
  1142. wchar_t itrFilename[FILENAME_SIZE] = {0};
  1143. PlayList_getitem(x, itrFilename, ft);
  1144. StringCchCopyW(entryFN, FILENAME_SIZE, itrFilename);
  1145. if (!LPDialogBoxW(IDD_EDITENTRY, DIALOG_PARENT(hwnd), (WNDPROC)entryProc))
  1146. {
  1147. SetFocus(hwnd);
  1148. break;
  1149. }
  1150. SetFocus(hwnd);
  1151. PlayList_setitem(x, entryFN, PlayList_gettitle(entryFN, 1));
  1152. }
  1153. }
  1154. RECT r = {0, 0, config_pe_width, config_pe_height - 37};
  1155. InvalidateRect(hwnd, &r, FALSE);
  1156. }
  1157. return 0;
  1158. case ID_PE_SAVEAS:
  1159. savepls(hwnd);
  1160. return 0;
  1161. case IDC_PLAYLIST_CROP:
  1162. {
  1163. int v = PlayList_getlength();
  1164. int x;
  1165. for (x = 0; x < v; x ++)
  1166. if (PlayList_getselect(x)) break;
  1167. if (x != v) for (x = v - 1; x >= 0; x--)
  1168. {
  1169. if (!PlayList_getselect(x))
  1170. {
  1171. PlayList_deleteitem(x);
  1172. }
  1173. }
  1174. {
  1175. RECT r = {0, 0, config_pe_width, config_pe_height - 37};
  1176. InvalidateRect(hwnd, &r, FALSE);
  1177. }
  1178. }
  1179. return 0;
  1180. case IDC_PLAYLIST_REMOVEMP3:
  1181. {
  1182. int v = PlayList_getlength(), x;
  1183. for (x = v - 1; x >= 0; x--)
  1184. {
  1185. if (PlayList_getselect(x))
  1186. {
  1187. PlayList_deleteitem(x);
  1188. }
  1189. }
  1190. InvalidateRect(hwnd, NULL, FALSE);
  1191. if (!g_has_deleted_current)
  1192. {
  1193. PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
  1194. draw_songname(FileTitle, &ui_songposition, playing ? in_getlength() : PlayList_getcurrentlength());
  1195. }
  1196. }
  1197. return 0;
  1198. case ID_PEPLAYLIST_PLAYLISTPREFERENCES:
  1199. prefs_last_page = 23;
  1200. prefs_dialog(1);
  1201. return 0;
  1202. case ID_PE_SCUP:
  1203. case ID_PE_SCDOWN:
  1204. // TODO: need to make the shift action more like Windows so it'll shrink the selection down rather than making it grow
  1205. // ideally need to keep a record of the 'current selection' so we can then adjust from there-will be interesting
  1206. if (config_pe_height != 14)
  1207. {
  1208. RECT r = {0, 0, config_pe_width, config_pe_height - 37};
  1209. int which;
  1210. int x;
  1211. int num_songs = (config_pe_height - 38 - 20 - 2) / pe_fontheight;
  1212. if (LOWORD(wParam) == ID_PE_SCUP)
  1213. {
  1214. for (x = pledit_disp_offs; x < pledit_disp_offs + num_songs; x ++) if (PlayList_getselect(x)) break;
  1215. if (x != pledit_disp_offs + num_songs) which = x - 1;
  1216. else which = pledit_disp_offs;
  1217. }
  1218. else
  1219. {
  1220. for (x = pledit_disp_offs + num_songs - 1; x >= pledit_disp_offs; x--) if (PlayList_getselect(x)) break;
  1221. if (x >= pledit_disp_offs) which = x + 1;
  1222. else which = pledit_disp_offs + num_songs - 1;
  1223. }
  1224. if (which < 0) which = 0;
  1225. if (which >= PlayList_getlength()) which = PlayList_getlength() - 1;
  1226. if (!(GetAsyncKeyState(VK_SHIFT)&0x8000))
  1227. {
  1228. for (x = PlayList_getlength() - 1; x >= 0; x --) PlayList_setselect(x, 0);
  1229. }
  1230. PlayList_setselect(which, 1);
  1231. if (which < pledit_disp_offs) pledit_disp_offs = which;
  1232. else if (which >= pledit_disp_offs + num_songs)
  1233. pledit_disp_offs = which - num_songs + 1;
  1234. InvalidateRect(hwnd, &r, FALSE);
  1235. }
  1236. else
  1237. {
  1238. if (LOWORD(wParam) == ID_PE_SCUP)
  1239. SendMessageW(hMainWindow, WM_COMMAND, WINAMP_BUTTON1, 0);
  1240. else
  1241. SendMessageW(hMainWindow, WM_COMMAND, WINAMP_BUTTON5, 0);
  1242. }
  1243. return 0;
  1244. case ID_PE_SCROLLDOWN:
  1245. {
  1246. RECT r = {0, 0, config_pe_width, config_pe_height - 37};
  1247. int num_songs = (config_pe_height - 38 - 20 - 2) / pe_fontheight;
  1248. int t = PlayList_getlength();
  1249. pledit_disp_offs += config_plscrollsize;
  1250. if (pledit_disp_offs >= t - num_songs) pledit_disp_offs = t - num_songs;
  1251. InvalidateRect(hwnd, &r, FALSE);
  1252. }
  1253. return 0;
  1254. case ID_PE_SCROLLUP:
  1255. if (pledit_disp_offs > 0)
  1256. {
  1257. RECT r = {0, 0, config_pe_width, config_pe_height - 37};
  1258. pledit_disp_offs -= config_plscrollsize;
  1259. if (pledit_disp_offs < 0) pledit_disp_offs = 0;
  1260. InvalidateRect(hwnd, &r, FALSE);
  1261. }
  1262. return 0;
  1263. case ID_PE_MOVEDOWN:
  1264. {
  1265. extern int shiftsel_1;
  1266. int v = PlayList_getlength();
  1267. RECT r =
  1268. {
  1269. 0, 0, config_pe_width, config_pe_height - 37
  1270. };
  1271. if (!PlayList_getselect(v - 1))
  1272. for (int x = v - 2; x >= 0; x --)
  1273. {
  1274. if (PlayList_getselect(x))
  1275. {
  1276. if (shiftsel_1 == x) shiftsel_1 = x + 1;
  1277. PlayList_swap(x, x + 1);
  1278. if (x == PlayList_getPosition()) PlayList_advance(1);
  1279. else if (x + 1 == PlayList_getPosition()) PlayList_advance(-1);
  1280. }
  1281. }
  1282. InvalidateRect(hwnd, &r, FALSE);
  1283. if (!g_has_deleted_current)
  1284. {
  1285. PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
  1286. draw_songname(FileTitle, &ui_songposition, playing ? in_getlength() : PlayList_getcurrentlength());
  1287. }
  1288. }
  1289. return 0;
  1290. case ID_PE_MOVEUP:
  1291. {
  1292. extern int shiftsel_1;
  1293. int v = PlayList_getlength();
  1294. RECT r =
  1295. {
  1296. 0, 0, config_pe_width, config_pe_height - 37
  1297. };
  1298. if (!PlayList_getselect(0))
  1299. for (int x = 1; x < v; x ++)
  1300. {
  1301. if (PlayList_getselect(x))
  1302. {
  1303. if (shiftsel_1 == x) shiftsel_1 = x + 1;
  1304. PlayList_swap(x, x - 1);
  1305. if (x == PlayList_getPosition()) PlayList_advance(-1);
  1306. else if (x - 1 == PlayList_getPosition()) PlayList_advance(1);
  1307. }
  1308. }
  1309. InvalidateRect(hwnd, &r, FALSE);
  1310. if (!g_has_deleted_current)
  1311. {
  1312. PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
  1313. draw_songname(FileTitle, &ui_songposition, playing ? in_getlength() : PlayList_getcurrentlength());
  1314. }
  1315. return 0;
  1316. }
  1317. case ID_PE_CLOSE:
  1318. SendMessageW(hMainWindow, WM_COMMAND, WINAMP_OPTIONS_PLEDIT, 0);
  1319. return 0;
  1320. case IDC_PLAYLIST_ADDMP3:
  1321. //getNewFile(0, hwnd, 0); // changed May-10-2005 benski
  1322. getNewFile(0, /*NULL*/DIALOG_PARENT(hMainWindow), 0);
  1323. {
  1324. RECT r = {0, 0, config_pe_width, config_pe_height - 37};
  1325. InvalidateRect(hwnd, &r, FALSE);
  1326. }
  1327. SetFocus(hwnd);
  1328. SetForegroundWindow(hwnd);
  1329. return 0;
  1330. case IDC_PLAYLIST_ADDLOC:
  1331. getNewLocation(0, hwnd);
  1332. {
  1333. RECT r = {0, 0, config_pe_width, config_pe_height - 37};
  1334. InvalidateRect(hwnd, &r, FALSE);
  1335. }
  1336. return 0;
  1337. case IDC_PLAYLIST_ADDDIR:
  1338. {
  1339. BROWSEINFOW bi = {0};
  1340. wchar_t name[MAX_PATH] = {0};
  1341. bi.hwndOwner = hwnd;
  1342. bi.pszDisplayName = name;
  1343. bi.lpszTitle = L"__foo";
  1344. bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
  1345. bi.lpfn = BrowseCallbackProc;
  1346. bi.lParam = 1;
  1347. ITEMIDLIST *idlist = SHBrowseForFolderW(&bi);
  1348. if (idlist)
  1349. {
  1350. int s = PlayList_getlength();
  1351. wchar_t path[MAX_PATH] = {0};
  1352. SHGetPathFromIDListW(idlist, path);
  1353. Shell_Free(idlist);
  1354. WASABI_API_APP->path_setWorkingPath(path);
  1355. //SetCurrentDirectoryW(path);
  1356. PlayList_adddir(path, (config_rofiob&2) ? 0 : 1);
  1357. if (config_rofiob&1)
  1358. PlayList_sort(2, s);
  1359. RECT r = {0, 0, config_pe_width, config_pe_height - 37};
  1360. InvalidateRect(hwnd, &r, FALSE);
  1361. }
  1362. }
  1363. return 0;
  1364. case IDC_PLAYLIST_PLAY:
  1365. {
  1366. int x, v = PlayList_getlength();
  1367. for (x = 0; x < v; x ++)
  1368. {
  1369. if (PlayList_getselect(x)) break;
  1370. }
  1371. if (x != v)
  1372. {
  1373. PlayList_setposition(x);
  1374. PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
  1375. StartPlaying();
  1376. SetForegroundWindow(hwnd);
  1377. }
  1378. }
  1379. return 0;
  1380. case ID_PE_S_TITLE:
  1381. case ID_PE_S_FILENAME:
  1382. case ID_PE_S_PATH:
  1383. case ID_PE_S_RANDOM:
  1384. case ID_PE_S_REV:
  1385. {
  1386. int num_songs = (config_pe_height - 38 - 20 - 2) / pe_fontheight;
  1387. int w = 0;
  1388. if (LOWORD(wParam) == ID_PE_S_TITLE) w = 1;
  1389. else if (LOWORD(wParam) == ID_PE_S_PATH) w = 2;
  1390. else if (LOWORD(wParam) == ID_PE_S_FILENAME) w = 0;
  1391. else if (LOWORD(wParam) == ID_PE_S_RANDOM) w = 3;
  1392. else if (LOWORD(wParam) == ID_PE_S_REV) w = 4;
  1393. if (w == 3) PlayList_randomize();
  1394. else if (w == 4) PlayList_reverse();
  1395. else if (w <= 2) PlayList_sort(w, 0);
  1396. pledit_disp_offs = PlayList_getPosition();
  1397. if (pledit_disp_offs + num_songs > PlayList_getlength())
  1398. pledit_disp_offs = PlayList_getlength() - num_songs;
  1399. if (pledit_disp_offs < 0) pledit_disp_offs = 0;
  1400. InvalidateRect(hwnd, NULL, FALSE);
  1401. if (!g_has_deleted_current)
  1402. {
  1403. PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
  1404. draw_songname(FileTitle, &ui_songposition, playing ? in_getlength() : PlayList_getcurrentlength());
  1405. }
  1406. }
  1407. break;
  1408. case ID_PE_DELETEFROMDISK:
  1409. {
  1410. int v, x;
  1411. v = PlayList_getlength();
  1412. for (x = v - 1; x >= 0; x --)
  1413. {
  1414. if (PlayList_getselect(x))
  1415. {
  1416. wchar_t fn[FILENAME_SIZE] = {0};
  1417. PlayList_getitem(x, fn, NULL);
  1418. if (!PathIsURLW(fn))
  1419. {
  1420. SHFILEOPSTRUCTW fileOp = {0};
  1421. wchar_t file[FILENAME_SIZE] = {0};
  1422. StringCchCopyW(file, FILENAME_SIZE - 1, fn);
  1423. file[ wcslen(fn) + 1] = 0; // double null terminate;
  1424. fileOp.hwnd = hwnd;
  1425. fileOp.wFunc = FO_DELETE;
  1426. fileOp.pFrom = file;
  1427. fileOp.pTo = 0;
  1428. fileOp.fFlags = config_playlist_recyclebin ? FOF_ALLOWUNDO : 0;
  1429. fileOp.fAnyOperationsAborted = 0;
  1430. fileOp.hNameMappings = 0;
  1431. fileOp.lpszProgressTitle = 0;
  1432. if (SHFileOperationW(&fileOp))
  1433. {
  1434. wchar_t mes[4096] = {0};
  1435. StringCchPrintfW(mes, 4096, getStringW(IDS_ERROR_DELETING,NULL,0), fn);
  1436. MessageBoxW(hwnd, mes, getStringW(IDS_ERROR,NULL,0), MB_OK);
  1437. }
  1438. else
  1439. {
  1440. // only remove if the deletion actually went ahead
  1441. if(!fileOp.fAnyOperationsAborted)
  1442. PlayList_deleteitem(x);
  1443. }
  1444. }
  1445. }
  1446. }
  1447. {
  1448. RECT r = {0, 0, config_pe_width, config_pe_height - 37};
  1449. InvalidateRect(hwnd, &r, FALSE);
  1450. }
  1451. }
  1452. break;
  1453. case ID_PE_NONEXIST:
  1454. {
  1455. int x, v;
  1456. v = PlayList_getlength();
  1457. for (x = v - 1; x >= 0; x --)
  1458. {
  1459. wchar_t fn[FILENAME_SIZE] = {0};
  1460. FILE *fp = NULL;
  1461. PlayList_getitem(x, fn, NULL);
  1462. fp = _wfopen(fn, L"rb");
  1463. if (!PathIsURLW(fn) && !(fp/* = _wfopen(fn, L"rb")*/))
  1464. {
  1465. PlayList_deleteitem(x);
  1466. }
  1467. else
  1468. {
  1469. if (fp) fclose(fp);
  1470. }
  1471. }
  1472. {
  1473. RECT r = {0, 0, config_pe_width, config_pe_height - 37};
  1474. InvalidateRect(hwnd, &r, FALSE);
  1475. }
  1476. }
  1477. break;
  1478. case ID_PE_TOP:
  1479. if (config_pe_height != 14)
  1480. {
  1481. pledit_disp_offs = 0;
  1482. {
  1483. RECT r = {0, 0, config_pe_width, config_pe_height - 37};
  1484. InvalidateRect(hwnd, &r, FALSE);
  1485. }
  1486. }
  1487. break;
  1488. case ID_PE_BOTTOM:
  1489. if (config_pe_height != 14)
  1490. {
  1491. pledit_disp_offs = PlayList_getlength() - (config_pe_height - 38 - 20 - 2) / pe_fontheight;
  1492. if (pledit_disp_offs < 0) pledit_disp_offs = 0;
  1493. {
  1494. RECT r = {0, 0, config_pe_width, config_pe_height - 37};
  1495. InvalidateRect(hwnd, &r, FALSE);
  1496. }
  1497. }
  1498. break;
  1499. case ID_PE_FONTBIGGER:
  1500. case ID_PE_FONTSMALLER:
  1501. case ID_PE_FONTRESET:
  1502. switch (LOWORD(wParam))
  1503. {
  1504. case ID_PE_FONTBIGGER:
  1505. config_pe_fontsize++;
  1506. break;
  1507. case ID_PE_FONTSMALLER:
  1508. if (config_pe_fontsize > 2) config_pe_fontsize--;
  1509. break;
  1510. case ID_PE_FONTRESET:
  1511. config_pe_fontsize = PE_FONTSIZE;
  1512. break;
  1513. }
  1514. if (hMainWindow)
  1515. {
  1516. draw_reinit_plfont(1);
  1517. InvalidateRect(hwnd, NULL, FALSE);
  1518. }
  1519. UpdatePlaylistFontSizeText();
  1520. _w_i("pe_fontsize", config_pe_fontsize);
  1521. break;
  1522. default:
  1523. SendMessageW(hMainWindow, uMsg, wParam, lParam);
  1524. if (GetForegroundWindow() == hMainWindow) SetForegroundWindow(hEQWindow);
  1525. return 0;
  1526. }
  1527. return 0;
  1528. case WM_USER + 0xebe:
  1529. if (lParam != 0xdeadbeef) break;
  1530. case WM_DROPFILES:
  1531. {
  1532. wchar_t temp[FILENAME_SIZE] = {0};
  1533. int x, y, a, t, lp;
  1534. HDROP h = (HDROP)(HANDLE) wParam;
  1535. POINT dp;
  1536. DragQueryPoint(h, &dp);
  1537. if (config_pe_height == 14) t = PlayList_getlength();
  1538. else
  1539. {
  1540. t = (dp.y - 20) / pe_fontheight;
  1541. if (t < 0) t = 0;
  1542. else if (t > (config_pe_height - 38 - 20 - 2) / pe_fontheight) t = PlayList_getlength();
  1543. else t += pledit_disp_offs;
  1544. }
  1545. y = DragQueryFileW(h, 0xffffffff, temp, FILENAME_SIZE);
  1546. a = PlayList_getlength();
  1547. PlayList_saveend(t);
  1548. lp = PlayList_getPosition();
  1549. for (x = 0; x < y; x ++)
  1550. {
  1551. DragQueryFileW(h, x, temp, FILENAME_SIZE);
  1552. PlayList_appendthing(temp, 0, 0);
  1553. }
  1554. PlayList_restoreend();
  1555. if (t <= PlayList_getPosition())
  1556. {
  1557. PlayList_setposition(lp + PlayList_getlength() - a);
  1558. if (!g_has_deleted_current)
  1559. {
  1560. PlayList_getcurrent(FileName, FileTitle, FileTitleNum);
  1561. draw_songname(FileTitle, &ui_songposition, playing ? in_getlength() : PlayList_getcurrentlength());
  1562. }
  1563. }
  1564. if (uMsg == WM_DROPFILES) DragFinish(h);
  1565. plEditRefresh();
  1566. }
  1567. return 0;
  1568. case WM_SETCURSOR:
  1569. if (config_usecursors && !disable_skin_cursors)
  1570. {
  1571. if ((HWND)wParam == hwnd && HIWORD(lParam) == WM_MOUSEMOVE)
  1572. pe_ui_handlecursor(hwnd);
  1573. return TRUE;
  1574. }
  1575. else SetCursor(LoadCursor(NULL, IDC_ARROW));
  1576. break;
  1577. case WM_MOUSEWHEEL:
  1578. {
  1579. int zDelta = GET_WHEEL_DELTA_WPARAM(wParam), dLines;
  1580. // if the delta changes then ignore prior carryover
  1581. // hopefully this will go with the expected action.
  1582. if(zDelta < 0 && pledit_delta_carryover > 0 ||
  1583. zDelta > 0 && pledit_delta_carryover < 0)
  1584. {
  1585. pledit_delta_carryover = 0;
  1586. }
  1587. // otherwise add on the carryover from the prior message
  1588. else zDelta += pledit_delta_carryover;
  1589. if (0 == (MK_MBUTTON & LOWORD(wParam)) &&
  1590. config_plmw2xscroll)
  1591. {
  1592. zDelta *= 2;
  1593. }
  1594. dLines = zDelta / WHEEL_DELTA;
  1595. pledit_delta_carryover = zDelta - dLines * WHEEL_DELTA;
  1596. if (!dLines)
  1597. {
  1598. if (zDelta > 0) dLines = 1;
  1599. else if (zDelta < 0) dLines = 0;
  1600. }
  1601. zDelta = (dLines >= 0) ? dLines : -dLines;
  1602. if (config_pe_height == 14)
  1603. {
  1604. if (dLines >= 0) dLines = WINAMP_BUTTON1;
  1605. else dLines = WINAMP_BUTTON5;
  1606. }
  1607. else
  1608. {
  1609. if (0 != (MK_MBUTTON & LOWORD(wParam)))
  1610. {
  1611. if (dLines >= 0) dLines = ID_PE_MOVEUP;
  1612. else dLines = ID_PE_MOVEDOWN;
  1613. }
  1614. else
  1615. {
  1616. if (dLines >= 0) dLines = ID_PE_SCROLLUP;
  1617. else dLines = ID_PE_SCROLLDOWN;
  1618. }
  1619. }
  1620. while (zDelta--)
  1621. {
  1622. SendMessageW(hwnd, WM_COMMAND, dLines, 0);
  1623. }
  1624. }
  1625. return 1; //FG> or gen_ff gets it too
  1626. }
  1627. if (FALSE != IsDirectMouseWheelMessage(uMsg))
  1628. {
  1629. SendMessageW(hwnd, WM_MOUSEWHEEL, wParam, lParam);
  1630. return TRUE;
  1631. }
  1632. return DefWindowProcW(hwnd, uMsg, wParam, lParam);
  1633. }