6 #ifndef GUILIB_MESSAGE_H
7 #define GUILIB_MESSAGE_H
12 * Copyright (C) 2005-2008 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, write to
27 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
28 * http://www.gnu.org/copyleft/gpl.html
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
36 #define GUI_MSG_SETFOCUS 3 // set focus to control param1=up/down/left/right
37 #define GUI_MSG_LOSTFOCUS 4 // control lost focus
39 #define GUI_MSG_CLICKED 5 // control has been clicked
41 #define GUI_MSG_VISIBLE 6 // set control visible
42 #define GUI_MSG_HIDDEN 7 // set control hidden
44 #define GUI_MSG_ENABLED 8 // enable control
45 #define GUI_MSG_DISABLED 9 // disable control
47 #define GUI_MSG_SELECTED 10 // control = selected
48 #define GUI_MSG_DESELECTED 11 // control = not selected
50 #define GUI_MSG_LABEL_ADD 12 // add label control (for controls supporting more then 1 label)
52 #define GUI_MSG_LABEL_SET 13 // set the label of a control
54 #define GUI_MSG_LABEL_RESET 14 // clear all labels of a control // add label control (for controls supporting more then 1 label)
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
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
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
67 #define GUI_MSG_REFRESH_THUMBS 22 // message is sent to all windows to refresh all thumbs
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.
72 #define GUI_MSG_LABEL_BIND 24 // bind label control (for controls supporting more then 1 label)
74 #define GUI_MSG_SELCHANGED 25 // selection within the control has changed
76 #define GUI_MSG_FOCUSED 26 // a control has become focused
78 #define GUI_MSG_PAGE_CHANGE 28 // a page control has changed the page number
80 #define GUI_MSG_REFRESH_LIST 29 // message sent to all listing controls telling them to refresh their item layouts
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
86 #define GUI_MSG_SET_TYPE 33 ///< Instruct a control to set it's type appropriately
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
93 #define GUI_MSG_WINDOW_RESIZE 34
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
100 #define GUI_MSG_RENDERER_LOST 35
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
106 #define GUI_MSG_RENDERER_RESET 36
109 \brief A control wishes to have (or release) exclusive access to mouse actions
111 #define GUI_MSG_EXCLUSIVE_MOUSE 37
114 \brief A request for supported gestures is made
116 #define GUI_MSG_GESTURE_NOTIFY 38
119 \brief A request to add a control
121 #define GUI_MSG_ADD_CONTROL 39
124 \brief A request to remove a control
126 #define GUI_MSG_REMOVE_CONTROL 40
129 \brief A request to unfocus all currently focused controls
131 #define GUI_MSG_UNFOCUS_ALL 41
133 #define GUI_MSG_SET_TEXT 42
135 #define GUI_MSG_USER 1000
141 #define CONTROL_SELECT(controlID) \
143 CGUIMessage msg(GUI_MSG_SELECTED, GetID(), controlID); \
151 #define CONTROL_DESELECT(controlID) \
153 CGUIMessage msg(GUI_MSG_DESELECTED, GetID(), controlID); \
162 #define CONTROL_ENABLE(controlID) \
164 CGUIMessage msg(GUI_MSG_ENABLED, GetID(), controlID); \
172 #define CONTROL_DISABLE(controlID) \
174 CGUIMessage msg(GUI_MSG_DISABLED, GetID(), controlID); \
183 #define CONTROL_ENABLE_ON_CONDITION(controlID, bCondition) \
185 CGUIMessage msg(bCondition ? GUI_MSG_ENABLED:GUI_MSG_DISABLED, GetID(), controlID); \
194 #define CONTROL_SELECT_ITEM(controlID,iItem) \
196 CGUIMessage msg(GUI_MSG_ITEM_SELECT, GetID(), controlID,iItem); \
202 \brief Set the label of the current control
204 #define SET_CONTROL_LABEL(controlID,label) \
206 CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), controlID); \
207 msg.SetLabel(label); \
213 \brief Set the second label of the current control
215 #define SET_CONTROL_LABEL2(controlID,label) \
217 CGUIMessage msg(GUI_MSG_LABEL2_SET, GetID(), controlID); \
218 msg.SetLabel(label); \
226 #define SET_CONTROL_HIDDEN(controlID) \
228 CGUIMessage msg(GUI_MSG_HIDDEN, GetID(), controlID); \
236 #define SET_CONTROL_FOCUS(controlID, dwParam) \
238 CGUIMessage msg(GUI_MSG_SETFOCUS, GetID(), controlID, dwParam); \
246 #define SET_CONTROL_VISIBLE(controlID) \
248 CGUIMessage msg(GUI_MSG_VISIBLE, GetID(), controlID); \
252 #define SET_CONTROL_SELECTED(dwSenderId, controlID, bSelect) \
254 CGUIMessage msg(bSelect?GUI_MSG_SELECTED:GUI_MSG_DESELECTED, dwSenderId, controlID); \
258 #define BIND_CONTROL(i,c,pv) \
260 pv = ((c*)GetControl(i));\
265 \brief Click message sent from controls to windows.
267 #define SEND_CLICK_MESSAGE(id, parentID, action) \
269 CGUIMessage msg(GUI_MSG_CLICKED, id, parentID, action); \
270 SendWindowMessage(msg); \
274 #include <boost/shared_ptr.hpp>
275 #include "utils/StdString.h"
278 class CGUIListItem; typedef boost::shared_ptr<CGUIListItem> CGUIListItemPtr;
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);
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> ¶ms);
310 const CStdString& GetStringParam(size_t param = 0) const;
311 size_t GetNumStringParams() const;
314 std::string m_strLabel;
315 std::vector<CStdString> m_params;
322 CGUIListItemPtr m_item;
324 static CStdString empty_string;