Difference between revisions of "List/Tree Widget"

From Adobe Open Source Wiki
Jump to: navigation, search
Line 19: Line 19:
  
 
   typedef std::string                  value_type;
 
   typedef std::string                  value_type;
   typedef std::vector<value_type>       model_type;
+
   typedef std::list<value_type>         model_type;
 
   typedef model_type::iterator          iterator;
 
   typedef model_type::iterator          iterator;
 
   typedef std::pair<iterator, iterator> sequence_type;
 
   typedef std::pair<iterator, iterator> sequence_type;
 +
  typedef std::vector<sequence_type>    sequence_set_type;
 
    
 
    
   typedef boost::function<void (const value_type&)> monitor_value_callback_t;
+
   typedef boost::function<void (iterator before, const sequence_set_type&)> monitor_splice_callback_t;
  typedef boost::function<void (const value_type&)> monitor_insert_callback_t;
+
  typedef boost::function<void ()>                  monitor_erase_callback_t;
+
  
 
== Model API ==
 
== Model API ==
  
   void insert(iterator before, const value_type& what);
+
   void splice(iterator before, const sequence_set_type& value);
   void monitor_value(iterator where, const monitor_value_callback_t& how);
+
   void monitor_splice(const monitor_splice_callback_t& how);
  void monitor_erase(iterator where, const monitor_erase_callback_t& how);
+
  
 
== View API ==
 
== View API ==
  
   void insert(iterator before, const value_type& value);
+
   void splice(iterator before, const sequence_set_type& value);
  void set(iterator who, const value_type& value);
+
  void erase(iterator who);
+
  
 
== Controller API ==
 
== Controller API ==
  
   void monitor_insert(iterator before, const monitor_insert_callback_t& how);
+
   void monitor_splice(const monitor_splice_callback_t& how);
  void monitor_value(iterator who, const monitor_value_callback_t& how);
+
  void monitor_erase(iterator who, const monitor_erase_callback_t& how);
+

Revision as of 18:29, 10 January 2007

(For the time being the focus will be on lists, not heirarchical trees.)

The tricky part of a list controller/view is that you have a controller/view on a sequence. You need to figure out:

  1. How to communicate requests for changes to the sequence
  2. What those requests are
  3. How to communicate a change in the visible portion of the sequence to the view

We assume the sequences in a list are disjoint.

Contents

Related Docs

Win32 Tree Control API Documentation (Tree View)

Carbon Tree Control API Documentation (Data Browser)

Typedefs

Assume for the time being that the model_type is simple:

 typedef std::string                   value_type;
 typedef std::list<value_type>         model_type;
 typedef model_type::iterator          iterator;
 typedef std::pair<iterator, iterator> sequence_type;
 typedef std::vector<sequence_type>    sequence_set_type;
 
 typedef boost::function<void (iterator before, const sequence_set_type&)> monitor_splice_callback_t;

Model API

 void splice(iterator before, const sequence_set_type& value);
 void monitor_splice(const monitor_splice_callback_t& how);

View API

 void splice(iterator before, const sequence_set_type& value);

Controller API

 void monitor_splice(const monitor_splice_callback_t& how);