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  INLINE const LPoint2i &get_origin() const;
72  INLINE int get_x_origin() const;
73  INLINE int get_y_origin() const;
74  INLINE bool has_origin() const;
75  INLINE void clear_origin();
76  MAKE_PROPERTY2(origin, has_origin, get_origin, set_origin, clear_origin);
77 
78  INLINE void set_size(const LVector2i &size);
79  INLINE void set_size(int x_size, int y_size);
80  INLINE const LVector2i &get_size() const;
81  INLINE int get_x_size() const;
82  INLINE int get_y_size() const;
83  INLINE bool has_size() const;
84  INLINE void clear_size();
85  MAKE_PROPERTY2(size, has_size, get_size, set_size, clear_size);
86 
87  INLINE bool has_mouse_mode() const;
88  INLINE void set_mouse_mode(MouseMode mode);
89  INLINE MouseMode get_mouse_mode() const;
90  INLINE void clear_mouse_mode();
91  MAKE_PROPERTY2(mouse_mode, has_mouse_mode, get_mouse_mode,
92  set_mouse_mode, clear_mouse_mode);
93 
94  INLINE void set_title(const std::string &title);
95  INLINE const std::string &get_title() const;
96  INLINE bool has_title() const;
97  INLINE void clear_title();
98  MAKE_PROPERTY2(title, has_title, get_title, set_title, clear_title);
99 
100  INLINE void set_undecorated(bool undecorated);
101  INLINE bool get_undecorated() const;
102  INLINE bool has_undecorated() const;
103  INLINE void clear_undecorated();
104  MAKE_PROPERTY2(undecorated, has_undecorated, get_undecorated,
105  set_undecorated, clear_undecorated);
106 
107  INLINE void set_fixed_size(bool fixed_size);
108  INLINE bool get_fixed_size() const;
109  INLINE bool has_fixed_size() const;
110  INLINE void clear_fixed_size();
111  MAKE_PROPERTY2(fixed_size, has_fixed_size, get_fixed_size,
112  set_fixed_size, clear_fixed_size);
113 
114  INLINE void set_fullscreen(bool fullscreen);
115  INLINE bool get_fullscreen() const;
116  INLINE bool has_fullscreen() const;
117  INLINE void clear_fullscreen();
118  MAKE_PROPERTY2(fullscreen, has_fullscreen, get_fullscreen,
119  set_fullscreen, clear_fullscreen);
120 
121  INLINE void set_foreground(bool foreground);
122  INLINE bool get_foreground() const;
123  INLINE bool has_foreground() const;
124  INLINE void clear_foreground();
125  MAKE_PROPERTY2(foreground, has_foreground, get_foreground,
126  set_foreground, clear_foreground);
127 
128  INLINE void set_minimized(bool minimized);
129  INLINE bool get_minimized() const;
130  INLINE bool has_minimized() const;
131  INLINE void clear_minimized();
132  MAKE_PROPERTY2(minimized, has_minimized, get_minimized,
133  set_minimized, clear_minimized);
134 
135  INLINE void set_raw_mice(bool raw_mice);
136  INLINE bool get_raw_mice() const;
137  INLINE bool has_raw_mice() const;
138  INLINE void clear_raw_mice();
139 
140  INLINE void set_open(bool open);
141  INLINE bool get_open() const;
142  INLINE bool has_open() const;
143  INLINE void clear_open();
144  MAKE_PROPERTY2(open, has_open, get_open, set_open, clear_open);
145 
146  INLINE void set_cursor_hidden(bool cursor_hidden);
147  INLINE bool get_cursor_hidden() const;
148  INLINE bool has_cursor_hidden() const;
149  INLINE void clear_cursor_hidden();
150  MAKE_PROPERTY2(cursor_hidden, has_cursor_hidden, get_cursor_hidden,
151  set_cursor_hidden, clear_cursor_hidden);
152 
153  INLINE void set_icon_filename(const Filename &icon_filename);
154  INLINE const Filename &get_icon_filename() const;
155  INLINE bool has_icon_filename() const;
156  INLINE void clear_icon_filename();
157  MAKE_PROPERTY2(icon_filename, has_icon_filename, get_icon_filename,
158  set_icon_filename, clear_icon_filename);
159 
160  INLINE void set_cursor_filename(const Filename &cursor_filename);
161  INLINE const Filename &get_cursor_filename() const;
162  INLINE bool has_cursor_filename() const;
163  INLINE void clear_cursor_filename();
164  MAKE_PROPERTY2(cursor_filename, has_cursor_filename, get_cursor_filename,
165  set_cursor_filename, clear_cursor_filename);
166 
167  INLINE void set_z_order(ZOrder z_order);
168  INLINE ZOrder get_z_order() const;
169  INLINE bool has_z_order() const;
170  INLINE void clear_z_order();
171  MAKE_PROPERTY2(z_order, has_z_order, get_z_order, set_z_order, clear_z_order);
172 
173  void set_parent_window(size_t parent);
174  INLINE void set_parent_window(WindowHandle *parent_window = nullptr);
175  INLINE WindowHandle *get_parent_window() const;
176  INLINE bool has_parent_window() const;
177  INLINE void clear_parent_window();
178  MAKE_PROPERTY2(parent_window, has_parent_window, get_parent_window,
179  set_parent_window, clear_parent_window);
180 
181  void add_properties(const WindowProperties &other);
182 
183  void output(std::ostream &out) const;
184 
185 private:
186  // This bitmask indicates which of the parameters in the properties
187  // structure have been filled in by the user, and which remain unspecified.
188  enum Specified {
189  S_origin = 0x00001,
190  S_size = 0x00002,
191  S_title = 0x00004,
192  S_undecorated = 0x00008,
193  S_fullscreen = 0x00010,
194  S_foreground = 0x00020,
195  S_minimized = 0x00040,
196  S_open = 0x00080,
197  S_cursor_hidden = 0x00100,
198  S_fixed_size = 0x00200,
199  S_z_order = 0x00400,
200  S_icon_filename = 0x00800,
201  S_cursor_filename = 0x01000,
202  S_mouse_mode = 0x02000,
203  S_parent_window = 0x04000,
204  S_raw_mice = 0x08000,
205  };
206 
207  // This bitmask represents the truefalse settings for various boolean flags
208  // (assuming the corresponding S_* bit has been set, above).
209  enum Flags {
210  F_undecorated = S_undecorated,
211  F_fullscreen = S_fullscreen,
212  F_foreground = S_foreground,
213  F_minimized = S_minimized,
214  F_open = S_open,
215  F_cursor_hidden = S_cursor_hidden,
216  F_fixed_size = S_fixed_size,
217  F_raw_mice = S_raw_mice,
218  };
219 
220  int _specified;
221  LPoint2i _origin;
222  LVector2i _size;
223  MouseMode _mouse_mode;
224  std::string _title;
225  Filename _cursor_filename;
226  Filename _icon_filename;
227  ZOrder _z_order;
228  int _flags;
229  PT(WindowHandle) _parent_window;
230 
231  static WindowProperties *_default_properties;
232 };
233 
234 EXPCL_PANDA_DISPLAY std::ostream &
235 operator << (std::ostream &out, WindowProperties::ZOrder z_order);
236 EXPCL_PANDA_DISPLAY std::istream &
237 operator >> (std::istream &in, WindowProperties::ZOrder &z_order);
238 
239 EXPCL_PANDA_DISPLAY std::ostream &
240 operator << (std::ostream &out, WindowProperties::MouseMode mode);
241 EXPCL_PANDA_DISPLAY std::istream &
242 operator >> (std::istream &in, WindowProperties::MouseMode &mode);
243 
244 
245 INLINE std::ostream &operator << (std::ostream &out, const WindowProperties &properties);
246 
247 #include "windowProperties.I"
248 
249 #endif
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This object represents a window on the desktop, not necessarily a Panda window.
Definition: windowHandle.h:34
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.
Definition: filename.h:39
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.