1 // Window for placing a Canvas onto it (for dialogs, menus, etc.)
3 // Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Library General Public
7 // License as published by the Free Software Foundation; either
8 // version 2 of the License, or (at your option) any later version.
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Library General Public License for more details.
15 // You should have received a copy of the GNU Library General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #ifndef CANVAS_WINDOW_HXX_
20 #define CANVAS_WINDOW_HXX_
22 #include <simgear/canvas/elements/CanvasImage.hxx>
23 #include <simgear/canvas/layout/Layout.hxx>
24 #include <simgear/canvas/events/MouseEvent.hxx>
25 #include <simgear/props/PropertyBasedElement.hxx>
26 #include <simgear/props/propertyObject.hxx>
27 #include <simgear/misc/CSSBorder.hxx>
30 #include <osg/Geometry>
42 static const std::string TYPE_NAME;
55 * @param node Property node containing settings for this window:
56 * capture-events Disable/Enable event capturing
57 * content-size[0-1] Size of content area (excluding
59 * decoration-border Size of decoration border
60 * resize Enable resize cursor and properties
61 * shadow-inset Inset of shadow image
62 * shadow-radius Radius/outset of shadow image
64 Window( const CanvasWeakPtr& canvas,
65 const SGPropertyNode_ptr& node,
66 const Style& parent_style = Style(),
67 Element* parent = 0 );
70 virtual void update(double delta_time_sec);
71 virtual void valueChanged(SGPropertyNode* node);
73 osg::Group* getGroup();
74 const SGVec2<float> getPosition() const;
75 const SGRect<float> getScreenRegion() const;
77 void setCanvasContent(CanvasPtr canvas);
78 simgear::canvas::CanvasWeakPtr getCanvasContent() const;
80 void setLayout(const LayoutRef& layout);
82 CanvasPtr getCanvasDecoration() const;
84 bool isResizable() const;
85 bool isCapturingEvents() const;
88 * Moves window on top of all other windows with the same z-index.
90 * @note If no z-index is set it defaults to 0.
94 void handleResize( uint8_t mode,
95 const osg::Vec2f& offset = osg::Vec2f() );
104 uint32_t _attributes_dirty;
106 CanvasPtr _canvas_decoration;
107 CanvasWeakPtr _canvas_content;
110 ImagePtr _image_content,
116 PropertyObject<int> _resize_top,
122 CSSBorder _decoration_border;
124 void parseDecorationBorder(const std::string& str);
125 void updateDecoration();
128 } // namespace canvas
129 } // namespace simgear
131 #endif /* CANVAS_WINDOW_HXX_ */