cwidget  0.5.17
Public Member Functions | List of all members
cwidget::fragment_cache Class Reference

A fragment that caches its contents; a cached result is used if the same width is passed to the layout routine twice in a row. More...

#include <fragment_cache.h>

Inheritance diagram for cwidget::fragment_cache:
cwidget::fragment

Public Member Functions

 fragment_cache (fragment *_contents)
 
void invalidate ()
 
fragment_contents layout (size_t firstw, size_t restw, const style &st)
 Return all the lines of this fragment, given the "shape" of the fragment. More...
 
void set_attr (int attr)
 
size_t max_width (size_t first_indent, size_t rest_indent) const
 
size_t trailing_width (size_t first_indent, size_t rest_indent) const
 
bool final_newline () const
 
- Public Member Functions inherited from cwidget::fragment
virtual ~fragment ()
 Nothing to do in the base class.
 

Detailed Description

A fragment that caches its contents; a cached result is used if the same width is passed to the layout routine twice in a row.

Obviously this should only be done if you know that the contents are static.

Member Function Documentation

◆ final_newline()

bool cwidget::fragment_cache::final_newline ( ) const
virtual
Returns
true if this fragment ends in a newline.

Implements cwidget::fragment.

◆ layout()

fragment_contents cwidget::fragment_cache::layout ( size_t  firstw,
size_t  w,
const style st 
)
virtual

Return all the lines of this fragment, given the "shape" of the fragment.

Note that some fragments ignore the given widths, so the caller is expected to either put everything in a formatting box (one that forces its contents to stay "in bounds") or manually clip the return value.

Parameters
firstwthe width to which the first line of the fragment should be formatted.
wthe width to which subsequent lines of the fragment should be formatted.
sthe enclosing style of this fragment. The fragment's size is guaranteed to be independent of s.
Returns
the lines of this fragment; the caller is responsible for deleting it.

Implements cwidget::fragment.

◆ max_width()

size_t cwidget::fragment_cache::max_width ( size_t  first_indent,
size_t  rest_indent 
) const
virtual
Parameters
first_indentthe indentation of the first line, relative to a baseline (which may be outside this fragment).
rest_indentthe indentation of any other lines.
Returns
the maximum length of any line in this fragment. Any call to layout() with a width greater than this maximum length will produce the same result.

Implements cwidget::fragment.

◆ trailing_width()

size_t cwidget::fragment_cache::trailing_width ( size_t  first_indent,
size_t  rest_indent 
) const
virtual
Parameters
first_indentthe indentation of the first line.
rest_indentthe indentation of any other lines.
Returns
the length of any "trailing" line in the fragment, including indentation.

Implements cwidget::fragment.


The documentation for this class was generated from the following files: