Mercurial > ~dholland > hg > ag > index.cgi
comparison examples/dsl/screen.h @ 0:13d2b8934445
Import AnaGram (near-)release tree into Mercurial.
author | David A. Holland |
---|---|
date | Sat, 22 Dec 2007 17:52:45 -0500 |
parents | |
children | a02e9434072e |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:13d2b8934445 |
---|---|
1 /***** | |
2 | |
3 AnaGram Programming Examples | |
4 | |
5 A Dos Script Language | |
6 Screen Control Class Definitions | |
7 | |
8 Copyright 1993 Parsifal Software. All Rights Reserved. | |
9 | |
10 This software is provided 'as-is', without any express or implied | |
11 warranty. In no event will the authors be held liable for any damages | |
12 arising from the use of this software. | |
13 | |
14 Permission is granted to anyone to use this software for any purpose, | |
15 including commercial applications, and to alter it and redistribute it | |
16 freely, subject to the following restrictions: | |
17 | |
18 1. The origin of this software must not be misrepresented; you must not | |
19 claim that you wrote the original software. If you use this software | |
20 in a product, an acknowledgment in the product documentation would be | |
21 appreciated but is not required. | |
22 2. Altered source versions must be plainly marked as such, and must not be | |
23 misrepresented as being the original software. | |
24 3. This notice may not be removed or altered from any source distribution. | |
25 | |
26 *****/ | |
27 | |
28 #ifndef SCREEN_H | |
29 #define SCREEN_H | |
30 | |
31 #include "pair.h" | |
32 | |
33 #define COLOR(fg,bg) (((bg & 0xf) << 4) | (fg & 0xf)) | |
34 | |
35 #ifdef __386__ | |
36 #define INT int386 | |
37 #define COLOR_ADAPTER_ADDRESS 0XB8000 | |
38 #else | |
39 #define INT int86 | |
40 #define COLOR_ADAPTER_ADDRESS 0XB8000000 | |
41 #endif | |
42 | |
43 | |
44 // char_cell class | |
45 | |
46 class char_cell { | |
47 public: | |
48 unsigned char data, color; | |
49 char_cell() {data = color = 0;} | |
50 char_cell(int d, int c) { | |
51 data = (unsigned char) d, color = (unsigned char) c; | |
52 } | |
53 char_cell(int d, int fg, int bg) { | |
54 data = (unsigned char) d, color = (unsigned char) COLOR(fg,bg); | |
55 } | |
56 char_cell &operator = (int d) { | |
57 data = (unsigned char) d; | |
58 return *this; | |
59 } | |
60 }; | |
61 | |
62 | |
63 // Protect Display | |
64 | |
65 class protect_display { | |
66 char_cell *p; | |
67 unsigned n; | |
68 pair<int> cursor_position; | |
69 public: | |
70 protect_display(); | |
71 ~protect_display(); | |
72 }; | |
73 | |
74 | |
75 // Screen Rectangle class | |
76 | |
77 class screen_rect{ | |
78 public: | |
79 pair <int> pos, size; // position and size of screen_rect | |
80 pair <int> jm; // justification mode | |
81 | |
82 // No constructors or destructors defined | |
83 | |
84 // Build a screen rectangle at absolute coordinates | |
85 friend screen_rect at(int, int, int); | |
86 | |
87 // Build a screen rectangle at relative coordinates | |
88 screen_rect at(int,int,int = 0); | |
89 | |
90 // Build a single line rectange at absolute coordinates | |
91 friend screen_rect line(int, int, int, int = 0); | |
92 | |
93 // Build a single line rectangle at relative coordinates | |
94 screen_rect line(int,int,int,int = 0) const; | |
95 | |
96 // Read the contents of a screen rectangle | |
97 friend char_cell *contents(const screen_rect &); | |
98 | |
99 // Set the contents of a screen rectangle | |
100 screen_rect &operator << (const char_cell *); | |
101 | |
102 // Build a sub-rectangle of given width, depth | |
103 screen_rect rect(int w, int d, int jm = 11); | |
104 | |
105 // Draw a box around a screen rectangle | |
106 friend screen_rect box(screen_rect); | |
107 | |
108 // Display data in rectangle | |
109 screen_rect &operator << (const char_cell &p); | |
110 screen_rect &operator << (const int); | |
111 screen_rect &operator << (const char *s); | |
112 | |
113 // Tint a rectangle | |
114 screen_rect &tint(int color); | |
115 screen_rect &tint(int fg, int bg); | |
116 | |
117 // Set cursor relative to rectangle | |
118 screen_rect &set_cursor(const int = 0, const int = 0); | |
119 }; | |
120 | |
121 screen_rect at(int, int, int = 0); | |
122 | |
123 #endif |