Team Ai
Datasetpublic

hschumann2/TempleOS-Source-Code

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