1 /*
2  * Copyright (c) 2023-2024 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef C_INCLUDE_DRAWING_RECT_H
17 #define C_INCLUDE_DRAWING_RECT_H
18 
19 /**
20  * @addtogroup Drawing
21  * @{
22  *
23  * @brief Provides functions such as 2D graphics rendering, text drawing, and image display.
24  *
25  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
26  *
27  * @since 11
28  * @version 1.0
29  */
30 
31 /**
32  * @file drawing_rect.h
33  *
34  * @brief Declares functions related to the <b>rect</b> object in the drawing module.
35  *
36  * @since 11
37  * @version 1.0
38  */
39 
40 #include "drawing_types.h"
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 /**
47  * @brief Creates an <b>OH_Drawing_Rect</b> object.
48  *
49  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
50  * @param left Indicates the left position of the rect.
51  * @param top Indicates the top position of the rect.
52  * @param right Indicates the right position of the rect.
53  * @param bottom Indicates the bottom position of the rect.
54  * @return Returns the pointer to the <b>OH_Drawing_Rect</b> object created.
55  * @since 11
56  * @version 1.0
57  */
58 OH_Drawing_Rect* OH_Drawing_RectCreate(float left, float top, float right, float bottom);
59 
60 /**
61  * @brief If rect intersects other, sets rect to intersection.
62  *
63  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
64  * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
65  * @param other Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
66  * @return Returns true if have area in common.
67  * @since 12
68  * @version 1.0
69  */
70 bool OH_Drawing_RectIntersect(OH_Drawing_Rect* rect, const OH_Drawing_Rect* other);
71 
72 /**
73  * @brief Sets rect to the union of rect and other.
74  *
75  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
76  * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
77  * @param other Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
78  * @return Returns true if rect and other are not nullptr and other is not empty.
79  * @since 12
80  * @version 1.0
81  */
82 bool OH_Drawing_RectJoin(OH_Drawing_Rect* rect, const OH_Drawing_Rect* other);
83 
84 /**
85  * @brief Set the left position of the rect.
86  *
87  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
88  * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
89  * @param left Indicates the left position of the rect.
90  * @since 12
91  * @version 1.0
92  */
93 void OH_Drawing_RectSetLeft(OH_Drawing_Rect* rect, float left);
94 
95 /**
96  * @brief Set the top position of the rect.
97  *
98  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
99  * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
100  * @param top Indicates the top position of the rect.
101  * @since 12
102  * @version 1.0
103  */
104 void OH_Drawing_RectSetTop(OH_Drawing_Rect* rect, float top);
105 
106 /**
107  * @brief Set the right position of the rect.
108  *
109  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
110  * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
111  * @param right Indicates the right position of the rect.
112  * @since 12
113  * @version 1.0
114  */
115 void OH_Drawing_RectSetRight(OH_Drawing_Rect* rect, float right);
116 
117 /**
118  * @brief Set the bottom position of the rect.
119  *
120  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
121  * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
122  * @param bottom Indicates the bottom position of the rect.
123  * @since 12
124  * @version 1.0
125  */
126 void OH_Drawing_RectSetBottom(OH_Drawing_Rect* rect, float bottom);
127 
128 /**
129  * @brief Get the left position of the rect.
130  *
131  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
132  * @param OH_Drawing_Rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
133  * @return Return the left position of the rect.
134  * @since 12
135  * @version 1.0
136  */
137 float OH_Drawing_RectGetLeft(OH_Drawing_Rect*);
138 
139 /**
140  * @brief Get the top position of the rect.
141  *
142  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
143  * @param OH_Drawing_Rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
144  * @return Return the top position of the rect.
145  * @since 12
146  * @version 1.0
147  */
148 float OH_Drawing_RectGetTop(OH_Drawing_Rect*);
149 
150 /**
151  * @brief Get the right position of the rect.
152  *
153  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
154  * @param OH_Drawing_Rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
155  * @return Return the right position of the rect.
156  * @since 12
157  * @version 1.0
158  */
159 float OH_Drawing_RectGetRight(OH_Drawing_Rect*);
160 
161 /**
162  * @brief Get the bottom position of the rect.
163  *
164  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
165  * @param OH_Drawing_Rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
166  * @return Return the bottom position of the rect.
167  * @since 12
168  * @version 1.0
169  */
170 float OH_Drawing_RectGetBottom(OH_Drawing_Rect*);
171 
172 /**
173  * @brief Get the height position of the rect.
174  *
175  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
176  * @param OH_Drawing_Rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
177  * @since 12
178  * @version 1.0
179  */
180 float OH_Drawing_RectGetHeight(OH_Drawing_Rect*);
181 
182 /* @brief Get the width position of the rect.
183  *
184  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
185  * @param OH_Drawing_Rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
186  * @return Returns the width.
187  * @since 12
188  * @version 1.0
189  */
190 float OH_Drawing_RectGetWidth(OH_Drawing_Rect*);
191 
192 /**
193  * @brief Copy the original rectangular object to the destination rectangular object.
194  *
195  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
196  * @param src Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
197  * @param dst Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
198  * @since 12
199  * @version 1.0
200  */
201 void OH_Drawing_RectCopy(OH_Drawing_Rect* src, OH_Drawing_Rect* dst);
202 
203 /**
204  * @brief Destroys an <b>OH_Drawing_Rect</b> object and reclaims the memory occupied by the object.
205  *
206  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
207  * @param OH_Drawing_Rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
208  * @since 11
209  * @version 1.0
210  */
211 void OH_Drawing_RectDestroy(OH_Drawing_Rect*);
212 
213 #ifdef __cplusplus
214 }
215 #endif
216 /** @} */
217 #endif
218