GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_utility_rectangle_center.c Lines: 16 16 100.0 %
Date: 2026-03-06 19:21:09 Branches: 0 0 - %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** GUIX Component                                                        */
17
/**                                                                       */
18
/**   Utility (Utility)                                                   */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_utility.h"
29
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _gx_utility_rectangle_center                        PORTABLE C      */
36
/*                                                           6.1          */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This service centers the rectangle within another rectangle.        */
44
/*                                                                        */
45
/*  INPUT                                                                 */
46
/*                                                                        */
47
/*    rectangle                             Rectangle to center           */
48
/*    within                                Rectangle to center within    */
49
/*                                                                        */
50
/*  OUTPUT                                                                */
51
/*                                                                        */
52
/*    None                                                                */
53
/*                                                                        */
54
/*  CALLS                                                                 */
55
/*                                                                        */
56
/*    None                                                                */
57
/*                                                                        */
58
/*  CALLED BY                                                             */
59
/*                                                                        */
60
/*    Application Code                                                    */
61
/*    GUIX Internal Code                                                  */
62
/*                                                                        */
63
/**************************************************************************/
64
1
UINT  _gx_utility_rectangle_center(GX_RECTANGLE *rectangle, GX_RECTANGLE *within)
65
{
66
67
INT x_space;
68
INT y_space;
69
INT x_delta;
70
INT y_delta;
71
72
1
    x_space = (((within -> gx_rectangle_right -
73
1
                 within -> gx_rectangle_left) + 1) -
74
1
               ((rectangle -> gx_rectangle_right -
75
1
                 rectangle -> gx_rectangle_left) + 1)) / 2;
76
77
1
    y_space = (((within -> gx_rectangle_bottom -
78
1
                 within -> gx_rectangle_top) + 1) -
79
1
               ((rectangle -> gx_rectangle_bottom -
80
1
                 rectangle -> gx_rectangle_top) + 1)) / 2;
81
82
1
    x_delta = within -> gx_rectangle_left + x_space - rectangle -> gx_rectangle_left;
83
1
    y_delta = within -> gx_rectangle_top + y_space - rectangle -> gx_rectangle_top;
84
85
1
    rectangle -> gx_rectangle_left = (GX_VALUE)(rectangle -> gx_rectangle_left + x_delta);
86
1
    rectangle -> gx_rectangle_top = (GX_VALUE)(rectangle -> gx_rectangle_top + y_delta);
87
1
    rectangle -> gx_rectangle_right = (GX_VALUE)(rectangle -> gx_rectangle_right + x_delta);
88
1
    rectangle -> gx_rectangle_bottom = (GX_VALUE)(rectangle -> gx_rectangle_bottom + y_delta);
89
1
    return GX_SUCCESS;
90
}
91