GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_drop_list_create.c Lines: 19 19 100.0 %
Date: 2026-03-06 19:21:09 Branches: 2 2 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
/**   Drop List (List)                                                    */
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_drop_list.h"
31
#include "gx_window.h"
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gx_drop_list_create                                PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This service creates a drop list.                                   */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    drop_list                             Drop list control block       */
50
/*    name                                  Name of drop list             */
51
/*    parent                                Pointer to parent widget      */
52
/*    total_rows                            Total number of rows in       */
53
/*                                            drop list                   */
54
/*    open_height                           Height of the vertical list   */
55
/*    callback                              function called to create     */
56
/*                                            new widgets when the list   */
57
/*                                            is scrolled.                */
58
/*    style                                 Style of drop list            */
59
/*    drop_list_id                          Application-defined ID of     */
60
/*                                            the drop list               */
61
/*    size                                  Dimensions of the drop list   */
62
/*                                                                        */
63
/*  OUTPUT                                                                */
64
/*                                                                        */
65
/*    status                                Completion status             */
66
/*                                                                        */
67
/*  CALLS                                                                 */
68
/*                                                                        */
69
/*    _gx_widget_create                     Create the underlying widget  */
70
/*    memset                                Clear the memory block        */
71
/*    _gx_vertical_list_create              Create the underlying         */
72
/*                                            vertical list               */
73
/*    _gx_widget_link                       Link the widget to its parent */
74
/*                                                                        */
75
/*  CALLED BY                                                             */
76
/*                                                                        */
77
/*    Application Code                                                    */
78
/*                                                                        */
79
/**************************************************************************/
80
562
UINT  _gx_drop_list_create(GX_DROP_LIST *drop_list, GX_CONST GX_CHAR *name,
81
                           GX_WIDGET *parent, INT total_rows, INT open_height,
82
                           VOID (*callback)(GX_VERTICAL_LIST *, GX_WIDGET *, INT),
83
                           ULONG style, USHORT drop_list_id,
84
                           GX_CONST GX_RECTANGLE *size)
85
{
86
GX_VERTICAL_LIST *list;
87
88
    /* the drop list should not have enabled style */
89
562
    style &= ~GX_STYLE_ENABLED;
90
91
    /* Call the widget create function.  */
92
562
    _gx_widget_create((GX_WIDGET *)drop_list, name, GX_NULL, style, drop_list_id, size);
93
94
562
    drop_list -> gx_widget_type = GX_TYPE_DROP_LIST;
95
562
    drop_list -> gx_widget_event_process_function = (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_drop_list_event_process;
96
562
    drop_list -> gx_drop_list_open_height = open_height;
97
562
    drop_list -> gx_drop_list_pixelmap = 0;
98
562
    drop_list -> gx_drop_list_popup_open = GX_FALSE;
99
562
    drop_list -> gx_widget_draw_function = (VOID (*)(GX_WIDGET *))_gx_drop_list_draw;
100
562
    drop_list -> gx_widget_event_process_function = (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_drop_list_event_process;
101
562
    drop_list -> gx_widget_disabled_fill_color = drop_list -> gx_widget_normal_fill_color;
102
103
    /* create the drop-down list, which is a modified vertical list */
104
562
    list = &drop_list -> gx_drop_list_popup.gx_popup_list_list;
105
106
562
    _gx_vertical_list_create(list, name, GX_NULL, total_rows, callback, style, drop_list_id, size);
107
562
    list -> gx_widget_type = GX_TYPE_POPUP_LIST;
108
562
    list -> gx_widget_event_process_function = (UINT (*)(GX_WIDGET *, GX_EVENT *))_gx_popup_list_event_process;
109
562
    drop_list -> gx_drop_list_popup.gx_popup_list_owner = (GX_WIDGET *)drop_list;
110
111
    /* Determine if a parent widget was provided.  */
112
562
    if (parent)
113
    {
114
561
        _gx_widget_link(parent, (GX_WIDGET *)drop_list);
115
    }
116
117
    /* Return completion status.  */
118
562
    return(GX_SUCCESS);
119
}
120