GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_tree_view_scroll_info_get.c Lines: 35 35 100.0 %
Date: 2024-12-05 08:52:37 Branches: 18 18 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
/**   Tree View Management (Menu)                                         */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_tree_view.h"
28
29
/**************************************************************************/
30
/*                                                                        */
31
/*  FUNCTION                                               RELEASE        */
32
/*                                                                        */
33
/*    _gx_tree_view_scroll_info_get                       PORTABLE C      */
34
/*                                                           6.1          */
35
/*  AUTHOR                                                                */
36
/*                                                                        */
37
/*    Kenneth Maxwell, Microsoft Corporation                              */
38
/*                                                                        */
39
/*  DESCRIPTION                                                           */
40
/*                                                                        */
41
/*    This function gets the tree view scroll information.                */
42
/*                                                                        */
43
/*  INPUT                                                                 */
44
/*                                                                        */
45
/*    tree                                 Pointer to tree view control   */
46
/*                                           block                        */
47
/*    type                                 GX_SCROLLBAR_HORIZONTAL        */
48
/*                                           or GX_SCROLLBAR_VERTICAL     */
49
/*    info                                 Pointer to destination for     */
50
/*                                           scroll info                  */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    status                               Completion status              */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    _gx_tree_view_scroll                 Scroll tree view client area   */
59
/*                                                                        */
60
/*  CALLED BY                                                             */
61
/*                                                                        */
62
/*    GUIX Internal Code                                                  */
63
/*                                                                        */
64
/*  RELEASE HISTORY                                                       */
65
/*                                                                        */
66
/*    DATE              NAME                      DESCRIPTION             */
67
/*                                                                        */
68
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
69
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
70
/*                                            resulting in version 6.1    */
71
/*                                                                        */
72
/**************************************************************************/
73
280
UINT _gx_tree_view_scroll_info_get(GX_TREE_VIEW *tree, ULONG type, GX_SCROLL_INFO *info)
74
{
75
GX_RECTANGLE *client;
76
INT           shift;
77
INT           value;
78
79
280
    client = &tree -> gx_window_client;
80
81
280
    if (type & GX_SCROLLBAR_VERTICAL)
82
    {
83
119
        info -> gx_scroll_minimum = client -> gx_rectangle_top;
84
119
        info -> gx_scroll_maximum = info -> gx_scroll_minimum + tree -> gx_tree_view_tree_height - 1;
85
119
        info -> gx_scroll_visible = (GX_VALUE)(client -> gx_rectangle_bottom - client -> gx_rectangle_top + 1);
86
87
119
        if (tree -> gx_tree_view_tree_height < info -> gx_scroll_visible)
88
        {
89
106
            info -> gx_scroll_maximum = info -> gx_scroll_minimum + info -> gx_scroll_visible - 1;
90
        }
91
92
119
        shift = tree -> gx_tree_view_y_shift;
93
119
        value = client -> gx_rectangle_top - shift;
94
95
119
        if (value < info -> gx_scroll_minimum)
96
        {
97
1
            value = info -> gx_scroll_minimum;
98
        }
99
118
        else if (value > info -> gx_scroll_maximum - info -> gx_scroll_visible + 1)
100
        {
101
5
            value = info -> gx_scroll_maximum - info -> gx_scroll_visible + 1;
102
        }
103
104
119
        shift = client -> gx_rectangle_top - value;
105
106
119
        if (shift != tree -> gx_tree_view_y_shift)
107
        {
108
6
            _gx_tree_view_scroll(tree, 0, (GX_VALUE)(shift - tree->gx_tree_view_y_shift));
109
        }
110
111
119
        info -> gx_scroll_value = value;
112
    }
113
    else
114
    {
115
161
        info -> gx_scroll_minimum = client -> gx_rectangle_left;
116
161
        info -> gx_scroll_maximum = info -> gx_scroll_minimum + tree -> gx_tree_view_tree_width - 1;
117
161
        info -> gx_scroll_visible = (GX_VALUE)(client -> gx_rectangle_right - client -> gx_rectangle_left + 1);
118
119
161
        if (tree -> gx_tree_view_tree_width < info -> gx_scroll_visible)
120
        {
121
143
            info -> gx_scroll_maximum = info -> gx_scroll_minimum + info -> gx_scroll_visible - 1;
122
        }
123
124
161
        shift = tree -> gx_tree_view_x_shift;
125
161
        value = client -> gx_rectangle_left - shift;
126
127
161
        if (value < info -> gx_scroll_minimum)
128
        {
129
1
            value = info -> gx_scroll_minimum;
130
        }
131
160
        else if (value > info -> gx_scroll_maximum - info -> gx_scroll_visible + 1)
132
        {
133
1
            value = info -> gx_scroll_maximum - info -> gx_scroll_visible + 1;
134
        }
135
136
161
        shift = client -> gx_rectangle_left - value;
137
161
        if (shift != tree -> gx_tree_view_x_shift)
138
        {
139
2
            _gx_tree_view_scroll(tree, (GX_VALUE)(shift - tree->gx_tree_view_x_shift), 0);
140
        }
141
161
        info -> gx_scroll_value = value;
142
    }
143
144
280
    info -> gx_scroll_increment = (GX_VALUE)(info -> gx_scroll_maximum - info -> gx_scroll_minimum) / 10;
145
146
280
    return(GX_SUCCESS);
147
}
148