[WASAPI] fix stream types and frequencies enumeration
[xbmc.git] / xbmc / guilib / GUIMessage.h
blob2fe3faeb2a48b4fd142bd1760b185c6b2ba0b54b
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 /*!
12 \file GUIMessage.h
13 \brief
16 constexpr const int GUI_MSG_WINDOW_INIT = 1; // initialize window
17 constexpr const int GUI_MSG_WINDOW_DEINIT = 2; // deinit window
18 constexpr const int GUI_MSG_WINDOW_RESET = 27; // reset window to initial state
20 constexpr const int GUI_MSG_SETFOCUS = 3; // set focus to control param1=up/down/left/right
21 constexpr const int GUI_MSG_LOSTFOCUS = 4; // control lost focus
23 constexpr const int GUI_MSG_CLICKED = 5; // control has been clicked
25 constexpr const int GUI_MSG_VISIBLE = 6; // set control visible
26 constexpr const int GUI_MSG_HIDDEN = 7; // set control hidden
28 constexpr const int GUI_MSG_ENABLED = 8; // enable control
29 constexpr const int GUI_MSG_DISABLED = 9; // disable control
31 constexpr const int GUI_MSG_SET_SELECTED = 10; // control = selected
32 constexpr const int GUI_MSG_SET_DESELECTED = 11; // control = not selected
34 constexpr const int GUI_MSG_LABEL_ADD = 12; // add label control (for controls supporting more then 1 label)
36 constexpr const int GUI_MSG_LABEL_SET = 13; // set the label of a control
38 constexpr const int GUI_MSG_LABEL_RESET = 14; // clear all labels of a control // add label control (for controls supporting more then 1 label)
40 constexpr const int GUI_MSG_ITEM_SELECTED = 15; // ask control 2 return the selected item
41 constexpr const int GUI_MSG_ITEM_SELECT = 16; // ask control 2 select a specific item
42 constexpr const int GUI_MSG_LABEL2_SET = 17;
43 constexpr const int GUI_MSG_SHOWRANGE = 18;
45 constexpr const int GUI_MSG_FULLSCREEN = 19; // should go to fullscreen window (vis or video)
46 constexpr const int GUI_MSG_EXECUTE = 20; // user has clicked on a button with <execute> tag
48 constexpr const int GUI_MSG_NOTIFY_ALL = 21; // message will be send to all active and inactive(!) windows, all active modal and modeless dialogs
49 // dwParam1 must contain an additional message the windows should react on
51 constexpr const int GUI_MSG_REFRESH_THUMBS = 22; // message is sent to all windows to refresh all thumbs
53 constexpr const int GUI_MSG_MOVE = 23; // message is sent to the window from the base control class when it's
54 // been asked to move. dwParam1 contains direction.
56 constexpr const int GUI_MSG_LABEL_BIND = 24; // bind label control (for controls supporting more then 1 label)
58 constexpr const int GUI_MSG_FOCUSED = 26; // a control has become focused
60 constexpr const int GUI_MSG_PAGE_CHANGE = 28; // a page control has changed the page number
62 constexpr const int GUI_MSG_REFRESH_LIST = 29; // message sent to all listing controls telling them to refresh their item layouts
64 constexpr const int GUI_MSG_PAGE_UP = 30; // page up
65 constexpr const int GUI_MSG_PAGE_DOWN = 31; // page down
66 constexpr const int GUI_MSG_MOVE_OFFSET = 32; // Instruct the control to MoveUp or MoveDown by offset amount
68 constexpr const int GUI_MSG_SET_TYPE = 33; ///< Instruct a control to set it's type appropriately
70 /*!
71 \brief Message indicating the window has been resized
72 Any controls that keep stored sizing information based on aspect ratio or window size should
73 recalculate sizing information
75 constexpr const int GUI_MSG_WINDOW_RESIZE = 34;
77 /*!
78 \brief Message indicating loss of renderer, prior to reset
79 Any controls that keep shared resources should free them on receipt of this message, as the renderer
80 is about to be reset.
82 constexpr const int GUI_MSG_RENDERER_LOST = 35;
84 /*!
85 \brief Message indicating regain of renderer, after reset
86 Any controls that keep shared resources may reallocate them now that the renderer is back
88 constexpr const int GUI_MSG_RENDERER_RESET = 36;
90 /*!
91 \brief A control wishes to have (or release) exclusive access to mouse actions
93 constexpr const int GUI_MSG_EXCLUSIVE_MOUSE = 37;
95 /*!
96 \brief A request for supported gestures is made
98 constexpr const int GUI_MSG_GESTURE_NOTIFY = 38;
101 \brief A request to add a control
103 constexpr const int GUI_MSG_ADD_CONTROL = 39;
106 \brief A request to remove a control
108 constexpr const int GUI_MSG_REMOVE_CONTROL = 40;
111 \brief A request to unfocus all currently focused controls
113 constexpr const int GUI_MSG_UNFOCUS_ALL = 41;
115 constexpr const int GUI_MSG_SET_TEXT = 42;
117 constexpr const int GUI_MSG_WINDOW_LOAD = 43;
119 constexpr const int GUI_MSG_VALIDITY_CHANGED = 44;
122 \brief Check whether a button is selected
124 constexpr const int GUI_MSG_IS_SELECTED = 45;
127 \brief Bind a set of labels to a spin (or similar) control
129 constexpr const int GUI_MSG_SET_LABELS = 46;
132 \brief Set the filename for an image control
134 constexpr const int GUI_MSG_SET_FILENAME = 47;
137 \brief Get the filename of an image control
140 constexpr const int GUI_MSG_GET_FILENAME = 48;
143 \brief The user interface is ready for usage
145 constexpr const int GUI_MSG_UI_READY = 49;
148 \brief Called every 500ms to allow time dependent updates
150 constexpr const int GUI_MSG_REFRESH_TIMER = 50;
153 \brief Called if state has changed which could lead to GUI changes
155 constexpr const int GUI_MSG_STATE_CHANGED = 51;
158 \brief Called when a subtitle download has finished
160 constexpr const int GUI_MSG_SUBTITLE_DOWNLOADED = 52;
163 constexpr const int GUI_MSG_USER = 1000;
166 \brief Complete to get codingtable page
168 constexpr const int GUI_MSG_CODINGTABLE_LOOKUP_COMPLETED = 65000;
171 \ingroup winmsg
172 \brief
174 #define CONTROL_SELECT(controlID) \
175 do \
177 CGUIMessage _msg(GUI_MSG_SET_SELECTED, GetID(), controlID); \
178 OnMessage(_msg); \
179 } while (0)
182 \ingroup winmsg
183 \brief
185 #define CONTROL_DESELECT(controlID) \
186 do \
188 CGUIMessage _msg(GUI_MSG_SET_DESELECTED, GetID(), controlID); \
189 OnMessage(_msg); \
190 } while (0)
194 \ingroup winmsg
195 \brief
197 #define CONTROL_ENABLE(controlID) \
198 do \
200 CGUIMessage _msg(GUI_MSG_ENABLED, GetID(), controlID); \
201 OnMessage(_msg); \
202 } while (0)
205 \ingroup winmsg
206 \brief
208 #define CONTROL_DISABLE(controlID) \
209 do \
211 CGUIMessage _msg(GUI_MSG_DISABLED, GetID(), controlID); \
212 OnMessage(_msg); \
213 } while (0)
217 \ingroup winmsg
218 \brief
220 #define CONTROL_ENABLE_ON_CONDITION(controlID, bCondition) \
221 do \
223 CGUIMessage _msg(bCondition ? GUI_MSG_ENABLED : GUI_MSG_DISABLED, GetID(), controlID); \
224 OnMessage(_msg); \
225 } while (0)
229 \ingroup winmsg
230 \brief
232 #define CONTROL_SELECT_ITEM(controlID, iItem) \
233 do \
235 CGUIMessage _msg(GUI_MSG_ITEM_SELECT, GetID(), controlID, iItem); \
236 OnMessage(_msg); \
237 } while (0)
240 \ingroup winmsg
241 \brief Set the label of the current control
243 #define SET_CONTROL_LABEL(controlID, label) \
244 do \
246 CGUIMessage _msg(GUI_MSG_LABEL_SET, GetID(), controlID); \
247 _msg.SetLabel(label); \
248 OnMessage(_msg); \
249 } while (0)
252 \ingroup winmsg
253 \brief Set the label of the current control
255 #define SET_CONTROL_LABEL_THREAD_SAFE(controlID, label) \
257 CGUIMessage _msg(GUI_MSG_LABEL_SET, GetID(), controlID); \
258 _msg.SetLabel(label); \
259 if (CServiceBroker::GetAppMessenger()->IsProcessThread()) \
260 OnMessage(_msg); \
261 else \
262 CServiceBroker::GetGUI()->GetWindowManager().SendThreadMessage(_msg, GetID()); \
266 \ingroup winmsg
267 \brief Set the second label of the current control
269 #define SET_CONTROL_LABEL2(controlID, label) \
270 do \
272 CGUIMessage _msg(GUI_MSG_LABEL2_SET, GetID(), controlID); \
273 _msg.SetLabel(label); \
274 OnMessage(_msg); \
275 } while (0)
278 \ingroup winmsg
279 \brief Set a bunch of labels on the given control
281 #define SET_CONTROL_LABELS(controlID, defaultValue, labels) \
282 do \
284 CGUIMessage _msg(GUI_MSG_SET_LABELS, GetID(), controlID, defaultValue); \
285 _msg.SetPointer(labels); \
286 OnMessage(_msg); \
287 } while (0)
290 \ingroup winmsg
291 \brief Set the label of the current control
293 #define SET_CONTROL_FILENAME(controlID, label) \
294 do \
296 CGUIMessage _msg(GUI_MSG_SET_FILENAME, GetID(), controlID); \
297 _msg.SetLabel(label); \
298 OnMessage(_msg); \
299 } while (0)
302 \ingroup winmsg
303 \brief
305 #define SET_CONTROL_HIDDEN(controlID) \
306 do \
308 CGUIMessage _msg(GUI_MSG_HIDDEN, GetID(), controlID); \
309 OnMessage(_msg); \
310 } while (0)
313 \ingroup winmsg
314 \brief
316 #define SET_CONTROL_FOCUS(controlID, dwParam) \
317 do \
319 CGUIMessage _msg(GUI_MSG_SETFOCUS, GetID(), controlID, dwParam); \
320 OnMessage(_msg); \
321 } while (0)
324 \ingroup winmsg
325 \brief
327 #define SET_CONTROL_VISIBLE(controlID) \
328 do \
330 CGUIMessage _msg(GUI_MSG_VISIBLE, GetID(), controlID); \
331 OnMessage(_msg); \
332 } while (0)
334 #define SET_CONTROL_SELECTED(dwSenderId, controlID, bSelect) \
335 do \
337 CGUIMessage _msg(bSelect ? GUI_MSG_SET_SELECTED : GUI_MSG_SET_DESELECTED, dwSenderId, \
338 controlID); \
339 OnMessage(_msg); \
340 } while (0)
343 \ingroup winmsg
344 \brief Click message sent from controls to windows.
346 #define SEND_CLICK_MESSAGE(id, parentID, action) \
347 do \
349 CGUIMessage _msg(GUI_MSG_CLICKED, id, parentID, action); \
350 SendWindowMessage(_msg); \
351 } while (0)
353 #include <string>
354 #include <vector>
355 #include <memory>
357 // forwards
358 class CGUIListItem;
359 class CFileItemList;
362 \ingroup winmsg
363 \brief
365 class CGUIMessage final
367 public:
368 CGUIMessage(int dwMsg, int senderID, int controlID, int64_t param1 = 0, int64_t param2 = 0);
369 CGUIMessage(
370 int msg, int senderID, int controlID, int64_t param1, int64_t param2, CFileItemList* item);
371 CGUIMessage(int msg,
372 int senderID,
373 int controlID,
374 int64_t param1,
375 int64_t param2,
376 const std::shared_ptr<CGUIListItem>& item);
377 CGUIMessage(const CGUIMessage& msg);
378 ~CGUIMessage(void);
379 CGUIMessage& operator = (const CGUIMessage& msg);
381 int GetControlId() const ;
382 int GetMessage() const;
383 void* GetPointer() const;
384 std::shared_ptr<CGUIListItem> GetItem() const;
385 int GetParam1() const;
386 int64_t GetParam1AsI64() const;
387 int GetParam2() const;
388 int64_t GetParam2AsI64() const;
389 int GetSenderId() const;
390 void SetParam1(int64_t param1);
391 void SetParam2(int64_t param2);
392 void SetPointer(void* pointer);
393 void SetLabel(const std::string& strLabel);
394 void SetLabel(int iString); // for convenience - looks up in strings.po
395 const std::string& GetLabel() const;
396 void SetStringParam(const std::string &strParam);
397 void SetStringParams(const std::vector<std::string> &params);
398 const std::string& GetStringParam(size_t param = 0) const;
399 size_t GetNumStringParams() const;
400 void SetItem(std::shared_ptr<CGUIListItem> item);
402 private:
403 std::string m_strLabel;
404 std::vector<std::string> m_params;
405 int m_senderID;
406 int m_controlID;
407 int m_message;
408 void* m_pointer;
409 int64_t m_param1;
410 int64_t m_param2;
411 std::shared_ptr<CGUIListItem> m_item;
413 static std::string empty_string;