-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpaintb.h
93 lines (79 loc) · 2.02 KB
/
paintb.h
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
#ifndef PAINTB_H
#define PAINTB_H
#define COMP_KEY 4826
#include <windows.h>
#include <string>
class canvas;
class canvasCRS;
enum funcType { voidPtr, cnvVoidPtr};
struct func {
union {
void (*voidFunc) ();
void (canvasCRS::*cnvFunc) ();
};
funcType type;
};
class canvas {
protected:
typedef struct FS {
unsigned char *frameString;
struct FS *next;
struct FS *prev;
int index;
} FS;
FS *head;
int rows;
int cols;
int rawPos(int row, int col);
int logRow(int rawPos);
int logCol(int rawPos);
public:
canvas(int rows, int cols);
~canvas();
void setBlock(int row, int col, int key);
void print_fs(); // innefficient print function
void initFS(FS &fs, int rows, int cols);
// initialize given FS(add border and fill with whitespace)
};
class canvasCRS: public canvas {
private:
HANDLE cohan; // console output handle
DWORD consoleMode_prev; // to restore in the destructor
COORD topLeft;
CONSOLE_CURSOR_INFO cci; // console cursor infor to set
CONSOLE_FONT_INFOEX cfi_prev; // to restore in the destructor
CONSOLE_FONT_INFOEX cfi; // console font info to set
// for console manipulation
unsigned char color;
FS *colorHead;
// color support
bool mouseInput;
HANDLE cihan; // console input handle
unsigned char block;
// for mouse input
unsigned char *display;
unsigned char *displayColor;
bool focusedMode;
COORD jumpTo;
COORD jumpBack;
// for fast display refreshing (focused mode)
void redrawConsole();
public:
canvasCRS(int rows, int cols);
~canvasCRS();
void cls();
void print();
void printFull();
void refreshDisplayString();
void maximize();
void setFocusedMode(bool state);
void setMouseInput(bool state);
unsigned char inputLoop();
void changeColor(int newColor);
void zoomIn();
void zoomOut();
int loadCanvas(std::string fileName);
int saveCanvas(std::string fileName);
int saveCanvasForce(std::string fileName);
};
#endif