]> git.sesse.net Git - vlc/blob - modules/gui/wxwidgets/dialogs/playlist.hpp
- Undo [14667]
[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     void OnEnDis( wxCommandEvent& event );
94
95     /* Sort */
96     int i_sort_mode;
97     void OnSort( wxCommandEvent& event );
98     int i_title_sorted;
99     int i_group_sorted;
100     int i_duration_sorted;
101
102     /* Dynamic menus */
103     void OnMenuEvent( wxCommandEvent& event );
104     void OnMenuOpen( wxMenuEvent& event );
105     wxMenu *p_view_menu;
106     wxMenu *p_sd_menu;
107     wxMenu *ViewMenu();
108     wxMenu *SDMenu();
109
110     void OnUp( wxCommandEvent& event);
111     void OnDown( wxCommandEvent& event);
112
113     void OnRandom( wxCommandEvent& event );
114     void OnRepeat( wxCommandEvent& event );
115     void OnLoop ( wxCommandEvent& event );
116
117     void OnActivateItem( wxTreeEvent& event );
118     void OnKeyDown( wxTreeEvent& event );
119     void OnNewGroup( wxCommandEvent& event );
120
121     void OnDragItemBegin( wxTreeEvent& event );
122     void OnDragItemEnd( wxTreeEvent& event );
123     wxTreeItemId draged_tree_item;
124
125     /* Popup  */
126     wxMenu *item_popup;
127     wxMenu *node_popup;
128     wxTreeItemId i_wx_popup_item;
129     int i_popup_item;
130     int i_popup_parent;
131     void OnPopup( wxContextMenuEvent& event );
132     void OnPopupPlay( wxCommandEvent& event );
133     void OnPopupPreparse( wxCommandEvent& event );
134     void OnPopupSort( wxCommandEvent& event );
135     void OnPopupDel( wxCommandEvent& event );
136     void OnPopupEna( wxCommandEvent& event );
137     void OnPopupInfo( wxCommandEvent& event );
138     void OnPopupAddNode( wxCommandEvent& event );
139 protected:
140     void Rebuild( vlc_bool_t );
141 private:
142
143     void Preparse();
144
145     /* Update */
146     void UpdateNode( playlist_item_t*, wxTreeItemId );
147     void UpdateNodeChildren( playlist_item_t*, wxTreeItemId );
148     void CreateNode( playlist_item_t*, wxTreeItemId );
149     void UpdateTreeItem( wxTreeItemId );
150
151     /* Search (internal) */
152     int CountItems( wxTreeItemId);
153     wxTreeItemId FindItem( wxTreeItemId, int );
154     wxTreeItemId FindItemByName( wxTreeItemId, wxString,
155                                  wxTreeItemId, vlc_bool_t *);
156
157     wxTreeItemId saved_tree_item;
158     int i_saved_id;
159
160 protected:
161     playlist_t *p_playlist;
162
163 private:
164     /* Custom events */
165     void OnPlaylistEvent( wxCommandEvent& event );
166
167     DECLARE_EVENT_TABLE();
168
169
170     /* Global widgets */
171     wxStatusBar *statusbar;
172     ItemInfoDialog *iteminfo_dialog;
173
174     int i_update_counter;
175
176     vlc_bool_t b_changed_view;
177     char **pp_sds;
178
179 protected:
180     intf_thread_t *p_intf;
181     wxTreeCtrl *treectrl;
182     int i_current_view;
183
184 friend class PlaylistFileDropTarget;
185 };
186
187 #if wxUSE_DRAG_AND_DROP
188 /* Playlist file drop target */
189 class PlaylistFileDropTarget: public wxFileDropTarget
190 {
191 public:
192     PlaylistFileDropTarget( Playlist * );
193     virtual bool OnDropFiles( wxCoord x, wxCoord y,
194                               const wxArrayString& filenames );
195 private:
196     Playlist *p;
197 };
198 #endif
199
200 } // end of wxvlc namespace
201
202 #endif