GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_horizontal_list_page_index_set.c Lines: 13 13 100.0 %
Date: 2026-03-06 19:21:09 Branches: 9 10 90.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
/**   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_page_index_set                  PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This service sets the index of first list item                      */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    horizontal_list                       Horizontal list widget        */
50
/*                                            control block               */
51
/*    list_entry                            Pointer to new list entry     */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    status                                Completion status             */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*    _gx_widget_event_generate             Creates a new GX_EVENT        */
60
/*    _gx_system_dirty_mark                 Mark the widget dirty         */
61
/*                                                                        */
62
/*  CALLED BY                                                             */
63
/*                                                                        */
64
/*    _gx_horizontal_list_event_process                                   */
65
/*                                                                        */
66
/**************************************************************************/
67
102
UINT _gx_horizontal_list_page_index_set(GX_HORIZONTAL_LIST *list, INT index)
68
{
69
GX_WIDGET    *child;
70
GX_SCROLLBAR *pScroll;
71
INT           scroll_value;
72
73
102
    if ((list -> gx_horizontal_list_total_columns > 0) &&
74

91
        ((index <= list -> gx_horizontal_list_total_columns - list -> gx_horizontal_list_visible_columns) || (list -> gx_widget_style & GX_STYLE_WRAP)))
75
    {
76
78
        child = _gx_widget_first_client_child_get((GX_WIDGET *)list);
77
78
78
        if (child)
79
        {
80
            /* Calculate scroll value. */
81
78
            scroll_value = child -> gx_widget_size.gx_rectangle_left;
82
78
            scroll_value += (index - list -> gx_horizontal_list_top_index) * list -> gx_horizontal_list_child_width;
83
78
            scroll_value = list -> gx_window_client.gx_rectangle_left - scroll_value;
84
85
            /* Scroll to make index as the first visible entry. */
86
78
            _gx_horizontal_list_scroll(list, scroll_value);
87
88
78
            _gx_window_scrollbar_find((GX_WINDOW *)list, GX_TYPE_HORIZONTAL_SCROLL, &pScroll);
89
90
78
            if (pScroll)
91
            {
92
33
                _gx_scrollbar_reset(pScroll, GX_NULL);
93
            }
94
        }
95
    }
96
97
102
    return GX_SUCCESS;
98
}
99