]> git.sesse.net Git - vlc/blob - modules/gui/wxwidgets/interface.hpp
* modules/gui/wxwidgets: don't call aout_VolumeGet so often because it is MIPS intensive.
[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         unsigned int i_update_counter;
168         int i_old_playing_status;
169
170         /* For auto-generated menus */
171         wxMenu *p_settings_menu;
172         wxMenu *p_audio_menu;
173         wxMenu *p_video_menu;
174         wxMenu *p_navig_menu;
175
176         /* Extended panel */
177         vlc_bool_t  b_extra;
178         wxPanel     *extra_frame;
179
180         /* Playlist panel */
181         wxPanel     *playlist_manager;
182
183         /* Utility dimensions */
184         wxSize main_min_size;
185         wxSize ext_min_size;
186     };
187
188
189     class WindowSettings
190     {
191     public:
192         WindowSettings( intf_thread_t *_p_intf );
193         virtual ~WindowSettings();
194         enum
195         {
196             ID_SCREEN = -1,
197             ID_MAIN,
198             ID_PLAYLIST,
199             ID_MESSAGES,
200             ID_FILE_INFO,
201             ID_BOOKMARKS,
202             ID_VIDEO,
203             ID_SMALL_PLAYLIST,
204             ID_MAX,
205         };
206
207         void SetSettings( int id, bool _b_shown,
208                     wxPoint p = wxDefaultPosition, wxSize s = wxDefaultSize );
209         bool GetSettings( int id, bool& _b_shown, wxPoint& p, wxSize& s );
210
211         void SetScreen( int i_screen_w, int i_screen_h );
212
213     private:
214         intf_thread_t *p_intf;
215
216         int     i_screen_w;
217         int     i_screen_h;
218         bool    b_valid[ID_MAX];
219         bool    b_shown[ID_MAX];
220         wxPoint position[ID_MAX];
221         wxSize  size[ID_MAX];
222     };
223
224
225     class MenuEvtHandler : public wxEvtHandler
226     {
227     public:
228         MenuEvtHandler( intf_thread_t *p_intf, Interface *p_main_interface );
229         virtual ~MenuEvtHandler();
230
231         void OnMenuEvent( wxCommandEvent& event );
232         void OnShowDialog( wxCommandEvent& event );
233
234     private:
235         DECLARE_EVENT_TABLE()
236
237         intf_thread_t *p_intf;
238         Interface *p_main_interface;
239     };
240 };
241
242 void PopupMenu( intf_thread_t *, wxWindow *, const wxPoint& );
243 void AudioPopupMenu( intf_thread_t *, wxWindow *, const wxPoint& );
244 void VideoPopupMenu( intf_thread_t *, wxWindow *, const wxPoint& );
245 void MiscPopupMenu( intf_thread_t *, wxWindow *, const wxPoint& );
246 wxMenu *SettingsMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
247 wxMenu *AudioMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
248 wxMenu *VideoMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
249 wxMenu *NavigMenu( intf_thread_t *, wxWindow *, wxMenu * = NULL );
250
251 #endif