GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_window_scroll_info_get.c Lines: 29 29 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
/**   Window Management (Window)                                          */
18
/**                                                                       */
19
/**************************************************************************/
20
21
#define GX_SOURCE_CODE
22
23
24
/* Include necessary system files.  */
25
26
#include "gx_api.h"
27
#include "gx_widget.h"
28
#include "gx_window.h"
29
#include "gx_system.h"
30
31
32
/**************************************************************************/
33
/*                                                                        */
34
/*  FUNCTION                                               RELEASE        */
35
/*                                                                        */
36
/*    _gx_window_scroll_info_get                          PORTABLE C      */
37
/*                                                           6.1          */
38
/*  AUTHOR                                                                */
39
/*                                                                        */
40
/*    Kenneth Maxwell, Microsoft Corporation                              */
41
/*                                                                        */
42
/*  DESCRIPTION                                                           */
43
/*                                                                        */
44
/*    This service gets the window scroll information.                    */
45
/*                                                                        */
46
/*  INPUT                                                                 */
47
/*                                                                        */
48
/*    window                               Pointer to window              */
49
/*    type                                 GX_SCROLLBAR_HORIZONTAL        */
50
/*                                           or GX_SCROLLBAR_VERTICAL     */
51
/*    return_scroll_info                   Pointer to destination for     */
52
/*                                           scroll info                  */
53
/*                                                                        */
54
/*  OUTPUT                                                                */
55
/*                                                                        */
56
/*    status                               Completion status              */
57
/*                                                                        */
58
/*  CALLS                                                                 */
59
/*                                                                        */
60
/*    None                                                                */
61
/*                                                                        */
62
/*  CALLED BY                                                             */
63
/*                                                                        */
64
/*    GUIX Internal Code                                                  */
65
/*                                                                        */
66
/*  RELEASE HISTORY                                                       */
67
/*                                                                        */
68
/*    DATE              NAME                      DESCRIPTION             */
69
/*                                                                        */
70
/*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
71
/*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
72
/*                                            resulting in version 6.1    */
73
/*                                                                        */
74
/**************************************************************************/
75
393
UINT _gx_window_scroll_info_get(GX_WINDOW *window, ULONG type, GX_SCROLL_INFO *return_scroll_info)
76
{
77
GX_WIDGET *child;
78
79
    /* default scroll information is to gather the limits of my child
80
       widgets, so that they can all be scrolled into view
81
     */
82
393
    return_scroll_info -> gx_scroll_increment = 1;
83
84
393
    if (type & GX_SCROLLBAR_VERTICAL)
85
    {
86
153
        return_scroll_info -> gx_scroll_maximum = window -> gx_window_client.gx_rectangle_bottom;
87
153
        return_scroll_info -> gx_scroll_minimum = window -> gx_window_client.gx_rectangle_top;
88
153
        return_scroll_info -> gx_scroll_visible = (GX_VALUE)(return_scroll_info -> gx_scroll_maximum - return_scroll_info -> gx_scroll_minimum + 1);
89
153
        return_scroll_info -> gx_scroll_value = window -> gx_window_client.gx_rectangle_top;
90
153
        child = window -> gx_widget_first_child;
91
92
716
        while (child)
93
        {
94
563
            if (!(child -> gx_widget_status & GX_STATUS_NONCLIENT))
95
            {
96
262
                if (child -> gx_widget_size.gx_rectangle_top < return_scroll_info -> gx_scroll_minimum)
97
                {
98
136
                    return_scroll_info -> gx_scroll_minimum = child -> gx_widget_size.gx_rectangle_top;
99
                }
100
262
                if (child -> gx_widget_size.gx_rectangle_bottom > return_scroll_info -> gx_scroll_maximum)
101
                {
102
147
                    return_scroll_info -> gx_scroll_maximum = child -> gx_widget_size.gx_rectangle_bottom;
103
                }
104
            }
105
563
            child = child -> gx_widget_next;
106
        }
107
    }
108
    else
109
    {
110
240
        return_scroll_info -> gx_scroll_maximum = window -> gx_window_client.gx_rectangle_right;
111
240
        return_scroll_info -> gx_scroll_minimum = window -> gx_window_client.gx_rectangle_left;
112
240
        return_scroll_info -> gx_scroll_visible = (GX_VALUE)(return_scroll_info -> gx_scroll_maximum - return_scroll_info -> gx_scroll_minimum + 1);
113
240
        return_scroll_info -> gx_scroll_value = window -> gx_window_client.gx_rectangle_left;
114
240
        child = window -> gx_widget_first_child;
115
116
1154
        while (child)
117
        {
118
914
            if (!(child -> gx_widget_status & GX_STATUS_NONCLIENT))
119
            {
120
439
                if (child -> gx_widget_size.gx_rectangle_left < return_scroll_info -> gx_scroll_minimum)
121
                {
122
212
                    return_scroll_info -> gx_scroll_minimum = child -> gx_widget_size.gx_rectangle_left;
123
                }
124
439
                if (child -> gx_widget_size.gx_rectangle_right > return_scroll_info -> gx_scroll_maximum)
125
                {
126
234
                    return_scroll_info -> gx_scroll_maximum = child -> gx_widget_size.gx_rectangle_right;
127
                }
128
            }
129
914
            child = child -> gx_widget_next;
130
        }
131
    }
132
133
393
    return_scroll_info -> gx_scroll_increment = (GX_VALUE)(return_scroll_info -> gx_scroll_maximum - return_scroll_info -> gx_scroll_minimum) / 10;
134
135
393
    return(GX_SUCCESS);
136
}
137