[glom] Print Layout: Create Standard: Use the full page width.



commit f523f4d5cbbf85c24fdc0baa99e321a26d5b69b3
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Oct 11 20:17:32 2011 +0200

    Print Layout: Create Standard: Use the full page width.
    
    * glom/print_layout/print_layout_utils.cc: Instead of hard-coding the
    width. However, the field title widths are still hard-coded.

 ChangeLog                               |    7 +++++++
 glom/print_layout/print_layout_utils.cc |   14 ++++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 6e5918d..c5ed36e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2011-10-11  Murray Cumming  <murrayc murrayc com>
 
+	Print Layout: Create Standard: Use the full page width.
+
+	* glom/print_layout/print_layout_utils.cc: Instead of hard-coding the 
+	width. However, the field title widths are still hard-coded.
+
+2011-10-11  Murray Cumming  <murrayc murrayc com>
+
 	Small fixes to Film Manager example.
 
 	* examples/example_film_manager.glom: Remove the unused (and hiddent)
diff --git a/glom/print_layout/print_layout_utils.cc b/glom/print_layout/print_layout_utils.cc
index d64e92a..e913b5a 100644
--- a/glom/print_layout/print_layout_utils.cc
+++ b/glom/print_layout/print_layout_utils.cc
@@ -77,9 +77,14 @@ static void create_standard(const sharedptr<const LayoutGroup>& layout_group, co
   double max_y = 0;
   get_page_y_start_and_end(page_setup, page_number, min_y, max_y);
 
-  const double field_height = ITEM_HEIGHT;
   const double gap = GRID_GAP;
 
+  const Gtk::Unit units = get_units();
+  const Gtk::PaperSize paper_size = page_setup->get_paper_size();
+  const double item_width = paper_size.get_width(units) - x -
+    page_setup->get_right_margin(units) - gap;
+  const double field_height = ITEM_HEIGHT;
+
   //Show the group's title
   //(but do not fall back to the name, because unnamed groups are really wanted sometimes.)
   const Glib::ustring title = layout_group->get_title();
@@ -89,7 +94,7 @@ static void create_standard(const sharedptr<const LayoutGroup>& layout_group, co
     text->set_text(title);
     text->m_formatting.set_text_format_font("Sans Bold 10");
 
-    text->set_print_layout_position(x, y, ITEM_WIDTH_WIDE, field_height); //TODO: Enough and no more.
+    text->set_print_layout_position(x, y, item_width, field_height); //TODO: Enough and no more.
     y += field_height + gap; //padding.
 
     print_layout_group->add_item(text);
@@ -115,7 +120,7 @@ static void create_standard(const sharedptr<const LayoutGroup>& layout_group, co
     if(rows_count)
       height = ITEM_HEIGHT * rows_count;
 
-    portal_clone->set_print_layout_position(x, y, 100, height); //TODO: Enough and no more.
+    portal_clone->set_print_layout_position(x, y, item_width, height); //TODO: Enough and no more.
     y += height + gap; //padding.
 
     print_layout_group->add_item(portal_clone);
@@ -167,7 +172,8 @@ static void create_standard(const sharedptr<const LayoutGroup>& layout_group, co
       if(field)
         item_x += (title_width + gap);
 
-      clone->set_print_layout_position(item_x, y, 100, field_height); //TODO: Enough and no more.
+      const double field_width = item_width - title_width - gap;
+      clone->set_print_layout_position(item_x, y, field_width, field_height); //TODO: Enough and no more.
       y += field_height + gap; //padding.
 
       print_layout_group->add_item(clone);



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