GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_vertical_list_scroll_info_get.c Lines: 27 27 100.0 %
Date: 2026-03-06 19:21:09 Branches: 12 14 85.7 %

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 Management                                            */
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
#include "gx_scrollbar.h"
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gx_vertical_list_scroll_info_get                   PORTABLE C      */
38
/*                                                           6.4.0        */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function gets the scrollbar information.                       */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    win                                   Pointer to window             */
50
/*    style                                 Style                         */
51
/*    info                                  Information of scrollbar      */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    None                                                                */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*    _gx_first_client_child_get            Get the first client child    */
60
/*                                                                        */
61
/*  CALLED BY                                                             */
62
/*                                                                        */
63
/*    Application Code                                                    */
64
/*                                                                        */
65
/**************************************************************************/
66
953
VOID _gx_vertical_list_scroll_info_get(GX_VERTICAL_LIST *list, ULONG style, GX_SCROLL_INFO *info)
67
{
68
INT        value;
69
GX_VALUE   height;
70
GX_WIDGET *child;
71
72
    GX_PARAMETER_NOT_USED(style);
73
74
953
    if (list -> gx_vertical_list_callback)
75
    {
76
        /* If list callback is set, children winthin the list should share the same height. */
77
945
        info -> gx_scroll_maximum = (list->gx_vertical_list_total_rows * list -> gx_vertical_list_child_height - 1);
78
    }
79
    else
80
    {
81
8
        info -> gx_scroll_maximum = 0;
82
83
8
        child = _gx_widget_first_client_child_get((GX_WIDGET *)list);
84
85
256
        while (child)
86
        {
87
248
            _gx_widget_height_get(child, &height);
88
89
248
            info -> gx_scroll_maximum += height;
90
91
248
            child = _gx_widget_next_client_child_get(child);
92
        }
93
    }
94
953
    info -> gx_scroll_minimum = 0;
95
953
    info -> gx_scroll_visible = (GX_VALUE)(list -> gx_window_client.gx_rectangle_bottom - list -> gx_window_client.gx_rectangle_top + 1);
96
97
953
    if (info -> gx_scroll_maximum <= info -> gx_scroll_visible)
98
    {
99
36
        info -> gx_scroll_value = 0;
100
36
        info -> gx_scroll_increment = 0;
101
36
        info -> gx_scroll_maximum = info->gx_scroll_visible;
102
36
        return;
103
    }
104
105
917
    value = list -> gx_vertical_list_top_index * list -> gx_vertical_list_child_height;
106
107
917
    if (list -> gx_vertical_list_top_index >= 0)
108
    {
109
917
        child = _gx_widget_first_client_child_get((GX_WIDGET *)list);
110
111
917
        if (child)
112
        {
113
917
            value += list -> gx_window_client.gx_rectangle_top - child -> gx_widget_size.gx_rectangle_top;
114
        }
115
    }
116
117
917
    if (value < info -> gx_scroll_minimum)
118
    {
119
166
        value = info -> gx_scroll_minimum;
120
    }
121
    else
122
    {
123
751
        if (value > info -> gx_scroll_maximum - info -> gx_scroll_visible + 1)
124
        {
125
108
            value = info -> gx_scroll_maximum - info -> gx_scroll_visible + 1;
126
        }
127
    }
128
129
917
    info -> gx_scroll_value = value;
130
917
    info -> gx_scroll_increment = list -> gx_vertical_list_child_height / 2;
131
}
132