Commit 434b2322 authored by Gildas Bazin's avatar Gildas Bazin

* modules/gui/wxwindows/*: misc improvements to the main interface, implementation of
drag and drop, proper initialisation of the i18n routines.
parent 269d8af1
......@@ -2,7 +2,7 @@
* interface.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: interface.cpp,v 1.6 2002/11/23 01:32:40 ipkiss Exp $
* $Id: interface.cpp,v 1.7 2002/11/23 14:28:51 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -29,10 +29,10 @@
#include <string.h> /* strerror() */
#include <stdio.h>
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <wx/wxprec.h>
#include <wx/wx.h>
/* Let wxWindows take care of the i18n stuff */
/* Let vlc take care of the i18n stuff */
#undef _
#ifdef WIN32 /* mingw32 hack */
......@@ -40,8 +40,8 @@
#undef CreateDialog
#endif
#include <wx/wxprec.h>
#include <wx/wx.h>
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include "wxwindows.h"
......@@ -59,6 +59,13 @@
#include "bitmaps/next.xpm"
#include "bitmaps/playlist.xpm"
/* include the icon graphic */
#include "share/vlc32x32.xpm"
/*****************************************************************************
* Local class declarations.
*****************************************************************************/
/*****************************************************************************
* Event Table.
*****************************************************************************/
......@@ -118,20 +125,69 @@ Interface::Interface( intf_thread_t *_p_intf ):
wxFrame( NULL, -1, "title", wxDefaultPosition, wxDefaultSize,
wxDEFAULT_FRAME_STYLE )
{
/* Initializations */
p_intf = _p_intf;
/* Give our interface a nice icon */
//SetIcon( wxICON(vlcicon) );
/* Give our interface a nice little icon */
SetIcon( *new wxIcon( vlc_xpm ) );
/* Create a sizer for the main frame */
frame_sizer = new wxBoxSizer( wxHORIZONTAL );
SetSizer( frame_sizer );
/* Creation of the menu bar */
CreateOurMenuBar();
/* Creation of the tool bar */
CreateOurToolBar();
/* Creation of the slider sub-window */
CreateOurSlider();
/* Creation of the status bar
* Helptext for menu items and toolbar tools will automatically get
* displayed here. */
int i_status_width[2] = {-2,-3};
statusbar = CreateStatusBar( 2 ); /* 2 fields */
statusbar->SetStatusWidths( 2, i_status_width );
SetTitle( COPYRIGHT_MESSAGE );
/* Layout everything */
SetAutoLayout( TRUE );
frame_sizer->Layout();
frame_sizer->SetSizeHints(this);
/* Create our "File" menu */
/* Associate drop targets with the main interface */
SetDropTarget( new DragAndDrop( p_intf ) );
}
Interface::~Interface()
{
}
/*****************************************************************************
* Private methods.
*****************************************************************************/
void Interface::CreateOurMenuBar()
{
#define HELP_FILE N_("Open a file")
#define HELP_DISC N_("Open a DVD or (S)VCD")
#define HELP_NET N_("Open a network stream")
#define HELP_SAT N_("Open a satellite stream")
#define HELP_EJECT N_("Eject the DVD/CD")
#define HELP_EXIT N_("Exit this program")
#define HELP_PLAYLIST N_("Open the playlist")
#define HELP_LOGS N_("Show the program logs")
#define HELP_AUDIO N_("Change the current audio track")
#define HELP_SUBS N_("Change the current subtitles stream")
#define HELP_PREFS N_("Go to the preferences menu")
#define HELP_ABOUT N_("About this program")
/* Create the "File" menu */
wxMenu *file_menu = new wxMenu;
file_menu->Append( OpenFile_Event, _("&Open File..."), HELP_FILE );
file_menu->Append( OpenDisc_Event, _("Open &Disc..."), HELP_DISC );
......@@ -144,25 +200,19 @@ Interface::Interface( intf_thread_t *_p_intf ):
file_menu->AppendSeparator();
file_menu->Append( Exit_Event, _("E&xit"), HELP_EXIT );
/* Create our "View" menu */
#define HELP_PLAYLIST N_("Open the playlist")
#define HELP_LOGS N_("Show the program logs")
/* Create the "View" menu */
wxMenu *view_menu = new wxMenu;
view_menu->Append( Playlist_Event, _("&Playlist..."), HELP_PLAYLIST );
view_menu->Append( Logs_Event, _("&Logs..."), HELP_LOGS );
/* Create our "Settings" menu */
#define HELP_AUDIO N_("Change the current audio track")
#define HELP_SUBS N_("Change the current subtitles stream")
#define HELP_PREFS N_("Go to the preferences menu")
/* Create the "Settings" menu */
wxMenu *settings_menu = new wxMenu;
settings_menu->Append( Audio_Event, _("&Audio"), HELP_AUDIO );
settings_menu->Append( Subtitles_Event, _("&Subtitles"), HELP_SUBS );
settings_menu->AppendSeparator();
settings_menu->Append( Prefs_Event, _("&Preferences..."), HELP_PREFS );
/* Create our "Help" menu */
#define HELP_ABOUT N_("About this program")
/* Create the "Help" menu */
wxMenu *help_menu = new wxMenu;
help_menu->Append( About_Event, _("&About..."), HELP_ABOUT );
......@@ -176,13 +226,19 @@ Interface::Interface( intf_thread_t *_p_intf ):
/* Attach the menu bar to the frame */
SetMenuBar( menubar );
/* Create toolbar */
/* Associate drop targets with the menubar */
menubar->SetDropTarget( new DragAndDrop( p_intf ) );
}
void Interface::CreateOurToolBar()
{
#define HELP_STOP N_("Stop current playlist item")
#define HELP_PLAY N_("Play current playlist item")
#define HELP_PAUSE N_("Pause current playlist item")
#define HELP_PLO N_("Open playlist")
#define HELP_PLP N_("Previous playlist item")
#define HELP_PLN N_("Next playlist item")
wxBitmap *p_bmp_file = new wxBitmap( file_xpm );
wxBitmap *p_bmp_disc = new wxBitmap( disc_xpm );
wxBitmap *p_bmp_net = new wxBitmap( net_xpm );
......@@ -214,44 +270,41 @@ Interface::Interface( intf_thread_t *_p_intf ):
toolbar->Realize();
/* Place the toolbar in a sizer, so that the window will stretch
* to get its size */
wxBoxSizer *toolbar_sizer = new wxBoxSizer( wxVERTICAL );
toolbar_sizer->Add( toolbar, 0 );
toolbar_sizer->SetSizeHints( this );
/* Create slider */
wxBoxSizer *slider_sizer = new wxBoxSizer( wxVERTICAL );
slider = new wxSlider( this, SliderScroll_Event, 0, 0, 100,
wxDefaultPosition, wxSize( 450, 50 ),
wxSL_HORIZONTAL | wxSL_TOP );
slider_sizer->Add( slider, 0, wxGROW | wxALL | wxALIGN_CENTER, 5 );
/* use the sizer for layout */
slider->Hide();
slider_sizer->Layout();
SetSizerAndFit( slider_sizer );
/* Give the frame an optional statusbar. The '1' just means one field.
* A gripsizer will automatically get put on into the corner, if that
* is the normal OS behaviour for frames on that platform. Helptext
* for menu items and toolbar tools will automatically get displayed
* here. */
statusbar = CreateStatusBar(2);
int i_status_width[2] = {-2,-3};
statusbar->SetStatusWidths( 2, i_status_width );
/* Place the toolbar in a sizer, so we can calculate the width of the
* toolbar and set this as the minimum for the main frame size. */
wxBoxSizer *toolbar_sizer = new wxBoxSizer( wxHORIZONTAL );
toolbar_sizer->Add( toolbar, 0, 0, 0 );
toolbar_sizer->Layout();
frame_sizer->SetMinSize( toolbar_sizer->GetMinSize().GetWidth(), -1 );
SetTitle( COPYRIGHT_MESSAGE );
SetAutoLayout( TRUE );
Layout();
/* Associate drop targets with the toolbar */
toolbar->SetDropTarget( new DragAndDrop( p_intf ) );
}
Interface::~Interface()
void Interface::CreateOurSlider()
{
/* Create a new frame containing the slider */
slider_frame = new wxPanel( this, -1, wxDefaultPosition, wxSize(-1,50) );
slider_frame->SetAutoLayout( TRUE );
slider_frame->Hide();
/* Create static box to surround the slider */
slider_box = new wxStaticBox( slider_frame, -1, "" );
/* Create sizer for slider frame */
wxStaticBoxSizer *slider_sizer =
new wxStaticBoxSizer( slider_box, wxHORIZONTAL );
slider_frame->SetSizer( slider_sizer );
/* Create slider */
slider = new wxSlider( slider_frame, SliderScroll_Event, 0, 0,
SLIDER_MAX_POS, wxDefaultPosition, wxDefaultSize );
slider_sizer->Add( slider, 1, wxGROW | wxALL, 5 );
slider_sizer->Layout();
}
/*****************************************************************************
* Private methods.
* Event Handlers.
*****************************************************************************/
void Interface::OnExit( wxCommandEvent& WXUNUSED(event) )
{
......@@ -387,3 +440,38 @@ void Interface::OnNextStream( wxCommandEvent& WXUNUSED(event) )
playlist_Next( p_playlist );
vlc_object_release( p_playlist );
}
/*****************************************************************************
* Definition of DragAndDrop class.
*****************************************************************************/
DragAndDrop::DragAndDrop( intf_thread_t *_p_intf )
{
p_intf = _p_intf;
}
bool DragAndDrop::OnDropFiles( wxCoord, wxCoord,
const wxArrayString& filenames )
{
unsigned int i;
/* Add dropped files to the playlist */
playlist_t *p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist == NULL )
{
return FALSE;
}
for( i = 0; i < filenames.GetCount(); i++ )
playlist_Add( p_playlist, (char *)filenames[i].c_str(),
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
/* Rebuild the playlist */
p_intf->p_sys->p_playlist_window->Rebuild();
vlc_object_release( p_playlist );
return TRUE;
}
......@@ -29,20 +29,20 @@
#include <string.h> /* strerror() */
#include <stdio.h>
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <wx/wxprec.h>
#include <wx/wx.h>
#include <wx/listctrl.h>
/* Let wxWindows take care of the i18n stuff */
/* Let vlc take care of the i18n stuff */
#undef _
#ifdef WIN32 /* mingw32 hack */
#undef Yield()
#undef CreateDialog()
#undef Yield
#undef CreateDialog
#endif
#include <wx/wxprec.h>
#include <wx/wx.h>
#include <wx/listctrl.h>
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include "wxwindows.h"
......@@ -143,6 +143,13 @@ Playlist::Playlist( intf_thread_t *_p_intf, Interface *_p_main_interface ):
main_sizer->Add( ok_button_sizer, 0, wxALIGN_CENTRE );
SetSizerAndFit( main_sizer );
/* Associate drop targets with the playlist */
SetDropTarget( new DragAndDrop( p_intf ) );
/* Update the playlist */
Rebuild();
}
Playlist::~Playlist()
......
......@@ -2,7 +2,7 @@
* timer.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: timer.cpp,v 1.3 2002/11/23 01:32:40 ipkiss Exp $
* $Id: timer.cpp,v 1.4 2002/11/23 14:28:51 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -29,10 +29,11 @@
#include <string.h> /* strerror() */
#include <stdio.h>
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <wx/wxprec.h>
#include <wx/wx.h>
#include <wx/timer.h>
/* Let wxWindows take care of the i18n stuff */
/* Let vlc take care of the i18n stuff */
#undef _
#ifdef WIN32 /* mingw32 hack */
......@@ -40,12 +41,13 @@
#undef CreateDialog
#endif
#include <wx/wxprec.h>
#include <wx/wx.h>
#include <wx/timer.h>
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include "wxwindows.h"
void DisplayStreamDate( wxControl *, intf_thread_t *, int );
/*****************************************************************************
* Constructor.
*****************************************************************************/
......@@ -94,7 +96,7 @@ static int wxSetupMenus( intf_thread_t * p_intf )
*****************************************************************************/
void Timer::Notify()
{
int i_start, i_stop;
int i_stop;
vlc_mutex_lock( &p_intf->change_lock );
......@@ -111,6 +113,7 @@ void Timer::Notify()
if( p_intf->p_sys->p_sub->i_start != i_stop )
{
/* Append all messages to log window */
}
/* Update the playlist */
......@@ -125,7 +128,11 @@ void Timer::Notify()
/* Show slider */
if(p_intf->p_sys->p_input)
{
p_main_interface->slider->Show();
p_main_interface->frame_sizer->Add(
p_main_interface->slider_frame, 1, wxGROW, 0 );
p_main_interface->slider_frame->Show();
p_main_interface->frame_sizer->Layout();
p_main_interface->frame_sizer->Fit( p_main_interface );
p_main_interface->statusbar->SetStatusText(
p_intf->p_sys->p_input->psz_source, 1 );
}
......@@ -134,7 +141,13 @@ void Timer::Notify()
{
/* Hide slider */
if(p_intf->p_sys->p_input)
p_main_interface->slider->Hide();
{
p_main_interface->slider_frame->Hide();
p_main_interface->frame_sizer->Remove(
p_main_interface->slider_frame );
p_main_interface->frame_sizer->Layout();
p_main_interface->frame_sizer->Fit( p_main_interface );
}
p_main_interface->statusbar->SetStatusText( "", 1 );
......@@ -174,7 +187,7 @@ void Timer::Notify()
input_Tell( p_input, &position );
vlc_mutex_lock( &p_input->stream.stream_lock );
p_intf->p_sys->i_slider_oldpos =
( 100 * position.i_tell ) / position.i_size;
( SLIDER_MAX_POS * position.i_tell ) / position.i_size;
if( p_intf->p_sys->i_slider_pos !=
p_intf->p_sys->i_slider_oldpos )
......@@ -184,6 +197,10 @@ void Timer::Notify()
p_main_interface->slider->SetValue(
p_intf->p_sys->i_slider_pos );
DisplayStreamDate( p_main_interface->slider_box,
p_intf,
p_intf->p_sys->i_slider_pos );
}
}
......@@ -193,7 +210,8 @@ void Timer::Notify()
{
/* release the lock to be able to seek */
vlc_mutex_unlock( &p_input->stream.stream_lock );
input_Seek( p_input, p_intf->p_sys->i_slider_pos,
input_Seek( p_input, p_intf->p_sys->i_slider_pos *
100 / SLIDER_MAX_POS,
INPUT_SEEK_PERCENT | INPUT_SEEK_SET );
vlc_mutex_lock( &p_input->stream.stream_lock );
......@@ -230,3 +248,26 @@ void Timer::Notify()
vlc_mutex_unlock( &p_intf->change_lock );
}
/*****************************************************************************
* DisplayStreamDate: display stream date
*****************************************************************************
* This function displays the current date related to the position in
* the stream. It is called whenever the slider changes its value.
* The lock has to be taken before you call the function.
*****************************************************************************/
void DisplayStreamDate( wxControl *p_slider_frame, intf_thread_t * p_intf ,
int i_pos )
{
if( p_intf->p_sys->p_input )
{
#define p_area p_intf->p_sys->p_input->stream.p_selected_area
char psz_time[ OFFSETTOTIME_MAX_SIZE ];
p_slider_frame->SetLabel(
input_OffsetToTime( p_intf->p_sys->p_input,
psz_time,
p_area->i_size * i_pos / SLIDER_MAX_POS ) );
#undef p_area
}
}
......@@ -2,7 +2,7 @@
* wxwindows.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: wxwindows.cpp,v 1.4 2002/11/23 01:32:40 ipkiss Exp $
* $Id: wxwindows.cpp,v 1.5 2002/11/23 14:28:51 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -29,10 +29,10 @@
#include <string.h> /* strerror() */
#include <stdio.h>
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <wx/wxprec.h>
#include <wx/wx.h>
/* Let wxWindows take care of the i18n stuff */
/* Let vlc take care of the i18n stuff */
#undef _
#ifdef WIN32 /* mingw32 hack */
......@@ -40,9 +40,8 @@
#undef CreateDialog
#endif
#include <wx/wxprec.h>
#include <wx/wx.h>
#include <wx/imagpng.h>
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include "wxwindows.h"
......@@ -67,6 +66,7 @@ public:
private:
intf_thread_t *p_intf;
wxLocale locale; /* locale we'll be using */
};
/*****************************************************************************
......@@ -175,6 +175,11 @@ IMPLEMENT_APP_NO_MAIN(Instance)
*****************************************************************************/
bool Instance::OnInit()
{
/* Initialization of i18n stuff.
* Usefull for things we don't have any control over, like wxWindows
* provided facilities (eg. open file dialog) */
locale.Init( wxLANGUAGE_DEFAULT );
/* Make an instance of your derived frame. Passing NULL (the default value
* of Frame's constructor is NULL) as the frame doesn't have a frame
* since it is the first window */
......
......@@ -2,7 +2,7 @@
* wxwindows.h: private wxWindows interface description
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: wxwindows.h,v 1.2 2002/11/23 01:32:40 ipkiss Exp $
* $Id: wxwindows.h,v 1.3 2002/11/23 14:28:51 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -22,9 +22,12 @@
*****************************************************************************/
#include <wx/listctrl.h>
#include <wx/dnd.h>
class Playlist;
#define SLIDER_MAX_POS 10000
/*****************************************************************************
* intf_sys_t: description and status of Gtk+ interface
*****************************************************************************/
......@@ -102,10 +105,19 @@ public:
/* Constructor */
Interface( intf_thread_t *p_intf );
virtual ~Interface();
wxSlider *slider;
wxBoxSizer *frame_sizer;
wxStatusBar *statusbar;
wxSlider *slider;
wxWindow *slider_frame;
wxStaticBox *slider_box;
private:
void CreateOurMenuBar();
void CreateOurToolBar();
void CreateOurSlider();
/* Event handlers (these functions should _not_ be virtual) */
void OnExit( wxCommandEvent& event );
void OnAbout( wxCommandEvent& event );
......@@ -153,3 +165,16 @@ private:
wxListView *listview;
wxButton *ok_button;
};
/* Drag and Drop class */
class DragAndDrop: public wxFileDropTarget
{
public:
DragAndDrop( intf_thread_t *_p_intf );
virtual bool OnDropFiles( wxCoord x, wxCoord y,
const wxArrayString& filenames );
private:
intf_thread_t *p_intf;
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment