GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_widget_style_set.c Lines: 27 27 100.0 %
Date: 2026-03-06 19:21:09 Branches: 18 18 100.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
/**   Widget Management (Widget)                                          */
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_system.h"
30
#include "gx_window.h"
31
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gx_widget_style_set                                PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function updates the style of the specified widget.            */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    widget                                Widget control block          */
50
/*    style                                 New style                     */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    status                                Completion status             */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    _gx_window_view_update_detect         Detect if views changed       */
59
/*    _gx_system_dirty_mark                 Mark the widget as dirty      */
60
/*                                                                        */
61
/*  CALLED BY                                                             */
62
/*                                                                        */
63
/*    GUIX Internal Code                                                  */
64
/*                                                                        */
65
/**************************************************************************/
66
18
UINT  _gx_widget_style_set(GX_WIDGET *widget, ULONG style)
67
{
68
GX_WINDOW *window;
69
GX_EVENT   my_event;
70
18
ULONG      old_style = widget -> gx_widget_style;
71
72
    /* Update the widget style.  */
73
18
    widget -> gx_widget_style = style;
74
75
18
    if (style & GX_STYLE_TRANSPARENT)
76
    {
77
9
        if (!(widget -> gx_widget_status & GX_STATUS_TRANSPARENT))
78
        {
79
            /* If we are changing a window transparency and the window is visible,
80
               we have to check to see if viewports need to be updated
81
             */
82
5
            if (widget -> gx_widget_type >= GX_TYPE_WINDOW &&
83
3
                widget -> gx_widget_status & GX_STATUS_VISIBLE)
84
            {
85
2
                window = (GX_WINDOW *)widget;
86
2
                _gx_window_view_update_detect(window);
87
            }
88
5
            widget -> gx_widget_status |= GX_STATUS_TRANSPARENT;
89
        }
90
    }
91
    else
92
    {
93
9
        if (widget -> gx_widget_status & GX_STATUS_TRANSPARENT)
94
        {
95
            /* If we are changing a window transparency and the window is visible,
96
                we have to check to see if viewports need to be updated
97
             */
98
5
            if (widget -> gx_widget_type >= GX_TYPE_WINDOW &&
99
3
                widget -> gx_widget_status & GX_STATUS_VISIBLE)
100
            {
101
2
                window = (GX_WINDOW *)widget;
102
2
                _gx_window_view_update_detect(window);
103
            }
104
5
            widget -> gx_widget_status &= ~GX_STATUS_TRANSPARENT;
105
        }
106
    }
107
108
18
    if (widget -> gx_widget_style & GX_STYLE_ENABLED)
109
    {
110
17
        _gx_widget_status_add(widget, GX_STATUS_SELECTABLE);
111
    }
112
    else
113
    {
114
1
        _gx_widget_status_remove(widget, GX_STATUS_SELECTABLE);
115
    }
116
117
18
    if (widget -> gx_widget_status & GX_STATUS_VISIBLE)
118
    {
119
10
        _gx_system_dirty_mark(widget);
120
    }
121
122
    /* notify widget of style modification */
123
18
    memset(&my_event, 0, sizeof(GX_EVENT));
124
18
    my_event.gx_event_payload.gx_event_ulongdata = old_style;
125
18
    my_event.gx_event_type = GX_EVENT_STYLE_CHANGED;
126
18
    my_event.gx_event_target = widget;
127
18
    _gx_system_event_fold(&my_event);
128
129
18
    return(GX_SUCCESS);
130
}
131