Line data Source code
1 : /* File: pos_nav_tree_node.inl; Copyright and License: see below */
2 :
3 : #include <assert.h>
4 :
5 15 : static inline void pos_nav_tree_node_init ( pos_nav_tree_node_t *this_,
6 : pos_nav_tree_node_type_t node_type,
7 : const data_diagram_t *diagram_data )
8 : {
9 15 : shape_int_rectangle_init_empty( &((*this_).icon_box) );
10 15 : shape_int_rectangle_init_empty( &((*this_).label_box) );
11 15 : (*this_).node_type = node_type;
12 15 : (*this_).data = diagram_data;
13 15 : }
14 :
15 15 : static inline void pos_nav_tree_node_destroy ( pos_nav_tree_node_t *this_ )
16 : {
17 15 : shape_int_rectangle_destroy( &((*this_).icon_box) );
18 15 : shape_int_rectangle_destroy( &((*this_).label_box) );
19 15 : (*this_).data = NULL;
20 15 : }
21 :
22 : static inline bool pos_nav_tree_node_is_valid ( const pos_nav_tree_node_t *this_ )
23 : {
24 : bool result;
25 : if ( (*this_).data == NULL )
26 : {
27 : result = false; /* can happen on initialized button objects */
28 : }
29 : else
30 : {
31 : result = data_diagram_is_valid( (*this_).data );
32 : }
33 : return result;
34 : }
35 :
36 160 : static inline const shape_int_rectangle_t *pos_nav_tree_node_get_icon_box_const ( const pos_nav_tree_node_t *this_ )
37 : {
38 160 : return &((*this_).icon_box);
39 : }
40 :
41 15 : static inline void pos_nav_tree_node_set_icon_box ( pos_nav_tree_node_t *this_, const shape_int_rectangle_t *icon_box )
42 : {
43 15 : shape_int_rectangle_replace( &((*this_).icon_box), icon_box );
44 15 : }
45 :
46 130 : static inline const shape_int_rectangle_t *pos_nav_tree_node_get_label_box_const ( const pos_nav_tree_node_t *this_ )
47 : {
48 130 : return &((*this_).label_box);
49 : }
50 :
51 15 : static inline void pos_nav_tree_node_set_label_box ( pos_nav_tree_node_t *this_, const shape_int_rectangle_t *label_box )
52 : {
53 15 : shape_int_rectangle_replace( &((*this_).label_box), label_box );
54 15 : }
55 :
56 30 : static inline pos_nav_tree_node_type_t pos_nav_tree_node_get_type ( const pos_nav_tree_node_t *this_ )
57 : {
58 30 : return (*this_).node_type;
59 : }
60 :
61 30 : static inline const data_diagram_t *pos_nav_tree_node_get_data_const ( const pos_nav_tree_node_t *this_ )
62 : {
63 30 : return (*this_).data;
64 : }
65 :
66 0 : static inline data_id_t pos_nav_tree_node_get_diagram_id ( const pos_nav_tree_node_t *this_ )
67 : {
68 : data_id_t result;
69 0 : if ( (*this_).data == NULL )
70 : {
71 : /* a button has no id */
72 0 : result = DATA_ID_VOID;
73 : }
74 : else
75 : {
76 0 : result = data_diagram_get_data_id( (*this_).data );
77 : }
78 0 : return result;
79 : }
80 :
81 :
82 : /*
83 : Copyright 2021-2025 Andreas Warnke
84 :
85 : Licensed under the Apache License, Version 2.0 (the "License");
86 : you may not use this file except in compliance with the License.
87 : You may obtain a copy of the License at
88 :
89 : http://www.apache.org/licenses/LICENSE-2.0
90 :
91 : Unless required by applicable law or agreed to in writing, software
92 : distributed under the License is distributed on an "AS IS" BASIS,
93 : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
94 : See the License for the specific language governing permissions and
95 : limitations under the License.
96 : */
|