]> git.sesse.net Git - vlc/blob - modules/gui/wxwidgets/dialogs/playlist.hpp
Merge back branch 0.8.6-playlist-vlm to trunk.
[vlc] / modules / gui / wxwidgets / dialogs / playlist.hpp
1 /*****************************************************************************
2  * playlist.hpp: Header for the playlist
3  *****************************************************************************
4  * Copyright (C) 1999-2005 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 #ifndef _WXVLC_PLAYLIST_H_
25 #define _WXVLC_PLAYLIST_H_
26
27 #include "wxwidgets.hpp"
28
29 #include <wx/treectrl.h>
30 #include <wx/dnd.h>
31
32 #define MODE_NONE 0
33 #define MODE_GROUP 1
34 #define MODE_AUTHOR 2
35 #define MODE_TITLE 3
36
37 #define OPEN_NORMAL 0
38 #define OPEN_STREAM 1
39
40 namespace wxvlc
41 {
42 class ItemInfoDialog;
43 class NewGroup;
44 class ExportPlaylist;
45
46 /* Playlist */
47 class Playlist: public wxFrame
48 {
49 public:
50     /* Constructor */
51     Playlist( intf_thread_t *p_intf, wxWindow *p_parent );
52     virtual ~Playlist();
53
54     void UpdatePlaylist();
55     void ShowPlaylist( bool show );
56     void UpdateItem( int );
57     void AppendItem( wxCommandEvent& );
58
59     bool b_need_update;
60     int  i_items_to_append;
61
62     int GetCurrentView( ){ return i_current_view; };
63
64 private:
65     void RemoveItem( int );
66     void DeleteTreeItem( wxTreeItemId );
67     void DeleteItem( int item );
68     void DeleteNode( playlist_item_t *node );
69
70     void RecursiveDeleteSelection( wxTreeItemId );
71
72     /* Event handlers (these functions should _not_ be virtual) */
73
74     /* Menu Handlers */
75     void OnAddFile( wxCommandEvent& event );
76     void OnAddDir( wxCommandEvent& event );
77     void OnAddMRL( wxCommandEvent& event );
78     void OnMenuClose( wxCommandEvent& event );
79     void OnClose( wxCloseEvent& WXUNUSED(event) );
80
81     void OnDeleteSelection( wxCommandEvent& event );
82
83     void OnOpen( wxCommandEvent& event );
84     void OnSave( wxCommandEvent& event );
85
86     /* Search (user) */
87     void OnSearch( wxCommandEvent& event );
88     /*void OnSearchTextChange( wxCommandEvent& event );*/
89     wxTextCtrl *search_text;
90     wxButton *search_button;
91     wxTreeItemId search_current;
92
93     /* Sort */
94     int i_sort_mode;
95     void OnSort( wxCommandEvent& event );
96     int i_title_sorted;
97     int i_group_sorted;
98     int i_duration_sorted;
99
100     /* Dynamic menus */
101     void OnMenuEvent( wxCommandEvent& event );
102     void OnMenuOpen( wxMenuEvent& event );
103     wxMenu *p_view_menu;
104     wxMenu *p_sd_menu;
105     wxMenu *ViewMenu();
106     wxMenu *SDMenu();
107
108     void OnUp( wxCommandEvent& event);
109     void OnDown( wxCommandEvent& event);
110
111     void OnRandom( wxCommandEvent& event );
112     void OnRepeat( wxCommandEvent& event );
113     void OnLoop ( wxCommandEvent& event );
114
115     void OnActivateItem( wxTreeEvent& event );
116     void OnKeyDown( wxTreeEvent& event );
117     void OnNewGroup( wxCommandEvent& event );
118
119     void OnDragItemBegin( wxTreeEvent& event );
120     void OnDragItemEnd( wxTreeEvent& event );
121     wxTreeItemId draged_tree_item;
122
123     /* Popup  */
124     wxMenu *item_popup;
125     wxMenu *node_popup;
126     wxTreeItemId i_wx_popup_item;
127     int i_popup_item;
128     int i_popup_parent;
129     void OnPopup( wxContextMenuEvent& event );
130     void OnPopupPlay( wxCommandEvent& event );
131     void OnPopupPreparse( wxCommandEvent& event );
132     void OnPopupSort( wxCommandEvent& event );
133     void OnPopupDel( wxCommandEvent& event );
134     void OnPopupEna( wxCommandEvent& event );
135     void OnPopupInfo( wxCommandEvent& event );
136     void OnPopupAddNode( wxCommandEvent& event );
137
138     /* List */
139     void OnSourceSelected( wxListEvent &event );
140 protected:
141     void Rebuild( vlc_bool_t );
142 private:
143
144     void Preparse();
145
146     /* Update */
147     void UpdateNode( playlist_item_t*, wxTreeItemId );
148     void UpdateNodeChildren( playlist_item_t*, wxTreeItemId );
149     void CreateNode( playlist_item_t*, wxTreeItemId );
150     void UpdateTreeItem( wxTreeItemId );
151
152     /* Search (internal) */
153     int CountItems( wxTreeItemId);
154     wxTreeItemId FindItem( wxTreeItemId, int );
155     wxTreeItemId FindItemByInput( wxTreeItemId, int );
156     wxTreeItemId FindItemInner( wxTreeItemId, int , bool );
157     wxTreeItemId FindItemByName( wxTreeItemId, wxString,
158                                  wxTreeItemId, vlc_bool_t *);
159
160     wxTreeItemId saved_tree_item;
161     wxTreeItemId saved_input_tree_item;
162     int i_saved_id;
163     int i_saved_input_id;
164
165 protected:
166     playlist_t *p_playlist;
167
168 private:
169     /* Custom events */
170     void OnPlaylistEvent( wxCommandEvent& event );
171
172     DECLARE_EVENT_TABLE();
173
174
175     /* Global widgets */
176     wxStatusBar *statusbar;
177     ItemInfoDialog *iteminfo_dialog;
178
179     int i_update_counter;
180
181     vlc_bool_t b_changed_view;
182     char **pp_sds;
183
184 protected:
185     intf_thread_t *p_intf;
186     wxTreeCtrl *treectrl;
187     wxListView *source_sel;
188     int i_current_view;
189     playlist_item_t *p_current_treeroot;
190     playlist_item_t *p_current_viewroot;
191
192 friend class PlaylistFileDropTarget;
193 };
194
195 #if wxUSE_DRAG_AND_DROP
196 /* Playlist file drop target */
197 class PlaylistFileDropTarget: public wxFileDropTarget
198 {
199 public:
200     PlaylistFileDropTarget( Playlist * );
201     virtual bool OnDropFiles( wxCoord x, wxCoord y,
202                               const wxArrayString& filenames );
203 private:
204     Playlist *p;
205 };
206 #endif
207
208 } // end of wxvlc namespace
209
210 #endif