Debian Codegraph @

pencil/include/draw/draw_relationship_label.h

raw
1 /* File: draw_relationship_label.h; Copyright and License: see below */
2
3 #ifndef DRAW_RELATIONSHIP_LABEL_H
4 #define DRAW_RELATIONSHIP_LABEL_H
5
6 /* public file for the doxygen documentation: */
7 /*!
8 * \file
9 * \brief Draws titles and types of relationships
10 */
11
12 #include "draw/draw_line_breaker.h"
13 #include "draw/draw_stereotype_icon.h"
14 #include "pencil_size.h"
15 #include "geometry/geometry_h_align.h"
16 #include "geometry/geometry_v_align.h"
17 #include "geometry/geometry_rectangle.h"
18 #include "geometry/geometry_dimensions.h"
19 #include "entity/data_relationship.h"
20 #include "set/data_profile_part.h"
21 #include "utf8stream/utf8stream_writemem.h"
22 #include <cairo.h>
23 #include <stdint.h>
24
25 /*!
26 * \brief attributes of the draw label functions
27 *
28 * \note This class is stateless.
29 * It may either be instantiated once and used many times or be instantiated per use.
30 */
31 struct draw_relationship_label_struct {
32 char text_buffer[ ( DATA_RELATIONSHIP_MAX_NAME_SIZE ) * 4 ]; /*!< x4 because any character may be followed by a 3-byte space */
33 utf8stream_writemem_t text_builder; /*!< a pair of utf8stream_writer_t and universal_memory_output_stream_t to build an output text */
34 draw_line_breaker_t linebr; /*!< An object to insert zero-width spaces (a 3 byte utf8 sequence) wherever a linebreak is allowed */
35 draw_stereotype_icon_t image_renderer; /*!< own instance of stereotype image renderer */
36 };
37
38 typedef struct draw_relationship_label_struct draw_relationship_label_t;
39
40 /*!
41 * \brief initializes the draw_relationship_label_t
42 *
43 * \param this_ pointer to own object attributes
44 */
45 void draw_relationship_label_init( draw_relationship_label_t *this_ );
46
47 /*!
48 * \brief destroys the draw_relationship_label_t
49 *
50 * \param this_ pointer to own object attributes
51 */
52 void draw_relationship_label_destroy( draw_relationship_label_t *this_ );
53
54 /*!
55 * \brief determines the dimensions of the stereotype and name of the relationship.
56 *
57 * \param this_ pointer to own object attributes
58 * \param relationship the relationship to draw
59 * \param profile profile-part that provides the stereotype definition of the element to be drawn
60 * \param proposed_bounds proposed bounds for the text width and height
61 * \param pencil_size set of sizes and colors for drawing lines and text
62 * \param font_layout pango layout object to determine the font metrics in the current cairo drawing context
63 * \param out_label_dim width and height of the type and name is returned. NULL is not permitted.
64 */
65 void draw_relationship_label_get_type_and_name_dimensions( draw_relationship_label_t *this_,
66 const data_relationship_t *relationship,
67 const data_profile_part_t *profile,
68 const geometry_dimensions_t *proposed_bounds,
69 const pencil_size_t *pencil_size,
70 PangoLayout *font_layout,
71 geometry_dimensions_t *out_label_dim
72 );
73
74 /*!
75 * \brief renders stereotype and name of the relationship.
76 *
77 * \param this_ pointer to own object attributes
78 * \param relationship the relationship to draw
79 * \param profile profile-part that provides the stereotype definition of the element to be drawn
80 * \param color color to draw text and to use as default for stereotype-image strokes
81 * \param label_box the rectangle where to draw to
82 * \param pencil_size set of sizes and colors for drawing lines and text
83 * \param font_layout pango layout object to determine the font metrics in the current cairo drawing context
84 * \param cr the cairo drawing context.
85 */
86 void draw_relationship_label_draw_type_and_name( draw_relationship_label_t *this_,
87 const data_relationship_t *relationship,
88 const data_profile_part_t *profile,
89 const GdkRGBA *color,
90 const geometry_rectangle_t *label_box,
91 const pencil_size_t *pencil_size,
92 PangoLayout *font_layout,
93 cairo_t *cr
94 );
95
96 /*!
97 * \brief gets the stereotype name for a given data_relationship_type_t.
98 *
99 * \param this_ pointer to own object attributes
100 * \param rel_type the relationship type to convert to a stereotype
101 * \return name of the stereotype if there is one associated to the rel_type, empty string "" otherwise, never NULL.
102 */
103 static inline char const * draw_relationship_label_private_stereotype_from_type( const draw_relationship_label_t *this_,
104 data_relationship_type_t rel_type
105 );
106
107 #include "draw_relationship_label.inl"
108
109 #endif /* DRAW_RELATIONSHIP_LABEL_H */
110
111
112 /*
113 Copyright 2019-2026 Andreas Warnke
114
115 Licensed under the Apache License, Version 2.0 (the "License");
116 you may not use this file except in compliance with the License.
117 You may obtain a copy of the License at
118
119 http://www.apache.org/licenses/LICENSE-2.0
120
121 Unless required by applicable law or agreed to in writing, software
122 distributed under the License is distributed on an "AS IS" BASIS,
123 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
124 See the License for the specific language governing permissions and
125 limitations under the License.
126 */