HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RE_Window.h
Go to the documentation of this file.
1 
2 #ifndef __RE_Window_h__
3 #define __RE_Window_h__
4 
5 #include "RE_API.h"
6 #include "RE_IDType.h"
7 #include "RE_Types.h"
8 
9 #include <UT/UT_Defines.h>
10 #include <UT/UT_Rect.h>
11 #include <UT/UT_Lock.h>
12 #include <UT/UT_Pair.h>
13 #include <UT/UT_ValArray.h>
14 
15 class RE_Visual;
16 class RE_Server;
17 class RE_Render;
18 
19 class QWidget;
20 
21 
23 {
25  alwaysOnTop:1,
26  maximized:1,
27  fullscreen:1;
28 };
29 
31 {
32 public:
33  RE_Window(RE_Server *server,
35  RE_VisualType visType = RE_NORMAL_VIS);
36 
37  virtual ~RE_Window();
38 
39  void setName(const char *name);
40  void setIconName(const char *name);
41 
42  void setParentWindow(RE_Window *parent);
43  const RE_Window *getParentWindow() const { return parentWindow; }
44 
45  void setDialogParentHint(RE_IDType parent_hint);
46 
47  RE_Server *getServer() { return myServer; }
49  { return myVisualResource; }
50  RE_Render *getRender();
51  void setRender(RE_Render *r) { myRender = r; }
52 
53  // Opens a window but does not show it immediately.
54  // Call showWindow to show the window.
55  RE_IDType openWindow();
56  void showWindow();
57  void closeWindow();
58 
59  void initMaxSize(int w, int h );
60  void initMinSize(int w, int h );
61  void initVisual( RE_Visual *visual );
62  void setLimitPositions(bool limitpos)
63  { myLimitPositions = limitpos; }
64  bool getLimitPositions() const
65  { return myLimitPositions; }
66 
67  void moveWindow(int x, int y);
68  void sizeWindow(int w, int h);
69 
70  // Set the window's opacity (0.0 - 1.0).
71  // Values less than 1.0 will make the window translucent.
72  void setWindowOpacity(fpreal opacity);
73 
74 
75  // Maximize the window and/or mark it as maximized so that when openWindow
76  // is called, it can open the window maximized.
77  void maximizeWindow();
78  void restoreWindow();
79 
80  bool isMaximized() const { return winFlags.maximized; }
81 
82  // Set the window as fullscreen. Depending on the windowing system, this
83  // either informs the window manager to set us as fullscreen or simply
84  // sets borders up so that higher-level classes can do the fullscreening
85  // themselves.
86  void fullscreenWindow(bool full);
87  bool isFullscreenWindow() const { return winFlags.fullscreen; }
88  void lowerWindow();
89  void raiseWindow();
90 
91  // Show/Hide the Window Frame/ Titlebar
92  void setHasWindowFrame(bool b);
93  bool hasWindowFrame() const;
94 
95  int getBorderWidth() const
96  { return myLeftBorder+myRightBorder; }
97  int getBorderHeight() const
98  { return myTopBorder+myBottomBorder; }
99  int getBorderTopSize() const
100  { return myTopBorder; }
101  int getBorderLeftSize() const
102  { return myLeftBorder; }
104  { return myBottomBorder; }
105  int getBorderRightSize() const
106  { return myRightBorder; }
107 
108  UT_DimRect findLocation() const;
109 
110  // Sets the window to sit on top of all other windows, or turns off that
111  // state, depending on whether newstate is true or false.
112  void setWindowAlwaysOnTop(bool newstate);
113  int getWindowAlwaysOnTop() const { return winFlags.alwaysOnTop; }
114 
115  void setWindowFloatOnTop(bool on_top);
116 
117  RE_DisplayMode getMode() const;
118 
120  { return myVisualType; }
121  void setVisualType(RE_VisualType t) { myVisualType = t; }
122 
123  // changes to the type will not occur until the window is opened again.
125  { myWindowType = t; }
126 
127  RE_WindowType getWindowType( bool extra=false) const;
128 
129 
130  void setWindowID(RE_IDType id) { myWindowID = id; }
132  { return myWindowID; }
133  int matchID( RE_IDType wid ) const
134  { return wid == myWindowID; }
135 
136  virtual RE_IDType getBufferID() const { return 0; }
137 
138  OGLDrawable getGraphicsDrawable() const { return myDrawable; }
139  void setGraphicsDrawable(OGLDrawable d) { myDrawable = d; }
140 
141 
142  void setIMESupport(bool enable);
143 
144  /// Return the Qt main window.
145  static QWidget * mainQtWindow();
146 
147  /// Create a Qt window widget for the given window type.
148  /// The caller takes ownership of the returned object.
149  static QWidget * createQtWindow(RE_WindowType win_type);
150 
151  /// Returns true if Houdini or any of its sub windows are focused
152  static bool appActive();
153 
154  void setWindowBorders(int left, int right, int top, int bottom)
155  {
156  myLeftBorder = left;
157  myRightBorder = right;
158  myTopBorder = top;
159  myBottomBorder = bottom;
160  }
161 
162  // This is called by the native window to inform that it has changed its
163  // maximized state.
164  void updateMaximizedFlag(bool is_maximized)
165  {
166  winFlags.maximized = is_maximized;
167  }
168 
169  static bool isTabFocusEnabled();
170  static void enableTabFocus(bool enable);
171 
172  /// Return the string tag used to identify whether a Qt widget is the
173  /// window for an RE_Window object.
174  static const char * windowTag() { return "RE_Window"; }
175 
176  bool isQuadBufferStereo() const;
177 
178  /// Return the screen number containing this window.
179  /// If the underlying platform window has not been created
180  /// yet then return the primary screen number.
181  int screen() const;
182 
183  /// Get screen-to-window scale.
184  fpreal screenToDeviceScale() const;
185 
186  /// Get Default Window Border Sizes
187  static const int* getDefaultWindowBorderSizes();
188  static int getDefaultWindowTitleBarHeight();
189 
190 private:
191  /// Initialize window borders.
192  void initBorderSizes_();
193 
194  /// Move the underlying Qt window to the position specified by myFrame.
195  void moveQtWindow_();
196 
197 #if defined(WIN32)
198  /// Add the Always On Top menu item to the window's system menu.
199  void addAlwaysOnTopSystemMenuItem_();
200 #endif
201 
202 private:
203  RE_Server *myServer;
204  RE_Render *myRender;
205  RE_Visual *myVisualResource;
206  RE_VisualType myVisualType;
207  RE_IDType myWindowID;
208 
209  UT_String myName;
210  UT_String myIconName;
211 
212  // Window geometry in native screen coordinates and scaling.
213  UT_DimRect myFrame;
214 
215  // Window sizes in native screen scaling.
216  UT_IntPair myMinSize;
217  UT_IntPair myMaxSize;
218 
219  OGLDrawable myDrawable;
220 
221 
222  unsigned long myIconPixmap;
223  RE_WindowFlags winFlags;
224  RE_Window *parentWindow;
225  RE_IDType myDialogParentHint;
226 
227  RE_WindowType myWindowType;
228 
229  int myLeftBorder;
230  int myTopBorder;
231  int myRightBorder;
232  int myBottomBorder;
233 
234  unsigned int myLimitPositions:1;
235 
236  fpreal myWindowOpacity;
237 
238 #if defined(WIN32)
239  bool myAddedAlwaysOnTopMenuItem;
240 #endif
241 };
242 
244 {
245 public:
247  { }
249  { }
250 
251  void lock()
252  { myLock.lock(); }
253  void unlock()
254  { myLock.unlock(); }
256  { lock(); myWindows.append(w); unlock(); }
258  { lock(); myWindows.findAndRemove(w); unlock(); }
259  int getNumWindows() const
260  { return myWindows.entries(); }
262  { return myWindows(index); }
263  void removeWindow(RE_IDType wid);
264  RE_Window *isWindowHere(RE_IDType wid);
265 
266 private:
267  UT_ValArray<RE_Window *> myWindows;
268  UT_Lock myLock;
269 };
270 
271 #endif
void * RE_IDType
Definition: RE_IDType.h:20
void setRender(RE_Render *r)
Definition: RE_Window.h:51
void removeWindow(RE_Window *w)
Definition: RE_Window.h:257
const RE_Window * getParentWindow() const
Definition: RE_Window.h:43
bool isOriginReadjusted
Definition: RE_Window.h:24
#define RE_API
Definition: RE_API.h:10
void setWindowID(RE_IDType id)
Definition: RE_Window.h:130
RE_VisualType getVisualType() const
Definition: RE_Window.h:119
GLint left
Definition: glcorearb.h:2004
int getBorderLeftSize() const
Definition: RE_Window.h:101
int getBorderWidth() const
Definition: RE_Window.h:95
bool isFullscreenWindow() const
Definition: RE_Window.h:87
void setWindowType(RE_WindowType t)
Definition: RE_Window.h:124
void addWindow(RE_Window *w)
Definition: RE_Window.h:255
GLint y
Definition: glcorearb.h:102
RE_Window * getWindow(int index) const
Definition: RE_Window.h:261
int getWindowAlwaysOnTop() const
Definition: RE_Window.h:113
bool alwaysOnTop
Definition: RE_Window.h:24
GLuint id
Definition: glcorearb.h:654
OGLDrawable getGraphicsDrawable() const
Definition: RE_Window.h:138
void setGraphicsDrawable(OGLDrawable d)
Definition: RE_Window.h:139
void unlock()
Definition: RE_Window.h:253
int getBorderBottomSize() const
Definition: RE_Window.h:103
void setVisualType(RE_VisualType t)
Definition: RE_Window.h:121
virtual RE_IDType getBufferID() const
Definition: RE_Window.h:136
int matchID(RE_IDType wid) const
Definition: RE_Window.h:133
int getNumWindows() const
Definition: RE_Window.h:259
int getBorderRightSize() const
Definition: RE_Window.h:105
RE_DisplayMode
Definition: RE_Types.h:536
GLuint const GLchar * name
Definition: glcorearb.h:785
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1221
void setLimitPositions(bool limitpos)
Definition: RE_Window.h:62
GLint GLint bottom
Definition: glcorearb.h:2004
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2001
double fpreal
Definition: SYS_Types.h:270
bool maximized
Definition: RE_Window.h:24
bool isMaximized() const
Definition: RE_Window.h:80
RE_Visual * getVisual()
Definition: RE_Window.h:48
int getBorderHeight() const
Definition: RE_Window.h:97
GLuint index
Definition: glcorearb.h:785
GLint GLenum GLint x
Definition: glcorearb.h:408
RE_VisualType
Definition: RE_Types.h:586
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107
void lock()
Definition: RE_Window.h:251
bool fullscreen
Definition: RE_Window.h:24
int getBorderTopSize() const
Definition: RE_Window.h:99
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
GLboolean r
Definition: glcorearb.h:1221
void updateMaximizedFlag(bool is_maximized)
Definition: RE_Window.h:164
void setWindowBorders(int left, int right, int top, int bottom)
Definition: RE_Window.h:154
RE_WindowType
Definition: RE_Types.h:20
static const char * windowTag()
Definition: RE_Window.h:174
bool getLimitPositions() const
Definition: RE_Window.h:64
RE_IDType getWindowID() const
Definition: RE_Window.h:131
RE_Server * getServer()
Definition: RE_Window.h:47