glom r1678 - in trunk: . glom/libglom/data_structure/layout glom/mode_data glom/mode_design/print_layouts
- From: murrayc svn gnome org
- To: svn-commits-list gnome org
- Subject: glom r1678 - in trunk: . glom/libglom/data_structure/layout glom/mode_data glom/mode_design/print_layouts
- Date: Wed, 3 Sep 2008 14:56:19 +0000 (UTC)
Author: murrayc
Date: Wed Sep 3 14:56:19 2008
New Revision: 1678
URL: http://svn.gnome.org/viewvc/glom?rev=1678&view=rev
Log:
2008-09-03 Murray Cumming <murrayc murrayc com>
* glom/libglom/data_structure/layout/layoutitem_portal.cc
* glom/libglom/data_structure/layout/layoutitem_portal.h: Added
get/set_print_layout_row_height().
* glom/mode_data/dialog_layout_list_related.cc
* glom/mode_data/dialog_layout_list_related.h: Added a set_document()
that takes the from_table, instead of an existing portal.
* glom/mode_design/print_layouts/canvas_layout_item.cc: set_layout_item():
Slightly more sane code, though I'm still just playing.
* glom/mode_design/print_layouts/canvas_print_layout.h:
* glom/mode_design/print_layouts/canvas_print_layout.cc
Added offer_related_records(), used in on_context_menu_edit(). Still needs
to block on the dialog show.
Modified:
trunk/ChangeLog
trunk/glom/libglom/data_structure/layout/layoutitem_portal.cc
trunk/glom/libglom/data_structure/layout/layoutitem_portal.h
trunk/glom/mode_data/dialog_layout_list_related.cc
trunk/glom/mode_data/dialog_layout_list_related.h
trunk/glom/mode_design/print_layouts/canvas_layout_item.cc
trunk/glom/mode_design/print_layouts/canvas_print_layout.cc
trunk/glom/mode_design/print_layouts/canvas_print_layout.h
Modified: trunk/glom/libglom/data_structure/layout/layoutitem_portal.cc
==============================================================================
--- trunk/glom/libglom/data_structure/layout/layoutitem_portal.cc (original)
+++ trunk/glom/libglom/data_structure/layout/layoutitem_portal.cc Wed Sep 3 14:56:19 2008
@@ -25,7 +25,8 @@
{
LayoutItem_Portal::LayoutItem_Portal()
-: m_navigation_relationship_specific_main(false)
+: m_navigation_relationship_specific_main(false),
+ m_print_layout_row_height(20) //arbitrary default.
{
}
@@ -33,7 +34,8 @@
: LayoutGroup(src),
UsesRelationship(src),
m_navigation_relationship_specific_main(src.m_navigation_relationship_specific_main),
- m_navigation_relationship_specific(src.m_navigation_relationship_specific)
+ m_navigation_relationship_specific(src.m_navigation_relationship_specific),
+ m_print_layout_row_height(src.m_print_layout_row_height)
{
}
@@ -54,6 +56,7 @@
m_navigation_relationship_specific_main = src.m_navigation_relationship_specific_main;
m_navigation_relationship_specific = src.m_navigation_relationship_specific;
+ m_print_layout_row_height = src.m_print_layout_row_height;
return *this;
}
@@ -125,6 +128,27 @@
m_navigation_relationship_specific = sharedptr<UsesRelationship>();
}
+Glib::ustring LayoutItem_Portal::get_from_table() const
+{
+ Glib::ustring from_table;
+
+ sharedptr<const Relationship> relationship = get_relationship();
+ if(relationship)
+ from_table = relationship->get_from_table();
+
+ return from_table;
+}
+
+double LayoutItem_Portal::get_print_layout_row_height() const
+{
+ return m_print_layout_row_height;
+}
+
+void LayoutItem_Portal::set_print_layout_row_height(double row_height)
+{
+ m_print_layout_row_height = row_height;
+}
+
/*
void LayoutItem_Portal::debug(guint level) const
{
Modified: trunk/glom/libglom/data_structure/layout/layoutitem_portal.h
==============================================================================
--- trunk/glom/libglom/data_structure/layout/layoutitem_portal.h (original)
+++ trunk/glom/libglom/data_structure/layout/layoutitem_portal.h Wed Sep 3 14:56:19 2008
@@ -46,17 +46,29 @@
virtual void change_field_item_name(const Glib::ustring& table_name, const Glib::ustring& field_name, const Glib::ustring& field_name_new);
virtual void change_related_field_item_name(const Glib::ustring& table_name, const Glib::ustring& field_name, const Glib::ustring& field_name_new);
+ ///A helper method to avoid extra ifs to avoid null dereferencing.
+ Glib::ustring get_from_table() const;
+
//virtual void debug(guint level = 0) const;
sharedptr<UsesRelationship> get_navigation_relationship_specific(bool& main_relationship);
sharedptr<const UsesRelationship> get_navigation_relationship_specific(bool& main_relationship) const;
void set_navigation_relationship_specific(bool main_relationship, const sharedptr<UsesRelationship>& relationship);
+ /// This is used only for the print layouts.
+ double get_print_layout_row_height() const;
+
+ /// This is used only for the print layouts.
+ void set_print_layout_row_height(double row_height);
+
protected:
//If no navigation relationship has been specified then it will be automatically chosen:
bool m_navigation_relationship_specific_main;
- sharedptr<UsesRelationship> m_navigation_relationship_specific;
+ sharedptr<UsesRelationship> m_navigation_relationship_specific;
+
+ // This is used only for the print layouts.
+ double m_print_layout_row_height;
};
} //namespace Glom
Modified: trunk/glom/mode_data/dialog_layout_list_related.cc
==============================================================================
--- trunk/glom/mode_data/dialog_layout_list_related.cc (original)
+++ trunk/glom/mode_data/dialog_layout_list_related.cc Wed Sep 3 14:56:19 2008
@@ -79,15 +79,24 @@
{
}
-void Dialog_Layout_List_Related::set_document(const Glib::ustring& layout, Document_Glom* document, const sharedptr<const LayoutItem_Portal>& portal)
+void Dialog_Layout_List_Related::set_document(const Glib::ustring& layout, Document_Glom* document, const Glib::ustring& from_table)
{
type_vecLayoutFields empty_fields; //Just to satisfy the base class.
- Dialog_Layout::set_document(layout, document, portal->get_relationship()->get_from_table(), empty_fields);
+ Dialog_Layout::set_document(layout, document, from_table, empty_fields);
//m_table_name is now actually the parent_table_name.
+ update_ui();
+}
+
+void Dialog_Layout_List_Related::set_document(const Glib::ustring& layout, Document_Glom* document, const sharedptr<const LayoutItem_Portal>& portal)
+{
m_portal = glom_sharedptr_clone(portal);
- update_ui();
+ Glib::ustring from_table;
+ if(portal)
+ from_table = portal->get_from_table();
+
+ set_document(layout, document, from_table);
}
void Dialog_Layout_List_Related::update_ui(bool including_relationship_list)
Modified: trunk/glom/mode_data/dialog_layout_list_related.h
==============================================================================
--- trunk/glom/mode_data/dialog_layout_list_related.h (original)
+++ trunk/glom/mode_data/dialog_layout_list_related.h Wed Sep 3 14:56:19 2008
@@ -37,10 +37,18 @@
/**
* @param layout "list" or "details"
* @param document The document, so that the dialog can load the previous layout, and save changes.
- * @param table_name The table name.
- * @param table_fields: The actual fields in the table, in case the document does not yet know about them all.
+ * @param portal The layout item, which knows its from_table, for instance.
*/
virtual void set_document(const Glib::ustring& layout, Document_Glom* document, const sharedptr<const LayoutItem_Portal>& portal);
+
+ /** Use this if there is no portal yet that can specify its from_table.
+ *
+ * @param layout "list" or "details"
+ * @param document The document, so that the dialog can load the previous layout, and save changes.
+ * @param from_table The parent table name.
+ */
+ virtual void set_document(const Glib::ustring& layout, Document_Glom* document, const Glib::ustring& from_table);
+
virtual void update_ui(bool including_relationships_list = true);
sharedptr<Relationship> get_relationship() const;
Modified: trunk/glom/mode_design/print_layouts/canvas_layout_item.cc
==============================================================================
--- trunk/glom/mode_design/print_layouts/canvas_layout_item.cc (original)
+++ trunk/glom/mode_design/print_layouts/canvas_layout_item.cc Wed Sep 3 14:56:19 2008
@@ -34,6 +34,7 @@
#include <glom/libglom/data_structure/layout/report_parts/layoutitem_fieldsummary.h>
#include <glom/libglom/data_structure/glomconversions.h>
#include <glibmm/i18n.h>
+#include <math.h>
namespace Glom
{
@@ -98,18 +99,6 @@
canvas_item->property_fill_color() = bg;
}
-//Just a convenience function until we think of a nice API for goocanvasmm:
-static void portal_add_child( const Glib::RefPtr<Goocanvas::Table>& table, guint row, guint col, const Glib::RefPtr<Goocanvas::Item>& item)
-{
- table->add_child(item);
- goo_canvas_item_set_child_properties(GOO_CANVAS_ITEM(table->gobj()), GOO_CANVAS_ITEM(item->gobj()),
- "row", row,
- "column", col,
- "x-fill", TRUE,
- "x-expand", TRUE,
- NULL);
-}
-
void CanvasLayoutItem::on_resized()
{
Glib::RefPtr<CanvasImageMovable> canvas_image = Glib::RefPtr<CanvasImageMovable>::cast_dynamic(get_child());
@@ -218,27 +207,43 @@
if(portal)
{
Glib::RefPtr<CanvasTableMovable> canvas_item = CanvasTableMovable::create();
- //canvas_item->property_line_width() = 0;
- Glib::RefPtr<CanvasRectMovable> rect1 = CanvasRectMovable::create();
- rect1->property_fill_color() = "white"; //This makes the whole area clickable, not just the outline stroke.
- rect1->property_line_width() = 1;
- rect1->property_stroke_color() = "black";
- rect1->set_width_height(20, 20);
- portal_add_child(canvas_item, 0, 0, rect1);
- Glib::RefPtr<CanvasRectMovable> rect2 = CanvasRectMovable::create();
- rect2->property_fill_color() = "white"; //This makes the whole area clickable, not just the outline stroke.
- rect2->property_line_width() = 1;
- rect2->property_stroke_color() = "black";
- rect2->set_width_height(30, 30);
- portal_add_child(canvas_item, 1, 1, rect2);
+ canvas_item->property_vert_grid_line_width() = 2;
+ canvas_item->property_stroke_color() = "black";
+
+ //Show as many rows as can fit in the height.
+ const double row_height = portal->get_print_layout_row_height(); //TODO: Let the user specify the row height
+ double ignore_x = 0;
+ double ignore_y = 0;
+ double total_width = 0;
+ double total_height = 0;
+ portal->get_print_layout_position(ignore_x, ignore_y, total_width, total_height);
+
+ const double max_rows_fraction = total_height / row_height;
+ double max_rows = 0;
+ modf(max_rows_fraction, &max_rows);
+ for(int i = 0; i < (int)max_rows; ++i)
+ {
+ Glib::RefPtr<CanvasRectMovable> rect_row = CanvasRectMovable::create();
+ rect_row->property_fill_color() = "white"; //This makes the whole area clickable, not just the outline stroke.
+ rect_row->property_line_width() = 1;
+ rect_row->property_stroke_color() = "black";
+ rect_row->set_width_height(total_width, row_height);
+
+ //TODO: Add/Remove rows when resizing, instead of resizing the rows:
+ canvas_item->attach(rect_row, 0 /* left_attach */, 1 /* right_attach */, i /* top_attach */, i + 1 /* right_attach */, (Gtk::AttachOptions)Gtk::FILL | Gtk::EXPAND, (Gtk::AttachOptions)Gtk::FILL | Gtk::EXPAND, 0.0, 0.0, 0.0, 0.0);
+ }
child = canvas_item;
child_item = canvas_item;
}
- else
+ else if(m_layout_item)
{
std::cerr << "CanvasLayoutItem::set_layout_item(): Unhandled LayoutItem type. part type=" << m_layout_item->get_part_type_name() << std::endl;
}
+ else
+ {
+ std::cerr << "CanvasLayoutItem::set_layout_item(): NULL LayoutItem type." << std::endl;
+ }
}
}
}
Modified: trunk/glom/mode_design/print_layouts/canvas_print_layout.cc
==============================================================================
--- trunk/glom/mode_design/print_layouts/canvas_print_layout.cc (original)
+++ trunk/glom/mode_design/print_layouts/canvas_print_layout.cc Wed Sep 3 14:56:19 2008
@@ -23,6 +23,7 @@
#include <bakery/App/App_Gtk.h> //For util_bold_message().
#include <gtkmm/stock.h>
#include <glom/mode_design/print_layouts/dialog_text_formatting.h>
+#include <glom/mode_data/dialog_layout_list_related.h>
#include <glom/libglom/glade_utils.h>
#include <glibmm/i18n.h>
@@ -280,6 +281,43 @@
layout_item->set_print_layout_position(x, y, width, height);
}
+sharedptr<LayoutItem_Portal> Canvas_PrintLayout::offer_related_records(const sharedptr<LayoutItem_Portal>& portal, Gtk::Widget* parent)
+{
+ sharedptr<LayoutItem_Portal> result = portal;
+
+ Dialog_Layout_List_Related* dialog = 0;
+
+ Glib::RefPtr<Gnome::Glade::Xml> refXml = Gnome::Glade::Xml::create(Utils::get_glade_file_path("glom_developer.glade"), "window_data_layout");
+ if(refXml)
+ refXml->get_widget_derived("window_data_layout", dialog);
+
+ if(!dialog)
+ {
+ std::cerr << "Canvas_PrintLayout::offer_related_records(): dialog was NULL." << std::endl;
+ return result;
+ }
+
+ add_view(dialog); //Give it access to the document.
+
+ if(!portal || (portal->get_from_table().empty()))
+ dialog->set_document("TODO_layout_name", get_document(), m_table_name);
+ else
+ dialog->set_document("TODO_layout_name", get_document(), portal);
+
+ //m_pDialogLayout->signal_hide().connect( sigc::mem_fun(*this, &Box_Data::on_dialog_layout_hide) );
+ dialog->run();
+
+
+
+ //TODO: block.
+
+ result = dialog->get_portal_layout();
+ delete dialog;
+ dialog = 0;
+
+ return result;
+}
+
void Canvas_PrintLayout::on_context_menu_edit()
{
Gtk::Window* parent = dynamic_cast<Gtk::Window*>(get_toplevel());
@@ -310,6 +348,15 @@
image = Base_DB::offer_imageobject(image, parent, false /* don't show title */);
m_context_item->set_layout_item(image);
}
+ else
+ {
+ sharedptr<LayoutItem_Portal> portal = sharedptr<LayoutItem_Portal>::cast_dynamic(layout_item);
+ if(portal)
+ {
+ portal = offer_related_records(portal, parent);
+ m_context_item->set_layout_item(portal);
+ }
+ }
}
}
Modified: trunk/glom/mode_design/print_layouts/canvas_print_layout.h
==============================================================================
--- trunk/glom/mode_design/print_layouts/canvas_print_layout.h (original)
+++ trunk/glom/mode_design/print_layouts/canvas_print_layout.h Wed Sep 3 14:56:19 2008
@@ -33,6 +33,7 @@
{
class Dialog_TextFormatting;
+class LayoutItem_Portal;
/// A canvas that contains CanvasLayoutItem items.
class Canvas_PrintLayout
@@ -70,6 +71,8 @@
void add_layout_group_children(const sharedptr<LayoutGroup>& group);
void fill_layout_group(const sharedptr<LayoutGroup>& group);
+ sharedptr<LayoutItem_Portal> offer_related_records(const sharedptr<LayoutItem_Portal>& portal, Gtk::Widget* parent);
+
void on_item_show_context_menu(guint button, guint32 activate_time, Glib::RefPtr<CanvasLayoutItem> item);
void on_context_menu_edit();
void on_context_menu_formatting();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]