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 |
|
|
/** Multi Line Text View Management (Multi Line Text View) */ |
18 |
|
|
/** */ |
19 |
|
|
/**************************************************************************/ |
20 |
|
|
|
21 |
|
|
#define GX_SOURCE_CODE |
22 |
|
|
|
23 |
|
|
|
24 |
|
|
/* Include necessary system files. */ |
25 |
|
|
|
26 |
|
|
#include "gx_api.h" |
27 |
|
|
#include "gx_system.h" |
28 |
|
|
#include "gx_window.h" |
29 |
|
|
#include "gx_multi_line_text_view.h" |
30 |
|
|
#include "gx_widget.h" |
31 |
|
|
|
32 |
|
|
/**************************************************************************/ |
33 |
|
|
/* */ |
34 |
|
|
/* FUNCTION RELEASE */ |
35 |
|
|
/* */ |
36 |
|
|
/* _gx_multi_line_text_view_visible_rows_compute PORTABLE C */ |
37 |
|
|
/* 6.1 */ |
38 |
|
|
/* AUTHOR */ |
39 |
|
|
/* */ |
40 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
41 |
|
|
/* */ |
42 |
|
|
/* DESCRIPTION */ |
43 |
|
|
/* */ |
44 |
|
|
/* This function computes the number of visible rows. */ |
45 |
|
|
/* */ |
46 |
|
|
/* INPUT */ |
47 |
|
|
/* */ |
48 |
|
|
/* view Multi line text view */ |
49 |
|
|
/* control block */ |
50 |
|
|
/* */ |
51 |
|
|
/* OUTPUT */ |
52 |
|
|
/* */ |
53 |
|
|
/* None */ |
54 |
|
|
/* */ |
55 |
|
|
/* CALLS */ |
56 |
|
|
/* */ |
57 |
|
|
/* _gx_widget_font_get Retrieve font */ |
58 |
|
|
/* _gx_window_client_height_get Get the height of client */ |
59 |
|
|
/* */ |
60 |
|
|
/* CALLED BY */ |
61 |
|
|
/* */ |
62 |
|
|
/* _gx_multi_line_text_view_event_process */ |
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 |
|
1021 |
UINT _gx_multi_line_text_view_visible_rows_compute(GX_MULTI_LINE_TEXT_VIEW *view) |
74 |
|
|
{ |
75 |
|
|
GX_FONT *font; |
76 |
|
|
GX_VALUE widget_height; |
77 |
|
|
INT line_height; |
78 |
|
|
|
79 |
|
1021 |
_gx_widget_font_get((GX_WIDGET *)view, view -> gx_multi_line_text_view_font_id, &font); |
80 |
|
|
|
81 |
✓✓ |
1021 |
if (!font) |
82 |
|
|
{ |
83 |
|
25 |
return GX_FAILURE; |
84 |
|
|
} |
85 |
|
|
|
86 |
|
|
/* Pickup text height. */ |
87 |
|
996 |
line_height = font -> gx_font_line_height + view -> gx_multi_line_text_view_line_space; |
88 |
|
|
|
89 |
|
|
/* Pickup widget height. */ |
90 |
|
996 |
_gx_window_client_height_get((GX_WINDOW *)view, &widget_height); |
91 |
|
|
|
92 |
✓✓ |
996 |
if (line_height) |
93 |
|
|
{ |
94 |
|
995 |
widget_height = (GX_VALUE)(widget_height - (view -> gx_multi_line_text_view_whitespace << 1)); |
95 |
|
|
|
96 |
|
|
/* Compute the total rows number of the widget. */ |
97 |
|
995 |
view -> gx_multi_line_text_view_text_visible_rows = (UINT)((widget_height + line_height - 1) / line_height); |
98 |
|
|
} |
99 |
|
|
|
100 |
|
996 |
return GX_SUCCESS; |
101 |
|
|
} |
102 |
|
|
|