• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /**
17  * @addtogroup Drawing
18  * @{
19  *
20  * @brief Provides functions such as 2D graphics rendering, text drawing, and image display.
21  *
22  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
23  *
24  * @since 11
25  * @version 1.0
26  */
27 
28 /**
29  * @file drawing_rect.h
30  *
31  * @brief Declares functions related to the <b>rect</b> object in the drawing module.
32  *
33  * @kit ArkGraphics2D
34  * @library libnative_drawing.so
35  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
36  * @since 11
37  * @version 1.0
38  */
39 
40 #ifndef C_INCLUDE_DRAWING_RECT_H
41 #define C_INCLUDE_DRAWING_RECT_H
42 
43 #include "drawing_error_code.h"
44 #include "drawing_types.h"
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 /**
51  * @brief Creates an <b>OH_Drawing_Rect</b> object.
52  *
53  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
54  * @param left Indicates the left position of the rect.
55  * @param top Indicates the top position of the rect.
56  * @param right Indicates the right position of the rect.
57  * @param bottom Indicates the bottom position of the rect.
58  * @return Returns the pointer to the <b>OH_Drawing_Rect</b> object created.
59  * @since 11
60  * @version 1.0
61  */
62 OH_Drawing_Rect* OH_Drawing_RectCreate(float left, float top, float right, float bottom);
63 
64 /**
65  * @brief If rect intersects other, sets rect to intersection.
66  *
67  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
68  * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
69  * @param other Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
70  * @return Returns true if have area in common.
71  * @since 12
72  * @version 1.0
73  */
74 bool OH_Drawing_RectIntersect(OH_Drawing_Rect* rect, const OH_Drawing_Rect* other);
75 
76 /**
77  * @brief Sets rect to the union of rect and other.
78  *
79  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
80  * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
81  * @param other Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
82  * @return Returns true if rect and other are not nullptr, and other is not empty;
83  *         false if rect or other is nullptr, or other is empty.
84  * @since 12
85  * @version 1.0
86  */
87 bool OH_Drawing_RectJoin(OH_Drawing_Rect* rect, const OH_Drawing_Rect* other);
88 
89 /**
90  * @brief Set the left position of the rect.
91  *
92  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
93  * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
94  * @param left Indicates the left position of the rect.
95  * @since 12
96  * @version 1.0
97  */
98 void OH_Drawing_RectSetLeft(OH_Drawing_Rect* rect, float left);
99 
100 /**
101  * @brief Set the top position of the rect.
102  *
103  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
104  * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
105  * @param top Indicates the top position of the rect.
106  * @since 12
107  * @version 1.0
108  */
109 void OH_Drawing_RectSetTop(OH_Drawing_Rect* rect, float top);
110 
111 /**
112  * @brief Set the right position of the rect.
113  *
114  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
115  * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
116  * @param right Indicates the right position of the rect.
117  * @since 12
118  * @version 1.0
119  */
120 void OH_Drawing_RectSetRight(OH_Drawing_Rect* rect, float right);
121 
122 /**
123  * @brief Set the bottom position of the rect.
124  *
125  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
126  * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
127  * @param bottom Indicates the bottom position of the rect.
128  * @since 12
129  * @version 1.0
130  */
131 void OH_Drawing_RectSetBottom(OH_Drawing_Rect* rect, float bottom);
132 
133 /**
134  * @brief Get the left position of the rect.
135  *
136  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
137  * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
138  * @return Return the left position of the rect.
139  * @since 12
140  * @version 1.0
141  */
142 float OH_Drawing_RectGetLeft(OH_Drawing_Rect* rect);
143 
144 /**
145  * @brief Get the top position of the rect.
146  *
147  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
148  * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
149  * @return Return the top position of the rect.
150  * @since 12
151  * @version 1.0
152  */
153 float OH_Drawing_RectGetTop(OH_Drawing_Rect* rect);
154 
155 /**
156  * @brief Get the right position of the rect.
157  *
158  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
159  * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
160  * @return Return the right position of the rect.
161  * @since 12
162  * @version 1.0
163  */
164 float OH_Drawing_RectGetRight(OH_Drawing_Rect* rect);
165 
166 /**
167  * @brief Get the bottom position of the rect.
168  *
169  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
170  * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
171  * @return Return the bottom position of the rect.
172  * @since 12
173  * @version 1.0
174  */
175 float OH_Drawing_RectGetBottom(OH_Drawing_Rect* rect);
176 
177 /**
178  * @brief Get the height position of the rect.
179  *
180  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
181  * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
182  * @since 12
183  * @version 1.0
184  */
185 float OH_Drawing_RectGetHeight(OH_Drawing_Rect* rect);
186 
187 /**
188  * @brief Get the width position of the rect.
189  *
190  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
191  * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
192  * @return Returns the width.
193  * @since 12
194  * @version 1.0
195  */
196 float OH_Drawing_RectGetWidth(OH_Drawing_Rect* rect);
197 
198 /**
199  * @brief Copy the original rectangular object to the destination rectangular object.
200  *
201  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
202  * @param src Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
203  * @param dst Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
204  * @since 12
205  * @version 1.0
206  */
207 void OH_Drawing_RectCopy(OH_Drawing_Rect* src, OH_Drawing_Rect* dst);
208 
209 /**
210  * @brief Destroys an <b>OH_Drawing_Rect</b> object and reclaims the memory occupied by the object.
211  *
212  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
213  * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
214  * @since 11
215  * @version 1.0
216  */
217 void OH_Drawing_RectDestroy(OH_Drawing_Rect* rect);
218 
219 /**
220  * @brief Creates an <b>OH_Drawing_Array</b> object, which is used to store multiple <b>OH_Drawing_Rect</b> object.
221  *
222  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
223  * @param size Indicates the size of the array object.
224  * @return Returns the pointer to the <b>OH_Drawing_Array</b> object created.
225  *         If nullptr is returned, the creation fails.
226  *         The possible cause of the failure is that the available memory is empty,
227  *         or size is invalid.
228  * @since 18
229  * @version 1.0
230  */
231 OH_Drawing_Array* OH_Drawing_RectCreateArray(size_t size);
232 
233 /**
234  * @brief Gets the size of an <b>OH_Drawing_Array</b> object.
235  *
236  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
237  * @param rectArray Indicates the array object.
238  * @param pSize Indicates the size pointer.
239  * @return Returns the error code.
240  *         Returns {@link OH_DRAWING_SUCCESS} if the operation is successful.
241  *         Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if rectArray or pSize is nullptr.
242  * @since 18
243  * @version 1.0
244  */
245 OH_Drawing_ErrorCode OH_Drawing_RectGetArraySize(OH_Drawing_Array* rectArray, size_t* pSize);
246 
247 /**
248  * @brief Gets the specified <b>OH_Drawing_Rect</b> object from <b>OH_Drawing_Array</b> object.
249  *
250  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
251  * @param rectArray Indicates the array object.
252  * @param index Indicates the index of array, caller must make sure the index is valid.
253  * @param rect Pointers to Pointer of <b>OH_Drawing_Rect</b> object, returned to the caller.
254  * @return Returns the error code.
255  *         Returns {@link OH_DRAWING_SUCCESS} if the operation is successful.
256  *         Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if rectArray or rect is nullptr,
257  *                 or index is valid.
258  * @since 18
259  * @version 1.0
260  */
261 OH_Drawing_ErrorCode OH_Drawing_RectGetArrayElement(OH_Drawing_Array* rectArray, size_t index,
262     OH_Drawing_Rect** rect);
263 
264 /**
265  * @brief Destroys an array <b>OH_Drawing_Rect</b> object and reclaims the memory occupied by the object.
266  *
267  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
268  * @param rectArray Indicates the pointer to an <b>OH_Drawing_Array</b> object.
269  * @return Returns the error code.
270  *         Returns {@link OH_DRAWING_SUCCESS} if the operation is successful.
271  *         Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if rectArray is nullptr.
272  * @since 18
273  * @version 1.0
274  */
275 OH_Drawing_ErrorCode OH_Drawing_RectDestroyArray(OH_Drawing_Array* rectArray);
276 
277 #ifdef __cplusplus
278 }
279 #endif
280 /** @} */
281 #endif
282