Panda3D
 All Classes Functions Variables Enumerations
graphicsWindow.h
1 // Filename: graphicsWindow.h
2 // Created by: mike (09Jan97)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef GRAPHICSWINDOW_H
16 #define GRAPHICSWINDOW_H
17 
18 #include "pandabase.h"
19 
20 #include "graphicsOutput.h"
21 #include "graphicsWindowInputDevice.h"
22 #include "graphicsWindowProc.h"
23 #include "graphicsWindowProcCallbackData.h"
24 #include "windowProperties.h"
25 #include "mouseData.h"
26 #include "modifierButtons.h"
27 #include "buttonEvent.h"
28 #include "keyboardButton.h"
29 #include "buttonMap.h"
30 #include "pnotify.h"
31 #include "lightMutex.h"
32 #include "lightReMutex.h"
33 #include "pvector.h"
34 #include "windowHandle.h"
35 #include "touchInfo.h"
36 
37 ////////////////////////////////////////////////////////////////////
38 // Class : GraphicsWindow
39 // Description : A window, fullscreen or on a desktop, into which a
40 // graphics device sends its output for interactive
41 // display.
42 ////////////////////////////////////////////////////////////////////
43 class EXPCL_PANDA_DISPLAY GraphicsWindow : public GraphicsOutput {
44 protected:
46  GraphicsPipe *pipe,
47  const string &name,
48  const FrameBufferProperties &fb_prop,
49  const WindowProperties &win_prop,
50  int flags,
52  GraphicsOutput *host);
53 
54 PUBLISHED:
55  virtual ~GraphicsWindow();
56 
57  const WindowProperties get_properties() const;
58  const WindowProperties get_requested_properties() const;
59  void clear_rejected_properties();
60  WindowProperties get_rejected_properties() const;
61  void request_properties(const WindowProperties &requested_properties);
62  INLINE bool is_closed() const;
63  virtual bool is_active() const;
64  INLINE bool is_fullscreen() const;
65 
66  void set_window_event(const string &window_event);
67  string get_window_event() const;
68 
69  void set_close_request_event(const string &close_request_event);
70  string get_close_request_event() const;
71 
72  INLINE void set_unexposed_draw(bool unexposed_draw);
73  INLINE bool get_unexposed_draw() const;
74 
75  INLINE WindowHandle *get_window_handle() const;
76 
77  // Mouse and keyboard routines
78  int get_num_input_devices() const;
79  string get_input_device_name(int device) const;
80  MAKE_SEQ(get_input_device_names, get_num_input_devices, get_input_device_name);
81  bool has_pointer(int device) const;
82  bool has_keyboard(int device) const;
83  virtual ButtonMap *get_keyboard_map() const;
84 
85  void enable_pointer_events(int device);
86  void disable_pointer_events(int device);
87  void enable_pointer_mode(int device, double speed);
88  void disable_pointer_mode(int device);
89 
90  MouseData get_pointer(int device) const;
91  virtual bool move_pointer(int device, int x, int y);
92  virtual void close_ime();
93 
94 public:
95  // No need to publish these.
96  bool has_button_event(int device) const;
97  ButtonEvent get_button_event(int device);
98  bool has_pointer_event(int device) const;
99  PT(PointerEventList) get_pointer_events(int device);
100 
101  virtual void add_window_proc( const GraphicsWindowProc* wnd_proc_object ){};
102  virtual void remove_window_proc( const GraphicsWindowProc* wnd_proc_object ){};
103  virtual void clear_window_procs(){};
104  virtual bool supports_window_procs() const;
105 
106  virtual int verify_window_sizes(int numsizes, int *dimen);
107 
108  virtual bool is_touch_event(GraphicsWindowProcCallbackData* callbackData);
109  virtual int get_num_touches();
110  virtual TouchInfo get_touch_info(int index);
111 
112 public:
113  virtual void request_open();
114  virtual void request_close();
115 
116  // It is an error to call any of the following methods from any
117  // thread other than the window thread. These methods are normally
118  // called by the GraphicsEngine.
119  virtual void set_close_now();
120  virtual void process_events();
121  virtual void set_properties_now(WindowProperties &properties);
122 
123 protected:
124  virtual void close_window();
125  virtual bool open_window();
126  virtual void reset_window(bool swapchain);
127 
128  virtual bool do_reshape_request(int x_origin, int y_origin, bool has_origin,
129  int x_size, int y_size);
130 
131  virtual void mouse_mode_absolute();
132  virtual void mouse_mode_relative();
133 
134  // It is an error to call any of the following methods from any
135  // thread other than the window thread.
136  void system_changed_properties(const WindowProperties &properties);
137  void system_changed_size(int x_size, int y_size);
138 
139 protected:
140  int add_input_device(const GraphicsWindowInputDevice &device);
141  typedef vector_GraphicsWindowInputDevice InputDevices;
142  InputDevices _input_devices;
143  LightMutex _input_lock;
144 
145 protected:
146  WindowProperties _properties;
147  PT(WindowHandle) _window_handle;
148  PT(WindowHandle) _parent_window_handle;
149 
150  bool _got_expose_event;
151 
152 private:
153  LightReMutex _properties_lock;
154  // protects _requested_properties, _rejected_properties, and
155  // _window_event.
156 
157  WindowProperties _requested_properties;
158  WindowProperties _rejected_properties;
159  string _window_event;
160  string _close_request_event;
161  bool _unexposed_draw;
162 
163 #ifdef HAVE_PYTHON
164  typedef pset<GraphicsWindowProc*> PythonWinProcClasses;
165  PythonWinProcClasses _python_window_proc_classes;
166 #endif
167 
168 public:
169  static TypeHandle get_class_type() {
170  return _type_handle;
171  }
172  static void init_type() {
173  GraphicsOutput::init_type();
174  register_type(_type_handle, "GraphicsWindow",
175  GraphicsOutput::get_class_type());
176  }
177  virtual TypeHandle get_type() const {
178  return get_class_type();
179  }
180  virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
181 
182 private:
183  static TypeHandle _type_handle;
184 
185  friend class GraphicsEngine;
186  friend class Extension<GraphicsWindow>;
187 };
188 
189 #include "graphicsWindow.I"
190 
191 #endif /* GRAPHICSWINDOW_H */
This specialization on CallbackData is passed when the callback is initiated from from an implementat...
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:40
A lightweight reentrant mutex.
Definition: lightReMutex.h:34
Records a set of pointer events that happened recently.
Records a button event of some kind.
Definition: buttonEvent.h:53
A window, fullscreen or on a desktop, into which a graphics device sends its output for interactive d...
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...
Stores information for a single touch event.
Definition: touchInfo.h:24
An object to create GraphicsOutputs that share a particular 3-D API.
Definition: graphicsPipe.h:58
This is a structure representing a single input device that may be associated with a window...
The default class template does not define any methods.
Definition: extension.h:39
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.
Holds the data that might be generated by a 2-d pointer input device, such as the mouse in the Graphi...
Definition: mouseData.h:28
Encapsulates all the communication with a particular instance of a given rendering backend...
This class is the main interface to controlling the render process.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85
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:45
This class represents a map containing all of the buttons of a (keyboard) device, though it can also ...
Definition: buttonMap.h:33
virtual bool is_active() const
Returns true if the window is ready to be rendered into, false otherwise.