annotate Gui/win32/dialogs.c @ 21868:13a488205267

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