GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_tree_view_scroll.c Lines: 27 27 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
/**   Tree View Management (Tree 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_widget.h"
29
#include "gx_tree_view.h"
30
#include "gx_system.h"
31
#include "gx_window.h"
32
#include "gx_scrollbar.h"
33
34
/**************************************************************************/
35
/*                                                                        */
36
/*  FUNCTION                                               RELEASE        */
37
/*                                                                        */
38
/*    _gx_tree_view_scroll                                PORTABLE C      */
39
/*                                                           6.1          */
40
/*  AUTHOR                                                                */
41
/*                                                                        */
42
/*    Kenneth Maxwell, Microsoft Corporation                              */
43
/*                                                                        */
44
/*  DESCRIPTION                                                           */
45
/*                                                                        */
46
/*    This service scrolls the tree client area by the specified amount.  */
47
/*                                                                        */
48
/*                                                                        */
49
/*  INPUT                                                                 */
50
/*                                                                        */
51
/*    tree                                  Pointer to tree view          */
52
/*    x_scroll                              Amount to scroll on x-axis    */
53
/*    y_scroll                              Amount to scroll on y-axis    */
54
/*                                                                        */
55
/*  OUTPUT                                                                */
56
/*                                                                        */
57
/*    status                                Completion status             */
58
/*                                                                        */
59
/*  CALLS                                                                 */
60
/*                                                                        */
61
/*    _gx_widget_scroll_shift               Change position of a widget   */
62
/*    _gx_widget_block_move                 Move a block of widget area   */
63
/*    _gx_window_scrollbar_find             Find scrollbar for a widget   */
64
/*    _gx_scrollbar_reset                   Reset scrollbar information   */
65
/*    _gx_system_dirty_partial_add          Mark partial area of a widget */
66
/*                                            as dirty                    */
67
/*                                                                        */
68
/*  CALLED BY                                                             */
69
/*                                                                        */
70
/*    GUIX Internal Code                                                  */
71
/*                                                                        */
72
/**************************************************************************/
73
14
UINT _gx_tree_view_scroll(GX_TREE_VIEW *tree, GX_VALUE x_scroll, GX_VALUE y_scroll)
74
{
75
GX_RECTANGLE  block;
76
GX_WIDGET    *child;
77
GX_SCROLLBAR *scroll;
78
79
14
    block = tree -> gx_window_client;
80
81
14
    if (!(tree -> gx_widget_style & GX_STYLE_TRANSPARENT) &&
82
12
        (tree -> gx_widget_style & GX_STYLE_BORDER_THIN))
83
    {
84
        /* Widget with think border have a round corner, which have some effects to block move. */
85
9
        block.gx_rectangle_right = (GX_VALUE)(block.gx_rectangle_left + 1);
86
9
        _gx_system_dirty_partial_add((GX_WIDGET *)tree, &block);
87
88
9
        block = tree -> gx_window_client;
89
9
        block.gx_rectangle_bottom = (GX_VALUE)(block.gx_rectangle_top + 1);
90
9
        _gx_system_dirty_partial_add((GX_WIDGET *)tree, &block);
91
92
9
        block = tree -> gx_window_client;
93
9
        block.gx_rectangle_left = (GX_VALUE)(block.gx_rectangle_left + 2);
94
9
        block.gx_rectangle_top = (GX_VALUE)(block.gx_rectangle_top + 2);
95
    }
96
97
    /* Calculate shift values. */
98
14
    tree -> gx_tree_view_x_shift = (GX_VALUE)(tree -> gx_tree_view_x_shift + x_scroll);
99
14
    tree -> gx_tree_view_y_shift = (GX_VALUE)(tree -> gx_tree_view_y_shift + y_scroll);
100
101
14
    child = tree -> gx_widget_first_child;
102
133
    while (child)
103
    {
104
119
        if (!(child -> gx_widget_status & GX_STATUS_NONCLIENT))
105
        {
106
92
            _gx_widget_scroll_shift(child, x_scroll, y_scroll, GX_TRUE);
107
        }
108
119
        child = child -> gx_widget_next;
109
    }
110
111
14
    _gx_widget_block_move((GX_WIDGET *)tree, &block, x_scroll, y_scroll);
112
113
    /* if we have a scrollbar, we need to tell it to re-calculate the thumb position */
114
115
14
    scroll = GX_NULL;
116
117
14
    if (x_scroll)
118
    {
119
5
        _gx_window_scrollbar_find((GX_WINDOW *)tree, (USHORT)GX_TYPE_HORIZONTAL_SCROLL, &scroll);
120
    }
121
    else
122
    {
123
9
        _gx_window_scrollbar_find((GX_WINDOW *)tree, GX_TYPE_VERTICAL_SCROLL, &scroll);
124
    }
125
126
14
    if (scroll)
127
    {
128
13
        _gx_scrollbar_reset(scroll, GX_NULL);
129
    }
130
14
    return(GX_SUCCESS);
131
}
132