B15F Board 15 Famulus Edition

view.h
1 #ifndef VIEW_H
2 #define VIEW_H
3
4 #include <iostream>
5 #include <cmath>
6 #include <vector>
7 #include <functional>
8 #include <ncurses.h> // sudo apt-get install libncurses5-dev
9 #include <sys/ioctl.h>
10 #include <unistd.h>
11 #include <signal.h>
12 #include "../drv/b15f.h"
13
14 extern std::string ERR_MSG;
15 typedef std::function<void(int)> call_t;
16
19 class View
20 {
21 public:
22 View(void);
23 virtual ~View(void);
24
25 static void setWinContext(WINDOW* win);
26 static WINDOW* getWinContext(void);
27 static std::vector<std::string> str_split(const std::string& str, const std::string delim);
28
29 virtual void setTitle(std::string title);
30
31 virtual void repaint(void);
32
33 virtual void draw(void) = 0;
34 virtual call_t keypress(int& key) = 0;
35
36
37 protected:
38 int width, height;
39 int start_x = 0, start_y = 0;
40 std::string title;
41 std::vector<call_t> calls;
42
43 static WINDOW* win;
44 constexpr static int KEY_ENT = 10;
45 };
46
47 #endif // VIEW_H
View
Definition: view.h:19