1 /***********************************************************************
2 created: 28/8/2004
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 #include "CEGUI/widgets/DefaultWindow.h"
28
29
30 // Start of CEGUI namespace section
31 namespace CEGUI
32 {
33 /*************************************************************************
34 Constants
35 *************************************************************************/
36 // type name for this widget
37 const String DefaultWindow::WidgetTypeName("DefaultWindow");
38
39 /*************************************************************************
40 Constructor
41 *************************************************************************/
DefaultWindow(const String & type,const String & name)42 DefaultWindow::DefaultWindow(const String& type, const String& name) :
43 Window(type, name)
44 {
45 USize sz(cegui_reldim(1.0f), cegui_reldim(1.0f));
46 setMaxSize(sz);
47 setSize(sz);
48 }
49
50 //----------------------------------------------------------------------------//
onMouseMove(MouseEventArgs & e)51 void DefaultWindow::onMouseMove(MouseEventArgs& e)
52 {
53 // always call the base class handler
54 Window::onMouseMove(e);
55 updateMouseEventHandled(e);
56 }
57
58 //----------------------------------------------------------------------------//
onMouseWheel(MouseEventArgs & e)59 void DefaultWindow::onMouseWheel(MouseEventArgs& e)
60 {
61 // always call the base class handler
62 Window::onMouseWheel(e);
63 updateMouseEventHandled(e);
64 }
65
66 //----------------------------------------------------------------------------//
onMouseButtonDown(MouseEventArgs & e)67 void DefaultWindow::onMouseButtonDown(MouseEventArgs& e)
68 {
69 // always call the base class handler
70 Window::onMouseButtonDown(e);
71 updateMouseEventHandled(e);
72 }
73
74 //----------------------------------------------------------------------------//
onMouseButtonUp(MouseEventArgs & e)75 void DefaultWindow::onMouseButtonUp(MouseEventArgs& e)
76 {
77 // always call the base class handler
78 Window::onMouseButtonUp(e);
79 updateMouseEventHandled(e);
80 }
81
82 //----------------------------------------------------------------------------//
onMouseClicked(MouseEventArgs & e)83 void DefaultWindow::onMouseClicked(MouseEventArgs& e)
84 {
85 // always call the base class handler
86 Window::onMouseClicked(e);
87 // only adjust the handled state if event was directly injected
88 if (!getGUIContext().isMouseClickEventGenerationEnabled())
89 updateMouseEventHandled(e);
90 }
91
92 //----------------------------------------------------------------------------//
onMouseDoubleClicked(MouseEventArgs & e)93 void DefaultWindow::onMouseDoubleClicked(MouseEventArgs& e)
94 {
95 // always call the base class handler
96 Window::onMouseDoubleClicked(e);
97 updateMouseEventHandled(e);
98 }
99
100 //----------------------------------------------------------------------------//
onMouseTripleClicked(MouseEventArgs & e)101 void DefaultWindow::onMouseTripleClicked(MouseEventArgs& e)
102 {
103 // always call the base class handler
104 Window::onMouseTripleClicked(e);
105 updateMouseEventHandled(e);
106 }
107
108 //----------------------------------------------------------------------------//
updateMouseEventHandled(MouseEventArgs & e) const109 void DefaultWindow::updateMouseEventHandled(MouseEventArgs& e) const
110 {
111 // by default, if we are a root window (no parent) with pass-though enabled
112 // we do /not/ mark mouse events as handled.
113 if (!d_parent && e.handled && d_mousePassThroughEnabled)
114 --e.handled;
115 }
116
117 //----------------------------------------------------------------------------//
moveToFront_impl(bool wasClicked)118 bool DefaultWindow::moveToFront_impl(bool wasClicked)
119 {
120 const bool took_action = Window::moveToFront_impl(wasClicked);
121
122 if (!d_parent && d_mousePassThroughEnabled)
123 return false;
124 else
125 return took_action;
126 }
127
128 //----------------------------------------------------------------------------//
129
130 } // End of CEGUI namespace section
131