Re: how to clip? -> add example
- From: Klaus Rudolph <lts-rudolph gmx de>
- To: gtkmm-list gnome org
- Subject: Re: how to clip? -> add example
- Date: Fri, 22 Feb 2013 21:00:30 +0100
Hi again,
I try to draw a line inside a box. The line should not go outside the
box. But I could not find the clip methods :-(
The following example is ready to compile but did not work with clipping :-(
Any hints?
If it is not possible to clip with goocanvas, can give me someone a code
snippet to draw in any other way with gtkmm?
Is there any good actual gtkmm book?
Regards
Klaus
#include <iostream>
using namespace std;
#include <gtkmm.h>
#include <goocanvasmm.h>
int main(int argc, char* argv[])
{
Gtk::Main app(&argc, &argv);
Goocanvas::init("example", "0.1", argc, argv);
Gtk::Window win;
Goocanvas::Canvas m_canvas;
m_canvas.set_size_request(640, 480);
m_canvas.set_bounds(0, 0, 800, 800);
Glib::RefPtr<Goocanvas::Item> root = m_canvas.get_root_item();
//--------------------------------
Glib::RefPtr<Goocanvas::Rect> m_rect =
Goocanvas::Rect::create(40,40, 60, 60);
m_rect->property_line_width() = 1.0;
m_rect->property_stroke_color() = "black";
m_rect->property_fill_color() = "blue";
root->add_child( m_rect);
//--------------------------------
Glib::RefPtr<Goocanvas::Polyline> m_line =
Goocanvas::Polyline::create( 40,40,100,100);
m_line->property_line_width() = 10;
m_line->property_stroke_color() = "black";
root->add_child( m_line);
Gtk::ScrolledWindow* sw = Gtk::manage(new Gtk::ScrolledWindow());
sw->add(m_canvas);
win.add(*sw);
win.show_all_children();
Gtk::Main::run(win);
return 0;
}
Thanks
Klaus
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]