cwidget 0.5.16
|
00001 // layout_item.h -*-c++-*- 00002 // 00003 // Copyright (C) 2004-2005, 2007 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 bridge from the layout code to the tree code. 00021 00022 #ifndef LAYOUT_ITEM_H 00023 #define LAYOUT_ITEM_H 00024 00025 #include "text_layout.h" 00026 #include "treeitem.h" 00027 00028 namespace cwidget 00029 { 00030 class fragment; 00031 00032 namespace widgets 00033 { 00034 class layout_item : public treeitem 00035 { 00036 protected: 00037 class layout_line; 00038 00039 private: 00040 typedef std::vector<layout_line *> child_list; 00041 00042 child_list children; 00043 fragment *f; 00044 fragment_contents lines; 00045 00046 int lastw; 00047 int lastbasex; 00048 00049 protected: 00050 class layout_line:public treeitem 00051 { 00052 int n; 00053 layout_item &parent; 00054 public: 00055 layout_line(int _n, layout_item &_parent); 00056 00057 void paint(tree *win, int y, bool hierarchical, 00058 const style &st); 00059 00060 const wchar_t *tag(); 00061 const wchar_t *label(); 00062 }; 00063 00064 // Assumes that children.size()>0 00065 class levelref:public tree_levelref 00066 { 00067 size_t item_num; 00068 const child_list &lines; 00069 00070 public: 00071 levelref(const levelref &x); 00072 levelref(size_t n, const child_list &_lines); 00073 00074 treeitem *get_item(); 00075 virtual void advance_next(); 00076 virtual void return_prev(); 00077 bool is_begin(); 00078 bool is_end(); 00079 levelref *clone() const; 00080 }; 00081 00082 public: 00083 layout_item(fragment *f); 00084 00085 const wchar_t *tag(); 00086 const wchar_t *label(); 00087 00089 void paint_line(int n, 00090 tree *win, int y, bool hierarchical, 00091 const style &st); 00092 void paint(tree *win, int y, bool hierarchical, 00093 const style &st); 00094 00095 int get_normal_attr(); 00096 00097 levelref *begin(); 00098 levelref *end(); 00099 bool has_visible_children(); 00100 00101 const fragment_line &get_line(tree *win, size_t n, int basex, 00102 const style &st); 00103 00104 ~layout_item(); 00105 }; 00106 } 00107 } 00108 00109 #endif