Scrollable(), pango_layout_(create_pango_layout("")), line_list_(),
id_map_(new text_element::IDMap),
res_num_map_(new text_element::ResNumMap),
+ res_num_(0),
+ metrics_(get_pango_context()->get_metrics(
+ get_pango_context()->get_font_description())),
width_(-1) {
}
}
void Layoutable::add_line(TextLine* line) {
+ line->itemize(get_pango_context(), metrics_);
line_list_.push_back(line);
}
void Layoutable::relayout() {
const int width = get_width();
LayoutSet set;
- set.layout = pango_layout_;
set.y = 0;
BOOST_FOREACH(TextLine& line, line_list_) {
adjustment_.set_upper(set.y);
}
-bool Layoutable::on_configure_event(GdkEventConfigure* event) {
+void Layoutable::safe_layout() {
if (width_ == -1)
relayout();
else if (width_ != get_width()) {
}
adjustment_.set_value(y - delta);
}
+}
+
+bool Layoutable::on_configure_event(GdkEventConfigure* event) {
+ safe_layout();
return Scrollable::on_configure_event(event);
}
+void Layoutable::on_realize() {
+ Scrollable::on_realize();
+ metrics_ = get_pango_context()->get_metrics(
+ get_pango_context()->get_font_description());
+}
+
+void Layoutable::on_style_changed(const Glib::RefPtr<Gtk::Style>& previous) {
+ Scrollable::on_style_changed(previous);
+ const Pango::FontMetrics metrics = get_pango_context()->get_metrics(
+ get_pango_context()->get_font_description());
+ BOOST_FOREACH(TextLine& line, line_list_)
+ line.itemize(get_pango_context(), metrics);
+ safe_layout();
+}
const TextLine* Layoutable::get_text_line(const gdouble y_adj) const {