Add gtk140
This commit is contained in:
parent
0555ad367c
commit
6be8ba1685
|
@ -0,0 +1,34 @@
|
||||||
|
#include "MineSweeper.hh"
|
||||||
|
|
||||||
|
MineSweeper::MineSweeper()
|
||||||
|
{
|
||||||
|
// Initalize Window
|
||||||
|
set_title("Gtkmm MineSweeper");
|
||||||
|
set_icon_name("org.gtk.daleclack");
|
||||||
|
|
||||||
|
// Append buttons to grid
|
||||||
|
for (int i = 0; i < 7; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < 7; j++)
|
||||||
|
{
|
||||||
|
cell[i * 7 + j].set_label("?");
|
||||||
|
cell[i * 7 + j].signal_clicked().connect(sigc::bind(
|
||||||
|
sigc::mem_fun(*this, &MineSweeper::cell_clicked), &cell[i * 7 + j]));
|
||||||
|
mine_grid.attach(cell[i * 7 + j], j, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show everything
|
||||||
|
add(mine_grid);
|
||||||
|
show_all_children();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MineSweeper::reset_game()
|
||||||
|
{
|
||||||
|
// Append item
|
||||||
|
}
|
||||||
|
|
||||||
|
void MineSweeper::cell_clicked(MineCell *cell)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
|
@ -2,3 +2,31 @@
|
||||||
|
|
||||||
#include <gtkmm.h>
|
#include <gtkmm.h>
|
||||||
|
|
||||||
|
class MineCell : public Gtk::Button
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
bool is_mine = false;
|
||||||
|
int mines_around;
|
||||||
|
MineCell(){
|
||||||
|
// Set button style
|
||||||
|
set_relief(Gtk::RELIEF_NONE);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class MineSweeper : public Gtk::ApplicationWindow
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
MineSweeper();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Child widgets
|
||||||
|
Gtk::Grid mine_grid;
|
||||||
|
MineCell cell[49];
|
||||||
|
|
||||||
|
// Timer
|
||||||
|
sigc::connection mytimer;
|
||||||
|
|
||||||
|
// Signal Handlers
|
||||||
|
void reset_game();
|
||||||
|
void cell_clicked(MineCell *cell);
|
||||||
|
};
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
#include "MineSweeper.hh"
|
#include "MineSweeper.hh"
|
||||||
|
|
||||||
int main(int argc, char **argv){}
|
int main(int argc, char **argv){
|
||||||
|
// Create a application and run
|
||||||
|
auto app = Gtk::Application::create(argc,argv,"org.gtk.daleclack");
|
||||||
|
MineSweeper window;
|
||||||
|
return app->run(window);
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
rm .\AppData\Local\Microsoft\vscode-cpptools\ipch\*
|
||||||
|
rm .\AppData\Roaming\Code\User\workspaceStorage\*
|
Loading…
Reference in New Issue