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 /**   Button Management (Button)                                          */
19 /**                                                                       */
20 /**************************************************************************/
21 
22 #define GX_SOURCE_CODE
23 
24 
25 /* Include necessary system files.  */
26 
27 #include "gx_api.h"
28 #include "gx_widget.h"
29 #include "gx_button.h"
30 
31 
32 /**************************************************************************/
33 /*                                                                        */
34 /*  FUNCTION                                               RELEASE        */
35 /*                                                                        */
36 /*    _gx_button_siblings_deselect                        PORTABLE C      */
37 /*                                                           6.1          */
38 /*  AUTHOR                                                                */
39 /*                                                                        */
40 /*    Kenneth Maxwell, Microsoft Corporation                              */
41 /*                                                                        */
42 /*  DESCRIPTION                                                           */
43 /*                                                                        */
44 /*    This function deselects all sibling buttons of the caller that      */
45 /*    have GX_STYLE_BUTTON_RADIO style.                                   */
46 /*                                                                        */
47 /*  INPUT                                                                 */
48 /*                                                                        */
49 /*    button                                Button control block          */
50 /*                                                                        */
51 /*  OUTPUT                                                                */
52 /*                                                                        */
53 /*    None                                                                */
54 /*                                                                        */
55 /*  CALLS                                                                 */
56 /*                                                                        */
57 /*    [gx_button_deselect_handler]          Widget-provided deselect      */
58 /*                                            handler routine             */
59 /*                                                                        */
60 /*  CALLED BY                                                             */
61 /*                                                                        */
62 /*    _gx_button_select                                                   */
63 /*                                                                        */
64 /*  RELEASE HISTORY                                                       */
65 /*                                                                        */
66 /*    DATE              NAME                      DESCRIPTION             */
67 /*                                                                        */
68 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
69 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
70 /*                                            resulting in version 6.1    */
71 /*                                                                        */
72 /**************************************************************************/
_gx_button_siblings_deselect(GX_BUTTON * button)73 VOID  _gx_button_siblings_deselect(GX_BUTTON *button)
74 {
75 GX_WIDGET *parent;
76 GX_WIDGET *test;
77 GX_WIDGET *widget;
78 GX_BUTTON *sibling;
79 
80     widget = (GX_WIDGET *)button;
81     parent = widget -> gx_widget_parent;
82     test = parent -> gx_widget_first_child;
83 
84     while (test)
85     {
86         /* not the incoming widget? */
87         if (test != widget)
88         {
89             /* is this widget a button? */
90             if (test -> gx_widget_status & GX_STATUS_BUTTON_DERIVED)
91             {
92                 sibling = (GX_BUTTON *)test;
93 
94                 /* is this a pushed radio button?  */
95                 if ((test -> gx_widget_style & (GX_STYLE_BUTTON_RADIO | GX_STYLE_BUTTON_PUSHED)) ==
96                     (GX_STYLE_BUTTON_RADIO | GX_STYLE_BUTTON_PUSHED))
97                 {
98                     sibling -> gx_button_deselect_handler(test, GX_TRUE);
99                 }
100             }
101         }
102         test = test -> gx_widget_next;
103     }
104 }
105 
106