Panda3D
Loading...
Searching...
No Matches
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 */
17INLINE WindowProperties::
18WindowProperties(const WindowProperties &copy) {
19 (*this) = copy;
20}
21
22/**
23 *
24 */
25INLINE WindowProperties::
26~WindowProperties() {
27}
28
29/**
30 *
31 */
32INLINE bool WindowProperties::
33operator != (const WindowProperties &other) const {
34 return !operator == (other);
35}
36
37/**
38 * Returns true if any properties have been specified, false otherwise.
39 */
41is_any_specified() const {
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 */
50INLINE void WindowProperties::
51set_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 */
61INLINE void WindowProperties::
62set_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 */
71INLINE const LPoint2i &WindowProperties::
72get_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 */
82get_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 */
92get_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 */
100INLINE bool WindowProperties::
101has_origin() const {
102 return ((_specified & S_origin) != 0);
103}
104
105/**
106 * Removes the origin specification from the properties.
107 */
108INLINE void WindowProperties::
109clear_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 */
118INLINE void WindowProperties::
119set_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 */
128INLINE void WindowProperties::
129set_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 */
138INLINE const LVector2i &WindowProperties::
139get_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 */
149get_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 */
159get_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 */
167INLINE bool WindowProperties::
168has_size() const {
169 return ((_specified & S_size) != 0);
170}
171
172/**
173 * Removes the size specification from the properties.
174 */
175INLINE void WindowProperties::
176clear_size() {
177 _specified &= ~S_size;
178 _size = LVector2i::zero();
179}
180
181/**
182 * Specifies the title that should be assigned to the window.
183 */
184INLINE void WindowProperties::
185set_title(const std::string &title) {
186 _title = title;
187 _specified |= S_title;
188}
189
190/**
191 * Returns the window's title.
192 */
193INLINE const std::string &WindowProperties::
194get_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 */
202INLINE bool WindowProperties::
203has_title() const {
204 return ((_specified & S_title) != 0);
205}
206
207/**
208 * Removes the title specification from the properties.
209 */
210INLINE void WindowProperties::
211clear_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 */
220INLINE void WindowProperties::
221set_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 */
233INLINE bool WindowProperties::
234get_undecorated() const {
235 return (_flags & F_undecorated) != 0;
236}
237
238/**
239 * Returns true if set_undecorated() has been specified.
240 */
241INLINE bool WindowProperties::
242has_undecorated() const {
243 return ((_specified & S_undecorated) != 0);
244}
245
246/**
247 * Removes the undecorated specification from the properties.
248 */
249INLINE void WindowProperties::
251 _specified &= ~S_undecorated;
252 _flags &= ~F_undecorated;
253}
254
255/**
256 * Specifies whether the window should be resizable by the user.
257 */
258INLINE void WindowProperties::
259set_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 */
271INLINE bool WindowProperties::
272get_fixed_size() const {
273 return (_flags & F_fixed_size) != 0;
274}
275
276/**
277 * Returns true if set_fixed_size() has been specified.
278 */
279INLINE bool WindowProperties::
280has_fixed_size() const {
281 return ((_specified & S_fixed_size) != 0);
282}
283
284/**
285 * Removes the fixed_size specification from the properties.
286 */
287INLINE void WindowProperties::
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 */
297INLINE void WindowProperties::
298set_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 */
310INLINE bool WindowProperties::
311get_fullscreen() const {
312 return (_flags & F_fullscreen) != 0;
313}
314
315/**
316 * Returns true if set_fullscreen() has been specified.
317 */
318INLINE bool WindowProperties::
319has_fullscreen() const {
320 return ((_specified & S_fullscreen) != 0);
321}
322
323/**
324 * Removes the fullscreen specification from the properties.
325 */
326INLINE void WindowProperties::
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 */
336INLINE void WindowProperties::
337set_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 */
349INLINE bool WindowProperties::
350get_foreground() const {
351 return (_flags & F_foreground) != 0;
352}
353
354/**
355 * Returns true if set_foreground() has been specified.
356 */
357INLINE bool WindowProperties::
358has_foreground() const {
359 return ((_specified & S_foreground) != 0);
360}
361
362/**
363 * Removes the foreground specification from the properties.
364 */
365INLINE void WindowProperties::
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 */
375INLINE void WindowProperties::
376set_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 */
388INLINE bool WindowProperties::
389get_minimized() const {
390 return (_flags & F_minimized) != 0;
391}
392
393/**
394 * Returns true if set_minimized() has been specified.
395 */
396INLINE bool WindowProperties::
397has_minimized() const {
398 return ((_specified & S_minimized) != 0);
399}
400
401/**
402 * Removes the minimized specification from the properties.
403 */
404INLINE void WindowProperties::
406 _specified &= ~S_minimized;
407 _flags &= ~F_minimized;
408}
409
410/**
411 * Specifies whether the window should read the raw mouse devices.
412 */
414set_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 */
427get_raw_mice() const {
428 return (_flags & F_raw_mice) != 0;
429}
430
431/**
432 * Returns true if set_raw_mice() has been specified.
433 */
435has_raw_mice() const {
436 return ((_specified & S_raw_mice) != 0);
437}
438
439/**
440 * Removes the raw_mice specification from the properties.
441 */
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 */
453INLINE void WindowProperties::
454set_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 */
466INLINE bool WindowProperties::
467get_open() const {
468 return (_flags & F_open) != 0;
469}
470
471/**
472 * Returns true if set_open() has been specified.
473 */
474INLINE bool WindowProperties::
475has_open() const {
476 return ((_specified & S_open) != 0);
477}
478
479/**
480 * Removes the open specification from the properties.
481 */
482INLINE void WindowProperties::
483clear_open() {
484 _specified &= ~S_open;
485 _flags &= ~F_open;
486}
487
488/**
489 * Specifies whether the mouse cursor should be visible.
490 */
491INLINE void WindowProperties::
492set_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 */
504INLINE bool WindowProperties::
505get_cursor_hidden() const {
506 return (_flags & F_cursor_hidden) != 0;
507}
508
509/**
510 * Returns true if set_cursor_hidden() has been specified.
511 */
512INLINE bool WindowProperties::
513has_cursor_hidden() const {
514 return ((_specified & S_cursor_hidden) != 0);
515}
516
517/**
518 * Removes the cursor_hidden specification from the properties.
519 */
520INLINE void WindowProperties::
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 */
530INLINE void WindowProperties::
531set_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 */
540INLINE const Filename &WindowProperties::
541get_icon_filename() const {
542 return _icon_filename;
543}
544
545/**
546 * Returns true if set_icon_filename() has been specified.
547 */
548INLINE bool WindowProperties::
549has_icon_filename() const {
550 return ((_specified & S_icon_filename) != 0);
551}
552
553/**
554 * Removes the icon_filename specification from the properties.
555 */
556INLINE void WindowProperties::
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 */
566INLINE void WindowProperties::
567set_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 */
575INLINE const Filename &WindowProperties::
576get_cursor_filename() const {
577 return _cursor_filename;
578}
579
580/**
581 * Returns true if set_cursor_filename() has been specified.
582 */
583INLINE bool WindowProperties::
584has_cursor_filename() const {
585 return ((_specified & S_cursor_filename) != 0);
586}
587
588/**
589 * Removes the cursor_filename specification from the properties.
590 */
591INLINE void WindowProperties::
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 */
604INLINE void WindowProperties::
605set_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 */
613INLINE WindowProperties::ZOrder WindowProperties::
614get_z_order() const {
615 return _z_order;
616}
617
618/**
619 * Returns true if the window z_order has been specified, false otherwise.
620 */
621INLINE bool WindowProperties::
622has_z_order() const {
623 return ((_specified & S_z_order) != 0);
624}
625
626/**
627 * Removes the z_order specification from the properties.
628 */
629INLINE void WindowProperties::
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 */
657INLINE void WindowProperties::
658set_mouse_mode(MouseMode mode) {
659 _mouse_mode=mode;
660 _specified |= S_mouse_mode;
661}
662
663/**
664 * See set_mouse_mode().
665 */
666INLINE WindowProperties::MouseMode WindowProperties::
667get_mouse_mode() const {
668 return _mouse_mode;
669}
670
671/**
672 *
673 */
674INLINE bool WindowProperties::
675has_mouse_mode() const {
676 return ((_specified & S_mouse_mode)!=0);
677}
678
679/**
680 * Removes the mouse_mode specification from the properties.
681 */
682INLINE void WindowProperties::
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 */
700INLINE void WindowProperties::
701set_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 */
711get_parent_window() const {
712 return _parent_window;
713}
714
715/**
716 * Checks the S_parent_window specification from the properties.
717 */
718INLINE bool WindowProperties::
719has_parent_window() const {
720 return ((_specified & S_parent_window)!=0);
721}
722
723/**
724 * Removes the S_parent_window specification from the properties.
725 */
726INLINE void WindowProperties::
728 _specified &= ~S_parent_window;
729 _parent_window = nullptr;
730}
731
732
733INLINE std::ostream &
734operator << (std::ostream &out, const WindowProperties &properties) {
735 properties.output(out);
736 return out;
737}
The name of a file, such as a texture file or an Egg file.
Definition filename.h:44
This object represents a window on the desktop, not necessarily a Panda window.
A container for the various kinds of properties we might ask to have on a graphics window before we o...
clear_cursor_filename
Removes the cursor_filename specification from the properties.
get_open
Returns true if the window is open.
has_cursor_filename
Returns true if set_cursor_filename() has been specified.
get_title
Returns the window's title.
get_undecorated
Returns true if the window has no border.
clear_cursor_hidden
Removes the cursor_hidden specification from the properties.
set_title
Specifies the title that should be assigned to the window.
has_open
Returns true if set_open() has been specified.
static WindowProperties size(const LVecBase2i &size)
Returns a WindowProperties structure with only the size specified.
int get_y_size() const
Returns size in pixels in the y dimension of the useful part of the window, not including decorations...
set_mouse_mode
Specifies the mode in which the window is to operate its mouse pointer.
has_parent_window
Checks the S_parent_window specification from the properties.
int get_x_size() const
Returns size in pixels in the x dimension of the useful part of the window, not including decorations...
void set_raw_mice(bool raw_mice)
Specifies whether the window should read the raw mouse devices.
clear_parent_window
Removes the S_parent_window specification from the properties.
get_origin
Returns the coordinates of the window's top-left corner, not including decorations.
set_parent_window
Specifies the window that this window should be attached to.
int get_y_origin() const
Returns the y coordinate of the window's top-left corner, not including decorations.
has_undecorated
Returns true if set_undecorated() has been specified.
clear_z_order
Removes the z_order specification from the properties.
get_minimized
Returns true if the window is minimized.
bool has_raw_mice() const
Returns true if set_raw_mice() has been specified.
clear_mouse_mode
Removes the mouse_mode specification from the properties.
has_fullscreen
Returns true if set_fullscreen() has been specified.
has_size
Returns true if the window size has been specified, false otherwise.
clear_title
Removes the title specification from the properties.
get_size
Returns size in pixels of the useful part of the window, not including decorations.
clear_origin
Removes the origin specification from the properties.
has_minimized
Returns true if set_minimized() has been specified.
set_size
Specifies the requested size of the window, in pixels.
get_foreground
Returns true if the window is in the foreground.
set_icon_filename
Specifies the file that contains the icon to associate with the window when it is minimized.
has_fixed_size
Returns true if set_fixed_size() has been specified.
bool is_any_specified() const
Returns true if any properties have been specified, false otherwise.
clear_fixed_size
Removes the fixed_size specification from the properties.
clear_fullscreen
Removes the fullscreen specification from the properties.
set_foreground
Specifies whether the window should be opened in the foreground (true), or left in the background (fa...
clear_size
Removes the size specification from the properties.
set_open
Specifies whether the window should be open.
set_undecorated
Specifies whether the window should be created with a visible title and border (false,...
get_z_order
Returns the window's z_order.
bool get_raw_mice() const
Returns true if the window reads the raw mice.
get_icon_filename
Returns the icon filename associated with the window.
get_fullscreen
Returns true if the window is in fullscreen mode.
set_cursor_filename
Specifies the file that contains the icon to associate with the mouse cursor when it is within the wi...
has_title
Returns true if the window title has been specified, false otherwise.
set_z_order
Specifies the relative ordering of the window with respect to other windows.
void clear_raw_mice()
Removes the raw_mice specification from the properties.
get_mouse_mode
See set_mouse_mode().
has_origin
Returns true if the window origin has been specified, false otherwise.
has_foreground
Returns true if set_foreground() has been specified.
set_cursor_hidden
Specifies whether the mouse cursor should be visible.
clear_foreground
Removes the foreground specification from the properties.
get_cursor_filename
Returns the icon filename associated with the mouse cursor.
clear_undecorated
Removes the undecorated specification from the properties.
get_cursor_hidden
Returns true if the mouse cursor is invisible.
clear_minimized
Removes the minimized specification from the properties.
has_cursor_hidden
Returns true if set_cursor_hidden() has been specified.
get_parent_window
Returns the parent window specification, or NULL if there is no parent window specified.
set_minimized
Specifies whether the window should be created minimized (true), or normal (false).
clear_open
Removes the open specification from the properties.
clear_icon_filename
Removes the icon_filename specification from the properties.
void output(std::ostream &out) const
Sets any properties that are explicitly specified in other on this object.
has_z_order
Returns true if the window z_order has been specified, false otherwise.
set_fixed_size
Specifies whether the window should be resizable by the user.
get_fixed_size
Returns true if the window cannot be resized by the user, false otherwise.
int get_x_origin() const
Returns the x coordinate of the window's top-left corner, not including decorations.
set_fullscreen
Specifies whether the window should be opened in fullscreen mode (true) or normal windowed mode (fals...
set_origin
Specifies the origin on the screen (in pixels, relative to the top-left corner) at which the window s...
has_icon_filename
Returns true if set_icon_filename() has been specified.