Panda3D
windowProperties.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 windowProperties.h
10  * @author drose
11  * @date 2002-08-13
12  */
13 
14 #ifndef WINDOWPROPERTIES_H
15 #define WINDOWPROPERTIES_H
16 
17 #include "pandabase.h"
18 #include "filename.h"
19 #include "pnotify.h"
20 #include "windowHandle.h"
21 #include "lpoint2.h"
22 #include "lvector2.h"
23 
24 /**
25  * A container for the various kinds of properties we might ask to have on a
26  * graphics window before we open it. This also serves to hold the current
27  * properties for a window after it has been opened.
28  */
29 class EXPCL_PANDA_DISPLAY WindowProperties {
30 public:
32  INLINE WindowProperties(const WindowProperties &copy);
33 
34 PUBLISHED:
35  enum ZOrder {
36  Z_bottom,
37  Z_normal,
38  Z_top,
39  };
40 
41  enum MouseMode {
42  M_absolute,
43  M_relative,
44  M_confined,
45  };
46 
47  EXTENSION(WindowProperties(PyObject *self, PyObject *args, PyObject *kwds));
48 
49 PUBLISHED:
50  void operator = (const WindowProperties &copy);
51  INLINE ~WindowProperties();
52 
53  static WindowProperties get_config_properties();
54  static WindowProperties get_default();
55  static void set_default(const WindowProperties &default_properties);
56  static void clear_default();
57  MAKE_PROPERTY(config_properties, get_config_properties);
58  MAKE_PROPERTY(default, get_default, set_default);
59 
60  static WindowProperties size(const LVecBase2i &size);
61  static WindowProperties size(int x_size, int y_size);
62 
63  bool operator == (const WindowProperties &other) const;
64  INLINE bool operator != (const WindowProperties &other) const;
65 
66  void clear();
67  INLINE bool is_any_specified() const;
68 
69  INLINE void set_origin(const LPoint2i &origin);
70  INLINE void set_origin(int x_origin, int y_origin);
71 #ifdef CPPPARSER
72  INLINE LPoint2i get_origin() const;
73 #else
74  INLINE const LPoint2i &get_origin() const;
75 #endif
76  INLINE int get_x_origin() const;
77  INLINE int get_y_origin() const;
78  INLINE bool has_origin() const;
79  INLINE void clear_origin();
80  MAKE_PROPERTY2(origin, has_origin, get_origin, set_origin, clear_origin);
81 
82  INLINE void set_size(const LVector2i &size);
83  INLINE void set_size(int x_size, int y_size);
84 #ifdef CPPPARSER
85  INLINE LVector2i get_size() const;
86 #else
87  INLINE const LVector2i &get_size() const;
88 #endif
89  INLINE int get_x_size() const;
90  INLINE int get_y_size() const;
91  INLINE bool has_size() const;
92  INLINE void clear_size();
93  MAKE_PROPERTY2(size, has_size, get_size, set_size, clear_size);
94 
95  INLINE bool has_mouse_mode() const;
96  INLINE void set_mouse_mode(MouseMode mode);
97  INLINE MouseMode get_mouse_mode() const;
98  INLINE void clear_mouse_mode();
99  MAKE_PROPERTY2(mouse_mode, has_mouse_mode, get_mouse_mode,
100  set_mouse_mode, clear_mouse_mode);
101 
102  INLINE void set_title(const std::string &title);
103 #ifdef CPPPARSER
104  INLINE std::string get_title() const;
105 #else
106  INLINE const std::string &get_title() const;
107 #endif
108  INLINE bool has_title() const;
109  INLINE void clear_title();
110  MAKE_PROPERTY2(title, has_title, get_title, set_title, clear_title);
111 
112  INLINE void set_undecorated(bool undecorated);
113  INLINE bool get_undecorated() const;
114  INLINE bool has_undecorated() const;
115  INLINE void clear_undecorated();
116  MAKE_PROPERTY2(undecorated, has_undecorated, get_undecorated,
117  set_undecorated, clear_undecorated);
118 
119  INLINE void set_fixed_size(bool fixed_size);
120  INLINE bool get_fixed_size() const;
121  INLINE bool has_fixed_size() const;
122  INLINE void clear_fixed_size();
123  MAKE_PROPERTY2(fixed_size, has_fixed_size, get_fixed_size,
124  set_fixed_size, clear_fixed_size);
125 
126  INLINE void set_fullscreen(bool fullscreen);
127  INLINE bool get_fullscreen() const;
128  INLINE bool has_fullscreen() const;
129  INLINE void clear_fullscreen();
130  MAKE_PROPERTY2(fullscreen, has_fullscreen, get_fullscreen,
131  set_fullscreen, clear_fullscreen);
132 
133  INLINE void set_foreground(bool foreground);
134  INLINE bool get_foreground() const;
135  INLINE bool has_foreground() const;
136  INLINE void clear_foreground();
137  MAKE_PROPERTY2(foreground, has_foreground, get_foreground,
138  set_foreground, clear_foreground);
139 
140  INLINE void set_minimized(bool minimized);
141  INLINE bool get_minimized() const;
142  INLINE bool has_minimized() const;
143  INLINE void clear_minimized();
144  MAKE_PROPERTY2(minimized, has_minimized, get_minimized,
145  set_minimized, clear_minimized);
146 
147  INLINE void set_raw_mice(bool raw_mice);
148  INLINE bool get_raw_mice() const;
149  INLINE bool has_raw_mice() const;
150  INLINE void clear_raw_mice();
151 
152  INLINE void set_open(bool open);
153  INLINE bool get_open() const;
154  INLINE bool has_open() const;
155  INLINE void clear_open();
156  MAKE_PROPERTY2(open, has_open, get_open, set_open, clear_open);
157 
158  INLINE void set_cursor_hidden(bool cursor_hidden);
159  INLINE bool get_cursor_hidden() const;
160  INLINE bool has_cursor_hidden() const;
161  INLINE void clear_cursor_hidden();
162  MAKE_PROPERTY2(cursor_hidden, has_cursor_hidden, get_cursor_hidden,
163  set_cursor_hidden, clear_cursor_hidden);
164 
165  INLINE void set_icon_filename(const Filename &icon_filename);
166 #ifdef CPPPARSER
167  INLINE Filename get_icon_filename() const;
168 #else
169  INLINE const Filename &get_icon_filename() const;
170 #endif
171  INLINE bool has_icon_filename() const;
172  INLINE void clear_icon_filename();
173  MAKE_PROPERTY2(icon_filename, has_icon_filename, get_icon_filename,
174  set_icon_filename, clear_icon_filename);
175 
176  INLINE void set_cursor_filename(const Filename &cursor_filename);
177 #ifdef CPPPARSER
178  INLINE Filename get_cursor_filename() const;
179 #else
180  INLINE const Filename &get_cursor_filename() const;
181 #endif
182  INLINE bool has_cursor_filename() const;
183  INLINE void clear_cursor_filename();
184  MAKE_PROPERTY2(cursor_filename, has_cursor_filename, get_cursor_filename,
185  set_cursor_filename, clear_cursor_filename);
186 
187  INLINE void set_z_order(ZOrder z_order);
188  INLINE ZOrder get_z_order() const;
189  INLINE bool has_z_order() const;
190  INLINE void clear_z_order();
191  MAKE_PROPERTY2(z_order, has_z_order, get_z_order, set_z_order, clear_z_order);
192 
193  void set_parent_window(size_t parent);
194  INLINE void set_parent_window(WindowHandle *parent_window = nullptr);
195  INLINE WindowHandle *get_parent_window() const;
196  INLINE bool has_parent_window() const;
197  INLINE void clear_parent_window();
198  MAKE_PROPERTY2(parent_window, has_parent_window, get_parent_window,
199  set_parent_window, clear_parent_window);
200 
201  void add_properties(const WindowProperties &other);
202 
203  void output(std::ostream &out) const;
204 
205 private:
206  // This bitmask indicates which of the parameters in the properties
207  // structure have been filled in by the user, and which remain unspecified.
208  enum Specified {
209  S_origin = 0x00001,
210  S_size = 0x00002,
211  S_title = 0x00004,
212  S_undecorated = 0x00008,
213  S_fullscreen = 0x00010,
214  S_foreground = 0x00020,
215  S_minimized = 0x00040,
216  S_open = 0x00080,
217  S_cursor_hidden = 0x00100,
218  S_fixed_size = 0x00200,
219  S_z_order = 0x00400,
220  S_icon_filename = 0x00800,
221  S_cursor_filename = 0x01000,
222  S_mouse_mode = 0x02000,
223  S_parent_window = 0x04000,
224  S_raw_mice = 0x08000,
225  };
226 
227  // This bitmask represents the truefalse settings for various boolean flags
228  // (assuming the corresponding S_* bit has been set, above).
229  enum Flags {
230  F_undecorated = S_undecorated,
231  F_fullscreen = S_fullscreen,
232  F_foreground = S_foreground,
233  F_minimized = S_minimized,
234  F_open = S_open,
235  F_cursor_hidden = S_cursor_hidden,
236  F_fixed_size = S_fixed_size,
237  F_raw_mice = S_raw_mice,
238  };
239 
240  int _specified;
241  LPoint2i _origin;
242  LVector2i _size;
243  MouseMode _mouse_mode;
244  std::string _title;
245  Filename _cursor_filename;
246  Filename _icon_filename;
247  ZOrder _z_order;
248  int _flags;
249  PT(WindowHandle) _parent_window;
250 
251  static WindowProperties *_default_properties;
252 };
253 
254 EXPCL_PANDA_DISPLAY std::ostream &
255 operator << (std::ostream &out, WindowProperties::ZOrder z_order);
256 EXPCL_PANDA_DISPLAY std::istream &
257 operator >> (std::istream &in, WindowProperties::ZOrder &z_order);
258 
259 EXPCL_PANDA_DISPLAY std::ostream &
260 operator << (std::ostream &out, WindowProperties::MouseMode mode);
261 EXPCL_PANDA_DISPLAY std::istream &
262 operator >> (std::istream &in, WindowProperties::MouseMode &mode);
263 
264 
265 INLINE std::ostream &operator << (std::ostream &out, const WindowProperties &properties);
266 
267 #include "windowProperties.I"
268 
269 #endif
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
This object represents a window on the desktop, not necessarily a Panda window.
Definition: windowHandle.h:34
A container for the various kinds of properties we might ask to have on a graphics window before we o...
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.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.