GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_numeric_scroll_wheel_text_get.c Lines: 16 16 100.0 %
Date: 2026-03-06 19:21:09 Branches: 8 8 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
/**   Numeric 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_scroll_wheel.h"
29
#include "gx_utility.h"
30
31
/**************************************************************************/
32
/*                                                                        */
33
/*  FUNCTION                                               RELEASE        */
34
/*                                                                        */
35
/*    _gx_numeric_scroll_wheel_text_get                   PORTABLE C      */
36
/*                                                           6.1          */
37
/*  AUTHOR                                                                */
38
/*                                                                        */
39
/*    Kenneth Maxwell, Microsoft Corporation                              */
40
/*                                                                        */
41
/*  DESCRIPTION                                                           */
42
/*                                                                        */
43
/*    This function returns pointer to numeric text.                      */
44
/*                                                                        */
45
/*  INPUT                                                                 */
46
/*                                                                        */
47
/*    wheel                                 Scroll wheel control block    */
48
/*    row                                   Desired text row              */
49
/*                                                                        */
50
/*  OUTPUT                                                                */
51
/*                                                                        */
52
/*    status                                Completion status             */
53
/*                                                                        */
54
/*  CALLS                                                                 */
55
/*                                                                        */
56
/*    _gx_utility_ltoa                      Convert integer to string     */
57
/*                                                                        */
58
/*  CALLED BY                                                             */
59
/*                                                                        */
60
/*    _gx_text_scroll_wheel_draw                                          */
61
/*                                                                        */
62
/**************************************************************************/
63
1349
UINT _gx_numeric_scroll_wheel_text_get(GX_NUMERIC_SCROLL_WHEEL *wheel, INT row, GX_STRING *string)
64
{
65
INT  step;
66
INT  val;
67
68
1349
    if (row < wheel -> gx_scroll_wheel_total_rows)
69
    {
70
1342
        step = wheel -> gx_numeric_scroll_wheel_end_val - wheel -> gx_numeric_scroll_wheel_start_val;
71
72
1342
        if (step == (wheel -> gx_scroll_wheel_total_rows - 1))
73
        {
74
95
            step = 1;
75
        }
76
1247
        else if (step == (1 - wheel -> gx_scroll_wheel_total_rows))
77
        {
78
15
            step = -1;
79
        }
80
1232
        else if (wheel -> gx_scroll_wheel_total_rows > 1)
81
        {
82
1141
            step /= (wheel -> gx_scroll_wheel_total_rows - 1);
83
        }
84
85
1342
        val = wheel -> gx_numeric_scroll_wheel_start_val + (step * row);
86
1342
        _gx_utility_ltoa(val, wheel -> gx_numeric_scroll_wheel_string_buffer, GX_NUMERIC_SCROLL_WHEEL_STRING_BUFFER_SIZE);
87
88
1342
        string -> gx_string_ptr = wheel -> gx_numeric_scroll_wheel_string_buffer;
89
1342
        _gx_utility_string_length_check(string -> gx_string_ptr, &string -> gx_string_length, GX_NUMERIC_SCROLL_WHEEL_STRING_BUFFER_SIZE - 1);
90
    }
91
    else
92
    {
93
7
        string -> gx_string_ptr = GX_NULL;
94
7
        string -> gx_string_length = 0;
95
    }
96
97
1349
    return(GX_SUCCESS);
98
}
99