32 #include <cwidget/curses++.h> 33 #include <cwidget/style.h> 35 #include "minibuf_win.h" 53 :parent(x.parent?x.parent->clone():NULL) {}
57 virtual void advance_next()=0;
58 virtual void return_prev()=0;
61 virtual bool is_begin()=0;
64 virtual bool is_end()=0;
84 void advance_next() {
if(val) { prevval=val; val=NULL;} }
85 void return_prev() {
if(prevval) {val=prevval; prevval=NULL;} }
89 bool is_end() {
return !val;}
90 bool is_begin() {
return prevval==NULL;}
109 virtual void set_depth(
int _depth) {depth=_depth;}
110 virtual void set_selectable(
bool _selectable) {selectable=_selectable;}
112 treeitem(
bool _selectable=
true):depth(0),selectable(_selectable) {}
126 virtual void paint(
tree *win,
int y,
bool hierarchical,
138 void paint(
tree *win,
int y,
bool hierarchical,
139 const std::wstring &str,
int depth_shift=2);
141 virtual const wchar_t *tag()=0;
144 virtual const wchar_t *
label()=0;
147 int get_depth() {
return depth;}
148 bool get_selectable() {
return selectable;}
150 virtual style get_normal_style() {
return style();}
156 virtual void sort() {}
175 virtual bool dispatch_key(
const config::key &k,
tree *owner) {
return false;}
180 virtual void dispatch_mouse(
short id,
int x, mmask_t bstate,
tree *owner)
191 virtual bool has_visible_children() {
return false;}
192 virtual bool has_children() {
return false;}
194 virtual bool matches(
const std::wstring &s)
const {
return false;}
198 virtual void expand() {}
199 virtual void expand_all() {}
200 virtual void collapse_all() {}
202 template<
class childtype,
class sorter>
211 bool ignore_collapsed;
216 treeiterator(
const treeiterator &x,
bool _ignore_collapsed):curr(x.curr?x.curr->clone():NULL),ignore_collapsed(_ignore_collapsed) {}
218 bool is_root() {
return curr->parent==NULL;}
227 if(curr && curr->get_item())
228 curr->get_item()->expand();
231 treeitem &operator*() {
return *curr->get_item();}
232 const treeitem &operator*()
const {
return *curr->get_item();}
233 treeitem *operator->() {
return curr->get_item();}
234 const treeitem *operator->()
const {
return curr->get_item();}
242 else if(curr->is_end())
243 return x.curr->is_end() && curr->parent == x.curr->parent;
244 else if(x.curr->is_end())
247 return curr->get_item()==x.curr->get_item();
250 {
return !(*
this==x);}
261 curr=x.curr?x.curr->clone():NULL;
268 if(curr->get_item() &&
269 (ignore_collapsed?curr->get_item()->has_children():curr->get_item()->has_visible_children()))
277 curr->advance_next();
279 while(curr->is_end() && curr->parent)
283 curr->advance_next();
313 while(curr->get_item() &&
314 (ignore_collapsed?curr->get_item()->has_children():curr->get_item()->has_visible_children()))
319 newref->return_prev();
335 void move_forward_level()
340 curr->advance_next();
352 void move_backward_level()
354 if(!curr->is_begin())
377 virtual bool operator()(
treeitem *item1,
390 return (wcscmp(item1->tag(), item2->tag())<0);
407 inline bool operator()(
treeitem *item1,
410 return real_policy(item1, item2);