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