linux-embedded-examples/gtkmm/hello_world.cpp
Sanchayan Maity f815cdce4b Initial Commit
Preliminary commit with the following projects in Eclipse
1. gtkmm Hello World
2. PCF8574 I2C GPIO Expander
3. PCF8591 I2C A-D & D-A Converter
4. SPI based OLED Display with SSD1306 controller

Library Dependencies
1. Gtk
2. Gtkmm
3. libsoc

TODO:
Documentation and cleanup
2017-04-12 14:35:53 +05:30

58 lines
1.1 KiB
C++

#include <gtkmm/button.h>
#include <gtkmm/window.h>
#include <gtkmm/main.h>
#include <iostream>
class HelloWorld : public Gtk::Window
{
public:
HelloWorld();
virtual ~HelloWorld();
protected:
//Signal handlers:
void on_button_clicked();
//Member widgets:
Gtk::Button m_button;
};
HelloWorld::HelloWorld()
: m_button("Hello World") // creates a new button with label "Hello World".
{
// Sets the border width of the window.
set_border_width(10);
// 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));
// This packs the button into the Window (a container).
add(m_button);
// The final step is to display this newly created widget...
m_button.show();
}
HelloWorld::~HelloWorld()
{
}
void HelloWorld::on_button_clicked()
{
std::cout << "Hello World" << std::endl;
}
int main (int argc, char *argv[])
{
Gtk::Main kit(argc, argv);
HelloWorld helloworld;
//Shows the window and returns when it is closed.
Gtk::Main::run(helloworld);
return 0;
}