| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
#include "tkWinInt.h" |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#define PI 3.14159265358979 |
| 23 |
#define XAngleToRadians(a) ((double)(a) / 64 * PI / 180); |
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
int tkpWinRopModes[] = { |
| 30 |
R2_BLACK, |
| 31 |
R2_MASKPEN, |
| 32 |
R2_MASKPENNOT, |
| 33 |
R2_COPYPEN, |
| 34 |
R2_MASKNOTPEN, |
| 35 |
R2_NOT, |
| 36 |
R2_XORPEN, |
| 37 |
R2_MERGEPEN, |
| 38 |
R2_NOTMERGEPEN, |
| 39 |
R2_NOTXORPEN, |
| 40 |
R2_NOT, |
| 41 |
R2_MERGEPENNOT, |
| 42 |
R2_NOTCOPYPEN, |
| 43 |
R2_MERGENOTPEN, |
| 44 |
R2_NOTMASKPEN, |
| 45 |
R2_WHITE |
| 46 |
}; |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
#define NOTSRCAND (DWORD)0x00220326 |
| 56 |
#define NOTSRCINVERT (DWORD)0x00990066 |
| 57 |
#define SRCORREVERSE (DWORD)0x00DD0228 |
| 58 |
#define SRCNAND (DWORD)0x007700E6 |
| 59 |
|
| 60 |
int tkpWinBltModes[] = { |
| 61 |
BLACKNESS, |
| 62 |
SRCAND, |
| 63 |
SRCERASE, |
| 64 |
SRCCOPY, |
| 65 |
NOTSRCAND, |
| 66 |
PATCOPY, |
| 67 |
SRCINVERT, |
| 68 |
SRCPAINT, |
| 69 |
NOTSRCERASE, |
| 70 |
NOTSRCINVERT, |
| 71 |
DSTINVERT, |
| 72 |
SRCORREVERSE, |
| 73 |
NOTSRCCOPY, |
| 74 |
MERGEPAINT, |
| 75 |
SRCNAND, |
| 76 |
WHITENESS |
| 77 |
}; |
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
#define MASKPAT 0x00E20746 |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
#define COPYFG 0x00CA0749 |
| 93 |
#define COPYBG 0x00AC0744 |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
#define MIN(a,b) ((a>b) ? b : a) |
| 100 |
#define MAX(a,b) ((a<b) ? b : a) |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
typedef BOOL (CALLBACK *WinDrawFunc) _ANSI_ARGS_((HDC dc, |
| 107 |
CONST POINT* points, int npoints)); |
| 108 |
|
| 109 |
typedef struct ThreadSpecificData { |
| 110 |
POINT *winPoints; |
| 111 |
int nWinPoints; |
| 112 |
} ThreadSpecificData; |
| 113 |
static Tcl_ThreadDataKey dataKey; |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
static POINT * ConvertPoints _ANSI_ARGS_((XPoint *points, int npoints, |
| 120 |
int mode, RECT *bbox)); |
| 121 |
static void DrawOrFillArc _ANSI_ARGS_((Display *display, |
| 122 |
Drawable d, GC gc, int x, int y, |
| 123 |
unsigned int width, unsigned int height, |
| 124 |
int start, int extent, int fill)); |
| 125 |
static void RenderObject _ANSI_ARGS_((HDC dc, GC gc, |
| 126 |
XPoint* points, int npoints, int mode, HPEN pen, |
| 127 |
WinDrawFunc func)); |
| 128 |
static HPEN SetUpGraphicsPort _ANSI_ARGS_((GC gc)); |
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
HDC |
| 149 |
TkWinGetDrawableDC(display, d, state) |
| 150 |
Display *display; |
| 151 |
Drawable d; |
| 152 |
TkWinDCState* state; |
| 153 |
{ |
| 154 |
HDC dc; |
| 155 |
TkWinDrawable *twdPtr = (TkWinDrawable *)d; |
| 156 |
Colormap cmap; |
| 157 |
|
| 158 |
if (twdPtr->type == TWD_WINDOW) { |
| 159 |
TkWindow *winPtr = twdPtr->window.winPtr; |
| 160 |
|
| 161 |
dc = GetDC(twdPtr->window.handle); |
| 162 |
if (winPtr == NULL) { |
| 163 |
cmap = DefaultColormap(display, DefaultScreen(display)); |
| 164 |
} else { |
| 165 |
cmap = winPtr->atts.colormap; |
| 166 |
} |
| 167 |
} else if (twdPtr->type == TWD_WINDC) { |
| 168 |
dc = twdPtr->winDC.hdc; |
| 169 |
cmap = DefaultColormap(display, DefaultScreen(display)); |
| 170 |
} else { |
| 171 |
dc = CreateCompatibleDC(NULL); |
| 172 |
SelectObject(dc, twdPtr->bitmap.handle); |
| 173 |
cmap = twdPtr->bitmap.colormap; |
| 174 |
} |
| 175 |
state->palette = TkWinSelectPalette(dc, cmap); |
| 176 |
state->bkmode = GetBkMode(dc); |
| 177 |
LangNoteDC(dc,1); |
| 178 |
return dc; |
| 179 |
} |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
void |
| 198 |
TkWinReleaseDrawableDC(d, dc, state) |
| 199 |
Drawable d; |
| 200 |
HDC dc; |
| 201 |
TkWinDCState *state; |
| 202 |
{ |
| 203 |
TkWinDrawable *twdPtr = (TkWinDrawable *)d; |
| 204 |
SetBkMode(dc, state->bkmode); |
| 205 |
SelectPalette(dc, state->palette, TRUE); |
| 206 |
RealizePalette(dc); |
| 207 |
if (twdPtr->type == TWD_WINDOW) { |
| 208 |
ReleaseDC(TkWinGetHWND(d), dc); |
| 209 |
} else if (twdPtr->type == TWD_BITMAP) { |
| 210 |
DeleteDC(dc); |
| 211 |
} |
| 212 |
LangNoteDC(dc,-1); |
| 213 |
} |
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
static POINT * |
| 233 |
ConvertPoints(points, npoints, mode, bbox) |
| 234 |
XPoint *points; |
| 235 |
int npoints; |
| 236 |
int mode; |
| 237 |
RECT *bbox; |
| 238 |
{ |
| 239 |
ThreadSpecificData *tsdPtr = (ThreadSpecificData *) |
| 240 |
Tcl_GetThreadData(&dataKey, sizeof(ThreadSpecificData)); |
| 241 |
int i; |
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
if (npoints > tsdPtr->nWinPoints) { |
| 249 |
if (tsdPtr->winPoints != NULL) { |
| 250 |
ckfree((char *) tsdPtr->winPoints); |
| 251 |
} |
| 252 |
tsdPtr->winPoints = (POINT *) ckalloc(sizeof(POINT) * npoints); |
| 253 |
if (tsdPtr->winPoints == NULL) { |
| 254 |
tsdPtr->nWinPoints = -1; |
| 255 |
return NULL; |
| 256 |
} |
| 257 |
tsdPtr->nWinPoints = npoints; |
| 258 |
} |
| 259 |
|
| 260 |
bbox->left = bbox->right = points[0].x; |
| 261 |
bbox->top = bbox->bottom = points[0].y; |
| 262 |
|
| 263 |
if (mode == CoordModeOrigin) { |
| 264 |
for (i = 0; i < npoints; i++) { |
| 265 |
tsdPtr->winPoints[i].x = points[i].x; |
| 266 |
tsdPtr->winPoints[i].y = points[i].y; |
| 267 |
bbox->left = MIN(bbox->left, tsdPtr->winPoints[i].x); |
| 268 |
bbox->right = MAX(bbox->right, tsdPtr->winPoints[i].x); |
| 269 |
bbox->top = MIN(bbox->top, tsdPtr->winPoints[i].y); |
| 270 |
bbox->bottom = MAX(bbox->bottom, tsdPtr->winPoints[i].y); |
| 271 |
} |
| 272 |
} else { |
| 273 |
tsdPtr->winPoints[0].x = points[0].x; |
| 274 |
tsdPtr->winPoints[0].y = points[0].y; |
| 275 |
for (i = 1; i < npoints; i++) { |
| 276 |
tsdPtr->winPoints[i].x = tsdPtr->winPoints[i-1].x + points[i].x; |
| 277 |
tsdPtr->winPoints[i].y = tsdPtr->winPoints[i-1].y + points[i].y; |
| 278 |
bbox->left = MIN(bbox->left, tsdPtr->winPoints[i].x); |
| 279 |
bbox->right = MAX(bbox->right, tsdPtr->winPoints[i].x); |
| 280 |
bbox->top = MIN(bbox->top, tsdPtr->winPoints[i].y); |
| 281 |
bbox->bottom = MAX(bbox->bottom, tsdPtr->winPoints[i].y); |
| 282 |
} |
| 283 |
} |
| 284 |
return tsdPtr->winPoints; |
| 285 |
} |
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
void |
| 306 |
XCopyArea(display, src, dest, gc, src_x, src_y, width, height, dest_x, dest_y) |
| 307 |
Display* display; |
| 308 |
Drawable src; |
| 309 |
Drawable dest; |
| 310 |
GC gc; |
| 311 |
int src_x, src_y; |
| 312 |
unsigned int width, height; |
| 313 |
int dest_x, dest_y; |
| 314 |
{ |
| 315 |
HDC srcDC, destDC; |
| 316 |
TkWinDCState srcState, destState; |
| 317 |
TkpClipMask *clipPtr = (TkpClipMask*)gc->clip_mask; |
| 318 |
|
| 319 |
srcDC = TkWinGetDrawableDC(display, src, &srcState); |
| 320 |
|
| 321 |
if (src != dest) { |
| 322 |
destDC = TkWinGetDrawableDC(display, dest, &destState); |
| 323 |
} else { |
| 324 |
destDC = srcDC; |
| 325 |
} |
| 326 |
|
| 327 |
if (clipPtr && clipPtr->type == TKP_CLIP_REGION) { |
| 328 |
SelectClipRgn(destDC, (HRGN) clipPtr->value.region); |
| 329 |
OffsetClipRgn(destDC, gc->clip_x_origin, gc->clip_y_origin); |
| 330 |
} |
| 331 |
|
| 332 |
BitBlt(destDC, dest_x, dest_y, width, height, srcDC, src_x, src_y, |
| 333 |
tkpWinBltModes[gc->function]); |
| 334 |
|
| 335 |
SelectClipRgn(destDC, NULL); |
| 336 |
|
| 337 |
if (src != dest) { |
| 338 |
TkWinReleaseDrawableDC(dest, destDC, &destState); |
| 339 |
} |
| 340 |
TkWinReleaseDrawableDC(src, srcDC, &srcState); |
| 341 |
} |
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
void |
| 363 |
XCopyPlane(display, src, dest, gc, src_x, src_y, width, height, dest_x, |
| 364 |
dest_y, plane) |
| 365 |
Display* display; |
| 366 |
Drawable src; |
| 367 |
Drawable dest; |
| 368 |
GC gc; |
| 369 |
int src_x, src_y; |
| 370 |
unsigned int width, height; |
| 371 |
int dest_x, dest_y; |
| 372 |
unsigned long plane; |
| 373 |
{ |
| 374 |
HDC srcDC, destDC; |
| 375 |
TkWinDCState srcState, destState; |
| 376 |
HBRUSH bgBrush, fgBrush, oldBrush; |
| 377 |
TkpClipMask *clipPtr = (TkpClipMask*)gc->clip_mask; |
| 378 |
|
| 379 |
display->request++; |
| 380 |
|
| 381 |
if (plane != 1) { |
| 382 |
panic("Unexpected plane specified for XCopyPlane"); |
| 383 |
} |
| 384 |
|
| 385 |
srcDC = TkWinGetDrawableDC(display, src, &srcState); |
| 386 |
|
| 387 |
if (src != dest) { |
| 388 |
destDC = TkWinGetDrawableDC(display, dest, &destState); |
| 389 |
} else { |
| 390 |
destDC = srcDC; |
| 391 |
} |
| 392 |
|
| 393 |
if (clipPtr == NULL || clipPtr->type == TKP_CLIP_REGION) { |
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
if (clipPtr && clipPtr->type == TKP_CLIP_REGION) { |
| 403 |
SelectClipRgn(destDC, (HRGN) clipPtr->value.region); |
| 404 |
OffsetClipRgn(destDC, gc->clip_x_origin, gc->clip_y_origin); |
| 405 |
} |
| 406 |
|
| 407 |
SetBkMode(destDC, OPAQUE); |
| 408 |
SetBkColor(destDC, gc->foreground); |
| 409 |
SetTextColor(destDC, gc->background); |
| 410 |
BitBlt(destDC, dest_x, dest_y, width, height, srcDC, src_x, src_y, |
| 411 |
SRCCOPY); |
| 412 |
|
| 413 |
SelectClipRgn(destDC, NULL); |
| 414 |
} else if (clipPtr->type == TKP_CLIP_PIXMAP) { |
| 415 |
if (clipPtr->value.pixmap == src) { |
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
fgBrush = CreateSolidBrush(gc->foreground); |
| 424 |
oldBrush = SelectObject(destDC, fgBrush); |
| 425 |
BitBlt(destDC, dest_x, dest_y, width, height, srcDC, src_x, src_y, |
| 426 |
MASKPAT); |
| 427 |
SelectObject(destDC, oldBrush); |
| 428 |
DeleteObject(fgBrush); |
| 429 |
} else { |
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
HDC memDC, maskDC; |
| 438 |
HBITMAP bitmap; |
| 439 |
TkWinDCState maskState; |
| 440 |
|
| 441 |
fgBrush = CreateSolidBrush(gc->foreground); |
| 442 |
bgBrush = CreateSolidBrush(gc->background); |
| 443 |
maskDC = TkWinGetDrawableDC(display, clipPtr->value.pixmap, |
| 444 |
&maskState); |
| 445 |
memDC = CreateCompatibleDC(destDC); |
| 446 |
bitmap = CreateBitmap(width, height, 1, 1, NULL); |
| 447 |
SelectObject(memDC, bitmap); |
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
BitBlt(memDC, 0, 0, width, height, srcDC, src_x, src_y, SRCCOPY); |
| 456 |
BitBlt(memDC, 0, 0, width, height, maskDC, |
| 457 |
dest_x - gc->clip_x_origin, dest_y - gc->clip_y_origin, |
| 458 |
SRCAND); |
| 459 |
oldBrush = SelectObject(destDC, fgBrush); |
| 460 |
BitBlt(destDC, dest_x, dest_y, width, height, memDC, 0, 0, |
| 461 |
MASKPAT); |
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
BitBlt(memDC, 0, 0, width, height, srcDC, src_x, src_y, |
| 469 |
NOTSRCCOPY); |
| 470 |
BitBlt(memDC, 0, 0, width, height, maskDC, |
| 471 |
dest_x - gc->clip_x_origin, dest_y - gc->clip_y_origin, |
| 472 |
SRCAND); |
| 473 |
SelectObject(destDC, bgBrush); |
| 474 |
BitBlt(destDC, dest_x, dest_y, width, height, memDC, 0, 0, |
| 475 |
MASKPAT); |
| 476 |
|
| 477 |
TkWinReleaseDrawableDC(clipPtr->value.pixmap, maskDC, &maskState); |
| 478 |
SelectObject(destDC, oldBrush); |
| 479 |
DeleteDC(memDC); |
| 480 |
DeleteObject(bitmap); |
| 481 |
DeleteObject(fgBrush); |
| 482 |
DeleteObject(bgBrush); |
| 483 |
} |
| 484 |
} |
| 485 |
if (src != dest) { |
| 486 |
TkWinReleaseDrawableDC(dest, destDC, &destState); |
| 487 |
} |
| 488 |
TkWinReleaseDrawableDC(src, srcDC, &srcState); |
| 489 |
} |
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
void |
| 509 |
TkPutImage(colors, ncolors, display, d, gc, image, src_x, src_y, dest_x, |
| 510 |
dest_y, width, height) |
| 511 |
unsigned long *colors; |
| 512 |
|
| 513 |
int ncolors; |
| 514 |
Display* display; |
| 515 |
Drawable d; |
| 516 |
GC gc; |
| 517 |
XImage* image; |
| 518 |
int src_x, src_y; |
| 519 |
int dest_x, dest_y; |
| 520 |
|
| 521 |
unsigned int width, height; |
| 522 |
{ |
| 523 |
HDC dc, dcMem; |
| 524 |
TkWinDCState state; |
| 525 |
BITMAPINFO *infoPtr; |
| 526 |
HBITMAP bitmap; |
| 527 |
char *data; |
| 528 |
|
| 529 |
display->request++; |
| 530 |
|
| 531 |
dc = TkWinGetDrawableDC(display, d, &state); |
| 532 |
SetROP2(dc, tkpWinRopModes[gc->function]); |
| 533 |
dcMem = CreateCompatibleDC(dc); |
| 534 |
|
| 535 |
if (image->bits_per_pixel == 1) { |
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
if ((image->bitmap_bit_order != MSBFirst) |
| 542 |
|| (image->bitmap_pad != sizeof(WORD))) { |
| 543 |
data = TkAlignImageData(image, sizeof(WORD), MSBFirst); |
| 544 |
bitmap = CreateBitmap(image->width, image->height, 1, 1, data); |
| 545 |
ckfree(data); |
| 546 |
} else { |
| 547 |
bitmap = CreateBitmap(image->width, image->height, 1, 1, |
| 548 |
image->data); |
| 549 |
} |
| 550 |
SetTextColor(dc, gc->foreground); |
| 551 |
SetBkColor(dc, gc->background); |
| 552 |
} else { |
| 553 |
int i, usePalette; |
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
usePalette = (image->bits_per_pixel < 16); |
| 560 |
|
| 561 |
if (usePalette) { |
| 562 |
infoPtr = (BITMAPINFO*) ckalloc(sizeof(BITMAPINFOHEADER) |
| 563 |
+ sizeof(RGBQUAD)*ncolors); |
| 564 |
} else { |
| 565 |
infoPtr = (BITMAPINFO*) ckalloc(sizeof(BITMAPINFOHEADER)); |
| 566 |
} |
| 567 |
|
| 568 |
infoPtr->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
| 569 |
infoPtr->bmiHeader.biWidth = image->width; |
| 570 |
infoPtr->bmiHeader.biHeight = -image->height; |
| 571 |
infoPtr->bmiHeader.biPlanes = 1; |
| 572 |
infoPtr->bmiHeader.biBitCount = image->bits_per_pixel; |
| 573 |
infoPtr->bmiHeader.biCompression = BI_RGB; |
| 574 |
infoPtr->bmiHeader.biSizeImage = 0; |
| 575 |
infoPtr->bmiHeader.biXPelsPerMeter = 0; |
| 576 |
infoPtr->bmiHeader.biYPelsPerMeter = 0; |
| 577 |
infoPtr->bmiHeader.biClrImportant = 0; |
| 578 |
|
| 579 |
if (usePalette) { |
| 580 |
infoPtr->bmiHeader.biClrUsed = ncolors; |
| 581 |
for (i = 0; i < ncolors; i++) { |
| 582 |
infoPtr->bmiColors[i].rgbBlue = GetBValue(colors[i]); |
| 583 |
infoPtr->bmiColors[i].rgbGreen = GetGValue(colors[i]); |
| 584 |
infoPtr->bmiColors[i].rgbRed = GetRValue(colors[i]); |
| 585 |
infoPtr->bmiColors[i].rgbReserved = 0; |
| 586 |
} |
| 587 |
} else { |
| 588 |
infoPtr->bmiHeader.biClrUsed = 0; |
| 589 |
} |
| 590 |
bitmap = CreateDIBitmap(dc, &infoPtr->bmiHeader, CBM_INIT, |
| 591 |
image->data, infoPtr, DIB_RGB_COLORS); |
| 592 |
ckfree((char *) infoPtr); |
| 593 |
} |
| 594 |
if(!bitmap) { |
| 595 |
panic("Fail to allocate bitmap\n"); |
| 596 |
DeleteDC(dcMem); |
| 597 |
TkWinReleaseDrawableDC(d, dc, &state); |
| 598 |
return; |
| 599 |
} |
| 600 |
bitmap = SelectObject(dcMem, bitmap); |
| 601 |
BitBlt(dc, dest_x, dest_y, width, height, dcMem, src_x, src_y, SRCCOPY); |
| 602 |
DeleteObject(SelectObject(dcMem, bitmap)); |
| 603 |
DeleteDC(dcMem); |
| 604 |
TkWinReleaseDrawableDC(d, dc, &state); |
| 605 |
} |
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
void |
| 624 |
XFillRectangles(display, d, gc, rectangles, nrectangles) |
| 625 |
Display* display; |
| 626 |
Drawable d; |
| 627 |
GC gc; |
| 628 |
XRectangle* rectangles; |
| 629 |
int nrectangles; |
| 630 |
{ |
| 631 |
HDC dc; |
| 632 |
int i; |
| 633 |
RECT rect; |
| 634 |
TkWinDCState state; |
| 635 |
HBRUSH brush, oldBrush; |
| 636 |
|
| 637 |
if (d == None) { |
| 638 |
return; |
| 639 |
} |
| 640 |
|
| 641 |
dc = TkWinGetDrawableDC(display, d, &state); |
| 642 |
SetROP2(dc, tkpWinRopModes[gc->function]); |
| 643 |
brush = CreateSolidBrush(gc->foreground); |
| 644 |
|
| 645 |
if ((gc->fill_style == FillStippled |
| 646 |
|| gc->fill_style == FillOpaqueStippled) |
| 647 |
&& gc->stipple != None) { |
| 648 |
TkWinDrawable *twdPtr = (TkWinDrawable *)gc->stipple; |
| 649 |
HBRUSH stipple; |
| 650 |
HBITMAP oldBitmap, bitmap; |
| 651 |
HDC dcMem; |
| 652 |
HBRUSH bgBrush = CreateSolidBrush(gc->background); |
| 653 |
|
| 654 |
if (twdPtr->type != TWD_BITMAP) { |
| 655 |
panic("unexpected drawable type in stipple"); |
| 656 |
} |
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
stipple = CreatePatternBrush(twdPtr->bitmap.handle); |
| 663 |
SetBrushOrgEx(dc, gc->ts_x_origin, gc->ts_y_origin, NULL); |
| 664 |
oldBrush = SelectObject(dc, stipple); |
| 665 |
dcMem = CreateCompatibleDC(dc); |
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
for (i = 0; i < nrectangles; i++) { |
| 674 |
bitmap = CreateCompatibleBitmap(dc, rectangles[i].width, |
| 675 |
rectangles[i].height); |
| 676 |
oldBitmap = SelectObject(dcMem, bitmap); |
| 677 |
rect.left = 0; |
| 678 |
rect.top = 0; |
| 679 |
rect.right = rectangles[i].width; |
| 680 |
rect.bottom = rectangles[i].height; |
| 681 |
FillRect(dcMem, &rect, brush); |
| 682 |
BitBlt(dc, rectangles[i].x, rectangles[i].y, rectangles[i].width, |
| 683 |
rectangles[i].height, dcMem, 0, 0, COPYFG); |
| 684 |
if (gc->fill_style == FillOpaqueStippled) { |
| 685 |
FillRect(dcMem, &rect, bgBrush); |
| 686 |
BitBlt(dc, rectangles[i].x, rectangles[i].y, |
| 687 |
rectangles[i].width, rectangles[i].height, dcMem, |
| 688 |
0, 0, COPYBG); |
| 689 |
} |
| 690 |
SelectObject(dcMem, oldBitmap); |
| 691 |
DeleteObject(bitmap); |
| 692 |
} |
| 693 |
|
| 694 |
DeleteDC(dcMem); |
| 695 |
SelectObject(dc, oldBrush); |
| 696 |
DeleteObject(stipple); |
| 697 |
DeleteObject(bgBrush); |
| 698 |
} else { |
| 699 |
if (gc->function == GXcopy) { |
| 700 |
for (i = 0; i < nrectangles; i++) { |
| 701 |
rect.left = rectangles[i].x; |
| 702 |
rect.right = rect.left + rectangles[i].width; |
| 703 |
rect.top = rectangles[i].y; |
| 704 |
rect.bottom = rect.top + rectangles[i].height; |
| 705 |
FillRect(dc, &rect, brush); |
| 706 |
} |
| 707 |
} else { |
| 708 |
HPEN newPen = CreatePen(PS_NULL, 0, gc->foreground); |
| 709 |
HPEN oldPen = SelectObject(dc, newPen); |
| 710 |
oldBrush = SelectObject(dc, brush); |
| 711 |
|
| 712 |
for (i = 0; i < nrectangles; i++) { |
| 713 |
Rectangle(dc, rectangles[i].x, rectangles[i].y, |
| 714 |
rectangles[i].x + rectangles[i].width + 1, |
| 715 |
rectangles[i].y + rectangles[i].height + 1); |
| 716 |
} |
| 717 |
|
| 718 |
SelectObject(dc, oldBrush); |
| 719 |
SelectObject(dc, oldPen); |
| 720 |
DeleteObject(newPen); |
| 721 |
} |
| 722 |
} |
| 723 |
DeleteObject(brush); |
| 724 |
TkWinReleaseDrawableDC(d, dc, &state); |
| 725 |
} |
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
|
| 738 |
|
| 739 |
|
| 740 |
|
| 741 |
|
| 742 |
|
| 743 |
|
| 744 |
static void |
| 745 |
RenderObject(dc, gc, points, npoints, mode, pen, func) |
| 746 |
HDC dc; |
| 747 |
GC gc; |
| 748 |
XPoint* points; |
| 749 |
int npoints; |
| 750 |
int mode; |
| 751 |
HPEN pen; |
| 752 |
WinDrawFunc func; |
| 753 |
{ |
| 754 |
RECT rect; |
| 755 |
HPEN oldPen; |
| 756 |
HBRUSH oldBrush; |
| 757 |
POINT *winPoints = ConvertPoints(points, npoints, mode, &rect); |
| 758 |
|
| 759 |
if ((gc->fill_style == FillStippled |
| 760 |
|| gc->fill_style == FillOpaqueStippled) |
| 761 |
&& gc->stipple != None) { |
| 762 |
|
| 763 |
TkWinDrawable *twdPtr = (TkWinDrawable *)gc->stipple; |
| 764 |
HDC dcMem; |
| 765 |
LONG width, height; |
| 766 |
HBITMAP oldBitmap; |
| 767 |
int i; |
| 768 |
HBRUSH oldMemBrush; |
| 769 |
|
| 770 |
if (twdPtr->type != TWD_BITMAP) { |
| 771 |
panic("unexpected drawable type in stipple"); |
| 772 |
} |
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
rect.left -= gc->line_width; |
| 779 |
rect.top -= gc->line_width; |
| 780 |
rect.right += gc->line_width; |
| 781 |
rect.bottom += gc->line_width; |
| 782 |
|
| 783 |
width = rect.right - rect.left; |
| 784 |
height = rect.bottom - rect.top; |
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
SetBrushOrgEx(dc, gc->ts_x_origin, gc->ts_y_origin, NULL); |
| 791 |
oldBrush = SelectObject(dc, CreatePatternBrush(twdPtr->bitmap.handle)); |
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
dcMem = CreateCompatibleDC(dc); |
| 799 |
oldBitmap = SelectObject(dcMem, CreateCompatibleBitmap(dc, width, |
| 800 |
height)); |
| 801 |
oldPen = SelectObject(dcMem, pen); |
| 802 |
BitBlt(dcMem, 0, 0, width, height, dc, rect.left, rect.top, SRCCOPY); |
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
for (i = 0; i < npoints; i++) { |
| 810 |
winPoints[i].x -= rect.left; |
| 811 |
winPoints[i].y -= rect.top; |
| 812 |
} |
| 813 |
|
| 814 |
|
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
SetPolyFillMode(dcMem, (gc->fill_rule == EvenOddRule) ? ALTERNATE |
| 820 |
: WINDING); |
| 821 |
oldMemBrush = SelectObject(dcMem, CreateSolidBrush(gc->foreground)); |
| 822 |
(*func)(dcMem, winPoints, npoints); |
| 823 |
BitBlt(dc, rect.left, rect.top, width, height, dcMem, 0, 0, COPYFG); |
| 824 |
|
| 825 |
|
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
if (gc->fill_style == FillOpaqueStippled) { |
| 832 |
DeleteObject(SelectObject(dcMem, |
| 833 |
CreateSolidBrush(gc->background))); |
| 834 |
(*func)(dcMem, winPoints, npoints); |
| 835 |
BitBlt(dc, rect.left, rect.top, width, height, dcMem, 0, 0, |
| 836 |
COPYBG); |
| 837 |
} |
| 838 |
|
| 839 |
SelectObject(dcMem, oldPen); |
| 840 |
DeleteObject(SelectObject(dcMem, oldMemBrush)); |
| 841 |
DeleteObject(SelectObject(dcMem, oldBitmap)); |
| 842 |
DeleteDC(dcMem); |
| 843 |
} else { |
| 844 |
oldPen = SelectObject(dc, pen); |
| 845 |
oldBrush = SelectObject(dc, CreateSolidBrush(gc->foreground)); |
| 846 |
SetROP2(dc, tkpWinRopModes[gc->function]); |
| 847 |
|
| 848 |
SetPolyFillMode(dc, (gc->fill_rule == EvenOddRule) ? ALTERNATE |
| 849 |
: WINDING); |
| 850 |
|
| 851 |
(*func)(dc, winPoints, npoints); |
| 852 |
|
| 853 |
SelectObject(dc, oldPen); |
| 854 |
} |
| 855 |
DeleteObject(SelectObject(dc, oldBrush)); |
| 856 |
} |
| 857 |
|
| 858 |
|
| 859 |
|
| 860 |
|
| 861 |
|
| 862 |
|
| 863 |
|
| 864 |
|
| 865 |
|
| 866 |
|
| 867 |
|
| 868 |
|
| 869 |
|
| 870 |
|
| 871 |
|
| 872 |
|
| 873 |
|
| 874 |
void |
| 875 |
XDrawLines(display, d, gc, points, npoints, mode) |
| 876 |
Display* display; |
| 877 |
Drawable d; |
| 878 |
GC gc; |
| 879 |
XPoint* points; |
| 880 |
int npoints; |
| 881 |
int mode; |
| 882 |
{ |
| 883 |
HPEN pen; |
| 884 |
TkWinDCState state; |
| 885 |
HDC dc; |
| 886 |
|
| 887 |
if (d == None) { |
| 888 |
return; |
| 889 |
} |
| 890 |
|
| 891 |
dc = TkWinGetDrawableDC(display, d, &state); |
| 892 |
|
| 893 |
pen = SetUpGraphicsPort(gc); |
| 894 |
SetBkMode(dc, TRANSPARENT); |
| 895 |
RenderObject(dc, gc, points, npoints, mode, pen, Polyline); |
| 896 |
DeleteObject(pen); |
| 897 |
|
| 898 |
TkWinReleaseDrawableDC(d, dc, &state); |
| 899 |
} |
| 900 |
|
| 901 |
|
| 902 |
void XDrawPoints(display, d, gc, points, npoints, mode) |
| 903 |
Display* display; |
| 904 |
Drawable d; |
| 905 |
GC gc; |
| 906 |
XPoint* points; |
| 907 |
int npoints; |
| 908 |
int mode; |
| 909 |
{ |
| 910 |
int i; |
| 911 |
|
| 912 |
for (i=0; i<npoints; i++) { |
| 913 |
XDrawLine(display, d, gc, points[i].x, points[i].y, |
| 914 |
points[i].x, points[i].y); |
| 915 |
} |
| 916 |
} |
| 917 |
|
| 918 |
|
| 919 |
|
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
|
| 925 |
|
| 926 |
|
| 927 |
|
| 928 |
|
| 929 |
|
| 930 |
|
| 931 |
|
| 932 |
|
| 933 |
|
| 934 |
void |
| 935 |
XFillPolygon(display, d, gc, points, npoints, shape, mode) |
| 936 |
Display* display; |
| 937 |
Drawable d; |
| 938 |
GC gc; |
| 939 |
XPoint* points; |
| 940 |
int npoints; |
| 941 |
int shape; |
| 942 |
int mode; |
| 943 |
{ |
| 944 |
HPEN pen; |
| 945 |
TkWinDCState state; |
| 946 |
HDC dc; |
| 947 |
|
| 948 |
if (d == None) { |
| 949 |
return; |
| 950 |
} |
| 951 |
|
| 952 |
dc = TkWinGetDrawableDC(display, d, &state); |
| 953 |
|
| 954 |
pen = GetStockObject(NULL_PEN); |
| 955 |
RenderObject(dc, gc, points, npoints, mode, pen, Polygon); |
| 956 |
|
| 957 |
TkWinReleaseDrawableDC(d, dc, &state); |
| 958 |
} |
| 959 |
|
| 960 |
|
| 961 |
|
| 962 |
|
| 963 |
|
| 964 |
|
| 965 |
|
| 966 |
|
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
|
| 971 |
|
| 972 |
|
| 973 |
|
| 974 |
|
| 975 |
|
| 976 |
void |
| 977 |
XDrawRectangle(display, d, gc, x, y, width, height) |
| 978 |
Display* display; |
| 979 |
Drawable d; |
| 980 |
GC gc; |
| 981 |
int x; |
| 982 |
int y; |
| 983 |
unsigned int width; |
| 984 |
unsigned int height; |
| 985 |
{ |
| 986 |
HPEN pen, oldPen; |
| 987 |
TkWinDCState state; |
| 988 |
HBRUSH oldBrush; |
| 989 |
HDC dc; |
| 990 |
|
| 991 |
if (d == None) { |
| 992 |
return; |
| 993 |
} |
| 994 |
|
| 995 |
dc = TkWinGetDrawableDC(display, d, &state); |
| 996 |
|
| 997 |
pen = SetUpGraphicsPort(gc); |
| 998 |
SetBkMode(dc, TRANSPARENT); |
| 999 |
oldPen = SelectObject(dc, pen); |
| 1000 |
oldBrush = SelectObject(dc, GetStockObject(NULL_BRUSH)); |
| 1001 |
SetROP2(dc, tkpWinRopModes[gc->function]); |
| 1002 |
|
| 1003 |
Rectangle(dc, x, y, x+width+1, y+height+1); |
| 1004 |
|
| 1005 |
DeleteObject(SelectObject(dc, oldPen)); |
| 1006 |
SelectObject(dc, oldBrush); |
| 1007 |
TkWinReleaseDrawableDC(d, dc, &state); |
| 1008 |
} |
| 1009 |
|
| 1010 |
|
| 1011 |
|
| 1012 |
|
| 1013 |
|
| 1014 |
|
| 1015 |
|
| 1016 |
|
| 1017 |
|
| 1018 |
|
| 1019 |
|
| 1020 |
|
| 1021 |
|
| 1022 |
|
| 1023 |
|
| 1024 |
|
| 1025 |
|
| 1026 |
void |
| 1027 |
XDrawArc(display, d, gc, x, y, width, height, start, extent) |
| 1028 |
Display* display; |
| 1029 |
Drawable d; |
| 1030 |
GC gc; |
| 1031 |
int x; |
| 1032 |
int y; |
| 1033 |
unsigned int width; |
| 1034 |
unsigned int height; |
| 1035 |
int start; |
| 1036 |
int extent; |
| 1037 |
{ |
| 1038 |
display->request++; |
| 1039 |
|
| 1040 |
DrawOrFillArc(display, d, gc, x, y, width, height, start, extent, 0); |
| 1041 |
} |
| 1042 |
|
| 1043 |
|
| 1044 |
|
| 1045 |
|
| 1046 |
|
| 1047 |
|
| 1048 |
|
| 1049 |
|
| 1050 |
|
| 1051 |
|
| 1052 |
|
| 1053 |
|
| 1054 |
|
| 1055 |
|
| 1056 |
|
| 1057 |
|
| 1058 |
|
| 1059 |
void |
| 1060 |
XFillArc(display, d, gc, x, y, width, height, start, extent) |
| 1061 |
Display* display; |
| 1062 |
Drawable d; |
| 1063 |
GC gc; |
| 1064 |
int x; |
| 1065 |
int y; |
| 1066 |
unsigned int width; |
| 1067 |
unsigned int height; |
| 1068 |
int start; |
| 1069 |
int extent; |
| 1070 |
{ |
| 1071 |
display->request++; |
| 1072 |
|
| 1073 |
DrawOrFillArc(display, d, gc, x, y, width, height, start, extent, 1); |
| 1074 |
} |
| 1075 |
|
| 1076 |
|
| 1077 |
|
| 1078 |
|
| 1079 |
|
| 1080 |
|
| 1081 |
|
| 1082 |
|
| 1083 |
|
| 1084 |
|
| 1085 |
|
| 1086 |
|
| 1087 |
|
| 1088 |
|
| 1089 |
|
| 1090 |
|
| 1091 |
|
| 1092 |
|
| 1093 |
static void |
| 1094 |
DrawOrFillArc(display, d, gc, x, y, width, height, start, extent, fill) |
| 1095 |
Display *display; |
| 1096 |
Drawable d; |
| 1097 |
GC gc; |
| 1098 |
int x, y; |
| 1099 |
unsigned int width, height; |
| 1100 |
int start; |
| 1101 |
int extent; |
| 1102 |
int fill; |
| 1103 |
{ |
| 1104 |
HDC dc; |
| 1105 |
HBRUSH brush, oldBrush; |
| 1106 |
HPEN pen, oldPen; |
| 1107 |
TkWinDCState state; |
| 1108 |
int clockwise = (extent < 0); |
| 1109 |
int xstart, ystart, xend, yend; |
| 1110 |
double radian_start, radian_end, xr, yr; |
| 1111 |
|
| 1112 |
if (d == None) { |
| 1113 |
return; |
| 1114 |
} |
| 1115 |
|
| 1116 |
dc = TkWinGetDrawableDC(display, d, &state); |
| 1117 |
|
| 1118 |
SetROP2(dc, tkpWinRopModes[gc->function]); |
| 1119 |
|
| 1120 |
|
| 1121 |
|
| 1122 |
|
| 1123 |
|
| 1124 |
|
| 1125 |
start = start % (64*360); |
| 1126 |
if (start < 0) { |
| 1127 |
start += (64*360); |
| 1128 |
} |
| 1129 |
extent = (start+extent) % (64*360); |
| 1130 |
if (extent < 0) { |
| 1131 |
extent += (64*360); |
| 1132 |
} |
| 1133 |
if (clockwise) { |
| 1134 |
int tmp = start; |
| 1135 |
start = extent; |
| 1136 |
extent = tmp; |
| 1137 |
} |
| 1138 |
radian_start = XAngleToRadians(start); |
| 1139 |
radian_end = XAngleToRadians(extent); |
| 1140 |
|
| 1141 |
|
| 1142 |
|
| 1143 |
|
| 1144 |
|
| 1145 |
|
| 1146 |
|
| 1147 |
xr = x + width / 2.0; |
| 1148 |
yr = y + height / 2.0; |
| 1149 |
xstart = (int)((xr + cos(radian_start)*width/2.0) + 0.5); |
| 1150 |
ystart = (int)((yr + sin(-radian_start)*height/2.0) + 0.5); |
| 1151 |
xend = (int)((xr + cos(radian_end)*width/2.0) + 0.5); |
| 1152 |
yend = (int)((yr + sin(-radian_end)*height/2.0) + 0.5); |
| 1153 |
|
| 1154 |
|
| 1155 |
|
| 1156 |
|
| 1157 |
|
| 1158 |
|
| 1159 |
|
| 1160 |
pen = SetUpGraphicsPort(gc); |
| 1161 |
oldPen = SelectObject(dc, pen); |
| 1162 |
if (!fill) { |
| 1163 |
|
| 1164 |
|
| 1165 |
|
| 1166 |
|
| 1167 |
|
| 1168 |
|
| 1169 |
SetBkMode(dc, TRANSPARENT); |
| 1170 |
Arc(dc, x, y, x+width+1, y+height+1, xstart, ystart, xend, yend); |
| 1171 |
} else { |
| 1172 |
brush = CreateSolidBrush(gc->foreground); |
| 1173 |
oldBrush = SelectObject(dc, brush); |
| 1174 |
if (gc->arc_mode == ArcChord) { |
| 1175 |
Chord(dc, x, y, x+width+1, y+height+1, xstart, ystart, xend, yend); |
| 1176 |
} else if ( gc->arc_mode == ArcPieSlice ) { |
| 1177 |
Pie(dc, x, y, x+width+1, y+height+1, xstart, ystart, xend, yend); |
| 1178 |
} |
| 1179 |
DeleteObject(SelectObject(dc, oldBrush)); |
| 1180 |
} |
| 1181 |
DeleteObject(SelectObject(dc, oldPen)); |
| 1182 |
TkWinReleaseDrawableDC(d, dc, &state); |
| 1183 |
} |
| 1184 |
|
| 1185 |
|
| 1186 |
|
| 1187 |
|
| 1188 |
|
| 1189 |
|
| 1190 |
|
| 1191 |
|
| 1192 |
|
| 1193 |
|
| 1194 |
|
| 1195 |
|
| 1196 |
|
| 1197 |
|
| 1198 |
|
| 1199 |
|
| 1200 |
|
| 1201 |
static HPEN |
| 1202 |
SetUpGraphicsPort(gc) |
| 1203 |
GC gc; |
| 1204 |
{ |
| 1205 |
DWORD style; |
| 1206 |
|
| 1207 |
if (gc->line_style == LineOnOffDash) { |
| 1208 |
unsigned char *p = (unsigned char *) &(gc->dashes); |
| 1209 |
|
| 1210 |
|
| 1211 |
|
| 1212 |
|
| 1213 |
|
| 1214 |
|
| 1215 |
|
| 1216 |
|
| 1217 |
|
| 1218 |
if (p[1] && p[2]) { |
| 1219 |
if (!p[3] || p[4]) { |
| 1220 |
style = PS_DASHDOTDOT; |
| 1221 |
} else { |
| 1222 |
style = PS_DASHDOT; |
| 1223 |
} |
| 1224 |
} else { |
| 1225 |
if (p[0] > (4 * gc->line_width)) { |
| 1226 |
style = PS_DASH; |
| 1227 |
} else { |
| 1228 |
style = PS_DOT; |
| 1229 |
} |
| 1230 |
} |
| 1231 |
} else { |
| 1232 |
style = PS_SOLID; |
| 1233 |
} |
| 1234 |
if (gc->line_width < 2) { |
| 1235 |
return CreatePen(style, gc->line_width, gc->foreground); |
| 1236 |
} else { |
| 1237 |
LOGBRUSH lb; |
| 1238 |
|
| 1239 |
lb.lbStyle = BS_SOLID; |
| 1240 |
lb.lbColor = gc->foreground; |
| 1241 |
lb.lbHatch = 0; |
| 1242 |
|
| 1243 |
style |= PS_GEOMETRIC; |
| 1244 |
switch (gc->cap_style) { |
| 1245 |
case CapNotLast: |
| 1246 |
case CapButt: |
| 1247 |
style |= PS_ENDCAP_FLAT; |
| 1248 |
break; |
| 1249 |
case CapRound: |
| 1250 |
style |= PS_ENDCAP_ROUND; |
| 1251 |
break; |
| 1252 |
default: |
| 1253 |
style |= PS_ENDCAP_SQUARE; |
| 1254 |
break; |
| 1255 |
} |
| 1256 |
switch (gc->join_style) { |
| 1257 |
case JoinMiter: |
| 1258 |
style |= PS_JOIN_MITER; |
| 1259 |
break; |
| 1260 |
case JoinRound: |
| 1261 |
style |= PS_JOIN_ROUND; |
| 1262 |
break; |
| 1263 |
default: |
| 1264 |
style |= PS_JOIN_BEVEL; |
| 1265 |
break; |
| 1266 |
} |
| 1267 |
return ExtCreatePen(style, gc->line_width, &lb, 0, NULL); |
| 1268 |
} |
| 1269 |
} |
| 1270 |
|
| 1271 |
|
| 1272 |
|
| 1273 |
|
| 1274 |
|
| 1275 |
|
| 1276 |
|
| 1277 |
|
| 1278 |
|
| 1279 |
|
| 1280 |
|
| 1281 |
|
| 1282 |
|
| 1283 |
|
| 1284 |
|
| 1285 |
|
| 1286 |
|
| 1287 |
|
| 1288 |
|
| 1289 |
|
| 1290 |
int |
| 1291 |
TkScrollWindow(tkwin, gc, x, y, width, height, dx, dy, damageRgn) |
| 1292 |
Tk_Window tkwin; |
| 1293 |
GC gc; |
| 1294 |
int x, y, width, height; |
| 1295 |
int dx, dy; |
| 1296 |
TkRegion damageRgn; |
| 1297 |
{ |
| 1298 |
HWND hwnd = TkWinGetHWND(Tk_WindowId(tkwin)); |
| 1299 |
RECT scrollRect; |
| 1300 |
|
| 1301 |
scrollRect.left = x; |
| 1302 |
scrollRect.top = y; |
| 1303 |
scrollRect.right = x + width; |
| 1304 |
scrollRect.bottom = y + height; |
| 1305 |
return (ScrollWindowEx(hwnd, dx, dy, &scrollRect, NULL, (HRGN) damageRgn, |
| 1306 |
NULL, 0) == NULLREGION) ? 0 : 1; |
| 1307 |
} |
| 1308 |
|
| 1309 |
|
| 1310 |
|
| 1311 |
|
| 1312 |
|
| 1313 |
|
| 1314 |
|
| 1315 |
|
| 1316 |
|
| 1317 |
|
| 1318 |
|
| 1319 |
|
| 1320 |
|
| 1321 |
|
| 1322 |
|
| 1323 |
|
| 1324 |
|
| 1325 |
|
| 1326 |
|
| 1327 |
void |
| 1328 |
TkWinFillRect(dc, x, y, width, height, pixel) |
| 1329 |
HDC dc; |
| 1330 |
int x, y, width, height; |
| 1331 |
int pixel; |
| 1332 |
{ |
| 1333 |
RECT rect; |
| 1334 |
COLORREF oldColor; |
| 1335 |
|
| 1336 |
rect.left = x; |
| 1337 |
rect.top = y; |
| 1338 |
rect.right = x + width; |
| 1339 |
rect.bottom = y + height; |
| 1340 |
oldColor = SetBkColor(dc, (COLORREF)pixel); |
| 1341 |
SetBkMode(dc, OPAQUE); |
| 1342 |
ExtTextOut(dc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, NULL); |
| 1343 |
SetBkColor(dc, oldColor); |
| 1344 |
} |
| 1345 |
|
| 1346 |
|
| 1347 |
|
| 1348 |
|
| 1349 |
|
| 1350 |
|
| 1351 |
|
| 1352 |
|
| 1353 |
|
| 1354 |
|
| 1355 |
|
| 1356 |
|
| 1357 |
|
| 1358 |
|
| 1359 |
|
| 1360 |
|
| 1361 |
|
| 1362 |
|
| 1363 |
|
| 1364 |
|
| 1365 |
|
| 1366 |
|
| 1367 |
|
| 1368 |
void |
| 1369 |
TkpDrawHighlightBorder(tkwin, fgGC, bgGC, highlightWidth, drawable) |
| 1370 |
Tk_Window tkwin; |
| 1371 |
GC fgGC; |
| 1372 |
GC bgGC; |
| 1373 |
int highlightWidth; |
| 1374 |
Drawable drawable; |
| 1375 |
{ |
| 1376 |
TkDrawInsetFocusHighlight(tkwin, fgGC, highlightWidth, drawable, 0); |
| 1377 |
} |
| 1378 |
|