GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: gx_multi_line_text_view_visible_rows_compute.c Lines: 10 10 100.0 %
Date: 2026-03-06 19:21:09 Branches: 4 4 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_window.h"
30
#include "gx_multi_line_text_view.h"
31
#include "gx_widget.h"
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _gx_multi_line_text_view_visible_rows_compute       PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Kenneth Maxwell, Microsoft Corporation                              */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function computes the number of visible rows.                  */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    view                                  Multi line text view          */
50
/*                                            control block               */
51
/*                                                                        */
52
/*  OUTPUT                                                                */
53
/*                                                                        */
54
/*    None                                                                */
55
/*                                                                        */
56
/*  CALLS                                                                 */
57
/*                                                                        */
58
/*    _gx_widget_font_get                   Retrieve font                 */
59
/*    _gx_window_client_height_get          Get the height of client      */
60
/*                                                                        */
61
/*  CALLED BY                                                             */
62
/*                                                                        */
63
/*    _gx_multi_line_text_view_event_process                              */
64
/*                                                                        */
65
/**************************************************************************/
66
1021
UINT _gx_multi_line_text_view_visible_rows_compute(GX_MULTI_LINE_TEXT_VIEW *view)
67
{
68
GX_FONT *font;
69
GX_VALUE widget_height;
70
INT      line_height;
71
72
1021
    _gx_widget_font_get((GX_WIDGET *)view, view -> gx_multi_line_text_view_font_id, &font);
73
74
1021
    if (!font)
75
    {
76
25
        return GX_FAILURE;
77
    }
78
79
    /* Pickup text height. */
80
996
    line_height = font -> gx_font_line_height + view -> gx_multi_line_text_view_line_space;
81
82
    /* Pickup widget height. */
83
996
    _gx_window_client_height_get((GX_WINDOW *)view, &widget_height);
84
85
996
    if (line_height)
86
    {
87
995
        widget_height = (GX_VALUE)(widget_height - (view -> gx_multi_line_text_view_whitespace << 1));
88
89
        /* Compute the total rows number of the widget. */
90
995
        view -> gx_multi_line_text_view_text_visible_rows = (UINT)((widget_height + line_height - 1) / line_height);
91
    }
92
93
996
    return GX_SUCCESS;
94
}
95