00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
#ifdef _USERK_
00018
#define CALCRECT(wFormat) FALSE
00019
#define EDITCONTROL(wFormat) FALSE
00020
#define EXPANDTABS(wFormat) FALSE
00021
#define EXTERNALLEADING(wFormat) FALSE
00022
#define MODIFYSTRING(wFormat) FALSE
00023
#define NOPREFIX(wFormat) TRUE
00024
#define PATHELLIPSIS(wFormat) FALSE
00025
#define SINGLELINE(wFormat) TRUE
00026
#define TABSTOP(wFormat) FALSE
00027
#define WORDBREAK(wFormat) FALSE
00028
#define WORDELLIPSIS(wFormat) FALSE
00029
#define NOFULLWIDTHCHARBREAK(dwFormat) FALSE
00030
#else
00031 #define CALCRECT(wFormat) (wFormat & DT_CALCRECT)
00032 #define EDITCONTROL(wFormat) (wFormat & DT_EDITCONTROL)
00033 #define EXPANDTABS(wFormat) (wFormat & DT_EXPANDTABS)
00034 #define EXTERNALLEADING(wFormat) (wFormat & DT_EXTERNALLEADING)
00035 #define MODIFYSTRING(wFormat) (wFormat & DT_MODIFYSTRING)
00036 #define NOPREFIX(wFormat) (wFormat & DT_NOPREFIX)
00037 #define PATHELLIPSIS(wFormat) (wFormat & DT_PATH_ELLIPSIS)
00038 #define SINGLELINE(wFormat) (wFormat & DT_SINGLELINE)
00039 #define TABSTOP(wFormat) (wFormat & DT_TABSTOP)
00040 #define WORDBREAK(wFormat) (wFormat & DT_WORDBREAK)
00041 #define WORDELLIPSIS(wFormat) (wFormat & DT_WORD_ELLIPSIS)
00042
00043
00044 #define NOFULLWIDTHCHARBREAK(dwFormat) (dwFormat & DT_NOFULLWIDTHCHARBREAK)
00045
#endif
00046 #define ENDELLIPSIS(wFormat) (wFormat & DT_END_ELLIPSIS)
00047 #define NOCLIP(wFormat) (wFormat & DT_NOCLIP)
00048 #define RTLREADING(wFormat) (wFormat & DT_RTLREADING)
00049 #define HIDEPREFIX(wFormat) (wFormat & DT_HIDEPREFIX)
00050
00051
00052
00053
00054
00055 #define CR 13
00056 #define LF 10
00057 #define DT_HFMTMASK 0x03
00058 #define DT_VFMTMASK 0x0C
00059 #define ETO_OPAQUEFGND 0x0A
00060
00061 static CONST WCHAR
szEllipsis[
CCHELLIPSIS+1] = TEXT(
"...");
00062
00063 extern HDC
ghdcBits2;
00064
00065
00066
00067
00068
00069
00070
00071 #define MAXBUFFSIZE 128
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
#if 0 // not currently used --- FYI only
00273
00274
00275
00276
00277
00278 CONST
BYTE aASCII_StartBreak[] = {
00279
00280 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
00281 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
00282 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00283 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0,
00284 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00285 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
00286 };
00287
00288 CONST
BYTE aCJKSymbol_StartBreak[] = {
00289
00290 1, 0, 1, 0, 1, 0, 1, 0,
00291 1, 0, 0, 0, 1
00292 };
00293
00294 CONST
BYTE aFullWidthHalfWidthVariants_StartBreak[] = {
00295
00296 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
00297 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
00298 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00299 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
00300 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00301 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
00302 0, 0, 1
00303 };
00304
#endif
00305
00306
00307
00308
00309
00310
00311 CONST
BYTE aASCII_Latin1_EndBreak[] = {
00312
00313 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 1, 0,
00314 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1,
00315 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00316 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
00317 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00318 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
00319 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00320 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00321 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0,
00322 1, 0, 0, 0, 0, 0, 0, 1
00323 };
00324
00325 CONST
BYTE aGeneralPunctuation_EndBreak[] = {
00326
00327 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 1, 0, 0,
00328 0, 0, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
00329 0, 0, 1, 1
00330 };
00331
00332 CONST
BYTE aCJKSymbol_EndBreak[] = {
00333
00334 1, 1, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 1,
00335 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1
00336 };
00337
00338 CONST
BYTE aCNS11643_SmallVariants_EndBreak[] = {
00339
00340 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0,
00341 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1,
00342 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 1
00343 };
00344
00345 CONST
BYTE aFullWidthHalfWidthVariants_EndBreak[] = {
00346
00347 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0,
00348 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1,
00349 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00350 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
00351 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00352 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0,
00353 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00354 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00355 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
00356 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1
00357 };
00358
00359
00360
00361
00362
00363
00364
00365
00366
#if 0 // not currently used --- FYI only
00367
BOOL UserIsFELineBreakStart(WCHAR wch)
00368 {
00369
switch (wch>>8) {
00370
case 0x00:
00371
00372
00373
00374
if ((wch >= 0x0024) && (wch <= 0x007B))
00375
return((
BOOL)(aASCII_StartBreak[wch - 0x0024]));
00376
else
00377
return(
FALSE);
00378
00379
case 0x20:
00380
00381
00382
00383
if ((wch == 0x2018) || (wch == 0x201C))
00384
return(
TRUE);
00385
else
00386
return(
FALSE);
00387
00388
case 0x30:
00389
00390
00391
00392
00393
if ((wch >= 0x3008) && (wch <= 0x3014))
00394
return((
BOOL)(aCJKSymbol_StartBreak[wch - 0x3008]));
00395
else
00396
return(
FALSE);
00397
00398
case 0xFF:
00399
00400
00401
00402
00403
if ((wch >= 0xFF04) && (wch <= 0xFF62))
00404
return((
BOOL)(aFullWidthHalfWidthVariants_StartBreak[wch - 0xFF04]));
00405
else if ((wch == 0xFFE1) || (wch == 0xFFE6))
00406
return(
TRUE);
00407
else
00408
return(
FALSE);
00409
00410
default:
00411
return(
FALSE);
00412 }
00413 }
00414
#endif
00415
00416 BOOL UserIsFELineBreakEnd(WCHAR wch)
00417 {
00418
switch (wch>>8) {
00419
case 0x00:
00420
00421
00422
00423
if ((wch >= 0x0021) && (wch <= 0x00B7))
00424
return((
BOOL)(
aASCII_Latin1_EndBreak[wch - 0x0021]));
00425
else
00426
return(
FALSE);
00427
00428
case 0x02:
00429
00430
00431
00432
if ((wch == 0x02C7) || (wch == 0x02C9))
00433
return(
TRUE);
00434
else
00435
return(
FALSE);
00436
00437
case 0x20:
00438
00439
00440
00441
if ((wch >= 0x2013) && (wch <= 0x2033))
00442
return((
BOOL)(
aGeneralPunctuation_EndBreak[wch - 0x2013]));
00443
else
00444
return(
FALSE);
00445
00446
case 0x21:
00447
00448
00449
00450
if (wch == 0x2103)
00451
return(
TRUE);
00452
else
00453
return(
FALSE);
00454
00455
case 0x22:
00456
00457
00458
00459
if (wch == 0x2236)
00460
return(
TRUE);
00461
else
00462
return(
FALSE);
00463
00464
case 0x25:
00465
00466
00467
00468
if (wch == 0x2574)
00469
return(
TRUE);
00470
else
00471
return(
FALSE);
00472
00473
case 0x30:
00474
00475
00476
00477
00478
if ((wch >= 0x3001) && (wch <= 0x301E))
00479
return((
BOOL)(
aCJKSymbol_EndBreak[wch - 0x3001]));
00480
else if ((wch == 0x309B) || (wch == 0x309C))
00481
return(
TRUE);
00482
else
00483
return(
FALSE);
00484
00485
case 0xFE:
00486
00487
00488
00489
00490
if ((wch >= 0xFE30) && (wch <= 0xFE5E))
00491
return((
BOOL)(
aCNS11643_SmallVariants_EndBreak[wch - 0xFE30]));
00492
else
00493
return(
FALSE);
00494
00495
case 0xFF:
00496
00497
00498
00499
00500
if ((wch >= 0xFF01) && (wch <= 0xFF9F))
00501
return((
BOOL)(
aFullWidthHalfWidthVariants_EndBreak[wch - 0xFF01]));
00502
else if (wch >= 0xFFE0)
00503
return(
TRUE);
00504
else
00505
return(
FALSE);
00506
00507
default:
00508
return(
FALSE);
00509 }
00510 }
00511
00512 #define UserIsFELineBreak(wChar) UserIsFELineBreakEnd(wChar)
00513
00514
00515
00516
00517
00518
00519
00520
00521 typedef struct _FULLWIDTH_UNICODE {
00522 WCHAR
Start;
00523 WCHAR
End;
00524 }
FULLWIDTH_UNICODE, *
PFULLWIDTH_UNICODE;
00525
00526 #define NUM_FULLWIDTH_UNICODES 4
00527
00528 CONST
FULLWIDTH_UNICODE FullWidthUnicodes[] = {
00529 { 0x4E00, 0x9FFF },
00530 { 0x3040, 0x309F },
00531 { 0x30A0, 0x30FF },
00532 { 0xAC00, 0xD7A3 }
00533 };
00534
00535 BOOL UserIsFullWidth(DWORD dwCodePage,WCHAR wChar)
00536 {
00537
INT index;
00538
INT cChars;
00539
#ifdef _USERK_
00540
CHAR aChars[2];
00541
#endif // _USERK_
00542
00543
00544
00545
00546
if (wChar < 0x0080) {
00547
00548
00549
00550
return (
FALSE);
00551 }
00552
00553
00554
00555
00556
for (index = 0; index <
NUM_FULLWIDTH_UNICODES; index++) {
00557
if ((wChar >=
FullWidthUnicodes[index].
Start) &&
00558 (wChar <=
FullWidthUnicodes[index].
End) ) {
00559
return (
TRUE);
00560 }
00561 }
00562
00563
00564
00565
00566
#ifdef _USERK_
00567
cChars = EngWideCharToMultiByte((
UINT)dwCodePage,&wChar,
sizeof(WCHAR),aChars,
sizeof(aChars));
00568
#else
00569
cChars = WideCharToMultiByte((
UINT)dwCodePage,0,&wChar,1,
NULL,0,
NULL,
NULL);
00570
#endif // _USERK_
00571
00572
return(cChars > 1 ?
TRUE :
FALSE);
00573 }
00574
00575
00576
00577
00578
00579
00580 BOOL UserTextOutWInternal(
00581 HDC hdc,
00582
int x,
00583
int y,
00584 LPCWSTR lp,
00585 UINT cc,
00586 DWORD dwFlags)
00587 {
00588 UNREFERENCED_PARAMETER(
dwFlags);
00589
return UserTextOutW(hdc, x, y, lp, cc);
00590 }
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604 int KKGetPrefixWidth(HDC hdc, LPCWSTR lpStr,
int cch)
00605 {
00606 SIZE size;
00607 SIZE iPrefix1 = {-1
L,-1
L};
00608 SIZE iPrefix2 = {-1
L,-1
L};
00609 SIZE iPrefix3 = {-1
L,-1
L};
00610
int iTotal = 0;
00611
00612
while (cch-- > 0 && *lpStr) {
00613
switch(*lpStr) {
00614
case CH_PREFIX:
00615
if (lpStr[1] !=
CH_PREFIX) {
00616
if (iPrefix1.cx == -1) {
00617
UserGetTextExtentPointW(hdc, lpStr, 1, &iPrefix1);
00618 }
00619 iTotal += iPrefix1.cx;
00620 }
else {
00621 lpStr++;
00622 cch--;
00623 }
00624
break;
00625
case CH_ENGLISHPREFIX:
00626
if (iPrefix2.cx == -1) {
00627
UserGetTextExtentPointW(hdc, lpStr, 1, &iPrefix2);
00628 }
00629 iTotal += iPrefix2.cx;
00630
break;
00631
case CH_KANJIPREFIX:
00632
if (iPrefix3.cx == -1) {
00633
UserGetTextExtentPointW(hdc, lpStr, 1, &iPrefix3);
00634 }
00635 iTotal += iPrefix3.cx;
00636
00637
00638
00639
00640
00641
UserGetTextExtentPointW(hdc, lpStr, 1, &size);
00642 iTotal += size.cx;
00643
break;
00644
default:
00645
00646
00647
00648
break;
00649 }
00650 lpStr++;
00651 }
00652
return iTotal;
00653 }
00654
00655
00656
00657
00658
00659
00660
00661
00662 LPCWSTR
GetNextWordbreak(DWORD dwCodePage,
00663 LPCWSTR lpch,
00664 LPCWSTR lpchEnd,
00665 DWORD dwFormat,
00666
LPDRAWTEXTDATA lpDrawInfo)
00667
00668 {
00669
00670
int ichNonWhite = 1;
00671
int ichComplexBreak = 0;
00672
#if ((DT_WORDBREAK & ~0xff) != 0)
00673
#error cannot use BOOLEAN for DT_WORDBREAK, or you should use "!!" before assigning it
00674
#endif
00675
BOOLEAN fBreakSpace = (BOOLEAN)
WORDBREAK(dwFormat);
00676
00677
00678
00679
00680
00681
00682 BOOLEAN fDbcsCharBreak = (fBreakSpace && !
NOFULLWIDTHCHARBREAK(dwFormat));
00683
00684
#ifdef _USERK_
00685
00686
00687
00688
00689
00690
00691
00692
00693 UNREFERENCED_PARAMETER(dwFormat);
00694
#endif
00695
00696
00697
00698
while (lpch < lpchEnd) {
00699
switch (*lpch) {
00700
case CR:
00701
case LF:
00702
return lpch;
00703
00704
case '\t':
00705
case ' ':
00706
if (fBreakSpace)
00707
return (lpch + ichNonWhite);
00708
00709
00710
00711
default:
00712
00713
00714
00715
00716
00717
if (fDbcsCharBreak &&
UserIsFullWidth(dwCodePage, *lpch)) {
00718
if (!ichNonWhite)
00719
return lpch;
00720
00721
00722
00723
00724
if ((lpch+1) != lpchEnd) {
00725
00726
00727
00728
00729
00730
00731
if (
UserIsFELineBreak(*(lpch+1))) {
00732
00733
00734
00735
00736
return (lpch + 1 + 1);
00737 }
00738 }
00739
00740
00741
00742
00743
return (lpch + 1);
00744 }
00745
00746
00747
00748
00749
00750
00751
00752
else if(fBreakSpace && lpDrawInfo->bCharsetDll) {
00753
#ifdef _USERK_
00754
PTHREADINFO ptiCurrent =
PtiCurrentShared();
00755
if(
CALL_LPK(ptiCurrent))
00756
#endif
00757
ichComplexBreak = (*UserLpkDrawTextEx)(0, 0, 0, lpch, (
int)(lpchEnd - lpch), 0,
00758 0,
NULL,
DT_GETNEXTWORD, -1);
00759
if (ichComplexBreak > 0)
00760
return (lpch + ichComplexBreak);
00761 }
00762 lpch++;
00763 ichNonWhite = 0;
00764 }
00765 }
00766
00767
return lpch;
00768 }
00769
00770
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806 LONG
GetPrefixCount(
00807 LPCWSTR lpstr,
00808
int cch,
00809 LPWSTR lpstrCopy,
00810
int charcopycount)
00811 {
00812
int chprintpos = 0;
00813
int chcount = 0;
00814
int chprefixloc = -1;
00815 WCHAR ch;
00816
00817
00818
00819
00820
if (lpstrCopy ==
NULL)
00821 charcopycount = 32767;
00822
00823
while ((cch-- > 0) && *lpstr && charcopycount-- != 0) {
00824
00825
00826
00827
00828
if ((ch = *lpstr++) ==
CH_PREFIX) {
00829
00830
00831
00832
00833 chcount++;
00834
00835
00836
00837
00838
if (*lpstr !=
CH_PREFIX) {
00839
00840
00841
00842
00843 chprefixloc = chprintpos;
00844
00845 }
else {
00846
00847
00848
00849
00850
if (lpstrCopy !=
NULL)
00851 *(lpstrCopy++) =
CH_PREFIX;
00852 cch--;
00853 lpstr++;
00854 chprintpos++;
00855 }
00856 }
else if (ch ==
CH_ENGLISHPREFIX) {
00857
00858
00859
00860 chcount++;
00861
00862
00863
00864
00865 chprefixloc = chprintpos;
00866
00867 }
else if (ch ==
CH_KANJIPREFIX) {
00868
00869
00870
00871
00872
00873
00874
00875 chcount++;
00876
00877
if(cch) {
00878
00879 chcount++;
00880 lpstr++;
00881 cch--;
00882 }
00883 }
else {
00884
00885
00886
00887
00888 chprintpos++;
00889
if (lpstrCopy !=
NULL)
00890 *(lpstrCopy++) = ch;
00891 }
00892 }
00893
00894
if (lpstrCopy !=
NULL)
00895 *lpstrCopy = 0;
00896
00897
00898
00899
00900
return MAKELONG(chprefixloc, chcount);
00901 }
00902
00903
00904
00905
00906
00907 int DT_GetExtentMinusPrefixes(HDC hdc, LPCWSTR lpchStr,
int cchCount, UINT wFormat,
00908
int iOverhang, LPDRAWTEXTDATA lpDrawInfo,
int iCharSet)
00909 {
00910
int iPrefixCount;
00911
int cxPrefixes = 0;
00912 WCHAR PrefixChar =
CH_PREFIX;
00913 SIZE size;
00914
PCLIENTINFO pci =
GetClientInfo();
00915
#ifdef _USERK_
00916
PTHREADINFO ptiCurrent =
PtiCurrentShared();
00917
#endif
00918
UNREFERENCED_PARAMETER(wFormat);
00919
00920
if(!
NOPREFIX(wFormat) &&
00921 (iPrefixCount = HIWORD(
GetPrefixCount(lpchStr, cchCount,
NULL, 0)))) {
00922
00923
00924
00925
00926
if (
IS_DBCS_ENABLED() && (pci->
dwTIFlags &
TIF_16BIT)) {
00927
00928 cxPrefixes =
KKGetPrefixWidth(hdc, lpchStr, cchCount) - (iPrefixCount * iOverhang);
00929 }
00930
else {
00931
if(lpDrawInfo->bCharsetDll) {
00932
#ifdef _USERK_
00933
if(
CALL_LPK(ptiCurrent))
00934
#endif // _USERK_
00935
{
00936
00937
return (*UserLpkDrawTextEx)(hdc, 0, 0, lpchStr, cchCount,
FALSE,
00938 wFormat, lpDrawInfo,
DT_CHARSETDRAW, iCharSet);
00939 }
00940 }
else {
00941 cxPrefixes =
UserGetTextExtentPointW(hdc, &PrefixChar, 1, &size);
00942 cxPrefixes = size.cx - iOverhang;
00943 cxPrefixes *= iPrefixCount;
00944 }
00945 }
00946 }
00947
#ifdef _USERK_
00948
if(
CALL_LPK(ptiCurrent))
00949
xxxClientGetTextExtentPointW(hdc, lpchStr, cchCount, &size);
00950
else
00951
#endif // _USERK_
00952
UserGetTextExtentPointW(hdc, lpchStr, cchCount, &size);
00953
return (size.cx - cxPrefixes);
00954 }
00955
00956
00957
00958
00959
00960
00961
00962
00963
00964
00965 int DT_DrawStr(HDC hdc,
int xLeft,
int yTop, LPCWSTR lpchStr,
00966
int cchCount, BOOL fDraw, UINT wFormat,
00967 LPDRAWTEXTDATA lpDrawInfo,
int iCharSet)
00968 {
00969 LPCWSTR lpch;
00970
int iLen;
00971
int cxExtent;
00972
int xOldLeft = xLeft;
00973
int xTabLength = lpDrawInfo->cxTabLength;
00974
int iTabOrigin = lpDrawInfo->rcFormat.left;
00975
00976
#ifdef USE_MIRRORING
00977
00978
00979
00980
00981
if (
UserGetLayout(hdc) & LAYOUT_RTL) {
00982 --xOldLeft;
00983 --xLeft;
00984 }
00985
#endif
00986
00987
00988
00989
00990
if(lpDrawInfo->bCharsetDll) {
00991
#ifdef _USERK_
00992
PTHREADINFO ptiCurrent =
PtiCurrentShared();
00993
00994
00995
00996
00997
if(!
CALL_LPK(ptiCurrent))
00998
return 0 ;
00999
#endif // _USERK_
01000
return (*UserLpkDrawTextEx)(hdc, xLeft, yTop, lpchStr, cchCount, fDraw,
01001 wFormat, lpDrawInfo,
DT_CHARSETDRAW, iCharSet);
01002 }
01003
01004
01005
if(
EXPANDTABS(wFormat)) {
01006
while(cchCount) {
01007
01008
for(iLen = 0, lpch = lpchStr; iLen < cchCount; iLen++)
01009
if(*lpch++ == TEXT(
'\t'))
01010
break;
01011
01012
01013
if (iLen) {
01014
01015
if (fDraw && !
CALCRECT(wFormat)) {
01016 (*(lpDrawInfo->lpfnTextDraw))(hdc, xLeft, yTop, (LPWSTR)lpchStr, iLen, wFormat);
01017 }
01018
01019 xLeft +=
DT_GetExtentMinusPrefixes(hdc, lpchStr, iLen, wFormat, lpDrawInfo->cxOverhang, lpDrawInfo, iCharSet) - lpDrawInfo->cxOverhang;
01020 }
01021
01022
01023
if (iLen < cchCount) {
01024 iLen++;
01025
if (xTabLength)
01026 xLeft = (((xLeft - iTabOrigin)/xTabLength) + 1)*xTabLength + iTabOrigin;
01027 }
01028
01029
01030 cchCount -= iLen;
01031 lpchStr = lpch;
01032 }
01033 cxExtent = xLeft - xOldLeft;
01034 }
else {
01035
01036
if (fDraw && !
CALCRECT(wFormat)) {
01037 (*(lpDrawInfo->lpfnTextDraw))(hdc, xLeft, yTop, (LPWSTR)lpchStr, cchCount, wFormat);
01038 }
01039
01040 cxExtent =
DT_GetExtentMinusPrefixes(hdc, lpchStr, cchCount, wFormat,
01041 lpDrawInfo->cxOverhang, lpDrawInfo, iCharSet) - lpDrawInfo->cxOverhang;
01042 }
01043
return cxExtent;
01044 }
01045
01046
01047
01048
01049
01050
01051
01052
01053 void DT_DrawJustifiedLine(HDC hdc,
int yTop, LPCWSTR lpchLineSt,
01054
int cchCount, UINT wFormat,
01055 LPDRAWTEXTDATA lpDrawInfo,
int iCharSet)
01056 {
01057 LPRECT lprc;
01058
int cxExtent;
01059
int xLeft;
01060
01061 lprc = &(lpDrawInfo->rcFormat);
01062 xLeft = lprc->left;
01063
01064
01065
if(wFormat & (DT_CENTER | DT_RIGHT)) {
01066 cxExtent =
DT_DrawStr(hdc, xLeft, yTop, lpchLineSt, cchCount,
FALSE,
01067 wFormat, lpDrawInfo, iCharSet) + lpDrawInfo->cxOverhang;
01068
if(wFormat & DT_CENTER)
01069 xLeft = lprc->left + (((lprc->right - lprc->left) - cxExtent) >> 1);
01070
else
01071 xLeft = lprc->right - cxExtent;
01072 }
else
01073 xLeft = lprc->left;
01074
01075
01076 cxExtent =
DT_DrawStr(hdc, xLeft, yTop, lpchLineSt, cchCount,
TRUE, wFormat,
01077 lpDrawInfo, iCharSet) +lpDrawInfo->cxOverhang;
01078
if(cxExtent > lpDrawInfo->cxMaxExtent)
01079 lpDrawInfo->cxMaxExtent = cxExtent;
01080 }
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090 BOOL DT_InitDrawTextInfo(
01091 HDC hdc,
01092 LPRECT lprc,
01093 UINT wFormat,
01094 LPDRAWTEXTDATA lpDrawInfo,
01095 LPDRAWTEXTPARAMS lpDTparams)
01096 {
01097 SIZE sizeViewPortExt = {0, 0},sizeWindowExt = {0, 0};
01098 TEXTMETRICW tm;
01099 LPRECT lprcDest;
01100
int iTabLength = 8;
01101
int iLeftMargin;
01102
int iRightMargin;
01103
BOOL fUseSystemFont;
01104
01105
if (lpDTparams) {
01106
01107
01108
01109
if (
TABSTOP(wFormat))
01110 iTabLength = lpDTparams->iTabLength;
01111 iLeftMargin = lpDTparams->iLeftMargin;
01112 iRightMargin = lpDTparams->iRightMargin;
01113 }
else {
01114 iLeftMargin = iRightMargin = 0;
01115 }
01116
01117
01118
01119
01120
01121
if (!
UserGetViewportExtEx(hdc,&sizeViewPortExt)) {
01122
#ifndef _USERK_
01123
01124
01125
01126
01127
01128
if ((hdc ==
NULL) || !GdiValidateHandle(hdc))
01129
#endif
01130
return FALSE;
01131 }
01132
UserGetWindowExtEx(hdc, &sizeWindowExt);
01133
01134
01135
01136
01137 lpDrawInfo->iXSign =
01138 (((sizeViewPortExt.cx ^ sizeWindowExt.cx) & 0x80000000) ? -1 : 1);
01139
01140
01141
01142
01143 lpDrawInfo->iYSign =
01144 (((sizeViewPortExt.cy ^ sizeWindowExt.cy) & 0x80000000) ? -1 : 1);
01145
01146
01147
01148
01149
01150 fUseSystemFont = ((wFormat & DT_INTERNAL) ||
IsSysFontAndDefaultMode(hdc));
01151
if (!fUseSystemFont) {
01152
01153
01154
01155
if (
EDITCONTROL(wFormat)) {
01156 tm.tmAveCharWidth =
UserGetCharDimensionsW(hdc, &tm,
NULL);
01157 tm.tmCharSet = (
BYTE)
UserGetTextCharsetInfo(hdc,
NULL, 0);
01158
if (tm.tmAveCharWidth == 0) {
01159 fUseSystemFont =
TRUE;
01160 }
01161 }
else if (!
UserGetTextMetricsW(hdc, &tm)) {
01162
01163
01164
01165
01166
01167
01168
01169
01170
01171 RIPMSG0(RIP_WARNING,
"UserGetTextMetricsW failed: only in logon/off?\n");
01172 tm.tmOverhang = 0;
01173
01174
01175
01176
01177
01178
01179 }
01180 }
01181
01182
if (fUseSystemFont) {
01183
01184
01185
01186 tm.tmHeight =
gpsi->cySysFontChar;
01187 tm.tmExternalLeading =
gpsi->tmSysFont.tmExternalLeading;
01188 tm.tmAveCharWidth =
gpsi->tmSysFont.tmAveCharWidth;
01189 tm.tmOverhang =
gpsi->tmSysFont.tmOverhang;
01190
#ifdef _USERK_
01191
tm.tmCharSet = (
BYTE)
UserGetTextCharsetInfo(
gpDispInfo->
hdcScreen,
NULL, 0);
01192
#else
01193
tm.tmCharSet = (
BYTE)
UserGetTextCharsetInfo(
ghdcBits2,
NULL, 0);
01194
#endif // _USERK_
01195
}
01196
01197
01198
01199 lpDrawInfo->cyLineHeight = (tm.tmHeight +
01200 (
EXTERNALLEADING(wFormat) ? tm.tmExternalLeading : 0)) *
01201 lpDrawInfo->iYSign;
01202
01203
01204 lpDrawInfo->cxTabLength = tm.tmAveCharWidth * iTabLength;
01205
01206
01207 lpDrawInfo->cxOverhang = tm.tmOverhang;
01208
01209
01210
#ifdef _USERK_
01211
lpDrawInfo->bCharsetDll =
PpiCurrent()->dwLpkEntryPoints &
LPK_DRAWTEXTEX;
01212
if (lpDrawInfo->bCharsetDll ==
FALSE) {
01213 lpDrawInfo->lpfnTextDraw = (
NOPREFIX(wFormat) ? (
LPFNTEXTDRAW)
UserTextOutWInternal :
xxxPSMTextOut);
01214 }
01215
#else
01216
lpDrawInfo->bCharsetDll = (
BOOL)(
fpLpkDrawTextEx != (
FPLPKDRAWTEXTEX)
NULL);
01217
if (lpDrawInfo->bCharsetDll ==
FALSE) {
01218 lpDrawInfo->lpfnTextDraw = (
NOPREFIX(wFormat) ? (
LPFNTEXTDRAW)
UserTextOutWInternal :
PSMTextOut);
01219 }
01220
#endif // _USERK_
01221
01222
01223
01224 lprcDest = &(lpDrawInfo->rcFormat);
01225 *lprcDest = *lprc;
01226
01227
01228
if(iLeftMargin | iRightMargin) {
01229 lprcDest->left += iLeftMargin * lpDrawInfo->iXSign;
01230 lprcDest->right -= (lpDrawInfo->cxRightMargin = iRightMargin * lpDrawInfo->iXSign);
01231 }
else
01232 lpDrawInfo->cxRightMargin = 0;
01233
01234
01235 lpDrawInfo->cxMaxWidth = (lprcDest->right - lprcDest->left) * lpDrawInfo->iXSign;
01236 lpDrawInfo->cxMaxExtent = 0;
01237
01238
return TRUE;
01239 }
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249 LPCWSTR
DT_AdjustWhiteSpaces(LPCWSTR lpStNext, LPINT lpiCount, UINT wFormat)
01250 {
01251
switch(wFormat &
DT_HFMTMASK) {
01252
case DT_LEFT:
01253
01254
01255
if((*lpStNext == TEXT(
' ')) || (*lpStNext == TEXT(
'\t'))) {
01256
01257 lpStNext++;
01258 }
01259
break;
01260
01261
case DT_RIGHT:
01262
01263
01264
if((*(lpStNext-1) == TEXT(
' ')) || (*(lpStNext - 1) == TEXT(
'\t'))) {
01265
01266 (*lpiCount)--;
01267 }
01268
break;
01269
01270
case DT_CENTER:
01271
01272
01273
if((*(lpStNext-1) == TEXT(
' ')) || (*(lpStNext - 1) == TEXT(
'\t')))
01274 (*lpiCount)--;
01275
01276
if((*lpStNext == TEXT(
' ')) || (*lpStNext == TEXT(
'\t')))
01277 lpStNext++;
01278
break;
01279 }
01280
return lpStNext;
01281 }
01282
01283
01284
01285
01286
01287
01288 LPCWSTR
DT_BreakAWord(HDC hdc, LPCWSTR lpchText,
01289
int iLength,
int iWidth, UINT wFormat,
int iOverhang, LPDRAWTEXTDATA lpDrawInfo,
int iCharSet)
01290 {
01291
int iLow = 0, iHigh = iLength;
01292
int iNew;
01293
01294
01295
while((iHigh - iLow) > 1) {
01296 iNew = iLow + (iHigh - iLow)/2;
01297
if(
DT_GetExtentMinusPrefixes(hdc, lpchText, iNew, wFormat, iOverhang, lpDrawInfo, iCharSet) > iWidth)
01298 iHigh = iNew;
01299
else
01300 iLow = iNew;
01301 }
01302
01303
01304
if(!iLow && iLength)
01305 iLow = 1;
01306
return (lpchText+iLow);
01307 }
01308
01309
01310
01311
01312
01313
01314
01315
01316
01317
01318
01319 LPWSTR
DT_GetLineBreak(
01320 HDC hdc,
01321 LPCWSTR lpchLineStart,
01322
int cchCount,
01323 DWORD dwFormat,
01324 LPINT lpiLineLength,
01325 LPDRAWTEXTDATA lpDrawInfo,
01326
int iCharSet)
01327 {
01328 LPCWSTR lpchText, lpchEnd, lpch, lpchLineEnd;
01329
int cxStart, cxExtent, cxNewExtent;
01330
BOOL fAdjustWhiteSpaces =
FALSE;
01331 WCHAR ch;
01332
DWORD dwCodePage = USERGETCODEPAGE(hdc);
01333
01334 cxStart = lpDrawInfo->rcFormat.left;
01335 cxExtent = cxNewExtent = 0;
01336 lpchText = lpchLineStart;
01337 lpchEnd = lpchLineStart + cchCount;
01338
01339
01340
while(lpchText < lpchEnd) {
01341 lpchLineEnd = lpch =
GetNextWordbreak(dwCodePage,lpchText, lpchEnd, dwFormat, lpDrawInfo);
01342
01343
01344
01345
01346
01347
01348
01349 cxNewExtent =
DT_DrawStr(hdc, cxStart, 0, lpchLineStart, (
int)(((
PBYTE)lpch - (
PBYTE)lpchLineStart)/
sizeof(WCHAR)),
FALSE,
01350 dwFormat, lpDrawInfo, iCharSet);
01351
01352
if (
WORDBREAK(dwFormat) && ((cxNewExtent + lpDrawInfo->cxOverhang) > lpDrawInfo->cxMaxWidth)) {
01353
01354
if (lpchText != lpchLineStart) {
01355 lpchLineEnd = lpch = lpchText;
01356 fAdjustWhiteSpaces =
TRUE;
01357 }
else {
01358
01359
01360
if(
EDITCONTROL(dwFormat) && !
WORDELLIPSIS(dwFormat)) {
01361 lpchLineEnd = lpch =
DT_BreakAWord(hdc, lpchText, (
int)(((
PBYTE)lpch - (
PBYTE)lpchText)/
sizeof(WCHAR)),
01362 lpDrawInfo->cxMaxWidth - cxExtent,
01363 dwFormat,
01364 lpDrawInfo->cxOverhang, lpDrawInfo, iCharSet);
01365
01366
01367 }
else {
01368 fAdjustWhiteSpaces =
TRUE;
01369
01370
if(
WORDELLIPSIS(dwFormat))
01371 {
01372
01373
if (lpch < lpchEnd)
01374 {
01375
01376
if ((ch = *lpch) ==
CR || ch ==
LF)
01377 {
01378
if ((++lpch < lpchEnd) && (*lpch == (WCHAR)(ch ^ (
LF ^
CR))))
01379 lpch++;
01380 fAdjustWhiteSpaces =
FALSE;
01381 }
01382 }
01383 }
01384 }
01385 }
01386
01387
01388
break;
01389 }
else {
01390
01391
if (lpch < lpchEnd) {
01392
if ((ch = *lpch) ==
CR || ch ==
LF) {
01393
if ((++lpch < lpchEnd) && (*lpch == (WCHAR)(ch ^ (
LF ^
CR))))
01394 lpch++;
01395 fAdjustWhiteSpaces =
FALSE;
01396
break;
01397 }
01398 }
01399 }
01400
01401
01402 lpchText = lpch;
01403 cxExtent = cxNewExtent;
01404 }
01405
01406
01407 *lpiLineLength = (
INT)((
PBYTE)lpchLineEnd - (
PBYTE)lpchLineStart)/
sizeof(WCHAR);
01408
01409
01410
if(fAdjustWhiteSpaces && (lpch < lpchEnd))
01411 lpch =
DT_AdjustWhiteSpaces(lpch, lpiLineLength, dwFormat);
01412
01413
01414
return (LPWSTR)lpch;
01415 }
01416
01417
01418
01419
01420
01421
01422
01423
01424 BOOL NeedsEndEllipsis(HDC hdc,
01425 LPCWSTR lpchText,
01426 LPINT lpCount,
01427 LPDRAWTEXTDATA lpDTdata,
01428 UINT wFormat, LPDRAWTEXTDATA lpDrawInfo,
int iCharSet)
01429 {
01430
int cchText;
01431
int ichMin, ichMax, ichMid;
01432
int cxMaxWidth;
01433
int iOverhang;
01434
int cxExtent;
01435 SIZE size;
01436 cchText = *lpCount;
01437
01438
if (cchText == 0)
01439
return FALSE;
01440
01441 cxMaxWidth = lpDTdata->cxMaxWidth;
01442 iOverhang = lpDTdata->cxOverhang;
01443
01444 cxExtent =
DT_GetExtentMinusPrefixes(hdc, lpchText, cchText, wFormat, iOverhang, lpDrawInfo, iCharSet);
01445
01446
if (cxExtent <= cxMaxWidth)
01447
return FALSE;
01448
01449
01450
UserGetTextExtentPointW(hdc,
szEllipsis,
CCHELLIPSIS, &size);
01451 cxMaxWidth -= size.cx - iOverhang;
01452
01453
01454
01455 ichMax = 1;
01456
if (cxMaxWidth > 0) {
01457
01458 ichMin = 0;
01459 ichMax = cchText;
01460
while (ichMin < ichMax) {
01461
01462
01463
01464 ichMid = (ichMin + ichMax + 1) / 2;
01465
01466 cxExtent =
DT_GetExtentMinusPrefixes(hdc, lpchText, ichMid, wFormat, iOverhang, lpDrawInfo, iCharSet);
01467
01468
if (cxExtent < cxMaxWidth)
01469 ichMin = ichMid;
01470
else {
01471
if (cxExtent > cxMaxWidth)
01472 ichMax = ichMid - 1;
01473
else {
01474
01475
01476 ichMax = ichMid;
01477
break;
01478 }
01479 }
01480 }
01481
01482
01483
01484
if (ichMax < 1)
01485 ichMax = 1;
01486 }
01487
01488 *lpCount = ichMax;
01489
return TRUE;
01490 }
01491
01492
01493
01494
01495
01496
01497
01498
01499
01500
01501
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514
01515 LPWSTR
PathFindFileName(LPCWSTR pPath,
int cchText)
01516 {
01517 LPCWSTR pT;
01518
01519
for (pT = pPath; cchText > 0 && *pPath; pPath++, cchText--) {
01520
if ((pPath[0] == TEXT(
'\\') || pPath[0] == TEXT(
':')) && pPath[1])
01521 pT = pPath + 1;
01522 }
01523
01524
return (LPWSTR)pT;
01525 }
01526
01527
01528
01529
01530
01531
01532
01533 int AddPathEllipsis(
01534 HDC hDC,
01535 LPWSTR lpszPath,
01536
int cchText,
01537 UINT wFormat,
01538
int cxMaxWidth,
01539
int iOverhang, LPDRAWTEXTDATA lpDrawInfo,
int iCharSet)
01540 {
01541
int iLen;
01542
UINT dxFixed, dxEllipsis;
01543 LPWSTR lpEnd;
01544 LPWSTR lpFixed;
01545
BOOL bEllipsisIn;
01546
int iLenFixed;
01547 SIZE size;
01548
01549 lpFixed =
PathFindFileName(lpszPath, cchText);
01550
if (lpFixed != lpszPath)
01551 lpFixed--;
01552
else
01553
return cchText;
01554
01555 lpEnd = lpFixed;
01556 bEllipsisIn =
FALSE;
01557 iLenFixed = cchText - (
int)(lpFixed - lpszPath);
01558 dxFixed =
DT_GetExtentMinusPrefixes(hDC, lpFixed, iLenFixed, wFormat, iOverhang, lpDrawInfo, iCharSet);
01559
01560
01561
UserGetTextExtentPointW(hDC,
szEllipsis,
CCHELLIPSIS, &size);
01562 dxEllipsis = size.cx - iOverhang;
01563
01564
while (
TRUE) {
01565 iLen = dxFixed +
DT_GetExtentMinusPrefixes(hDC, lpszPath, (
int)((
PBYTE)lpEnd - (
PBYTE)lpszPath)/
sizeof(WCHAR),
01566 wFormat, iOverhang, lpDrawInfo, iCharSet) - iOverhang;
01567
01568
if (bEllipsisIn)
01569 iLen += dxEllipsis;
01570
01571
if (iLen <= cxMaxWidth)
01572
break;
01573
01574 bEllipsisIn =
TRUE;
01575
01576
if (lpEnd <= lpszPath) {
01577
01578 lpEnd = lpszPath;
01579
break;
01580 }
01581
01582
01583 lpEnd--;
01584 }
01585
01586
if (bEllipsisIn && (lpEnd +
CCHELLIPSIS < lpFixed)) {
01587
01588
01589 RtlMoveMemory((lpEnd +
CCHELLIPSIS), lpFixed, iLenFixed *
sizeof(WCHAR));
01590 RtlCopyMemory(lpEnd,
szEllipsis,
CCHELLIPSIS *
sizeof(WCHAR));
01591
01592 cchText = (
int)(lpEnd - lpszPath) +
CCHELLIPSIS + iLenFixed;
01593
01594
01595 *(lpszPath + cchText) = TEXT(
'\0');
01596 }
01597
01598
return cchText;
01599 }
01600
01601
01602
01603
01604 int AddEllipsisAndDrawLine(
01605 HDC hdc,
01606
int yLine,
01607 LPCWSTR lpchText,
01608
int cchText,
01609 DWORD dwDTformat,
01610 LPDRAWTEXTDATA lpDrawInfo,
01611
int iCharSet)
01612 {
01613 LPWSTR pEllipsis =
NULL;
01614 WCHAR szTempBuff[
MAXBUFFSIZE];
01615 LPWSTR
lpDest;
01616
BOOL fAlreadyCopied =
FALSE;
01617
01618
01619
01620
if(
PATHELLIPSIS(dwDTformat) &&
01621 ((
DT_GetExtentMinusPrefixes(hdc, lpchText, cchText,
01622 dwDTformat, lpDrawInfo->cxOverhang, lpDrawInfo, iCharSet)) > lpDrawInfo->cxMaxWidth)) {
01623
01624
if(!
MODIFYSTRING(dwDTformat)) {
01625
01626
01627
if((cchText +
CCHELLIPSIS + 1) <=
MAXBUFFSIZE)
01628
lpDest = szTempBuff;
01629
else {
01630
01631
if(!(pEllipsis = (LPWSTR)
UserRtlAllocMem(
01632 (cchText+
CCHELLIPSIS+1)*
sizeof(WCHAR))))
01633
return 0;
01634
lpDest = (LPWSTR)pEllipsis;
01635 }
01636
01637
01638 RtlCopyMemory(
lpDest, lpchText, cchText*
sizeof(WCHAR));
01639 lpchText =
lpDest;
01640 fAlreadyCopied =
TRUE;
01641 }
01642
01643 cchText =
AddPathEllipsis(hdc, (LPWSTR)lpchText, cchText, dwDTformat,
01644 lpDrawInfo->cxMaxWidth, lpDrawInfo->cxOverhang, lpDrawInfo, iCharSet);
01645 }
01646
01647
01648
if((
ENDELLIPSIS(dwDTformat) ||
WORDELLIPSIS(dwDTformat)) &&
01649
NeedsEndEllipsis(hdc, lpchText, &cchText, lpDrawInfo, dwDTformat, lpDrawInfo, iCharSet)) {
01650
01651
if(!
MODIFYSTRING(dwDTformat) && !fAlreadyCopied) {
01652
01653
if((cchText+
CCHELLIPSIS+1) <=
MAXBUFFSIZE)
01654
lpDest = szTempBuff;
01655
else {
01656
01657
if(!(pEllipsis = (LPWSTR)
UserRtlAllocMem(
01658 (cchText+
CCHELLIPSIS+1)*
sizeof(WCHAR))))
01659
return 0;
01660
lpDest = pEllipsis;
01661 }
01662
01663 RtlCopyMemory(
lpDest, lpchText, cchText*
sizeof(WCHAR));
01664 lpchText =
lpDest;
01665 }
01666
01667 RtlCopyMemory((LPWSTR)(lpchText+cchText),
szEllipsis, (
CCHELLIPSIS+1)*
sizeof(WCHAR));
01668 cchText +=
CCHELLIPSIS;
01669 }
01670
01671
01672
DT_DrawJustifiedLine(hdc, yLine, lpchText, cchText, dwDTformat, lpDrawInfo, iCharSet);
01673
01674
01675
if(pEllipsis)
01676
UserRtlFreeMem(pEllipsis);
01677
01678
return cchText;
01679 }
01680
01681
01682
01683
01684
01685
01686
01687
01688
01689
01690
01691
01692 int DrawTextExW(
01693 HDC hdc,
01694 LPWSTR lpchText,
01695
int cchText,
01696 LPRECT lprc,
01697 UINT dwDTformat,
01698 LPDRAWTEXTPARAMS lpDTparams)
01699 {
01700
01701
01702
01703
01704
01705
return DrawTextExWorker(hdc, lpchText, cchText, lprc, dwDTformat, lpDTparams, -1);
01706 }
01707
01708 int DrawTextExWorker(
01709 HDC hdc,
01710 LPWSTR lpchText,
01711
int cchText,
01712 LPRECT lprc,
01713 UINT dwDTformat,
01714 LPDRAWTEXTPARAMS lpDTparams,
01715
int iCharset)
01716 {
01717
DRAWTEXTDATA DrawInfo;
01718 WORD wFormat = LOWORD(dwDTformat);
01719 LPWSTR lpchTextBegin;
01720 LPWSTR lpchEnd;
01721 LPWSTR lpchNextLineSt;
01722
int iLineLength;
01723
int iySign;
01724
int yLine;
01725
int yLastLineHeight;
01726 HRGN hrgnClip;
01727
int iLineCount;
01728 RECT rc;
01729
BOOL fLastLine;
01730 WCHAR ch;
01731
UINT oldAlign;
01732
01733
#if DBG
01734
if (dwDTformat & ~DT_VALID)
01735 RIPMSG0 (RIP_WARNING,
"DrawTextExW: Invalid dwDTformat flags");
01736
#endif
01737
01738
if (lpchText ==
NULL) {
01739
return 1;
01740 }
01741
01742
if (cchText == 0 && *lpchText) {
01743
01744
01745
01746
01747
01748
01749
01750
01751
01752
01753
return 1;
01754 }
01755
01756
if (cchText == -1)
01757 cchText = wcslen(lpchText);
01758
01759
01760
01761
if ((lpDTparams) && (lpDTparams->cbSize !=
sizeof(DRAWTEXTPARAMS))) {
01762 RIPERR1(ERROR_INVALID_PARAMETER, RIP_WARNING,
"DrawTextEx: cbSize %ld is invalid",
01763 lpDTparams->cbSize);
01764
return 0;
01765 }
01766
01767
01768
#ifdef LATER
01769
01770
01771
01772
if (
MODIFYSTRING(dwDTformat) &&
01773 (
ENDELLIPSIS(dwDTformat) ||
PATHELLIPSIS(dwDTformat))) {
01774
if(IsBadWritePtr(lpchText, cchText)) {
01775 RIPERR0(ERROR_INVALID_PARAMETER, RIP_WARNING,
"DrawTextEx: For DT_MODIFYSTRING, lpchText must be read-write");
01776
return(0);
01777 }
01778 }
01779
#endif
01780
01781
01782
01783
01784
if (!
DT_InitDrawTextInfo(hdc, lprc, dwDTformat, (
LPDRAWTEXTDATA)&DrawInfo, lpDTparams))
01785
return 0;
01786
01787 DrawInfo.iCharset = iCharset;
01788
01789
01790
01791
01792
01793
01794
01795
01796
01797
if (DrawInfo.cxMaxWidth <= 0) {
01798
01799
01800
01801
01802
01803
#ifdef _USERK_
01804
if (0) {
01805
#else
01806
if (
GETAPPVER() <
VER40) {
01807
#endif
01808
if((DrawInfo.cxMaxWidth == 0) && !
CALCRECT(wFormat)) {
01809
return(1);
01810 }
01811 }
else {
01812
if (
WORDBREAK(wFormat)) {
01813 RIPMSG0 (RIP_WARNING,
"DrawTextExW: FAILURE DrawInfo.cxMaxWidth <=0");
01814
return (1);
01815 }
01816 }
01817 }
01818
01819
01820
01821
01822
if (
RTLREADING(dwDTformat)) {
01823 oldAlign =
UserSetTextAlign(hdc, TA_RTLREADING |
UserGetTextAlign(hdc));
01824 }
01825
01826
if (DrawInfo.bCharsetDll) {
01827
#ifdef _USERK_
01828
PTHREADINFO ptiCurrent =
PtiCurrentShared();
01829
01830
if(
CALL_LPK(ptiCurrent))
01831
#endif // _USERK_
01832
(*UserLpkDrawTextEx)(hdc, 0, 0, lpchText, cchText,
FALSE, dwDTformat,
01833 (
LPDRAWTEXTDATA)&DrawInfo,
DT_CHARSETINIT, iCharset);
01834 }
01835
01836
01837
01838
01839
if (!
NOCLIP(wFormat)) {
01840
01841
01842
01843
01844
01845
01846 hrgnClip =
UserCreateRectRgn(0,0,0,0);
01847
if (hrgnClip !=
NULL) {
01848
if (
UserGetClipRgn(hdc, hrgnClip) != 1) {
01849
UserDeleteObject(hrgnClip);
01850 hrgnClip = (HRGN)-1;
01851 }
01852 rc = *lprc;
01853
UserIntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom);
01854 }
01855 }
else {
01856 hrgnClip =
NULL;
01857 }
01858
01859 lpchTextBegin = lpchText;
01860 lpchEnd = lpchText + cchText;
01861
01862 ProcessDrawText:
01863
01864 iLineCount = 0;
01865 yLine = lprc->top;
01866
01867
if (
SINGLELINE(wFormat)) {
01868 iLineCount = 1;
01869
01870
01871
01872
01873
01874
switch (wFormat &
DT_VFMTMASK) {
01875
case DT_BOTTOM:
01876 yLine = lprc->bottom - DrawInfo.cyLineHeight;
01877
break;
01878
01879
case DT_VCENTER:
01880 yLine = lprc->top + ((lprc->bottom - lprc->top - DrawInfo.cyLineHeight) / 2);
01881
break;
01882 }
01883
01884 cchText =
AddEllipsisAndDrawLine(hdc, yLine, lpchText, cchText, dwDTformat, &DrawInfo, iCharset);
01885 yLine += DrawInfo.cyLineHeight;
01886 lpchText += cchText;
01887 }
else {
01888
01889
01890
01891
01892
01893
01894
01895
01896
01897
01898
if (
EDITCONTROL(wFormat))
01899 yLastLineHeight = DrawInfo.cyLineHeight;
01900
else
01901 yLastLineHeight = 0;
01902
01903 iySign = DrawInfo.iYSign;
01904 fLastLine =
FALSE;
01905
01906
while ((lpchText < lpchEnd) && (!fLastLine)) {
01907
01908
01909
01910
01911
if (!
CALCRECT(wFormat) &&
01912 (!
NOCLIP(wFormat)) &&
01913
01914 ((yLine + DrawInfo.cyLineHeight + yLastLineHeight)*iySign > (lprc->bottom*iySign))) {
01915 fLastLine =
TRUE;
01916 }
01917
01918
01919
01920
01921
01922
if (fLastLine && (
ENDELLIPSIS(dwDTformat) ||
PATHELLIPSIS(dwDTformat))) {
01923 lpchText +=
AddEllipsisAndDrawLine(hdc, yLine, lpchText, cchText, dwDTformat, &DrawInfo, iCharset);
01924 }
else {
01925 lpchNextLineSt = (LPWSTR)
DT_GetLineBreak(hdc, lpchText, cchText, dwDTformat, &iLineLength, &DrawInfo, iCharset);
01926
01927
01928
01929
01930
01931
if (
WORDELLIPSIS(dwDTformat) ||
01932 ((lpchNextLineSt >= lpchEnd) && (
ENDELLIPSIS(dwDTformat) ||
PATHELLIPSIS(dwDTformat))))
01933
AddEllipsisAndDrawLine(hdc, yLine, lpchText, iLineLength, dwDTformat, &DrawInfo, iCharset);
01934
else
01935
DT_DrawJustifiedLine(hdc, yLine, lpchText, iLineLength, dwDTformat, &DrawInfo, iCharset);
01936 cchText -= (
int)((
PBYTE)lpchNextLineSt - (
PBYTE)lpchText) /
sizeof(WCHAR);
01937 lpchText = lpchNextLineSt;
01938 }
01939 iLineCount++;
01940 yLine += DrawInfo.cyLineHeight;
01941 }
01942
01943
01944
01945
01946
01947
01948
if (!
EDITCONTROL(dwDTformat) &&
01949 (lpchEnd > lpchTextBegin) &&
01950 (((ch = (*(lpchEnd-1))) ==
CR) || (ch ==
LF)))
01951 yLine += DrawInfo.cyLineHeight;
01952 }
01953
01954
01955
01956
01957
01958
01959
if (
CALCRECT(wFormat)) {
01960 DrawInfo.rcFormat.right = DrawInfo.rcFormat.left + DrawInfo.cxMaxExtent * DrawInfo.iXSign;
01961 lprc->right = DrawInfo.rcFormat.right + DrawInfo.cxRightMargin;
01962
01963
01964
01965
01966
if((iLineCount > 1) && (DrawInfo.cxMaxExtent > DrawInfo.cxMaxWidth)) {
01967 DrawInfo.cxMaxWidth = DrawInfo.cxMaxExtent;
01968 lpchText = lpchTextBegin;
01969 cchText = (
int)((
PBYTE)lpchEnd - (
PBYTE)lpchTextBegin)/
sizeof(WCHAR);
01970
goto ProcessDrawText;
01971 }
01972 lprc->bottom = yLine;
01973 }
01974
01975
01976
01977
01978
01979
01980
if (hrgnClip !=
NULL) {
01981
if (hrgnClip == (HRGN)-1) {
01982
UserExtSelectClipRgn(hdc,
NULL, RGN_COPY);
01983 }
else {
01984
UserExtSelectClipRgn(hdc, hrgnClip, RGN_COPY);
01985
UserDeleteObject(hrgnClip);
01986 }
01987 }
01988
01989
if(DrawInfo.bCharsetDll) {
01990
#ifdef _USERK_
01991
PTHREADINFO ptiCurrent =
PtiCurrentShared();
01992
01993
if(
CALL_LPK(ptiCurrent))
01994
#endif // _USERK_
01995
(*UserLpkDrawTextEx)(hdc, 0, 0, lpchText, cchText,
FALSE, dwDTformat,
01996 (
LPDRAWTEXTDATA)&DrawInfo,
DT_CHARSETDONE, iCharset);
01997 }
01998
01999
if (
RTLREADING(dwDTformat))
02000
UserSetTextAlign(hdc, oldAlign);
02001
02002
02003
02004
02005
if(lpDTparams !=
NULL)
02006 lpDTparams->uiLengthDrawn = (
UINT)((
PBYTE)lpchText - (
PBYTE)lpchTextBegin)/
sizeof(WCHAR);
02007
02008
if (yLine == lprc->top)
02009
return 1;
02010
02011
return (yLine - lprc->top);
02012 }
02013
02014
02015
02016
02017
02018
02019
02020
02021
02022
02023
02024
02025
02026
02027 BOOL IsSysFontAndDefaultMode(HDC hdc)
02028 {
02029
return((
UserGetHFONT(hdc) ==
ghFontSys) && (
UserGetMapMode(hdc) == MM_TEXT));
02030 }