annotate Gui/win32/dialogs.c @ 22652:c1603578b1f8

Get rid of ugly conditionals.
author diego
date Sat, 17 Mar 2007 01:09:37 +0000
parents 1c5ea79749ea
children
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 {
22487
1c5ea79749ea fixed dvd chapter and title switching
vayne
parents: 21897
diff changeset
146 mplSetFileName(NULL, filename, STREAMTYPE_FILE);
21770
7b549b0ee467 fix to allow adding multiple files to the playlist with the open file dialog.
vayne
parents: 21417
diff changeset
147 if(!parse_filename(filename, playtree, mconfig, 0))
18914
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
148 gui->playlist->add_track(gui->playlist, filename, NULL, filepart, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
149 mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding file: %s - path %s\n", filespec, filename);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
150 result++;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
151 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
152 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
153 fileopen.nFileOffset += strlen(filespec) + 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
154 } while (*filespec);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
155 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
156 return result;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
157 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
158
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
159 void display_opensubtitlewindow(gui_t *gui)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
160 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
161 OPENFILENAME subtitleopen;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
162 char subtitlefile[MAX_PATH];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
163
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
164 /* Safety check */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
165 if (guiIntfStruct.Playing == 0 || !guiIntfStruct.sh_video) return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
166
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
167 memset(&subtitleopen, 0, sizeof(OPENFILENAME));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
168 memset(subtitlefile, 0, sizeof(subtitlefile));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
169
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
170 subtitleopen.lStructSize = sizeof(OPENFILENAME);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
171 subtitleopen.hwndOwner = gui->mainwindow;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
172 subtitleopen.hInstance = GetModuleHandle(NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
173 subtitleopen.lpstrFilter = "All Files (*.*)\0*.*\0"
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
174 "Subtitle Files (*.srt;*.txt;*.vob)\0*.srt;*.txt;*.vob\0";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
175 subtitleopen.nFilterIndex = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
176 subtitleopen.lpstrTitle = "Add Subtitle...";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
177 subtitleopen.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_EXPLORER | OFN_READONLY | OFN_HIDEREADONLY;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
178 subtitleopen.lpstrFile = subtitlefile;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
179 subtitleopen.lpstrCustomFilter = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
180 subtitleopen.nMaxFile = MAXFILE;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
181
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
182 if(GetOpenFileName(&subtitleopen))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
183 guiLoadSubtitle(subtitlefile);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
184 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
185
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
186 void display_loadplaylistwindow(gui_t *gui)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
187 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
188 OPENFILENAME playlistopen;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
189 char playlistfile[MAX_PATH];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
190
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
191 memset(&playlistopen, 0, sizeof(OPENFILENAME));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
192 memset(playlistfile, 0, sizeof(playlistfile));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
193
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
194 playlistopen.lStructSize = sizeof(OPENFILENAME);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
195 playlistopen.hwndOwner = gui->mainwindow;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
196 playlistopen.hInstance = GetModuleHandle(NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
197 playlistopen.lpstrFilter = "All Files (*.*)\0*.*\0"
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
198 "Playlist Files (*.m3u;*.pls;*.txt)\0*.m3u;*.pls;*.txt\0";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
199 playlistopen.nFilterIndex = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
200 playlistopen.lpstrTitle = "Load Playlist...";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
201 playlistopen.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_EXPLORER | OFN_READONLY | OFN_HIDEREADONLY;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
202 playlistopen.lpstrFile = playlistfile;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
203 playlistopen.lpstrCustomFilter = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
204 playlistopen.nMaxFile = MAXFILE;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
205
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
206 if(GetOpenFileName(&playlistopen))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
207 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
208 if(parse_filename(playlistfile, playtree, mconfig, 1))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
209 gui->startplay(gui);
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
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
213 void display_saveplaylistwindow(gui_t* gui)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
214 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
215 OPENFILENAME playlistsave;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
216 static FILE *playlist_file = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
217 char playlistname[MAX_PATH];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
218
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
219 memset(&playlistsave, 0, sizeof(OPENFILENAME));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
220 memset(playlistname, 0, sizeof(playlistname));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
221
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
222 playlistsave.lStructSize = sizeof(OPENFILENAME);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
223 playlistsave.hwndOwner = gui->mainwindow;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
224 playlistsave.hInstance = GetModuleHandle(NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
225 playlistsave.lpstrFilter = "Playlist Files (*.pls)\0*.pls\0";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
226 playlistsave.nFilterIndex = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
227 playlistsave.lpstrTitle = "Save Playlist...";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
228 playlistsave.Flags = OFN_LONGNAMES | OFN_EXPLORER | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
229 playlistsave.lpstrFile = playlistname;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
230 playlistsave.lpstrCustomFilter = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
231 playlistsave.nMaxFile = MAXFILE;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
232
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
233 if(GetSaveFileName(&playlistsave))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
234 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
235 int i=0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
236 HANDLE my_playlist;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
237
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
238 if(!strstr(playlistname, ".pls")) strcat(playlistname, ".pls");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
239
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
240 my_playlist = CreateFile(playlistname,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
241 GENERIC_WRITE,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
242 0,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
243 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
244 CREATE_ALWAYS,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
245 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
246 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
247
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
248 if(my_playlist != INVALID_HANDLE_VALUE)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
249 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
250 CloseHandle(my_playlist); /* close the file first so we can write to it */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
251 playlist_file = fopen(playlistsave.lpstrFile, "w");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
252 fprintf(playlist_file, "[playlist]\n");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
253 fprintf(playlist_file, "numberofentries=%d\n", gui->playlist->trackcount);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
254
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
255 for(i=0; i<(gui->playlist->trackcount); i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
256 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
257 fprintf(playlist_file, "File%i=%s\n", i + 1, gui->playlist->tracks[i]->filename);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
258 fprintf(playlist_file, "Length%i=-1\n", i + 1);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
259 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
260 fclose(playlist_file);
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
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
265 static LRESULT CALLBACK OpenUrlWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
266 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
267 static HWND url;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
268 HWND wdg;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
269 FILE *f;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
270 char *history = get_path("gui.url");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
271 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
272 switch (iMsg)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
273 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
274 case WM_CREATE:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
275 wdg = CreateWindow("button", "Ok",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
276 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
277 4, 43, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
278 (HMENU) ID_OK,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
279 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
280 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
281 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
282
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
283 wdg = CreateWindow("button", "Cancel",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
284 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
285 90, 43, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
286 (HMENU) ID_CANCEL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
287 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
288 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
289 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
290
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
291 url = wdg = CreateWindowEx(WS_EX_CLIENTEDGE,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
292 "edit", NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
293 WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOHSCROLL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
294 4, 10, 300, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
295 (HMENU) ID_URL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
296 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
297 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
298 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
299 SendMessage(wdg, EM_SETLIMITTEXT, MAX_PATH, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
300
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
301 /*subclass the edit box to capture the VK_RETURN key*/
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
302 OldUrlWndProc = (WNDPROC)SetWindowLongPtr(url, GWLP_WNDPROC, (LONG_PTR)SubUrlWndProc);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
303
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
304 if((f = fopen(history, "r")))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
305 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
306 char lasturl[MAX_PATH];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
307 fgets(lasturl, MAX_PATH, f);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
308 SendMessage(url, WM_SETTEXT, 0, (LPARAM) lasturl);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
309 SendMessage(url, EM_SETSEL, 0, -1);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
310 fclose(f);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
311 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
312 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
313 case WM_KEYDOWN:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
314 switch (LOWORD(wParam))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
315 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
316 case VK_RETURN:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
317 SendMessage(hwnd, WM_COMMAND, (WPARAM) ID_OK, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
318 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
319 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
320 case WM_COMMAND:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
321 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
322 switch (LOWORD(wParam))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
323 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
324 case ID_CANCEL:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
325 DestroyWindow(hwnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
326 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
327 case ID_OK:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
328 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
329 char file[MAX_PATH];
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
330 SendMessage(url, WM_GETTEXT, MAX_PATH, (LPARAM) file);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
331 mplSetFileName(NULL, file, STREAMTYPE_STREAM);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
332 if((f = fopen(history, "wt+")))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
333 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
334 fprintf(f, file);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
335 fclose(f);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
336 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
337 if(!parse_filename(file, playtree, mconfig, addurl? 0 : 1))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
338 gui->playlist->add_track(gui->playlist, file, NULL, NULL, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
339 if(!addurl)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
340 gui->startplay(gui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
341 else update_playlistwindow();
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
342 DestroyWindow(hwnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
343 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
344 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
345 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
346 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
347 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
348 case WM_DESTROY:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
349 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
350 PostQuitMessage (0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
351 addurl = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
352 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
353 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
354 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
355 return DefWindowProc(hwnd, iMsg, wParam, lParam);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
356 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
357
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
358 LRESULT CALLBACK SubUrlWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
359 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
360 switch(iMsg)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
361 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
362 case WM_KEYDOWN:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
363 switch (LOWORD(wParam))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
364 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
365 case VK_RETURN:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
366 SendMessage(FindWindow(NULL, "MPlayer - Open URL..."), WM_COMMAND, (WPARAM) ID_OK, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
367 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
368 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
369 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
370 return CallWindowProc(OldUrlWndProc, hwnd, iMsg, wParam, lParam);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
371 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
372
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
373 void display_openurlwindow(gui_t *gui, int add)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
374 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
375 HWND hWnd;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
376 HINSTANCE hInstance = GetModuleHandle(NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
377 WNDCLASS wc;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
378 int x, y;
19718
e701a6eed5cb ISO C90 warnings fixes
vayne
parents: 19271
diff changeset
379
e701a6eed5cb ISO C90 warnings fixes
vayne
parents: 19271
diff changeset
380 if(add) addurl = 1;
18914
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
381 if(FindWindow(NULL, "MPlayer - Open URL...")) return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
382 wc.style = CS_HREDRAW | CS_VREDRAW;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
383 wc.lpfnWndProc = OpenUrlWndProc;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
384 wc.cbClsExtra = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
385 wc.cbWndExtra = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
386 wc.hInstance = hInstance;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
387 wc.hCursor = LoadCursor(NULL,IDC_ARROW);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
388 wc.hIcon = gui->icon;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
389 wc.hbrBackground = SOLID_GREY2;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
390 wc.lpszClassName = "MPlayer - URL";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
391 wc.lpszMenuName = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
392 RegisterClass(&wc);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
393 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (320 / 2);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
394 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (100 / 2);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
395 hWnd = CreateWindow("MPlayer - URL",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
396 "MPlayer - Open URL...",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
397 WS_POPUPWINDOW | WS_CAPTION,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
398 x,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
399 y,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
400 320,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
401 100,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
402 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
403 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
404 hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
405 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
406 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
407 ShowWindow(hWnd, SW_SHOW);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
408 UpdateWindow(hWnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
409 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
410
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
411 static void create_playlistmenu(gui_t *gui)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
412 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
413 gui->playlistmenu = CreatePopupMenu();
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
414 AppendMenu(gui->playlistmenu, MF_STRING, ID_ADDFILE, "Add File...");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
415 AppendMenu(gui->playlistmenu, MF_STRING, ID_ADDURL, "Add Url...");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
416 AppendMenu(gui->playlistmenu, MF_SEPARATOR, 0, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
417 AppendMenu(gui->playlistmenu, MF_STRING, ID_REMOVE, "Remove Selected");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
418 AppendMenu(gui->playlistmenu, MF_STRING, ID_CLEAR, "Clear Playlist");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
419 AppendMenu(gui->playlistmenu, MF_SEPARATOR, 0, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
420 AppendMenu(gui->playlistmenu, MF_STRING, ID_CLOSE, "Close");
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
421 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
422
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
423 static void updatetracklist(HWND hwnd)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
424 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
425 int i=0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
426 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
427 /* 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
428 SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_RESETCONTENT, 0, 0);
18914
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
429 for (i=0; i < gui->playlist->trackcount; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
430 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
431 SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_ADDSTRING, 0, (LPARAM)gui->playlist->tracks[i]->title);
18914
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
432 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
433 SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_ADDSTRING, 0, (LPARAM)gui->playlist->tracks[i]->filename);
18914
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
434 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
435
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
436 static LRESULT CALLBACK PlayListWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
437 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
438 HWND wdg;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
439 POINT cursor;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
440 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
441 playlist_t *pl = gui ? gui->playlist : NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
442 switch (iMsg)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
443 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
444 case WM_CREATE:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
445 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
446 wdg = CreateWindow("button", "Play",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
447 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
448 4, 10, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
449 (HMENU) ID_PLAY,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
450 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
451 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
452 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
453
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
454 wdg = CreateWindow ("button", "Up",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
455 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
456 4, 37, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
457 (HMENU) ID_UP,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
458 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
459 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
460 SendMessage(wdg, WM_SETFONT,(WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
461
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
462 wdg = CreateWindow ("button", "Down",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
463 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
464 4, 64, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
465 (HMENU) ID_DOWN,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
466 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
467 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
468 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
469
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
470 wdg = CreateWindow ("button", "Remove",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
471 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
472 4, 91, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
473 (HMENU) ID_REMOVE,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
474 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
475 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
476 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
477
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
478 wdg = CreateWindow ("button", "Load",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
479 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
480 4, 118, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
481 (HMENU) ID_PLAYLISTLOAD,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
482 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
483 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
484 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
485
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
486 wdg = CreateWindow ("button", "Save",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
487 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
488 4, 145, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
489 (HMENU) ID_PLAYLISTSAVE,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
490 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
491 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
492 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
493
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
494 wdg = CreateWindow ("button", "Close",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
495 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
496 4, 193, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
497 (HMENU) ID_CLOSE,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
498 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
499 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
500 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT),0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
501
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
502 wdg = CreateWindow ("listbox", "tracklist", WS_CHILD | WS_VISIBLE | LBS_NOTIFY | WS_VSCROLL |
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
503 WS_HSCROLL | LBS_DISABLENOSCROLL, 92, 10, 300, 208, hwnd, (HMENU) ID_TRACKLIST,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
504 ((LPCREATESTRUCT) lParam) -> hInstance, NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
505 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
506 SendMessage(wdg, LB_SETHORIZONTALEXTENT, MAX_PATH*4, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
507 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
508 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
509 case WM_CONTEXTMENU:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
510 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
511 GetCursorPos(&cursor);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
512 SetForegroundWindow(hwnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
513 TrackPopupMenu(gui->playlistmenu, 0, cursor.x, cursor.y, 0, hwnd, NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
514 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
515 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
516 case WM_COMMAND:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
517 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
518 int selected = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
519 int i;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
520 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
521 if(0 < SendDlgItemMessage(hwnd, ID_TRACKLIST, LB_GETSEL, i, 0)) selected = i + 1;
18914
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
522 switch (LOWORD(wParam))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
523 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
524 case ID_CLOSE:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
525 DestroyWindow(hwnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
526 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
527 case ID_TRACKLIST:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
528 if(HIWORD(wParam) == LBN_DBLCLK)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
529 {
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
530 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
531 if(selected) pl->current = selected - 1;
20134
42ce2edca8b7 indentation fixes.
vayne
parents: 20131
diff changeset
532 mplSetFileName(NULL, pl->tracks[pl->current]->filename, STREAMTYPE_STREAM);
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] = "";
22487
1c5ea79749ea fixed dvd chapter and title switching
vayne
parents: 21897
diff changeset
795 gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
18914
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
796 switch (iMsg)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
797 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
798 case WM_CREATE:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
799 wdg = CreateWindow("button", "Ok",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
800 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
801 4, 43, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
802 (HMENU) ID_OK,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
803 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
804 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
805 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
806
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
807 wdg = CreateWindow("button", "Cancel",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
808 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
809 90, 43, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
810 (HMENU) ID_CANCEL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
811 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
812 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
813 SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
814
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
815 title = CreateWindow("combobox", NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
816 CBS_DROPDOWNLIST | CB_SHOWDROPDOWN | CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS |
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
817 WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
818 4, 10, 80, 160, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
819 (HMENU) ID_TITLESEL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
820 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
821 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
822
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
823 SendMessage(title, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
824
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
825 chapter = CreateWindow("combobox", NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
826 CBS_DROPDOWNLIST | CB_SHOWDROPDOWN | CBS_NOINTEGRALHEIGHT | CBS_HASSTRINGS |
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
827 WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
828 90, 10, 80, 160, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
829 (HMENU) ID_CHAPTERSEL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
830 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
831 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
832 SendMessage(chapter, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
833
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
834 for (i=0; i<guiIntfStruct.DVD.titles; i++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
835 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
836 /* we have to reverse the order here because of the way CB_INSERTSTRING adds items */
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
837 sprintf(&titles[i], "%d", guiIntfStruct.DVD.titles - i);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
838 SendDlgItemMessage(hwnd, ID_TITLESEL, CB_INSERTSTRING, 0, (LPARAM) &titles[i]);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
839 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
840 SendDlgItemMessage(hwnd, ID_TITLESEL, CB_SETCURSEL, dvd_title, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
841
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
842 for (j=0; j<guiIntfStruct.DVD.chapters; j++)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
843 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
844 sprintf(&chapters[j], "%d", guiIntfStruct.DVD.chapters - j);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
845 SendDlgItemMessage(hwnd, ID_CHAPTERSEL, CB_INSERTSTRING, 0, (LPARAM) &chapters[j]);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
846 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
847 SendDlgItemMessage(hwnd, ID_CHAPTERSEL, CB_SETCURSEL, dvd_chapter, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
848
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
849 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
850 case WM_COMMAND:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
851 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
852 switch (LOWORD(wParam))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
853 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
854 case ID_CANCEL:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
855 DestroyWindow(hwnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
856 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
857 case ID_OK:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
858 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
859 guiIntfStruct.DVD.current_title = SendMessage(title, CB_GETCURSEL, 0, 0) + 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
860 guiIntfStruct.DVD.current_chapter = SendMessage(chapter, CB_GETCURSEL, 0, 0) + 1;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
861
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
862 if((guiIntfStruct.DVD.current_title != 0 || guiIntfStruct.DVD.current_chapter != 0))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
863 {
22487
1c5ea79749ea fixed dvd chapter and title switching
vayne
parents: 21897
diff changeset
864 gui->startplay(gui);
18914
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
865 DestroyWindow(hwnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
866 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
867 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
868 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
869 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
870 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
871 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
872 case WM_DESTROY:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
873 PostQuitMessage (0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
874 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
875 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
876 return DefWindowProc(hwnd, iMsg, wParam, lParam);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
877 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
878
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
879 void display_chapterselwindow(gui_t *gui)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
880 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
881 HWND hWnd;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
882 HINSTANCE hInstance = GetModuleHandle(NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
883 WNDCLASS wc;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
884 int x, y;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
885
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
886 if (guiIntfStruct.StreamType != STREAMTYPE_DVD) return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
887 if (FindWindow(NULL, "Select Title/Chapter...")) return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
888
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
889 wc.style = CS_HREDRAW | CS_VREDRAW;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
890 wc.lpfnWndProc = TitleChapterWndProc;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
891 wc.cbClsExtra = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
892 wc.cbWndExtra = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
893 wc.hInstance = hInstance;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
894 wc.hCursor = LoadCursor(NULL,IDC_ARROW);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
895 wc.hIcon = gui->icon;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
896 wc.hbrBackground = SOLID_GREY2;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
897 wc.lpszClassName = "Select Title/Chapter...";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
898 wc.lpszMenuName = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
899 RegisterClass(&wc);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
900 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (180 / 2);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
901 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (100 / 2);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
902 hWnd = CreateWindow("Select Title/Chapter...",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
903 "Select Title/Chapter...",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
904 WS_POPUPWINDOW | WS_CAPTION,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
905 x,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
906 y,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
907 180,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
908 100,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
909 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
910 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
911 hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
912 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
913 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
914 ShowWindow(hWnd, SW_SHOW);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
915 UpdateWindow(hWnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
916 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
917 #endif
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
918
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
919 static LRESULT CALLBACK EqWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
920 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
921 HWND btn, label, eq0, eq1, eq2, eq3;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
922
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
923 switch (iMsg)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
924 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
925 case WM_CREATE:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
926 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
927 btn = CreateWindow("button", "Reset",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
928 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
929 157, 143, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
930 (HMENU) ID_DEFAULTS,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
931 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
932 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
933 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
934
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
935 btn = CreateWindow("button", "Close",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
936 WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
937 243, 143, 80, 25, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
938 (HMENU) ID_CLOSE,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
939 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
940 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
941 SendMessage(btn, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
942
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
943 label = CreateWindow("static", "Brightness",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
944 WS_CHILD | WS_VISIBLE,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
945 12, 122, 70, 15, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
946 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
947 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
948 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
949 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
950
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
951 label = CreateWindow("static", "Contrast",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
952 WS_CHILD | WS_VISIBLE,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
953 99, 122, 70, 15, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
954 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
955 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
956 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
957 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
958
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
959 label = CreateWindow("static", "Hue",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
960 WS_CHILD | WS_VISIBLE,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
961 191, 122, 70, 15, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
962 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
963 ((LPCREATESTRUCT) lParam) -> hInstance, NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
964 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
965
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
966 label = CreateWindow("static", "Saturation",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
967 WS_CHILD | WS_VISIBLE,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
968 260, 122, 70, 15, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
969 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
970 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
971 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
972 SendMessage(label, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
973
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
974 eq0 = CreateWindow(TRACKBAR_CLASS, "brightness",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
975 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED |
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
976 TBS_VERT | TBS_NOTICKS,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
977 30, 0, 20, 120, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
978 (HMENU) ID_EQ0,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
979 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
980 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
981 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETRANGE, 1, MAKELONG(0, 200));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
982
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
983 eq1 = CreateWindow(TRACKBAR_CLASS, "contrast",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
984 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED |
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
985 TBS_VERT | TBS_NOTICKS,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
986 112, 0, 20, 120, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
987 (HMENU) ID_EQ1,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
988 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
989 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
990 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETRANGE, 1, MAKELONG(0, 200));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
991
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
992 eq2 = CreateWindow(TRACKBAR_CLASS, "hue",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
993 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED |
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
994 TBS_VERT | TBS_NOTICKS,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
995 194, 0, 20, 120, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
996 (HMENU) ID_EQ2,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
997 ((LPCREATESTRUCT) lParam) -> hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
998 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
999 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETRANGE, 1, MAKELONG(0, 200));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1000
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1001 eq3 = CreateWindow(TRACKBAR_CLASS, "saturation",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1002 WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_DISABLED |
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1003 TBS_VERT | TBS_NOTICKS,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1004 276, 0, 20, 120, hwnd,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1005 (HMENU) ID_EQ3,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1006 ((LPCREATESTRUCT) lParam) -> hInstance, NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1007 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETRANGE, 1, MAKELONG(0, 200));
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1008
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1009 if(guiIntfStruct.sh_video && guiIntfStruct.Playing)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1010 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1011 EnableWindow(eq0, 1); EnableWindow(eq1, 1); EnableWindow(eq2, 1); EnableWindow(eq3, 1);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1012 get_video_colors(guiIntfStruct.sh_video, "brightness", &vo_gamma_brightness);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1013 get_video_colors(guiIntfStruct.sh_video, "contrast", &vo_gamma_contrast);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1014 get_video_colors(guiIntfStruct.sh_video, "hue", &vo_gamma_hue);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1015 get_video_colors(guiIntfStruct.sh_video, "saturation", &vo_gamma_saturation);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1016 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1017 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_brightness);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1018 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_contrast);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1019 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_hue);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1020 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETPOS, 1, (LPARAM)100 - vo_gamma_saturation);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1021 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1022 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1023 case WM_VSCROLL:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1024 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1025 switch (LOWORD(wParam))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1026 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1027 case TB_THUMBTRACK:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1028 if(guiIntfStruct.sh_video && guiIntfStruct.Playing)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1029 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1030 vo_gamma_brightness = 100 - SendDlgItemMessage(hwnd, ID_EQ0, TBM_GETPOS, 0, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1031 set_video_colors(guiIntfStruct.sh_video, "brightness", vo_gamma_brightness);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1032
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1033 vo_gamma_contrast = 100 - SendDlgItemMessage(hwnd, ID_EQ1, TBM_GETPOS, 0, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1034 set_video_colors(guiIntfStruct.sh_video, "contrast", vo_gamma_contrast);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1035
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1036 vo_gamma_hue = 100 - SendDlgItemMessage(hwnd, ID_EQ2, TBM_GETPOS, 0, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1037 set_video_colors(guiIntfStruct.sh_video, "hue", vo_gamma_hue);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1038
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1039 vo_gamma_saturation = 100 - SendDlgItemMessage(hwnd, ID_EQ3, TBM_GETPOS, 0, 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1040 set_video_colors(guiIntfStruct.sh_video, "saturation", vo_gamma_saturation);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1041 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1042 else
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1043 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1044 EnableWindow(GetDlgItem(hwnd, ID_EQ0), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1045 EnableWindow(GetDlgItem(hwnd, ID_EQ1), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1046 EnableWindow(GetDlgItem(hwnd, ID_EQ2), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1047 EnableWindow(GetDlgItem(hwnd, ID_EQ3), 0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1048 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1049 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1050 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1051 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1052 case WM_CTLCOLORDLG:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1053 case WM_CTLCOLORSTATIC:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1054 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1055 HDC hdc = (HDC)wParam;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1056 SetBkMode(hdc, TRANSPARENT);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1057 return (INT_PTR)SOLID_GREY2;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1058 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1059 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1060 case WM_COMMAND:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1061 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1062 switch (LOWORD(wParam))
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1063 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1064 case ID_CLOSE:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1065 DestroyWindow(hwnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1066 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1067 case ID_DEFAULTS:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1068 if(guiIntfStruct.sh_video && guiIntfStruct.Playing)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1069 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1070 vo_gamma_brightness=0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1071 SendDlgItemMessage(hwnd, ID_EQ0, TBM_SETPOS, 1, (LPARAM)100);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1072 set_video_colors(guiIntfStruct.sh_video, "brightness", vo_gamma_brightness);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1073
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1074 vo_gamma_contrast=0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1075 SendDlgItemMessage(hwnd, ID_EQ1, TBM_SETPOS, 1, (LPARAM)100);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1076 set_video_colors(guiIntfStruct.sh_video, "contrast", vo_gamma_contrast);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1077
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1078 vo_gamma_hue=0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1079 SendDlgItemMessage(hwnd, ID_EQ2, TBM_SETPOS, 1, (LPARAM)100);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1080 set_video_colors(guiIntfStruct.sh_video, "hue", vo_gamma_hue);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1081
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1082 vo_gamma_saturation=0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1083 SendDlgItemMessage(hwnd, ID_EQ3, TBM_SETPOS, 1, (LPARAM)100);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1084 set_video_colors(guiIntfStruct.sh_video, "saturation", vo_gamma_saturation);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1085 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1086 break;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1087 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1088 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1089 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1090 case WM_DESTROY:
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1091 PostQuitMessage (0);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1092 return 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1093 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1094 return DefWindowProc(hwnd, iMsg, wParam, lParam);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1095 }
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1096
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1097 void display_eqwindow(gui_t *gui)
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1098 {
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1099 HWND hWnd;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1100 HINSTANCE hInstance = GetModuleHandle(NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1101 WNDCLASS wc;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1102 int x, y;
19718
e701a6eed5cb ISO C90 warnings fixes
vayne
parents: 19271
diff changeset
1103
e701a6eed5cb ISO C90 warnings fixes
vayne
parents: 19271
diff changeset
1104 if(!guiIntfStruct.sh_video) return;
18914
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1105 if(FindWindow(NULL, "MPlayer - Equalizer")) return;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1106 wc.style = CS_HREDRAW | CS_VREDRAW;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1107 wc.lpfnWndProc = EqWndProc;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1108 wc.cbClsExtra = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1109 wc.cbWndExtra = 0;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1110 wc.hInstance = hInstance;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1111 wc.hCursor = LoadCursor(NULL,IDC_ARROW);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1112 wc.hIcon = gui->icon;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1113 wc.hbrBackground = SOLID_GREY2;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1114 wc.lpszClassName = "MPlayer - Equalizer";
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1115 wc.lpszMenuName = NULL;
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1116 RegisterClass(&wc);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1117 x = (GetSystemMetrics(SM_CXSCREEN) / 2) - (332 / 2);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1118 y = (GetSystemMetrics(SM_CYSCREEN) / 2) - (200 / 2);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1119 hWnd = CreateWindow("MPlayer - Equalizer",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1120 "MPlayer - Equalizer",
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1121 WS_POPUPWINDOW | WS_CAPTION,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1122 x,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1123 y,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1124 332,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1125 200,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1126 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1127 NULL,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1128 hInstance,
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1129 NULL);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1130 SetWindowLongPtr(hWnd, GWLP_USERDATA, (DWORD) gui);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1131 ShowWindow(hWnd, SW_SHOW);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1132 UpdateWindow(hWnd);
d450ec82ae57 Initial win32 gui release.
vayne
parents:
diff changeset
1133 }