Attachment 'diagonals.cpp'

Download

   1 
   2 #include <gtkmm.h>
   3 #include <boost/lambda/bind.hpp>
   4 #include <mlib/sigc.h>
   5 
   6 namespace bl = boost::lambda;
   7 
   8 bool DrawDiagonals(Gtk::DrawingArea& da)
   9 {
  10     int wdh = da.get_width(), hgt = da.get_height();
  11     Cairo::RefPtr<Cairo::Context> cr = da.get_window()->create_cairo_context();
  12 
  13     cr->move_to(0, 0);
  14     cr->line_to(wdh, hgt);
  15     cr->stroke();
  16 
  17     cr->move_to(wdh, 0);
  18     cr->line_to(0, hgt);
  19     cr->stroke();
  20 
  21     return true;
  22 }
  23 
  24 int main(int argc, char* argv[])
  25 {
  26     Gtk::Main kit(argc, argv);
  27 
  28     Gtk::DrawingArea da;
  29     da.signal_expose_event().connect( wrap_return<bool>(bl::bind(&DrawDiagonals, boost::ref(da))) );
  30 
  31     Gtk::Window win;
  32     win.add(da);
  33 
  34     win.show_all();
  35     Gtk::Main::run(win);
  36     return 0;
  37 }
  38 

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.
  • [get | view] (2011-11-10 21:19:09, 4.5 KB) [[attachment:Diagonals.png]]
  • [get | view] (2011-11-10 21:19:09, 0.7 KB) [[attachment:diagonals.cpp]]

You are not allowed to attach a file to this page.