| 1 |
#include "tictactoe.h" |
| 2 |
#include <gtkmm/window.h> |
| 3 |
#include <gtkmm/application.h> |
| 4 |
#include <iostream> |
| 5 |
|
| 6 |
void |
| 7 |
win (TicTacToe* ttt) |
| 8 |
{ |
| 9 |
std::cout << "Yay!\n"; |
| 10 |
ttt->clear(); |
| 11 |
} |
| 12 |
|
| 13 |
class MyWindow : public Gtk::Window |
| 14 |
{ |
| 15 |
public: |
| 16 |
MyWindow(); |
| 17 |
}; |
| 18 |
|
| 19 |
MyWindow::MyWindow() |
| 20 |
{ |
| 21 |
set_title("Tic-Tac-Toe"); |
| 22 |
|
| 23 |
auto ttt = Gtk::make_managed<TicTacToe>(); |
| 24 |
ttt->tictactoe.connect([ttt](){ win(ttt); }); |
| 25 |
ttt->set_margin(10); |
| 26 |
set_child(*ttt); |
| 27 |
} |
| 28 |
|
| 29 |
int |
| 30 |
main(int argc, char* argv[]) |
| 31 |
{ |
| 32 |
auto app = Gtk::Application::create("org.gtkmm.example"); |
| 33 |
|
| 34 |
return app->make_window_and_run<MyWindow>(argc, argv); |
| 35 |
} |