Kodi Development  20.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 
19 namespace 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
88  getId();
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
261  {
262  XBMC_TRACE;
263  return false;
264  }
265  SWIGHIDDENVIRTUAL bool IsDialog() const
266  {
267  XBMC_TRACE;
268  return false;
269  }
270  SWIGHIDDENVIRTUAL bool IsModalDialog() const
271  {
272  XBMC_TRACE;
273  return false;
274  }
275  SWIGHIDDENVIRTUAL bool IsMediaWindow() const
276  {
277  XBMC_TRACE;
278  return false;
279  }
280  SWIGHIDDENVIRTUAL void dispose();
281 
286  inline void interceptorClear() { CSingleLock lock(*this); window = NULL; }
287 #endif
288 
289  //
307  //
308 
309  // callback takes a parameter
310 #ifdef DOXYGEN_SHOULD_USE_THIS
351  onAction(...);
352 #else
353  virtual void onAction(Action* action);
354 #endif
355 
356  // on control is not actually on Window in the api but is called into Python anyway.
357 #ifdef DOXYGEN_SHOULD_USE_THIS
381  void onControl(...);
382 #else
383  virtual void onControl(Control* control);
384 #endif
385 
386 #ifdef DOXYGEN_SHOULD_USE_THIS
412  onClick(...);
413 #else
414  virtual void onClick(int controlId);
415 #endif
416 
417 #ifdef DOXYGEN_SHOULD_USE_THIS
444 #else
445  virtual void onDoubleClick(int controlId);
446 #endif
447 
448 #ifdef DOXYGEN_SHOULD_USE_THIS
473  onFocus(...);
474 #else
475  virtual void onFocus(int controlId);
476 #endif
477 
478 #ifdef DOXYGEN_SHOULD_USE_THIS
500  onInit(...);
501 #else
502  virtual void onInit();
503 #endif
505 
506 #ifdef DOXYGEN_SHOULD_USE_THIS
519  show();
520 #else
521  SWIGHIDDENVIRTUAL void show();
522 #endif
523 
524 #ifdef DOXYGEN_SHOULD_USE_THIS
536  setFocus(...);
537 #else
538  SWIGHIDDENVIRTUAL void setFocus(Control* pControl);
539 #endif
540 
541 #ifdef DOXYGEN_SHOULD_USE_THIS
552 #else
553  SWIGHIDDENVIRTUAL void setFocusId(int iControlId);
554 #endif
555 
556 #ifdef DOXYGEN_SHOULD_USE_THIS
567 #else
568  SWIGHIDDENVIRTUAL Control* getFocus();
569 #endif
570 
571 #ifdef DOXYGEN_SHOULD_USE_THIS
582 #else
583  SWIGHIDDENVIRTUAL long getFocusId();
584 #endif
585 
586 #ifdef DOXYGEN_SHOULD_USE_THIS
600 #else
601  SWIGHIDDENVIRTUAL void removeControl(Control* pControl);
602 #endif
603 
604 #ifdef DOXYGEN_SHOULD_USE_THIS
619 #else
620  SWIGHIDDENVIRTUAL void removeControls(std::vector<Control*> pControls);
621 #endif
622 
623 #ifdef DOXYGEN_SHOULD_USE_THIS
635 #else
636  SWIGHIDDENVIRTUAL long getHeight();
637 #endif
638 
639 #ifdef DOXYGEN_SHOULD_USE_THIS
651 #else
652  SWIGHIDDENVIRTUAL long getWidth();
653 #endif
654 
655 #ifdef DOXYGEN_SHOULD_USE_THIS
683 #else
684  SWIGHIDDENVIRTUAL void setProperty(const char* key, const String& value);
685 #endif
686 
687 #ifdef DOXYGEN_SHOULD_USE_THIS
713 #else
714  SWIGHIDDENVIRTUAL String getProperty(const char* key);
715 #endif
716 
717 #ifdef DOXYGEN_SHOULD_USE_THIS
743 #else
744  SWIGHIDDENVIRTUAL void clearProperty(const char* key);
745 #endif
746 
747 #ifdef DOXYGEN_SHOULD_USE_THIS
765 #else
766  SWIGHIDDENVIRTUAL void clearProperties();
767 #endif
768 
769 #ifdef DOXYGEN_SHOULD_USE_THIS
779  close();
780 #else
781  SWIGHIDDENVIRTUAL void close();
782 #endif
783 
784 #ifdef DOXYGEN_SHOULD_USE_THIS
791 #else
792 
793  SWIGHIDDENVIRTUAL void doModal();
794 #endif
795 
796 #ifdef DOXYGEN_SHOULD_USE_THIS
828 #else
829  SWIGHIDDENVIRTUAL void addControl(Control* pControl);
830 #endif
831 
832 #ifdef DOXYGEN_SHOULD_USE_THIS
847 #else
848  SWIGHIDDENVIRTUAL void addControls(std::vector<Control*> pControls);
849 #endif
850 
851 #ifdef DOXYGEN_SHOULD_USE_THIS
867 #else
868  SWIGHIDDENVIRTUAL Control* getControl(int iControlId);
869 #endif
870  };
872  }
873 }
Definition: Window.h:43
Definition: Control.h:62
Definition: Window.h:186
Control * GetControlById(int iControlId, CCriticalSection *gc)
static int getNextAvailableWindowId()
void setWindow(InterceptorBase *_window)
void interceptorClear()
Definition: Window.h:286
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...