VideoTools
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
gxwindowmap.cpp
Go to the documentation of this file.
1 //
2 // Copyright (C) 2017 Graeme Walker
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 // ===
17 //
18 // gxwindowmap.cpp
19 //
20 
21 #include "gdef.h"
22 #include "gxdef.h"
23 #include "gxwindowmap.h"
24 #include "gxerror.h"
25 
26 GX::WindowMap * GX::WindowMap::m_this = nullptr ;
27 
29 {
30  if( m_this == nullptr )
31  m_this = this ;
32 }
33 
35 {
36  if( m_this == this )
37  m_this = nullptr ;
38 }
39 
41 {
42  return m_this ;
43 }
44 
46 {
47  m_map.insert( Map::value_type(w.x(),&w) ) ;
48 }
49 
51 {
52  m_map.erase( w.x() ) ;
53 }
54 
56 {
57  Map::const_iterator p = m_map.find( w ) ;
58  if( p == m_map.end() )
59  throw NotFound() ;
60  return *((*p).second) ;
61 }
62 
63 /// \file gxwindowmap.cpp
A window class that is-a GX::Drawable and a GX::EventHandler.
Definition: gxwindow.h:47
~WindowMap()
Destructor.
Definition: gxwindowmap.cpp:34
::Window x()
Returns the X object.
Definition: gxwindow.cpp:149
void add(GX::Window &w)
Adds a window.
Definition: gxwindowmap.cpp:45
GX::Window & find(::Window w) const
Finds a window. Throws if not found.
Definition: gxwindowmap.cpp:55
Exception class for GX::WindowMap.
Definition: gxwindowmap.h:42
A class that can locate a GX::Window object based on a Xlib window handle.
Definition: gxwindowmap.h:39
void remove(GX::Window &w)
Removes a window.
Definition: gxwindowmap.cpp:50
static WindowMap * instance()
Singleton access. Returns nullptr if none.
Definition: gxwindowmap.cpp:40
WindowMap()
Constructor.
Definition: gxwindowmap.cpp:28