15 #include "windowProperties.h" 16 #include "config_display.h" 17 #include "nativeWindowHandle.h" 36 void WindowProperties::
38 _specified = copy._specified;
39 _origin = copy._origin;
42 _icon_filename = copy._icon_filename;
43 _cursor_filename = copy._cursor_filename;
44 _z_order = copy._z_order;
46 _mouse_mode = copy._mouse_mode;
47 _parent_window = copy._parent_window;
64 props.
set_size(win_size[0], win_size[0]);
66 props.
set_size(win_size[0], win_size[1]);
70 props.
set_origin(win_origin[0], win_origin[1]);
77 if (!icon_filename.empty()) {
80 if (!cursor_filename.empty()) {
83 if (z_order.has_value()) {
87 if (parent_window_handle.
get_value() != 0) {
89 }
else if (!subprocess_window.empty()) {
107 if (_default_properties != NULL) {
108 return *_default_properties;
127 if (_default_properties == NULL) {
130 (*_default_properties) = default_properties;
141 if (_default_properties != NULL) {
142 delete _default_properties;
143 _default_properties = NULL;
166 bool WindowProperties::
168 return (_specified == other._specified &&
169 _flags == other._flags &&
170 _origin == other._origin &&
171 _size == other._size &&
172 _z_order == other._z_order &&
173 _title == other._title &&
174 _icon_filename == other._icon_filename &&
175 _cursor_filename == other._cursor_filename &&
176 _mouse_mode == other._mouse_mode &&
177 _parent_window == other._parent_window);
197 _mouse_mode = M_absolute;
198 _parent_window = NULL;
226 PT(
WindowHandle) handle = NativeWindowHandle::make_int(parent);
282 if (other.has_mouse_mode()) {
306 out <<
"title=\"" <<
get_title() <<
"\"" <<
" ";
327 out << (
get_open() ?
"open " :
"!open ");
341 if (has_mouse_mode()) {
346 out <<
"parent:none ";
354 operator << (ostream &out, WindowProperties::ZOrder z_order) {
356 case WindowProperties::Z_bottom:
357 return out <<
"bottom";
359 case WindowProperties::Z_normal:
360 return out <<
"normal";
362 case WindowProperties::Z_top:
366 return out <<
"**invalid WindowProperties::ZOrder(" << (int)z_order <<
")**";
370 operator >> (istream &in, WindowProperties::ZOrder &z_order) {
374 if (word ==
"bottom") {
375 z_order = WindowProperties::Z_bottom;
377 }
else if (word ==
"top") {
378 z_order = WindowProperties::Z_top;
380 }
else if (word ==
"normal") {
381 z_order = WindowProperties::Z_normal;
384 display_cat.warning()
385 <<
"Unknown z-order: " << word <<
"\n";
386 z_order = WindowProperties::Z_normal;
397 operator << (ostream &out, WindowProperties::MouseMode mode) {
399 case WindowProperties::M_absolute:
400 return out <<
"absolute";
401 case WindowProperties::M_relative:
402 return out <<
"relative";
403 case WindowProperties::M_confined:
404 return out <<
"confined";
406 return out <<
"**invalid WindowProperties::MouseMode(" << (int)mode <<
")**";
410 operator >> (istream &in, WindowProperties::MouseMode &mode) {
414 if (word ==
"absolute") {
415 mode = WindowProperties::M_absolute;
416 }
else if (word ==
"relative") {
417 mode = WindowProperties::M_relative;
418 }
else if (word ==
"confined") {
419 mode = WindowProperties::M_confined;
421 display_cat.warning()
422 <<
"Unknown mouse mode: " << word <<
"\n";
423 mode = WindowProperties::M_absolute;
MouseMode get_mouse_mode() const
See set_mouse_mode().
void clear()
Unsets all properties that have been specified so far, and resets the WindowProperties structure to i...
void set_cursor_hidden(bool cursor_hidden)
Specifies whether the mouse cursor should be visible.
This object represents a window on the desktop, not necessarily a Panda window.
bool has_open() const
Returns true if set_open() has been specified.
bool get_foreground() const
Returns true if the window is in the foreground.
static WindowProperties size(int x_size, int y_size)
Returns a WindowProperties structure with only the size specified.
bool get_fixed_size() const
Returns true if the window cannot be resized by the user, false otherwise.
static WindowProperties get_config_properties()
Returns a WindowProperties structure with all of the default values filled in according to the user's...
void set_parent_window(size_t parent)
Specifies the window that this window should be attached to.
void set_raw_mice(bool raw_mice)
Specifies whether the window should read the raw mouse devices.
ZOrder get_z_order() const
Returns the window's z_order.
bool get_undecorated() const
Returns true if the window has no border.
bool has_icon_filename() const
Returns true if set_icon_filename() has been specified.
static const LPoint2i & zero()
Returns a zero-length point.
bool get_minimized() const
Returns true if the window is minimized.
void set_fixed_size(bool fixed_size)
Specifies whether the window should be resizable by the user.
void set_mouse_mode(MouseMode mode)
Specifies the mode in which the window is to operate its mouse pointer.
static void set_default(const WindowProperties &default_properties)
Replaces the "default" WindowProperties with the specified structure.
bool has_parent_window() const
Checks the S_parent_window specification from the properties.
void set_size(const LVector2i &size)
Specifies the requested size of the window, in pixels.
bool has_origin() const
Returns true if the window origin has been specified, false otherwise.
bool has_fixed_size() const
Returns true if set_fixed_size() has been specified.
const string & get_title() const
Returns the window's title.
void set_fullscreen(bool fullscreen)
Specifies whether the window should be opened in fullscreen mode (true) or normal windowed mode (fals...
int get_y_origin() const
Returns the y coordinate of the window's top-left corner, not including decorations.
void set_icon_filename(const Filename &icon_filename)
Specifies the file that contains the icon to associate with the window when it is minimized...
bool has_fullscreen() const
Returns true if set_fullscreen() has been specified.
void set_undecorated(bool undecorated)
Specifies whether the window should be created with a visible title and border (false, the default) or not (true).
static void clear_default()
Returns the "default" WindowProperties to whatever is specified in the user's config file...
A container for the various kinds of properties we might ask to have on a graphics window before we o...
The name of a file, such as a texture file or an Egg file.
bool get_open() const
Returns true if the window is open.
bool get_fullscreen() const
Returns true if the window is in fullscreen mode.
void set_z_order(ZOrder z_order)
Specifies the relative ordering of the window with respect to other windows.
static WindowProperties get_default()
Returns the "default" WindowProperties.
const Filename & get_icon_filename() const
Returns the icon filename associated with the window.
const Filename & get_cursor_filename() const
Returns the icon filename associated with the mouse cursor.
void set_origin(const LPoint2i &origin)
Specifies the origin on the screen (in pixels, relative to the top-left corner) at which the window s...
bool has_foreground() const
Returns true if set_foreground() has been specified.
const LVector2i & get_size() const
Returns size in pixels of the useful part of the window, not including decorations.
static const LVector2i & zero()
Returns a zero-length vector.
bool has_cursor_hidden() const
Returns true if set_cursor_hidden() has been specified.
bool has_z_order() const
Returns true if the window z_order has been specified, false otherwise.
void set_cursor_filename(const Filename &cursor_filename)
Specifies the file that contains the icon to associate with the mouse cursor when it is within the wi...
bool get_cursor_hidden() const
Returns true if the mouse cursor is invisible.
bool get_raw_mice() const
Returns true if the window reads the raw mice.
void set_foreground(bool foreground)
Specifies whether the window should be opened in the foreground (true), or left in the background (fa...
int get_num_words() const
Returns the number of words in the variable's value.
bool has_cursor_filename() const
Returns true if set_cursor_filename() has been specified.
void add_properties(const WindowProperties &other)
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.
void set_minimized(bool minimized)
Specifies whether the window should be created minimized (true), or normal (false).
bool has_minimized() const
Returns true if set_minimized() has been specified.
void set_title(const string &title)
Specifies the title that should be assigned to the window.
bool has_undecorated() const
Returns true if set_undecorated() has been specified.
int get_value() const
Returns the variable's value.
const LPoint2i & get_origin() const
Returns the coordinates of the window's top-left corner, not including decorations.
int get_y_size() const
Returns size in pixels in the y dimension of the useful part of the window, not including decorations...
WindowHandle * get_parent_window() const
Returns the parent window specification, or NULL if there is no parent window specified.
int get_x_size() const
Returns size in pixels in the x dimension of the useful part of the window, not including decorations...
bool has_title() const
Returns true if the window title has been specified, false otherwise.
bool has_size() const
Returns true if the window size has been specified, false otherwise.
void set_open(bool 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.
void output(ostream &out) const
Sets any properties that are explicitly specified in other on this object.