File size: 21,566 Bytes
806d4b5 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 |
#help_index "Graphics/Sprite;Sprites"
#define SPBM_EXIT 0
#define SPBM_MAIN_MENU 1
#define SPBM_COLOR 2
#define SPBM_DITHER_COLOR 3
#define SPBM_WIDTH 4
#define SPBM_PT 5
#define SPBM_LINE 6
#define SPBM_ARROW 7
#define SPBM_RECT 8
#define SPBM_CIRCLE 9
#define SPBM_TEXT 10
#define SPBM_TEXT_BOX 11
#define SPBM_TEXT_DIAMOND 12
#define SPBM_FLOOD_FILL 13
#define SPBM_FLOOD_FILL_NOT 14
#define SPBM_POLYLINE 15
#define SPBM_POLYPT 16
#define SPBM_COPY 17
#define SPBM_DELETE 18
#define SPBM_PASTE 19
#define SPBM_PASTE_TRANSPARENT 20
#define SPBM_FIND_AND_REPLACE 21
#define SPBM_TRIM_TO_EXTENTS 22
#define SPBM_ADD_OUTLINE 23
#define SPBM_ETCH 24
#define SPBM_UNDO 25
#define SPBM_SAVE_BMP 26
#define SPBM_SAVE_GRA 27
U0 GrInit4()
{
DefineLstLoad("ST_SPRITE_BITMAP_MENU",
"Exit\0Main Menu\0Color\0Dither Color\0Width\0Point\0Line\0Arrow\0"
"Rect\0Circle\0Text\0Text Box\0Text Diamond\0Flood Fill\0"
"Flood Fill Not Color\0PolyLine\0PolyPoint\0Copy\0Delete\0Paste\0"
"Paste Transparent\0Find and Replace\0Trim to Extents\0Add Outline\0"
"Etch\0Undo\0Save BMP\0Save GR\0");
}
GrInit4;
I64 PopUpSpriteBitMap(CColorROPU32 color,I64 width)
{
I64 res;
U8 *st1,*st2,buf[STR_LEN];
CDoc *doc=DocNew;
Color2Str(buf,color);
if (color&ROPF_DITHER) {
st1="";
st2=buf;
} else {
st1=buf;
st2="";
}
DocPrint(doc,"$PURPLE$$TX+CX,\"Sprite BitMap Menu\"$\n"
"$LK+PU+CX,\"Click for Help\",A=\"FI:::/Doc/SpriteBitMap.DD.Z\"$\n"
"\n$LTBLUE$$MU-UL,\"Color %s\",LE=SPBM_COLOR$\n"
"$MU-UL,\"Dither Color %s\",LE=SPBM_DITHER_COLOR$\n"
"$MU-UL,\"Width %d\",LE=SPBM_WIDTH$\n"
"$MU-UL,\"Find & Replace Color\",LE=SPBM_FIND_AND_REPLACE$\n"
"$MU-UL,\"Trim to Extents\",LE=SPBM_TRIM_TO_EXTENTS$\n"
"$MU-UL,\"Add Outline\",LE=SPBM_ADD_OUTLINE$\n"
"$MU-UL,\"Etch\",LE=SPBM_ETCH$\n"
"\n$MU-UL,\"Point\",LE=SPBM_PT$\n"
"$MU-UL,\"Line\",LE=SPBM_LINE$\n"
"$MU-UL,\"Arrow\",LE=SPBM_ARROW$\n"
"$MU-UL,\"Rect\",LE=SPBM_RECT$\n"
"$MU-UL,\"Circle\",LE=SPBM_CIRCLE$\n"
"$MU-UL,\"Text\",LE=SPBM_TEXT$\n"
"$MU-UL,\"Text Box\",LE=SPBM_TEXT_BOX$\n"
"$MU-UL,\"Text Diamond\",LE=SPBM_TEXT_DIAMOND$\n"
"$MU-UL,\"Flood Fill\",LE=SPBM_FLOOD_FILL$\n"
"$MU-UL,\"Flood Fill Not Color\",LE=SPBM_FLOOD_FILL_NOT$\n"
"$MU-UL,\"PolyLine\",LE=SPBM_POLYLINE$\n"
"$MU-UL,\"PolyPoint\",LE=SPBM_POLYPT$\n"
"\n$MU-UL,\"Copy to Clip\",LE=SPBM_COPY$\n"
"$MU-UL,\"Delete to Clip\",LE=SPBM_DELETE$\n"
"$MU-UL,\"Paste Clip\",LE=SPBM_PASTE$\n"
"$MU-UL,\"Paste Transparent Clip\",LE=SPBM_PASTE_TRANSPARENT$\n"
"\n$MU-UL,\"Save BMP File\",LE=SPBM_SAVE_BMP$\n"
"$MU-UL,\"Save GR File\",LE=SPBM_SAVE_GRA$\n"
"\n$MU-UL,\"Undo\",LE=SPBM_UNDO$\n"
"\n$PURPLE$$MU-UL,\"+] Sprite Main Menu\",LE=SPBM_MAIN_MENU$$LTBLUE$\n"
"$MU-UL,\"Exit Sprite\",LE=SPBM_EXIT$\n"
"$MU-UL,\"Abort Sprite\",LE=DOCM_CANCEL$\n"
"\nRight-Click to get back to this menu.",st1,st2,width);
res=PopUpMenu(doc);
DocDel(doc);
return res;
}
U0 GrBitMapEdPrepPersistentDC(CDC *dc,I64 xx1,I64 yy1,CDC *img)
{
DCFill(dc);
GrBlot(dc,xx1,yy1,img);
}
U0 GrBitMapEdTrimToExtents(CDC **_img,I64 *_xx1,I64 *_yy1,
I64 *_xx2,I64 *_yy2,CColorROPU32 bkcolor)
{
CDC *img=*_img;
I64 i,c,
x1=0,y1=0,x2=img->width-1,y2=img->height-1; //inclusive
while (y1<y2) {
for (i=x1;i<=x2;i++) {
c=GrPeek(img,i,y1);
if (c!=bkcolor&&c!=TRANSPARENT) goto tr_y2;
}
y1++;
}
tr_y2:
while (y1<y2) {
for (i=x1;i<=x2;i++) {
c=GrPeek(img,i,y2);
if (c!=bkcolor&&c!=TRANSPARENT) goto tr_x1;
}
y2--;
}
tr_x1:
while (x1<x2) {
for (i=y1;i<=y2;i++) {
c=GrPeek(img,x1,i);
if (c!=bkcolor&&c!=TRANSPARENT) goto tr_x2;
}
x1++;
}
tr_x2:
while (x1<x2) {
for (i=y1;i<=y2;i++) {
c=GrPeek(img,x2,i);
if (c!=bkcolor&&c!=TRANSPARENT) goto tr_done;
}
x2--;
}
tr_done:
*_img=DCExt(img,x1,y1,x2,y2);
*_xx1+=x1; *_yy1+=y1;
*_xx2+=x2-(img->width-1); *_yy2+=y2-(img->height-1); //not inclusive
DCDel(img);
}
U0 GrBitMapEdAddOutline(CDC *img,I64 width,
CColorROPU32 color,CColorROPU32 bkcolor)
{
I64 i,j,k,c;
CColorROPU32 old_color;
CDC *src;
if (img->width && img->height) {
old_color=img->color;
img->color=color;
while (width-->0) {
src=DCExt(img,0,0,img->width-1,img->height-1);
for (i=0;i<img->height;i++)
for (j=0;j<img->width;j++)
if (GrPeek(src,j,i)==bkcolor)
for (k=0;k<8;k++) {
c=GrPeek(src,j+gr_x_offsets[k],i+gr_y_offsets[k]);
if (c>=0 && c!=bkcolor) {
GrPlot(img,j,i);
break;
}
}
DCDel(src);
}
img->color=old_color;
}
}
U0 GrBitMapEdEtch(CDC *img,I64 width,CColorROPU32 bkcolor)
{
I64 i,j,k,c;
CColorROPU32 old_color;
CDC *src;
if (img->width && img->height) {
old_color=img->color;
img->color=bkcolor;
while (width-->0) {
src=DCExt(img,0,0,img->width-1,img->height-1);
for (i=0;i<img->height;i++)
for (j=0;j<img->width;j++)
if (GrPeek(src,j,i)!=bkcolor)
for (k=0;k<8;k++) {
c=GrPeek(src,j+gr_x_offsets[k],i+gr_y_offsets[k]);
if (c<0 || c==bkcolor) {
GrPlot(img,j,i);
break;
}
}
DCDel(src);
}
img->color=old_color;
}
}
I64 SpriteBitMapEd(CDoc *,CDocEntry *doc_e,CDC *dc,I64 *_xx1,I64 *_yy1,
I64 *_xx2,I64 *_yy2,CDC **_img,CColorROPU32 bkcolor)
{
I64 i,j,mode=SPBM_LINE,color=BLACK,width=1,msg_code,arg1,arg2,x1,y1,x11,y11,
x22,y22,res,xx1=*_xx1,yy1=*_yy1,xx2=*_xx2,yy2=*_yy2,
old_de_flags=doc_e->de_flags;
Bool down=FALSE;
U8 *st=NULL;
CEdFileName filename;
CDC *img=*_img,
*clip=NULL,*undo=NULL,*dc2;
SettingsPush; //See SettingsPush
doc_e->de_flags|=DOCEF_DONT_DRAW;
goto bm_menu;
while (TRUE) {
if (kbd.scan_code&SCF_CTRL)//grab scroll update?
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
dc->color=ROPF_DITHER+WHITE<<16+BLACK;
dc->thick=1;
GrBorder(dc,xx1-1,yy1-1,xx2,yy2);//This is done little bit too often.
while (msg_code=ScanMsg(&arg1,&arg2,1<<MSG_MS_L_DOWN|1<<MSG_MS_L_UP|
1<<MSG_MS_R_DOWN|1<<MSG_MS_MOVE|1<<MSG_KEY_DOWN)) {
switch (msg_code) {
case MSG_KEY_DOWN:
switch (arg1) {
case CH_SHIFT_ESC:
res=SPE_ABORT;
goto bm_key_up_done;
case CH_ESC:
res=SPE_CONT;
goto bm_key_up_done;
case 'c': //eye-dropper
dc2=DCScrnCapture(FALSE);
color=GrPeek(dc2,ms.pos.x,ms.pos.y)^15;//Mouse cursor is XORed.
DCDel(dc2);
break;
case 't': //Set to transparent color
color=TRANSPARENT;
break;
}
break;
case MSG_MS_R_DOWN:
bm_menu:
DCFill(dc);
StrCpy(Fs->task_title,"Sprite BitMap Menu");
i=PopUpSpriteBitMap(color,width);
if (i>=0)
StrCpy(Fs->task_title,DefineSub(i,"ST_SPRITE_BITMAP_MENU"));
switch (i) {
case DOCM_CANCEL:
res=SPE_ABORT;
goto bm_done;
case SPBM_EXIT:
res=SPE_EXIT;
goto bm_done;
case SPBM_MAIN_MENU:
res=SPE_CONT;
goto bm_done;
case SPBM_COLOR:
i=PopUpColor(,,FALSE);
if (i>=0) color=i;
goto bm_menu;
case SPBM_FIND_AND_REPLACE:
i=PopUpColor("Find Color\n",,FALSE);
if (i>=0) {
j=PopUpColor("Replace Color\n",,FALSE);
if (j>=0) {
DCColorChg(img,i,j);
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
}
}
goto bm_menu;
case SPBM_TRIM_TO_EXTENTS:
GrBitMapEdTrimToExtents(&img,&xx1,&yy1,&xx2,&yy2,bkcolor);
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
goto bm_menu;
case SPBM_ADD_OUTLINE:
i=PopUpRangeI64(1,16,1,"Outline Width\n");
if (i>=0) {
GrBitMapEdAddOutline(img,i,color,bkcolor);
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
}
goto bm_menu;
case SPBM_ETCH:
i=PopUpRangeI64(1,16,1,"Etch Width\n");
if (i>=0) {
GrBitMapEdEtch(img,i,bkcolor);
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
}
goto bm_menu;
case SPBM_SAVE_BMP:
*filename.name=0;
if (DocForm(&filename) && *filename.name)
BMPWrite(filename.name,img);
goto bm_menu;
case SPBM_SAVE_GRA:
*filename.name=0;
if (DocForm(&filename) && *filename.name)
GRWrite(filename.name,img,DCSF_COMPRESSED|DCSF_PALETTE_GET);
goto bm_menu;
case SPBM_DITHER_COLOR:
i=PopUpColorDither;
if (i>=0) color=i;
goto bm_menu;
case SPBM_WIDTH:
i=PopUpRangeI64(1,16,1,"Thick\n");
if (i>=0) width=i;
goto bm_menu;
case SPBM_UNDO:
if (undo) {
DCFill(img,bkcolor);
img->color=ROP_EQU;
GrBlot(img,0,0,undo);
DCDel(undo);
undo=NULL;
}
goto bm_menu;
case SPBM_PT:
case SPBM_LINE:
case SPBM_ARROW:
case SPBM_RECT:
case SPBM_CIRCLE:
case SPBM_FLOOD_FILL:
case SPBM_FLOOD_FILL_NOT:
case SPBM_POLYPT:
case SPBM_POLYLINE:
case SPBM_COPY:
case SPBM_DELETE:
case SPBM_PASTE:
case SPBM_PASTE_TRANSPARENT:
mode=i;
break;
case SPBM_TEXT:
case SPBM_TEXT_BOX:
case SPBM_TEXT_DIAMOND:
Free(st);
st=PopUpGetStr("Enter text and press <ESC>.\n");
if (st && *st)
mode=i;
else
goto bm_menu;
break;
}
DCDel(undo);
undo=DCExt(img,0,0,img->width-1,img->height-1);
undo->bkcolor=bkcolor;
Refresh(2,TRUE); //Let popup close
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
down=FALSE;
break;
case MSG_MS_L_DOWN:
switch (mode) {
case SPBM_PT:
img->color=color;
img->thick=width;
GrPlot3(img,arg1-xx1,arg2-yy1,0);
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
break;
start:
if (down)
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
x1=arg1; y1=arg2;
down=TRUE;
dc->color=color;
dc->thick=width;
case SPBM_LINE:
GrLine3(dc,x1,y1,0,arg1,arg2,0);
break;
case SPBM_ARROW:
GrArrow3(dc,x1,y1,0,arg1,arg2,0);
break;
case SPBM_RECT:
GrRect(dc,x1,y1,1,1);
break;
case SPBM_CIRCLE:
GrCircle3(dc,x1,y1,0,1);
break;
case SPBM_COPY:
case SPBM_DELETE:
dc->color=ROPF_DITHER+WHITE<<16+BLACK;
dc->thick=1;
GrBorder(dc,x1,y1,x1,y1);
break;
end:
break;
case SPBM_PASTE:
case SPBM_PASTE_TRANSPARENT:
if (clip) {
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
if (mode==SPBM_PASTE) {
clip->flags|=DCF_NO_TRANSPARENTS;
GrBlot(dc,arg1,arg2,clip);
clip->flags&=~DCF_NO_TRANSPARENTS;
} else {
dc2=DCCopy(clip);
DCColorChg(dc2,bkcolor);
GrBlot(dc,arg1,arg2,dc2);
DCDel(dc2);
}
}
break;
case SPBM_TEXT:
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
dc->color=color;
GrPrint(dc,arg1,arg2,"%s",st);
break;
case SPBM_TEXT_BOX:
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
dc->color=color;
GrTextBox3(dc,arg1,arg2,0,st);
break;
case SPBM_TEXT_DIAMOND:
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
dc->color=color;
GrTextDiamond3(dc,arg1,arg2,0,st);
break;
case SPBM_FLOOD_FILL:
img->color=color;
GrFloodFill(img,arg1-xx1,arg2-yy1);
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
break;
case SPBM_FLOOD_FILL_NOT:
img->color=color;
GrFloodFill(img,arg1-xx1,arg2-yy1,TRUE);
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
break;
case SPBM_POLYLINE:
if (!down) {
x1=arg1; y1=arg2;
down=TRUE;
dc->color=color;
dc->thick=width;
GrLine3(dc,x1,y1,0,arg1,arg2,0);
}
break;
case SPBM_POLYPT:
x1=arg1; y1=arg2;
down=TRUE;
img->color=color;
img->thick=width;
GrLine3(img,x1-xx1,y1-yy1,0,arg1-xx1,arg2-yy1,0);
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
break;
}
break;
case MSG_MS_MOVE:
switch (mode) {
case SPBM_LINE:
case SPBM_ARROW:
case SPBM_POLYLINE:
if (down) {
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
dc->color=color;
dc->thick=width;
if (mode==SPBM_ARROW)
GrArrow3(dc,x1,y1,0,arg1,arg2,0);
else
GrLine3(dc,x1,y1,0,arg1,arg2,0);
}
break;
case SPBM_RECT:
if (down) {
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
if (x1<arg1) {
x11=x1;
x22=arg1;
} else {
x11=arg1;
x22=x1;
}
if (y1<arg2) {
y11=y1;
y22=arg2;
} else {
y11=arg2;
y22=y1;
}
dc->color=color;
GrRect(dc,x11,y11,x22-x11+1,y22-y11+1);
}
break;
case SPBM_COPY:
case SPBM_DELETE:
if (down) {
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
if (x1<arg1) {
x11=x1;
x22=arg1;
} else {
x11=arg1;
x22=x1;
}
if (y1<arg2) {
y11=y1;
y22=arg2;
} else {
y11=arg2;
y22=y1;
}
dc->color=ROPF_DITHER+WHITE<<16+BLACK;
dc->thick=1;
GrBorder(dc,x11,y11,x22,y22);
}
break;
case SPBM_CIRCLE:
if (down) {
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
dc->color=color;
dc->thick=width;
GrCircle3(dc,x1,y1,0,Sqrt(SqrI64(arg1-x1)+SqrI64(arg2-y1)));
}
break;
case SPBM_PASTE:
case SPBM_PASTE_TRANSPARENT:
if (clip) {
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
if (mode==SPBM_PASTE) {
clip->flags|=DCF_NO_TRANSPARENTS;
GrBlot(dc,arg1,arg2,clip);
clip->flags&=~DCF_NO_TRANSPARENTS;
} else {
dc2=DCCopy(clip);
DCColorChg(dc2,bkcolor);
GrBlot(dc,arg1,arg2,dc2);
DCDel(dc2);
}
}
break;
case SPBM_TEXT:
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
dc->color=color;
GrPrint(dc,arg1,arg2,"%s",st);
break;
case SPBM_TEXT_BOX:
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
dc->color=color;
GrTextBox3(dc,arg1,arg2,0,st);
break;
case SPBM_TEXT_DIAMOND:
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
dc->color=color;
GrTextDiamond3(dc,arg1,arg2,0,st);
break;
case SPBM_POLYPT:
if (down) {
img->color=color;
img->thick=width;
GrLine3(img,x1-xx1,y1-yy1,0,arg1-xx1,arg2-yy1,0);
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
x1=arg1; y1=arg2;
}
break;
}
break;
case MSG_MS_L_UP:
switch (mode) {
case SPBM_LINE:
case SPBM_ARROW:
case SPBM_POLYPT:
case SPBM_POLYLINE:
img->color=color;
img->thick=width;
if (mode==SPBM_ARROW)
GrArrow3(img,x1-xx1,y1-yy1,0,arg1-xx1,arg2-yy1,0);
else
GrLine3(img,x1-xx1,y1-yy1,0,arg1-xx1,arg2-yy1,0);
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
if (mode==SPBM_POLYLINE) {
x1=arg1; y1=arg2;
} else
down=FALSE;
break;
case SPBM_RECT:
img->color=color;
if (x1<arg1) {
x11=x1;
x22=arg1;
} else {
x11=arg1;
x22=x1;
}
if (y1<arg2) {
y11=y1;
y22=arg2;
} else {
y11=arg2;
y22=y1;
}
GrRect(img,x11-xx1,y11-yy1,x22-x11+1,y22-y11+1);
down=FALSE;
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
break;
case SPBM_COPY:
case SPBM_DELETE:
if (x1<arg1) {
x11=x1;
x22=arg1;
} else {
x11=arg1;
x22=x1;
}
if (y1<arg2) {
y11=y1;
y22=arg2;
} else {
y11=arg2;
y22=y1;
}
DCDel(clip);
clip=DCExt(img,x11-xx1,y11-yy1,x22-xx1,y22-yy1);
clip->bkcolor=bkcolor;
if (mode==SPBM_DELETE) {
img->color=bkcolor;
GrRect(img,x11-xx1,y11-yy1,x22-x11+1,y22-y11+1);
}
goto bm_menu;
case SPBM_CIRCLE:
img->color=color;
img->thick=width;
GrCircle3(img,x1-xx1,y1-yy1,0,
Sqrt(SqrI64(arg1-x1)+SqrI64(arg2-y1)));
down=FALSE;
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
break;
case SPBM_PASTE:
case SPBM_PASTE_TRANSPARENT:
if (clip) {
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
if (mode==SPBM_PASTE) {
clip->flags|=DCF_NO_TRANSPARENTS;
GrBlot(img,arg1-xx1,arg2-yy1,clip);
clip->flags&=~DCF_NO_TRANSPARENTS;
} else {
dc2=DCCopy(clip);
DCColorChg(dc2,bkcolor);
GrBlot(img,arg1-xx1,arg2-yy1,dc2);
DCDel(dc2);
}
GrBitMapEdPrepPersistentDC(dc,xx1,yy1,img);
}
break;
case SPBM_TEXT:
img->color=color;
GrPrint(img,arg1-xx1,arg2-yy1,"%s",st);
goto bm_menu;
case SPBM_TEXT_BOX:
img->color=color;
GrTextBox3(img,arg1-xx1,arg2-yy1,0,st);
goto bm_menu;
case SPBM_TEXT_DIAMOND:
img->color=color;
GrTextDiamond3(img,arg1-xx1,arg2-yy1,0,st);
goto bm_menu;
}
break;
}
}
Refresh;
}
bm_key_up_done:
GetMsg(,,1<<MSG_KEY_UP);
bm_done:
DCDel(clip);
DCDel(undo);
Free(st);
DCFill(dc);
SettingsPop;
doc_e->de_flags=old_de_flags;
*_img=img;
*_xx1=xx1,*_yy1=yy1,*_xx2=xx2,*_yy2=yy2;
return res;
}
|