]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwindows/wxwindows.h
cdda/info.c: changes for libcddb 1.1.0 API
[vlc] / modules / gui / wxwindows / wxwindows.h
index a42df689902ab7a4d875aeba518d868b8c1f9315..5936b3ddf36c445b8132ac8fa0a590675af129ae 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * wxwindows.h: private wxWindows interface description
  *****************************************************************************
- * Copyright (C) 1999-2004 VideoLAN
+ * Copyright (C) 1999-2005 the VideoLAN team
  * $Id$
  *
  * Authors: Gildas Bazin <gbazin@videolan.org>
 #include <wx/accel.h>
 #include <wx/checkbox.h>
 #include <wx/wizard.h>
+#include <wx/taskbar.h>
 #include "vlc_keys.h"
 
-
-/* Hmmm, work-around for newest wxWin */
-#ifdef wxStaticCastEvent
-#   undef wxStaticCastEvent
-#   define wxStaticCastEvent(type, val) ((type)(val))
+#if (!wxCHECK_VERSION(2,5,0))
+typedef long wxTreeItemIdValue;
 #endif
 
 DECLARE_LOCAL_EVENT_TYPE( wxEVT_DIALOG, 0 );
@@ -67,9 +65,9 @@ DECLARE_LOCAL_EVENT_TYPE( wxEVT_INTF, 1 );
 
 #else // ENABLE_NLS && ENABLE_UTF8
 #if wxUSE_UNICODE
-#   define wxU(ansi) wxString(ansi, *wxConvCurrent)
+#   define wxU(ansi) wxString(ansi, wxConvLocal)
 #else
-#   define wxU(ansi) ansi
+#   define wxU(ansi) (ansi)
 #endif
 #define ISUTF8 0
 
@@ -77,11 +75,7 @@ DECLARE_LOCAL_EVENT_TYPE( wxEVT_INTF, 1 );
 
 /* wxL2U (locale to unicode) is used to convert ansi strings to unicode
  * strings (wchar_t) */
-#if wxUSE_UNICODE
-#   define wxL2U(ansi) wxString(ansi, *wxConvCurrent)
-#else
-#   define wxL2U(ansi) ansi
-#endif
+#define wxL2U(ansi) wxU(ansi)
 
 #define WRAPCOUNT 80
 
@@ -93,10 +87,16 @@ DECLARE_LOCAL_EVENT_TYPE( wxEVT_INTF, 1 );
 #define MODE_AUTHOR 2
 #define MODE_TITLE 3
 
+enum{
+  ID_CONTROLS_TIMER,
+  ID_SLIDER_TIMER,
+};
+
 class DialogsProvider;
 class PrefsTreeCtrl;
 class AutoBuiltPanel;
 class VideoWindow;
+class WindowSettings;
 
 /*****************************************************************************
  * intf_sys_t: description and status of wxwindows interface
@@ -107,6 +107,9 @@ struct intf_sys_t
     wxWindow            *p_wxwindow;
     wxIcon              *p_icon;
 
+    /* window settings */
+    WindowSettings      *p_window_settings;
+
     /* special actions */
     vlc_bool_t          b_playing;
     vlc_bool_t          b_intf_show;                /* interface to be shown */
@@ -124,6 +127,7 @@ struct intf_sys_t
 
     /* Playlist management */
     int                 i_playing;                 /* playlist selected item */
+    unsigned            i_playlist_usage;
 
     /* Send an event to show a dialog */
     void (*pf_show_dialog) ( intf_thread_t *p_intf, int i_dialog, int i_arg,
@@ -139,6 +143,7 @@ struct intf_sys_t
     /* Embedded vout */
     VideoWindow         *p_video_window;
     wxBoxSizer          *p_video_sizer;
+    vlc_bool_t          b_video_autosize;
 
     /* Aout */
     aout_instance_t     *p_aout;
@@ -148,7 +153,8 @@ struct intf_sys_t
  * Prototypes
  *****************************************************************************/
 wxArrayString SeparateEntries( wxString );
-wxWindow *VideoWindow( intf_thread_t *p_intf, wxWindow *p_parent );
+wxWindow *CreateVideoWindow( intf_thread_t *p_intf, wxWindow *p_parent );
+void UpdateVideoWindow( intf_thread_t *p_intf, wxWindow *p_window );
 wxWindow *BookmarksDialog( intf_thread_t *p_intf, wxWindow *p_parent );
 wxWindow *CreateDialogsProvider( intf_thread_t *p_intf, wxWindow *p_parent );
 
@@ -181,12 +187,14 @@ public:
     virtual void Notify();
 
 private:
+    //use wxWindow::IsShown instead
+    //vlc_bool_t b_slider_shown;
+    //vlc_bool_t b_disc_shown;
     intf_thread_t *p_intf;
     Interface *p_main_interface;
     vlc_bool_t b_init;
     int i_old_playing_status;
     int i_old_rate;
-    vlc_bool_t b_old_seekable;
 };
 
 
@@ -225,7 +233,10 @@ private:
 
     wxCheckBox *eq_2p_chkbox;
 
+    wxButton *eq_restoredefaults_button;
+
     wxSlider *smooth_slider;
+    wxStaticText *smooth_text;
 
     wxSlider *preamp_slider;
     wxStaticText * preamp_text;
@@ -287,31 +298,78 @@ private:
 };
 #endif
 
+/* Systray integration */
+#ifdef wxHAS_TASK_BAR_ICON
+class Systray: public wxTaskBarIcon
+{
+public:
+    Systray( Interface* p_main_interface, intf_thread_t *p_intf );
+    virtual ~Systray() {};
+    wxMenu* CreatePopupMenu();
+    void UpdateTooltip( const wxChar* tooltip );
+
+private:
+    void OnMenuIconize( wxCommandEvent& event );
+    void OnLeftClick( wxTaskBarIconEvent& event );
+    void OnPlayStream ( wxCommandEvent& event );
+    void OnStopStream ( wxCommandEvent& event );
+    void OnPrevStream ( wxCommandEvent& event );
+    void OnNextStream ( wxCommandEvent& event );
+    void OnExit(  wxCommandEvent& event );
+    Interface* p_main_interface;
+    intf_thread_t *p_intf;
+    DECLARE_EVENT_TABLE()
+};
+#endif
+
 /* Main Interface */
 class Interface: public wxFrame
 {
 public:
     /* Constructor */
-    Interface( intf_thread_t *p_intf );
+    Interface( intf_thread_t *p_intf, long style = wxDEFAULT_FRAME_STYLE );
     virtual ~Interface();
     void Init();
     void TogglePlayButton( int i_playing_status );
     void Update();
+    void PlayStream();
+    void StopStream();
+    void PrevStream();
+    void NextStream();
 
     wxBoxSizer  *frame_sizer;
     wxStatusBar *statusbar;
 
+    void HideSlider(bool layout = true);
+    void ShowSlider(bool show = true, bool layout = true);
+
     wxSlider    *slider;
     wxWindow    *slider_frame;
+    wxBoxSizer  *slider_sizer;
     wxPanel     *extra_frame;
 
+    void HideDiscFrame(bool layout = true);
+    void ShowDiscFrame(bool show = true, bool layout = true);
+
+    wxPanel         *disc_frame;
+    wxBoxSizer      *disc_sizer;
+    wxBitmapButton  *disc_menu_button;
+    wxBitmapButton  *disc_prev_button;
+    wxBitmapButton  *disc_next_button;
+
     wxFrame    *extra_window;
 
     vlc_bool_t b_extra;
     vlc_bool_t b_undock;
 
+    wxControl  *volctrl;
+
+#ifdef wxHAS_TASK_BAR_ICON
+    Systray     *p_systray;
+#endif
 
-    wxGauge     *volctrl;
+    wxTimer m_controls_timer;
+    wxTimer m_slider_timer;
 
 private:
     void SetupHotkeys();
@@ -322,10 +380,14 @@ private:
     void Open( int i_access_method );
 
     /* Event handlers (these functions should _not_ be virtual) */
+    void OnControlsTimer(wxTimerEvent& WXUNUSED(event));
+    void OnSliderTimer(wxTimerEvent& WXUNUSED(event));
+
     void OnExit( wxCommandEvent& event );
     void OnAbout( wxCommandEvent& event );
 
     void OnOpenFileSimple( wxCommandEvent& event );
+    void OnOpenDir( wxCommandEvent& event );
     void OnOpenFile( wxCommandEvent& event );
     void OnOpenDisc( wxCommandEvent& event );
     void OnOpenNet( wxCommandEvent& event );
@@ -344,6 +406,10 @@ private:
     void OnSlowStream( wxCommandEvent& event );
     void OnFastStream( wxCommandEvent& event );
 
+    void OnDiscMenu( wxCommandEvent& event );
+    void OnDiscPrev( wxCommandEvent& event );
+    void OnDiscNext( wxCommandEvent& event );
+
     void OnMenuOpen( wxMenuEvent& event );
 
 #if defined( __WXMSW__ ) || defined( __WXMAC__ )
@@ -358,7 +424,8 @@ private:
     Timer *timer;
     intf_thread_t *p_intf;
 
-private:
+    wxWindow *video_window;
+
     int i_old_playing_status;
 
     /* For auto-generated menus */
@@ -400,6 +467,7 @@ private:
     /* Event handlers (these functions should _not_ be virtual) */
     void OnOk( wxCommandEvent& event );
     void OnCancel( wxCommandEvent& event );
+    void OnClose( wxCloseEvent& event );
 
     void OnPageChange( wxNotebookEvent& event );
     void OnMRLChange( wxCommandEvent& event );
@@ -409,11 +477,16 @@ private:
     void OnFileBrowse( wxCommandEvent& event );
 
     /* Event handlers for the disc page */
+    void OnDiscPanelChangeSpin( wxSpinEvent& event );
     void OnDiscPanelChange( wxCommandEvent& event );
     void OnDiscTypeChange( wxCommandEvent& event );
+#ifdef HAVE_LIBCDIO
+    void OnDiscProbe( wxCommandEvent& event );
+#endif
     void OnDiscDeviceChange( wxCommandEvent& event );
 
     /* Event handlers for the net page */
+    void OnNetPanelChangeSpin( wxSpinEvent& event );
     void OnNetPanelChange( wxCommandEvent& event );
     void OnNetTypeChange( wxCommandEvent& event );
 
@@ -428,6 +501,7 @@ private:
     /* Event handlers for the caching option */
     void OnCachingEnable( wxCommandEvent& event );
     void OnCachingChange( wxCommandEvent& event );
+    void OnCachingChangeSpin( wxSpinEvent& event );
 
     DECLARE_EVENT_TABLE();
 
@@ -448,20 +522,23 @@ private:
 
     /* Controls for the disc panel */
     wxRadioBox *disc_type;
+    wxCheckBox *disc_probe;
     wxTextCtrl *disc_device;
     wxSpinCtrl *disc_title; int i_disc_title;
     wxSpinCtrl *disc_chapter; int i_disc_chapter;
     wxSpinCtrl *disc_sub; int i_disc_sub;
+    wxSpinCtrl *disc_audio; int i_disc_audio;
 
     /* The media equivalent name for a DVD names. For example,
      * "Title", is "Track" for a CD-DA */
     wxStaticText *disc_title_label;
     wxStaticText *disc_chapter_label;
     wxStaticText *disc_sub_label;
-    
+    wxStaticText *disc_audio_label;
+
     /* Indicates if the disc device control was modified */
     bool b_disc_device_changed;
-    
+
     /* Controls for the net panel */
     wxRadioBox *net_type;
     int i_net_type;
@@ -470,6 +547,7 @@ private:
     wxSpinCtrl *net_ports[4];
     int        i_net_ports[4];
     wxTextCtrl *net_addrs[4];
+    wxCheckBox *net_timeshift;
     wxCheckBox *net_ipv6;
 
     /* Controls for the subtitles file */
@@ -509,7 +587,6 @@ enum
     HTTP_ACCESS_OUT,
     MMSH_ACCESS_OUT,
     UDP_ACCESS_OUT,
-    RTP_ACCESS_OUT,
     ACCESS_OUT_NUM
 };
 
@@ -566,6 +643,7 @@ private:
     void OnNetChange( wxCommandEvent& event );
 
     /* Event specific to the announce address */
+    void OnAnnounceGroupChange( wxCommandEvent& event );
     void OnAnnounceAddrChange( wxCommandEvent& event );
 
     /* Event handlers for the encapsulation panel */
@@ -603,6 +681,7 @@ private:
     wxPanel *misc_subpanels[MISC_SOUT_NUM];
     wxCheckBox *sap_checkbox;
     wxCheckBox *slp_checkbox;
+    wxTextCtrl *announce_group;
     wxTextCtrl *announce_addr;
 
     /* Controls for the encapsulation */
@@ -620,6 +699,12 @@ private:
     wxComboBox *audio_bitrate_combo;
     wxComboBox *audio_channels_combo;
     wxComboBox *video_scale_combo;
+    wxComboBox *subtitles_codec_combo;
+    wxCheckBox *subtitles_transc_checkbox;
+    wxCheckBox *subtitles_overlay_checkbox;
+
+    /* Misc controls */
+    wxCheckBox *sout_all_checkbox;
 };
 
 /* Subtitles File Dialog */
@@ -682,18 +767,18 @@ class WizardDialog : public wxWizard
 {
 public:
     /* Constructor */
-    WizardDialog( intf_thread_t *p_intf, wxWindow *p_parent,char *, int, int );
+    WizardDialog( intf_thread_t *, wxWindow *p_parent, char *, int, int );
     virtual ~WizardDialog();
-    void SetTranscode( char *vcodec, int vb, char *acodec,int ab);
+    void SetTranscode( char const *vcodec, int vb, char const *acodec, int ab);
     void SetMrl( const char *mrl );
     void SetTTL( int i_ttl );
     void SetPartial( int, int );
-    void SetStream( char *method, char *address );
-    void SetTranscodeOut( char *address );
+    void SetStream( char const *method, char const *address );
+    void SetTranscodeOut( char const *address );
     void SetAction( int i_action );
     int  GetAction();
     void SetSAP( bool b_enabled, const char *psz_name );
-    void SetMux( char *mux );
+    void SetMux( char const *mux );
     void Run();
     int i_action;
     char *method;
@@ -727,6 +812,7 @@ private:
     void OnSave( wxCommandEvent& event );
     void OnResetAll( wxCommandEvent& event );
     void OnAdvanced( wxCommandEvent& event );
+    void OnClose( wxCloseEvent& event );
 
     DECLARE_EVENT_TABLE();
 
@@ -747,7 +833,8 @@ public:
 
 private:
     /* Event handlers (these functions should _not_ be virtual) */
-    void OnClose( wxCommandEvent& event );
+    void OnButtonClose( wxCommandEvent& event );
+    void OnClose( wxCloseEvent& WXUNUSED(event) );
     void OnClear( wxCommandEvent& event );
     void OnSaveLog( wxCommandEvent& event );
 
@@ -776,43 +863,59 @@ public:
     void UpdatePlaylist();
     void ShowPlaylist( bool show );
     void UpdateItem( int );
+    void AppendItem( wxCommandEvent& );
 
     bool b_need_update;
 
 private:
+    void RemoveItem( int );
+    void DeleteTreeItem( wxTreeItemId );
     void DeleteItem( int item );
-    void ShowInfos( int item );
+    void DeleteNode( playlist_item_t *node );
 
-    /* Event handlers (these functions should _not_ be virtual) */
+    void RecursiveDeleteSelection( wxTreeItemId );
 
-    void OnSize( wxSizeEvent &event );
+    /* Event handlers (these functions should _not_ be virtual) */
 
     /* Menu Handlers */
     void OnAddFile( wxCommandEvent& event );
+    void OnAddDir( wxCommandEvent& event );
     void OnAddMRL( wxCommandEvent& event );
-    void OnClose( wxCommandEvent& event );
-    void OnSearch( wxCommandEvent& event );
-    void OnEnDis( wxCommandEvent& event );
-    void OnInfos( wxCommandEvent& event );
-    void OnSearchTextChange( wxCommandEvent& event );
+    void OnMenuClose( wxCommandEvent& event );
+    void OnClose( wxCloseEvent& WXUNUSED(event) );
+
+    void OnDeleteSelection( wxCommandEvent& event );
+
     void OnOpen( wxCommandEvent& event );
     void OnSave( wxCommandEvent& event );
 
+    /* Search (user) */
+    void OnSearch( wxCommandEvent& event );
+    /*void OnSearchTextChange( wxCommandEvent& event );*/
+    wxTextCtrl *search_text;
+    wxButton *search_button;
+    wxTreeItemId search_current;
+
+    void OnEnDis( wxCommandEvent& event );
+
+    /* Sort */
+    int i_sort_mode;
     void OnSort( wxCommandEvent& event );
+    int i_title_sorted;
+    int i_group_sorted;
+    int i_duration_sorted;
 
+    /* Dynamic menus */
     void OnMenuEvent( wxCommandEvent& event );
     void OnMenuOpen( wxMenuEvent& event );
-
+    wxMenu *p_view_menu;
+    wxMenu *p_sd_menu;
     wxMenu *ViewMenu();
+    wxMenu *SDMenu();
 
     void OnUp( wxCommandEvent& event);
     void OnDown( wxCommandEvent& event);
 
-    void OnEnableSelection( wxCommandEvent& event );
-    void OnDisableSelection( wxCommandEvent& event );
-    void OnInvertSelection( wxCommandEvent& event );
-    void OnDeleteSelection( wxCommandEvent& event );
-    void OnSelectAll( wxCommandEvent& event );
     void OnRandom( wxCommandEvent& event );
     void OnRepeat( wxCommandEvent& event );
     void OnLoop ( wxCommandEvent& event );
@@ -821,50 +924,60 @@ private:
     void OnKeyDown( wxTreeEvent& event );
     void OnNewGroup( wxCommandEvent& event );
 
-    /* Popup functions */
+    /* Popup  */
+    wxMenu *item_popup;
+    wxMenu *node_popup;
+    wxTreeItemId i_wx_popup_item;
+    int i_popup_item;
+    int i_popup_parent;
     void OnPopup( wxContextMenuEvent& event );
-    void OnPopupPlay( wxMenuEvent& event );
-    void OnPopupDel( wxMenuEvent& event );
-    void OnPopupEna( wxMenuEvent& event );
-    void OnPopupInfo( wxMenuEvent& event );
-    void Rebuild();
+    void OnPopupPlay( wxCommandEvent& event );
+    void OnPopupPreparse( wxCommandEvent& event );
+    void OnPopupSort( wxCommandEvent& event );
+    void OnPopupDel( wxCommandEvent& event );
+    void OnPopupEna( wxCommandEvent& event );
+    void OnPopupInfo( wxCommandEvent& event );
+    void Rebuild( vlc_bool_t );
+
+    void Preparse();
 
     /* Update */
-    void UpdateNode( playlist_t *, playlist_item_t*, wxTreeItemId );
-    void CreateNode( playlist_t *, playlist_item_t*, wxTreeItemId );
+    void UpdateNode( playlist_item_t*, wxTreeItemId );
+    void UpdateNodeChildren( playlist_item_t*, wxTreeItemId );
+    void CreateNode( playlist_item_t*, wxTreeItemId );
+    void UpdateTreeItem( wxTreeItemId );
+
+    /* Search (internal) */
+    int CountItems( wxTreeItemId);
+    wxTreeItemId FindItem( wxTreeItemId, int );
+    wxTreeItemId FindItemByName( wxTreeItemId, wxString,
+                                 wxTreeItemId, vlc_bool_t *);
+
+    wxTreeItemId saved_tree_item;
+    int i_saved_id;
+
+    playlist_t *p_playlist;
 
-    wxTreeItemId FindItem( wxTreeItemId, playlist_item_t * );
-    void SetCurrentItem( wxTreeItemId );
-    void UpdateTreeItem( playlist_t *, wxTreeItemId );
 
     /* Custom events */
     void OnPlaylistEvent( wxCommandEvent& event );
 
-    wxTextCtrl *search_text;
-    wxButton *search_button;
     DECLARE_EVENT_TABLE();
 
-    wxMenu *popup_menu;
-
-    wxMenu *p_view_menu;
 
+    /* Global widgets */
+    wxStatusBar *statusbar;
     ItemInfoDialog *iteminfo_dialog;
 
-    intf_thread_t *p_intf;
-    wxTreeCtrl *treectrl;
     int i_update_counter;
-    int i_sort_mode;
 
+    intf_thread_t *p_intf;
+    wxTreeCtrl *treectrl;
     int i_current_view;
+    vlc_bool_t b_changed_view;
+    char **pp_sds;
 
-    wxTreeItemId i_popup_item;
-    playlist_item_t *p_popup_item;
-    playlist_item_t *p_popup_parent;
 
-    int i_title_sorted;
-    int i_author_sorted;
-    int i_group_sorted;
-    int i_duration_sorted;
 };
 
 /* ItemInfo Dialog */
@@ -903,12 +1016,10 @@ private:
 
     wxTextCtrl *uri_text;
     wxTextCtrl *name_text;
-    wxTextCtrl *author_text;
 
     wxTreeCtrl *info_tree;
     wxTreeItemId info_root;
 
-    wxCheckBox *enabled_checkbox;
 };
 
 
@@ -924,7 +1035,8 @@ public:
     vlc_bool_t b_need_update;
 
 private:
-    void OnClose( wxCommandEvent& event );
+    void OnButtonClose( wxCommandEvent& event );
+    void OnClose( wxCloseEvent& WXUNUSED(event) );
 
     DECLARE_EVENT_TABLE();
 
@@ -933,7 +1045,6 @@ private:
     wxTreeItemId fileinfo_root;
     wxString fileinfo_root_label;
 
-
 };
 
 #if wxUSE_DRAG_AND_DROP
@@ -953,6 +1064,42 @@ private:
 #endif
 } // end of wxvlc namespace
 
+/* */
+class WindowSettings
+{
+public:
+    WindowSettings( intf_thread_t *_p_intf );
+    virtual ~WindowSettings();
+    enum
+    {
+        ID_SCREEN = -1,
+        ID_MAIN,
+        ID_PLAYLIST,
+        ID_MESSAGES,
+        ID_FILE_INFO,
+        ID_BOOKMARKS,
+        ID_VIDEO,
+
+        ID_MAX,
+    };
+
+    void SetSettings( int id, bool _b_shown,
+                      wxPoint p = wxDefaultPosition, wxSize s = wxDefaultSize );
+    bool GetSettings( int id, bool& _b_shown, wxPoint& p, wxSize& s );
+
+    void SetScreen( int i_screen_w, int i_screen_h );
+
+private:
+    intf_thread_t *p_intf;
+
+    int     i_screen_w;
+    int     i_screen_h;
+    bool    b_valid[ID_MAX];
+    bool    b_shown[ID_MAX];
+    wxPoint position[ID_MAX];
+    wxSize  size[ID_MAX];
+};
+
 /* Menus */
 void PopupMenu( intf_thread_t *, wxWindow *, const wxPoint& );
 wxMenu *SettingsMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
@@ -980,4 +1127,24 @@ private:
 };
 
 } // end of wxvlc namespace
+
+
+/*
+ * wxWindows keeps dead locking because the timer tries to lock the playlist
+ * when it's already locked somewhere else in the very wxWindows interface
+ * module. Unless someone implements a "vlc_mutex_trylock", we need that.
+ */
+inline void LockPlaylist( intf_sys_t *p_sys, playlist_t *p_pl )
+{
+    if( p_sys->i_playlist_usage++ == 0)
+        vlc_mutex_lock( &p_pl->object_lock );
+}
+
+inline void UnlockPlaylist( intf_sys_t *p_sys, playlist_t *p_pl )
+{
+    if( --p_sys->i_playlist_usage == 0)
+        vlc_mutex_unlock( &p_pl->object_lock );
+}
+
 using namespace wxvlc;
+