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

📄 fted_draw.c

📁 操作系统SunOS 4.1.3版本的源码
💻 C
📖 第 1 页 / 共 3 页
字号:
#ifndef lint#ifdef sccsstatic	char sccsid[] = "@(#)fted_draw.c 1.1 92/07/30 Copyr 1984 Sun Micro";#endif#endif/* * Copyright (c) 1984 by Sun Microsystems, Inc. */#include <stdio.h>#include <signal.h>#include "other_hs.h"#include "fontedit.h"#include "externs.h"#include "button.h"#include "slider.h"#include "patches.h"#include "edit.h"/* * This file contains the routines to do the drawing operations * in the edit pad. In general, most operations require 2 or more * steps (e.g. button down, and move to position a line and button * up to actually draw it) and information is saved during the  * transition from state to state in static, global variables. *  * It might be helpful to point out here that there are 3 * coordinate systems used. * The first is the coordinate system of the subwindow with * the origin in the upper left hand corner of the subwindow. * The second is the coordinate system of the edit pad; it's  * origin is the upper left hand corner of the inner-most rect * of the edit_pad (i.e. the out_fted_line2 rect). The third system * that of the pixrect which holds the glyph of the character  * being edited. So, the cursor position is in the first system; * subtracting the the upper left hand corner of the out_fted_line2 * rect from cursor position yields a coordinate in the second * system and dividing by the cell size yields a value in * the last system. *  * Most operations have 5 routines/states * xxx0: is the start state - it prints out an explanitory message * xxx1: what happens when the a mouse button is pressed down - init things * xxx2: what happens as the mouse is moved with the button down - feed back * xxx3: "    "       when the button is released - preform the action * xxx_reset: reset things  *  * See input.c and action_table.h  */static int	hilight_displayed = FALSE;/* true if a hilight is displayed */static int	old_org_x, old_org_y;static int	old_cell_x, old_cell_y;	/* previously hilighted location */static int	old_cell_color;		/* "          "         "'s color value */static int	pt_wipe_down = FALSE;	/* true if button pressed down for */					/* point wipe function  */#define GET_ORG(X,Y)							\    X = fted_edit_pad_groups[pad_num].edit->buttons[EDIT_BUTTON]->out_fted_line2.r_left;	\    Y = fted_edit_pad_groups[pad_num].edit->buttons[EDIT_BUTTON]->out_fted_line2.r_top;  #define GET_CELL(CELL_X, CELL_Y, X, Y, ORG_X, ORG_Y)			\    CELL_X = (X - ORG_X) / CELL_SIZE;					\    CELL_Y = (Y - ORG_Y) / CELL_SIZE;    /* * A hilighted cell is gray in color (rather than black or white). * fted_hilight_cell is the initializer routine and it saves the old * color of the cell by looking at the characters pixrect. * The next routine moves the hilight by restoring the previous * cell's value and hilighting the current cell. */fted_hilight_cell(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 */{    GET_ORG(old_org_x, old_org_y);    GET_CELL(old_cell_x, old_cell_y, x, y, old_org_x, old_org_y);    old_cell_color = pr_get(fted_edit_pad_info[pad_num].pix_char_ptr->pc_pr,    					old_cell_x, old_cell_y);        fted_paint_cell(old_org_x, old_org_y, old_cell_x, old_cell_y, HI_LIGHT);    hilight_displayed = TRUE;}fted_move_hilight(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_org_x, cur_org_y;    register int cur_cell_x, cur_cell_y;        cur_org_x = fted_edit_pad_groups[pad_num].edit->buttons[EDIT_BUTTON]->out_fted_line2.r_left;    cur_org_y = fted_edit_pad_groups[pad_num].edit->buttons[EDIT_BUTTON]->out_fted_line2.r_top;    cur_cell_x = (x - cur_org_x) / CELL_SIZE;	    cur_cell_y = (y - cur_org_y) / CELL_SIZE;    if (!hilight_displayed)        fted_hilight_cell(x, y, pad_num, mouse_button, shifted);    if ((cur_cell_x != old_cell_x) || (cur_cell_y != old_cell_y) ){	fted_paint_cell(old_org_x, old_org_y, old_cell_x, old_cell_y, old_cell_color); 	old_cell_color = pr_get(fted_edit_pad_info[pad_num].pix_char_ptr->pc_pr, cur_cell_x, cur_cell_y);	old_org_x = cur_org_x;	old_org_y = cur_org_y;	old_cell_x = cur_cell_x;	old_cell_y = cur_cell_y;	fted_paint_cell(cur_org_x, cur_org_y, cur_cell_x, cur_cell_y, HI_LIGHT);    }}fted_reset_cell_hilight(){    if (hilight_displayed) {	fted_paint_cell(old_org_x, old_org_y, old_cell_x, old_cell_y, old_cell_color);	hilight_displayed = FALSE;    }}/* * These routines draw a single point on button up. the two previous * routines handle what happens as the mouse is moved around with * button down. */fted_point_single0(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(       "Left button draws, middle erases a single point; release the button to do the action.");}fted_point_single3(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_org_x, cur_org_y;    register int cur_cell_x, cur_cell_y;    register int color;    fted_reset_cell_hilight();    cur_org_x = fted_edit_pad_groups[pad_num].edit->buttons[EDIT_BUTTON]->out_fted_line2.r_left;    cur_org_y = fted_edit_pad_groups[pad_num].edit->buttons[EDIT_BUTTON]->out_fted_line2.r_top;    cur_cell_x = (x - cur_org_x) / CELL_SIZE;	/* calculate the coords of the point in the definition of the character */    cur_cell_y = (y - cur_org_y) / CELL_SIZE;    fted_undo_push(&(fted_edit_pad_info[pad_num]));    if (mouse_button == MS_LEFT) 	color = FOREGROUND;    else  	color = BACKGROUND;	    fted_paint_cell(cur_org_x, cur_org_y, cur_cell_x, cur_cell_y, color);    pr_put(fted_edit_pad_info[pad_num].pix_char_ptr->pc_pr, cur_cell_x, cur_cell_y, color);    pw_put(fted_canvas_pw, fted_edit_pad_info[pad_num].proof.out_fted_line2.r_left + cur_cell_x + PROOF_X_OFFSET,                      fted_edit_pad_info[pad_num].proof.out_fted_line2.r_top + cur_cell_y + PROOF_Y_OFFSET, color);    hilight_displayed = FALSE;    fted_edit_pad_info[pad_num].modified = TRUE;}/* * Point wipe draws a point while a mouse button is depressed. */fted_point_wipe0(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("Press and hold button to wipe points.");}fted_point_wipe1(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_org_x, cur_org_y;    register int cur_cell_x, cur_cell_y;    register int color;        GET_ORG(cur_org_x, cur_org_y);    GET_CELL(cur_cell_x, cur_cell_y, x, y, cur_org_x, cur_org_y);    if (mouse_button == MS_LEFT) 	color = FOREGROUND;    else  	color = BACKGROUND;    fted_undo_push(&(fted_edit_pad_info[pad_num]));	    fted_paint_cell(cur_org_x, cur_org_y, cur_cell_x, cur_cell_y, color);    pr_put(fted_edit_pad_info[pad_num].pix_char_ptr->pc_pr, cur_cell_x, 		cur_cell_y, color);    pw_put(fted_canvas_pw, fted_edit_pad_info[pad_num].proof.out_fted_line2.r_left + 			cur_cell_x + PROOF_X_OFFSET,		fted_edit_pad_info[pad_num].proof.out_fted_line2.r_top + 			cur_cell_y + PROOF_Y_OFFSET, color);    fted_edit_pad_info[pad_num].modified = TRUE;    pt_wipe_down = TRUE;    old_cell_x = cur_cell_x;    old_cell_y = cur_cell_y;}fted_point_wipe2(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_org_x, cur_org_y;    register int cur_cell_x, cur_cell_y;    register int color;        GET_ORG(cur_org_x, cur_org_y);    GET_CELL(cur_cell_x, cur_cell_y, x, y, cur_org_x, cur_org_y);    if (!pt_wipe_down)    	fted_point_wipe1(x, y, pad_num, mouse_button, shifted);    if ((cur_cell_x == old_cell_x) && (cur_cell_y == old_cell_y))	return;    if (mouse_button == MS_LEFT) 	color = FOREGROUND;    else  	color = BACKGROUND;    fted_undo_push(&(fted_edit_pad_info[pad_num]));	    fted_paint_cell(cur_org_x, cur_org_y, cur_cell_x, cur_cell_y, color);    pr_put(fted_edit_pad_info[pad_num].pix_char_ptr->pc_pr, cur_cell_x, 		cur_cell_y, color);    pw_put(fted_canvas_pw, fted_edit_pad_info[pad_num].proof.out_fted_line2.r_left + 			cur_cell_x + PROOF_X_OFFSET,		fted_edit_pad_info[pad_num].proof.out_fted_line2.r_top + 			cur_cell_y + PROOF_Y_OFFSET, color);    fted_edit_pad_info[pad_num].modified = TRUE;        old_cell_x = cur_cell_x;    old_cell_y = cur_cell_y;}fted_point_wipe3(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_org_x, cur_org_y;    register int cur_cell_x, cur_cell_y;    register int color;        GET_ORG(cur_org_x, cur_org_y);    GET_CELL(cur_cell_x, cur_cell_y, x, y, cur_org_x, cur_org_y);    if (!pt_wipe_down)    	fted_point_wipe1(x, y, pad_num, mouse_button, shifted);        pt_wipe_down = FALSE;    if ((cur_cell_x == old_cell_x) && (cur_cell_y == old_cell_y))	return;    if (mouse_button == MS_LEFT) 	color = FOREGROUND;    else  	color = BACKGROUND;    fted_undo_push(&(fted_edit_pad_info[pad_num]));	    fted_paint_cell(cur_org_x, cur_org_y, cur_cell_x, cur_cell_y, color);    pr_put(fted_edit_pad_info[pad_num].pix_char_ptr->pc_pr, cur_cell_x, 		cur_cell_y, color);    pw_put(fted_canvas_pw, fted_edit_pad_info[pad_num].proof.out_fted_line2.r_left + 			cur_cell_x + PROOF_X_OFFSET,		fted_edit_pad_info[pad_num].proof.out_fted_line2.r_top + 			cur_cell_y + PROOF_Y_OFFSET, color);

⌨️ 快捷键说明

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