Difference between revisions of "List/Tree Widget"

From Adobe Open Source Wiki
Jump to: navigation, search
Line 18: Line 18:
 
''This API set will be updated piecemeal as I am able to further the implementation''
 
''This API set will be updated piecemeal as I am able to further the implementation''
  
== Typedefs ==
+
Assume for the time being that the model_type is a simple string for now...
  
Assume for the time being that the model_type is simple:
+
== Model ==
  
   typedef std::string                  value_type;
+
   class list_model_t
  typedef std::list<value_type>        model_type;
+
  {
  typedef model_type::iterator          iterator;
+
  public:
  typedef std::pair<iterator, iterator> range_type;
+
    typedef std::string                  value_type;
  typedef std::vector<range_type>      selection_type;
+
    typedef std::list<value_type>        model_type;
 +
    typedef model_type::const_iterator    iterator;
 +
    typedef std::pair<iterator, iterator> range_type;
 +
    typedef std::vector<range_type>      selection_type;
 +
    typedef boost::signals::connection    connection_type;
 
    
 
    
  typedef boost::function<void (iterator before, const selection_type&)> monitor_splice_callback_t;
+
    typedef boost::function<void (iterator, const selection_type&)> monitor_splice_callback_t;
 
+
    typedef boost::function<void (iterator)>                        monitor_value_callback_t;
== Model ==
+
 
 
+
    void push_front(const value_type& value);
   void splice(iterator before, const selection_type& value);
+
    void push_back(const value_type& value);
   void monitor_splice(const monitor_splice_callback_t& how);
+
    
 +
    void splice(iterator before, const selection_type& value);
 +
    
 +
    void set(iterator who, const value_type& value);
 +
 
 +
    connection_type monitor_splice(const monitor_splice_callback_t& how);
 +
    connection_type monitor_value(const monitor_value_callback_t& how);
 +
 
 +
  private:
 +
    typedef boost::signal<void (iterator, const selection_type&)> splice_callback_set_t;
 +
    typedef boost::signal<void (iterator)>                        value_callback_set_t;
 +
 
 +
    model_type            model_m;
 +
    splice_callback_set_t splice_callback_set_m;
 +
    value_callback_set_t  value_callback_set_m;
 +
  };
  
 
== View ==
 
== View ==
  
   void splice(iterator before, const selection_type& value);
+
   struct list_view_t
 +
  {
 +
    typedef model_type::const_iterator    iterator;
 +
    typedef std::vector<range_type>      selection_type;
 +
 
 +
    void set(iterator who);
 +
 
 +
    void splice(iterator before, const selection_type& value);
 +
  };
  
 
== Controller ==
 
== Controller ==
  
   void monitor_splice(const monitor_splice_callback_t& how);
+
   struct list_controller_t
 +
  {
 +
    typedef adobe::list_model_t::monitor_splice_callback_t          monitor_splice_callback_t;
 +
    typedef boost::function<void (const value_type&)>              monitor_push_back_callback_t;
 +
    typedef boost::function<void (const value_type&)>              monitor_push_front_callback_t;
 +
    typedef boost::function<void (iterator who, const value_type&)> monitor_value_callback_t;
 +
 
 +
    void enable(bool make_enabled);
 +
 
 +
    void monitor_value(const monitor_value_callback_t& how);
 +
 
 +
    void monitor_splice(const monitor_splice_callback_t& how);
 +
 
 +
    void monitor_push_front(const monitor_push_front_callback_t& how);
 +
 
 +
    void monitor_push_back(const monitor_push_back_callback_t& how);
 +
  };

Revision as of 00:05, 13 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)

API

This API set will be updated piecemeal as I am able to further the implementation

Assume for the time being that the model_type is a simple string for now...

Model

 class list_model_t
 {
 public:
   typedef std::string                   value_type;
   typedef std::list<value_type>         model_type;
   typedef model_type::const_iterator    iterator;
   typedef std::pair<iterator, iterator> range_type;
   typedef std::vector<range_type>       selection_type;
   typedef boost::signals::connection    connection_type;
 
   typedef boost::function<void (iterator, const selection_type&)> monitor_splice_callback_t;
   typedef boost::function<void (iterator)>                        monitor_value_callback_t;
 
   void push_front(const value_type& value);
   void push_back(const value_type& value);
 
   void splice(iterator before, const selection_type& value);
 
   void set(iterator who, const value_type& value);
 
   connection_type monitor_splice(const monitor_splice_callback_t& how);
   connection_type monitor_value(const monitor_value_callback_t& how);
 
 private:
   typedef boost::signal<void (iterator, const selection_type&)> splice_callback_set_t;
   typedef boost::signal<void (iterator)>                        value_callback_set_t;
 
   model_type            model_m;
   splice_callback_set_t splice_callback_set_m;
   value_callback_set_t  value_callback_set_m;
 };

View

 struct list_view_t
 {
   typedef model_type::const_iterator    iterator;
   typedef std::vector<range_type>       selection_type;
 
   void set(iterator who);
 
   void splice(iterator before, const selection_type& value);
 };

Controller

 struct list_controller_t
 {
   typedef adobe::list_model_t::monitor_splice_callback_t          monitor_splice_callback_t;
   typedef boost::function<void (const value_type&)>               monitor_push_back_callback_t;
   typedef boost::function<void (const value_type&)>               monitor_push_front_callback_t;
   typedef boost::function<void (iterator who, const value_type&)> monitor_value_callback_t;
 
   void enable(bool make_enabled);
 
   void monitor_value(const monitor_value_callback_t& how);
 
   void monitor_splice(const monitor_splice_callback_t& how);
 
   void monitor_push_front(const monitor_push_front_callback_t& how);
 
   void monitor_push_back(const monitor_push_back_callback_t& how);
 };