comparison gui/win32/preferences.c @ 23077:17bf4f4b0715

Gui --> gui
author diego
date Mon, 23 Apr 2007 07:42:42 +0000
parents
children f81cd5be161b
comparison
equal deleted inserted replaced
23076:39dd908375b2 23077:17bf4f4b0715
1 /*
2 MPlayer Gui for win32
3 Copyright (c) 2003 Sascha Sommer <saschasommer@freenet.de>
4 Copyright (c) 2006 Erik Augustson <erik_27can@yahoo.com>
5 Copyright (c) 2006 Gianluigi Tiesi <sherpya@netfarm.it>
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
20 */
21
22 #include <windows.h>
23 #include <commctrl.h>
24 #include <stdio.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include <libvo/video_out.h>
28 #include <libao2/audio_out.h>
29 #include <mixer.h>
30 #include "interface.h"
31 #include "gui.h"
32 #include "mp_msg.h"
33 #include "help_mp.h"
34 #include "dialogs.h"
35 #include "wincfg.h"
36
37 extern int vo_doublebuffering;
38 extern int vo_directrendering;
39 extern int frame_dropping;
40 extern int soft_vol;
41 extern float audio_delay;
42 extern int osd_level;
43 extern char *dvd_device, *cdrom_device;
44 extern char *proc_priority;
45
46 static void set_defaults(void);
47
48 static LRESULT CALLBACK PrefsWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
49 {
50 HWND btn, label, edit1, edit2, edit3, updown1, updown2, track1, track2;
51 static HWND vo_driver, ao_driver, prio;
52 int i = 0, j = 0;
53 char dvddevice[MAX_PATH];
54 char cdromdevice[MAX_PATH];
55 char procprio[11];
56 float x = 10.0, y = 100.0, stereopos, delaypos;
57 stereopos = gtkAOExtraStereoMul * x;
58 delaypos = audio_delay * y;
59
60 switch (iMsg)
61 {
62 case WM_CREATE:
63 {
64 /* video and audio drivers */
65 label = CreateWindow("static", "Video Driver:",
66 WS_CHILD | WS_VISIBLE,
67 10, 13, 70, 15, hwnd,
68 NULL, ((LPCREATESTRUCT) lParam) -> hInstance,
69 NULL);
70 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
71
72 label = CreateWindow("static", "Audio Driver:",
73 WS_CHILD | WS_VISIBLE,
74 190, 13, 70, 15, hwnd,
75 NULL, ((LPCREATESTRUCT) lParam) -> hInstance,
76 NULL);
77 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
78
79 label = CreateWindow("static", "Extra stereo coefficient:",
80 WS_CHILD | WS_VISIBLE,
81 10, 126, 115, 15, hwnd,
82 NULL, ((LPCREATESTRUCT) lParam) -> hInstance,
83 NULL);
84 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
85
86 label = CreateWindow("static", "Audio delay:",
87 WS_CHILD | WS_VISIBLE,
88 36, 165, 115, 15, hwnd,
89 NULL, ((LPCREATESTRUCT) lParam) -> hInstance,
90 NULL);
91 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
92
93 label = CreateWindow("static", "OSD level:",
94 WS_CHILD | WS_VISIBLE,
95 10, 264, 115, 15, hwnd,
96 NULL, ((LPCREATESTRUCT) lParam) -> hInstance,
97 NULL);
98 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
99
100 label = CreateWindow("static", "DVD device:",
101 WS_CHILD | WS_VISIBLE,
102 80, 363, 115, 15, hwnd,
103 NULL, ((LPCREATESTRUCT) lParam) -> hInstance,
104 NULL);
105 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
106
107 label = CreateWindow("static", "CD device:",
108 WS_CHILD | WS_VISIBLE,
109 202, 363, 115, 15, hwnd,
110 NULL, ((LPCREATESTRUCT) lParam) -> hInstance,
111 NULL);
112 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
113
114 label = CreateWindow("static", "Priority:",
115 WS_CHILD | WS_VISIBLE,
116 217, 264, 115, 15, hwnd,
117 NULL, ((LPCREATESTRUCT) lParam) -> hInstance,
118 NULL);
119 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
120
121 vo_driver = CreateWindow("combobox", NULL,
122 CBS_DROPDOWNLIST | CB_SHOWDROPDOWN |
123 CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS |
124 WS_CHILD | WS_VISIBLE |
125 WS_VSCROLL | WS_TABSTOP,
126 80, 10, 100, 160, hwnd,
127 (HMENU) ID_VO_DRIVER,
128 ((LPCREATESTRUCT) lParam) -> hInstance,
129 NULL);
130
131 ao_driver = CreateWindow("combobox", NULL,
132 CBS_DROPDOWNLIST | CB_SHOWDROPDOWN |
133 CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS |
134 WS_CHILD | WS_VISIBLE |
135 WS_VSCROLL | WS_TABSTOP,
136 260, 10, 100, 160, hwnd,
137 (HMENU) ID_AO_DRIVER,
138 ((LPCREATESTRUCT) lParam) -> hInstance,
139 NULL);
140
141 prio = CreateWindow("combobox", NULL,
142 CBS_DROPDOWNLIST | CB_SHOWDROPDOWN |
143 CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS |
144 WS_CHILD | WS_VISIBLE |
145 WS_VSCROLL | WS_TABSTOP,
146 260, 260, 100, 160, hwnd,
147 (HMENU) ID_PRIO,
148 ((LPCREATESTRUCT) lParam) -> hInstance,
149 NULL);
150
151 /* checkboxes */
152 btn = CreateWindow("button", "Enable double buffering",
153 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
154 25, 35, 150, 25,
155 hwnd, (HMENU) ID_DOUBLE,
156 ((LPCREATESTRUCT) lParam) -> hInstance,
157 NULL);
158 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
159
160 btn = CreateWindow("button", "Enable direct rendering",
161 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
162 25, 57, 150, 25,
163 hwnd, (HMENU) ID_DIRECT,
164 ((LPCREATESTRUCT) lParam) -> hInstance,
165 NULL);
166 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
167
168 btn = CreateWindow("button", "Enable framedropping",
169 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
170 25, 79, 150, 25,
171 hwnd, (HMENU) ID_FRAMEDROP,
172 ((LPCREATESTRUCT) lParam) -> hInstance,
173 NULL);
174 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
175
176 btn = CreateWindow("button", "Normalize sound",
177 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
178 205, 35, 150, 25,
179 hwnd, (HMENU) ID_NORMALIZE,
180 ((LPCREATESTRUCT) lParam) -> hInstance,
181 NULL);
182 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
183
184 btn = CreateWindow("button", "Enable software mixer",
185 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
186 205, 57, 150, 25,
187 hwnd, (HMENU) ID_SOFTMIX,
188 ((LPCREATESTRUCT) lParam) -> hInstance,
189 NULL);
190 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
191
192 btn = CreateWindow("button", "Enable extra stereo",
193 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
194 205, 79, 150, 25,
195 hwnd, (HMENU) ID_EXTRASTEREO,
196 ((LPCREATESTRUCT) lParam) -> hInstance,
197 NULL);
198 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
199
200 btn = CreateWindow("button", "Enable cache",
201 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
202 10, 200, 90, 25,
203 hwnd, (HMENU) ID_CACHE,
204 ((LPCREATESTRUCT) lParam) -> hInstance,
205 NULL);
206 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
207
208 btn = CreateWindow("button", "Enable autosync",
209 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
210 192, 200, 100, 25, hwnd,
211 (HMENU) ID_AUTOSYNC,
212 ((LPCREATESTRUCT) lParam) -> hInstance,
213 NULL);
214 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
215
216 btn = CreateWindow("button", "Display videos in the sub window",
217 WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
218 85, 227, 250, 25,
219 hwnd, (HMENU) ID_SUBWINDOW,
220 ((LPCREATESTRUCT) lParam) -> hInstance,
221 NULL);
222 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
223
224 /* osd level */
225 btn = CreateWindow("button", "None",
226 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
227 95, 260, 100, 25, hwnd,
228 (HMENU) ID_NONE,
229 ((LPCREATESTRUCT) lParam) -> hInstance,
230 NULL);
231 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
232
233 btn = CreateWindow("button", "Timer and indicators",
234 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
235 95, 280, 180, 25, hwnd,
236 (HMENU) ID_OSD1,
237 ((LPCREATESTRUCT) lParam) -> hInstance,
238 NULL);
239 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
240
241 btn = CreateWindow("button", "Progress bar only",
242 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
243 95, 300, 180, 25, hwnd,
244 (HMENU) ID_OSD2,
245 ((LPCREATESTRUCT) lParam) -> hInstance,
246 NULL);
247 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
248
249 btn = CreateWindow("button", "Timer, percentage, and total time",
250 WS_CHILD | WS_VISIBLE | BS_AUTORADIOBUTTON,
251 95, 320, 180, 25, hwnd,
252 (HMENU) ID_OSD3,
253 ((LPCREATESTRUCT) lParam) -> hInstance,
254 NULL);
255 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
256
257 btn = CreateWindow("button", "Apply",
258 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
259 199, 395, 80, 25, hwnd,
260 (HMENU) ID_APPLY,
261 ((LPCREATESTRUCT) lParam) -> hInstance,
262 NULL);
263 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
264
265 btn = CreateWindow("button", "Cancel",
266 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
267 285, 395, 80, 25, hwnd,
268 (HMENU) ID_CANCEL,
269 ((LPCREATESTRUCT) lParam) -> hInstance,
270 NULL);
271 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
272
273 btn = CreateWindow("button", "Defaults",
274 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
275 4, 395, 80, 25, hwnd,
276 (HMENU) ID_DEFAULTS,
277 ((LPCREATESTRUCT) lParam) -> hInstance,
278 NULL);
279 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
280
281 /* extra stereo coefficient trackbar */
282 track1 = CreateWindow(TRACKBAR_CLASS, "Coefficient",
283 WS_CHILD | WS_VISIBLE | WS_TABSTOP |
284 WS_DISABLED | TBS_HORZ |
285 TBS_BOTTOM | TBS_NOTICKS,
286 120, 120, 245, 35, hwnd,
287 (HMENU) ID_TRACKBAR1,
288 ((LPCREATESTRUCT) lParam) -> hInstance,
289 NULL);
290 SendDlgItemMessage(hwnd, ID_TRACKBAR1, TBM_SETRANGE, 1, MAKELONG(-100, 100));
291
292 /* audio delay */
293 track2 = CreateWindow(TRACKBAR_CLASS, "Audio delay",
294 WS_CHILD | WS_VISIBLE | WS_TABSTOP |
295 WS_DISABLED | TBS_HORZ |
296 TBS_BOTTOM | TBS_NOTICKS,
297 120, 160, 245, 35, hwnd,
298 (HMENU) ID_TRACKBAR2,
299 ((LPCREATESTRUCT) lParam) -> hInstance,
300 NULL);
301 SendDlgItemMessage(hwnd, ID_TRACKBAR2, TBM_SETRANGE, 1, MAKELONG(-1000, 1000));
302
303 /* cache */
304 edit1 = CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "cache",
305 WS_CHILD | WS_VISIBLE | WS_DISABLED |
306 ES_LEFT | ES_AUTOHSCROLL,
307 105, 203, 40, 20, hwnd,
308 (HMENU) ID_EDIT1,
309 ((LPCREATESTRUCT) lParam) -> hInstance,
310 NULL);
311 SendMessage(edit1, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
312
313 updown1 = CreateUpDownControl(WS_CHILD | WS_VISIBLE |
314 WS_DISABLED | UDS_SETBUDDYINT |
315 UDS_ARROWKEYS | UDS_NOTHOUSANDS,
316 145, 203, 20, 20, hwnd,
317 ID_UPDOWN1,
318 ((LPCREATESTRUCT) lParam) -> hInstance,
319 (HWND)edit1, 0, 0, 0);
320 SendDlgItemMessage(hwnd, ID_UPDOWN1, UDM_SETRANGE32, (WPARAM)0, (LPARAM)65535);
321
322 /* autosync */
323 edit2 = CreateWindowEx(WS_EX_CLIENTEDGE, "edit", "autosync",
324 WS_CHILD | WS_VISIBLE | WS_DISABLED |
325 ES_LEFT | ES_AUTOHSCROLL,
326 300, 203, 40, 20, hwnd,
327 (HMENU) ID_EDIT2,
328 ((LPCREATESTRUCT) lParam) -> hInstance,
329 NULL);
330 SendMessage(edit2, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
331
332 updown2 = CreateUpDownControl(WS_CHILD | WS_VISIBLE |
333 WS_DISABLED | UDS_SETBUDDYINT |
334 UDS_ARROWKEYS | UDS_NOTHOUSANDS,
335 340, 203, 20, 20, hwnd,
336 ID_UPDOWN2,
337 ((LPCREATESTRUCT) lParam) -> hInstance,
338 (HWND)edit2, 0, 0, 0);
339 SendDlgItemMessage(hwnd, ID_UPDOWN2, UDM_SETRANGE32, (WPARAM)0, (LPARAM)10000);
340
341 /* dvd and cd devices */
342 edit3 = CreateWindowEx(WS_EX_CLIENTEDGE, "edit", NULL,
343 WS_CHILD | WS_VISIBLE |
344 ES_LEFT | ES_AUTOHSCROLL,
345 145, 360, 20, 20, hwnd,
346 (HMENU) ID_DVDDEVICE,
347 ((LPCREATESTRUCT) lParam) -> hInstance,
348 NULL);
349 SendMessage(edit3, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
350
351 edit3 = CreateWindowEx(WS_EX_CLIENTEDGE, "edit", NULL,
352 WS_CHILD | WS_VISIBLE |
353 ES_LEFT| ES_AUTOHSCROLL,
354 260, 360, 20, 20, hwnd,
355 (HMENU) ID_CDDEVICE,
356 ((LPCREATESTRUCT) lParam) -> hInstance,
357 NULL);
358 SendMessage(edit3, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
359
360 while(video_out_drivers[i])
361 {
362 const vo_info_t *info = video_out_drivers[i++]->info;
363 if(!video_driver_list) gaddlist(&video_driver_list, (char *)info->short_name);
364 SendDlgItemMessage(hwnd, ID_VO_DRIVER, CB_ADDSTRING, 0, (LPARAM) info->short_name);
365 }
366 /* Special case for directx:noaccel */
367 SendDlgItemMessage(hwnd, ID_VO_DRIVER, CB_ADDSTRING, 0, (LPARAM) "directx:noaccel");
368 SendMessage(vo_driver, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
369
370 while(audio_out_drivers[j])
371 {
372 const ao_info_t *info = audio_out_drivers[j++]->info;
373 if(!audio_driver_list)
374 {
375 // FIXME: default priority (i.e. order in audio_out_drivers) should be fixed instead
376 // if win32 as default is really desirable
377 gaddlist(&audio_driver_list, "win32"/*(char *)info->short_name*/);
378 }
379 SendDlgItemMessage(hwnd, ID_AO_DRIVER, CB_ADDSTRING, 0, (LPARAM) info->short_name);
380 }
381 SendMessage(ao_driver, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
382
383 /* priority list, i'm leaving out realtime for safety's sake */
384 SendDlgItemMessage(hwnd, ID_PRIO, CB_INSERTSTRING, 0, (LPARAM) "low");
385 SendDlgItemMessage(hwnd, ID_PRIO, CB_INSERTSTRING, 0, (LPARAM) "belownormal");
386 SendDlgItemMessage(hwnd, ID_PRIO, CB_INSERTSTRING, 0, (LPARAM) "normal");
387 SendDlgItemMessage(hwnd, ID_PRIO, CB_INSERTSTRING, 0, (LPARAM) "abovenormal");
388 SendDlgItemMessage(hwnd, ID_PRIO, CB_INSERTSTRING, 0, (LPARAM) "high");
389 SendMessage(prio, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
390
391 /* set our preferences on what we already have */
392 if(video_driver_list)
393 SendDlgItemMessage(hwnd, ID_VO_DRIVER, CB_SETCURSEL,
394 (WPARAM)SendMessage(vo_driver, CB_FINDSTRING, -1,
395 (LPARAM)video_driver_list[0]), 0);
396
397 if(audio_driver_list)
398 SendDlgItemMessage(hwnd, ID_AO_DRIVER, CB_SETCURSEL,
399 (WPARAM)SendMessage(ao_driver, CB_FINDSTRING, -1,
400 (LPARAM)audio_driver_list[0]), 0);
401
402 if(vo_doublebuffering)
403 SendDlgItemMessage(hwnd, ID_DOUBLE, BM_SETCHECK, 1, 0);
404 if(vo_directrendering)
405 SendDlgItemMessage(hwnd, ID_DIRECT, BM_SETCHECK, 1, 0);
406 if(frame_dropping)
407 SendDlgItemMessage(hwnd, ID_FRAMEDROP, BM_SETCHECK, 1, 0);
408 if(gtkAONorm)
409 SendDlgItemMessage(hwnd, ID_NORMALIZE, BM_SETCHECK, 1, 0);
410 if(soft_vol)
411 SendDlgItemMessage(hwnd, ID_SOFTMIX, BM_SETCHECK, 1, 0);
412 if(gtkAOExtraStereo)
413 {
414 SendDlgItemMessage(hwnd, ID_EXTRASTEREO, BM_SETCHECK, 1, 0);
415 if(!guiIntfStruct.Playing)
416 {
417 EnableWindow(track1, 1);
418 EnableWindow(track2, 1);
419 }
420 }
421 else gtkAOExtraStereoMul = 1.0;
422 SendDlgItemMessage(hwnd, ID_TRACKBAR1, TBM_SETPOS, 1, (LPARAM)stereopos);
423
424 if(audio_delay)
425 SendDlgItemMessage(hwnd, ID_TRACKBAR2, TBM_SETPOS, 1, (LPARAM)delaypos);
426
427 if(gtkCacheOn) {
428 SendDlgItemMessage(hwnd, ID_CACHE, BM_SETCHECK, 1, 0);
429 EnableWindow(edit1, 1);
430 EnableWindow(updown1, 1);
431 }
432 else gtkCacheSize = 2048;
433 SendDlgItemMessage(hwnd, ID_UPDOWN1, UDM_SETPOS32, 0, (LPARAM)gtkCacheSize);
434
435 if(gtkAutoSyncOn) {
436 SendDlgItemMessage(hwnd, ID_AUTOSYNC, BM_SETCHECK, 1, 0);
437 EnableWindow(edit2, 1);
438 EnableWindow(updown2, 1);
439 }
440 else gtkAutoSync = 0;
441 SendDlgItemMessage(hwnd, ID_UPDOWN2, UDM_SETPOS32, 0, (LPARAM)gtkAutoSync);
442
443 if(sub_window)
444 SendDlgItemMessage(hwnd, ID_SUBWINDOW, BM_SETCHECK, 1, 0);
445
446 if(!osd_level)
447 SendDlgItemMessage(hwnd, ID_NONE, BM_SETCHECK, 1, 0);
448 else if(osd_level == 1)
449 SendDlgItemMessage(hwnd, ID_OSD1, BM_SETCHECK, 1, 0);
450 else if(osd_level == 2)
451 SendDlgItemMessage(hwnd, ID_OSD2, BM_SETCHECK, 1, 0);
452 else if(osd_level == 3)
453 SendDlgItemMessage(hwnd, ID_OSD3, BM_SETCHECK, 1, 0);
454
455 if(dvd_device)
456 SendDlgItemMessage(hwnd, ID_DVDDEVICE, WM_SETTEXT, 0, (LPARAM)dvd_device);
457 else SendDlgItemMessage(hwnd, ID_DVDDEVICE, WM_SETTEXT, 0, (LPARAM)"D:");
458
459 if(cdrom_device)
460 SendDlgItemMessage(hwnd, ID_CDDEVICE, WM_SETTEXT, 0, (LPARAM)cdrom_device);
461 else SendDlgItemMessage(hwnd, ID_CDDEVICE, WM_SETTEXT, 0, (LPARAM)"D:");
462
463 if(proc_priority)
464 SendDlgItemMessage(hwnd, ID_PRIO, CB_SETCURSEL,
465 (WPARAM)SendMessage(prio, CB_FINDSTRING, -1,
466 (LPARAM)proc_priority), 0);
467
468 else SendDlgItemMessage(hwnd, ID_PRIO, CB_SETCURSEL, 2, 0);
469
470 break;
471 }
472 case WM_CTLCOLORDLG:
473 case WM_CTLCOLOREDIT:
474 case WM_CTLCOLORBTN:
475 case WM_CTLCOLORSTATIC:
476 {
477 HDC hdc = (HDC)wParam;
478 SetBkMode(hdc, TRANSPARENT);
479 return (INT_PTR)SOLID_GREY;
480 }
481 break;
482 case WM_COMMAND:
483 {
484 switch (LOWORD(wParam))
485 {
486 case ID_EXTRASTEREO:
487 {
488 if(SendDlgItemMessage(hwnd, ID_EXTRASTEREO, BM_GETCHECK, 0, 0) == BST_CHECKED)
489 {
490 EnableWindow(GetDlgItem(hwnd, ID_TRACKBAR1), 1);
491 EnableWindow(GetDlgItem(hwnd, ID_TRACKBAR2), 1);
492 } else {
493 EnableWindow(GetDlgItem(hwnd, ID_TRACKBAR1), 0);
494 EnableWindow(GetDlgItem(hwnd, ID_TRACKBAR2), 0);
495 SendDlgItemMessage(hwnd, ID_TRACKBAR1, TBM_SETPOS, 1, (LPARAM)10.0);
496 SendDlgItemMessage(hwnd, ID_TRACKBAR2, TBM_SETPOS, 1, (LPARAM)0);
497 }
498 break;
499 }
500 case ID_CACHE:
501 {
502 if(SendDlgItemMessage(hwnd, ID_CACHE, BM_GETCHECK, 0, 0) == BST_CHECKED)
503 {
504 EnableWindow(GetDlgItem(hwnd, ID_EDIT1), 1);
505 EnableWindow(GetDlgItem(hwnd, ID_UPDOWN1), 1);
506 } else {
507 EnableWindow(GetDlgItem(hwnd, ID_EDIT1), 0);
508 EnableWindow(GetDlgItem(hwnd, ID_UPDOWN1), 0);
509 SendDlgItemMessage(hwnd, ID_UPDOWN1, UDM_SETPOS32, 1, (LPARAM)2048);
510 }
511 break;
512 }
513 case ID_AUTOSYNC:
514 {
515 if(SendDlgItemMessage(hwnd, ID_AUTOSYNC, BM_GETCHECK, 0, 0) == BST_CHECKED)
516 {
517 EnableWindow(GetDlgItem(hwnd, ID_EDIT2), 1);
518 EnableWindow(GetDlgItem(hwnd, ID_UPDOWN2), 1);
519 } else {
520 EnableWindow(GetDlgItem(hwnd, ID_EDIT2), 0);
521 EnableWindow(GetDlgItem(hwnd, ID_UPDOWN2), 0);
522 SendDlgItemMessage(hwnd, ID_UPDOWN2, UDM_SETPOS32, 1, (LPARAM)0);
523 }
524 break;
525 }
526 case ID_DEFAULTS:
527 {
528 set_defaults();
529 SendDlgItemMessage(hwnd, ID_VO_DRIVER, CB_SETCURSEL,
530 (WPARAM)SendMessage(vo_driver, CB_FINDSTRING, -1, (LPARAM)"directx"), 0);
531
532 SendDlgItemMessage(hwnd, ID_AO_DRIVER, CB_SETCURSEL,
533 (WPARAM)SendMessage(ao_driver, CB_FINDSTRING, -1, (LPARAM)"dsound"), 0);
534
535 SendDlgItemMessage(hwnd, ID_PRIO, CB_SETCURSEL,
536 (WPARAM)SendMessage(prio, CB_FINDSTRING, -1, (LPARAM)proc_priority), 0);
537
538 SendDlgItemMessage(hwnd, ID_TRACKBAR1, TBM_SETPOS, 1, (LPARAM)10.0);
539 SendDlgItemMessage(hwnd, ID_TRACKBAR2, TBM_SETPOS, 1, (LPARAM)0.0);
540 SendDlgItemMessage(hwnd, ID_UPDOWN1, UDM_SETPOS32, 0, (LPARAM)gtkCacheSize);
541 SendDlgItemMessage(hwnd, ID_UPDOWN2, UDM_SETPOS32, 0, (LPARAM)gtkAutoSync);
542 SendDlgItemMessage(hwnd, ID_DOUBLE, BM_SETCHECK, 0, 0);
543 SendDlgItemMessage(hwnd, ID_DIRECT, BM_SETCHECK, 0, 0);
544 SendDlgItemMessage(hwnd, ID_FRAMEDROP, BM_SETCHECK, 0, 0);
545 SendDlgItemMessage(hwnd, ID_NORMALIZE, BM_SETCHECK, 0, 0);
546 SendDlgItemMessage(hwnd, ID_SOFTMIX, BM_SETCHECK, 0, 0);
547 SendDlgItemMessage(hwnd, ID_EXTRASTEREO, BM_SETCHECK, 0, 0);
548 SendDlgItemMessage(hwnd, ID_CACHE, BM_SETCHECK, 0, 0);
549 SendDlgItemMessage(hwnd, ID_AUTOSYNC, BM_SETCHECK, 0, 0);
550 SendDlgItemMessage(hwnd, ID_SUBWINDOW, BM_SETCHECK, 1, 0);
551 SendDlgItemMessage(hwnd, ID_NONE, BM_SETCHECK, 0, 0);
552 SendDlgItemMessage(hwnd, ID_OSD1, BM_SETCHECK, 1, 0);
553 SendDlgItemMessage(hwnd, ID_OSD2, BM_SETCHECK, 0, 0);
554 SendDlgItemMessage(hwnd, ID_OSD3, BM_SETCHECK, 0, 0);
555 SendDlgItemMessage(hwnd, ID_DVDDEVICE, WM_SETTEXT, 0, (LPARAM)"D:");
556 SendDlgItemMessage(hwnd, ID_CDDEVICE, WM_SETTEXT, 0, (LPARAM)"D:");
557 SendMessage(hwnd, WM_COMMAND, (WPARAM)ID_APPLY, 0);
558 break;
559 }
560 case ID_CANCEL:
561 DestroyWindow(hwnd);
562 return 0;
563 case ID_APPLY:
564 {
565 int strl;
566 if(guiIntfStruct.Playing) guiGetEvent(guiCEvent, (void *)guiSetStop);
567
568 /* Set the video driver */
569 gfree(video_driver_list[0]);
570 strl = SendMessage(vo_driver, CB_GETCURSEL, 0, 0);
571 video_driver_list[0] = malloc(strl);
572 SendMessage(vo_driver, CB_GETLBTEXT, (WPARAM)strl,
573 (LPARAM)video_driver_list[0]);
574
575 /* Set the audio driver */
576 gfree(audio_driver_list[0]);
577 strl = SendMessage(ao_driver, CB_GETCURSEL, 0, 0);
578 audio_driver_list[0] = malloc(strl);
579 SendMessage(ao_driver, CB_GETLBTEXT, (WPARAM)strl,
580 (LPARAM)audio_driver_list[0]);
581
582 /* Set the priority level */
583 SendMessage(prio, CB_GETLBTEXT, (WPARAM)SendMessage(prio, CB_GETCURSEL, 0, 0), (LPARAM)procprio);
584 proc_priority = strdup(procprio);
585
586 /* double buffering */
587 if(SendDlgItemMessage(hwnd, ID_DOUBLE, BM_GETCHECK, 0, 0) == BST_CHECKED)
588 vo_doublebuffering = 1;
589 else vo_doublebuffering = 0;
590
591 /* direct rendering */
592 if(SendDlgItemMessage(hwnd, ID_DIRECT, BM_GETCHECK, 0, 0) == BST_CHECKED)
593 vo_directrendering = 1;
594 else vo_directrendering = 0;
595
596 /* frame dropping */
597 if(SendDlgItemMessage(hwnd, ID_FRAMEDROP, BM_GETCHECK, 0, 0) == BST_CHECKED)
598 frame_dropping = 1;
599 else frame_dropping = 0;
600
601 /* normalize */
602 if(SendDlgItemMessage(hwnd, ID_NORMALIZE, BM_GETCHECK, 0, 0) == BST_CHECKED)
603 gtkAONorm = 1;
604 else gtkAONorm = 0;
605
606 /* software mixer */
607 if(SendDlgItemMessage(hwnd, ID_SOFTMIX, BM_GETCHECK, 0, 0) == BST_CHECKED)
608 soft_vol = 1;
609 else soft_vol = 0;
610
611 /* extra stereo */
612 if(SendDlgItemMessage(hwnd, ID_EXTRASTEREO, BM_GETCHECK, 0, 0) == BST_CHECKED)
613 gtkAOExtraStereo = 1;
614 else {
615 gtkAOExtraStereo = 0;
616 gtkAOExtraStereoMul = 10.0;
617 }
618 gtkAOExtraStereoMul = SendDlgItemMessage(hwnd, ID_TRACKBAR1, TBM_GETPOS, 0, 0) / 10.0;
619
620 /* audio delay */
621 audio_delay = SendDlgItemMessage(hwnd, ID_TRACKBAR2, TBM_GETPOS, 0, 0) / 100.0;
622
623 /* cache */
624 if(SendDlgItemMessage(hwnd, ID_CACHE, BM_GETCHECK, 0, 0) == BST_CHECKED)
625 gtkCacheOn = 1;
626 else gtkCacheOn = 0;
627 gtkCacheSize = SendDlgItemMessage(hwnd, ID_UPDOWN1, UDM_GETPOS32, 0, 0);
628
629 /* autosync */
630 if(SendDlgItemMessage(hwnd, ID_AUTOSYNC, BM_GETCHECK, 0, 0) == BST_CHECKED)
631 gtkAutoSyncOn = 1;
632 else gtkAutoSyncOn = 0;
633 gtkAutoSync = SendDlgItemMessage(hwnd, ID_UPDOWN2, UDM_GETPOS32, 0, 0);
634
635 /* sub window */
636 if(SendDlgItemMessage(hwnd, ID_SUBWINDOW, BM_GETCHECK, 0, 0) == BST_CHECKED)
637 sub_window = 1;
638 else sub_window = 0;
639
640 /* osd level */
641 if(SendDlgItemMessage(hwnd, ID_NONE, BM_GETCHECK, 0, 0) == BST_CHECKED)
642 osd_level = 0;
643 else if(SendDlgItemMessage(hwnd, ID_OSD1, BM_GETCHECK, 0, 0) == BST_CHECKED)
644 osd_level = 1;
645 else if(SendDlgItemMessage(hwnd, ID_OSD2, BM_GETCHECK, 0, 0) == BST_CHECKED)
646 osd_level = 2;
647 else if(SendDlgItemMessage(hwnd, ID_OSD3, BM_GETCHECK, 0, 0) == BST_CHECKED)
648 osd_level = 3;
649
650 /* dvd and cd devices */
651 SendDlgItemMessage(hwnd, ID_DVDDEVICE, WM_GETTEXT, MAX_PATH, (LPARAM)dvddevice);
652 dvd_device = strdup(dvddevice);
653 SendDlgItemMessage(hwnd, ID_CDDEVICE, WM_GETTEXT, MAX_PATH, (LPARAM)cdromdevice);
654 cdrom_device = strdup(cdromdevice);
655
656 MessageBox(hwnd, "You must restart MPlayer for the changes to take effect.", "MPlayer - Info:", MB_OK);
657 DestroyWindow(hwnd);
658 break;
659 }
660 }
661 return 0;
662 }
663 case WM_DESTROY:
664 PostQuitMessage (0);
665 return 0;
666 }
667 return DefWindowProc(hwnd, iMsg, wParam, lParam);
668 }
669
670 void display_prefswindow(gui_t *gui)
671 {
672 HWND hWnd;
673 HINSTANCE hInstance = GetModuleHandle(NULL);
674 WNDCLASS wc;
675 int x, y;
676 if(FindWindow(NULL, "MPlayer - Preferences")) return;
677 wc.style = CS_HREDRAW | CS_VREDRAW;
678 wc.lpfnWndProc = PrefsWndProc;
679 wc.cbClsExtra = 0;
680 wc.cbWndExtra = 0;
681 wc.hInstance = hInstance;
682 wc.hCursor = LoadCursor(NULL,IDC_ARROW);
683 wc.hIcon = gui->icon;
684 wc.hbrBackground = SOLID_GREY;
685 wc.lpszClassName = "MPlayer - Preferences";
686 wc.lpszMenuName = NULL;
687 RegisterClass(&wc);
688 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (375 / 2);
689 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (452 / 2);
690 hWnd = CreateWindow("MPlayer - Preferences",
691 "MPlayer - Preferences",
692 WS_POPUPWINDOW | WS_CAPTION,
693 x,
694 y,
695 375,
696 452,
697 NULL,
698 NULL,
699 hInstance,
700 NULL);
701 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui);
702 ShowWindow(hWnd, SW_SHOW);
703 UpdateWindow(hWnd);
704 }
705
706 static void set_defaults(void)
707 {
708 proc_priority = "normal";
709 vo_doublebuffering = 1;
710 vo_directrendering = 0;
711 frame_dropping = 0;
712 soft_vol = 0;
713 gtkAONorm = 0;
714 gtkAOExtraStereo = 0;
715 gtkAOExtraStereoMul = 1.0;
716 audio_delay = 0.0;
717 sub_window = 1;
718 gtkCacheOn = 0;
719 gtkCacheSize = 2048;
720 gtkAutoSyncOn = 0;
721 gtkAutoSync = 0;
722 }