https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1fc041c91a89b9a3327b7…
commit 1fc041c91a89b9a3327b76ebc18590787387ddb5
Author: Baruch Rutman <peterooch(a)gmail.com>
AuthorDate: Fri Sep 7 10:59:59 2018 +0300
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Sun Sep 9 18:03:48 2018 +0200
[BIDITEXT] Add more demo code. (#842)
Add code that demonstrates the use of the lpOrder and lpCaretPos struct members of
GCP_RESULTS w/ and w/o GCP_REORDER flag.
Changed demo string literals to arrays containing character unicode values.
---
modules/rostests/win32/user32/biditext/biditext.c | 84 +++++++++++++++++++++--
modules/rostests/win32/user32/biditext/biditext.h | 1 +
2 files changed, 79 insertions(+), 6 deletions(-)
diff --git a/modules/rostests/win32/user32/biditext/biditext.c
b/modules/rostests/win32/user32/biditext/biditext.c
index cc714c40f7..ee11d56b79 100644
--- a/modules/rostests/win32/user32/biditext/biditext.c
+++ b/modules/rostests/win32/user32/biditext/biditext.c
@@ -60,7 +60,7 @@ wWinMain(HINSTANCE hInstance,
hAccelerators = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCELERATOR));
/* Show main window and force a paint */
- ShowWindow(hWnd, nCmdShow);
+ ShowWindow(hWnd, nCmdShow | SW_MAXIMIZE);
UpdateWindow(hWnd);
/* Main message loop */
@@ -171,24 +171,47 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam,
LPARAM lParam)
case WM_PAINT:
{
PAINTSTRUCT ps;
-
+
HDC hdc = BeginPaint(hWnd, &ps);
-
- LPWSTR szString = L"אבגדהABCDוזחטי";
- int Len = (int)wcslen(szString);
+ enum
+ {
+ ALEF = 0x5D0,
+ BET,
+ GIMEL,
+ DALET,
+ HEY,
+ VAV,
+ ZAYIN,
+ HET,
+ TET,
+ YUD
+ };
+
+ const WCHAR szString[] = {ALEF, BET, GIMEL, DALET, HEY, 'A',
'B', 'C', 'D', VAV, ZAYIN, HET, TET, YUD, 0};
+ const WCHAR szReversedString[] = {HEY, DALET, GIMEL, BET, ALEF, 'A',
'B', 'C', 'D', YUD, TET, HET, ZAYIN, VAV, 0};
+ int Len = wcslen(szString);
+ int i, xpos, tempLength;
+ WCHAR tempString[20] = { 0 };
WCHAR Glyphs[100] = { 0 };
WCHAR OutString[100] = { 0 };
+ INT lpCaretPos[100] = { 0 };
+ UINT lpOrder[100] = { 0 };
GCP_RESULTSW Results = { 0 };
+
Results.lStructSize = sizeof(Results);
Results.lpOutString = OutString;
Results.lpGlyphs = Glyphs;
Results.nGlyphs = 100;
+ Results.lpCaretPos = lpCaretPos;
+ Results.lpOrder = lpOrder;
+
+ SetBkMode(hdc, TRANSPARENT);
TextOutW(hdc, 10, 10, L"Proper (string being used):", 27);
TextOutW(hdc, 200, 10, szString, 14);
TextOutW(hdc, 10, 30, L"Reversed (example):", 19);
- TextOutW(hdc, 200, 30, L"הדגבאABCDיטחזו", 14);
+ TextOutW(hdc, 200, 30, szReversedString, 14);
TextOutW(hdc, 10, 50, L"String with NULL LpkETO call (not
reversed):", 44);
LpkExtTextOut(hdc, 10, 70, 0, NULL, szString, Len, NULL, 0);
@@ -217,6 +240,55 @@ LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam,
LPARAM lParam)
TextOutW(hdc, 10, 370, L"String with ETO_RTLREADING ETO call (slight
order change)", 57);
ExtTextOutW(hdc, 10, 390, ETO_RTLREADING, NULL, szString, Len, NULL);
+ GetCharacterPlacementW(hdc, szString, Len, 0, &Results, GCP_REORDER);
+ TextOutW(hdc, 10, 410, L"Glyph positions with GCP_REORDER flag",
37);
+
+ /* Prints per column the location of the character in the string, reordered
location, its position and the character itself */
+ for (i = 0, xpos = 10; i < Len; i++, xpos += 30)
+ {
+ StringCchPrintfW(tempString, 20, L"%d", i);
+ tempLength = wcslen(tempString);
+ TextOutW(hdc, xpos, 430, tempString, tempLength);
+
+ StringCchPrintfW(tempString, 20, L"%d", lpOrder[i]);
+ tempLength = wcslen(tempString);
+ TextOutW(hdc, xpos, 450, tempString, tempLength);
+
+ StringCchPrintfW(tempString, 20, L"%d", lpCaretPos[i]);
+ tempLength = wcslen(tempString);
+ TextOutW(hdc, xpos, 470, tempString, tempLength);
+
+ TextOutW(hdc, xpos, 490, &szString[i], 1);
+ }
+ TextOutW(hdc, xpos, 430, L"Character location", 18);
+ TextOutW(hdc, xpos, 450, L"lpOrder[i]", 10);
+ TextOutW(hdc, xpos, 470, L"lpCaretPos[i]", 13);
+ TextOutW(hdc, xpos, 490, L"String[i]", 9);
+
+ GetCharacterPlacementW(hdc, szString, Len, 0, &Results, 0);
+ TextOutW(hdc, 10, 510, L"Glyph positions without GCP_REORDER flag",
40);
+
+ for (i = 0, xpos = 10; i < Len; i++, xpos += 30)
+ {
+ StringCchPrintfW(tempString, 20, L"%d", i);
+ tempLength = wcslen(tempString);
+ TextOutW(hdc, xpos, 530, tempString, tempLength);
+
+ StringCchPrintfW(tempString, 20, L"%d", lpOrder[i]);
+ tempLength = wcslen(tempString);
+ TextOutW(hdc, xpos, 550, tempString, tempLength);
+
+ StringCchPrintfW(tempString, 20, L"%d", lpCaretPos[i]);
+ tempLength = wcslen(tempString);
+ TextOutW(hdc, xpos, 570, tempString, tempLength);
+
+ TextOutW(hdc, xpos, 590, &szString[i], 1);
+ }
+ TextOutW(hdc, xpos, 530, L"Character location", 18);
+ TextOutW(hdc, xpos, 550, L"lpOrder[i]", 10);
+ TextOutW(hdc, xpos, 570, L"lpCaretPos[i]", 13);
+ TextOutW(hdc, xpos, 590, L"String[i]", 9);
+
EndPaint(hWnd, &ps);
break;
}
diff --git a/modules/rostests/win32/user32/biditext/biditext.h
b/modules/rostests/win32/user32/biditext/biditext.h
index 433223776d..f9207fe5ea 100644
--- a/modules/rostests/win32/user32/biditext/biditext.h
+++ b/modules/rostests/win32/user32/biditext/biditext.h
@@ -2,6 +2,7 @@
#include <windows.h>
#include <commctrl.h>
+#include <strsafe.h>
/* Global instance handle */
extern HINSTANCE g_hInstance;