]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/scout-gfx/include/doc/verbatim
update
[l4.git] / l4 / pkg / scout-gfx / include / doc / verbatim
1 // vi:ft=cpp
2 /*
3  * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
4  *     economic rights: Technische Universität Dresden (Germany)
5  *
6  * This file is part of TUD:OS and distributed under the terms of the
7  * GNU General Public License 2.
8  * Please see the COPYING-GPL-2 file for details.
9  */
10 #pragma once
11
12 #include <l4/scout-gfx/widget>
13 #include <l4/scout-gfx/doc/token>
14
15 #include <cstring>
16
17 namespace Scout_gfx {
18 /**
19  * Verbatim text block
20  *
21  * A verbatim text block consists of a number of preformatted text lines.
22  * The text is printed in a monospaced font and the whole verbatim area
23  * has a shaded background.
24  */
25 class Verbatim : public Parent_widget
26 {
27 public:
28
29   Color bgcol;
30
31   /**
32    * Constructor
33    */
34   explicit Verbatim(Color bg);
35
36   /**
37    * Append verbatim text line
38    */
39   void append_textline(const char *str, Style *style)
40   {
41     append(new Token(style, str, strlen(str)));
42   }
43
44   /**
45    * Element interface
46    */
47   void draw(Canvas *c, Point const &p);
48
49   void append(Widget *e);
50   void remove(Widget *e);
51
52   Orientations expanding() const { return Mag_gfx::Horizontal; }
53
54   void set_geometry(Rect const &r)
55   {
56     _pos = r.p1();
57     _size = r.area();
58
59     child_layout()->set_geometry(Rect(_size));
60   }
61
62   Area max_size() const
63   { return Area(Area::Max_w, child_layout()->max_size().h()); }
64 };
65
66 }