]> git.sesse.net Git - vlc/blob - modules/gui/skins/src/event.h
* ./doc/skins/events-howto.txt: added some events
[vlc] / modules / gui / skins / src / event.h
1 /*****************************************************************************
2  * event.h: Event class
3  *****************************************************************************
4  * Copyright (C) 2003 VideoLAN
5  * $Id: event.h,v 1.10 2003/06/20 21:34:37 ipkiss Exp $
6  *
7  * Authors: Olivier Teulière <ipkiss@via.ecp.fr>
8  *          Emmanuel Puig    <karibu@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111,
23  * USA.
24  *****************************************************************************/
25
26
27 #ifndef VLC_SKIN_EVENT
28 #define VLC_SKIN_EVENT
29
30 //--- GENERAL ---------------------------------------------------------------
31 #include <string>
32 #include <list>
33 using namespace std;
34
35
36
37 //---------------------------------------------------------------------------
38 // VLC specific messages
39 //---------------------------------------------------------------------------
40
41 #define MAX_EVENT_SIZE 30
42 #define MAX_PARAM_SIZE 20
43 #define EVENT_MAX_BUFFER_SIZE 20
44
45 #if !defined _WIN32
46 #define WM_APP 0x8000
47 #endif
48
49 #define VLC_MESSAGE         (WM_APP)
50 #define VLC_WINDOW          (WM_APP + 1000)
51 #define VLC_CONTROL         (WM_APP + 2000)
52
53 // VLC messages
54 #define VLC_NOTHING         (VLC_MESSAGE + 1)
55 #define VLC_SHOW            (VLC_MESSAGE + 2)
56 #define VLC_HIDE            (VLC_MESSAGE + 3)
57
58 #define VLC_QUIT            (VLC_MESSAGE + 4)
59 #define VLC_OPEN            (VLC_MESSAGE + 5)
60 #define VLC_LOAD_SKIN       (VLC_MESSAGE + 6)
61 #define VLC_DROP            (VLC_MESSAGE + 7)
62
63 #define VLC_LOG_SHOW        (VLC_MESSAGE + 20)
64 #define VLC_LOG_CLEAR       (VLC_MESSAGE + 22)
65 #define VLC_PREFS_SHOW      (VLC_MESSAGE + 23)
66 #define VLC_INFO_SHOW       (VLC_MESSAGE + 24)
67
68 #define VLC_INTF_REFRESH    (VLC_MESSAGE + 30)
69 #define VLC_CHANGE_TRAY     (VLC_MESSAGE + 31)
70 #define VLC_CHANGE_TASKBAR  (VLC_MESSAGE + 32)
71
72 #define VLC_FULLSCREEN      (VLC_MESSAGE + 40)
73
74 // Stream control
75 #define VLC_PLAY            (VLC_MESSAGE + 101)
76 #define VLC_STOP            (VLC_MESSAGE + 102)
77 #define VLC_PAUSE           (VLC_MESSAGE + 103)
78 #define VLC_NEXT            (VLC_MESSAGE + 104)
79 #define VLC_PREV            (VLC_MESSAGE + 105)
80 #define VLC_STREAMPOS       (VLC_MESSAGE + 106)
81 #define VLC_ENDSTREAMPOS    (VLC_MESSAGE + 107)
82 #define VLC_TOTALSTREAMPOS  (VLC_MESSAGE + 108)
83 #define VLC_STREAM_NAME     (VLC_MESSAGE + 109)
84 #define VLC_STREAM_TITLE    (VLC_MESSAGE + 110)
85 #define VLC_HELP_TEXT       (VLC_MESSAGE + 111)
86
87 // Volume control
88 #define VLC_VOLUME_CHANGE   (VLC_MESSAGE + 201)
89 #define VLC_VOLUME_MUTE     (VLC_MESSAGE + 202)
90 #define VLC_VOLUME_UP       (VLC_MESSAGE + 203)
91 #define VLC_VOLUME_DOWN     (VLC_MESSAGE + 204)
92 #define VLC_VOLUME_SET      (VLC_MESSAGE + 205)
93
94 // Playlist events
95 #define VLC_PLAYLIST_ADD_FILE (VLC_MESSAGE + 301)
96 #define VLC_TEST_ALL_CLOSED (VLC_MESSAGE + 600)
97
98 // Network events
99 #define VLC_NET_ADDUDP      (VLC_MESSAGE + 701)
100
101 // Window event
102 #define WINDOW_MOVE         (VLC_WINDOW + 1)
103 #define WINDOW_OPEN         (VLC_WINDOW + 2)
104 #define WINDOW_CLOSE        (VLC_WINDOW + 3)
105 #define WINDOW_SHOW         (VLC_WINDOW + 4)
106 #define WINDOW_HIDE         (VLC_WINDOW + 5)
107 #define WINDOW_FADE         (VLC_WINDOW + 6)
108 #define WINDOW_LEAVE        (VLC_WINDOW + 7)
109 #define WINDOW_REFRESH      (VLC_WINDOW + 8)
110
111 // Control event
112 #define CTRL_ENABLED        (VLC_CONTROL + 1)
113 #define CTRL_VISIBLE        (VLC_CONTROL + 2)
114 #define CTRL_SYNCHRO        (VLC_CONTROL + 3)
115
116 #define CTRL_SET_SLIDER     (VLC_CONTROL + 10)
117 #define CTRL_SET_TEXT       (VLC_CONTROL + 11)
118
119 // Control event by ID
120 #define CTRL_ID_VISIBLE     (VLC_CONTROL + 100)
121 #define CTRL_ID_ENABLED     (VLC_CONTROL + 101)
122 #define CTRL_ID_MOVE        (VLC_CONTROL + 102)
123
124 // Control definition
125 #define CTRL_SLIDER         (VLC_CONTROL + 301)
126 #define CTRL_TIME           (VLC_CONTROL + 302)
127 #define CTRL_PLAYLIST       (VLC_CONTROL + 303)
128
129 // Playlist
130 #define PLAYLIST_ID_DEL     (VLC_CONTROL + 400)
131
132 //---------------------------------------------------------------------------
133 struct intf_thread_t;
134 class GenericControl;
135 class SkinWindow;
136 class Event;
137
138
139
140 //---------------------------------------------------------------------------
141 // EVENT CLASS
142 //---------------------------------------------------------------------------
143 class Event
144 {
145     protected:
146         string          EventDesc;
147         unsigned int    Message;
148         unsigned int    Param1;
149         long            Param2;
150         unsigned int    GetMessageType( string desc );
151         string          Shortcut;
152         int             KeyModifier;
153         int             Key;
154         intf_thread_t * p_intf;
155
156         // Transform expr to special boolean :
157         //   0 = false
158         //   1 = true
159         //   2 = change boolean
160         int GetBool( string expr );
161
162     public:
163         // Constructor
164         Event( intf_thread_t *_p_intf, string Desc, string shortcut );
165         Event( intf_thread_t *_p_intf, unsigned int msg, unsigned int par1,
166                long par2 );
167
168         // Destructor
169         virtual ~Event();
170         void DestructParameters( bool force = false );
171
172         // General operations on events
173         GenericControl * FindControl( string id );
174         void CreateEvent();
175         virtual void CreateOSEvent( string para1, string para2,
176                                     string para3 ) = 0;
177         virtual bool IsEqual( Event *evt );
178
179         // Event sending
180         virtual bool SendEvent() = 0;
181         void PostTextMessage( string text );
182         void PostSynchroMessage( bool autodelete = false );
183
184         // Shortcuts methods
185         bool MatchShortcut( int key, int mod );
186         void CreateShortcut();
187
188         // Getters
189         unsigned int GetMessage()   { return Message; }
190         unsigned int GetParam1()    { return Param1; }
191         long         GetParam2()    { return Param2; }
192
193         // Setters
194         void SetParam1( unsigned int p1 )    { Param1 = p1; }
195         void SetParam2( unsigned int p2 )    { Param2 = p2; }
196 };
197 //---------------------------------------------------------------------------
198
199 #define ACTION_MATCH_ALL    0
200 #define ACTION_MATCH_FIRST  1
201 #define ACTION_MATCH_ONE    2
202
203 //---------------------------------------------------------------------------
204 class Action
205 {
206     private:
207         list<Event *> EventList;
208         int GetBool( string expr );
209         intf_thread_t * p_intf;
210
211     public:
212         // Constructor
213         Action::Action( intf_thread_t *_p_intf, string code );
214
215         // Destructor
216         Action::~Action();
217
218         // Send event
219         bool SendEvent();
220         bool MatchEvent( Event *evt, int flag = ACTION_MATCH_ALL );
221 };
222 //---------------------------------------------------------------------------
223
224 #endif