Rapicorn - Experimental UI Toolkit - Source Code
13.07.0
|
00001 // Licensed GNU LGPL v3 or later: http://www.gnu.org/licenses/lgpl.html 00002 #ifndef __RAPICORN_LIST_AREA_HH__ 00003 #define __RAPICORN_LIST_AREA_HH__ 00004 00005 #include <ui/adjustment.hh> 00006 #include <ui/container.hh> 00007 #include <ui/layoutcontainers.hh> 00008 #include <deque> 00009 00010 namespace Rapicorn { 00011 00012 class WidgetListRowImpl; 00013 00014 struct ListRow { 00015 vector<WidgetImpl*> cols; // FIXME 00016 WidgetListRowImpl *lrow; 00017 Allocation area; 00018 uint allocated : 1; 00019 ListRow() : lrow (NULL), allocated (0) {} 00020 }; 00021 00022 class WidgetListImpl : public virtual WidgetListIface, 00023 public virtual MultiContainerImpl, 00024 public virtual AdjustmentSource, 00025 public virtual EventHandler 00026 { 00027 friend class WidgetListRowImpl; 00028 typedef map<int64,ListRow*> RowMap; 00029 typedef std::deque<int> SizeQueue; 00030 ListModelIface *model_; 00031 size_t conid_updated_; 00032 vector<int> row_heights_; 00033 mutable Adjustment *hadjustment_, *vadjustment_; 00034 RowMap row_map_, off_map_; 00035 vector<bool> selection_; 00036 vector<SizeGroup*> size_groups_; 00037 SelectionMode selection_mode_; 00038 bool virtualized_pixel_scrolling_; 00039 bool need_scroll_layout_; 00040 bool block_invalidate_; 00041 int first_row_, last_row_, multi_sel_range_start_; 00042 void model_updated (const UpdateRequest &ur); 00043 void selection_changed (int first, int length); 00044 virtual void invalidate_parent (); 00045 protected: 00046 virtual const PropertyList& __aida_properties__ (); 00047 void change_selection (int current, int previous, bool toggle, bool range, bool preserve); 00048 virtual bool key_press_event (const EventKey &event); 00049 virtual bool button_event (const EventButton &event, WidgetListRowImpl *lrow, int index); 00050 virtual bool handle_event (const Event &event); 00051 virtual bool row_event (const Event &event, WidgetListRowImpl *lrow, int index); 00052 virtual void reset (ResetMode mode); 00053 virtual bool can_focus () const { return true; } 00054 virtual bool move_focus (FocusDirType fdir); 00055 virtual void focus_lost (); 00056 bool selected (int row) { return size_t (row) < selection_.size() && selection_[row]; } 00057 void toggle_selected (int row); 00058 void deselect_all (); 00059 public: 00060 // == WidgetListIface == 00061 virtual std::string model () const; 00062 virtual void model (const std::string &modelurl); 00063 virtual SelectionMode selection_mode () const; 00064 virtual void selection_mode (SelectionMode smode); 00065 virtual void set_selection (const BoolSeq &selection); 00066 virtual BoolSeq get_selection (); 00067 virtual void select_range (int first, int length); 00068 virtual void unselect_range (int first, int length); 00069 // == WidgetListImpl == 00070 explicit WidgetListImpl (); 00071 virtual ~WidgetListImpl (); 00072 bool validate_selection (int fallback = 0); 00073 bool has_selection () const; 00074 virtual void hierarchy_changed (WidgetImpl *old_toplevel); 00075 Adjustment& hadjustment () const; 00076 Adjustment& vadjustment () const; 00077 Adjustment* get_adjustment (AdjustmentSourceType adj_source, 00078 const String &name); 00079 void invalidate_model (bool invalidate_heights, 00080 bool invalidate_widgets); 00081 virtual void visual_update (); 00082 virtual void size_request (Requisition &requisition); 00083 virtual void size_allocate (Allocation area, bool changed); 00084 int focus_row (); 00085 bool grab_row_focus (int next_focus, int old_focus = -1); 00086 /* sizing and positioning */ 00087 int row_height (int nth_row); 00088 void scroll_layout_preserving(); 00089 void cache_row (ListRow *lr); 00090 void destroy_row (ListRow *lr); 00091 void destroy_range (size_t first, size_t bound); 00092 void fill_row (ListRow *lr, int row); 00093 ListRow* create_row (uint64 row, 00094 bool with_size_groups = true); 00095 ListRow* lookup_row (int row, bool maybe_cached = true); 00096 ListRow* fetch_row (int row); 00097 void update_row (int row); 00098 // == Scrolling Implementation == 00099 void scroll_layout () { return virtualized_pixel_scrolling_ ? vscroll_layout() : pscroll_layout(); } 00100 double scroll_row_position (const int r, const double a) { return virtualized_pixel_scrolling_ ? vscroll_row_position (r, a) : pscroll_row_position (r, a); } 00101 // == Virtualized Scrolling == 00102 void vscroll_layout (); 00103 double vscroll_row_position (const int target_row, const double list_alignment); 00104 int vscroll_row_yoffset (const double value, const int target_row); 00105 int vscroll_relative_row (const int src_row, int pixel_delta); 00106 // == Pixel Accurate Scrolling == 00107 void pscroll_layout (); 00108 double pscroll_row_position (const int target_row, const double list_alignment); 00109 }; 00110 00111 } // Rapicorn 00112 00113 #endif /* __RAPICORN_LIST_AREA_HH__ */