[glom] FlowTable: In developer mode, draw some lines.



commit 8fdddc4c2807359895b713919e1a671fdb925045
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Nov 3 11:50:20 2011 +0100

    FlowTable: In developer mode, draw some lines.
    
    	* glom/utility_widgets/flowtable.[h|cc]: on_draw(): Draw some dashed lines
    	a little like the lines drawn in on_expose_event() in Glom 1.18.
    	This is not very good, but it was not very good before, but I still think
    	we need something to show the boundaries.

 ChangeLog                         |    9 +++++++
 glom/utility_widgets/flowtable.cc |   48 +++++++++++++++++++++++++++++++++++++
 glom/utility_widgets/flowtable.h  |    2 +
 3 files changed, 59 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 1ff5bd8..fe6d87d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2011-11-03  Murray Cumming  <murrayc murrayc com>
 
+	FlowTable: In developer mode, draw some lines.
+
+	* glom/utility_widgets/flowtable.[h|cc]: on_draw(): Draw some dashed lines
+	a little like the lines drawn in on_expose_event() in Glom 1.18.
+	This is not very good, but it was not very good before, but I still think
+	we need something to show the boundaries.
+
+2011-11-03  Murray Cumming  <murrayc murrayc com>
+
 	Small Business example: Add a little more data so the report is useful.
 
 	* examples/example_smallbusiness.glom: Contacts: Add towns and countries.
diff --git a/glom/utility_widgets/flowtable.cc b/glom/utility_widgets/flowtable.cc
index ae3cb15..3dc77d6 100644
--- a/glom/utility_widgets/flowtable.cc
+++ b/glom/utility_widgets/flowtable.cc
@@ -255,4 +255,52 @@ bool FlowTable::get_column_for_first_widget(const Gtk::Widget& first, guint& col
   return true;
 }
 
+bool FlowTable::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
+{
+  const bool result = Egg::SpreadTableDnd::on_draw(cr);
+  if(!m_design_mode)
+    return result;
+
+  cr->set_line_width(1);
+  cr->set_line_cap(Cairo::LINE_CAP_SQUARE);
+  cr->set_line_join(Cairo::LINE_JOIN_MITER);
+  std::vector<double> dashes;
+  dashes.push_back(10);
+  cr->set_dash(dashes, 0);
+
+  //Draw lines based on the allocations of the "first" widgets:
+  //This is a very rough interpretation of the column/item borders,
+  //but it is better than nothing.
+  //TODO: Add API to EggSpreadTable for this?
+  for(type_const_list_widgets::iterator iter = m_list_first_widgets.begin(); iter != m_list_first_widgets.end(); ++iter)
+  {
+    const Gtk::Widget* widget = *iter;
+    //std::cout << G_STRFUNC << ": widget: " << widget << std::endl;
+
+    if(!widget)
+      continue;
+
+    const Gtk::Allocation allocation = widget->get_allocation();
+    const int x = allocation.get_x();
+    const int y = allocation.get_y();
+    //std::cout << G_STRFUNC << ": x: " << x << ", y: " << y << std::endl;
+
+    int real_x = 0;
+    int real_y = 0;
+    Gtk::Widget* unconst = const_cast<Gtk::Widget*>(widget);
+    unconst->translate_coordinates(*this, x, y, real_x, real_y);
+    //std::cout << G_STRFUNC << ": real_x: " << real_x << ", real_y: " << real_y << std::endl;
+
+    cr->move_to(real_x, real_y);
+    cr->line_to(real_x + allocation.get_width(), real_y);
+    cr->stroke();
+
+    //cr->move_to(real_x, real_y + allocation.get_height());
+    //cr->line_to(real_x + allocation.get_width(), real_y + allocation.get_height());
+    //cr->stroke();
+  }
+
+  return result;
+}
+
 } //namespace Glom
diff --git a/glom/utility_widgets/flowtable.h b/glom/utility_widgets/flowtable.h
index 8f9d0bb..d169d2f 100644
--- a/glom/utility_widgets/flowtable.h
+++ b/glom/utility_widgets/flowtable.h
@@ -63,6 +63,8 @@ protected:
    */
   type_const_list_widgets get_first_child_widgets() const;
 
+  virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
+
 private:
 
   const Gtk::Box* get_parent_hbox(const Gtk::Widget* first) const;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]