]> git.sesse.net Git - vlc/blob - modules/gui/wxwidgets/dialogs/playlist.hpp
Fix node insertion. Thanks to zorglub.
[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 #if wxUSE_DRAG_AND_DROP
49 , public wxFileDropTarget
50 #endif
51 {
52 public:
53     /* Constructor */
54     Playlist( intf_thread_t *p_intf, wxWindow *p_parent );
55     virtual ~Playlist();
56
57     void UpdatePlaylist();
58     void ShowPlaylist( bool show );
59     void UpdateItem( int );
60     void AppendItem( wxCommandEvent& );
61
62     bool b_need_update;
63     int  i_items_to_append;
64 #if wxUSE_DRAG_AND_DROP
65     virtual bool OnDropFiles( wxCoord x, wxCoord y,
66                               const wxArrayString& filenames );
67 #endif
68
69 private:
70     void RemoveItem( int );
71     void DeleteTreeItem( wxTreeItemId );
72     void DeleteItem( int item );
73     void DeleteNode( playlist_item_t *node );
74
75     void RecursiveDeleteSelection( wxTreeItemId );
76
77     /* Event handlers (these functions should _not_ be virtual) */
78
79     /* Menu Handlers */
80     void OnAddFile( wxCommandEvent& event );
81     void OnAddDir( wxCommandEvent& event );
82     void OnAddMRL( wxCommandEvent& event );
83     void OnMenuClose( wxCommandEvent& event );
84     void OnClose( wxCloseEvent& WXUNUSED(event) );
85
86     void OnDeleteSelection( wxCommandEvent& event );
87
88     void OnOpen( wxCommandEvent& event );
89     void OnSave( wxCommandEvent& event );
90
91     /* Search (user) */
92     void OnSearch( wxCommandEvent& event );
93     /*void OnSearchTextChange( wxCommandEvent& event );*/
94     wxTextCtrl *search_text;
95     wxButton *search_button;
96     wxTreeItemId search_current;
97
98     void OnEnDis( wxCommandEvent& event );
99
100     /* Sort */
101     int i_sort_mode;
102     void OnSort( wxCommandEvent& event );
103     int i_title_sorted;
104     int i_group_sorted;
105     int i_duration_sorted;
106
107     /* Dynamic menus */
108     void OnMenuEvent( wxCommandEvent& event );
109     void OnMenuOpen( wxMenuEvent& event );
110     wxMenu *p_view_menu;
111     wxMenu *p_sd_menu;
112     wxMenu *ViewMenu();
113     wxMenu *SDMenu();
114
115     void OnUp( wxCommandEvent& event);
116     void OnDown( wxCommandEvent& event);
117
118     void OnRandom( wxCommandEvent& event );
119     void OnRepeat( wxCommandEvent& event );
120     void OnLoop ( wxCommandEvent& event );
121
122     void OnActivateItem( wxTreeEvent& event );
123     void OnKeyDown( wxTreeEvent& event );
124     void OnNewGroup( wxCommandEvent& event );
125
126     void OnDragItemBegin( wxTreeEvent& event );
127     void OnDragItemEnd( wxTreeEvent& event );
128     wxTreeItemId draged_tree_item;
129
130     /* Popup  */
131     wxMenu *item_popup;
132     wxMenu *node_popup;
133     wxTreeItemId i_wx_popup_item;
134     int i_popup_item;
135     int i_popup_parent;
136     void OnPopup( wxContextMenuEvent& event );
137     void OnPopupPlay( wxCommandEvent& event );
138     void OnPopupPreparse( wxCommandEvent& event );
139     void OnPopupSort( wxCommandEvent& event );
140     void OnPopupDel( wxCommandEvent& event );
141     void OnPopupEna( wxCommandEvent& event );
142     void OnPopupInfo( wxCommandEvent& event );
143     void OnPopupAddNode( wxCommandEvent& event );
144     void Rebuild( vlc_bool_t );
145
146     void Preparse();
147
148     /* Update */
149     void UpdateNode( playlist_item_t*, wxTreeItemId );
150     void UpdateNodeChildren( playlist_item_t*, wxTreeItemId );
151     void CreateNode( playlist_item_t*, wxTreeItemId );
152     void UpdateTreeItem( wxTreeItemId );
153
154     /* Search (internal) */
155     int CountItems( wxTreeItemId);
156     wxTreeItemId FindItem( wxTreeItemId, int );
157     wxTreeItemId FindItemByName( wxTreeItemId, wxString,
158                                  wxTreeItemId, vlc_bool_t *);
159
160     wxTreeItemId saved_tree_item;
161     int i_saved_id;
162
163     playlist_t *p_playlist;
164
165
166     /* Custom events */
167     void OnPlaylistEvent( wxCommandEvent& event );
168
169     DECLARE_EVENT_TABLE();
170
171
172     /* Global widgets */
173     wxStatusBar *statusbar;
174     ItemInfoDialog *iteminfo_dialog;
175
176     int i_update_counter;
177
178     intf_thread_t *p_intf;
179     wxTreeCtrl *treectrl;
180     int i_current_view;
181     vlc_bool_t b_changed_view;
182     char **pp_sds;
183
184
185 };
186
187 } // end of wxvlc namespace
188
189 #endif