1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
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 /*  RELEASE HISTORY                                                       */
66 /*                                                                        */
67 /*    DATE              NAME                      DESCRIPTION             */
68 /*                                                                        */
69 /*  05-19-2020     Kenneth Maxwell          Initial Version 6.0           */
70 /*  09-30-2020     Kenneth Maxwell          Modified comment(s),          */
71 /*                                            resulting in version 6.1    */
72 /*                                                                        */
73 /**************************************************************************/
_gx_multi_line_text_view_visible_rows_compute(GX_MULTI_LINE_TEXT_VIEW * view)74 UINT _gx_multi_line_text_view_visible_rows_compute(GX_MULTI_LINE_TEXT_VIEW *view)
75 {
76 GX_FONT *font;
77 GX_VALUE widget_height;
78 INT      line_height;
79 
80     _gx_widget_font_get((GX_WIDGET *)view, view -> gx_multi_line_text_view_font_id, &font);
81 
82     if (!font)
83     {
84         return GX_FAILURE;
85     }
86 
87     /* Pickup text height. */
88     line_height = font -> gx_font_line_height + view -> gx_multi_line_text_view_line_space;
89 
90     /* Pickup widget height. */
91     _gx_window_client_height_get((GX_WINDOW *)view, &widget_height);
92 
93     if (line_height)
94     {
95         widget_height = (GX_VALUE)(widget_height - (view -> gx_multi_line_text_view_whitespace << 1));
96 
97         /* Compute the total rows number of the widget. */
98         view -> gx_multi_line_text_view_text_visible_rows = (UINT)((widget_height + line_height - 1) / line_height);
99     }
100 
101     return GX_SUCCESS;
102 }
103 
104