1
0

prefs.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #include "precomp__gen_ff.h"
  2. #include "main.h"
  3. #include "resource.h"
  4. #include "prefs.h"
  5. #include "wa2cfgitems.h"
  6. #include "wa2frontend.h"
  7. #include "../Agave/Language/api_language.h"
  8. #include "gen.h"
  9. #include <commctrl.h>
  10. #include <windowsx.h>
  11. void turnonoff(HWND wnd, int *t, int n, int v) {
  12. for (int i=0;i<n;i++) {
  13. EnableWindow(GetDlgItem(wnd, t[i]), v);
  14. }
  15. }
  16. extern void initFFApi();
  17. extern Wa2CfgItems *cfgitems;
  18. extern HINSTANCE hInstance;
  19. _int last_page(L"Last Page", 0);
  20. Wa2FFOptions *ffoptions = NULL;
  21. HWND subWnd = NULL, tabwnd = NULL;
  22. int subWndId = -1;
  23. extern int m_are_we_loaded;
  24. int toggle_from_wa2 = 0;
  25. void _dosetsel(HWND hwndDlg)
  26. {
  27. tabwnd = GetDlgItem(hwndDlg,IDC_TAB1);
  28. int sel=TabCtrl_GetCurSel(tabwnd);
  29. if (sel >= 0 && (sel != last_page.getValueAsInt() || !subWnd))
  30. {
  31. last_page.setValueAsInt(sel);
  32. if (subWnd) DestroyWindow(subWnd);
  33. subWnd = NULL;
  34. subWndId = -1;
  35. UINT t=0;
  36. DLGPROC p=0;
  37. switch (sel)
  38. {
  39. case 0: t=IDD_PREFS_GENERAL; p=ffPrefsProc1; subWndId = 0; break;
  40. case 1: t=IDD_PREFS_WINDOWS; p=ffPrefsProc4; subWndId = 1; break;
  41. case 2: t=IDD_PREFS_FONTS; p=ffPrefsProc2; subWndId = 2; break;
  42. case 3: t=IDD_PREFS_THEMES; p=ffPrefsProc3; subWndId = 3; break;
  43. case 4: t=IDD_PREFS_SKIN; p=ffPrefsProc5; subWndId = 5; break;
  44. }
  45. if (t) subWnd=WASABI_API_CREATEDIALOGW(t,hwndDlg,p);
  46. if (IsWindow(subWnd))
  47. {
  48. RECT r = {0};
  49. GetClientRect(tabwnd,&r);
  50. TabCtrl_AdjustRect(tabwnd,FALSE,&r);
  51. SetWindowPos(subWnd,HWND_TOP,r.left,r.top,r.right-r.left,r.bottom-r.top,SWP_NOACTIVATE);
  52. ShowWindow(subWnd,SW_SHOWNA);
  53. }
  54. if(!SendMessageW(plugin.hwndParent,WM_WA_IPC,IPC_ISWINTHEMEPRESENT,IPC_USE_UXTHEME_FUNC))
  55. {
  56. SendMessageW(plugin.hwndParent,WM_WA_IPC,(WPARAM)tabwnd,IPC_USE_UXTHEME_FUNC);
  57. SendMessageW(plugin.hwndParent,WM_WA_IPC,(WPARAM)subWnd,IPC_USE_UXTHEME_FUNC);
  58. }
  59. }
  60. }
  61. #define TabCtrl_InsertItemW(hwnd, iItem, pitem) \
  62. (int)SNDMSG((hwnd), TCM_INSERTITEMW, (WPARAM)(int)(iItem), (LPARAM)(const TC_ITEMW *)(pitem))
  63. // frame proc
  64. INT_PTR CALLBACK ffPrefsProc(HWND hwndDlg, UINT uMsg, WPARAM wParam,LPARAM lParam) {
  65. switch (uMsg)
  66. {
  67. case WM_INITDIALOG:
  68. {
  69. if (WASABI_API_APP == NULL)
  70. {
  71. // wasabi is not initialized ! we need to init before we can access cfgitems otherwise we'd have
  72. // to mirror their values with winamp.ini and that'd be seriously crappy
  73. initFFApi();
  74. }
  75. if (!ffoptions)
  76. ffoptions = new Wa2FFOptions();
  77. TCITEMW item = {0};
  78. HWND tabwnd=GetDlgItem(hwndDlg,IDC_TAB1);
  79. item.mask=TCIF_TEXT;
  80. item.pszText=WASABI_API_LNGSTRINGW(IDS_GENERAL);
  81. TabCtrl_InsertItemW(tabwnd,0,&item);
  82. item.pszText=WASABI_API_LNGSTRINGW(IDS_WINDOW_SETTINGS);
  83. TabCtrl_InsertItemW(tabwnd,1,&item);
  84. item.pszText=WASABI_API_LNGSTRINGW(IDS_FONT_RENDERING);
  85. TabCtrl_InsertItemW(tabwnd,2,&item);
  86. if (m_are_we_loaded)
  87. {
  88. item.pszText=WASABI_API_LNGSTRINGW(IDS_COLOR_THEMES);
  89. TabCtrl_InsertItemW(tabwnd,3,&item);
  90. item.pszText=WASABI_API_LNGSTRINGW(IDS_CURRENT_SKIN);
  91. TabCtrl_InsertItemW(tabwnd,4,&item);
  92. }
  93. TabCtrl_SetCurSel(tabwnd,last_page.getValueAsInt());
  94. _dosetsel(hwndDlg);
  95. }
  96. return 0;
  97. case WM_NOTIFY:
  98. {
  99. LPNMHDR p=(LPNMHDR) lParam;
  100. if (p->idFrom == IDC_TAB1 && p->code == TCN_SELCHANGE)
  101. {
  102. _dosetsel(hwndDlg);
  103. return 0;
  104. }
  105. }
  106. break;
  107. case WM_DESTROY:
  108. subWnd=NULL;
  109. return 0;
  110. }
  111. return 0;
  112. }
  113. Wa2FFOptions::Wa2FFOptions() : CfgItemI(L"Winamp5", Wa2FFOptionsGuid) {
  114. registerAttribute(&last_page);
  115. }
  116. int ComboBox_AddStringW(HWND list, const wchar_t *string)
  117. {
  118. return SendMessageW(list, CB_ADDSTRING, 0, (LPARAM)string);
  119. }