GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_scroll_wheel_scroll.c Lines: 19 19 100.0 %
Date: 2026-03-06 19:21:09 Branches: 16 16 100.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
/**   Scroll Wheel Management (Scroll Wheel)                              */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
25
/* Include necessary system files.  */
26
27
#include "gx_api.h"
28
#include "gx_system.h"
29
#include "gx_scroll_wheel.h"
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _gx_scroll_wheel_scroll                             PORTABLE C      */
36
/*                                                           6.1.7        */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This function scrolls a scroll widget widget.                       */
44
/*                                                                        */
45
/*  INPUT                                                                 */
46
/*                                                                        */
47
/*    wheel                                 Scroll wheel control block    */
48
/*    shift                                 Value to be shift             */
49
/*                                                                        */
50
/*  OUTPUT                                                                */
51
/*                                                                        */
52
/*    status                                Completion status             */
53
/*                                                                        */
54
/*  CALLS                                                                 */
55
/*                                                                        */
56
/*    _gx_scroll_wheel_selected_row_calculate                             */
57
/*                                          Calculate current selected row*/
58
/*    _gx_system_dirty_mark                 Mark a widget as dirty        */
59
/*                                                                        */
60
/*  CALLED BY                                                             */
61
/*                                                                        */
62
/*    _gx_scroll_wheel_event_process                                      */
63
/*                                                                        */
64
/**************************************************************************/
65
328
UINT _gx_scroll_wheel_scroll(GX_SCROLL_WHEEL *wheel, GX_VALUE shift)
66
{
67
INT y_shift;
68
INT min_shift;
69
INT max_shift;
70
71
328
    if (!wheel -> gx_scroll_wheel_wrap_style_check(wheel))
72
    {
73
242
        y_shift = wheel -> gx_scroll_wheel_selected_yshift + shift;
74
75

242
        if ((shift > 0 && wheel -> gx_scroll_wheel_selected_row == 0) ||
76
131
            (shift < 0 && wheel -> gx_scroll_wheel_selected_row == wheel -> gx_scroll_wheel_total_rows - 1))
77
        {
78
17
            y_shift = wheel -> gx_scroll_wheel_selected_yshift + shift;
79
80
17
            min_shift = (wheel -> gx_scroll_wheel_selected_row - wheel -> gx_scroll_wheel_total_rows + 1) *
81
17
                wheel -> gx_scroll_wheel_row_height;
82
17
            max_shift = (wheel -> gx_scroll_wheel_selected_row * wheel -> gx_scroll_wheel_row_height);
83
84

17
            if ((y_shift < min_shift) || (y_shift > max_shift))
85
            {
86
15
                shift = (GX_VALUE)(shift + wheel -> gx_scroll_wheel_shift_error);
87
15
                wheel -> gx_scroll_wheel_shift_error = (GX_BYTE)(shift % 4);
88
15
                shift /= 4;
89
            }
90
            else
91
            {
92
2
                wheel -> gx_scroll_wheel_shift_error = 0;
93
            }
94
        }
95
    }
96
97
328
    wheel -> gx_scroll_wheel_selected_yshift = (GX_VALUE)(wheel -> gx_scroll_wheel_selected_yshift + shift);
98
99
328
    _gx_scroll_wheel_selected_row_calculate(wheel);
100
101
328
    if (wheel -> gx_widget_status & GX_STATUS_VISIBLE)
102
    {
103
320
        _gx_system_dirty_mark((GX_WIDGET *)wheel);
104
    }
105
328
    return GX_SUCCESS;
106
}
107