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_multi_line_text_view.h" |
29 |
|
|
#include "gx_window.h" |
30 |
|
|
#include "gx_widget.h" |
31 |
|
|
#include "gx_utility.h" |
32 |
|
|
#include "gx_scrollbar.h" |
33 |
|
|
|
34 |
|
|
|
35 |
|
|
/**************************************************************************/ |
36 |
|
|
/* */ |
37 |
|
|
/* FUNCTION RELEASE */ |
38 |
|
|
/* */ |
39 |
|
|
/* _gx_multi_line_text_view_scroll PORTABLE C */ |
40 |
|
|
/* 6.1 */ |
41 |
|
|
/* AUTHOR */ |
42 |
|
|
/* */ |
43 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
44 |
|
|
/* */ |
45 |
|
|
/* DESCRIPTION */ |
46 |
|
|
/* */ |
47 |
|
|
/* This function performs the scroll action */ |
48 |
|
|
/* */ |
49 |
|
|
/* INPUT */ |
50 |
|
|
/* */ |
51 |
|
|
/* view Multi-line text view widget */ |
52 |
|
|
/* control block */ |
53 |
|
|
/* amount_to_scroll Shifting value */ |
54 |
|
|
/* */ |
55 |
|
|
/* OUTPUT */ |
56 |
|
|
/* */ |
57 |
|
|
/* status Completion status */ |
58 |
|
|
/* */ |
59 |
|
|
/* CALLS */ |
60 |
|
|
/* */ |
61 |
|
|
/* _gx_window_scrollbar_find Find scrollbar for a window */ |
62 |
|
|
/* _gx_scrollbar_reset Reset scrollbar information */ |
63 |
|
|
/* _gx_utility_rectangle_resize Offset rectangle by specified */ |
64 |
|
|
/* value */ |
65 |
|
|
/* _gx_multi_line_text_view_line_cache_update */ |
66 |
|
|
/* Update line cache */ |
67 |
|
|
/* _gx_widget_block_move Move a block of pixels */ |
68 |
|
|
/* */ |
69 |
|
|
/* CALLED BY */ |
70 |
|
|
/* */ |
71 |
|
|
/* _gx_multi_line_text_view_event_process */ |
72 |
|
|
/* Multi line text view */ |
73 |
|
|
/* event process routine */ |
74 |
|
|
/* */ |
75 |
|
|
/* RELEASE HISTORY */ |
76 |
|
|
/* */ |
77 |
|
|
/* DATE NAME DESCRIPTION */ |
78 |
|
|
/* */ |
79 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
80 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
81 |
|
|
/* resulting in version 6.1 */ |
82 |
|
|
/* */ |
83 |
|
|
/**************************************************************************/ |
84 |
|
1116 |
UINT _gx_multi_line_text_view_scroll(GX_MULTI_LINE_TEXT_VIEW *view, GX_VALUE amount_to_scroll) |
85 |
|
|
{ |
86 |
|
|
GX_RECTANGLE block; |
87 |
|
|
GX_SCROLLBAR *scroll; |
88 |
|
|
|
89 |
✓✓ |
1116 |
if (!amount_to_scroll) |
90 |
|
|
{ |
91 |
|
1 |
return GX_SUCCESS; |
92 |
|
|
} |
93 |
|
|
|
94 |
|
|
/* Calculate the shift value. */ |
95 |
|
1115 |
view -> gx_multi_line_text_view_text_scroll_shift += amount_to_scroll; |
96 |
|
|
|
97 |
|
1115 |
_gx_window_scrollbar_find((GX_WINDOW *)view, GX_TYPE_VERTICAL_SCROLL, &scroll); |
98 |
|
|
|
99 |
✓✓ |
1115 |
if (scroll) |
100 |
|
|
{ |
101 |
|
1113 |
_gx_scrollbar_reset((GX_SCROLLBAR *)scroll, GX_NULL); |
102 |
|
|
} |
103 |
|
|
else |
104 |
|
|
{ |
105 |
|
2 |
if (view -> gx_multi_line_text_view_text_total_rows > |
106 |
✓✓ |
2 |
view -> gx_multi_line_text_view_cache_size) |
107 |
|
|
{ |
108 |
|
|
/* Update line index. */ |
109 |
|
1 |
_gx_multi_line_text_view_line_cache_update(view); |
110 |
|
|
} |
111 |
|
|
} |
112 |
|
|
|
113 |
|
1115 |
block = view -> gx_window_client; |
114 |
|
|
|
115 |
|
|
/* Offset client area by the size of whitespace. */ |
116 |
|
1115 |
_gx_utility_rectangle_resize(&block, (GX_VALUE)(-view -> gx_multi_line_text_view_whitespace)); |
117 |
|
|
|
118 |
|
1115 |
block.gx_rectangle_left = (GX_VALUE)(block.gx_rectangle_left + 1); |
119 |
|
|
|
120 |
|
|
/* If the text view has a thin (rounded) border with no |
121 |
|
|
whitespace between border and text, we cannot use block |
122 |
|
|
move to scroll because we will capture pixels from the |
123 |
|
|
rounded corner. In that case just use dirty_mark, otherwise |
124 |
|
|
use block_move |
125 |
|
|
*/ |
126 |
✓✓ |
1115 |
if ((view -> gx_widget_style & GX_STYLE_BORDER_THIN) && |
127 |
✓✓ |
834 |
!(view -> gx_widget_style & GX_STYLE_TRANSPARENT) && |
128 |
✓✓ |
833 |
(view -> gx_multi_line_text_view_whitespace == 0)) |
129 |
|
|
{ |
130 |
|
142 |
_gx_system_dirty_mark((GX_WIDGET *)view); |
131 |
|
|
} |
132 |
|
|
else |
133 |
|
|
{ |
134 |
|
973 |
_gx_widget_block_move((GX_WIDGET *)view, &block, 0, amount_to_scroll); |
135 |
|
|
} |
136 |
|
|
|
137 |
|
1115 |
return(GX_SUCCESS); |
138 |
|
|
} |
139 |
|
|
|