⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bccanvas.c

📁 用你的语音Modem实现像电话一样通话的程序
💻 C
字号:
#include "bccanvas.h"BC_Canvas::BC_Canvas(int x, int y, int w, int h, int color) : BC_Tool(x, y, w, h){	this->color = color;}BC_Canvas::create_tool_objects(){	create_window(x, y, w, h, color);	XGCValues gcvalues;	unsigned long gcmask;	gcmask = GCFont;	gcvalues.font = top_level->largefont->fid;	gc = XCreateGC(top_level->display, win, gcmask, &gcvalues);}BC_Canvas::set_size(int x, int y, int w, int h){	this->x = x; this->y = y; this->w = w; this->h = h;	resize_window(x, y, w, h);    // canvases must be redrawn after resize}BC_Canvas::clear_box(int x_, int y_, int w_, int h_) { 	set_color(color);	draw_box(x_, y_, w_, h_); }BC_Canvas::deactivate_tools(){	if(top_level->active_tool) top_level->active_tool->deactivate();}BC_Canvas::draw(){}BC_Canvas::button_press_(){	if(cursor_x > 0 && cursor_x < w		 && cursor_y > 0 && cursor_y < h)	{//printf("button_press\n");		activate();		button_press();	}}BC_Canvas::button_release_(){	button_release();}BC_Canvas::cursor_motion_(){	cursor_motion();}BC_Canvas::draw_bitmap(VFrame *frame, 			int in_x1, int in_y1, int in_x2, int in_y2, 			int out_x1, int out_y1, int out_x2, int out_y2){	BC_Tool::draw_bitmap(frame, 		in_x1, in_y1, in_x2, in_y2, 		out_x1, out_y1, out_x2, out_y2, &gc);}BC_Canvas::draw_edit(int x, int y, int h) // draw edit bar{	set_inverse();	set_color(RED);	draw_line(x, y, x, y + h);	set_opaque();}BC_Canvas::draw_start_edit(int x, int y, int vertical) // draw edit handle{	set_inverse();	set_color(LTBLUE);	XPoint point[3];		if(vertical)	{		int x2, x3, y2;		const int w = 15, h = 10;				y2 = y + h;		x -= w / 2; x2 = x + w / 2; x3 = x + w;		point[0].x = x; point[0].y = y2;		point[1].x = x2; point[1].y = y;		point[2].x = x3; point[2].y = y2;	}	else	{		int x2, y2, y3;		const int w = 10, h = 15;		x2 = x + w;		y -= h / 2; y2 = y + h / 2; y3 = y + h;		point[0].x = x; point[0].y = y2;		point[1].x = x2; point[1].y = y;		point[2].x = x2; point[2].y = y3;	}		XFillPolygon(top_level->display, pixmap, gc, point, 3, Nonconvex, CoordModeOrigin);	set_opaque();}BC_Canvas::draw_end_edit(int x, int y, int vertical) // draw edit handle{	set_inverse();	set_color(LTBLUE);	XPoint point[3];	if(vertical)	{		int x2, x3, y2;		const int w = 15, h = 10;		y2 = y;  y -= h;		x -= w / 2; x2 = x + w / 2; x3 = x + w;				point[0].x = x; point[0].y = y;		point[1].x = x2; point[1].y = y2;		point[2].x = x3; point[2].y = y;			}	else	{		int x2, y2, y3;		const int w = 10, h = 15;			x2 = x; x -= w;		y -= h / 2; y2 = y + h / 2; y3 = y + h;		point[0].x = x; point[0].y = y;		point[1].x = x2; point[1].y = y2;		point[2].x = x; point[2].y = y3;	}		XFillPolygon(top_level->display, pixmap, gc, point, 3, Nonconvex, CoordModeOrigin);	set_opaque();}BC_Canvas::draw_3d_big(int x1, int y1, int w, int h, int light, int middle, int shadow){	int lx,ly,ux,uy;	h--; w--;	lx = x1+1;  ly = y1+1;	ux = x1+w-1;  uy = y1+h-1;	set_color(middle);	draw_box(x1, y1, w, h);	set_color(light);	draw_line(x1, y1, x1+w, y1);	draw_line(x1, y1, x1, y1+h);	draw_line(lx, ly, ux, ly);	draw_line(lx, ly, lx, uy);	set_color(shadow);	draw_line(x1+w, y1, x1+w, y1+h);	draw_line(x1, y1+h, x1+w, y1+h);	draw_line(ux, ly, ux, uy);	draw_line(lx, uy, ux, uy);}BC_Canvas::set_color(int color){	XSetForeground(top_level->display, gc, top_level->get_color(color)); }BC_Canvas::set_inverse() {	XSetFunction(top_level->display, gc, GXxor);}BC_Canvas::set_opaque() {	XSetFunction(top_level->display, gc, GXcopy);}BC_Canvas::draw_box(int x_, int y_, int w_, int h_) { 	XFillRectangle(top_level->display, pixmap, gc, x_, y_, w_, h_); }BC_Canvas::draw_rectangle(int x_, int y_, int w_, int h_){	XDrawRectangle(top_level->display, pixmap, gc, x_, y_, w_, h_); }BC_Canvas::draw_line(int x1, int y1, int x2, int y2) {	XDrawLine(top_level->display, pixmap, gc, x1, y1, x2, y2);}BC_Canvas::draw_3d_line(int x1, int y1, int x2, int y2, int color1, int color2){	BC_Tool::draw_3d_line(x1, y2, x2, y2, color1, color2, &gc);}BC_Canvas::draw_text(int x_, int y_, char *text) {	XDrawString(top_level->display, pixmap, gc, x_, y_, text, strlen(text));}BC_Canvas::draw_vertical_text(int x, int y, char *text, int fgcolor, int bgcolor){	BC_Tool::draw_vertical_text(x, y, text, fgcolor, bgcolor, &gc);}BC_Canvas::draw_center_text(int x, int y, char *text, XFontStruct *font) {	if(!font) font = top_level->smallfont;	x -= XTextWidth(font, text, strlen(text)) / 2;	XDrawString(top_level->display, pixmap, gc, x, y, text, strlen(text));};BC_Canvas::set_font(XFontStruct *font) { 	XSetFont(top_level->display, gc, font->fid);};BC_Canvas::set_font(int font) { 	switch(font)	{		case LARGEFONT: XSetFont(top_level->display, gc, top_level->largefont->fid); break;		case SMALLFONT: XSetFont(top_level->display, gc, top_level->smallfont->fid); break;		case TITLEFONT: XSetFont(top_level->display, gc, top_level->titlefont->fid); break;	}};BC_Canvas::get_text_width(XFontStruct *font, char *text){	return XTextWidth(font, text, strlen(text));}BC_Canvas::get_text_width(int font, char *text){	switch(font)	{		case LARGEFONT:			return XTextWidth(top_level->largefont, text, strlen(text));			break;					case SMALLFONT:			return XTextWidth(top_level->smallfont, text, strlen(text));			break;					case TITLEFONT:			return XTextWidth(top_level->titlefont, text, strlen(text));			break;	}}BC_Canvas::draw_circle(int x, int y, int w, int h){	XDrawArc(top_level->display, pixmap, gc, x, y, (w - 1), (h - 2), 0*64, 360*64);}BC_Canvas::draw_disc(int x, int y, int w, int h){	BC_Tool::draw_disc(x, y, w, h, &gc);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -