fragment_cache.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef FRAGMENT_CACHE_H
00023 #define FRAGMENT_CACHE_H
00024
00025 #include "fragment.h"
00026
00027 namespace cwidget
00028 {
00034 class fragment_cache:public fragment
00035 {
00036 fragment *contents;
00037
00039 mutable fragment_contents cached_lines;
00040
00042 mutable style cached_lines_style;
00043
00047 mutable size_t cached_lines_first_width, cached_lines_rest_width;
00048
00050 mutable size_t cached_max_width;
00051
00053 mutable size_t cached_max_width_first_indent, cached_max_width_rest_indent;
00054
00056 mutable size_t cached_trailing_width;
00057
00059 mutable size_t cached_trailing_width_first_indent, cached_trailing_width_rest_indent;
00060
00062 mutable bool cached_final_nl:1;
00063
00065 mutable bool cached_lines_valid:1, cached_max_width_valid:1;
00067 mutable bool cached_trailing_width_valid:1, cached_final_nl_valid:1;
00068 public:
00069 fragment_cache(fragment *_contents);
00070 ~fragment_cache();
00071
00072 void invalidate();
00073
00074 fragment_contents layout(size_t firstw, size_t restw,
00075 const style &st);
00076
00077 void set_attr(int attr);
00078
00079 size_t max_width(size_t first_indent, size_t rest_indent) const;
00080 size_t trailing_width(size_t first_indent, size_t rest_indent) const;
00081
00082 bool final_newline() const;
00083 };
00084 }
00085
00086 #endif