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