1 # pragma once 2 3 # include <vector> 4 5 # include <gtkmm.h> 6 # include <gtkmm/cellrenderer.h> 7 8 # include "proto.hh" 9 # include "db.hh" 10 11 namespace Astroid { 12 class ThreadIndexListCellRenderer : public Gtk::CellRenderer { 13 public: 14 ThreadIndexListCellRenderer (ThreadIndex * ti); 15 ~ThreadIndexListCellRenderer (); 16 17 ThreadIndex * thread_index; 18 19 Glib::RefPtr<NotmuchThread> thread; /* thread that should be rendered now */ 20 bool last; 21 bool marked; 22 23 /* these tags are displayed otherwisely (or ignored by the user), so they 24 * are not shown explicitly: MUST BE SORTED. default defined in config.cc. */ 25 std::vector<ustring> hidden_tags; // default: { "attachment", "flagged", "unread" } }; 26 27 int get_height (); 28 29 protected: 30 /* best documentation so far from here: 31 * https://git.gnome.org/browse/gtkmm/tree/gtk/src/cellrenderer.hg 32 */ 33 virtual void render_vfunc (const ::Cairo::RefPtr< ::Cairo::Context>&, 34 Gtk::Widget &, 35 const Gdk::Rectangle &, 36 const Gdk::Rectangle &, 37 Gtk::CellRendererState) override; 38 39 virtual bool activate_vfunc( 40 GdkEvent *, 41 Gtk::Widget &, 42 const Glib::ustring &, 43 const Gdk::Rectangle &, 44 const Gdk::Rectangle &, 45 Gtk::CellRendererState) override; 46 47 int calculate_height (Gtk::Widget &) const; 48 49 virtual void get_preferred_height_vfunc ( 50 Gtk::Widget& widget, 51 int& minimum_height, 52 int& natural_height) const override; 53 54 virtual void get_preferred_height_for_width_vfunc ( 55 Gtk::Widget& widget, 56 int width, 57 int& minimum_height, 58 int& natural_height) const override; 59 60 virtual void get_preferred_width_vfunc ( 61 Gtk::Widget& widget, 62 int& minimum_width, 63 int& natural_width) const override; 64 65 virtual Gtk::SizeRequestMode get_request_mode_vfunc () const override; 66 67 public: 68 int height; 69 bool height_set = false; 70 71 private: 72 int line_height; // content_height + line_spacing 73 int content_height; 74 int line_spacing = 2; // configurable 75 76 int left_icons_size; 77 int left_icons_width; 78 const int left_icons_width_n = 2; 79 const int left_icons_padding = 1; 80 int padding; 81 82 ustring font_desc_string; 83 Pango::FontDescription font_description; 84 Pango::FontMetrics font_metrics; 85 86 int date_start; 87 int date_len = 10; // chars, configurable 88 int date_width; 89 90 int message_count_start; 91 int message_count_len = 4; // chars, configurable 92 int message_count_width; 93 94 int authors_start; 95 int authors_len = 20; // chars, configurable 96 int authors_width; 97 98 int tags_start; 99 int tags_width; 100 int tags_len = 80; // chars, configurable 101 102 int subject_start; 103 ustring subject_color; // configurable 104 ustring subject_color_selected; // configurable 105 ustring background_color_selected; // configurable 106 ustring background_color_marked; // configurable 107 ustring background_color_marked_selected; // configurable 108 109 void render_background ( 110 const ::Cairo::RefPtr< ::Cairo::Context>&cr, 111 Gtk::Widget &widget, 112 const Gdk::Rectangle &background_area, 113 Gtk::CellRendererState flags); 114 115 void render_subject ( 116 const ::Cairo::RefPtr< ::Cairo::Context>&cr, 117 Gtk::Widget &widget, 118 const Gdk::Rectangle &cell_area, 119 Gtk::CellRendererState flags); 120 121 int render_tags ( 122 const ::Cairo::RefPtr< ::Cairo::Context>&cr, 123 Gtk::Widget &widget, 124 const Gdk::Rectangle &cell_area, 125 Gtk::CellRendererState flags ); 126 127 int render_date ( 128 const ::Cairo::RefPtr< ::Cairo::Context>&cr, 129 Gtk::Widget &widget, 130 const Gdk::Rectangle &cell_area ); 131 132 void render_message_count ( 133 const ::Cairo::RefPtr< ::Cairo::Context>&cr, 134 Gtk::Widget &widget, 135 const Gdk::Rectangle &cell_area ); 136 137 void render_authors ( 138 const ::Cairo::RefPtr< ::Cairo::Context>&cr, 139 Gtk::Widget &widget, 140 const Gdk::Rectangle &cell_area ); 141 142 void render_delimiter ( 143 const ::Cairo::RefPtr< ::Cairo::Context>&cr, 144 Gtk::Widget &widget, 145 const Gdk::Rectangle &cell_area ); 146 147 refptr<Gdk::Pixbuf> flagged_icon; 148 void render_flagged ( 149 const ::Cairo::RefPtr< ::Cairo::Context>&cr, 150 Gtk::Widget &widget, 151 const Gdk::Rectangle &cell_area ); 152 153 refptr<Gdk::Pixbuf> attachment_icon; 154 void render_attachment ( 155 const ::Cairo::RefPtr< ::Cairo::Context>&cr, 156 Gtk::Widget &widget, 157 const Gdk::Rectangle &cell_area ); 158 159 refptr<Gdk::Pixbuf> marked_icon; 160 void render_marked ( 161 const ::Cairo::RefPtr< ::Cairo::Context>&cr, 162 Gtk::Widget &widget, 163 const Gdk::Rectangle &cell_area ); 164 }; 165 } 166 167