Rev 1805 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1805 | Rev 5123 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | #ifndef _GRAPHIC_DRAW_H |
1 | #ifndef _GRAPHIC_DRAW_H |
2 | #define _GRAPHIC_DRAW_H |
2 | #define _GRAPHIC_DRAW_H |
Line 3... | Line -... | ||
3 | - | ||
4 | #ifndef __MENUET__ |
3 | |
5 | #include |
4 | #include |
Line 6... | Line 5... | ||
6 | #include |
5 | #include |
7 | 6 | ||
8 | #ifdef _Windows |
7 | #ifdef _Windows |
9 | # include |
- | |
10 | #endif |
- | |
11 | #else |
- | |
12 | #define LONG_MIN (-2147483647L-1) /* minimum signed long value */ |
- | |
Line -... | Line 8... | ||
- | 8 | # include |
|
13 | #define INT_MIN LONG_MIN |
9 | #endif |
14 | #endif |
10 | |
15 | 11 | template |
|
16 | class TGraphDraw |
12 | class TBaseGraphDraw |
17 | { |
13 | { |
18 | public: |
14 | public: |
19 | union event |
15 | union event |
Line 20... | Line 16... | ||
20 | { |
16 | { |
21 | enum evtype {noevent = 0, draw, button_down, button_up, |
17 | enum evtype {noevent = 0, draw, button_down, button_up, |
22 | mouse_move, key_down, key_up, start, close} type; |
18 | mouse_move, key_down, key_up, start, close} type; |
23 | 19 | ||
24 | struct evany |
20 | struct evany |
Line 25... | Line 21... | ||
25 | { |
21 | { |
26 | evtype type; |
22 | evtype type; |
27 | TGraphDraw *drw; |
23 | TRealGraphDraw *drw; |
Line 41... | Line 37... | ||
41 | enum {button_down_mask = 0x1, button_up_mask = 0x2, key_down_mask = 0x4, |
37 | enum {button_down_mask = 0x1, button_up_mask = 0x2, key_down_mask = 0x4, |
42 | key_up_mask = 0x8, mouse_move_mask = 0x10, mouse_drag_mask = 0x20}; |
38 | key_up_mask = 0x8, mouse_move_mask = 0x10, mouse_drag_mask = 0x20}; |
Line 43... | Line 39... | ||
43 | 39 | ||
44 | enum {ret_setcapture = 0x10}; |
40 | enum {ret_setcapture = 0x10}; |
45 | public: |
41 | public: |
46 | TGraphDraw(const char *s = 0) : title(0), about_info(0), |
42 | TBaseGraphDraw(const char *s = 0) : title(0), about_info(0), |
47 | evfunc(0), id(0), data(0) {CopyTitle(s);} |
43 | evfunc(0), id(0), data(0) {CopyTitle(s);} |
Line 48... | Line 44... | ||
48 | ~TGraphDraw() {FreeTitle();} |
44 | ~TBaseGraphDraw() {FreeTitle();} |
49 | 45 | ||
50 | virtual unsigned long GetBlackColor() {return 0;} |
46 | unsigned long GetBlackColor() {return 0;} |
51 | virtual unsigned long GetWhiteColor() {return 0xFFFFFFL;} |
47 | unsigned long GetWhiteColor() {return 0xFFFFFFL;} |
52 | virtual unsigned long CreateColor(unsigned short red, |
48 | unsigned long CreateColor(unsigned short red, |
53 | unsigned short green, unsigned short blue); |
49 | unsigned short green, unsigned short blue); |
54 | virtual void FreeColor(unsigned long c) {} |
50 | void FreeColor(unsigned long c) {} |
Line 55... | Line 51... | ||
55 | virtual unsigned long GetBgColor() {return GetWhiteColor();} |
51 | unsigned long GetBgColor() {return GetWhiteColor();} |
56 | virtual void SetBgColor(unsigned long c) {} |
52 | void SetBgColor(unsigned long c) {} |
Line 57... | Line 53... | ||
57 | 53 | ||
58 | virtual void SetTitle(const char *s) {CopyTitle(s);} |
54 | void SetTitle(const char *s) {CopyTitle(s);} |
59 | const char *GetTitle() const {return title;} |
55 | const char *GetTitle() const {return title;} |
60 | 56 | ||
61 | virtual int GetStatus() {return 0;} //1 - can draw, 0 - can't draw, <0 - error |
57 | int GetStatus() {return 0;} //1 - can draw, 0 - can't draw, <0 - error |
62 | virtual int Init() {return 0;} |
58 | int Init() {return 0;} |
63 | virtual void UnInit() {} |
59 | void UnInit() {} |
64 | virtual int Run(int evmask = 0, int w = INT_MIN, int h = INT_MIN) {return -100;} |
60 | int Run(int evmask = 0, int w = INT_MIN, int h = INT_MIN) {return -100;} |
65 | 61 | ||
66 | virtual void GetSize(int &w, int &h) {w = 200; h = 200;} |
62 | void GetSize(int &w, int &h) {w = 200; h = 200;} |
67 | virtual int OpenDraw() {return 0;} |
63 | int OpenDraw() {return 0;} |
68 | virtual int IsDraw() {return 0;} |
64 | int IsDraw() {return 0;} |
69 | virtual void CloseDraw() {} |
65 | void CloseDraw() {} |
70 | 66 | ||
71 | virtual int SetColor(unsigned long c) {return 0;} |
67 | int SetColor(unsigned long c) {return 0;} |
72 | virtual int DrawLine(int x0, int y0, int x1, int y1) {return 0;} |
68 | int DrawLine(int x0, int y0, int x1, int y1) {return 0;} |
73 | virtual int DrawText(int x0, int y0, char *text) {return 0;} |
69 | int DrawText(int x0, int y0, char *text) {return 0;} |
74 | virtual int DrawClear() {return 0;} |
70 | int DrawClear() {return 0;} |
75 | virtual int GetTextH(const char *s) {return 16;} |
71 | int GetTextH(const char *s) {return 16;} |
76 | virtual int GetTextW(const char *s) {return 8 * strlen(s);} |
72 | int GetTextW(const char *s) {return 8 * strlen(s);} |
77 | virtual void Quit(int q = 1) {} |
73 | void Quit(int q = 1) {} |
78 | virtual void ResReinit(int w = INT_MIN, int h = INT_MIN) {} |
74 | void ResReinit(int w = INT_MIN, int h = INT_MIN) {} |
79 | virtual int GetAboutInfo() {return about_info;} |
75 | int GetAboutInfo() {return about_info;} |
80 | virtual void SetAboutInfo(int inf) {about_info = inf;} |
76 | void SetAboutInfo(int inf) {about_info = inf;} |
81 | protected: |
77 | protected: |
Line 87... | Line 83... | ||
87 | int (*evfunc)(const event &ev); |
83 | int (*evfunc)(const event &ev); |
88 | int id; |
84 | int id; |
89 | void *data; |
85 | void *data; |
90 | }; |
86 | }; |
Line -... | Line 87... | ||
- | 87 | ||
91 | 88 | template |
|
92 | unsigned long TGraphDraw::CreateColor(unsigned short red, |
89 | unsigned long TBaseGraphDraw |
93 | unsigned short green, unsigned short blue) |
90 | unsigned short green, unsigned short blue) |
94 | { |
91 | { |
95 | return (unsigned long)(red >> 8) + ((unsigned long)(green >> 8) << 8) + |
92 | return (unsigned long)(red >> 8) + ((unsigned long)(green >> 8) << 8) + |
96 | ((unsigned long)(blue >> 8) << 16); |
93 | ((unsigned long)(blue >> 8) << 16); |
Line -... | Line 94... | ||
- | 94 | } |
|
97 | } |
95 | |
98 | 96 | template |
|
99 | void TGraphDraw::CopyTitle(const char *s) |
97 | void TBaseGraphDraw |
100 | { |
98 | { |
101 | FreeTitle(); |
99 | FreeTitle(); |
Line -... | Line 100... | ||
- | 100 | if (s) {title = new char[strlen(s) + 1]; strcpy(title, s);} |
|
- | 101 | } |
|
- | 102 | ||
102 | if (s) {title = new char[strlen(s) + 1]; strcpy(title, s);} |
103 | #if defined _KOLIBRI |
103 | } |
104 | # include "kolibri-draw.h" |
104 | 105 | typedef TKlbrGraphDraw TMainGraphDraw; |
|
105 | #if defined __GNUC__ |
- | |
106 | # include "gnu-draw.h" |
- | |
107 | typedef TGnuGraphDraw TMainGraphDraw; |
- | |
108 | #elif defined __MENUET__ |
106 | #elif defined __GNUC__ |
109 | # include "mt-draw.h" |
107 | # include "gnu-draw.h" |
110 | typedef TKlbrGraphDraw TMainGraphDraw; |
108 | typedef TGnuGraphDraw TMainGraphDraw; |
111 | #elif defined _Windows |
109 | #elif defined _Windows |
112 | # include "win-draw.h" |
110 | # include "win-draw.h" |
113 | typedef TWinGraphDraw TMainGraphDraw; |
111 | typedef TWinGraphDraw TMainGraphDraw; |
114 | #elif defined __MSDOS__ |
112 | #elif defined __MSDOS__ |
115 | # include "dos-draw.h" |
113 | # include "dos-draw.h" |
116 | typedef TDosGraphDraw TMainGraphDraw; |
114 | typedef TDosGraphDraw TMainGraphDraw; |
- | 115 | #else |
|
Line 117... | Line 116... | ||
117 | #else |
116 | #error "Unknown platform" |