strip added smb:// shares of their user/pass when adding, and instead store that...
[vuplus_xbmc] / xbmc / guilib / GUIMessage.h
1 /*!
2 \file GUIMessage.h
3 \brief
4 */
5
6 #ifndef GUILIB_MESSAGE_H
7 #define GUILIB_MESSAGE_H
8
9 #pragma once
10
11 /*
12  *      Copyright (C) 2005-2008 Team XBMC
13  *      http://www.xbmc.org
14  *
15  *  This Program is free software; you can redistribute it and/or modify
16  *  it under the terms of the GNU General Public License as published by
17  *  the Free Software Foundation; either version 2, or (at your option)
18  *  any later version.
19  *
20  *  This Program is distributed in the hope that it will be useful,
21  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
22  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  *  GNU General Public License for more details.
24  *
25  *  You should have received a copy of the GNU General Public License
26  *  along with XBMC; see the file COPYING.  If not, write to
27  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
28  *  http://www.gnu.org/copyleft/gpl.html
29  *
30  */
31
32 #define GUI_MSG_WINDOW_INIT     1   // initialize window
33 #define GUI_MSG_WINDOW_DEINIT   2   // deinit window
34 #define GUI_MSG_WINDOW_RESET    27  // reset window to initial state
35
36 #define GUI_MSG_SETFOCUS        3   // set focus to control param1=up/down/left/right
37 #define GUI_MSG_LOSTFOCUS       4   // control lost focus
38
39 #define GUI_MSG_CLICKED         5   // control has been clicked
40
41 #define GUI_MSG_VISIBLE         6   // set control visible
42 #define GUI_MSG_HIDDEN          7   // set control hidden
43
44 #define GUI_MSG_ENABLED         8   // enable control
45 #define GUI_MSG_DISABLED        9   // disable control
46
47 #define GUI_MSG_SELECTED       10   // control = selected
48 #define GUI_MSG_DESELECTED     11   // control = not selected
49
50 #define GUI_MSG_LABEL_ADD      12   // add label control (for controls supporting more then 1 label)
51
52 #define GUI_MSG_LABEL_SET      13  // set the label of a control
53
54 #define GUI_MSG_LABEL_RESET    14  // clear all labels of a control // add label control (for controls supporting more then 1 label)
55
56 #define GUI_MSG_ITEM_SELECTED  15  // ask control 2 return the selected item
57 #define GUI_MSG_ITEM_SELECT   16  // ask control 2 select a specific item
58 #define GUI_MSG_LABEL2_SET   17
59 #define GUI_MSG_SHOWRANGE      18
60
61 #define GUI_MSG_FULLSCREEN  19  // should go to fullscreen window (vis or video)
62 #define GUI_MSG_EXECUTE    20  // user has clicked on a button with <execute> tag
63
64 #define GUI_MSG_NOTIFY_ALL    21  // message will be send to all active and inactive(!) windows, all active modal and modeless dialogs
65                                   // dwParam1 must contain an additional message the windows should react on
66
67 #define GUI_MSG_REFRESH_THUMBS 22 // message is sent to all windows to refresh all thumbs
68
69 #define GUI_MSG_MOVE          23 // message is sent to the window from the base control class when it's
70                                  // been asked to move.  dwParam1 contains direction.
71
72 #define GUI_MSG_LABEL_BIND     24   // bind label control (for controls supporting more then 1 label)
73
74 #define GUI_MSG_SELCHANGED  25  // selection within the control has changed
75
76 #define GUI_MSG_FOCUSED     26  // a control has become focused
77
78 #define GUI_MSG_PAGE_CHANGE 28  // a page control has changed the page number
79
80 #define GUI_MSG_REFRESH_LIST 29 // message sent to all listing controls telling them to refresh their item layouts
81
82 #define GUI_MSG_PAGE_UP      30 // page up
83 #define GUI_MSG_PAGE_DOWN    31 // page down
84 #define GUI_MSG_MOVE_OFFSET  32 // Instruct the contorl to MoveUp or MoveDown by offset amount
85
86 #define GUI_MSG_SET_TYPE     33 ///< Instruct a control to set it's type appropriately
87
88 /*!
89  \brief Message indicating the window has been resized
90  Any controls that keep stored sizing information based on aspect ratio or window size should
91  recalculate sizing information
92  */
93 #define GUI_MSG_WINDOW_RESIZE  34
94
95 /*!
96  \brief Message indicating loss of renderer, prior to reset
97  Any controls that keep shared resources should free them on receipt of this message, as the renderer
98  is about to be reset.
99  */
100 #define GUI_MSG_RENDERER_LOST  35
101
102 /*!
103  \brief Message indicating regain of renderer, after reset
104  Any controls that keep shared resources may reallocate them now that the renderer is back
105  */
106 #define GUI_MSG_RENDERER_RESET 36
107
108 /*!
109  \brief A control wishes to have (or release) exclusive access to mouse actions
110  */
111 #define GUI_MSG_EXCLUSIVE_MOUSE 37
112
113 /*!
114  \brief A request for supported gestures is made
115  */
116 #define GUI_MSG_GESTURE_NOTIFY  38
117
118 /*!
119  \brief A request to add a control
120  */
121 #define GUI_MSG_ADD_CONTROL     39
122
123 /*!
124  \brief A request to remove a control
125  */
126 #define GUI_MSG_REMOVE_CONTROL  40
127
128 /*!
129  \brief A request to unfocus all currently focused controls
130  */
131 #define GUI_MSG_UNFOCUS_ALL 41
132
133 #define GUI_MSG_USER         1000
134
135 /*!
136  \ingroup winmsg
137  \brief
138  */
139 #define CONTROL_SELECT(controlID) \
140 do { \
141  CGUIMessage msg(GUI_MSG_SELECTED, GetID(), controlID); \
142  OnMessage(msg); \
143 } while(0)
144
145 /*!
146  \ingroup winmsg
147  \brief
148  */
149 #define CONTROL_DESELECT(controlID) \
150 do { \
151  CGUIMessage msg(GUI_MSG_DESELECTED, GetID(), controlID); \
152  OnMessage(msg); \
153 } while(0)
154
155
156 /*!
157  \ingroup winmsg
158  \brief
159  */
160 #define CONTROL_ENABLE(controlID) \
161 do { \
162  CGUIMessage msg(GUI_MSG_ENABLED, GetID(), controlID); \
163  OnMessage(msg); \
164 } while(0)
165
166 /*!
167  \ingroup winmsg
168  \brief
169  */
170 #define CONTROL_DISABLE(controlID) \
171 do { \
172  CGUIMessage msg(GUI_MSG_DISABLED, GetID(), controlID); \
173  OnMessage(msg); \
174 } while(0)
175
176
177 /*!
178  \ingroup winmsg
179  \brief
180  */
181 #define CONTROL_ENABLE_ON_CONDITION(controlID, bCondition) \
182 do { \
183  CGUIMessage msg(bCondition ? GUI_MSG_ENABLED:GUI_MSG_DISABLED, GetID(), controlID); \
184  OnMessage(msg); \
185 } while(0)
186
187
188 /*!
189  \ingroup winmsg
190  \brief
191  */
192 #define CONTROL_SELECT_ITEM(controlID,iItem) \
193 do { \
194  CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), controlID,iItem); \
195  OnMessage(msg); \
196 } while(0)
197
198 /*!
199  \ingroup winmsg
200  \brief Set the label of the current control
201  */
202 #define SET_CONTROL_LABEL(controlID,label) \
203 do { \
204  CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), controlID); \
205  msg.SetLabel(label); \
206  OnMessage(msg); \
207 } while(0)
208
209 /*!
210  \ingroup winmsg
211  \brief Set the second label of the current control
212  */
213 #define SET_CONTROL_LABEL2(controlID,label) \
214 do { \
215  CGUIMessage msg(GUI_MSG_LABEL2_SET, GetID(), controlID); \
216  msg.SetLabel(label); \
217  OnMessage(msg); \
218 } while(0)
219
220 /*!
221  \ingroup winmsg
222  \brief
223  */
224 #define SET_CONTROL_HIDDEN(controlID) \
225 do { \
226  CGUIMessage msg(GUI_MSG_HIDDEN, GetID(), controlID); \
227  OnMessage(msg); \
228 } while(0)
229
230 /*!
231  \ingroup winmsg
232  \brief
233  */
234 #define SET_CONTROL_FOCUS(controlID, dwParam) \
235 do { \
236  CGUIMessage msg(GUI_MSG_SETFOCUS, GetID(), controlID, dwParam); \
237  OnMessage(msg); \
238 } while(0)
239
240 /*!
241  \ingroup winmsg
242  \brief
243  */
244 #define SET_CONTROL_VISIBLE(controlID) \
245 do { \
246  CGUIMessage msg(GUI_MSG_VISIBLE, GetID(), controlID); \
247  OnMessage(msg); \
248 } while(0)
249
250 #define SET_CONTROL_SELECTED(dwSenderId, controlID, bSelect) \
251 do { \
252  CGUIMessage msg(bSelect?GUI_MSG_SELECTED:GUI_MSG_DESELECTED, dwSenderId, controlID); \
253  OnMessage(msg); \
254 } while(0)
255
256 #define BIND_CONTROL(i,c,pv) \
257 do { \
258  pv = ((c*)GetControl(i));\
259 } while(0)
260
261 /*!
262 \ingroup winmsg
263 \brief Click message sent from controls to windows.
264  */
265 #define SEND_CLICK_MESSAGE(id, parentID, action) \
266 do { \
267  CGUIMessage msg(GUI_MSG_CLICKED, id, parentID, action); \
268  SendWindowMessage(msg); \
269 } while(0)
270
271 #include <vector>
272 #include <boost/shared_ptr.hpp>
273 #include "utils/StdString.h"
274
275 // forwards
276 class CGUIListItem; typedef boost::shared_ptr<CGUIListItem> CGUIListItemPtr;
277 class CFileItemList;
278
279 /*!
280  \ingroup winmsg
281  \brief
282  */
283 class CGUIMessage
284 {
285 public:
286   CGUIMessage(int dwMsg, int senderID, int controlID, int param1 = 0, int param2 = 0);
287   CGUIMessage(int msg, int senderID, int controlID, int param1, int param2, CFileItemList* item);
288   CGUIMessage(int msg, int senderID, int controlID, int param1, int param2, const CGUIListItemPtr &item);
289   CGUIMessage(const CGUIMessage& msg);
290   virtual ~CGUIMessage(void);
291   const CGUIMessage& operator = (const CGUIMessage& msg);
292
293   int GetControlId() const ;
294   int GetMessage() const;
295   void* GetPointer() const;
296   CGUIListItemPtr GetItem() const;
297   int GetParam1() const;
298   int GetParam2() const;
299   int GetSenderId() const;
300   void SetParam1(int param1);
301   void SetParam2(int param2);
302   void SetPointer(void* pointer);
303   void SetLabel(const std::string& strLabel);
304   void SetLabel(int iString);               // for convience - looks up in strings.xml
305   const std::string& GetLabel() const;
306   void SetStringParam(const CStdString &strParam);
307   void SetStringParams(const std::vector<CStdString> &params);
308   const CStdString& GetStringParam(size_t param = 0) const;
309   size_t GetNumStringParams() const;
310
311 private:
312   std::string m_strLabel;
313   std::vector<CStdString> m_params;
314   int m_senderID;
315   int m_controlID;
316   int m_message;
317   void* m_pointer;
318   int m_param1;
319   int m_param2;
320   CGUIListItemPtr m_item;
321
322   static CStdString empty_string;
323 };
324 #endif