Merge pull request #1129 from jmarshallnz/remove_smb_auth_details_in_add_source
[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_SET_TEXT        42
134
135 #define GUI_MSG_USER         1000
136
137 /*!
138  \ingroup winmsg
139  \brief
140  */
141 #define CONTROL_SELECT(controlID) \
142 do { \
143  CGUIMessage msg(GUI_MSG_SELECTED, GetID(), controlID); \
144  OnMessage(msg); \
145 } while(0)
146
147 /*!
148  \ingroup winmsg
149  \brief
150  */
151 #define CONTROL_DESELECT(controlID) \
152 do { \
153  CGUIMessage msg(GUI_MSG_DESELECTED, GetID(), controlID); \
154  OnMessage(msg); \
155 } while(0)
156
157
158 /*!
159  \ingroup winmsg
160  \brief
161  */
162 #define CONTROL_ENABLE(controlID) \
163 do { \
164  CGUIMessage msg(GUI_MSG_ENABLED, GetID(), controlID); \
165  OnMessage(msg); \
166 } while(0)
167
168 /*!
169  \ingroup winmsg
170  \brief
171  */
172 #define CONTROL_DISABLE(controlID) \
173 do { \
174  CGUIMessage msg(GUI_MSG_DISABLED, GetID(), controlID); \
175  OnMessage(msg); \
176 } while(0)
177
178
179 /*!
180  \ingroup winmsg
181  \brief
182  */
183 #define CONTROL_ENABLE_ON_CONDITION(controlID, bCondition) \
184 do { \
185  CGUIMessage msg(bCondition ? GUI_MSG_ENABLED:GUI_MSG_DISABLED, GetID(), controlID); \
186  OnMessage(msg); \
187 } while(0)
188
189
190 /*!
191  \ingroup winmsg
192  \brief
193  */
194 #define CONTROL_SELECT_ITEM(controlID,iItem) \
195 do { \
196  CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), controlID,iItem); \
197  OnMessage(msg); \
198 } while(0)
199
200 /*!
201  \ingroup winmsg
202  \brief Set the label of the current control
203  */
204 #define SET_CONTROL_LABEL(controlID,label) \
205 do { \
206  CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), controlID); \
207  msg.SetLabel(label); \
208  OnMessage(msg); \
209 } while(0)
210
211 /*!
212  \ingroup winmsg
213  \brief Set the second label of the current control
214  */
215 #define SET_CONTROL_LABEL2(controlID,label) \
216 do { \
217  CGUIMessage msg(GUI_MSG_LABEL2_SET, GetID(), controlID); \
218  msg.SetLabel(label); \
219  OnMessage(msg); \
220 } while(0)
221
222 /*!
223  \ingroup winmsg
224  \brief
225  */
226 #define SET_CONTROL_HIDDEN(controlID) \
227 do { \
228  CGUIMessage msg(GUI_MSG_HIDDEN, GetID(), controlID); \
229  OnMessage(msg); \
230 } while(0)
231
232 /*!
233  \ingroup winmsg
234  \brief
235  */
236 #define SET_CONTROL_FOCUS(controlID, dwParam) \
237 do { \
238  CGUIMessage msg(GUI_MSG_SETFOCUS, GetID(), controlID, dwParam); \
239  OnMessage(msg); \
240 } while(0)
241
242 /*!
243  \ingroup winmsg
244  \brief
245  */
246 #define SET_CONTROL_VISIBLE(controlID) \
247 do { \
248  CGUIMessage msg(GUI_MSG_VISIBLE, GetID(), controlID); \
249  OnMessage(msg); \
250 } while(0)
251
252 #define SET_CONTROL_SELECTED(dwSenderId, controlID, bSelect) \
253 do { \
254  CGUIMessage msg(bSelect?GUI_MSG_SELECTED:GUI_MSG_DESELECTED, dwSenderId, controlID); \
255  OnMessage(msg); \
256 } while(0)
257
258 #define BIND_CONTROL(i,c,pv) \
259 do { \
260  pv = ((c*)GetControl(i));\
261 } while(0)
262
263 /*!
264 \ingroup winmsg
265 \brief Click message sent from controls to windows.
266  */
267 #define SEND_CLICK_MESSAGE(id, parentID, action) \
268 do { \
269  CGUIMessage msg(GUI_MSG_CLICKED, id, parentID, action); \
270  SendWindowMessage(msg); \
271 } while(0)
272
273 #include <vector>
274 #include <boost/shared_ptr.hpp>
275 #include "utils/StdString.h"
276
277 // forwards
278 class CGUIListItem; typedef boost::shared_ptr<CGUIListItem> CGUIListItemPtr;
279 class CFileItemList;
280
281 /*!
282  \ingroup winmsg
283  \brief
284  */
285 class CGUIMessage
286 {
287 public:
288   CGUIMessage(int dwMsg, int senderID, int controlID, int param1 = 0, int param2 = 0);
289   CGUIMessage(int msg, int senderID, int controlID, int param1, int param2, CFileItemList* item);
290   CGUIMessage(int msg, int senderID, int controlID, int param1, int param2, const CGUIListItemPtr &item);
291   CGUIMessage(const CGUIMessage& msg);
292   virtual ~CGUIMessage(void);
293   const CGUIMessage& operator = (const CGUIMessage& msg);
294
295   int GetControlId() const ;
296   int GetMessage() const;
297   void* GetPointer() const;
298   CGUIListItemPtr GetItem() const;
299   int GetParam1() const;
300   int GetParam2() const;
301   int GetSenderId() const;
302   void SetParam1(int param1);
303   void SetParam2(int param2);
304   void SetPointer(void* pointer);
305   void SetLabel(const std::string& strLabel);
306   void SetLabel(int iString);               // for convience - looks up in strings.xml
307   const std::string& GetLabel() const;
308   void SetStringParam(const CStdString &strParam);
309   void SetStringParams(const std::vector<CStdString> &params);
310   const CStdString& GetStringParam(size_t param = 0) const;
311   size_t GetNumStringParams() const;
312
313 private:
314   std::string m_strLabel;
315   std::vector<CStdString> m_params;
316   int m_senderID;
317   int m_controlID;
318   int m_message;
319   void* m_pointer;
320   int m_param1;
321   int m_param2;
322   CGUIListItemPtr m_item;
323
324   static CStdString empty_string;
325 };
326 #endif