Still not really comfortable (2)

This is better.

I did not notice the difference between the two; sigc::ptr_fun() generates a slot for a standalone function or static method. sigc::mem_fun() generates a slot for a member method of a particular instance.

So it’s another RTFM as it always happens to me.

/* MyWindow.cpp */

#include "MyWindow.h"
#include "MyArea.h"
#include <gtkmm.h>

MyWindow::MyWindow() : m_box(Gtk::ORIENTATION_VERTICAL), m_buttons(Gtk::ORIENTATION_HORIZONTAL),
		m_button1("_reset", true), m_button2("_shrink", true), m_button3("_left", true),
		m_button4("righ_t", true), m_button5("_up"    , true), m_button6("_down", true) {
	set_title("Test test...");
	set_default_size(300, 329);
	set_border_width(10);
	add(m_box);
	m_box.pack_start(m_buttons, false, true);
	m_buttons.pack_start(m_button1, true, true);
	m_buttons.pack_start(m_button2, true, true);
	m_buttons.pack_start(m_button3, true, true);
	m_buttons.pack_start(m_button4, true, true);
	m_buttons.pack_start(m_button5, true, true);
	m_buttons.pack_start(m_button6, true, true);
	m_button1.signal_clicked().connect(sigc::mem_fun(m_area, &MyArea::area_reset ));
	m_button2.signal_clicked().connect(sigc::mem_fun(m_area, &MyArea::area_shrink));
	m_button3.signal_clicked().connect(sigc::mem_fun(m_area, &MyArea::area_left  ));
	m_button4.signal_clicked().connect(sigc::mem_fun(m_area, &MyArea::area_right ));
	m_button5.signal_clicked().connect(sigc::mem_fun(m_area, &MyArea::area_up    ));
	m_button6.signal_clicked().connect(sigc::mem_fun(m_area, &MyArea::area_down  ));
	m_box.pack_start(m_area);
	show_all_children();
}

MyWindow::~MyWindow() {
}

Leave a Reply

Your email address will not be published. Required fields are marked *