GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_numeric_scroll_wheel_text_get.c Lines: 16 16 100.0 %
Date: 2024-12-05 08:52:37 Branches: 8 8 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 *
4
 * This program and the accompanying materials are made available under the
5
 * terms of the MIT License which is available at
6
 * https://opensource.org/licenses/MIT.
7
 *
8
 * SPDX-License-Identifier: MIT
9
 **************************************************************************/
10
11
12
/**************************************************************************/
13
/**************************************************************************/
14
/**                                                                       */
15
/** GUIX Component                                                        */
16
/**                                                                       */
17
/**   Numeric Scroll Wheel Management (Scroll Wheel)                      */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_scroll_wheel.h"
28
#include "gx_utility.h"
29
30
/**************************************************************************/
31
/*                                                                        */
32
/*  FUNCTION                                               RELEASE        */
33
/*                                                                        */
34
/*    _gx_numeric_scroll_wheel_text_get                   PORTABLE C      */
35
/*                                                           6.1          */
36
/*  AUTHOR                                                                */
37
/*                                                                        */
38
/*    Kenneth Maxwell, Microsoft Corporation                              */
39
/*                                                                        */
40
/*  DESCRIPTION                                                           */
41
/*                                                                        */
42
/*    This function returns pointer to numeric text.                      */
43
/*                                                                        */
44
/*  INPUT                                                                 */
45
/*                                                                        */
46
/*    wheel                                 Scroll wheel control block    */
47
/*    row                                   Desired text row              */
48
/*                                                                        */
49
/*  OUTPUT                                                                */
50
/*                                                                        */
51
/*    status                                Completion status             */
52
/*                                                                        */
53
/*  CALLS                                                                 */
54
/*                                                                        */
55
/*    _gx_utility_ltoa                      Convert integer to string     */
56
/*                                                                        */
57
/*  CALLED BY                                                             */
58
/*                                                                        */
59
/*    _gx_text_scroll_wheel_draw                                          */
60
/*                                                                        */
61
/*  RELEASE HISTORY                                                       */
62
/*                                                                        */
63
/*    DATE              NAME                      DESCRIPTION             */
64
/*                                                                        */
65
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
66
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
67
/*                                            resulting in version 6.1    */
68
/*                                                                        */
69
/**************************************************************************/
70
1349
UINT _gx_numeric_scroll_wheel_text_get(GX_NUMERIC_SCROLL_WHEEL *wheel, INT row, GX_STRING *string)
71
{
72
INT  step;
73
INT  val;
74
75
1349
    if (row < wheel -> gx_scroll_wheel_total_rows)
76
    {
77
1342
        step = wheel -> gx_numeric_scroll_wheel_end_val - wheel -> gx_numeric_scroll_wheel_start_val;
78
79
1342
        if (step == (wheel -> gx_scroll_wheel_total_rows - 1))
80
        {
81
95
            step = 1;
82
        }
83
1247
        else if (step == (1 - wheel -> gx_scroll_wheel_total_rows))
84
        {
85
15
            step = -1;
86
        }
87
1232
        else if (wheel -> gx_scroll_wheel_total_rows > 1)
88
        {
89
1141
            step /= (wheel -> gx_scroll_wheel_total_rows - 1);
90
        }
91
92
1342
        val = wheel -> gx_numeric_scroll_wheel_start_val + (step * row);
93
1342
        _gx_utility_ltoa(val, wheel -> gx_numeric_scroll_wheel_string_buffer, GX_NUMERIC_SCROLL_WHEEL_STRING_BUFFER_SIZE);
94
95
1342
        string -> gx_string_ptr = wheel -> gx_numeric_scroll_wheel_string_buffer;
96
1342
        _gx_utility_string_length_check(string -> gx_string_ptr, &string -> gx_string_length, GX_NUMERIC_SCROLL_WHEEL_STRING_BUFFER_SIZE - 1);
97
    }
98
    else
99
    {
100
7
        string -> gx_string_ptr = GX_NULL;
101
7
        string -> gx_string_length = 0;
102
    }
103
104
1349
    return(GX_SUCCESS);
105
}
106