]> git.sesse.net Git - vlc/blob - modules/gui/wxwidgets/dialogs/playlist.hpp
update module LIST file.
[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/listctrl.h>
30 #include <wx/treectrl.h>
31 #include <wx/dnd.h>
32
33 #define MODE_NONE 0
34 #define MODE_GROUP 1
35 #define MODE_AUTHOR 2
36 #define MODE_TITLE 3
37
38 #define OPEN_NORMAL 0
39 #define OPEN_STREAM 1
40
41 namespace wxvlc
42 {
43 class ItemInfoDialog;
44 class NewGroup;
45 class ExportPlaylist;
46
47 /* Playlist */
48 class Playlist: public wxFrame
49 {
50 public:
51     /* Constructor */
52     Playlist( intf_thread_t *p_intf, wxWindow *p_parent );
53     virtual ~Playlist();
54
55     void UpdatePlaylist();
56     void ShowPlaylist( bool show );
57     void UpdateItem( int );
58     void AppendItem( wxCommandEvent& );
59
60     bool b_need_update;
61     int  i_items_to_append;
62
63     int GetCurrentView( ){ return i_current_view; };
64
65 private:
66     void RemoveItem( int );
67     void DeleteTreeItem( wxTreeItemId );
68     void DeleteItem( int item );
69     void DeleteNode( playlist_item_t *node );
70
71     void RecursiveDeleteSelection( wxTreeItemId );
72
73     /* Event handlers (these functions should _not_ be virtual) */
74
75     /* Menu Handlers */
76     void OnAddFile( wxCommandEvent& event );
77     void OnAddDir( wxCommandEvent& event );
78     void OnAddMRL( wxCommandEvent& event );
79     void OnMenuClose( wxCommandEvent& event );
80     void OnClose( wxCloseEvent& WXUNUSED(event) );
81
82     void OnDeleteSelection( wxCommandEvent& event );
83
84     void OnOpen( wxCommandEvent& event );
85     void OnSave( wxCommandEvent& event );
86
87     /* Search (user) */
88     void OnSearch( wxCommandEvent& event );
89     /*void OnSearchTextChange( wxCommandEvent& event );*/
90     wxTextCtrl *search_text;
91     wxButton *search_button;
92     wxTreeItemId search_current;
93
94     /* Sort */
95     int i_sort_mode;
96     void OnSort( wxCommandEvent& event );
97     int i_title_sorted;
98     int i_group_sorted;
99     int i_duration_sorted;
100
101     /* Dynamic menus */
102     void OnMenuEvent( wxCommandEvent& event );
103     void OnMenuOpen( wxMenuEvent& event );
104     wxMenu *p_view_menu;
105     wxMenu *p_sd_menu;
106     wxMenu *ViewMenu();
107     wxMenu *SDMenu();
108
109     void OnUp( wxCommandEvent& event);
110     void OnDown( wxCommandEvent& event);
111
112     void OnRandom( wxCommandEvent& event );
113     void OnRepeat( wxCommandEvent& event );
114     void OnLoop ( wxCommandEvent& event );
115
116     void OnActivateItem( wxTreeEvent& event );
117     void OnKeyDown( wxTreeEvent& event );
118     void OnNewGroup( wxCommandEvent& event );
119
120     void OnDragItemBegin( wxTreeEvent& event );
121     void OnDragItemEnd( wxTreeEvent& event );
122     wxTreeItemId draged_tree_item;
123
124     /* Popup  */
125     wxMenu *item_popup;
126     wxMenu *node_popup;
127     wxTreeItemId i_wx_popup_item;
128     int i_popup_item;
129     int i_popup_parent;
130     void OnPopup( wxContextMenuEvent& event );
131     void OnPopupPlay( wxCommandEvent& event );
132     void OnPopupPreparse( wxCommandEvent& event );
133     void OnPopupSort( wxCommandEvent& event );
134     void OnPopupDel( wxCommandEvent& event );
135     void OnPopupEna( wxCommandEvent& event );
136     void OnPopupInfo( wxCommandEvent& event );
137     void OnPopupAddNode( wxCommandEvent& event );
138
139     /* List */
140     void OnSourceSelected( wxListEvent &event );
141 protected:
142     void Rebuild( vlc_bool_t );
143 private:
144
145     void Preparse();
146
147     /* Update */
148     void UpdateNode( playlist_item_t*, wxTreeItemId );
149     void UpdateNodeChildren( playlist_item_t*, wxTreeItemId );
150     void CreateNode( playlist_item_t*, wxTreeItemId );
151     void UpdateTreeItem( wxTreeItemId );
152
153     /* Search (internal) */
154     int CountItems( wxTreeItemId);
155     wxTreeItemId FindItem( wxTreeItemId, int );
156     wxTreeItemId FindItemByInput( wxTreeItemId, int );
157     wxTreeItemId FindItemInner( wxTreeItemId, int , bool );
158     wxTreeItemId FindItemByName( wxTreeItemId, wxString,
159                                  wxTreeItemId, vlc_bool_t *);
160
161     wxTreeItemId saved_tree_item;
162     wxTreeItemId saved_input_tree_item;
163     int i_saved_id;
164     int i_saved_input_id;
165
166 protected:
167     playlist_t *p_playlist;
168
169 private:
170     /* Custom events */
171     void OnPlaylistEvent( wxCommandEvent& event );
172
173     DECLARE_EVENT_TABLE();
174
175
176     /* Global widgets */
177     wxStatusBar *statusbar;
178     ItemInfoDialog *iteminfo_dialog;
179
180     int i_update_counter;
181
182     vlc_bool_t b_changed_view;
183     const char **pp_sds;
184
185 protected:
186     intf_thread_t *p_intf;
187     wxTreeCtrl *treectrl;
188     wxListView *source_sel;
189     int i_current_view;
190     playlist_item_t *p_current_treeroot;
191     playlist_item_t *p_current_viewroot;
192
193 friend class PlaylistFileDropTarget;
194 };
195
196 #if wxUSE_DRAG_AND_DROP
197 /* Playlist file drop target */
198 class PlaylistFileDropTarget: public wxFileDropTarget
199 {
200 public:
201     PlaylistFileDropTarget( Playlist * );
202     virtual bool OnDropFiles( wxCoord x, wxCoord y,
203                               const wxArrayString& filenames );
204 private:
205     Playlist *p;
206 };
207 #endif
208
209 } // end of wxvlc namespace
210
211 #endif