Crazy Eddie's GUI System  0.8.5
GUIContext.h
1 /***********************************************************************
2  created: Mon Jan 12 2009
3  author: Paul D Turner
4 *************************************************************************/
5 /***************************************************************************
6  * Copyright (C) 2004 - 2012 Paul D Turner & The CEGUI Development Team
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining
9  * a copy of this software and associated documentation files (the
10  * "Software"), to deal in the Software without restriction, including
11  * without limitation the rights to use, copy, modify, merge, publish,
12  * distribute, sublicense, and/or sell copies of the Software, and to
13  * permit persons to whom the Software is furnished to do so, subject to
14  * the following conditions:
15  *
16  * The above copyright notice and this permission notice shall be
17  * included in all copies or substantial portions of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25  * OTHER DEALINGS IN THE SOFTWARE.
26  ***************************************************************************/
27 #ifndef _CEGUIGUIContext_h_
28 #define _CEGUIGUIContext_h_
29 
30 #include "CEGUI/RenderingSurface.h"
31 #include "CEGUI/InjectedInputReceiver.h"
32 #include "CEGUI/MouseCursor.h"
33 #include "CEGUI/SystemKeys.h"
34 
35 #if defined (_MSC_VER)
36 # pragma warning(push)
37 # pragma warning(disable : 4251)
38 #endif
39 
40 namespace CEGUI
41 {
42 struct MouseClickTracker;
43 
45 class CEGUIEXPORT GUIContextEventArgs : public EventArgs
46 {
47 public:
49  context(context)
50  {}
51 
54 };
55 
58 {
59 public:
61  GUIContextEventArgs(context),
62  renderTarget(target)
63  {}
64 
65  RenderTarget* renderTarget;
66 };
67 
68 class CEGUIEXPORT GUIContext : public RenderingSurface,
70 {
71 public:
72  static const float DefaultMouseButtonClickTimeout;
73  static const float DefaultMouseButtonMultiClickTimeout;
74  static const Sizef DefaultMouseButtonMultiClickTolerance;
75 
109 
110  GUIContext(RenderTarget& target);
111  ~GUIContext();
112 
113  Window* getRootWindow() const;
114  void setRootWindow(Window* new_root);
115 
124  void setModalWindow(Window* window);
125 
127  Window* getModalWindow() const;
128 
129  Window* getWindowContainingMouse() const;
130 
131  const Sizef& getSurfaceSize() const;
132 
133  const SystemKeys& getSystemKeys() const;
134 
136  void markAsDirty();
137  bool isDirty() const;
138 
150  MouseCursor& getMouseCursor();
151  const MouseCursor& getMouseCursor() const;
152 
153  void setMouseMoveScalingFactor(float factor);
154  float getMouseMoveScalingFactor() const;
155 
156  void setMouseButtonClickTimeout(float seconds);
157  float getMouseButtonClickTimeout() const;
158 
159  void setMouseButtonMultiClickTimeout(float seconds);
160  float getMouseButtonMultiClickTimeout() const;
161 
162  void setMouseButtonMultiClickTolerance(const Sizef& sz);
163  const Sizef& getMouseButtonMultiClickTolerance() const;
164 
178  void setMouseClickEventGenerationEnabled(const bool enable);
179 
193  bool isMouseClickEventGenerationEnabled() const;
194 
196  void updateWindowContainingMouse();
197 
198  Window* getInputCaptureWindow() const;
199  void setInputCaptureWindow(Window* window);
200 
215  void setDefaultTooltipObject(Tooltip* tooltip);
216 
229  void setDefaultTooltipType(const String& tooltip_type);
230 
232  Tooltip* getDefaultTooltipObject() const;
233 
234  void setRenderTarget(RenderTarget& target);
235 
244  void setDefaultFont(const String& name);
245 
253  void setDefaultFont(Font* font);
254 
262  Font* getDefaultFont() const;
263 
264  // Implementation of InjectedInputReceiver interface
265  bool injectMouseMove(float delta_x, float delta_y);
266  bool injectMouseLeaves(void);
267  bool injectMouseButtonDown(MouseButton button);
268  bool injectMouseButtonUp(MouseButton button);
269  bool injectKeyDown(Key::Scan scan_code);
270  bool injectKeyUp(Key::Scan scan_code);
271  bool injectChar(String::value_type code_point);
272  bool injectMouseWheelChange(float delta);
273  bool injectMousePosition(float x_pos, float y_pos);
274  bool injectTimePulse(float timeElapsed);
275  bool injectMouseButtonClick(const MouseButton button);
276  bool injectMouseButtonDoubleClick(const MouseButton button);
277  bool injectMouseButtonTripleClick(const MouseButton button);
278  bool injectCopyRequest();
279  bool injectCutRequest();
280  bool injectPasteRequest();
281 
282  // public overrides
283  void draw();
284 
285 protected:
286  void updateRootWindowAreaRects() const;
287  void drawWindowContentToTarget();
288  void renderWindowHierarchyToSurfaces();
289 
290  void createDefaultTooltipWindowInstance() const;
291  void destroyDefaultTooltipWindowInstance();
292 
294  void notifyDefaultFontChanged(Window* hierarchy_root) const;
295 
296  bool mouseMoveInjection_impl(MouseEventArgs& ma);
297  Window* getTargetWindow(const Vector2f& pt, const bool allow_disabled) const;
298  Window* getKeyboardTargetWindow() const;
299  Window* getCommonAncestor(Window* w1, Window* w2) const;
301  void notifyMouseTransition(Window* top, Window* bottom,
302  void (Window::*func)(MouseEventArgs&),
303  MouseEventArgs& args) const;
304 
305  bool areaChangedHandler(const EventArgs& args);
306  bool windowDestroyedHandler(const EventArgs& args);
307 
309  bool updateWindowContainingMouse_impl() const;
310  void resetWindowContainingMouse();
311 
312  // event trigger functions.
313  virtual void onRootWindowChanged(WindowEventArgs& args);
314  virtual void onMouseMoveScalingFactorChanged(GUIContextEventArgs& args);
315  virtual void onMouseButtonClickTimeoutChanged(GUIContextEventArgs& args);
316  virtual void onMouseButtonMultiClickTimeoutChanged(GUIContextEventArgs& args);
317  virtual void onMouseButtonMultiClickToleranceChanged(GUIContextEventArgs& args);
318  virtual void onRenderTargetChanged(GUIContextRenderTargetEventArgs& args);
319  virtual void onDefaultFontChanged(EventArgs& args);
320 
321  // protected overrides
322  void drawContent();
323 
324  Window* d_rootWindow;
325  bool d_isDirty;
326  MouseCursor d_mouseCursor;
337 
338  mutable Tooltip* d_defaultTooltipObject;
339  mutable bool d_weCreatedTooltipObject;
340  String d_defaultTooltipType;
341 
342  Font* d_defaultFont;
343 
346 
347  mutable Window* d_windowContainingMouse;
348  mutable bool d_windowContainingMouseIsUpToDate;
349  Window* d_modalWindow;
350  Window* d_captureWindow;
351 
352  SystemKeys d_systemKeys;
353  MouseClickTracker* d_mouseClickTrackers;
354 
355  Event::ScopedConnection d_areaChangedEventConnection;
356  Event::ScopedConnection d_windowDestroyedEventConnection;
357 };
358 
359 }
360 
361 #if defined(_MSC_VER)
362 # pragma warning(pop)
363 #endif
364 
365 #endif
366 
Definition: GUIContext.h:68
Class that provides mouse cursor support.
Definition: MouseCursor.h:51
float d_mouseButtonClickTimeout
Timeout used to when detecting a single-click.
Definition: GUIContext.h:332
Sizef d_surfaceSize
a cache of the target surface size, allows returning by ref.
Definition: GUIContext.h:345
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
Event::Connection wrapper that automatically disconnects the connection when the object is deleted (o...
Definition: Event.h:91
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:49
Base class for Tooltip widgets.
Definition: widgets/Tooltip.h:79
MouseButton
Enumeration of mouse buttons.
Definition: InputEvent.h:209
Sizef d_mouseButtonMultiClickTolerance
Movement tolerance used when detecting multi-click events.
Definition: GUIContext.h:336
EventArgs class passed for GUIContext RenderTarget related events.
Definition: GUIContext.h:57
static const String EventMouseMoveScalingFactorChanged
Definition: GUIContext.h:86
Input injection interface to be inplemented by classes that take raw inputs.
Definition: InjectedInputReceiver.h:36
EventArgs class passed to subscribers for (most) GUIContext events.
Definition: GUIContext.h:45
Class that encapsulates a typeface.
Definition: Font.h:58
static const String EventDefaultFontChanged
Definition: GUIContext.h:108
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:149
Class that represents a surface that can have geometry based imagery drawn to it. ...
Definition: RenderingSurface.h:108
Defines interface to some surface that can be rendered to. Concrete instances of objects that impleme...
Definition: RenderTarget.h:57
float d_mouseButtonMultiClickTimeout
Timeout used when detecting multi-click events.
Definition: GUIContext.h:334
static const String EventMouseButtonMultiClickToleranceChanged
Definition: GUIContext.h:99
static const String EventRenderTargetChanged
Definition: GUIContext.h:104
utf32 value_type
Basic 'code point' type used for String (utf32)
Definition: String.h:69
float d_mouseMovementScalingFactor
Scaling factor applied to injected mouse move deltas.
Definition: GUIContext.h:328
EventArgs based class that is used for objects passed to handlers triggered for events concerning som...
Definition: InputEvent.h:251
Definition: SystemKeys.h:34
static const String EventMouseButtonClickTimeoutChanged
Definition: GUIContext.h:90
EventArgs based class that is used for objects passed to input event handlers concerning mouse input...
Definition: InputEvent.h:280
bool d_generateMouseClickEvents
should mouse click/multi-click events be automatically generated.
Definition: GUIContext.h:330
GUIContext * context
pointer to the GUIContext that triggered the event.
Definition: GUIContext.h:53
static const String EventRootWindowChanged
Definition: GUIContext.h:82
static const String EventMouseButtonMultiClickTimeoutChanged
Definition: GUIContext.h:94
String class used within the GUI system.
Definition: String.h:62