Commit 5eb9bd3a authored by Gildas Bazin's avatar Gildas Bazin

* modules/gui/wxwindows/open.cpp: New "open dialog" that mimics the one from the gtk interface.
* modules/gui/wxwindows/popup.cpp: Started implementing the popup menu.
* modules/gui/wxwindows/interface.cpp: Got rid of the pause button. The play button now acts as a
play/pause button depending on the context.
* modules/gui/wxwindows/*: A few hacks needed to make the win32 version useable.
parent 8f10d4fe
......@@ -2,6 +2,7 @@ SOURCES_wxwindows = \
modules/gui/wxwindows/wxwindows.cpp \
modules/gui/wxwindows/wxwindows.h \
modules/gui/wxwindows/interface.cpp \
modules/gui/wxwindows/open.cpp \
modules/gui/wxwindows/messages.cpp \
modules/gui/wxwindows/playlist.cpp \
modules/gui/wxwindows/popup.cpp \
......
This diff is collapsed.
This diff is collapsed.
......@@ -2,7 +2,7 @@
* popup.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: popup.cpp,v 1.1 2002/12/13 01:50:32 gbazin Exp $
* $Id: popup.cpp,v 1.2 2003/01/23 23:57:50 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -55,38 +55,85 @@
enum
{
/* menu items */
Close_Event = 1,
MenuEntry_Event,
MenuDummy_Event
Close_Event = wxID_HIGHEST,
MenuDummy_Event,
};
BEGIN_EVENT_TABLE(PopupMenu, wxMenu)
/* Menu events */
EVT_MENU(Close_Event, PopupMenu::OnClose)
EVT_MENU(MenuEntry_Event, PopupMenu::OnEntrySelected)
EVT_MENU(MenuDummy_Event, PopupMenu::OnEntrySelected)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(PopupEvtHandler, wxEvtHandler)
EVT_MENU(-1, PopupEvtHandler::OnMenuEvent)
END_EVENT_TABLE()
/*****************************************************************************
* Constructor.
*****************************************************************************/
PopupMenu::PopupMenu( intf_thread_t *_p_intf, Interface *_p_main_interface ):
wxMenu( "VideoLan" )
wxMenu( )
{
vlc_object_t *p_object;
/* Initializations */
p_intf = _p_intf;
p_main_interface = _p_main_interface;
i_item_id = 0;
/* Audio menu */
Append( MenuDummy_Event, _("Audio menu") );
AppendSeparator();
p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_AOUT,
FIND_ANYWHERE );
if( p_object == NULL ) return;
CreateMenuEntry( "audio-device", p_object );
CreateMenuEntry( "audio-channels", p_object );
vlc_object_release( p_object );
/* Video menu */
AppendSeparator();
Append( MenuDummy_Event, _("Video menu") );
AppendSeparator();
p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
FIND_ANYWHERE );
if( p_object == NULL ) return;
CreateMenuEntry( "fullscreen", p_object );
vlc_object_release( p_object );
Append(MenuEntry_Event, "Dummy1");
Append(MenuEntry_Event, "Dummy2");
Append(MenuDummy_Event, "&Dummy sub menu",
CreateDummyMenu(), "Dummy sub menu help");
Append(MenuEntry_Event, "Dummy3", "", TRUE);
/* Input menu */
AppendSeparator();
Append( MenuDummy_Event, _("Input menu") );
AppendSeparator();
p_object = (vlc_object_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
FIND_ANYWHERE );
if( p_object == NULL ) return;
CreateMenuEntry( "title", p_object );
CreateMenuEntry( "chapter", p_object );
vlc_object_release( p_object );
/* Misc stuff */
AppendSeparator();
Append( Close_Event, _("&Close") );
/* Intercept all menu events in our custom event handler */
p_main_interface->p_popup_menu = this;
p_main_interface->PushEventHandler(
new PopupEvtHandler( p_intf, p_main_interface ) );
wxPoint mousepos = wxGetMousePosition();
p_main_interface->PopupMenu( this, mousepos.x, mousepos.y );
p_main_interface->PopupMenu( this,
p_main_interface->ScreenToClient(mousepos).x,
p_main_interface->ScreenToClient(mousepos).y
);
}
PopupMenu::~PopupMenu()
......@@ -105,12 +152,163 @@ void PopupMenu::OnEntrySelected( wxCommandEvent& WXUNUSED(event) )
{
}
wxMenu *PopupMenu::CreateDummyMenu()
void PopupMenu::CreateMenuEntry( char *psz_var, vlc_object_t *p_object )
{
vlc_value_t val, val1;
int i_type;
/* Check the type of the object variable */
i_type = var_Type( p_object, psz_var );
if( i_type & VLC_VAR_HASCHOICE )
{
Append( MenuDummy_Event, psz_var,
CreateSubMenu( psz_var, p_object ),
"YEAAAARRRGGGHHH HEEELLPPPPPP" );
return;
}
if( var_Get( p_object, psz_var, &val ) < 0 )
{
return;
}
wxMenuItemExt *menuitem;
switch( i_type )
{
case VLC_VAR_VOID:
menuitem = new wxMenuItemExt( this, i_item_id++, psz_var,
"", wxITEM_NORMAL, strdup(psz_var),
p_object->i_object_id, val );
Append( menuitem );
break;
case VLC_VAR_BOOL:
val1.b_bool = !val.b_bool;
menuitem = new wxMenuItemExt( this, i_item_id++, psz_var,
"", wxITEM_CHECK, strdup(psz_var),
p_object->i_object_id, val1 );
Append( menuitem );
Check( i_item_id - 1, val.b_bool ? TRUE : FALSE );
break;
case VLC_VAR_STRING:
break;
default:
break;
}
}
wxMenu *PopupMenu::CreateSubMenu( char *psz_var, vlc_object_t *p_object )
{
wxMenu *menu = new wxMenu;
menu->Append(MenuEntry_Event, "Sub Dummy1");
menu->AppendSeparator();
menu->Append(MenuEntry_Event, "Sub Dummy2", "", TRUE);
vlc_value_t val;
char *psz_value;
int i_type, i;
/* Check the type of the object variable */
i_type = var_Type( p_object, psz_var );
switch( i_type )
{
case VLC_VAR_VOID:
case VLC_VAR_STRING:
break;
default:
break;
}
if( var_Get( p_object, psz_var, &val ) < 0 )
{
return NULL;
}
psz_value = val.psz_string;
if( var_Change( p_object, psz_var, VLC_VAR_GETLIST, &val ) < 0 )
{
return NULL;
}
for( i = 0; i < val.p_list->i_count; i++ )
{
vlc_value_t another_val;
wxMenuItemExt *menuitem;
switch( i_type & VLC_VAR_TYPE )
{
case VLC_VAR_STRING:
another_val.psz_string =
strdup(val.p_list->p_values[i].psz_string);
menuitem =
new wxMenuItemExt( this, i_item_id++, another_val.psz_string,
"", wxITEM_RADIO, strdup(psz_var),
p_object->i_object_id,
another_val );
menu->Append( menuitem );
if( !strcmp( psz_value, val.p_list->p_values[i].psz_string ) )
menu->Check( i_item_id - 1, TRUE );
break;
case VLC_VAR_INTEGER:
menuitem =
new wxMenuItemExt( this, i_item_id++,
wxString::Format(_("%d"),
val.p_list->p_values[i].i_int),
"", wxITEM_RADIO, strdup(psz_var),
p_object->i_object_id,
val.p_list->p_values[i] );
menu->Append( menuitem );
break;
default:
break;
}
}
var_Change( p_object, psz_var, VLC_VAR_FREELIST, &val );
return menu;
}
/*****************************************************************************
* A small helper class which intercepts all popup menu events
*****************************************************************************/
PopupEvtHandler::PopupEvtHandler( intf_thread_t *_p_intf,
Interface *_p_main_interface )
{
/* Initializations */
p_intf = _p_intf;
p_main_interface = _p_main_interface;
}
PopupEvtHandler::~PopupEvtHandler()
{
}
void PopupEvtHandler::OnMenuEvent( wxCommandEvent& event )
{
wxMenuItemExt *p_menuitem = (wxMenuItemExt *)
p_main_interface->p_popup_menu->FindItem( event.GetId() );
if( p_menuitem )
{
vlc_object_t *p_object;
p_object = (vlc_object_t *)vlc_object_get( p_intf,
p_menuitem->i_object_id );
if( p_object == NULL ) return;
var_Set( p_object, p_menuitem->psz_var, p_menuitem->val );
vlc_object_release( p_object );
}
else
event.Skip();
}
......@@ -2,7 +2,7 @@
* timer.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: timer.cpp,v 1.7 2002/12/15 18:37:39 ipkiss Exp $
* $Id: timer.cpp,v 1.8 2003/01/23 23:57:50 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -104,7 +104,8 @@ void Timer::Notify()
/* If the "display popup" flag has changed */
if( p_intf->b_menu_change )
{
new PopupMenu( p_intf, p_main_interface );
p_main_interface->p_popup_menu =
new PopupMenu( p_intf, p_main_interface );
p_intf->b_menu_change = 0;
}
......
......@@ -2,7 +2,7 @@
* wxwindows.cpp : wxWindows plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: wxwindows.cpp,v 1.9 2002/12/15 18:37:39 ipkiss Exp $
* $Id: wxwindows.cpp,v 1.10 2003/01/23 23:57:50 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -144,6 +144,16 @@ static void Close( vlc_object_t *p_this )
/*****************************************************************************
* Run: wxWindows thread
*****************************************************************************/
#if defined( WIN32 )
HINSTANCE hInstance = 0;
extern "C" BOOL WINAPI
DllMain (HANDLE hModule, DWORD fdwReason, LPVOID lpReserved)
{
hInstance = (HINSTANCE)hModule;
return TRUE;
}
#endif
static void Run( intf_thread_t *p_intf )
{
#if !defined( WIN32 )
......@@ -154,7 +164,7 @@ static void Run( intf_thread_t *p_intf )
wxTheApp = new Instance( p_intf );
#if defined( WIN32 )
wxEntry( GetModuleHandle(NULL), NULL, NULL, SW_SHOW, TRUE );
wxEntry( hInstance/*GetModuleHandle(NULL)*/, NULL, NULL, SW_SHOW, TRUE );
#else
wxEntry( 1, p_args );
#endif
......
......@@ -2,7 +2,7 @@
* wxwindows.h: private wxWindows interface description
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: wxwindows.h,v 1.7 2002/12/21 11:20:30 sigmunau Exp $
* $Id: wxwindows.h,v 1.8 2003/01/23 23:57:50 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -23,6 +23,8 @@
#include <wx/listctrl.h>
#include <wx/textctrl.h>
#include <wx/notebook.h>
#include <wx/spinctrl.h>
#include <wx/dnd.h>
class Playlist;
......@@ -116,10 +118,15 @@ public:
wxWindow *slider_frame;
wxStaticBox *slider_box;
wxMenu *p_popup_menu;
wxArrayString mrl_history;
private:
void CreateOurMenuBar();
void CreateOurToolBar();
void CreateOurSlider();
void Open( int i_access_method );
/* Event handlers (these functions should _not_ be virtual) */
void OnExit( wxCommandEvent& event );
......@@ -128,18 +135,98 @@ private:
void OnPlaylist( wxCommandEvent& event );
void OnLogs( wxCommandEvent& event );
void OnFileInfo( wxCommandEvent& event );
void OnOpenFile( wxCommandEvent& event );
void OnOpenDisc( wxCommandEvent& event );
void OnOpenNet( wxCommandEvent& event );
void OnOpenSat( wxCommandEvent& event );
void OnPlayStream( wxCommandEvent& event );
void OnStopStream( wxCommandEvent& event );
void OnPauseStream( wxCommandEvent& event );
void OnSliderUpdate( wxScrollEvent& event );
void OnPrevStream( wxCommandEvent& event );
void OnNextStream( wxCommandEvent& event );
void TogglePlayButton();
DECLARE_EVENT_TABLE();
Timer *timer;
intf_thread_t *p_intf;
int i_playing_status;
};
/* Open Dialog */
class OpenDialog: public wxDialog
{
public:
/* Constructor */
OpenDialog( intf_thread_t *p_intf, Interface *p_main_interface,
int i_access_method );
virtual ~OpenDialog();
void Rebuild();
void Manage();
wxString mrl;
private:
wxPanel *FilePanel( wxWindow* parent );
wxPanel *DiscPanel( wxWindow* parent );
wxPanel *NetPanel( wxWindow* parent );
wxPanel *SatPanel( wxWindow* parent );
void OpenDialog::UpdateMRL( int i_access_method );
/* Event handlers (these functions should _not_ be virtual) */
void OnOk( wxCommandEvent& event );
void OnCancel( wxCommandEvent& event );
void OnPageChange( wxNotebookEvent& event );
void OnMRLChange( wxCommandEvent& event );
/* Event handlers for the disc page */
void OnFilePanelChange( wxCommandEvent& event );
void OnFileBrowse( wxCommandEvent& event );
/* Event handlers for the disc page */
void OnDiscPanelChange( wxCommandEvent& event );
void OnDiscTypeChange( wxCommandEvent& event );
/* Event handlers for the net page */
void OnNetPanelChange( wxCommandEvent& event );
void OnNetTypeChange( wxCommandEvent& event );
DECLARE_EVENT_TABLE();
intf_thread_t *p_intf;
Interface *p_main_interface;
wxComboBox *mrl_combo;
/* Controls for the file panel */
wxComboBox *file_combo;
/* Controls for the disc panel */
wxRadioBox *disc_type;
wxTextCtrl *disc_device;
wxSpinCtrl *disc_title;
wxSpinCtrl *disc_chapter;
/* Controls for the net panel */
wxRadioBox *net_type;
int i_net_type;
wxPanel *net_subpanels[4];
wxRadioButton *net_radios[4];
wxSpinCtrl *net_ports[4];
wxTextCtrl *net_addrs[4];
};
enum
{
FILE_ACCESS = 0,
DISC_ACCESS,
NET_ACCESS,
SAT_ACCESS
};
/* Messages */
......@@ -241,9 +328,56 @@ private:
void OnEntrySelected( wxCommandEvent& event );
wxMenu *PopupMenu::CreateDummyMenu();
void PopupMenu::CreateMenuEntry( char *, vlc_object_t * );
wxMenu *PopupMenu::CreateSubMenu( char *, vlc_object_t * );
DECLARE_EVENT_TABLE();
intf_thread_t *p_intf;
Interface *p_main_interface;
int i_item_id;
};
class PopupEvtHandler : public wxEvtHandler
{
public:
PopupEvtHandler( intf_thread_t *p_intf, Interface *p_main_interface );
virtual ~PopupEvtHandler();
void PopupEvtHandler::OnMenuEvent( wxCommandEvent& event );
private:
DECLARE_EVENT_TABLE()
intf_thread_t *p_intf;
Interface *p_main_interface;
};
class wxMenuItemExt: public wxMenuItem
{
public:
/* Constructor */
wxMenuItemExt( wxMenu* parentMenu, int id,
const wxString& text,
const wxString& helpString,
wxItemKind kind,
char *_psz_var, int _i_object_id, vlc_value_t _val ):
wxMenuItem( parentMenu, id, text, helpString, kind )
{
/* Initializations */
psz_var = _psz_var;
i_object_id = _i_object_id;
val = _val;
};
virtual ~wxMenuItemExt() { if( psz_var ) free( psz_var ); };
char *psz_var;
int i_object_id;
vlc_value_t val;
private:
};
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