Subversion Repositories Kolibri OS

Rev

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

Rev 8425 Rev 8439
Line 7... Line 7...
7
#endif
7
#endif
Line 8... Line 8...
8
 
8
 
Line 9... Line 9...
9
dword buf_data=0;
9
dword buf_data=0;
10
 
10
 
11
 
11
 
Line 12... Line 12...
12
struct DrawBufer {
12
struct CANVAS {
13
	dword bufx, bufy, bufw, bufh;
13
	dword bufx, bufy, bufw, bufh;
Line 23... Line 23...
23
	void AlignRight();
23
	void AlignRight();
24
	void IncreaseBufSize();
24
	void IncreaseBufSize();
25
};
25
};
Line 26... Line 26...
26
 
26
 
27
char draw_buf_not_enaught_ram[] = 
27
char draw_buf_not_enaught_ram[] = 
28
"'DrawBufer requested %i MB more memory than the system has.
28
"'CANVAS requested %i MB more memory than the system has.
Line 29... Line 29...
29
Application could be unstable.' -E";
29
Application could be unstable.' -E";
30
 
30
 
31
bool DrawBufer::Init(dword i_bufx, i_bufy, i_bufw, i_bufh)
31
bool CANVAS::Init(dword i_bufx, i_bufy, i_bufw, i_bufh)
32
{
32
{
33
	bufx = i_bufx;
33
	bufx = i_bufx;
34
	bufy = i_bufy;
34
	bufy = i_bufy;
Line 40... Line 40...
40
	ESDWORD[buf_data] = bufw;
40
	ESDWORD[buf_data] = bufw;
41
	ESDWORD[buf_data+4] = bufh;
41
	ESDWORD[buf_data+4] = bufh;
42
	return true;
42
	return true;
43
}
43
}
Line 44... Line 44...
44
 
44
 
45
void DrawBufer::Fill(dword start_pointer, i_fill_color)
45
void CANVAS::Fill(dword start_pointer, i_fill_color)
46
{
46
{
47
	dword max_i = bufw * bufh * 4 - start_pointer/4;
47
	dword max_i = bufw * bufh * 4 - start_pointer/4;
48
	fill_color = i_fill_color;
48
	fill_color = i_fill_color;
49
	@MEMSETD(buf_data+start_pointer+8, max_i, fill_color);
49
	@MEMSETD(buf_data+start_pointer+8, max_i, fill_color);
Line 50... Line 50...
50
}
50
}
51
 
51
 
52
void DrawBufer::DrawBar(dword x, y, w, h, color)
52
void CANVAS::DrawBar(dword x, y, w, h, color)
53
{
53
{
54
	dword i, j;
54
	dword i, j;
55
	if (y + h >= bufh) IncreaseBufSize();
55
	if (y + h >= bufh) IncreaseBufSize();
56
	for (j=0; j
56
	for (j=0; j
57
		for (i = y+j*bufw+x<<2+8+buf_data; i
57
		for (i = y+j*bufw+x<<2+8+buf_data; i
58
			ESDWORD[i] = color;
58
			ESDWORD[i] = color;
59
		}
59
		}
Line 60... Line 60...
60
	}
60
	}
61
}
61
}
62
 
62
 
63
void DrawBufer::WriteText(dword x, y, byte fontType, dword color, str_offset, strlen)
63
void CANVAS::WriteText(dword x, y, byte fontType, dword color, str_offset, strlen)
64
{
64
{
65
	#define BUGFIX_32000 32000
65
	#define BUGFIX_32000 32000
Line 87... Line 87...
87
		ESDWORD[new_buf_offset] = reserve_data_1;
87
		ESDWORD[new_buf_offset] = reserve_data_1;
88
		ESDWORD[new_buf_offset+4] = reserve_data_2;
88
		ESDWORD[new_buf_offset+4] = reserve_data_2;
89
	}
89
	}
90
}
90
}
Line 91... Line 91...
91
 
91
 
92
void DrawBufer::PutPixel(dword x, y, color)
92
void CANVAS::PutPixel(dword x, y, color)
93
{
93
{
94
	dword pos = y*bufw+x*4+8+buf_data;
94
	dword pos = y*bufw+x*4+8+buf_data;
95
	ESDWORD[pos] = color;
95
	ESDWORD[pos] = color;
Line 96... Line 96...
96
}
96
}
97
 
97
 
98
void DrawBufer::AlignRight(dword x,y,w,h, content_width)
98
void CANVAS::AlignRight(dword x,y,w,h, content_width)
99
{
99
{
100
	dword i, j, l;
100
	dword i, j, l;
101
	dword content_left = w - content_width / 2;
101
	dword content_left = w - content_width / 2;
Line 106... Line 106...
106
			ESDWORD[buf_data+8+i] >< ESDWORD[buf_data+8+l];
106
			ESDWORD[buf_data+8+i] >< ESDWORD[buf_data+8+l];
107
		}
107
		}
108
	}
108
	}
109
}
109
}
Line 110... Line 110...
110
 
110
 
111
void DrawBufer::AlignCenter(dword x,y,w,h, content_width)
111
void CANVAS::AlignCenter(dword x,y,w,h, content_width)
112
{
112
{
113
	dword i, j, l;
113
	dword i, j, l;
114
	dword content_left = w - content_width / 2;
114
	dword content_left = w - content_width / 2;
115
	for (j=0; j
115
	for (j=0; j
Line 119... Line 119...
119
			ESDWORD[buf_data+8+i] >< ESDWORD[buf_data+8+l];
119
			ESDWORD[buf_data+8+i] >< ESDWORD[buf_data+8+l];
120
		}
120
		}
121
	}
121
	}
122
}
122
}
Line 123... Line 123...
123
 
123
 
124
void DrawBufer::Show(dword _y_offset, _h)
124
void CANVAS::Show(dword _y_offset, _h)
125
{
125
{
126
	PutPaletteImage(_y_offset * bufw * 4 + buf_data+8, bufw, _h, bufx, bufy, 32, 0);
126
	PutPaletteImage(_y_offset * bufw * 4 + buf_data+8, bufw, _h, bufx, bufy, 32, 0);
Line 127... Line 127...
127
}
127
}
128
 
128
 
129
void DrawBufer::IncreaseBufSize()
129
void CANVAS::IncreaseBufSize()
130
{
130
{
131
	static dword bufh_initial;
131
	static dword bufh_initial;
132
	dword alloc_size;
132
	dword alloc_size;