Kodi Development 19.0
for Binary and Script based Add-Ons
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 <vector>
18
19namespace XBMCAddon
20{
21 namespace xbmcgui
22 {
23 // Forward declare the interceptor as the AddonWindowInterceptor.h
24 // file needs to include the Window class because of the template
25 class InterceptorBase;
26
27 //
42 class Action : public AddonClass
43 {
44 public:
45 Action() = default;
46
47#ifndef SWIG
48 explicit Action(const CAction& caction) { setFromCAction(caction); }
49
50 void setFromCAction(const CAction& caction);
51
52 long id = -1;
53 float fAmount1 = 0.0f;
54 float fAmount2 = 0.0f;
55 float fRepeat = 0.0f;
56 unsigned long buttonCode = 0;
57 std::string strAction;
58
59 // Not sure if this is correct but it's here for now.
60 AddonClass::Ref<Control> control; // previously pObject
61#endif
62
63#ifdef DOXYGEN_SHOULD_USE_THIS
89#else
90 long getId() { XBMC_TRACE; return id; }
91#endif
92
93#ifdef DOXYGEN_SHOULD_USE_THIS
102#else
103 long getButtonCode() { XBMC_TRACE; return buttonCode; }
104#endif
105
106#ifdef DOXYGEN_SHOULD_USE_THIS
115#else
116 float getAmount1() { XBMC_TRACE; return fAmount1; }
117#endif
118
119#ifdef DOXYGEN_SHOULD_USE_THIS
128#else
129 float getAmount2() { XBMC_TRACE; return fAmount2; }
130#endif
131 };
133
134 //==========================================================================
135 // This is the main class for the xbmcgui.Window functionality. It is tied
136 // into the main Kodi windowing system via the Interceptor
137 //==========================================================================
138 //
184 //
185 class Window : public AddonCallback
186 {
187 friend class WindowDialogMixin;
188 bool isDisposed = false;
189
190 void doAddControl(Control* pControl, CCriticalSection* gcontext, bool wait);
191 void doRemoveControl(Control* pControl, CCriticalSection* gcontext, bool wait);
192
193 protected:
194#ifndef SWIG
195 InterceptorBase* window;
196 int iWindowId = -1;
197
198 std::vector<AddonClass::Ref<Control> > vecControls;
199 int iOldWindowId = 0;
200 int iCurrentControlId = 3000;
201 bool bModal = false;
202 CEvent m_actionEvent;
203
204 bool canPulse = false;
205
206 // I REALLY hate this ... but it's the simplest fix right now.
207 bool existingWindow = true;
208 bool destroyAfterDeInit = false;
209
216 explicit Window(bool discrim);
217
218 void deallocating() override;
219
225
231 void setWindow(InterceptorBase* _window);
232
238
243 Control* GetControlById(int iControlId, CCriticalSection* gc);
244
245 SWIGHIDDENVIRTUAL void PulseActionEvent();
246 SWIGHIDDENVIRTUAL bool WaitForActionEvent(unsigned int milliseconds);
247#endif
248
249 public:
250 explicit Window(int existingWindowId = -1);
251
252 ~Window() override;
253
254#ifndef SWIG
255 SWIGHIDDENVIRTUAL bool OnMessage(CGUIMessage& message);
256 SWIGHIDDENVIRTUAL bool OnAction(const CAction &action);
257 SWIGHIDDENVIRTUAL bool OnBack(int actionId);
258 SWIGHIDDENVIRTUAL void OnDeinitWindow(int nextWindowID);
259
260 SWIGHIDDENVIRTUAL bool IsDialogRunning() const { XBMC_TRACE; return false; };
261 SWIGHIDDENVIRTUAL bool IsDialog() const { XBMC_TRACE; return false; };
262 SWIGHIDDENVIRTUAL bool IsModalDialog() const { XBMC_TRACE; return false; };
263 SWIGHIDDENVIRTUAL bool IsMediaWindow() const { XBMC_TRACE; return false; };
264 SWIGHIDDENVIRTUAL void dispose();
265
270 inline void interceptorClear() { CSingleLock lock(*this); window = NULL; }
271#endif
272
273 //
291 //
292
293 // callback takes a parameter
294#ifdef DOXYGEN_SHOULD_USE_THIS
336#else
337 virtual void onAction(Action* action);
338#endif
339
340 // on control is not actually on Window in the api but is called into Python anyway.
341#ifdef DOXYGEN_SHOULD_USE_THIS
365 void onControl(...);
366#else
367 virtual void onControl(Control* control);
368#endif
369
370#ifdef DOXYGEN_SHOULD_USE_THIS
397#else
398 virtual void onClick(int controlId);
399#endif
400
401#ifdef DOXYGEN_SHOULD_USE_THIS
428#else
429 virtual void onDoubleClick(int controlId);
430#endif
431
432#ifdef DOXYGEN_SHOULD_USE_THIS
458#else
459 virtual void onFocus(int controlId);
460#endif
461
462#ifdef DOXYGEN_SHOULD_USE_THIS
484 onInit(...);
485#else
486 virtual void onInit();
487#endif
489
490#ifdef DOXYGEN_SHOULD_USE_THIS
504#else
505 SWIGHIDDENVIRTUAL void show();
506#endif
507
508#ifdef DOXYGEN_SHOULD_USE_THIS
521#else
522 SWIGHIDDENVIRTUAL void setFocus(Control* pControl);
523#endif
524
525#ifdef DOXYGEN_SHOULD_USE_THIS
536#else
537 SWIGHIDDENVIRTUAL void setFocusId(int iControlId);
538#endif
539
540#ifdef DOXYGEN_SHOULD_USE_THIS
551#else
552 SWIGHIDDENVIRTUAL Control* getFocus();
553#endif
554
555#ifdef DOXYGEN_SHOULD_USE_THIS
566#else
567 SWIGHIDDENVIRTUAL long getFocusId();
568#endif
569
570#ifdef DOXYGEN_SHOULD_USE_THIS
584#else
585 SWIGHIDDENVIRTUAL void removeControl(Control* pControl);
586#endif
587
588#ifdef DOXYGEN_SHOULD_USE_THIS
603#else
604 SWIGHIDDENVIRTUAL void removeControls(std::vector<Control*> pControls);
605#endif
606
607#ifdef DOXYGEN_SHOULD_USE_THIS
619#else
620 SWIGHIDDENVIRTUAL long getHeight();
621#endif
622
623#ifdef DOXYGEN_SHOULD_USE_THIS
635#else
636 SWIGHIDDENVIRTUAL long getWidth();
637#endif
638
639#ifdef DOXYGEN_SHOULD_USE_THIS
667#else
668 SWIGHIDDENVIRTUAL void setProperty(const char* key, const String& value);
669#endif
670
671#ifdef DOXYGEN_SHOULD_USE_THIS
697#else
698 SWIGHIDDENVIRTUAL String getProperty(const char* key);
699#endif
700
701#ifdef DOXYGEN_SHOULD_USE_THIS
727#else
728 SWIGHIDDENVIRTUAL void clearProperty(const char* key);
729#endif
730
731#ifdef DOXYGEN_SHOULD_USE_THIS
749#else
750 SWIGHIDDENVIRTUAL void clearProperties();
751#endif
752
753#ifdef DOXYGEN_SHOULD_USE_THIS
764#else
765 SWIGHIDDENVIRTUAL void close();
766#endif
767
768#ifdef DOXYGEN_SHOULD_USE_THIS
775#else
776
777 SWIGHIDDENVIRTUAL void doModal();
778#endif
779
780#ifdef DOXYGEN_SHOULD_USE_THIS
812#else
813 SWIGHIDDENVIRTUAL void addControl(Control* pControl);
814#endif
815
816#ifdef DOXYGEN_SHOULD_USE_THIS
831#else
832 SWIGHIDDENVIRTUAL void addControls(std::vector<Control*> pControls);
833#endif
834
835#ifdef DOXYGEN_SHOULD_USE_THIS
851#else
852 SWIGHIDDENVIRTUAL Control* getControl(int iControlId);
853#endif
854 };
856 }
857}
Definition: Window.h:43
Definition: Control.h:62
Definition: Window.h:186
static int getNextAvailableWindowId()
void setWindow(InterceptorBase *_window)
void interceptorClear()
Definition: Window.h:270
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...