GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_vertical_list_children_position.c Lines: 29 29 100.0 %
Date: 2026-03-06 19:21:09 Branches: 12 12 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
/**   Vertical 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_window.h"
30
#include "gx_system.h"
31
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gx_vertical_list_children_position                 PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function positions the children for the vertical list          */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    vertical_list                         Vertical list control block   */
50
/*                                                                        */
51
/*  OUTPUT                                                                */
52
/*                                                                        */
53
/*    status                                Completion status             */
54
/*                                                                        */
55
/*  CALLS                                                                 */
56
/*                                                                        */
57
/*    _gx_widget_height_get                 retrieves the height of the   */
58
/*                                            widget                      */
59
/*    _gx_widget_resize                     resizes the widget            */
60
/*                                                                        */
61
/*  CALLED BY                                                             */
62
/*                                                                        */
63
/*    Application Code                                                    */
64
/*                                                                        */
65
/**************************************************************************/
66
223
UINT _gx_vertical_list_children_position(GX_VERTICAL_LIST *vertical_list)
67
{
68
223
GX_RECTANGLE childsize = vertical_list -> gx_window_client;
69
223
GX_WIDGET   *child = vertical_list -> gx_widget_first_child;
70
223
INT          index    = vertical_list -> gx_vertical_list_top_index;
71
GX_VALUE     height;
72
GX_VALUE     client_height;
73
74
223
    vertical_list -> gx_vertical_list_child_height = 0;
75
223
    vertical_list -> gx_vertical_list_child_count = 0;
76
77
2370
    while (child)
78
    {
79
2147
        if (!(child -> gx_widget_status & GX_STATUS_NONCLIENT))
80
        {
81
            /* increment child count */
82
2085
            vertical_list -> gx_vertical_list_child_count++;
83
84
            /* assign this child's id */
85
86
2085
            if (!(child -> gx_widget_id))
87
            {
88
1042
                child -> gx_widget_id = (USHORT)(LIST_CHILD_ID_START + vertical_list -> gx_vertical_list_child_count);
89
            }
90
91
2085
            if (index == vertical_list -> gx_vertical_list_selected)
92
            {
93
207
                child -> gx_widget_style |= GX_STYLE_DRAW_SELECTED;
94
            }
95
            else
96
            {
97
1878
                child -> gx_widget_style &= ~GX_STYLE_DRAW_SELECTED;
98
            }
99
2085
            index++;
100
101
2085
            child -> gx_widget_status &= ~GX_STATUS_ACCEPTS_FOCUS;
102
103
            /* pick up child item height, needed for scrolling */
104
2085
            _gx_widget_height_get(child, &height);
105
2085
            if (height > vertical_list -> gx_vertical_list_child_height)
106
            {
107
209
                vertical_list -> gx_vertical_list_child_height = height;
108
            }
109
110
            /* move this child into position */
111
2085
            childsize.gx_rectangle_bottom = (GX_VALUE)(childsize.gx_rectangle_top + height - 1);
112
2085
            _gx_widget_resize(child, &childsize);
113
2085
            childsize.gx_rectangle_top = (GX_VALUE)(childsize.gx_rectangle_bottom + 1);
114
        }
115
2147
        child = child -> gx_widget_next;
116
    }
117
118
    /* calculate number of visible rows, needed for scrolling info */
119
223
    if (vertical_list -> gx_vertical_list_child_height > 0)
120
    {
121
209
        _gx_window_client_height_get((GX_WINDOW *)vertical_list, &client_height);
122
209
        vertical_list -> gx_vertical_list_visible_rows = (GX_VALUE)((client_height + vertical_list -> gx_vertical_list_child_height - 1) /
123
209
                                                                    vertical_list -> gx_vertical_list_child_height);
124
    }
125
    else
126
    {
127
14
        vertical_list -> gx_vertical_list_visible_rows = 1;
128
    }
129
130
223
    return(GX_SUCCESS);
131
}
132