From 93c7cb4629a128ae44d67e659ad2d9a1d7438855 Mon Sep 17 00:00:00 2001 From: tslediter Date: Wed, 15 Nov 2023 17:30:30 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=8C=E9=9D=A2=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 加入自动换行文本 --- d_examples/desktop.ini | 4 + designer/utslvcldcomponents.tsf | 31 ++++++ funcext/tvclib/tslvcl.tsf | 160 +++++++++++++++++++++++++++++++ funcext/tvclib/utslmemo.tsf | 9 +- funcext/tvclib/utslvclstdctl.tsf | 1 - 5 files changed, 200 insertions(+), 5 deletions(-) create mode 100644 d_examples/desktop.ini diff --git a/d_examples/desktop.ini b/d_examples/desktop.ini new file mode 100644 index 0000000..d957fd1 --- /dev/null +++ b/d_examples/desktop.ini @@ -0,0 +1,4 @@ +[ViewState] +Mode= +Vid= +FolderType=Generic diff --git a/designer/utslvcldcomponents.tsf b/designer/utslvcldcomponents.tsf index 6f68198..caf8fff 100644 --- a/designer/utslvcldcomponents.tsf +++ b/designer/utslvcldcomponents.tsf @@ -2874,6 +2874,36 @@ A5183913CA16C9848495A52E9D4E97F11C21C73721A9904C28B506B19AD21D177 ); end end +type tdwrapmemo= class(TDComponent) + function HitTip();override; + begin + return inherited; + end + function bitmapinfo();override; + begin + return "0502000000060400000074797065000203000000696D670006040000006461746 +100025C01000089504E470D0A1A0A0000000D4948445200000018000000180806 +000000E0773DF8000000017352474200AECE1CE90000000467414D410000B18F0 +BFC6105000000097048597300000EC300000EC301C76FA864000000F149444154 +484BBD963B0E84300C44B9222D2DF474746968A938055C841370083A2A2A1AAFE +C4D90133928F1C23E692407AC997C1444B1AE2B689542519625689502054CD324 +CE3026ECCF0E40243349E3385280F40EC5F102B07E429CFFAD406A8C29E50C5C2 +F056875879BC46BF7E00AB0E39F5996C5565F1E0D40F370CB866180AAAAA030C6 +408E429C390FC0674DD350081DB2641413879B87AAEB9A7ABC7B90CB799ED0F7F +D658A3E287E1E5E8034E35008F6BBFA380EE8BA8E0224D401DC70DF7768DBD68E +7C545B140620DBB6D9CAE79115DCA10A98E75917908A7A05A9A802A48F594CD95 +BA4550A2FFFB6007C0044475BEF4A7043C50000000049454E44AE42608200"; + end; + function WndClass();override; + begin + return Class(twrapmemo); + end + function Create(AOwner);override; + begin + inherited; + fiscontainerdcmp := false; + end +end type TDpassword= class(TDComponent) function HitTip();override; begin @@ -3780,6 +3810,7 @@ begin class(TDEdit), class(TDpassword), class(TDmemo), + class(tdwrapmemo), class(tdhighlighter), class(TDradiobtn), class(TDCheckBtn), diff --git a/funcext/tvclib/tslvcl.tsf b/funcext/tvclib/tslvcl.tsf index 0674143..dca3080 100644 --- a/funcext/tvclib/tslvcl.tsf +++ b/funcext/tvclib/tslvcl.tsf @@ -1345,6 +1345,166 @@ type tmemo = class(TSynMemoNorm) // FonSetFocus; fonKillFocus; end +type twrapmemo = class(TScrollingWinControl) + public + function create(aowner); + begin + ftexts := array(); + fcharcount := 10; + ftext := ""; + inherited; + AutoScroll := 1; + end + function doControlALign();override; + begin + formattexts(); + inherited; + end + function MouseDown(o,e);override; + begin + SetFocus(); + end + function KeyDown(o,e);override; // + begin + if ssCtrl in e.shiftstate then + begin + case e.charcode of + ord("C"): + begin + getclipboard().text := ftext; + end + end ; + end + end + function paint();override; + begin + ypos := GetYPos(); + // Ҫػ + ps := PAINTSTRUCT().rcPaint; + tp := ps[1]; + bo := ps[3]; + FirstLine := integer(max(0,yPos+(tp)/GetYScrollDelta())); + LastLine := integer(min(length(ftexts)-1,yPos+(bo)/GetYScrollDelta())); + rc := ps; + cvs := Canvas; + cvs.Font := font; + for i:= FirstLine to LastLine do + begin + s := ftexts[i]; + r := RC; + r[1]:= RC[1]+FCharHeight * (i-ypos); + r[3]:= r[1]+FCharHeight; + if ifstring(s) then + begin + cvs.drawtext(s,r); + end + end + end + function FontChanged(o);override; + begin + if HandleAllocated() then doControlALign(); + end + protected + function GetXScrollDelta();override; //x + begin + return FCharwidth; + end + function GetYScrollDelta();override; //y + begin + return FCharHeight; + end + function GetClientXCapacity();override; // + begin + return fcharcount+1; + end + function GetClientYCapacity();override; //߶ + begin + r := ClientRect; + return ceil((r[3]-r[1])/GetYScrollDelta()); + end + function GetClientXCount();override; //ȼ + begin + return fcharcount; + end + function GetClientYCount();override; //߶ + begin + h := FCharHeight * length(ftexts); + return integer(h/GetYScrollDelta()); + end + function PositionChanged();override; //׼ı + begin + InvalidateRect(nil,false); + end + published + property text:text read ftext write settext; + private + function formattexts(); + begin + FCharwidth := font.Width; + FCharHeight := font.Height+4; + ss := str2array(ftext,"\n"); + rec := ClientRect; + fcharcount := integer((rec[2]-rec[0])/FCharwidth); + ftexts := array(); + if fcharcount>0 then + begin + for i,v in ss do + begin + cutstr(v,fcharcount,ftexts); + end + end + end + function settext(s); + begin + if ifstring(s) and s<>ftext then + begin + ftext := s; + if HandleAllocated() then + begin + doControlALign(); + InvalidateRect(nil,false); + end + end + end + function getclipboard();//clipbord + begin + if not FCopyer then + begin + FCopyer := new TcustomClipBoard(self); + end + return FCopyer; + end + function cutstr(s,w,r); +begin + idx := length(r); + len := length(s); + i := 0; + while i10 then n := fMaxCharsInRow; - else n := 10; - return((FLines.RowMaxLength/n)+0.5)* n; + if fMaxCharsInRow>5 then n := fMaxCharsInRow; + else n := 5; + //return((FLines.RowMaxLength/n)+0.5)* n; + return(ceil((FLines.RowMaxLength+1)/n))* n; end function CreateCaret(); // begin diff --git a/funcext/tvclib/utslvclstdctl.tsf b/funcext/tvclib/utslvclstdctl.tsf index 1c5e3b3..e2456c8 100644 --- a/funcext/tvclib/utslvclstdctl.tsf +++ b/funcext/tvclib/utslvclstdctl.tsf @@ -10,7 +10,6 @@ type TcustomClipBoard=class(tcomponent) // @explan(˵) а %% **} private - private FIsopen; function CloseClipboard(); //ر begin