cwidget 0.5.16
|
00001 // fragment_cache.h -*-c++-*- 00002 // 00003 // Copyright (C) 2005 Daniel Burrows 00004 // 00005 // This program is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU General Public License as 00007 // published by the Free Software Foundation; either version 2 of 00008 // the License, or (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; see the file COPYING. If not, write to 00017 // the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 // Boston, MA 02111-1307, USA. 00019 // 00020 // A special fragment class that caches its contents. 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