1 /***************************************************************************
2  * Copyright (c) 2024 Microsoft Corporation
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the MIT License which is available at
6  * https://opensource.org/licenses/MIT.
7  *
8  * SPDX-License-Identifier: MIT
9  **************************************************************************/
10 
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** GUIX Component                                                        */
16 /**                                                                       */
17 /**   Progress Bar Management (Radial Progress Bar)                       */
18 /**                                                                       */
19 /**************************************************************************/
20 
21 #define GX_SOURCE_CODE
22 
23 
24 /* Include necessary system files.  */
25 
26 #include "gx_api.h"
27 #include "gx_radial_progress_bar.h"
28 #include "gx_widget.h"
29 #include "gx_utility.h"
30 
31 /**************************************************************************/
32 /*                                                                        */
33 /*  FUNCTION                                               RELEASE        */
34 /*                                                                        */
35 /*    _gx_radial_prpgress_bar_size_update                 PORTABLE C      */
36 /*                                                           6.1          */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    Kenneth Maxwell, Microsoft Corporation                              */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    This function calculate the size of the radial progress bar.        */
44 /*                                                                        */
45 /*  INPUT                                                                 */
46 /*                                                                        */
47 /*    radial_progress                       Radial progess bar control    */
48 /*                                            block                       */
49 /*                                                                        */
50 /*  OUTPUT                                                                */
51 /*                                                                        */
52 /*    status                                Completion status             */
53 /*                                                                        */
54 /*  CALLS                                                                 */
55 /*                                                                        */
56 /*    _gx_widget_resize                     Resize the widget             */
57 /*                                                                        */
58 /*  CALLED BY                                                             */
59 /*                                                                        */
60 /*    Application Code                                                    */
61 /*                                                                        */
62 /*  RELEASE HISTORY                                                       */
63 /*                                                                        */
64 /*    DATE              NAME                      DESCRIPTION             */
65 /*                                                                        */
66 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
67 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
68 /*                                            resulting in version 6.1    */
69 /*                                                                        */
70 /**************************************************************************/
71 
_gx_radial_progress_bar_size_update(GX_RADIAL_PROGRESS_BAR * radial_progress)72 UINT _gx_radial_progress_bar_size_update(GX_RADIAL_PROGRESS_BAR *radial_progress)
73 {
74 GX_RADIAL_PROGRESS_BAR_INFO *info;
75 GX_RECTANGLE                *size;
76 GX_RECTANGLE                 new_size;
77 GX_VALUE                     width;
78 
79     info = &radial_progress -> gx_radial_progress_bar_info;
80 
81     width = info -> gx_radial_progress_bar_info_selected_brush_width;
82 
83     if (width < info -> gx_radial_progress_bar_info_normal_brush_width)
84     {
85         width = info -> gx_radial_progress_bar_info_normal_brush_width;
86     }
87 
88     width = (GX_VALUE)((width + 1) >> 1);
89     /* Calculate new size.  */
90     new_size.gx_rectangle_left = (GX_VALUE)(info -> gx_radial_progress_bar_info_xcenter - info -> gx_radial_progress_bar_info_radius - width);
91     new_size.gx_rectangle_right = (GX_VALUE)(info -> gx_radial_progress_bar_info_xcenter + info -> gx_radial_progress_bar_info_radius + width);
92     new_size.gx_rectangle_top = (GX_VALUE)(info -> gx_radial_progress_bar_info_ycenter - info -> gx_radial_progress_bar_info_radius - width);
93     new_size.gx_rectangle_bottom = (GX_VALUE)(info -> gx_radial_progress_bar_info_ycenter + info -> gx_radial_progress_bar_info_radius + width);
94 
95     /* Retrieve old progress bar size.  */
96     size = &radial_progress -> gx_widget_size;
97 
98     if ((new_size.gx_rectangle_left != size -> gx_rectangle_left) ||
99         (new_size.gx_rectangle_right != size -> gx_rectangle_right) ||
100         (new_size.gx_rectangle_top != size -> gx_rectangle_top))
101     {
102         /* Update radial progress bar size.  */
103         _gx_widget_resize((GX_WIDGET *)radial_progress, &new_size);
104     }
105 
106     return GX_SUCCESS;
107 }
108 
109