Subversion Repositories Kolibri OS

Rev

Rev 6803 | Rev 7739 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 6803 Rev 7738
Line 9... Line 9...
9
dword buf_data;
9
dword buf_data;
Line 10... Line 10...
10
 
10
 
11
 
11
 
-
 
12
struct DrawBufer {
Line 12... Line 13...
12
struct DrawBufer {
13
	dword bufx, bufy, bufw, bufh;
13
	dword bufx, bufy, bufw, bufh;
14
	dword fill_color;
14
 
15
 
15
	bool Init();
16
	bool Init();
-
 
17
	void Show();
16
	void Show();
18
	void Fill();
17
	void Fill();
19
	void DrawBar();
18
	void DrawBar();
20
	void WriteText();
-
 
21
	void PutPixel();
19
	void PutPixel();
22
	void AlignCenter();
Line 20... Line 23...
20
	void AlignCenter();
23
	void AlignRight();
21
	void AlignRight();
24
	void IncreaseBufSize();
22
};
25
};
Line 28... Line 31...
28
Requested size: %i Mb
31
Requested size: %i Mb
29
Free RAM: %i Mb' -E";
32
Free RAM: %i Mb' -E";
Line 30... Line 33...
30
 
33
 
31
bool DrawBufer::Init(dword i_bufx, i_bufy, i_bufw, i_bufh)
34
bool DrawBufer::Init(dword i_bufx, i_bufy, i_bufw, i_bufh)
32
{
-
 
33
	dword alloc_size, free_ram_size;
-
 
34
	char error_str[256];
35
{
35
	bufx = i_bufx;
36
	bufx = i_bufx;
36
	bufy = i_bufy;
37
	bufy = i_bufy;
37
	bufw = i_bufw; 
38
	bufw = i_bufw; 
38
	bufh = i_bufh;
39
	bufh = i_bufh;
39
	free(buf_data);
-
 
40
	free_ram_size = GetFreeRAM() * 1024;
-
 
41
	alloc_size = bufw * bufh * 4 + 8;
-
 
42
	if (alloc_size >= free_ram_size) {
-
 
43
		sprintf(#error_str, #draw_buf_not_enaught_ram, alloc_size/1048576, free_ram_size/1048576);
40
	buf_data = free(buf_data);
44
		notify(#error_str);
-
 
45
	}
-
 
46
	buf_data = malloc(alloc_size);
41
	IncreaseBufSize();
47
	//debugval("buf_data",buf_data);
42
	//debugval("buf_data",buf_data);
48
	if (!buf_data) return false;
43
	if (!buf_data) return false;
49
	ESDWORD[buf_data] = bufw;
44
	ESDWORD[buf_data] = bufw;
50
	ESDWORD[buf_data+4] = bufh;
45
	ESDWORD[buf_data+4] = bufh;
51
	return true;
46
	return true;
Line 52... Line 47...
52
}
47
}
53
 
48
 
54
void DrawBufer::Fill(dword fill_color)
49
void DrawBufer::Fill(dword start_pointer, i_fill_color)
55
{
50
{
-
 
51
	dword i;
56
	dword i;
52
	dword max_i = bufw * bufh * 4 + buf_data + 8;
57
	dword max_i = bufw * bufh * 4 + buf_data + 8;
53
	fill_color = i_fill_color;
Line 58... Line 54...
58
	for (i=buf_data+8; i
54
	for (i=buf_data+start_pointer+8; i
59
}
55
}
60
 
56
 
-
 
57
void DrawBufer::DrawBar(dword x, y, w, h, color)
61
void DrawBufer::DrawBar(dword x, y, w, h, color)
58
{
62
{
-
 
63
	dword i, j;
59
	dword i, j;
64
	for (j=0; j
60
	if (y + h >= bufh) IncreaseBufSize();
65
	{
61
	for (j=0; j
66
		for (i = y+j*bufw+x<<2+8+buf_data; i
62
		for (i = y+j*bufw+x<<2+8+buf_data; i
67
			ESDWORD[i] = color;
63
			ESDWORD[i] = color;
Line -... Line 64...
-
 
64
		}
-
 
65
	}
-
 
66
}
-
 
67
 
-
 
68
void DrawBuf_WriteText(dword x, y, byte fontType, dword color, str_offset)
-
 
69
{
-
 
70
	EDI = buf_data;
-
 
71
	WriteText(x, y, fontType, color, str_offset);
-
 
72
}
-
 
73
void DrawBufer::WriteText(dword x, y, byte fontType, dword color, str_offset)
-
 
74
{
68
		}
75
	if (y + 30 >= bufh) IncreaseBufSize();
69
	}
76
	DrawBuf_WriteText(x, y, fontType, color, str_offset);
70
}
77
}
71
 
78
 
72
void DrawBufer::PutPixel(dword x, y, color)
79
void DrawBufer::PutPixel(dword x, y, color)
Line 140... Line 147...
140
void DrawBufer::Show()
147
void DrawBufer::Show()
141
{
148
{
142
	PutPaletteImage(buf_data+8, bufw, bufh, bufx, bufy, 32, 0);	
149
	PutPaletteImage(buf_data+8, bufw, bufh, bufx, bufy, 32, 0);	
143
}
150
}
Line -... Line 151...
-
 
151
 
-
 
152
void DrawBufer::IncreaseBufSize()
-
 
153
{
-
 
154
	static dword alloc_counter;
-
 
155
	static dword bufh_initial;
-
 
156
	dword alloc_size;
-
 
157
	dword free_ram_size;
-
 
158
	char error_str[256];
-
 
159
 
-
 
160
	if (!buf_data) {
-
 
161
		alloc_counter = 1;
-
 
162
		bufh_initial = bufh;
-
 
163
		alloc_size = bufw * bufh * 4 + 8;
-
 
164
		buf_data = malloc(alloc_size);
-
 
165
	}
-
 
166
	else {
-
 
167
		alloc_counter++;
-
 
168
		bufh = bufh_initial * alloc_counter;
-
 
169
		alloc_size = bufw * bufh * 4 + 8;
-
 
170
		buf_data = realloc(buf_data, alloc_size);
-
 
171
		Fill(alloc_counter - 1 * bufw * bufh_initial * 4 + 8, fill_color);
-
 
172
	}
-
 
173
 
-
 
174
	free_ram_size = GetFreeRAM() * 1024;
-
 
175
	if (alloc_size >= free_ram_size) {
-
 
176
		sprintf(#error_str, #draw_buf_not_enaught_ram, alloc_size/1048576, free_ram_size/1048576);
-
 
177
		notify(#error_str);
-
 
178
	}
-
 
179
}
-
 
180
 
-
 
181
 
144
 
182
 
145
#endif
183
#endif