~ubuntu-branches/ubuntu/trusty/xfig/trusty

« back to all changes in this revision

Viewing changes to d_arcbox.c

  • Committer: Bazaar Package Importer
  • Author(s): Roland Rosenfeld
  • Date: 2002-03-22 10:39:49 UTC
  • Revision ID: james.westby@ubuntu.com-20020322103949-63082hoxulq6n7u1
Tags: upstream-3.2.3.d-rel
ImportĀ upstreamĀ versionĀ 3.2.3.d-rel

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * FIG : Facility for Interactive Generation of figures
 
3
 * Copyright (c) 1985-1988 by Supoj Sutanthavibul
 
4
 * Parts Copyright (c) 1989-2000 by Brian V. Smith
 
5
 * Parts Copyright (c) 1991 by Paul King
 
6
 *
 
7
 * Any party obtaining a copy of these files is granted, free of charge, a
 
8
 * full and unrestricted irrevocable, world-wide, paid up, royalty-free,
 
9
 * nonexclusive right and license to deal in this software and
 
10
 * documentation files (the "Software"), including without limitation the
 
11
 * rights to use, copy, modify, merge, publish, distribute, sublicense,
 
12
 * and/or sell copies of the Software, and to permit persons who receive
 
13
 * copies from any such party to do so, with the only requirement being
 
14
 * that this copyright notice remain intact.
 
15
 *
 
16
 */
 
17
 
 
18
#include "fig.h"
 
19
#include "resources.h"
 
20
#include "mode.h"
 
21
#include "object.h"
 
22
#include "paintop.h"
 
23
#include "u_create.h"
 
24
#include "u_elastic.h"
 
25
#include "u_list.h"
 
26
#include "w_canvas.h"
 
27
#include "w_cursor.h"
 
28
#include "w_msgpanel.h"
 
29
#include "w_mousefun.h"
 
30
 
 
31
/*************************** local procedures *********************/
 
32
 
 
33
static void     create_arc_boxobject();
 
34
static void     cancel_arc_boxobject();
 
35
static void     init_arc_box_drawing();
 
36
 
 
37
void
 
38
arcbox_drawing_selected()
 
39
{
 
40
    set_mousefun("corner point", "", "", "", "", "");
 
41
    canvas_kbd_proc = null_proc;
 
42
    canvas_locmove_proc = null_proc;
 
43
    canvas_leftbut_proc = init_arc_box_drawing;
 
44
    canvas_middlebut_proc = null_proc;
 
45
    canvas_rightbut_proc = null_proc;
 
46
    set_cursor(arrow_cursor);
 
47
    reset_action_on();
 
48
}
 
49
 
 
50
static void
 
51
init_arc_box_drawing(x, y)
 
52
    int             x, y;
 
53
{
 
54
    cur_x = fix_x = x;
 
55
    cur_y = fix_y = y;
 
56
    set_mousefun("final point", "", "cancel", "", "", "");
 
57
    draw_mousefun_canvas();
 
58
    canvas_locmove_proc = resizing_box;
 
59
    canvas_leftbut_proc = create_arc_boxobject;
 
60
    canvas_middlebut_proc = null_proc;
 
61
    canvas_rightbut_proc = cancel_arc_boxobject;
 
62
    elastic_box(fix_x, fix_y, cur_x, cur_y);
 
63
    set_cursor(null_cursor);
 
64
    set_action_on();
 
65
}
 
66
 
 
67
static void
 
68
cancel_arc_boxobject()
 
69
{
 
70
    elastic_box(fix_x, fix_y, cur_x, cur_y);
 
71
    arcbox_drawing_selected();
 
72
    draw_mousefun_canvas();
 
73
}
 
74
 
 
75
static void
 
76
create_arc_boxobject(x, y)
 
77
    int             x, y;
 
78
{
 
79
    F_line         *box;
 
80
    F_point        *point;
 
81
 
 
82
    elastic_box(fix_x, fix_y, cur_x, cur_y);
 
83
    /* erase last lengths if appres.showlengths is true */
 
84
    erase_box_lengths();
 
85
 
 
86
    if (fix_x == x || fix_y == y) {
 
87
        beep();
 
88
        put_msg("Arc box must have area");
 
89
        arcbox_drawing_selected();
 
90
        draw_mousefun_canvas();
 
91
        return;
 
92
    }
 
93
 
 
94
    if ((point = create_point()) == NULL)
 
95
        return;
 
96
 
 
97
    point->x = x;
 
98
    point->y = y;
 
99
    point->next = NULL;
 
100
 
 
101
    if ((box = create_line()) == NULL) {
 
102
        free((char *) point);
 
103
        return;
 
104
    }
 
105
    box->type = T_ARC_BOX;
 
106
    box->style = cur_linestyle;
 
107
    box->thickness = cur_linewidth;
 
108
    box->pen_color = cur_pencolor;
 
109
    box->fill_color = cur_fillcolor;
 
110
    box->depth = cur_depth;
 
111
    box->pen_style = 0;
 
112
    box->join_style = cur_joinstyle;
 
113
    box->cap_style = cur_capstyle;
 
114
    box->fill_style = cur_fillstyle;
 
115
    /* multiply  dash length by line thickness */
 
116
    box->style_val = cur_styleval * (cur_linewidth + 1) / 2;
 
117
    box->radius = cur_boxradius;/* corner radius */
 
118
    box->points = point;
 
119
    append_point(x, fix_y, &point);
 
120
    append_point(fix_x, fix_y, &point);
 
121
    append_point(fix_x, y, &point);
 
122
    append_point(x, y, &point);
 
123
    add_line(box);
 
124
    reset_action_on(); /* this signals redisplay_curobj() not to refresh */
 
125
    /* draw it and anything on top of it */
 
126
    redisplay_line(box);
 
127
    arcbox_drawing_selected();
 
128
    draw_mousefun_canvas();
 
129
}