Panda3D
windowProperties.I
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.I
10  * @author drose
11  * @date 2002-08-13
12  */
13 
14 /**
15  *
16  */
17 INLINE WindowProperties::
18 WindowProperties(const WindowProperties &copy) {
19  (*this) = copy;
20 }
21 
22 /**
23  *
24  */
25 INLINE WindowProperties::
26 ~WindowProperties() {
27 }
28 
29 /**
30  *
31  */
32 INLINE bool WindowProperties::
33 operator != (const WindowProperties &other) const {
34  return !operator == (other);
35 }
36 
37 /**
38  * Returns true if any properties have been specified, false otherwise.
39  */
40 INLINE bool WindowProperties::
42  return (_specified != 0);
43 }
44 
45 /**
46  * Specifies the origin on the screen (in pixels, relative to the top-left
47  * corner) at which the window should appear. This is the origin of the top-
48  * left corner of the useful part of the window, not including decorations.
49  */
50 INLINE void WindowProperties::
51 set_origin(const LPoint2i &origin) {
52  _origin = origin;
53  _specified |= S_origin;
54 }
55 
56 /**
57  * Specifies the origin on the screen (in pixels, relative to the top-left
58  * corner) at which the window should appear. This is the origin of the top-
59  * left corner of the useful part of the window, not including decorations.
60  */
61 INLINE void WindowProperties::
62 set_origin(int x_origin, int y_origin) {
63  _origin.set(x_origin, y_origin);
64  _specified |= S_origin;
65 }
66 
67 /**
68  * Returns the coordinates of the window's top-left corner, not including
69  * decorations.
70  */
71 INLINE const LPoint2i &WindowProperties::
72 get_origin() const {
73  nassertr(has_origin(), LPoint2i::zero());
74  return _origin;
75 }
76 
77 /**
78  * Returns the x coordinate of the window's top-left corner, not including
79  * decorations.
80  */
81 INLINE int WindowProperties::
82 get_x_origin() const {
83  nassertr(has_origin(), 0);
84  return _origin.get_x();
85 }
86 
87 /**
88  * Returns the y coordinate of the window's top-left corner, not including
89  * decorations.
90  */
91 INLINE int WindowProperties::
92 get_y_origin() const {
93  nassertr(has_origin(), 0);
94  return _origin.get_y();
95 }
96 
97 /**
98  * Returns true if the window origin has been specified, false otherwise.
99  */
100 INLINE bool WindowProperties::
101 has_origin() const {
102  return ((_specified & S_origin) != 0);
103 }
104 
105 /**
106  * Removes the origin specification from the properties.
107  */
108 INLINE void WindowProperties::
109 clear_origin() {
110  _specified &= ~S_origin;
111  _origin = LPoint2i::zero();
112 }
113 
114 /**
115  * Specifies the requested size of the window, in pixels. This is the size of
116  * the useful part of the window, not including decorations.
117  */
118 INLINE void WindowProperties::
119 set_size(const LVector2i &size) {
120  _size = size;
121  _specified |= S_size;
122 }
123 
124 /**
125  * Specifies the requested size of the window, in pixels. This is the size of
126  * the useful part of the window, not including decorations.
127  */
128 INLINE void WindowProperties::
129 set_size(int x_size, int y_size) {
130  _size.set(x_size, y_size);
131  _specified |= S_size;
132 }
133 
134 /**
135  * Returns size in pixels of the useful part of the window, not including
136  * decorations.
137  */
138 INLINE const LVector2i &WindowProperties::
139 get_size() const {
140  nassertr(has_size(), LVector2i::zero());
141  return _size;
142 }
143 
144 /**
145  * Returns size in pixels in the x dimension of the useful part of the window,
146  * not including decorations. That is, this is the window's width.
147  */
148 INLINE int WindowProperties::
149 get_x_size() const {
150  nassertr(has_size(), 0);
151  return _size.get_x();
152 }
153 
154 /**
155  * Returns size in pixels in the y dimension of the useful part of the window,
156  * not including decorations. That is, this is the window's height.
157  */
158 INLINE int WindowProperties::
159 get_y_size() const {
160  nassertr(has_size(), 0);
161  return _size.get_y();
162 }
163 
164 /**
165  * Returns true if the window size has been specified, false otherwise.
166  */
167 INLINE bool WindowProperties::
168 has_size() const {
169  return ((_specified & S_size) != 0);
170 }
171 
172 /**
173  * Removes the size specification from the properties.
174  */
175 INLINE void WindowProperties::
176 clear_size() {
177  _specified &= ~S_size;
178  _size = LVector2i::zero();
179 }
180 
181 /**
182  * Specifies the title that should be assigned to the window.
183  */
184 INLINE void WindowProperties::
185 set_title(const std::string &title) {
186  _title = title;
187  _specified |= S_title;
188 }
189 
190 /**
191  * Returns the window's title.
192  */
193 INLINE const std::string &WindowProperties::
194 get_title() const {
195  nassertr(has_title(), _title);
196  return _title;
197 }
198 
199 /**
200  * Returns true if the window title has been specified, false otherwise.
201  */
202 INLINE bool WindowProperties::
203 has_title() const {
204  return ((_specified & S_title) != 0);
205 }
206 
207 /**
208  * Removes the title specification from the properties.
209  */
210 INLINE void WindowProperties::
211 clear_title() {
212  _specified &= ~S_title;
213  _title = std::string();
214 }
215 
216 /**
217  * Specifies whether the window should be created with a visible title and
218  * border (false, the default) or not (true).
219  */
220 INLINE void WindowProperties::
221 set_undecorated(bool undecorated) {
222  if (undecorated) {
223  _flags |= F_undecorated;
224  } else {
225  _flags &= ~F_undecorated;
226  }
227  _specified |= S_undecorated;
228 }
229 
230 /**
231  * Returns true if the window has no border.
232  */
233 INLINE bool WindowProperties::
234 get_undecorated() const {
235  return (_flags & F_undecorated) != 0;
236 }
237 
238 /**
239  * Returns true if set_undecorated() has been specified.
240  */
241 INLINE bool WindowProperties::
242 has_undecorated() const {
243  return ((_specified & S_undecorated) != 0);
244 }
245 
246 /**
247  * Removes the undecorated specification from the properties.
248  */
249 INLINE void WindowProperties::
250 clear_undecorated() {
251  _specified &= ~S_undecorated;
252  _flags &= ~F_undecorated;
253 }
254 
255 /**
256  * Specifies whether the window should be resizable by the user.
257  */
258 INLINE void WindowProperties::
259 set_fixed_size(bool fixed_size) {
260  if (fixed_size) {
261  _flags |= F_fixed_size;
262  } else {
263  _flags &= ~F_fixed_size;
264  }
265  _specified |= S_fixed_size;
266 }
267 
268 /**
269  * Returns true if the window cannot be resized by the user, false otherwise.
270  */
271 INLINE bool WindowProperties::
272 get_fixed_size() const {
273  return (_flags & F_fixed_size) != 0;
274 }
275 
276 /**
277  * Returns true if set_fixed_size() has been specified.
278  */
279 INLINE bool WindowProperties::
280 has_fixed_size() const {
281  return ((_specified & S_fixed_size) != 0);
282 }
283 
284 /**
285  * Removes the fixed_size specification from the properties.
286  */
287 INLINE void WindowProperties::
288 clear_fixed_size() {
289  _specified &= ~S_fixed_size;
290  _flags &= ~F_fixed_size;
291 }
292 
293 /**
294  * Specifies whether the window should be opened in fullscreen mode (true) or
295  * normal windowed mode (false, the default).
296  */
297 INLINE void WindowProperties::
298 set_fullscreen(bool fullscreen) {
299  if (fullscreen) {
300  _flags |= F_fullscreen;
301  } else {
302  _flags &= ~F_fullscreen;
303  }
304  _specified |= S_fullscreen;
305 }
306 
307 /**
308  * Returns true if the window is in fullscreen mode.
309  */
310 INLINE bool WindowProperties::
311 get_fullscreen() const {
312  return (_flags & F_fullscreen) != 0;
313 }
314 
315 /**
316  * Returns true if set_fullscreen() has been specified.
317  */
318 INLINE bool WindowProperties::
319 has_fullscreen() const {
320  return ((_specified & S_fullscreen) != 0);
321 }
322 
323 /**
324  * Removes the fullscreen specification from the properties.
325  */
326 INLINE void WindowProperties::
327 clear_fullscreen() {
328  _specified &= ~S_fullscreen;
329  _flags &= ~F_fullscreen;
330 }
331 
332 /**
333  * Specifies whether the window should be opened in the foreground (true), or
334  * left in the background (false).
335  */
336 INLINE void WindowProperties::
337 set_foreground(bool foreground) {
338  if (foreground) {
339  _flags |= F_foreground;
340  } else {
341  _flags &= ~F_foreground;
342  }
343  _specified |= S_foreground;
344 }
345 
346 /**
347  * Returns true if the window is in the foreground.
348  */
349 INLINE bool WindowProperties::
350 get_foreground() const {
351  return (_flags & F_foreground) != 0;
352 }
353 
354 /**
355  * Returns true if set_foreground() has been specified.
356  */
357 INLINE bool WindowProperties::
358 has_foreground() const {
359  return ((_specified & S_foreground) != 0);
360 }
361 
362 /**
363  * Removes the foreground specification from the properties.
364  */
365 INLINE void WindowProperties::
366 clear_foreground() {
367  _specified &= ~S_foreground;
368  _flags &= ~F_foreground;
369 }
370 
371 /**
372  * Specifies whether the window should be created minimized (true), or normal
373  * (false).
374  */
375 INLINE void WindowProperties::
376 set_minimized(bool minimized) {
377  if (minimized) {
378  _flags |= F_minimized;
379  } else {
380  _flags &= ~F_minimized;
381  }
382  _specified |= S_minimized;
383 }
384 
385 /**
386  * Returns true if the window is minimized.
387  */
388 INLINE bool WindowProperties::
389 get_minimized() const {
390  return (_flags & F_minimized) != 0;
391 }
392 
393 /**
394  * Returns true if set_minimized() has been specified.
395  */
396 INLINE bool WindowProperties::
397 has_minimized() const {
398  return ((_specified & S_minimized) != 0);
399 }
400 
401 /**
402  * Removes the minimized specification from the properties.
403  */
404 INLINE void WindowProperties::
405 clear_minimized() {
406  _specified &= ~S_minimized;
407  _flags &= ~F_minimized;
408 }
409 
410 /**
411  * Specifies whether the window should read the raw mouse devices.
412  */
413 INLINE void WindowProperties::
414 set_raw_mice(bool raw_mice) {
415  if (raw_mice) {
416  _flags |= F_raw_mice;
417  } else {
418  _flags &= ~F_raw_mice;
419  }
420  _specified |= S_raw_mice;
421 }
422 
423 /**
424  * Returns true if the window reads the raw mice.
425  */
426 INLINE bool WindowProperties::
427 get_raw_mice() const {
428  return (_flags & F_raw_mice) != 0;
429 }
430 
431 /**
432  * Returns true if set_raw_mice() has been specified.
433  */
434 INLINE bool WindowProperties::
435 has_raw_mice() const {
436  return ((_specified & S_raw_mice) != 0);
437 }
438 
439 /**
440  * Removes the raw_mice specification from the properties.
441  */
442 INLINE void WindowProperties::
444  _specified &= ~S_raw_mice;
445  _flags &= ~F_raw_mice;
446 }
447 
448 /**
449  * Specifies whether the window should be open. It is legal to create a
450  * GraphicsWindow in the closed state, and later request it to open by
451  * changing this flag.
452  */
453 INLINE void WindowProperties::
454 set_open(bool open) {
455  if (open) {
456  _flags |= F_open;
457  } else {
458  _flags &= ~F_open;
459  }
460  _specified |= S_open;
461 }
462 
463 /**
464  * Returns true if the window is open.
465  */
466 INLINE bool WindowProperties::
467 get_open() const {
468  return (_flags & F_open) != 0;
469 }
470 
471 /**
472  * Returns true if set_open() has been specified.
473  */
474 INLINE bool WindowProperties::
475 has_open() const {
476  return ((_specified & S_open) != 0);
477 }
478 
479 /**
480  * Removes the open specification from the properties.
481  */
482 INLINE void WindowProperties::
483 clear_open() {
484  _specified &= ~S_open;
485  _flags &= ~F_open;
486 }
487 
488 /**
489  * Specifies whether the mouse cursor should be visible.
490  */
491 INLINE void WindowProperties::
492 set_cursor_hidden(bool cursor_hidden) {
493  if (cursor_hidden) {
494  _flags |= F_cursor_hidden;
495  } else {
496  _flags &= ~F_cursor_hidden;
497  }
498  _specified |= S_cursor_hidden;
499 }
500 
501 /**
502  * Returns true if the mouse cursor is invisible.
503  */
504 INLINE bool WindowProperties::
505 get_cursor_hidden() const {
506  return (_flags & F_cursor_hidden) != 0;
507 }
508 
509 /**
510  * Returns true if set_cursor_hidden() has been specified.
511  */
512 INLINE bool WindowProperties::
513 has_cursor_hidden() const {
514  return ((_specified & S_cursor_hidden) != 0);
515 }
516 
517 /**
518  * Removes the cursor_hidden specification from the properties.
519  */
520 INLINE void WindowProperties::
521 clear_cursor_hidden() {
522  _specified &= ~S_cursor_hidden;
523  _flags &= ~F_cursor_hidden;
524 }
525 
526 /**
527  * Specifies the file that contains the icon to associate with the window when
528  * it is minimized.
529  */
530 INLINE void WindowProperties::
531 set_icon_filename(const Filename &icon_filename) {
532  _icon_filename = icon_filename;
533  _specified |= S_icon_filename;
534 }
535 
536 
537 /**
538  * Returns the icon filename associated with the window.
539  */
540 INLINE const Filename &WindowProperties::
541 get_icon_filename() const {
542  return _icon_filename;
543 }
544 
545 /**
546  * Returns true if set_icon_filename() has been specified.
547  */
548 INLINE bool WindowProperties::
549 has_icon_filename() const {
550  return ((_specified & S_icon_filename) != 0);
551 }
552 
553 /**
554  * Removes the icon_filename specification from the properties.
555  */
556 INLINE void WindowProperties::
557 clear_icon_filename() {
558  _specified &= ~S_icon_filename;
559  _icon_filename = Filename();
560 }
561 
562 /**
563  * Specifies the file that contains the icon to associate with the mouse
564  * cursor when it is within the window (and visible).
565  */
566 INLINE void WindowProperties::
567 set_cursor_filename(const Filename &cursor_filename) {
568  _cursor_filename = cursor_filename;
569  _specified |= S_cursor_filename;
570 }
571 
572 /**
573  * Returns the icon filename associated with the mouse cursor.
574  */
575 INLINE const Filename &WindowProperties::
576 get_cursor_filename() const {
577  return _cursor_filename;
578 }
579 
580 /**
581  * Returns true if set_cursor_filename() has been specified.
582  */
583 INLINE bool WindowProperties::
584 has_cursor_filename() const {
585  return ((_specified & S_cursor_filename) != 0);
586 }
587 
588 /**
589  * Removes the cursor_filename specification from the properties.
590  */
591 INLINE void WindowProperties::
592 clear_cursor_filename() {
593  _specified &= ~S_cursor_filename;
594  _cursor_filename = Filename();
595 }
596 
597 /**
598  * Specifies the relative ordering of the window with respect to other
599  * windows. If the z_order is Z_top, the window will always be on top of
600  * other windows; if it is Z_bottom, it will always be below other windows.
601  * Most windows will want to be Z_normal, which allows the user to control the
602  * order.
603  */
604 INLINE void WindowProperties::
605 set_z_order(WindowProperties::ZOrder z_order) {
606  _z_order = z_order;
607  _specified |= S_z_order;
608 }
609 
610 /**
611  * Returns the window's z_order.
612  */
613 INLINE WindowProperties::ZOrder WindowProperties::
614 get_z_order() const {
615  return _z_order;
616 }
617 
618 /**
619  * Returns true if the window z_order has been specified, false otherwise.
620  */
621 INLINE bool WindowProperties::
622 has_z_order() const {
623  return ((_specified & S_z_order) != 0);
624 }
625 
626 /**
627  * Removes the z_order specification from the properties.
628  */
629 INLINE void WindowProperties::
630 clear_z_order() {
631  _specified &= ~S_z_order;
632  _z_order = Z_normal;
633 }
634 
635 
636 /**
637  * Specifies the mode in which the window is to operate its mouse pointer.
638  *
639  * M_absolute: the normal mode in which a mouse pointer operates, where the
640  * mouse can move outside the window and the mouse coordinates are relative to
641  * its position in the window.
642  *
643  * M_relative (OSX or Unix/X11 only): a mode where only relative movements are
644  * reported; particularly useful for FPS-style mouse movements where you have
645  * hidden the mouse pointer and are are more interested in how fast the mouse
646  * is moving, rather than precisely where the pointer is hovering.
647  *
648  * This has no effect on Windows. On Unix/X11, this requires the Xxf86dga
649  * extension to be available.
650  *
651  * M_confined: this mode reports absolute mouse positions, but confines the
652  * mouse pointer to the window boundary. It can portably replace M_relative
653  * for an FPS, but you need to periodically move the pointer to the center of
654  * the window and track movement deltas.
655  *
656  */
657 INLINE void WindowProperties::
658 set_mouse_mode(MouseMode mode) {
659  _mouse_mode=mode;
660  _specified |= S_mouse_mode;
661 }
662 
663 /**
664  * See set_mouse_mode().
665  */
666 INLINE WindowProperties::MouseMode WindowProperties::
667 get_mouse_mode() const {
668  return _mouse_mode;
669 }
670 
671 /**
672  *
673  */
674 INLINE bool WindowProperties::
675 has_mouse_mode() const {
676  return ((_specified & S_mouse_mode)!=0);
677 }
678 
679 /**
680  * Removes the mouse_mode specification from the properties.
681  */
682 INLINE void WindowProperties::
683 clear_mouse_mode() {
684  _specified &= ~S_mouse_mode;
685  _mouse_mode = M_absolute;
686 }
687 
688 /**
689  * Specifies the window that this window should be attached to. If this is
690  * NULL or unspecified, the window will be created as a toplevel window on the
691  * desktop; if this is non-NULL, the window will be bound as a child window to
692  * the indicated parent window.
693  *
694  * You should use GraphicsPipe::make_window_handle() to create an instance of
695  * a WindowHandle object given an appropriate OS-specific window handle
696  * representation. Each OS-specific GraphicsPipe class defines a
697  * make_window_handle() method that returns an appropriate WindowHandle object
698  * to wrap the particular OS-specific representation.
699  */
700 INLINE void WindowProperties::
701 set_parent_window(WindowHandle *parent_window) {
702  _parent_window = parent_window;
703  _specified |= S_parent_window;
704 }
705 
706 /**
707  * Returns the parent window specification, or NULL if there is no parent
708  * window specified.
709  */
710 INLINE WindowHandle *WindowProperties::
711 get_parent_window() const {
712  return _parent_window;
713 }
714 
715 /**
716  * Checks the S_parent_window specification from the properties.
717  */
718 INLINE bool WindowProperties::
719 has_parent_window() const {
720  return ((_specified & S_parent_window)!=0);
721 }
722 
723 /**
724  * Removes the S_parent_window specification from the properties.
725  */
726 INLINE void WindowProperties::
727 clear_parent_window() {
728  _specified &= ~S_parent_window;
729  _parent_window = nullptr;
730 }
731 
732 
733 INLINE std::ostream &
734 operator << (std::ostream &out, const WindowProperties &properties) {
735  properties.output(out);
736  return out;
737 }
set_mouse_mode
Specifies the mode in which the window is to operate its mouse pointer.
bool is_any_specified() const
Returns true if any properties have been specified, false otherwise.
set_cursor_hidden
Specifies whether the mouse cursor should be visible.
set_parent_window
Specifies the window that this window should be attached to.
This object represents a window on the desktop, not necessarily a Panda window.
Definition: windowHandle.h:34
set_size
Specifies the requested size of the window, in pixels.
set_fullscreen
Specifies whether the window should be opened in fullscreen mode (true) or normal windowed mode (fals...
set_z_order
Specifies the relative ordering of the window with respect to other windows.
void set_raw_mice(bool raw_mice)
Specifies whether the window should read the raw mouse devices.
set_minimized
Specifies whether the window should be created minimized (true), or normal (false).
set_fixed_size
Specifies whether the window should be resizable by the user.
int get_y_origin() const
Returns the y coordinate of the window's top-left corner, not including decorations.
static WindowProperties size(const LVecBase2i &size)
Returns a WindowProperties structure with only the size specified.
set_undecorated
Specifies whether the window should be created with a visible title and border (false,...
set_cursor_filename
Specifies the file that contains the icon to associate with the mouse cursor when it is within the wi...
A container for the various kinds of properties we might ask to have on a graphics window before we o...
has_origin
Returns true if the window origin has been specified, false otherwise.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
set_origin
Specifies the origin on the screen (in pixels, relative to the top-left corner) at which the window s...
void clear_raw_mice()
Removes the raw_mice specification from the properties.
set_icon_filename
Specifies the file that contains the icon to associate with the window when it is minimized.
bool get_raw_mice() const
Returns true if the window reads the raw mice.
void output(std::ostream &out) const
Sets any properties that are explicitly specified in other on this object.
bool has_raw_mice() const
Returns true if set_raw_mice() has been specified.
has_title
Returns true if the window title has been specified, false otherwise.
int get_y_size() const
Returns size in pixels in the y dimension of the useful part of the window, not including decorations...
int get_x_size() const
Returns size in pixels in the x dimension of the useful part of the window, not including decorations...
set_open
Specifies whether the window should be open.
int get_x_origin() const
Returns the x coordinate of the window's top-left corner, not including decorations.
has_size
Returns true if the window size has been specified, false otherwise.
set_title
Specifies the title that should be assigned to the window.
set_foreground
Specifies whether the window should be opened in the foreground (true), or left in the background (fa...