options_playlist.cpp 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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 <windowsx.h>
  9. #include "Main.h"
  10. #include "resource.h"
  11. #include "Options.h"
  12. #include "SkinCOM.h"
  13. #include "ExternalCOM.h"
  14. #include "../nu/combobox.h"
  15. #include "../nu/ns_wc.h"
  16. #include <malloc.h>
  17. static int CALLBACK EnumFontsProc( LOGFONT *lplf, TEXTMETRIC *lptm, DWORD dwType, LPARAM lpData )
  18. {
  19. ComboBox_AddString( (HWND)lpData, lplf->lfFaceName );
  20. return TRUE;
  21. }
  22. void UpdatePlaylistFontSizeText( void )
  23. {
  24. HWND plpref = GetDlgItem( prefs_hwnd, IDC_RECT );
  25. plpref = GetWindow( plpref, GW_HWNDNEXT );
  26. if ( IsWindow( plpref ) )
  27. SetDlgItemInt( plpref, IDC_PLFONTSIZE, config_pe_fontsize, 0 );
  28. }
  29. void UpdateManualAdvanceState( void )
  30. {
  31. HWND plpref = GetDlgItem( prefs_hwnd, IDC_RECT );
  32. plpref = GetWindow( plpref, GW_HWNDNEXT );
  33. if ( IsWindow( plpref ) )
  34. CheckDlgButton( plpref, IDC_MANUALPLAYLISTADVANCE, config_pladv ? 0 : 1 );
  35. }
  36. // shuffle tab procedure
  37. INT_PTR CALLBACK PlaybackOptionsProc( HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam )
  38. {
  39. static int pl_prefs_init;
  40. hi helpinfo[] = {
  41. {IDC_PREFS_SHUFFLE_MORPH_RATE,IDS_P_O_SMS},
  42. {IDC_DEFEXT,IDS_P_O_DEFEXT},
  43. {IDC_RFL,IDS_P_O_RFL},
  44. {IDC_MANUALPLAYLISTADVANCE,IDS_P_O_MPA},
  45. {IDC_PLNUMS,IDS_P_DISP_TNUMS},
  46. {IDC_PLFONTSIZE,IDS_P_DISP_PLFONT},
  47. };
  48. DO_HELP();
  49. if ( uMsg == WM_INITDIALOG )
  50. {
  51. pl_prefs_init = 0;
  52. SetDlgItemTextA( hwndDlg, IDC_DEFEXT, config_defext );
  53. SendDlgItemMessage( hwndDlg, IDC_DEFEXT, EM_LIMITTEXT, sizeof( config_defext ), 0 );
  54. CheckDlgButton( hwndDlg, IDC_RFL, ( config_rofiob & 1 ) ? 1 : 0 );
  55. CheckDlgButton( hwndDlg, IDC_MANUALPLAYLISTADVANCE, config_pladv ? 0 : 1 );
  56. SendMessageW( GetDlgItem( hwndDlg, IDC_PREFS_SHUFFLE_MORPH_RATE ), TBM_SETRANGEMAX, 0, 50 );
  57. SendMessageW( GetDlgItem( hwndDlg, IDC_PREFS_SHUFFLE_MORPH_RATE ), TBM_SETRANGEMIN, 0, 0 );
  58. SendMessageW( GetDlgItem( hwndDlg, IDC_PREFS_SHUFFLE_MORPH_RATE ), TBM_SETPOS, 1, config_shuffle_morph_rate );
  59. CheckDlgButton( hwndDlg, IDC_PLNUMS, config_shownumsinpl ? 1 : 0 );
  60. CheckDlgButton( hwndDlg, IDC_PLZEROPAD, config_zeropadplnum ? 1 : 0 );
  61. EnableWindow( GetDlgItem( hwndDlg, IDC_PLZEROPAD ), config_shownumsinpl );
  62. SendDlgItemMessage( hwndDlg, IDC_SPIN1, UDM_SETRANGE, 0, MAKELONG( 999, 1 ) );
  63. SetDlgItemInt( hwndDlg, IDC_PLFONTSIZE, config_pe_fontsize, 0 );
  64. SendDlgItemMessageW( hwndDlg, IDC_PLDIRECTION, CB_ADDSTRING, 0, (LPARAM)getStringW( IDS_P_PLDIRECTION_AUTO, NULL, 0 ) );
  65. SendDlgItemMessageW( hwndDlg, IDC_PLDIRECTION, CB_ADDSTRING, 0, (LPARAM)getStringW( IDS_P_PLDIRECTION_L2R, NULL, 0 ) );
  66. SendDlgItemMessageW( hwndDlg, IDC_PLDIRECTION, CB_ADDSTRING, 0, (LPARAM)getStringW( IDS_P_PLDIRECTION_R2L, NULL, 0 ) );
  67. SendDlgItemMessage( hwndDlg, IDC_PLDIRECTION, CB_SETCURSEL, config_pe_direction, 0 );
  68. HWND fontcombo = GetDlgItem( hwndDlg, IDC_CUSTOMFONT );
  69. HDC dc = GetDC( NULL );
  70. EnumFonts( dc, NULL, (FONTENUMPROC)EnumFontsProc, (LPARAM)fontcombo );
  71. ReleaseDC( NULL, dc );
  72. // select the font, but fall back to Arial if it doesn't exist
  73. ComboBox combobox( fontcombo );
  74. if ( combobox.SelectString( playlist_custom_fontW ) == CB_ERR )
  75. {
  76. StringCbCopyW( playlist_custom_fontW, sizeof( playlist_custom_fontW ), FALLBACK_FONT );
  77. combobox.SelectString( playlist_custom_fontW );
  78. }
  79. CheckDlgButton( hwndDlg, IDC_NOCUSTOMFONT, config_custom_plfont ? 0 : 1 );
  80. if ( !config_custom_plfont )
  81. {
  82. EnableWindow( GetDlgItem( hwndDlg, IDC_CUSTOMFONT ), FALSE );
  83. EnableWindow( GetDlgItem( hwndDlg, IDC_STATIC_CUSTOMFONT ), FALSE );
  84. }
  85. //WI(plscrollsize);
  86. //WI(plmw2xscroll);
  87. SetDlgItemInt( hwndDlg, IDC_PLSCROLL, config_plscrollsize, 0 );
  88. SendDlgItemMessage( hwndDlg, IDC_SPIN3, UDM_SETRANGE, 0, MAKELONG( 100, 1 ) );
  89. CheckDlgButton( hwndDlg, IDC_MOUSE_SCROLL_DOUBLE_LINES, config_plmw2xscroll ? 1 : 0 );
  90. pl_prefs_init = 1;
  91. }
  92. else if ( uMsg == WM_COMMAND )
  93. switch ( LOWORD( wParam ) )
  94. {
  95. case IDC_PLDIRECTION:
  96. if ( HIWORD( wParam ) == CBN_SELCHANGE )
  97. {
  98. int l = SendDlgItemMessage( hwndDlg, IDC_PLDIRECTION, CB_GETCURSEL, 0, 0 );
  99. if ( l != CB_ERR )
  100. config_pe_direction = l;
  101. InvalidateRect( hPLWindow, NULL, FALSE );
  102. }
  103. return 0;
  104. case IDC_NOCUSTOMFONT:
  105. config_custom_plfont = !IsDlgButtonChecked( hwndDlg, IDC_NOCUSTOMFONT );
  106. EnableWindow( GetDlgItem( hwndDlg, IDC_CUSTOMFONT ), IsDlgButtonChecked( hwndDlg, IDC_NOCUSTOMFONT ) ? 0 : 1 );
  107. EnableWindow( GetDlgItem( hwndDlg, IDC_STATIC_CUSTOMFONT ), IsDlgButtonChecked( hwndDlg, IDC_NOCUSTOMFONT ) ? 0 : 1 );
  108. draw_reinit_plfont( 1 );
  109. InvalidateRect( hPLWindow, NULL, FALSE );
  110. JSAPI1_SkinChanged();
  111. break;
  112. case IDC_CUSTOMFONT:
  113. if ( HIWORD( wParam ) == CBN_SELCHANGE )
  114. {
  115. HWND fontcombo;
  116. int idx, len;
  117. wchar_t *t;
  118. fontcombo = GetDlgItem( hwndDlg, IDC_CUSTOMFONT );
  119. ComboBox combobox( fontcombo );
  120. idx = combobox.GetSelection();
  121. len = combobox.GetTextLen( idx );
  122. t = (wchar_t *)_malloca( ( len + 1 ) * sizeof( wchar_t ) );
  123. combobox.GetText( idx, t );
  124. t[ len ] = 0;
  125. StringCbCopyW( playlist_custom_fontW, sizeof( playlist_custom_fontW ), t );
  126. WideCharToMultiByteSZ( CP_ACP, 0, playlist_custom_fontW, -1, playlist_custom_font, 128, 0, 0 );
  127. _freea( t );
  128. draw_reinit_plfont( 1 );
  129. InvalidateRect( hPLWindow, NULL, FALSE );
  130. JSAPI1_SkinChanged();
  131. }
  132. break;
  133. case IDC_PLNUMS:
  134. {
  135. int t = config_shownumsinpl;
  136. config_shownumsinpl = IsDlgButtonChecked( hwndDlg, IDC_PLNUMS ) ? 1 : 0;
  137. if ( config_shownumsinpl != t )
  138. {
  139. _w_i( "shownumsinpl", config_shownumsinpl );
  140. draw_reinit_plfont( 1 );
  141. if ( config_pe_open )
  142. InvalidateRect( hPLWindow, NULL, FALSE );
  143. }
  144. EnableWindow( GetDlgItem( hwndDlg, IDC_PLZEROPAD ), config_shownumsinpl );
  145. }
  146. break;
  147. case IDC_PLZEROPAD:
  148. {
  149. config_zeropadplnum = IsDlgButtonChecked( hwndDlg, IDC_PLZEROPAD ) ? 1 : 0;
  150. InvalidateRect( hPLWindow, NULL, FALSE );
  151. }
  152. break;
  153. case IDC_PLFONTSIZE:
  154. if ( HIWORD( wParam ) == EN_CHANGE && pl_prefs_init )
  155. {
  156. int s = 0, t = GetDlgItemInt( hwndDlg, IDC_PLFONTSIZE, &s, 0 );
  157. if ( t < 2 )
  158. t = 11;
  159. if ( t != config_pe_fontsize && s )
  160. {
  161. config_pe_fontsize = t;
  162. if ( hMainWindow )
  163. {
  164. draw_reinit_plfont( 1 );
  165. InvalidateRect( hPLWindow, NULL, FALSE );
  166. }
  167. JSAPI1_SkinChanged();
  168. }
  169. }
  170. break;
  171. case IDC_DEFEXT:
  172. if ( HIWORD( wParam ) == EN_CHANGE )
  173. {
  174. GetWindowTextA( GetDlgItem( hwndDlg, IDC_DEFEXT ), config_defext, sizeof( config_defext ) );
  175. }
  176. break;
  177. case IDC_RFL:
  178. config_rofiob &= ~1;
  179. config_rofiob |= IsDlgButtonChecked( hwndDlg, IDC_RFL ) ? 1 : 0;
  180. break;
  181. case IDC_MANUALPLAYLISTADVANCE:
  182. {
  183. int manadv = IsDlgButtonChecked( hwndDlg, IDC_MANUALPLAYLISTADVANCE ) ? 0 : 1;
  184. if ( manadv != config_pladv )
  185. SendMessageW( hMainWindow, WM_COMMAND, WINAMP_FILE_MANUALPLADVANCE, 0 );
  186. break;
  187. }
  188. case IDC_MOUSE_SCROLL_DOUBLE_LINES:
  189. config_plmw2xscroll = IsDlgButtonChecked( hwndDlg, IDC_MOUSE_SCROLL_DOUBLE_LINES ) ? 1 : 0;
  190. break;
  191. case IDC_PLSCROLL:
  192. if ( HIWORD( wParam ) == EN_CHANGE && pl_prefs_init )
  193. {
  194. int s = 0, t = GetDlgItemInt( hwndDlg, IDC_PLSCROLL, &s, 0 );
  195. if ( t < 1 )
  196. t = 1;
  197. if ( t > 16 )
  198. t = 16;
  199. if ( t != config_plscrollsize && s )
  200. config_plscrollsize = t;
  201. }
  202. break;
  203. case IDC_SHUFFLE_HELP:
  204. {
  205. wchar_t title[ 64 ] = { 0 };
  206. MessageBoxW( hwndDlg, getStringW( IDS_SHUFFLE_MORPH_INFO, NULL, 0 ),
  207. getStringW( IDS_SHUFFLE_MORPH_RATE, title, 64 ), 0 );
  208. }
  209. break;
  210. }
  211. else if ( uMsg == WM_HSCROLL )
  212. {
  213. HWND swnd = (HWND)lParam;
  214. if ( swnd == GetDlgItem( hwndDlg, IDC_PREFS_SHUFFLE_MORPH_RATE ) )
  215. {
  216. config_shuffle_morph_rate = (unsigned char)SendMessageW( GetDlgItem( hwndDlg, IDC_PREFS_SHUFFLE_MORPH_RATE ), TBM_GETPOS, 0, 0 );
  217. }
  218. }
  219. else if ( uMsg == WM_DESTROY )
  220. {
  221. pl_prefs_init = 0;
  222. }
  223. const int controls[] =
  224. {
  225. IDC_PREFS_SHUFFLE_MORPH_RATE,
  226. };
  227. if ( FALSE != DirectMouseWheel_ProcessDialogMessage( hwndDlg, uMsg, wParam, lParam, controls, ARRAYSIZE( controls ) ) )
  228. return TRUE;
  229. return FALSE;
  230. } //shuffle