界面库

优化
This commit is contained in:
JianjunLiu 2022-11-02 17:17:35 +08:00
parent eb4da18fa4
commit 4519cff2a0
4 changed files with 138 additions and 167 deletions

View File

@ -3007,33 +3007,6 @@ type TPairSplitterSide=class(TCustomControl)
cursor := OCR_NORMAL; cursor := OCR_NORMAL;
border := true; border := true;
end end
function CreateParams(p);override;
begin
inherited;
end
function SetParent(p);override;
begin
if(P is class(TPairSplitter))and parent <> p then
begin
oldparent := Parent;
if oldparent then
begin
oldparent.RemoveSide(self);
end
inherited;
parent.AddSide(self(true));
end else
if not(p is class(TWincontrol))then
begin
odp := Parent;
inherited;
if odp then odp.RemoveSide(self);
end
end
function Recycling();override;
begin
inherited;
end
function publishs();override; function publishs();override;
begin begin
return array("name","border","caption","color","font","parentcolor","parentfont","popupmenu","bkbitmap","wsdlgmodalframe","onsize","onnotification"); return array("name","border","caption","color","font","parentcolor","parentfont","popupmenu","bkbitmap","wsdlgmodalframe","onsize","onnotification");
@ -3052,26 +3025,30 @@ type TPairSplitter=class(tcustomcontrol) //
FSplitterType; FSplitterType;
Fhimgelist; Fhimgelist;
FEnables; FEnables;
function EnabledChild(f); function AddSide(ASide);//Ìí¼Óside
begin
if not(ASide is class(TPairSplitterSide))then return -1;
FSides.Push(ASide);
end
function EnabledChild(f);//enabeld
begin begin
if f then if f then
begin begin
if FEnables[0]then FSides[0].enabled := true; for i,v in FEnables do
if FEnables[1]then FSides[1].enabled := true; begin
return; if v then
begin
FSides[i].enabled := true;
end end
end
end else
begin
FEnables := array(); FEnables := array();
s1 := FSides[0]; for i,v in FSides.data do
S2 := FSides[1];
if s1 then
begin begin
FEnables[0]:= s1.enabled; FEnables[i] := v.enabled;
s1.enabled := false; v.enabled := false;
end end
if s2 then
begin
FEnables[1]:= s2.enabled;
s2.enabled := false;
end end
end end
Function SetSplitterType(v); Function SetSplitterType(v);
@ -3105,12 +3082,41 @@ type TPairSplitter=class(tcustomcontrol) //
DoControlAlign(); DoControlAlign();
end end
end end
protected function getvisbleside(id);
function GetSides(index);
begin begin
return FSides[index]; c := 0;
for i := 0 to fsides.length()-1 do
begin
v := fsides[i];
if v.Visible then
begin
if c = id then return v;
c++;
end
end
end end
public public
function ControlAppended(AControl);override;
begin
if not FSides then return ;
AddSide(AControl);
end
function ControlDeleted(AControl);override;
begin
if not FSides then return ;
for i,v in FSides.data do
begin
if v=AControl then
begin
FSides.splice(i,1);
return ;
end
end
end
function checknewchild(c);override;
begin
return c is class(TPairSplitterSide);
end
function create(AOwner);override; function create(AOwner);override;
begin begin
inherited; inherited;
@ -3118,35 +3124,18 @@ type TPairSplitter=class(tcustomcontrol) //
function AfterConstruction();override; function AfterConstruction();override;
begin begin
inherited; inherited;
FSides := new tnumindexarray();
caption := "pairspliter"; caption := "pairspliter";
width := 200; width := 200;
height := 200; height := 200;
Border := false; Border := false;
WsDlgModalFrame := true; WsDlgModalFrame := true;
FSides := new TFpList();
FSplitterType := pstHorizontal; FSplitterType := pstHorizontal;
cursor := OCR_SIZEWE; cursor := OCR_SIZEWE;
FWill_Drag := true; FWill_Drag := true;
Color := _wapi.GetSysColor(COLOR_MENUBAR); Color := _wapi.GetSysColor(COLOR_MENUBAR);
end end
function AddSide(ASide);
begin
{**
@explan(˵Ã÷) Ìí¼Óside
**}
if not(ASide is class(TPairSplitterSide))then return -1;
if ASide.Parent=self then
begin
if FSides.indexof(ASide)<0 {and FSides.count<2}then
begin
FSides.add(ASide);
DoControlAlign();
end
end else
begin
ASide.parent := self;
end
end
function MouseUp(o,e);override; function MouseUp(o,e);override;
begin begin
if csDesigning in ComponentState then exit; if csDesigning in ComponentState then exit;
@ -3180,7 +3169,6 @@ type TPairSplitter=class(tcustomcontrol) //
begin begin
x := r[3]-5; x := r[3]-5;
end end
FPosition :=x; FPosition :=x;
end end
EnabledChild(true); EnabledChild(true);
@ -3231,14 +3219,7 @@ type TPairSplitter=class(tcustomcontrol) //
_wapi.ImageList_DragMove(nxy[0],nxy[1]); _wapi.ImageList_DragMove(nxy[0],nxy[1]);
end else end else
begin begin
idx := 0; if getvisbleside(0) then
for i:= 0 to FSides.count-1 do
begin
vi := FSides[i];
if vi.Enabled and vi.Visible then idx++;
if idx>1 then break;
end
if idx>1 then
begin begin
if FSplitterType=pstHorizontal then if FSplitterType=pstHorizontal then
begin begin
@ -3255,36 +3236,14 @@ type TPairSplitter=class(tcustomcontrol) //
end end
inherited; inherited;
end end
function RemoveSide(ASide);
begin
{**
@explan(˵Ã÷)pairsider %%
**}
id := FSides.indexof(ASide);
if id<0 then exit;
FSides.deli(id);
DoControlAlign();
if ASide.parent=self then
begin
ASide.parent := nil;
end
end
function Notification(AComponent,Operation);override;
begin
if Operation=opRemove then
begin
RemoveSide(AComponent);
end
inherited;
end
function DoControlAlign();override; function DoControlAlign();override;
begin begin
{** {**
@explan(˵Ã÷) ¶ÔÆëµ÷Õû %% @explan(˵Ã÷) ¶ÔÆëµ÷Õû %%
**} **}
if not HandleAllocated()then return; if not HandleAllocated()then return;
sd1 := GetSides(0); sd1 := getvisbleside(0);
sd2 := GetSides(1); sd2 := getvisbleside(1);
if not(sd1 or sd2)then return; if not(sd1 or sd2)then return;
rc := GetClientRect(); rc := GetClientRect();
pz := GetPosition(); pz := GetPosition();
@ -3308,8 +3267,8 @@ type TPairSplitter=class(tcustomcontrol) //
end end
function paint();override; function paint();override;
begin begin
sd1 := GetSides(0); sd1 := getvisbleside(0);
sd2 := GetSides(1); sd2 := getvisbleside(1);
if not(sd1 or sd2)then return; if not(sd1 or sd2)then return;
rc := GetClientRect(); rc := GetClientRect();
pz := GetPosition(); pz := GetPosition();
@ -3334,13 +3293,12 @@ type TPairSplitter=class(tcustomcontrol) //
if x1>rc[0] and x1<rc[2] then if x1>rc[0] and x1<rc[2] then
dc.SetPixel(array(x1,y),0); dc.SetPixel(array(x1,y),0);
end end
end end
end end
function Recycling();override; function Recycling();override;
begin begin
if FDRageimglist then _wapi.ImageList_Destroy(FDRageimglist); if FDRageimglist then _wapi.ImageList_Destroy(FDRageimglist);
FSides := nil;
inherited; inherited;
end end
property Position:integer read GetPosition write SetPosition; property Position:integer read GetPosition write SetPosition;

View File

@ -134,6 +134,26 @@ type TCharDiscrimi=class()
end end
return 0; return 0;
end end
class function IsLowercaseVariableName(s);
begin
if ifstring(s)and length(s)>= 1 then
begin
cc := ord(s[1]);
if IsLowercaseLetter(cc)or cc=CD_UDL then
begin
for i := 2 To length(s) do
begin
cc := ord(s[i]);
if not(IsLowercaseLetter(cc)or IsNumber(cc)or(cc=CD_UDL))then
begin
return false;
end
end
return true;
end
end
return 0;
end
function create(); function create();
begin begin
sinit(); sinit();

View File

@ -11,10 +11,11 @@ type tcustomtabsheet = class(TCustomControl) //
function RealSetText(s);override; function RealSetText(s);override;
begin begin
inherited; inherited;
if ifstring(s) and Parent then p := parent;
if ifstring(s) and p and (p is class(tcustompagecontrol)) then
begin begin
id := parent.GetPageID(self(true)); id := p.GetPageID(self(true));
Parent.SetTabText(id,s); p.SetTabText(id,s);
end end
end end
public public
@ -33,15 +34,10 @@ type tcustomtabsheet = class(TCustomControl) //
function create(AOwner);override; function create(AOwner);override;
begin begin
inherited; inherited;
WsDlgModalFrame := true; WsDlgModalFrame := true; //p.exstyle := 0x101;
Caption := "tab"; Caption := "tab";
Visible := false; Visible := false;
end end
{function CreateParams(p);override;
begin
inherited;
p.exstyle := 0x101;
end }
end end
type tcustompagecontrol = class(TCustomControl) type tcustompagecontrol = class(TCustomControl)
private private
@ -90,7 +86,7 @@ type tcustompagecontrol = class(TCustomControl)
begin begin
pg := FTabItems[i]; pg := FTabItems[i];
ta := pg.Caption; ta := pg.Caption;
FTabItemswidth[i] := max(20, length(ta)*fw+8 ); FTabItemswidth[i] := max(20, length(ta)*fw+10 );
end end
FMaxsize := 0; FMaxsize := 0;
if FTabPosition in array(alLeft,alRight) then if FTabPosition in array(alLeft,alRight) then
@ -263,6 +259,7 @@ type tcustompagecontrol = class(TCustomControl)
function PaintTabs(); function PaintTabs();
begin begin
dc := Canvas; dc := Canvas;
dc.font := font;
for i := 0 to FTabItems.length()-1 do for i := 0 to FTabItems.length()-1 do
begin begin
rec := FTabRects[i]; rec := FTabRects[i];
@ -378,6 +375,12 @@ type tcustompagecontrol = class(TCustomControl)
end end
end end
public public
function FontChanged(o);override;
begin
inherited;
DoControlAlign();
end
function getsheetrect(); //»ñµÃsheet function getsheetrect(); //»ñµÃsheet
begin begin
{** {**
@ -548,16 +551,11 @@ type tcustompagecontrol = class(TCustomControl)
@param(Value)(string)Îı¾ %%; @param(Value)(string)Îı¾ %%;
**} **}
it := FTabItems[i]; it := FTabItems[i];
if it then if it and value<>it.caption then
begin
if Value = it.caption then
begin
CalcTabs();
InvalidateRect(nil,false);
end else
begin begin
it.Caption := Value; it.Caption := Value;
end DoControlAlign();
InvalidateRect(nil,false);
end end
end end
function SetTabIndex(AIndex,AIndexnew); function SetTabIndex(AIndex,AIndexnew);
@ -627,7 +625,6 @@ type tcustomtabitem = class() //
if ifstring(s) and s<>FCaption then if ifstring(s) and s<>FCaption then
begin begin
FCaption := s; FCaption := s;
psztext := FCaption;
if PageSheet is class(tcustomtabsheet) then PageSheet.Caption := s; if PageSheet is class(tcustomtabsheet) then PageSheet.Caption := s;
end end
end end

View File

@ -532,8 +532,8 @@ type TTmfParser = class(TTmfParserbase)
if ifstring(v)and(not v)then return tostn(""); if ifstring(v)and(not v)then return tostn("");
if ifstring(v)then if ifstring(v)then
begin begin
if v in array({"item",}"end","object")then return tostn(v); if v in array({"item",}"end","object","inherited")then return tostn(v);
if new TCharDiscrimi().IsVariableName(v)then if new TCharDiscrimi().IsLowercaseVariableName(v)then
begin begin
return v; return v;
end else end else
@ -659,9 +659,9 @@ type TTmfParser = class(TTmfParserbase)
r := "<\r\n"; r := "<\r\n";
for i,v in d do for i,v in d do
begin begin
if ifstring(i)then si := i; //if ifstring(i)then si := i;
else si := tostn(i); //else si := tostn(i);
r += tablelines(si+"="+call(thisfunction,v)," "); r += tablelines(totfmstr(i)+"="+call(thisfunction,v)," ");
//r+="\r\n"; //r+="\r\n";
end end
r += " >\r\n"; r += " >\r\n";
@ -840,6 +840,13 @@ type TTmfParser = class(TTmfParserbase)
if tt=TT_SIG and tv=")" then break; if tt=TT_SIG and tv=")" then break;
r["parent"] := tv; r["parent"] := tv;
end end
end else
if tt=TT_STR then
begin
if not pp then
begin
pp := tv;
end
end else end else
PError("ÆäËû´íÎó",1); PError("ÆäËû´íÎó",1);
end end
@ -1503,12 +1510,13 @@ type TPropertyFileFilter=class(TPropertyType)
end end
function FormatTMF(d);override; function FormatTMF(d);override;
begin begin
r := "{ "+TslToHexFormatStr(d)+" }"; if dataisnotsample(d) then return "";
return r; return TmfParser.tslasItem(d);
end end
function TmfToNode(d);override; function TmfToNode(d);override;
begin begin
return HexFormatStrToTSL(d); return d;
//return HexFormatStrToTSL(d);
end end
end end
type TPropertyLazyInteger=class(TPropertyInteger) type TPropertyLazyInteger=class(TPropertyInteger)
@ -1917,40 +1925,16 @@ type tpropertytsl=class(TPropertyType)
end end
function TmfToNode(d);override; function TmfToNode(d);override;
begin begin
if ifstring(d)then return d;
begin
r := HexFormatStrToTsl(d);
return r;
end
end end
function FormatTMF(d);override; function FormatTMF(d);override;
begin begin
if datanotok(d) then return ""; if dataisnotsample(d) then return "";
reti := TSlToHexFormatStr(d); return TmfParser.tslasItem(d);
ret := "{ ";
ret += reti;
ret += " }";
return ret;
end end
function ReadTMF(d,o);override; function ReadTMF(d,o);override;
begin begin
if d and ifstring(d) then return d;
begin
return HexFormatStrToTsl(d);
end
end
private
function datanotok(d);//
begin
if ifobj(d) then return true;
if ifarray(d) then
begin
for i ,v in d do
begin
if (datanotok(v)) then return true;
end
end
return false;
end end
end end
type tpropertylazytsl = class(tpropertytsl) type tpropertylazytsl = class(tpropertytsl)
@ -2423,6 +2407,18 @@ function InitLib();
begin begin
static Sinitlib(); static Sinitlib();
end end
function dataisnotsample(d);//
begin
if ifobj(d) then return true;
if ifarray(d) then
begin
for i ,v in d do
begin
if (dataisnotsample(v)) then return true;
end
end
return false;
end
Initialization Initialization
InitLib(); InitLib();