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

📄 myedit2.pas

📁 delphi LED 显示屏用,带串口发送,内容编辑,演示功能
💻 PAS
📖 第 1 页 / 共 4 页
字号:
                    if lineheight<kh then  lineheight:=kh;
               end;
               i:=i+k;
          end;
     end;
     if  linewidth<>0 then
     begin
          tpstr[lineno].linebyte:=klen-kk;
          tpstr[lineno].lineheight:=lineheight+Fspace;
          lineno:=lineno+1;
     end;
     totalline:=lineno;
     j:=0;
     tptotal:=0;
     for i:=0  to lineno-1 do
     begin
          j:=j+tpstr[i].lineheight;
          if j>16*Ftprownum then
          begin
               tptotal:=tptotal+1;
               j:=tpstr[i].lineheight;
          end;
          tpstr[i].no:=tptotal+1;
     end;
     if (j>0) then tptotal:=tptotal+1;
end;

procedure Tmyedit.settppos(Value: longint);
var
    i:integer;
    kk,klen:longint;
begin
    if Value <> Ftppos then
    begin
          Ftppos:=Value;
          if Ftxt='' then Ftpcount:=0
          else
          begin
               kk:=0;
               i:=0;
               klen:=Ftppos;
               while (kk+tpstr[i].linebyte<=klen) and (i<totalline) do
               begin
                    if kk+tpstr[i].linebyte<=klen then
                    begin
                         kk:=kk+tpstr[i].linebyte;
                         if kk<=klen then i:=i+1;
                    end;
               end;
               if i>=totalline then i:=totalline-1;
               Ftpcount:=tpstr[i].no;
          end;
     end;
end;

procedure Tmyedit.settpcount(Value: integer);
var
    i,j:integer;
    kk:longint;
begin
    if Value <> Ftpcount then
    begin
        Ftpcount:=Value;
        if Ftpcount<2 then Ftppos:=0
        else
        begin
            kk:=0;
            j:=0;
            for i:=0 to Ftpcount-2 do
            begin
                while (tpstr[j].no=i+1) and (j<totalline) do
                begin
                    kk:=kk+tpstr[j].linebyte;
                    j:=j+1;
                end;
            end;
            Ftppos:=kk;
        end;
     //   Invalidate;
    end;
end;

procedure Tmyedit.Paint;
var
    str1:string;
    i,j,k,x,y,k1,kh,kw,yoff,yy:integer;
    kx,ky:integer;
    kk,kct:longint;
    aRect : TRect;
    pic:Tpicture;
begin
    bmp.Width:=width;
    bmp.Height:=height;
    bmp.Canvas.Brush.Color:=color;
    bmp.Canvas.FillRect(rect(0,0,bmp.Width,bmp.Height));
    bmp.Canvas.Font:=Font;
    bmp.Canvas.CopyMode:=cmSrcPaint;
    kk:=0;
    if Ftpcount>0 then
    begin
        i:=0;
        while (tpstr[i].no<Ftpcount) and (i<totalline) do
        begin
            kk:=kk+tpstr[i].linebyte;
            i:=i+1;
        end;
        y:=0;
        j:=i;
        x:=1;
        while (tpstr[j].no=Ftpcount) and (j<totalline) do
        begin
               y:=y+tpstr[j].lineheight;
               j:=j+1;
               x:=x+1;
        end;
        yy:=(height-y*Fscale) div x;
        y:=yy;
        while (tpstr[i].no=Ftpcount) and (i<totalline) do
        begin
            j:=0;
            x:=0;
            while(j<tpstr[i].linebyte) do
            begin
                str1:=Ftxt[kk+1];
                k:=1;
                if str1[1]>#$80 then
                begin
                    str1:=str1+Ftxt[kk+2];
                    k:=2;
                end;
                kh:=((4*tpdata.fontsize[kk]+1) div 3)*Fscale;
                myfont.lfHeight:=kh;
                myfont.lfWidth:=kh;
                if (tpdata.fontstyle[kk] and $80)=0 then myfont.lfWeight:=400
                else  myfont.lfWeight:=700;
                if (tpdata.fontstyle[kk] and $40)=0 then myfont.lfItalic:=0
                else myfont.lfItalic:=1;
                if (tpdata.fontstyle[kk] and $20)=0 then myfont.lfUnderline:=0
                else myfont.lfUnderline:=1;
                if (tpdata.fontstyle[kk] and $10)=0 then  myfont.lfStrikeOut:=0
                else myfont.lfStrikeOut:=1;
                sysfont.Handle:=CreateFontIndirect(myfont);
                bmp.Canvas.font.Assign(SYSfont);

                if tpdata.fontname[kk]<=0 then tpdata.fontname[kk]:=fontname.Count-1;
                bmp.Canvas.Font.Name:=fontname.Strings[tpdata.fontname[kk]];
                if (tpdata.color[kk]<0) or (tpdata.color[kk]>2)  then  tpdata.color[kk]:=0;
                bmp.Canvas.Font.Color:=SCREENCOLOR[tpdata.color[kk]];
                kw:=k*kh div 2;
                if str1[1]>=#$20 then
                begin
                    yoff:=((tpstr[i].lineheight-kh)*Fscale) div 2;
                    if yoff<0 then yoff:=0;
                    if (kw>0) and (kh>0) then
                    begin
                      bmptemp.Width:=2*kw;
                      bmptemp.Height:=kh;
                      bmptemp.Canvas.Brush.Color:=color;
                      arect:=Rect(0,0,bmptemp.Width,bmptemp.Height);
                      bmptemp.Canvas.FillRect(arect);
                      bmptemp.Canvas.Font:=bmp.Canvas.Font;
                      bmptemp.canvas.TextOut(0,0,str1);
                      bmp.Canvas.Draw(x,y+yoff,bmptemp);
                    end;
                end;
                for kx:=x to x+kw-1 do
                begin
                  for ky:=y to y+tpstr[i].lineheight*Fscale-1 do
                  begin
                    kct:=bmp.Canvas.Pixels[kx,ky];
                    if (kct and $ff00)=0  then bmp.Canvas.Pixels[kx,ky]:=kct or $ff00;
                  end;
                end;
                x:=x+kw;
                j:=j+k;
                kk:=kk+k;
            end;
            y:=y+tpstr[i].lineheight*Fscale+yy;
            i:=i+1;
        end;
        if Fdataflag=false then
        begin
          kct:=Getimagecount;
          for i:=0 to kct-1 do
          begin
                str1:=Getimage(i);
                val(str1,dispno,k);
                delete(str1,1,k);
                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);

                atop:=atop+(dispno-Ftpcount+1)*height;

                if k>0 then  str1:=copy(str1,1,k-1);
                if (str1<>'') and fileexists(str1) then
                begin
                    pic:=Tpicture.Create;
                    pic.LoadFromFile(str1);
                    if k1=1 then
                    begin
                        str1:=inttostr(pic.width*Fscale);
                        SetCells(3,i,str1);
                        awidth:=pic.width*Fscale;
                        str1:=inttostr(pic.height*Fscale);
                        SetCells(4,i,str1);
                        aheight:=pic.height*Fscale;
                        bmp.Canvas.Draw(aleft,atop, pic.Bitmap);
                    end
                    else
                    bmp.Canvas.StretchDraw(rect(aleft,atop,awidth+aleft,aheight+atop), Pic.Graphic);
                    pic.Free;
                end;
                if (Fplay=false) and  (Fselectbmpno=i) and (Fselectbmpno>=0) then
                begin
                    readselectdot(Fselectbmpno);
                    for j:=1 to 8 do
                    begin
                        bmp.Canvas.Brush.Color:=$7f7f7f+bmp.Canvas.Pixels[selectdotx[j]+3,selectdoty[j]+3];
                        bmp.Canvas.FillRect(rect(selectdotx[j],selectdoty[j],selectdotx[j]+5,selectdoty[j]+5));
                    end;
                end;
          end;
        end;
    end;
    Canvas.Draw(0,0,bmp);
end;

procedure Tmyedit.readdot(pageno:integer);
var
    str1:string;
    i,j,k,k1,x,y,kh,kw,yoff,yy:integer;
    kk,kcolor:longint;
    kct:longint;
    pic:Tpicture;
    bmpdot:Tbitmap;
begin
    bmpdot:=Tbitmap.Create;
    bmpdot.Width:=width;
    bmpdot.Height:=height;
    bmpdot.Canvas.Brush.Color:=color;
    bmpdot.Canvas.FillRect(rect(0,0,bmpdot.Width,bmpdot.Height));
    bmpdot.Canvas.Font:=Font;
    bmpdot.Canvas.Brush.Color:=color;
    bmpdot.Canvas.CopyMode:=cmSrcPaint;
    kk:=0;
    if pageno>0 then
    begin
          i:=0;
          while (tpstr[i].no<pageno) and (i<totalline) do
          begin
               kk:=kk+tpstr[i].linebyte;
               i:=i+1;
          end;
        y:=0;
        j:=i;
        x:=1;
        while (tpstr[j].no=pageno) and (j<totalline) do
        begin
               y:=y+tpstr[j].lineheight;
               j:=j+1;
               x:=x+1;
        end;
        yy:=(height div Fscale -y) div x;
        y:=yy;
          while (tpstr[i].no=pageno) and (i<totalline) do
          begin
               j:=0;
               x:=0;
               while(j<tpstr[i].linebyte) do
               begin
                    str1:=Ftxt[kk+1];
                    k:=1;
                    if str1[1]>#$80 then
                    begin
                         str1:=str1+Ftxt[kk+2];
                         k:=2;
                    end;
                    kh:=((4*tpdata.fontsize[kk]+1) div 3)*Fscale;
                    myfont.lfHeight:=kh;
                    myfont.lfWidth:=kh;
                    if (tpdata.fontstyle[kk] and $80)=0 then myfont.lfWeight:=400
                    else  myfont.lfWeight:=700;
                    if (tpdata.fontstyle[kk] and $40)=0 then myfont.lfItalic:=0
                    else myfont.lfItalic:=1;
                    if (tpdata.fontstyle[kk] and $20)=0 then myfont.lfUnderline:=0
                    else myfont.lfUnderline:=1;
                    if (tpdata.fontstyle[kk] and $10)=0 then  myfont.lfStrikeOut:=0
                    else myfont.lfStrikeOut:=1;
                    sysfont.Handle:=CreateFontIndirect(myfont);
                    bmpdot.Canvas.font.Assign(SYSfont);

                    if tpdata.fontname[kk]<=0 then tpdata.fontname[kk]:=fontname.Count-1;
                    bmpdot.Canvas.Font.Name:=fontname.Strings[tpdata.fontname[kk]];
                    if (tpdata.color[kk]<0) or (tpdata.color[kk]>2)  then  tpdata.color[kk]:=0;
                    bmpdot.Canvas.Font.Color:=SCREENCOLOR[tpdata.color[kk]];
                    kw:=k*kh div 2;
                    if str1[1]>=#$20 then
                    begin
                        yoff:=(tpstr[i].lineheight-kh) div 2;
                        if yoff<0 then yoff:=0;
                        if (kw>0) and (kh>0) then
                        begin
                          bmptemp.Width:=2*kw;
                          bmptemp.Height:=kh;
                          bmptemp.Canvas.Brush.Color:=color;
                          bmptemp.Canvas.FillRect(Rect(0,0,bmptemp.Width,bmptemp.Height));
                          bmptemp.Canvas.Font:=bmpdot.Canvas.Font;
                          bmptemp.canvas.TextOut(0,0,str1);
                          bmpdot.Canvas.Draw(x,y+yoff,bmptemp);
                      end;
                    end;
                    x:=x+kw;
                    j:=j+k;
                    kk:=kk+k;
               end;
               y:=y+tpstr[i].lineheight+yy;
               i:=i+1;
          end;
          if Fdataflag=false then
          begin
               kct:=Getimagecount;
               for i:=0 to kct-1 do
               begin
                    str1:=Getimage(i);
                    val(str1,dispno,k);
                    begin
                         delete(str1,1,k);
                         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);
                         atop:=atop+(dispno-pageno+1)*height;

                         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 height div Fscale-1 do
    begin
        for j:=0 to (width div (Fscale * 8))-1 do
        begin
            senddata.sendred[i][j]:=0;
            senddata.sendgreen[i][j]:=0;
            for k:=0 to 7 do
            begin
                kcolor:=bmpdot.canvas.Pixels[8*j+k,i];
                if (kcolor and $ff)>0 then senddata.sendred[i][j]:=senddata.sendred[i][j]+bmm[k];
                if (kcolor and $ff00)>0 then senddata.sendgreen[i][j]:=senddata.sendgreen[i][j]+bmm[k];
           end;
        end;
        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;

procedure Tmyedit.readkkdot(pageno:integer);
var
    str1:string;
    i,j,k,k1,x,y:integer;
    kk,kcolor:longint;
    kct:longint;
    pic:Tpicture;
    bmpdot:Tbitmap;
begin
    bmpdot:=Tbitmap.Create;
    bmpdot.Width:=width+1;
    bmpdot.Height:=height+1;
    bmpdot.Canvas.Brush.Color:=color;
    bmpdot.Canvas.FillRect(rect(0,0,bmpdot.Width,bmpdot.Height));
    bmpdot.Canvas.Font:=Font;
    bmpdot.Canvas.Brush.Color:=color;
    kk:=0;
    if pageno>0 then
    begin
          i:=0;
          while (tpstr[i].no<pageno) and (i<totalline) do
          begin
               kk:=kk+tpstr[i].linebyte;
               i:=i+1;
          end;
          y:=0;
          while (tpstr[i].no=pageno) and (i<totalline) do
          begin
               j:=0;
               x:=0;
               while(j<tpstr[i].linebyte) do
               begin
                    str1:=Ftxt[kk+1];
                    k:=2;
                    if str1[1]>#$80 then
                    begin
                         str1:=str1+Ftxt[kk+2];
                         k:=1;
                    end;
                    if Fdataflag=false then
                    begin
                         if tpdata.fontname[kk]<=0 then bmpdot.Canvas.Font.Name:=font.name
                         else bmpdot.Canvas.Font.Name:=fontname.Strings[tpdata.fontname[kk]];
                         bmpdot.Canvas.Font.Height:=-tpdata.fontsize[kk];
                    end
                    else
                    begin
                         bmpdot.Canvas.Font.Name:='宋体';
                         if tpdata.fontsize[kk]>24 then bmpdot.Canvas.Font.Height:=-32
                         else  bmpdot.Canvas.Font.Height:=-16;
                    end;
                    if (tpdata.color[kk]<0) or (tpdata.color[kk]>2)  then  tpdata.color[kk]:=0;
              {  k1:=tpdata.color[kk] div 3;
                k2:=(tpdata.color[kk]+k1) mod 3;
                if k2>=k1 then k2:=k2+1;}

                    bmpdot.Canvas.Font.Color:=SCREENCOLOR[tpdata.color[kk]];
                    {k1:=tpdata.color[kk] div 3;
                    k2:=(tpdata.color[kk]+k1) mod 3;
                    if k2>=k1 then k2:=k2+1;
                    bmpdot.Canvas.Brush.Color:=SCREENCOLOR[k1];
                    bmpdot.Canvas.Font.Color:=SCREENCOLOR[k2]; }
                    if str1[1]>=#$20 then
                    bmpdot.canvas.Textout(x,y+(tpstr[i].lineheight+bmpdot.Canvas.Font.Height) div 2,str1);
                    x:=x+bmpdot.Canvas.TextWidth(str1);//(-bmpdot.Canvas.Font.Height div k);
                    j:=j+3-k;
                    kk:=kk+3-k;
               end;
               y:=y+tpstr[i].lineheight;
               i:=i+1;
          end;
          if Fdataflag=false then
          begin
               kct:=Getimagecount;
               for i:=0 to kct-1 do
               begin
                    str1:=Getimage(i);
                    val(str1,dispno,k);
                    if dispno=pageno then
                    begin
                         delete(str1,1,k);

⌨️ 快捷键说明

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