Crazy Eddie's GUI System  0.8.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
GUIContext.h
1 /***********************************************************************
2  filename: GUIContext.h
3  created: Mon Jan 12 2009
4  author: Paul D Turner
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2012 Paul D Turner & The CEGUI Development Team
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  ***************************************************************************/
28 #ifndef _CEGUIGUIContext_h_
29 #define _CEGUIGUIContext_h_
30 
31 #include "CEGUI/RenderingSurface.h"
32 #include "CEGUI/InjectedInputReceiver.h"
33 #include "CEGUI/MouseCursor.h"
34 #include "CEGUI/SystemKeys.h"
35 
36 #if defined (_MSC_VER)
37 # pragma warning(push)
38 # pragma warning(disable : 4251)
39 #endif
40 
41 namespace CEGUI
42 {
43 struct MouseClickTracker;
44 
46 class CEGUIEXPORT GUIContextEventArgs : public EventArgs
47 {
48 public:
50  context(context)
51  {}
52 
55 };
56 
59 {
60 public:
62  GUIContextEventArgs(context),
63  renderTarget(target)
64  {}
65 
66  RenderTarget* renderTarget;
67 };
68 
69 class CEGUIEXPORT GUIContext : public RenderingSurface,
71 {
72 public:
73  static const float DefaultMouseButtonClickTimeout;
74  static const float DefaultMouseButtonMultiClickTimeout;
75  static const Sizef DefaultMouseButtonMultiClickTolerance;
76 
110 
111  GUIContext(RenderTarget& target);
112  ~GUIContext();
113 
114  Window* getRootWindow() const;
115  void setRootWindow(Window* new_root);
116 
125  void setModalWindow(Window* window);
126 
128  Window* getModalWindow() const;
129 
130  Window* getWindowContainingMouse() const;
131 
132  const Sizef& getSurfaceSize() const;
133 
134  const SystemKeys& getSystemKeys() const;
135 
137  void markAsDirty();
138  bool isDirty() const;
139 
140  MouseCursor& getMouseCursor();
141  const MouseCursor& getMouseCursor() const;
142 
143  void setMouseMoveScalingFactor(float factor);
144  float getMouseMoveScalingFactor() const;
145 
146  void setMouseButtonClickTimeout(float seconds);
147  float getMouseButtonClickTimeout() const;
148 
149  void setMouseButtonMultiClickTimeout(float seconds);
150  float getMouseButtonMultiClickTimeout() const;
151 
152  void setMouseButtonMultiClickTolerance(const Sizef& sz);
153  const Sizef& getMouseButtonMultiClickTolerance() const;
154 
168  void setMouseClickEventGenerationEnabled(const bool enable);
169 
183  bool isMouseClickEventGenerationEnabled() const;
184 
186  void updateWindowContainingMouse();
187 
188  Window* getInputCaptureWindow() const;
189  void setInputCaptureWindow(Window* window);
190 
205  void setDefaultTooltipObject(Tooltip* tooltip);
206 
219  void setDefaultTooltipType(const String& tooltip_type);
220 
222  Tooltip* getDefaultTooltipObject() const;
223 
224  void setRenderTarget(RenderTarget& target);
225 
234  void setDefaultFont(const String& name);
235 
243  void setDefaultFont(Font* font);
244 
252  Font* getDefaultFont() const;
253 
254  // Implementation of InjectedInputReceiver interface
255  bool injectMouseMove(float delta_x, float delta_y);
256  bool injectMouseLeaves(void);
257  bool injectMouseButtonDown(MouseButton button);
258  bool injectMouseButtonUp(MouseButton button);
259  bool injectKeyDown(Key::Scan scan_code);
260  bool injectKeyUp(Key::Scan scan_code);
261  bool injectChar(String::value_type code_point);
262  bool injectMouseWheelChange(float delta);
263  bool injectMousePosition(float x_pos, float y_pos);
264  bool injectTimePulse(float timeElapsed);
265  bool injectMouseButtonClick(const MouseButton button);
266  bool injectMouseButtonDoubleClick(const MouseButton button);
267  bool injectMouseButtonTripleClick(const MouseButton button);
268  bool injectCopyRequest();
269  bool injectCutRequest();
270  bool injectPasteRequest();
271 
272  // public overrides
273  void draw();
274 
275 protected:
276  void updateRootWindowAreaRects() const;
277  void drawWindowContentToTarget();
278  void renderWindowHierarchyToSurfaces();
279 
280  void createDefaultTooltipWindowInstance() const;
281  void destroyDefaultTooltipWindowInstance();
282 
284  void notifyDefaultFontChanged(Window* hierarchy_root) const;
285 
286  bool mouseMoveInjection_impl(MouseEventArgs& ma);
287  Window* getTargetWindow(const Vector2f& pt, const bool allow_disabled) const;
288  Window* getKeyboardTargetWindow() const;
289  Window* getCommonAncestor(Window* w1, Window* w2) const;
291  void notifyMouseTransition(Window* top, Window* bottom,
292  void (Window::*func)(MouseEventArgs&),
293  MouseEventArgs& args) const;
294 
295  bool areaChangedHandler(const EventArgs& args);
296  bool windowDestroyedHandler(const EventArgs& args);
297 
299  bool updateWindowContainingMouse_impl() const;
300  void resetWindowContainingMouse();
301 
302  // event trigger functions.
303  virtual void onRootWindowChanged(WindowEventArgs& args);
304  virtual void onMouseMoveScalingFactorChanged(GUIContextEventArgs& args);
305  virtual void onMouseButtonClickTimeoutChanged(GUIContextEventArgs& args);
306  virtual void onMouseButtonMultiClickTimeoutChanged(GUIContextEventArgs& args);
307  virtual void onMouseButtonMultiClickToleranceChanged(GUIContextEventArgs& args);
308  virtual void onRenderTargetChanged(GUIContextRenderTargetEventArgs& args);
309  virtual void onDefaultFontChanged(EventArgs& args);
310 
311  // protected overrides
312  void drawContent();
313 
314  Window* d_rootWindow;
315  bool d_isDirty;
316  MouseCursor d_mouseCursor;
327 
328  mutable Tooltip* d_defaultTooltipObject;
329  mutable bool d_weCreatedTooltipObject;
330  String d_defaultTooltipType;
331 
332  Font* d_defaultFont;
333 
336 
337  mutable Window* d_windowContainingMouse;
338  mutable bool d_windowContainingMouseIsUpToDate;
339  Window* d_modalWindow;
340  Window* d_captureWindow;
341 
342  SystemKeys d_systemKeys;
343  MouseClickTracker* d_mouseClickTrackers;
344 
345  Event::ScopedConnection d_areaChangedEventConnection;
346  Event::ScopedConnection d_windowDestroyedEventConnection;
347 };
348 
349 }
350 
351 #if defined(_MSC_VER)
352 # pragma warning(pop)
353 #endif
354 
355 #endif
356