1 #include <l4/scout-gfx/window>
3 #include <l4/re/event_enums.h>
6 using namespace Mag_gfx;
10 class Win_layout : public Layout
13 Window::Deco_policy::Insets _inset;
18 Win_layout(Layout_item *child, Window::Deco_policy::Insets **insets)
19 : _inset(), _child(child)
21 _inset.tl = Area(0,0);
22 _inset.br = Area(0,0);
23 _child->set_parent_layout_item(this);
27 virtual ~Win_layout() {}
29 Area preferred_size() const
30 { return _child->preferred_size() + _inset.tl + _inset.br; }
33 { return _child->min_size() + _inset.tl + _inset.br; }
36 { return _child->max_size() + _inset.tl + _inset.br; }
38 Orientations expanding() const { return _child->expanding(); }
39 bool empty() const { return false; }
40 bool has_height_for_width() const
41 { return _child->has_height_for_width(); }
43 int height_for_width(int w) const
44 { return _child->height_for_width(w); }
46 int min_height_for_width(int w) const
47 { return _child->min_height_for_width(w); }
49 //void child_invalidate() { _child->invalidate(); }
50 //void invalidate() { _child->invalidate(); }
52 void set_geometry(Rect const &r)
55 = r.offset(_inset.tl.w(), _inset.tl.h(), -_inset.br.w(), -_inset.br.h());
57 _child->set_geometry(x);
62 return _child->geometry().offset(-_inset.tl.w(), -_inset.tl.h(),
63 _inset.br.w(), _inset.br.h());
66 void add_item(Layout_item *) {}
67 Layout_item *remove_item(int) { return 0; }
68 Layout_item *item(int) const { return _child; }
73 Window::Window(Window::Deco_policy *dp, View *v,
75 : Basic_window(v, max_size),
76 // this is some stupid hack, needs to be defined by the app
77 _normal_pos(Point(100, 100), Area(300, 200)),
80 _deco = _deco_policy->create_deco(this);
81 Basic_window::set_child_layout(new Win_layout(&_content, &_insets));
82 _deco_policy->set_deco_mode(Window::Fullscreen, _deco, _insets);
84 Basic_window::append(&_content);
85 Basic_window::append(_deco);
90 Window::set_window_mode(Mode mode)
92 _deco_policy->set_deco_mode(mode, _deco, _insets);
94 set_geometry(_normal_pos);
97 _normal_pos = geometry();
102 set_geometry(Rect(Point(0,0), max_size()));
105 set_geometry(Rect(pos(), min_size()));
111 redraw_area(Rect(Point(0, 0), size()));