]> git.mxchange.org Git - flightgear.git/blob - src/Canvas/window.hxx
Base canvas::Window on simgear::canvas::Image
[flightgear.git] / src / Canvas / window.hxx
1 // Window for placing a Canvas onto it (for dialogs, menus, etc.)
2 //
3 // Copyright (C) 2012  Thomas Geymayer <tomgey@gmail.com>
4 //
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.
9 //
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.
14 //
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.
18
19 #ifndef CANVAS_WINDOW_HXX_
20 #define CANVAS_WINDOW_HXX_
21
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>
27
28 #include <osg/Geode>
29 #include <osg/Geometry>
30
31 namespace canvas
32 {
33   class Window:
34     public simgear::canvas::Image
35   {
36     public:
37
38       enum Resize
39       {
40         NONE    = 0,
41         LEFT    = 1,
42         RIGHT   = LEFT << 1,
43         TOP     = RIGHT << 1,
44         BOTTOM  = TOP << 1,
45         INIT    = BOTTOM << 1
46       };
47
48       Window(SGPropertyNode* node);
49       virtual ~Window();
50
51       virtual void update(double delta_time_sec);
52       virtual void valueChanged(SGPropertyNode* node);
53
54       osg::Group* getGroup();
55       const SGVec2<float> getPosition() const;
56       const SGRect<float>  getScreenRegion() const;
57
58       void setCanvas(simgear::canvas::CanvasPtr canvas);
59       simgear::canvas::CanvasWeakPtr getCanvas() const;
60
61       simgear::canvas::CanvasPtr getCanvasDecoration();
62
63       bool isResizable() const;
64       bool isCapturingEvents() const;
65
66       void handleResize(uint8_t mode, const osg::Vec2f& delta = osg::Vec2f());
67
68       void doRaise(SGPropertyNode* node_raise = 0);
69
70     protected:
71
72       enum Attributes
73       {
74         DECORATION = 1
75       };
76
77       uint32_t  _attributes_dirty;
78
79       simgear::canvas::CanvasPtr        _canvas_decoration;
80       simgear::canvas::CanvasWeakPtr    _canvas_content;
81
82       simgear::canvas::ImagePtr _image_content,
83                                 _image_shadow;
84
85       bool _resizable,
86            _capture_events;
87
88       simgear::PropertyObject<int> _resize_top,
89                                    _resize_right,
90                                    _resize_bottom,
91                                    _resize_left,
92                                    _resize_status;
93
94       simgear::CSSBorder    _decoration_border;
95
96       void parseDecorationBorder(const std::string& str);
97       void updateDecoration();
98   };
99 } // namespace canvas
100
101 #endif /* CANVAS_WINDOW_HXX_ */