summaryrefslogtreecommitdiff
path: root/MainWindow.h
blob: ed252c7b622cee83c1d3a8f8d714974dc9454168 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <fx.h>
#include <FXScrollArea.h>
#include <FXMessageBox.h>
#include <algorithm>
#include <string>
#include <fxkeys.h>
#include "Board.h"
#include "icons.h"

class MainWindow : public FXMainWindow
{
	FXDECLARE(MainWindow)

	public:
		explicit MainWindow(FXApp* a);
		~MainWindow();
		virtual void create();

		/* Event system */
		// Messages for our class
		enum {
			UI_Tile       = FXMainWindow::ID_LAST,
			UI_New,
			UI_Timer_Tick,
		};

		/* Event handlers */
		long on_Tile_Click(FXObject *sender, FXSelector sel, void *data);
		long on_New_Click(FXObject *sender, FXSelector sel, void *data);
		long on_Tile_Right_Click(FXObject *sender, FXSelector sel, void *data);
		long on_Timer_Tick(FXObject *sender, FXSelector sel, void *data);
		long on_Key_Press(FXObject *sender, FXSelector sel, void *data);
		long on_Key_Release(FXObject *sender, FXSelector sel, void *data);
		FXApp *get_app(){ return app; };


	protected:
		// Required constructor for FXObject
		MainWindow(){}

	private:
		void create_ui();
		void new_game(int w, int h, int minecount);
		void draw_buttons();
		bool game_over;
		long unsigned int seconds;
		bool ticking;
		int game_count;
		FXHorizontalFrame *contents;                // Content frame
		FXVerticalFrame   *canvasFrame;             // Canvas frame
		FXVerticalFrame   *buttonFrame;             // Button frame
		FXScrollWindow 	*scroll_area;
		FXApp *app;
		Board *board;
		FXMatrix *matrix;
		FXLabel *time_label;
		FXTextField *width_input;
		FXTextField *height_input;
		FXTextField *mine_input;
		FXHorizontalFrame *width_input_frame;
		FXHorizontalFrame *height_input_frame;
		FXHorizontalFrame *mine_input_frame;
		std::vector<std::unique_ptr<FXButton>> tile_buttons;
		/* icons */
		FXIcon *bomb_icon;
		FXIcon *flag_icon;
		FXIcon *empty_icon;
		FXIcon *tile_1_icon;
		FXIcon *tile_2_icon;
		FXIcon *tile_3_icon;
		FXIcon *tile_4_icon;
		FXIcon *tile_5_icon;
		FXIcon *tile_6_icon;
		FXIcon *tile_7_icon;
		FXIcon *tile_8_icon;


};

#endif // MAINWINDOW_H