]> git.sesse.net Git - vlc/blob - modules/gui/skins/src/event.h
3c3146a8b6c35191d3d536ab0f6a875f03c52938
[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.1 2003/03/18 02:21:47 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 20
42 #define MAX_PARAM_SIZE 20
43
44 #define VLC_MESSAGE         (WM_APP)
45 #define VLC_WINDOW          (WM_APP + 1000)
46 #define VLC_CONTROL         (WM_APP + 2000)
47
48 // VLC messages
49 #define VLC_NOTHING         (VLC_MESSAGE + 1)
50 #define VLC_SHOW            (VLC_MESSAGE + 2)
51 #define VLC_HIDE            (VLC_MESSAGE + 3)
52
53 #define VLC_QUIT            (VLC_MESSAGE + 4)
54 #define VLC_OPEN            (VLC_MESSAGE + 5)
55 #define VLC_LOAD_SKIN       (VLC_MESSAGE + 6)
56 #define VLC_DROP            (VLC_MESSAGE + 7)
57
58 #define VLC_LOG_SHOW        (VLC_MESSAGE + 20)
59 #define VLC_LOG_CLEAR       (VLC_MESSAGE + 22)
60
61 #define VLC_INTF_REFRESH    (VLC_MESSAGE + 30)
62 #define VLC_CHANGE_TRAY     (VLC_MESSAGE + 31)
63 #define VLC_CHANGE_TASKBAR  (VLC_MESSAGE + 32)
64
65 #define VLC_FULLSCREEN      (VLC_MESSAGE + 40)
66
67 // Stream control
68 #define VLC_PLAY            (VLC_MESSAGE + 101)
69 #define VLC_STOP            (VLC_MESSAGE + 102)
70 #define VLC_PAUSE           (VLC_MESSAGE + 103)
71 #define VLC_NEXT            (VLC_MESSAGE + 104)
72 #define VLC_PREV            (VLC_MESSAGE + 105)
73 #define VLC_STREAMPOS       (VLC_MESSAGE + 106)
74 #define VLC_ENDSTREAMPOS    (VLC_MESSAGE + 107)
75 #define VLC_TOTALSTREAMPOS  (VLC_MESSAGE + 108)
76 #define VLC_STREAMNAME      (VLC_MESSAGE + 109)
77 #define VLC_HELP_TEXT       (VLC_MESSAGE + 110)
78
79 // Volume control
80 #define VLC_VOLUME_CHANGE   (VLC_MESSAGE + 201)
81 #define VLC_VOLUME_MUTE     (VLC_MESSAGE + 202)
82 #define VLC_VOLUME_UP       (VLC_MESSAGE + 203)
83 #define VLC_VOLUME_DOWN     (VLC_MESSAGE + 204)
84 #define VLC_VOLUME_SET      (VLC_MESSAGE + 205)
85
86 // Playlist events
87 #define VLC_PLAYLIST_ADD_FILE (VLC_MESSAGE + 301)
88 #define VLC_TEST_ALL_CLOSED (VLC_MESSAGE + 600)
89
90 // Window event
91 #define WINDOW_MOVE         (VLC_WINDOW + 1)
92 #define WINDOW_OPEN         (VLC_WINDOW + 2)
93 #define WINDOW_CLOSE        (VLC_WINDOW + 3)
94 #define WINDOW_SHOW         (VLC_WINDOW + 4)
95 #define WINDOW_HIDE         (VLC_WINDOW + 5)
96 #define WINDOW_FADE         (VLC_WINDOW + 6)
97
98 // Control event
99 #define CTRL_ENABLED        (VLC_CONTROL + 1)
100 #define CTRL_VISIBLE        (VLC_CONTROL + 2)
101 #define CTRL_SYNCHRO        (VLC_CONTROL + 3)
102
103 #define CTRL_SET_SLIDER     (VLC_CONTROL + 10)
104 #define CTRL_SET_TEXT       (VLC_CONTROL + 11)
105
106 // Control event by ID
107 #define CTRL_ID_VISIBLE     (VLC_CONTROL + 100)
108 #define CTRL_ID_ENABLED     (VLC_CONTROL + 101)
109 #define CTRL_ID_MOVE        (VLC_CONTROL + 102)
110
111 // Control definition
112 #define CTRL_SLIDER         (VLC_CONTROL + 301)
113 #define CTRL_TIME           (VLC_CONTROL + 302)
114 #define CTRL_PLAYLIST       (VLC_CONTROL + 303)
115
116 // Playlist
117 #define PLAYLIST_ID_DEL     (VLC_CONTROL + 400)
118
119 //---------------------------------------------------------------------------
120 struct intf_thread_t;
121 class GenericControl;
122 class Window;
123 class Event;
124
125
126
127 //---------------------------------------------------------------------------
128 // EVENT CLASS
129 //---------------------------------------------------------------------------
130 class Event
131 {
132     protected:
133         string          EventDesc;
134         unsigned int    Message;
135         unsigned int    Param1;
136         long            Param2;
137         unsigned int    GetMessageType( string desc );
138         string          Shortcut;
139         int             KeyModifier;
140         int             Key;
141         intf_thread_t * p_intf;
142
143         // Transform expr to special boolean :
144         //   0 = false
145         //   1 = true
146         //   2 = change boolean
147         int GetBool( string expr );
148
149     public:
150         // Constructor
151         Event( intf_thread_t *_p_intf, string Desc, string shortcut );
152         Event( intf_thread_t *_p_intf, unsigned int msg, unsigned int par1,
153                long par2 );
154
155         // Destructor
156         virtual ~Event();
157         void DestructParameters();
158
159         // General operations on events
160         GenericControl * FindControl( string id );
161         void CreateEvent();
162         virtual void CreateOSEvent( string para1, string para2,
163                                     string para3 ) = 0;
164         virtual bool IsEqual( Event *evt );
165
166         // Event sending
167         virtual bool SendEvent() = 0;
168         void PostTextMessage( string text );
169         void PostSynchroMessage( bool autodelete = false );
170
171         // Shortcuts methods
172         bool MatchShortcut( int key, int mod );
173         void CreateShortcut();
174
175         // Getters
176         unsigned int GetMessage()   { return Message; }
177         unsigned int GetParam1()    { return Param1; }
178         long         GetParam2()    { return Param2; }
179
180         // Setters
181         void SetParam1( unsigned int p1 )    { Param1 = p1; }
182         void SetParam2( unsigned int p2 )    { Param2 = p2; }
183 };
184 //---------------------------------------------------------------------------
185
186 #define ACTION_MATCH_ALL    0
187 #define ACTION_MATCH_FIRST  1
188 #define ACTION_MATCH_ONE    2
189
190 //---------------------------------------------------------------------------
191 class Action
192 {
193     private:
194         list<Event *> EventList;
195         int GetBool( string expr );
196         intf_thread_t * p_intf;
197
198     public:
199         // Constructor
200         Action::Action( intf_thread_t *_p_intf, string code );
201
202         // Destructor
203         Action::~Action();
204
205         // Send event
206         bool SendEvent();
207         bool MatchEvent( Event *evt, int flag = ACTION_MATCH_ALL );
208 };
209 //---------------------------------------------------------------------------
210
211 #endif