annotate Gui/win32/dialogs.c @ 19219:7b6e341b72f5

10l, last commit swapped U and V planes.
author reimar
date Fri, 28 Jul 2006 17:56:38 +0000
parents 42d4e99a075e
children 64d82a45a05d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18914
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1 /*
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
2 MPlayer Gui for win32
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
3 Copyright (c) 2003 Sascha Sommer <saschasommer@freenet.de>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
4 Copyright (c) 2006 Erik Augustson <erik_27can@yahoo.com>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
5 Copyright (c) 2006 Gianluigi Tiesi <sherpya@netfarm.it>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
6
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
7 This program is free software; you can redistribute it and/or modify
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
8 it under the terms of the GNU General Public License as published by
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
9 the Free Software Foundation; either version 2 of the License, or
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
10 (at your option) any later version.
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
11
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
12 This program is distributed in the hope that it will be useful,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
15 GNU General Public License for more details.
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
16
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
18 along with this program; if not, write to the Free Software
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02111-1307 USA
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
20 */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
21
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
22 #include <windows.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
23 #include <commctrl.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
24 #include <interface.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
25 #include <mp_msg.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
26 #include <help_mp.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
27 #include <libmpdemux/stream.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
28 #include <libmpdemux/demuxer.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
29 #include <libmpdemux/stheader.h>
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
30 #include "gui.h"
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
31 #include "wincfg.h"
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
32 #include "dialogs.h"
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
33
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
34 WNDPROC OldUrlWndProc;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
35 LRESULT CALLBACK SubUrlWndProc(HWND, UINT, WPARAM, LPARAM);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
36 extern int vo_gamma_brightness;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
37 extern int vo_gamma_saturation;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
38 extern int vo_gamma_contrast;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
39 extern int vo_gamma_hue;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
40 extern int set_video_colors(sh_video_t *sh_video, char *item, int value);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
41 extern int get_video_colors(sh_video_t *sh_video, char *item, int *value);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
42
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
43 guiInterface_t guiIntfStruct;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
44 int addurl = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
45
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
46 #ifdef USE_SUB
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
47 extern mp_osd_obj_t* vo_osd_list;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
48 extern char **sub_name;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
49
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
50 void guiLoadSubtitle(char *name)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
51 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
52 if (!guiIntfStruct.Playing)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
53 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
54 guiIntfStruct.SubtitleChanged = 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
55 return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
56 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
57 if (subdata)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
58 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
59 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_DeletingSubtitles);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
60 sub_free(subdata);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
61 subdata = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
62 vo_sub = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
63 if (vo_osd_list)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
64 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
65 int len;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
66 mp_osd_obj_t *osd = vo_osd_list;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
67 while (osd)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
68 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
69 if (osd->type == OSDTYPE_SUBTITLE) break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
70 osd = osd->next;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
71 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
72 if (osd && osd->flags & OSDFLAG_VISIBLE)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
73 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
74 len = osd->stride * (osd->bbox.y2 - osd->bbox.y1);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
75 memset(osd->bitmap_buffer, 0, len);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
76 memset(osd->alpha_buffer, 0, len);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
77 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
78 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
79 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
80
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
81 if (name)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
82 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
83 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_LoadingSubtitles, name);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
84 subdata = sub_read_file(strdup(name), guiIntfStruct.FPS);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
85 if (!subdata) mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_CantLoadSub,name);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
86 sub_name = (malloc(2 * sizeof(char*))); /* when mplayer will be restarted */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
87 sub_name[0] = strdup(name); /* sub_name[0] will be read */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
88 sub_name[1] = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
89 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
90 update_set_of_subtitles();
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
91 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
92 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
93
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
94 int display_openfilewindow(gui_t *gui, int add)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
95 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
96 OPENFILENAME fileopen;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
97 int result = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
98 char filelist[MAXFILE];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
99 char filename[MAX_PATH];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
100 char directory[MAX_PATH];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
101 char *filespec = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
102 char *filepart = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
103
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
104 memset(&fileopen, 0, sizeof(OPENFILENAME));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
105 memset(filelist, 0, sizeof(filelist));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
106
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
107 fileopen.lStructSize = sizeof(OPENFILENAME);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
108 fileopen.hwndOwner = gui->mainwindow;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
109 fileopen.hInstance = GetModuleHandle(NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
110 fileopen.lpstrFilter = "All Files (*.*)\0*.*\0"
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
111 "Media Files (*.avi;*.asf;*.wmv;*.mpg;*.mpeg;*.m2v;*.mov;\
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
112 *.rmvb;*.rm;*.ogm;*.mp3;*.wav;*.wma;*.ra;*.ogg)\0\
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
113 *.avi;*.asf;*.wmv;*.mpg;*.mpeg;*.m2v;*.mov;\
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
114 *.rmvb;*.rm;*.ogm;*.mp3;*.wav;*.wma;*.ra;*.ogg\0"
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
115 "Video Files (*.avi;*.mpg;*.mpeg;*.mov)\0*.avi;*.mpg;*.mpeg;*.mov\0"
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
116 "Avisynth Scripts (*.avs)\0*.avs\0"
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
117 "Audio Files (*.mp3;*.wav;*.ra)\0*.mp3;*.wav;*.ra\000";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
118 fileopen.nFilterIndex = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
119 fileopen.lpstrTitle = "Add file(s)...";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
120 fileopen.Flags = OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST| OFN_LONGNAMES | OFN_EXPLORER| OFN_READONLY | OFN_HIDEREADONLY;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
121 fileopen.lpstrFile = filelist;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
122 fileopen.lpstrCustomFilter = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
123 fileopen.nMaxFile = MAXFILE;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
124
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
125 if(GetOpenFileName(&fileopen))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
126 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
127 /* clear playlist */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
128 if(!add) gui->playlist->clear_playlist(gui->playlist);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
129
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
130 memcpy(directory, fileopen.lpstrFile, fileopen.nFileOffset - 1);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
131 directory[fileopen.nFileOffset - 1] = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
132
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
133 do
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
134 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
135 filespec = &fileopen.lpstrFile[fileopen.nFileOffset];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
136 filename[0] = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
137 strcat(filename, directory);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
138 strcat(filename, "\\");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
139 strcat(filename, filespec);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
140
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
141 if (GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
142 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] %s is a directory, skipping...\n", filename);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
143 else
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
144 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
145 if (GetFullPathName(filename, MAX_PATH, filename, &filepart))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
146 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
147 if(!parse_filename(filename, playtree, mconfig, add? 0 : 1))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
148 gui->playlist->add_track(gui->playlist, filename, NULL, filepart, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
149 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding file: %s - path %s\n", filespec, filename);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
150 result++;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
151 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
152 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
153 fileopen.nFileOffset += strlen(filespec) + 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
154 } while (*filespec);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
155 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
156 return result;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
157 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
158
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
159 #ifdef USE_SUB
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
160 void display_opensubtitlewindow(gui_t *gui)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
161 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
162 OPENFILENAME subtitleopen;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
163 char subtitlefile[MAX_PATH];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
164
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
165 /* Safety check */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
166 if (guiIntfStruct.Playing == 0 || !guiIntfStruct.sh_video) return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
167
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
168 memset(&subtitleopen, 0, sizeof(OPENFILENAME));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
169 memset(subtitlefile, 0, sizeof(subtitlefile));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
170
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
171 subtitleopen.lStructSize = sizeof(OPENFILENAME);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
172 subtitleopen.hwndOwner = gui->mainwindow;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
173 subtitleopen.hInstance = GetModuleHandle(NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
174 subtitleopen.lpstrFilter = "All Files (*.*)\0*.*\0"
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
175 "Subtitle Files (*.srt;*.txt;*.vob)\0*.srt;*.txt;*.vob\0";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
176 subtitleopen.nFilterIndex = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
177 subtitleopen.lpstrTitle = "Add Subtitle...";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
178 subtitleopen.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_EXPLORER | OFN_READONLY | OFN_HIDEREADONLY;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
179 subtitleopen.lpstrFile = subtitlefile;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
180 subtitleopen.lpstrCustomFilter = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
181 subtitleopen.nMaxFile = MAXFILE;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
182
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
183 if(GetOpenFileName(&subtitleopen))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
184 guiLoadSubtitle(subtitlefile);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
185 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
186 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
187
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
188 void display_loadplaylistwindow(gui_t *gui)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
189 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
190 OPENFILENAME playlistopen;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
191 char playlistfile[MAX_PATH];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
192
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
193 memset(&playlistopen, 0, sizeof(OPENFILENAME));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
194 memset(playlistfile, 0, sizeof(playlistfile));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
195
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
196 playlistopen.lStructSize = sizeof(OPENFILENAME);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
197 playlistopen.hwndOwner = gui->mainwindow;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
198 playlistopen.hInstance = GetModuleHandle(NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
199 playlistopen.lpstrFilter = "All Files (*.*)\0*.*\0"
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
200 "Playlist Files (*.m3u;*.pls;*.txt)\0*.m3u;*.pls;*.txt\0";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
201 playlistopen.nFilterIndex = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
202 playlistopen.lpstrTitle = "Load Playlist...";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
203 playlistopen.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_EXPLORER | OFN_READONLY | OFN_HIDEREADONLY;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
204 playlistopen.lpstrFile = playlistfile;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
205 playlistopen.lpstrCustomFilter = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
206 playlistopen.nMaxFile = MAXFILE;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
207
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
208 if(GetOpenFileName(&playlistopen))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
209 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
210 if(parse_filename(playlistfile, playtree, mconfig, 1))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
211 gui->startplay(gui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
212 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
213 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
214
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
215 void display_saveplaylistwindow(gui_t* gui)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
216 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
217 OPENFILENAME playlistsave;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
218 static FILE *playlist_file = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
219 char playlistname[MAX_PATH];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
220
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
221 memset(&playlistsave, 0, sizeof(OPENFILENAME));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
222 memset(playlistname, 0, sizeof(playlistname));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
223
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
224 playlistsave.lStructSize = sizeof(OPENFILENAME);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
225 playlistsave.hwndOwner = gui->mainwindow;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
226 playlistsave.hInstance = GetModuleHandle(NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
227 playlistsave.lpstrFilter = "Playlist Files (*.pls)\0*.pls\0";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
228 playlistsave.nFilterIndex = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
229 playlistsave.lpstrTitle = "Save Playlist...";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
230 playlistsave.Flags = OFN_LONGNAMES | OFN_EXPLORER | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
231 playlistsave.lpstrFile = playlistname;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
232 playlistsave.lpstrCustomFilter = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
233 playlistsave.nMaxFile = MAXFILE;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
234
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
235 if(GetSaveFileName(&playlistsave))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
236 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
237 int i=0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
238 HANDLE my_playlist;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
239
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
240 if(!strstr(playlistname, ".pls")) strcat(playlistname, ".pls");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
241
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
242 my_playlist = CreateFile(playlistname,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
243 GENERIC_WRITE,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
244 0,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
245 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
246 CREATE_ALWAYS,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
247 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
248 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
249
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
250 if(my_playlist != INVALID_HANDLE_VALUE)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
251 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
252 CloseHandle(my_playlist); /* close the file first so we can write to it */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
253 playlist_file = fopen(playlistsave.lpstrFile, "w");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
254 fprintf(playlist_file, "[playlist]\n");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
255 fprintf(playlist_file, "numberofentries=%d\n", gui->playlist->trackcount);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
256
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
257 for(i=0; i<(gui->playlist->trackcount); i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
258 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
259 fprintf(playlist_file, "File%i=%s\n", i + 1, gui->playlist->tracks[i]->filename);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
260 fprintf(playlist_file, "Length%i=-1\n", i + 1);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
261 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
262 fclose(playlist_file);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
263 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
264 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
265 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
266
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
267 static LRESULT CALLBACK OpenUrlWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
268 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
269 static HWND url;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
270 HWND wdg;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
271 FILE *f;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
272 char *history = get_path("gui.url");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
273 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
274 switch (iMsg)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
275 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
276 case WM_CREATE:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
277 wdg = CreateWindow("button", "Ok",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
278 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
279 4, 43, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
280 (HMENU) ID_OK,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
281 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
282 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
283 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
284
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
285 wdg = CreateWindow("button", "Cancel",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
286 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
287 90, 43, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
288 (HMENU) ID_CANCEL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
289 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
290 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
291 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
292
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
293 url = wdg = CreateWindowEx(WS_EX_CLIENTEDGE,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
294 "edit", NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
295 WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOHSCROLL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
296 4, 10, 300, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
297 (HMENU) ID_URL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
298 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
299 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
300 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
301 SendMessage(wdg, EM_SETLIMITTEXT, MAX_PATH, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
302
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
303 /*subclass the edit box to capture the VK_RETURN key*/
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
304 OldUrlWndProc = (WNDPROC)SetWindowLongPtr(url, GWLP_WNDPROC, (LONG_PTR)SubUrlWndProc);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
305
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
306 if((f = fopen(history, "r")))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
307 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
308 char lasturl[MAX_PATH];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
309 fgets(lasturl, MAX_PATH, f);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
310 SendMessage(url, WM_SETTEXT, 0, (LPARAM) lasturl);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
311 SendMessage(url, EM_SETSEL, 0, -1);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
312 fclose(f);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
313 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
314 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
315 case WM_KEYDOWN:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
316 switch (LOWORD(wParam))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
317 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
318 case VK_RETURN:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
319 SendMessage(hwnd, WM_COMMAND, (WPARAM) ID_OK, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
320 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
321 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
322 case WM_COMMAND:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
323 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
324 switch (LOWORD(wParam))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
325 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
326 case ID_CANCEL:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
327 DestroyWindow(hwnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
328 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
329 case ID_OK:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
330 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
331 char file[MAX_PATH];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
332 SendMessage(url, WM_GETTEXT, MAX_PATH, (LPARAM) file);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
333 mplSetFileName(NULL, file, STREAMTYPE_STREAM);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
334 if((f = fopen(history, "wt+")))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
335 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
336 fprintf(f, file);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
337 fclose(f);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
338 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
339 if(!parse_filename(file, playtree, mconfig, addurl? 0 : 1))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
340 gui->playlist->add_track(gui->playlist, file, NULL, NULL, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
341 if(!addurl)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
342 gui->startplay(gui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
343 else update_playlistwindow();
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
344 DestroyWindow(hwnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
345 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
346 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
347 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
348 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
349 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
350 case WM_DESTROY:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
351 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
352 PostQuitMessage (0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
353 addurl = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
354 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
355 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
356 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
357 return DefWindowProc(hwnd, iMsg, wParam, lParam);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
358 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
359
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
360 LRESULT CALLBACK SubUrlWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
361 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
362 switch(iMsg)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
363 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
364 case WM_KEYDOWN:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
365 switch (LOWORD(wParam))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
366 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
367 case VK_RETURN:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
368 SendMessage(FindWindow(NULL, "MPlayer - Open URL..."), WM_COMMAND, (WPARAM) ID_OK, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
369 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
370 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
371 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
372 return CallWindowProc(OldUrlWndProc, hwnd, iMsg, wParam, lParam);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
373 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
374
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
375 void display_openurlwindow(gui_t *gui, int add)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
376 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
377 if(add) addurl = 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
378 HWND hWnd;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
379 HINSTANCE hInstance = GetModuleHandle(NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
380 WNDCLASS wc;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
381 int x, y;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
382 if(FindWindow(NULL, "MPlayer - Open URL...")) return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
383 wc.style = CS_HREDRAW | CS_VREDRAW;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
384 wc.lpfnWndProc = OpenUrlWndProc;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
385 wc.cbClsExtra = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
386 wc.cbWndExtra = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
387 wc.hInstance = hInstance;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
388 wc.hCursor = LoadCursor(NULL,IDC_ARROW);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
389 wc.hIcon = gui->icon;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
390 wc.hbrBackground = SOLID_GREY2;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
391 wc.lpszClassName = "MPlayer - URL";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
392 wc.lpszMenuName = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
393 RegisterClass(&wc);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
394 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (320 / 2);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
395 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (100 / 2);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
396 hWnd = CreateWindow("MPlayer - URL",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
397 "MPlayer - Open URL...",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
398 WS_POPUPWINDOW | WS_CAPTION,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
399 x,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
400 y,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
401 320,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
402 100,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
403 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
404 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
405 hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
406 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
407 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
408 ShowWindow(hWnd, SW_SHOW);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
409 UpdateWindow(hWnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
410 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
411
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
412 static void create_playlistmenu(gui_t *gui)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
413 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
414 gui->playlistmenu = CreatePopupMenu();
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
415 AppendMenu(gui->playlistmenu, MF_STRING, ID_ADDFILE, "Add File...");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
416 AppendMenu(gui->playlistmenu, MF_STRING, ID_ADDURL, "Add Url...");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
417 AppendMenu(gui->playlistmenu, MF_SEPARATOR, 0, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
418 AppendMenu(gui->playlistmenu, MF_STRING, ID_REMOVE, "Remove Selected");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
419 AppendMenu(gui->playlistmenu, MF_STRING, ID_CLEAR, "Clear Playlist");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
420 AppendMenu(gui->playlistmenu, MF_SEPARATOR, 0, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
421 AppendMenu(gui->playlistmenu, MF_STRING, ID_CLOSE, "Close");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
422 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
423
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
424 static void updatetracklist(HWND hwnd)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
425 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
426 int i=0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
427 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
428 HWND tracklist = GetDlgItem(hwnd, ID_TRACKLIST);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
429 /* clear listbox */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
430 SendMessage(tracklist, LB_RESETCONTENT, 0, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
431 for (i=0; i < gui->playlist->trackcount; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
432 if (gui->playlist->tracks[i]->title)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
433 SendMessage(tracklist, LB_ADDSTRING, 0, (LPARAM)gui->playlist->tracks[i]->title);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
434 else
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
435 SendMessage(tracklist, LB_ADDSTRING, 0, (LPARAM)gui->playlist->tracks[i]->filename);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
436 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
437
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
438 static LRESULT CALLBACK PlayListWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
439 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
440 HWND wdg;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
441 POINT cursor;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
442 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
443 playlist_t *pl = gui ? gui->playlist : NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
444 switch (iMsg)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
445 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
446 case WM_CREATE:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
447 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
448 wdg = CreateWindow("button", "Play",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
449 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
450 4, 10, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
451 (HMENU) ID_PLAY,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
452 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
453 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
454 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
455
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
456 wdg = CreateWindow ("button", "Up",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
457 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
458 4, 37, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
459 (HMENU) ID_UP,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
460 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
461 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
462 SendMessage(wdg, WM_SETFONT,(WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
463
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
464 wdg = CreateWindow ("button", "Down",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
465 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
466 4, 64, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
467 (HMENU) ID_DOWN,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
468 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
469 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
470 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
471
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
472 wdg = CreateWindow ("button", "Remove",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
473 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
474 4, 91, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
475 (HMENU) ID_REMOVE,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
476 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
477 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
478 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
479
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
480 wdg = CreateWindow ("button", "Load",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
481 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
482 4, 118, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
483 (HMENU) ID_PLAYLISTLOAD,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
484 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
485 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
486 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
487
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
488 wdg = CreateWindow ("button", "Save",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
489 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
490 4, 145, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
491 (HMENU) ID_PLAYLISTSAVE,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
492 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
493 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
494 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
495
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
496 wdg = CreateWindow ("button", "Close",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
497 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
498 4, 193, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
499 (HMENU) ID_CLOSE,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
500 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
501 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
502 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
503
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
504 wdg = CreateWindow ("listbox", "tracklist", WS_CHILD | WS_VISIBLE | LBS_NOTIFY | WS_VSCROLL |
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
505 WS_HSCROLL | LBS_DISABLENOSCROLL, 92, 10, 300, 208, hwnd, (HMENU) ID_TRACKLIST,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
506 ((LPCREATESTRUCT) lParam) -> hInstance, NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
507 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
508 SendMessage(wdg, LB_SETHORIZONTALEXTENT, MAX_PATH*4, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
509 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
510 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
511 case WM_CONTEXTMENU:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
512 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
513 GetCursorPos(&cursor);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
514 SetForegroundWindow(hwnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
515 TrackPopupMenu(gui->playlistmenu, 0, cursor.x, cursor.y, 0, hwnd, NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
516 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
517 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
518 case WM_COMMAND:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
519 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
520 HWND tracklist = GetDlgItem(hwnd, ID_TRACKLIST);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
521 int selected = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
522 int i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
523 for (i=0; i<pl->trackcount; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
524 if(0 < SendMessage(tracklist, LB_GETSEL, i, 0)) selected = i + 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
525 switch (LOWORD(wParam))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
526 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
527 case ID_CLOSE:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
528 DestroyWindow(hwnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
529 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
530 case ID_TRACKLIST:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
531 if(HIWORD(wParam) == LBN_DBLCLK)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
532 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
533 if(selected) pl->current = selected - 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
534 mplGotoTheNext = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
535 gui->startplay(gui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
536 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
537 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
538 case ID_UP:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
539 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
540 if(selected) pl->moveup_track(pl, selected);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
541 selected--;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
542 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
543 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
544 case ID_DOWN:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
545 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
546 if(selected) pl->movedown_track(pl, selected);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
547 selected++;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
548 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
549 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
550 case ID_PLAY:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
551 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
552 if(selected) pl->current = selected - 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
553 mplGotoTheNext = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
554 gui->startplay(gui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
555 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
556 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
557 case ID_REMOVE:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
558 if(selected) pl->remove_track(pl, selected);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
559 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
560 case ID_ADDFILE:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
561 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
562 if(guiIntfStruct.StreamType == STREAMTYPE_DVD ||
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
563 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
564 display_openfilewindow(gui, 1);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
565 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
566 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
567 case ID_ADDURL:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
568 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
569 if(guiIntfStruct.StreamType == STREAMTYPE_DVD ||
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
570 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
571 display_openurlwindow(gui, 1);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
572 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
573 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
574 case ID_CLEAR:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
575 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
576 if(!gui->playlist->trackcount) return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
577 gui->playlist->clear_playlist(gui->playlist);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
578 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
579 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
580 case ID_PLAYLISTLOAD:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
581 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
582 if(guiIntfStruct.StreamType == STREAMTYPE_DVD ||
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
583 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV) return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
584 display_loadplaylistwindow(gui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
585 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
586 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
587 case ID_PLAYLISTSAVE:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
588 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
589 /* no point saving an empty playlist */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
590 if(!gui->playlist->trackcount ||
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
591 guiIntfStruct.StreamType == STREAMTYPE_DVD ||
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
592 guiIntfStruct.StreamType == STREAMTYPE_DVDNAV)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
593 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
594 display_saveplaylistwindow(gui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
595 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
596 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
597 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
598 updatetracklist(hwnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
599 if(selected < 1) selected = 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
600 else if(selected>pl->trackcount) selected = pl->trackcount;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
601 SendMessage(tracklist, LB_SETCURSEL, selected - 1, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
602 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
603 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
604 case WM_DROPFILES:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
605 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
606 char file[MAX_PATH];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
607 int filecount = DragQueryFile((HDROP) wParam, -1, file, MAX_PATH);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
608 int i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
609 for (i=0; i<filecount; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
610 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
611 DragQueryFile((HDROP) wParam, i, file, MAX_PATH);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
612 if(!parse_filename(file, playtree, mconfig, 0))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
613 pl->add_track(pl, file, NULL, NULL, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
614 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
615 DragFinish((HDROP) wParam);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
616 updatetracklist(hwnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
617 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
618 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
619 case WM_DESTROY:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
620 PostQuitMessage(0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
621 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
622 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
623 return DefWindowProc(hwnd, iMsg, wParam, lParam);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
624 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
625
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
626 void update_playlistwindow(void)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
627 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
628 HWND hWnd = FindWindow(NULL, "MPlayer Playlist");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
629 if (hWnd) updatetracklist(hWnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
630 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
631
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
632 void display_playlistwindow(gui_t *gui)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
633 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
634 HWND hWnd = FindWindow(NULL, "MPlayer Playlist");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
635 if (hWnd)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
636 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
637 SendMessage(hWnd, WM_CLOSE, 0, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
638 return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
639 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
640
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
641 HINSTANCE hInstance = GetModuleHandle(NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
642 WNDCLASS wc;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
643 int x, y;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
644
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
645 wc.style = CS_HREDRAW | CS_VREDRAW;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
646 wc.lpfnWndProc = PlayListWndProc;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
647 wc.cbClsExtra = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
648 wc.cbWndExtra = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
649 wc.hInstance = hInstance;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
650 wc.hCursor = LoadCursor(NULL,IDC_ARROW);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
651 wc.hIcon = gui->icon;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
652 wc.hbrBackground = SOLID_GREY2;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
653 wc.lpszClassName = "MPlayer - Playlist";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
654 wc.lpszMenuName = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
655 RegisterClass(&wc);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
656 create_playlistmenu(gui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
657 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (400 / 2); /* Erik: center popup window on screen */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
658 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (254 / 2);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
659 hWnd = CreateWindow("MPlayer - Playlist",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
660 "MPlayer Playlist",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
661 WS_POPUPWINDOW | WS_CAPTION | WS_MINIMIZEBOX,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
662 x,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
663 y,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
664 400,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
665 254,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
666 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
667 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
668 hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
669 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
670 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD)gui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
671 updatetracklist(hWnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
672 DragAcceptFiles(hWnd,TRUE);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
673 ShowWindow(hWnd, SW_SHOW);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
674 UpdateWindow(hWnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
675 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
676
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
677 static LRESULT CALLBACK SkinBrowserWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
678 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
679 static HWND listbox;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
680 static char skinspath[MAX_PATH];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
681 gui_t* gui = (gui_t*) GetWindowLongPtr(hwnd, GWLP_USERDATA);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
682 switch (iMsg)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
683 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
684 case WM_CREATE:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
685 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
686 listbox = CreateWindow("listbox", NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
687 WS_CHILD | WS_VISIBLE | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT |
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
688 LBS_DISABLENOSCROLL | WS_VSCROLL | WS_TABSTOP,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
689 4, 5, 166, 60, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
690 (HMENU) ID_DIR,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
691 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
692 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
693 SendMessage(listbox, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
694
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
695 /* This opens the skins directory, lists the directory names, and adds them to the listbox */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
696 sprintf(skinspath, "%s/*.", get_path("skins"));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
697
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
698 HANDLE skinHandle = INVALID_HANDLE_VALUE;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
699 WIN32_FIND_DATA finddata;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
700
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
701 skinHandle = FindFirstFile(skinspath, &finddata);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
702 if (skinHandle != INVALID_HANDLE_VALUE)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
703 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
704 do
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
705 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
706 if (finddata.cFileName[0] == '.') continue;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
707 /* populate the listbox */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
708 capitalize(finddata.cFileName);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
709 SendDlgItemMessage(hwnd, ID_DIR, LB_ADDSTRING, 0, (LPARAM) finddata.cFileName);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
710 } while (FindNextFile(skinHandle, &finddata));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
711 FindClose(skinHandle);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
712 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
713 else
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
714 mp_msg(MSGT_GPLAYER, MSGL_FATAL, "Error opening %s\n", get_path("skins"));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
715 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
716 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
717 case WM_COMMAND:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
718 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
719 if ((HWND) lParam == listbox)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
720 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
721 if(HIWORD(wParam) == LBN_DBLCLK)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
722 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
723 int index = SendMessage(listbox, LB_GETCURSEL, 0, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
724 int len = SendMessage(listbox, LB_GETTEXTLEN, index, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
725 if (len)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
726 {
18954
42d4e99a075e small fix to properly display skins when switching skins during playback.
vayne
parents: 18914
diff changeset
727 if (guiIntfStruct.Playing) guiGetEvent(guiCEvent, (void *) guiSetStop);
18914
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
728 if (skinName) free(skinName);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
729 skinName = (char *) malloc(len+1);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
730 SendMessage(listbox, LB_GETTEXT, (WPARAM) index, (LPARAM) skinName);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
731 /* fill out the full pathname to the skin */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
732 strcpy(skinspath, get_path("skins"));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
733 strcat(skinspath, "\\");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
734 strcat(skinspath, skinName);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
735 ShowWindow(hwnd, SW_HIDE);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
736 Shell_NotifyIcon(NIM_DELETE, &nid);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
737 destroy_window(gui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
738 create_window(gui, skinspath);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
739 create_subwindow(gui, skinspath);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
740 SendMessage(hwnd, WM_CLOSE, 0, 0); /* Avoid crashing when switching skin */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
741 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
742 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
743 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
744 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
745 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
746 case WM_DESTROY:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
747 PostQuitMessage(0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
748 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
749 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
750 return DefWindowProc(hwnd, iMsg, wParam, lParam);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
751 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
752
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
753 void display_skinbrowser(gui_t* gui)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
754 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
755 HWND hWnd = FindWindow(NULL, "Skin Browser");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
756 if (hWnd)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
757 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
758 SendMessage(hWnd, WM_CLOSE, 0, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
759 return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
760 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
761
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
762 HINSTANCE hInstance = GetModuleHandle(NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
763 WNDCLASS wc;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
764 int x, y;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
765
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
766 wc.style = CS_HREDRAW | CS_VREDRAW;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
767 wc.lpfnWndProc = SkinBrowserWndProc;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
768 wc.cbClsExtra = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
769 wc.cbWndExtra = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
770 wc.hInstance = hInstance;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
771 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
772 wc.hIcon = gui->icon;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
773 wc.hbrBackground = SOLID_GREY2;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
774 wc.lpszClassName = "Skin Browser";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
775 wc.lpszMenuName = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
776 RegisterClass(&wc);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
777 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (180 / 2);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
778 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (102 / 2);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
779 hWnd = CreateWindow("Skin Browser",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
780 "Skin Browser",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
781 WS_POPUPWINDOW |WS_CAPTION,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
782 x,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
783 y,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
784 180,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
785 102,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
786 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
787 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
788 hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
789 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
790 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
791 ShowWindow(hWnd, SW_SHOW);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
792 UpdateWindow(hWnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
793 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
794
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
795 #ifdef USE_DVDREAD
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
796 static LRESULT CALLBACK TitleChapterWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
797 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
798 static HWND title;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
799 static HWND chapter;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
800 HWND wdg;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
801 int i=0, j=0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
802 char titles[MAX_PATH] = "";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
803 char chapters[MAX_PATH] = "";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
804 switch (iMsg)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
805 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
806 case WM_CREATE:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
807 wdg = CreateWindow("button", "Ok",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
808 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
809 4, 43, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
810 (HMENU) ID_OK,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
811 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
812 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
813 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
814
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
815 wdg = CreateWindow("button", "Cancel",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
816 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
817 90, 43, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
818 (HMENU) ID_CANCEL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
819 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
820 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
821 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
822
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
823 title = CreateWindow("combobox", NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
824 CBS_DROPDOWNLIST | CB_SHOWDROPDOWN | CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS |
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
825 WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
826 4, 10, 80, 160, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
827 (HMENU) ID_TITLESEL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
828 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
829 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
830
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
831 SendMessage(title, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
832
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
833 chapter = CreateWindow("combobox", NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
834 CBS_DROPDOWNLIST | CB_SHOWDROPDOWN | CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS |
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
835 WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
836 90, 10, 80, 160, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
837 (HMENU) ID_CHAPTERSEL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
838 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
839 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
840 SendMessage(chapter, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
841
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
842 for (i=0; i<guiIntfStruct.DVD.titles; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
843 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
844 /* we have to reverse the order here because of the way CB_INSERTSTRING adds items */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
845 sprintf(&titles[i], "%d", guiIntfStruct.DVD.titles - i);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
846 SendDlgItemMessage(hwnd, ID_TITLESEL, CB_INSERTSTRING, 0, (LPARAM) &titles[i]);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
847 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
848 SendDlgItemMessage(hwnd, ID_TITLESEL, CB_SETCURSEL, dvd_title, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
849
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
850 for (j=0; j<guiIntfStruct.DVD.chapters; j++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
851 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
852 sprintf(&chapters[j], "%d", guiIntfStruct.DVD.chapters - j);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
853 SendDlgItemMessage(hwnd, ID_CHAPTERSEL, CB_INSERTSTRING, 0, (LPARAM) &chapters[j]);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
854 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
855 SendDlgItemMessage(hwnd, ID_CHAPTERSEL, CB_SETCURSEL, dvd_chapter, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
856
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
857 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
858 case WM_COMMAND:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
859 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
860 switch (LOWORD(wParam))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
861 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
862 case ID_CANCEL:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
863 DestroyWindow(hwnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
864 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
865 case ID_OK:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
866 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
867 guiIntfStruct.DVD.current_title = SendMessage(title, CB_GETCURSEL, 0, 0) + 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
868 guiIntfStruct.DVD.current_chapter = SendMessage(chapter, CB_GETCURSEL, 0, 0) + 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
869
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
870 if((guiIntfStruct.DVD.current_title != 0 || guiIntfStruct.DVD.current_chapter != 0))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
871 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
872 mplGotoTheNext = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
873 guiGetEvent(guiCEvent, (void *) guiSetStop);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
874 guiGetEvent(guiCEvent, (void *) guiSetPlay);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
875 DestroyWindow(hwnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
876 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
877 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
878 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
879 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
880 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
881 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
882 case WM_DESTROY:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
883 PostQuitMessage (0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
884 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
885 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
886 return DefWindowProc(hwnd, iMsg, wParam, lParam);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
887 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
888
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
889 void display_chapterselwindow(gui_t *gui)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
890 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
891 HWND hWnd;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
892 HINSTANCE hInstance = GetModuleHandle(NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
893 WNDCLASS wc;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
894 int x, y;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
895
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
896 if (guiIntfStruct.StreamType != STREAMTYPE_DVD) return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
897 if (FindWindow(NULL, "Select Title/Chapter...")) return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
898
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
899 wc.style = CS_HREDRAW | CS_VREDRAW;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
900 wc.lpfnWndProc = TitleChapterWndProc;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
901 wc.cbClsExtra = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
902 wc.cbWndExtra = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
903 wc.hInstance = hInstance;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
904 wc.hCursor = LoadCursor(NULL,IDC_ARROW);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
905 wc.hIcon = gui->icon;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
906 wc.hbrBackground = SOLID_GREY2;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
907 wc.lpszClassName = "Select Title/Chapter...";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
908 wc.lpszMenuName = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
909 RegisterClass(&wc);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
910 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (180 / 2);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
911 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (100 / 2);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
912 hWnd = CreateWindow("Select Title/Chapter...",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
913 "Select Title/Chapter...",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
914 WS_POPUPWINDOW | WS_CAPTION,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
915 x,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
916 y,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
917 180,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
918 100,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
919 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
920 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
921 hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
922 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
923 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
924 ShowWindow(hWnd, SW_SHOW);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
925 UpdateWindow(hWnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
926 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
927 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
928
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
929 static LRESULT CALLBACK EqWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
930 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
931 HWND btn, label, eq0, eq1, eq2, eq3;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
932
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
933 switch (iMsg)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
934 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
935 case WM_CREATE:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
936 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
937 btn = CreateWindow("button", "Reset",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
938 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
939 157, 143, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
940 (HMENU) ID_DEFAULTS,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
941 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
942 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
943 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
944
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
945 btn = CreateWindow("button", "Close",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
946 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
947 243, 143, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
948 (HMENU) ID_CLOSE,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
949 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
950 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
951 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
952
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
953 label = CreateWindow("static", "Brightness",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
954 WS_CHILD | WS_VISIBLE,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
955 12, 122, 70, 15, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
956 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
957 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
958 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
959 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
960
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
961 label = CreateWindow("static", "Contrast",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
962 WS_CHILD | WS_VISIBLE,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
963 99, 122, 70, 15, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
964 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
965 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
966 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
967 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
968
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
969 label = CreateWindow("static", "Hue",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
970 WS_CHILD | WS_VISIBLE,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
971 191, 122, 70, 15, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
972 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
973 ((LPCREATESTRUCT) lParam) -> hInstance, NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
974 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
975
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
976 label = CreateWindow("static", "Saturation",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
977 WS_CHILD | WS_VISIBLE,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
978 260, 122, 70, 15, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
979 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
980 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
981 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
982 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
983
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
984 eq0 = CreateWindow(TRACKBAR_CLASS, "brightness",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
985 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED |
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
986 TBS_VERT | TBS_NOTICKS,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
987 30, 0, 20, 120, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
988 (HMENU) ID_EQ0,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
989 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
990 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
991 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETRANGE, 1, MAKELONG(0, 200));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
992
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
993 eq1 = CreateWindow(TRACKBAR_CLASS, "contrast",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
994 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED |
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
995 TBS_VERT | TBS_NOTICKS,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
996 112, 0, 20, 120, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
997 (HMENU) ID_EQ1,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
998 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
999 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1000 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETRANGE, 1, MAKELONG(0, 200));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1001
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1002 eq2 = CreateWindow(TRACKBAR_CLASS, "hue",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1003 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED |
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1004 TBS_VERT | TBS_NOTICKS,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1005 194, 0, 20, 120, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1006 (HMENU) ID_EQ2,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1007 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1008 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1009 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETRANGE, 1, MAKELONG(0, 200));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1010
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1011 eq3 = CreateWindow(TRACKBAR_CLASS, "saturation",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1012 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED |
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1013 TBS_VERT | TBS_NOTICKS,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1014 276, 0, 20, 120, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1015 (HMENU) ID_EQ3,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1016 ((LPCREATESTRUCT) lParam) -> hInstance, NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1017 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETRANGE, 1, MAKELONG(0, 200));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1018
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1019 if(guiIntfStruct.sh_video && guiIntfStruct.Playing)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1020 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1021 EnableWindow(eq0, 1); EnableWindow(eq1, 1); EnableWindow(eq2, 1); EnableWindow(eq3, 1);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1022 get_video_colors(guiIntfStruct.sh_video, "brightness", &vo_gamma_brightness);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1023 get_video_colors(guiIntfStruct.sh_video, "contrast", &vo_gamma_contrast);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1024 get_video_colors(guiIntfStruct.sh_video, "hue", &vo_gamma_hue);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1025 get_video_colors(guiIntfStruct.sh_video, "saturation", &vo_gamma_saturation);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1026 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1027 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_brightness);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1028 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_contrast);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1029 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_hue);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1030 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_saturation);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1031 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1032 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1033 case WM_VSCROLL:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1034 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1035 switch (LOWORD(wParam))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1036 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1037 case TB_THUMBTRACK:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1038 if(guiIntfStruct.sh_video && guiIntfStruct.Playing)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1039 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1040 vo_gamma_brightness = 100 - SendDlgItemMessage(hwnd, ID_EQ0, TBM_GETPOS, 0, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1041 set_video_colors(guiIntfStruct.sh_video, "brightness", vo_gamma_brightness);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1042
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1043 vo_gamma_contrast = 100 - SendDlgItemMessage(hwnd, ID_EQ1, TBM_GETPOS, 0, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1044 set_video_colors(guiIntfStruct.sh_video, "contrast", vo_gamma_contrast);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1045
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1046 vo_gamma_hue = 100 - SendDlgItemMessage(hwnd, ID_EQ2, TBM_GETPOS, 0, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1047 set_video_colors(guiIntfStruct.sh_video, "hue", vo_gamma_hue);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1048
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1049 vo_gamma_saturation = 100 - SendDlgItemMessage(hwnd, ID_EQ3, TBM_GETPOS, 0, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1050 set_video_colors(guiIntfStruct.sh_video, "saturation", vo_gamma_saturation);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1051 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1052 else
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1053 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1054 EnableWindow(GetDlgItem(hwnd, ID_EQ0), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1055 EnableWindow(GetDlgItem(hwnd, ID_EQ1), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1056 EnableWindow(GetDlgItem(hwnd, ID_EQ2), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1057 EnableWindow(GetDlgItem(hwnd, ID_EQ3), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1058 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1059 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1060 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1061 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1062 case WM_CTLCOLORDLG:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1063 case WM_CTLCOLORSTATIC:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1064 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1065 HDC hdc = (HDC)wParam;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1066 SetBkMode(hdc, TRANSPARENT);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1067 return (INT_PTR)SOLID_GREY2;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1068 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1069 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1070 case WM_COMMAND:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1071 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1072 switch (LOWORD(wParam))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1073 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1074 case ID_CLOSE:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1075 DestroyWindow(hwnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1076 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1077 case ID_DEFAULTS:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1078 if(guiIntfStruct.sh_video && guiIntfStruct.Playing)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1079 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1080 vo_gamma_brightness=0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1081 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETPOS, 1, (LPARAM)100);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1082 set_video_colors(guiIntfStruct.sh_video, "brightness", vo_gamma_brightness);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1083
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1084 vo_gamma_contrast=0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1085 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETPOS, 1, (LPARAM)100);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1086 set_video_colors(guiIntfStruct.sh_video, "contrast", vo_gamma_contrast);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1087
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1088 vo_gamma_hue=0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1089 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETPOS, 1, (LPARAM)100);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1090 set_video_colors(guiIntfStruct.sh_video, "hue", vo_gamma_hue);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1091
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1092 vo_gamma_saturation=0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1093 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETPOS, 1, (LPARAM)100);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1094 set_video_colors(guiIntfStruct.sh_video, "saturation", vo_gamma_saturation);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1095 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1096 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1097 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1098 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1099 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1100 case WM_DESTROY:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1101 PostQuitMessage (0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1102 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1103 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1104 return DefWindowProc(hwnd, iMsg, wParam, lParam);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1105 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1106
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1107 void display_eqwindow(gui_t *gui)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1108 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1109 if(!guiIntfStruct.sh_video) return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1110
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1111 HWND hWnd;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1112 HINSTANCE hInstance = GetModuleHandle(NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1113 WNDCLASS wc;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1114 int x, y;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1115 if(FindWindow(NULL, "MPlayer - Equalizer")) return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1116 wc.style = CS_HREDRAW | CS_VREDRAW;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1117 wc.lpfnWndProc = EqWndProc;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1118 wc.cbClsExtra = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1119 wc.cbWndExtra = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1120 wc.hInstance = hInstance;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1121 wc.hCursor = LoadCursor(NULL,IDC_ARROW);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1122 wc.hIcon = gui->icon;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1123 wc.hbrBackground = SOLID_GREY2;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1124 wc.lpszClassName = "MPlayer - Equalizer";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1125 wc.lpszMenuName = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1126 RegisterClass(&wc);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1127 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (332 / 2);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1128 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (200 / 2);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1129 hWnd = CreateWindow("MPlayer - Equalizer",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1130 "MPlayer - Equalizer",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1131 WS_POPUPWINDOW | WS_CAPTION,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1132 x,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1133 y,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1134 332,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1135 200,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1136 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1137 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1138 hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1139 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1140 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1141 ShowWindow(hWnd, SW_SHOW);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1142 UpdateWindow(hWnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1143 }