升级设计器

This commit is contained in:
2024-09-24 17:48:01 +08:00
parent cc72d4c6fc
commit 6d2f348019
10 changed files with 301 additions and 133 deletions
@@ -0,0 +1,124 @@
object fm_inheritedwnd:tfm_inheritedwnd
caption="通过继承构造窗口"
height=543
left=526
minmaxbox=false
onclose=fm_inheritedwnd_close
top=288
visible=false
width=433
object statusbar1:tstatusbar
caption="statusbar1"
height=25
left=0
top=479
width=417
end
object panel2:tpanel
align=albottom
caption="panel2"
height=31
left=0
top=448
width=417
wsdlgmodalframe=false
object label1:tlabel
left=399
top=0
width=18
height=31
caption=""
align=alright
end
object ed_ok:tbtn
align=alright
caption="确定"
enabled=false
height=31
left=308
onclick=ed_ok_clk
top=0
width=91
end
object label2:tlabel
left=283
top=0
width=25
height=31
caption=" "
align=alright
end
object bt_cancel:tbtn
align=alright
caption="取消"
height=31
left=195
onclick=bt_cancel_clk
top=0
width=88
end
end
object panel1:tpanel
align=altop
caption="panel1"
height=27
left=0
top=0
width=417
wsdlgmodalframe=false
object label3:tlabel
left=0
top=0
width=85
height=27
caption="可以继承:"
align=alleft
end
object ed_search:tedit
align=alclient
caption="edit1"
height=27
left=85
onchanged=ed_search_onchanged
onkeyup=ed_search_keyup
placeholder="搜索"
top=0
width=332
end
end
object panel3:tpanel
align=albottom
caption="panel1"
height=35
left=0
top=413
width=417
wsdlgmodalframe=false
object label4:tlabel
left=0
top=0
width=85
height=35
caption=" 名称:"
align=alleft
end
object ed_name:tedit
align=alclient
caption="edit1"
height=35
left=85
placeholder="名称"
top=0
width=332
end
end
object lbx_pal:tlistbox
align=alclient
caption="listbox1"
height=386
left=0
onselchanged=lbx_pal_sel
top=27
width=417
end
end
+133
View File
@@ -0,0 +1,133 @@
type tfm_inheritedwnd=class(tdcreateform)
uses tslvcl;
statusbar1:tstatusbar;
panel1:tpanel;
panel2:tpanel;
ed_ok:tbtn;
label1:tlabel;
label2:tlabel;
bt_cancel:tbtn;
label3:tlabel;
ed_search:tedit;
panel3:tpanel;
label4:tlabel;
ed_name:tedit;
lbx_pal:tlistbox;
function Create(AOwner);override; //构造
begin
fnds := array();
fnds2 := array();
fns := array();
inherited;
rc := _wapi.GetScreenRect();
left :=(rc[2]-rc[0])/2-280;
top :=(rc[3]-rc[1])/2-230;
end
function ed_search_keyup(o;e);
begin
case e.charcode of
VK_UP:
begin
idx := lbx_pal.ItemIndex;
if idx>0 then lbx_pal.ItemIndex := idx-1;
else lbx_pal.ItemIndex := length(fnds2)-1;
end
VK_DOWN:
begin
len := length(fnds2);
idx := lbx_pal.ItemIndex;
if idx<(len-1) then lbx_pal.ItemIndex := idx+1;
else lbx_pal.ItemIndex := 0;
end
end ;
end
function ed_ok_clk(o;e);
begin
EndModal(1);
end
function bt_cancel_clk(o;e);
begin
EndModal(0);
end
function lbx_pal_sel(o;e);
begin
idx := o.getCurrentSelection();
if idx>=0 then
begin
s := o.getItemText(idx);
n := 1;
while true do
begin
ns := s+inttostr(n);
if not(fns[ns]) then break;
n++;
end
ed_name.text := ns;
end else ed_name.text := "";
ed_ok.Enabled := (idx>=0);
end
function fm_inheritedwnd_close(o;e);
begin
e.skip := true;
o.EndModal(0);
end
function ed_search_onchanged(o;e); //搜索改变
begin
//if not fsearchok then return ;
set_to_list();
end
function getinfo();
begin
return array(fnds2[lbx_pal.getCurrentSelection()],ed_name.text);
end
function setinfo();
begin
ActiveControl := ed_search;
if parent then
begin
tr := parent.tree;
fnds := array();
tr.GetNodesBytype(fnds,array("form","panel"));
end
set_to_list();
end
function set_to_list();
begin
s := lowercase(trim( ed_search.text));
ss := array();
ssl := 0;
fnds2 := array();
fns := array();
for i,v in fnds do
begin
ssi := v.Fname;
fns[ssi] := true;
if not( s) or (s and pos(s,ssi)) then
begin
fnds2[ssl] := v;
ss[ssl++] := ssi;
end
end
lbx_pal.Items := ss;
ed_name.ExecuteCommand("ecselall");
end
function Recycling();override; //回收变量
begin
inherited;
ci := self.classinfo(); //将成员变量赋值为nil避免循环引用
for i,v in ci["members"] do
begin
if v["const"] then continue;
if v["static"] then continue;
invoke(self,v["name"],nil);
end
end
private
fsearchok;
fnds;
fnds2;
fns;
end
+11
View File
@@ -0,0 +1,11 @@
array("name":"vcldesginer","version":"1.1.2","dir":
(),"files":
("textcompclassadder":
("name":"textcompclassadder","type":"form","dir":""),"textcompclassmgr":
("name":"textcompclassmgr","type":"form","dir":""),"tfm_inheritedwnd":
("name":"tfm_inheritedwnd","type":"form","dir":""),"t_bconfig_cmd_shower":
("name":"t_bconfig_cmd_shower","type":"form","dir":""),"t_compile_config":
("name":"t_compile_config","type":"form","dir":""),"t_dir_list":
("name":"t_dir_list","type":"form","dir":""),"t_m_list_editor":
("name":"t_m_list_editor","type":"form","dir":"")),"mainform":"textcompclassmgr")
+1 -127
View File
@@ -319,7 +319,7 @@ type TProjectView = class(TVCForm) //
width := 300; //350
height := max(400,rc[3]-200);
FInput := new TNameInput(self);
finheritedinput := new tinheritedimput(self);
finheritedinput := new tfm_inheritedwnd(self);
finheritedinput.parent := self;
FInput.visible := false;
FInput.parent := self;
@@ -2904,132 +2904,6 @@ type TKeyValueList = class(TListBox) //kvalue list
private
FCurrentIndex;
end
type tinheritedimput = class(TVCForm)
function Create(AOwner);override;
begin
inherited;
info := %%
object tinheritedinput1:tinheritedinput
visible = false
caption="通过继承构建窗口"
height=328
left=420
top=232
width=300
minmaxbox=false
object label3:tlabel
left=6
top=9
caption="可继承父类:"
end
object listbox1:tlistbox
caption="listbox1"
height=178
left=6
top=40
visible=true
width=280
onselchanged=listselchanged
end
object btn1:tbtn
caption="取消"
height=25
left=79
top=262
end
object btn2:tbtn
caption="确定"
height=27
left=187
top=261
end
object label1:tlabel
left=7
top=225
width=53
height=24
caption="名称:"
end
object edit1:tedit
caption="edit1"
left=62
top=226
width=218
end
end
%%;
WSSizebox := false;
loader.LoadFromTfmScript(self,info);
rc := _wapi.GetScreenRect();
left :=(rc[2]-rc[0])/2-280;
top :=(rc[3]-rc[1])/2-230;
Onclose := thisfunction(CloseEndModalForm);
btn1.onClick := function(o,e)
begin
Endmodal(0);
end
btn2.onClick := function(o,e);
begin
Endmodal(1);
end
end
function CloseEndModalForm(o,e);
begin
e.skip := true;
o.Endmodal(0);
end
function listselchanged(o,e);
begin
idx := o.getCurrentSelection();
if idx>=0 then
begin
s := o.getItemText(idx);
n := 1;
while true do
begin
ns := s+inttostr(n);
if not(fns[ns]) then break;
n++;
end
edit1.text := ns;
end
end
function getinfo();
begin
return array(fnds[listbox1.getCurrentSelection()],edit1.text);
end
function setinfo();
begin
ss := array();
fns := array();
if parent then
begin
tr := parent.tree;
fnds := array();
tr.GetNodesBytype(fnds,array("form","panel"));
for i,v in fnds do
begin
s := v.Fname;
ss[i] := s;
fns[s] := true;
end
end
listbox1.Items := ss;
edit1.ExecuteCommand("ecselall");
end
public //成员变量
fnds;
fns;
label3;
listbox1;
btn1;
btn2;
label1;
edit1;
end
type TNameInput=class(TCustomControl) //输入文件名窗口
function Create(AOwner);override;
begin
+2 -1
View File
@@ -318,7 +318,7 @@ type TVclDesigner = class(tvcform)
public //设计器工程
ffilemenu;
fviewmenu;
function OpenFileFromTpjFile(f); //从文件打开工程
function OpenFileFromTpjFile(f,e); //从文件打开工程
begin
FProjectFileOpener.caption := "打开";
@@ -326,6 +326,7 @@ type TVclDesigner = class(tvcform)
begin
f := FProjectFileOpener.FileName;
end
if not ifstring(f) then return ;
if not fileexists("",f) then return ;
FProjectsManager.OpenFileFromTpjFile(f);
fio := ioFileseparator();