diff options
Diffstat (limited to 'xbmc/addons/AddonCallbacksGUI.h')
| -rw-r--r-- | xbmc/addons/AddonCallbacksGUI.h | 272 |
1 files changed, 0 insertions, 272 deletions
diff --git a/xbmc/addons/AddonCallbacksGUI.h b/xbmc/addons/AddonCallbacksGUI.h deleted file mode 100644 index ae032a7..0000000 --- a/xbmc/addons/AddonCallbacksGUI.h +++ /dev/null | |||
| @@ -1,272 +0,0 @@ | |||
| 1 | #pragma once | ||
| 2 | /* | ||
| 3 | * Copyright (C) 2012-2013 Team XBMC | ||
| 4 | * http://xbmc.org | ||
| 5 | * | ||
| 6 | * This Program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; either version 2, or (at your option) | ||
| 9 | * any later version. | ||
| 10 | * | ||
| 11 | * This Program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with XBMC; see the file COPYING. If not, see | ||
| 18 | * <http://www.gnu.org/licenses/>. | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | |||
| 23 | #include "AddonCallbacks.h" | ||
| 24 | #include "windows/GUIMediaWindow.h" | ||
| 25 | #include "threads/Event.h" | ||
| 26 | #include "guilib/IRenderingCallback.h" | ||
| 27 | |||
| 28 | class CGUISpinControlEx; | ||
| 29 | class CGUIButtonControl; | ||
| 30 | class CGUIRadioButtonControl; | ||
| 31 | class CGUISliderControl; | ||
| 32 | class CGUISettingsSliderControl; | ||
| 33 | class CGUIEditControl; | ||
| 34 | class CGUIRenderingControl; | ||
| 35 | |||
| 36 | namespace ADDON | ||
| 37 | { | ||
| 38 | |||
| 39 | class CAddonCallbacksGUI | ||
| 40 | { | ||
| 41 | public: | ||
| 42 | CAddonCallbacksGUI(CAddon* addon); | ||
| 43 | ~CAddonCallbacksGUI(); | ||
| 44 | |||
| 45 | /**! \name General Functions */ | ||
| 46 | CB_GUILib *GetCallbacks() { return m_callbacks; } | ||
| 47 | |||
| 48 | static void Lock(); | ||
| 49 | static void Unlock(); | ||
| 50 | static int GetScreenHeight(); | ||
| 51 | static int GetScreenWidth(); | ||
| 52 | static int GetVideoResolution(); | ||
| 53 | |||
| 54 | static GUIHANDLE Window_New(void *addonData, const char *xmlFilename, const char *defaultSkin, bool forceFallback, bool asDialog); | ||
| 55 | static void Window_Delete(void *addonData, GUIHANDLE handle); | ||
| 56 | static void Window_SetCallbacks(void *addonData, GUIHANDLE handle, GUIHANDLE clienthandle, bool (*initCB)(GUIHANDLE), bool (*clickCB)(GUIHANDLE, int), bool (*focusCB)(GUIHANDLE, int), bool (*onActionCB)(GUIHANDLE handle, int)); | ||
| 57 | static bool Window_Show(void *addonData, GUIHANDLE handle); | ||
| 58 | static bool Window_Close(void *addonData, GUIHANDLE handle); | ||
| 59 | static bool Window_DoModal(void *addonData, GUIHANDLE handle); | ||
| 60 | static bool Window_SetFocusId(void *addonData, GUIHANDLE handle, int iControlId); | ||
| 61 | static int Window_GetFocusId(void *addonData, GUIHANDLE handle); | ||
| 62 | static bool Window_SetCoordinateResolution(void *addonData, GUIHANDLE handle, int res); | ||
| 63 | static void Window_SetProperty(void *addonData, GUIHANDLE handle, const char *key, const char *value); | ||
| 64 | static void Window_SetPropertyInt(void *addonData, GUIHANDLE handle, const char *key, int value); | ||
| 65 | static void Window_SetPropertyBool(void *addonData, GUIHANDLE handle, const char *key, bool value); | ||
| 66 | static void Window_SetPropertyDouble(void *addonData, GUIHANDLE handle, const char *key, double value); | ||
| 67 | static const char * Window_GetProperty(void *addonData, GUIHANDLE handle, const char *key); | ||
| 68 | static int Window_GetPropertyInt(void *addonData, GUIHANDLE handle, const char *key); | ||
| 69 | static bool Window_GetPropertyBool(void *addonData, GUIHANDLE handle, const char *key); | ||
| 70 | static double Window_GetPropertyDouble(void *addonData, GUIHANDLE handle, const char *key); | ||
| 71 | static void Window_ClearProperties(void *addonData, GUIHANDLE handle); | ||
| 72 | static int Window_GetListSize(void *addonData, GUIHANDLE handle); | ||
| 73 | static void Window_ClearList(void *addonData, GUIHANDLE handle); | ||
| 74 | static GUIHANDLE Window_AddItem(void *addonData, GUIHANDLE handle, GUIHANDLE item, int itemPosition); | ||
| 75 | static GUIHANDLE Window_AddStringItem(void *addonData, GUIHANDLE handle, const char *itemName, int itemPosition); | ||
| 76 | static void Window_RemoveItem(void *addonData, GUIHANDLE handle, int itemPosition); | ||
| 77 | static GUIHANDLE Window_GetListItem(void *addonData, GUIHANDLE handle, int listPos); | ||
| 78 | static void Window_SetCurrentListPosition(void *addonData, GUIHANDLE handle, int listPos); | ||
| 79 | static int Window_GetCurrentListPosition(void *addonData, GUIHANDLE handle); | ||
| 80 | static GUIHANDLE Window_GetControl_Spin(void *addonData, GUIHANDLE handle, int controlId); | ||
| 81 | static GUIHANDLE Window_GetControl_Button(void *addonData, GUIHANDLE handle, int controlId); | ||
| 82 | static GUIHANDLE Window_GetControl_RadioButton(void *addonData, GUIHANDLE handle, int controlId); | ||
| 83 | static GUIHANDLE Window_GetControl_Edit(void *addonData, GUIHANDLE handle, int controlId); | ||
| 84 | static GUIHANDLE Window_GetControl_Progress(void *addonData, GUIHANDLE handle, int controlId); | ||
| 85 | static GUIHANDLE Window_GetControl_RenderAddon(void *addonData, GUIHANDLE handle, int controlId); | ||
| 86 | static void Window_SetControlLabel(void *addonData, GUIHANDLE handle, int controlId, const char *label); | ||
| 87 | static void Window_MarkDirtyRegion(void *addonData, GUIHANDLE handle); | ||
| 88 | static void Control_Spin_SetVisible(void *addonData, GUIHANDLE spinhandle, bool yesNo); | ||
| 89 | static void Control_Spin_SetText(void *addonData, GUIHANDLE spinhandle, const char *label); | ||
| 90 | static void Control_Spin_Clear(void *addonData, GUIHANDLE spinhandle); | ||
| 91 | static void Control_Spin_AddLabel(void *addonData, GUIHANDLE spinhandle, const char *label, int iValue); | ||
| 92 | static int Control_Spin_GetValue(void *addonData, GUIHANDLE spinhandle); | ||
| 93 | static void Control_Spin_SetValue(void *addonData, GUIHANDLE spinhandle, int iValue); | ||
| 94 | static void Control_RadioButton_SetVisible(void *addonData, GUIHANDLE handle, bool yesNo); | ||
| 95 | static void Control_RadioButton_SetText(void *addonData, GUIHANDLE handle, const char *label); | ||
| 96 | static void Control_RadioButton_SetSelected(void *addonData, GUIHANDLE handle, bool yesNo); | ||
| 97 | static bool Control_RadioButton_IsSelected(void *addonData, GUIHANDLE handle); | ||
| 98 | static void Control_Progress_SetPercentage(void *addonData, GUIHANDLE handle, float fPercent); | ||
| 99 | static float Control_Progress_GetPercentage(void *addonData, GUIHANDLE handle); | ||
| 100 | static void Control_Progress_SetInfo(void *addonData, GUIHANDLE handle, int iInfo); | ||
| 101 | static int Control_Progress_GetInfo(void *addonData, GUIHANDLE handle); | ||
| 102 | static const char * Control_Progress_GetDescription(void *addonData, GUIHANDLE handle); | ||
| 103 | |||
| 104 | static GUIHANDLE Window_GetControl_Slider(void *addonData, GUIHANDLE handle, int controlId); | ||
| 105 | static void Control_Slider_SetVisible(void *addonData, GUIHANDLE handle, bool yesNo); | ||
| 106 | static const char * Control_Slider_GetDescription(void *addonData, GUIHANDLE handle); | ||
| 107 | static void Control_Slider_SetIntRange(void *addonData, GUIHANDLE handle, int iStart, int iEnd); | ||
| 108 | static void Control_Slider_SetIntValue(void *addonData, GUIHANDLE handle, int iValue); | ||
| 109 | static int Control_Slider_GetIntValue(void *addonData, GUIHANDLE handle); | ||
| 110 | static void Control_Slider_SetIntInterval(void *addonData, GUIHANDLE handle, int iInterval); | ||
| 111 | static void Control_Slider_SetPercentage(void *addonData, GUIHANDLE handle, float fPercent); | ||
| 112 | static float Control_Slider_GetPercentage(void *addonData, GUIHANDLE handle); | ||
| 113 | static void Control_Slider_SetFloatRange(void *addonData, GUIHANDLE handle, float fStart, float fEnd); | ||
| 114 | static void Control_Slider_SetFloatValue(void *addonData, GUIHANDLE handle, float fValue); | ||
| 115 | static float Control_Slider_GetFloatValue(void *addonData, GUIHANDLE handle); | ||
| 116 | static void Control_Slider_SetFloatInterval(void *addonData, GUIHANDLE handle, float fInterval); | ||
| 117 | |||
| 118 | static GUIHANDLE Window_GetControl_SettingsSlider(void *addonData, GUIHANDLE handle, int controlId); | ||
| 119 | static void Control_SettingsSlider_SetVisible(void *addonData, GUIHANDLE handle, bool yesNo); | ||
| 120 | static void Control_SettingsSlider_SetText(void *addonData, GUIHANDLE handle, const char *label); | ||
| 121 | static const char * Control_SettingsSlider_GetDescription(void *addonData, GUIHANDLE handle); | ||
| 122 | static void Control_SettingsSlider_SetIntRange(void *addonData, GUIHANDLE handle, int iStart, int iEnd); | ||
| 123 | static void Control_SettingsSlider_SetIntValue(void *addonData, GUIHANDLE handle, int iValue); | ||
| 124 | static int Control_SettingsSlider_GetIntValue(void *addonData, GUIHANDLE handle); | ||
| 125 | static void Control_SettingsSlider_SetIntInterval(void *addonData, GUIHANDLE handle, int iInterval); | ||
| 126 | static void Control_SettingsSlider_SetPercentage(void *addonData, GUIHANDLE handle, float fPercent); | ||
| 127 | static float Control_SettingsSlider_GetPercentage(void *addonData, GUIHANDLE handle); | ||
| 128 | static void Control_SettingsSlider_SetFloatRange(void *addonData, GUIHANDLE handle, float fStart, float fEnd); | ||
| 129 | static void Control_SettingsSlider_SetFloatValue(void *addonData, GUIHANDLE handle, float fValue); | ||
| 130 | static float Control_SettingsSlider_GetFloatValue(void *addonData, GUIHANDLE handle); | ||
| 131 | static void Control_SettingsSlider_SetFloatInterval(void *addonData, GUIHANDLE handle, float fInterval); | ||
| 132 | |||
| 133 | static GUIHANDLE ListItem_Create(void *addonData, const char *label, const char *label2, const char *iconImage, const char *thumbnailImage, const char *path); | ||
| 134 | static const char * ListItem_GetLabel(void *addonData, GUIHANDLE handle); | ||
| 135 | static void ListItem_SetLabel(void *addonData, GUIHANDLE handle, const char *label); | ||
| 136 | static const char * ListItem_GetLabel2(void *addonData, GUIHANDLE handle); | ||
| 137 | static void ListItem_SetLabel2(void *addonData, GUIHANDLE handle, const char *label); | ||
| 138 | static void ListItem_SetIconImage(void *addonData, GUIHANDLE handle, const char *image); | ||
| 139 | static void ListItem_SetThumbnailImage(void *addonData, GUIHANDLE handle, const char *image); | ||
| 140 | static void ListItem_SetInfo(void *addonData, GUIHANDLE handle, const char *info); | ||
| 141 | static void ListItem_SetProperty(void *addonData, GUIHANDLE handle, const char *key, const char *value); | ||
| 142 | static const char * ListItem_GetProperty(void *addonData, GUIHANDLE handle, const char *key); | ||
| 143 | static void ListItem_SetPath(void *addonData, GUIHANDLE handle, const char *path); | ||
| 144 | static void RenderAddon_SetCallbacks(void *addonData, GUIHANDLE handle, GUIHANDLE clienthandle, bool (*createCB)(GUIHANDLE,int,int,int,int,void*), void (*renderCB)(GUIHANDLE), void (*stopCB)(GUIHANDLE), bool (*dirtyCB)(GUIHANDLE)); | ||
| 145 | static void RenderAddon_Delete(void *addonData, GUIHANDLE handle); | ||
| 146 | static void RenderAddon_MarkDirty(void *addonData, GUIHANDLE handle); | ||
| 147 | |||
| 148 | static bool Dialog_Keyboard_ShowAndGetInput(char &aTextString, unsigned int iMaxStringSize, bool allowEmptyResult, unsigned int autoCloseMs); | ||
| 149 | static bool Dialog_Keyboard_ShowAndGetInputWithHead(char &aTextString, unsigned int iMaxStringSize, const char *heading, bool allowEmptyResult, bool hiddenInput, unsigned int autoCloseMs); | ||
| 150 | static bool Dialog_Keyboard_ShowAndGetNewPassword(char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs); | ||
| 151 | static bool Dialog_Keyboard_ShowAndGetNewPasswordWithHead(char &newPassword, unsigned int iMaxStringSize, const char *strHeading, bool allowEmptyResult, unsigned int autoCloseMs); | ||
| 152 | static bool Dialog_Keyboard_ShowAndVerifyNewPassword(char &strNewPassword, unsigned int iMaxStringSize, unsigned int autoCloseMs); | ||
| 153 | static bool Dialog_Keyboard_ShowAndVerifyNewPasswordWithHead(char &strNewPassword, unsigned int iMaxStringSize, const char *strHeading, bool allowEmpty, unsigned int autoCloseMs); | ||
| 154 | static int Dialog_Keyboard_ShowAndVerifyPassword(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries, unsigned int autoCloseMs); | ||
| 155 | static bool Dialog_Keyboard_ShowAndGetFilter(char &aTextString, unsigned int iMaxStringSize, bool searching, unsigned int autoCloseMs); | ||
| 156 | static bool Dialog_Keyboard_SendTextToActiveKeyboard(const char *aTextString, bool closeKeyboard); | ||
| 157 | static bool Dialog_Keyboard_isKeyboardActivated(); | ||
| 158 | |||
| 159 | static bool Dialog_Numeric_ShowAndVerifyNewPassword(char &strNewPasswor, unsigned int iMaxStringSized); | ||
| 160 | static int Dialog_Numeric_ShowAndVerifyPassword(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, int iRetries); | ||
| 161 | static bool Dialog_Numeric_ShowAndVerifyInput(char &strPassword, unsigned int iMaxStringSize, const char *strHeading, bool bGetUserInput); | ||
| 162 | static bool Dialog_Numeric_ShowAndGetTime(tm &time, const char *strHeading); | ||
| 163 | static bool Dialog_Numeric_ShowAndGetDate(tm &date, const char *strHeading); | ||
| 164 | static bool Dialog_Numeric_ShowAndGetIPAddress(char &strIPAddress, unsigned int iMaxStringSize, const char *strHeading); | ||
| 165 | static bool Dialog_Numeric_ShowAndGetNumber(char &strInput, unsigned int iMaxStringSize, const char *strHeading, unsigned int iAutoCloseTimeoutMs); | ||
| 166 | static bool Dialog_Numeric_ShowAndGetSeconds(char &timeString, unsigned int iMaxStringSize, const char *strHeading); | ||
| 167 | |||
| 168 | static bool Dialog_FileBrowser_ShowAndGetFile(const char *directory, const char *mask, const char *heading, char &path, unsigned int iMaxStringSize, bool useThumbs, bool useFileDirectories, bool singleList); | ||
| 169 | |||
| 170 | static void Dialog_OK_ShowAndGetInputSingleText(const char *heading, const char *text); | ||
| 171 | static void Dialog_OK_ShowAndGetInputLineText(const char *heading, const char *line0, const char *line1, const char *line2); | ||
| 172 | |||
| 173 | static bool Dialog_YesNo_ShowAndGetInputSingleText(const char *heading, const char *text, bool& bCanceled, const char *noLabel, const char *yesLabel); | ||
| 174 | static bool Dialog_YesNo_ShowAndGetInputLineText(const char *heading, const char *line0, const char *line1, const char *line2, const char *noLabel, const char *yesLabel); | ||
| 175 | static bool Dialog_YesNo_ShowAndGetInputLineButtonText(const char *heading, const char *line0, const char *line1, const char *line2, bool &bCanceled, const char *noLabel, const char *yesLabel); | ||
| 176 | |||
| 177 | static void Dialog_TextViewer(const char *heading, const char *text); | ||
| 178 | static int Dialog_Select(const char *heading, const char *entries[], unsigned int size, int selected); | ||
| 179 | |||
| 180 | private: | ||
| 181 | CB_GUILib *m_callbacks; | ||
| 182 | CAddon *m_addon; | ||
| 183 | }; | ||
| 184 | |||
| 185 | class CGUIAddonWindow : public CGUIMediaWindow | ||
| 186 | { | ||
| 187 | friend class CAddonCallbacksGUI; | ||
| 188 | |||
| 189 | public: | ||
| 190 | CGUIAddonWindow(int id, const std::string& strXML, CAddon* addon); | ||
| 191 | virtual ~CGUIAddonWindow(void); | ||
| 192 | |||
| 193 | virtual bool OnMessage(CGUIMessage& message); | ||
| 194 | virtual bool OnAction(const CAction &action); | ||
| 195 | virtual void AllocResources(bool forceLoad = false); | ||
| 196 | virtual void FreeResources(bool forceUnLoad = false); | ||
| 197 | virtual void Render(); | ||
| 198 | void WaitForActionEvent(unsigned int timeout); | ||
| 199 | void PulseActionEvent(); | ||
| 200 | void AddItem(CFileItemPtr fileItem, int itemPosition); | ||
| 201 | void RemoveItem(int itemPosition); | ||
| 202 | void ClearList(); | ||
| 203 | CFileItemPtr GetListItem(int position); | ||
| 204 | int GetListSize(); | ||
| 205 | int GetCurrentListPosition(); | ||
| 206 | void SetCurrentListPosition(int item); | ||
| 207 | virtual bool OnClick(int iItem); | ||
| 208 | |||
| 209 | protected: | ||
| 210 | virtual void Update(); | ||
| 211 | virtual void GetContextButtons(int itemNumber, CContextButtons &buttons); | ||
| 212 | void SetupShares(); | ||
| 213 | |||
| 214 | bool (*CBOnInit)(GUIHANDLE cbhdl); | ||
| 215 | bool (*CBOnFocus)(GUIHANDLE cbhdl, int controlId); | ||
| 216 | bool (*CBOnClick)(GUIHANDLE cbhdl, int controlId); | ||
| 217 | bool (*CBOnAction)(GUIHANDLE cbhdl, int); | ||
| 218 | |||
| 219 | GUIHANDLE m_clientHandle; | ||
| 220 | const int m_iWindowId; | ||
| 221 | int m_iOldWindowId; | ||
| 222 | bool m_bModal; | ||
| 223 | bool m_bIsDialog; | ||
| 224 | |||
| 225 | private: | ||
| 226 | CEvent m_actionEvent; | ||
| 227 | CAddon *m_addon; | ||
| 228 | std::string m_mediaDir; | ||
| 229 | }; | ||
| 230 | |||
| 231 | class CGUIAddonWindowDialog : public CGUIAddonWindow | ||
| 232 | { | ||
| 233 | public: | ||
| 234 | CGUIAddonWindowDialog(int id, const std::string& strXML, CAddon* addon); | ||
| 235 | virtual ~CGUIAddonWindowDialog(void); | ||
| 236 | |||
| 237 | void Show(bool show = true); | ||
| 238 | virtual bool OnMessage(CGUIMessage &message); | ||
| 239 | virtual bool IsDialogRunning() const { return m_bRunning; } | ||
| 240 | virtual bool IsDialog() const { return true;}; | ||
| 241 | virtual bool IsModalDialog() const { return true; }; | ||
| 242 | virtual bool IsMediaWindow() const { return false; }; | ||
| 243 | |||
| 244 | void Show_Internal(bool show = true); | ||
| 245 | |||
| 246 | private: | ||
| 247 | bool m_bRunning; | ||
| 248 | }; | ||
| 249 | |||
| 250 | class CGUIAddonRenderingControl : public IRenderingCallback | ||
| 251 | { | ||
| 252 | friend class CAddonCallbacksGUI; | ||
| 253 | public: | ||
| 254 | CGUIAddonRenderingControl(CGUIRenderingControl *pControl); | ||
| 255 | virtual ~CGUIAddonRenderingControl() {} | ||
| 256 | virtual bool Create(int x, int y, int w, int h, void *device); | ||
| 257 | virtual void Render(); | ||
| 258 | virtual void Stop(); | ||
| 259 | virtual bool IsDirty(); | ||
| 260 | virtual void Delete(); | ||
| 261 | protected: | ||
| 262 | bool (*CBCreate) (GUIHANDLE cbhdl, int x, int y, int w, int h, void *device); | ||
| 263 | void (*CBRender)(GUIHANDLE cbhdl); | ||
| 264 | void (*CBStop)(GUIHANDLE cbhdl); | ||
| 265 | bool (*CBDirty)(GUIHANDLE cbhdl); | ||
| 266 | |||
| 267 | GUIHANDLE m_clientHandle; | ||
| 268 | CGUIRenderingControl *m_pControl; | ||
| 269 | int m_refCount; | ||
| 270 | }; | ||
| 271 | |||
| 272 | }; /* namespace ADDON */ | ||
