ReactOS 0.4.16-dev-2104-gb84fa49
lpk.c File Reference
#include "ros_lpk.h"
Include dependency graph for lpk.c:

Go to the source code of this file.

Macros

#define PREFIX   38
 
#define ALPHA_PREFIX   30 /* Win16: Alphabet prefix */
 
#define KANA_PREFIX   31 /* Win16: Katakana prefix */
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (bidi)
 
static int PSM_FindLastPrefix (LPCWSTR str, int count)
 
static void PSM_PrepareToDraw (LPCWSTR str, INT count, LPWSTR new_str, LPINT new_count)
 
static void LPK_DrawUnderscore (HDC hdc, int x, int y, LPCWSTR str, int count, int offset)
 
static BOOL GetProcessImageVersionInfo (_Out_ PVOID *pFileInfo, _Out_ LPDWORD pdwLen)
 
static void LPK_ApplyMirroring (void)
 
BOOL WINAPI LpkDllInitialize (_In_ HANDLE hDll, _In_ ULONG dwReason, _In_opt_ PVOID pReserved)
 
BOOL WINAPI LpkExtTextOut (HDC hdc, int x, int y, UINT fuOptions, const RECT *lprc, LPCWSTR lpString, UINT uCount, const INT *lpDx, INT unknown)
 
DWORD WINAPI LpkGetCharacterPlacement (HDC hdc, LPCWSTR lpString, INT uCount, INT nMaxExtent, LPGCP_RESULTSW lpResults, DWORD dwFlags, DWORD dwUnused)
 
INT WINAPI LpkPSMTextOut (HDC hdc, int x, int y, LPCWSTR lpString, int cString, DWORD dwFlags)
 
BOOL WINAPI LpkGetTextExtentExPoint (HDC hdc, LPCWSTR lpString, INT cString, INT nMaxExtent, LPINT lpnFit, LPINT lpnDx, LPSIZE lpSize, DWORD dwUnused, int unknown)
 

Variables

LPK_LPEDITCONTROL_LIST LpkEditControl
 

Macro Definition Documentation

◆ ALPHA_PREFIX

#define ALPHA_PREFIX   30 /* Win16: Alphabet prefix */

Definition at line 19 of file lpk.c.

◆ KANA_PREFIX

#define KANA_PREFIX   31 /* Win16: Katakana prefix */

Definition at line 20 of file lpk.c.

◆ PREFIX

#define PREFIX   38

Definition at line 18 of file lpk.c.

Function Documentation

◆ GetProcessImageVersionInfo()

static BOOL GetProcessImageVersionInfo ( _Out_ PVOID pFileInfo,
_Out_ LPDWORD  pdwLen 
)
static

Definition at line 115 of file lpk.c.

118{
119 HRSRC hResource;
120 DWORD dwResourceSize;
121 HGLOBAL hResourceData;
122 PVOID pvResourceData;
123
124 *pFileInfo = NULL;
125 *pdwLen = 0;
126
127 /* Try to get the VersionInfo resource */
129 if (hResource == NULL)
130 return FALSE;
131
132 /* Get resource size and do basic size check */
133 dwResourceSize = SizeofResource(NULL, hResource);
134 if (dwResourceSize < sizeof(VS_FIXEDFILEINFO))
135 return FALSE;
136
137 /* Load the resource */
138 hResourceData = LoadResource(NULL, hResource);
139 if (hResourceData == NULL)
140 return FALSE;
141
142 /* Lock the resource */
143 pvResourceData = LockResource(hResourceData);
144 if (pvResourceData == NULL)
145 return FALSE;
146
147 *pFileInfo = pvResourceData;
148 *pdwLen = dwResourceSize;
149 return TRUE;
150}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
DWORD WINAPI SizeofResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:568
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
unsigned long DWORD
Definition: ntddk_ex.h:95
#define VS_VERSION_INFO
Definition: ntverrsrc.c:27
#define RT_VERSION
Definition: ntverrsrc.c:26
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582

Referenced by LPK_ApplyMirroring().

◆ LPK_ApplyMirroring()

static void LPK_ApplyMirroring ( void  )
static

Definition at line 161 of file lpk.c.

162{
163 PWSTR pwstrFileDescription = NULL;
164 PVOID pvFileInfo;
165 DWORD cbFileInfoSize;
166
167 /* Get the VersionInfo resource of the main executable */
168 if (!GetProcessImageVersionInfo(&pvFileInfo, &cbFileInfoSize))
169 {
170 return;
171 }
172
173 /* The length (in WCHARs) of the key name, including the null-terminator */
174 const DWORD cchKeyLength = sizeof(L"FileDescription") / sizeof(WCHAR);
175
176 /* Calculate the required length (in WCHARs) for a FileDescription entry:
177 The key (incl. null) + alignment byte + 2 LTR markers (note: the key
178 is always unaligned by 2 bytes) */
179 const DWORD cchRequired = cchKeyLength + 1 + 2;
180
181 /* Scan the VersionInfo resource for the "FileDescription" key */
182 PWSTR pwchCurrent = (PWSTR)pvFileInfo;
183 DWORD cchRemining = cbFileInfoSize / sizeof(WCHAR);
184 while (cchRemining >= cchRequired)
185 {
186 /* Compare current position with the "FileDescription" key */
187 if (lstrcmpW(pwchCurrent, L"FileDescription") == 0)
188 {
189 /* The value starts after the key, the null-terminator and 1 WCHAR alignment */
190 pwstrFileDescription = pwchCurrent + cchKeyLength + 1;
191 break;
192 }
193
194 /* Move to next position */
195 pwchCurrent++;
196 cchRemining--;
197 }
198
199 /* Check if the description starts with 2 LTR markers (u200E).
200 Yes, this is how MS marks the layout as RTL (see article linked above). */
201 if ((pwstrFileDescription != NULL) &&
202 (pwstrFileDescription[0] == 0x200E) &&
203 (pwstrFileDescription[1] == 0x200E))
204 {
206 }
207}
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4246
#define L(x)
Definition: resources.c:13
static BOOL GetProcessImageVersionInfo(_Out_ PVOID *pFileInfo, _Out_ LPDWORD pdwLen)
Definition: lpk.c:115
uint16_t * PWSTR
Definition: typedefs.h:56
BOOL WINAPI SetProcessDefaultLayout(DWORD dwDefaultLayout)
Definition: window.c:1689
#define LAYOUT_RTL
Definition: wingdi.h:1371
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by LpkDllInitialize().

◆ LPK_DrawUnderscore()

static void LPK_DrawUnderscore ( HDC  hdc,
int  x,
int  y,
LPCWSTR  str,
int  count,
int  offset 
)
static

Definition at line 66 of file lpk.c.

67{
69 DWORD dwSSAFlags = SSA_GLYPHS;
70 int prefix_x;
71 int prefix_end;
72 int pos;
73 SIZE size;
74 HPEN hpen;
75 HPEN oldPen;
77
78 if (offset == -1)
79 return;
80
82 {
84 dwSSAFlags |= SSA_RTL;
85
86 hr = ScriptStringAnalyse(hdc, str, count, (3 * count / 2 + 16),
87 -1, dwSSAFlags, -1, NULL, NULL, NULL, NULL, NULL, &ssa);
88 }
89
90 if (hr == S_OK)
91 {
93 prefix_x = x + pos;
95 prefix_end = x + pos;
96 ScriptStringFree(&ssa);
97 }
98 else
99 {
101 prefix_x = x + size.cx;
103 prefix_end = x + size.cx - 1;
104 }
106 oldPen = SelectObject(hdc, hpen);
107 MoveToEx(hdc, prefix_x, y, NULL);
108 LineTo(hdc, prefix_end, y);
109 SelectObject(hdc, oldPen);
111}
static HPEN hpen
HRESULT WINAPI ScriptStringFree(SCRIPT_STRING_ANALYSIS *pssa)
Definition: usp10.c:2577
HRESULT WINAPI ScriptStringAnalyse(HDC hdc, const void *pString, int cString, int cGlyphs, int iCharset, DWORD dwFlags, int iReqWidth, SCRIPT_CONTROL *psControl, SCRIPT_STATE *psState, const int *piDx, SCRIPT_TABDEF *pTabdef, const BYTE *pbInClass, SCRIPT_STRING_ANALYSIS *pssa)
Definition: usp10.c:1985
HRESULT WINAPI ScriptStringCPtoX(SCRIPT_STRING_ANALYSIS ssa, int icp, BOOL fTrailing, int *pX)
Definition: usp10.c:2432
HRESULT WINAPI ScriptIsComplex(const WCHAR *chars, int len, DWORD flag)
Definition: usp10.c:3095
pKey DeleteObject()
DWORD WINAPI GetLayout(_In_ HDC hdc)
Definition: coord.c:750
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
#define S_OK
Definition: intsafe.h:52
HDC hdc
Definition: main.c:9
const WCHAR * str
HRESULT hr
Definition: shlfolder.c:183
#define SIC_COMPLEX
Definition: usp10.h:56
#define SSA_GLYPHS
Definition: usp10.h:40
#define SSA_RTL
Definition: usp10.h:41
#define S_FALSE
Definition: winerror.h:3451
UINT WINAPI GetTextAlign(_In_ HDC)
Definition: text.c:837
COLORREF WINAPI GetTextColor(_In_ HDC)
Definition: text.c:860
BOOL WINAPI GetTextExtentPointW(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE lpsz)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
#define TA_RTLREADING
Definition: wingdi.h:934
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
#define PS_SOLID
Definition: wingdi.h:586

Referenced by LpkPSMTextOut().

◆ LpkDllInitialize()

BOOL WINAPI LpkDllInitialize ( _In_ HANDLE  hDll,
_In_ ULONG  dwReason,
_In_opt_ PVOID  pReserved 
)

Definition at line 211 of file lpk.c.

215{
217
218 switch (dwReason)
219 {
222 /* Tell usp10 it is activated usp10 */
223 //LpkPresent();
225 break;
226
227 default:
228 break;
229 }
230
231 return TRUE;
232}
DWORD dwReason
Definition: misc.cpp:135
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
static void LPK_ApplyMirroring(void)
Definition: lpk.c:161
_Out_ PVOID pReserved
Definition: netsh.h:77
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329

◆ LpkExtTextOut()

BOOL WINAPI LpkExtTextOut ( HDC  hdc,
int  x,
int  y,
UINT  fuOptions,
const RECT lprc,
LPCWSTR  lpString,
UINT  uCount,
const INT lpDx,
INT  unknown 
)

Definition at line 240 of file lpk.c.

250{
252 LPWSTR reordered_str = NULL;
253 INT cGlyphs;
254 DWORD dwSICFlags = SIC_COMPLEX;
255 BOOL bResult, bReorder;
256
258
259 fuOptions |= ETO_IGNORELANGUAGE;
260
261 /* Check text direction */
263 fuOptions |= ETO_RTLREADING;
264
265 /* If text direction is RTL change flag to account neutral characters */
266 if (fuOptions & ETO_RTLREADING)
267 dwSICFlags |= SIC_NEUTRAL;
268
269 /* Check if the string requires complex script processing and not a "glyph indices" array */
270 if (ScriptIsComplex(lpString, uCount, dwSICFlags) == S_OK && !(fuOptions & ETO_GLYPH_INDEX))
271 {
272 /* reordered_str is used as fallback in case the glyphs array fails to generate,
273 BIDI_Reorder() doesn't attempt to write into reordered_str if memory allocation fails */
274 reordered_str = HeapAlloc(GetProcessHeap(), 0, uCount * sizeof(WCHAR));
275
276 bReorder = BIDI_Reorder(hdc, lpString, uCount, GCP_REORDER,
277 (fuOptions & ETO_RTLREADING) ? WINE_GCPW_FORCE_RTL : WINE_GCPW_FORCE_LTR,
278 reordered_str, uCount, NULL, &glyphs, &cGlyphs);
279
280 /* Now display the reordered text if any of the arrays is valid and if BIDI_Reorder() succeeded */
281 if ((glyphs || reordered_str) && bReorder)
282 {
283 if (glyphs)
284 {
285 fuOptions |= ETO_GLYPH_INDEX;
286 uCount = cGlyphs;
287 }
288
289 bResult = ExtTextOutW(hdc, x, y, fuOptions, lprc,
290 glyphs ? (LPWSTR)glyphs : reordered_str, uCount, lpDx);
291 }
292 else
293 {
294 WARN("BIDI_Reorder failed, falling back to original string.\n");
295 bResult = ExtTextOutW(hdc, x, y, fuOptions, lprc, lpString, uCount, lpDx);
296 }
297
299 HeapFree(GetProcessHeap(), 0, reordered_str);
300
301 return bResult;
302 }
303
304 return ExtTextOutW(hdc, x, y, fuOptions, lprc, lpString, uCount, lpDx);
305}
#define WARN(fmt,...)
Definition: precomp.h:61
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1605
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL BIDI_Reorder(HDC hDC, LPCWSTR lpString, INT uCount, DWORD dwFlags, DWORD dwWineGCP_Flags, LPWSTR lpOutString, INT uCountOut, UINT *lpOrder, WORD **lpGlyphs, INT *cGlyphs)
Definition: bidi.c:320
static UINT UINT LPWORD glyphs
Definition: font.c:44
#define WINE_GCPW_FORCE_LTR
Definition: ros_lpk.h:88
#define WINE_GCPW_FORCE_RTL
Definition: ros_lpk.h:89
uint16_t * LPWORD
Definition: typedefs.h:56
int32_t INT
Definition: typedefs.h:58
#define SIC_NEUTRAL
Definition: usp10.h:58
_In_ FONTOBJ _In_ ULONG _In_ ULONG cGlyphs
Definition: winddi.h:3799
BOOL WINAPI ExtTextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_ UINT options, _In_opt_ const RECT *lprect, _In_reads_opt_(c) LPCWSTR lpString, _In_ UINT c, _In_reads_opt_(c) const INT *lpDx)
#define GCP_REORDER
Definition: wingdi.h:843
_In_ int _Inout_ LPRECT lprc
Definition: winuser.h:4568
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ LpkGetCharacterPlacement()

DWORD WINAPI LpkGetCharacterPlacement ( HDC  hdc,
LPCWSTR  lpString,
INT  uCount,
INT  nMaxExtent,
LPGCP_RESULTSW  lpResults,
DWORD  dwFlags,
DWORD  dwUnused 
)

Definition at line 312 of file lpk.c.

320{
321 DWORD ret = 0;
322 HRESULT hr;
324 LPWORD lpGlyphs = NULL;
325 SIZE size;
326 UINT nSet, i;
327 INT cGlyphs;
328
329 UNREFERENCED_PARAMETER(dwUnused);
330
331 /* Sanity check (most likely a direct call) */
332 if (!(dwFlags & GCP_REORDER))
333 return GetCharacterPlacementW(hdc, lpString, uCount, nMaxExtent, lpResults, dwFlags);
334
335 nSet = (UINT)uCount;
336 if (nSet > lpResults->nGlyphs)
337 nSet = lpResults->nGlyphs;
338
339 BIDI_Reorder(hdc, lpString, uCount, dwFlags, WINE_GCPW_FORCE_LTR, lpResults->lpOutString,
340 nSet, lpResults->lpOrder, &lpGlyphs, &cGlyphs);
341
342 lpResults->nGlyphs = (UINT)cGlyphs;
343
344 if (lpResults->lpGlyphs)
345 {
346 if (lpGlyphs)
347 StringCchCopyW(lpResults->lpGlyphs, cGlyphs, lpGlyphs);
348 else if (lpResults->lpOutString)
349 GetGlyphIndicesW(hdc, lpResults->lpOutString, nSet, lpResults->lpGlyphs, 0);
350 }
351
352 if (lpResults->lpDx)
353 {
354 int c;
355
356 /* If glyph shaping was requested */
358 {
359 if (lpResults->lpGlyphs)
360 {
361 for (i = 0; i < lpResults->nGlyphs; i++)
362 {
363 if (GetCharWidthI(hdc, 0, 1, (WORD *)&lpResults->lpGlyphs[i], &c))
364 lpResults->lpDx[i] = c;
365 }
366 }
367 }
368
369 else
370 {
371 for (i = 0; i < nSet; i++)
372 {
373 if (GetCharWidth32W(hdc, lpResults->lpOutString[i], lpResults->lpOutString[i], &c))
374 lpResults->lpDx[i] = c;
375 }
376 }
377 }
378
379 if (lpResults->lpCaretPos)
380 {
381 int pos = 0;
382
383 hr = ScriptStringAnalyse(hdc, lpString, nSet, (3 * nSet / 2 + 16), -1, SSA_GLYPHS, -1,
384 NULL, NULL, NULL, NULL, NULL, &ssa);
385 if (hr == S_OK)
386 {
387 for (i = 0; i < nSet; i++)
388 {
389 if (ScriptStringCPtoX(ssa, i, FALSE, &pos) == S_OK)
390 lpResults->lpCaretPos[i] = pos;
391 }
392 ScriptStringFree(&ssa);
393 }
394 else
395 {
396 lpResults->lpCaretPos[0] = 0;
397 for (i = 1; i < nSet; i++)
398 {
399 if (GetTextExtentPoint32W(hdc, &(lpString[i - 1]), 1, &size))
400 lpResults->lpCaretPos[i] = (pos += size.cx);
401 }
402 }
403 }
404
405 if (GetTextExtentPoint32W(hdc, lpString, uCount, &size))
406 ret = MAKELONG(size.cx, size.cy);
407
408 HeapFree(GetProcessHeap(), 0, lpGlyphs);
409
410 return ret;
411}
return ret
Definition: mutex.c:146
unsigned short WORD
Definition: ntddk_ex.h:93
const GLubyte * c
Definition: glext.h:8905
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define c
Definition: ke_i.h:80
unsigned int UINT
Definition: ndis.h:50
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141
STRSAFEAPI StringCchCopyW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:149
INT * lpCaretPos
Definition: wingdi.h:2881
LPWSTR lpOutString
Definition: wingdi.h:2878
UINT * lpOrder
Definition: wingdi.h:2879
LPWSTR lpGlyphs
Definition: wingdi.h:2883
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define GCP_GLYPHSHAPE
Definition: wingdi.h:833
DWORD WINAPI GetGlyphIndicesW(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpstr, _In_ int c, _Out_writes_(c) LPWORD pgi, _In_ DWORD fl)
BOOL WINAPI GetCharWidthI(_In_ HDC hdc, _In_ UINT giFirst, _In_ UINT cgi, _In_reads_opt_(cgi) LPWORD pgi, _Out_writes_(cgi) LPINT piWidths)
DWORD WINAPI GetCharacterPlacementW(_In_ HDC hdc, _In_reads_(nCount) LPCWSTR lpString, _In_ int nCount, _In_ int nMexExtent, _Inout_ LPGCP_RESULTSW lpResults, _In_ DWORD dwFlags)
BOOL WINAPI GetCharWidth32W(_In_ HDC hdc, _In_ UINT iFirst, _In_ UINT iLast, _Out_writes_(iLast+1 - iFirst) LPINT lpBuffer)
BOOL WINAPI GetTextExtentPoint32W(_In_ HDC hdc, _In_reads_(c) LPCWSTR lpString, _In_ int c, _Out_ LPSIZE psizl)

◆ LpkGetTextExtentExPoint()

BOOL WINAPI LpkGetTextExtentExPoint ( HDC  hdc,
LPCWSTR  lpString,
INT  cString,
INT  nMaxExtent,
LPINT  lpnFit,
LPINT  lpnDx,
LPSIZE  lpSize,
DWORD  dwUnused,
int  unknown 
)

Definition at line 472 of file lpk.c.

482{
484 HRESULT hr;
485 INT i, extent, *Dx;
487
488 UNREFERENCED_PARAMETER(dwUnused);
490
491 if (cString < 0 || !lpSize)
492 return FALSE;
493
494 if (cString == 0 || !lpString)
495 {
496 lpSize->cx = 0;
497 lpSize->cy = 0;
498 return TRUE;
499 }
500
501 /* Check if any processing is required */
502 if (ScriptIsComplex(lpString, cString, SIC_COMPLEX) != S_OK)
503 goto fallback;
504
505 hr = ScriptStringAnalyse(hdc, lpString, cString, 3 * cString / 2 + 16, -1,
506 SSA_GLYPHS, 0, NULL, NULL, NULL, NULL, NULL, &ssa);
507 if (hr != S_OK)
508 goto fallback;
509
510 /* Use logic from TextIntGetTextExtentPoint() */
511 Dx = HeapAlloc(GetProcessHeap(), 0, cString * sizeof(INT));
512 if (!Dx)
513 {
514 ScriptStringFree(&ssa);
515 goto fallback;
516 }
517
518 if (lpnFit)
519 *lpnFit = 0;
520
522
523 for (i = 0, extent = 0; i < cString; i++)
524 {
525 extent += Dx[i];
526
527 if (extent <= nMaxExtent && lpnFit)
528 *lpnFit = i + 1;
529
530 if (lpnDx)
531 lpnDx[i] = extent;
532 }
533
534 HeapFree(GetProcessHeap(), 0, Dx);
535 ScriptStringFree(&ssa);
536
537 if (!GetTextMetricsW(hdc, &tm))
538 return GetTextExtentExPointWPri(hdc, lpString, cString, 0, NULL, NULL, lpSize);
539
540 lpSize->cx = extent;
541 lpSize->cy = tm.tmHeight;
542
543 return TRUE;
544
545fallback:
546 return GetTextExtentExPointWPri(hdc, lpString, cString, nMaxExtent, lpnFit, lpnDx, lpSize);
547}
HRESULT WINAPI ScriptStringGetLogicalWidths(SCRIPT_STRING_ANALYSIS ssa, int *piDx)
Definition: usp10.c:3825
LONG cx
Definition: windef.h:128
LONG cy
Definition: windef.h:129
BOOL WINAPI GetTextExtentExPointWPri(_In_ HDC hdc, _In_reads_(cwc) PCWCH lpwsz, _In_ INT cwc, _In_ INT dxMax, _Out_opt_ LPINT pcCh, _Out_writes_to_opt_(cwc, *pcCh) LPINT pdxOut, _In_ LPSIZE psize)
Definition: text.c:311
BOOL WINAPI GetTextMetricsW(_In_ HDC, _Out_ LPTEXTMETRICW)
Definition: text.c:221

◆ LpkPSMTextOut()

INT WINAPI LpkPSMTextOut ( HDC  hdc,
int  x,
int  y,
LPCWSTR  lpString,
int  cString,
DWORD  dwFlags 
)

Definition at line 427 of file lpk.c.

428{
429 SIZE size;
431 int prefix_offset, len;
432 LPWSTR display_str = NULL;
433
434 if (!lpString || cString <= 0)
435 return 0;
436
437 if (dwFlags & DT_NOPREFIX)
438 {
439 LpkExtTextOut(hdc, x, y, 0, NULL, lpString, cString, NULL, 0);
440 GetTextExtentPointW(hdc, lpString, cString, &size);
441 return size.cx;
442 }
443
444 display_str = HeapAlloc(GetProcessHeap(), 0, (cString + 1) * sizeof(WCHAR));
445
446 if (!display_str)
447 return 0;
448
449 PSM_PrepareToDraw(lpString, cString, display_str, &len);
450
451 if (!(dwFlags & DT_PREFIXONLY))
452 LpkExtTextOut(hdc, x, y, 0, NULL, display_str, len, NULL, 0);
453
454 if (!(dwFlags & DT_HIDEPREFIX))
455 {
456 prefix_offset = PSM_FindLastPrefix(lpString, cString);
458 LPK_DrawUnderscore(hdc, x, y + tm.tmAscent + 1, display_str, len, prefix_offset);
459 }
460
461 GetTextExtentPointW(hdc, display_str, len + 1, &size);
462 HeapFree(GetProcessHeap(), 0, display_str);
463
464 return size.cx;
465}
LPKETO LpkExtTextOut
Definition: utils.c:5
GLenum GLsizei len
Definition: glext.h:6722
static void PSM_PrepareToDraw(LPCWSTR str, INT count, LPWSTR new_str, LPINT new_count)
Definition: lpk.c:41
static void LPK_DrawUnderscore(HDC hdc, int x, int y, LPCWSTR str, int count, int offset)
Definition: lpk.c:66
static int PSM_FindLastPrefix(LPCWSTR str, int count)
Definition: lpk.c:22
#define DT_NOPREFIX
Definition: winuser.h:537
#define DT_PREFIXONLY
Definition: winuser.h:548
#define DT_HIDEPREFIX
Definition: winuser.h:547

Referenced by DrawTest().

◆ PSM_FindLastPrefix()

static int PSM_FindLastPrefix ( LPCWSTR  str,
int  count 
)
static

Definition at line 22 of file lpk.c.

23{
24 int i, prefix_count = 0, index = -1;
25
26 for (i = 0; i < count - 1; i++)
27 {
28 if (str[i] == PREFIX && str[i + 1] != PREFIX)
29 {
30 index = i - prefix_count;
31 prefix_count++;
32 }
33 else if (str[i] == PREFIX && str[i + 1] == PREFIX)
34 {
35 i++;
36 }
37 }
38 return index;
39}
#define index(s, c)
Definition: various.h:29
GLuint index
Definition: glext.h:6031
#define PREFIX
Definition: lpk.c:18

Referenced by LpkPSMTextOut().

◆ PSM_PrepareToDraw()

static void PSM_PrepareToDraw ( LPCWSTR  str,
INT  count,
LPWSTR  new_str,
LPINT  new_count 
)
static

Definition at line 41 of file lpk.c.

42{
43 int len, i = 0, j = 0;
44
45 while (i < count)
46 {
47 if (str[i] == PREFIX || (iswspace(str[i]) && str[i] != L' '))
48 {
49 if (i < count - 1 && str[i + 1] == PREFIX)
50 new_str[j++] = str[i++];
51 else
52 i++;
53 }
54 else
55 {
56 new_str[j++] = str[i++];
57 }
58 }
59
60 new_str[j] = L'\0';
61 len = wcslen(new_str);
62 *new_count = len;
63}
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2983
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define iswspace(_c)
Definition: ctype.h:669

Referenced by LpkPSMTextOut().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( bidi  )

Variable Documentation

◆ LpkEditControl

LPK_LPEDITCONTROL_LIST LpkEditControl
Initial value:
DWORD WINAPI EditNextWord(DWORD x1, DWORD x2, DWORD x3, DWORD x4, DWORD x5, DWORD x6, DWORD x7)
Definition: stub.c:116
DWORD WINAPI EditIchToXY(DWORD x1, DWORD x2, DWORD x3, DWORD x4, DWORD x5)
Definition: stub.c:67
DWORD WINAPI EditAdjustCaret(DWORD x1, DWORD x2, DWORD x3, DWORD x5)
Definition: stub.c:140
DWORD WINAPI EditCreate(DWORD x1, DWORD x2)
Definition: stub.c:61
DWORD WINAPI EditSetMenu(DWORD x1, DWORD x2)
Definition: stub.c:122
DWORD WINAPI EditGetLineWidth(DWORD x1, DWORD x2, DWORD x3, DWORD x4)
Definition: stub.c:86
DWORD WINAPI EditMouseToIch(DWORD x1, DWORD x2, DWORD x3, DWORD x4, DWORD x5)
Definition: stub.c:73
DWORD WINAPI EditCreateCaret(DWORD x1, DWORD x2, DWORD x3, DWORD x4, DWORD x5)
Definition: stub.c:134
DWORD WINAPI EditDrawText(DWORD x1, DWORD x2, DWORD x3, DWORD x4, DWORD x5, DWORD x6, DWORD x7)
Definition: stub.c:92
DWORD WINAPI EditHScroll(DWORD x1, DWORD x2, DWORD x3)
Definition: stub.c:98
DWORD WINAPI EditMoveSelection(DWORD x1, DWORD x2, DWORD x3, DWORD x4, DWORD x5)
Definition: stub.c:104
DWORD WINAPI EditProcessMenu(DWORD x1, DWORD x2)
Definition: stub.c:128
DWORD WINAPI EditCchInWidth(DWORD x1, DWORD x2, DWORD x3, DWORD x4, DWORD x5)
Definition: stub.c:79
DWORD WINAPI EditVerifyText(DWORD x1, DWORD x2, DWORD x3, DWORD x4, DWORD x5, DWORD x6)
Definition: stub.c:110

Definition at line 13 of file lpk.c.