xbmc
GUIMessage.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2005-2018 Team Kodi
3  * This file is part of Kodi - https://kodi.tv
4  *
5  * SPDX-License-Identifier: GPL-2.0-or-later
6  * See LICENSES/README.md for more information.
7  */
8 
9 #pragma once
10 
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
19 
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
22 
23 constexpr const int GUI_MSG_CLICKED = 5; // control has been clicked
24 
25 constexpr const int GUI_MSG_VISIBLE = 6; // set control visible
26 constexpr const int GUI_MSG_HIDDEN = 7; // set control hidden
27 
28 constexpr const int GUI_MSG_ENABLED = 8; // enable control
29 constexpr const int GUI_MSG_DISABLED = 9; // disable control
30 
31 constexpr const int GUI_MSG_SET_SELECTED = 10; // control = selected
32 constexpr const int GUI_MSG_SET_DESELECTED = 11; // control = not selected
33 
34 constexpr const int GUI_MSG_LABEL_ADD = 12; // add label control (for controls supporting more then 1 label)
35 
36 constexpr const int GUI_MSG_LABEL_SET = 13; // set the label of a control
37 
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)
39 
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;
44 
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
47 
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
50 
51 constexpr const int GUI_MSG_REFRESH_THUMBS = 22; // message is sent to all windows to refresh all thumbs
52 
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.
55 
56 constexpr const int GUI_MSG_LABEL_BIND = 24; // bind label control (for controls supporting more then 1 label)
57 
58 constexpr const int GUI_MSG_FOCUSED = 26; // a control has become focused
59 
60 constexpr const int GUI_MSG_PAGE_CHANGE = 28; // a page control has changed the page number
61 
62 constexpr const int GUI_MSG_REFRESH_LIST = 29; // message sent to all listing controls telling them to refresh their item layouts
63 
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
67 
68 constexpr const int GUI_MSG_SET_TYPE = 33;
69 
75 constexpr const int GUI_MSG_WINDOW_RESIZE = 34;
76 
82 constexpr const int GUI_MSG_RENDERER_LOST = 35;
83 
88 constexpr const int GUI_MSG_RENDERER_RESET = 36;
89 
93 constexpr const int GUI_MSG_EXCLUSIVE_MOUSE = 37;
94 
98 constexpr const int GUI_MSG_GESTURE_NOTIFY = 38;
99 
103 constexpr const int GUI_MSG_ADD_CONTROL = 39;
104 
108 constexpr const int GUI_MSG_REMOVE_CONTROL = 40;
109 
113 constexpr const int GUI_MSG_UNFOCUS_ALL = 41;
114 
115 constexpr const int GUI_MSG_SET_TEXT = 42;
116 
117 constexpr const int GUI_MSG_WINDOW_LOAD = 43;
118 
119 constexpr const int GUI_MSG_VALIDITY_CHANGED = 44;
120 
124 constexpr const int GUI_MSG_IS_SELECTED = 45;
125 
129 constexpr const int GUI_MSG_SET_LABELS = 46;
130 
134 constexpr const int GUI_MSG_SET_FILENAME = 47;
135 
140 constexpr const int GUI_MSG_GET_FILENAME = 48;
141 
145 constexpr const int GUI_MSG_UI_READY = 49;
146 
150 constexpr const int GUI_MSG_REFRESH_TIMER = 50;
151 
155 constexpr const int GUI_MSG_STATE_CHANGED = 51;
156 
160 constexpr const int GUI_MSG_SUBTITLE_DOWNLOADED = 52;
161 
162 
163 constexpr const int GUI_MSG_USER = 1000;
164 
168 constexpr const int GUI_MSG_CODINGTABLE_LOOKUP_COMPLETED = 65000;
169 
174 #define CONTROL_SELECT(controlID) \
175  do \
176  { \
177  CGUIMessage _msg(GUI_MSG_SET_SELECTED, GetID(), controlID); \
178  OnMessage(_msg); \
179  } while (0)
180 
185 #define CONTROL_DESELECT(controlID) \
186  do \
187  { \
188  CGUIMessage _msg(GUI_MSG_SET_DESELECTED, GetID(), controlID); \
189  OnMessage(_msg); \
190  } while (0)
191 
192 
197 #define CONTROL_ENABLE(controlID) \
198  do \
199  { \
200  CGUIMessage _msg(GUI_MSG_ENABLED, GetID(), controlID); \
201  OnMessage(_msg); \
202  } while (0)
203 
208 #define CONTROL_DISABLE(controlID) \
209  do \
210  { \
211  CGUIMessage _msg(GUI_MSG_DISABLED, GetID(), controlID); \
212  OnMessage(_msg); \
213  } while (0)
214 
215 
220 #define CONTROL_ENABLE_ON_CONDITION(controlID, bCondition) \
221  do \
222  { \
223  CGUIMessage _msg(bCondition ? GUI_MSG_ENABLED : GUI_MSG_DISABLED, GetID(), controlID); \
224  OnMessage(_msg); \
225  } while (0)
226 
227 
232 #define CONTROL_SELECT_ITEM(controlID, iItem) \
233  do \
234  { \
235  CGUIMessage _msg(GUI_MSG_ITEM_SELECT, GetID(), controlID, iItem); \
236  OnMessage(_msg); \
237  } while (0)
238 
243 #define SET_CONTROL_LABEL(controlID, label) \
244  do \
245  { \
246  CGUIMessage _msg(GUI_MSG_LABEL_SET, GetID(), controlID); \
247  _msg.SetLabel(label); \
248  OnMessage(_msg); \
249  } while (0)
250 
255 #define SET_CONTROL_LABEL_THREAD_SAFE(controlID, label) \
256  { \
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()); \
263  }
264 
269 #define SET_CONTROL_LABEL2(controlID, label) \
270  do \
271  { \
272  CGUIMessage _msg(GUI_MSG_LABEL2_SET, GetID(), controlID); \
273  _msg.SetLabel(label); \
274  OnMessage(_msg); \
275  } while (0)
276 
281 #define SET_CONTROL_LABELS(controlID, defaultValue, labels) \
282  do \
283  { \
284  CGUIMessage _msg(GUI_MSG_SET_LABELS, GetID(), controlID, defaultValue); \
285  _msg.SetPointer(labels); \
286  OnMessage(_msg); \
287  } while (0)
288 
293 #define SET_CONTROL_FILENAME(controlID, label) \
294  do \
295  { \
296  CGUIMessage _msg(GUI_MSG_SET_FILENAME, GetID(), controlID); \
297  _msg.SetLabel(label); \
298  OnMessage(_msg); \
299  } while (0)
300 
305 #define SET_CONTROL_HIDDEN(controlID) \
306  do \
307  { \
308  CGUIMessage _msg(GUI_MSG_HIDDEN, GetID(), controlID); \
309  OnMessage(_msg); \
310  } while (0)
311 
316 #define SET_CONTROL_FOCUS(controlID, dwParam) \
317  do \
318  { \
319  CGUIMessage _msg(GUI_MSG_SETFOCUS, GetID(), controlID, dwParam); \
320  OnMessage(_msg); \
321  } while (0)
322 
327 #define SET_CONTROL_VISIBLE(controlID) \
328  do \
329  { \
330  CGUIMessage _msg(GUI_MSG_VISIBLE, GetID(), controlID); \
331  OnMessage(_msg); \
332  } while (0)
333 
334 #define SET_CONTROL_SELECTED(dwSenderId, controlID, bSelect) \
335  do \
336  { \
337  CGUIMessage _msg(bSelect ? GUI_MSG_SET_SELECTED : GUI_MSG_SET_DESELECTED, dwSenderId, \
338  controlID); \
339  OnMessage(_msg); \
340  } while (0)
341 
346 #define SEND_CLICK_MESSAGE(id, parentID, action) \
347  do \
348  { \
349  CGUIMessage _msg(GUI_MSG_CLICKED, id, parentID, action); \
350  SendWindowMessage(_msg); \
351  } while (0)
352 
353 #include <string>
354 #include <vector>
355 #include <memory>
356 
357 // forwards
358 class CGUIListItem; typedef std::shared_ptr<CGUIListItem> CGUIListItemPtr;
359 class CFileItemList;
360 
365 class CGUIMessage final
366 {
367 public:
368  CGUIMessage(int dwMsg, int senderID, int controlID, int param1 = 0, int param2 = 0);
369  CGUIMessage(int msg, int senderID, int controlID, int param1, int param2, CFileItemList* item);
370  CGUIMessage(int msg, int senderID, int controlID, int param1, int param2, const CGUIListItemPtr &item);
371  CGUIMessage(const CGUIMessage& msg);
372  ~CGUIMessage(void);
373  CGUIMessage& operator = (const CGUIMessage& msg);
374 
375  int GetControlId() const ;
376  int GetMessage() const;
377  void* GetPointer() const;
378  CGUIListItemPtr GetItem() const;
379  int GetParam1() const;
380  int GetParam2() const;
381  int GetSenderId() const;
382  void SetParam1(int param1);
383  void SetParam2(int param2);
384  void SetPointer(void* pointer);
385  void SetLabel(const std::string& strLabel);
386  void SetLabel(int iString); // for convenience - looks up in strings.po
387  const std::string& GetLabel() const;
388  void SetStringParam(const std::string &strParam);
389  void SetStringParams(const std::vector<std::string> &params);
390  const std::string& GetStringParam(size_t param = 0) const;
391  size_t GetNumStringParams() const;
392  void SetItem(CGUIListItemPtr item);
393 
394 private:
395  std::string m_strLabel;
396  std::vector<std::string> m_params;
397  int m_senderID;
398  int m_controlID;
399  int m_message;
400  void* m_pointer;
401  int m_param1;
402  int m_param2;
403  CGUIListItemPtr m_item;
404 
405  static std::string empty_string;
406 };
407 
constexpr const int GUI_MSG_EXCLUSIVE_MOUSE
A control wishes to have (or release) exclusive access to mouse actions.
Definition: GUIMessage.h:93
constexpr const int GUI_MSG_RENDERER_LOST
Message indicating loss of renderer, prior to reset Any controls that keep shared resources should fr...
Definition: GUIMessage.h:82
Definition: GUIListItem.h:30
constexpr const int GUI_MSG_ADD_CONTROL
A request to add a control.
Definition: GUIMessage.h:103
constexpr const int GUI_MSG_UNFOCUS_ALL
A request to unfocus all currently focused controls.
Definition: GUIMessage.h:113
Represents a list of files.
Definition: FileItem.h:721
constexpr const int GUI_MSG_GET_FILENAME
Get the filename of an image control.
Definition: GUIMessage.h:140
constexpr const int GUI_MSG_SET_FILENAME
Set the filename for an image control.
Definition: GUIMessage.h:134
constexpr const int GUI_MSG_SET_LABELS
Bind a set of labels to a spin (or similar) control.
Definition: GUIMessage.h:129
constexpr const int GUI_MSG_IS_SELECTED
Check whether a button is selected.
Definition: GUIMessage.h:124
Definition: GUIMessage.h:365
constexpr const int GUI_MSG_GESTURE_NOTIFY
A request for supported gestures is made.
Definition: GUIMessage.h:98
constexpr const int GUI_MSG_SET_TYPE
Instruct a control to set it&#39;s type appropriately.
Definition: GUIMessage.h:68
constexpr const int GUI_MSG_UI_READY
The user interface is ready for usage.
Definition: GUIMessage.h:145
constexpr const int GUI_MSG_RENDERER_RESET
Message indicating regain of renderer, after reset Any controls that keep shared resources may reallo...
Definition: GUIMessage.h:88
constexpr const int GUI_MSG_REMOVE_CONTROL
A request to remove a control.
Definition: GUIMessage.h:108
constexpr const int GUI_MSG_STATE_CHANGED
Called if state has changed which could lead to GUI changes.
Definition: GUIMessage.h:155
constexpr const int GUI_MSG_CODINGTABLE_LOOKUP_COMPLETED
Complete to get codingtable page.
Definition: GUIMessage.h:168
constexpr const int GUI_MSG_REFRESH_TIMER
Called every 500ms to allow time dependent updates.
Definition: GUIMessage.h:150
constexpr const int GUI_MSG_WINDOW_RESIZE
Message indicating the window has been resized Any controls that keep stored sizing information based...
Definition: GUIMessage.h:75
constexpr const int GUI_MSG_SUBTITLE_DOWNLOADED
Called when a subtitle download has finished.
Definition: GUIMessage.h:160