-
Notifications
You must be signed in to change notification settings - Fork 0
/
d_box.cpp
executable file
·117 lines (103 loc) · 2.88 KB
/
d_box.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
extern "C" {
#include "fig.h"
#include "resources.h"
#include "mode.h"
#include "object.h"
#include "paintop.h"
#include "d_box.h"
#include "u_create.h"
#include "u_elastic.h"
#include "u_list.h"
#include "w_canvas.h"
#include "w_mousefun.h"
#include "f_util.h"
#include "u_redraw.h"
#include "w_cursor.h"
#include "w_msgpanel.h"
}
/*************************** local declarations *********************/
static void create_boxobject(int x, int y);
static void cancel_box(int, int);
void
box_drawing_selected(void)
{
set_mousefun("corner point", "", "", "", "", "");
canvas_kbd_proc = (FCallBack) null_proc;
canvas_locmove_proc = null_proc;
canvas_leftbut_proc = (FCallBack)init_box_drawing;
canvas_middlebut_proc = (FCallBack)null_proc;
canvas_rightbut_proc = (FCallBack)null_proc;
set_cursor(crosshair_cursor);
reset_action_on();
}
void init_box_drawing(int x, int y)
{
cur_x = fix_x = x;
cur_y = fix_y = y;
set_mousefun("final point", "", "cancel", "", "", "");
draw_mousefun_canvas();
canvas_locmove_proc = resizing_box;
canvas_leftbut_proc = (FCallBack)create_boxobject;
canvas_middlebut_proc = (FCallBack)null_proc;
canvas_rightbut_proc = (FCallBack)cancel_box;
elastic_box(fix_x, fix_y, cur_x, cur_y);
set_cursor(null_cursor);
set_action_on();
}
static void
cancel_box(int a, int b)
{
elastic_box(fix_x, fix_y, cur_x, cur_y);
/* erase last lengths if appres.showlengths is true */
erase_box_lengths();
box_drawing_selected();
draw_mousefun_canvas();
}
static void
create_boxobject(int x, int y)
{
F_line *box;
F_point *point;
elastic_box(fix_x, fix_y, cur_x, cur_y);
/* erase last lengths if appres.showlengths is true */
erase_box_lengths();
if (fix_x == x || fix_y == y) {
beep();
put_msg("Box must have area");
box_drawing_selected();
draw_mousefun_canvas();
return;
}
if ((point = create_point()) == NULL)
return;
point->x = fix_x;
point->y = fix_y;
point->next = NULL;
if ((box = create_line()) == NULL) {
free((char *) point);
return;
}
box->type = T_BOX;
box->style = cur_linestyle;
box->thickness = cur_linewidth;
box->pen_color = cur_pencolor;
box->fill_color = cur_fillcolor;
box->depth = cur_depth;
box->pen_style = -1;
box->join_style = cur_joinstyle;
box->cap_style = cur_capstyle;
box->fill_style = cur_fillstyle;
/* scale dash length by line thickness */
box->style_val = cur_styleval * (cur_linewidth + 1) / 2;
box->points = point;
append_point(x, fix_y, &point);
append_point(x, y, &point);
append_point(fix_x, y, &point);
append_point(fix_x, fix_y, &point);
add_line(box);
reset_action_on(); /* this signals redisplay_curobj() not to refresh */
/* draw it and anything on top of it */
redisplay_line(box);
box_drawing_selected();
draw_mousefun_canvas();
}