draw_main.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696
  1. /** (c) Nullsoft, Inc. C O N F I D E N T I A L
  2. ** Filename:
  3. ** Project:
  4. ** Description:
  5. ** Author:
  6. ** Created:
  7. **/
  8. #include "Main.h"
  9. #include "draw.h"
  10. #include "../nu/AutoWide.h"
  11. HBITMAP tbBM, cbuttonsBM, mainBM2,oldmainBM2, numbersBM, numbersBM_ex,
  12. playpauseBM, posbarBM, monostereoBM, volBM,panBM;
  13. void draw_tbuttons(int b1, int b2, int b3, int b4)
  14. {
  15. setSrcBM(tbBM);
  16. if (b1 != -1) BitBlt(mainDC,6,3,9,9,bmDC,0,b1*9,SRCCOPY);
  17. if (b2 != -1) BitBlt(mainDC,244,3,9,9,bmDC,9,b2*9,SRCCOPY);
  18. if (b3 != -1) BitBlt(mainDC,264,3,9,9,bmDC,18,b3*9,SRCCOPY);
  19. if (b4 != -1) BitBlt(mainDC,254,3,9,9,bmDC,b4*9,config_windowshade?27:18,SRCCOPY);
  20. unsetSrcBM();
  21. update_area(6,3,9,9);
  22. update_area(243,3,274-243,9);
  23. }
  24. void draw_eject(int pressed)
  25. {
  26. RECT r;
  27. if (!draw_initted) return;
  28. r.left = 132+7-4+1;
  29. r.top = 60+14+15;
  30. r.right = r.left+22;
  31. r.bottom = r.top+16;
  32. setSrcBM(cbuttonsBM);
  33. BitBlt(mainDC,r.left,r.top,r.right-r.left,r.bottom-r.top,bmDC,114,(pressed?16:0),SRCCOPY);
  34. unsetSrcBM();
  35. update_rect(r);
  36. }
  37. static void draw_paintDC(HDC hdc, const RECT &r)
  38. {
  39. if (!draw_initted) return;
  40. //int dsize=(config_dsize && config_eqdsize);
  41. int dsize = config_dsize;
  42. do_palmode(hdc);
  43. if (!dsize)
  44. {
  45. BitBlt(hdc,r.left,r.top,r.right-r.left,r.bottom-r.top,mainDC,r.left,r.top,SRCCOPY);
  46. if (mainBM2)
  47. {
  48. SelectObject(mainDC2,oldmainBM2);
  49. DeleteObject(mainBM2);
  50. mainBM2=NULL;
  51. }
  52. }
  53. else
  54. {
  55. if (!mainBM2)
  56. {
  57. mainBM2 = CreateCompatibleBitmap(mainDC,WINDOW_WIDTH*2,WINDOW_HEIGHT*2);
  58. oldmainBM2 = (HBITMAP)SelectObject(mainDC2,mainBM2);
  59. StretchBlt(mainDC2,0,0,WINDOW_WIDTH*2,WINDOW_HEIGHT*2,mainDC,0,0,WINDOW_WIDTH,WINDOW_HEIGHT,SRCCOPY);
  60. }
  61. BitBlt(hdc,r.left,r.top,r.right-r.left,r.bottom-r.top,mainDC2,r.left,r.top,SRCCOPY);
  62. }
  63. }
  64. void draw_printclient(HDC hdc, LPARAM /*drawingOptions*/)
  65. {
  66. RECT r;
  67. GetClientRect(hMainWindow,&r);
  68. draw_paintDC(hdc, r);
  69. }
  70. void draw_paint(HWND hwnd)
  71. {
  72. HDC screenHdc;
  73. PAINTSTRUCT ps;
  74. RECT r;
  75. if (!draw_initted) return;
  76. if (hwnd)
  77. {
  78. GetUpdateRect(hwnd,&ps.rcPaint,0);
  79. EnterCriticalSection(&g_mainwndcs);
  80. screenHdc = BeginPaint(hwnd,&ps);
  81. memcpy(&r,&ps.rcPaint,sizeof(r));
  82. }
  83. else
  84. {
  85. screenHdc = draw_GetWindowDC(hMainWindow);
  86. GetClientRect(hMainWindow,&r);
  87. }
  88. draw_paintDC(screenHdc, r);
  89. if (hwnd)
  90. {
  91. EndPaint(hwnd,&ps);
  92. LeaveCriticalSection(&g_mainwndcs);
  93. }
  94. else
  95. draw_ReleaseDC(hMainWindow,screenHdc);
  96. }
  97. void draw_tbar( int active, int windowshade, int egg )
  98. {
  99. int t[ 4 ] = { 0, 15, 29, 42 };
  100. int l = t[ ( ( active ? 0 : 1 ) + ( windowshade ? 2 : 0 ) ) ];
  101. if ( egg && !windowshade )
  102. l = active ? 57 : 72;
  103. if ( !draw_initted )
  104. return;
  105. setSrcBM( tbBM );
  106. BitBlt( mainDC, 0, 0, WINDOW_WIDTH, 14, bmDC, 27, l, SRCCOPY );
  107. unsetSrcBM();
  108. if ( windowshade && config_windowshade )
  109. {
  110. int pos = 0;
  111. draw_songname( L"", &pos, 0 );
  112. }
  113. update_area( 0, 0, WINDOW_WIDTH, 14 );
  114. }
  115. static int g_need_erase=0;
  116. static int _draw_songname(const wchar_t *str, int startpos, int offs_in_first)
  117. {
  118. int xp;
  119. int o = offs_in_first;
  120. str += startpos;
  121. xp = 111;
  122. if (g_need_erase)
  123. {
  124. IntersectClipRect(mainDC,111,12+13,264,12+15+8);
  125. HGDIOBJ oldBrush=SelectObject(mainDC,mfont_bgbrush);
  126. Rectangle(mainDC,108,12+12,267,12+15+10);
  127. SelectObject(mainDC,oldBrush);
  128. ExtSelectClipRgn(mainDC,NULL,RGN_COPY);
  129. g_need_erase=0;
  130. }
  131. setSrcBM(fontBM);
  132. while (xp < 265 && *str)
  133. {
  134. int c2=0,c=0;
  135. getXYfromChar(*str++,&c,&c2);
  136. if (xp >= 265-5)
  137. {
  138. BitBlt(mainDC,xp,12+15,265-xp,6,bmDC,c,c2,SRCCOPY);
  139. xp = 265;
  140. }
  141. else
  142. {
  143. BitBlt(mainDC,xp,12+15,5-o,6,bmDC,c+o,c2,SRCCOPY);
  144. xp += 5-o;
  145. o = 0;
  146. }
  147. }
  148. while (xp < 265) BitBlt(mainDC,xp++,12+15,1,6,bmDC,4,0,SRCCOPY);
  149. update_area(111,10+15,265-111,10);
  150. unsetSrcBM();
  151. return 0;
  152. }
  153. static int _draw_songname_winfont(const wchar_t *str, int start_pix)
  154. {
  155. RECT r={111-start_pix,12+11,265,12+16+mfont_height};
  156. HGDIOBJ oldBrush;
  157. g_need_erase=1;
  158. IntersectClipRect(mainDC,111,12+12,265,12+16+8);
  159. SetTextColor(mainDC,mfont_fgcolor);
  160. SetBkColor(mainDC,mfont_bgcolor);
  161. oldBrush=SelectObject(mainDC,mfont_bgbrush);
  162. Rectangle(mainDC,108,12+11,268,12+16+10);
  163. SelectObject(mainDC,oldBrush);
  164. DrawTextW(mainDC,str,-1,&r, DT_LEFT | DT_SINGLELINE |DT_NOPREFIX);
  165. ExtSelectClipRgn(mainDC,NULL,RGN_COPY);
  166. update_area(111,12+11,265-111,4+9);
  167. return 0;
  168. }
  169. void draw_time(int minutes, int seconds, int clear) {
  170. int ex=0;
  171. int tlm;
  172. if (!draw_initted) return;
  173. tlm=config_timeleftmode && in_mod && in_mod->is_seekable;
  174. if (tlm)
  175. {
  176. int s;
  177. int tmp=in_getlength();
  178. s = minutes*60+seconds;
  179. s = tmp - s;
  180. if (tmp>0)
  181. {
  182. minutes = s/60;
  183. seconds = -(s%60);
  184. }
  185. else
  186. minutes=seconds=tlm=0;
  187. }
  188. if (config_windowshade)
  189. setSrcBM(fontBM);
  190. else
  191. {
  192. if (numbersBM) setSrcBM(numbersBM);
  193. else
  194. {
  195. setSrcBM(numbersBM_ex);
  196. ex=1;
  197. }
  198. }
  199. if (clear)
  200. {
  201. if (config_windowshade)
  202. {
  203. BitBlt(mainDC,126,4,3,6,bmDC,142,0,SRCCOPY);
  204. BitBlt(mainDC,130,4,3,6,bmDC,142,0,SRCCOPY);
  205. BitBlt(mainDC,130+4,4,5,6,bmDC,142,0,SRCCOPY);
  206. BitBlt(mainDC,130+4+5,4,5,6,bmDC,142,0,SRCCOPY);
  207. BitBlt(mainDC,130+4+5+4+4,4,5,6,bmDC,142,0,SRCCOPY);
  208. BitBlt(mainDC,130+4+5+4+5+4,4,5,6,bmDC,142,0,SRCCOPY);
  209. }
  210. else
  211. {
  212. BitBlt(mainDC,23+7+6,11+15,9,13,bmDC,90,0,SRCCOPY);
  213. if (ex)
  214. BitBlt(mainDC,36+4-2,11+15,9,13,bmDC,90,0,SRCCOPY);
  215. else
  216. BitBlt(mainDC,36+4,32,5,1,bmDC,9,6,SRCCOPY);
  217. BitBlt(mainDC,35+7+6,11+15,9,13,bmDC,90,0,SRCCOPY);
  218. BitBlt(mainDC,47+7+6,11+15,9,13,bmDC,90,0,SRCCOPY);
  219. BitBlt(mainDC,65+7+6,11+15,9,13,bmDC,90,0,SRCCOPY);
  220. BitBlt(mainDC,77+7+6,11+15,9,13,bmDC,90,0,SRCCOPY);
  221. }
  222. }
  223. else
  224. {
  225. if (config_windowshade)
  226. {
  227. if (tlm)
  228. {
  229. if (minutes < 0) minutes=-minutes;
  230. if (seconds < 0) seconds=-seconds;
  231. if (minutes/100)
  232. BitBlt(mainDC,130-4,4,3,6,bmDC,75,6,SRCCOPY);
  233. else
  234. BitBlt(mainDC,130,4,3,6,bmDC,75,6,SRCCOPY);
  235. }
  236. else
  237. {
  238. if (!(minutes/100))
  239. {
  240. BitBlt(mainDC,130,4,3,6,bmDC,142,0,SRCCOPY);
  241. }
  242. BitBlt(mainDC,130-4,4,3,6,bmDC,142,0,SRCCOPY);
  243. }
  244. if (minutes / 100)
  245. BitBlt(mainDC,130-1,4,5,6,bmDC,5*((minutes/100)%10),6,SRCCOPY);
  246. BitBlt(mainDC,130+4,4,5,6,bmDC,5*((minutes/10)%10),6,SRCCOPY);
  247. BitBlt(mainDC,130+4+5,4,5,6,bmDC,5*((minutes)%10),6,SRCCOPY);
  248. BitBlt(mainDC,130+4+5+4+4,4,5,6,bmDC,5*((seconds/10)%10),6,SRCCOPY);
  249. BitBlt(mainDC,130+4+5+4+5+4,4,5,6,bmDC,5*((seconds)%10),6,SRCCOPY);
  250. }
  251. else
  252. {
  253. BitBlt(mainDC,23+7+6,11+15,9,13,bmDC,90,0,SRCCOPY);
  254. if (tlm)
  255. {
  256. int t= 36+4-2;
  257. if (minutes < 0) minutes=-minutes;
  258. if (seconds < 0) seconds=-seconds;
  259. if (minutes/100)
  260. {
  261. BitBlt(mainDC,23+7+6,11+15,9,13,bmDC,((minutes/100)%10)*9,0,SRCCOPY);
  262. // t-=4;
  263. }
  264. if (ex)
  265. BitBlt(mainDC,t-2,11+15,9,13,bmDC,99,0,SRCCOPY);
  266. else
  267. BitBlt(mainDC,t,32,5,1,bmDC,20,6,SRCCOPY);
  268. }
  269. else
  270. {
  271. if (minutes/100)
  272. BitBlt(mainDC,23+7+6,11+15,9,13,bmDC,((minutes/100)%10)*9,0,SRCCOPY);
  273. }
  274. BitBlt(mainDC,35+7+6,11+15,9,13,bmDC,((minutes/10)%10)*9,0,SRCCOPY);
  275. BitBlt(mainDC,47+7+6,11+15,9,13,bmDC,((minutes)%10)*9,0,SRCCOPY);
  276. BitBlt(mainDC,65+7+6,11+15,9,13,bmDC,((seconds/10)%10)*9,0,SRCCOPY);
  277. BitBlt(mainDC,77+7+6,11+15,9,13,bmDC,((seconds)%10)*9,0,SRCCOPY);
  278. }
  279. }
  280. unsetSrcBM();
  281. if (config_pe_open && config_pe_height != 14)
  282. {
  283. draw_pe_timedisp(NULL, minutes,seconds,tlm,clear);
  284. }
  285. if (config_windowshade) update_area(125,4,32,6);
  286. else update_area(36,11+15,96-36+4,13);
  287. }
  288. void draw_playicon(int whichicon) // 0 = none, 1 = play, 2 = stop, 4 = pause, 8 = lost sync play
  289. {
  290. int offset;
  291. RECT r;
  292. if (!draw_initted) return;
  293. r.left = 19+7;
  294. r.top = 13+15;
  295. r.right = r.left+9;
  296. r.bottom = r.top+9;
  297. switch (whichicon)
  298. {
  299. case 0: offset = 27; break;
  300. case 1: offset = 0; break;
  301. case 2: offset = 18; break;
  302. case 4: offset = 9; break;
  303. case 8: offset = 0; break;
  304. default: return;
  305. }
  306. setSrcBM(playpauseBM);
  307. BitBlt(mainDC,r.left,r.top,r.right-r.left,r.bottom-r.top,bmDC,offset,0,SRCCOPY);
  308. r.left -= 2;
  309. r.right = r.left+3;
  310. if (whichicon == 1 || whichicon == 8)
  311. {
  312. offset = (whichicon==1?36:39);
  313. BitBlt(mainDC,r.left,r.top,r.right-r.left,r.bottom-r.top,bmDC,offset,0,SRCCOPY);
  314. }
  315. else
  316. {
  317. r.right = r.left+2;
  318. offset = 27;
  319. BitBlt(mainDC,r.left,r.top,r.right-r.left,r.bottom-r.top,bmDC,offset,0,SRCCOPY);
  320. }
  321. r.right = r.left + 11;
  322. unsetSrcBM();
  323. update_rect(r);
  324. }
  325. void draw_buttonbar(int buttonpressed) // starts at 0 with leftmost, -1 = no button
  326. {
  327. if (!draw_initted) return;
  328. setSrcBM(cbuttonsBM);
  329. if (buttonpressed == -1)
  330. {
  331. BitBlt(mainDC,8+8,58+14+15+1,114,18,bmDC,0,0,SRCCOPY);
  332. }
  333. else
  334. {
  335. int d1[5] = { 0, 23, 46, 69, 92 }; // width of first section
  336. int d2[5] = { 23, 46, 69, 92, 114 }; // start of next button
  337. if (buttonpressed)
  338. BitBlt(mainDC,8+8,58+14+15+1,d1[buttonpressed],18,bmDC,0,0,SRCCOPY);
  339. BitBlt(mainDC,8+8+d1[buttonpressed],58+14+15+1,d2[buttonpressed]-d1[buttonpressed],
  340. 18,bmDC,d1[buttonpressed],18,SRCCOPY);
  341. if (buttonpressed != 4)
  342. BitBlt(mainDC,8+8+d2[buttonpressed],58+14+15+1,114-d2[buttonpressed],18,
  343. bmDC,d2[buttonpressed],0,SRCCOPY);
  344. }
  345. unsetSrcBM();
  346. update_area(8+7,58+14+15,116,20);
  347. }
  348. void draw_bitmixrate(int bitrate, int mixrate)
  349. {
  350. static int l1=-1, l2=-1;
  351. if (bitrate < 0) bitrate= l1;
  352. if (mixrate < 0) mixrate = l2;
  353. if (bitrate < 0) return;
  354. if (!draw_initted) return;
  355. setSrcBM(fontBM);
  356. if (bitrate/10000)
  357. {
  358. if (bitrate/100000) BitBlt(mainDC,111,28+15,5,6,bmDC,(((bitrate/100000)%10))*5,6,SRCCOPY);
  359. else BitBlt(mainDC,111,28+15,5,6,bmDC,100,12,SRCCOPY); // blank
  360. BitBlt(mainDC,111+5,28+15,5,6,bmDC,(((bitrate/10000)%10))*5,6,SRCCOPY);
  361. {
  362. int x,y;
  363. getXYfromChar(L'C',&x,&y);
  364. BitBlt(mainDC,111+5*2,28+15,5,6,bmDC,x,y,SRCCOPY);
  365. }
  366. }
  367. else if (bitrate/1000)
  368. {
  369. BitBlt(mainDC,111,28+15,5,6,bmDC,(((bitrate/1000)%10))*5,6,SRCCOPY);
  370. BitBlt(mainDC,111+5,28+15,5,6,bmDC,(((bitrate/100)%10))*5,6,SRCCOPY);
  371. {
  372. int x,y;
  373. getXYfromChar(L'H',&x,&y);
  374. BitBlt(mainDC,111+5*2,28+15,5,6,bmDC,x,y,SRCCOPY);
  375. }
  376. }
  377. else
  378. {
  379. if (bitrate/100)
  380. BitBlt(mainDC,111,28+15,5,6,bmDC,(((bitrate/100)%10))*5,6,SRCCOPY);
  381. else
  382. BitBlt(mainDC,111,28+15,5,6,bmDC,100,12,SRCCOPY); // blank
  383. if (bitrate/10)
  384. BitBlt(mainDC,111+5,28+15,5,6,bmDC,(((bitrate/10)%10))*5,6,SRCCOPY);
  385. else
  386. BitBlt(mainDC,111+5,28+15,5,6,bmDC,100,12,SRCCOPY);
  387. BitBlt(mainDC,111+5*2,28+15,5,6,bmDC,((bitrate%10))*5,6,SRCCOPY);
  388. }
  389. if (mixrate/10) BitBlt(mainDC,156,28+15,5,6,bmDC,(((mixrate/10)%10))*5,6,SRCCOPY);
  390. else BitBlt(mainDC,156,28+15,5,6,bmDC,100,12,SRCCOPY);
  391. BitBlt(mainDC,156+5,28+15,5,6,bmDC,((mixrate%10))*5,6,SRCCOPY);
  392. unsetSrcBM();
  393. update_area(111,28+15,176-111,6);
  394. l1 = bitrate;
  395. l2 = mixrate;
  396. }
  397. void draw_positionbar(int position, int pressed) // position is 0-256
  398. {
  399. RECT r;
  400. int op=position;
  401. if (!draw_initted) return;
  402. position = (position * (248-29)) / 256;
  403. if (position < 0) position = 0;
  404. if (position > (248-29)) position = 248-29;
  405. r.left = 9+7;
  406. r.top = 57+15;
  407. r.right = r.left+248;
  408. r.bottom = r.top+10;
  409. setSrcBM(posbarBM);
  410. if (position)
  411. BitBlt(mainDC,r.left,r.top,position,r.bottom-r.top,bmDC,0,0,SRCCOPY);
  412. BitBlt(mainDC,r.left+position,r.top,29,10,bmDC,pressed?278:248,0,SRCCOPY);
  413. if (position != 248-29)
  414. BitBlt(mainDC,r.left+position+29,r.top,248-29-position,r.bottom-r.top,
  415. bmDC,position+29,0,SRCCOPY);
  416. unsetSrcBM();
  417. update_rect(r);
  418. if (config_windowshade)
  419. {
  420. int a;
  421. r.left = 226;
  422. r.top=4;
  423. r.right=243;
  424. r.bottom=11;
  425. op = (op * 12) / 256;
  426. if (++op < 1) op = 1;
  427. if (op > 13) op = 13;
  428. if (op < 6) a=0;
  429. else if (op < 9) a=1;
  430. else a=2;
  431. setSrcBM(tbBM);
  432. BitBlt(mainDC,r.left,r.top,r.right-r.left,r.bottom-r.top,bmDC,0,36,SRCCOPY);
  433. BitBlt(mainDC,r.left+op,r.top,3,r.bottom-r.top,bmDC,17+a*3,36,SRCCOPY);
  434. unsetSrcBM();
  435. update_rect(r);
  436. }
  437. }
  438. void draw_monostereo(int value) // 0 is clear, 1 is mono, 2 is stereo, 3 is downmixed stereo
  439. {
  440. static int l = -1;
  441. if (!draw_initted) return;
  442. if (value < 0) value = l;
  443. if (value < 0) return;
  444. setSrcBM(monostereoBM);
  445. BitBlt(mainDC,7+205,41,28,12,bmDC,29,value==1?0:12,SRCCOPY);
  446. BitBlt(mainDC,7+232,41,29,12,bmDC,0,value==2?0:12,SRCCOPY);
  447. unsetSrcBM();
  448. update_area(199,41,7+232+29-199,12);
  449. l = value;
  450. }
  451. void draw_songname(const wchar_t *name, int *out_position, int songlen) // position is the number of chars over it is
  452. {
  453. int position = *out_position;
  454. wchar_t buf[2048];
  455. const wchar_t *draw_buf = buf;
  456. int len_of_str, len_of_spacer;
  457. int mode=!config_bifont;
  458. HGDIOBJ hOldFont;
  459. if (!draw_initted || !name)
  460. return;
  461. if (*name)
  462. {
  463. static int hold;
  464. if (songlen >= 0)
  465. {
  466. if (hold > 0)
  467. {
  468. hold--;
  469. return;
  470. }
  471. if(config_dotitlenum)
  472. StringCchPrintfW(buf,2048, L"%d. %s (%d:%02d)",PlayList_getPosition()+1, name,songlen/60,songlen%60);
  473. else
  474. StringCchPrintfW(buf,2048, L"%s (%d:%02d)",name,songlen/60,songlen%60);
  475. }
  476. else if (name == FileTitle) // benski> ok, ok, ok, this is a big hack
  477. {
  478. if (hold > 0)
  479. {
  480. hold--;
  481. return;
  482. }
  483. StringCchPrintfW(buf,2048, L"%d. %s", PlayList_getPosition()+1, name);
  484. }
  485. else
  486. {
  487. KillTimer(hMainWindow, UPDATE_DISPLAY_TIMER + 2);
  488. SetTimer(hMainWindow, UPDATE_DISPLAY_TIMER + 2, 1000, NULL);
  489. hold = (config_autoscrollname&1 ? ((songlen == -2) ? 5 : 1) : 0);
  490. StringCchCopyW(buf, 2048, name);
  491. }
  492. }
  493. else
  494. StringCchPrintfW(buf,2048, L"%S %S", app_name, app_version_string);
  495. if (!mode)
  496. {
  497. len_of_str = lstrlenW(buf)*5;
  498. len_of_spacer=lstrlenW(L" *** ")*5;
  499. }
  500. else
  501. {
  502. RECT r;
  503. hOldFont=SelectObject(mainDC,mfont);
  504. DrawTextW(mainDC,buf,-1,&r, DT_CALCRECT | DT_SINGLELINE | DT_NOPREFIX);
  505. len_of_str=r.right-r.left;
  506. DrawTextW(mainDC,L" *** ",-1,&r, DT_CALCRECT | DT_SINGLELINE |DT_NOPREFIX);
  507. len_of_spacer=r.right-r.left;
  508. }
  509. const int textAreaWidth = 258-112;
  510. wchar_t obuf[4096];
  511. if (len_of_str > textAreaWidth)
  512. {
  513. StringCchPrintfW(obuf, 4096, L"%s *** %s", buf, buf);
  514. while (position < 0) position += len_of_str+len_of_spacer;
  515. if (position >= len_of_str+len_of_spacer) position -= len_of_str+len_of_spacer;
  516. draw_buf = obuf;
  517. }
  518. else
  519. position=0;
  520. if (!mode)
  521. _draw_songname(draw_buf,position/5,position%5);
  522. else
  523. {
  524. _draw_songname_winfont(draw_buf, position);
  525. SelectObject(mainDC,hOldFont);
  526. }
  527. *out_position = position;
  528. }
  529. #define PANBAR_WIDTH 38
  530. #define PANBAR_SLIDER_WIDTH 14
  531. #define PANBAR_LENGTH (PANBAR_WIDTH-PANBAR_SLIDER_WIDTH)
  532. #define ABS(x) (( x ) > 0 ? ( x ) : - ( x ))
  533. void draw_panbar(int volume, int pressed) // volume is 0-256
  534. {
  535. int ypos = ((ABS(volume) * 27) / 127)*15;
  536. RECT r;
  537. if (!draw_initted) return;
  538. if (ypos < 0) ypos=0; else if (ypos > 27*15) ypos=27*15;
  539. r.left = 177;
  540. r.top = 42+15;
  541. r.right = r.left + PANBAR_WIDTH;
  542. r.bottom = r.top + 13;
  543. setSrcBM(panBM);
  544. BitBlt(mainDC, r.left,r.top,r.right-r.left,r.bottom-r.top,bmDC,9,ypos,SRCCOPY);
  545. {
  546. int xpos = ((volume*12)/127)+12;
  547. if (xpos > PANBAR_LENGTH)
  548. xpos = PANBAR_LENGTH;
  549. else if (xpos < 0)
  550. xpos = 0;
  551. BitBlt(mainDC,r.left+xpos,r.top+1,14,11,bmDC,pressed?0:15,422,SRCCOPY);
  552. }
  553. unsetSrcBM();
  554. update_rect(r);
  555. }
  556. void draw_shuffle(int on, int pressed)
  557. {
  558. RECT r;
  559. if (!draw_initted) return;
  560. r.left = 164;
  561. r.top = 89;
  562. r.right = r.left+79-28-4;
  563. r.bottom = r.top+15;
  564. setSrcBM(shufflerepeatBM);
  565. BitBlt(mainDC,r.left,r.top,r.right-r.left,r.bottom-r.top,bmDC,28,(on?30:0) + (pressed?15:0),SRCCOPY);
  566. unsetSrcBM();
  567. update_rect(r);
  568. }
  569. void draw_repeat(int on, int pressed)
  570. {
  571. RECT r;
  572. if (!draw_initted) return;
  573. r.left = 182+7-4-4+29;
  574. r.top = 60+14+15;
  575. r.right = r.left+28;
  576. r.bottom = r.top+15;
  577. setSrcBM(shufflerepeatBM);
  578. BitBlt(mainDC,r.left,r.top,r.right-r.left,r.bottom-r.top,bmDC,0,(on?30:0) + (pressed?15:0),SRCCOPY);
  579. unsetSrcBM();
  580. update_rect(r);
  581. }
  582. void update_panning_text(int songlen)
  583. {
  584. wchar_t buf[128] = {0};
  585. int v=config_pan;
  586. v *= 100;
  587. v/=127;
  588. if (v)
  589. {
  590. wchar_t lorrStr[32] = {0}, balanceStr[64] = {0};
  591. StringCchPrintfW(buf, 128, L"%s: %d%% %s",getStringW(IDS_BALANCE,balanceStr,64),v<0?-v:v,v<0?getStringW(IDS_BALANCE_LEFT,lorrStr,32):getStringW(IDS_BALANCE_RIGHT,lorrStr,32));
  592. }
  593. else
  594. getStringW(IDS_BALANCE_CENTRE,buf,128);
  595. v=0;
  596. draw_songname(buf,&v,songlen);
  597. }
  598. void update_volume_text(int songlen)
  599. {
  600. wchar_t buf[128] = {0}, volStr[64] = {0};
  601. int v = config_volume;
  602. v *= 100;
  603. v/=255;
  604. StringCchPrintfW(buf, 128,L"%s: %d%%",getStringW(IDS_VOLUME,volStr,64),v);
  605. draw_songname(buf,&v,songlen);
  606. }
  607. #define VOLBAR_WIDTH 68
  608. #define VOLBAR_SLIDER_WIDTH 14
  609. #define VOLBAR_LENGTH (VOLBAR_WIDTH-VOLBAR_SLIDER_WIDTH)
  610. void draw_volumebar(int volume, int pressed) // volume is 0-256
  611. {
  612. int ypos = ((volume * 27) / 255)*15;
  613. RECT r;
  614. if (!draw_initted) return;
  615. if (ypos < 0) ypos=0; else if (ypos > 27*15) ypos=27*15;
  616. r.left = 107;
  617. r.top = 42+15;
  618. r.right = r.left + VOLBAR_WIDTH;
  619. r.bottom = r.top + 13;
  620. setSrcBM(volBM);
  621. BitBlt(mainDC, r.left,r.top,r.right-r.left,r.bottom-r.top,bmDC,0,ypos,SRCCOPY);
  622. {
  623. int xpos = (volume*51)/255;
  624. if (xpos > VOLBAR_LENGTH) xpos = VOLBAR_LENGTH; else if (xpos < 0) xpos = 0;
  625. BitBlt(mainDC,r.left+xpos,r.top+1,14,11,bmDC,pressed?0:15,422,SRCCOPY);
  626. }
  627. unsetSrcBM();
  628. update_rect(r);
  629. }
  630. void draw_eqplbut(int eqon, int eqpressed, int plon, int plpressed)
  631. {
  632. RECT urect = { 219, 58, 265, 70 };
  633. int x, y;
  634. if (!draw_initted) return ;
  635. x = eqpressed ? 46 : 0;
  636. y = eqon ? 12 : 0;
  637. setSrcBM(shufflerepeatBM);
  638. BitBlt(mainDC, urect.left, urect.top, (urect.right - urect.left) / 2, urect.bottom - urect.top,
  639. bmDC, x, y + 61, SRCCOPY);
  640. x = plpressed ? 46 : 0;
  641. y = plon ? 12 : 0;
  642. BitBlt(mainDC, urect.left + (urect.right - urect.left) / 2, urect.top, (urect.right - urect.left) / 2, urect.bottom - urect.top,
  643. bmDC, x + 23, y + 61, SRCCOPY);
  644. unsetSrcBM();
  645. update_rect(urect);
  646. }