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