cwidget  0.5.17
layout_item.h
1 // layout_item.h -*-c++-*-
2 //
3 // Copyright (C) 2004-2005, 2007 Daniel Burrows
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License as
7 // published by the Free Software Foundation; either version 2 of
8 // the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; see the file COPYING. If not, write to
17 // the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 // Boston, MA 02111-1307, USA.
19 //
20 // A bridge from the layout code to the tree code.
21 
22 #ifndef LAYOUT_ITEM_H
23 #define LAYOUT_ITEM_H
24 
25 #include "text_layout.h"
26 #include "treeitem.h"
27 
28 namespace cwidget
29 {
30  class fragment;
31 
32  namespace widgets
33  {
34  class layout_item : public treeitem
35  {
36  protected:
37  class layout_line;
38 
39  private:
40  typedef std::vector<layout_line *> child_list;
41 
42  child_list children;
43  fragment *f;
44  fragment_contents lines;
45 
46  int lastw;
47  int lastbasex;
48 
49  protected:
50  class layout_line:public treeitem
51  {
52  int n;
53  layout_item &parent;
54  public:
55  layout_line(int _n, layout_item &_parent);
56 
57  void paint(tree *win, int y, bool hierarchical,
58  const style &st);
59 
60  const wchar_t *tag();
61  const wchar_t *label();
62  };
63 
64  // Assumes that children.size()>0
65  class levelref:public tree_levelref
66  {
67  size_t item_num;
68  const child_list &lines;
69 
70  public:
71  levelref(const levelref &x);
72  levelref(size_t n, const child_list &_lines);
73 
74  treeitem *get_item();
75  virtual void advance_next();
76  virtual void return_prev();
77  bool is_begin();
78  bool is_end();
79  levelref *clone() const;
80  };
81 
82  public:
84 
85  const wchar_t *tag();
86  const wchar_t *label();
87 
89  void paint_line(int n,
90  tree *win, int y, bool hierarchical,
91  const style &st);
92  void paint(tree *win, int y, bool hierarchical,
93  const style &st);
94 
95  int get_normal_attr();
96 
97  levelref *begin();
98  levelref *end();
99  bool has_visible_children();
100 
101  const fragment_line &get_line(tree *win, size_t n, int basex,
102  const style &st);
103 
104  ~layout_item();
105  };
106  }
107 }
108 
109 #endif
A "style" is a setting to be applied to a display element (widget, text, etc).
Definition: style.h:51
This class represents the formatted contents of a fragment.
Definition: fragment_contents.h:30
Definition: curses++.h:199
Definition: layout_item.h:34
The namespace containing everything defined by cwidget.
Definition: columnify.cc:26
label widgets display some (possibly formatted) text statically.
Definition: label.h:24
void paint(tree *win, int y, bool hierarchical, const style &st)
Display this item and this item only (does not descend to the children of the item, if any).
Definition: layout_item.cc:142
Definition: treeitem.h:101
Definition: layout_item.h:65
void paint_line(int n, tree *win, int y, bool hierarchical, const style &st)
Paints the nth line of this item at the given location in &#39;win&#39;.
Definition: layout_item.cc:133
Definition: treeitem.h:45
Definition: tree.h:57
A fragment represents a logical unit of text.
Definition: fragment.h:37
Definition: layout_item.h:50