GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_vertical_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
/**   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
#include "gx_scrollbar.h"
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gx_vertical_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 starting page index for vertical list.        */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    vertical_list                         Vertical list widget control  */
50
/*                                          block                         */
51
/*    index                                 The new top index             */
52
/*                                                                        */
53
/*  OUTPUT                                                                */
54
/*                                                                        */
55
/*    status                                Completion status             */
56
/*                                                                        */
57
/*  CALLS                                                                 */
58
/*                                                                        */
59
/*  CALLED BY                                                             */
60
/*                                                                        */
61
/*    _gx_vertical_list_selected_set        Process drop list event       */
62
/*                                                                        */
63
/**************************************************************************/
64
103
UINT _gx_vertical_list_page_index_set(GX_VERTICAL_LIST *list, INT index)
65
{
66
GX_WIDGET    *child;
67
GX_SCROLLBAR *pScroll;
68
INT           scroll_value;
69
70
103
    if ((list -> gx_vertical_list_total_rows > 0) &&
71

92
        ((index <= list -> gx_vertical_list_total_rows - list -> gx_vertical_list_visible_rows) || (list -> gx_widget_style & GX_STYLE_WRAP)))
72
    {
73
79
        child = _gx_widget_first_client_child_get((GX_WIDGET *)list);
74
75
79
        if (child)
76
        {
77
79
            scroll_value = child -> gx_widget_size.gx_rectangle_top;
78
79
            scroll_value += (index - list -> gx_vertical_list_top_index) * list -> gx_vertical_list_child_height;
79
79
            scroll_value = list -> gx_window_client.gx_rectangle_top - scroll_value;
80
81
            /* Scroll to make index as the first visible entry. */
82
79
            _gx_vertical_list_scroll(list, scroll_value);
83
84
79
            _gx_window_scrollbar_find((GX_WINDOW *)list, GX_TYPE_VERTICAL_SCROLL, &pScroll);
85
86
79
            if (pScroll)
87
            {
88
34
                _gx_scrollbar_reset(pScroll, GX_NULL);
89
            }
90
        }
91
    }
92
93
103
    return GX_SUCCESS;
94
}
95