1 // Window for placing a Canvas onto it (for dialogs, menus, etc.)
3 // Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 2 of the
8 // License, or (at your option) any later version.
10 // This program is distributed in the hope that it will be useful, but
11 // WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, 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/MouseEvent.hxx>
24 #include <simgear/props/PropertyBasedElement.hxx>
25 #include <simgear/props/propertyObject.hxx>
26 #include <simgear/misc/CSSBorder.hxx>
29 #include <osg/Geometry>
34 public simgear::canvas::Image
37 static const std::string TYPE_NAME;
49 typedef simgear::canvas::Style Style;
52 * @param node Property node containing settings for this window:
53 * capture-events Disable/Enable event capturing
54 * content-size[0-1] Size of content area (excluding
56 * decoration-border Size of decoration border
57 * resize Enable resize cursor and properties
58 * shadow-inset Inset of shadow image
59 * shadow-radius Radius/outset of shadow image
61 Window( const simgear::canvas::CanvasWeakPtr& canvas,
62 const SGPropertyNode_ptr& node,
63 const Style& parent_style = Style(),
64 Element* parent = 0 );
67 virtual void update(double delta_time_sec);
68 virtual void valueChanged(SGPropertyNode* node);
70 osg::Group* getGroup();
71 const SGVec2<float> getPosition() const;
72 const SGRect<float> getScreenRegion() const;
74 void setCanvasContent(simgear::canvas::CanvasPtr canvas);
75 simgear::canvas::CanvasWeakPtr getCanvasContent() const;
77 simgear::canvas::CanvasPtr getCanvasDecoration();
79 bool isResizable() const;
80 bool isCapturingEvents() const;
83 * Moves window on top of all other windows with the same z-index.
85 * @note If no z-index is set it defaults to 0.
89 void handleResize( uint8_t mode,
90 const osg::Vec2f& offset = osg::Vec2f() );
99 uint32_t _attributes_dirty;
101 simgear::canvas::CanvasPtr _canvas_decoration;
102 simgear::canvas::CanvasWeakPtr _canvas_content;
104 simgear::canvas::ImagePtr _image_content,
110 simgear::PropertyObject<int> _resize_top,
116 simgear::CSSBorder _decoration_border;
118 void parseDecorationBorder(const std::string& str);
119 void updateDecoration();
121 } // namespace canvas
123 #endif /* CANVAS_WINDOW_HXX_ */