Text objects are now internally encapsulated, simplifying code and
[dia.git] / lib / arrows.h
blob7f698815d9ce7b33fd0ed038273f548491a9ff23
1 /* Dia -- an diagram creation/manipulation program
2 * Copyright (C) 1998 Alexander Larsson
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 #ifndef ARROWS_H
19 #define ARROWS_H
21 #include "diavar.h"
22 #include "diatypes.h"
23 #include "geometry.h"
24 #include "color.h"
25 #include "dia_xml.h"
26 #include "attributes.h"
27 #include "widgets.h"
29 /* NOTE: Add new arrow types at the end, or the enums
30 will change order leading to file incompatibilities. */
32 /* Comments in curly braces mention ISO 10303-AP201 names */
34 typedef enum {
35 ARROW_NONE,
36 ARROW_LINES, /* {open arrow} */
37 ARROW_HOLLOW_TRIANGLE, /* {blanked arrow} */
38 ARROW_FILLED_TRIANGLE, /* {filled arrow} */
39 ARROW_HOLLOW_DIAMOND,
40 ARROW_FILLED_DIAMOND,
41 ARROW_HALF_HEAD,
42 ARROW_SLASHED_CROSS, /* Vertical + diagonal line */
43 ARROW_FILLED_ELLIPSE,
44 ARROW_HOLLOW_ELLIPSE,
45 ARROW_DOUBLE_HOLLOW_TRIANGLE,
46 ARROW_DOUBLE_FILLED_TRIANGLE,
47 ARROW_UNFILLED_TRIANGLE, /* {unfilled arrow} */
48 ARROW_FILLED_DOT, /* {filled dot} Ellipse + vertical line */
49 ARROW_DIMENSION_ORIGIN, /* {dimension origin} Ellipse + vert line */
50 ARROW_BLANKED_DOT, /* {blanked dot} Empty ellipse + vert line */
51 ARROW_FILLED_BOX, /* {filled box} Box + vertical line */
52 ARROW_BLANKED_BOX, /* {blanked box} Box + vertical line */
53 ARROW_SLASH_ARROW, /* {slash arrow} Vertical + diagonal line*/
54 ARROW_INTEGRAL_SYMBOL, /* {integral symbol} Vertical + integral */
55 ARROW_CROW_FOOT,
56 ARROW_CROSS, /* Vertical line */
57 ARROW_FILLED_CONCAVE,
58 ARROW_BLANKED_CONCAVE,
59 ARROW_ROUNDED,
60 ARROW_HALF_DIAMOND, /* ---< */
61 ARROW_OPEN_ROUNDED, /* ---c */
62 ARROW_FILLED_DOT_N_TRIANGLE, /* ---|>o */
63 ARROW_ONE_OR_MANY, /* ER-model: 1 or many*/
64 ARROW_NONE_OR_MANY, /* ER-model: 0 or many*/
65 ARROW_ONE_OR_NONE, /* ER-model: 1 or 0 */
66 ARROW_ONE_EXACTLY, /* ER-model: exactly one*/
67 ARROW_BACKSLASH, /* -\---- */
68 ARROW_THREE_DOTS,
70 MAX_ARROW_TYPE /* No arrow heads may be defined beyond here. */
71 } ArrowType;
73 struct menudesc {
74 char *name;
75 ArrowType enum_value;
78 /** The number of centimeters long and wide an arrow starts with by default.
79 * This can be changed without breaking old diagrams, as the arrow width
80 * is stored in there.
81 * Note: Currently, many places have this number hardcoded.
82 * find . -name \*.[ch] | xargs grep \\.8
84 #define DEFAULT_ARROW_SIZE 0.5
86 /** The minimum width or length of an arrowhead. This to avoid borderline
87 * cases that break trig functions, as seen in bug #144394
89 #define MIN_ARROW_DIMENSION 0.001
91 /* These are used to fill menus. See dia_arrow_fill_menu in widgets.c */
92 DIAVAR struct menudesc arrow_types[];
94 struct _Arrow {
95 ArrowType type;
96 real length;
97 real width;
100 void arrow_draw(DiaRenderer *renderer, ArrowType type,
101 Point *to, Point *from,
102 real length, real width, real linewidth,
103 Color *fg_color, Color *bg_color);
105 void
106 calculate_arrow_point(const Arrow *arrow, const Point *to, const Point *from,
107 Point *move_arrow, Point *move_line,
108 real linewidth);
110 /* Transforms 'start' to be at the back end of the arrow, and puts the
111 * tip of the arrow into 'arrowtip'.
113 void arrow_transform_points(Arrow *arrow, Point *start, Point *to,
114 int linewidth, Point *arrowtip);
116 void save_arrow(ObjectNode obj_node, Arrow *arrow, gchar *type_attribute,
117 gchar *length_attribute, gchar *width_attribute);
118 void load_arrow(ObjectNode obj_node, Arrow *arrow, gchar *type_attribute,
119 gchar *length_attribute, gchar *width_attribute);
121 /** Returns the ArrowType for a given name of an arrow, or 0 if not found. */
122 ArrowType arrow_type_from_name(gchar *name);
123 /** Returns the index in arrow_types of the given arrow type. */
124 gint arrow_index_from_type(ArrowType type);
125 gchar *arrow_get_name_from_type(ArrowType type);
126 GList *get_arrow_names(void);
128 #endif /* ARROWS_H */