GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_multi_line_text_view_scroll.c Lines: 19 19 100.0 %
Date: 2026-03-06 19:21:09 Branches: 12 12 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
/**   Multi Line Text View Management (Multi Line Text View)              */
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_multi_line_text_view.h"
30
#include "gx_window.h"
31
#include "gx_widget.h"
32
#include "gx_utility.h"
33
#include "gx_scrollbar.h"
34
35
36
/**************************************************************************/
37
/*                                                                        */
38
/*  FUNCTION                                               RELEASE        */
39
/*                                                                        */
40
/*    _gx_multi_line_text_view_scroll                     PORTABLE C      */
41
/*                                                           6.1          */
42
/*  AUTHOR                                                                */
43
/*                                                                        */
44
/*    Kenneth Maxwell, Microsoft Corporation                              */
45
/*                                                                        */
46
/*  DESCRIPTION                                                           */
47
/*                                                                        */
48
/*    This function performs the scroll action                            */
49
/*                                                                        */
50
/*  INPUT                                                                 */
51
/*                                                                        */
52
/*    view                                  Multi-line text view widget   */
53
/*                                             control block              */
54
/*    amount_to_scroll                      Shifting value                */
55
/*                                                                        */
56
/*  OUTPUT                                                                */
57
/*                                                                        */
58
/*    status                                Completion status             */
59
/*                                                                        */
60
/*  CALLS                                                                 */
61
/*                                                                        */
62
/*    _gx_window_scrollbar_find             Find scrollbar for a window   */
63
/*    _gx_scrollbar_reset                   Reset scrollbar information   */
64
/*    _gx_utility_rectangle_resize          Offset rectangle by specified */
65
/*                                            value                       */
66
/*    _gx_multi_line_text_view_line_cache_update                          */
67
/*                                          Update line cache             */
68
/*    _gx_widget_block_move                 Move a block of pixels        */
69
/*                                                                        */
70
/*  CALLED BY                                                             */
71
/*                                                                        */
72
/*    _gx_multi_line_text_view_event_process                              */
73
/*                                         Multi line text view           */
74
/*                                           event process routine        */
75
/*                                                                        */
76
/**************************************************************************/
77
1116
UINT    _gx_multi_line_text_view_scroll(GX_MULTI_LINE_TEXT_VIEW *view, GX_VALUE amount_to_scroll)
78
{
79
GX_RECTANGLE  block;
80
GX_SCROLLBAR *scroll;
81
82
1116
    if (!amount_to_scroll)
83
    {
84
1
        return GX_SUCCESS;
85
    }
86
87
    /* Calculate the shift value. */
88
1115
    view -> gx_multi_line_text_view_text_scroll_shift += amount_to_scroll;
89
90
1115
    _gx_window_scrollbar_find((GX_WINDOW *)view, GX_TYPE_VERTICAL_SCROLL, &scroll);
91
92
1115
    if (scroll)
93
    {
94
1113
        _gx_scrollbar_reset((GX_SCROLLBAR *)scroll, GX_NULL);
95
    }
96
    else
97
    {
98
2
        if (view -> gx_multi_line_text_view_text_total_rows >
99
2
            view -> gx_multi_line_text_view_cache_size)
100
        {
101
            /* Update line index. */
102
1
            _gx_multi_line_text_view_line_cache_update(view);
103
        }
104
    }
105
106
1115
    block = view -> gx_window_client;
107
108
    /* Offset client area by the size of whitespace.  */
109
1115
    _gx_utility_rectangle_resize(&block, (GX_VALUE)(-view -> gx_multi_line_text_view_whitespace));
110
111
1115
    block.gx_rectangle_left = (GX_VALUE)(block.gx_rectangle_left + 1);
112
113
    /* If the text view has a thin (rounded) border with no
114
       whitespace between border and text, we cannot use block
115
       move to scroll because we will capture pixels from the
116
       rounded corner. In that case just use dirty_mark, otherwise
117
       use block_move
118
    */
119
1115
    if ((view -> gx_widget_style & GX_STYLE_BORDER_THIN) &&
120
834
        !(view -> gx_widget_style & GX_STYLE_TRANSPARENT) &&
121
833
        (view -> gx_multi_line_text_view_whitespace == 0))
122
    {
123
142
        _gx_system_dirty_mark((GX_WIDGET *)view);
124
    }
125
    else
126
    {
127
973
        _gx_widget_block_move((GX_WIDGET *)view, &block, 0, amount_to_scroll);
128
    }
129
130
1115
    return(GX_SUCCESS);
131
}
132