[goocanvasmm: 1/3] Fix the build with disabled
- From: Murray Cumming <murrayc src gnome org>
- To: svn-commits-list gnome org
- Subject: [goocanvasmm: 1/3] Fix the build with disabled
- Date: Sun, 5 Jul 2009 18:54:40 +0000 (UTC)
commit 5747333b573dd29f9857098db8b0a01df31e5345
Author: Murray Cumming <murrayc murrayc com>
Date: Sun Jul 5 20:12:43 2009 +0200
Fix the build with disabled
exceptions and disabled properties API. It is not pretty.
* examples/coordinates/window.cc:
* examples/custom_item/examplewindow.cc:
* examples/demo/primitives.cc:
* examples/drag_to_canvas/examplewindow.cc:
* examples/moving_shapes/window.cc:
* examples/simple/examplewindow.cc:
* examples/table/examplewindow.cc:
* examples/tablemodel/examplewindow.cc:
* examples/text/window.cc:
* goocanvas/src/polyline.ccg:
* goocanvas/src/polylinemodel.ccg: Added ifdefs.
ChangeLog | 17 +++
configure.in | 2 +-
examples/coordinates/window.cc | 16 +++
examples/custom_item/examplewindow.cc | 6 +
examples/demo/primitives.cc | 159 ++++++++++++++++++++++++++++--
examples/drag_to_canvas/examplewindow.cc | 30 ++++--
examples/moving_shapes/window.cc | 74 +++++++++-----
examples/simple/examplewindow.cc | 29 ++++--
examples/table/examplewindow.cc | 7 ++
examples/tablemodel/examplewindow.cc | 7 ++
examples/text/window.cc | 31 ++++++
goocanvas/src/polyline.ccg | 11 ++-
goocanvas/src/polylinemodel.ccg | 11 ++-
13 files changed, 343 insertions(+), 57 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 621bc16..a74d282 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2009-07-05 Murray Cumming <murrayc murrayc-x61>
+
+ Fix the build with disabled
+ exceptions and disabled properties API. It is not pretty.
+
+ * examples/coordinates/window.cc:
+ * examples/custom_item/examplewindow.cc:
+ * examples/demo/primitives.cc:
+ * examples/drag_to_canvas/examplewindow.cc:
+ * examples/moving_shapes/window.cc:
+ * examples/simple/examplewindow.cc:
+ * examples/table/examplewindow.cc:
+ * examples/tablemodel/examplewindow.cc:
+ * examples/text/window.cc:
+ * goocanvas/src/polyline.ccg:
+ * goocanvas/src/polylinemodel.ccg: Added ifdefs.
+
0.14.0:
2009-03-25 Murray Cumming <murrayc murrayc com>
diff --git a/configure.in b/configure.in
index db899d4..944df0e 100644
--- a/configure.in
+++ b/configure.in
@@ -16,7 +16,7 @@ AC_INIT(goocanvas/goocanvasmmconfig.h.in)
# Version and initialization
#########################################################################
LIBGOOCANVASMM_MAJOR_VERSION=0
-LIBGOOCANVASMM_MINOR_VERSION=14
+LIBGOOCANVASMM_MINOR_VERSION=15
LIBGOOCANVASMM_MICRO_VERSION=0
#
diff --git a/examples/coordinates/window.cc b/examples/coordinates/window.cc
index fa06fb6..588b2c1 100644
--- a/examples/coordinates/window.cc
+++ b/examples/coordinates/window.cc
@@ -37,9 +37,15 @@ ExampleWindow::ExampleWindow()
Glib::RefPtr<Goocanvas::Item> root = m_canvas.get_root_item();
m_rect = Goocanvas::Rect::create(10, 10, 60, 60);
root->add_child(m_rect);
+#ifdef GLIBMM_PROPERTIES_ENABLED
m_rect->property_line_width().set_value(10.0);
m_rect->property_stroke_color().set_value("yellow");
m_rect->property_fill_color().set_value("gray");
+#else
+ m_rect->set_property("line_width", 10.0);
+ m_rect->set_property("stroke_color", Glib::ustring("yellow"));
+ m_rect->set_property("fill_color", Glib::ustring("gray"));
+#endif
Gtk::ScrolledWindow* sw = Gtk::manage(new Gtk::ScrolledWindow());
@@ -70,9 +76,13 @@ ExampleWindow::ExampleWindow()
void ExampleWindow::update_label()
{
std::stringstream str;
+#ifdef GLIBMM_PROPERTIES_ENABLED
str << "Rect: x=" << m_rect->property_x() << ", y=" << m_rect->property_y() <<
", width=" << m_rect->property_width() << ", height=" << m_rect->property_height() <<
", line_width=" << m_rect->property_line_width() << std::endl;
+#else
+ //TODO.
+#endif
Goocanvas::Bounds bounds = m_rect->get_bounds();
str << "Item bounds: x1=" << bounds.get_x1() << ", y1=" << bounds.get_y1() << ", x2=" << bounds.get_x2() << ", y2=" << bounds.get_y2() << std::endl;
@@ -90,8 +100,14 @@ void ExampleWindow::on_button_translate()
void ExampleWindow::on_button_setxy()
{
+#ifdef GLIBMM_PROPERTIES_ENABLED
m_rect->property_x() = 50;
m_rect->property_y() = 50;
+#else
+ m_rect->set_property("x", 50);
+ m_rect->set_property("y", 50);
+#endif
+
update_label();
}
diff --git a/examples/custom_item/examplewindow.cc b/examples/custom_item/examplewindow.cc
index 6c830e5..f1536a2 100644
--- a/examples/custom_item/examplewindow.cc
+++ b/examples/custom_item/examplewindow.cc
@@ -28,9 +28,15 @@ ExampleWindow::ExampleWindow()
Glib::RefPtr<ExampleItem> item = ExampleItem::create(100, 100, 400, 400);
+#ifdef GLIBMM_PROPERTIES_ENABLED
item->property_line_width().set_value(10.0);
item->property_stroke_color().set_value("yellow");
item->property_fill_color().set_value("red");
+#else
+ item->set_property("line_width", 10.0);
+ item->set_property("stroke_color", Glib::ustring("yellow"));
+ item->set_property("fill_color", Glib::ustring("red"));
+#endif
Glib::RefPtr<Goocanvas::Item> root = m_canvas.get_root_item();
root->add_child(item);
diff --git a/examples/demo/primitives.cc b/examples/demo/primitives.cc
index 2d6ab3e..859c989 100644
--- a/examples/demo/primitives.cc
+++ b/examples/demo/primitives.cc
@@ -100,7 +100,12 @@ Primitives::_setup_heading(const Glib::ustring& heading, int pos)
Glib::RefPtr<Goocanvas::Text> text = Goocanvas::Text::create(heading, x, y, -1, Gtk::ANCHOR_N) ;
_canvas->get_root_item()->add_child(text);
+#ifdef GLIBMM_PROPERTIES_ENABLED
text->property_font() = "Sans 12" ;
+#else
+ text->set_property("font", Glib::ustring("Sans 12"));
+#endif
+
text->skew_y(30, x, y) ;
}
@@ -115,23 +120,43 @@ Primitives::_setup_divisions()
item = Goocanvas::Rect::create(0, 0, 600, 450) ;
group->add_child(item);
+#ifdef GLIBMM_PROPERTIES_ENABLED
item->property_line_width() = 4.0 ;
+#else
+ item->set_property("line_width", 4.0);
+#endif
item = Goocanvas::Polyline::create(0, 150, 600, 150) ;
group->add_child(item);
+#ifdef GLIBMM_PROPERTIES_ENABLED
item->property_line_width() = 4.0 ;
+#else
+ item->set_property("line_width", 4.0);
+#endif
item = Goocanvas::Polyline::create(0, 300, 600, 300) ;
group->add_child(item);
+#ifdef GLIBMM_PROPERTIES_ENABLED
item->property_line_width() = 4.0 ;
+#else
+ item->set_property("line_width", 4.0);
+#endif
item = Goocanvas::Polyline::create(200, 0, 200, 450) ;
group->add_child(item);
+#ifdef GLIBMM_PROPERTIES_ENABLED
item->property_line_width() = 4.0 ;
+#else
+ item->set_property("line_width", 4.0);
+#endif
item = Goocanvas::Polyline::create(400, 0, 400, 450) ;
group->add_child(item);
+#ifdef GLIBMM_PROPERTIES_ENABLED
item->property_line_width() = 4.0 ;
+#else
+ item->set_property("line_width", 4.0);
+#endif
_setup_heading("Rectangles", 0) ;
_setup_heading("Ellipses", 1) ;
@@ -152,8 +177,13 @@ Primitives::_setup_rectangles()
rect = Goocanvas::Rect::create(20, 30, 50, 30) ;
root->add_child(rect);
+#ifdef GLIBMM_PROPERTIES_ENABLED
rect->property_stroke_color() = "red" ;
rect->property_line_width() = 8.0 ;
+#else
+ rect->set_property("stroke_color", Glib::ustring("red"));
+ rect->set_property("line_width", 8.0);
+#endif
_setup_signals(rect) ;
rect = Goocanvas::Rect::create(90, 40, 90, 60) ;
@@ -161,33 +191,59 @@ Primitives::_setup_rectangles()
//rect->property_fill_pattern() = _create_stipple("mediumseagreen") ;
Cairo::RefPtr<Cairo::Pattern> p = _create_stipple("mediumseagreen") ;
g_object_set(rect->gobj(), "fill-pattern", p->cobj(), NULL) ;
+#ifdef GLIBMM_PROPERTIES_ENABLED
rect->property_stroke_color() = "black" ;
rect->property_line_width() = 4.0 ;
+#else
+ rect->set_property("stroke_color", Glib::ustring("black"));
+ rect->set_property("line_width", 4.0);
+#endif
_setup_signals(rect) ;
rect = Goocanvas::Rect::create(10, 80, 70, 60) ;
root->add_child(rect);
+#ifdef GLIBMM_PROPERTIES_ENABLED
rect->property_fill_color() = "steelblue" ;
+#else
+ rect->set_property("fill_color", Glib::ustring("steelblue"));
+#endif
_setup_signals(rect) ;
rect = Goocanvas::Rect::create(20, 90, 70, 60) ;
root->add_child(rect);
+#ifdef GLIBMM_PROPERTIES_ENABLED
rect->property_fill_color_rgba() = 0x3cb37180 ;
rect->property_stroke_color() = "blue" ;
rect->property_line_width() = 2.0 ;
+#else
+ rect->set_property("fill_color_rgba", 0x3cb37180);
+ rect->set_property("stroke_color", Glib::ustring("blue"));
+ rect->set_property("line_width", 2.0);
+#endif
_setup_signals(rect) ;
rect = Goocanvas::Rect::create(110, 80, 50, 30) ;
root->add_child(rect);
+#ifdef GLIBMM_PROPERTIES_ENABLED
rect->property_radius_x() = 20.0 ;
rect->property_radius_y() = 10.0 ;
rect->property_stroke_color() = "yellow" ;
rect->property_fill_color_rgba() = 0x3cb3f180 ;
+#else
+ rect->set_property("radius_x", 20.0);
+ rect->set_property("radius_y", 10.0);
+ rect->set_property("stroke_color", Glib::ustring("yellow"));
+ rect->set_property("fill_color_rgba", 0x3cb3f180);
+#endif
_setup_signals(rect) ;
rect = Goocanvas::Rect::create(30, 20, 50, 30) ;
root->add_child(rect);
+#ifdef GLIBMM_PROPERTIES_ENABLED
rect->property_fill_color() = "yellow" ;
+#else
+ rect->set_property("fill_color", Glib::ustring("yellow"));
+#endif
_setup_signals(rect) ;
}
@@ -199,16 +255,28 @@ Primitives::_setup_ellipses()
ellipse = Goocanvas::Ellipse::create(245, 45, 25, 15);
root->add_child(ellipse);
+#ifdef GLIBMM_PROPERTIES_ENABLED
ellipse->property_stroke_color() = "goldenrod" ;
ellipse->property_line_width() = 8.0 ;
+#else
+ ellipse->set_property("stroke_color", Glib::ustring("goldenrod"));
+ ellipse->set_property("line_width", 8.0);
+#endif
_setup_signals(ellipse) ;
ellipse = Goocanvas::Ellipse::create(335, 70, 45, 30) ;
root->add_child(ellipse);
+#ifdef GLIBMM_PROPERTIES_ENABLED
ellipse->property_fill_color() = "wheat" ;
ellipse->property_stroke_color() = "midnightblue" ;
ellipse->property_line_width() = 4.0 ;
ellipse->property_title() = "An ellipse" ;
+#else
+ ellipse->set_property("fill_color", Glib::ustring("wheat"));
+ ellipse->set_property("stroke_color", Glib::ustring("midnightblue"));
+ ellipse->set_property("line_width", 4.0);
+ ellipse->set_property("title", Glib::ustring("An ellipse"));
+#endif
_setup_signals(ellipse) ;
ellipse = Goocanvas::Ellipse::create(245, 110, 35, 30) ;
@@ -216,8 +284,14 @@ Primitives::_setup_ellipses()
//ellipse->property_fill_pattern() = _create_stipple("cadetblue") ;
Cairo::RefPtr<Cairo::Pattern> p = _create_stipple("cadetblue") ;
g_object_set(ellipse->gobj(), "fill-pattern", p->cobj(), NULL) ;
+
+#ifdef GLIBMM_PROPERTIES_ENABLED
ellipse->property_stroke_color() = "black" ;
ellipse->property_line_width() = 1.0 ;
+#else
+ ellipse->set_property("stroke_color", Glib::ustring("black"));
+ ellipse->set_property("line_width", 1.0);
+#endif
_setup_signals(ellipse) ;
}
@@ -233,17 +307,29 @@ Primitives::_setup_texts()
//ellipse->property_fill_pattern() = _create_stipple("blue") ;
Cairo::RefPtr<Cairo::Pattern> p = _create_stipple("blue") ;
g_object_set(text->gobj(), "fill-pattern", p->cobj(), NULL) ;
+#ifdef GLIBMM_PROPERTIES_ENABLED
text->property_font() = "Sans Bold 24" ;
text->property_alignment() = Pango::ALIGN_CENTER ;
text->property_fill_color() = "firebrick" ;
+#else
+ text->set_property("font", Glib::ustring("Sans Bold 24"));
+ text->set_property("alignment", Pango::ALIGN_CENTER);
+ text->set_property("fill_color", Glib::ustring("firebrick"));
+#endif
_setup_signals(text) ;
anchor = _create_anchor(470, 75);
text = Goocanvas::Text::create("Anchor center\nJustify center\nMultiline text\n8bit text 'gibberish'", 0, 0, -1, Gtk::ANCHOR_CENTER) ;
anchor->add_child(text);
+#ifdef GLIBMM_PROPERTIES_ENABLED
text->property_font() = "monospace bold 14" ;
text->property_alignment() = Pango::ALIGN_CENTER ;
text->property_fill_color() = "firebrick" ;
+#else
+ text->set_property("font", Glib::ustring("monospace bold 14"));
+ text->set_property("alignment", Pango::ALIGN_CENTER);
+ text->set_property("fill_color", Glib::ustring("firebrick"));
+#endif
_setup_signals(text) ;
anchor = _create_anchor(420, 240);
@@ -251,39 +337,63 @@ Primitives::_setup_texts()
"This is a very long paragraph that will need to be wrapped over several lines so we can see what happens to line-breaking as the view is zoomed in and out.",
0, 0, 180, Gtk::ANCHOR_W) ;
anchor->add_child(text);
+#ifdef GLIBMM_PROPERTIES_ENABLED
text->property_font() = "Sans 12" ;
text->property_fill_color() = "goldenrod" ;
+#else
+ text->set_property("font", Glib::ustring("Sans 12"));
+ text->set_property("fill_color", Glib::ustring("goldenrod"));
+#endif
_setup_signals(text) ;
text = Goocanvas::Text::create("Ellipsized text.", 20, 420, 115, Gtk::ANCHOR_W) ;
_canvas->get_root_item()->add_child(text);
+#ifdef GLIBMM_PROPERTIES_ENABLED
text->property_font() = "Sans 12" ;
text->property_fill_color() = "blue" ;
text->property_ellipsize() = Pango::ELLIPSIZE_END ;
+#else
+ text->set_property("font", Glib::ustring("Sans 12"));
+ text->set_property("fill_color", Glib::ustring("blue"));
+ text->set_property("ellipsize", Pango::ELLIPSIZE_END);
+#endif
_setup_signals(text) ;
}
void
Primitives::_setup_images()
{
+#ifdef GLIBMM_EXCEPTIONS_ENABLED
try
{
Glib::RefPtr<Gdk::Pixbuf> pb = Gdk::Pixbuf::create_from_file("toroid.png") ;
-
- double w = pb->get_width() ;
- double h = pb->get_height() ;
-
- Glib::RefPtr<Goocanvas::Image> img = Goocanvas::Image::create(pb, 100.0 - w / 2.0, 225.0 - h / 2.0) ;
- _canvas->get_root_item()->add_child(img);
- img->property_width() = w ;
- img->property_height() = h ;
- _setup_signals(img) ;
}
-
catch(...)
{
g_warning("Couldn't find the toroid.png sample file.") ;
}
+#else
+ std::auto_ptr<Glib::Error> error;
+ Glib::RefPtr<Gdk::Pixbuf> pb = Gdk::Pixbuf::create_from_file("toroid.png", error) ;
+ if(error.get())
+ {
+ g_warning("Couldn't find the toroid.png sample file.") ;
+ }
+#endif
+
+ double w = pb->get_width() ;
+ double h = pb->get_height() ;
+
+ Glib::RefPtr<Goocanvas::Image> img = Goocanvas::Image::create(pb, 100.0 - w / 2.0, 225.0 - h / 2.0) ;
+ _canvas->get_root_item()->add_child(img);
+#ifdef GLIBMM_PROPERTIES_ENABLED
+ img->property_width() = w ;
+ img->property_height() = h ;
+#else
+ img->set_property("width", w);
+ img->set_property("height", h);
+#endif
+ _setup_signals(img) ;
_create_flower(20.0, 170.0, Gtk::ANCHOR_NW) ;
_create_flower(180.0, 170.0, Gtk::ANCHOR_NE) ;
@@ -312,6 +422,7 @@ Primitives::_setup_lines()
line = Goocanvas::Polyline::create(356, 180, 374, 220) ;
root->add_child(line);
+#ifdef GLIBMM_PROPERTIES_ENABLED
line->property_stroke_color() = "blue" ;
line->property_line_width() = 1.0 ;
line->property_start_arrow() = true ;
@@ -319,10 +430,20 @@ Primitives::_setup_lines()
line->property_arrow_tip_length() = 5.0 ;
line->property_arrow_length() = 6.0 ;
line->property_arrow_width() = 6.0 ;
+#else
+ line->set_property("stroke_color", Glib::ustring("blue"));
+ line->set_property("line_width", 1.0);
+ line->set_property("start_arrow", true);
+ line->set_property("end_arrow", true);
+ line->set_property("arrow_tip_length", 5.0);
+ line->set_property("arrow_length", 6.0);
+ line->set_property("arrow_width", 6.0);
+#endif
_setup_signals(line) ;
line = Goocanvas::Polyline::create(356, 220, 374, 180) ;
root->add_child(line);
+#ifdef GLIBMM_PROPERTIES_ENABLED
line->property_stroke_color() = "blue" ;
line->property_line_width() = 1.0 ;
line->property_start_arrow() = true ;
@@ -330,6 +451,15 @@ Primitives::_setup_lines()
line->property_arrow_tip_length() = 5.0 ;
line->property_arrow_length() = 6.0 ;
line->property_arrow_width() = 6.0 ;
+#else
+ line->set_property("stroke_color", Glib::ustring("blue"));
+ line->set_property("line_width", 1.0);
+ line->set_property("start_arrow", true);
+ line->set_property("end_arrow", true);
+ line->set_property("arrow_tip_length", 5.0);
+ line->set_property("arrow_length", 6.0);
+ line->set_property("arrow_width", 6.0);
+#endif
_setup_signals(line) ;
}
@@ -367,7 +497,11 @@ Primitives::_create_anchor(double x, double y)
Glib::RefPtr<Goocanvas::Rect> rect = Goocanvas::Rect::create(-2.5, -2.5, 4, 4) ;
group->add_child(rect);
+#ifdef GLIBMM_PROPERTIES_ENABLED
rect->property_line_width() = 1.0 ;
+#else
+ rect->set_property("line_width", 1.0);
+#endif
_setup_signals(group) ;
@@ -399,8 +533,13 @@ Primitives::_create_flower(double x, double y, Gtk::AnchorType anchor)
_canvas->get_root_item()->add_child(img);
//TODO: img->property_pattern() = pattern ;
g_object_set(img->gobj(), "pattern", pattern->cobj(), NULL) ;
+#ifdef GLIBMM_PROPERTIES_ENABLED
img->property_width() = w ;
img->property_height() = h ;
+#else
+ img->set_property("width", w);
+ img->set_property("height", h);
+#endif
_setup_signals(img) ;
}
diff --git a/examples/drag_to_canvas/examplewindow.cc b/examples/drag_to_canvas/examplewindow.cc
index 075f7fd..17767ef 100644
--- a/examples/drag_to_canvas/examplewindow.cc
+++ b/examples/drag_to_canvas/examplewindow.cc
@@ -199,19 +199,33 @@ Glib::RefPtr<Goocanvas::Item> ExampleWindow::create_canvas_item(DragItem drag_it
if(drag_item == DRAG_ITEM_RECTANGLE)
{
Glib::RefPtr<Goocanvas::Rect> rect = Goocanvas::Rect::create(0, 0, 20, 20);
- rect->property_line_width().set_value(10.0);
- rect->property_stroke_color().set_value("yellow");
- rect->property_fill_color().set_value("red");
+#ifdef GLIBMM_PROPERTIES_ENABLED
+ rect->property_line_width() = 10.0;
+ rect->property_stroke_color() = "yellow");
+ rect->property_fill_color() = "red";
+#else
+ rect->set_property("line_width", 10.0);
+ rect->set_property("stroke_color", Glib::ustring("yellow"));
+ rect->set_property("fill_color", Glib::ustring("red"));
+#endif //GLIBMM_PROPERTIES_ENABLED
result = rect;
}
else if(drag_item == DRAG_ITEM_ELLIPSE)
{
Glib::RefPtr<Goocanvas::Ellipse> ellipse = Goocanvas::Ellipse::create();
- ellipse->property_line_width().set_value(10.0);
- ellipse->property_radius_x().set_value(20.0);
- ellipse->property_radius_y().set_value(20.0);
- ellipse->property_stroke_color().set_value("yellow");
- ellipse->property_fill_color().set_value("red");
+#ifdef GLIBMM_PROPERTIES_ENABLED
+ ellipse->property_line_width() = 10.0;
+ ellipse->property_radius_x() = 20.0;
+ ellipse->property_radius_y() = 20.0;
+ ellipse->property_stroke_color() = "yellow";
+ ellipse->property_fill_color() = "red";
+#else
+ ellipse->set_property("line_width", 10.0);
+ ellipse->set_property("radius_x", 20.0);
+ ellipse->set_property("radius_y", 20.0);
+ ellipse->set_property("stroke_color", Glib::ustring("yellow"));
+ ellipse->set_property("fill_color", Glib::ustring("red"));
+#endif //GLIBMM_PROPERTIES_ENABLED
result = ellipse;
}
diff --git a/examples/moving_shapes/window.cc b/examples/moving_shapes/window.cc
index 87a37f0..e2a6d7a 100644
--- a/examples/moving_shapes/window.cc
+++ b/examples/moving_shapes/window.cc
@@ -21,48 +21,66 @@
Window::Window()
{
- set_title("goocanvasmm Moving Shapes") ;
- set_default_size(640, 480) ;
+ set_title("goocanvasmm Moving Shapes");
+ set_default_size(640, 480);
- _canvas = Gtk::manage(new Goocanvas::Canvas()) ;
- _canvas->signal_item_created().connect(sigc::mem_fun(*this, &Window::on_item_created)) ;
- Glib::RefPtr<Goocanvas::ItemModel> root = Goocanvas::GroupModel::create() ;
- _canvas->set_root_item_model(root) ;
+ _canvas = Gtk::manage(new Goocanvas::Canvas());
+ _canvas->signal_item_created().connect(sigc::mem_fun(*this, &Window::on_item_created));
+ Glib::RefPtr<Goocanvas::ItemModel> root = Goocanvas::GroupModel::create();
+ _canvas->set_root_item_model(root);
- Glib::RefPtr<Goocanvas::RectModel> rect = Goocanvas::RectModel::create(200, 200, 100, 100) ;
+ Glib::RefPtr<Goocanvas::RectModel> rect = Goocanvas::RectModel::create(200, 200, 100, 100);
root->add_child(rect);
- rect->property_line_width().set_value(3) ;
- rect->property_radius_x().set_value(10.0) ;
- rect->property_radius_y().set_value(10.0) ;
- rect->property_stroke_color().set_value("red") ;
- rect->property_fill_color().set_value("blue") ;
+#ifdef GLIBMM_PROPERTIES_ENABLED
+ rect->property_line_width() = 3;
+ rect->property_radius_x() = 10.0;
+ rect->property_radius_y() = 10.0;
+ rect->property_stroke_color() = "red";
+ rect->property_fill_color() = "blue";
+#else
+ rect->set_property("line_width", 3);
+ rect->set_property("radius_x", 10.0);
+ rect->set_property("radius_y", 10.0);
+ rect->set_property("stroke_color", Glib::ustring("red"));
+ rect->set_property("fill_color", Glib::ustring("blue"));
+#endif //GLIBMM_PROPERTIES_ENABLED
- Glib::RefPtr<Goocanvas::EllipseModel> ellipse = Goocanvas::EllipseModel::create(400, 200, 100, 50) ;
+ Glib::RefPtr<Goocanvas::EllipseModel> ellipse = Goocanvas::EllipseModel::create(400, 200, 100, 50);
root->add_child(ellipse);
- ellipse->property_line_width().set_value(3) ;
- ellipse->property_stroke_color().set_value("midnightblue") ;
- ellipse->property_fill_color().set_value("wheat") ;
+#ifdef GLIBMM_PROPERTIES_ENABLED
+ ellipse->property_line_width() = 3;
+ ellipse->property_stroke_color() = "midnightblue";
+ ellipse->property_fill_color() = "wheat";
+#else
+ ellipse->set_property("line_width", 3);
+ ellipse->set_property("stroke_color", Glib::ustring("midnightblue"));
+ ellipse->set_property("fill_color", Glib::ustring("wheat"));
+#endif //GLIBMM_PROPERTIES_ENABLED
- Glib::RefPtr<Goocanvas::PolylineModel> polyline = Goocanvas::PolylineModel::create(250, 250, 450, 225) ;
+ Glib::RefPtr<Goocanvas::PolylineModel> polyline = Goocanvas::PolylineModel::create(250, 250, 450, 225);
root->add_child(polyline);
- polyline->property_line_width().set_value(4) ;
+#ifdef GLIBMM_PROPERTIES_ENABLED
+ polyline->property_line_width() = 4;
+#else
+ polyline->set_property("line_width", 4);
+#endif //GLIBMM_PROPERTIES_ENABLED
- Gtk::ScrolledWindow* sw = Gtk::manage(new Gtk::ScrolledWindow()) ;
- sw->add(*_canvas) ;
- add(*sw) ;
+ Gtk::ScrolledWindow* sw = Gtk::manage(new Gtk::ScrolledWindow());
+ sw->add(*_canvas);
+ add(*sw);
- show_all_children() ;
+ show_all_children();
}
void
Window::on_item_created(const Glib::RefPtr<Goocanvas::Item>& item, const Glib::RefPtr<Goocanvas::ItemModel>& model)
{
- Glib::RefPtr<Goocanvas::Group> group = Glib::RefPtr<Goocanvas::Group>::cast_dynamic(item) ;
+ Glib::RefPtr<Goocanvas::Group> group = Glib::RefPtr<Goocanvas::Group>::cast_dynamic(item);
if(group) return ;
- item->signal_button_press_event().connect(sigc::mem_fun(*this, &Window::on_item_button_press_event)) ;
- item->signal_button_release_event().connect(sigc::mem_fun(*this, &Window::on_item_button_release_event)) ;
- item->signal_motion_notify_event().connect(sigc::mem_fun(*this, &Window::on_item_motion_notify_event)) ;
+ item->signal_button_press_event().connect(sigc::mem_fun(*this, &Window::on_item_button_press_event));
+ item->signal_button_release_event().connect(sigc::mem_fun(*this, &Window::on_item_button_release_event));
+ item->signal_motion_notify_event().connect(sigc::mem_fun(*this, &Window::on_item_motion_notify_event));
}
bool
@@ -82,7 +100,7 @@ Window::on_item_button_release_event(const Glib::RefPtr<Goocanvas::Item>& item,
{
if(event->button == 1)
{
- _dragging.clear() ;
+ _dragging.clear();
}
return false;
}
@@ -94,7 +112,7 @@ Window::on_item_motion_notify_event(const Glib::RefPtr<Goocanvas::Item>& item, G
{
double new_x = event->x ;
double new_y = event->y ;
- item->translate(new_x - _drag_x, new_y - _drag_y) ;
+ item->translate(new_x - _drag_x, new_y - _drag_y);
}
return false;
}
diff --git a/examples/simple/examplewindow.cc b/examples/simple/examplewindow.cc
index 5c9b1f6..658120c 100644
--- a/examples/simple/examplewindow.cc
+++ b/examples/simple/examplewindow.cc
@@ -29,17 +29,30 @@ ExampleWindow::ExampleWindow()
Glib::RefPtr<Goocanvas::Item> root = m_canvas.get_root_item();
Glib::RefPtr<Goocanvas::Rect> rect = Goocanvas::Rect::create(100, 100, 400, 400);
root->add_child(rect);
- rect->property_line_width().set_value(10.0);
- rect->property_radius_x().set_value(20.0);
- rect->property_radius_y().set_value(20.0);
- rect->property_stroke_color().set_value("yellow");
- rect->property_fill_color().set_value("red");
+
+#ifdef GLIBMM_PROPERTIES_ENABLED
+ rect->property_line_width() = 10.0;
+ rect->property_radius_x() = 20.0;
+ rect->property_radius_y() = 20.0;
+ rect->property_stroke_color() = "yellow";
+ rect->property_fill_color() = "red";
+#else
+ rect->set_property("line_width", 10.0);
+ rect->set_property("radius_x", 20.0);
+ rect->set_property("radius_y", 20.0);
+ rect->set_property("stroke_color", Glib::ustring("yellow"));
+ rect->set_property("fill_color", Glib::ustring("red"));
+#endif //GLIBMM_PROPERTIES_ENABLED
rect->signal_button_press_event ().connect (sigc::mem_fun (this,
- &ExampleWindow::on_rect_button_press));
+ &ExampleWindow::on_rect_button_press));
Glib::RefPtr<Goocanvas::Text> text = Goocanvas::Text::create("Hello World", 300, 300, -1, Gtk::ANCHOR_CENTER);
root->add_child(text);
- text->property_font().set_value("Sans 24");
+#ifdef GLIBMM_PROPERTIES_ENABLED
+ text->property_font() = "Sans 24");
+#else
+ text->set_property("font=", Glib::ustring("Sans 24"));
+#endif //GLIBMM_PROPERTIES_ENABLED
text->rotate(45, 300, 300);
Gtk::ScrolledWindow* sw = Gtk::manage(new Gtk::ScrolledWindow());
@@ -52,7 +65,7 @@ ExampleWindow::ExampleWindow()
bool
ExampleWindow::on_rect_button_press(const Glib::RefPtr<Goocanvas::Item>& item, GdkEventButton* event)
{
- std::cout << "You clicked the rectangle!" << std::endl ;
+ std::cout << "You clicked the rectangle." << std::endl ;
return true ;
}
diff --git a/examples/table/examplewindow.cc b/examples/table/examplewindow.cc
index 2c3419b..dc80d2b 100644
--- a/examples/table/examplewindow.cc
+++ b/examples/table/examplewindow.cc
@@ -32,12 +32,19 @@ ExampleWindow::ExampleWindow()
m_table = Goocanvas::Table::create();
//m_table->property_x() = 10;
//m_table->property_y() = 10;
+#ifdef GLIBMM_PROPERTIES_ENABLED
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;
+#else
+ m_table->set_property("height", 200);
+ m_table->set_property("width", 300);
+ m_table->set_property("column_spacing", 6);
+ m_table->set_property("row_spacing", 6);
+#endif
root->add_child(m_table);
add_text_to_cell(m_table, "top left", 0, 0);
diff --git a/examples/tablemodel/examplewindow.cc b/examples/tablemodel/examplewindow.cc
index ad41fe6..2503408 100644
--- a/examples/tablemodel/examplewindow.cc
+++ b/examples/tablemodel/examplewindow.cc
@@ -35,6 +35,7 @@ ExampleWindow::ExampleWindow()
m_second_canvas.set_root_item_model(root);
m_table = Goocanvas::TableModel::create();
+#ifdef GLIBMM_PROPERTIES_ENABLED
//m_table->property_x() = 10;
//m_table->property_y() = 10;
m_table->property_height() = 200;
@@ -43,6 +44,12 @@ ExampleWindow::ExampleWindow()
m_table->property_row_spacing() = 6;
//m_table->property_columns() = 2;
//m_table->property_row() = 2;
+#else
+ m_table->set_property("height", 200);
+ m_table->set_property("width", 300);
+ m_table->set_property("column_spacing", 6);
+ m_table->set_property("row_spacing", 6);
+#endif
root->add_child(m_table);
add_text_to_cell(m_table, "top left", 0, 0);
diff --git a/examples/text/window.cc b/examples/text/window.cc
index 67b9b51..8ae4a60 100644
--- a/examples/text/window.cc
+++ b/examples/text/window.cc
@@ -36,16 +36,27 @@ ExampleWindow::ExampleWindow()
m_label_origin.set_alignment(0.0, 0.5);
m_canvas.set_size_request(640, 480);
+#ifdef GLIBMM_PROPERTIES_ENABLED
m_canvas.property_units() = Gtk::UNIT_MM;
+#else
+ m_canvas.set_property("units", Gtk::UNIT_MM);
+#endif
m_canvas.set_bounds(0, 0, 210, 297);
Glib::RefPtr<Goocanvas::Item> root = m_canvas.get_root_item();
m_text = Goocanvas::Text::create("some text");
root->add_child(m_text);
+#ifdef GLIBMM_PROPERTIES_ENABLED
m_text->property_font() = "Sans 9";
m_text->property_line_width().set_value(10.0);
m_text->property_stroke_color().set_value("yellow");
m_text->property_fill_color().set_value("gray");
+#else
+ m_text->set_property("font", Glib::ustring("Sans 9"));
+ m_text->set_property("line_width", 10.0);
+ m_text->set_property("stroke_color", Glib::ustring("yellow"));
+ m_text->set_property("fill_color", Glib::ustring("gray"));
+#endif
Gtk::ScrolledWindow* sw = Gtk::manage(new Gtk::ScrolledWindow());
@@ -87,9 +98,14 @@ ExampleWindow::ExampleWindow()
void ExampleWindow::update_label()
{
std::stringstream str;
+
+#ifdef GLIBMM_PROPERTIES_ENABLED
str << "Rect: x=" << m_text->property_x() << ", y=" << m_text->property_y() <<
", width=" << m_text->property_width() << //", height=" << m_text->property_height() <<
", line_width=" << m_text->property_line_width() << std::endl;
+#else
+ //TODO:
+#endif
Goocanvas::Bounds bounds = m_text->get_bounds();
str << "Item bounds: x1=" << bounds.get_x1() << ", y1=" << bounds.get_y1() << ", x2=" << bounds.get_x2() << ", y2=" << bounds.get_y2() << std::endl;
@@ -107,8 +123,14 @@ void ExampleWindow::on_button_translate()
void ExampleWindow::on_button_setxy()
{
+#ifdef GLIBMM_PROPERTIES_ENABLED
m_text->property_x() = 50;
m_text->property_y() = 50;
+#else
+ m_text->set_property("x", 50);
+ m_text->set_property("y", 50);
+#endif
+
update_label();
}
@@ -126,13 +148,22 @@ void ExampleWindow::on_button_zoom_canvas()
void ExampleWindow::on_button_set_width()
{
+#ifdef GLIBMM_PROPERTIES_ENABLED
m_text->property_width() = 40;
+#else
+ m_text->set_property("width", 40);
+#endif
+
update_label();
}
void ExampleWindow::on_button_set_width_unlimited()
{
+#ifdef GLIBMM_PROPERTIES_ENABLED
m_text->property_width() = -1;
+#else
+ m_text->set_property("width", -1);
+#endif
update_label();
}
diff --git a/goocanvas/src/polyline.ccg b/goocanvas/src/polyline.ccg
index d71e4c8..6026b08 100644
--- a/goocanvas/src/polyline.ccg
+++ b/goocanvas/src/polyline.ccg
@@ -27,7 +27,11 @@ Polyline::Polyline(bool close_path, const Points& points )
:
_CONSTRUCT("close_path", close_path ? TRUE : FALSE)
{
+#ifdef GLIBMM_PROPERTIES_ENABLED
property_points() = points ;
+#else
+ set_property("points", points);
+#endif
}
Polyline::Polyline(double x1, double y1, double x2, double y2)
@@ -36,7 +40,12 @@ Polyline::Polyline(double x1, double y1, double x2, double y2)
{
double data[4] = {x1, y1, x2, y2};
Goocanvas::Points points(2, data);
- property_points() = points;
+
+#ifdef GLIBMM_PROPERTIES_ENABLED
+ property_points() = points ;
+#else
+ set_property("points", points);
+#endif
}
} //namespace Goocanvas
diff --git a/goocanvas/src/polylinemodel.ccg b/goocanvas/src/polylinemodel.ccg
index ab066d9..3ebc3be 100644
--- a/goocanvas/src/polylinemodel.ccg
+++ b/goocanvas/src/polylinemodel.ccg
@@ -27,7 +27,11 @@ PolylineModel::PolylineModel(bool close_path, const Points& points )
:
_CONSTRUCT("close_path", close_path ? TRUE : FALSE)
{
+#ifdef GLIBMM_PROPERTIES_ENABLED
property_points() = points ;
+#else
+ set_property("points", points);
+#endif
}
PolylineModel::PolylineModel(double x1, double y1, double x2, double y2)
@@ -36,7 +40,12 @@ PolylineModel::PolylineModel(double x1, double y1, double x2, double y2)
{
double data[4] = {x1, y1, x2, y2};
Goocanvas::Points points(2, data);
- property_points() = points;
+
+#ifdef GLIBMM_PROPERTIES_ENABLED
+ property_points() = points ;
+#else
+ set_property("points", points);
+#endif
}
} //namespace Goocanvas
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]