]> git.sesse.net Git - vlc/blob - modules/gui/wxwidgets/interface.hpp
Replace function callback by variable callback.
[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., 59 Temple Place - Suite 330, Boston, MA  02111, 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 #ifdef wxHAS_TASK_BAR_ICON
58    class Systray: public wxTaskBarIcon
59    {
60    public:
61         Systray( Interface* p_main_interface, intf_thread_t *p_intf );
62         virtual ~Systray() {};
63         wxMenu* CreatePopupMenu();
64         void UpdateTooltip( const wxChar* tooltip );
65
66     private:
67         void OnMenuIconize( wxCommandEvent& event );
68         void OnLeftClick( wxTaskBarIconEvent& event );
69         void OnPlayStream ( wxCommandEvent& event );
70         void OnStopStream ( wxCommandEvent& event );
71         void OnPrevStream ( wxCommandEvent& event );
72         void OnNextStream ( wxCommandEvent& event );
73         void OnExit(  wxCommandEvent& event );
74         Interface* p_main_interface;
75         intf_thread_t *p_intf;
76         DECLARE_EVENT_TABLE()
77     };
78 #endif
79
80     /* Main Interface */
81     class Interface: public wxFrame
82     {
83     public:
84         /* Constructor */
85         Interface( intf_thread_t *p_intf, long style = wxDEFAULT_FRAME_STYLE );
86         virtual ~Interface();
87         void Init();
88         void TogglePlayButton( int i_playing_status );
89         void Update();
90         void PlayStream();
91         void StopStream();
92         void PrevStream();
93         void NextStream();
94
95         wxBoxSizer  *main_sizer;
96         Splitter    *splitter;
97
98         wxPanel     *main_panel;
99         wxBoxSizer  *panel_sizer;
100
101         wxStatusBar *statusbar;
102
103         InputManager *input_manager;
104
105         wxControl  *volctrl;
106
107     #ifdef wxHAS_TASK_BAR_ICON
108         Systray     *p_systray;
109     #endif
110
111         wxWindow *video_window;
112
113     private:
114         void SetupHotkeys();
115         void CreateOurMenuBar();
116         void CreateOurToolBar();
117         void CreateOurExtendedPanel();
118         void Open( int i_access_method );
119
120         void SetIntfMinSize();
121
122         /* Event handlers (these functions should _not_ be virtual) */
123         void OnExit( wxCommandEvent& event );
124         void OnAbout( wxCommandEvent& event );
125
126         void OnOpenFileSimple( wxCommandEvent& event );
127         void OnOpenDir( wxCommandEvent& event );
128         void OnOpenFile( wxCommandEvent& event );
129         void OnOpenDisc( wxCommandEvent& event );
130         void OnOpenNet( wxCommandEvent& event );
131         void OnOpenSat( wxCommandEvent& event );
132
133         void OnExtended( wxCommandEvent& event );
134         void OnSmallPlaylist( wxCommandEvent& event );
135
136         void OnBookmarks( wxCommandEvent& event );
137         void OnShowDialog( wxCommandEvent& event );
138         void OnPlayStream( wxCommandEvent& event );
139         void OnStopStream( wxCommandEvent& event );
140         void OnPrevStream( wxCommandEvent& event );
141         void OnNextStream( wxCommandEvent& event );
142         void OnSlowStream( wxCommandEvent& event );
143         void OnFastStream( wxCommandEvent& event );
144
145         void OnInteraction( wxCommandEvent& event );
146
147         void OnMenuOpen( wxMenuEvent& event );
148
149     #if defined( __WXMSW__ ) || defined( __WXMAC__ )
150         void OnContextMenu2(wxContextMenuEvent& event);
151     #endif
152         void OnContextMenu(wxMouseEvent& event);
153
154         void OnControlEvent( wxCommandEvent& event );
155
156         DECLARE_EVENT_TABLE();
157
158         Timer *timer;
159         intf_thread_t *p_intf;
160
161         int i_old_playing_status;
162
163         /* For auto-generated menus */
164         wxMenu *p_settings_menu;
165         wxMenu *p_audio_menu;
166         wxMenu *p_video_menu;
167         wxMenu *p_navig_menu;
168
169         /* Extended panel */
170         vlc_bool_t  b_extra;
171         wxPanel     *extra_frame;
172
173         /* Playlist panel */
174         wxPanel     *playlist_manager;
175
176         /* Utility dimensions */
177         wxSize main_min_size;
178         wxSize ext_min_size;
179     };
180
181
182     class WindowSettings
183     {
184     public:
185         WindowSettings( intf_thread_t *_p_intf );
186         virtual ~WindowSettings();
187         enum
188         {
189             ID_SCREEN = -1,
190             ID_MAIN,
191             ID_PLAYLIST,
192             ID_MESSAGES,
193             ID_FILE_INFO,
194             ID_BOOKMARKS,
195             ID_VIDEO,
196             ID_SMALL_PLAYLIST,
197             ID_MAX,
198         };
199
200         void SetSettings( int id, bool _b_shown,
201                     wxPoint p = wxDefaultPosition, wxSize s = wxDefaultSize );
202         bool GetSettings( int id, bool& _b_shown, wxPoint& p, wxSize& s );
203
204         void SetScreen( int i_screen_w, int i_screen_h );
205
206     private:
207         intf_thread_t *p_intf;
208
209         int     i_screen_w;
210         int     i_screen_h;
211         bool    b_valid[ID_MAX];
212         bool    b_shown[ID_MAX];
213         wxPoint position[ID_MAX];
214         wxSize  size[ID_MAX];
215     };
216
217
218     class MenuEvtHandler : public wxEvtHandler
219     {
220     public:
221         MenuEvtHandler( intf_thread_t *p_intf, Interface *p_main_interface );
222         virtual ~MenuEvtHandler();
223
224         void OnMenuEvent( wxCommandEvent& event );
225         void OnShowDialog( wxCommandEvent& event );
226
227     private:
228         DECLARE_EVENT_TABLE()
229
230         intf_thread_t *p_intf;
231         Interface *p_main_interface;
232     };
233 };
234
235 void PopupMenu( intf_thread_t *, wxWindow *, const wxPoint& );
236 wxMenu *SettingsMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
237 wxMenu *AudioMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
238 wxMenu *VideoMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
239 wxMenu *NavigMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
240
241 #endif