6 #ifndef GUILIB_MESSAGE_H
7 #define GUILIB_MESSAGE_H
12 * Copyright (C) 2005-2013 Team XBMC
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)
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.
25 * You should have received a copy of the GNU General Public License
26 * along with XBMC; see the file COPYING. If not, see
27 * <http://www.gnu.org/licenses/>.
31 #define GUI_MSG_WINDOW_INIT 1 // initialize window
32 #define GUI_MSG_WINDOW_DEINIT 2 // deinit window
33 #define GUI_MSG_WINDOW_RESET 27 // reset window to initial state
35 #define GUI_MSG_SETFOCUS 3 // set focus to control param1=up/down/left/right
36 #define GUI_MSG_LOSTFOCUS 4 // control lost focus
38 #define GUI_MSG_CLICKED 5 // control has been clicked
40 #define GUI_MSG_VISIBLE 6 // set control visible
41 #define GUI_MSG_HIDDEN 7 // set control hidden
43 #define GUI_MSG_ENABLED 8 // enable control
44 #define GUI_MSG_DISABLED 9 // disable control
46 #define GUI_MSG_SELECTED 10 // control = selected
47 #define GUI_MSG_DESELECTED 11 // control = not selected
49 #define GUI_MSG_LABEL_ADD 12 // add label control (for controls supporting more then 1 label)
51 #define GUI_MSG_LABEL_SET 13 // set the label of a control
53 #define GUI_MSG_LABEL_RESET 14 // clear all labels of a control // add label control (for controls supporting more then 1 label)
55 #define GUI_MSG_ITEM_SELECTED 15 // ask control 2 return the selected item
56 #define GUI_MSG_ITEM_SELECT 16 // ask control 2 select a specific item
57 #define GUI_MSG_LABEL2_SET 17
58 #define GUI_MSG_SHOWRANGE 18
60 #define GUI_MSG_FULLSCREEN 19 // should go to fullscreen window (vis or video)
61 #define GUI_MSG_EXECUTE 20 // user has clicked on a button with <execute> tag
63 #define GUI_MSG_NOTIFY_ALL 21 // message will be send to all active and inactive(!) windows, all active modal and modeless dialogs
64 // dwParam1 must contain an additional message the windows should react on
66 #define GUI_MSG_REFRESH_THUMBS 22 // message is sent to all windows to refresh all thumbs
68 #define GUI_MSG_MOVE 23 // message is sent to the window from the base control class when it's
69 // been asked to move. dwParam1 contains direction.
71 #define GUI_MSG_LABEL_BIND 24 // bind label control (for controls supporting more then 1 label)
73 #define GUI_MSG_SELCHANGED 25 // selection within the control has changed
75 #define GUI_MSG_FOCUSED 26 // a control has become focused
77 #define GUI_MSG_PAGE_CHANGE 28 // a page control has changed the page number
79 #define GUI_MSG_REFRESH_LIST 29 // message sent to all listing controls telling them to refresh their item layouts
81 #define GUI_MSG_PAGE_UP 30 // page up
82 #define GUI_MSG_PAGE_DOWN 31 // page down
83 #define GUI_MSG_MOVE_OFFSET 32 // Instruct the contorl to MoveUp or MoveDown by offset amount
85 #define GUI_MSG_SET_TYPE 33 ///< Instruct a control to set it's type appropriately
88 \brief Message indicating the window has been resized
89 Any controls that keep stored sizing information based on aspect ratio or window size should
90 recalculate sizing information
92 #define GUI_MSG_WINDOW_RESIZE 34
95 \brief Message indicating loss of renderer, prior to reset
96 Any controls that keep shared resources should free them on receipt of this message, as the renderer
99 #define GUI_MSG_RENDERER_LOST 35
102 \brief Message indicating regain of renderer, after reset
103 Any controls that keep shared resources may reallocate them now that the renderer is back
105 #define GUI_MSG_RENDERER_RESET 36
108 \brief A control wishes to have (or release) exclusive access to mouse actions
110 #define GUI_MSG_EXCLUSIVE_MOUSE 37
113 \brief A request for supported gestures is made
115 #define GUI_MSG_GESTURE_NOTIFY 38
118 \brief A request to add a control
120 #define GUI_MSG_ADD_CONTROL 39
123 \brief A request to remove a control
125 #define GUI_MSG_REMOVE_CONTROL 40
128 \brief A request to unfocus all currently focused controls
130 #define GUI_MSG_UNFOCUS_ALL 41
132 #define GUI_MSG_SET_TEXT 42
134 #define GUI_MSG_WINDOW_LOAD 43
136 #define GUI_MSG_VALIDITY_CHANGED 44
138 #define GUI_MSG_USER 1000
144 #define CONTROL_SELECT(controlID) \
146 CGUIMessage msg(GUI_MSG_SELECTED, GetID(), controlID); \
154 #define CONTROL_DESELECT(controlID) \
156 CGUIMessage msg(GUI_MSG_DESELECTED, GetID(), controlID); \
165 #define CONTROL_ENABLE(controlID) \
167 CGUIMessage msg(GUI_MSG_ENABLED, GetID(), controlID); \
175 #define CONTROL_DISABLE(controlID) \
177 CGUIMessage msg(GUI_MSG_DISABLED, GetID(), controlID); \
186 #define CONTROL_ENABLE_ON_CONDITION(controlID, bCondition) \
188 CGUIMessage msg(bCondition ? GUI_MSG_ENABLED:GUI_MSG_DISABLED, GetID(), controlID); \
197 #define CONTROL_SELECT_ITEM(controlID,iItem) \
199 CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), controlID,iItem); \
205 \brief Set the label of the current control
207 #define SET_CONTROL_LABEL(controlID,label) \
209 CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), controlID); \
210 msg.SetLabel(label); \
216 \brief Set the label of the current control
218 #define SET_CONTROL_LABEL_THREAD_SAFE(controlID,label) \
220 CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), controlID); \
221 msg.SetLabel(label); \
222 if(g_application.IsCurrentThread()) \
225 g_windowManager.SendThreadMessage(msg, GetID()); \
230 \brief Set the second label of the current control
232 #define SET_CONTROL_LABEL2(controlID,label) \
234 CGUIMessage msg(GUI_MSG_LABEL2_SET, GetID(), controlID); \
235 msg.SetLabel(label); \
243 #define SET_CONTROL_HIDDEN(controlID) \
245 CGUIMessage msg(GUI_MSG_HIDDEN, GetID(), controlID); \
253 #define SET_CONTROL_FOCUS(controlID, dwParam) \
255 CGUIMessage msg(GUI_MSG_SETFOCUS, GetID(), controlID, dwParam); \
263 #define SET_CONTROL_VISIBLE(controlID) \
265 CGUIMessage msg(GUI_MSG_VISIBLE, GetID(), controlID); \
269 #define SET_CONTROL_SELECTED(dwSenderId, controlID, bSelect) \
271 CGUIMessage msg(bSelect?GUI_MSG_SELECTED:GUI_MSG_DESELECTED, dwSenderId, controlID); \
275 #define BIND_CONTROL(i,c,pv) \
277 pv = ((c*)GetControl(i));\
282 \brief Click message sent from controls to windows.
284 #define SEND_CLICK_MESSAGE(id, parentID, action) \
286 CGUIMessage msg(GUI_MSG_CLICKED, id, parentID, action); \
287 SendWindowMessage(msg); \
291 #include <boost/shared_ptr.hpp>
292 #include "utils/StdString.h"
295 class CGUIListItem; typedef boost::shared_ptr<CGUIListItem> CGUIListItemPtr;
305 CGUIMessage(int dwMsg, int senderID, int controlID, int param1 = 0, int param2 = 0);
306 CGUIMessage(int msg, int senderID, int controlID, int param1, int param2, CFileItemList* item);
307 CGUIMessage(int msg, int senderID, int controlID, int param1, int param2, const CGUIListItemPtr &item);
308 CGUIMessage(const CGUIMessage& msg);
309 virtual ~CGUIMessage(void);
310 CGUIMessage& operator = (const CGUIMessage& msg);
312 int GetControlId() const ;
313 int GetMessage() const;
314 void* GetPointer() const;
315 CGUIListItemPtr GetItem() const;
316 int GetParam1() const;
317 int GetParam2() const;
318 int GetSenderId() const;
319 void SetParam1(int param1);
320 void SetParam2(int param2);
321 void SetPointer(void* pointer);
322 void SetLabel(const std::string& strLabel);
323 void SetLabel(int iString); // for convience - looks up in strings.xml
324 const std::string& GetLabel() const;
325 void SetStringParam(const CStdString &strParam);
326 void SetStringParams(const std::vector<CStdString> ¶ms);
327 const CStdString& GetStringParam(size_t param = 0) const;
328 size_t GetNumStringParams() const;
331 std::string m_strLabel;
332 std::vector<CStdString> m_params;
339 CGUIListItemPtr m_item;
341 static CStdString empty_string;