]> git.mxchange.org Git - flightgear.git/blob - src/Canvas/window.hxx
commradio: improvements for atis speech
[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       static const std::string TYPE_NAME;
38
39       enum Resize
40       {
41         NONE    = 0,
42         LEFT    = 1,
43         RIGHT   = LEFT << 1,
44         TOP     = RIGHT << 1,
45         BOTTOM  = TOP << 1,
46         INIT    = BOTTOM << 1
47       };
48
49       typedef simgear::canvas::Style Style;
50
51       /**
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
55        *                                    decoration border)
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
60        */
61       Window( const simgear::canvas::CanvasWeakPtr& canvas,
62               const SGPropertyNode_ptr& node,
63               const Style& parent_style = Style(),
64               Element* parent = 0 );
65       virtual ~Window();
66
67       virtual void update(double delta_time_sec);
68       virtual void valueChanged(SGPropertyNode* node);
69
70       osg::Group* getGroup();
71       const SGVec2<float> getPosition() const;
72       const SGRect<float>  getScreenRegion() const;
73
74       void setCanvasContent(simgear::canvas::CanvasPtr canvas);
75       simgear::canvas::CanvasWeakPtr getCanvasContent() const;
76
77       simgear::canvas::CanvasPtr getCanvasDecoration();
78
79       bool isResizable() const;
80       bool isCapturingEvents() const;
81
82       /**
83        * Moves window on top of all other windows with the same z-index.
84        *
85        * @note If no z-index is set it defaults to 0.
86        */
87       void raise();
88
89       void handleResize( uint8_t mode,
90                          const osg::Vec2f& offset = osg::Vec2f() );
91
92     protected:
93
94       enum Attributes
95       {
96         DECORATION = 1
97       };
98
99       uint32_t  _attributes_dirty;
100
101       simgear::canvas::CanvasPtr        _canvas_decoration;
102       simgear::canvas::CanvasWeakPtr    _canvas_content;
103
104       simgear::canvas::ImagePtr _image_content,
105                                 _image_shadow;
106
107       bool _resizable,
108            _capture_events;
109
110       simgear::PropertyObject<int> _resize_top,
111                                    _resize_right,
112                                    _resize_bottom,
113                                    _resize_left,
114                                    _resize_status;
115
116       simgear::CSSBorder    _decoration_border;
117
118       void parseDecorationBorder(const std::string& str);
119       void updateDecoration();
120   };
121 } // namespace canvas
122
123 #endif /* CANVAS_WINDOW_HXX_ */