⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dialogs.c

📁 uclinux下mplayer的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
/* * MPlayer GUI for Win32 * Copyright (C) 2003 Sascha Sommer <saschasommer@freenet.de> * Copyright (C) 2006 Erik Augustson <erik_27can@yahoo.com> * Copyright (C) 2006 Gianluigi Tiesi <sherpya@netfarm.it> * * This file is part of MPlayer. * * MPlayer is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * MPlayer is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with MPlayer; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */#include <windows.h>#include <commctrl.h>#include "interface.h"#include "mp_msg.h"#include "help_mp.h"#include "stream/stream.h"#include "libmpdemux/demuxer.h"#include "libmpdemux/stheader.h"#include "gui.h"#include "wincfg.h"#include "dialogs.h"#include "libvo/sub.h"WNDPROC OldUrlWndProc;LRESULT CALLBACK SubUrlWndProc(HWND, UINT, WPARAM, LPARAM);extern int vo_gamma_brightness;extern int vo_gamma_saturation;extern int vo_gamma_contrast;extern int vo_gamma_hue;extern int set_video_colors(sh_video_t *sh_video, char *item, int value);extern int get_video_colors(sh_video_t *sh_video, char *item, int *value);guiInterface_t guiIntfStruct;int addurl = 0;extern mp_osd_obj_t* vo_osd_list;extern char **sub_name;void guiLoadSubtitle(char *name){    if (!guiIntfStruct.Playing)    {        guiIntfStruct.SubtitleChanged = 1;        return;    }    if (subdata)    {        mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_DeletingSubtitles);        sub_free(subdata);        subdata = NULL;        vo_sub = NULL;        if (vo_osd_list)        {            int len;            mp_osd_obj_t *osd = vo_osd_list;            while (osd)            {                if (osd->type == OSDTYPE_SUBTITLE) break;                osd = osd->next;            }            if (osd && osd->flags & OSDFLAG_VISIBLE)            {                len = osd->stride * (osd->bbox.y2 - osd->bbox.y1);                memset(osd->bitmap_buffer, 0, len);                memset(osd->alpha_buffer, 0, len);            }        }    }    if (name)    {        mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_LoadingSubtitles, name);        subdata = sub_read_file(strdup(name), guiIntfStruct.FPS);        if (!subdata) mp_msg(MSGT_GPLAYER, MSGL_ERR, MSGTR_CantLoadSub,name);        sub_name = (malloc(2 * sizeof(char*))); /* when mplayer will be restarted */        sub_name[0] = strdup(name);               /* sub_name[0] will be read */        sub_name[1] = NULL;    }    update_set_of_subtitles();}int display_openfilewindow(gui_t *gui, int add){    OPENFILENAME fileopen;    int result = 0;    char filelist[MAXFILE];    char filename[MAX_PATH];    char directory[MAX_PATH];    char *filespec = NULL;    char *filepart = NULL;    memset(&fileopen, 0, sizeof(OPENFILENAME));    memset(filelist, 0, sizeof(filelist));    fileopen.lStructSize = sizeof(OPENFILENAME);    fileopen.hwndOwner = gui->mainwindow;    fileopen.hInstance = GetModuleHandle(NULL);    fileopen.lpstrFilter = "All Files (*.*)\0*.*\0"                           "Media Files (*.avi;*.asf;*.wmv;*.mpg;*.mpeg;*.m2v;*.mov;\                                         *.rmvb;*.rm;*.ogm;*.mp3;*.wav;*.wma;*.ra;*.ogg)\0\                                         *.avi;*.asf;*.wmv;*.mpg;*.mpeg;*.m2v;*.mov;\                                         *.rmvb;*.rm;*.ogm;*.mp3;*.wav;*.wma;*.ra;*.ogg\0"                           "Video Files (*.avi;*.mpg;*.mpeg;*.mov)\0*.avi;*.mpg;*.mpeg;*.mov\0"                           "Avisynth Scripts (*.avs)\0*.avs\0"                           "Audio Files (*.mp3;*.wav;*.ra)\0*.mp3;*.wav;*.ra\000";    fileopen.nFilterIndex = 0;    fileopen.lpstrTitle = "Add file(s)...";    fileopen.Flags = OFN_ALLOWMULTISELECT | OFN_FILEMUSTEXIST| OFN_LONGNAMES | OFN_EXPLORER| OFN_READONLY | OFN_HIDEREADONLY;    fileopen.lpstrFile = filelist;    fileopen.lpstrCustomFilter = NULL;    fileopen.nMaxFile = MAXFILE;    if(GetOpenFileName(&fileopen))    {        /* clear playlist */        if(!add) gui->playlist->clear_playlist(gui->playlist);        memcpy(directory, fileopen.lpstrFile, fileopen.nFileOffset - 1);        directory[fileopen.nFileOffset - 1] = 0;        do        {            filespec = &fileopen.lpstrFile[fileopen.nFileOffset];            filename[0] = 0;            strcat(filename, directory);            strcat(filename, "\\");            strcat(filename, filespec);            if (GetFileAttributes(filename) & FILE_ATTRIBUTE_DIRECTORY)                mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] %s is a directory, skipping...\n", filename);            else            {                if (GetFullPathName(filename, MAX_PATH, filename, &filepart))                {                    mplSetFileName(NULL, filename, STREAMTYPE_FILE);                    if(!parse_filename(filename, playtree, mconfig, 0))                        gui->playlist->add_track(gui->playlist, filename, NULL, filepart, 0);                    mp_msg(MSGT_GPLAYER, MSGL_V, "[GUI] Adding file: %s - path %s\n", filespec, filename);                    result++;                }            }            fileopen.nFileOffset += strlen(filespec) + 1;        } while (*filespec);    }    return result;}void display_opensubtitlewindow(gui_t *gui){    OPENFILENAME subtitleopen;    char subtitlefile[MAX_PATH];    /* Safety check */    if (guiIntfStruct.Playing == 0 || !guiIntfStruct.sh_video) return;    memset(&subtitleopen, 0, sizeof(OPENFILENAME));    memset(subtitlefile, 0, sizeof(subtitlefile));    subtitleopen.lStructSize = sizeof(OPENFILENAME);    subtitleopen.hwndOwner = gui->mainwindow;    subtitleopen.hInstance = GetModuleHandle(NULL);    subtitleopen.lpstrFilter = "All Files (*.*)\0*.*\0"                               "Subtitle Files (*.srt;*.txt;*.vob)\0*.srt;*.txt;*.vob\0";    subtitleopen.nFilterIndex = 0;    subtitleopen.lpstrTitle = "Add Subtitle...";    subtitleopen.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_EXPLORER | OFN_READONLY | OFN_HIDEREADONLY;    subtitleopen.lpstrFile = subtitlefile;    subtitleopen.lpstrCustomFilter = NULL;    subtitleopen.nMaxFile = MAXFILE;    if(GetOpenFileName(&subtitleopen))        guiLoadSubtitle(subtitlefile);}void display_loadplaylistwindow(gui_t *gui){    OPENFILENAME playlistopen;    char playlistfile[MAX_PATH];    memset(&playlistopen, 0, sizeof(OPENFILENAME));    memset(playlistfile, 0, sizeof(playlistfile));    playlistopen.lStructSize = sizeof(OPENFILENAME);    playlistopen.hwndOwner = gui->mainwindow;    playlistopen.hInstance = GetModuleHandle(NULL);    playlistopen.lpstrFilter = "All Files (*.*)\0*.*\0"                               "Playlist Files (*.m3u;*.pls;*.txt)\0*.m3u;*.pls;*.txt\0";    playlistopen.nFilterIndex = 0;    playlistopen.lpstrTitle = "Load Playlist...";    playlistopen.Flags = OFN_FILEMUSTEXIST | OFN_LONGNAMES | OFN_EXPLORER | OFN_READONLY | OFN_HIDEREADONLY;    playlistopen.lpstrFile = playlistfile;    playlistopen.lpstrCustomFilter = NULL;    playlistopen.nMaxFile = MAXFILE;    if(GetOpenFileName(&playlistopen))    {        if(parse_filename(playlistfile, playtree, mconfig, 1))            gui->startplay(gui);    }}void display_saveplaylistwindow(gui_t* gui){    OPENFILENAME playlistsave;    static FILE *playlist_file = NULL;    char playlistname[MAX_PATH];    memset(&playlistsave, 0, sizeof(OPENFILENAME));    memset(playlistname, 0, sizeof(playlistname));    playlistsave.lStructSize = sizeof(OPENFILENAME);    playlistsave.hwndOwner = gui->mainwindow;    playlistsave.hInstance = GetModuleHandle(NULL);    playlistsave.lpstrFilter = "Playlist Files (*.pls)\0*.pls\0";    playlistsave.nFilterIndex = 0;    playlistsave.lpstrTitle = "Save Playlist...";    playlistsave.Flags = OFN_LONGNAMES | OFN_EXPLORER | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY;    playlistsave.lpstrFile = playlistname;    playlistsave.lpstrCustomFilter = NULL;    playlistsave.nMaxFile = MAXFILE;    if(GetSaveFileName(&playlistsave))    {        int i=0;        HANDLE my_playlist;        if(!strstr(playlistname, ".pls")) strcat(playlistname, ".pls");        my_playlist = CreateFile(playlistname,                                 GENERIC_WRITE,                                 0,                                 NULL,                                 CREATE_ALWAYS,                                 FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,                                 NULL);        if(my_playlist != INVALID_HANDLE_VALUE)        {            CloseHandle(my_playlist); /* close the file first so we can write to it */            playlist_file = fopen(playlistsave.lpstrFile, "w");            fprintf(playlist_file, "[playlist]\n");            fprintf(playlist_file, "numberofentries=%d\n", gui->playlist->trackcount);            for(i=0; i<(gui->playlist->trackcount); i++)            {                fprintf(playlist_file, "File%i=%s\n", i + 1, gui->playlist->tracks[i]->filename);                fprintf(playlist_file, "Length%i=-1\n", i + 1);            }            fclose(playlist_file);        }    }}static LRESULT CALLBACK OpenUrlWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam){    static HWND url;    HWND wdg;    FILE *f;    char *history = get_path("gui.url");    gui_t *gui = (gui_t *) GetWindowLongPtr(hwnd, GWLP_USERDATA);    switch (iMsg)    {        case WM_CREATE:            wdg = CreateWindow("button", "Ok",                               WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,                               4, 43, 80, 25, hwnd,                               (HMENU) ID_OK,                               ((LPCREATESTRUCT) lParam) -> hInstance,                               NULL);            SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);            wdg = CreateWindow("button", "Cancel",                               WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,                               90, 43, 80, 25, hwnd,                               (HMENU) ID_CANCEL,                               ((LPCREATESTRUCT) lParam) -> hInstance,                               NULL);            SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);            url = wdg = CreateWindowEx(WS_EX_CLIENTEDGE,                               "edit", NULL,                               WS_CHILD | WS_VISIBLE | ES_LEFT | ES_AUTOHSCROLL,                               4, 10, 300, 25, hwnd,                               (HMENU) ID_URL,                               ((LPCREATESTRUCT) lParam) -> hInstance,                               NULL);            SendMessage(wdg, WM_SETFONT, (WPARAM) GetStockObject(DEFAULT_GUI_FONT), 0);            SendMessage(wdg, EM_SETLIMITTEXT, MAX_PATH, 0);            /*subclass the edit box to capture the VK_RETURN key*/            OldUrlWndProc = (WNDPROC)SetWindowLongPtr(url, GWLP_WNDPROC, (LONG_PTR)SubUrlWndProc);            if((f = fopen(history, "r")))            {               char lasturl[MAX_PATH];               fgets(lasturl, MAX_PATH, f);               SendMessage(url, WM_SETTEXT, 0, (LPARAM) lasturl);               SendMessage(url, EM_SETSEL, 0, -1);               fclose(f);            }            break;        case WM_KEYDOWN:            switch (LOWORD(wParam))            {                case VK_RETURN:                    SendMessage(hwnd, WM_COMMAND, (WPARAM) ID_OK, 0);                    break;            }        case WM_COMMAND:        {            switch (LOWORD(wParam))            {                case ID_CANCEL:                    DestroyWindow(hwnd);                    return 0;                case ID_OK:                {                    char file[MAX_PATH];                    SendMessage(url, WM_GETTEXT, MAX_PATH, (LPARAM) file);                    mplSetFileName(NULL, file, STREAMTYPE_STREAM);                    if((f = fopen(history, "wt+")))                    {                        fprintf(f, file);                        fclose(f);                    }                    if(!parse_filename(file, playtree, mconfig, addurl? 0 : 1))                        gui->playlist->add_track(gui->playlist, file, NULL, NULL, 0);                    if(!addurl)                        gui->startplay(gui);                    else update_playlistwindow();                    DestroyWindow(hwnd);                }                break;            }        }        return 0;        case WM_DESTROY:        {            PostQuitMessage (0);            addurl = 0;            return 0;        }    }    return DefWindowProc(hwnd, iMsg, wParam, lParam);}LRESULT CALLBACK SubUrlWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam){    switch(iMsg)    {        case WM_KEYDOWN:            switch (LOWORD(wParam))            {                case VK_RETURN:                    SendMessage(FindWindow(NULL, "MPlayer - Open URL..."), WM_COMMAND, (WPARAM) ID_OK, 0);                    break;            }    }    return CallWindowProc(OldUrlWndProc, hwnd, iMsg, wParam, lParam);}void display_openurlwindow(gui_t *gui, int add){    HWND hWnd;    HINSTANCE hInstance = GetModuleHandle(NULL);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -