GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_horizontal_list_left_wrap.c Lines: 29 29 100.0 %
Date: 2026-03-06 19:21:09 Branches: 15 16 93.8 %

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_utility.h"
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gx_horizontal_list_left_wrap                       PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function scrolls up the horizontal list.                       */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    list                                  horizontal list widget control*/
50
/*                                            block                       */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    None                                                                */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    _gx_first_client_child_get            Get the first client child    */
59
/*    _gx_last_client_child_get             Get the last client child     */
60
/*    _gx_widget_front_move                 Move widget to the front      */
61
/*    _gx_widget_shift                      Shift a widget                */
62
/*    [gx_horizontal_list_callback]         Horizontal list callback      */
63
/*                                                                        */
64
/*  CALLED BY                                                             */
65
/*                                                                        */
66
/*    _gx_horizontal_list_scroll                                          */
67
/*                                                                        */
68
/**************************************************************************/
69
227
VOID _gx_horizontal_list_left_wrap(GX_HORIZONTAL_LIST *list)
70
{
71
GX_WIDGET   *test;
72
GX_WIDGET   *check;
73
GX_RECTANGLE newpos;
74
227
GX_BOOL      moving = GX_TRUE;
75
INT          index;
76
77
803
    while (moving)
78
    {
79
576
        moving = GX_FALSE;
80
81
576
        if ((list -> gx_horizontal_list_top_index + list -> gx_horizontal_list_child_count < list -> gx_horizontal_list_total_columns) ||
82
151
            (list -> gx_widget_style & GX_STYLE_WRAP))
83
        {
84
            /* scrolling up. See if my top widget is already above my
85
               client area: */
86
87
528
            test = _gx_widget_first_client_child_get((GX_WIDGET *)list);
88
528
            if (test)
89
            {
90
528
                if (test -> gx_widget_size.gx_rectangle_right < list -> gx_widget_size.gx_rectangle_left)
91
                {
92
                    /* left widget is left of my client area, move it to the right: */
93
94
349
                    moving = GX_TRUE;
95
349
                    check = _gx_widget_last_client_child_get((GX_WIDGET *)list);
96
97
349
                    _gx_widget_detach(test);
98
99
349
                    newpos = test -> gx_widget_size;
100
349
                    _gx_utility_rectangle_shift(&newpos,
101
349
                                                (GX_VALUE)(check -> gx_widget_size.gx_rectangle_right -
102
349
                                                           test -> gx_widget_size.gx_rectangle_left + 1),
103
                                                0);
104
349
                    _gx_widget_resize(test, &newpos);
105
106
349
                    index = list -> gx_horizontal_list_top_index + list -> gx_horizontal_list_child_count;
107
108
                    /* Wrap index. */
109
349
                    if (index >= list -> gx_horizontal_list_total_columns)
110
                    {
111
73
                        index -= list -> gx_horizontal_list_total_columns;
112
                    }
113
114
349
                    list -> gx_horizontal_list_callback(list, test, index);
115
349
                    if (index == list -> gx_horizontal_list_selected)
116
                    {
117
13
                        test -> gx_widget_style |=  GX_STYLE_DRAW_SELECTED;
118
                    }
119
                    else
120
                    {
121
336
                        test -> gx_widget_style &= ~GX_STYLE_DRAW_SELECTED;
122
                    }
123
349
                    _gx_widget_attach((GX_WIDGET *)list, test);
124
349
                    list -> gx_horizontal_list_top_index++;
125
126
                    /* Wrap page index.  */
127
349
                    if (list -> gx_horizontal_list_top_index >= list -> gx_horizontal_list_total_columns)
128
                    {
129
2
                        list -> gx_horizontal_list_top_index -= list -> gx_horizontal_list_total_columns;
130
                    }
131
                }
132
            }
133
        }
134
    }
135
227
}
136