[gtkmm-documentation] Update the build for the latest gtkmm API.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm-documentation] Update the build for the latest gtkmm API.
- Date: Wed, 29 Sep 2010 09:19:57 +0000 (UTC)
commit abc9168a5fcf809af3bbe5e8f724be962282ea3c
Author: Murray Cumming <murrayc murrayc com>
Date: Wed Sep 29 11:19:48 2010 +0200
Update the build for the latest gtkmm API.
Use FileFilter via RefPtr.
Change expose_event handlers to draw handlers. This is untested and probably
incomplete.
ChangeLog | 8 +
.../book/custom/custom_container/mycontainer.cc | 4 +-
examples/book/custom/custom_widget/mywidget.cc | 80 ++++-----
examples/book/custom/custom_widget/mywidget.h | 2 +-
.../dialogs/filechooserdialog/examplewindow.cc | 22 ++--
examples/book/drawingarea/arcs/myarea.cc | 117 ++++++-------
examples/book/drawingarea/arcs/myarea.h | 2 +-
examples/book/drawingarea/clock/clock.cc | 179 +++++++++-----------
examples/book/drawingarea/clock/clock.h | 2 +-
examples/book/drawingarea/curve/myarea.cc | 67 ++++----
examples/book/drawingarea/curve/myarea.h | 2 +-
examples/book/drawingarea/joins/myarea.cc | 9 +-
examples/book/drawingarea/joins/myarea.h | 2 +-
examples/book/drawingarea/simple/myarea.cc | 52 +++----
examples/book/drawingarea/simple/myarea.h | 2 +-
examples/book/giomm/usage/usage.cc | 2 +-
examples/book/printing/advanced/previewdialog.cc | 12 +-
examples/book/printing/advanced/previewdialog.h | 4 +-
examples/book/range_widgets/examplewindow.cc | 35 ++--
examples/book/range_widgets/examplewindow.h | 2 +-
examples/book/spinbutton/examplewindow.cc | 12 +-
examples/book/spinbutton/examplewindow.h | 2 +-
examples/book/toolpalette/canvas.cc | 19 +--
examples/book/toolpalette/canvas.h | 2 +-
.../book/treeview/editable_cells/examplewindow.cc | 2 +-
.../others/cellrenderercustom/cellrendererpopup.cc | 4 +-
.../others/cellrenderercustom/cellrendererpopup.h | 2 +-
.../cellrenderercustom/cellrenderertoggle.cc | 59 +++----
examples/others/cellrenderercustom/popupentry.cc | 2 +-
29 files changed, 317 insertions(+), 392 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 00898f8..d6cf4cf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-09-29 Murray Cumming <murrayc murrayc com>
+
+ Update the build for the latest gtkmm API.
+
+ Use FileFilter via RefPtr.
+ Change expose_event handlers to draw handlers. This is untested and probably
+ incomplete.
+
2010-09-27 Murray Cumming <murrayc murrayc com>
Wrapping C Libraries with gmmproc: Fix a typo.
diff --git a/examples/book/custom/custom_container/mycontainer.cc b/examples/book/custom/custom_container/mycontainer.cc
index a9f85a4..6a67631 100644
--- a/examples/book/custom/custom_container/mycontainer.cc
+++ b/examples/book/custom/custom_container/mycontainer.cc
@@ -55,14 +55,14 @@ void MyContainer::on_size_request(Gtk::Requisition* requisition)
{
//TODO: Support natural-size properly:
Gtk::Requisition child_requisition_one_natural;
- m_child_one->get_size(child_requisition_one, child_requisition_one_natural);
+ m_child_one->get_preferred_size(child_requisition_one, child_requisition_one_natural);
}
if(m_child_two && m_child_two->get_visible())
{
//TODO: Support natural-size properly:
Gtk::Requisition child_requisition_two_natural;
- m_child_two->get_size(child_requisition_two, child_requisition_two_natural);
+ m_child_two->get_preferred_size(child_requisition_two, child_requisition_two_natural);
}
//See which one has the most width:
diff --git a/examples/book/custom/custom_widget/mywidget.cc b/examples/book/custom/custom_widget/mywidget.cc
index c08dcaa..fd3d0e9 100644
--- a/examples/book/custom/custom_widget/mywidget.cc
+++ b/examples/book/custom/custom_widget/mywidget.cc
@@ -39,9 +39,9 @@ MyWidget::MyWidget() :
//std::cout << "Gtype is a GtkWidget?:" << GTK_IS_WIDGET(gobj()) << std::endl;
//Install a style so that an aspect of this widget may be themed via an RC
- //file:
+ //file:
gtk_widget_class_install_style_property(GTK_WIDGET_CLASS(
- G_OBJECT_GET_CLASS(gobj())),
+ G_OBJECT_GET_CLASS(gobj())),
g_param_spec_int("example_scale",
"Scale of Example Drawing",
"The scale to use when drawing. This is just a silly example.",
@@ -107,7 +107,7 @@ void MyWidget::on_realize()
//Get the themed style from the RC file:
get_style_property("example_scale", m_scale);
std::cout << "m_scale (example_scale from the theme/rc-file) is: "
- << m_scale << std::endl;
+ << m_scale << std::endl;
if(!m_refGdkWindow)
{
@@ -124,7 +124,7 @@ void MyWidget::on_realize()
attributes.width = allocation.get_width();
attributes.height = allocation.get_height();
- attributes.event_mask = get_events () | Gdk::EXPOSURE_MASK;
+ attributes.event_mask = get_events () | Gdk::EXPOSURE_MASK;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.wclass = GDK_INPUT_OUTPUT;
@@ -151,48 +151,36 @@ void MyWidget::on_unrealize()
Gtk::Widget::on_unrealize();
}
-bool MyWidget::on_expose_event(GdkEventExpose* event)
+bool MyWidget::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
- if(m_refGdkWindow)
- {
- double scale_x = (double)get_allocation().get_width() / m_scale;
- double scale_y = (double)get_allocation().get_height() / m_scale;
-
- Cairo::RefPtr<Cairo::Context> cr = m_refGdkWindow->create_cairo_context();
- if(event)
- {
- // clip to the area that needs to be re-exposed so we don't draw any
- // more than we need to.
- cr->rectangle(event->area.x, event->area.y,
- event->area.width, event->area.height);
- cr->clip();
- }
-
- // paint the background
- Gdk::Cairo::set_source_color(cr, get_style()->get_bg(Gtk::STATE_NORMAL));
- cr->paint();
-
- // draw the foreground
- Gdk::Cairo::set_source_color(cr, get_style()->get_fg(Gtk::STATE_NORMAL));
- cr->move_to(155.*scale_x, 165.*scale_y);
- cr->line_to(155.*scale_x, 838.*scale_y);
- cr->line_to(265.*scale_x, 900.*scale_y);
- cr->line_to(849.*scale_x, 564.*scale_y);
- cr->line_to(849.*scale_x, 438.*scale_y);
- cr->line_to(265.*scale_x, 100.*scale_y);
- cr->line_to(155.*scale_x, 165.*scale_y);
- cr->move_to(265.*scale_x, 100.*scale_y);
- cr->line_to(265.*scale_x, 652.*scale_y);
- cr->line_to(526.*scale_x, 502.*scale_y);
- cr->move_to(369.*scale_x, 411.*scale_y);
- cr->line_to(633.*scale_x, 564.*scale_y);
- cr->move_to(369.*scale_x, 286.*scale_y);
- cr->line_to(369.*scale_x, 592.*scale_y);
- cr->move_to(369.*scale_x, 286.*scale_y);
- cr->line_to(849.*scale_x, 564.*scale_y);
- cr->move_to(633.*scale_x, 564.*scale_y);
- cr->line_to(155.*scale_x, 838.*scale_y);
- cr->stroke();
- }
+ const double scale_x = (double)get_allocation().get_width() / m_scale;
+ const double scale_y = (double)get_allocation().get_height() / m_scale;
+
+ // paint the background
+ Gdk::Cairo::set_source_color(cr, get_style()->get_bg(Gtk::STATE_NORMAL));
+ cr->paint();
+
+ // draw the foreground
+ Gdk::Cairo::set_source_color(cr, get_style()->get_fg(Gtk::STATE_NORMAL));
+ cr->move_to(155.*scale_x, 165.*scale_y);
+ cr->line_to(155.*scale_x, 838.*scale_y);
+ cr->line_to(265.*scale_x, 900.*scale_y);
+ cr->line_to(849.*scale_x, 564.*scale_y);
+ cr->line_to(849.*scale_x, 438.*scale_y);
+ cr->line_to(265.*scale_x, 100.*scale_y);
+ cr->line_to(155.*scale_x, 165.*scale_y);
+ cr->move_to(265.*scale_x, 100.*scale_y);
+ cr->line_to(265.*scale_x, 652.*scale_y);
+ cr->line_to(526.*scale_x, 502.*scale_y);
+ cr->move_to(369.*scale_x, 411.*scale_y);
+ cr->line_to(633.*scale_x, 564.*scale_y);
+ cr->move_to(369.*scale_x, 286.*scale_y);
+ cr->line_to(369.*scale_x, 592.*scale_y);
+ cr->move_to(369.*scale_x, 286.*scale_y);
+ cr->line_to(849.*scale_x, 564.*scale_y);
+ cr->move_to(633.*scale_x, 564.*scale_y);
+ cr->line_to(155.*scale_x, 838.*scale_y);
+ cr->stroke();
+
return true;
}
diff --git a/examples/book/custom/custom_widget/mywidget.h b/examples/book/custom/custom_widget/mywidget.h
index 7c080eb..92198f4 100644
--- a/examples/book/custom/custom_widget/mywidget.h
+++ b/examples/book/custom/custom_widget/mywidget.h
@@ -36,7 +36,7 @@ protected:
virtual void on_unmap();
virtual void on_realize();
virtual void on_unrealize();
- virtual bool on_expose_event(GdkEventExpose* event);
+ virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
Glib::RefPtr<Gdk::Window> m_refGdkWindow;
diff --git a/examples/book/dialogs/filechooserdialog/examplewindow.cc b/examples/book/dialogs/filechooserdialog/examplewindow.cc
index 1d41f81..6eafa6d 100644
--- a/examples/book/dialogs/filechooserdialog/examplewindow.cc
+++ b/examples/book/dialogs/filechooserdialog/examplewindow.cc
@@ -90,21 +90,21 @@ void ExampleWindow::on_button_file_clicked()
//Add filters, so that only certain file types can be selected:
- Gtk::FileFilter filter_text;
- filter_text.set_name("Text files");
- filter_text.add_mime_type("text/plain");
+ Glib::RefPtr<Gtk::FileFilter> filter_text = Gtk::FileFilter::create();
+ filter_text->set_name("Text files");
+ filter_text->add_mime_type("text/plain");
dialog.add_filter(filter_text);
- Gtk::FileFilter filter_cpp;
- filter_cpp.set_name("C/C++ files");
- filter_cpp.add_mime_type("text/x-c");
- filter_cpp.add_mime_type("text/x-c++");
- filter_cpp.add_mime_type("text/x-c-header");
+ Glib::RefPtr<Gtk::FileFilter> filter_cpp = Gtk::FileFilter::create();
+ filter_cpp->set_name("C/C++ files");
+ filter_cpp->add_mime_type("text/x-c");
+ filter_cpp->add_mime_type("text/x-c++");
+ filter_cpp->add_mime_type("text/x-c-header");
dialog.add_filter(filter_cpp);
- Gtk::FileFilter filter_any;
- filter_any.set_name("Any files");
- filter_any.add_pattern("*");
+ Glib::RefPtr<Gtk::FileFilter> filter_any = Gtk::FileFilter::create();
+ filter_any->set_name("Any files");
+ filter_any->add_pattern("*");
dialog.add_filter(filter_any);
//Show the dialog and wait for a user response:
diff --git a/examples/book/drawingarea/arcs/myarea.cc b/examples/book/drawingarea/arcs/myarea.cc
index e2fc79f..503bce8 100644
--- a/examples/book/drawingarea/arcs/myarea.cc
+++ b/examples/book/drawingarea/arcs/myarea.cc
@@ -28,72 +28,61 @@ MyArea::~MyArea()
{
}
-bool MyArea::on_expose_event(GdkEventExpose* event)
+bool MyArea::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
// This is where we draw on the window
- Glib::RefPtr<Gdk::Window> window = get_window();
- if(window)
- {
- Gtk::Allocation allocation = get_allocation();
- const int width = allocation.get_width();
- const int height = allocation.get_height();
- int lesser = MIN(width, height);
-
- // coordinates for the center of the window
- int xc, yc;
- xc = width / 2;
- yc = height / 2;
-
- Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
- cr->set_line_width(lesser * 0.02); // outline thickness changes
- // with window size
-
- // clip to the area indicated by the expose event so that we only redraw
- // the portion of the window that needs to be redrawn
- cr->rectangle(event->area.x, event->area.y,
- event->area.width, event->area.height);
- cr->clip();
-
- // first draw a simple unclosed arc
- cr->save();
- cr->arc(width / 3.0, height / 4.0, lesser / 4.0, -(M_PI / 5.0), M_PI);
- cr->close_path(); // line back to start point
- cr->set_source_rgb(0.0, 0.8, 0.0);
- cr->fill_preserve();
- cr->restore(); // back to opaque black
- cr->stroke(); // outline it
-
- // now draw a circle
- cr->save();
- cr->arc(xc, yc, lesser / 4.0, 0.0, 2.0 * M_PI); // full circle
- cr->set_source_rgba(0.0, 0.0, 0.8, 0.6); // partially translucent
- cr->fill_preserve();
- cr->restore(); // back to opaque black
- cr->stroke();
-
- // and finally an ellipse
- double ex, ey, ew, eh;
- // center of ellipse
- ex = xc;
- ey = 3.0 * height / 4.0;
- // ellipse dimensions
- ew = 3.0 * width / 4.0;
- eh = height / 3.0;
-
- cr->save();
-
- cr->translate(ex, ey); // make (ex, ey) == (0, 0)
- cr->scale(ew / 2.0, eh / 2.0); // for width: ew / 2.0 == 1.0
- // for height: eh / 2.0 == 1.0
-
- cr->arc(0.0, 0.0, 1.0, 0.0, 2 * M_PI); // 'circle' centered at (0, 0)
- // with 'radius' of 1.0
-
- cr->set_source_rgba(0.8, 0.0, 0.0, 0.7);
- cr->fill_preserve();
- cr->restore(); // back to opaque black
- cr->stroke();
- }
+ Gtk::Allocation allocation = get_allocation();
+ const int width = allocation.get_width();
+ const int height = allocation.get_height();
+ const int lesser = MIN(width, height);
+
+ // coordinates for the center of the window
+ int xc, yc;
+ xc = width / 2;
+ yc = height / 2;
+
+ cr->set_line_width(lesser * 0.02); // outline thickness changes
+ // with window size
+
+ // first draw a simple unclosed arc
+ cr->save();
+ cr->arc(width / 3.0, height / 4.0, lesser / 4.0, -(M_PI / 5.0), M_PI);
+ cr->close_path(); // line back to start point
+ cr->set_source_rgb(0.0, 0.8, 0.0);
+ cr->fill_preserve();
+ cr->restore(); // back to opaque black
+ cr->stroke(); // outline it
+
+ // now draw a circle
+ cr->save();
+ cr->arc(xc, yc, lesser / 4.0, 0.0, 2.0 * M_PI); // full circle
+ cr->set_source_rgba(0.0, 0.0, 0.8, 0.6); // partially translucent
+ cr->fill_preserve();
+ cr->restore(); // back to opaque black
+ cr->stroke();
+
+ // and finally an ellipse
+ double ex, ey, ew, eh;
+ // center of ellipse
+ ex = xc;
+ ey = 3.0 * height / 4.0;
+ // ellipse dimensions
+ ew = 3.0 * width / 4.0;
+ eh = height / 3.0;
+
+ cr->save();
+
+ cr->translate(ex, ey); // make (ex, ey) == (0, 0)
+ cr->scale(ew / 2.0, eh / 2.0); // for width: ew / 2.0 == 1.0
+ // for height: eh / 2.0 == 1.0
+
+ cr->arc(0.0, 0.0, 1.0, 0.0, 2 * M_PI); // 'circle' centered at (0, 0)
+ // with 'radius' of 1.0
+
+ cr->set_source_rgba(0.8, 0.0, 0.0, 0.7);
+ cr->fill_preserve();
+ cr->restore(); // back to opaque black
+ cr->stroke();
return true;
}
diff --git a/examples/book/drawingarea/arcs/myarea.h b/examples/book/drawingarea/arcs/myarea.h
index 684fc2e..3bbc877 100644
--- a/examples/book/drawingarea/arcs/myarea.h
+++ b/examples/book/drawingarea/arcs/myarea.h
@@ -29,7 +29,7 @@ public:
protected:
//Override default signal handler:
- virtual bool on_expose_event(GdkEventExpose* event);
+ virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
};
#endif // GTKMM_EXAMPLE_MYAREA_H
diff --git a/examples/book/drawingarea/clock/clock.cc b/examples/book/drawingarea/clock/clock.cc
index b0609d9..1b0b8bf 100644
--- a/examples/book/drawingarea/clock/clock.cc
+++ b/examples/book/drawingarea/clock/clock.cc
@@ -28,7 +28,7 @@ Clock::Clock()
#ifndef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
//Connect the signal handler if it isn't already a virtual method override:
- signal_expose_event().connect(sigc::mem_fun(*this, &Clock::on_expose_event), false);
+ signal_draw().connect(sigc::mem_fun(*this, &Clock::on_draw), false);
#endif //GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
}
@@ -36,113 +36,96 @@ Clock::~Clock()
{
}
-bool Clock::on_expose_event(GdkEventExpose* event)
+bool Clock::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
- // This is where we draw on the window
- Glib::RefPtr<Gdk::Window> window = get_window();
- if(window)
+ Gtk::Allocation allocation = get_allocation();
+ const int width = allocation.get_width();
+ const int height = allocation.get_height();
+
+ // scale to unit square and translate (0, 0) to be (0.5, 0.5), i.e.
+ // the center of the window
+ cr->scale(width, height);
+ cr->translate(0.5, 0.5);
+ cr->set_line_width(m_line_width);
+
+ cr->save();
+ cr->set_source_rgba(0.337, 0.612, 0.117, 0.9); // green
+ cr->paint();
+ cr->restore();
+ cr->arc(0, 0, m_radius, 0, 2 * M_PI);
+ cr->save();
+ cr->set_source_rgba(1.0, 1.0, 1.0, 0.8);
+ cr->fill_preserve();
+ cr->restore();
+ cr->stroke_preserve();
+ cr->clip();
+
+ //clock ticks
+ for (int i = 0; i < 12; i++)
{
- Gtk::Allocation allocation = get_allocation();
- const int width = allocation.get_width();
- const int height = allocation.get_height();
-
- Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
-
- if(event)
- {
- // clip to the area indicated by the expose event so that we only
- // redraw the portion of the window that needs to be redrawn
- cr->rectangle(event->area.x, event->area.y,
- event->area.width, event->area.height);
- cr->clip();
- }
-
- // scale to unit square and translate (0, 0) to be (0.5, 0.5), i.e.
- // the center of the window
- cr->scale(width, height);
- cr->translate(0.5, 0.5);
- cr->set_line_width(m_line_width);
-
- cr->save();
- cr->set_source_rgba(0.337, 0.612, 0.117, 0.9); // green
- cr->paint();
- cr->restore();
- cr->arc(0, 0, m_radius, 0, 2 * M_PI);
- cr->save();
- cr->set_source_rgba(1.0, 1.0, 1.0, 0.8);
- cr->fill_preserve();
- cr->restore();
- cr->stroke_preserve();
- cr->clip();
-
- //clock ticks
- for (int i = 0; i < 12; i++)
- {
- double inset = 0.05;
-
- cr->save();
- cr->set_line_cap(Cairo::LINE_CAP_ROUND);
-
- if(i % 3 != 0)
- {
- inset *= 0.8;
- cr->set_line_width(0.03);
- }
-
- cr->move_to(
- (m_radius - inset) * cos (i * M_PI / 6),
- (m_radius - inset) * sin (i * M_PI / 6));
- cr->line_to (
- m_radius * cos (i * M_PI / 6),
- m_radius * sin (i * M_PI / 6));
- cr->stroke();
- cr->restore(); /* stack-pen-size */
- }
-
- // store the current time
- time_t rawtime;
- time(&rawtime);
- struct tm * timeinfo = localtime (&rawtime);
-
- // compute the angles of the indicators of our clock
- double minutes = timeinfo->tm_min * M_PI / 30;
- double hours = timeinfo->tm_hour * M_PI / 6;
- double seconds= timeinfo->tm_sec * M_PI / 30;
+ double inset = 0.05;
cr->save();
cr->set_line_cap(Cairo::LINE_CAP_ROUND);
- // draw the seconds hand
- cr->save();
- cr->set_line_width(m_line_width / 3);
- cr->set_source_rgba(0.7, 0.7, 0.7, 0.8); // gray
- cr->move_to(0, 0);
- cr->line_to(sin(seconds) * (m_radius * 0.9),
- -cos(seconds) * (m_radius * 0.9));
- cr->stroke();
- cr->restore();
-
- // draw the minutes hand
- cr->set_source_rgba(0.117, 0.337, 0.612, 0.9); // blue
- cr->move_to(0, 0);
- cr->line_to(sin(minutes + seconds / 60) * (m_radius * 0.8),
- -cos(minutes + seconds / 60) * (m_radius * 0.8));
- cr->stroke();
+ if(i % 3 != 0)
+ {
+ inset *= 0.8;
+ cr->set_line_width(0.03);
+ }
- // draw the hours hand
- cr->set_source_rgba(0.337, 0.612, 0.117, 0.9); // green
- cr->move_to(0, 0);
- cr->line_to(sin(hours + minutes / 12.0) * (m_radius * 0.5),
- -cos(hours + minutes / 12.0) * (m_radius * 0.5));
+ cr->move_to(
+ (m_radius - inset) * cos (i * M_PI / 6),
+ (m_radius - inset) * sin (i * M_PI / 6));
+ cr->line_to (
+ m_radius * cos (i * M_PI / 6),
+ m_radius * sin (i * M_PI / 6));
cr->stroke();
- cr->restore();
-
- // draw a little dot in the middle
- cr->arc(0, 0, m_line_width / 3.0, 0, 2 * M_PI);
- cr->fill();
-
+ cr->restore(); /* stack-pen-size */
}
+ // store the current time
+ time_t rawtime;
+ time(&rawtime);
+ struct tm * timeinfo = localtime (&rawtime);
+
+ // compute the angles of the indicators of our clock
+ double minutes = timeinfo->tm_min * M_PI / 30;
+ double hours = timeinfo->tm_hour * M_PI / 6;
+ double seconds= timeinfo->tm_sec * M_PI / 30;
+
+ cr->save();
+ cr->set_line_cap(Cairo::LINE_CAP_ROUND);
+
+ // draw the seconds hand
+ cr->save();
+ cr->set_line_width(m_line_width / 3);
+ cr->set_source_rgba(0.7, 0.7, 0.7, 0.8); // gray
+ cr->move_to(0, 0);
+ cr->line_to(sin(seconds) * (m_radius * 0.9),
+ -cos(seconds) * (m_radius * 0.9));
+ cr->stroke();
+ cr->restore();
+
+ // draw the minutes hand
+ cr->set_source_rgba(0.117, 0.337, 0.612, 0.9); // blue
+ cr->move_to(0, 0);
+ cr->line_to(sin(minutes + seconds / 60) * (m_radius * 0.8),
+ -cos(minutes + seconds / 60) * (m_radius * 0.8));
+ cr->stroke();
+
+ // draw the hours hand
+ cr->set_source_rgba(0.337, 0.612, 0.117, 0.9); // green
+ cr->move_to(0, 0);
+ cr->line_to(sin(hours + minutes / 12.0) * (m_radius * 0.5),
+ -cos(hours + minutes / 12.0) * (m_radius * 0.5));
+ cr->stroke();
+ cr->restore();
+
+ // draw a little dot in the middle
+ cr->arc(0, 0, m_line_width / 3.0, 0, 2 * M_PI);
+ cr->fill();
+
return true;
}
diff --git a/examples/book/drawingarea/clock/clock.h b/examples/book/drawingarea/clock/clock.h
index 321a0e9..374bba4 100644
--- a/examples/book/drawingarea/clock/clock.h
+++ b/examples/book/drawingarea/clock/clock.h
@@ -29,7 +29,7 @@ public:
protected:
//Override default signal handler:
- virtual bool on_expose_event(GdkEventExpose* event);
+ virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
bool on_timeout();
diff --git a/examples/book/drawingarea/curve/myarea.cc b/examples/book/drawingarea/curve/myarea.cc
index e758b97..665ff16 100644
--- a/examples/book/drawingarea/curve/myarea.cc
+++ b/examples/book/drawingarea/curve/myarea.cc
@@ -27,44 +27,37 @@ MyArea::~MyArea()
{
}
-bool MyArea::on_expose_event(GdkEventExpose* event)
+bool MyArea::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
- // This is where we draw on the window
- Glib::RefPtr<Gdk::Window> window = get_window();
- if(window)
- {
- Gtk::Allocation allocation = get_allocation();
- const int width = allocation.get_width();
- const int height = allocation.get_height();
-
- double x0=0.1, y0=0.5, // start point
- x1=0.4, y1=0.9, // control point #1
- x2=0.6, y2=0.1, // control point #2
- x3=0.9, y3=0.5; // end point
-
- Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
- // clip to the area indicated by the expose event so that we only redraw
- // the portion of the window that needs to be redrawn
- cr->rectangle(event->area.x, event->area.y,
- event->area.width, event->area.height);
- cr->clip();
-
- // scale to unit square (0 to 1 with and height)
- cr->scale(width, height);
-
- cr->set_line_width(0.05);
- // draw curve
- cr->move_to(x0, y0);
- cr->curve_to(x1, y1, x2, y2, x3, y3);
- cr->stroke();
- // show control points
- cr->set_source_rgba(1, 0.2, 0.2, 0.6);
- cr->move_to(x0, y0);
- cr->line_to (x1, y1);
- cr->move_to(x2, y2);
- cr->line_to (x3, y3);
- cr->stroke();
- }
+ Gtk::Allocation allocation = get_allocation();
+ const int width = allocation.get_width();
+ const int height = allocation.get_height();
+
+ double x0=0.1, y0=0.5, // start point
+ x1=0.4, y1=0.9, // control point #1
+ x2=0.6, y2=0.1, // control point #2
+ x3=0.9, y3=0.5; // end point
+
+ // clip to the area indicated by the expose event so that we only redraw
+ // the portion of the window that needs to be redrawn
+ cr->rectangle(0, 0, width, height);
+ cr->clip();
+
+ // scale to unit square (0 to 1 with and height)
+ cr->scale(width, height);
+
+ cr->set_line_width(0.05);
+ // draw curve
+ cr->move_to(x0, y0);
+ cr->curve_to(x1, y1, x2, y2, x3, y3);
+ cr->stroke();
+ // show control points
+ cr->set_source_rgba(1, 0.2, 0.2, 0.6);
+ cr->move_to(x0, y0);
+ cr->line_to (x1, y1);
+ cr->move_to(x2, y2);
+ cr->line_to (x3, y3);
+ cr->stroke();
return true;
}
diff --git a/examples/book/drawingarea/curve/myarea.h b/examples/book/drawingarea/curve/myarea.h
index 684fc2e..3bbc877 100644
--- a/examples/book/drawingarea/curve/myarea.h
+++ b/examples/book/drawingarea/curve/myarea.h
@@ -29,7 +29,7 @@ public:
protected:
//Override default signal handler:
- virtual bool on_expose_event(GdkEventExpose* event);
+ virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
};
#endif // GTKMM_EXAMPLE_MYAREA_H
diff --git a/examples/book/drawingarea/joins/myarea.cc b/examples/book/drawingarea/joins/myarea.cc
index d421c18..bc4d43f 100644
--- a/examples/book/drawingarea/joins/myarea.cc
+++ b/examples/book/drawingarea/joins/myarea.cc
@@ -27,7 +27,7 @@ MyArea::~MyArea()
{
}
-bool MyArea::on_expose_event(GdkEventExpose* event)
+bool MyArea::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
// This is where we draw on the window
Glib::RefPtr<Gdk::Window> window = get_window();
@@ -42,15 +42,8 @@ bool MyArea::on_expose_event(GdkEventExpose* event)
xc = width / 2;
yc = height / 2;
- Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
cr->set_line_width(10.0);
- // clip to the area indicated by the expose event so that we only redraw
- // the portion of the window that needs to be redrawn
- cr->rectangle(event->area.x, event->area.y,
- event->area.width, event->area.height);
- cr->clip();
-
cr->scale(width, height);
cr->save();
cr->set_source_rgb(1, 1, 1);
diff --git a/examples/book/drawingarea/joins/myarea.h b/examples/book/drawingarea/joins/myarea.h
index 684fc2e..3bbc877 100644
--- a/examples/book/drawingarea/joins/myarea.h
+++ b/examples/book/drawingarea/joins/myarea.h
@@ -29,7 +29,7 @@ public:
protected:
//Override default signal handler:
- virtual bool on_expose_event(GdkEventExpose* event);
+ virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
};
#endif // GTKMM_EXAMPLE_MYAREA_H
diff --git a/examples/book/drawingarea/simple/myarea.cc b/examples/book/drawingarea/simple/myarea.cc
index 088c07d..99d1ee2 100644
--- a/examples/book/drawingarea/simple/myarea.cc
+++ b/examples/book/drawingarea/simple/myarea.cc
@@ -27,39 +27,27 @@ MyArea::~MyArea()
{
}
-bool MyArea::on_expose_event(GdkEventExpose* event)
+bool MyArea::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
- // This is where we draw on the window
- Glib::RefPtr<Gdk::Window> window = get_window();
- if(window)
- {
- Gtk::Allocation allocation = get_allocation();
- const int width = allocation.get_width();
- const int height = allocation.get_height();
-
- // coordinates for the center of the window
- int xc, yc;
- xc = width / 2;
- yc = height / 2;
-
- Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
- cr->set_line_width(10.0);
-
- // clip to the area indicated by the expose event so that we only redraw
- // the portion of the window that needs to be redrawn
- cr->rectangle(event->area.x, event->area.y,
- event->area.width, event->area.height);
- cr->clip();
-
- // draw red lines out from the center of the window
- cr->set_source_rgb(0.8, 0.0, 0.0);
- cr->move_to(0, 0);
- cr->line_to(xc, yc);
- cr->line_to(0, height);
- cr->move_to(xc, yc);
- cr->line_to(width, yc);
- cr->stroke();
- }
+ Gtk::Allocation allocation = get_allocation();
+ const int width = allocation.get_width();
+ const int height = allocation.get_height();
+
+ // coordinates for the center of the window
+ int xc, yc;
+ xc = width / 2;
+ yc = height / 2;
+
+ cr->set_line_width(10.0);
+
+ // draw red lines out from the center of the window
+ cr->set_source_rgb(0.8, 0.0, 0.0);
+ cr->move_to(0, 0);
+ cr->line_to(xc, yc);
+ cr->line_to(0, height);
+ cr->move_to(xc, yc);
+ cr->line_to(width, yc);
+ cr->stroke();
return true;
}
diff --git a/examples/book/drawingarea/simple/myarea.h b/examples/book/drawingarea/simple/myarea.h
index 684fc2e..3bbc877 100644
--- a/examples/book/drawingarea/simple/myarea.h
+++ b/examples/book/drawingarea/simple/myarea.h
@@ -29,7 +29,7 @@ public:
protected:
//Override default signal handler:
- virtual bool on_expose_event(GdkEventExpose* event);
+ virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
};
#endif // GTKMM_EXAMPLE_MYAREA_H
diff --git a/examples/book/giomm/usage/usage.cc b/examples/book/giomm/usage/usage.cc
index a7a2d4f..67f856a 100644
--- a/examples/book/giomm/usage/usage.cc
+++ b/examples/book/giomm/usage/usage.cc
@@ -21,7 +21,7 @@
#include <giomm.h>
#include <iostream>
-goffset get_size_recursively(const Glib::RefPtr<Gio::File>& file)
+static goffset get_size_recursively(const Glib::RefPtr<Gio::File>& file)
{
goffset total = 0;
g_return_val_if_fail(file, total);
diff --git a/examples/book/printing/advanced/previewdialog.cc b/examples/book/printing/advanced/previewdialog.cc
index 5e438f9..aee1ac4 100644
--- a/examples/book/printing/advanced/previewdialog.cc
+++ b/examples/book/printing/advanced/previewdialog.cc
@@ -28,7 +28,7 @@ PreviewDialog::PreviewDialog(
m_pOperation(pfo),
m_refPreview(preview),
m_refPrintContext(print_ctx),
- m_SpinAdjustment(1, 100, 1), //Used to construct m_PageSpin
+ m_SpinAdjustment( Gtk::Adjustment::create(1, 100, 1) ), //Used to construct m_PageSpin
m_PageSpin(m_SpinAdjustment, 1, 0),
m_CloseButton(Gtk::Stock::CLOSE),
m_Page(1),
@@ -59,8 +59,8 @@ PreviewDialog::PreviewDialog(
m_DrawingArea.signal_realize().connect(
sigc::mem_fun(*this, &PreviewDialog::on_drawing_area_realized));
- m_DrawingArea.signal_expose_event().connect(
- sigc::mem_fun(*this, &PreviewDialog::on_drawing_area_expose_event));
+ m_DrawingArea.signal_draw().connect(
+ sigc::mem_fun(*this, &PreviewDialog::on_drawing_area_draw));
m_CloseButton.signal_clicked().connect(
sigc::mem_fun(*this, &PreviewDialog::on_close_clicked));
@@ -94,11 +94,13 @@ void PreviewDialog::on_page_number_changed()
m_DrawingArea.queue_draw();
}
-bool PreviewDialog::on_drawing_area_expose_event(GdkEventExpose* /* event */)
+bool PreviewDialog::on_drawing_area_draw(const Cairo::RefPtr<Cairo::Context>& /* cr */)
{
+ /* TODO: Do this with cairo?
Glib::RefPtr<Gdk::Window> window = m_DrawingArea.get_window();
if(window)
window->clear();
+ */
if(m_refPreview)
m_refPreview->render_page(m_Page - 1);
@@ -155,7 +157,7 @@ void PreviewDialog::on_hide()
//We will not be using these anymore, so null the RefPtrs:
m_refPreview.clear();
- m_refPrintContext.clear();
+ m_refPrintContext.clear();
}
void PreviewDialog::on_close_clicked()
diff --git a/examples/book/printing/advanced/previewdialog.h b/examples/book/printing/advanced/previewdialog.h
index 434d100..cb93b58 100644
--- a/examples/book/printing/advanced/previewdialog.h
+++ b/examples/book/printing/advanced/previewdialog.h
@@ -35,7 +35,7 @@ protected:
void on_close_clicked();
virtual void on_hide();
- virtual bool on_drawing_area_expose_event(GdkEventExpose* event);
+ virtual bool on_drawing_area_draw(const Cairo::RefPtr<Cairo::Context>& cr);
//PrintOperationPreview signal handlers:
void on_popreview_ready(const Glib::RefPtr<Gtk::PrintContext>& print_ctx);
@@ -49,7 +49,7 @@ protected:
Gtk::VBox m_VBox;
Gtk::HBox m_HBox;
- Gtk::Adjustment m_SpinAdjustment;
+ Glib::RefPtr<Gtk::Adjustment> m_SpinAdjustment;
Gtk::SpinButton m_PageSpin;
Gtk::Button m_CloseButton;
Gtk::DrawingArea m_DrawingArea;
diff --git a/examples/book/range_widgets/examplewindow.cc b/examples/book/range_widgets/examplewindow.cc
index 93b51ae..332f140 100644
--- a/examples/book/range_widgets/examplewindow.cc
+++ b/examples/book/range_widgets/examplewindow.cc
@@ -32,9 +32,9 @@ ExampleWindow::ExampleWindow()
// Note that the page_size value only makes a difference for
// scrollbar widgets, and the highest value you'll get is actually
// (upper - page_size).
- m_adjustment(0.0, 0.0, 101.0, 0.1, 1.0, 1.0),
- m_adjustment_digits(1.0, 0.0, 5.0),
- m_adjustment_pagesize(1.0, 1.0, 101.0),
+ m_adjustment( Gtk::Adjustment::create(0.0, 0.0, 101.0, 0.1, 1.0, 1.0) ),
+ m_adjustment_digits( Gtk::Adjustment::create(1.0, 0.0, 5.0) ),
+ m_adjustment_pagesize( Gtk::Adjustment::create(1.0, 1.0, 101.0) ),
m_VScale(m_adjustment),
m_HScale(m_adjustment),
@@ -45,7 +45,7 @@ ExampleWindow::ExampleWindow()
m_CheckButton("Display value on scale widgets", 0),
// Reuse the same adjustment again.
- // Notice how this causes the scales to always be updated
+ // Notice how this causes the scales to always be updated
// continuously when the scrollbar is moved.
m_Scrollbar(m_adjustment),
@@ -93,25 +93,25 @@ ExampleWindow::ExampleWindow()
sigc::bind(sigc::mem_fun(*this,
&ExampleWindow::on_menu_position), Gtk::POS_TOP));
m_Menu_Position.append(*item);
-
+
item = Gtk::manage(new Gtk::MenuItem("Bottom"));
item->signal_activate().connect(
sigc::bind(sigc::mem_fun(*this,
&ExampleWindow::on_menu_position), Gtk::POS_BOTTOM));
m_Menu_Position.append(*item);
-
+
item = Gtk::manage(new Gtk::MenuItem("Left"));
item->signal_activate().connect(
sigc::bind(sigc::mem_fun(*this,
&ExampleWindow::on_menu_position), Gtk::POS_LEFT));
m_Menu_Position.append(*item);
-
+
item = Gtk::manage(new Gtk::MenuItem("Right"));
item->signal_activate().connect(
sigc::bind(sigc::mem_fun(*this,
&ExampleWindow::on_menu_position), Gtk::POS_RIGHT));
m_Menu_Position.append(*item);
-
+
m_VBox2.pack_start(
*Gtk::manage(new LabeledOptionMenu("Scale Value Position:",
m_Menu_Position)));
@@ -122,13 +122,13 @@ ExampleWindow::ExampleWindow()
sigc::bind(sigc::mem_fun(*this,
&ExampleWindow::on_menu_policy), Gtk::UPDATE_CONTINUOUS));
m_Menu_Policy.append(*item);
-
+
item = Gtk::manage(new Gtk::MenuItem("Discontinuous"));
item->signal_activate().connect(
sigc::bind(sigc::mem_fun(*this,
&ExampleWindow::on_menu_policy), Gtk::UPDATE_DISCONTINUOUS));
m_Menu_Policy.append(*item);
-
+
item = Gtk::manage(new Gtk::MenuItem("Delayed"));
item->signal_activate().connect(
sigc::bind(sigc::mem_fun(*this,
@@ -143,7 +143,7 @@ ExampleWindow::ExampleWindow()
m_HBox_Digits.pack_start(
*Gtk::manage(new Gtk::Label("Scale Digits:", 0)), Gtk::PACK_SHRINK);
m_Scale_Digits.set_digits(0);
- m_adjustment_digits.signal_value_changed().connect(sigc::mem_fun(*this,
+ m_adjustment_digits->signal_value_changed().connect(sigc::mem_fun(*this,
&ExampleWindow::on_adjustment1_value_changed));
m_HBox_Digits.pack_start(m_Scale_Digits);
@@ -152,7 +152,7 @@ ExampleWindow::ExampleWindow()
*Gtk::manage(new Gtk::Label("Scrollbar Page Size:", 0)),
Gtk::PACK_SHRINK);
m_Scale_PageSize.set_digits(0);
- m_adjustment_pagesize.signal_value_changed().connect(sigc::mem_fun(*this,
+ m_adjustment_pagesize->signal_value_changed().connect(sigc::mem_fun(*this,
&ExampleWindow::on_adjustment2_value_changed));
m_HBox_PageSize.pack_start(m_Scale_PageSize);
@@ -194,18 +194,18 @@ void ExampleWindow::on_menu_policy(Gtk::UpdateType type)
void ExampleWindow::on_adjustment1_value_changed()
{
- double val = m_adjustment_digits.get_value();
+ const double val = m_adjustment_digits->get_value();
m_VScale.set_digits((int)val);
m_HScale.set_digits((int)val);
}
void ExampleWindow::on_adjustment2_value_changed()
{
- double val = m_adjustment_pagesize.get_value();
- m_adjustment.set_page_size(val);
- m_adjustment.set_page_increment(val);
+ const double val = m_adjustment_pagesize->get_value();
+ m_adjustment->set_page_size(val);
+ m_adjustment->set_page_increment(val);
- // Note that we don't have to emit the "changed" signal
+ // Note that we don't have to emit the "changed" signal
// because gtkmm does this for us.
}
@@ -213,4 +213,3 @@ void ExampleWindow::on_button_quit()
{
hide();
}
-
diff --git a/examples/book/range_widgets/examplewindow.h b/examples/book/range_widgets/examplewindow.h
index b00ee63..511a9b5 100644
--- a/examples/book/range_widgets/examplewindow.h
+++ b/examples/book/range_widgets/examplewindow.h
@@ -40,7 +40,7 @@ protected:
Gtk::VBox m_VBox_Top, m_VBox2, m_VBox_HScale;
Gtk::HBox m_HBox_Scales, m_HBox_Digits, m_HBox_PageSize;
- Gtk::Adjustment m_adjustment, m_adjustment_digits, m_adjustment_pagesize;
+ Glib::RefPtr<Gtk::Adjustment> m_adjustment, m_adjustment_digits, m_adjustment_pagesize;
Gtk::VScale m_VScale;
Gtk::HScale m_HScale, m_Scale_Digits, m_Scale_PageSize;
diff --git a/examples/book/spinbutton/examplewindow.cc b/examples/book/spinbutton/examplewindow.cc
index adbb139..ce20696 100644
--- a/examples/book/spinbutton/examplewindow.cc
+++ b/examples/book/spinbutton/examplewindow.cc
@@ -30,11 +30,11 @@ ExampleWindow::ExampleWindow()
m_Label_Year("Year: "),
m_Label_Value("Value: "),
m_Label_Digits("Digits: "),
- m_adjustment_day(1.0, 1.0, 31.0, 1.0, 5.0, 0.0),
- m_adjustment_month(1.0, 1.0, 12.0, 1.0, 5.0, 0.0),
- m_adjustment_year(1998.0, 0.0, 2100.0, 1.0, 100.0, 0.0),
- m_adjustment_value(0.0, -10000.0, 10000.0, 0.5, 100.0, 0.0),
- m_adjustment_digits(2.0, 1.0, 5.0, 1.0, 1.0, 0.0),
+ m_adjustment_day( Gtk::Adjustment::create(1.0, 1.0, 31.0, 1.0, 5.0, 0.0) ),
+ m_adjustment_month( Gtk::Adjustment::create(1.0, 1.0, 12.0, 1.0, 5.0, 0.0) ),
+ m_adjustment_year( Gtk::Adjustment::create(1998.0, 0.0, 2100.0, 1.0, 100.0, 0.0) ),
+ m_adjustment_value( Gtk::Adjustment::create(0.0, -10000.0, 10000.0, 0.5, 100.0, 0.0) ),
+ m_adjustment_digits( Gtk::Adjustment::create(2.0, 1.0, 5.0, 1.0, 1.0, 0.0) ),
m_SpinButton_Day(m_adjustment_day),
m_SpinButton_Month(m_adjustment_month),
m_SpinButton_Year(m_adjustment_year),
@@ -109,7 +109,7 @@ ExampleWindow::ExampleWindow()
m_VBox_Digits.pack_start(m_Label_Digits);
m_SpinButton_Digits.set_wrap();
- m_adjustment_digits.signal_value_changed().connect( sigc::mem_fun(*this,
+ m_adjustment_digits->signal_value_changed().connect( sigc::mem_fun(*this,
&ExampleWindow::on_spinbutton_digits_changed) );
m_VBox_Digits.pack_start(m_SpinButton_Digits);
diff --git a/examples/book/spinbutton/examplewindow.h b/examples/book/spinbutton/examplewindow.h
index 23b6949..9ba05a5 100644
--- a/examples/book/spinbutton/examplewindow.h
+++ b/examples/book/spinbutton/examplewindow.h
@@ -50,7 +50,7 @@ protected:
Gtk::Label m_Label_Day, m_Label_Month, m_Label_Year,
m_Label_Value, m_Label_Digits,
m_Label_ShowValue;
- Gtk::Adjustment m_adjustment_day, m_adjustment_month, m_adjustment_year,
+ Glib::RefPtr<Gtk::Adjustment> m_adjustment_day, m_adjustment_month, m_adjustment_year,
m_adjustment_value, m_adjustment_digits;
Gtk::SpinButton m_SpinButton_Day, m_SpinButton_Month, m_SpinButton_Year,
m_SpinButton_Value, m_SpinButton_Digits;
diff --git a/examples/book/toolpalette/canvas.cc b/examples/book/toolpalette/canvas.cc
index 8a69d7a..32df7f9 100644
--- a/examples/book/toolpalette/canvas.cc
+++ b/examples/book/toolpalette/canvas.cc
@@ -60,19 +60,8 @@ void Canvas::item_draw(const CanvasItem *item,
cr->paint();
}
-bool Canvas::on_expose_event(GdkEventExpose* event)
+bool Canvas::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
- // This is where we draw on the window
- Glib::RefPtr<Gdk::Window> window = get_window();
- if(!window)
- return false;
-
- Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
- const Cairo::RefPtr<Cairo::Region> region =
- Cairo::RefPtr<Cairo::Region>(new Cairo::Region(event->region, true /* take ref */));
- Gdk::Cairo::add_region_to_path(cr, region);
- cr->clip();
-
cr->set_source_rgb(1.0, 1.0, 1.0);
const Gtk::Allocation allocation = get_allocation();
cr->rectangle(0, 0, allocation.get_width(), allocation.get_height());
@@ -97,7 +86,7 @@ bool Canvas::on_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context,
m_drag_data_requested_for_drop = false; //It's for drag-motion instead.
if(m_drop_item)
- {
+ {
// We already have a drop indicator so just update its position.
m_drop_item->x = x;
@@ -155,7 +144,7 @@ void Canvas::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context
if(m_drag_data_requested_for_drop)
{
m_canvas_items.push_back(item);
-
+
// Signal that the item was accepted and then redraw.
context->drag_finish(true /* success */, false /* del */, time);
}
@@ -165,7 +154,7 @@ void Canvas::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context
// We are getting this data due to a request in drag_motion,
// rather than due to a request in drag_drop, so we are just
- // supposed to call gdk_drag_status (), not actually paste in
+ // supposed to call gdk_drag_status (), not actually paste in
// the data.
context->drag_status(Gdk::ACTION_COPY, time);
}
diff --git a/examples/book/toolpalette/canvas.h b/examples/book/toolpalette/canvas.h
index 0997fe6..2cce137 100644
--- a/examples/book/toolpalette/canvas.h
+++ b/examples/book/toolpalette/canvas.h
@@ -51,7 +51,7 @@ private:
const Cairo::RefPtr<Cairo::Context>& cr,
bool preview);
- virtual bool on_expose_event(GdkEventExpose* event);
+ virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
virtual void on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context,
int x, int y, const Gtk::SelectionData& selection_data, guint info, guint time);
virtual bool on_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time);
diff --git a/examples/book/treeview/editable_cells/examplewindow.cc b/examples/book/treeview/editable_cells/examplewindow.cc
index 0658eb8..e7527c1 100644
--- a/examples/book/treeview/editable_cells/examplewindow.cc
+++ b/examples/book/treeview/editable_cells/examplewindow.cc
@@ -107,7 +107,7 @@ ExampleWindow::ExampleWindow()
&ExampleWindow::cellrenderer_validated_on_edited) );
//If this was a CellRendererSpin then you would have to set the adjustment:
- //m_cellrenderer_validated.property_adjustment() = &m_spin_adjustment;
+ //m_cellrenderer_validated.property_adjustment() = m_spin_adjustment;
show_all_children();
}
diff --git a/examples/others/cellrenderercustom/cellrendererpopup.cc b/examples/others/cellrenderercustom/cellrendererpopup.cc
index 627dfe5..5eda435 100644
--- a/examples/others/cellrenderercustom/cellrendererpopup.cc
+++ b/examples/others/cellrenderercustom/cellrendererpopup.cc
@@ -103,12 +103,12 @@ void CellRendererPopup::hide_popup()
//TODO: Port this to gtkmm 3:
/*
-void CellRendererPopup::get_size_vfunc(Gtk::Widget& widget,
+void CellRendererPopup::get_preferred_size_vfunc(Gtk::Widget& widget,
const Gdk::Rectangle* cell_area,
int* x_offset, int* y_offset,
int* width, int* height) const
{
- Gtk::CellRendererText::get_size_vfunc(widget, cell_area, x_offset, y_offset, width, height);
+ Gtk::CellRendererText::get_preferred_size_vfunc(widget, cell_area, x_offset, y_offset, width, height);
// We cache this because it takes a really long time to get the width.
if(button_width_ < 0)
diff --git a/examples/others/cellrenderercustom/cellrendererpopup.h b/examples/others/cellrenderercustom/cellrendererpopup.h
index db8d47f..219c701 100644
--- a/examples/others/cellrenderercustom/cellrendererpopup.h
+++ b/examples/others/cellrenderercustom/cellrendererpopup.h
@@ -47,7 +47,7 @@ protected:
//TODO: Port this to gtkmm 3:
/*
- virtual void get_size_vfunc(Gtk::Widget& widget,
+ virtual void get_preferred_size_vfunc(Gtk::Widget& widget,
const Gdk::Rectangle* cell_area,
int* x_offset, int* y_offset,
int* width, int* height) const;
diff --git a/examples/others/cellrenderercustom/cellrenderertoggle.cc b/examples/others/cellrenderercustom/cellrenderertoggle.cc
index 9ab5b1e..9aba27c 100644
--- a/examples/others/cellrenderercustom/cellrenderertoggle.cc
+++ b/examples/others/cellrenderercustom/cellrenderertoggle.cc
@@ -42,17 +42,16 @@ public:
SignalToggled& signal_toggled();
protected:
- virtual void get_size_vfunc(Gtk::Widget& widget,
+ virtual void get_preferred_size_vfunc(Gtk::Widget& widget,
const Gdk::Rectangle* cell_area,
int* x_offset, int* y_offset,
int* width, int* height) const;
- virtual void render_vfunc(const Glib::RefPtr<Gdk::Drawable>& window,
+ virtual void render_vfunc(const Cairo::RefPtr<Cairo::Context>& cr,
Gtk::Widget& widget,
const Gdk::Rectangle& background_area,
const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle& expose_area,
- Gtk::CellRendererState flags);
+ Gtk::CellRendererState flag);
virtual bool activate_vfunc(GdkEvent* event,
Gtk::Widget& widget,
@@ -130,7 +129,7 @@ MyCellRendererToggle::SignalToggled& MyCellRendererToggle::signal_toggled()
return signal_toggled_;
}
-void MyCellRendererToggle::get_size_vfunc(Gtk::Widget&,
+void MyCellRendererToggle::get_preferred_size_vfunc(Gtk::Widget&,
const Gdk::Rectangle* cell_area,
int* x_offset, int* y_offset,
int* width, int* height) const
@@ -167,12 +166,11 @@ void MyCellRendererToggle::get_size_vfunc(Gtk::Widget&,
}
}
-void MyCellRendererToggle::render_vfunc(const Glib::RefPtr<Gdk::Drawable>& window,
- Gtk::Widget& widget,
- const Gdk::Rectangle&,
- const Gdk::Rectangle& cell_area,
- const Gdk::Rectangle&,
- Gtk::CellRendererState flags)
+void MyCellRendererToggle::render_vfunc(const Cairo::RefPtr<Cairo::Context>& cr,
+ Gtk::Widget& widget,
+ const Gdk::Rectangle& /* background_area */,
+ const Gdk::Rectangle& cell_area,
+ Gtk::CellRendererState flags)
{
const unsigned int cell_xpad = property_xpad();
const unsigned int cell_ypad = property_ypad();
@@ -182,7 +180,7 @@ void MyCellRendererToggle::render_vfunc(const Glib::RefPtr<Gdk::Drawable>& windo
//TODO: Support natural size.
GtkRequisition requisition_min, requisition_natural;
- get_size(widget, requisition_min, requisition_natural);
+ get_preferred_size(widget, requisition_min, requisition_natural);
width = requisition_min.width;
height = requisition_min.height;
@@ -202,28 +200,23 @@ void MyCellRendererToggle::render_vfunc(const Glib::RefPtr<Gdk::Drawable>& windo
const Gtk::ShadowType shadow = (property_active_) ? Gtk::SHADOW_IN : Gtk::SHADOW_OUT;
- //Cast the drawable to a Window. TODO: Maybe paint_option() should take a Drawable? murrayc.
- Glib::RefPtr<Gdk::Window> window_casted = Glib::RefPtr<Gdk::Window>::cast_dynamic<>(window);
- if(window_casted)
+ if(property_radio_)
{
- if(property_radio_)
- {
- widget.get_style()->paint_option(
- window_casted, state, shadow,
- cell_area, widget, "cellradio",
- cell_area.get_x() + cell_xpad,
- cell_area.get_y() + cell_ypad,
- width - 1, height - 1);
- }
- else
- {
- widget.get_style()->paint_check(
- window_casted, state, shadow,
- cell_area, widget, "cellcheck",
- cell_area.get_x() + cell_xpad,
- cell_area.get_y() + cell_ypad,
- width - 1, height - 1);
- }
+ widget.get_style()->paint_option(
+ cr, state, shadow,
+ widget, "cellradio",
+ cell_area.get_x() + cell_xpad,
+ cell_area.get_y() + cell_ypad,
+ width - 1, height - 1);
+ }
+ else
+ {
+ widget.get_style()->paint_check(
+ cr, state, shadow,
+ widget, "cellcheck",
+ cell_area.get_x() + cell_xpad,
+ cell_area.get_y() + cell_ypad,
+ width - 1, height - 1);
}
}
diff --git a/examples/others/cellrenderercustom/popupentry.cc b/examples/others/cellrenderercustom/popupentry.cc
index 8d83fb0..c02634f 100644
--- a/examples/others/cellrenderercustom/popupentry.cc
+++ b/examples/others/cellrenderercustom/popupentry.cc
@@ -93,7 +93,7 @@ int PopupEntry::get_button_width()
//TODO: Support natural-size:
Gtk::Requisition requisition_min, requisition_natural;
- window.Gtk::SizeRequest::get_size(requisition_min, requisition_natural);
+ window.get_preferred_size(requisition_min, requisition_natural);
return requisition_min.width;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]