00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
#include "precomp.h"
00015
#pragma hdrstop
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 BOOL UT_CaretSet(
00029
PWND pwnd)
00030 {
00031
PQ pq;
00032
PTHREADINFO ptiCurrent;
00033
00034
00035
00036
00037 ptiCurrent =
PtiCurrent();
00038 pq = ptiCurrent->
pq;
00039
00040
if (pq->
caret.
spwnd ==
NULL) {
00041 RIPERR0(ERROR_ACCESS_DENIED,
00042 RIP_VERBOSE,
00043
"Access denied in UT_CaretSet to current queue's caret");
00044
00045
return FALSE;
00046 }
00047
00048
00049
00050
00051
00052
00053
if (pq->
caret.
tid !=
TIDq(ptiCurrent)) {
00054
PTHREADINFO ptiCursorOwner;
00055
00056 ptiCursorOwner =
PtiFromThreadId(pq->
caret.
tid);
00057
00058
if ((ptiCurrent->
TIF_flags &
TIF_16BIT) || ptiCursorOwner ==
NULL ||
00059 (ptiCurrent->
ppi != ptiCursorOwner->
ppi)) {
00060 RIPERR0(ERROR_ACCESS_DENIED,
00061 RIP_VERBOSE,
00062
"Access denied in UT_CaretSet");
00063
00064
return FALSE;
00065 }
00066 }
00067
00068
00069
00070
00071
00072
if (pwnd ==
NULL)
00073
return TRUE;
00074
00075
00076
00077
00078
00079
if (pwnd == pq->
caret.
spwnd)
00080
return TRUE;
00081
00082
return FALSE;
00083 }
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094 void UT_InvertCaret()
00095 {
00096 HDC hdc;
00097
PWND pwnd;
00098
PQ pq;
00099 HBITMAP hbmSave;
00100
BOOL fRestore;
00101
00102 pq =
PtiCurrent()->pq;
00103 pwnd = pq->
caret.
spwnd;
00104
00105
00106
if (pwnd ==
NULL || !
IsVisible(pwnd)) {
00107 pq->
caret.
fVisible =
FALSE;
00108
return;
00109 }
00110
00111
00112
00113
00114 hdc =
_GetDC(pwnd);
00115
00116
if (fRestore = (pwnd->
hrgnUpdate ?
TRUE :
FALSE)) {
00117 GreSaveDC(hdc);
00118
if (
TestWF(pwnd,
WFWIN31COMPAT))
00119
_ExcludeUpdateRgn(hdc, pwnd);
00120 }
00121
00122
00123
00124
00125
00126
00127
if ((pq->
caret.
hBitmap) > (HBITMAP)1) {
00128
00129
00130
00131
00132 hbmSave = GreSelectBitmap(
ghdcMem, pq->
caret.
hBitmap);
00133 GreBitBlt(hdc, pq->
caret.
x, pq->
caret.
y, pq->
caret.
cx,
00134 pq->
caret.
cy,
ghdcMem, 0, 0, SRCINVERT, 0);
00135
00136 GreSelectBitmap(
ghdcMem, hbmSave);
00137
00138 }
else {
00139
00140 POLYPATBLT PolyData;
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152 PolyData.x = pq->
caret.
x;
00153 PolyData.y = pq->
caret.
y;
00154 PolyData.cx = pq->
caret.
cx;
00155 PolyData.cy = pq->
caret.
cy;
00156
00157
if ((pq->
caret.
hBitmap) == (HBITMAP)1) {
00158
00159 PolyData.BrClr.hbr =
gpsi->hbrGray;
00160 }
else {
00161
00162 PolyData.BrClr.hbr =
ghbrWhite;
00163 }
00164
00165 GrePolyPatBlt(hdc,PATINVERT,&PolyData,1,PPB_BRUSH);
00166
00167
00168
00169
00170
00171 }
00172
00173
if (fRestore)
00174 GreRestoreDC(hdc, -1);
00175
00176
_ReleaseDC(hdc);
00177 }
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189 void zzzInternalDestroyCaret()
00190 {
00191
PQ pq;
00192
PTHREADINFO ptiCurrent =
PtiCurrent();
00193
PWND pwndCaret;
00194
TL tlpwndCaret;
00195
00196
00197
00198
00199
zzzInternalHideCaret();
00200 pq = ptiCurrent->
pq;
00201
_KillSystemTimer(pq->
caret.
spwnd,
IDSYS_CARET);
00202
00203 pq->
caret.
hTimer = 0;
00204 pq->
caret.
hBitmap =
NULL;
00205 pq->
caret.
iHideLevel = 0;
00206
00207 pwndCaret = pq->
caret.
spwnd;
00208
if (pwndCaret !=
NULL) {
00209
00210
00211
00212
ThreadLockWithPti(ptiCurrent, pwndCaret, &tlpwndCaret);
00213
Unlock(&pq->
caret.
spwnd);
00214
00215
if (
FWINABLE()) {
00216
zzzWindowEvent(EVENT_OBJECT_DESTROY, pwndCaret, OBJID_CARET, INDEXID_CONTAINER, 0);
00217 }
00218
00219
ThreadUnlock(&tlpwndCaret);
00220 }
00221 }
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234 BOOL zzzDestroyCaret()
00235 {
00236
if (
UT_CaretSet(
NULL)) {
00237
zzzInternalDestroyCaret();
00238
return TRUE;
00239 }
00240
return FALSE;
00241 }
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254 BOOL xxxCreateCaret(
00255
PWND pwnd,
00256 HBITMAP hBitmap,
00257
int cx,
00258
int cy)
00259 {
00260
PQ pq;
00261 BITMAP bitmap;
00262
PTHREADINFO ptiCurrent =
PtiCurrent();
00263
00264
CheckLock(pwnd);
00265 UserAssert(
IsWinEventNotifyDeferredOK());
00266
00267 pq = ptiCurrent->
pq;
00268
00269
00270
00271
00272
00273
if (
GETPTI(pwnd)->pq != pq) {
00274
return FALSE;
00275 }
00276
00277
00278
00279
00280
DeferWinEventNotify();
00281
00282
if (pq->
caret.
spwnd !=
NULL)
00283
zzzInternalDestroyCaret();
00284
00285
Lock(&pq->
caret.
spwnd, pwnd);
00286 pq->
caret.
iHideLevel = 1;
00287 pq->
caret.
fOn =
TRUE;
00288 pq->
caret.
fVisible =
FALSE;
00289 pq->
caret.
tid =
TIDq(ptiCurrent);
00290
00291
if (
cy == 0)
00292
cy =
SYSMET(CYBORDER);
00293
if (cx == 0)
00294 cx =
SYSMET(CXBORDER);
00295
00296
if ((pq->
caret.
hBitmap = hBitmap) > (HBITMAP)1) {
00297 GreExtGetObjectW(hBitmap,
sizeof(BITMAP), &bitmap);
00298
cy = bitmap.bmHeight;
00299 cx = bitmap.bmWidth;
00300 }
00301
00302 pq->
caret.
cy =
cy;
00303 pq->
caret.
cx = cx;
00304
00305 pq->
caret.
hTimer =
_SetSystemTimer(pwnd,
IDSYS_CARET,
gpsi->dtCaretBlink,
00306
CaretBlinkProc);
00307
00308 UserAssert(pwnd == pq->
caret.
spwnd);
00309
zzzEndDeferWinEventNotify();
00310
if (
FWINABLE()) {
00311
00312
00313
00314
00315
00316
xxxWindowEvent(EVENT_OBJECT_CREATE, pwnd, OBJID_CARET, INDEXID_CONTAINER, 0);
00317 }
00318
00319
return TRUE;
00320 }
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331 void zzzInternalShowCaret()
00332 {
00333
PQ pq;
00334
PTHREADINFO ptiCurrent =
PtiCurrent();
00335
00336 pq = ptiCurrent->
pq;
00337
00338
00339
00340
00341
00342
if (pq->
caret.
iHideLevel == 0) {
00343
if (!pq->
caret.
fVisible) {
00344
if ((pq->
caret.
fVisible = pq->
caret.
fOn) != 0) {
00345
UT_InvertCaret();
00346 }
00347 }
00348
return;
00349 }
00350
00351
00352
00353
00354
00355
00356
if (--pq->
caret.
iHideLevel == 0) {
00357
if ((pq->
caret.
fVisible = pq->
caret.
fOn) != 0)
00358
UT_InvertCaret();
00359
00360
if (
FWINABLE()) {
00361
zzzWindowEvent(EVENT_OBJECT_SHOW, pq->
caret.
spwnd, OBJID_CARET, INDEXID_CONTAINER, 0);
00362 }
00363 }
00364 }
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00376 void zzzInternalHideCaret()
00377 {
00378
PQ pq;
00379
PTHREADINFO ptiCurrent =
PtiCurrent();
00380
00381 pq = ptiCurrent->
pq;
00382
00383
00384
00385
00386
00387
if (pq->
caret.
fVisible)
00388
UT_InvertCaret();
00389
00390 pq->
caret.
fVisible =
FALSE;
00391 pq->
caret.
iHideLevel++;
00392
00393
00394
00395
00396
00397
if (
FWINABLE() && (pq->
caret.
iHideLevel == 1)) {
00398
zzzWindowEvent(EVENT_OBJECT_HIDE, pq->
caret.
spwnd, OBJID_CARET, INDEXID_CONTAINER, 0);
00399 }
00400 }
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413 BOOL zzzShowCaret(
00414
PWND pwnd)
00415 {
00416
if (
UT_CaretSet(pwnd)) {
00417
zzzInternalShowCaret();
00418
return TRUE;
00419 }
00420
return FALSE;
00421 }
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434 BOOL zzzHideCaret(
00435
PWND pwnd)
00436 {
00437
if (
UT_CaretSet(pwnd)) {
00438
zzzInternalHideCaret();
00439
return TRUE;
00440 }
00441
return FALSE;
00442 }
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454 VOID CaretBlinkProc(
00455
PWND pwnd,
00456 UINT message,
00457 UINT_PTR
id,
00458 LPARAM lParam)
00459 {
00460
PQ pq;
00461
00462
00463
00464
00465
00466
00467 pq =
PtiCurrent()->pq;
00468
if (pwnd != pq->
caret.
spwnd)
00469
return;
00470
00471
00472
00473
00474
00475
if (
gbRemoteSession && (
gpsi->dtCaretBlink >= 1200) && pq->
caret.
fOn && pq->
caret.
fVisible) {
00476
00477
00478
00479
00480
_KillSystemTimer(pq->
caret.
spwnd,
IDSYS_CARET);
00481
return;
00482 }
00483
00484
00485
00486
00487
00488 pq->
caret.
fOn ^= 1;
00489
if (pq->
caret.
iHideLevel == 0) {
00490 pq->
caret.
fVisible ^= 1;
00491
UT_InvertCaret();
00492 }
00493
00494
return;
00495
00496 DBG_UNREFERENCED_PARAMETER(message);
00497 DBG_UNREFERENCED_PARAMETER(
id);
00498 DBG_UNREFERENCED_PARAMETER(lParam);
00499 }
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513 BOOL _SetCaretBlinkTime(
00514 UINT cmsBlink)
00515 {
00516
PQ pq;
00517
PTHREADINFO ptiCurrent =
PtiCurrent();
00518
00519
00520
00521
00522
if (!
CheckWinstaWriteAttributesAccess()) {
00523
return FALSE;
00524 }
00525
00526
gpsi->dtCaretBlink = cmsBlink;
00527
00528 pq = ptiCurrent->
pq;
00529
00530
if (pq->
caret.
spwnd) {
00531
_KillSystemTimer(pq->
caret.
spwnd,
IDSYS_CARET);
00532 pq->
caret.
hTimer =
_SetSystemTimer(pq->
caret.
spwnd,
IDSYS_CARET,
00533
gpsi->dtCaretBlink,
CaretBlinkProc);
00534 }
00535
00536
return TRUE;
00537 }
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550 BOOL zzzSetCaretPos(
00551
int x,
00552
int y)
00553 {
00554
PQ pq;
00555
PTHREADINFO ptiCurrent =
PtiCurrent();
00556
00557
00558
00559
00560
if (!
UT_CaretSet(
NULL)) {
00561 RIPERR0(ERROR_ACCESS_DENIED, RIP_VERBOSE,
"Access denied in zzzSetCaretPos");
00562
return FALSE;
00563 }
00564
00565
00566
00567
00568 pq = ptiCurrent->
pq;
00569
if (pq->
caret.
x == x && pq->
caret.
y == y)
00570
return TRUE;
00571
00572
00573
00574
00575
if (pq->
caret.
fVisible)
00576
UT_InvertCaret();
00577
00578
00579
00580
00581 pq->
caret.
x = x;
00582 pq->
caret.
y = y;
00583
00584
00585
00586
00587
00588
_KillSystemTimer(pq->
caret.
spwnd,
IDSYS_CARET);
00589 pq->
caret.
hTimer =
_SetSystemTimer(pq->
caret.
spwnd,
IDSYS_CARET,
00590
gpsi->dtCaretBlink,
CaretBlinkProc);
00591
00592 pq->
caret.
fOn =
TRUE;
00593
00594
00595
00596
00597 pq->
caret.
fVisible =
FALSE;
00598
if (pq->
caret.
iHideLevel == 0) {
00599 pq->
caret.
fVisible =
TRUE;
00600
UT_InvertCaret();
00601 }
00602
00603
if (
FWINABLE()) {
00604
zzzWindowEvent(EVENT_OBJECT_LOCATIONCHANGE, pq->
caret.
spwnd, OBJID_CARET, INDEXID_CONTAINER, 0);
00605 }
00606
00607
return TRUE;
00608 }