Panda3D
Loading...
Searching...
No Matches
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 */
29class EXPCL_PANDA_DISPLAY WindowProperties {
30public:
31 WindowProperties();
32 INLINE WindowProperties(const WindowProperties &copy);
33
34PUBLISHED:
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
49PUBLISHED:
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();
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,
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,
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,
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,
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,
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,
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,
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,
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,
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();
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,
200
201 void add_properties(const WindowProperties &other);
202
203 void output(std::ostream &out) const;
204
205private:
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 true/false 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
254EXPCL_PANDA_DISPLAY std::ostream &
255operator << (std::ostream &out, WindowProperties::ZOrder z_order);
256EXPCL_PANDA_DISPLAY std::istream &
257operator >> (std::istream &in, WindowProperties::ZOrder &z_order);
258
259EXPCL_PANDA_DISPLAY std::ostream &
260operator << (std::ostream &out, WindowProperties::MouseMode mode);
261EXPCL_PANDA_DISPLAY std::istream &
262operator >> (std::istream &in, WindowProperties::MouseMode &mode);
263
264
265INLINE 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: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...
void add_properties(const WindowProperties &other)
Sets any properties that are explicitly specified in other on this object.
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.
void clear()
Unsets all properties that have been specified so far, and resets the WindowProperties structure to i...
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.
set_default
Replaces the "default" WindowProperties with the specified structure.
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.
static void clear_default()
Returns the "default" WindowProperties to whatever is specified in the user's config file.
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...
get_default
Returns the "default" WindowProperties.
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_config_properties
Returns a WindowProperties structure with all of the default values filled in according to the user's...
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.
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.