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 
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
64  getId();
89 #else
90  long getId() { XBMC_TRACE; return id; }
91 #endif
92 
93 #ifdef DOXYGEN_SHOULD_USE_THIS
94  getButtonCode();
102 #else
103  long getButtonCode() { XBMC_TRACE; return buttonCode; }
104 #endif
105 
106 #ifdef DOXYGEN_SHOULD_USE_THIS
107  getAmount1();
115 #else
116  float getAmount1() { XBMC_TRACE; return fAmount1; }
117 #endif
118 
119 #ifdef DOXYGEN_SHOULD_USE_THIS
120  getAmount2();
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
295  onAction(...);
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
342  void onControl(...);
366 #else
367  virtual void onControl(Control* control);
368 #endif
369 
370 #ifdef DOXYGEN_SHOULD_USE_THIS
371  onClick(...);
397 #else
398  virtual void onClick(int controlId);
399 #endif
400 
401 #ifdef DOXYGEN_SHOULD_USE_THIS
402  onDoubleClick(...);
428 #else
429  virtual void onDoubleClick(int controlId);
430 #endif
431 
432 #ifdef DOXYGEN_SHOULD_USE_THIS
433  onFocus(...);
458 #else
459  virtual void onFocus(int controlId);
460 #endif
461 
462 #ifdef DOXYGEN_SHOULD_USE_THIS
463  onInit(...);
485 #else
486  virtual void onInit();
487 #endif
488 
489 
490 #ifdef DOXYGEN_SHOULD_USE_THIS
491  show();
504 #else
505  SWIGHIDDENVIRTUAL void show();
506 #endif
507 
508 #ifdef DOXYGEN_SHOULD_USE_THIS
509  setFocus(...);
521 #else
522  SWIGHIDDENVIRTUAL void setFocus(Control* pControl);
523 #endif
524 
525 #ifdef DOXYGEN_SHOULD_USE_THIS
526  setFocusId(...);
536 #else
537  SWIGHIDDENVIRTUAL void setFocusId(int iControlId);
538 #endif
539 
540 #ifdef DOXYGEN_SHOULD_USE_THIS
541  getFocus();
551 #else
552  SWIGHIDDENVIRTUAL Control* getFocus();
553 #endif
554 
555 #ifdef DOXYGEN_SHOULD_USE_THIS
556  getFocusId();
566 #else
567  SWIGHIDDENVIRTUAL long getFocusId();
568 #endif
569 
570 #ifdef DOXYGEN_SHOULD_USE_THIS
571  removeControl(...);
584 #else
585  SWIGHIDDENVIRTUAL void removeControl(Control* pControl);
586 #endif
587 
588 #ifdef DOXYGEN_SHOULD_USE_THIS
589  removeControls(...);
603 #else
604  SWIGHIDDENVIRTUAL void removeControls(std::vector<Control*> pControls);
605 #endif
606 
607 #ifdef DOXYGEN_SHOULD_USE_THIS
608  getHeight();
619 #else
620  SWIGHIDDENVIRTUAL long getHeight();
621 #endif
622 
623 #ifdef DOXYGEN_SHOULD_USE_THIS
624  getWidth();
635 #else
636  SWIGHIDDENVIRTUAL long getWidth();
637 #endif
638 
639 #ifdef DOXYGEN_SHOULD_USE_THIS
640  setProperty(...);
667 #else
668  SWIGHIDDENVIRTUAL void setProperty(const char* key, const String& value);
669 #endif
670 
671 #ifdef DOXYGEN_SHOULD_USE_THIS
672  getProperty(...);
697 #else
698  SWIGHIDDENVIRTUAL String getProperty(const char* key);
699 #endif
700 
701 #ifdef DOXYGEN_SHOULD_USE_THIS
702  clearProperty(...);
727 #else
728  SWIGHIDDENVIRTUAL void clearProperty(const char* key);
729 #endif
730 
731 #ifdef DOXYGEN_SHOULD_USE_THIS
732  clearProperties();
749 #else
750  SWIGHIDDENVIRTUAL void clearProperties();
751 #endif
752 
753 #ifdef DOXYGEN_SHOULD_USE_THIS
754  close();
764 #else
765  SWIGHIDDENVIRTUAL void close();
766 #endif
767 
768 #ifdef DOXYGEN_SHOULD_USE_THIS
769  doModal();
775 #else
776 
777  SWIGHIDDENVIRTUAL void doModal();
778 #endif
779 
780 #ifdef DOXYGEN_SHOULD_USE_THIS
781  addControl(...);
812 #else
813  SWIGHIDDENVIRTUAL void addControl(Control* pControl);
814 #endif
815 
816 #ifdef DOXYGEN_SHOULD_USE_THIS
817  addControls(...);
831 #else
832  SWIGHIDDENVIRTUAL void addControls(std::vector<Control*> pControls);
833 #endif
834 
835 #ifdef DOXYGEN_SHOULD_USE_THIS
836  getControl(...);
851 #else
852  SWIGHIDDENVIRTUAL Control* getControl(int iControlId);
853 #endif
854  };
856  }
857 }
XBMCAddon::xbmcgui::Window::onClick
onClick(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::getWidth
getWidth()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::getFocus
getFocus()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::onControl
void onControl(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::onFocus
onFocus(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Control
Definition: Control.h:62
XBMCAddon::xbmcgui::Window::getFocusId
getFocusId()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Action::getId
getId()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::getControl
getControl(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::show
show()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::GetControlById
Control * GetControlById(int iControlId, CCriticalSection *gc)
XBMCAddon::xbmcgui::Action::getAmount1
getAmount1()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::doModal
doModal()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::clearProperties
clearProperties()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::setFocus
setFocus(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::addControl
addControl(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window
Definition: Window.h:186
XBMCAddon::xbmcgui::Window::onDoubleClick
onDoubleClick(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::getHeight
getHeight()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::getNextAvailableWindowId
static int getNextAvailableWindowId()
XBMCAddon::xbmcgui::Action::getAmount2
getAmount2()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::addControls
addControls(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::getProperty
getProperty(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::removeControl
removeControl(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::popActiveWindowId
void popActiveWindowId()
XBMCAddon::xbmcgui::Window::close
close()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::setFocusId
setFocusId(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::clearProperty
clearProperty(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::onAction
onAction(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Action
Definition: Window.h:43
XBMCAddon::xbmcgui::Window::setProperty
setProperty(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::setWindow
void setWindow(InterceptorBase *_window)
XBMCAddon::xbmcgui::Window::onInit
onInit(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::removeControls
removeControls(...)
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Action::getButtonCode
getButtonCode()
<h4><code><span style="font-style: italic;">Function: </span><span style="font-style: bold;"><font co...
XBMCAddon::xbmcgui::Window::Window
Window(bool discrim)
XBMCAddon::xbmcgui::Window::interceptorClear
void interceptorClear()
Definition: Window.h:270