GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_horizontal_list_scroll_info_get.c Lines: 22 28 78.6 %
Date: 2026-03-06 19:21:09 Branches: 9 14 64.3 %

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
/**   Horizontal 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
#include "gx_scrollbar.h"
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gx_horizontal_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
609
VOID _gx_horizontal_list_scroll_info_get(GX_WINDOW *win, ULONG style, GX_SCROLL_INFO *info)
67
{
68
INT                 value;
69
GX_WIDGET          *child;
70
609
GX_HORIZONTAL_LIST *list = (GX_HORIZONTAL_LIST *)win;
71
GX_VALUE            width;
72
73
74
    GX_PARAMETER_NOT_USED(style);
75
76
609
    if (list -> gx_horizontal_list_callback)
77
    {
78
    	/* If list callback is set, children winthin the list should share the same width. */
79
609
        info -> gx_scroll_maximum = (list -> gx_horizontal_list_total_columns * list -> gx_horizontal_list_child_width - 1);
80
    }
81
    else
82
    {
83
        info -> gx_scroll_maximum = 0;
84
85
        child = _gx_widget_first_client_child_get((GX_WIDGET*)list);
86
        while (child)
87
        {
88
            _gx_widget_width_get(child, &width);
89
            info -> gx_scroll_maximum += width;
90
            child = _gx_widget_next_client_child_get(child);
91
        }
92
    }
93
609
    info -> gx_scroll_minimum = 0;
94
609
    info -> gx_scroll_visible = (GX_VALUE)(list -> gx_window_client.gx_rectangle_right - list -> gx_window_client.gx_rectangle_left + 1);
95
96
609
    if (info -> gx_scroll_maximum <= info -> gx_scroll_visible)
97
    {
98
31
        info -> gx_scroll_value = 0;
99
31
        info -> gx_scroll_increment = 0;
100
31
        info -> gx_scroll_maximum = info -> gx_scroll_visible;
101
31
        return;
102
    }
103
104
578
    value = list -> gx_horizontal_list_top_index * list -> gx_horizontal_list_child_width;
105
106
578
    if (list -> gx_horizontal_list_top_index >= 0)
107
    {
108
578
        child = _gx_widget_first_client_child_get((GX_WIDGET *)win);
109
110
578
        if (child)
111
        {
112
578
            value += win -> gx_window_client.gx_rectangle_left - child -> gx_widget_size.gx_rectangle_left;
113
        }
114
    }
115
116
578
    if (value < info -> gx_scroll_minimum)
117
    {
118
150
        value = info -> gx_scroll_minimum;
119
    }
120
    else
121
    {
122
428
        if (value > info -> gx_scroll_maximum - info -> gx_scroll_visible + 1)
123
        {
124
108
            value = info -> gx_scroll_maximum - info -> gx_scroll_visible + 1;
125
        }
126
    }
127
128
578
    info -> gx_scroll_value = value;
129
578
    info -> gx_scroll_increment = list -> gx_horizontal_list_child_width / 2;
130
}
131