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