From ce4f3efd78c110c015c54eab05f201d1caac5f8d Mon Sep 17 00:00:00 2001 From: Guenter Bartsch Date: Sun, 20 Apr 2003 16:42:06 +0000 Subject: importing win32 contrib sources and msvc build environment CVS patchset: 4641 CVS date: 2003/04/20 16:42:06 --- win32/source/bitmap1.bmp | Bin 0 -> 206 bytes win32/source/bmp00001.bmp | Bin 0 -> 206 bytes win32/source/bmp00002.bmp | Bin 0 -> 206 bytes win32/source/bmp00003.bmp | Bin 0 -> 206 bytes win32/source/bmp00004.bmp | Bin 0 -> 598 bytes win32/source/bmp00005.bmp | Bin 0 -> 134 bytes win32/source/bmp00006.bmp | Bin 0 -> 134 bytes win32/source/bmp00007.bmp | Bin 0 -> 134 bytes win32/source/bmp00008.bmp | Bin 0 -> 214 bytes win32/source/bmp00009.bmp | Bin 0 -> 214 bytes win32/source/bmp00010.bmp | Bin 0 -> 214 bytes win32/source/bmp00011.bmp | Bin 0 -> 310 bytes win32/source/bmp_arro.bmp | Bin 0 -> 134 bytes win32/source/bmp_conf.bmp | Bin 0 -> 310 bytes win32/source/bmp_ffor.bmp | Bin 0 -> 206 bytes win32/source/bmp_full.bmp | Bin 0 -> 214 bytes win32/source/bmp_next.bmp | Bin 0 -> 206 bytes win32/source/bmp_play.bmp | Bin 0 -> 206 bytes win32/source/bmp_prev.bmp | Bin 0 -> 206 bytes win32/source/bmp_volu.bmp | Bin 0 -> 598 bytes win32/source/icon1.ico | Bin 0 -> 4534 bytes win32/source/main.cpp | 184 ++++++++ win32/source/resource.aps | Bin 0 -> 247364 bytes win32/source/resource.h | 47 +++ win32/source/resource.rc | 99 +++++ win32/source/utils.cpp | 61 +++ win32/source/utils.h | 14 + win32/source/wnd.ctrl.cpp | 430 +++++++++++++++++++ win32/source/wnd.panel.cpp | 963 ++++++++++++++++++++++++++++++++++++++++++ win32/source/wnd.playlist.cpp | 411 ++++++++++++++++++ win32/source/wnd.video.cpp | 158 +++++++ win32/source/xine_logo.bmp | Bin 0 -> 216054 bytes win32/source/xineconsole.cpp | 65 +++ win32/source/xineint.cpp | 209 +++++++++ win32/source/xineint.h | 33 ++ win32/source/xineui.cpp | 864 +++++++++++++++++++++++++++++++++++++ win32/source/xineui.h | 163 +++++++ 37 files changed, 3701 insertions(+) create mode 100644 win32/source/bitmap1.bmp create mode 100644 win32/source/bmp00001.bmp create mode 100644 win32/source/bmp00002.bmp create mode 100644 win32/source/bmp00003.bmp create mode 100644 win32/source/bmp00004.bmp create mode 100644 win32/source/bmp00005.bmp create mode 100644 win32/source/bmp00006.bmp create mode 100644 win32/source/bmp00007.bmp create mode 100644 win32/source/bmp00008.bmp create mode 100644 win32/source/bmp00009.bmp create mode 100644 win32/source/bmp00010.bmp create mode 100644 win32/source/bmp00011.bmp create mode 100644 win32/source/bmp_arro.bmp create mode 100644 win32/source/bmp_conf.bmp create mode 100644 win32/source/bmp_ffor.bmp create mode 100644 win32/source/bmp_full.bmp create mode 100644 win32/source/bmp_next.bmp create mode 100644 win32/source/bmp_play.bmp create mode 100644 win32/source/bmp_prev.bmp create mode 100644 win32/source/bmp_volu.bmp create mode 100644 win32/source/icon1.ico create mode 100644 win32/source/main.cpp create mode 100644 win32/source/resource.aps create mode 100644 win32/source/resource.h create mode 100644 win32/source/resource.rc create mode 100644 win32/source/utils.cpp create mode 100644 win32/source/utils.h create mode 100644 win32/source/wnd.ctrl.cpp create mode 100644 win32/source/wnd.panel.cpp create mode 100644 win32/source/wnd.playlist.cpp create mode 100644 win32/source/wnd.video.cpp create mode 100644 win32/source/xine_logo.bmp create mode 100644 win32/source/xineconsole.cpp create mode 100644 win32/source/xineint.cpp create mode 100644 win32/source/xineint.h create mode 100644 win32/source/xineui.cpp create mode 100644 win32/source/xineui.h (limited to 'win32/source') diff --git a/win32/source/bitmap1.bmp b/win32/source/bitmap1.bmp new file mode 100644 index 000000000..e4da913f5 Binary files /dev/null and b/win32/source/bitmap1.bmp differ diff --git a/win32/source/bmp00001.bmp b/win32/source/bmp00001.bmp new file mode 100644 index 000000000..872c46217 Binary files /dev/null and b/win32/source/bmp00001.bmp differ diff --git a/win32/source/bmp00002.bmp b/win32/source/bmp00002.bmp new file mode 100644 index 000000000..298ae556c Binary files /dev/null and b/win32/source/bmp00002.bmp differ diff --git a/win32/source/bmp00003.bmp b/win32/source/bmp00003.bmp new file mode 100644 index 000000000..f1b7369f8 Binary files /dev/null and b/win32/source/bmp00003.bmp differ diff --git a/win32/source/bmp00004.bmp b/win32/source/bmp00004.bmp new file mode 100644 index 000000000..4fcd24d30 Binary files /dev/null and b/win32/source/bmp00004.bmp differ diff --git a/win32/source/bmp00005.bmp b/win32/source/bmp00005.bmp new file mode 100644 index 000000000..e3891558b Binary files /dev/null and b/win32/source/bmp00005.bmp differ diff --git a/win32/source/bmp00006.bmp b/win32/source/bmp00006.bmp new file mode 100644 index 000000000..0d4f3f170 Binary files /dev/null and b/win32/source/bmp00006.bmp differ diff --git a/win32/source/bmp00007.bmp b/win32/source/bmp00007.bmp new file mode 100644 index 000000000..db8faada8 Binary files /dev/null and b/win32/source/bmp00007.bmp differ diff --git a/win32/source/bmp00008.bmp b/win32/source/bmp00008.bmp new file mode 100644 index 000000000..901fabc1b Binary files /dev/null and b/win32/source/bmp00008.bmp differ diff --git a/win32/source/bmp00009.bmp b/win32/source/bmp00009.bmp new file mode 100644 index 000000000..0649060c6 Binary files /dev/null and b/win32/source/bmp00009.bmp differ diff --git a/win32/source/bmp00010.bmp b/win32/source/bmp00010.bmp new file mode 100644 index 000000000..c9c374882 Binary files /dev/null and b/win32/source/bmp00010.bmp differ diff --git a/win32/source/bmp00011.bmp b/win32/source/bmp00011.bmp new file mode 100644 index 000000000..9d53f02ce Binary files /dev/null and b/win32/source/bmp00011.bmp differ diff --git a/win32/source/bmp_arro.bmp b/win32/source/bmp_arro.bmp new file mode 100644 index 000000000..a517fbd75 Binary files /dev/null and b/win32/source/bmp_arro.bmp differ diff --git a/win32/source/bmp_conf.bmp b/win32/source/bmp_conf.bmp new file mode 100644 index 000000000..0df61b47b Binary files /dev/null and b/win32/source/bmp_conf.bmp differ diff --git a/win32/source/bmp_ffor.bmp b/win32/source/bmp_ffor.bmp new file mode 100644 index 000000000..03f5bf844 Binary files /dev/null and b/win32/source/bmp_ffor.bmp differ diff --git a/win32/source/bmp_full.bmp b/win32/source/bmp_full.bmp new file mode 100644 index 000000000..7268627c3 Binary files /dev/null and b/win32/source/bmp_full.bmp differ diff --git a/win32/source/bmp_next.bmp b/win32/source/bmp_next.bmp new file mode 100644 index 000000000..37ed99699 Binary files /dev/null and b/win32/source/bmp_next.bmp differ diff --git a/win32/source/bmp_play.bmp b/win32/source/bmp_play.bmp new file mode 100644 index 000000000..e129a4b7d Binary files /dev/null and b/win32/source/bmp_play.bmp differ diff --git a/win32/source/bmp_prev.bmp b/win32/source/bmp_prev.bmp new file mode 100644 index 000000000..93de40bc7 Binary files /dev/null and b/win32/source/bmp_prev.bmp differ diff --git a/win32/source/bmp_volu.bmp b/win32/source/bmp_volu.bmp new file mode 100644 index 000000000..9774b430d Binary files /dev/null and b/win32/source/bmp_volu.bmp differ diff --git a/win32/source/icon1.ico b/win32/source/icon1.ico new file mode 100644 index 000000000..23a904bfa Binary files /dev/null and b/win32/source/icon1.ico differ diff --git a/win32/source/main.cpp b/win32/source/main.cpp new file mode 100644 index 000000000..f57cc2713 --- /dev/null +++ b/win32/source/main.cpp @@ -0,0 +1,184 @@ +/* + * Copyright (C) 2000-2001 the xine project + * + * This file is part of xine for win32 video player. + * + * xine 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. + * + * xine 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * Xine win32 UI + * by Matthew Grooms + */ + +#include "xineui.h" +#include "common.h" + +#include +#include + +#define MAX_CONSOLE_LINES 1000 + +gGui_t *gGui; + +void RedirectIOToConsole() +{ + int hConHandle; + long lStdHandle; + CONSOLE_SCREEN_BUFFER_INFO coninfo; + FILE *fp; + + // allocate a console for this app + AllocConsole(); + + // set the screen buffer to be big enough to let us scroll text + GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), + &coninfo); + coninfo.dwSize.Y = MAX_CONSOLE_LINES; + SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), + coninfo.dwSize); + + // redirect unbuffered STDOUT to the console + lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE); + hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); + fp = _fdopen( hConHandle, "w" ); + *stdout = *fp; + setvbuf( stdout, NULL, _IONBF, 0 ); + + // redirect unbuffered STDIN to the console + lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE); + hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); + fp = _fdopen( hConHandle, "r" ); + *stdin = *fp; + setvbuf( stdin, NULL, _IONBF, 0 ); + + // redirect unbuffered STDERR to the console + lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE); + hConHandle = _open_osfhandle(lStdHandle, _O_TEXT); + fp = _fdopen( hConHandle, "w" ); + *stderr = *fp; + setvbuf( stderr, NULL, _IONBF, 0 ); + + // make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog + // point to console as well + /*ios::sync_with_stdio();*/ +} + +int WINAPI WinMain( HINSTANCE hinst, HINSTANCE hprevinst, LPSTR cmdline, int ncmdshow ) +{ + XINE_UI xine_ui; + + +#if !defined (__MINGW32__) + /* We only need the output window for MSVC */ + RedirectIOToConsole(); +#endif + + // prepair our mrl(s) and add them + // to our playlist + + char * next_mrl = cmdline; + while( next_mrl ) + { + char temp_mrl[ 1024 ]; + memset( temp_mrl, 0, sizeof( temp_mrl ) ); + + if( *next_mrl == 0 ) + break; + + if( *next_mrl == ' ' ) + { + next_mrl++; + continue; + } + + if( *next_mrl == '\"' ) + { + strcpy( temp_mrl, next_mrl + 1 ); + + char * end_mrl = strchr( temp_mrl, '\"' ); + if( end_mrl ) + { + *end_mrl = 0; + next_mrl = end_mrl + 1; + } + else + next_mrl = 0; + } + else + { + strcpy( temp_mrl, next_mrl ); + + char * end_mrl = strchr( temp_mrl, ' ' ); + if( end_mrl ) + { + *end_mrl = 0; + next_mrl = end_mrl + 1; + } + else + next_mrl = 0; + } + + char * back_slash = strrchr( temp_mrl, '\\' ); + char * fore_slash = strrchr( temp_mrl, '/' ); + char * last_slash = 0; + + if( back_slash > temp_mrl ) + if( *( back_slash - 1 ) == ':' ) + back_slash = 0; + + if( back_slash > fore_slash ) + last_slash = back_slash; + else + last_slash = fore_slash; + + if( last_slash ) + xine_ui.PlaylistAdd( last_slash + 1, temp_mrl, 0 ); + else + xine_ui.PlaylistAdd( temp_mrl, temp_mrl, 0 ); + } + + // initialize common control tools + + InitCommonControls(); + + // init gui + + if( !xine_ui.InitGui( hinst ) ) + return 1; + + // init libxine + + if( !xine_ui.InitXine() ) + return 1; + + // start playback + + if( xine_ui.playcount ) + xine_ui.Play( 0 ); + + + // start the message loop. + + MSG msg; + + while( GetMessage( &msg, ( HWND ) NULL, 0, 0 ) ) + { + TranslateMessage( &msg ); + DispatchMessage( &msg ); + } + + // return the exit code to Windows. + + return msg.wParam; +} diff --git a/win32/source/resource.aps b/win32/source/resource.aps new file mode 100644 index 000000000..ae5263339 Binary files /dev/null and b/win32/source/resource.aps differ diff --git a/win32/source/resource.h b/win32/source/resource.h new file mode 100644 index 000000000..7afff8c3c --- /dev/null +++ b/win32/source/resource.h @@ -0,0 +1,47 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by resource.rc +// +#define dialog_main 101 +#define bmp_xine_logo 104 +#define bmp_play_button 105 +#define bmp_pause_button 106 +#define bmp_stop_button 107 +#define bmp_prev_button 108 +#define bmp_next_button 109 +#define bmp_fforward_button 110 +#define bmp_rwind_button 111 +#define bmp_eject_button 112 +#define bmp_volume_on_button 113 +#define bmp_volume_off_button 114 +#define ico_xine_logo 117 +#define bmp_arrow_up_normal 119 +#define bmp_arrow_down_selected 120 +#define bmp_arrow_up_selected 121 +#define bmp_arrow_down_normal 122 +#define bmp_fullscreen_off_normal 123 +#define bmp_fullscreen_off_selected 124 +#define bmp_fullscreen_on_normal 125 +#define bmp_fullscreen_on_selected 126 +#define bmp_configure_normal 127 +#define bmp_configure_selected 128 +#define slider_video 1000 +#define button_play 1001 +#define button_pause 1002 +#define button_stop 1003 +#define button_prev 1004 +#define button_rwiind 1005 +#define button_fforward 1006 +#define button_next 1007 +#define slider_audio 1008 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 128 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1016 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/win32/source/resource.rc b/win32/source/resource.rc new file mode 100644 index 000000000..653ecca5d --- /dev/null +++ b/win32/source/resource.rc @@ -0,0 +1,99 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +#ifdef _WIN32 +LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Bitmap +// + +bmp_xine_logo BITMAP DISCARDABLE "xine_logo.bmp" +bmp_play_button BITMAP DISCARDABLE "bitmap1.bmp" +bmp_pause_button BITMAP DISCARDABLE "bmp_play.bmp" +bmp_stop_button BITMAP DISCARDABLE "bmp00001.bmp" +bmp_prev_button BITMAP DISCARDABLE "bmp00002.bmp" +bmp_next_button BITMAP DISCARDABLE "bmp_prev.bmp" +bmp_fforward_button BITMAP DISCARDABLE "bmp_next.bmp" +bmp_rwind_button BITMAP DISCARDABLE "bmp_ffor.bmp" +bmp_eject_button BITMAP DISCARDABLE "bmp00003.bmp" +bmp_volume_on_button BITMAP DISCARDABLE "bmp00004.bmp" +bmp_volume_off_button BITMAP DISCARDABLE "bmp_volu.bmp" +bmp_arrow_up_normal BITMAP DISCARDABLE "bmp00005.bmp" +bmp_arrow_down_selected BITMAP DISCARDABLE "bmp00006.bmp" +bmp_arrow_up_selected BITMAP DISCARDABLE "bmp_arro.bmp" +bmp_arrow_down_normal BITMAP DISCARDABLE "bmp00007.bmp" +bmp_fullscreen_off_normal BITMAP DISCARDABLE "bmp_full.bmp" +bmp_fullscreen_off_selected BITMAP DISCARDABLE "bmp00008.bmp" +bmp_fullscreen_on_normal BITMAP DISCARDABLE "bmp00009.bmp" +bmp_fullscreen_on_selected BITMAP DISCARDABLE "bmp00010.bmp" +bmp_configure_normal BITMAP DISCARDABLE "bmp_conf.bmp" +bmp_configure_selected BITMAP DISCARDABLE "bmp00011.bmp" + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +ico_xine_logo ICON DISCARDABLE "icon1.ico" +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/win32/source/utils.cpp b/win32/source/utils.cpp new file mode 100644 index 000000000..cce30acc8 --- /dev/null +++ b/win32/source/utils.cpp @@ -0,0 +1,61 @@ + +#include "xineui.h" + +int Question( HWND hwnd, LPSTR szFmt, ... ) +{ + + char szBuff[256]; + + *szBuff = 0; + wvsprintf( &szBuff[ strlen( szBuff ) ], + szFmt, + (CHAR *)(&szFmt+1) ); + + return MessageBox( hwnd, szBuff, "Question", MB_ICONQUESTION | MB_YESNO | MB_APPLMODAL ); +} + +void Error( HWND hwnd, LPSTR szFmt, ... ) +{ + + char szBuff[256]; + + *szBuff = 0; + wvsprintf( &szBuff[ strlen( szBuff ) ], + szFmt, + (CHAR *)(&szFmt+1) ); + + MessageBox( hwnd, szBuff, "Error", MB_ICONERROR | MB_OK | MB_APPLMODAL | MB_SYSTEMMODAL ); +} + +BOOL CenterWindow( HWND hwnd ) +{ + RECT window_rect; + GetWindowRect( hwnd, &window_rect ); + + int screen_x = GetSystemMetrics( SM_CXFULLSCREEN ); + int screen_y = GetSystemMetrics( SM_CYFULLSCREEN ); + + int window_x = screen_x / 2 - ( window_rect.right - window_rect.left ) / 2; + int window_y = screen_y / 2 - ( window_rect.bottom - window_rect.top ) / 2; + + return SetWindowPos( hwnd, HWND_TOP, window_x, window_y, 0, 0, SWP_NOSIZE ); +} + +BOOL AnchorWindow( HWND hwnd ) +{ + HWND phwnd = GetParent( hwnd ); + + RECT parent_rect; + GetWindowRect( phwnd, &parent_rect ); + + RECT window_rect; + GetWindowRect( hwnd, &window_rect ); + + int center_x = parent_rect.left + ( parent_rect.right - parent_rect.left ) / 2; + int center_y = parent_rect.top + ( parent_rect.bottom - parent_rect.top ) / 2; + + int window_x = center_x - ( window_rect.right - window_rect.left ) / 2; + int window_y = center_y - ( window_rect.bottom - window_rect.top ) / 2; + + return SetWindowPos( hwnd, HWND_TOP, window_x, window_y, 0, 0, SWP_NOSIZE ); +} diff --git a/win32/source/utils.h b/win32/source/utils.h new file mode 100644 index 000000000..9fca5a926 --- /dev/null +++ b/win32/source/utils.h @@ -0,0 +1,14 @@ + +#ifndef _UTILS_H_ +#define _UTILS_H_ + +extern BOOL CenterWindow( HWND hwnd ); +extern BOOL AnchorWindow( HWND hwnd ); + +extern void SetTextNormal( HWND hwnd, char * newstatus ); +extern void SetTextError( HWND hwnd, char * newstatus ); + +extern int Question( HWND hwnd, LPSTR szFmt, ... ); +extern void Error( HWND hwnd, LPSTR szFmt, ... ); + +#endif \ No newline at end of file diff --git a/win32/source/wnd.ctrl.cpp b/win32/source/wnd.ctrl.cpp new file mode 100644 index 000000000..7b0ce9de3 --- /dev/null +++ b/win32/source/wnd.ctrl.cpp @@ -0,0 +1,430 @@ +/* + * Copyright (C) 2000-2001 the xine project + * + * This file is part of xine for win32 video player. + * + * xine 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. + * + * xine 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * Xine win32 UI + * by Matthew Grooms + */ + +#include "xineui.h" + +#define WINDOW_WIDTH 215 +#define WINDOW_HEIGHT 85 + +HIMAGELIST himagelist; + +LRESULT CALLBACK proc_ctrlwnd( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) +{ + XINE_UI * xine_ui = ( XINE_UI * ) GetWindowLong( hwnd, GWL_USERDATA ); + + switch( msg ) + { + case WM_COMMAND: + { + WORD ncode = HIWORD( wparam ); // notification code + WORD cid = LOWORD( wparam ); // item, control, or accelerator identifier + HWND chwnd = ( HWND ) lparam; // handle of control + + if( cid == ID_PLAY_BTTN ) + { + xine_ui->Play( 0 ); + return 0L; + } + + if( cid == ID_STOP_BTTN ) + { + xine_ui->Stop(); + return 0L; + } + + if( cid == ID_PAUSE_BTTN ) + { + xine_ui->SetSpeed( XINE_SPEED_PAUSE ); + return 0L; + } + + if( cid == ID_NEXT_BTTN ) + { + xine_ui->Stop(); + xine_ui->Play( xine_ui->playindex + 1 ); + return 0L; + } + + if( cid == ID_PREV_BTTN ) + { + xine_ui->Stop(); + xine_ui->Play( xine_ui->playindex - 1 ); + return 0L; + } + + if( cid == ID_RWND_BTTN ) + { + int current_speed = xine_ui->GetSpeed(); + + if( current_speed == XINE_SPEED_FAST_4 ) + xine_ui->SetSpeed( XINE_SPEED_FAST_2 ); + + else if( current_speed == XINE_SPEED_FAST_2 ) + xine_ui->SetSpeed( XINE_SPEED_NORMAL ); + + else if( current_speed == XINE_SPEED_NORMAL ) + xine_ui->SetSpeed( XINE_SPEED_SLOW_2 ); + + else if( current_speed == XINE_SPEED_SLOW_2 ) + xine_ui->SetSpeed( XINE_SPEED_SLOW_4 ); + + else if( current_speed == XINE_SPEED_SLOW_4 ) + xine_ui->SetSpeed( XINE_SPEED_PAUSE ); + + return 0L; + } + + if( cid == ID_FFWD_BTTN ) + { + int current_speed = xine_ui->GetSpeed(); + + if( current_speed == XINE_SPEED_PAUSE ) + xine_ui->SetSpeed( XINE_SPEED_SLOW_4 ); + + else if( current_speed == XINE_SPEED_SLOW_4 ) + xine_ui->SetSpeed( XINE_SPEED_SLOW_2 ); + + else if( current_speed == XINE_SPEED_SLOW_2 ) + xine_ui->SetSpeed( XINE_SPEED_NORMAL ); + + else if( current_speed == XINE_SPEED_NORMAL ) + xine_ui->SetSpeed( XINE_SPEED_FAST_2 ); + + else if( current_speed == XINE_SPEED_FAST_2 ) + xine_ui->SetSpeed( XINE_SPEED_FAST_4 ); + + return 0L; + } + + if( cid == ID_EJECT_BTTN ) + { + xine_ui->init_playlistwnd(); + return 0L; + } + + } + + case WM_HSCROLL: + { + int code = ( int ) LOWORD( wparam ); + HWND hctrl = ( HWND ) lparam; + + switch( code ) + { + case TB_THUMBTRACK: + xine_ui->tracking = true; + break; + + case TB_LINEUP: + case TB_LINEDOWN: + case TB_PAGEUP: + case TB_PAGEDOWN: + case TB_TOP: + case TB_BOTTOM: + case TB_ENDTRACK: + { + int new_time = SendMessage( hctrl, TBM_GETPOS, (WPARAM) 0, (LPARAM) 0 ); + xine_ui->SetTime( new_time ); + xine_ui->tracking = false; + + return 0L; + } + } + } + break; + + case WM_DESTROY: + // Cleanup and close the app + PostQuitMessage( 0 ); + return 0L; + } + + return DefWindowProc( hwnd, msg, wparam, lparam); +} + +bool ToolbarAddButton( HWND htoolbar, int dataindex, int id ) +{ + // define and add icon buttons + TBBUTTON button; + button.iBitmap = dataindex; + button.idCommand = id; + button.fsState = TBSTATE_ENABLED; + button.fsStyle = TBSTYLE_BUTTON; + button.iString = dataindex; + + if( !SendMessage( htoolbar, TB_ADDBUTTONS, (UINT) 1, (LPARAM) &button ) ) + return false; + + return true; +} + +bool ToolbarAddDivider( HWND htoolbar ) +{ + // define and add icon divider + TBBUTTON button; + button.iBitmap = 0; + button.idCommand = 0; + button.fsState = TBSTATE_ENABLED; + button.fsStyle = TBSTYLE_SEP; + button.iString = 0; + + if( !SendMessage( htoolbar, TB_ADDBUTTONS, (UINT) 1, (LPARAM) &button ) ) + return false; + + return true; +} + +bool XINE_UI::init_ctrlwnd() +{ + WNDCLASSEX wc; + + // register our window class + + wc.cbSize = sizeof( wc ); + wc.lpszClassName = TEXT( "xinectrlwindow" ); + wc.lpfnWndProc = proc_ctrlwnd; + wc.style = CS_VREDRAW | CS_HREDRAW; + wc.hInstance = hinst; + wc.hIcon = LoadIcon( hinst, MAKEINTRESOURCE( ico_xine_logo ) ); + wc.hIconSm = LoadIcon( hinst, MAKEINTRESOURCE( ico_xine_logo ) ); + wc.hCursor = LoadCursor( NULL, IDC_ARROW ); + wc.hbrBackground = ( HBRUSH ) ( 1 + COLOR_BTNFACE ); + wc.lpszMenuName = 0; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + + if( !RegisterClassEx( &wc ) ) + { + error( "Error RegisterClassEx : for xinectrlwindow" ); + return false; + } + + // calculate the proper size for the windows given client size + + DWORD dwFrameWidth = GetSystemMetrics( SM_CXSIZEFRAME ); + DWORD dwFrameHeight = GetSystemMetrics( SM_CYSIZEFRAME ); + DWORD dwMenuHeight = GetSystemMetrics( SM_CYMENU ); + DWORD dwCaptionHeight = GetSystemMetrics( SM_CYCAPTION ); + DWORD dwWindowWidth = WINDOW_WIDTH + dwFrameWidth * 2; + DWORD dwWindowHeight = WINDOW_HEIGHT + dwFrameHeight * 2 + + dwMenuHeight + dwCaptionHeight; + + // create the ctrl window + + hctrlwnd = CreateWindowEx( 0, + TEXT( "xinectrlwindow" ), + TEXT( "xine" ), + WS_SYSMENU, + CW_USEDEFAULT, CW_USEDEFAULT, + dwWindowWidth, dwWindowHeight, + NULL, + NULL, + hinst, + NULL ); + if( !hctrlwnd ) + { + error( "Error CreateWindowEx : for xinectrlwindow" ); + return 0; + } + + // create our panel window ( handles its own error reporting ) + + init_panelwnd(); + if( !hpanelwnd ) + return false; + + SetWindowPos( hpanelwnd, HWND_TOP, 5, 5, WINDOW_WIDTH - 5, 50, SWP_SHOWWINDOW ); + + // create our time slider + + HWND htimebar = CreateWindowEx( WS_EX_TOOLWINDOW, + TRACKBAR_CLASS, + "Trackbar Control", + WS_CHILD | WS_VISIBLE | TBS_ENABLESELRANGE | TBS_NOTICKS, + 0, 0, + 0, 0, + hctrlwnd, + (HMENU) ID_TIMEBAR, + hinst, + 0 ); + + if( !htimebar ) + { + error( "Error CreateWindowEx : for TRACKBAR_CLASS ( time )" ); + return false; + } + + SendMessage( htimebar, TBM_SETRANGE, (WPARAM) TRUE, (LPARAM) MAKELONG( 0, 1000 ) ); + SendMessage( htimebar, TBM_SETPAGESIZE, 0, (LPARAM) 1 ); + SendMessage( htimebar, TBM_SETSEL, (WPARAM) FALSE, (LPARAM) MAKELONG( 0, 0 ) ); + SendMessage( htimebar, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) 0 ); + + SetWindowPos( htimebar, HWND_TOP, 5, 60, WINDOW_WIDTH - 10, 17, SWP_SHOWWINDOW ); + + // create our button toolbar + + HWND htoolbar = CreateWindowEx( WS_EX_TOOLWINDOW, + TOOLBARCLASSNAME, + 0, + WS_CHILDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | + TBSTYLE_TRANSPARENT | TBSTYLE_FLAT | CCS_NODIVIDER | + CCS_NOPARENTALIGN, + 0, 0, + 0, 0, + hctrlwnd, + (HMENU) ID_TOOLBAR, + hinst, + 0 ); + + if( !htoolbar ) + { + error( "Error CreateWindowEx : for TOOLBARCLASSNAME" ); + return false; + } + + SendMessage( htoolbar, TB_BUTTONSTRUCTSIZE, sizeof( TBBUTTON ), 0 ); + + // create the toolbar image list + + COLORREF TransColor = RGB( 255, 0, 255 ); + + himagelist = ImageList_Create( 11, 11, ILC_COLOR8 | ILC_MASK, 0, 7 ); + + HBITMAP h_bmp_play_button = LoadBitmap( hinst, MAKEINTRESOURCE( bmp_play_button ) ); + HBITMAP h_bmp_pause_button = LoadBitmap( hinst, MAKEINTRESOURCE( bmp_pause_button ) ); + HBITMAP h_bmp_stop_button = LoadBitmap( hinst, MAKEINTRESOURCE( bmp_stop_button ) ); + HBITMAP h_bmp_prev_button = LoadBitmap( hinst, MAKEINTRESOURCE( bmp_prev_button ) ); + HBITMAP h_bmp_rwind_button = LoadBitmap( hinst, MAKEINTRESOURCE( bmp_rwind_button ) ); + HBITMAP h_bmp_fforward_button = LoadBitmap( hinst, MAKEINTRESOURCE( bmp_fforward_button ) ); + HBITMAP h_bmp_next_button = LoadBitmap( hinst, MAKEINTRESOURCE( bmp_next_button ) ); + HBITMAP h_bmp_eject_button = LoadBitmap( hinst, MAKEINTRESOURCE( bmp_eject_button ) ); + + ImageList_AddMasked( himagelist, h_bmp_play_button, TransColor ); + ImageList_AddMasked( himagelist, h_bmp_pause_button, TransColor ); + ImageList_AddMasked( himagelist, h_bmp_stop_button, TransColor ); + ImageList_AddMasked( himagelist, h_bmp_prev_button, TransColor ); + ImageList_AddMasked( himagelist, h_bmp_rwind_button, TransColor ); + ImageList_AddMasked( himagelist, h_bmp_fforward_button, TransColor ); + ImageList_AddMasked( himagelist, h_bmp_next_button, TransColor ); + ImageList_AddMasked( himagelist, h_bmp_eject_button, TransColor ); + + DeleteObject( h_bmp_play_button ); + DeleteObject( h_bmp_pause_button ); + DeleteObject( h_bmp_stop_button ); + DeleteObject( h_bmp_prev_button ); + DeleteObject( h_bmp_rwind_button ); + DeleteObject( h_bmp_fforward_button ); + DeleteObject( h_bmp_next_button ); + DeleteObject( h_bmp_eject_button ); + + SendMessage( htoolbar, TB_SETIMAGELIST, 0, (LPARAM) himagelist ); + SendMessage( htoolbar, TB_SETBITMAPSIZE, 0, (LPARAM) MAKELONG( 11, 11 ) ); + SendMessage( htoolbar, TB_SETBUTTONSIZE, 0, (LPARAM) MAKELONG( 22, 18 ) ); + + // add our buttons to our toolbar + + ToolbarAddButton( htoolbar, 0, ID_PLAY_BTTN ); + ToolbarAddButton( htoolbar, 1, ID_PAUSE_BTTN ); + ToolbarAddButton( htoolbar, 2, ID_STOP_BTTN ); + ToolbarAddDivider( htoolbar ); + ToolbarAddButton( htoolbar, 3, ID_PREV_BTTN ); + ToolbarAddButton( htoolbar, 4, ID_RWND_BTTN ); + ToolbarAddButton( htoolbar, 5, ID_FFWD_BTTN ); + ToolbarAddButton( htoolbar, 6, ID_NEXT_BTTN ); + ToolbarAddDivider( htoolbar ); + ToolbarAddButton( htoolbar, 7, ID_EJECT_BTTN ); + + SetWindowPos( htoolbar, HWND_TOP, 10, 80, 100, 100, SWP_SHOWWINDOW ); + + // show the ctrl window + + ShowWindow( hctrlwnd, SW_SHOW ); + UpdateWindow( hctrlwnd ); + + SetWindowLong( hctrlwnd, GWL_USERDATA, ( long ) this ); + + return true; +} + +void XINE_UI::end_ctrlwnd() +{ + end_panelwnd(); + + ImageList_Destroy( himagelist ); + + HWND htoolbar = GetDlgItem( hctrlwnd, ID_TOOLBAR ); + DestroyWindow( htoolbar ); + + HWND htimebar = GetDlgItem( hctrlwnd, ID_TIMEBAR ); + DestroyWindow( htimebar ); + + DestroyWindow( hctrlwnd ); + UnregisterClass( "xinectrlwindow", hinst ); +} + +bool _XINE_UI::UpdateCtrl() +{ + if( gGui->stream ) + { + if( mode == XINE_STATUS_PLAY ) + { + /*mrl_time_current = xine_get_current_time( gGui->stream );*/ + if (xine_get_pos_length(gGui->stream, 0, &mrl_time_current, 0)) + { + mrl_time_current /= 1000; + if( !tracking ) + { + HWND htimebar = GetDlgItem( hctrlwnd, ID_TIMEBAR ); + SendMessage( htimebar, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) mrl_time_current ); + } + } + } + } + + return true; +} + +DWORD __stdcall update_loop_helper( void * param ) +{ + XINE_UI * xine_ui = ( XINE_UI * ) param; + + while( xine_ui->mode == XINE_STATUS_PLAY ) + { + xine_ui->UpdateCtrl(); + xine_ui->UpdatePanel(); + + Sleep( 500 ); + } + + return 0; +} + +DWORD XINE_UI::UpdateLoop() +{ + // start ctrl update loop + + DWORD panel_loop_id; + CreateThread( 0, 0, &update_loop_helper, ( void * ) this, 0, &panel_loop_id ); + + return 0; +} \ No newline at end of file diff --git a/win32/source/wnd.panel.cpp b/win32/source/wnd.panel.cpp new file mode 100644 index 000000000..42bf828f3 --- /dev/null +++ b/win32/source/wnd.panel.cpp @@ -0,0 +1,963 @@ +/* + * Copyright (C) 2000-2001 the xine project + * + * This file is part of xine for win32 video player. + * + * xine 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. + * + * xine 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * Xine win32 UI + * by Matthew Grooms + */ + +#include "xineui.h" + +#define VOLBAR_WIDTH 13 +#define VOLBAR_HEIGHT 46 + +#define VOLBUTTON_WIDTH 22 +#define VOLBUTTON_HEIGHT 40 + +#define ARROW_WIDTH 7 +#define ARROW_HEIGHT 4 + +#define PANEL_SPLIT 110 + +static HFONT smallfont; +static HFONT largefont; + +static HBITMAP configure_normal_bmp; +static HBITMAP configure_selected_bmp; +static HBITMAP fullscreenbutton_off_normal_bmp; +static HBITMAP fullscreenbutton_off_selected_bmp; +static HBITMAP fullscreenbutton_on_normal_bmp; +static HBITMAP fullscreenbutton_on_selected_bmp; +static HBITMAP volbutton_on_bmp; +static HBITMAP volbutton_off_bmp; +static HBITMAP arrowbutton_up_normal_bmp; +static HBITMAP arrowbutton_up_selected_bmp; +static HBITMAP arrowbutton_down_normal_bmp; +static HBITMAP arrowbutton_down_selected_bmp; + + +static void ResizeChildren( HWND hpanelwnd ) +{ + RECT rect; + GetClientRect( hpanelwnd, &rect ); + + HWND htitlewnd = GetDlgItem( hpanelwnd, ID_TITLE ); + if( htitlewnd ) + { + SetWindowPos( htitlewnd, HWND_TOP, + 5, 5, + PANEL_SPLIT, 14, + SWP_SHOWWINDOW ); + } + + HWND htimewnd = GetDlgItem( hpanelwnd, ID_TIME ); + if( htimewnd ) + { + SetWindowPos( htimewnd, HWND_TOP, + 5, 25, + PANEL_SPLIT, 16, + SWP_SHOWWINDOW ); + } + + HWND hfullscreenwnd = GetDlgItem( hpanelwnd, ID_FULLSCREEN ); + if( hfullscreenwnd ) + { + SetWindowPos( hfullscreenwnd, HWND_TOP, + rect.right - 90, 5, + 16, 12, + SWP_SHOWWINDOW ); + } + + HWND hconfigurewnd = GetDlgItem( hpanelwnd, ID_CONFIG ); + if( hconfigurewnd ) + { + SetWindowPos( hconfigurewnd, HWND_TOP, + rect.right - 72, 5, + 32, 12, + SWP_SHOWWINDOW ); + } + + HWND hspulabelwnd = GetDlgItem( hpanelwnd, ID_SPULABEL ); + if( hspulabelwnd ) + { + SetWindowPos( hspulabelwnd, HWND_TOP, + rect.right - 103, 18, + 28, 12, + SWP_SHOWWINDOW ); + } + + HWND haudiolabelwnd = GetDlgItem( hpanelwnd, ID_AUDIOLABEL ); + if( haudiolabelwnd ) + { + SetWindowPos( haudiolabelwnd, HWND_TOP, + rect.right - 103, 31, + 28, 12, + SWP_SHOWWINDOW ); + } + + HWND hspuvaluewnd = GetDlgItem( hpanelwnd, ID_SPUVALUE ); + if( hspuvaluewnd ) + { + SetWindowPos( hspuvaluewnd, HWND_TOP, + rect.right - 61, 18, + 23, 12, + SWP_SHOWWINDOW ); + } + + HWND haudiovaluewnd = GetDlgItem( hpanelwnd, ID_AUDIOVALUE ); + if( haudiovaluewnd ) + { + SetWindowPos( haudiovaluewnd, HWND_TOP, + rect.right - 61, 31, + 23, 12, + SWP_SHOWWINDOW ); + } + + HWND hspuinc = GetDlgItem( hpanelwnd, ID_SPUINC ); + if( hspuinc ) + { + SetWindowPos( hspuinc, HWND_TOP, + rect.right - 71, rect.top + 20, + ARROW_WIDTH, ARROW_HEIGHT, + SWP_SHOWWINDOW ); + } + + HWND hspudec = GetDlgItem( hpanelwnd, ID_SPUDEC ); + if( hspudec ) + { + SetWindowPos( hspudec, HWND_TOP, + rect.right - 71, rect.top + 26, + ARROW_WIDTH, ARROW_HEIGHT, + SWP_SHOWWINDOW ); + } + + HWND haudioinc = GetDlgItem( hpanelwnd, ID_AUDIOINC ); + if( haudioinc ) + { + SetWindowPos( haudioinc, HWND_TOP, + rect.right - 71, rect.top + 33, + ARROW_WIDTH, ARROW_HEIGHT, + SWP_SHOWWINDOW ); + } + + HWND haudiodec = GetDlgItem( hpanelwnd, ID_AUDIODEC ); + if( haudiodec ) + { + SetWindowPos( haudiodec, HWND_TOP, + rect.right - 71, rect.top + 39, + ARROW_WIDTH, ARROW_HEIGHT, + SWP_SHOWWINDOW ); + } + + HWND hvolbutton = GetDlgItem( hpanelwnd, ID_VOLBUTTON ); + if( hvolbutton ) + { + SetWindowPos( hvolbutton, HWND_TOP, + rect.right - ( VOLBAR_WIDTH + VOLBUTTON_WIDTH ) - 2, rect.top + 4, + VOLBUTTON_WIDTH, VOLBUTTON_HEIGHT, + SWP_SHOWWINDOW ); + } + + + HWND hvolbar = GetDlgItem( hpanelwnd, ID_VOLBAR ); + if( hvolbar ) + { + SetWindowPos( hvolbar, HWND_TOP, + rect.right - VOLBAR_WIDTH, rect.top + 1, + VOLBAR_WIDTH, VOLBAR_HEIGHT, + SWP_SHOWWINDOW ); + } +} + +LRESULT CALLBACK proc_panelwnd( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) +{ + XINE_UI * xine_ui = ( XINE_UI * ) GetWindowLong( hwnd, GWL_USERDATA ); + + switch( msg ) + { + case WM_COMMAND: + { + WORD ncode = HIWORD( wparam ); // notification code + WORD cid = LOWORD( wparam ); // item, control, or accelerator identifier + HWND chwnd = ( HWND ) lparam; // handle of control + + if( cid == ID_FULLSCREEN ) + { + if( ncode == BN_CLICKED ) + { + if( GetWindowLong( chwnd, GWL_USERDATA ) ) + { + SetWindowLong( chwnd, GWL_USERDATA, 0 ); + xine_ui->DriverMessage( GUI_WIN32_MOVED_OR_RESIZED, 0 ); + xine_ui->win32_visual.FullScreen = false; + + int style = GetWindowLong( xine_ui->hvideownd, GWL_STYLE ); + SetWindowLong( xine_ui->hvideownd, GWL_STYLE, style | WS_CAPTION | WS_SIZEBOX | WS_SYSMENU | WS_MAXIMIZEBOX ); + ShowWindow( xine_ui->hvideownd, SW_SHOWNORMAL ); + + } + else + { + SetWindowLong( chwnd, GWL_USERDATA, 1 ); + xine_ui->DriverMessage( GUI_WIN32_MOVED_OR_RESIZED, 0 ); + xine_ui->win32_visual.FullScreen = true; + + int style = GetWindowLong( xine_ui->hvideownd, GWL_STYLE ); + SetWindowLong( xine_ui->hvideownd, GWL_STYLE, style & ~( WS_CAPTION | WS_BORDER | WS_SIZEBOX | WS_SYSMENU | WS_MAXIMIZEBOX ) ); + ShowWindow( xine_ui->hvideownd, SW_MAXIMIZE ); + } + + // FIXME : There must be a better way to + // force a WM_DRAITEM message + + ShowWindow( chwnd, SW_HIDE ); + ShowWindow( chwnd, SW_SHOW ); + + return 0L; + } + } + + if( cid == ID_SPUINC ) + { + if( ncode == BN_CLICKED ) + { + xine_ui->SelectSpuChannel( xine_get_param(gGui->stream, XINE_PARAM_SPU_CHANNEL) + 1 ); + xine_ui->spu_channel = xine_get_param(gGui->stream, XINE_PARAM_SPU_CHANNEL); + return 0L; + } + } + + if( cid == ID_SPUDEC ) + { + if( ncode == BN_CLICKED ) + { + xine_ui->SelectSpuChannel( xine_get_param(gGui->stream, XINE_PARAM_SPU_CHANNEL) - 1 ); + xine_ui->spu_channel = xine_get_param(gGui->stream, XINE_PARAM_SPU_CHANNEL); + return 0L; + } + } + + if( cid == ID_AUDIOINC ) + { + if( ncode == BN_CLICKED ) + { + xine_ui->SelectAudioChannel( xine_get_param(gGui->stream, XINE_PARAM_AUDIO_CHANNEL_LOGICAL) + 1 ); + xine_ui->audio_channel = xine_get_param(gGui->stream, XINE_PARAM_AUDIO_CHANNEL_LOGICAL); + return 0L; + } + } + + if( cid == ID_AUDIODEC ) + { + if( ncode == BN_CLICKED ) + { + xine_ui->SelectAudioChannel( xine_get_param(gGui->stream, XINE_PARAM_AUDIO_CHANNEL_LOGICAL) - 1 ); + xine_ui->audio_channel = xine_get_param(gGui->stream, XINE_PARAM_AUDIO_CHANNEL_LOGICAL); + return 0L; + } + } + + if( cid == ID_VOLBUTTON ) + { + if( ncode == BN_CLICKED ) + { + HWND hvolbar = GetDlgItem( hwnd, ID_VOLBAR ); + + if( GetWindowLong( chwnd, GWL_USERDATA ) ) + { + SetWindowLong( chwnd, GWL_USERDATA, 0 ); + EnableWindow( hvolbar, false ); + xine_ui->SetMute( true ); + } + else + { + SetWindowLong( chwnd, GWL_USERDATA, 1 ); + EnableWindow( hvolbar, true ); + xine_ui->SetMute( false ); + } + + // FIXME : There must be a better way to + // force a WM_DRAITEM message + + ShowWindow( chwnd, SW_HIDE ); + ShowWindow( chwnd, SW_SHOW ); + + return 0L; + } + } + } + break; + + case WM_VSCROLL: + { + int code = ( int ) LOWORD( wparam ); + HWND hcntrl = ( HWND ) lparam; + + switch( code ) + { + case TB_THUMBTRACK: + case TB_LINEUP: + case TB_LINEDOWN: + case TB_PAGEUP: + case TB_PAGEDOWN: + case TB_TOP: + case TB_BOTTOM: + case TB_ENDTRACK: + { + int new_volume = SendMessage( hcntrl, TBM_GETPOS, (WPARAM) 0, (LPARAM) 0 ); + xine_ui->SetVolume( new_volume ); + return 0L; + } + } + + } + break; + + case WM_SIZE: + { + ResizeChildren( hwnd ); + } + break; + + case WM_DRAWITEM: + { + LPDRAWITEMSTRUCT lpdis = ( LPDRAWITEMSTRUCT ) lparam; + + if( lpdis->CtlID == ID_FULLSCREEN ) + { + HDC hdcMem = CreateCompatibleDC( lpdis->hDC ); + long bstate = GetWindowLong( lpdis->hwndItem, GWL_USERDATA ); + + if( bstate ) + { + if( lpdis->itemState & ODS_SELECTED ) + SelectObject( hdcMem, fullscreenbutton_on_selected_bmp ); + else + SelectObject( hdcMem, fullscreenbutton_on_normal_bmp ); + } + else + { + if( lpdis->itemState & ODS_SELECTED ) + SelectObject( hdcMem, fullscreenbutton_off_selected_bmp ); + else + SelectObject( hdcMem, fullscreenbutton_off_normal_bmp ); + } + + BitBlt( lpdis->hDC, 0, 0, 16, 12, hdcMem, 0, 0, SRCCOPY ); + + DeleteDC( hdcMem ); + return TRUE; + } + + if( lpdis->CtlID == ID_CONFIG ) + { + HDC hdcMem = CreateCompatibleDC( lpdis->hDC ); + + if( lpdis->itemState & ODS_SELECTED ) + SelectObject( hdcMem, configure_selected_bmp ); + else + SelectObject( hdcMem, configure_normal_bmp ); + + BitBlt( lpdis->hDC, 0, 0, 32, 12, hdcMem, 0, 0, SRCCOPY ); + + DeleteDC( hdcMem ); + return TRUE; + } + + if( ( lpdis->CtlID == ID_SPUINC ) || ( lpdis->CtlID == ID_AUDIOINC ) ) + { + HDC hdcMem = CreateCompatibleDC( lpdis->hDC ); + + if( lpdis->itemState & ODS_SELECTED ) + SelectObject( hdcMem, arrowbutton_up_selected_bmp ); + else + SelectObject( hdcMem, arrowbutton_up_normal_bmp ); + + BitBlt( lpdis->hDC, 0, 0, 7, 4, hdcMem, 0, 0, SRCCOPY ); + + DeleteDC( hdcMem ); + return TRUE; + } + + if( ( lpdis->CtlID == ID_SPUDEC ) || ( lpdis->CtlID == ID_AUDIODEC ) ) + { + HDC hdcMem = CreateCompatibleDC( lpdis->hDC ); + + if( lpdis->itemState & ODS_SELECTED ) + SelectObject( hdcMem, arrowbutton_down_selected_bmp ); + else + SelectObject( hdcMem, arrowbutton_down_normal_bmp ); + + BitBlt( lpdis->hDC, 0, 0, 7, 4, hdcMem, 0, 0, SRCCOPY ); + + DeleteDC( hdcMem ); + return TRUE; + } + + if( lpdis->CtlID == ID_VOLBUTTON ) + { + HDC hdcMem = CreateCompatibleDC( lpdis->hDC ); + long bstate = GetWindowLong( lpdis->hwndItem, GWL_USERDATA ); + + if( bstate ) + SelectObject( hdcMem, volbutton_on_bmp ); + else + SelectObject( hdcMem, volbutton_off_bmp ); + + BitBlt( lpdis->hDC, 0, 0, VOLBUTTON_WIDTH, VOLBUTTON_HEIGHT, + hdcMem, 0, 0, SRCCOPY ); + + DeleteDC( hdcMem ); + return TRUE; + } + } + break; + + case WM_CTLCOLORBTN: + case WM_CTLCOLORSTATIC: + { + HDC hdcstatic = ( HDC ) wparam; + SetTextColor( hdcstatic, RGB( 255, 255, 255 ) ); + SetBkColor( hdcstatic, RGB( 0, 0, 0 ) ); + + HBRUSH bkgrd = ( HBRUSH ) GetClassLong( hwnd, GCL_HBRBACKGROUND ); + + return ( long ) bkgrd; + } + break; + + case WM_DESTROY: + if( xine_ui ) + xine_ui->end_panelwnd(); + return 0L; + } + + return DefWindowProc( hwnd, msg, wparam, lparam); +} + +bool _XINE_UI::init_panelwnd() +{ + WNDCLASSEX wc; + + // register our window class + + wc.cbSize = sizeof( wc ); + wc.lpszClassName = TEXT( "xinepanelwindow" ); + wc.lpfnWndProc = proc_panelwnd; + wc.style = CS_VREDRAW | CS_HREDRAW; + wc.hInstance = hinst; + wc.hIcon = 0, + wc.hIconSm = 0, + wc.hCursor = LoadCursor( NULL, IDC_ARROW ); + wc.hbrBackground = ( HBRUSH ) GetStockObject( BLACK_BRUSH ); + wc.lpszMenuName = 0; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + + if( !RegisterClassEx( &wc ) ) + { + error( "Error RegisterClassEx : for xinepanelwindow" ); + return false; + } + + // create the ctrl window + + hpanelwnd = CreateWindowEx( WS_EX_STATICEDGE, + TEXT( "xinepanelwindow" ), + 0, + WS_CHILD, + 0, 0, + 0, 0, + hctrlwnd, + ( HMENU ) ID_PANEL, + hinst, + NULL ); + if( !hpanelwnd ) + { + error( "Error CreateWindowEx : for xinepanelwindow" ); + return false; + } + + // create our fonts + + smallfont = CreateFont( 13, // logical height of font + 5, // logical average character width + 0, // angle of escapement + 0, // base-line orientation angle + 0, // font weight + 0, // italic attribute flag + 0, // underline attribute flag + 0, // strikeout attribute flag + 0, // character set identifier + 0, // output precision + 0, // clipping precision + ANTIALIASED_QUALITY, // output quality + FF_MODERN | VARIABLE_PITCH , // pitch and family + "Areal" ); // pointer to typeface name string + + largefont = CreateFont( 20, // logical height of font + 7, // logical average character width + 0, // angle of escapement + 0, // base-line orientation angle + 0, // font weight + 0, // italic attribute flag + 0, // underline attribute flag + 0, // strikeout attribute flag + 0, // character set identifier + 0, // output precision + 0, // clipping precision + ANTIALIASED_QUALITY, // output quality + FF_MODERN | VARIABLE_PITCH , // pitch and family + "Areal" ); // pointer to typeface name string + + // create our title window + + HWND htitle = CreateWindow( "STATIC", + 0, + WS_CHILD | WS_VISIBLE | SS_LEFT, + 0, 0, + 0, 0, + hpanelwnd, + (HMENU) ID_TITLE, + hinst, + 0 ); + + if( !htitle ) + { + error( "Error CreateWindowEx : for STATIC ( htitle )" ); + return false; + } + + SendMessage( htitle, WM_SETFONT, ( WPARAM ) smallfont, false ); + + // create our time window + + HWND htime = CreateWindow( "STATIC", + 0, + WS_CHILD | WS_VISIBLE | SS_LEFT, + 0, 0, + 0, 0, + hpanelwnd, + (HMENU) ID_TIME, + hinst, + 0 ); + + if( !htime ) + { + error( "Error CreateWindowEx : for STATIC ( time )" ); + return false; + } + + SendMessage( htime, WM_SETFONT, ( WPARAM ) largefont, false ); + + // create our fullscreen button + + fullscreenbutton_off_normal_bmp = LoadBitmap( hinst, MAKEINTRESOURCE( bmp_fullscreen_off_normal ) ); + fullscreenbutton_off_selected_bmp = LoadBitmap( hinst, MAKEINTRESOURCE( bmp_fullscreen_off_selected ) ); + fullscreenbutton_on_normal_bmp = LoadBitmap( hinst, MAKEINTRESOURCE( bmp_fullscreen_on_normal ) ); + fullscreenbutton_on_selected_bmp = LoadBitmap( hinst, MAKEINTRESOURCE( bmp_fullscreen_on_selected ) ); + + if( !fullscreenbutton_off_normal_bmp || !fullscreenbutton_off_selected_bmp || + !fullscreenbutton_on_normal_bmp || !fullscreenbutton_on_selected_bmp ) + { + error( "Error LoadBitmap : for fullscreenbutton (s)" ); + return false; + } + + HWND hfullscrrenbutton = CreateWindow( "BUTTON", + 0, + WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, + 0, 0, + 0, 0, + hpanelwnd, + (HMENU) ID_FULLSCREEN, + hinst, + 0 ); + + if( !hfullscrrenbutton ) + { + error( "Error CreateWindowEx : for BUTTON ( hfullscrrenbutton )" ); + return false; + } + + SetWindowLong( hfullscrrenbutton, GWL_USERDATA, 0 ); + + // create our configure button + + configure_normal_bmp = LoadBitmap( hinst, MAKEINTRESOURCE( bmp_configure_normal ) ); + configure_selected_bmp = LoadBitmap( hinst, MAKEINTRESOURCE( bmp_configure_selected ) ); + + if( !configure_normal_bmp || !configure_selected_bmp ) + { + error( "Error LoadBitmap : for configure button(s)" ); + return false; + } + + HWND hconfigbutton = CreateWindow( "BUTTON", + 0, + WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, + 0, 0, + 0, 0, + hpanelwnd, + (HMENU) ID_CONFIG, + hinst, + 0 ); + + if( !hconfigbutton ) + { + error( "Error CreateWindowEx : for BUTTON ( hconfigbutton )" ); + return false; + } + + SetWindowLong( hfullscrrenbutton, GWL_USERDATA, 0 ); + + // create our spu and audio label windows + + HWND hspulabelwnd = CreateWindow( "STATIC", + "spu", + WS_CHILD | WS_VISIBLE | SS_RIGHT, + 0, 0, + 0, 0, + hpanelwnd, + (HMENU) ID_SPULABEL, + hinst, + 0 ); + + if( !hspulabelwnd ) + { + error( "Error CreateWindowEx : for STATIC ( hspulabelwnd )" ); + return false; + } + + SendMessage( hspulabelwnd, WM_SETFONT, ( WPARAM ) smallfont, false ); + + HWND haudiolabelwnd = CreateWindow( "STATIC", + "aud", + WS_CHILD | WS_VISIBLE | SS_RIGHT, + 0, 0, + 0, 0, + hpanelwnd, + (HMENU) ID_AUDIOLABEL, + hinst, + 0 ); + + if( !haudiolabelwnd ) + { + error( "Error CreateWindowEx : for STATIC ( haudiolabelwnd )" ); + return false; + } + + SendMessage( haudiolabelwnd, WM_SETFONT, ( WPARAM ) smallfont, false ); + + // create our spu and audio inc & dec buttons + + arrowbutton_up_normal_bmp = LoadBitmap( hinst, MAKEINTRESOURCE( bmp_arrow_up_normal ) ); + arrowbutton_up_selected_bmp = LoadBitmap( hinst, MAKEINTRESOURCE( bmp_arrow_up_selected ) ); + arrowbutton_down_normal_bmp = LoadBitmap( hinst, MAKEINTRESOURCE( bmp_arrow_down_normal ) ); + arrowbutton_down_selected_bmp = LoadBitmap( hinst, MAKEINTRESOURCE( bmp_arrow_down_selected ) ); + + if( !arrowbutton_up_normal_bmp || !arrowbutton_up_selected_bmp || + !arrowbutton_down_normal_bmp || !arrowbutton_down_selected_bmp ) + { + error( "Error LoadBitmap : for bmp_volume_button (s)" ); + return false; + } + + HWND hspuinc = CreateWindow( "BUTTON", + 0, + WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, + 0, 0, + 0, 0, + hpanelwnd, + (HMENU) ID_SPUINC, + hinst, + 0 ); + + if( !hspuinc ) + { + error( "Error CreateWindowEx : for BUTTON ( hspuinc )" ); + return false; + } + + HWND hspudec = CreateWindow( "BUTTON", + 0, + WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, + 0, 0, + 0, 0, + hpanelwnd, + (HMENU) ID_SPUDEC, + hinst, + 0 ); + + if( !hspudec ) + { + error( "Error CreateWindowEx : for BUTTON ( hspudec )" ); + return false; + } + + HWND haudioinc = CreateWindow( "BUTTON", + 0, + WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, + 0, 0, + 0, 0, + hpanelwnd, + (HMENU) ID_AUDIOINC, + hinst, + 0 ); + + if( !haudioinc ) + { + error( "Error CreateWindowEx : for BUTTON ( haudioinc )" ); + return false; + } + + HWND haudiodec = CreateWindow( "BUTTON", + 0, + WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, + 0, 0, + 0, 0, + hpanelwnd, + (HMENU) ID_AUDIODEC, + hinst, + 0 ); + + if( !haudiodec ) + { + error( "Error CreateWindowEx : for BUTTON ( haudiodec )" ); + return false; + } + + // create our spu and audio value windows + + HWND hspuvaluewnd = CreateWindow( "STATIC", + "None", + WS_CHILD | WS_VISIBLE | SS_LEFT, + 0, 0, + 0, 0, + hpanelwnd, + (HMENU) ID_SPUVALUE, + hinst, + 0 ); + + if( !hspuvaluewnd ) + { + error( "Error CreateWindowEx : for STATIC ( hspuvaluewnd )" ); + return false; + } + + SendMessage( hspuvaluewnd, WM_SETFONT, ( WPARAM ) smallfont, false ); + + HWND haudiovaluewnd = CreateWindow( "STATIC", + "None", + WS_CHILD | WS_VISIBLE | SS_LEFT, + 0, 0, + 0, 0, + hpanelwnd, + (HMENU) ID_AUDIOVALUE, + hinst, + 0 ); + + if( !haudiovaluewnd ) + { + error( "Error CreateWindowEx : for STATIC ( haudiovaluewnd )" ); + return false; + } + + SendMessage( haudiovaluewnd, WM_SETFONT, ( WPARAM ) smallfont, false ); + + // create our volume button + + volbutton_on_bmp = LoadBitmap( hinst, MAKEINTRESOURCE( bmp_volume_on_button ) ); + volbutton_off_bmp = LoadBitmap( hinst, MAKEINTRESOURCE( bmp_volume_off_button ) ); + + if( !volbutton_on_bmp || !volbutton_off_bmp ) + { + error( "Error LoadBitmap : for bmp_volume_button (s)" ); + return false; + } + + HWND hvolbutton = CreateWindow( "BUTTON", + 0, + WS_CHILD | WS_VISIBLE | BS_OWNERDRAW, + 0, 0, + 0, 0, + hpanelwnd, + (HMENU) ID_VOLBUTTON, + hinst, + 0 ); + + if( !hvolbutton ) + { + error( "Error CreateWindowEx : for BUTTON ( volume )" ); + return false; + } + + SetWindowLong( hvolbutton, GWL_USERDATA, 1 ); + + // create our volume slider + + HWND hvolbar = CreateWindowEx( WS_EX_TOOLWINDOW, + TRACKBAR_CLASS, + "Volume Control", + WS_CHILD | WS_VISIBLE | TBS_NOTICKS | TBS_VERT, + 0, 0, + 0, 0, + hpanelwnd, + (HMENU) ID_VOLBAR, + hinst, + 0 ); + + if( !hvolbar ) + { + error( "Error CreateWindowEx : for TRACKBAR_CLASS ( volume )" ); + return false; + } + + + SendMessage( hvolbar, TBM_SETRANGE, (WPARAM) TRUE, (LPARAM) MAKELONG( 0, 100 ) ); + SendMessage( hvolbar, TBM_SETPAGESIZE, 0, (LPARAM) 1 ); + SendMessage( hvolbar, TBM_SETPOS, (WPARAM) TRUE, (LPARAM) 0 ); + + ShowWindow( hpanelwnd, SW_SHOW ); + UpdateWindow( hpanelwnd ); + + UpdatePanel(); + + SetWindowLong( hpanelwnd, GWL_USERDATA, ( long ) this ); + + return true; +} + +bool XINE_UI::UpdatePanel() +{ + char buffer[10]; + char *lang = NULL; + + UpdateWindow( hpanelwnd ); + + // set our title + + if( mrl_short_name ) + SetDlgItemText( hpanelwnd, ID_TITLE, mrl_short_name ); + else + SetDlgItemText( hpanelwnd, ID_TITLE, "" ); + + // set our time + + char tmpbuff[ 50 ]; + sprintf( tmpbuff, "%u:%u:%u / %u:%u:%u", + mrl_time_current / ( 60 * 60 ), mrl_time_current / 60, mrl_time_current % 60, + mrl_time_length / ( 60 * 60 ), mrl_time_length / 60, mrl_time_length % 60 ); + + SetDlgItemText( hpanelwnd, ID_TIME, tmpbuff ); + + // set our spu channel + if (gGui != NULL) { + memset(&buffer, 0, sizeof(buffer)); + switch (spu_channel) { + case -2: + lang = "off"; + break; + + case -1: + if(!xine_get_spu_lang (gGui->stream, spu_channel, &buffer[0])) + lang = "auto"; + else + lang = buffer; + break; + + default: + if(!xine_get_spu_lang (gGui->stream, spu_channel, &buffer[0])) + sprintf(buffer, "%3d", spu_channel); + lang = buffer; + break; + } + + sprintf( tmpbuff, "%s", lang ); + } + else { + sprintf( tmpbuff, "%i", spu_channel ); + } + + SetDlgItemText( hpanelwnd, ID_SPUVALUE, tmpbuff ); + + // set our audio channel + if (gGui != NULL) { + memset(&buffer, 0, sizeof(buffer)); + switch (audio_channel) { + case -2: + lang = "off"; + break; + + case -1: + if(!xine_get_audio_lang (gGui->stream, audio_channel, &buffer[0])) + lang = "auto"; + else + lang = buffer; + break; + + default: + if(!xine_get_audio_lang (gGui->stream, audio_channel, &buffer[0])) + sprintf(buffer, "%3d", audio_channel); + lang = buffer; + break; + } + + sprintf( tmpbuff, "%s", lang ); + } + else { + sprintf( tmpbuff, "%i", audio_channel ); + } + + SetDlgItemText( hpanelwnd, ID_AUDIOVALUE, tmpbuff ); + + return true; +} + +void XINE_UI::end_panelwnd() +{ + DeleteObject( win32_visual.Brush ); + DestroyWindow( hvideownd ); + UnregisterClass( "xinevideowindow", hinst ); + + HWND hvolbar = GetDlgItem( hpanelwnd, ID_VOLBAR ); + DestroyWindow( hvolbar ); + + DeleteObject( smallfont ); + DeleteObject( largefont ); + + DeleteObject( configure_normal_bmp ); + DeleteObject( configure_selected_bmp ); + DeleteObject( fullscreenbutton_off_normal_bmp ); + DeleteObject( fullscreenbutton_off_selected_bmp ); + DeleteObject( fullscreenbutton_on_normal_bmp ); + DeleteObject( fullscreenbutton_on_selected_bmp ); + DeleteObject( volbutton_on_bmp ); + DeleteObject( volbutton_off_bmp ); + DeleteObject( arrowbutton_up_normal_bmp ); + DeleteObject( arrowbutton_up_selected_bmp ); + DeleteObject( arrowbutton_down_normal_bmp ); + DeleteObject( arrowbutton_down_selected_bmp ); + + HWND hvolbutton = GetDlgItem( hpanelwnd, ID_VOLBUTTON ); + DestroyWindow( hvolbutton ); + + DestroyWindow( hpanelwnd ); + UnregisterClass( "xinepanelwindow", hinst ); +} + diff --git a/win32/source/wnd.playlist.cpp b/win32/source/wnd.playlist.cpp new file mode 100644 index 000000000..1593144b0 --- /dev/null +++ b/win32/source/wnd.playlist.cpp @@ -0,0 +1,411 @@ +/* + * Copyright (C) 2000-2001 the xine project + * + * This file is part of xine for win32 video player. + * + * xine 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. + * + * xine 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * Xine win32 UI + * by Matthew Grooms + */ + +#include "xineui.h" + +#define WINDOW_WIDTH 200 +#define WINDOW_HEIGHT 200 + +HFONT hfont; + +bool AddPlaylistColumn( HWND hlistwnd, int width, int index ) +{ + LV_COLUMN lvCol; + lvCol.mask = LVCF_FMT | LVCF_SUBITEM | LVCF_WIDTH; + lvCol.fmt = LVCFMT_LEFT; + lvCol.cx = width; + lvCol.iSubItem = index; + + int columnindex = SendMessage( hlistwnd, LVM_INSERTCOLUMN, ( WPARAM ) index, ( LPARAM ) &lvCol ); + if( columnindex == -1 ) + return false; + + return true; +} + +bool AddPlaylistItem( HWND hlistwnd, void * lparam ) +{ + int itemcount = ListView_GetItemCount( hlistwnd ); + + LV_ITEM newItem; + newItem.mask = LVIF_PARAM | LVIF_TEXT; + newItem.iItem = itemcount; + newItem.iSubItem = 0; + newItem.pszText = LPSTR_TEXTCALLBACK; + newItem.lParam = ( long ) lparam; + + if( SendMessage( hlistwnd, LVM_INSERTITEM, 0, ( LPARAM ) &newItem ) == -1 ) + return false; + + return true; +} + +void ResizeChildren( HWND hplaylistwnd ) +{ + RECT rect; + GetClientRect( hplaylistwnd, &rect ); + + HWND hstauswnd = GetDlgItem( hplaylistwnd, ID_STATUS ); + SetWindowPos( hstauswnd, HWND_TOP, + rect.left + 5, rect.bottom - 25, + rect.right - rect.left - 10, 20, + SWP_SHOWWINDOW ); + + HWND hlistwnd = GetDlgItem( hplaylistwnd, ID_LIST ); + SetWindowPos( hlistwnd, HWND_TOP, + rect.left + 5, rect.top + 5, + rect.right - rect.left - 55, rect.bottom - rect.top - 30, + SWP_SHOWWINDOW ); + + HWND haddwnd = GetDlgItem( hplaylistwnd, ID_ADD ); + SetWindowPos( haddwnd, HWND_TOP, + rect.right - 40, rect.top + 5, + 35, 20, + SWP_SHOWWINDOW ); + + HWND hdelwnd = GetDlgItem( hplaylistwnd, ID_DEL ); + SetWindowPos( hdelwnd, HWND_TOP, + rect.right - 40, rect.top + 30, + 35, 20, + SWP_SHOWWINDOW ); + + GetClientRect( hlistwnd, &rect ); + SendMessage( hlistwnd, LVM_SETCOLUMNWIDTH, 1, rect.right - rect.left - 22 ); +} + +LRESULT CALLBACK proc_playlistwnd( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) +{ + XINE_UI * xine_ui = ( XINE_UI * ) GetWindowLong( hwnd, GWL_USERDATA ); + + switch( msg ) + { + case WM_NOTIFY: + { + int controlid = ( int ) wparam; + NMHDR * lpnm = ( NMHDR * ) lparam; + NMLVDISPINFO * nmlvdi = ( NMLVDISPINFO * ) lparam; + + if( lpnm->code == LVN_GETDISPINFO ) + { + PLAYITEM * playitem = ( PLAYITEM * ) ( nmlvdi->item.lParam ); + + // first column + + if( nmlvdi->item.iSubItem == 0 ) + nmlvdi->item.iImage = playitem->mrl_type; + + // second column + + if( nmlvdi->item.iSubItem == 1 ) + nmlvdi->item.pszText = playitem->mrl_short_name; + } + + return 0L; + } + break; + + + case WM_COMMAND: + { + WORD ncode = HIWORD( wparam ); // notification code + WORD cid = LOWORD( wparam ); // item, control, or accelerator identifier + HWND chwnd = ( HWND ) lparam; // handle of control + + if( cid == ID_ADD ) + { + OPENFILENAME ofn; // common dialog box structure + char tmpbuff[ 2048 ]; // buffer for filename + memset( &tmpbuff, 0, sizeof( tmpbuff ) ); + + memset( &ofn, 0, sizeof( OPENFILENAME ) ); + ofn.lStructSize = sizeof( OPENFILENAME ); + ofn.hwndOwner = hwnd; + ofn.lpstrFile = tmpbuff; + ofn.nMaxFile = sizeof( tmpbuff ); + ofn.lpstrFilter = "All\0*.*\0"; + ofn.nFilterIndex = 1; + ofn.lpstrFileTitle = 0; + ofn.nMaxFileTitle = 0; + ofn.lpstrInitialDir = 0; + ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER; + + // Display the Open dialog box. + + if( GetOpenFileName( &ofn ) ) + { + HWND hlistwnd = GetDlgItem( hwnd, ID_LIST ); + char * szItem = tmpbuff; + char szLength = strlen( szItem ); + + // did we get multiple files + + if( !szItem[ szLength + 1 ] ) + { + // single file + + // add to playlist and to listview + + PLAYITEM * playitem = xine_ui->PlaylistAdd( szItem + ofn.nFileOffset, szItem, 0 ); + AddPlaylistItem( hlistwnd, playitem ); + } + else + { + // multiple files + + szItem = szItem + szLength + 1; + szLength = strlen( szItem ); + + while( szLength ) + { + char tmpfname[ 1024 ]; + sprintf( tmpfname, "%s\\%s", tmpbuff, szItem ); + + // add to playlist and to listview + + PLAYITEM * playitem = xine_ui->PlaylistAdd( szItem, tmpfname, 0 ); + AddPlaylistItem( hlistwnd, playitem ); + + szItem = szItem + szLength + 1; + szLength = strlen( szItem ); + } + } + + xine_ui->Play( xine_ui->playindex ); + } + + return 0L; + } + + if( cid == ID_DEL ) + { + HWND hlistwnd = GetDlgItem( hwnd, ID_LIST ); + int lvindex; + + while( ( lvindex = ListView_GetNextItem( hlistwnd, -1, LVNI_SELECTED ) ) != -1 ) + { + LVITEM lvitem; + lvitem.mask = LVIF_PARAM; + lvitem.iItem = lvindex; + ListView_GetItem( hlistwnd, &lvitem ); + + PLAYITEM * playitem = ( PLAYITEM * ) lvitem.lParam; + + if( xine_ui->PlaylistDel( lvindex ) ) + ListView_DeleteItem( hlistwnd, lvindex ); + } + + xine_ui->Play( xine_ui->playindex ); + return 0L; + } + } + break; + + case WM_SIZE: + { + ResizeChildren( hwnd ); + return 0L; + } + + case WM_DESTROY: + { + xine_ui->end_playlistwnd(); + return 0L; + } + + } + + return DefWindowProc( hwnd, msg, wparam, lparam); +} + + +bool XINE_UI::init_playlistwnd() +{ + // if our playlist is already open, return + + if( hplaylistwnd ) + return true; + + WNDCLASSEX wc; + + // register our window class + + wc.cbSize = sizeof( wc ); + wc.lpszClassName = TEXT( "xineplaylistwindow" ); + wc.lpfnWndProc = proc_playlistwnd; + wc.style = CS_VREDRAW | CS_HREDRAW; + wc.hInstance = hinst; + wc.hIcon = LoadIcon( hinst, MAKEINTRESOURCE( ico_xine_logo ) ); + wc.hIconSm = LoadIcon( hinst, MAKEINTRESOURCE( ico_xine_logo ) ); + wc.hCursor = LoadCursor( NULL, IDC_ARROW ); + wc.hbrBackground = ( HBRUSH ) ( 1 + COLOR_BTNFACE ); + wc.lpszMenuName = 0; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + + if( !RegisterClassEx( &wc ) ) + { + error( "init_videownd : cannot register window class" ); + return false; + } + + // calculate the proper size for the windows given client size + + DWORD dwFrameWidth = GetSystemMetrics( SM_CXSIZEFRAME ); + DWORD dwFrameHeight = GetSystemMetrics( SM_CYSIZEFRAME ); + DWORD dwMenuHeight = GetSystemMetrics( SM_CYMENU ); + DWORD dwCaptionHeight = GetSystemMetrics( SM_CYCAPTION ); + DWORD dwWindowWidth = WINDOW_WIDTH + dwFrameWidth * 2; + DWORD dwWindowHeight = WINDOW_HEIGHT + dwFrameHeight * 2 + + dwMenuHeight + dwCaptionHeight; + + // create and show the main window + + hplaylistwnd = CreateWindowEx( 0, + TEXT( "xineplaylistwindow" ), + TEXT( "xine Playlist" ), + WS_POPUP | WS_CAPTION | WS_CHILD | WS_SIZEBOX | WS_SYSMENU, + CW_USEDEFAULT, CW_USEDEFAULT, + dwWindowWidth, dwWindowHeight, + hctrlwnd, + NULL, + hinst, + NULL ); + if( !hplaylistwnd ) + { + error( "init_playlistwnd : cannot create video window" ); + return false; + } + + ShowWindow( hplaylistwnd, SW_SHOW ); + UpdateWindow( hplaylistwnd ); + + SetWindowLong( hplaylistwnd, GWL_USERDATA, ( long ) this ); + + if( !CreateStatusWindow( WS_CHILD | WS_VISIBLE | SBARS_SIZEGRIP, + "Add or Delete files from the playlist", + hplaylistwnd, + ID_STATUS ) ) + { + error( "CreateStatusWindow : cannot create status window" ); + return false; + } + + hfont = CreateFont( 13, // logical height of font + 5, // logical average character width + 0, // angle of escapement + 0, // base-line orientation angle + 0, // font weight + 0, // italic attribute flag + 0, // underline attribute flag + 0, // strikeout attribute flag + 0, // character set identifier + 0, // output precision + 0, // clipping precision + PROOF_QUALITY, // output quality + FF_MODERN | VARIABLE_PITCH , // pitch and family + "Areal" ); // pointer to typeface name string + + if( !hfont ) + { + error( "CreateFont : cannot create font" ); + return false; + } + + HWND hlistwnd = CreateWindowEx( WS_EX_STATICEDGE, + WC_LISTVIEW, + 0, + WS_CHILD | WS_VISIBLE | LVS_REPORT | LVS_NOCOLUMNHEADER, + 0, 0, + 0, 0, + hplaylistwnd, + ( HMENU ) ID_LIST, + hinst, + NULL ); + if( !hlistwnd ) + { + error( "CreateWindow : cannot create list view" ); + return false; + } + + AddPlaylistColumn( hlistwnd, 20, 0 ); + AddPlaylistColumn( hlistwnd, 100, 1 ); + + SendMessage( hlistwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, ( LPARAM ) LVS_EX_FULLROWSELECT ); + SendMessage( hlistwnd, WM_SETFONT, ( WPARAM ) hfont, MAKELPARAM( TRUE, 0 ) ); + ListView_SetBkColor( hlistwnd, RGB( 0, 0, 0 ) ); + ListView_SetTextBkColor( hlistwnd, RGB( 0, 0, 0 ) ); + ListView_SetTextColor( hlistwnd, RGB( 255, 255, 255 ) ); + + HWND haddwnd = CreateWindow( "BUTTON", + TEXT( "Add" ), + WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, + 0, 0, + 0, 0, + hplaylistwnd, + ( HMENU ) ID_ADD, + hinst, + NULL ); + if( !haddwnd ) + { + error( "CreateWindow : cannot create add button" ); + return false; + } + + SendMessage( haddwnd, WM_SETFONT, ( WPARAM ) hfont, MAKELPARAM( TRUE, 0 ) ); + + HWND hdelwnd = CreateWindow( "BUTTON", + TEXT( "Del" ), + WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, + 0, 0, + 0, 0, + hplaylistwnd, + ( HMENU ) ID_DEL, + hinst, + NULL ); + if( !hdelwnd ) + { + error( "CreateWindow : cannot create del button" ); + return false; + } + + SendMessage( hdelwnd, WM_SETFONT, ( WPARAM ) hfont, MAKELPARAM( TRUE, 0 ) ); + + // resize all playlist window children + + ResizeChildren( hplaylistwnd ); + + // add all playlist items to view + + for( int x = 0; x < playcount; x++ ) + AddPlaylistItem( hlistwnd, playlist[ x ] ); + + return true; +} + +void XINE_UI::end_playlistwnd() +{ + DestroyWindow( hplaylistwnd ); + UnregisterClass( "xineplaylistwindow", hinst ); + + hplaylistwnd = 0; +} diff --git a/win32/source/wnd.video.cpp b/win32/source/wnd.video.cpp new file mode 100644 index 000000000..72c2856bb --- /dev/null +++ b/win32/source/wnd.video.cpp @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2000-2001 the xine project + * + * This file is part of xine for win32 video player. + * + * xine 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. + * + * xine 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * Xine win32 UI + * by Matthew Grooms + */ + +#include "xineui.h" + +#define WINDOW_WIDTH 640 +#define WINDOW_HEIGHT 480 + +LRESULT CALLBACK proc_videownd( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) +{ + XINE_UI * xine_ui = ( XINE_UI * ) GetWindowLong( hwnd, GWL_USERDATA ); + + switch( msg ) + { + case WM_RBUTTONDOWN: + { + if( xine_ui ) + if( xine_ui->hctrlwnd ) + { + SetWindowPos( xine_ui->hctrlwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW ); + UpdateWindow( xine_ui->hpanelwnd ); + } + + return 0L; + } + + case WM_MOVE: + { + if( xine_ui ) + xine_ui->DriverMessage( GUI_WIN32_MOVED_OR_RESIZED, 0 ); + return 0L; + } + + case WM_SIZE: + { + if( xine_ui ) + xine_ui->DriverMessage( GUI_WIN32_MOVED_OR_RESIZED, 0 ); + return 0L; + } + + case WM_DESTROY: + { + PostQuitMessage( 0 ); + return 0L; + } + } + + return DefWindowProc( hwnd, msg, wparam, lparam); +} + + +bool XINE_UI::init_videownd() +{ + WNDCLASSEX wc; + HWND desktop; + HDC hdc; + COLORREF colorkey; + + // colorkey section borrowed from videolan code + + desktop = GetDesktopWindow(); + hdc = GetDC( desktop ); + for( colorkey = 5; colorkey < 0xFF /*all shades of red*/; colorkey++ ) + { + if( colorkey == GetNearestColor( hdc, colorkey ) ) + break; + } + ReleaseDC( desktop, hdc ); + + // create the brush + + win32_visual.Brush = CreateSolidBrush( colorkey ); + win32_visual.ColorKey = ( int ) colorkey; + + // register our window class + + wc.cbSize = sizeof( wc ); + wc.lpszClassName = TEXT( "xinevideowindow" ); + wc.lpfnWndProc = proc_videownd; + wc.style = CS_VREDRAW | CS_HREDRAW; + wc.hInstance = hinst; + wc.hIcon = LoadIcon( hinst, MAKEINTRESOURCE( ico_xine_logo ) ); + wc.hIconSm = LoadIcon( hinst, MAKEINTRESOURCE( ico_xine_logo ) ); + wc.hCursor = LoadCursor( NULL, IDC_ARROW ); + wc.hbrBackground = ( HBRUSH ) win32_visual.Brush; + wc.lpszMenuName = 0; + wc.cbClsExtra = 0; + wc.cbWndExtra = 0; + + if( !RegisterClassEx( &wc ) ) + { + error( "init_videownd : cannot register window class" ); + return false; + } + + // calculate the proper size for the windows given client size + + DWORD dwFrameWidth = GetSystemMetrics( SM_CXSIZEFRAME ); + DWORD dwFrameHeight = GetSystemMetrics( SM_CYSIZEFRAME ); + DWORD dwMenuHeight = GetSystemMetrics( SM_CYMENU ); + DWORD dwCaptionHeight = GetSystemMetrics( SM_CYCAPTION ); + DWORD dwWindowWidth = WINDOW_WIDTH + dwFrameWidth * 2; + DWORD dwWindowHeight = WINDOW_HEIGHT + dwFrameHeight * 2 + + dwMenuHeight + dwCaptionHeight; + + // create and show the main window + + hvideownd = CreateWindowEx( 0, + TEXT( "xinevideowindow" ), + TEXT( "xine Video Output" ), + WS_SIZEBOX | WS_SYSMENU | WS_MAXIMIZEBOX, + CW_USEDEFAULT, CW_USEDEFAULT, + dwWindowWidth, dwWindowHeight, + NULL, + NULL, + hinst, + NULL ); + if( !hvideownd ) + { + error( "init_videownd : cannot create video window" ); + return false; + } + + ShowWindow( hvideownd, SW_SHOW ); + UpdateWindow( hvideownd ); + + win32_visual.WndHnd = hvideownd; + SetWindowLong( hvideownd, GWL_USERDATA, ( long ) this ); + + return true; +} + +void XINE_UI::end_videownd() +{ + DeleteObject( win32_visual.Brush ); + DestroyWindow( hvideownd ); + UnregisterClass( "xinevideowindow", hinst ); +} diff --git a/win32/source/xine_logo.bmp b/win32/source/xine_logo.bmp new file mode 100644 index 000000000..f58b27f00 Binary files /dev/null and b/win32/source/xine_logo.bmp differ diff --git a/win32/source/xineconsole.cpp b/win32/source/xineconsole.cpp new file mode 100644 index 000000000..21055b667 --- /dev/null +++ b/win32/source/xineconsole.cpp @@ -0,0 +1,65 @@ +#include +#include +#include +#include +#include "utils.h" +#include "xineint.h" + + +void event_listener( void * user_data, xine_event_t * xine_event ) +{ + printf ("main: event listener, got event type %d\n", xine_event->type); + + switch( xine_event->type ) + { + case XINE_EVENT_UI_CHANNELS_CHANGED: + printf( "xine-event : XINE_EVENT_UI_CHANNELS_CHANGED\n" ); + break; + + case XINE_EVENT_UI_SET_TITLE: + printf( "xine-event : XINE_EVENT_UI_SET_TITLE\n" ); + break; + + case XINE_EVENT_UI_PLAYBACK_FINISHED: + printf( "xine-event : XINE_EVENT_PLAYBACK_FINISHED\n" ); + break; + +#if 0 + case XINE_EVENT_NEED_NEXT_MRL: + printf( "xine-event : XINE_EVENT_NEED_NEXT_MRL\n" ); + break; + + case XINE_EVENT_BRANCHED: + printf( "xine-event : XINE_EVENT_BRANCHED\n" ); + break; +#endif + } +} + +int main( int argc, char *argv[ ], char *envp[ ] ) +{ + win32_visual_t win32_visual; + + // print welcome + + printf( "xine win32 console app v 0.1\n" ); + + // init xine libs + + config_values_t config; + memset( &win32_visual, 0, sizeof( win32_visual ) ); + xine_t * xine = xine_startup( &config, &win32_visual ); + + if( !argv[1] ) + printf( "xineconsole error : no media input file specified\n" ); + else + xine_play( xine, argv[1], 0, 0 ); + + xine_register_event_listener( xine, event_listener, &win32_visual ); + + xine_set_audio_property( xine, AO_PROP_MUTE_VOL, 1 ); + + getch(); + + return 0; +} diff --git a/win32/source/xineint.cpp b/win32/source/xineint.cpp new file mode 100644 index 000000000..2534f8555 --- /dev/null +++ b/win32/source/xineint.cpp @@ -0,0 +1,209 @@ + +#include "xineui.h" + +static vo_driver_t * load_video_out_driver( char * video_driver_id, config_values_t * config, win32_visual_t * win32_visual ) +{ + vo_driver_t * vo_driver = 0; + + /* + * Setting default (configfile stuff need registering before updating, etc...). + */ + + char ** driver_ids = xine_list_video_output_plugins( VISUAL_TYPE_WIN32 ); + int i; + + /* video output driver auto-probing */ + + i = 0; + + while( driver_ids[i] ) + { + video_driver_id = driver_ids[i]; + +// printf (_("main: probing <%s> video output plugin\n"), video_driver_id); + + vo_driver = xine_load_video_output_plugin( config, video_driver_id, VISUAL_TYPE_WIN32, (void *) win32_visual ); + + if( vo_driver ) + { + if(driver_ids) + free(driver_ids); + + config->update_string( config, "video.driver", video_driver_id ); + return vo_driver; + } + + i++; + } + +// Error( 0, "main: all available video drivers failed.\n"); + return 0; +} + + +static ao_driver_t * load_audio_out_driver( char * audio_driver_id, config_values_t * config ) +{ + ao_driver_t * ao_driver = 0; + + /* + * Setting default (configfile stuff need registering before updating, etc...). + */ + + char * default_driver = config->register_string( config, "audio.driver", "auto", "audio driver to use", NULL, NULL, NULL ); + + /* + * if no audio driver was specified at the command line, + * look up audio driver id in the config file + */ + + if( !audio_driver_id ) + audio_driver_id = default_driver; + + /* probe ? */ + + if( !strncmp( audio_driver_id, "auto", 4 ) ) + { + char **driver_ids = xine_list_audio_output_plugins(); + int i = 0; + +// Error( 0, "main: probing audio drivers...\n" ); + + while( driver_ids[i] != NULL ) + { + audio_driver_id = driver_ids[i]; +// Error( 0, "main: trying to autoload '%s' audio driver :", driver_ids[i] ); + ao_driver = xine_load_audio_output_plugin( config, driver_ids[i] ); + + if( ao_driver ) + { + printf ("main: ...worked, using '%s' audio driver.\n", driver_ids[i] ); + config->update_string( config, "audio.driver", audio_driver_id ); + + return ao_driver; + } + + i++; + } + +// Error( 0, "main: audio driver probing failed => no audio output\n" ); + + config->update_string( config, "audio.driver", "null" ); + + } + else + { + /* don't want to load an audio driver ? */ + if( !strnicmp( audio_driver_id, "NULL", 4 ) ) + { +// Error( 0,"main: not using any audio driver (as requested).\n"); + config->update_string( config, "audio.driver", "null" ); + + } + else + { + + ao_driver = xine_load_audio_output_plugin( config, audio_driver_id ); + + if( !ao_driver ) + { +// Error( 0, "main: the specified audio driver '%s' failed\n", audio_driver_id ); + exit(1); + } + + config->update_string( config, "audio.driver", audio_driver_id ); + } + } + + return ao_driver; +} + +xine_t * xine_startup( config_values_t * config, win32_visual_t * win32_visual ) +{ + vo_driver_t * vo_driver; + ao_driver_t * ao_driver; + + int audio_channel = -1; + int spu_channel = -1; + + xine_t * xine; + xine_stream_t *stream; + xine_stream_t *spu_stream; + + /* + * Check xine library version + */ + +#if (1) + if(!xine_check_version(1, 0, 0)) { + int major, minor, sub; + + xine_get_version (&major, &minor, &sub); + fprintf(stderr, _("Require xine library version 1.0.0, found %d.%d.%d.\n"), + major, minor,sub); + exit(1); + } +#else + if( !xine_check_version( 0, 9, 4 ) ) + { +// Error( 0, "require xine library version 0.9.4, found %d.%d.%d.\n", +// xine_get_major_version(), xine_get_minor_version(), xine_get_sub_version() ); + return false; + } +#endif + + /* + * generate and init a config "object" + */ + char * cfgfile = "config"; + char * configfile = ( char * ) xine_xmalloc( ( strlen( ( xine_get_homedir( ) ) ) + strlen( cfgfile ) ) +2 ); + sprintf( configfile, "%s/%s", ( xine_get_homedir() ), cfgfile ); + + /*config = config_file_init( configfile );*/ + xine = xine_new(); + xine_config_load(xine, configfile); + + /* + * Try to load video output plugin, by stored name or probing + */ + + vo_driver = load_video_out_driver( "vo_directx", config, win32_visual ); + + /* + * Try to load audio output plugin, by stored name or probing + */ + + ao_driver = load_audio_out_driver( "auto", config ); + + /* + * xine init + */ + stream = xine_stream_new(xine, ao_driver, vo_driver); + spu_stream = xine_stream_new(xine, NULL, vo_driver); + + osd_init(); + + event_queue = xine_event_new_queue(gGui->stream); + xine_event_create_listener_thread(gGui->event_queue, event_listener, NULL); + + xine_tvmode_init(xine); + + /* TC - We need to allow switches on the command line for this stuff! */ + xine_set_param(stream, XINE_PARAM_AUDIO_CHANNEL_LOGICAL, audio_channel); + xine_set_param(stream, XINE_PARAM_SPU_CHANNEL, spu_channel); + +#if (0) + /* Visual animation stream init */ + gGui->visual_anim.stream = xine_stream_new(gGui->xine, NULL, gGui->vo_port); + gGui->visual_anim.event_queue = xine_event_new_queue(gGui->visual_anim.stream); + gGui->visual_anim.current = 0; + xine_event_create_listener_thread(gGui->visual_anim.event_queue, event_listener, NULL); + xine_set_param(gGui->visual_anim.stream, XINE_PARAM_AUDIO_CHANNEL_LOGICAL, -2); + xine_set_param(gGui->visual_anim.stream, XINE_PARAM_SPU_CHANNEL, -2); + + /* Playlist scanning feature stream */ + gGui->playlist.scan_stream = xine_stream_new(gGui->xine, gGui->ao_port, gGui->vo_port); + xine_set_param(gGui->playlist.scan_stream, XINE_PARAM_SPU_CHANNEL, -2); +#endif + + return xine; +} \ No newline at end of file diff --git a/win32/source/xineint.h b/win32/source/xineint.h new file mode 100644 index 000000000..88166a7b6 --- /dev/null +++ b/win32/source/xineint.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2000-2001 the xine project + * + * This file is part of xine for win32 video player. + * + * xine 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. + * + * xine 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * Xine win32 UI + * by Matthew Grooms + */ + +#include "configfile.h" +#include "xine.h" +#include "xineutils.h" +#include "video_out_win32.h" + +#include +#include +#include "inttypes.h" + +xine_t * xine_startup( config_values_t * config, win32_visual_t * win32_visual ); diff --git a/win32/source/xineui.cpp b/win32/source/xineui.cpp new file mode 100644 index 000000000..5214547e4 --- /dev/null +++ b/win32/source/xineui.cpp @@ -0,0 +1,864 @@ +/* + * Copyright (C) 2000-2001 the xine project + * + * This file is part of xine for win32 video player. + * + * xine 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. + * + * xine 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * Xine win32 UI + * by Matthew Grooms + */ + +#include "xineui.h" +#include "common.h" + +/* +#define LOG 1 +*/ +/**/ + +static char **video_driver_ids; +static char **audio_driver_ids; + + +static void config_update(xine_cfg_entry_t *entry, + int type, int min, int max, int value, char *string) { + + switch(type) { + + case XINE_CONFIG_TYPE_UNKNOWN: + fprintf(stderr, "Config key '%s' isn't registered yet.\n", entry->key); + return; + break; + + case XINE_CONFIG_TYPE_RANGE: + entry->range_min = min; + entry->range_max = max; + break; + + case XINE_CONFIG_TYPE_STRING: + entry->str_value = string; + break; + + case XINE_CONFIG_TYPE_ENUM: + case XINE_CONFIG_TYPE_NUM: + case XINE_CONFIG_TYPE_BOOL: + entry->num_value = value; + break; + + default: + fprintf(stderr, "Unknown config type %d\n", type); + return; + break; + } + + xine_config_update_entry(gGui->xine, entry); +} + +static void config_update_num(char *key, int value) { + xine_cfg_entry_t entry; + + if(xine_config_lookup_entry(gGui->xine, key, &entry)) + config_update(&entry, XINE_CONFIG_TYPE_NUM, 0, 0, value, NULL); + else + fprintf(stderr, "WOW, key %s isn't registered\n", key); +} + +/* + * Try to load video output plugin, by stored name or probing + */ +static xine_video_port_t *load_video_out_driver(int driver_number, win32_visual_t *vis) { + xine_video_port_t *video_port = NULL; + int driver_num; + + + /* + * Setting default (configfile stuff need registering before updating, etc...). + */ + driver_num = + xine_config_register_enum(gGui->xine, "video.driver", + 0, video_driver_ids, + ("video driver to use"), + ("Choose video driver. " + "NOTE: you may restart xine to use the new driver"), + CONFIG_LEVEL_ADV, + CONFIG_NO_CB, + CONFIG_NO_DATA); + + if (driver_number < 0) { + /* video output driver auto-probing */ + const char *const *driver_ids; + int i; + + if((!strcasecmp(video_driver_ids[driver_num], "none")) || + (!strcasecmp(video_driver_ids[driver_num], "null"))) { + + /*vis = (win32_visual_t *) xine_xmalloc(sizeof(win32_visual_t));*/ + video_port = xine_open_video_driver(gGui->xine, + video_driver_ids[driver_num], + XINE_VISUAL_TYPE_NONE, + (void *) vis); + if (video_port) + return video_port; + + } + else if(strcasecmp(video_driver_ids[driver_num], "auto")) { + + vis = (win32_visual_t *) xine_xmalloc(sizeof(win32_visual_t)); + video_port = xine_open_video_driver(gGui->xine, + video_driver_ids[driver_num], + XINE_VISUAL_TYPE_WIN32, + (void *) vis); + if (video_port) + return video_port; + } + + /* note: xine-lib can do auto-probing for us if we want. + * but doing it here should do no harm. + */ + i = 0; + driver_ids = xine_list_video_output_plugins (gGui->xine); + + while (driver_ids[i]) { + + printf (("main: probing <%s> video output plugin\n"), driver_ids[i]); + + /*vis = (win32_visual_t *) xine_xmalloc(sizeof(win32_visual_t));*/ + video_port = xine_open_video_driver(gGui->xine, + driver_ids[i], + XINE_VISUAL_TYPE_WIN32, + (void *) vis); + if (video_port) { + return video_port; + } + + i++; + } + + if (!video_port) { + printf (("main: all available video drivers failed.\n")); + exit (1); + } + + } + else { + + /* 'none' plugin is a special case, just change the visual type */ + if((!strcasecmp(video_driver_ids[driver_number], "none")) + || (!strcasecmp(video_driver_ids[driver_number], "null"))) { + + vis = (win32_visual_t *) xine_xmalloc(sizeof(win32_visual_t)); + video_port = xine_open_video_driver(gGui->xine, + video_driver_ids[driver_number], + XINE_VISUAL_TYPE_NONE, + (void *) &vis); + + /* do not save on config, otherwise user would never see images again... */ + } + else { + vis = (win32_visual_t *) xine_xmalloc(sizeof(win32_visual_t)); + video_port = xine_open_video_driver(gGui->xine, + video_driver_ids[driver_number], + XINE_VISUAL_TYPE_WIN32, + (void *) &vis); + +#if (0) + /* save requested driver (-V) */ + if(video_port) + config_update_num("video.driver", driver_number); +#endif + } + + if(!video_port) { + printf (("main: video driver <%s> failed\n"), video_driver_ids[driver_number]); + exit (1); + } + + } + + return video_port; +} + +/* + * Try to load audio output plugin, by stored name or probing + */ +static xine_audio_port_t *load_audio_out_driver(int driver_number) { + xine_audio_port_t *audio_port = NULL; + int driver_num; + + /* + * Setting default (configfile stuff need registering before updating, etc...). + */ + driver_num = + xine_config_register_enum(gGui->xine, "video.driver", + 0, video_driver_ids, + ("video driver to use"), + ("Choose video driver. " + "NOTE: you may restart xine to use the new driver"), + CONFIG_LEVEL_ADV, + CONFIG_NO_CB, + CONFIG_NO_DATA); + + + driver_num = + xine_config_register_enum(gGui->xine, "audio.driver", + 0, audio_driver_ids, + ("audio driver to use"), + ("Choose audio driver. " + "NOTE: you may restart xine to use the new driver"), + CONFIG_LEVEL_ADV, + CONFIG_NO_CB, + CONFIG_NO_DATA); + + if (driver_number < 0) { + const char *const *driver_ids; + int i; + + if (strcasecmp(audio_driver_ids[driver_num], "auto")) { + + /* don't want to load an audio driver ? */ + if (!strncasecmp(audio_driver_ids[driver_num], "NULL", 4)) { + printf(("main: not using any audio driver (as requested).\n")); + return NULL; + } + + audio_port = xine_open_audio_driver(gGui->xine, + audio_driver_ids[driver_num], + NULL); + if (audio_port) + return audio_port; + } + + /* note: xine-lib can do auto-probing for us if we want. + * but doing it here should do no harm. + */ + i = 0; + driver_ids = xine_list_audio_output_plugins (gGui->xine); + + while (driver_ids[i]) { + + printf (("main: probing <%s> audio output plugin\n"), driver_ids[i]); + + audio_port = xine_open_audio_driver(gGui->xine, + driver_ids[i], + NULL); + if (audio_port) { + return audio_port; + } + + i++; + } + + printf(("main: audio driver probing failed => no audio output\n")); + } + else { + + /* don't want to load an audio driver ? */ + if (!strncasecmp (audio_driver_ids[driver_number], "NULL", 4)) { + + printf(("main: not using any audio driver (as requested).\n")); + + /* calling -A null is useful to developers, but we should not save it at + * config. if user doesn't have a sound card he may go to setup screen + * changing audio.driver to NULL in order to make xine start a bit faster. + */ + + } + else { + + audio_port = xine_open_audio_driver(gGui->xine, audio_driver_ids[driver_number], NULL); + + if (!audio_port) { + printf (("main: audio driver <%s> failed\n"), audio_driver_ids[driver_number]); + exit (1); + } + + /* save requested driver (-A) */ + config_update_num("audio.driver", driver_number); + } + + } + + return audio_port; +} + + +static void event_listener(void *user_data, const xine_event_t *event) { + struct timeval tv; + + XINE_UI * xine_ui = ( XINE_UI * ) user_data; + + /* + * Ignoring finished event logo is displayed (or played), that save us + * from a loop of death + */ + if(gGui->logo_mode && (event->type == XINE_EVENT_UI_PLAYBACK_FINISHED)) + return; + + gettimeofday (&tv, NULL); + + if(abs(tv.tv_sec - event->tv.tv_sec) > 3) { + printf("Event too old, discarding\n"); + return; + } + + + switch( event->type ) + { + case XINE_EVENT_UI_CHANNELS_CHANGED: + { + xine_ui->spu_channel = xine_get_param(gGui->stream, XINE_PARAM_SPU_CHANNEL); + xine_ui->audio_channel = xine_get_param(gGui->stream, XINE_PARAM_AUDIO_CHANNEL_LOGICAL); + } + break; + + case XINE_EVENT_UI_PLAYBACK_FINISHED: + xine_ui->Stop(); + xine_ui->Play( xine_ui->playindex + 1 ); + break; + +#if (0) + case XINE_EVENT_NEED_NEXT_MRL: + { + xine_next_mrl_event_t * xine_next_mrl_event = ( xine_next_mrl_event_t * ) xine_event; + + PLAYITEM * playitem = 0; + if( xine_ui->playindex < ( xine_ui->playcount - 1 ) ) + { + xine_ui->mrl_short_name = xine_ui->playlist[ xine_ui->playindex + 1 ]->mrl_short_name; + xine_ui->mrl_long_name = xine_ui->playlist[ xine_ui->playindex + 1 ]->mrl_long_name; + xine_next_mrl_event->mrl = xine_ui->mrl_long_name; + xine_ui->playindex++; + } + else + xine_next_mrl_event->mrl = 0; + + xine_next_mrl_event->handled = 1; + } + break; + + case XINE_EVENT_BRANCHED: +#ifdef LOG + printf("xineui.cpp : event received XINE_EVENT_BRANCHED\n"); +#endif +// gui_branched_callback (); + break; +#endif + + /* e.g. aspect ratio change during dvd playback */ + case XINE_EVENT_FRAME_FORMAT_CHANGE: +#ifdef LOG + printf("xineui.cpp : event received XINE_EVENT_FRAME_FORMAT_CHANGE\n"); +#endif + break; + + /* report current audio level (l/r) */ + case XINE_EVENT_AUDIO_LEVEL: + if(event->stream == gGui->stream) { + xine_audio_level_data_t *aevent = (xine_audio_level_data_t *) event->data; + + printf("XINE_EVENT_AUDIO_LEVEL: left 0>%d<255, right 0>%d<255\n", + aevent->left, aevent->right); + } + break; + + /* last event sent when stream is disposed */ + case XINE_EVENT_QUIT: +#ifdef LOG + printf("xineui.cpp : event received XINE_EVENT_QUIT\n"); +#endif + break; + + default: +#ifdef LOG + printf("xineui.cpp : unsupported event received 0x%X\n", event->type); +#endif + break; + + } +} + +_XINE_UI::_XINE_UI() +{ + memset( this, 0, sizeof( _XINE_UI ) ); +} + +_XINE_UI::~_XINE_UI() +{ + EndGui(); + EndXine(); +} + +bool _XINE_UI::InitGui( HINSTANCE hinstance ) +{ + if( !hinstance ) + return false; + + hinst = hinstance; + + if( !init_ctrlwnd() ) + return false; + + if( !init_videownd() ) + return false; + + return true; +} + +void _XINE_UI::EndGui() +{ + end_ctrlwnd(); + end_videownd(); +} + +bool _XINE_UI::InitXine() +{ + int i; + int audio_channel = -1; + int spu_channel = -1; + char *audio_driver_id = NULL; + char *video_driver_id = NULL; + int driver_num; + int session = -1; + char *session_mrl = NULL; + int major, minor, sub; + + /* Check xine library version */ + if( !xine_check_version( 0, 9, 4 ) ) + { + xine_get_version(&major, &minor, &sub); + error( "require xine library version 0.9.4, found %d.%d.%d.\n", + major, minor, sub ); + return false; + } + + gGui = (gGui_t *) xine_xmalloc(sizeof(gGui_t)); + gui = gGui; + + gGui->stream = NULL; + gGui->debug_level = 0; + gGui->autoscan_plugin = NULL; + gGui->network = 0; + gGui->use_root_window = 0; + + /*gGui->vo_port*/ + +#ifdef HAVE_XF86VIDMODE + gGui->XF86VidMode_fullscreen = 0; +#endif + +#if (0) + /* generate and init a config "object" */ + char * cfgfile = "config"; + gGui->configfile = ( char * ) xine_xmalloc( ( strlen( ( xine_get_homedir( ) ) ) + strlen( cfgfile ) ) +2 ); + sprintf( configfile, "%s/%s", ( xine_get_homedir() ), cfgfile ); + + /*config = config_file_init( configfile );*/ + +#else + /* + * Initialize config + */ + { + char *cfgdir = ".xine"; + char *cfgfile = "config"; + + if (!(gGui->configfile = getenv ("XINERC"))) { + gGui->configfile = (char *) xine_xmalloc(strlen(xine_get_homedir()) + + strlen(cfgdir) + + strlen(cfgfile) + + 3); + sprintf (gGui->configfile, "%s/%s", xine_get_homedir(), cfgdir); + mkdir (gGui->configfile, 0755); + sprintf (gGui->configfile + strlen(gGui->configfile), "/%s", cfgfile); + } + +#if (0) + /* Popup setup window if there is no config file */ + if(stat(gGui->configfile, &st) < 0) + gGui->actions_on_start[aos++] = ACTID_SETUP; +#endif + + } +#endif + + + gGui->xine = xine_new(); + xine_config_load(gGui->xine, gGui->configfile); + +#if (0) + /* + * init gui + */ + gui_init(_argc - optind, &_argv[optind], &window_attribute); +#endif + + pthread_mutex_init(&gGui->download_mutex, NULL); + +#if (0) + /* Automatically start playback if new_mode is enabled and playlist is filled */ + if(gGui->smart_mode && + (gGui->playlist.num || actions_on_start(gGui->actions_on_start, ACTID_PLAYLIST)) && + (!(actions_on_start(gGui->actions_on_start, ACTID_PLAY)))) + gGui->actions_on_start[aos++] = ACTID_PLAY; +#endif + + /* + * xine init + */ + xine_init(gGui->xine); + + + /* + * load and init output drivers + */ + /* Video out plugin */ + driver_num = -1; + { + const char *const *vids = xine_list_video_output_plugins(gGui->xine); + int i = 0; + + while(vids[i++]); + + video_driver_ids = (char **) xine_xmalloc(sizeof(char *) * (i + 1)); + i = 0; + video_driver_ids[i] = strdup("auto"); + while(vids[i]) { + video_driver_ids[i + 1] = strdup(vids[i]); + i++; + } + + video_driver_ids[i + 1] = NULL; + + if(video_driver_id) { + for(i = 0; video_driver_ids[i] != NULL; i++) { + if(!strcasecmp(video_driver_id, video_driver_ids[i])) { + driver_num = i; + break; + } + } + } + gGui->vo_port = load_video_out_driver(driver_num, &win32_visual); + } + + { + xine_cfg_entry_t cfg_vo_entry; + + if(xine_config_lookup_entry(gGui->xine, "video.driver", &cfg_vo_entry)) { + + if(!strcasecmp(video_driver_ids[cfg_vo_entry.num_value], "dxr3")) { + xine_cfg_entry_t cfg_entry; + } + } + } + SAFE_FREE(video_driver_id); + + /* Audio out plugin */ + driver_num = -1; + { + const char *const *aids = xine_list_audio_output_plugins(gGui->xine); + int i = 0; + + while(aids[i++]); + + audio_driver_ids = (char **) xine_xmalloc(sizeof(char *) * (i + 2)); + i = 0; + audio_driver_ids[i] = strdup("auto"); + audio_driver_ids[i + 1] = strdup("null"); + while(aids[i]) { + audio_driver_ids[i + 2] = strdup(aids[i]); + i++; + } + + audio_driver_ids[i + 2] = NULL; + + if(audio_driver_id) { + for(i = 0; audio_driver_ids[i] != NULL; i++) { + if(!strcasecmp(audio_driver_id, audio_driver_ids[i])) { + driver_num = i; + break; + } + } + } + gGui->ao_port = load_audio_out_driver(driver_num); + } + SAFE_FREE(audio_driver_id); + + /* post_init(); */ + + gGui->stream = xine_stream_new(gGui->xine, gGui->ao_port, gGui->vo_port); + gGui->spu_stream = xine_stream_new(gGui->xine, NULL, gGui->vo_port); + +#if (0) + osd_init(); + + /* + * Setup logo. + */ + gGui->logo_mode = 0; + gGui->logo_has_changed = 0; + gGui->logo_mrl = xine_config_register_string (gGui->xine, "gui.logo_mrl", XINE_LOGO_MRL, + _("Logo mrl"), + CONFIG_NO_HELP, + CONFIG_LEVEL_EXP, + main_change_logo_cb, + CONFIG_NO_DATA); +#endif + + gGui->event_queue = xine_event_new_queue(gGui->stream); + xine_event_create_listener_thread(gGui->event_queue, event_listener, this); + + xine_tvmode_init(gGui->xine); + + +#if 1 + xine_set_param(gGui->stream, XINE_PARAM_AUDIO_CHANNEL_LOGICAL, audio_channel); + xine_set_param(gGui->stream, XINE_PARAM_SPU_CHANNEL, spu_channel); +#else + xine_set_param(gGui->stream, XINE_PARAM_AUDIO_CHANNEL_LOGICAL, 0); + xine_set_param(gGui->stream, XINE_PARAM_SPU_CHANNEL, 0); +#endif + + +#if 0 + /* Visual animation stream init */ + gGui->visual_anim.stream = xine_stream_new(gGui->xine, NULL, gGui->vo_port); + gGui->visual_anim.event_queue = xine_event_new_queue(gGui->visual_anim.stream); + gGui->visual_anim.current = 0; + xine_event_create_listener_thread(gGui->visual_anim.event_queue, event_listener, this); + xine_set_param(gGui->visual_anim.stream, XINE_PARAM_AUDIO_CHANNEL_LOGICAL, -2); + xine_set_param(gGui->visual_anim.stream, XINE_PARAM_SPU_CHANNEL, -2); +#endif + +#if (0) + /* Playlist scanning feature stream */ + gGui->playlist.scan_stream = xine_stream_new(gGui->xine, gGui->ao_port, gGui->vo_port); + xine_set_param(gGui->playlist.scan_stream, XINE_PARAM_SPU_CHANNEL, -2); +#endif + + return true; +} + +void _XINE_UI::EndXine() +{ + if( gui && gui->xine ) + xine_exit( gui->xine ); +} + +void _XINE_UI::error( LPSTR szfmt, ... ) +{ + char tempbuff[ 256 ]; + *tempbuff = 0; + wvsprintf( &tempbuff[ strlen( tempbuff ) ], szfmt, ( char * )( &szfmt + 1 ) ); + MessageBox( 0, tempbuff, "Error", MB_ICONERROR | MB_OK | MB_APPLMODAL | MB_SYSTEMMODAL ); +} + +void _XINE_UI::warning( LPSTR szfmt, ... ) +{ + char tempbuff[ 256 ]; + *tempbuff = 0; + wvsprintf( &tempbuff[ strlen( tempbuff ) ], szfmt, ( char * )( &szfmt + 1 ) ); + MessageBox( 0, tempbuff, "Warning", MB_ICONWARNING | MB_OK | MB_APPLMODAL | MB_SYSTEMMODAL ); +} + +PLAYITEM * _XINE_UI::PlaylistAdd( char * short_name, char * long_name, int type ) +{ + if( playcount >= MAX_PLAYITEMS ) + return false; + + PLAYITEM * playitem = new PLAYITEM; + + playitem->mrl_short_name = strdup( short_name ); + playitem->mrl_long_name = strdup( long_name ); + playitem->mrl_type = type; + + playlist[ playcount ] = playitem; + playcount++; + + return playitem; +} + +bool _XINE_UI::PlaylistDel( int index ) +{ + if( index >= playcount ) + return false; + + PLAYITEM * playitem = playlist[ index ]; + + free( playitem->mrl_short_name ); + free( playitem->mrl_long_name ); + + delete playitem; + + memcpy( &playlist[ index ], &playlist[ index + 1 ], ( playcount - index ) * sizeof( PLAYITEM * ) ); + playcount--; + + if( ( index < playindex ) && ( playcount > 0 ) ) + playindex--; + + if( index == playindex ) + { + if( playindex >= playcount ) + playindex--; + + mrl_short_name = 0; + mrl_long_name = 0; + Stop(); + } + + return true; +} + +bool _XINE_UI::Play( int newindex ) +{ + int pos_stream, pos_time; + int length_time; + + // if we are paused, just continue playing + + if( mode == XINE_STATUS_PLAY ) + { + SetSpeed( XINE_SPEED_NORMAL ); + return true; + } + + // make sure the playindex is valid + + if( ( newindex >= 0 ) && ( newindex < playcount ) ) + playindex = newindex; + else + return false; + + // is this different mrl then we are already playing + + if( newindex == playindex ) + { + // its the same, play from current time + + HWND htimebar = GetDlgItem( hctrlwnd, ID_TIMEBAR ); + mrl_time_current = SendMessage( htimebar, TBM_GETPOS, (WPARAM) 0, (LPARAM) 0 ); + } + else + { + // its different, rewind and play from 0 + + mrl_time_current = 0; + } + + // store our new mrl info + + mrl_short_name = playlist[ playindex ]->mrl_short_name; + mrl_long_name = playlist[ playindex ]->mrl_long_name; + mrl_type = playlist[ playindex ]->mrl_type; + + // play our mrl + if(!xine_open(gGui->stream, (const char *)mrl_long_name)) { + return 0; + } + + if(xine_play(gGui->stream, 0, mrl_time_current)) + { + mrl_time_length = 0; + if (xine_get_pos_length (gGui->stream, &pos_stream, &pos_time, &length_time)) + { + mrl_time_length = length_time/1000; + } + + /*mrl_time_length = xine_get_stream_length( gGui->stream )/1000;*/ + + HWND htimebar = GetDlgItem( hctrlwnd, ID_TIMEBAR ); + SendMessage( htimebar, TBM_SETRANGE, (WPARAM) TRUE, (LPARAM) MAKELONG( 0, mrl_time_length ) ); + mode = XINE_STATUS_PLAY; + + // start our update loop + + UpdateLoop(); + } + + return true; +} + +bool _XINE_UI::Stop() +{ + mode = XINE_STATUS_STOP; + mrl_time_current = 0; + UpdateCtrl(); + UpdatePanel(); + xine_stop( gGui->stream ); + + return true; +} + +bool _XINE_UI::SetSpeed( int speed ) +{ + /*xine_set_speed( gGui->stream, speed );*/ + xine_set_param(gGui->stream, XINE_PARAM_SPEED, speed); + return true; +} + +int _XINE_UI::GetSpeed() +{ + /*return xine_get_speed( gGui->stream );*/ + return xine_get_param(gGui->stream, XINE_PARAM_SPEED); + +} + +bool _XINE_UI::SetTime( int time ) +{ + if( mode == XINE_STATUS_PLAY ) + { + if(!xine_open(gGui->stream, (const char *)mrl_long_name)) { + return false; + } + + xine_play(gGui->stream, 0, time); + + + mrl_time_current = time; + } + + return true; +} + +bool _XINE_UI::SelectSpuChannel( int channel ) +{ + xine_set_param(gGui->stream, XINE_PARAM_SPU_CHANNEL, channel); + return true; +} + +bool _XINE_UI::SelectAudioChannel( int channel ) +{ + xine_set_param(gGui->stream, XINE_PARAM_AUDIO_CHANNEL_LOGICAL, channel); + return true; +} + +bool _XINE_UI::SetVolume( int volume ) +{ + xine_set_param(gGui->stream, XINE_PARAM_AUDIO_VOLUME, volume); + return true; +} + +bool _XINE_UI::SetMute( bool mute ) +{ + xine_set_param(gGui->stream, XINE_PARAM_AUDIO_MUTE, mute); + return true; +} + +bool _XINE_UI::DriverMessage( int type, void * param ) +{ + gGui->vo_port->driver->gui_data_exchange( gGui->vo_port->driver, type, param ); + return true; +} + diff --git a/win32/source/xineui.h b/win32/source/xineui.h new file mode 100644 index 000000000..73a23c9c8 --- /dev/null +++ b/win32/source/xineui.h @@ -0,0 +1,163 @@ +/* + * Copyright (C) 2000-2001 the xine project + * + * This file is part of xine for win32 video player. + * + * xine 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. + * + * xine 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 this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * + * Xine win32 UI + * by Matthew Grooms + */ + +#include +#include +#include +#include +#include + +#include "xine.h" +#include "xineint.h" +#include "resource.h" + +#include "common.h" + +#include "video_out.h" +#include "audio_out.h" + +#include "video_out_win32.h" + +#ifndef _XINEUI_H_ +#define _XINEUI_H_ + +#define ID_PANEL 10001 +#define ID_TIMEBAR 10002 +#define ID_TOOLBAR 10003 + +#define ID_PLAY_BTTN 20001 +#define ID_PAUSE_BTTN 20002 +#define ID_STOP_BTTN 20003 +#define ID_PREV_BTTN 20004 +#define ID_NEXT_BTTN 20005 +#define ID_FFWD_BTTN 20006 +#define ID_RWND_BTTN 20007 +#define ID_EJECT_BTTN 20008 + +#define ID_TITLE 10001 +#define ID_TIME 10002 +#define ID_CONFIG 10003 +#define ID_FULLSCREEN 10004 +#define ID_SPULABEL 10005 +#define ID_SPUINC 10006 +#define ID_SPUDEC 10007 +#define ID_SPUVALUE 10008 +#define ID_AUDIOLABEL 10009 +#define ID_AUDIOINC 10010 +#define ID_AUDIODEC 10011 +#define ID_AUDIOVALUE 10012 +#define ID_VOLBUTTON 10013 +#define ID_VOLBAR 10014 + +#define ID_STATUS 10001 +#define ID_LIST 10002 +#define ID_ADD 10003 +#define ID_DEL 10004 + +typedef struct _PLAYITEM +{ + char * mrl_short_name; + char * mrl_long_name; + int mrl_type; + +}PLAYITEM; + +#define MAX_PLAYITEMS 10004 + +typedef class _XINE_UI +{ + public: + + config_values_t * config; + + gGui_t *gui; + + bool init_ctrlwnd(); + void end_ctrlwnd(); + bool init_videownd(); + void end_videownd(); + bool init_panelwnd(); + void end_panelwnd(); + bool init_playlistwnd(); + void end_playlistwnd(); + + void error( LPSTR szfmt, ... ); + void warning( LPSTR szfmt, ... ); + + char * mrl_long_name; + char * mrl_short_name; + int mrl_type; + int mrl_time_length; + int mrl_time_current; + int spu_channel; + int audio_channel; + int mode; + + PLAYITEM * playlist[ MAX_PLAYITEMS ]; + int playcount; + int playindex; + + win32_visual_t win32_visual; + + HINSTANCE hinst; + HWND hctrlwnd; + HWND hpanelwnd; + HWND hvideownd; + HWND hplaylistwnd; + bool tracking; + + _XINE_UI(); + ~_XINE_UI(); + + DWORD UpdateLoop(); + bool UpdateCtrl(); + bool UpdatePanel(); + + bool InitGui( HINSTANCE hinstance ); + void EndGui(); + bool InitXine(); + void EndXine(); + + PLAYITEM * PlaylistAdd( char * short_name, char * long_name, int type ); + bool PlaylistDel( int index ); + + bool Play( int playindex ); + bool Stop(); + bool SetTime( int time ); + + bool SetSpeed( int speed ); + int GetSpeed(); + + bool SelectSpuChannel( int channel ); + bool SelectAudioChannel( int channel ); + + bool SetVolume( int volume ); + bool SetMute( bool mute ); + + bool DriverMessage( int type, void * param ); + +}XINE_UI; + +extern gGui_t *gGui; + +#endif \ No newline at end of file -- cgit v1.2.3