]> git.sesse.net Git - vlc/blob - modules/gui/wxwidgets/interface.hpp
89615511c08cbbce23c361d25c880ae159960a40
[vlc] / modules / gui / wxwidgets / interface.hpp
1 /*****************************************************************************
2  * interface.hpp: Main interface headers
3  *****************************************************************************
4  * Copyright (C) 1999-2005 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Gildas Bazin <gbazin@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_INTERFACE_H_
25 #define _WXVLC_INTERFACE_H_
26
27 #include "wxwidgets.hpp"
28 #include "input_manager.hpp"
29
30 #include <wx/dnd.h>
31 #include <wx/accel.h>
32 #include <wx/taskbar.h>
33
34 class Splitter;
35
36 namespace wxvlc
37 {
38     class Timer;
39     class Interface;
40
41 #if wxUSE_DRAG_AND_DROP
42     /* Drag and Drop class */
43     class DragAndDrop: public wxFileDropTarget
44     {
45     public:
46         DragAndDrop( intf_thread_t *_p_intf, vlc_bool_t b_enqueue = VLC_FALSE );
47         virtual bool OnDropFiles( wxCoord x, wxCoord y,
48                                   const wxArrayString& filenames );
49
50     private:
51         intf_thread_t *p_intf;
52         vlc_bool_t b_enqueue;
53     };
54 #endif
55
56     /* Systray integration */
57 /* wxCocoa pretends to support this, but at least 2.6.x doesn't */
58 #ifndef __APPLE__
59 #ifdef wxHAS_TASK_BAR_ICON
60    class Systray: public wxTaskBarIcon
61    {
62    public:
63         Systray( Interface* p_main_interface, intf_thread_t *p_intf );
64         virtual ~Systray() {};
65         wxMenu* CreatePopupMenu();
66         void UpdateTooltip( const wxChar* tooltip );
67
68     private:
69         void OnMenuIconize( wxCommandEvent& event );
70         void OnLeftClick( wxTaskBarIconEvent& event );
71         void OnPlayStream ( wxCommandEvent& event );
72         void OnStopStream ( wxCommandEvent& event );
73         void OnPrevStream ( wxCommandEvent& event );
74         void OnNextStream ( wxCommandEvent& event );
75         void OnExit(  wxCommandEvent& event );
76         Interface* p_main_interface;
77         intf_thread_t *p_intf;
78         DECLARE_EVENT_TABLE()
79     };
80 #endif
81 #endif
82
83     /* Main Interface */
84     class Interface: public wxFrame
85     {
86     public:
87         /* Constructor */
88         Interface( intf_thread_t *p_intf, long style = wxDEFAULT_FRAME_STYLE );
89         virtual ~Interface();
90         void Init();
91         void TogglePlayButton( int i_playing_status );
92         void Update();
93         void PlayStream();
94         void StopStream();
95         void PrevStream();
96         void NextStream();
97
98         wxBoxSizer  *main_sizer;
99         Splitter    *splitter;
100
101         wxPanel     *main_panel;
102         wxBoxSizer  *panel_sizer;
103
104         wxStatusBar *statusbar;
105
106         InputManager *input_manager;
107
108         wxControl  *volctrl;
109
110     /* wxCocoa pretends to support this, but at least 2.6.x doesn't */
111     #ifndef __APPLE__
112     #ifdef wxHAS_TASK_BAR_ICON
113         Systray     *p_systray;
114     #endif
115     #endif
116
117         wxWindow *video_window;
118
119     private:
120         void SetupHotkeys();
121         void CreateOurMenuBar();
122         void CreateOurToolBar();
123         void CreateOurExtendedPanel();
124         void Open( int i_access_method );
125
126         void SetIntfMinSize();
127
128         /* Event handlers (these functions should _not_ be virtual) */
129         void OnExit( wxCommandEvent& event );
130         void OnAbout( wxCommandEvent& event );
131
132         void OnOpenFileSimple( wxCommandEvent& event );
133         void OnOpenDir( wxCommandEvent& event );
134         void OnOpenFile( wxCommandEvent& event );
135         void OnOpenDisc( wxCommandEvent& event );
136         void OnOpenNet( wxCommandEvent& event );
137         void OnOpenSat( wxCommandEvent& event );
138
139         void OnExtended( wxCommandEvent& event );
140         void OnSmallPlaylist( wxCommandEvent& event );
141
142         void OnBookmarks( wxCommandEvent& event );
143         void OnShowDialog( wxCommandEvent& event );
144         void OnPlayStream( wxCommandEvent& event );
145         void OnStopStream( wxCommandEvent& event );
146         void OnPrevStream( wxCommandEvent& event );
147         void OnNextStream( wxCommandEvent& event );
148         void OnSlowStream( wxCommandEvent& event );
149         void OnFastStream( wxCommandEvent& event );
150
151         void OnInteraction( wxCommandEvent& event );
152
153         void OnMenuOpen( wxMenuEvent& event );
154
155     #if defined( __WXMSW__ ) || defined( __WXMAC__ )
156         void OnContextMenu2(wxContextMenuEvent& event);
157     #endif
158         void OnContextMenu(wxMouseEvent& event);
159
160         void OnControlEvent( wxCommandEvent& event );
161
162         DECLARE_EVENT_TABLE();
163
164         Timer *timer;
165         intf_thread_t *p_intf;
166
167         int i_old_playing_status;
168
169         /* For auto-generated menus */
170         wxMenu *p_settings_menu;
171         wxMenu *p_audio_menu;
172         wxMenu *p_video_menu;
173         wxMenu *p_navig_menu;
174
175         /* Extended panel */
176         vlc_bool_t  b_extra;
177         wxPanel     *extra_frame;
178
179         /* Playlist panel */
180         wxPanel     *playlist_manager;
181
182         /* Utility dimensions */
183         wxSize main_min_size;
184         wxSize ext_min_size;
185     };
186
187
188     class WindowSettings
189     {
190     public:
191         WindowSettings( intf_thread_t *_p_intf );
192         virtual ~WindowSettings();
193         enum
194         {
195             ID_SCREEN = -1,
196             ID_MAIN,
197             ID_PLAYLIST,
198             ID_MESSAGES,
199             ID_FILE_INFO,
200             ID_BOOKMARKS,
201             ID_VIDEO,
202             ID_SMALL_PLAYLIST,
203             ID_MAX,
204         };
205
206         void SetSettings( int id, bool _b_shown,
207                     wxPoint p = wxDefaultPosition, wxSize s = wxDefaultSize );
208         bool GetSettings( int id, bool& _b_shown, wxPoint& p, wxSize& s );
209
210         void SetScreen( int i_screen_w, int i_screen_h );
211
212     private:
213         intf_thread_t *p_intf;
214
215         int     i_screen_w;
216         int     i_screen_h;
217         bool    b_valid[ID_MAX];
218         bool    b_shown[ID_MAX];
219         wxPoint position[ID_MAX];
220         wxSize  size[ID_MAX];
221     };
222
223
224     class MenuEvtHandler : public wxEvtHandler
225     {
226     public:
227         MenuEvtHandler( intf_thread_t *p_intf, Interface *p_main_interface );
228         virtual ~MenuEvtHandler();
229
230         void OnMenuEvent( wxCommandEvent& event );
231         void OnShowDialog( wxCommandEvent& event );
232
233     private:
234         DECLARE_EVENT_TABLE()
235
236         intf_thread_t *p_intf;
237         Interface *p_main_interface;
238     };
239 };
240
241 void PopupMenu( intf_thread_t *, wxWindow *, const wxPoint& );
242 void AudioPopupMenu( intf_thread_t *, wxWindow *, const wxPoint& );
243 void VideoPopupMenu( intf_thread_t *, wxWindow *, const wxPoint& );
244 void MiscPopupMenu( intf_thread_t *, wxWindow *, const wxPoint& );
245 wxMenu *SettingsMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
246 wxMenu *AudioMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
247 wxMenu *VideoMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
248 wxMenu *NavigMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
249
250 #endif