Panda3D
graphicsWindow.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file graphicsWindow.h
10  * @author mike
11  * @date 1997-01-09
12  */
13 
14 #ifndef GRAPHICSWINDOW_H
15 #define GRAPHICSWINDOW_H
16 
17 #include "pandabase.h"
18 
19 #include "graphicsOutput.h"
21 #include "graphicsWindowProc.h"
23 #include "windowProperties.h"
24 #include "mouseData.h"
25 #include "modifierButtons.h"
26 #include "buttonEvent.h"
27 #include "keyboardButton.h"
28 #include "buttonMap.h"
29 #include "pnotify.h"
30 #include "lightMutex.h"
31 #include "lightReMutex.h"
32 #include "pvector.h"
33 #include "windowHandle.h"
34 #include "touchInfo.h"
35 
36 /**
37  * A window, fullscreen or on a desktop, into which a graphics device sends
38  * its output for interactive display.
39  */
40 class EXPCL_PANDA_DISPLAY GraphicsWindow : public GraphicsOutput {
41 protected:
43  GraphicsPipe *pipe,
44  const std::string &name,
45  const FrameBufferProperties &fb_prop,
46  const WindowProperties &win_prop,
47  int flags,
49  GraphicsOutput *host);
50 
51 PUBLISHED:
52  virtual ~GraphicsWindow();
53 
54  const WindowProperties get_properties() const;
55  const WindowProperties get_requested_properties() const;
56  void clear_rejected_properties();
57  WindowProperties get_rejected_properties() const;
58  void request_properties(const WindowProperties &requested_properties);
59  INLINE bool is_closed() const;
60  virtual bool is_active() const;
61  INLINE bool is_fullscreen() const;
62 
63  MAKE_PROPERTY(properties, get_properties);
64  MAKE_PROPERTY(requested_properties, get_requested_properties);
65  MAKE_PROPERTY(rejected_properties, get_rejected_properties);
66  MAKE_PROPERTY(closed, is_closed);
67 
68  void set_window_event(const std::string &window_event);
69  std::string get_window_event() const;
70  MAKE_PROPERTY(window_event, get_window_event, set_window_event);
71 
72  void set_close_request_event(const std::string &close_request_event);
73  std::string get_close_request_event() const;
74  MAKE_PROPERTY(close_request_event, get_close_request_event, set_close_request_event);
75 
76  INLINE void set_unexposed_draw(bool unexposed_draw);
77  INLINE bool get_unexposed_draw() const;
78  MAKE_PROPERTY(unexposed_draw, get_unexposed_draw, set_unexposed_draw);
79 
80  INLINE WindowHandle *get_window_handle() const;
81  MAKE_PROPERTY(window_handle, get_window_handle);
82 
83  // Mouse and keyboard routines
84  int get_num_input_devices() const;
85  InputDevice *get_input_device(int i) const;
86  std::string get_input_device_name(int device) const;
87  MAKE_SEQ(get_input_devices, get_num_input_devices, get_input_device);
88  MAKE_SEQ(get_input_device_names, get_num_input_devices, get_input_device_name);
89  bool has_pointer(int device) const;
90  bool has_keyboard(int device) const;
91  virtual ButtonMap *get_keyboard_map() const;
92 
93  void enable_pointer_events(int device);
94  void disable_pointer_events(int device);
95  /*void enable_pointer_mode(int device, double speed);
96  void disable_pointer_mode(int device);*/
97 
98  virtual MouseData get_pointer(int device) const;
99  virtual bool move_pointer(int device, int x, int y);
100  virtual void close_ime();
101 
102 public:
103  virtual void add_window_proc( const GraphicsWindowProc* wnd_proc_object ){};
104  virtual void remove_window_proc( const GraphicsWindowProc* wnd_proc_object ){};
105  virtual void clear_window_procs(){};
106  virtual bool supports_window_procs() const;
107 
108  virtual int verify_window_sizes(int numsizes, int *dimen);
109 
110  virtual bool is_touch_event(GraphicsWindowProcCallbackData* callbackData);
111  virtual int get_num_touches();
112  virtual TouchInfo get_touch_info(int index);
113 
114 public:
115  virtual void request_open();
116  virtual void request_close();
117 
118  // It is an error to call any of the following methods from any thread other
119  // than the window thread. These methods are normally called by the
120  // GraphicsEngine.
121  virtual void set_close_now();
122  virtual void process_events();
123  virtual void set_properties_now(WindowProperties &properties);
124 
125 protected:
126  virtual void close_window();
127  virtual bool open_window();
128  virtual void reset_window(bool swapchain);
129 
130  virtual bool do_reshape_request(int x_origin, int y_origin, bool has_origin,
131  int x_size, int y_size);
132 
133  virtual void mouse_mode_absolute();
134  virtual void mouse_mode_relative();
135 
136  // It is an error to call any of the following methods from any thread other
137  // than the window thread.
138  void system_changed_properties(const WindowProperties &properties);
139  void system_changed_size(int x_size, int y_size);
140 
141 protected:
142  int add_input_device(InputDevice *device);
143  typedef pvector<PT(InputDevice)> InputDevices;
144  InputDevices _input_devices;
145  LightMutex _input_lock;
146 
147 protected:
148  WindowProperties _properties;
149  PT(WindowHandle) _window_handle;
150  PT(WindowHandle) _parent_window_handle;
151 
152  bool _got_expose_event;
153 
154 private:
155  LightReMutex _properties_lock;
156  // protects _requested_properties, _rejected_properties, and _window_event.
157 
158  WindowProperties _requested_properties;
159  WindowProperties _rejected_properties;
160  std::string _window_event;
161  std::string _close_request_event;
162  bool _unexposed_draw;
163 
164 #ifdef HAVE_PYTHON
165  typedef pset<GraphicsWindowProc*> PythonWinProcClasses;
166  PythonWinProcClasses _python_window_proc_classes;
167 #endif
168 
169 public:
170  static TypeHandle get_class_type() {
171  return _type_handle;
172  }
173  static void init_type() {
174  GraphicsOutput::init_type();
175  register_type(_type_handle, "GraphicsWindow",
176  GraphicsOutput::get_class_type());
177  }
178  virtual TypeHandle get_type() const {
179  return get_class_type();
180  }
181  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
182 
183 private:
184  static TypeHandle _type_handle;
185 
186  friend class GraphicsEngine;
187  friend class Extension<GraphicsWindow>;
188 };
189 
190 #include "graphicsWindow.I"
191 
192 #endif /* GRAPHICSWINDOW_H */
This specialization on CallbackData is passed when the callback is initiated from from an implementat...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
virtual void request_close()
This is called by the GraphicsEngine to request that the window (or whatever) close itself or,...
This object represents a window on the desktop, not necessarily a Panda window.
Definition: windowHandle.h:34
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
BEGIN_PUBLISH typedef PointerData MouseData
Deprecated alias for PointerData.
Definition: mouseData.h:23
void register_type(TypeHandle &type_handle, const std::string &name)
This inline function is just a convenient way to call TypeRegistry::register_type(),...
Definition: register_type.I:22
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A lightweight reentrant mutex.
Definition: lightReMutex.h:30
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
A window, fullscreen or on a desktop, into which a graphics device sends its output for interactive d...
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
virtual void set_close_now()
This is called by the GraphicsEngine to insist that the output be closed immediately.
A container for the various kinds of properties we might ask to have on a graphics window before we o...
virtual void request_open()
This is called by the GraphicsEngine to request that the window (or whatever) open itself or,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Stores information for a single touch event.
Definition: touchInfo.h:22
This is a structure representing a single input device.
Definition: inputDevice.h:53
An object to create GraphicsOutputs that share a particular 3-D API.
Definition: graphicsPipe.h:52
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
The default class template does not define any methods.
Definition: extension.h:34
This is a base class for the various different classes that represent the result of a frame of render...
virtual void process_events()
Do whatever processing in the window thread is appropriate for this output object each frame.
virtual void reset_window(bool swapchain)
Resets the window framebuffer from its derived children.
Defines an interface for storing platform-specific window processor methods.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
Encapsulates all the communication with a particular instance of a given rendering backend.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class is the main interface to controlling the render process.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
A container for the various kinds of properties we might ask to have on a graphics frameBuffer before...
This is a standard, non-reentrant mutex, similar to the Mutex class.
Definition: lightMutex.h:39
This class represents a map containing all of the buttons of a (keyboard) device, though it can also ...
Definition: buttonMap.h:30
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.