GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_scrollbar_value_set.c Lines: 17 17 100.0 %
Date: 2026-03-06 19:21:09 Branches: 6 6 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
/**   Scrollbar Management (Scrollbar)                                    */
19
/**                                                                       */
20
/**************************************************************************/
21
22
#define GX_SOURCE_CODE
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_system.h"
28
#include "gx_scrollbar.h"
29
30
/**************************************************************************/
31
/*                                                                        */
32
/*  FUNCTION                                               RELEASE        */
33
/*                                                                        */
34
/*    _gx_scrollbar_value_set                             PORTABLE C      */
35
/*                                                           6.1          */
36
/*  AUTHOR                                                                */
37
/*                                                                        */
38
/*    Kenneth Maxwell, Microsoft Corporation                              */
39
/*                                                                        */
40
/*  DESCRIPTION                                                           */
41
/*                                                                        */
42
/*    This service resets the scrollbar.                                  */
43
/*                                                                        */
44
/*                                                                        */
45
/*  INPUT                                                                 */
46
/*                                                                        */
47
/*    scrollbar                             Scrollbar control block       */
48
/*    value                                 New scrollbar value           */
49
/*                                                                        */
50
/*  OUTPUT                                                                */
51
/*                                                                        */
52
/*    status                                Completion status             */
53
/*                                                                        */
54
/*  CALLS                                                                 */
55
/*                                                                        */
56
/*    _gx_scrollbar_limit_check             Check value limits            */
57
/*    _gx_scrollbar_thumb_position_calculate                              */
58
/*                                          Calculate the scrollbar thumb */
59
/*                                          position                      */
60
/*    _gx_system_dirty_mark                 Mark system block dirty       */
61
/*                                                                        */
62
/*  CALLED BY                                                             */
63
/*                                                                        */
64
/*    Application Code                                                    */
65
/*                                                                        */
66
/**************************************************************************/
67
966
UINT _gx_scrollbar_value_set(GX_SCROLLBAR *scrollbar, INT value)
68
{
69
GX_EVENT newevent;
70
INT old_value;
71
72
966
    old_value = scrollbar -> gx_scrollbar_info.gx_scroll_value;
73
74
966
    scrollbar -> gx_scrollbar_info.gx_scroll_value = value;
75
966
    _gx_scrollbar_limit_check(scrollbar);
76
77
966
    if (old_value != scrollbar ->gx_scrollbar_info.gx_scroll_value)
78
    {
79
902
        _gx_scrollbar_thumb_position_calculate(scrollbar);
80
81
902
        newevent.gx_event_payload.gx_event_intdata[0] = scrollbar -> gx_scrollbar_info.gx_scroll_value;
82
902
        newevent.gx_event_payload.gx_event_intdata[1] = old_value;
83
902
        newevent.gx_event_sender = scrollbar -> gx_widget_id;
84
85
902
        if (scrollbar -> gx_widget_style & GX_SCROLLBAR_VERTICAL)
86
        {
87
169
            newevent.gx_event_type = GX_EVENT_VERTICAL_SCROLL;
88
        }
89
        else
90
        {
91
733
            newevent.gx_event_type = GX_EVENT_HORIZONTAL_SCROLL;
92
        }
93
902
        newevent.gx_event_target = scrollbar -> gx_widget_parent;
94
902
        _gx_system_event_send(&newevent);
95
96
902
        if (scrollbar -> gx_widget_status & GX_STATUS_VISIBLE)
97
        {
98
897
            _gx_system_dirty_mark((GX_WIDGET *)scrollbar);
99
        }
100
    }
101
966
    return(GX_SUCCESS);
102
}
103