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

📄 fted_draw.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
    fted_edit_pad_info[pad_num].modified = TRUE;    }fted_point_wipe_reset(x, y, pad_num, mouse_button, shifted)register int	x, y;				/* coord of point	*/register int	pad_num;			/* index of button	*/int		mouse_button;			/* which mouse button was used */int		shifted;			/* true if the shift key is down */{    pt_wipe_down = FALSE;}/* * The operations rect, cut, copy, paste and, to an extent, line all use  * a rectangle that is drawn on the screen. These static variables * hold info about the rect (in the various coordinate systems). *  */static int base_x_wc;	/* base corner of rectangle or endpt of line (in window coordinates)	*/static int base_y_wc;static int base_x_cc;	/* base corner of rectangle or endpt of line (in cell coordinates)	*/static int base_y_cc;static int end_x_wc;	/* end point of rectangle or endpt of line (in window coordinates)	*/static int end_y_wc;static int pad_org_x;	/* origin of pad (in window coordinates)				*/static int pad_org_y;static int button_pressed = FALSE; /* true if the mouse button has been pressed down		*/#define DRAW_RECT_OUTLINE(x, y) 					\   pw_vector(fted_canvas_pw, base_x_wc, base_y_wc, x,			\   		base_y_wc, PIX_XOR, FOREGROUND);			\   pw_vector(fted_canvas_pw, x, base_y_wc, x, y, PIX_XOR, FOREGROUND);	\   pw_vector(fted_canvas_pw, x, y, base_x_wc, y, PIX_XOR, FOREGROUND);	\   pw_vector(fted_canvas_pw, base_x_wc, y, base_x_wc,			\   		base_y_wc, PIX_XOR, FOREGROUND);		#define DRAW_LINE(x,y)							\   pw_vector(fted_canvas_pw, base_x_wc, base_y_wc, x, y, PIX_XOR, FOREGROUND);fted_line0(x, y, pad_num, mouse_button, shifted)register int	x, y;				/* coord of point	*/register int	pad_num;			/* index of button	*/int		mouse_button;			/* which mouse button was used */int		shifted;			/* true if the shift key is down */{    fted_message_user("To draw a line, press down a mouse button and move the mouse.");    fted_line_reset(x, y, pad_num, mouse_button, shifted);}fted_line1(x, y, pad_num, mouse_button, shifted)register int	x, y;				/* coord of point	*/register int	pad_num;			/* index of button	*/int		mouse_button;			/* which mouse button was used */int		shifted;			/* true if the shift key is down */{    register int cur_cell_x, cur_cell_y;        GET_ORG(pad_org_x, pad_org_y);    GET_CELL(cur_cell_x, cur_cell_y, x, y, pad_org_x, pad_org_y);    base_x_cc = cur_cell_x;    base_y_cc = cur_cell_y;    base_x_wc = end_x_wc = (cur_cell_x * CELL_SIZE + pad_org_x) + (CELL_SIZE / 2);    base_y_wc = end_y_wc = (cur_cell_y * CELL_SIZE + pad_org_y) + (CELL_SIZE / 2);    DRAW_LINE(end_x_wc, end_y_wc);    fted_message_user("Now, move the mouse.");    button_pressed = TRUE;}fted_line2(x, y, pad_num, mouse_button, shifted)register int	x, y;				/* coord of point	*/register int	pad_num;			/* index of button	*/int		mouse_button;			/* which mouse button was used */int		shifted;			/* true if the shift key is down */{    register int cur_cell_x, cur_cell_y;    if (!button_pressed)       return;    GET_CELL(cur_cell_x, cur_cell_y, x, y, pad_org_x, pad_org_y);    DRAW_LINE(end_x_wc, end_y_wc);    end_x_wc = (cur_cell_x * CELL_SIZE + pad_org_x) + (CELL_SIZE / 2);    end_y_wc = (cur_cell_y * CELL_SIZE + pad_org_y) + (CELL_SIZE / 2);    DRAW_LINE(end_x_wc, end_y_wc);}fted_line_reset(x, y, pad_num, mouse_button, shifted)register int	x, y;				/* coord of point	*/register int	pad_num;			/* index of button	*/int		mouse_button;			/* which mouse button was used */int		shifted;			/* true if the shift key is down */{    if (button_pressed) {	DRAW_LINE(end_x_wc, end_y_wc);	button_pressed = FALSE;    }}    fted_line3(x, y, pad_num, mouse_button, shifted)register int	x, y;				/* coord of point	*/register int	pad_num;			/* index of button	*/int		mouse_button;			/* which mouse button was used */int		shifted;			/* true if the shift key is down */{    register int cur_cell_x, cur_cell_y;    int  color;    struct pixrect *pr;	        if (!button_pressed)       return;    DRAW_LINE(end_x_wc, end_y_wc);        GET_CELL(cur_cell_x, cur_cell_y, x, y, pad_org_x, pad_org_y);    if (mouse_button == MS_LEFT)	color = FOREGROUND;    else	color = BACKGROUND;        fted_undo_push(&(fted_edit_pad_info[pad_num]));    fted_draw_line_of_cells(pad_org_x, pad_org_y, cur_cell_x, cur_cell_y,	                   			 base_x_cc, base_y_cc, color);    pr = fted_edit_pad_info[pad_num].pix_char_ptr->pc_pr;    pr_vector(pr,cur_cell_x, cur_cell_y, base_x_cc, base_y_cc, PIX_SRC, color);        pw_write(fted_canvas_pw, fted_edit_pad_info[pad_num].proof.out_fted_line2.r_left + PROOF_X_OFFSET,	                    fted_edit_pad_info[pad_num].proof.out_fted_line2.r_top + PROOF_Y_OFFSET,			    fted_char_max_width, fted_char_max_height,			    PIX_SRC, pr, 0, 0);    fted_message_user("  ");    button_pressed = FALSE;    fted_edit_pad_info[pad_num].modified = TRUE;}fted_rect0(x, y, pad_num, mouse_button, shifted)register int	x, y;				/* coord of point	*/register int	pad_num;			/* index of button	*/int		mouse_button;			/* which mouse button was used */int		shifted;			/* true if the shift key is down */{    fted_message_user("To define a rectangle, press down a mouse button and move the mouse.");    fted_rect_reset(x, y, pad_num, mouse_button, shifted);}fted_rect1(x, y, pad_num, mouse_button, shifted)register int	x, y;				/* coord of point	*/register int	pad_num;			/* index of button	*/int		mouse_button;			/* which mouse button was used */int		shifted;			/* true if the shift key is down */{    register int cur_cell_x, cur_cell_y;        GET_ORG(pad_org_x, pad_org_y);    GET_CELL(cur_cell_x, cur_cell_y, x, y, pad_org_x, pad_org_y);    base_x_cc = cur_cell_x;    base_y_cc = cur_cell_y;    base_x_wc = end_x_wc =    				(cur_cell_x * CELL_SIZE + pad_org_x) + (CELL_SIZE / 2);    base_y_wc = end_y_wc =    				(cur_cell_y * CELL_SIZE + pad_org_y) + (CELL_SIZE / 2);    DRAW_RECT_OUTLINE(end_x_wc, end_y_wc);    fted_message_user("Now, move the mouse.");    button_pressed = TRUE;}fted_rect2(x, y, pad_num, mouse_button, shifted)register int	x, y;				/* coord of point	*/register int	pad_num;			/* index of button	*/int		mouse_button;			/* which mouse button was used */int		shifted;			/* true if the shift key is down */{    register int cur_cell_x, cur_cell_y;    if (!button_pressed)       return;    GET_CELL(cur_cell_x, cur_cell_y, x, y, pad_org_x, pad_org_y);    DRAW_RECT_OUTLINE(end_x_wc, end_y_wc);    end_x_wc = (cur_cell_x * CELL_SIZE + pad_org_x) + (CELL_SIZE / 2);    end_y_wc = (cur_cell_y * CELL_SIZE + pad_org_y) + (CELL_SIZE / 2);    DRAW_RECT_OUTLINE(end_x_wc, end_y_wc);}fted_rect_reset(x, y, pad_num, mouse_button, shifted)register int	x, y;				/* coord of point	*/register int	pad_num;			/* index of button	*/int		mouse_button;			/* which mouse button was used */int		shifted;			/* true if the shift key is down */{    if (button_pressed) {	DRAW_RECT_OUTLINE(end_x_wc, end_y_wc);	button_pressed = FALSE;    }}    fted_rect3(x, y, pad_num, mouse_button, shifted)register int	x, y;				/* coord of point	*/register int	pad_num;			/* index of button	*/int		mouse_button;			/* which mouse button was used */int		shifted;			/* true if the shift key is down */{    register int cur_cell_x, cur_cell_y;    int  color;    struct pixrect *pr;	        if (!button_pressed)       return;    DRAW_RECT_OUTLINE(end_x_wc, end_y_wc);        GET_CELL(cur_cell_x, cur_cell_y, x, y, pad_org_x, pad_org_y);	if (mouse_button == MS_LEFT)	   color = FOREGROUND;	else	   color = BACKGROUND;    fted_undo_push(&(fted_edit_pad_info[pad_num]));    fted_draw_line_of_cells(pad_org_x, pad_org_y, cur_cell_x, cur_cell_y,                			 base_x_cc, cur_cell_y, color);    fted_draw_line_of_cells(pad_org_x, pad_org_y, base_x_cc, cur_cell_y,        	       			 base_x_cc, base_y_cc, color);    fted_draw_line_of_cells(pad_org_x, pad_org_y, base_x_cc, base_y_cc,					 cur_cell_x, base_y_cc, color);    fted_draw_line_of_cells(pad_org_x, pad_org_y, cur_cell_x, base_y_cc,	 				 cur_cell_x, cur_cell_y, color);    pr = fted_edit_pad_info[pad_num].pix_char_ptr->pc_pr;    pr_vector(pr, cur_cell_x, cur_cell_y, base_x_cc, cur_cell_y,					PIX_SRC, color);    pr_vector(pr, base_x_cc, cur_cell_y, base_x_cc, base_y_cc,					PIX_SRC, color);    pr_vector(pr, base_x_cc, base_y_cc,    cur_cell_x, base_y_cc,					PIX_SRC, color);    pr_vector(pr, cur_cell_x, base_y_cc, cur_cell_x,					cur_cell_y, PIX_SRC, color);    pw_write(fted_canvas_pw, fted_edit_pad_info[pad_num].proof.out_fted_line2.r_left +					PROOF_X_OFFSET,	                    fted_edit_pad_info[pad_num].proof.out_fted_line2.r_top +			    		PROOF_Y_OFFSET,			    fted_char_max_width, fted_char_max_height,			    PIX_SRC, pr, 0, 0);    fted_message_user("  ");    button_pressed = FALSE;    fted_edit_pad_info[pad_num].modified = TRUE;}/* * A pixrect is used as the buffer to hold data used by the cut,copy and * paste routines. fted_buffer_rect contains the location and size of the * buffer. *  * previous_shift is used in a hack to implement an accelerator for * the cut/copy - paste steps. If the shift key is held down while in * cut or copy mode, paste mode is entered. previous_shift is used to * tell if the shift key is pressed or left up during an operation.  */static unsigned int buffer[((MAX_FONT_CHAR_SIZE_WIDTH / 32) + 1)*MAX_FONT_CHAR_SIZE_HEIGHT];mpr_static(fted_buffer_pixrect, MAX_FONT_CHAR_SIZE_WIDTH, MAX_FONT_CHAR_SIZE_HEIGHT, 1,			(short *)buffer);struct pixrect	*fted_buffer_pr = &fted_buffer_pixrect;struct rect 	fted_buffer_rect;static int	buffer_empty = TRUE;static int 	previous_shift;			/* the previous value of the shift key*/fted_cut_copy1(x, y, pad_num, mouse_button, shifted)register int	x, y;				/* coord of point	*/register int	pad_num;			/* index of button	*/int		mouse_button;			/* which mouse button was used */int		shifted;			/* true if the shift key is down */{    previous_shift = shifted;    if (shifted)    	fted_paste1(x, y, pad_num, mouse_button, shifted);    else    	fted_rect1(x, y, pad_num, mouse_button, shifted);}

⌨️ 快捷键说明

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