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 |
|
|
/** Text Input Management (Single Line Text Input) */ |
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_widget.h" |
29 |
|
|
#include "gx_single_line_text_input.h" |
30 |
|
|
#include "gx_utility.h" |
31 |
|
|
|
32 |
|
|
/**************************************************************************/ |
33 |
|
|
/* */ |
34 |
|
|
/* FUNCTION RELEASE */ |
35 |
|
|
/* */ |
36 |
|
|
/* _gx_single_line_text_input_keydown_process PORTABLE C */ |
37 |
|
|
/* 6.1 */ |
38 |
|
|
/* AUTHOR */ |
39 |
|
|
/* */ |
40 |
|
|
/* Kenneth Maxwell, Microsoft Corporation */ |
41 |
|
|
/* */ |
42 |
|
|
/* DESCRIPTION */ |
43 |
|
|
/* */ |
44 |
|
|
/* This function processes key-down events for the single line text */ |
45 |
|
|
/* input widget. */ |
46 |
|
|
/* */ |
47 |
|
|
/* INPUT */ |
48 |
|
|
/* */ |
49 |
|
|
/* text_input Single-line text input widget */ |
50 |
|
|
/* control block */ |
51 |
|
|
/* event_ptr Pointer to GX_EVENT structure */ |
52 |
|
|
/* */ |
53 |
|
|
/* OUTPUT */ |
54 |
|
|
/* */ |
55 |
|
|
/* None */ |
56 |
|
|
/* */ |
57 |
|
|
/* CALLS */ |
58 |
|
|
/* */ |
59 |
|
|
/* _gx_widget_event_process Default widget event process */ |
60 |
|
|
/* _gx_widget_event_generate Create a event and send it to */ |
61 |
|
|
/* parent */ |
62 |
|
|
/* _gx_single_line_text_input_home Process the home key */ |
63 |
|
|
/* _gx_single_line_text_input_end Process the end key */ |
64 |
|
|
/* _gx_single_line_text_input_backspace Process the backspace key */ |
65 |
|
|
/* _gx_single_line_text_input_character_delete */ |
66 |
|
|
/* Delete a character */ |
67 |
|
|
/* _gx_single_line_text_input_left_arrow */ |
68 |
|
|
/* Process the left arrow key */ |
69 |
|
|
/* _gx_single_line_text_input_right_arrow */ |
70 |
|
|
/* Process the right arrow key */ |
71 |
|
|
/* _gx_single_line_text_input_character_insert */ |
72 |
|
|
/* Insert a charcter */ |
73 |
|
|
/* */ |
74 |
|
|
/* CALLED BY */ |
75 |
|
|
/* */ |
76 |
|
|
/* _gx_single_line_text_input_event_process */ |
77 |
|
|
/* Single line text input widget */ |
78 |
|
|
/* event process routine */ |
79 |
|
|
/* */ |
80 |
|
|
/* RELEASE HISTORY */ |
81 |
|
|
/* */ |
82 |
|
|
/* DATE NAME DESCRIPTION */ |
83 |
|
|
/* */ |
84 |
|
|
/* 05-19-2020 Kenneth Maxwell Initial Version 6.0 */ |
85 |
|
|
/* 09-30-2020 Kenneth Maxwell Modified comment(s), */ |
86 |
|
|
/* resulting in version 6.1 */ |
87 |
|
|
/* */ |
88 |
|
|
/**************************************************************************/ |
89 |
|
12077 |
VOID _gx_single_line_text_input_keydown_process(GX_SINGLE_LINE_TEXT_INPUT *text_input, GX_EVENT *event_ptr) |
90 |
|
|
{ |
91 |
|
12077 |
GX_WIDGET *widget = (GX_WIDGET *)text_input; |
92 |
|
|
USHORT key_value; |
93 |
|
|
GX_UBYTE utf8_str[10]; |
94 |
|
|
UINT utf8_size; |
95 |
|
|
|
96 |
|
|
/* Process relative to the value of key. */ |
97 |
✓✓✓✓ ✓✓✓✓ ✓ |
12077 |
switch (event_ptr -> gx_event_payload.gx_event_ushortdata[0]) |
98 |
|
|
{ |
99 |
|
667 |
case GX_KEY_HOME: |
100 |
|
667 |
_gx_single_line_text_input_home(text_input); |
101 |
|
667 |
break; |
102 |
|
|
|
103 |
|
660 |
case GX_KEY_END: |
104 |
|
660 |
_gx_single_line_text_input_end(text_input); |
105 |
|
660 |
break; |
106 |
|
|
|
107 |
|
548 |
case GX_KEY_BACKSPACE: |
108 |
|
548 |
_gx_single_line_text_input_backspace(text_input); |
109 |
|
548 |
break; |
110 |
|
|
|
111 |
|
559 |
case GX_KEY_DELETE: |
112 |
|
559 |
_gx_single_line_text_input_character_delete(text_input); |
113 |
|
559 |
break; |
114 |
|
|
|
115 |
|
556 |
case GX_KEY_LEFT_ARROW: |
116 |
|
556 |
_gx_single_line_text_input_left_arrow(text_input); |
117 |
|
556 |
break; |
118 |
|
|
|
119 |
|
6404 |
case GX_KEY_RIGHT_ARROW: |
120 |
|
6404 |
_gx_single_line_text_input_right_arrow(text_input); |
121 |
|
6404 |
break; |
122 |
|
|
|
123 |
|
501 |
case GX_KEY_SELECT: |
124 |
✓✓ |
501 |
if (text_input -> gx_single_line_text_input_was_modified) |
125 |
|
|
{ |
126 |
|
497 |
_gx_widget_event_generate(widget, GX_EVENT_TEXT_EDITED, 0); |
127 |
|
497 |
text_input -> gx_single_line_text_input_was_modified = GX_FALSE; |
128 |
|
|
} |
129 |
|
501 |
break; |
130 |
|
516 |
case GX_KEY_SPACE: |
131 |
|
516 |
utf8_str[0] = ' '; |
132 |
|
516 |
utf8_size = 1; |
133 |
|
516 |
_gx_single_line_text_input_character_insert(text_input, utf8_str, utf8_size); |
134 |
|
516 |
break; |
135 |
|
|
|
136 |
|
1666 |
default: |
137 |
|
1666 |
key_value = event_ptr -> gx_event_payload.gx_event_ushortdata[0]; |
138 |
|
|
|
139 |
✓✓✓✓
|
1666 |
if ((key_value <= 0x1f) || |
140 |
✓✓ |
408 |
((key_value >= 0x1b01) && key_value <= 0x1b14)) |
141 |
|
|
{ |
142 |
|
293 |
_gx_widget_event_process((GX_WIDGET *)text_input, event_ptr); |
143 |
|
293 |
return; |
144 |
|
|
} |
145 |
|
|
|
146 |
|
|
/* If the key value is displayable, insert the value to the text input. */ |
147 |
✓✓ |
1373 |
if (key_value <= 0x7e) |
148 |
|
|
{ |
149 |
|
1255 |
utf8_str[0] = (GX_UBYTE)key_value; |
150 |
|
1255 |
utf8_size = 1; |
151 |
|
1255 |
_gx_single_line_text_input_character_insert(text_input, utf8_str, utf8_size); |
152 |
|
|
} |
153 |
|
|
#ifdef GX_UTF8_SUPPORT |
154 |
|
|
else |
155 |
|
|
{ |
156 |
|
118 |
_gx_utility_unicode_to_utf8(key_value, utf8_str, &utf8_size); |
157 |
|
|
|
158 |
|
|
/* Insert a utf8 string to input buffer. */ |
159 |
|
118 |
_gx_single_line_text_input_character_insert(text_input, utf8_str, utf8_size); |
160 |
|
|
} |
161 |
|
|
#endif |
162 |
|
1373 |
break; |
163 |
|
|
} |
164 |
|
|
} |
165 |
|
|
|