gnomemm r1452 - in goocanvasmm/trunk: . examples examples/tablemodel



Author: arminb
Date: Fri Apr 11 12:03:04 2008
New Revision: 1452
URL: http://svn.gnome.org/viewvc/gnomemm?rev=1452&view=rev

Log:
2008-04-11  Armin Burgmeier  <armin openismus com>

	* examples/tablemodel/examplewindow.h:
	* examples/tablemodel/examplewindow.cc:
	* examples/tablemodel/Makefile.am: Added a new example showing two
	canvases that display the same underlaying model.

	* examples/Makefile.am:
	* configure.in: Build the new example.


Added:
   goocanvasmm/trunk/examples/tablemodel/
   goocanvasmm/trunk/examples/tablemodel/Makefile.am
   goocanvasmm/trunk/examples/tablemodel/examplewindow.cc
   goocanvasmm/trunk/examples/tablemodel/examplewindow.h
Modified:
   goocanvasmm/trunk/ChangeLog
   goocanvasmm/trunk/configure.in
   goocanvasmm/trunk/examples/Makefile.am

Modified: goocanvasmm/trunk/configure.in
==============================================================================
--- goocanvasmm/trunk/configure.in	(original)
+++ goocanvasmm/trunk/configure.in	Fri Apr 11 12:03:04 2008
@@ -151,5 +151,6 @@
     examples/coordinates/Makefile
     examples/text/Makefile
     examples/table/Makefile
+    examples/tablemodel/Makefile
 ])
 :

Modified: goocanvasmm/trunk/examples/Makefile.am
==============================================================================
--- goocanvasmm/trunk/examples/Makefile.am	(original)
+++ goocanvasmm/trunk/examples/Makefile.am	Fri Apr 11 12:03:04 2008
@@ -1,4 +1,4 @@
-SUBDIRS = drag_to_canvas simple moving_shapes demo coordinates text table
+SUBDIRS = drag_to_canvas simple moving_shapes demo coordinates text table tablemodel
 
 #EXTRA_DIST	=  Makefile.am_fragment README.txt
 

Added: goocanvasmm/trunk/examples/tablemodel/Makefile.am
==============================================================================
--- (empty file)
+++ goocanvasmm/trunk/examples/tablemodel/Makefile.am	Fri Apr 11 12:03:04 2008
@@ -0,0 +1,5 @@
+include $(top_srcdir)/examples/Makefile.am_fragment
+
+noinst_PROGRAMS = example
+example_SOURCES = main.cc examplewindow.cc examplewindow.h
+

Added: goocanvasmm/trunk/examples/tablemodel/examplewindow.cc
==============================================================================
--- (empty file)
+++ goocanvasmm/trunk/examples/tablemodel/examplewindow.cc	Fri Apr 11 12:03:04 2008
@@ -0,0 +1,55 @@
+#include "examplewindow.h"
+#include <cairomm/cairomm.h>
+#include <iostream>
+
+
+ExampleWindow::ExampleWindow()
+{
+  set_title("goocanvasmm - TableModel example");
+
+  m_first_canvas.set_size_request(640, 240);
+  m_first_canvas.set_bounds(0, 0, 1000, 1000);
+
+  m_second_canvas.set_size_request(640, 240);
+  m_second_canvas.set_bounds(0, 0, 500, 500);
+
+  Glib::RefPtr<Goocanvas::ItemModel> root = Goocanvas::GroupModel::create() ;
+  m_first_canvas.set_root_item_model(root);
+  m_second_canvas.set_root_item_model(root);
+
+  m_table = Goocanvas::TableModel::create();
+  //m_table->property_x() = 10;
+  //m_table->property_y() = 10;
+  m_table->property_height() = 200;
+  m_table->property_width() = 300;
+  m_table->property_column_spacing() = 6;
+  m_table->property_row_spacing() = 6;
+  //m_table->property_columns() = 2;
+  //m_table->property_row() = 2;
+  root->add_child(m_table);
+
+  add_text_to_cell(m_table, "top left", 0, 0); 
+  add_text_to_cell(m_table, "top right", 0, 1);
+  add_text_to_cell(m_table, "bottom left", 1, 0);
+  add_text_to_cell(m_table, "bottom right", 1, 1);
+
+
+  Gtk::ScrolledWindow* sw1 = Gtk::manage(new Gtk::ScrolledWindow());
+  sw1->add(m_first_canvas);
+  Gtk::ScrolledWindow* sw2 = Gtk::manage(new Gtk::ScrolledWindow());
+  sw2->add(m_second_canvas);
+
+  Gtk::VBox* box = Gtk::manage(new Gtk::VBox(false, 6));
+  box->pack_start(*sw1, Gtk::PACK_EXPAND_WIDGET);
+  box->pack_start(*sw2, Gtk::PACK_EXPAND_WIDGET);
+  add(*box);
+
+  show_all_children();
+}
+
+void ExampleWindow::add_text_to_cell(const Glib::RefPtr<Goocanvas::TableModel>& table, const Glib::ustring& text, guint row, guint col)
+{
+  Glib::RefPtr<Goocanvas::TextModel> text_item = Goocanvas::TextModel::create(text);
+  table->attach(text_item, col, col+1, row, row+1, Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
+}
+

Added: goocanvasmm/trunk/examples/tablemodel/examplewindow.h
==============================================================================
--- (empty file)
+++ goocanvasmm/trunk/examples/tablemodel/examplewindow.h	Fri Apr 11 12:03:04 2008
@@ -0,0 +1,20 @@
+
+#include <gtkmm.h>
+#include <goocanvasmm.h>
+
+class ExampleWindow : public Gtk::Window
+{
+public:
+  ExampleWindow() ;
+
+protected:
+
+  void add_text_to_cell(const Glib::RefPtr<Goocanvas::TableModel>&, const Glib::ustring& text, guint row, guint col);
+
+  //bool on_rect_button_press(const Glib::RefPtr<Goocanvas::ItemModel>& target, GdkEventButton* event);
+  
+  Goocanvas::Canvas m_first_canvas;
+  Goocanvas::Canvas m_second_canvas;
+  Glib::RefPtr<Goocanvas::TableModel> m_table;
+};
+



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