// vi:ft=cpp
/*
 * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
 *     economic rights: Technische Universität Dresden (Germany)
 *
 * This file is part of TUD:OS and distributed under the terms of the
 * GNU General Public License 2.
 * Please see the COPYING-GPL-2 file for details.
 */
#pragma once

#include <l4/scout-gfx/widget>
#include <l4/scout-gfx/doc/token>

#include <cstring>

namespace Scout_gfx {
/**
 * Verbatim text block
 *
 * A verbatim text block consists of a number of preformatted text lines.
 * The text is printed in a monospaced font and the whole verbatim area
 * has a shaded background.
 */
class Verbatim : public Parent_widget
{
public:

  Color bgcol;

  /**
   * Constructor
   */
  explicit Verbatim(Color bg);

  /**
   * Append verbatim text line
   */
  void append_textline(const char *str, Style *style)
  {
    append(new Token(style, str, strlen(str)));
  }

  /**
   * Element interface
   */
  void draw(Canvas *c, Point const &p);

  void append(Widget *e);
  void remove(Widget *e);

  Orientations expanding() const { return Mag_gfx::Horizontal; }

  void set_geometry(Rect const &r)
  {
    _pos = r.p1();
    _size = r.area();

    child_layout()->set_geometry(Rect(_size));
  }

  Area max_size() const
  { return Area(Area::Max_w, child_layout()->max_size().h()); }
};

}
