//
// g++ main.cc `pkg-config --cflags --libs gtkmm-3.0` -o sample
//

#include <iostream>

#include <gtkmm/button.h>
#include <gtkmm/box.h>
#include <gtkmm/checkbutton.h>
#include <gtkmm/stack.h>
#include <gtkmm/stackswitcher.h>
#include <gtkmm/window.h>

class HelloWorld : public Gtk::Window
{

public:
  HelloWorld();
  virtual ~HelloWorld();

protected:
  //Signal handlers:
  void on_button_clicked();

  //Member widgets:
  Gtk::Box    m_box;
  Gtk::Stack  m_stack;
  Gtk::StackSwitcher m_switcher;
  Gtk::Button *m_button;
  Gtk::CheckButton *m_checkbox;
};


int main (int argc, char *argv[])
{
  Glib::RefPtr<Gtk::Application> app = Gtk::Application::create(argc, argv, "org.gtkmm.example");

  HelloWorld helloworld;

  //Shows the window and returns when it is closed.
  return app->run(helloworld);
}

HelloWorld::HelloWorld()
  : m_box(Gtk::ORIENTATION_VERTICAL)
//  , m_button("Hello World")   // creates a new button with label "Hello World".
//  , m_checkbox("Good bye")
{
  // Sets the border width of the window.
  set_border_width(10);

  m_button = Gtk::manage(new Gtk::Button("Hello world"));
  m_checkbox = Gtk::manage(new Gtk::CheckButton("Good bye"));

  // When the button receives the "clicked" signal, it will call the
  // on_button_clicked() method defined below.
  m_button->signal_clicked().connect(sigc::mem_fun(*this,
              &HelloWorld::on_button_clicked));

  add(m_box);

  m_box.pack_start(m_switcher);
  // This packs the button into the Window (a container).
  m_box.pack_end(m_stack);
  m_switcher.set_stack(m_stack);

  // add content
  m_stack.add(*m_button, "Hello", "Hello");
  m_stack.add(*m_checkbox, "bye", "Good bye");

  // The final step is to display this newly created widget...
  m_box.show_all();
}

HelloWorld::~HelloWorld()
{
}

void HelloWorld::on_button_clicked()
{
  std::cout << "Hello World" << std::endl;
}
