⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myedit2.pas

📁 delphi LED 显示屏用,带串口发送,内容编辑,演示功能
💻 PAS
📖 第 1 页 / 共 4 页
字号:
                         val(str1,aleft,k);
                         if (str1<>'') and (str1[1]='-') then aleft:=-1*aleft;
                         delete(str1,1,k);
                         val(str1,atop,k);
                         if (str1<>'') and (str1[1]='-') then atop:=-1*atop;
                         delete(str1,1,k);
                         val(str1,awidth,k);
                         delete(str1,1,k);
                         val(str1,aheight,k);
                         delete(str1,1,k);
                         val(str1,k1,k);
                         delete(str1,1,k);
                         k:=pos(',',str1);
                         if k>0 then  str1:=copy(str1,1,k-1);
                         if (str1<>'') and fileexists(str1) then
                         begin
                              pic:=Tpicture.Create;
                              pic.LoadFromFile(str1);
                              bmpdot.Canvas.StretchDraw(rect(aleft div Fscale,atop div Fscale,(awidth+aleft) div Fscale,(aheight+atop) div Fscale), Pic.Graphic);
                              pic.Free;
                         end;
                    end;
               end;
          end;
    end;
    for i:=0 to 15 do
    begin
        for k:=0 to 15 do
        begin
            for j:=0 to 1 do
            begin
                senddata.sendred[k+16][2*i+j]:=0;
                for k1:=0 to 7 do
                begin
                    kcolor:=bmpdot.canvas.Pixels[16*i+15-k,8*j+k1+1];
                    if (kcolor and $ff)>0 then senddata.sendred[k+16][2*i+j]:=senddata.sendred[k+16][2*i+j]+bmm[k1];
                end;
            end;
        end;
        for k:=0 to 15 do
        begin
            for j:=0 to 1 do
            begin
                senddata.sendred[k][2*i+j]:=0;
                for k1:=0 to 7 do
                begin
                    kcolor:=bmpdot.canvas.Pixels[16*i+15-k,8*j+k1+17];
                    if (kcolor and $ff)>0 then senddata.sendred[k][2*i+j]:=senddata.sendred[k][2*i+j]+bmm[k1];
                end;
            end;
        end;
    end;

    {for i:=0 to Ftpbyte div 2-1 do
    begin
        for k:=0 to 15 do
        begin
            for j:=0 to 2*tprownum -1 do
            begin
                senddata.sendred[15-k][2*i+j]:=0;
                senddata.sendgreen[15-k][2*i+j]:=0;
                for k1:=0 to 7 do
                begin
                    kcolor:=bmpdot.canvas.Pixels[16*i+14-k,8*j+k1];
                    if (kcolor and $ff)>0 then senddata.sendred[15-k][2*i+j]:=senddata.sendred[15-k][2*i+j]+bmm[k1];
                    if (kcolor and $ff00)>0 then senddata.sendgreen[15-k][2*i+j]:=senddata.sendgreen[15-k][2*i+j]+bmm[k1];
                end;
            end;
        end;
    end;
    for i:=0 to height div Fscale-1 do
    begin
        senddata.sendred[i][(width div (Fscale * 8))-1]:=senddata.sendred[i][(width div (Fscale * 8))-1] and $fe;
        senddata.sendgreen[i][(width div (Fscale * 8))-1]:=senddata.sendgreen[i][(width div (Fscale * 8))-1] and $fe;
    end;}
    bmpdot.free;
end;

function Tmyedit.readasc(pageno:integer):string;
var
    str1:string;
    i,j,k:integer;
    kk:longint;
begin
     str1:='';
     if pageno>0 then
     begin
          i:=0;
          kk:=0;
          while (tpstr[i].no<pageno) and (i<totalline) do
          begin
               kk:=kk+tpstr[i].linebyte;
               i:=i+1;
          end;
          while (tpstr[i].no=pageno) and (i<totalline) do
          begin
               k:=Ftpbyte;
               for j:=1 to tpstr[i].linebyte do
               begin
                    if Ftxt[kk+j]>=#$20 then
                    begin
                         str1:=str1+Ftxt[kk+j];
                         k:=k-1;
                    end;
               end;
               kk:=kk+tpstr[i].linebyte;
               i:=i+1;
               for j:=1 to k do str1:=str1+' ';
          end;
     end;
     readasc:=str1;
end;

function Tmyedit.readasc:string;
var
    str1:string;
    i,j,k:integer;
    kk:longint;
begin
     str1:='';
     i:=0;
     kk:=0;
     while (i<totalline) do
     begin
          k:=Ftpbyte;
          for j:=1 to tpstr[i].linebyte do
          begin
               if Ftxt[kk+j]>=#$20 then
               begin
                    str1:=str1+Ftxt[kk+j];
                    k:=k-1;
               end;
          end;
          kk:=kk+tpstr[i].linebyte;
          i:=i+1;
          for j:=1 to k do str1:=str1+' ';
     end;
     readasc:=str1;
end;

function Tmyedit.readcolor(pageno:integer):string;
var
    str1:string;
    i,j,k:integer;
    kk:longint;
begin
     str1:='';
     if pageno>0 then
     begin
          i:=0;
          kk:=0;
          while (tpstr[i].no<pageno) and (i<totalline) do
          begin
               kk:=kk+tpstr[i].linebyte;
               i:=i+1;
          end;
          while (tpstr[i].no=pageno) and (i<totalline) do
          begin
               k:=Ftpbyte;
               for j:=1 to tpstr[i].linebyte do
               begin
                    if Ftxt[kk+j]>=#$20 then
                    begin
                         str1:=str1+chr(tpdata.color[kk+j]);
                         k:=k-1;
                    end;
               end;
               kk:=kk+tpstr[i].linebyte;
               i:=i+1;
               for j:=1 to k do str1:=str1+#0;
          end;
     end;
     readcolor:=str1;
end;

function Tmyedit.readcolor:string;
var
    str1:string;
    i,j,k:integer;
    kk:longint;
begin
     str1:='';
     i:=0;
     kk:=0;
     while (i<totalline) do
     begin
          k:=Ftpbyte;
          for j:=1 to tpstr[i].linebyte do
          begin
               if Ftxt[kk+j]>=#$20 then
               begin
                    str1:=str1+chr(tpdata.color[kk+j]);
                    k:=k-1;
               end;
          end;
          kk:=kk+tpstr[i].linebyte;
          i:=i+1;
          for j:=1 to k do str1:=str1+#0;
     end;
     readcolor:=str1;
end;

procedure Tmyedit.insertpara(startpos,len,totallen,colorvalue,sizevalue,namevalue,stylevalue:longint);
var
    i:longint;
begin
    for i:=totallen downto startpos do
    begin
        tpdata.color[i+len]:=tpdata.color[i];
        tpdata.fontsize[i+len]:=tpdata.fontsize[i];
        tpdata.fontname[i+len]:=tpdata.fontname[i];
        tpdata.fontstyle[i+len]:=tpdata.fontstyle[i];
    end;
    for i:=startpos to startpos+len-1 do
    begin
        tpdata.color[i]:=colorvalue;
        tpdata.fontsize[i]:=sizevalue;
        tpdata.fontname[i]:=namevalue;
        tpdata.fontstyle[i]:=stylevalue;
    end;
end;

procedure Tmyedit.deletepara(startpos,len,totallen:longint);
var
    i:longint;
begin
    for i:=startpos to totallen-len do
    begin
        tpdata.color[i]:=tpdata.color[i+len];
        tpdata.fontsize[i]:=tpdata.fontsize[i+len];
        tpdata.fontname[i]:=tpdata.fontname[i+len];
        tpdata.fontstyle[i]:=tpdata.fontstyle[i+len];
    end;
end;

procedure Tmyedit.movepara(startpos,len,endpos,fontcolor,fontsize,fontname,stylevalue:longint);
var
    i,j,k,kcolor,ksize,kname,kstyle:longint;
begin
    if startpos>endpos then
    begin
        k:=length(Ftxt);
        for i:=0 to len-1 do
        begin
            if (startpos+i)<k then
            begin
               for j:=startpos-1+i downto i+endpos do
               begin
                    kcolor:=tpdata.color[j];
                    kname:=tpdata.fontname[j];
                    ksize:=tpdata.fontsize[j];
                    kstyle:=tpdata.fontstyle[j];
                    tpdata.color[j]:=tpdata.color[j+1];
                    tpdata.fontname[j]:=tpdata.fontname[j+1];
                    tpdata.fontsize[j]:=tpdata.fontsize[j+1];
                    tpdata.fontstyle[j]:=tpdata.fontstyle[j+1];
                    tpdata.color[j+1]:=kcolor;
                    tpdata.fontname[j+1]:=kname;
                    tpdata.fontsize[j+1]:=ksize;
                    tpdata.fontsize[j+1]:=kstyle;
               end;
            end;
        end;
    end
    else if startpos<endpos then
    begin
        for i:=0 to len-1 do
        begin
            kcolor:=tpdata.color[startpos];
            ksize:=tpdata.fontsize[startpos];
            kname:=tpdata.fontname[startpos];
            kstyle:=tpdata.fontstyle[startpos];
            deletepara(startpos,1,endpos+len);
            tpdata.color[endpos+len-1]:=kcolor;
            tpdata.fontsize[endpos+len-1]:=ksize;
            tpdata.fontname[endpos+len-1]:=kname;
            tpdata.fontname[endpos+len-1]:=kstyle;
        end;
    end
    else
    begin
          for i:=0 to len-1 do
          begin
               tpdata.color[startpos+i]:=fontcolor;
               tpdata.fontname[startpos+i]:=fontname;
               tpdata.fontsize[startpos+i]:=fontsize;
               tpdata.fontstyle[startpos+i]:=stylevalue;
          end;
    end;
end;


procedure Tmyedit.changepara(startpos,selectlen,klen,k,fontcolor,fontsize,fontname,stylevalue:longint);
begin
    if (selectlen<>0) then
    begin
        deletepara(startpos,selectlen,k);
        if klen<>k-selectlen then
            insertpara(startpos,klen-k+selectlen,k-selectlen,fontcolor,fontsize,fontname,stylevalue);
    end
    else
    begin
        if klen>k then
        begin
            insertpara(startpos,klen-k,k,fontcolor,fontsize,fontname,stylevalue);
        end
        else if k>klen then
        begin
            deletepara(startpos,k-klen,k);
        end;
    end;
end;

procedure Tmyedit.addstyle(startpos,endpos,value:integer);
var
   i:longint;
begin
    for i:=startpos to endpos do
    begin
        tpdata.fontstyle[i]:=tpdata.fontstyle[i] or value;
    end;
end;

procedure Tmyedit.changestyle(startpos,endpos,value:integer);
var
   i:longint;
begin
    for i:=startpos to endpos do
    begin
        tpdata.fontstyle[i]:=value;
    end;
end;

procedure Tmyedit.subbstyle(startpos,endpos,value:integer);
var
   i:longint;
begin
    for i:=startpos to endpos do
    begin
        tpdata.fontstyle[i]:=tpdata.fontstyle[i] and value
    end;
end;

procedure Tmyedit.readselectdot(Index: Integer);
begin
    selectdotx[1]:=aleft;
    selectdotx[7]:=selectdotx[1];
    selectdotx[8]:=selectdotx[1];
    selectdoty[1]:=atop;
    selectdoty[2]:=selectdoty[1];
    selectdoty[3]:=selectdoty[1];
    selectdotx[3]:=selectdotx[1]+awidth-5;
    selectdotx[4]:=selectdotx[3];
    selectdotx[5]:=selectdotx[3];
    selectdotx[2]:=(selectdotx[1]+selectdotx[3]+5) div 2-5;
    selectdotx[6]:=selectdotx[2];
    selectdoty[5]:=selectdoty[1]+aheight-5;
    selectdoty[6]:=selectdoty[5];
    selectdoty[7]:=selectdoty[5];
    selectdoty[4]:=(selectdoty[1]+selectdoty[5]+5) div 2-5;
    selectdoty[8]:=selectdoty[4];
end;

procedure Tmyedit.WMLButtonDown(var msg: TWMLButtonDown);
var
    i:integer;
begin
    if (visible) and (Fplay=false) and (not (csDesigning in ComponentState)) then
    begin
        Fselectbmpno:=-1;
        if Faddflag=true then
        begin
             pushed:=true;
             pmouseposx:=msg.Xpos;
             pmouseposy:=msg.Ypos;
             startposx:=msg.Xpos;
             startposy:=msg.Ypos;
             canvas.DrawFocusRect(rect(startposx,startposy,pmouseposx,pmouseposy));
        end
        else
        begin
            for i:=getimagecount-1 downto 0 do
            begin
                readdata(i);
                if dotinrect(msg.Xpos,msg.Ypos,aleft,atop,aWidth,aHeight) then
                begin
                    selectdispno:=dispno;
                    pushed:=true;
                    pmouseposx:=msg.Xpos;
                    pmouseposy:=msg.Ypos;
                    Fselectbmpno:=i;
                    paint;
                    selseccursor(msg.Xpos,msg.Ypos);
                    inherited;
                    exit;
                end;
            end;
            paint;
        end;
    end;
    inherited;
end;

procedure Tmyedit.readdata(Index: Integer);
var
    i:integer;
    str:string;
begin
    str:=Getimage(Index);
    val(str,dispno,i);
    delete(str,1,i);
    val(str,aleft,i);
    if (str<>'') and (str[1]='-') then aleft:=-1*aleft;
    delete(str,1,i);
    val(str,atop,i);
    if (str<>'') and (str[1]='-') then atop:=-1*atop;
    delete(str,1,i);
    val(str,awidth,i);
    delete(str,1,i);
    val(str,aheight,i);
    atop:=atop+(dispno-Ftpcount+1)*height;
end;


procedure Tmyedit.WMMouseMove(var msg: TWMMouseMove);
var
    x,y,x1,y1:integer;
begin
    if (msg.Xpos=pmouseposx) and (msg.Ypos=pmouseposy) then exit;
    if (pushed=true) then
    begin
        if Faddflag=true then
        begin
            canvas.DrawFocusRect(rect(startposx,startposy,pmouseposx,pmouseposy));
            canvas.DrawFocusRect(rect(startposx,startposy,msg.xpos,msg.ypos));
            pmouseposx:=msg.Xpos;
            pmouseposy:=msg.Ypos;
        end
        else if (Fselectbmpno>=0) then
        begin
            x:=strtoint(GetCells(1,Fselectbmpno));
            y:=strtoint(GetCells(2,Fselectbmpno));
            x1:=strtoint(GetCells(3,Fselectbmpno));
            y1:=strtoint(GetCells(4,Fselectbmpno));
            if (selectdot=0) then
            begin
                x:=x+msg.Xpos-pmouseposx;
                y:=y+msg.ypos-pmouseposy;
            end
            else if (selectdot=1) then
            begin
                x:=x+msg.Xpos-pmouseposx;
                y:=y+msg.ypos-pmouseposy;
                x1:=x1-msg.Xpos+pmouseposx;
                y1:=y1-msg.ypos+pmouseposy;
            end
            else if (selectdot=2) then
            begin
                y:=y+msg.ypos-pmouseposy;
                y1:=y1-msg.ypos+pmouseposy;
            end
            else if (selectdot=3) then
            begin
                y:=y+msg.ypos-pmouseposy;
                x1:=x1+msg.Xpos-pmouseposx;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -