Merge pull request #22816 from CastagnaIT/fix_tx3g
[xbmc.git] / xbmc / guilib / GUIControlLookup.h
blob01175e4b907419973642b5a13471529fda201c49
1 /*
2 * Copyright (C) 2017-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
9 #pragma once
11 #include "GUIControl.h"
13 class CGUIControlLookup : public CGUIControl
15 public:
16 CGUIControlLookup() = default;
17 CGUIControlLookup(int parentID, int controlID, float posX, float posY, float width, float height)
18 : CGUIControl(parentID, controlID, posX, posY, width, height) {}
19 explicit CGUIControlLookup(const CGUIControlLookup& from);
20 ~CGUIControlLookup(void) override = default;
22 CGUIControl *GetControl(int id, std::vector<CGUIControl*> *idCollector = nullptr) override;
23 protected:
24 typedef std::multimap<int, CGUIControl *> LookupMap;
26 /*!
27 \brief Check whether a given control is valid
28 Runs through controls and returns whether this control is valid. Only functional
29 for controls with non-zero id.
30 \param control to check
31 \return true if the control is valid, false otherwise.
33 bool IsValidControl(const CGUIControl *control) const;
34 std::pair<LookupMap::const_iterator, LookupMap::const_iterator> GetLookupControls(int controlId) const
36 return m_lookup.equal_range(controlId);
39 // fast lookup by id
40 void AddLookup(CGUIControl *control);
41 void RemoveLookup(CGUIControl *control);
42 void RemoveLookup();
43 const LookupMap &GetLookup() const { return m_lookup; }
44 void ClearLookup() { m_lookup.clear(); }
45 private:
46 LookupMap m_lookup;