Blender  V2.93
GHOST_WindowManager.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
28 #include "GHOST_WindowManager.h"
29 #include "GHOST_Debug.h"
30 #include "GHOST_Window.h"
31 #include <algorithm>
32 
34  : m_fullScreenWindow(0), m_activeWindow(0), m_activeWindowBeforeFullScreen(0)
35 {
36 }
37 
39 {
40  /* m_windows is freed by GHOST_System::disposeWindow */
41 }
42 
44 {
46  if (window) {
47  if (!getWindowFound(window)) {
48  // Store the pointer to the window
49  m_windows.push_back(window);
50  success = GHOST_kSuccess;
51  }
52  }
53  return success;
54 }
55 
57 {
59  if (window) {
60  if (window == m_fullScreenWindow) {
61  endFullScreen();
62  }
63  else {
64  std::vector<GHOST_IWindow *>::iterator result = find(
65  m_windows.begin(), m_windows.end(), window);
66  if (result != m_windows.end()) {
67  setWindowInactive(window);
68  m_windows.erase(result);
69  success = GHOST_kSuccess;
70  }
71  }
72  }
73  return success;
74 }
75 
77 {
78  bool found = false;
79  if (window) {
80  if (getFullScreen() && (window == m_fullScreenWindow)) {
81  found = true;
82  }
83  else {
84  std::vector<GHOST_IWindow *>::const_iterator result = find(
85  m_windows.begin(), m_windows.end(), window);
86  if (result != m_windows.end()) {
87  found = true;
88  }
89  }
90  }
91  return found;
92 }
93 
95 {
96  return m_fullScreenWindow != NULL;
97 }
98 
100 {
101  return m_fullScreenWindow;
102 }
103 
105 {
106  GHOST_TSuccess success = GHOST_kFailure;
107  GHOST_ASSERT(window, "GHOST_WindowManager::beginFullScreen(): invalid window");
108  GHOST_ASSERT(window->getValid(), "GHOST_WindowManager::beginFullScreen(): invalid window");
109  if (!getFullScreen()) {
110  m_fullScreenWindow = window;
114  success = GHOST_kSuccess;
115  }
116  return success;
117 }
118 
120 {
121  GHOST_TSuccess success = GHOST_kFailure;
122  if (getFullScreen()) {
123  if (m_fullScreenWindow != NULL) {
124  // GHOST_PRINT("GHOST_WindowManager::endFullScreen(): deleting full-screen window\n");
127  delete m_fullScreenWindow;
128  // GHOST_PRINT("GHOST_WindowManager::endFullScreen(): done\n");
132  }
133  }
134  success = GHOST_kSuccess;
135  }
136  return success;
137 }
138 
140 {
141  GHOST_TSuccess success = GHOST_kSuccess;
142  if (window != m_activeWindow) {
143  if (getWindowFound(window)) {
144  m_activeWindow = window;
145  }
146  else {
147  success = GHOST_kFailure;
148  }
149  }
150  return success;
151 }
152 
154 {
155  return m_activeWindow;
156 }
157 
159 {
160  if (window == m_activeWindow) {
162  }
163 }
164 
165 const std::vector<GHOST_IWindow *> &GHOST_WindowManager::getWindows() const
166 {
167  return m_windows;
168 }
169 
171 {
172  std::vector<GHOST_IWindow *>::iterator iter;
173 
174  for (iter = m_windows.begin(); iter != m_windows.end(); ++iter) {
175  if ((*iter)->getOSWindow() == osWindow)
176  return *iter;
177  }
178 
179  return NULL;
180 }
181 
183 {
184  bool isAnyModified = false;
185  std::vector<GHOST_IWindow *>::iterator iter;
186 
187  for (iter = m_windows.begin(); iter != m_windows.end(); ++iter) {
188  if ((*iter)->getModifiedState())
189  isAnyModified = true;
190  }
191 
192  return isAnyModified;
193 }
#define GHOST_ASSERT(x, info)
Definition: GHOST_Debug.h:79
GHOST_TSuccess
Definition: GHOST_Types.h:91
@ GHOST_kFailure
Definition: GHOST_Types.h:91
@ GHOST_kSuccess
Definition: GHOST_Types.h:91
virtual GHOST_TSuccess beginFullScreen() const =0
virtual bool getValid() const =0
virtual GHOST_TSuccess endFullScreen() const =0
GHOST_TSuccess addWindow(GHOST_IWindow *window)
GHOST_TSuccess endFullScreen(void)
bool getFullScreen(void) const
std::vector< GHOST_IWindow * > m_windows
GHOST_TSuccess removeWindow(const GHOST_IWindow *window)
GHOST_IWindow * getActiveWindow(void) const
GHOST_IWindow * m_activeWindowBeforeFullScreen
GHOST_IWindow * getWindowAssociatedWithOSWindow(void *osWindow)
const std::vector< GHOST_IWindow * > & getWindows() const
GHOST_IWindow * m_activeWindow
GHOST_TSuccess beginFullScreen(GHOST_IWindow *window, const bool stereoVisual)
GHOST_TSuccess setActiveWindow(GHOST_IWindow *window)
GHOST_IWindow * m_fullScreenWindow
bool getWindowFound(const GHOST_IWindow *window) const
GHOST_IWindow * getFullScreenWindow(void) const
void setWindowInactive(const GHOST_IWindow *window)