Kodi Development 22.0
for Binary and Script based Add-Ons
 
Loading...
Searching...
No Matches
Window.h
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
11#include "AddonCallback.h"
12#include "AddonString.h"
13#include "Control.h"
14#include "swighelper.h"
15
16#include <limits.h>
17#include <mutex>
18#include <vector>
19
20namespace XBMCAddon
21{
22 namespace xbmcgui
23 {
24 // Forward declare the interceptor as the AddonWindowInterceptor.h
25 // file needs to include the Window class because of the template
26 class InterceptorBase;
27
28 //
43 class Action : public AddonClass
44 {
45 public:
46 Action() = default;
47
48#ifndef SWIG
49 explicit Action(const CAction& caction) { setFromCAction(caction); }
50
51 void setFromCAction(const CAction& caction);
52
53 long id = -1;
54 float fAmount1 = 0.0f;
55 float fAmount2 = 0.0f;
56 float fRepeat = 0.0f;
57 unsigned long buttonCode = 0;
58 std::string strAction;
59
60 // Not sure if this is correct but it's here for now.
61 AddonClass::Ref<Control> control; // previously pObject
62#endif
63
64#ifdef DOXYGEN_SHOULD_USE_THIS
90#else
91 long getId() { XBMC_TRACE; return id; }
92#endif
93
94#ifdef DOXYGEN_SHOULD_USE_THIS
103#else
104 long getButtonCode() { XBMC_TRACE; return buttonCode; }
105#endif
106
107#ifdef DOXYGEN_SHOULD_USE_THIS
116#else
117 float getAmount1() { XBMC_TRACE; return fAmount1; }
118#endif
119
120#ifdef DOXYGEN_SHOULD_USE_THIS
129#else
130 float getAmount2() { XBMC_TRACE; return fAmount2; }
131#endif
132 };
134
135 //==========================================================================
136 // This is the main class for the xbmcgui.Window functionality. It is tied
137 // into the main Kodi windowing system via the Interceptor
138 //==========================================================================
139 //
185 //
186 class Window : public AddonCallback
187 {
188 friend class WindowDialogMixin;
189 bool isDisposed = false;
190
191 void doAddControl(Control* pControl, CCriticalSection* gcontext, bool wait);
192 void doRemoveControl(Control* pControl, CCriticalSection* gcontext, bool wait);
193
194 protected:
195#ifndef SWIG
196 InterceptorBase* window;
197 int iWindowId = -1;
198
199 std::vector<AddonClass::Ref<Control> > vecControls;
200 int iOldWindowId = 0;
201 int iCurrentControlId = 3000;
202 bool bModal = false;
203 CEvent m_actionEvent;
204
205 bool canPulse = false;
206
207 // I REALLY hate this ... but it's the simplest fix right now.
208 bool existingWindow = true;
209 bool destroyAfterDeInit = false;
210
217 explicit Window(bool discrim);
218
219 void deallocating() override;
220
226
232 void setWindow(InterceptorBase* _window);
233
239
244 Control* GetControlById(int iControlId, CCriticalSection* gc);
245
246 SWIGHIDDENVIRTUAL void PulseActionEvent();
247 SWIGHIDDENVIRTUAL bool WaitForActionEvent(unsigned int milliseconds);
248#endif
249
250 public:
251 explicit Window(int existingWindowId = -1);
252
253 ~Window() override;
254
255#ifndef SWIG
256 SWIGHIDDENVIRTUAL bool OnMessage(CGUIMessage& message);
257 SWIGHIDDENVIRTUAL bool OnAction(const CAction &action);
258 SWIGHIDDENVIRTUAL bool OnBack(int actionId);
259 SWIGHIDDENVIRTUAL void OnDeinitWindow(int nextWindowID);
260
261 SWIGHIDDENVIRTUAL bool IsDialogRunning() const
262 {
263 XBMC_TRACE;
264 return false;
265 }
266 SWIGHIDDENVIRTUAL bool IsDialog() const
267 {
268 XBMC_TRACE;
269 return false;
270 }
271 SWIGHIDDENVIRTUAL bool IsModalDialog() const
272 {
273 XBMC_TRACE;
274 return false;
275 }
276 SWIGHIDDENVIRTUAL bool IsMediaWindow() const
277 {
278 XBMC_TRACE;
279 return false;
280 }
281 SWIGHIDDENVIRTUAL void dispose();
282
287 inline void interceptorClear()
288 {
289 std::unique_lock<CCriticalSection> lock(*this);
290 window = NULL;
291 }
292#endif
293
294 //
312 //
313
314 // callback takes a parameter
315#ifdef DOXYGEN_SHOULD_USE_THIS
357#else
358 virtual void onAction(Action* action);
359#endif
360
361 // on control is not actually on Window in the api but is called into Python anyway.
362#ifdef DOXYGEN_SHOULD_USE_THIS
386 void onControl(...);
387#else
388 virtual void onControl(Control* control);
389#endif
390
391#ifdef DOXYGEN_SHOULD_USE_THIS
418#else
419 virtual void onClick(int controlId);
420#endif
421
422#ifdef DOXYGEN_SHOULD_USE_THIS
449#else
450 virtual void onDoubleClick(int controlId);
451#endif
452
453#ifdef DOXYGEN_SHOULD_USE_THIS
479#else
480 virtual void onFocus(int controlId);
481#endif
482
483#ifdef DOXYGEN_SHOULD_USE_THIS
505 onInit(...);
506#else
507 virtual void onInit();
508#endif
510
511#ifdef DOXYGEN_SHOULD_USE_THIS
525#else
526 SWIGHIDDENVIRTUAL void show();
527#endif
528
529#ifdef DOXYGEN_SHOULD_USE_THIS
542#else
543 SWIGHIDDENVIRTUAL void setFocus(Control* pControl);
544#endif
545
546#ifdef DOXYGEN_SHOULD_USE_THIS
557#else
558 SWIGHIDDENVIRTUAL void setFocusId(int iControlId);
559#endif
560
561#ifdef DOXYGEN_SHOULD_USE_THIS
572#else
573 SWIGHIDDENVIRTUAL Control* getFocus();
574#endif
575
576#ifdef DOXYGEN_SHOULD_USE_THIS
587#else
588 SWIGHIDDENVIRTUAL long getFocusId();
589#endif
590
591#ifdef DOXYGEN_SHOULD_USE_THIS
605#else
606 SWIGHIDDENVIRTUAL void removeControl(Control* pControl);
607#endif
608
609#ifdef DOXYGEN_SHOULD_USE_THIS
624#else
625 SWIGHIDDENVIRTUAL void removeControls(std::vector<Control*> pControls);
626#endif
627
628#ifdef DOXYGEN_SHOULD_USE_THIS
640#else
641 SWIGHIDDENVIRTUAL long getHeight();
642#endif
643
644#ifdef DOXYGEN_SHOULD_USE_THIS
656#else
657 SWIGHIDDENVIRTUAL long getWidth();
658#endif
659
660#ifdef DOXYGEN_SHOULD_USE_THIS
688#else
689 SWIGHIDDENVIRTUAL void setProperty(const char* key, const String& value);
690#endif
691
692#ifdef DOXYGEN_SHOULD_USE_THIS
718#else
719 SWIGHIDDENVIRTUAL String getProperty(const char* key);
720#endif
721
722#ifdef DOXYGEN_SHOULD_USE_THIS
748#else
749 SWIGHIDDENVIRTUAL void clearProperty(const char* key);
750#endif
751
752#ifdef DOXYGEN_SHOULD_USE_THIS
770#else
771 SWIGHIDDENVIRTUAL void clearProperties();
772#endif
773
774#ifdef DOXYGEN_SHOULD_USE_THIS
785#else
786 SWIGHIDDENVIRTUAL void close();
787#endif
788
789#ifdef DOXYGEN_SHOULD_USE_THIS
796#else
797
798 SWIGHIDDENVIRTUAL void doModal();
799#endif
800
801#ifdef DOXYGEN_SHOULD_USE_THIS
833#else
834 SWIGHIDDENVIRTUAL void addControl(Control* pControl);
835#endif
836
837#ifdef DOXYGEN_SHOULD_USE_THIS
852#else
853 SWIGHIDDENVIRTUAL void addControls(std::vector<Control*> pControls);
854#endif
855
856#ifdef DOXYGEN_SHOULD_USE_THIS
872#else
873 SWIGHIDDENVIRTUAL Control* getControl(int iControlId);
874#endif
875 };
877 }
878}
Action class.
Definition Window.h:44
Definition Control.h:62
Definition Window.h:187
static int getNextAvailableWindowId()
void setWindow(InterceptorBase *_window)
void interceptorClear()
Definition Window.h:287
Control * GetControlById(int iControlId, CCriticalSection *gc)
getButtonCode()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getId()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getAmount1()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getAmount2()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
onInit(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
onAction(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
onDoubleClick(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
onClick(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
onFocus(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
void onControl(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
removeControls(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
setFocusId(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
removeControl(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
clearProperty(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getProperty(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
show()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
clearProperties()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getFocusId()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
addControl(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
setFocus(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
addControls(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
setProperty(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
close()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getHeight()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getFocus()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getWidth()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
getControl(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
doModal()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...