This commit is contained in:
liujianjun 2025-07-22 17:28:43 +08:00
parent e4d6b23680
commit db909b5520
36 changed files with 2389 additions and 1094 deletions

Binary file not shown.

4
d_examples/desktop.ini Normal file
View File

@ -0,0 +1,4 @@
[ViewState]
Mode=
Vid=
FolderType=Generic

View File

@ -10,12 +10,12 @@ object ed_script:t_compile_config
topbottomspacing=10 topbottomspacing=10
> >
height=560 height=562
left=638 left=638
minmaxbox=false minmaxbox=false
onclose=compile_config_close onclose=compile_config_close
top=208 top=208
width=484 width=488
wssizebox=true wssizebox=true
object panel1:tpanel object panel1:tpanel
autosize=true autosize=true
@ -31,7 +31,7 @@ object ed_script:t_compile_config
height=25 height=25
left=10 left=10
top=10 top=10
width=448 width=452
wsdlgmodalframe=false wsdlgmodalframe=false
object lb_input:tlabel object lb_input:tlabel
left=2 left=2
@ -74,7 +74,7 @@ object ed_script:t_compile_config
left=10 left=10
parentcolor=true parentcolor=true
top=45 top=45
width=448 width=452
object lb_ype:tlabel object lb_ype:tlabel
left=6 left=6
top=21 top=21
@ -121,13 +121,12 @@ object ed_script:t_compile_config
top=44 top=44
width=324 width=324
end end
object bt_output:tbtn object bt_outputname:tbtn
autosize=true autosize=true
caption=".." caption=".."
enabled=false
height=21 height=21
left=408 left=408
onclick=bt_output_clk onclick=bt_outputname_clk
top=44 top=44
width=28 width=28
end end
@ -148,12 +147,13 @@ object ed_script:t_compile_config
top=67 top=67
width=324 width=324
end end
object bt_outputname:tbtn object bt_output:tbtn
autosize=true autosize=true
caption=".." caption=".."
enabled=false
height=21 height=21
left=408 left=408
onclick=bt_outputname_clk onclick=bt_output_clk
top=67 top=67
width=28 width=28
end end
@ -169,23 +169,23 @@ object ed_script:t_compile_config
leftrightspacing=2 leftrightspacing=2
topbottomspacing=2 topbottomspacing=2
> >
height=71 height=73
left=10 left=10
parentcolor=true parentcolor=true
top=149 top=149
width=448 width=452
object label1:tlabel object label1:tlabel
left=6 left=6
top=21 top=21
width=58 width=58
height=21 height=23
autosize=true autosize=true
caption="º¯ÊýĿ¼" caption="º¯ÊýĿ¼"
end end
object ed_f_dirs:tedit object ed_f_dirs:tedit
autosize=true autosize=true
caption="edit1" caption="edit1"
height=21 height=23
left=66 left=66
top=21 top=21
width=312 width=312
@ -193,7 +193,7 @@ object ed_script:t_compile_config
object bt_f_dir:tbtn object bt_f_dir:tbtn
autosize=true autosize=true
caption=".." caption=".."
height=21 height=23
left=380 left=380
onclick=bt_f_dir_clk onclick=bt_f_dir_clk
top=21 top=21
@ -201,7 +201,7 @@ object ed_script:t_compile_config
end end
object label2:tlabel object label2:tlabel
left=6 left=6
top=44 top=46
width=58 width=58
height=21 height=21
autosize=true autosize=true
@ -212,7 +212,7 @@ object ed_script:t_compile_config
caption="edit2" caption="edit2"
height=21 height=21
left=66 left=66
top=44 top=46
width=312 width=312
end end
object bt_s_dir:tbtn object bt_s_dir:tbtn
@ -221,7 +221,7 @@ object ed_script:t_compile_config
height=21 height=21
left=380 left=380
onclick=bt_s_dir_clk onclick=bt_s_dir_clk
top=44 top=46
width=28 width=28
end end
end end
@ -239,8 +239,8 @@ object ed_script:t_compile_config
height=139 height=139
left=10 left=10
parentcolor=true parentcolor=true
top=230 top=232
width=448 width=452
object lb_s_type:tlabel object lb_s_type:tlabel
left=6 left=6
top=21 top=21
@ -256,10 +256,10 @@ object ed_script:t_compile_config
left=94 left=94
text="*.tfm,*.ini" text="*.tfm,*.ini"
top=21 top=21
width=318 width=322
end end
object label7:tlabel object label7:tlabel
left=414 left=418
top=21 top=21
width=28 width=28
height=20 height=20
@ -281,13 +281,13 @@ object ed_script:t_compile_config
height=21 height=21
left=94 left=94
top=43 top=43
width=318 width=322
end end
object bt_i_s:tbtn object bt_i_s:tbtn
autosize=true autosize=true
caption=".." caption=".."
height=21 height=21
left=414 left=418
onclick=bt_i_s_clk onclick=bt_i_s_clk
top=43 top=43
width=28 width=28
@ -307,13 +307,13 @@ object ed_script:t_compile_config
height=21 height=21
left=94 left=94
top=66 top=66
width=318 width=322
end end
object bt_i_f:tbtn object bt_i_f:tbtn
autosize=true autosize=true
caption=".." caption=".."
height=21 height=21
left=414 left=418
onclick=bt_i_f_clk onclick=bt_i_f_clk
top=66 top=66
width=28 width=28
@ -333,13 +333,13 @@ object ed_script:t_compile_config
height=21 height=21
left=94 left=94
top=89 top=89
width=318 width=322
end end
object bt_tsgadd:tbtn object bt_tsgadd:tbtn
autosize=true autosize=true
caption=".." caption=".."
height=21 height=21
left=414 left=418
onclick=bt_tsgadd_clk onclick=bt_tsgadd_clk
top=89 top=89
width=28 width=28
@ -359,13 +359,13 @@ object ed_script:t_compile_config
height=21 height=21
left=94 left=94
top=112 top=112
width=318 width=322
end end
object bt_d_f:tbtn object bt_d_f:tbtn
autosize=true autosize=true
caption=".." caption=".."
height=21 height=21
left=414 left=418
onclick=bt_d_f_clk onclick=bt_d_f_clk
top=112 top=112
width=28 width=28
@ -385,8 +385,8 @@ object ed_script:t_compile_config
height=97 height=97
left=10 left=10
parentcolor=true parentcolor=true
top=379 top=381
width=448 width=452
object label9:tlabel object label9:tlabel
left=6 left=6
top=21 top=21
@ -521,8 +521,8 @@ object ed_script:t_compile_config
> >
height=25 height=25
left=10 left=10
top=486 top=488
width=448 width=452
wsdlgmodalframe=false wsdlgmodalframe=false
object bt_cmd:tbtn object bt_cmd:tbtn
autosize=true autosize=true

View File

@ -95,7 +95,7 @@ type t_compile_config=class(tdcreateform)
function bt_tsgadd_clk(o;e);virtual; function bt_tsgadd_clk(o;e);virtual;
begin begin
tp := array("tsg¿â":"*.tsg"); tp := array("tsg¿â":"*.tsg");
if show_dir_list(s_to_array(ed_tsg.text,true),tp)then if show_dir_list(s_to_array(ed_tsg.text,true),tp,"tsg库目录")then
begin begin
ed_tsg.text := array_to_s(dir_list.get_dirs(),true); ed_tsg.text := array_to_s(dir_list.get_dirs(),true);
end end
@ -183,6 +183,7 @@ type t_compile_config=class(tdcreateform)
function bt_outputname_clk(o;e);virtual; function bt_outputname_clk(o;e);virtual;
begin begin
f_op.filter := array(get_type():"*"+get_type()); f_op.filter := array(get_type():"*"+get_type());
f_op.Caption := "输出文件名";
if f_op.OpenDlg()then if f_op.OpenDlg()then
begin begin
ed_output.text :=relative_path( f_op.filename); ed_output.text :=relative_path( f_op.filename);
@ -201,6 +202,7 @@ type t_compile_config=class(tdcreateform)
function bt_script_clk(o;e);virtual; function bt_script_clk(o;e);virtual;
begin begin
f_op.filter := array("tsl½Å±¾":"*.tsf;*.tsl"); f_op.filter := array("tsl½Å±¾":"*.tsf;*.tsl");
f_op.Caption := "入口脚本";
if f_op.OpenDlg()then if f_op.OpenDlg()then
begin begin
e_script.text := relative_path( f_op.filename); e_script.text := relative_path( f_op.filename);
@ -210,6 +212,7 @@ type t_compile_config=class(tdcreateform)
function bt_ico_clk(o;e);virtual; function bt_ico_clk(o;e);virtual;
begin begin
f_op.filter := array("icoͼ±ê":"*.ico"); f_op.filter := array("icoͼ±ê":"*.ico");
f_op.Caption := "图标文件";
if f_op.OpenDlg()then if f_op.OpenDlg()then
begin begin
ed_ico.text := relative_path( f_op.filename); ed_ico.text := relative_path( f_op.filename);
@ -217,28 +220,28 @@ type t_compile_config=class(tdcreateform)
end end
function bt_d_f_clk(o;e);virtual; function bt_d_f_clk(o;e);virtual;
begin begin
if show_m_editor(s_to_array(ed_exclude_f.text))then if show_m_editor(s_to_array(ed_exclude_f.text),"排除函数")then
begin begin
ed_exclude_f.text := array_to_s(m_list_editor.get_data()); ed_exclude_f.text := array_to_s(m_list_editor.get_data());
end end
end end
function bt_i_f_clk(o;e);virtual; function bt_i_f_clk(o;e);virtual;
begin begin
if show_m_editor(s_to_array(ed_include_f.text))then if show_m_editor(s_to_array(ed_include_f.text),"指定函数")then
begin begin
ed_include_f.text := array_to_s(m_list_editor.get_data()); ed_include_f.text := array_to_s(m_list_editor.get_data());
end end
end end
function bt_i_s_clk(o;e);virtual; function bt_i_s_clk(o;e);virtual;
begin begin
if show_m_editor(s_to_array(ed_include_s.text))then if show_m_editor(s_to_array(ed_include_s.text),"指定资源")then
begin begin
ed_include_s.text := array_to_s(m_list_editor.get_data()); ed_include_s.text := array_to_s(m_list_editor.get_data());
end end
end end
function bt_output_clk(o;e); function bt_output_clk(o;e);
begin begin
if show_m_editor(s_to_array(ed_out_f.text))then if show_m_editor(s_to_array(ed_out_f.text),"输出函数")then
begin begin
ed_out_f.text := array_to_s(m_list_editor.get_data()); ed_out_f.text := array_to_s(m_list_editor.get_data());
end end
@ -246,14 +249,14 @@ type t_compile_config=class(tdcreateform)
function bt_s_dir_clk(o;e); function bt_s_dir_clk(o;e);
begin begin
if show_dir_list(s_to_array(ed_s_dirs.text,true))then if show_dir_list(s_to_array(ed_s_dirs.text,true),nil,"资源目录")then
begin begin
ed_s_dirs.text := array_to_s(dir_list.get_dirs(),true); ed_s_dirs.text := array_to_s(dir_list.get_dirs(),true);
end end
end end
function bt_f_dir_clk(o;e); function bt_f_dir_clk(o;e);
begin begin
if show_dir_list(s_to_array(ed_f_dirs.text,true))then if show_dir_list(s_to_array(ed_f_dirs.text,true),nil,"函数目录")then
begin begin
ed_f_dirs.text := array_to_s(dir_list.get_dirs(),true); ed_f_dirs.text := array_to_s(dir_list.get_dirs(),true);
end end
@ -274,19 +277,21 @@ type t_compile_config=class(tdcreateform)
invoke(self,v["name"],nil); invoke(self,v["name"],nil);
end end
end end
function show_dir_list(data,filetype); function show_dir_list(data,filetype,cp);
begin begin
dir_list.Left := Left-20; dir_list.Left := Left-20;
dir_list.top := top+50; dir_list.top := top+50;
dir_list.set_dirs(data); dir_list.set_dirs(data);
dir_list.fopentype := filetype; dir_list.fopentype := filetype;
if ifstring(cp) then dir_list.Caption := cp;
return dir_list.ShowModal(); return dir_list.ShowModal();
end end
function show_m_editor(data); function show_m_editor(data,cp);
begin begin
m_list_editor.Left := Left-20; m_list_editor.Left := Left-20;
m_list_editor.top := top+50; m_list_editor.top := top+50;
m_list_editor.set_data(data); m_list_editor.set_data(data);
if ifstring(cp) then m_list_editor.Caption := cp;
return m_list_editor.ShowModal(); return m_list_editor.ShowModal();
end end
function enabled_script_input(f); function enabled_script_input(f);

View File

@ -35,6 +35,7 @@ object ditor_color_mgr:t_editor_color_mgr
onselchanged=colorcombobox1_onselchanged onselchanged=colorcombobox1_onselchanged
top=18 top=18
width=132 width=132
parentfont=false
end end
object listbox1:tlistbox object listbox1:tlistbox
caption="listbox1" caption="listbox1"
@ -55,6 +56,7 @@ object ditor_color_mgr:t_editor_color_mgr
onselchanged=colorcombobox2_onselchanged onselchanged=colorcombobox2_onselchanged
top=18 top=18
width=177 width=177
parentfont=false
end end
object openfileadlg1:topenfileadlg object openfileadlg1:topenfileadlg
left=314 left=314

View File

@ -4,7 +4,7 @@ interface
@param(说明) 设计器工程相关工具,包括历史工程,工程目录管理,代码编辑器 %% @param(说明) 设计器工程相关工具,包括历史工程,工程目录管理,代码编辑器 %%
@date(20220518) @date(20220518)
**} **}
uses utslvclauxiliary,tslvcl,utslmemo,UTslSynMemo,UVCPropertyTypesPersistence,UtslCodeEditor,utslvclsyntaxparser; uses utslvclauxiliary,utslvcldcomponents,tslvcl,utslmemo,UTslSynMemo,UVCPropertyTypesPersistence,UtslCodeEditor,utslvclsyntaxparser;
function SetWndPostWithMouse(wnd,lft); function SetWndPostWithMouse(wnd,lft);
type TProjectManagerForm = class(TVCForm) //工程管理 TCustomControl type TProjectManagerForm = class(TVCForm) //工程管理 TCustomControl
function Create(AOwner);override; function Create(AOwner);override;
@ -175,7 +175,7 @@ end
%%,n,n+"main"); %%,n,n+"main");
ReWriteString(cprojpath+n+".tsl",r); ReWriteString(cprojpath+n+".tsl",r);
ReWriteString(cprojpath+n+"main.tsf",CreateAForm(n+"main")); ReWriteString(cprojpath+n+"main.tsf",CreateAForm(n+"main"));
ReWriteString(cprojpath+n+format("%smain.tfm",n),CreateAtfm(n+"main",n+"main")); ReWriteString(cprojpath+n+"main.tfm",CreateAtfm(n+"main",n+"main"));
//ReWriteString(cprojpath+"resource.tfm"+fio+format("%smain.tfm",n),CreateAtfm(n+"main",n+"main")); //ReWriteString(cprojpath+"resource.tfm"+fio+format("%smain.tfm",n),CreateAtfm(n+"main",n+"main"));
//写入缓存 //写入缓存
FProjectCoder.AddProject(n,f); FProjectCoder.AddProject(n,f);
@ -352,6 +352,8 @@ type TProjectView = class(TVCForm) //
FInput.visible := false; FInput.visible := false;
FInput.parent := self; FInput.parent := self;
FTslEditer := new TTslEditer(AOwner); FTslEditer := new TTslEditer(AOwner);
FTslEditer.ParentFont := false;
FTslEditer.dbclkcreate := false;
FTslEditer.Notification(FTslEditer,"change_editor_keys"); FTslEditer.Notification(FTslEditer,"change_editor_keys");
FTslEditer.FExecuteEditer.cannotadd := true; FTslEditer.FExecuteEditer.cannotadd := true;
FTslEditer.FExecuteEditer.onsaveclk := function(o,e) FTslEditer.FExecuteEditer.onsaveclk := function(o,e)
@ -402,11 +404,12 @@ type TProjectView = class(TVCForm) //
begin begin
app := initializeapplication(); app := initializeapplication();
app.font := array("width":ginfo["fontsize"],"height" :ginfo["fontsize"]*2); app.font := array("width":ginfo["fontsize"],"height" :ginfo["fontsize"]*2);
FTslEditer.font := array("width":ginfo["fontsize"],"height" :ginfo["fontsize"]*2);
NotifyComponent(self,ginfo); NotifyComponent(self,ginfo);
end end
end end
FTslEditer.Parent := AOwner; //FTslEditer.Parent := AOwner;
FTmfParser := new TTmfParser(); FTmfParser := new TTmfParser();
FTslParser := new ttslscripparser(); FTslParser := new ttslscripparser();
FTreeTool := new TToolBar(self); FTreeTool := new TToolBar(self);
@ -553,6 +556,11 @@ type TProjectView = class(TVCForm) //
if fopenbuzy then return ; if fopenbuzy then return ;
ftree.setsel(nd); ftree.setsel(nd);
end end
function getall_class_tsf();//列表
begin
ls := FTree.get_leaf_nodes();
return ls;
end
function OpenTreeNode(); //打开当前节点 function OpenTreeNode(); //打开当前节点
begin begin
if not FCProjectPath then return Messageboxa("工程没打开","提示",0,self); if not FCProjectPath then return Messageboxa("工程没打开","提示",0,self);
@ -895,8 +903,11 @@ type TProjectView = class(TVCForm) //
function ShowEditor(); //显示函数编辑 function ShowEditor(); //显示函数编辑
begin begin
FTslEditer.Show(SW_SHOWNOACTIVATE); // //FTslEditer.Show(SW_SHOWNOACTIVATE); //
FTslEditer.Show(); //
_wapi.bringWindowToTop(FTslEditer.Handle); _wapi.bringWindowToTop(FTslEditer.Handle);
it := FTslEditer.GetCurrentEditer();
if it then return it.SetFocus();
end end
function hiddeneditor(rc);//隐藏 function hiddeneditor(rc);//隐藏
begin begin
@ -965,9 +976,10 @@ type TProjectView = class(TVCForm) //
return r; return r;
end end
end end
function GoToAFunction(n); //Ìø×ªµ½º¯Êý function GoToAFunction(n,fn); //跳转到函数
begin begin
fn := FCurrentOpend.gettsfname(); if not fn then
fn := FCurrentOpend.gettsfname();
r := FTslEditer.GoToFunction(fn,n); r := FTslEditer.GoToFunction(fn,n);
saveformcode(fn); saveformcode(fn);
ShowEditor(); ShowEditor();
@ -1037,9 +1049,13 @@ type TProjectView = class(TVCForm) //
//FTfmComponets := array(); //FTfmComponets := array();
//FTmfParser.GetAllSubObjects(nil,FTfmComponets); //FTmfParser.GetAllSubObjects(nil,FTfmComponets);
FDesigner.LoadTreeNode(FTmfParser,inh,FCurrentOpend);
xx := FTslEditer.OpenAndGotoFileByName(FCurrentOpend.gettsfname()); xx := FTslEditer.OpenAndGotoFileByName(FCurrentOpend.gettsfname());
FDesigner.LoadTreeNode(FTmfParser,inh,FCurrentOpend);
FDesigner.EditerCodeChanged(FCurrentOpend); FDesigner.EditerCodeChanged(FCurrentOpend);
end else //缺少tfm文件
begin
xx := FTslEditer.OpenAndGotoFileByName(FCurrentOpend.gettsfname());
ShowEditor();
end end
fopenbuzy := false; fopenbuzy := false;
end else end else
@ -1330,7 +1346,7 @@ end
%%,n,nd.Fname,us); %%,n,nd.Fname,us);
ReWriteString(ph,r); ReWriteString(ph,r);
FTmfParser.ScriptPath := nd.gettmfname(); FTmfParser.ScriptPath := nd.gettmfname();
r := FTmfParser.inheritedcoy(n+"1",n,nd.Fname); r := FTmfParser.inheritedcopy(n+"1",n,nd.Fname);
ReWriteString(tfm,r); ReWriteString(tfm,r);
//ReWriteString((FCProjectPath+"resource.tfm"+fio+n+".tfm"),r); //ReWriteString((FCProjectPath+"resource.tfm"+fio+n+".tfm"),r);
end else end else
@ -2206,7 +2222,7 @@ BD141CA912494F502D48D224F45050274A21E03806FF2C7CA7516022D7D000000
function GoToFunction(fn,n); function GoToFunction(fn,n);
begin begin
it := OpenAndGotoFileByName(fn); it := OpenAndGotoFileByName(fn);
if it then it.GotoFunction(n); if it then return it.GotoFunction(n);
end end
function AddFunction(n,fn,finfo); //添加函数 function AddFunction(n,fn,finfo); //添加函数
begin begin
@ -2429,6 +2445,12 @@ type TFileTree = class(TTreeCtl)
end end
fprojectpath; fprojectpath;
fio; fio;
function get_leaf_nodes();
begin
leafs := array();
GetNodeLeafs(FPNode,leafs);
return leafs;
end
function GetInfo(dir,files); //获得信息 function GetInfo(dir,files); //获得信息
begin begin
leafs := array(); leafs := array();
@ -3117,6 +3139,7 @@ end
//////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////
function move_tfm_to_tsf(dir); function move_tfm_to_tsf(dir);
begin begin
if not(FileList("",dir+iofileseparator()+"resource.tfm"+iofileseparator()+"*.tfm")) then return ;
tsfs := array(); tsfs := array();
tfms := array(); tfms := array();
find_tsf_tfm(dir,tsfs,tfms); find_tsf_tfm(dir,tsfs,tfms);
@ -3248,41 +3271,6 @@ function LegalFolderName(n); //Ŀ¼
begin begin
return ifstring(n) and n and (1=ParseRegExpr("^[A-Za-z_]\\w{2,}$",n,v,vp,vl)) and (lowercase(n)<>"con"); return ifstring(n) and n and (1=ParseRegExpr("^[A-Za-z_]\\w{2,}$",n,v,vp,vl)) and (lowercase(n)<>"con");
end end
function createtslfunction(f);//¹¹Ô캯Êý
begin
n := f["name"];
p := f["param"];
b := f["body"];
ps := "";
if ifarray(p)then
begin
len := length(p);
for i := 0 to len-1 do
begin
v := p[i];
if ifstring(v)then ps += v;
if i<len-1 then ps += ";";
end
end
hs := nil;
vt := "";
if f["virtual"] then vt := "virtual;";
if ifstring(n) and ifstring(b)then
begin
//hs := "\r\nfunction "+n+"("+ps+");"+vt+"\r\n\tbegin\r\n"+b+"\r\n\tend\r\n";
bs := str2array(b,"\r\n");
bs2 := "";
for i,v in bs do
begin
if not v then continue;
bs2 += " "+v+"\r\n";
end
hs := "\r\n\ function "+n+"("+ps+");"+vt+"\r\n\ begin\r\n"+bs2+"\r\n\ end\r\n";
end
//hs := "\r\n\tfunction "+n+"("+ps+");"+vt+"\r\n\tbegin\r\n"+b+"\r\n\tend\r\n";
return hs;
end
function SetWndPostWithMouse(wnd,lft); function SetWndPostWithMouse(wnd,lft);
begin begin
{** {**

View File

@ -1229,12 +1229,23 @@ type TPageEditerItem=class(TPageItem)
p := crec[0]; p := crec[0];
if ifarray(p)then if ifarray(p)then
begin begin
tpl := FEditer.TopLine;
cxy := FEditer.CaretY;
FEditer.ExecuteCommand(FEditer.ecGotoXY,p); FEditer.ExecuteCommand(FEditer.ecGotoXY,p);
FEditer.ExecuteCommand(FEditer.ecString,fld+";\r\n "); FEditer.ExecuteCommand(FEditer.ecString,fld+";\r\n ");
if p[1]<cxy then
begin
FEditer.TopLine := tpl+1;
FEditer.CaretY := cxy+1;
end else
begin
FEditer.TopLine := tpl;
FEditer.CaretY := cxy;
end
end end
end end
end end
function getuses(); function getuses();//获取uses
begin begin
if not FTslParser then return 0; if not FTslParser then return 0;
d := GetClassInfo(); d := GetClassInfo();
@ -1262,8 +1273,19 @@ type TPageEditerItem=class(TPageItem)
p := rec[0]; p := rec[0];
if ifarray(p) then if ifarray(p) then
begin begin
FEditer.ExecuteCommand(FEditer.ecGotoXY,rec[0]); tpl := FEditer.TopLine;
FEditer.ExecuteCommand(FEditer.ecString,adus); cxy := FEditer.CaretY;
FEditer.ExecuteCommand(FEditer.ecGotoXY,rec[0]);
FEditer.ExecuteCommand(FEditer.ecString,adus);
if p[1]<cxy then
begin
FEditer.TopLine := tpl+1;
FEditer.CaretY := cxy+1;
end else
begin
FEditer.TopLine := tpl;
FEditer.CaretXY := cxy;
end
end end
end end
end end
@ -1305,11 +1327,23 @@ type TPageEditerItem=class(TPageItem)
if v["name"]=nfld then if v["name"]=nfld then
begin begin
frec := GetInfoRowCol2(v); frec := GetInfoRowCol2(v);
tpl := FEditer.TopLine;
cxy := FEditer.CaretY;
if ifarray(frec[0])and ifarray(frec[1])then if ifarray(frec[0])and ifarray(frec[1])then
begin begin
FEditer.ExecuteCommand(FEditer.ecGotoXY,frec[0]); FEditer.ExecuteCommand(FEditer.ecGotoXY,frec[0]);
FEditer.ExecuteCommand(FEditer.ecSelGotoXY,frec[1]); FEditer.ExecuteCommand(FEditer.ecSelGotoXY,frec[1]);
FEditer.SelText := nn?(nn+";"):""; FEditer.SelText := nn?(nn+";"):"";
if cxy>=frec[1,1] then //删除
begin
cn := frec[1,1]-frec[0,1];
FEditer.TopLine := tpl-cn;
FEditer.CaretY := cxy-cn;
end else
begin
FEditer.TopLine := tpl;
FEditer.CaretY := cxy;
end
end end
wek := v["dstatic"]; wek := v["dstatic"];
if wek then if wek then
@ -1332,12 +1366,11 @@ type TPageEditerItem=class(TPageItem)
FEditer.ExecuteCommand(FEditer.ecSelGotoXY,frec[1]); FEditer.ExecuteCommand(FEditer.ecSelGotoXY,frec[1]);
FEditer.SelText := nn?(nn+";"):""; FEditer.SelText := nn?(nn+";"):"";
end end
end end
end end
end end
end end
function GoToFunction(fn); function GoToFunction(fn);//定位到函数
begin begin
if not(ifstring(fn))then return false; if not(ifstring(fn))then return false;
nfld := lowercase(fn); nfld := lowercase(fn);
@ -1355,6 +1388,7 @@ type TPageEditerItem=class(TPageItem)
return true; return true;
end end
end end
return d["inherited",0];
end end
function AddFunction(fn,finfo); //添加函数 function AddFunction(fn,finfo); //添加函数
begin begin
@ -1429,6 +1463,7 @@ type TPageEditerItem=class(TPageItem)
if cp then cp.PrePareCompletion(t); if cp then cp.PrePareCompletion(t);
RepreComple := false; RepreComple := false;
end end
//////////转码/////////////////////////
function ToUnicode_big(); function ToUnicode_big();
begin begin
if FEnCode="UCS2-big" then return; if FEnCode="UCS2-big" then return;
@ -1497,6 +1532,7 @@ type TPageEditerItem=class(TPageItem)
FEnCode := "ANSI"; FEnCode := "ANSI";
end end
end end
///////////////////////////////
function SetLoadScript(s); //保存文件 function SetLoadScript(s); //保存文件
begin begin
if not ifstring(s)then return; if not ifstring(s)then return;
@ -1576,8 +1612,7 @@ type TPageEditerItem=class(TPageItem)
end end
function getmfunctioninfo(); function getmfunctioninfo();
begin begin
if not ftslparser2 then if not ftslparser2 then ftslparser2 := new ttslscripparser();
ftslparser2 := new ttslscripparser();
ftslparser2.Script :=FEditer.Text; ftslparser2.Script :=FEditer.Text;
return ftslparser2.gettslfunctions(); return ftslparser2.gettslfunctions();
end end
@ -1799,6 +1834,7 @@ type TEditer=class(TCustomcontrol) //
function Create(AOwner);override; function Create(AOwner);override;
begin begin
inherited; inherited;
fdbclkcreate := true;
if not Fhightercolor then if not Fhightercolor then
Fhightercolor := new thighlitcolor(self); Fhightercolor := new thighlitcolor(self);
FOpenHistory := new TMyarrayb(); FOpenHistory := new TMyarrayb();
@ -1980,7 +2016,7 @@ type TEditer=class(TCustomcontrol) //
DoControlAlign(); DoControlAlign();
end end
///////////////////// /////////////////////
FStatus.Items := array(("text":"","width":0.85),("text":"","width":0.16)); FStatus.Items := array(("text":"","width":0.7),("text":"","width":0.31));
///////////////////////////////////////// /////////////////////////////////////////
//FInfoShowWnd.Caption := "信息:"; //FInfoShowWnd.Caption := "信息:";
////构造节点//////////////////////////////////////////////////// ////构造节点////////////////////////////////////////////////////
@ -2041,6 +2077,7 @@ type TEditer=class(TCustomcontrol) //
sz := editorglobalinfo["fontsize"]; sz := editorglobalinfo["fontsize"];
sz2 := sz*2; sz2 := sz*2;
app.font := array("width":sz,"height":sz2); app.font := array("width":sz,"height":sz2);
self.font := array("width":sz,"height":sz2);
if not(r) or (ifarray( r ) and r["imgsize"]<>editorglobalinfo["imgsize"]) then NotifyComponent(fsyssizemgr,editorglobalinfo); if not(r) or (ifarray( r ) and r["imgsize"]<>editorglobalinfo["imgsize"]) then NotifyComponent(fsyssizemgr,editorglobalinfo);
end end
end end
@ -3407,6 +3444,7 @@ type TEditer=class(TCustomcontrol) //
end end
function CreateAFile(); //构造文件 function CreateAFile(); //构造文件
begin begin
if not fdbclkcreate then return ;
if FTslCacheDir then if FTslCacheDir then
begin begin
idx := 0; idx := 0;
@ -3885,6 +3923,7 @@ type TEditer=class(TCustomcontrol) //
end end
published //property 位置 published //property 位置
FHistoryDir; FHistoryDir;
property dbclkcreate read fdbclkcreate write fdbclkcreate;
property hltcolor read gethclor write sethclor; property hltcolor read gethclor write sethclor;
function showhltcolor(); function showhltcolor();
begin begin
@ -3982,13 +4021,15 @@ type TEditer=class(TCustomcontrol) //
fs := data["target"]; fs := data["target"];
finder := finder_set_info(data,ed.Text); finder := finder_set_info(data,ed.Text);
idx := 0; idx := 0;
rsult := finder.replace_all(r); rsult := finder.replace_all(r);
if rsult then if rsult then
begin begin
FFindListWnd.ffindstr := fs;
idx := length(rsult); idx := length(rsult);
ed.ExecuteCommand(ed.ecSelectAll); ed.ExecuteCommand(ed.ecSelectAll);
ed.SelText := r; ed.SelText := r;
lastidx := -1; lastidx := -1;
sct := integer((FFindListWnd.Width-10)/(FFindListWnd.font.Width))-17;
for i,v in rsult do for i,v in rsult do
begin begin
if i=0 then if i=0 then
@ -3997,12 +4038,11 @@ type TEditer=class(TCustomcontrol) //
if rdx=lastidx then continue; if rdx=lastidx then continue;
lastidx := rdx; lastidx := rdx;
if not ifstring(v[3]) then continue; if not ifstring(v[3]) then continue;
scap := format(" %d:(µÚ%dÐÐ) ",i,rdx)+limitstringlength(v[3]); scap := format(" %d:(第%d行) ",i,rdx)+ limitstringlength(v[3],sct);
FFindListWnd.AppendItem(array("caption":scap,"file":it.OrigScriptPath,"line":rdx)); FFindListWnd.AppendItem(array("caption":scap,"file":it.OrigScriptPath,"line":rdx));
end end
end end
end end
function Find_InFiles(d,o,rep,ct); function Find_InFiles(d,o,rep,ct);
begin begin
@ -4133,8 +4173,13 @@ type TEditer=class(TCustomcontrol) //
lastidx := -1; lastidx := -1;
if rsult then if rsult then
begin begin
if not fnoshow then
begin
FFindListWnd.ffindstr := fs;
end
rt := length(rsult); rt := length(rsult);
iits := 0; iits := 0;
sct := integer((FFindListWnd.Width-10)/(FFindListWnd.font.Width))-17;
for i,v in rsult do for i,v in rsult do
begin begin
if i=0 and (not fnoshow) then if i=0 and (not fnoshow) then
@ -4145,7 +4190,7 @@ type TEditer=class(TCustomcontrol) //
if rdx=lastidx then continue; if rdx=lastidx then continue;
lastidx := rdx; lastidx := rdx;
if not ifstring(v[3]) then continue; if not ifstring(v[3]) then continue;
scap := format(" %d:(µÚ%dÐÐ) ",i,rdx)+limitstringlength(v[3]); scap := format(" %d:(第%d行) ",i,rdx)+ limitstringlength(v[3],sct);
FFindListWnd.AppendItem(array("caption":scap,"file":it.OrigScriptPath,"line":rdx)); FFindListWnd.AppendItem(array("caption":scap,"file":it.OrigScriptPath,"line":rdx));
iits++; iits++;
if iits>80 then if iits>80 then
@ -4313,6 +4358,7 @@ type TEditer=class(TCustomcontrol) //
FGoBackB; // := new TMyarrayB(); FGoBackB; // := new TMyarrayB();
FRebackFlag; FRebackFlag;
FPageEditer; FPageEditer;
fdbclkcreate;
fcoolbar; fcoolbar;
ftoolbara; ftoolbara;
ftoolbarb; ftoolbarb;
@ -5281,15 +5327,18 @@ type TFindListWnd=class(TListBox) //
function Create(AOwner); function Create(AOwner);
begin begin
inherited; inherited;
//font := array("width":11,"height":22); ffindstr := "";
//ParentFont := false; ownerdraw := true;
{onnotification := function(o,e)begin ondrawlist := thisfunction(findbox_drawlist); //绘制
ms := e.message; end
if ifarray(ms) and ms[0] ="font" then function FontChanged(o);override;
begin begin
font := ms[1]; ft := font;
end if ft then
end } begin
if ownerdraw then ItemHeight := font.Height+4;
return inherited;
end
end end
function CheckListItem(s);override; function CheckListItem(s);override;
begin begin
@ -5302,6 +5351,62 @@ type TFindListWnd=class(TListBox) //
if not ifstring(r)then return ""; if not ifstring(r)then return "";
return r; return r;
end end
ffindstr; //查找的串
fignorcase;//忽略大小写
function findbox_drawlist(sender:tlistbox; evnt:tlistdrawevent; cvs:tcanvas; idx:integer; ARect:array of integer);
begin
ft := cvs.font;
w := ft.Width;
s := GetItemText(idx);
if not s then return ;
rc := ARect;
if pos("find:",s)=1 then
begin
ft.Color := 0xf0a000;
return cvs.DrawText(s,rc);
end
if ffindstr then
begin
x := 0;
ls := length(s);
ct := integer((rc[2]-rc[0])/w)-3;
if ct>1 and ct<ls then
begin
if bytetype(s,ct)=1 then
begin
s := s[1:(ct-1)]+"...";
end else s := s[1:ct]+"...";
end
p := 1;
ss := str2array(lowercase(s),lowercase(ffindstr));
lenf := length(ffindstr);
lenss := length(ss)-1;
for i,v in ss do
begin
if v then
begin
ft.Color := 0;
lenv := length(v);
rc[2] := lenv*w+x;
cvs.DrawText(s[p:(p+lenv-1)],rc);
x := rc[2];
rc[0] := x;
p+=lenv;
end
if x>ARect[2] then break;
if lenss>i then
begin
ft.Color := 244;
rc[2] := lenf*w+x;
cvs.DrawText(s[p:(p+lenf-1)],rc);
p+=lenf;
x := rc[2];
if x>ARect[2] then break;
rc[0] := x;
end
end
end
end
end end
type TFindWnd=class(TPage) type TFindWnd=class(TPage)
type TFindBtn=class(TBtn) type TFindBtn=class(TBtn)
@ -5775,8 +5880,6 @@ type TGoToLineWnd=class(TVCForm) //
function Create(AOwner);override; function Create(AOwner);override;
begin begin
inherited; inherited;
//ParentFont := false;
//font := array("width":10,"height":20);
wssizebox := false; wssizebox := false;
minmaxbox := false; minmaxbox := false;
WsDlgModalFrame := true; WsDlgModalFrame := true;
@ -5815,9 +5918,6 @@ type TGoToLineWnd=class(TVCForm) //
childsizing := array("layout":1,"leftrightspacing":5,"topbottomspacing":10,"verticalspacing":5,"controlsperline":3); childsizing := array("layout":1,"leftrightspacing":5,"topbottomspacing":10,"verticalspacing":5,"controlsperline":3);
autosize := true; autosize := true;
end end
function DoControlAlign();override;
begin
end
function ShowGoto(); function ShowGoto();
begin begin
show(); show();
@ -5937,6 +6037,7 @@ type tsyssizemgr = class(TVCForm)
pal.Parent := self; pal.Parent := self;
childsizing := array("layout":1,"controlsperline":2); childsizing := array("layout":1,"controlsperline":2);
pal.childsizing := array("layout":1,"controlsperline":2,"topbottomspacing":3); pal.childsizing := array("layout":1,"controlsperline":2,"topbottomspacing":3);
fpal2 := pal;
autosize := true; autosize := true;
fok.onclick := thisfunction(okclk); fok.onclick := thisfunction(okclk);
fcancel.onclick := thisfunction(cancelclk); fcancel.onclick := thisfunction(cancelclk);
@ -5948,6 +6049,7 @@ type tsyssizemgr = class(TVCForm)
ft := font; ft := font;
e.Height := ft.Height+5; e.Height := ft.Height+5;
e.Width := ft.Width*7; e.Width := ft.Width*7;
if fpal2 then e.Width :=fpal2.Width;
end end
function okclk(o,e); function okclk(o,e);
begin begin
@ -5982,7 +6084,8 @@ type tsyssizemgr = class(TVCForm)
setinfo(editorglobalinfo?:array()); setinfo(editorglobalinfo?:array());
center_popup_wnd(self); center_popup_wnd(self);
return ShowModal(); return ShowModal();
end end
fpal2;
fsysimg; fsysimg;
fsysfont; fsysfont;
end end
@ -6062,10 +6165,11 @@ function gettslexe();
begin begin
return static gettslexefullpath(); return static gettslexefullpath();
end end
function limitstringlength(s); function limitstringlength(s,n);
begin begin
return trim(s);
len := length(s); len := length(s);
n := 150; if not(n>30) then n := 150;
if len>n then if len>n then
begin begin
if bytetype(s,n)=1 then if bytetype(s,n)=1 then

View File

@ -133,6 +133,9 @@ type TFormatParser = class
"%%","(*","//","#!", "%%","(*","//","#!",
"<?tslx>", "<?tslx>",
"?>", "?>",
"...",
":>",":<",":<>", ":==",":>=",":<=",
"::>","::<","::<>", "::==","::>=","::<=",
//"0x","0O","0b", //"0x","0O","0b",
); );
TslSyn2 := array("div=","union2=","intersect=","outersect=","minus=","end.",); TslSyn2 := array("div=","union2=","intersect=","outersect=","minus=","end.",);

View File

@ -1013,9 +1013,7 @@ type TTslSynHighLighter = class(TSynHighLighter)
end end
tvi := s[idx]; tvi := s[idx];
if tvi=" " or tvi="\t" then if tvi=" " or tvi="\t" then
begin begin
SetTToken(tokens,const ccs,idx-1,array("%%")); SetTToken(tokens,const ccs,idx-1,array("%%"));
return ParserTokenLines(s,idx+1,e,ccs,tokens); return ParserTokenLines(s,idx+1,e,ccs,tokens);
end end
@ -1023,7 +1021,7 @@ type TTslSynHighLighter = class(TSynHighLighter)
end end
end else end else
begin begin
SetTToken(tokens,"%",idx-1); SetTToken(tokens,"%",idx-1);
idx--; idx--;
end end
end end
@ -1053,6 +1051,13 @@ type TTslSynHighLighter = class(TSynHighLighter)
SetTToken(tokens,"<",idx); SetTToken(tokens,"<",idx);
end end
end else end else
if vi="." and (idx<e-2) and s[idx+1]="." and s[idx+2]="." then //////////¼ÓÈë´¦Àí ...
begin
if ttk then
SetTToken(tokens,ttk,idx-1);
SetTToken(tokens,"...",idx+2);
idx+=2;
end else
if pos(vi,"`~@#$^&*)+-;,.?:[]|\\=><%/") then if pos(vi,"`~@#$^&*)+-;,.?:[]|\\=><%/") then
begin begin
if ttk then if ttk then
@ -1248,8 +1253,8 @@ type TTslSynHighLighter = class(TSynHighLighter)
end end
function GetLineTokens(idx);override; function GetLineTokens(idx);override;
begin begin
if idx<FSatesCount then if idx<FSatesCount then return FTokens[idx];
return FTokens[idx]; return nil;
end end
private private
function FindRightChar(c,s,b,e,zy); //²éÕÒ·â±ÕµÄ×Ö·û function FindRightChar(c,s,b,e,zy); //²éÕÒ·â±ÕµÄ×Ö·û

File diff suppressed because it is too large Load Diff

View File

@ -2717,6 +2717,11 @@ type tdbgvalueshowgrid=class(TDrawGrid)
end end
end end
PopupMenu := mu; PopupMenu := mu;
onfontchanged := function()begin
ft := font;
if not ft then return ;
ItemHeight := ft.Height+4;
end
end end
function DoDrawSubItem(o,e);override; function DoDrawSubItem(o,e);override;
begin begin

View File

@ -41,6 +41,7 @@ type TVclDesigner = class(tvcform)
FStopMenu; FStopMenu;
FProjectsManager; FProjectsManager;
FProjectManager; FProjectManager;
FTslParser;//解析器
//*************************** //***************************
function WrapProjectTo(); //打包当前 function WrapProjectTo(); //打包当前
begin begin
@ -116,7 +117,7 @@ type TVclDesigner = class(tvcform)
height := (integer(mx*32/twidth)+1)*32+60+30{+24}+5; height := (integer(mx*32/twidth)+1)*32+60+30{+24}+5;
end end
function TreeNode2tfmsub(lib,node,itemnames,nd);//tmf文件字符串 function TreeNode2tfmsub(lib,node,itemnames,nd,bshow);//tmf文件字符串
begin begin
if not(node) then if not(node) then
begin begin
@ -128,7 +129,7 @@ type TVclDesigner = class(tvcform)
if not tr then return ; if not tr then return ;
it := tr.RootItem; it := tr.RootItem;
node := (it.items)[0]; node := (it.items)[0];
ifnit := true; ifnit := true;
end end
if not ifarray(itemnames) then itemnames := array(); if not ifarray(itemnames) then itemnames := array();
if not ifarray(lib) then lib := array(); if not ifarray(lib) then lib := array();
@ -145,7 +146,7 @@ type TVclDesigner = class(tvcform)
begin begin
tcname := tc.name; tcname := tc.name;
tcclassname := tc.dclassname; tcclassname := tc.dclassname;
if not(tcclassname and tcname and ifstring(tcname) and ifstring(tcclassname)) then raise "错误!"; if not(tcclassname and tcname and ifstring(tcname) and ifstring(tcclassname)) then return " ";//raise "错误!"$" "$tcname$" "$tcclassname$"<<<<";
oorinh := (tc.isinherited)?"inherited ":"object "; oorinh := (tc.isinherited)?"inherited ":"object ";
ihp := ""; ihp := "";
if tc.isinherited then if tc.isinherited then
@ -153,8 +154,9 @@ type TVclDesigner = class(tvcform)
if ifstring(tc.inheritedparent) then if ifstring(tc.inheritedparent) then
begin begin
ihp := "("+tc.inheritedparent+")"; ihp := "("+tc.inheritedparent+")";
bshow := true;
end end
end end else bshow := true;
r+= oorinh + tcname +":"+tcclassname+ihp+"\r\n"; r+= oorinh + tcname +":"+tcclassname+ihp+"\r\n";
itemnames[length(itemnames)] := array(tcname,tcclassname); itemnames[length(itemnames)] := array(tcname,tcclassname);
cr := tc.GetChangedPublish(); cr := tc.GetChangedPublish();
@ -163,10 +165,18 @@ type TVclDesigner = class(tvcform)
if not(v and ifstring(i) and ifstring(v) ) then continue; //严格判断 if not(v and ifstring(i) and ifstring(v) ) then continue; //严格判断
r+=tab; r+=tab;
r+= i + "=" + v +"\r\n"; r+= i + "=" + v +"\r\n";
bshow := true;
end end
for i := 0 to node.ItemCount-1 do for i := 0 to node.ItemCount-1 do
begin begin
r += tablelines( TreeNode2tfmsub(lib,(node.items)[i],itemnames),tab); ibshow := false;
rri := TreeNode2tfmsub(lib,(node.items)[i],itemnames,nil,ibshow);
if ibshow then
begin
rr := tablelines( rri,tab);
r += rr;
bshow := true;
end
end end
r += "end"; r += "end";
end end
@ -469,12 +479,12 @@ type TVclDesigner = class(tvcform)
begin begin
Foh := o.height; Foh := o.height;
_send_(WM_USER,123,123,1); _send_(WM_USER,123,123,1);
e.skip := true;
return ; return ;
end end
SC_MINIMIZE: SC_MINIMIZE:
begin begin
e.skip := true; //e.skip := true;
return ;
end end
SC_DEFAULT: SC_DEFAULT:
begin begin
@ -487,6 +497,8 @@ type TVclDesigner = class(tvcform)
end end
SC_RESTORE: SC_RESTORE:
begin begin
Foh := o.height;
_send_(WM_USER,123,123,1);
end end
end; end;
@ -503,7 +515,7 @@ type TVclDesigner = class(tvcform)
begin begin
if e.wparam = 123 and e.lparam=123 then if e.wparam = 123 and e.lparam=123 then
begin begin
if o.height>Foh then if {o.height>Foh}true then
begin begin
o.height := Foh; //gtk 逻辑正确但是设置无效 o.height := Foh; //gtk 逻辑正确但是设置无效
end end
@ -911,8 +923,46 @@ type TVclDesigner = class(tvcform)
end end
end else end else
begin begin
FProjectManager.GoToAFunction(dv); inh := FProjectManager.GoToAFunction(dv);
return ; if not ifstring(inh) then return ;
////////////////父类中查找////////////////////////////////////////////
flg := true;
fs := FProjectManager.getall_class_tsf();
while flg and inh do //循环查找父类
begin
fn := 0;
for i,v in fs do //查找父类文件
begin
if v.fname=inh and v.FType<>"tsl" then
begin
fn := v.gettsfname();
break;
end
end
if not fn then break;//没找到文件退出
FTslParser.ScriptPath := fn;
ci := FTslParser.GetClassInfo();
for i,vf in ci["funcs"] do //对比函数名
begin
if dv=vf then
begin
flg := false;
break;
end
end
if flg then //没找到函数,继续找上一级父类
begin
inh := ci["inherited",0] ;
end else //找到函数,提示跳转
begin
if messageboxa("函数:"$dv$"在父类:"$inh$"中,是否打开","打开提示!",1,self)=IDOK then
begin
return FProjectManager.GoToAFunction(dv,v.gettsfname());
end
end
end
//////////////////////////////////////////////////////////////////
end end
end end
end end
@ -969,6 +1019,7 @@ type TVclDesigner = class(tvcform)
{** {**
@explan(说明) 组件被点击 %% @explan(说明) 组件被点击 %%
**} **}
uses utslvclevent;
nd := o._tag; nd := o._tag;
tr := nd.owner; tr := nd.owner;
if not(tr.visible) then if not(tr.visible) then
@ -977,6 +1028,20 @@ type TVclDesigner = class(tvcform)
FProjectManager.setnodesel(wnd); FProjectManager.setnodesel(wnd);
return ;// return ;//
end end
///////////////////特殊处理page控件///////////////////////////////////////////
if (o is class(TPageControl)) and (e is class(TMMouse)) then
begin
d := o.hittabat(e.pos);
if ifarray(d) then
begin
pid := d["idx"];
if (pid>=0) then
begin
o.SetPublish("cursel",pid,1);
end
end
end
///////////////////////////////////////////
if fselctlnode<> nd then if fselctlnode<> nd then
begin begin
//wd := o;//nd.Component.Cwnd; //wd := o;//nd.Component.Cwnd;
@ -1045,7 +1110,8 @@ type TVclDesigner = class(tvcform)
@explan(说明) 选择工具按钮 %% @explan(说明) 选择工具按钮 %%
**} **}
cct := o._tag; cct := o._tag;
FComponentCreater := cct; FComponentCreater := cct;
//if FProjectManager then FProjectManager.hiddeneditor();
end end
function CloseShowForm(o,e); //主窗口关闭 function CloseShowForm(o,e); //主窗口关闭
@ -1433,8 +1499,8 @@ type TVclDesigner = class(tvcform)
{$endif} {$endif}
compcwnd.Handle; compcwnd.Handle;
end end
comp.isinherited := d["inherited"];
comp.inheritedparent := d["parent"]; comp.inheritedparent := d["parent"];
comp.isinherited := d["inherited"];
comp.name := d["name"]; comp.name := d["name"];
obarray[d["name"]] := comp; obarray[d["name"]] := comp;
FVariableSelecter.additem(comp); FVariableSelecter.additem(comp);
@ -1511,7 +1577,7 @@ type TVclDesigner = class(tvcform)
rect := _wapi.GetScreenRect(); rect := _wapi.GetScreenRect();
twidth := (rect[2]-50); twidth := (rect[2]-50);
width := twidth; width := twidth;
height := 180; height := 190;
//calcheight(twidth); //calcheight(twidth);
caption := "TVCL界面设计器"; caption := "TVCL界面设计器";
FProjectsManager := new TProjectManagerForm(self); FProjectsManager := new TProjectManagerForm(self);
@ -1563,24 +1629,36 @@ type TVclDesigner = class(tvcform)
tparent.parent := FObjInspector; tparent.parent := FObjInspector;
pparent.parent := FObjInspector; pparent.parent := FObjInspector;
//FTree.parent := tparent; //FTree.parent := tparent;
/////////////////属性筛选////////////////////////////////
fsearch := new tedit(self);
fsearch.placeholder := "筛选";
fsearch.Align := alTop;
fsearch.autosize := true;
fsearch.parent := pparent;
fsearch.OnChange := function(o,e)begin
if FPropGrid then FPropGrid.searchidex := o.text;
if FEventGrid then FEventGrid.searchidex := o.text;
end
////////////////////////////////////////////////
pedits.parent := pparent ; pedits.parent := pparent ;
FProp.parent := pedits; FProp.parent := pedits;
FEvent.parent := pedits; FEvent.parent := pedits;
FPropGrid.align := alclient; FPropGrid.align := alclient;
FEventGrid.align := alclient; FEventGrid.align := alclient;
FPropGrid.parent := FProp; FPropGrid.parent := FProp;
FEventGrid.parent := FEvent; FEventGrid.parent := FEvent;
Mobjinspect();
onactivate := thisfunction(OnDesignerActivate); onactivate := thisfunction(OnDesignerActivate);
fdimagelist := new TDesigImageList(self); fdimagelist := new TDesigImageList(self);
global editorglobalinfo ; global editorglobalinfo ;
if ifarray(editorglobalinfo) and editorglobalinfo then if ifarray(editorglobalinfo) and editorglobalinfo then
begin begin
fdimagelist.imgsize := editorglobalinfo["imgsize"]; fdimagelist.imgsize := editorglobalinfo["imgsize"];
sz := editorglobalinfo["fontsize"] ;
if sz>5 then FObjInspector.width :=sz*34+20;
end end
Mobjinspect();
//FTree.Imagelist := fdimagelist; //FTree.Imagelist := fdimagelist;
fwindowinfos := new tfilesinfo(self,thisfunction(ClickTreeNode),fdimagelist,tparent); fwindowinfos := new tfilesinfo(self,thisfunction(ClickTreeNode),fdimagelist,tparent);
//******************toolbar *************** //******************toolbar ***************
@ -1646,6 +1724,7 @@ type TVclDesigner = class(tvcform)
fdimagelist.imgsize := d["imgsize"]; fdimagelist.imgsize := d["imgsize"];
end end
end ; end ;
FTslParser := new unit(utslvclsyntaxparser).ttslscripparser();
//OnChange //OnChange
//fnewmenu //fnewmenu
end end
@ -1988,42 +2067,41 @@ type TPropEditGrid = class(TPropGrid) //
function SetComponent(v);override; function SetComponent(v);override;
begin begin
if v=FComponent then exit; if v=FComponent then exit;
ocls := Columns;
if v is class(TDComponent) then if v is class(TDComponent) then
begin begin
TSLData := v.GetPublishProperties(); TSLData := getneedpublished(v);//
end else end else
begin begin
TSLData := array();//array(NIL); TSLData := array();//array(NIL);
end end
inherited; inherited;
if ocls then
begin
w := ocls[1,"width"];
if w>0 then
begin
i := 1;
self.ColumnWidth(1) := w;
end
end
end end
public public
function Create(AOwner); function Create(AOwner);
begin begin
inherited; inherited;
FobjProptype := p_properys; FobjProptype := p_properys;
end end
function getneedpublished(v);virtual;
begin
return v.GetPublishProperties();
end
end end
type TEventEditGrid = class(TPropGrid) //事件编辑器 type TEventEditGrid = class(TPropEditGrid) //事件编辑器
{** {**
@explan(说明) 事件编辑 %% @explan(说明) 事件编辑 %%
**} **}
protected
function SetComponent(v);override;
begin
if v=FComponent then exit;
if v is class(TDComponent) then
begin
TSLData := v.GetPublishEvents();
//echo tostn(TSLData);
end else
begin
TSLData := array(NIL);
end
inherited;
end
public public
function Create(AOwner); function Create(AOwner);
begin begin
@ -2031,6 +2109,10 @@ type TEventEditGrid = class(TPropGrid) //
FobjProptype := p_evnets; FobjProptype := p_evnets;
OndblClick := thisfunction(GridCellDblClick); OndblClick := thisfunction(GridCellDblClick);
end end
function getneedpublished(v);override;
begin
return v.GetPublishEvents();
end
function GridCellDblClick(o,e);override;//双击处理 function GridCellDblClick(o,e);override;//双击处理
begin begin
i := e.iitem; i := e.iitem;

View File

@ -55,7 +55,7 @@ type TGridPropertyRender = class(TGCellRender) //
inherited; inherited;
Owner := AOwner; Owner := AOwner;
end end
Owner ; [weakref]Owner ;
end end
type TGridCellEditWithButton = class(TGridPropertyRender) //带按钮的单元格编辑 type TGridCellEditWithButton = class(TGridPropertyRender) //带按钮的单元格编辑
{** {**
@ -387,7 +387,6 @@ type TListVariable = class(TGridList)
SetColumnWidth(0,Width-11); SetColumnWidth(0,Width-11);
end end
end end
function create(AOwner);override; function create(AOwner);override;
begin begin
inherited; inherited;
@ -397,6 +396,11 @@ type TListVariable = class(TGridList)
Columns := array( Columns := array(
("text":"variable","width":180) ("text":"variable","width":180)
); );
OnFontChanged := function()begin
ft := font;
if not ft then return ;
ItemHeight := ft.height+6;
end
end end
function SetSelectedByValue(v_);override; function SetSelectedByValue(v_);override;
begin begin
@ -458,7 +462,7 @@ type TListStr = class(TListVariable)
function create(AOwner);override; function create(AOwner);override;
begin begin
inherited; inherited;
Columns := array(("text":"´ò¿ª±à¼­Æ÷","width":160)); Columns := array(("text":"±à¼­Æ÷","width":160));
end end
function additem(v);override; function additem(v);override;
begin begin
@ -913,7 +917,7 @@ type TTSLDataGrid=class(TDrawGrid)
@explan(说明)TSL数组和对象展示 %% @explan(说明)TSL数组和对象展示 %%
**} **}
private private
fsearchidex;
FCols; FCols;
Fdata; Fdata;
FObjectData; FObjectData;
@ -922,7 +926,7 @@ type TTSLDataGrid=class(TDrawGrid)
FRows; FRows;
FShowTwo; FShowTwo;
FCControls; FCControls;
FColumnWidth; FdfColumnWidth;
FRowHeader; FRowHeader;
static FGCellRender; static FGCellRender;
FCanEditStr; FCanEditStr;
@ -992,6 +996,14 @@ type TTSLDataGrid=class(TDrawGrid)
return FGCellRender[n]; return FGCellRender[n];
end end
private private
function setsearchidex(s);
begin
if fsearchidex<>s and ifstring(s) then
begin
fsearchidex := s;
InvalidateRect(nil,false);
end
end
function SetRowHeader(v); function SetRowHeader(v);
begin begin
nv := v?true:false; nv := v?true:false;
@ -1045,16 +1057,17 @@ type TTSLDataGrid=class(TDrawGrid)
begin begin
fcs[0]:= array("text":" ","width":min(500,wd)); fcs[0]:= array("text":" ","width":min(500,wd));
end end
cw := 15* ftwidth;
if FCL and allFCL and FShowTwo then if FCL and allFCL and FShowTwo then
begin begin
FCols := FCl; FCols := FCl;
for i,v in FCols do for i,v in FCols do
begin begin
fcs[length(fcs)]:= array("text":ifstring(v)?v:inttostr(v),"width":FMRWD); fcs[length(fcs)]:= array("text":ifstring(v)?v:inttostr(v),"width":cw);
end end
end else end else
begin begin
fcs[length(fcs)]:= array("text":" ","width":ColumnWidth>20?ColumnWidth:100); fcs[length(fcs)]:= array("text":" ","width":fdfColumnWidth>20?fdfColumnWidth:cw);
end end
Columns := fcs; Columns := fcs;
ItemCount := length(FRows); ItemCount := length(FRows);
@ -1146,6 +1159,7 @@ type TTSLDataGrid=class(TDrawGrid)
end end
end end
public public
property searchidex read fsearchidex write setsearchidex;
function create(AOwner);override; function create(AOwner);override;
begin begin
inherited; inherited;
@ -1162,7 +1176,7 @@ type TTSLDataGrid=class(TDrawGrid)
FStringAlign := AL9_CENTERLEFT; FStringAlign := AL9_CENTERLEFT;
FDefAlign := AL9_CENTER; FDefAlign := AL9_CENTER;
end end
function InitializeWnd();override; function InitializeWnd();override;
begin begin
inherited; inherited;
@ -1242,6 +1256,10 @@ type TTSLDataGrid=class(TDrawGrid)
begin begin
ds := d; ds := d;
//dc.drawtext(ds,src); //dc.drawtext(ds,src);
if j=0 and fsearchidex and pos(lowercase(fsearchidex),lowercase(d)) then
begin
dc.font.color := 0xff;
end
class(TLabel).CanvasDrawAlignText(dc,src,ds,FStringAlign); class(TLabel).CanvasDrawAlignText(dc,src,ds,FStringAlign);
end else end else
if ifobj(d)then if ifobj(d)then
@ -1267,12 +1285,8 @@ type TTSLDataGrid=class(TDrawGrid)
begin begin
dc := e.canvas; dc := e.canvas;
rc := e.rcitem; rc := e.rcitem;
{if SelectedRow = e.id then c := color;
if ifnumber(SelectRowColor) then dc.brush.color := SelectRowColor; if c then dc.brush.color := c; //
else
dc.brush.color := rgb(150,150,150);
else }
if color then dc.brush.color := color; //
else dc.brush.color := rgb(255,255,255); else dc.brush.color := rgb(255,255,255);
dc.fillrect(rc); dc.fillrect(rc);
inherited; inherited;
@ -1315,9 +1329,8 @@ type TTSLDataGrid=class(TDrawGrid)
begin begin
if d["type"]="object" then if d["type"]="object" then
begin begin
rd := GetCellRender(d["class"]); rd := GetCellRender(d["class"]);
if rd then return rd.CelldbClick(o,e,d); ///////////
if r then return r.CelldbClick(o,e,d);
end end
getitemcontrol(d,p,e.iitem,cl,"grid",cp,indexs); getitemcontrol(d,p,e.iitem,cl,"grid",cp,indexs);
end else end else
@ -1362,24 +1375,6 @@ type TTSLDataGrid=class(TDrawGrid)
end end
end end
return r; return r;
idx := "FData";
for i,v in index do
begin
if ifnumber(v)then idx += format("[%d]",v);
else if ifstring(v)then
begin
idx += format('["%s"]',v);
end
end
if length(idx)>5 then
begin
vals := idx+":="+tostn(val)+";"; //FData["c"]["value"]:=0;
try
eval(&vals);
except
//echo "===errr";
end;
end
end end
function ControlIndexs(dx); function ControlIndexs(dx);
begin begin
@ -1460,7 +1455,7 @@ type TTSLDataGrid=class(TDrawGrid)
end end
property Twodimensional:bool read FShowTwo write SetTwoD; property Twodimensional:bool read FShowTwo write SetTwoD;
property TSLdata:variable read GetTSLData write SetData; property TSLdata:variable read GetTSLData write SetData;
property ColumnWidth:integer read FColumnWidth write FColumnWidth; property dfColumnWidth:integer read FdfColumnWidth write FdfColumnWidth;
property RowHeader:bool read FRowHeader write SetRowHeader; property RowHeader:bool read FRowHeader write SetRowHeader;
property CanEditStr:bool read FCanEditStr write FCanEditStr; property CanEditStr:bool read FCanEditStr write FCanEditStr;
property StringAlign:AlignStyle9 read FStringAlign write SetStringAlign; property StringAlign:AlignStyle9 read FStringAlign write SetStringAlign;
@ -3051,6 +3046,7 @@ private
public public
function create(aOwner);override;begin function create(aOwner);override;begin
inherited; inherited;
ParentFont := false;
caption:="TreeViewEditor"; caption:="TreeViewEditor";
left:=300; left:=300;
top:=300; top:=300;
@ -3256,13 +3252,15 @@ type TMultiSelList = class(TCustomControl)
function Create(AOwner); function Create(AOwner);
begin begin
inherited; inherited;
FBtnWidth := 80;
border := true;
FList := new TListBox(self); FList := new TListBox(self);
FList.checkbox := true;
FList.Multisel := 2; FList.Multisel := 2;
//FList.Appenditems(array("a","b","c")); //FList.Appenditems(array("a","b","c"));
FList.setCurrentSelection(array(0,1)); FList.setCurrentSelection(array(0,1));
FList.parent := self; FList.parent := self;
FOkBtn := new TBTN(self); FOkBtn := new TBTN(self);
FBtnWidth := 80;
FOkBtn.width := FBtnWidth; FOkBtn.width := FBtnWidth;
FOkBtn.caption := "确定"; FOkBtn.caption := "确定";
FOkBtn.parent := self; FOkBtn.parent := self;
@ -3272,7 +3270,20 @@ type TMultiSelList = class(TCustomControl)
FCanceBtn.parent := self; FCanceBtn.parent := self;
FCanceBtn.onclick := thisfunction(CancelClick); FCanceBtn.onclick := thisfunction(CancelClick);
FOkBtn.onclick := thisfunction(okClick); FOkBtn.onclick := thisfunction(okClick);
OnFontChanged := thisfunction(DoControlAlign);
end end
{function FontChanged(o);override;
begin
ft := font;
if not ft then return ;
inherited;
FBtnWidth := 5*ft.width;
FOkBtn.height := ft.height+5;
Fokbtn.width := FBtnWidth;
FCanceBtn.height := ft.height+5;
FCanceBtn.width := FCanceBtn;
end }
function GetSelectdata(); function GetSelectdata();
begin begin
idx := FList.getSelectedIndexes(); idx := FList.getSelectedIndexes();
@ -3319,18 +3330,24 @@ type TMultiSelList = class(TCustomControl)
end end
function DoControlAlign();override; function DoControlAlign();override;
begin begin
if FList and FOkBtn AND FCanceBtn then ft := font;
if ft and FList and FOkBtn AND FCanceBtn then
begin begin
r := ClientRect; r := ClientRect;
h := FOkBtn.height; h :=ft.height+4;
w :=ft.width*5;
c := r; c := r;
c[3]-=h+4; c[3]-=h+4;
FList.SetBoundsRect(c); FList.SetBoundsRect(c);
bt := r[3]-h-1; bt := r[3]-h-1;
FOkBtn.height := h;
FOkBtn.width := w;
FOkBtn.Top := bt; FOkBtn.Top := bt;
FOkBtn.Left := r[2]-FBtnWidth-5; FOkBtn.Left := r[2]-w-5;
FCanceBtn.top := bt; FCanceBtn.top := bt;
FCanceBtn.Left := r[2]-FBtnWidth-FBtnWidth-10; FCanceBtn.height := h;
FCanceBtn.width := w;
FCanceBtn.Left := r[2]-w*2-10;
end end
end end
function CancelClick(o,e); function CancelClick(o,e);

View File

@ -958,6 +958,12 @@ type tsltoken = class(tslparserbase) //
vf := 1; vf := 1;
setdata(FTokens,nk,v,"»Ø³µ",pos,hh); setdata(FTokens,nk,v,"»Ø³µ",pos,hh);
end else end else
if v="." and (pos< len-2) and str[pos+1]="." and str[pos+2]="." then
begin
if length(vs)then setdata(FTokens,nk,vs,"Óï¾ä",pos,hh);
setdata(FTokens,nk,"...","Óï¾ä",pos,3);
pos+=2;
end else
if v in array(",",";",".","]","[",":","=","!")then if v in array(",",";",".","]","[",":","=","!")then
begin begin
if length(vs)then setdata(FTokens,nk,vs,"Óï¾ä",pos,hh); if length(vs)then setdata(FTokens,nk,vs,"Óï¾ä",pos,hh);

Binary file not shown.

View File

@ -248,7 +248,7 @@ private
if op=opRemove or op=opInsert then return 0; if op=opRemove or op=opInsert then return 0;
if fonnotification then if fonnotification then
begin begin
e := new tuieventbase(op,0,0,0); e := new unit(utslvclevent).tmnotif(op);
e.sender := a; e.sender := a;
CallMessgeFunction(fonnotification,self(true),e); CallMessgeFunction(fonnotification,self(true),e);
return e.skip; return e.skip;
@ -258,7 +258,7 @@ private
begin begin
if foninqurequit then if foninqurequit then
begin begin
e := new tuieventbase(0,0,0,0); e := new unit(utslvclevent).tminqurequit();//tuieventbase(0,0,0,0);
CallMessgeFunction(foninqurequit,self(true),e); CallMessgeFunction(foninqurequit,self(true),e);
return e.skip; return e.skip;
end end
@ -335,12 +335,6 @@ public //
FEventsProperties := array(); FEventsProperties := array();
FVariableProperties := array(); FVariableProperties := array();
FComponentCreated := true; FComponentCreated := true;
return;
If AOwner is class(tcomponent)then
begin
FOwner := AOwner;
AOwner.InsertComponent(Self);
end
end end
function set_loadstate(v); //设置loading状态 function set_loadstate(v); //设置loading状态
begin begin
@ -519,30 +513,6 @@ public //
FChangedinheritedProperties; FChangedinheritedProperties;
FChangedProperties; FChangedProperties;
FVariableProperties; FVariableProperties;
{function GetPublishInfo();//属性获取
begin
r := publishs();
rr := array();
ri := 0;
for i,v in r do
begin
if ifstring(v) then rr[ri++] := lowercase(v);
end
return rr;
end }
{function OrderPublish(r,od); //排序发布的东西
begin
if od then
begin
r1 := array();
for i,v in od do
begin
vi := r[v];
if vi then r1[v]:= vi;
end
r := r1;
end
end}
public //设计器属性设置相关 public //设计器属性设置相关
function GetPublishproperties();virtual; //获得属性信息 function GetPublishproperties();virtual; //获得属性信息
begin begin
@ -551,7 +521,6 @@ public //
**} **}
ps := GetPropInfo(); ps := GetPropInfo();
r := array(); r := array();
//pps := GetPublishInfo();
for i,v in ps do for i,v in ps do
begin begin
typ := v["type"]; typ := v["type"];
@ -561,7 +530,6 @@ public //
if otype then if otype then
begin begin
n := v["name"]; n := v["name"];
//if pps and not(n in pps)then continue;
if typ in array("variable","popupmenu","syscursor","tmainmenu")then if typ in array("variable","popupmenu","syscursor","tmainmenu")then
begin begin
r[n]:= otype.FormatEdit(FVariableProperties[n],v["write"]?true:false); r[n]:= otype.FormatEdit(FVariableProperties[n],v["write"]?true:false);
@ -676,7 +644,6 @@ public //
if ifobj(otype)then if ifobj(otype)then
begin begin
iv := otype.UnformatEdit(v); //反转换 iv := otype.UnformatEdit(v); //反转换
//if FChangedProperties[n]=vi then continue; //没有改变
if FChangedProperties[n]=iv then continue; //没有改变 if FChangedProperties[n]=iv then continue; //没有改变
SetChangedPublish(n,iv,pp); //保存 SetChangedPublish(n,iv,pp); //保存
if n="visible" or n="wspopup" or n="enabled" then if n="visible" or n="wspopup" or n="enabled" then
@ -724,7 +691,6 @@ public //
@param(ComponentStyle)() 样式结合 %% @param(ComponentStyle)() 样式结合 %%
@param(ComponentCreated)(bool) 样式结合 %% @param(ComponentCreated)(bool) 样式结合 %%
**} **}
//property DesignInfo read FDesignInfo write FDesignInfo;
property ComponentCreated read FComponentCreated; property ComponentCreated read FComponentCreated;
property Components read FComponents; property Components read FComponents;
property ComponentState read FComponentState write SetComponentState; property ComponentState read FComponentState write SetComponentState;

View File

@ -441,42 +441,66 @@ type tcontrol = class(tcomponent)
{** {**
@explan(说明)根据消息参数构造消息对象; @explan(说明)根据消息参数构造消息对象;
**} **}
if message in array(WM_MOUSEMOVE,WM_LBUTTONDOWN, case message of
WM_CLOSE :
begin
r := new tmclose(message,wparam,lparam,hwnd);
end
WM_MOUSEMOVE :
begin
r := new tmm_move(message,wparam,lparam,hwnd);
end
WM_CONTEXTMENU :
begin
r := new tmcontextpop(message,wparam,lparam,hwnd);
end
WM_LBUTTONDOWN,
WM_RBUTTONDOWN,WM_LBUTTONUP, WM_RBUTTONDOWN,WM_LBUTTONUP,
WM_RBUTTONUP,WM_LBUTTONDBLCLK, WM_RBUTTONUP,WM_LBUTTONDBLCLK,
WM_RBUTTONDBLCLK,WM_MBUTTONDOWN,WM_MBUTTONUP,WM_MBUTTONDBLCLK)then WM_RBUTTONDBLCLK,WM_MBUTTONDOWN,WM_MBUTTONUP,WM_MBUTTONDBLCLK :
begin begin
r := new TMMouse(message,wparam,lparam,hwnd); r := new TMMouse(message,wparam,lparam,hwnd);
end else end
if message=WM_MENUSELECT then WM_MENUSELECT :
begin begin
r := new TMMENUSELECT(message,wparam,lparam,hwnd); r := new TMMENUSELECT(message,wparam,lparam,hwnd);
end else end
if message=WM_MEASUREITEM then WM_MEASUREITEM :
begin begin
r := new TMMEASUREITEM(message,wparam,lparam,hwnd); r := new TMMEASUREITEM(message,wparam,lparam,hwnd);
end else end
if message in array(WM_KEYDOWN,WM_KEYUP,WM_CHAR,WM_SYSCHAR,WM_SYSKEYDOWN,WM_SYSKEYUP)THEN WM_ACTIVATE :
begin begin
r := new TMKEY(message,wparam,lparam,hwnd); r := new tmactivate(message,wparam,lparam,hwnd);
end else end
if message=WM_DRAWITEM then WM_KEYDOWN,WM_KEYUP,
begin WM_SYSCHAR,WM_SYSKEYDOWN,WM_SYSKEYUP :
r := new TMDRAWITEM(message,wparam,lparam,hwnd); begin
end else r := new TMKEY(message,wparam,lparam,hwnd);
if message=WM_NOTIFY then end
begin WM_CHAR:
r := new TMNOTIFY(message,wparam,lparam,hwnd); begin
end else r := new tmk_press(message,wparam,lparam,hwnd);
if message=WM_MOUSEWHEEL then end
begin WM_DRAWITEM :
r := new TMMOUSEWHEEL(message,wparam,lparam,hwnd); begin
end else r := new TMDRAWITEM(message,wparam,lparam,hwnd);
if message=WM_STYLECHANGED or message=WM_STYLECHANGING then end
begin WM_NOTIFY :
r := new TMSTYLECHANG(message,wparam,lparam,hwnd); begin
end else r := new TMNOTIFY(message,wparam,lparam,hwnd);
r := new tuieventbase(message,wparam,lparam,hwnd); end
WM_MOUSEWHEEL :
begin
r := new TMMOUSEWHEEL(message,wparam,lparam,hwnd);
end
WM_STYLECHANGED ,WM_STYLECHANGING :
begin
r := new TMSTYLECHANG(message,wparam,lparam,hwnd);
end
else
r := new tuieventbase(message,wparam,lparam,hwnd);
end ;
return r; return r;
//return new tuieventbase(message,wparam,lparam,hwnd); //return new tuieventbase(message,wparam,lparam,hwnd);
end end
@ -1014,7 +1038,7 @@ type tcontrol = class(tcomponent)
function WMMove(o,e):LM_MOVE;virtual; function WMMove(o,e):LM_MOVE;virtual;
begin begin
if not NoRecycled() then return ; if not NoRecycled() then return ;
CallMessgeFunction(OnMove,o,e); CallMessgeFunction(fOnMove,o,e);
if (o is class(TWinControl)) and o.WsPopUp then return ; if (o is class(TWinControl)) and o.WsPopUp then return ;
if (Align=alNone) then if (Align=alNone) then
begin begin
@ -1029,7 +1053,7 @@ type tcontrol = class(tcomponent)
function WMSize(o,e):LM_SIZE;virtual; function WMSize(o,e):LM_SIZE;virtual;
begin begin
if not NoRecycled() then return ; if not NoRecycled() then return ;
CallMessgeFunction(OnSize,o,e); CallMessgeFunction(fOnSize,o,e);
DoWMSIZE(o,e); DoWMSIZE(o,e);
p := Parent ; p := Parent ;
if p and p.childsizing.layout>0 then return p.AdjustSize(); if p and p.childsizing.layout>0 then return p.AdjustSize();
@ -1580,7 +1604,7 @@ type tcontrol = class(tcomponent)
@param(Cursor)(tcursor 通过 member of TSystemCursor 设置) 系统鼠标 %% @param(Cursor)(tcursor 通过 member of TSystemCursor 设置) 系统鼠标 %%
**} **}
property Font:font read GetControlFont write SetControlFont;//write SetFont; property Font:font read GetControlFont write SetControlFont;//write SetFont;
property OnMouseWheel read FOnMouseWheel write FOnMouseWheel; property OnMouseWheel:eventhandler read FOnMouseWheel write FOnMouseWheel;
{** {**
@param(Caption)(string) 控件标题 %% @param(Caption)(string) 控件标题 %%
@param(Enabled)(bool) 控件是否有效 %% @param(Enabled)(bool) 控件是否有效 %%

View File

@ -18,6 +18,7 @@ type tcustomcontrol=class(TWinControl)
cvs.rcpaint := PAINTSTRUCT().rcpaint(); cvs.rcpaint := PAINTSTRUCT().rcpaint();
try try
Paint(); Paint();
inherited;
finally finally
cvs.Handle := 0; cvs.Handle := 0;
end; end;

View File

@ -33,10 +33,10 @@ function ExitMessageLoop(); //
function NotifyComponent(Sender,Act,ToComponent); //notfiy function NotifyComponent(Sender,Act,ToComponent); //notfiy
//////////////////////操作///////////////////// //////////////////////操作/////////////////////
Function tslcstructure(data,dsize,pack,ptr); Function tslcstructure(data,dsize,pack,ptr);
//function CompareRect(orect,nrect); //function CompareRect(orect,nrect);
function calldatafunction(); function calldatafunction();
function CallMessgeFunction(f,o,e); function CallMessgeFunction(f,o,e);
function CallMessageFunction(f,o,e); //执行消息回调
//////////////////////执行tsl脚本代码//////////////////// //////////////////////执行tsl脚本代码////////////////////
//function TSL_Check(func,funclen,oResult); //function TSL_Check(func,funclen,oResult);
function CheckTslCode(code,err); //检查tsl语法 function CheckTslCode(code,err); //检查tsl语法
@ -1276,6 +1276,7 @@ type TpanelForm=class(tpanel) //
protected protected
function SetWsPopUp(v);override; function SetWsPopUp(v);override;
begin begin
if self(true).classinfo()["classname"]<>"tdcreatepanel" then return inherited;
if csDesigning in ComponentState then if csDesigning in ComponentState then
begin begin
end else end else
@ -1285,6 +1286,7 @@ type TpanelForm=class(tpanel) //
end end
function GetWsPopUp();override; function GetWsPopUp();override;
begin begin
if self(true).classinfo()["classname"]<>"tdcreatepanel" then return inherited;
if csDesigning in ComponentState then if csDesigning in ComponentState then
begin begin
return true; return true;
@ -1317,7 +1319,7 @@ type TpanelForm=class(tpanel) //
end end
function SetDesigning(f,fc);override; function SetDesigning(f,fc);override;
begin begin
if f then wspopup := true; if f and (self(true).classinfo()["classname"]="tdcreatepanel") then wspopup := true;
inherited; inherited;
end end
end end
@ -1489,8 +1491,7 @@ type tmemo = class(TSynMemoNorm) //
function DoTextChanged(p);override;//文本改变 function DoTextChanged(p);override;//文本改变
begin begin
inherited; inherited;
if Fonchange then CallMessgeFunction(Fonchange,self(true));
calldatafunction(Fonchange,self(true),new tuieventbase(0,0,0,0));
end end
function GetPreferredSize(w,h);override; function GetPreferredSize(w,h);override;
begin begin
@ -3591,8 +3592,7 @@ type TListView = class(TDrawGrid)
end end
function CallSelChanged(); function CallSelChanged();
begin begin
if OnSelChanged then CallMessgeFunction(FSelectedChanged,self(true));
return calldatafunction(OnSelChanged,self(true),new tuieventbase(0,0,0,0));
end end
function SetCanSelected(v); function SetCanSelected(v);
begin begin
@ -5203,7 +5203,7 @@ type TQuotations=class(tcomponent)
**} **}
if not ifarray(d)then exit; if not ifarray(d)then exit;
FData := d; FData := d;
calldatafunction(FOncallBack,self(true)); CallMessgeFunction(FOncallBack,self(true));
end end
public public
function create(AOwner);override; function create(AOwner);override;
@ -6530,6 +6530,10 @@ function GetTextWidthAndHeightWidthFont(s,f,mul);//
begin begin
return unit(utslvclgdi).GetTextWidthAndHeightWidthFont(s,f,mul); return unit(utslvclgdi).GetTextWidthAndHeightWidthFont(s,f,mul);
end end
function CallMessageFunction(f,o,e); //执行消息回调
begin
return unit(utslvclauxiliary).CallMessgeFunction(f,o,e);
end
function CallMessgeFunction(f,o,e); //执行消息回调 function CallMessgeFunction(f,o,e); //执行消息回调
begin begin
return unit(utslvclauxiliary).CallMessgeFunction(f,o,e); return unit(utslvclauxiliary).CallMessgeFunction(f,o,e);

View File

@ -64,6 +64,11 @@ type tuieventbase=class(TSLUICONST)
Lparam := l; Lparam := l;
Hwnd := h; Hwnd := h;
end end
function expandinfo();virtual; //作为函数参数展开
begin
//返回二维数组,字段 name ,var,alias,type
return array();
end
function hilparam(); function hilparam();
begin begin
{** {**

View File

@ -62,6 +62,7 @@ type TWinControl = class(tcontrol)
FWsDlgModalFrame; FWsDlgModalFrame;
private //模态相关 private //模态相关
//*******showmodal****************** //*******showmodal******************
fmodalcenter;//模态居中
FModaling; FModaling;
FModalCode; FModalCode;
FMinWidth; FMinWidth;
@ -129,6 +130,7 @@ type TWinControl = class(tcontrol)
FMSG := new TTagMSG(); FMSG := new TTagMSG();
msg := FMSG._getptr_; msg := FMSG._getptr_;
//显示自己 //显示自己
center_self();
_wapi.ShowWindow(hWnd,SW_SHOW); _wapi.ShowWindow(hWnd,SW_SHOW);
_wapi.BringWindowToTop(hWnd); _wapi.BringWindowToTop(hWnd);
//disable掉父窗口 //disable掉父窗口
@ -918,7 +920,7 @@ type TWinControl = class(tcontrol)
function WMACTIVATE(o,e):WM_ACTIVATE;virtual; function WMACTIVATE(o,e):WM_ACTIVATE;virtual;
begin begin
factivated := e.wparam; factivated := e.wparam;
CallMessgeFunction(OnActivate,o,e); CallMessgeFunction(fOnActivate,o,e);
if e.skip then return ; if e.skip then return ;
defaulthandler(e); defaulthandler(e);
if factivated and ContainsControl(factivecontrol) then if factivated and ContainsControl(factivecontrol) then
@ -1557,6 +1559,27 @@ type TWinControl = class(tcontrol)
end end
procedure PaintWindow(DC:HDC);virtual; procedure PaintWindow(DC:HDC);virtual;
begin begin
///////////////////设计器中选中绘制/////////////////////////////////////////////
if (csDesigning in ComponentState) and FDesignSelect then //选中
begin
c := getwndclientrect();
x := (c[0]+c[2])/2;
y := (c[1]+c[3])/2;
ps := array(
(x,c[1]),
(c[0],y),
(c[2],y),
(x,c[3])
);
cvs := Canvas;
cvs.Brush.color := sys_complementar_color(Color);
sz := 4;
for i,v in ps do
begin
cvs.draw_rect().rect(array(v[0]-sz,v[1]-sz,v[0]+sz,v[1]+sz)).draw();
end
end
////////////////////////////////////////////////////
end end
function SetTempCursor(Value);override; function SetTempCursor(Value);override;
begin begin
@ -1946,6 +1969,7 @@ type TWinControl = class(tcontrol)
end end
function create(aowner);override; //type_twinctrol function create(aowner);override; //type_twinctrol
begin begin
fmodalcenter := true;
inherited; inherited;
fchildsizing := new t_children_sizer(self(true)); fchildsizing := new t_children_sizer(self(true));
//fbordercolor := rgb(190,190,190); //fbordercolor := rgb(190,190,190);
@ -2073,17 +2097,20 @@ type TWinControl = class(tcontrol)
dy := 20; dy := 20;
x := 0; x := 0;
y := 0; y := 0;
c := 0; c := sys_complementar_color(color);
bbc := cv.brush.color;
cv.brush.color := c;
while y<rc[3] do while y<rc[3] do
begin begin
y+=dx; y+=dx;
x := 0; x := 0;
while x<rc[2] do while x<rc[2] do
begin begin
x+=dx; x+=dx;
cv.SetPixel(array(x,y),c); cv.FillRect(array(x-1,y-1,x+1,y+1));
end end
end end
cv.brush.color := bbc;
ctls := controls; ctls := controls;
rcs := array(); rcs := array();
sel := -1; sel := -1;
@ -2112,7 +2139,7 @@ type TWinControl = class(tcontrol)
pct := cv.pen.style; pct := cv.pen.style;
pcw := cv.pen.width; pcw := cv.pen.width;
cv.pen.Style := PS_DOT; cv.pen.Style := PS_DOT;
cv.pen.color := 0x3f3f3f; cv.pen.color := c;//0x3f3f3f;
for i := 0 to len do for i := 0 to len do
begin begin
if i=sel then continue; if i=sel then continue;
@ -2294,6 +2321,14 @@ type TWinControl = class(tcontrol)
end end
end end
private //绘制相关成员 private //绘制相关成员
function sys_complementar_color(c);
begin
if (c .& 0xff000000) then
begin
return complementary_color( _wapi.GetSysColor(c .& 0x00ffffff));
end
return complementary_color(c);
end
FPaintRects; FPaintRects;
FUpDateCount; FUpDateCount;
public public
@ -2553,7 +2588,7 @@ type TWinControl = class(tcontrol)
_Send_(WM_NCLBUTTONDOWN,HTCAPTION,0,0); _Send_(WM_NCLBUTTONDOWN,HTCAPTION,0,0);
e.skip := true; e.skip := true;
end end
CallMessgeFunction(OnDesignClick,self(true),e); CallMessgeFunction(FOnDesinedsel,self(true),e);
//保留原有的点击消息 //保留原有的点击消息
{if DesigningClick() then {if DesigningClick() then
begin begin
@ -2562,11 +2597,11 @@ type TWinControl = class(tcontrol)
end else end else
if msg = WM_LBUTTONDBLCLK then if msg = WM_LBUTTONDBLCLK then
begin begin
CallMessgeFunction(OnDesignDBLClick,self(true),e); CallMessgeFunction(FOnDesigDBLClick,self(true),e);
end else end else
if msg = WM_RBUTTONDOWN then if msg = WM_RBUTTONDOWN then
begin begin
CallMessgeFunction(OnDesignRClick,self(true),e); CallMessgeFunction(FOnDesinedRclick,self(true),e);
end else end else
if msg = WM_USER then if msg = WM_USER then
begin begin
@ -2902,11 +2937,11 @@ type TWinControl = class(tcontrol)
property OnActivate:eventhandler read FOnActivate write FOnActivate; property OnActivate:eventhandler read FOnActivate write FOnActivate;
property OnClose:eventhandler read FOnClose write FOnClose; property OnClose:eventhandler read FOnClose write FOnClose;
property OnKeyDown:eventhandler read FOnKeyDown write FOnKeyDown; property OnKeyDown:eventhandler read FOnKeyDown write FOnKeyDown;
property OnsysKeyDown:eventhandler read FOnsysKeyDown write FOnsysKeyDown; property OnsysKeyDown read FOnsysKeyDown write FOnsysKeyDown;
property OnKeyUp:eventhandler read FOnKeyUp write FOnKeyUp; property OnKeyUp:eventhandler read FOnKeyUp write FOnKeyUp;
property OnsysKeyUp:eventhandler read FOnsysKeyUp write FOnsysKeyUp; property OnsysKeyUp read FOnsysKeyUp write FOnsysKeyUp;
property OnKeyPress:eventhandler read FOnKeyPress write FOnKeyPress; property OnKeyPress:eventhandler read FOnKeyPress write FOnKeyPress;
property OnSysKeyPress:eventhandler read FOnSysKeyPress write FOnSysKeyPress; property OnSysKeyPress read FOnSysKeyPress write FOnSysKeyPress;
property OnDesignClick read FOnDesinedsel write FOnDesinedsel; property OnDesignClick read FOnDesinedsel write FOnDesinedsel;
property OnDesignDBLClick read FOnDesigDBLClick write FOnDesigDBLClick; property OnDesignDBLClick read FOnDesigDBLClick write FOnDesigDBLClick;
property OnDesignRClick read FOnDesinedRclick write FOnDesinedRclick; property OnDesignRClick read FOnDesinedRclick write FOnDesinedRclick;
@ -2923,7 +2958,34 @@ type TWinControl = class(tcontrol)
property ActiveControl read getactivecontrol write setactivecontrol; property ActiveControl read getactivecontrol write setactivecontrol;
property Active read factivated;//是否获活动窗口 property Active read factivated;//是否获活动窗口
property childsizing:tchildsizing read fchildsizing write setchildsizing; property childsizing:tchildsizing read fchildsizing write setchildsizing;
property modalcenter read fmodalcenter write fmodalcenter; //模态时候居中
private //模态相关 private //模态相关
function center_self();
begin
////////////////////窗口居中处理/////////////////////////////////
////////////////////wnd待居中的窗口/////////////////////////////////
////////////////////pwnd父窗口/////////////////////////////////
if not fmodalcenter then return ;
wnd := self(true);
pd := wnd.parent;
if pd and pd.Visible then
begin
while not(pd.wspopup) do
begin
npd := pd.parent;
if npd then pd := npd;
else break;
end
r := pd.ClientRect;
xy := pd.clienttoscreen(r[0],r[1]);
end else
begin
xy := array(0,0);
r := wnd._wapi.GetScreenRect();
end
wnd.Left := max(0,xy[0]+(r[2]-r[0]-wnd.width)/2) ;
wnd.top := max(0,xy[1]+(r[3]-r[1]-wnd.Height)/2);
end
property Modaling read FModaling; property Modaling read FModaling;
{** {**
@param(BorderStyle)(bsNone|bsSingle) 边框样式 %% @param(BorderStyle)(bsNone|bsSingle) 边框样式 %%
@ -2933,7 +2995,7 @@ type TWinControl = class(tcontrol)
@param(OnClose)(function[TWincontrol,tuieventbase]) 窗口关闭消息回调 %% @param(OnClose)(function[TWincontrol,tuieventbase]) 窗口关闭消息回调 %%
@param(OnKeyDown)(function[TWincontrol,TMKEY]) 按键按下回调 %% @param(OnKeyDown)(function[TWincontrol,TMKEY]) 按键按下回调 %%
@param(OnKeyUp)(function[TWincontrol,TMKEY]) 按键松开 %% @param(OnKeyUp)(function[TWincontrol,TMKEY]) 按键松开 %%
@param(OnKeyPress)(function[TWincontrol,TMKEY]) ×Ö·ûÏûÏ¢ %% @param(OnKeyPress)(function[TWincontrol,tmk_press]) 字符消息 %%
**} **}
private //ShortCut private //ShortCut
function dispatchshortcut(c,st); //快捷键分发 function dispatchshortcut(c,st); //快捷键分发

View File

@ -1062,6 +1062,16 @@ type tsgtkapi = class(tgtkapis)
end end
Function DrawTextExA(hdc :pointer;txt:string;len:integer;rec:array of integer;fmt:integer;lpdtp:pointer):integer; Function DrawTextExA(hdc :pointer;txt:string;len:integer;rec:array of integer;fmt:integer;lpdtp:pointer):integer;
begin begin
//DT_LEFT := 0;
DT_RIGHT := 0x2;
//DT_TOP := 0;
DT_BOTTOM:= 0x8;
DT_CENTER := 0x1;
DT_VCENTER:= 0x4;
DT_SINGLELINE:= 0x20;
//DT_TABSTOP:= 0x80;
fmt := (fmt>0 or fmt<0)?fmt:0;
dfs := (fmt .& DT_SINGLELINE) = DT_SINGLELINE;
slen := length( txt); slen := length( txt);
if slen<1 then return ; if slen<1 then return ;
ft := gtk_object_get_data(hdc,"font"); ft := gtk_object_get_data(hdc,"font");
@ -1082,23 +1092,19 @@ type tsgtkapi = class(tgtkapis)
if vi="\r" then continue; if vi="\r" then continue;
if vi="\n" then if vi="\n" then
begin begin
rs++; if not dfs then
mxl := max(mxl,rl); begin
rl := 0; rs++;
mxl := max(mxl,rl);
rl := 0;
end
continue; continue;
end end
rl++; rl++;
end end
if dfs then slen := rl;
ht := ht*rs; ht := ht*rs;
mxl := max(mxl,rl); mxl := max(mxl,rl);
//DT_LEFT := 0;
DT_RIGHT := 0x2;
//DT_TOP := 0;
DT_BOTTOM:= 0x8;
DT_CENTER := 0x1;
DT_VCENTER:= 0x4;
//DT_SINGLELINE:= 0x20;
//DT_TABSTOP:= 0x80;
rw := rec[2]-rec[0]; rw := rec[2]-rec[0];
nlen := min(len, min(integer(rw/wd),mxl)); nlen := min(len, min(integer(rw/wd),mxl));
sx := rec[0]; sx := rec[0];
@ -1140,7 +1146,11 @@ type tsgtkapi = class(tgtkapis)
y := 0;//gtk_object_get_data(hdc,"viewport.y"); y := 0;//gtk_object_get_data(hdc,"viewport.y");
reci := array(rec[0]+x,rec[1]+y,rec[2]+x,rec[3]+y); reci := array(rec[0]+x,rec[1]+y,rec[2]+x,rec[3]+y);
cairo_clip_rec(hdc,reci); cairo_clip_rec(hdc,reci);
r := TextOutexA(hdc,sx,sy-dht,txt,slen); if dfs then
begin
r := TextOutexA(hdc,sx,sy-dht,replacetext(replacetext(txt,"\r",""),"\n",""),slen);
end else
r := TextOutexA(hdc,sx,sy-dht,txt,slen);
cairo_restore(hdc); cairo_restore(hdc);
return r; return r;
end end

View File

@ -456,7 +456,9 @@ type TCustomMemoCmd=class() //
static const ecPrevBlock=0x2BE;static const ecNextJumpOut=0x2BF;static const ecPrevJumpOut=0x2C0; static const ecPrevBlock=0x2BE;static const ecNextJumpOut=0x2BF;static const ecPrevJumpOut=0x2C0;
static const ecUserFirst=0x3E9;static const ecFind=0x3EA;static const ecReplace=0x3EB; static const ecUserFirst=0x3E9;static const ecFind=0x3EA;static const ecReplace=0x3EB;
static const ecSearchAgain=0x3EC;static const ecFindAll=0x3ED;static const ecString=0x3EE; static const ecSearchAgain=0x3EC;static const ecFindAll=0x3ED;static const ecString=0x3EE;
static const ecSearchUpAgain=0x3EF; static const ecSearchUpAgain=0x3EF;
//////////////////////选择模式/////////////////////////////////
static const smNormal = 0;static const smLine = 1;static const smColumn = 2;
end end
type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) //编辑器基类 type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) //编辑器基类
@ -518,10 +520,7 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) //
static const crUnindent = 7; static const crUnindent = 7;
static const crSilentDelete = 8; static const crSilentDelete = 8;
static const crSilentDeleteAfterCursor = 9; static const crSilentDeleteAfterCursor = 9;
static const crNothing = 10; static const crNothing = 10;
static const smNormal = 0;
static const smLine = 1;
static const smColumn = 2;
//**************** //****************
protected protected
@ -693,9 +692,42 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) //
begin begin
cvs.Brush.Color := fselectbkcolor;//rgb(192,192,192); cvs.Brush.Color := fselectbkcolor;//rgb(192,192,192);
src := r; src := r;
if FSelectionMode=smLine then if FSelectionMode=smLine then //行选择
begin begin
end else end else
if FSelectionMode=smColumn then //块选择
begin
if bb[0]=ee[0] then
begin
src[0]+= fCharWidth *(bb[1]-1);
src[2]:= src[0]+fCharWidth *(ee[1]-bb[1]);
end
else
begin
t1 := bb;
t2 := ee;
bb := array(min(t1[0],t2[0]),min(t1[1],t2[1]));
ee := array(max(t1[0],t2[0]),max(t1[1],t2[1]));
s := FLines.GetStringByIndex(i);
ls := length(s);
dx := 0;
case bytetype(s,bb[1]) of
2:
begin
src[0]+= fCharWidth *(bb[1]);
dx := -1;
end
else src[0]+= fCharWidth *(bb[1]-1);
end ;
case bytetype(s,ee[1]-1) of
1:src[2]:= src[0]+max(0,fCharWidth *(min(ee[1],ls+1)-bb[1]+1+dx));
else src[2]:= src[0]+max(0,fCharWidth *(min(ee[1],ls+1)-bb[1]+dx));
end ;
end
end else
begin begin
if bb[0]=ee[0]then //同一行 if bb[0]=ee[0]then //同一行
begin begin
@ -1027,7 +1059,7 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) //
if ftmemlockv.locked then return ; if ftmemlockv.locked then return ;
if e.skip then return; if e.skip then return;
c := e.wparam; c := e.wparam;
if ReadOnly then return; if ReadOnly or (FSelectionMode=smColumn) then return;
if c=13 then return CharInput("\r\n"); if c=13 then return CharInput("\r\n");
if c<32 and not(c in array(9))then return; if c<32 and not(c in array(9))then return;
cc := e.char; cc := e.char;
@ -1139,7 +1171,7 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) //
end end
function CharInput(c);virtual;//插入字符 function CharInput(c);virtual;//插入字符
begin begin
if not ReadOnly then return InsertChars(c); if not(ReadOnly or (FSelectionMode=smColumn)) then return InsertChars(c);
end end
function ExecuteCommand(cmd,data);override;//执行命令 function ExecuteCommand(cmd,data);override;//执行命令
begin begin
@ -1801,7 +1833,7 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) //
end end
function SetSelectionMode(v); function SetSelectionMode(v);
begin begin
if(v <> FSelectionMode)and(v in array(smNormal,smLine))then FSelectionMode := v; if(v <> FSelectionMode)and(v in array(smNormal,smLine,smColumn))then FSelectionMode := v;
end end
function MoveCaretHorz(stp,sel); function MoveCaretHorz(stp,sel);
begin begin
@ -2236,7 +2268,7 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) //
function GetBlockEnd(); function GetBlockEnd();
begin begin
if GetSelAvail()then if GetSelAvail()then
begin begin
if fBlockEnd[0]<fBlockBegin[0]or(fBlockEnd[0]=fBlockBegin[0]and fBlockEnd[1]<fBlockBegin[1])then return fBlockBegin; if fBlockEnd[0]<fBlockBegin[0]or(fBlockEnd[0]=fBlockBegin[0]and fBlockEnd[1]<fBlockBegin[1])then return fBlockBegin;
else return fBlockEnd; else return fBlockEnd;
end end
@ -2297,6 +2329,52 @@ type TCustomMemo = class(TCustomScrollControl,TCustomMemoCmd) //
if i<len then r += "\r\n"; if i<len then r += "\r\n";
end end
end else end else
if sm=smColumn then
begin
if bb[0]=ee[0]then
begin
s := fLines[bb[0]-1].FStr;
if not s then return "";
bg := min(bb[1],ee[1]);
ed := max(bb[1],ee[1]);
if bg<ed then return s[bg:(ed-1)]; //2023078 出错
return "";
end else
begin
//第一行
r += "";
//中间
for i := bb[0]-1 to ee[0]-1 do
begin
s := fLines[i].FStr;
ls := length(s);
t1 := bb;
t2 := ee;
bb := array(min(t1[0],t2[0]),min(t1[1],t2[1]));
ee := array(max(t1[0],t2[0]),max(t1[1],t2[1]));
if bb[1]<=ls then
begin
dx := 0;
case bytetype(s,bb[1]) of
2:
begin
bx := bb[1]+1;
dx := -1;
end
else bx := bb[1];
end ;
case bytetype(s,ee[1]-1) of
1: ex := min(ee[1],ls);
else ex:= min(ee[1]-1,ls);
end ;
if bx<=ex then r += s[bx:ex];
end
if i<ee[0]-1 then r += "\r\n";
end
//最后一行
end
end else
begin begin
if bb[0]=ee[0]then if bb[0]=ee[0]then
begin begin
@ -2958,7 +3036,7 @@ type TSynHighLighter = class(TComponent) //
r := FCacheTokens[ridx]; r := FCacheTokens[ridx];
if r then return r; if r then return r;
s := Flines.GetSTringByIndex(ridx); s := Flines.GetSTringByIndex(ridx);
if not ifstring(s) then return; if not ifstring(s) then return nil;
idx := 1; idx := 1;
len := length(s); len := length(s);
tks := array(); tks := array();
@ -3199,6 +3277,7 @@ type tcustomsynhighlighter = class(TSynHighLighter)
function GetLineTokens(idx);override; function GetLineTokens(idx);override;
begin begin
if idx<FSatesCount then return FTokens[idx]; if idx<FSatesCount then return FTokens[idx];
return nil;
end end
function SetTToken(tokens,ttk,idx,ext);override; //设置token function SetTToken(tokens,ttk,idx,ext);override; //设置token
begin begin
@ -3766,7 +3845,7 @@ type TSynCustomMemo = class(TCustomMemo)
end end
function CharInput(c);override; //字符输入 function CharInput(c);override; //字符输入
begin begin
if ReadOnly then return ; if ReadOnly or (FSelectionMode=smColumn) then return ;
if c="\r\n" then if c="\r\n" then
begin begin
if FinishCompletion() then //确定键 if FinishCompletion() then //确定键
@ -4061,28 +4140,28 @@ type TSynMemoNorm = class(TsynCustomMemo) //
end end
ord("V"): ord("V"):
begin begin
if ReadOnly then return ; if ReadOnly or (FSelectionMode=smColumn) then return ;
ExecuteCommand(ecPaste); ExecuteCommand(ecPaste);
end end
ord("X"): ord("X"):
begin begin
//if (ssAlt in e.shiftstate) then return ExecuteCommand(ecRedo); //if (ssAlt in e.shiftstate) then return ExecuteCommand(ecRedo);
if ReadOnly then return ; if ReadOnly or (FSelectionMode=smColumn) then return ;
ExecuteCommand(ecCut); ExecuteCommand(ecCut);
end end
ord("Y"),ord("L"): ord("Y"),ord("L"):
begin begin
if ReadOnly then return ; if ReadOnly or (FSelectionMode=smColumn) then return ;
return ExecuteCommand(ecDeleteLine); return ExecuteCommand(ecDeleteLine);
end end
ord("Z"): ord("Z"):
begin begin
if ReadOnly then return ; if ReadOnly or (FSelectionMode=smColumn) then return ;
return ExecuteCommand(ecUndo); return ExecuteCommand(ecUndo);
end end
ord("U"): ord("U"):
begin begin
if ReadOnly then return ; if ReadOnly or (FSelectionMode=smColumn) then return ;
return ExecuteCommand(ecRedo); return ExecuteCommand(ecRedo);
end end
VK_LEFT: VK_LEFT:
@ -4115,7 +4194,7 @@ type TSynMemoNorm = class(TsynCustomMemo) //
VK_TAB: VK_TAB:
begin begin
if ReadOnly then return ; if ReadOnly or (FSelectionMode=smColumn) then return ;
FSheetTabFlage := true; FSheetTabFlage := true;
return ExecuteCommand(ecShifttab,array(TabChar,"\t"," ")); return ExecuteCommand(ecShifttab,array(TabChar,"\t"," "));
end end
@ -4182,13 +4261,13 @@ type TSynMemoNorm = class(TsynCustomMemo) //
end end
VK_DELETE: VK_DELETE:
begin begin
if ReadOnly then return ; if ReadOnly or (FSelectionMode=smColumn) then return ;
ExecuteCommand(ecDeleteChar); ExecuteCommand(ecDeleteChar);
return CancelCompletion(); return CancelCompletion();
end end
VK_BACK : VK_BACK :
begin begin
if ReadOnly then return ; if ReadOnly or (FSelectionMode=smColumn) then return ;
ExecuteCommand(ecDeleteLastChar,1); ExecuteCommand(ecDeleteLastChar,1);
return CancelCompletion(); return CancelCompletion();
end end

View File

@ -82,8 +82,7 @@ type TBasicAction=class(TComponent)
if csDesigning in ComponentState then return ; if csDesigning in ComponentState then return ;
if FOnExecute then if FOnExecute then
begin begin
e := new tuieventbase(0,0,0,0); if iffuncptr(FOnExecute) then call(FOnExecute,self(true));
if iffuncptr(FOnExecute) then call(FOnExecute,self(true),e);
return true; return true;
end end
return false; return false;

View File

@ -615,7 +615,7 @@ type tarray1dlk=class //
function dochanged(info); function dochanged(info);
begin begin
if onchangelock then return ; if onchangelock then return ;
if fonchanged then CallMessgeFunction(fonchanged,self(true),info); if fonchanged then CallMessgeFunction(fonchanged,self(true),info);
end end
function SwapNoCheck(i,j); function SwapNoCheck(i,j);
begin begin
@ -910,7 +910,7 @@ type tstrindexarray = class() //
begin begin
{** {**
@explan(˵Ã÷) »ñµÃtsl array %% @explan(˵Ã÷) »ñµÃtsl array %%
@param(n)(bool) false 返回小写下标true 返回原始下标 %% @param(n)(bool) true 返回小写下标false 返回原始下标 %%
**} **}
r := array(); r := array();
for i,v in FData do for i,v in FData do
@ -3450,8 +3450,9 @@ end;
////////////////////////////////////// //////////////////////////////////////
function iffuncptr(fn); function iffuncptr(fn);
begin begin
return datatype(fn) in array(7,37);
//return datatype(fn)=7; //return datatype(fn)=7;
return fn and ifobj(fn); //return fn and ifobj(fn);
end end
function includestate(u,s); function includestate(u,s);
begin begin
@ -4039,12 +4040,136 @@ begin
if m in array(1,3,5,7,8,10,12) then return 31; if m in array(1,3,5,7,8,10,12) then return 31;
return 30; return 30;
end end
function CallMessgeFunction2(f,o,e);
begin
{**
@ignore(忽略)
**}
if iffuncptr(f) then return call(f,o,e);
end
function get_evt_expand(e,n); //展开形式
begin
if (n=0 or n>2) and (e is class(tuieventbase)) then
begin
ps := e.expandinfo();
//echo e.Classinfo()["classname"],"\r\n";
if ps and ifarray(ps) then
begin
r := ps[0:(n-3)];
len := length(r);
n := len+2;
return r;
end
end
n := min(n,2);
return array();
end
function CallMessgeFunction(f,o,e); function CallMessgeFunction(f,o,e);
begin begin
{** {**
@ignore(ºöÂÔ) @ignore(ºöÂÔ)
**} **}
if iffuncptr(f) then return call(f,o,e); if not iffuncptr(f) then return ;
//////////////事件信息处理//////////////
ff := f.functioninfo();
ffp := ff["parameter"];
plen := length(ffp);
ex := get_evt_expand(e,plen);
//////////////////////////////////
case plen of
1:
begin
r := call(f,o);
end
3:
begin
if ifstring(ex[0,"name"]) then x0 := invoke(e,ex[0,"name"]); else x0 := nil;
r := call(f,o,e,x0);
if ex[0,"var"] then invoke(e,ex[0,"name"],1,x0);
end
4:
begin
if ifstring(ex[0,"name"]) then x0 := invoke(e,ex[0,"name"]); else x0 := nil;
if ifstring(ex[1,"name"]) then x1 := invoke(e,ex[1,"name"]); else x1 := nil;
r := call(f,o,e,x0,x1);
if ex[0,"var"] then invoke(e,ex[0,"name"],1,x0);
if ex[1,"var"] then invoke(e,ex[1,"name"],1,x1);
end
5:
begin
if ifstring(ex[0,"name"]) then x0 := invoke(e,ex[0,"name"]); else x0 := nil;
if ifstring(ex[1,"name"]) then x1 := invoke(e,ex[1,"name"]); else x1 := nil;
if ifstring(ex[2,"name"]) then x2 := invoke(e,ex[2,"name"]); else x2 := nil;
r := call(f,o,e,x0,x1,x2);
if ex[0,"var"] then invoke(e,ex[0,"name"],1,x0);
if ex[1,"var"] then invoke(e,ex[1,"name"],1,x1);
if ex[2,"var"] then invoke(e,ex[2,"name"],1,x2);
end
6:
begin
if ifstring(ex[0,"name"]) then x0 := invoke(e,ex[0,"name"]); else x0 := nil;
if ifstring(ex[1,"name"]) then x1 := invoke(e,ex[1,"name"]); else x1 := nil;
if ifstring(ex[2,"name"]) then x2 := invoke(e,ex[2,"name"]); else x2 := nil;
if ifstring(ex[3,"name"]) then x3 := invoke(e,ex[3,"name"]); else x3 := nil;
r := call(f,o,e,x0,x1,x2,x3);
if ex[0,"var"] then invoke(e,ex[0,"name"],1,x0);
if ex[1,"var"] then invoke(e,ex[1,"name"],1,x1);
if ex[2,"var"] then invoke(e,ex[2,"name"],1,x2);
if ex[3,"var"] then invoke(e,ex[3,"name"],1,x3);
end
7:
begin
if ifstring(ex[0,"name"]) then x0 := invoke(e,ex[0,"name"]); else x0 := nil;
if ifstring(ex[1,"name"]) then x1 := invoke(e,ex[1,"name"]); else x1 := nil;
if ifstring(ex[2,"name"]) then x2 := invoke(e,ex[2,"name"]); else x2 := nil;
if ifstring(ex[3,"name"]) then x3 := invoke(e,ex[3,"name"]); else x3 := nil;
if ifstring(ex[4,"name"]) then x4 := invoke(e,ex[4,"name"]); else x4 := nil;
r := call(f,o,e,x0,x1,x2,x3,x4);
if ex[0,"var"] then invoke(e,ex[0,"name"],1,x0);
if ex[1,"var"] then invoke(e,ex[1,"name"],1,x1);
if ex[2,"var"] then invoke(e,ex[2,"name"],1,x2);
if ex[3,"var"] then invoke(e,ex[3,"name"],1,x3);
if ex[4,"var"] then invoke(e,ex[4,"name"],1,x4);
end
8:
begin
if ifstring(ex[0,"name"]) then x0 := invoke(e,ex[0,"name"]); else x0 := nil;
if ifstring(ex[1,"name"]) then x1 := invoke(e,ex[1,"name"]); else x1 := nil;
if ifstring(ex[2,"name"]) then x2 := invoke(e,ex[2,"name"]); else x2 := nil;
if ifstring(ex[3,"name"]) then x3 := invoke(e,ex[3,"name"]); else x3 := nil;
if ifstring(ex[4,"name"]) then x4 := invoke(e,ex[4,"name"]); else x4 := nil;
if ifstring(ex[5,"name"]) then x5 := invoke(e,ex[5,"name"]); else x5 := nil;
r := call(f,o,e,x0,x1,x2,x3,x4,x5);
if ex[0,"var"] then invoke(e,ex[0,"name"],1,x0);
if ex[1,"var"] then invoke(e,ex[1,"name"],1,x1);
if ex[2,"var"] then invoke(e,ex[2,"name"],1,x2);
if ex[3,"var"] then invoke(e,ex[3,"name"],1,x3);
if ex[4,"var"] then invoke(e,ex[4,"name"],1,x4);
if ex[5,"var"] then invoke(e,ex[5,"name"],1,x5);
end
9:
begin
if ifstring(ex[0,"name"]) then x0 := invoke(e,ex[0,"name"]); else x0 := nil;
if ifstring(ex[1,"name"]) then x1 := invoke(e,ex[1,"name"]); else x1 := nil;
if ifstring(ex[2,"name"]) then x2 := invoke(e,ex[2,"name"]); else x2 := nil;
if ifstring(ex[3,"name"]) then x3 := invoke(e,ex[3,"name"]); else x3 := nil;
if ifstring(ex[4,"name"]) then x4 := invoke(e,ex[4,"name"]); else x4 := nil;
if ifstring(ex[5,"name"]) then x5 := invoke(e,ex[5,"name"]); else x5 := nil;
if ifstring(ex[6,"name"]) then x6 := invoke(e,ex[6,"name"]); else x6 := nil;
r := call(f,o,e,x0,x1,x2,x3,x4,x5,x6);
if ex[0,"var"] then invoke(e,ex[0,"name"],1,x0);
if ex[1,"var"] then invoke(e,ex[1,"name"],1,x1);
if ex[2,"var"] then invoke(e,ex[2,"name"],1,x2);
if ex[3,"var"] then invoke(e,ex[3,"name"],1,x3);
if ex[4,"var"] then invoke(e,ex[4,"name"],1,x4);
if ex[5,"var"] then invoke(e,ex[5,"name"],1,x5);
if ex[6,"var"] then invoke(e,ex[6,"name"],1,x6);
end else
begin
r := call(f,o,e);
end
end ;
return r;
end end
function CheckArrayIsNumbers(Value,n); function CheckArrayIsNumbers(Value,n);
begin begin

View File

@ -74,6 +74,13 @@ type tmmeasuresize = class(tuieventbase)
width := -1; width := -1;
height := -1; height := -1;
end end
function expandinfo();override;
begin
r := array();
r[0] := array("name":"width","alias":"wd","type":"integer","var":true);
r[1] := array("name":"height","alias":"ht","type":"integer","var":true);
return r;
end
width; width;
height; height;
end end
@ -106,8 +113,17 @@ type TMKEY=class(tuieventbase)
function create(m,w,l,h);override; function create(m,w,l,h);override;
begin begin
inherited; inherited;
FChar := chr(w); if w>0 then
FChar := chr(w);
else FChar := chr(0);
end end
function expandinfo();override;
begin
r := array();
r[0] := array("name":"charcode","alias":"key","type":"word");
r[1] := array("name":"shiftstate","alias":"shift","type":"tshiftstateenum");
return r;
end
property char read FChar; property char read FChar;
property CharCode read wparam; property CharCode read wparam;
property shiftstate read getshiftsate; property shiftstate read getshiftsate;
@ -117,6 +133,22 @@ type TMKEY=class(tuieventbase)
@param(shiftstate)(arry of TShiftStateEnum member ) ascii码 %% @param(shiftstate)(arry of TShiftStateEnum member ) ascii码 %%
**} **}
end end
type tmk_press=class(TMKEY)
{**
@param(说明) 按键输入
**}
public
function create(m,w,l,h);override;
begin
inherited;
end
function expandinfo();override;
begin
r := array();
r[0] := array("name":"char","alias":"key","type":"string");
return r;
end
end
Type TtageDrawItem=class(tslcstructureobj) Type TtageDrawItem=class(tslcstructureobj)
private private
@ -265,7 +297,7 @@ type TSIFTSTATE = class(TSLUICONST)
end; end;
end end
type TMMOUSEWHEEL=class(tuieventbase) type tmmousewheel=class(tuieventbase)
{** {**
@explan(说明)鼠标滚动消息类 %% @explan(说明)鼠标滚动消息类 %%
**} **}
@ -288,12 +320,26 @@ type TMMOUSEWHEEL=class(tuieventbase)
property delta read hiwparamsigned; property delta read hiwparamsigned;
property ypos read hilparamsigned; property ypos read hilparamsigned;
property xpos read lolparamsigned; property xpos read lolparamsigned;
property pos read getpos;
function expandinfo();override;
begin
r := array();
i := 0;
r[i++] := array("name":"shiftstate","alias":"shift","type":"tshiftstateenum");
r[i++] := array("name":"delta","alias":"delta","type":"integer");
r[i++] := array("name":"pos","alias":"mousepos","type":"array of integer");
return r;
end
{** {**
@param(ypos)(integer)鼠标的y坐标 %% @param(ypos)(integer)鼠标的y坐标 %%
@param(xpos)(integer)鼠标的x坐标 %% @param(xpos)(integer)鼠标的x坐标 %%
@param(delta)(integer)运动距离 %% @param(delta)(integer)运动距离 %%
**} **}
private private
function getpos();
begin
return array(xpos,ypos);
end
FKeyState; FKeyState;
end end
type TMMouse=class(tuieventbase) type TMMouse=class(tuieventbase)
@ -370,9 +416,110 @@ type TMMouse=class(tuieventbase)
shiftstate(); shiftstate();
return(ssDouble in FKeyState); return(ssDouble in FKeyState);
end end
function expandinfo();override;
begin
r := array();
r[0] := array("name":"button","alias":"button","type":"tmousebutton");
r[1] := array("name":"shiftstate","alias":"shift","type":"tshiftstateenum");
r[2] := array("name":"xpos","alias":"x","type":"integer");
r[3] := array("name":"ypos","alias":"y","type":"integer");
return r;
end
private private
FKeyState; FKeyState;
end end
type tmm_move=class(TMMouse)
{**
@explan(说明) 鼠标移动消息类 %%
**}
public
function create(m,w,l,h);override;
begin
inherited;
end
function expandinfo();override;
begin
r := array();
r[0] := array("name":"shiftstate","alias":"shift","type":"tshiftstateenum");
r[1] := array("name":"xpos","alias":"x","type":"integer");
r[2] := array("name":"ypos","alias":"y","type":"integer");
return r;
end
end
type tmcontextpop = class(tuieventbase)
function create(m,w,l,h);
begin
inherited;
end
property mousepos read getpos; //鼠标位置
function expandinfo();override;
begin
r := array();
r[0] := array("name":"mousepos","alias":"mousepos","type":"array of integer");
return r;
end
private
function getpos();
begin
return array(lolparamsigned(),hilparamsigned());
end
end
type tmnotif = class(tuieventbase) //通知消息
function create(op);
begin
inherited create(op,0,0,0);
end
function expandinfo();override;
begin
r := array();
r[0] := array("name":"msg","alias":"msg");
r[1] := array("name":"skip","alias":"stopnotify","type":"bool","var":true);
return r;
end
end
type tmclose = class(tuieventbase) //窗口关闭
function create(m,w,l,h);
begin
inherited;
end
function expandinfo();override;
begin
r := array();
r[0] := array("name":"skip","alias":"stopclose","type":"bool","var":true);
return r;
end
end
type tminqurequit = class(tuieventbase) //退出询问
function create();
begin
inherited create(0,0,0,0);
end
function expandinfo();override;
begin
r := array();
r[0] := array("name":"skip","alias":"stopquit","type":"bool","var":true);
return r;
end
end
type tmactivate = class(tuieventbase)
function create(m,w,l,h);
begin
inherited;
end
property deactivate read getdeactivate;
function expandinfo();override;
begin
r := array();
r[0] := array("name":"deactivate","alias":"deactivate","type":"bool");
return r;
end
private
function getdeactivate();
begin
return Wparam=0;
end
end
type TMSTYLECHANG=class(tuieventbase) type TMSTYLECHANG=class(tuieventbase)
{** {**
@explan(说明)窗口样式改变消息 %% @explan(说明)窗口样式改变消息 %%

View File

@ -69,6 +69,12 @@ type TcustomGridCtl = class(tcustomscrollcontrol) //
// end // end
function GetPreferredSize(w,h);override; function GetPreferredSize(w,h);override;
begin begin
if csDesigning in ComponentState then
begin
w := 250;
h := 150;
return ;
end
if ongetpreferredsize then return inherited; if ongetpreferredsize then return inherited;
w := Width; w := Width;
h := Height; h := Height;
@ -822,7 +828,7 @@ type TcustomGridCtl = class(tcustomscrollcontrol) //
begin begin
if fonhitcellsizer then if fonhitcellsizer then
begin begin
e := new tuieventbase(0,r,i,0); e := new triddragsize(0,r,i,0);
CallMessgeFunction(fonhitcellsizer,self(true),e); CallMessgeFunction(fonhitcellsizer,self(true),e);
return e.skip; return e.skip;
end end
@ -1175,11 +1181,47 @@ type tgriddrawcellevent = class(tuieventbase)
rec := rc; rec := rc;
canvas := cvs; canvas := cvs;
end end
function expandinfo();override;
begin
r := array();
idx := 0;
r[idx++] := array("name":"canvas","alias":"cvs","type":"tcanvas");
r[idx++] := array("name":"row","alias":"rowidx","type":"integer");
r[idx++] := array("name":"col","alias":"colidx","type":"integer");
r[idx++] := array("name":"rec","alias":"arec");
return r;
end
row; row;
col; col;
rec; rec;
canvas; canvas;
end end
type triddragsize=class(tuieventbase)
function create(a,b,c,d);
begin
inherited;
end
function expandinfo();override;
begin
r := array();
i := 0;
r[i++] := array("name":"idx","alias":"idx","type":"integer");
r[i++] := array("name":"r_or_c","alias":"r_or_c","type":"integer");
r[i++] := array("name":"skip","alias":"stopact","type":"bool","var":true);
return r;
end
property idx read getidx;
property r_or_c read getrc;
private
function getidx();
begin
return lparam;
end
function getrc();
begin
return wparam;
end
end
implementation implementation
type TPAINTCOUNT=class()//»æÖƱê¼Ç type TPAINTCOUNT=class()//»æÖƱê¼Ç
function create(v); function create(v);

View File

@ -1501,6 +1501,29 @@ type TMONITORINFO=class(tslcstructureobj)
property rcwork index "rcwork" read _getvalue_ write _setvalue_; property rcwork index "rcwork" read _getvalue_ write _setvalue_;
property dwflags index "dwflags" read _getvalue_ write _setvalue_; property dwflags index "dwflags" read _getvalue_ write _setvalue_;
end end
type tagTRACKMOUSEEVENT=class(tslcstructureobj)
private
static SSTRUCT;
class function getstruct()
begin
if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array(
("cbsize","int",0),
("dwflags","int",0),
("hwndtrack","pointer",),
("dwhovertime","int",200)));
return SSTRUCT;
end
public
function create(ptr)
begin
inherited create(getstruct(),ptr);
cbsize := _size_();
end
property cbsize index "cbsize" read _getvalue_ write _setvalue_;
property dwFlags index "dwflags" read _getvalue_ write _setvalue_;
property hwndtrack index "hwndtrack" read _getvalue_ write _setvalue_;
property dwhovertime index "dwhovertime" read _getvalue_ write _setvalue_;
end
implementation implementation
(* (*

View File

@ -1,4 +1,5 @@
unit utslvclpage; unit utslvclpage;
/////////20250710 tab控件添加inert_tab方法//////////////////////////////////
interface interface
uses utslvclauxiliary,utslvclbase,utslvclgdi; uses utslvclauxiliary,utslvclbase,utslvclgdi;
type tcustomtabsheet = class(TCustomControl) //控件页面 type tcustomtabsheet = class(TCustomControl) //控件页面
@ -71,15 +72,13 @@ type tcustomtabcontrol = class(TCustomControl)
begin begin
if FCurrentid<>-1 and fOnSelChanging then if FCurrentid<>-1 and fOnSelChanging then
begin begin
e := new tuieventbase(0,FCurrentid,id,0); //m,w,l,h e := new tmtabselchanging(0,FCurrentid,id,0); //m,w,l,h
doonSelChanging(self(true),e); doonSelChanging(self(true),e);
if e.skip then return ; if e.skip then return ;
end end
FPrevid := FCurrentid; FPrevid := FCurrentid;
FCurrentid := id; FCurrentid := id;
InsureIdxVisible(id); InsureIdxVisible(id);
//InvalidateRect(nil,false);
//DoControlAlign();
DoControlAlign(); DoControlAlign();
if FOnSelChanged then if FOnSelChanged then
begin begin
@ -92,43 +91,6 @@ type tcustomtabcontrol = class(TCustomControl)
FCurrentid := -1; FCurrentid := -1;
end end
end end
function RemovePageTab(id);//移除sheet
begin
if not(id>=0) then return ;
FTabItems.splice(id,1);
if id = FCurrentid then
begin
if id = 0 then
begin
if FTabItems.length()=0 then
begin
FCurrentid := -1;
FPrevid := -1;
end
end
FCurrentid := -1;
FPrevid := -1;
cid := min(max(0,id-1),FTabItems.length()-1);
if cid >=0 then
begin
return setselidx(cid);
end else
begin
if FOnSelChanged then
begin
doonSelChange(self(true),new tuieventbase(0,-1,-1,0));
end
end
end else
if id<FCurrentid then
begin
FCurrentid--;
end
FPrevid := -1;
DoControlAlign();
//CalcTabs();
//InvalidateRect(nil,false);
end
function CreateTableItem(cp); function CreateTableItem(cp);
begin begin
r := new tcustomtabitem(); r := new tcustomtabitem();
@ -148,7 +110,7 @@ type tcustomtabcontrol = class(TCustomControl)
FTabHeight := fh+8; FTabHeight := fh+8;
end end
FTabItemswidth := array(); FTabItemswidth := array();
e := new tuieventbase(0,0,0,0); e := new tmtabmeasure(0,-1);
for i := 0 to FTabItems.length()-1 do for i := 0 to FTabItems.length()-1 do
begin begin
pg := FTabItems[i]; pg := FTabItems[i];
@ -400,7 +362,6 @@ type tcustomtabcontrol = class(TCustomControl)
begin begin
FirstViewIndex-- ; FirstViewIndex-- ;
DoControlAlign();//CalcTabs(); DoControlAlign();//CalcTabs();
//InvalidateRect(nil,false);
end end
end end
function scrollnext(); //滚动到上一个 function scrollnext(); //滚动到上一个
@ -419,8 +380,6 @@ type tcustomtabcontrol = class(TCustomControl)
end end
end ; end ;
FirstViewIndex++ ; FirstViewIndex++ ;
//CalcTabs();
//InvalidateRect(nil,false);
DoControlAlign(); DoControlAlign();
end end
end end
@ -619,7 +578,6 @@ type tcustomtabcontrol = class(TCustomControl)
begin begin
it.Caption := Value; it.Caption := Value;
DoControlAlign(); DoControlAlign();
//InvalidateRect(nil,false);
end end
end end
function SetTabIndex(AIndex,AIndexnew); function SetTabIndex(AIndex,AIndexnew);
@ -646,6 +604,59 @@ type tcustomtabcontrol = class(TCustomControl)
//InvalidateRect(nil,false); //InvalidateRect(nil,false);
end end
end end
function remove_tab_byidx(id);virtual;//移除tab
begin
{**
@explan(说明) 移除标签 %%
@param(idx)(integer) 序号 %%
**}
if not(id>=0 and id<FTabItems.length()) then return ;
FTabItems.splice(id,1);
if id = FCurrentid then
begin
if id = 0 then
begin
if FTabItems.length()=0 then
begin
FCurrentid := -1;
FPrevid := -1;
end
end
FCurrentid := -1;
FPrevid := -1;
cid := min(max(0,id-1),FTabItems.length()-1);
if cid >=0 then
begin
return setselidx(cid);
end else
begin
if FOnSelChanged then
begin
doonSelChange(self(true),new tuieventbase(0,-1,-1,0));
end
end
end else
if id<FCurrentid then
begin
FCurrentid--;
end
FPrevid := -1;
DoControlAlign();
end
function insert_tab(c,idx);virtual; //插入tab
begin
{**
@explan(说明) 插入标签 %%
@param(c)(string) 标签 %%
@param(idx)(integer) 位置,默认为尾部 %%
**}
if not ifstring(c) then return 0;
cp := CreateTableItem(c);
if idx>=0 or idx<0 then FTabItems.splice(integer(idx),0,cp);
else FTabItems.Push(cp);
DoControlAlign();
return 1;
end
function Recycling();override; function Recycling();override;
begin begin
FOnSelChanged := nil; FOnSelChanged := nil;
@ -656,7 +667,7 @@ type tcustomtabcontrol = class(TCustomControl)
{** {**
@param(cursel)(integer) 当前选中序号 %% @param(cursel)(integer) 当前选中序号 %%
@param(TabCount)(integer) page数量 %% @param(TabCount)(integer) page数量 %%
@param(OnSelChange)(function[tcustompagecontrol,tuieventbase]) 标签已经切换 %% @param(OnSelChanged)(function[tcustompagecontrol,tuieventbase]) 标签已经切换 %%
@param(OnSelChanging)(function[tcustompagecontrol,tuieventbase]) 标签正在切换 %% @param(OnSelChanging)(function[tcustompagecontrol,tuieventbase]) 标签正在切换 %%
@param(Onrclcik)(function[tcustompagecontrol,tuieventbase]) 右键点击 %% @param(Onrclcik)(function[tcustompagecontrol,tuieventbase]) 右键点击 %%
**} **}
@ -790,6 +801,11 @@ type tcustompagecontrol = class(tcustomtabcontrol)
if not (page is class(TWinControl)) then CalcTabs(); if not (page is class(TWinControl)) then CalcTabs();
InvalidateRect(nil,false); InvalidateRect(nil,false);
end end
end
protected
function remove_tab_byidx(id);override;
begin
return inherited;
end end
public public
function GetPreferredSize(w,h);override; function GetPreferredSize(w,h);override;
@ -837,7 +853,7 @@ type tcustompagecontrol = class(tcustomtabcontrol)
begin begin
if not isacceptsheettype(AControl){ not(AControl is class(tcustomtabsheet))} then return; if not isacceptsheettype(AControl){ not(AControl is class(tcustomtabsheet))} then return;
id := GetPageID(AControl); id := GetPageID(AControl);
RemovePageTab(id); remove_tab_byidx(id);
//fcoolbands.deleteitem(AControl,true); //fcoolbands.deleteitem(AControl,true);
end end
Function SetCurSel(id);override; //设置当前序号 Function SetCurSel(id);override; //设置当前序号
@ -946,6 +962,10 @@ type tcustompagecontrol = class(tcustomtabcontrol)
tabs; tabs;
faccepttype; faccepttype;
private private
function insert_tab(c,idx);override; //插入tab
begin
end
function isacceptsheettype(c); function isacceptsheettype(c);
begin begin
for i,v in faccepttype do for i,v in faccepttype do
@ -953,6 +973,64 @@ type tcustompagecontrol = class(tcustomtabcontrol)
if c is v then return true; if c is v then return true;
end end
end end
end
type tmtabselchanging = class(tuieventbase) //改变
function create(m,w,l,h);
begin
inherited;
end
function expandinfo();override;
begin
r := array();
r[0] := array("name":"lparam","alias":"nselidx","type":"integer");
r[1] := array("name":"skip","alias":"stopchange","type":"bool","var":true);
return r;
end
end
type tmtabmeasure = class(tuieventbase)
function create(i,w);
begin
inherited create(nil,w,i,0);
end
function expandinfo();override;
begin
r := array();
r[0] := array("name":"idx","alias":"idx","type":"integer");
r[1] := array("name":"width","alias":"wid","type":"integer","var":true);
return r;
end
property idx read wparam ; //序号
property width read lparam write lparam;//宽度
end
type teventdrawtab = class(tuieventbase)
{**
@explan(说明)绘制消息对象 %%
@param(idx)(integer) 序号 %%
@param(sel)(integer) 是否选中 %%
@param(rec)(array(左上右下)) 区域 %%
@param(canvas)(TCanvas) 画布 %%
**}
function create(id,s,rc,cvs);
begin
inherited create(0,0,0,0);
idx := id;
sel := s;
rec := rc;
canvas := cvs;
end
function expandinfo();override;
begin
r := array();
i := 0;
r[i++] := array("name":"canvas","alias":"cvs","type":"tcanvas");
r[i++] := array("name":"idx","alias":"idx","type":"integer");
r[i++] := array("name":"rec","alias":"arec","type":"array of integer");
return r;
end
idx;
sel;
rec;
canvas;
end end
implementation implementation
type tcustomtabitem = class() // type tcustomtabitem = class() //
@ -990,27 +1068,6 @@ type tcustomtabitem = class() //
property PageSheet read FPageSheet Write FPageSheet; property PageSheet read FPageSheet Write FPageSheet;
_tag; _tag;
end end
type teventdrawtab = class(tuieventbase)
{**
@explan(说明)单元格绘制消息对象 %%
@param(idx)(integer) 序号 %%
@param(sel)(integer) 是否选中 %%
@param(rec)(array(左上右下)) 区域 %%
@param(canvas)(TCanvas) 画布 %%
**}
function create(id,s,rc,cvs);
begin
inherited create(0,0,0,0);
idx := id;
sel := s;
rec := rc;
canvas := cvs;
end
idx;
sel;
rec;
canvas;
end
initialization initialization
end. end.

View File

@ -502,7 +502,7 @@ type tcustombtn = class(TCustomControl) //
3: df := DT_RIGHT 3: df := DT_RIGHT
4: df := DT_LEFT .| DT_VCENTER; 4: df := DT_LEFT .| DT_VCENTER;
6: df := DT_RIGHT .| DT_VCENTER; 6: df := DT_RIGHT .| DT_VCENTER;
7: d := DT_BOTTOM .| DT_LEFT; 7: df := DT_BOTTOM .| DT_LEFT;
8: df := DT_BOTTOM .|DT_CENTER; 8: df := DT_BOTTOM .|DT_CENTER;
9: df := DT_BOTTOM .| DT_RIGHT; 9: df := DT_BOTTOM .| DT_RIGHT;
else else
@ -530,12 +530,46 @@ type tcustombtn = class(TCustomControl) //
end end
function GetPreferredSize(w,h);override; function GetPreferredSize(w,h);override;
begin begin
class(tcontrol).GetPreferredSize(w,h); if iffuncptr(onGetPreferredSize) then return class(tcontrol).GetPreferredSize(w,h); //
if ongetpreferredsize then return ;
bs := BoundsRect; bs := BoundsRect;
cs := ClientRect; cs := ClientRect;
dh := (bs[3]-bs[1])-(cs[3]-cs[1])+2; dh := (bs[3]-bs[1])-(cs[3]-cs[1])+2;
h+=dh; dw := (bs[2]-bs[0])-(cs[2]-cs[0]);
c := caption;lc := length(c);
ft := font;
fw := ft.Width;
fh := ft.Height;
if FtextPosition=0 then
begin
w := fw*(lc+2);
h := fh+4;
end else
begin
rs := 1;
mlen := 0;
mmlen := 0;
for i := 1 to lc do
begin
ci := c[i];
case ci of
"\r":
begin
continue;
end
"\n":
begin
rs+=1;
mmlen := max(mmlen,mlen);
mlen := -1;
end
end ;
mlen++;
end
w := fw*(max(mmlen,mlen)+2);
h := fh*rs+4;
end
w += dw;
h += dh;
end end
function FontChanged(o);override; //字体改变 function FontChanged(o);override; //字体改变
begin begin
@ -624,12 +658,11 @@ type tcustombtn = class(TCustomControl) //
end end
function setTextPosition(n); function setTextPosition(n);
begin begin
if not ifnumber(n) or n<0 or n>9 then if not(n>=0 and n<=9) then return ;
n:=0; n:=integer(n);
else
n:=integer(n);
if FtextPosition=n then return ; if FtextPosition=n then return ;
FtextPosition:=n; FtextPosition:=n;
AdjustSize();
InvalidateRect(nil,false); InvalidateRect(nil,false);
end end
function judgestate(o,e); function judgestate(o,e);
@ -684,7 +717,10 @@ type tcustomcheckbtn=class(tcustombtn) //checkbtn
function GetPreferredSize(w,h);override; function GetPreferredSize(w,h);override;
begin begin
inherited; inherited;
w+=20+1; //w+=20+1;
c := caption;
if c then w+=21;
else w := 21;
end end
published published
property checked:bool read FcheckState write setChecked; property checked:bool read FcheckState write setChecked;
@ -2555,6 +2591,7 @@ type TcustomLabel = class(TGraphicControl)
if v <> FTextAlign then if v <> FTextAlign then
begin begin
FTextAlign := v; FTextAlign := v;
AdjustSize();
InvalidateRect(nil,true); InvalidateRect(nil,true);
end end
end end
@ -2578,6 +2615,47 @@ type TcustomLabel = class(TGraphicControl)
set_Preferre_size(); set_Preferre_size();
inherited; inherited;
end end
function GetPreferredSize(w,h);override;
begin
if iffuncptr(onGetPreferredSize) then return class(tcontrol).GetPreferredSize(w,h); //
ft := font;
if not ft then return ;
fw := ft.Width;
fh := ft.Height;
c := caption;lc := length(c);
if FTextAlign=0 then
begin
w := fw*(lc)+2;
h := fh+3;
end else
begin
rs := 1;
mlen := 0;
mmlen := 0;
for i := 1 to lc do
begin
ci := c[i];
case ci of
"\r":
begin
continue;
end
"\n":
begin
rs+=1;
mmlen := max(mmlen,mlen);
mlen := -1;
end
end ;
mlen++;
end
w := fw*(max(mmlen,mlen))+2;
h := fh*rs+3;
end
bd := Border;
w += bd;
h += bd;
end
function FontChanged(o);override; function FontChanged(o);override;
begin begin
inherited; inherited;
@ -2768,7 +2846,7 @@ type tcustomedit=class(TCustomControl)
begin begin
ft := Font; ft := Font;
if not ft then return ; if not ft then return ;
if ongetpreferredsize then if iffuncptr(onGetPreferredSize) then
begin begin
return class(tcontrol).GetPreferredSize(w,h); return class(tcontrol).GetPreferredSize(w,h);
end end
@ -2802,16 +2880,13 @@ type tcustomedit=class(TCustomControl)
inherited; inherited;
end end
function doonmaxtext(); function doonmaxtext();
begin begin
if FOnMaxText then CallMessgeFunction(FOnMaxText,self(true));
CallMessgeFunction(FOnMaxText,self(true),new tuieventbase(0,0,0,0));
end end
function DoChanged(); function DoChanged();
begin begin
if FOnChange then CallMessgeFunction(FOnChange,self(true));
CallMessgeFunction(FOnChange,self(true),new tuieventbase(0,0,0,0)); CallMessgeFunction(FOnUpdate,self(true));
if FOnUpdate then
CallMessgeFunction(FOnUpdate,self(true),new tuieventbase(0,0,0,0));
end end
function FontChanged(sender);override; function FontChanged(sender);override;
begin begin
@ -3479,6 +3554,16 @@ type TCustomListBoxbase=class(TCustomScrollControl)
begin begin
return FItemCount; return FItemCount;
end end
function GetPreferredSize(w,h);override;
begin
if csDesigning in ComponentState then
begin
w := 250;
h := 150;
return ;
end
return inherited;
end
published published
property ItemCount read GetItemCount write SetItemCount; property ItemCount read GetItemCount write SetItemCount;
property ItemHeight read GetYScrollDelta; property ItemHeight read GetYScrollDelta;
@ -3530,6 +3615,15 @@ type tlistdrawevent = class(tuieventbase)
rec := r; rec := r;
Canvas := c; Canvas := c;
end end
function expandinfo();override;
begin
r := array();
i := 0;
r[i++] := array("name":"canvas","alias":"cvs","type":"tcanvas");
r[i++] := array("name":"idx","alias":"idx","type":"integer");
r[i++] := array("name":"rec","alias":"ARect","type":"array of integer");
return r;
end
rec; rec;
idx; idx;
sel; sel;
@ -3707,7 +3801,7 @@ type TcustomListBox=class(TCustomListBoxbase)
end end
function PaintIdexText(idx,rc,cvs);virtual; function PaintIdexText(idx,rc,cvs);virtual;
begin begin
if fownerdraw and Fondrawlist then if fownerdraw and iffuncptr( Fondrawlist) then
begin begin
e := new tlistdrawevent(idx,rc[4],rc,cvs); e := new tlistdrawevent(idx,rc[4],rc,cvs);
CallMessgeFunction(Fondrawlist,self(true),e); CallMessgeFunction(Fondrawlist,self(true),e);
@ -4263,7 +4357,7 @@ type TcustomListBox=class(TCustomListBoxbase)
end end
function calllistselchengd(); function calllistselchengd();
begin begin
if FselectionChange then CallMessgeFunction(FselectionChange,self(true),new tuieventbase(0,0,0,0)); CallMessgeFunction(FselectionChange,self(true));
end end
private private
fselbkcolor; fselbkcolor;
@ -4316,7 +4410,7 @@ type TCustomComboBoxbase=class(TCustomControl)
function GetPreferredSize(w,h);override; function GetPreferredSize(w,h);override;
begin begin
class(tcontrol).GetPreferredSize(w,h); class(tcontrol).GetPreferredSize(w,h);
if onGetPreferredSize then return ; if iffuncptr(onGetPreferredSize) then return ;
bs := BoundsRect; bs := BoundsRect;
cs := ClientRect; cs := ClientRect;
dh := (bs[3]-bs[1])-(cs[3]-cs[1])+2; dh := (bs[3]-bs[1])-(cs[3]-cs[1])+2;
@ -4598,6 +4692,7 @@ type TcustomComboBox=class(TCustomComboBoxbase)
end end
function DoControlAlign();override; function DoControlAlign();override;
begin begin
if not FEdit then return ;
rc := ClientRect; rc := ClientRect;
rc[2]-= 20; rc[2]-= 20;
FEdit.SetBoundsRect(rc); FEdit.SetBoundsRect(rc);
@ -5153,7 +5248,7 @@ type TcustomToolBar=class(TCustomControl)
begin begin
ft := Font; ft := Font;
if not ft then return ; if not ft then return ;
if ongetpreferredsize then return class(tcontrol).GetPreferredSize(w,h); if iffuncptr(onGetPreferredSize) then return class(tcontrol).GetPreferredSize(w,h);
ftw := ft.Width; ftw := ft.Width;
fth := ft.Height; fth := ft.Height;
brec := BoundsRect; brec := BoundsRect;
@ -6019,7 +6114,7 @@ type TcustomStatusBar=class(TCustomControl)
function GetPreferredSize(w,h);override; function GetPreferredSize(w,h);override;
begin begin
class(tcontrol).GetPreferredSize(w,h); class(tcontrol).GetPreferredSize(w,h);
if ongetpreferredsize then return ; if iffuncptr(onGetPreferredSize) then return ;
bs := BoundsRect; bs := BoundsRect;
cs := ClientRect; cs := ClientRect;
dh := (bs[3]-bs[1])-(cs[3]-cs[1])+2; dh := (bs[3]-bs[1])-(cs[3]-cs[1])+2;
@ -6077,6 +6172,7 @@ type TcustomStatusBar=class(TCustomControl)
{** {**
@explan(说明) 设置多个项目 %% @explan(说明) 设置多个项目 %%
**} **}
if Fitems=its then return ;
Fitems := array(); Fitems := array();
for i,v in its do for i,v in its do
begin begin
@ -6446,7 +6542,7 @@ type TCustomSpinEdit = class(TCustomControl)
function GetPreferredSize(w,h);override; function GetPreferredSize(w,h);override;
begin begin
class(tcontrol).GetPreferredSize(w,h); class(tcontrol).GetPreferredSize(w,h);
if ongetpreferredsize then return ; if iffuncptr(onGetPreferredSize) then return ;
ft := Font; ft := Font;
if not ft then return ; if not ft then return ;
h := ft.Height+4; h := ft.Height+4;
@ -7026,7 +7122,7 @@ type tcustomipaddr = class(TCustomControl)
end end
function DoIpChanged(); function DoIpChanged();
begin begin
return CallMessgeFunction(onAddrChange,self(true),new tuieventbase(0,0,0,0)); return CallMessgeFunction(FaddrChange,self(true));
end end
function cleanAddr(); function cleanAddr();
begin begin
@ -7130,7 +7226,7 @@ type tcustomipaddr = class(TCustomControl)
begin begin
ft := Font; ft := Font;
if not ft then return ; if not ft then return ;
if ongetpreferredsize then if iffuncptr(onGetPreferredSize) then
begin begin
return class(tcontrol).GetPreferredSize(w,h); return class(tcontrol).GetPreferredSize(w,h);
end end
@ -7676,9 +7772,8 @@ type tcustomtimepicker = class(tthreeEntry)
ti := strtointdef(t,0); ti := strtointdef(t,0);
if ti<0 then p.text := "24"; if ti<0 then p.text := "24";
else if ti>24 then p.text := "0"; else if ti>24 then p.text := "0";
end end
if Fonselectchange then CallMessgeFunction(Fonselectchange,self(true));
calldatafunction(Fonselectchange,self(true),new tuieventbase(0,0,0,0));
end end
end end
end end
@ -7846,9 +7941,8 @@ type tcustomdatetimepicker = class(tthreeEntry)
ct := getmonthdates(y,m); ct := getmonthdates(y,m);
if d>ct then es[2].text := inttostr(ct); if d>ct then es[2].text := inttostr(ct);
end end
end end
if Fonselectchange then CallMessgeFunction(Fonselectchange,self(true)) ;
calldatafunction(Fonselectchange,self(true),new tuieventbase(0,0,0,0));
end end
"dtadate": "dtadate":
begin begin
@ -7860,18 +7954,15 @@ type tcustomdatetimepicker = class(tthreeEntry)
es[0].text := inttostr(y); es[0].text := inttostr(y);
es[1].text := inttostr(m); es[1].text := inttostr(m);
es[2].text := inttostr(d); es[2].text := inttostr(d);
if Fonselectchange then CallMessgeFunction(Fonselectchange,self(true));
calldatafunction(Fonselectchange,self(true),new tuieventbase(0,0,0,0));
end else end else
begin begin
y := strtointdef(es[0].text,2021); y := strtointdef(es[0].text,2021);
m := strtointdef(es[1].text,1); m := strtointdef(es[1].text,1);
d := strtointdef(es[2].text,1); d := strtointdef(es[2].text,1);
return array(y,m,d); return array(y,m,d);
end end
end
end
end end
end end
function ShowDropDown(f);virtual; function ShowDropDown(f);virtual;
@ -7985,8 +8076,7 @@ type tcustommonthcalendar = class(TCustomControl)
r := FCalender.ExecuteCommand("meselbypos",e.pos); r := FCalender.ExecuteCommand("meselbypos",e.pos);
if std=3 or r="today" then if std=3 or r="today" then
begin begin
if FonSelect then CallMessgeFunction(FonSelect,self(true));
CallMessgeFunction(FonSelect,self(true),new tuieventbase(0,0,0,0));
end end
end end
end end
@ -8034,8 +8124,7 @@ type tcustommonthcalendar = class(TCustomControl)
end end
function DoDatechanged(); function DoDatechanged();
begin begin
if FonSelectChange then CallMessgeFunction(FonSelectChange,self(true));
CallMessgeFunction(FonSelectChange,self(true),new tuieventbase(0,0,0,0));
end end
function recycling();override; function recycling();override;
begin begin

View File

@ -114,8 +114,8 @@ type ttreelistwnd = class(TCustomScrollControl)
FItemHeight := font.height+2; FItemHeight := font.height+2;
FxClientMax := fColWidth; FxClientMax := fColWidth;
FItemMinWidth := FxClientMax; FItemMinWidth := FxClientMax;
height := 400; height := 150;
width := 300; width := 250;
border := true; border := true;
autoscroll := 3; autoscroll := 3;
ThumbTrack := true; ThumbTrack := true;
@ -453,6 +453,16 @@ type ttreelistwnd = class(TCustomScrollControl)
end end
return r; return r;
end end
function GetPreferredSize(w,h);override;
begin
if csDesigning in ComponentState then
begin
w := 250;
h := 150;
return ;
end
return inherited;
end
published //属性 published //属性
property Items read GetItems; property Items read GetItems;
property ItemCount read GetItemCount; property ItemCount read GetItemCount;
@ -574,23 +584,65 @@ type ttreelistwnd = class(TCustomScrollControl)
end end
end end
type TTreeSelCHngedEvent=class(tuieventbase) type tm_nodeseling=class(tuieventbase)
{** {**
@explan(说明) 导航选择改变消息%% @explan(说明) 节点选择正在改变%%
**} **}
function create(m,w,l,h);override; function create(m,ito,itn,h);override;
begin begin
inherited; ItemOld := ito;
ItemNew := itn;
item := itn;
end
function expandinfo();override;
begin
r := array();
i := 0;
r[i++] := array("name":"itemold","alias":"node","type":"tcustomtreectlnode");
r[i++] := array("name":"itemnew","alias":"nselnode","type":"tcustomtreectlnode");
r[i++] := array("name":"skip","alias":"stopchang","type":"bool","var":true);
return r;
end
ItemOld;
ItemNew;
Item;
end
type tm_nodeseled=class(tm_nodeseling)
{**
@explan(说明) 节点选择成功改变%%
**}
function create(m,ito,itn,h);override;
begin
ItemOld := ito;
ItemNew := itn;
item := itn;
end
function expandinfo();override;
begin
r := inherited;
r := r[0:length(r)-2];
return r;
end end
ItemOld; ItemOld;
ItemNew; ItemNew;
Item; Item;
end
type tm_nodechang = class(tuieventbase)
{** {**
@param(ItemOld)(TcustomTreeCtlNode) 旧的节点 %% @explan(说明) 节点改变消息%%
@param(ItemNew)(TcustomTreeCtlNode) 新节点 %%
@param(Item)(TcustomTreeCtlNode) 当前节点 %%
**} **}
end function create(m,w,l,h);
begin
Item := w;
end
function expandinfo();override;
begin
r := array();
r[0] := array("name":"Item","alias":"node","type":"tcustomtreectlnode");
return r;
end
Item;
end
type TcustomTreeCtlNode = class(tsluibase) //树结点 type TcustomTreeCtlNode = class(tsluibase) //树结点
{** {**
@explan(说明) 树结点 %% @explan(说明) 树结点 %%
@ -1617,10 +1669,7 @@ type TcustomTreeCtl = class(ttreelistwnd)
begin begin
if FonEmptyNodeExapanding then if FonEmptyNodeExapanding then
begin begin
e := new TTreeSelCHngedEvent(0,0,0,0); e := new tm_nodechang(0,pm,0,0);
e.item := pm;
e.ItemNew := pm;
e.ItemOld := pm;
CallMessgeFunction(FonEmptyNodeExapanding,self(true),e); CallMessgeFunction(FonEmptyNodeExapanding,self(true),e);
end end
end end
@ -1832,6 +1881,16 @@ type TcustomTreeCtl = class(ttreelistwnd)
dc.pen.color := rgb(171,173,179); dc.pen.color := rgb(171,173,179);
dc.draw("polyline",ls); dc.draw("polyline",ls);
end end
function GetPreferredSize(w,h);override;
begin
if csDesigning in ComponentState then
begin
w := 100;
h := 125;
return ;
end
return inherited;
end
published //属性 published //属性
property CurrentNode read FCurrentNode write setcurrentnode; //20221118 加上写 property CurrentNode read FCurrentNode write setcurrentnode; //20221118 加上写
property selectionColor:color read FselectionColor write SetselectionColor; property selectionColor:color read FselectionColor write SetselectionColor;
@ -1970,12 +2029,14 @@ type TcustomTreeCtl = class(ttreelistwnd)
t1 := FCurrentNode; t1 := FCurrentNode;
//if t1 then InvalidateItem(t1,false); //if t1 then InvalidateItem(t1,false);
//InvalidateItem(it,false); //InvalidateItem(it,false);
ne := new TTreeSelCHngedEvent(0,0,0,0); //ne := new TTreeSelCHngedEvent(0,0,0,0);
ne.ItemOld := t1; //ne.ItemOld := t1;
ne.ItemNew := it; //ne.ItemNew := it;
ne.Item := it; //ne.Item := it;
ne := new tm_nodeseling(nil,t1,it);
CallMessgeFunction(FOnSelChanging,self(true),ne); CallMessgeFunction(FOnSelChanging,self(true),ne);
if ne.Skip then return true; if ne.Skip then return true;
ne := new tm_nodeseled(nil,t1,it);
FCurrentNode := it; FCurrentNode := it;
CallMessgeFunction(FOnSelChanged,self(true),ne); CallMessgeFunction(FOnSelChanged,self(true),ne);
end end

View File

@ -207,7 +207,7 @@ app := initializeapplication();
app.createform(class(tfm),fm); app.createform(class(tfm),fm);
fm.show(); fm.show();
app.run(); app.run();
type tfm = class(tvcform) type tfm = class(tvcform,tg_const)
function create(aowner); function create(aowner);
begin begin
inherited; inherited;
@ -234,10 +234,10 @@ type tfm = class(tvcform)
line.lineinfo.color := 0xff0000; line.lineinfo.color := 0xff0000;
line.markinfo.bkcolor := 0x00ff00; line.markinfo.bkcolor := 0x00ff00;
line.markinfo.color := 0x0000ff; line.markinfo.color := 0x0000ff;
line.mark_mode := "on"; line.mark_mode := tgc_on;
line.markinfo.size := 30; line.markinfo.size := 30;
line.markinfo.style := line.tgc_mks_pentagram; line.markinfo.style := tgc_mks_pentagram;
line.polyline_style := line.tgc_LS_staircase; line.polyline_style := tgc_LS_staircase;
d := array(); d := array();
idx := 0; idx := 0;
for i:= -pi() to pi() step 0.2 do for i:= -pi() to pi() step 0.2 do
@ -256,7 +256,7 @@ app := initializeapplication();
app.createform(class(tfm),fm); app.createform(class(tfm),fm);
fm.show(); fm.show();
app.run(); app.run();
type tfm = class(tvcform) type tfm = class(tvcform,tg_const)
function create(aowner); function create(aowner);
begin begin
inherited; inherited;
@ -280,7 +280,7 @@ type tfm = class(tvcform)
axs.axises(1).lineinfo.color := 0x00ff00; axs.axises(1).lineinfo.color := 0x00ff00;
sf := new tg_my_surf(); sf := new tg_my_surf();
sf.lineinfo.color := 0x0000ff; sf.lineinfo.color := 0x0000ff;
sf.lineinfo.style := sf.tgc_BS_SOLID; sf.lineinfo.style := tgc_BS_SOLID;
sf.graph_data := get_surf_data(); sf.graph_data := get_surf_data();
sf.parent := axs; sf.parent := axs;
return ; return ;
@ -388,7 +388,7 @@ app := initializeapplication();
app.createform(class(tfm),fm); app.createform(class(tfm),fm);
fm.show(); fm.show();
app.run(); app.run();
type tfm = class(tvcform) type tfm = class(tvcform,tg_const)
function create(aowner); function create(aowner);
begin begin
inherited; inherited;
@ -402,7 +402,7 @@ type tfm = class(tvcform)
//////////设置坐标轴属性//////////////////////// //////////设置坐标轴属性////////////////////////
axs := new tg_axes(); axs := new tg_axes();
axs.box := true; axs.box := true;
axs.figure := fg.figure; axs.figure := fg;
axs.title.text := "hello pie "; axs.title.text := "hello pie ";
axs.axises(1).tics_color := 0x0000ff; axs.axises(1).tics_color := 0x0000ff;
axs.axises(1).fontinfo.size := 8; axs.axises(1).fontinfo.size := 8;
@ -421,7 +421,7 @@ type tfm = class(tvcform)
for i,v in args do for i,v in args do
begin begin
line := new tg_Polyline(); line := new tg_Polyline();
line.polyline_style := line.tgc_LS_filled; line.polyline_style := tgc_LS_filled;
line.closed := true; line.closed := true;
c := (i=2)?1.1:1; c := (i=2)?1.1:1;
line.graph_data := 1+get_pie_lines(v[0],v[1],i=prominentidx,prominentrate); line.graph_data := 1+get_pie_lines(v[0],v[1],i=prominentidx,prominentrate);
@ -459,7 +459,7 @@ app := initializeapplication();
app.createform(class(tfm),fm); app.createform(class(tfm),fm);
fm.show(); fm.show();
app.run(); app.run();
type tfm = class(tvcform) type tfm = class(tvcform,tg_const)
function create(aowner); function create(aowner);
begin begin
inherited; inherited;
@ -504,7 +504,7 @@ type tfm = class(tvcform)
gtx.text := array("按住鼠标左键","移动我"); gtx.text := array("按住鼠标左键","移动我");
gtx.data := array(0.3,0.2); gtx.data := array(0.3,0.2);
//处理鼠标按下 //处理鼠标按下
gtx.addEventListener("mouse_down",function(e)begin gtx.addEventListener(evt_mouse_down,function(e)begin
fdragtext := e.target; fdragtext := e.target;
ftextinitpos := fdragtext.data; ftextinitpos := fdragtext.data;
x := e.cvsx;y := e.cvsy; x := e.cvsx;y := e.cvsy;
@ -512,7 +512,7 @@ type tfm = class(tvcform)
fmousedownpos := array(x1,y1); fmousedownpos := array(x1,y1);
end); end);
//移动标签 //移动标签
fg.addEventListener("mouse_move",function(e)begin fg.addEventListener(evt_mouse_move,function(e)begin
if fdragtext then if fdragtext then
begin begin
e.stoppropagation(); e.stoppropagation();
@ -524,7 +524,7 @@ type tfm = class(tvcform)
end end
end ,true); end ,true);
//处理鼠标松开 //处理鼠标松开
fg.addEventListener("mouse_up",function(e)begin fg.addEventListener(evt_mouse_up,function(e)begin
if fdragtext then if fdragtext then
begin begin
e.stoppropagation(); e.stoppropagation();
@ -548,12 +548,12 @@ type tfm = class(tvcform)
fhitidx := r; fhitidx := r;
return r>=0; return r>=0;
end end
line.addEventListener("mouse_out",function(e)begin line.addEventListener(evt_mouse_out,function(e)begin
if e.eventPhase<>2 then return ; if e.eventPhase<>2 then return ;
fmovetip.Visible := false; fmovetip.Visible := false;
e.stoppropagation(); e.stoppropagation();
end,true); end,true);
line.addEventListener("mouse_move",function(e) line.addEventListener(evt_mouse_move,function(e)
begin begin
if e.eventPhase<>2 then return ; if e.eventPhase<>2 then return ;
e.stoppropagation(); e.stoppropagation();
@ -638,18 +638,24 @@ end }
type tg_WinControl = class(tcustomcontrol,tg_figure_container) //绘图窗口 type tg_WinControl = class(tcustomcontrol,tg_figure_container) //绘图窗口
function create(AOwner); function create(AOwner);
begin begin
if not(s_flush_interval>9) then
begin
s_flush_interval := 150;
ftgwindows := array();
end
class(tcustomcontrol).create(AOwner); class(tcustomcontrol).create(AOwner);
width := 300; width := 300;
height := 300; height := 300;
class(tg_figure_container).create(); class(tg_figure_container).create();
fg_timer := new unit(utslvclstdctl).tcustomtimer(self); fg_timer := new unit(utslvclstdctl).tcustomtimer(self);
fg_timer.Interval := 300; fg_timer.Interval := s_flush_interval;
fg_timer.Ontimer := thisfunction(figure_need_fresh); fg_timer.Ontimer := thisfunction(figure_need_fresh);
ffigureprepared := false; ffigureprepared := false;
ffigure.rec_getter := function()begin ffigure.rec_getter := function()begin
return clientrect; return clientrect;
end end
ffigure.fresh_caller := thisfunction(flushfigure); ffigure.fresh_caller := thisfunction(flushfigure);
ftgwindows[length(ftgwindows)] := makeweakref(self(true));
end end
function flushfigure(); function flushfigure();
begin begin
@ -692,10 +698,35 @@ type tg_WinControl = class(tcustomcontrol,tg_figure_container) //
if ffigure then if ffigure then
begin begin
d := e_2_array(e,evt_mouse_down); d := e_2_array(e,evt_mouse_down);
if ffigure.executecommand(evt_mouse_down,d)=1 then e.skip := true; if ffigure.executecommand(evt_mouse_down,d)=1 then e.skip := true;
SetFocus();
end end
//echo "\r\n",functionname(),tostn(array(xy,bt,sh)); //echo "\r\n",functionname(),tostn(array(xy,bt,sh));
end end
function KeyDown(o,e);override;
begin
if ffigure then
begin
d := ek_2_array(e,evt_key_down);
if ffigure.executecommand(evt_key_down,d)=1 then e.skip := true;
end
end
function keyup(o,e);override;
begin
if ffigure then
begin
d := ek_2_array(e,evt_key_up);
if ffigure.executecommand(evt_key_up,d)=1 then e.skip := true;
end
end
function keypress(o,e);override;
begin
if ffigure then
begin
d := ek_2_array(e,evt_key_press);
if ffigure.executecommand(evt_key_press,d)=1 then e.skip := true;
end
end
function MouseMove(o,e);override; function MouseMove(o,e);override;
begin begin
if ffigure then if ffigure then
@ -729,16 +760,58 @@ type tg_WinControl = class(tcustomcontrol,tg_figure_container) //
function Recycling();override; function Recycling();override;
begin begin
ffigure:=nil; ffigure:=nil;
for i := 0 to length(ftgwindows)-1 do
begin
if ftgwindows[i] =self then
begin
deleteindex(ftgwindows,i);
break;
end
end
inherited; inherited;
end end
class function set_sys_flush_interal(itv); //设置所有窗口的刷新间隔
begin
if itv>9 and itv<>s_flush_interval then
begin
s_flush_interval := itv;
for i,v in ftgwindows do
begin
v.flash_interval := itv;
end
end
end
property flush_interval read get_interval write set_interval; //当前窗口的刷新间隔
private private
function get_interval();
begin
return fg_timer.Interval;
end
function set_interval(itv);
begin
return fg_timer.Interval := itv;
end
function figure_need_fresh(o,e); //定时刷新 function figure_need_fresh(o,e); //定时刷新
begin begin
o.stop(); o.stop();
if not ffigureprepared then return ; //没有准备好 if not ffigureprepared then return ; //没有准备好
if f_validate_doing then return; if f_validate_doing then return;
InvalidateRect(nil,false); InvalidateRect(nil,false);
end
function ek_2_array(e,tp);
begin
d := array();
st := e.shiftstate();
sft := 0x0 in st;
sctl := 0x2 in st;
d := array(
"type":tp,
"shift":sft,
"ctrl":sctl,
"key":e.char,
"keycode":e.CharCode,
);
return d;
end end
function e_2_array(e,tp); function e_2_array(e,tp);
begin begin
@ -757,6 +830,8 @@ type tg_WinControl = class(tcustomcontrol,tg_figure_container) //
return d; return d;
end end
private private
static s_flush_interval;
static ftgwindows;
fmovecnt; fmovecnt;
fg_timer; fg_timer;
f_validate_doing; f_validate_doing;
@ -790,6 +865,18 @@ type tg_figure = class(tg_evet_conainter) //
function executecommand(cmd,p); function executecommand(cmd,p);
begin begin
case cmd of case cmd of
evt_key_down:
begin
return cmd_key_event(evt_key_down,p);
end
evt_key_up:
begin
return cmd_key_event(evt_key_up,p);
end
evt_key_press:
begin
return cmd_key_event(evt_key_press,p);
end
"figure_need_fresh": "figure_need_fresh":
begin begin
fresh(); fresh();
@ -950,7 +1037,24 @@ type tg_figure = class(tg_evet_conainter) //
r[len-i] := v; r[len-i] := v;
end end
return r; return r;
end end
function cmd_key_event(evtname,p) ;
begin
if not fMouseOnOBJ then return ;
d := p;
d["istrusted"] := true;
d["bubbles"] := true;
onds := array();
nnd := fMouseOnOBJ;
while nnd do
begin
onds[length(onds)] := nnd;
nnd := nnd.parent;
end
evt := new tg_evt_key(evtname,d);
dispatchEvent(evt,onds);
return evt.stoppropagationed or evt.defaultPrevented; //是否停止
end
function cmd_mouse_event(evtname,p); function cmd_mouse_event(evtname,p);
begin begin
d := p; d := p;
@ -987,7 +1091,8 @@ type tg_figure = class(tg_evet_conainter) //
end end
fMouseOnOBJ := ninnode; fMouseOnOBJ := ninnode;
evt := new tg_evt_mouse(evt_mouse_in,d); //处理mouse in evt := new tg_evt_mouse(evt_mouse_in,d); //处理mouse in
dispatchEvent(evt,nds); dispatchEvent(evt,nds);
return true;
end end
end else end else
begin begin
@ -1176,6 +1281,7 @@ type tg_axes = class(tg_base) //
cvs.axesrec := r; cvs.axesrec := r;
cvs.axesvector := get_top_outer_points(); cvs.axesvector := get_top_outer_points();
//paint(cvs); //paint(cvs);
cvs.executecommand("painter",self(true));
paint_grid(cvs); paint_grid(cvs);
inherited; inherited;
cvs.axesunclip(); cvs.axesunclip();
@ -2351,7 +2457,11 @@ type tg_canvas = class(TcustomCanvas) //
ffigurergn.rect := fg.rect(); ffigurergn.rect := fg.rect();
faxesrgntemp := new TRGNPOLY();//new TRGNRECT(); faxesrgntemp := new TRGNPOLY();//new TRGNRECT();
//ffigurergn. //ffigurergn.
end end
function executecommand(cmd,p);override;
begin
if cmd ="painter" then fpainter := p;
end
function axesclip(); //裁剪坐标系范围 function axesclip(); //裁剪坐标系范围
begin begin
if faxesrgn then if faxesrgn then
@ -2386,6 +2496,23 @@ type tg_canvas = class(TcustomCanvas) //
property figure:tg_figure read ffigure; //绘制区域 property figure:tg_figure read ffigure; //绘制区域
property axesvector read faxesvector write set_clip_vector; //坐标系区域 property axesvector read faxesvector write set_clip_vector; //坐标系区域
property axesrec read FaxesRec write set_clip_rect; //坐标系矩形区域 property axesrec read FaxesRec write set_clip_rect; //坐标系矩形区域
property painter read fpainter;
////////////绘制相关//////////////////////////////////////////////
function tg_movto(x,y,z);//移动
begin
if not fpainter then return ;
if fpainter.zoom_to_xyz(x,y,z,x0,y0) then return moveto(x0,y0);
end
function tg_lineto(x,y,z);//画线
begin
if not fpainter then return ;
if fpainter.zoom_to_xyz(x,y,z,x0,y0) then return lineto(x0,y0);
end
function tg_trans(a,x,y,z);//旋转
begin
if not fpainter then return ;
if fpainter.zoom_to_xyz(x,y,z,x0,y0) then return trans(a,x0,y0);
end
private private
FaxesRec; FaxesRec;
faxesvector; faxesvector;
@ -2395,6 +2522,7 @@ type tg_canvas = class(TcustomCanvas) //
faxesrgntemp; faxesrgntemp;
ffigurerect; ffigurerect;
[weakref]ffigure; [weakref]ffigure;
[weakref]fpainter;
private private
function set_clip_rect(rec); function set_clip_rect(rec);
begin begin
@ -3076,12 +3204,12 @@ type tg_text = class(tg_base)
if not zoom_to_xyz(fdata[0],fdata[1],fdata[2],x,y) then return ; if not zoom_to_xyz(fdata[0],fdata[1],fdata[2],x,y) then return ;
if clip_state=tgc_on or ((p:=parent) and p.clip_state=tgc_on) then if clip_state=tgc_on or ((p:=parent) and p.clip_state=tgc_on) then
begin begin
bx := axes.zoom_box; {bx := axes.zoom_box;
vj := fdata; vj := fdata;
if vj[0]<bx[0,0] or vj[1]<bx[1,0] or vj[2]<bx[2,0] or vj[0]>bx[0,1] or vj[1]>bx[1,1] or vj[2]>bx[2,1] then if vj[0]<bx[0,0] or vj[1]<bx[1,0] or vj[2]<bx[2,0] or vj[0]>bx[0,1] or vj[1]>bx[1,1] or vj[2]>bx[2,1] then
begin begin
return ; return ;
end end }
cvs.axesclip(); cvs.axesclip();
end end
else cvs.axesunclip(); else cvs.axesunclip();
@ -4393,7 +4521,8 @@ type tg_base = class(TNode,tg_evet_conainter) //
end end
function paint_pre(cvs);virtual; function paint_pre(cvs);virtual;
begin begin
cvs.executecommand("painter",self(true));
paint(cvs); paint(cvs);
lgns := array(); lgns := array();
for i := 0 to NodeCount-1 do for i := 0 to NodeCount-1 do
@ -4697,6 +4826,9 @@ type tg_const = class()
//static const tgc_out_lower_right = "out_lower_right"; //static const tgc_out_lower_right = "out_lower_right";
//static const tgc_out_lower_left = "out_lower_left"; //static const tgc_out_lower_left = "out_lower_left";
////////////// //////////////
static evt_key_down = "key_down";
static evt_key_up = "key_up";
static evt_key_press = "key_press";
static evt_mouse_down = "mouse_down"; static evt_mouse_down = "mouse_down";
static evt_mouse_wheel = "mouse_wheel"; static evt_mouse_wheel = "mouse_wheel";
static evt_mouse_move = "mouse_move"; static evt_mouse_move = "mouse_move";
@ -4804,8 +4936,8 @@ type tg_evt_mouse = class(tg_evt_custom) //
fdouble := pms["double"]; fdouble := pms["double"];
fbutton := pms["button"]; fbutton := pms["button"];
fshift := pms["shift"]; fshift := pms["shift"];
fctl := pms["ctrl"]; fctrl := pms["ctrl"];
fctl := pms["fdelta"]; fdelta := pms["fdelta"];
end end
end end
property cvsx read fcvsx; property cvsx read fcvsx;
@ -4825,6 +4957,28 @@ type tg_evt_mouse = class(tg_evt_custom) //
fctrl; fctrl;
fbutton; fbutton;
end end
type tg_evt_key = class(tg_evt_custom) //key消息
function create(etyp,pms);
begin
inherited;
if ifarray(pms) then
begin
fshift := pms["shift"];
fctrl := pms["ctrl"];
fkey := pms["key"];
fkeycode := pms["keycode"];
end
end
property key read fkey;
property shift read fshift;
property ctrl read fctrl;
property keycode read fkeycode;
private
fshift;
fctrl;
fkey;
fkeycode;
end
implementation implementation
///////////事件存储对象/////////////////////// ///////////事件存储对象///////////////////////

View File

@ -172,7 +172,7 @@ type t_worker_host = class(t_worker_base)
{** {**
@param(OnMessage)(function[TThreadWorker,data]) 消息回调 %% @param(OnMessage)(function[TThreadWorker,data]) 消息回调 %%
@param(OnStart)(function[TThreadWorker]) 子线程启动 %% @param(OnStart)(function[TThreadWorker]) 子线程启动 %%
@param(OnError)(function[TThreadWorker,d]) 子线程启动 %% @param(OnError)(function[TThreadWorker,d]) 子线程运行错误%%
**} **}
function terminate();override; function terminate();override;
begin begin
@ -576,6 +576,7 @@ begin
end end
function iffuncptr(fn); function iffuncptr(fn);
begin begin
return datatype(fn) in array(7,37);
//return datatype(fn)=7; //return datatype(fn)=7;
return ifobj(fn); return ifobj(fn);
end end

View File

@ -6,65 +6,39 @@ uses utslvclauxiliary;//,utslvclgdi;
**} **}
////////////tmf文件相关////////////////////////////////////////////// ////////////tmf文件相关//////////////////////////////////////////////
/////////////tmf字符串解析/////////////////////// /////////////tmf字符串解析///////////////////////
function RegComponentPropertyType(vc); function RegComponentPropertyType(vc);
function GetComponentPropertyType(n); function GetComponentPropertyType(n);
type TTmfParserbase = class type TTmfParserbase = class
{** {**
@explan(说明) 解析基类,提供基础类型,提供类型常量 @explan(说明) 解析基类,提供基础类型,提供类型常量
目前使用的常量有 TT_NUM,TT_BIN,TT_STR,TT_SYM%% 目前使用的常量有 TT_NUM,TT_BIN,TT_STR,TT_SYM%%
**} **}
Static Fsok; static const TT_NUM = 1; //数字
static TT_NUM;//数字 static const TT_LLB = 2; //大括号
static TT_LLB;//大括号 static const TT_RLB = 3; //大括号
static TT_RLB;//大括号 static const TT_LSB = 4; //(
static TT_LSB; //( static const TT_RSB = 5; //)
static TT_RSB; //) static const TT_STR = 6; //字符串
static TT_STR;//字符串 static const TT_SYM = 7; //符号
static TT_SYM;//符号 static const TT_POI = 8; //点 .
static TT_POI;//点 . static const TT_SIG = 9; // : + - :< > =
static TT_SIG;// : + - :< > = static const TT_BNK = 10; //空白 \r \n \t
static TT_BNK;//空白 \r \n \t static const TT_ITEM = 11;
static TT_ITEM; static const TT_LMB = 12;
static TT_RMB; static const TT_RMB = 13;
static TT_LMB; static const TT_SET = 14;
static TT_SET; static const TT_HASH = 15;
static TT_COLL; static const TT_COLL = 0x10;
static TT_LIST; static const TT_BIN = 0x11;
static TT_BIN; static const TT_BOOL = 0x12;
static TT_BOOL; static const TT_LIST = 0x13;
static TT_IDENT; static const TT_IDENT = 0x14;
static TT_HEX; static const TT_HEX = 0x15;
static TT_COMP; static const TT_COMP = 0x16;
public public
class function sinit();virtual; class function sinit();virtual;
begin begin
if not Fsok then end
begin
TT_NUM := 1; //数字
TT_LLB := 2; //大括号
TT_RLB := 3; //大括号
TT_LSB := 4; //(
TT_RSB := 5; //)
TT_STR := 6; //字符串
TT_SYM := 7; //符号
TT_POI := 8; //点 .
TT_SIG := 9; // : + - :< > =
TT_BNK := 10; //空白 \r \n \t
TT_ITEM := 11;
TT_LMB := 12;
TT_RMB := 13;
TT_SET := 14;
TT_HASH := 15;
TT_COLL := 0x10;
TT_BIN := 0x11;
TT_BOOL := 0x12;
TT_LIST := 0x13;
TT_IDENT := 0x14;
TT_HEX := 0x15;
TT_COMP := 0x16;
Fsok := true;
end
end
class function PError(msg,lev); class function PError(msg,lev);
begin begin
//messagebox(msg,"解析错误",1); //messagebox(msg,"解析错误",1);
@ -73,7 +47,7 @@ type TTmfParserbase = class
begin begin
sinit(); sinit();
end end
end end
type TTmfParserToken = class(TTmfParserbase) type TTmfParserToken = class(TTmfParserbase)
{** {**
@ -89,8 +63,6 @@ type TTmfParserToken = class(TTmfParserbase)
FTokens; FTokens;
FSplitter; //分隔符 FSplitter; //分隔符
FSyms; //符号 FSyms; //符号
FNumberChar;
FHexChar;
Function SetScript(S);//设置文本 Function SetScript(S);//设置文本
begin begin
IF FScript <> S then IF FScript <> S then
@ -360,9 +332,6 @@ type TTmfParserToken = class(TTmfParserbase)
//Ffloat := FNumbers union array("."); //Ffloat := FNumbers union array(".");
FSplitter := array(' ','\t',"\r","\n",";",","); FSplitter := array(' ','\t',"\r","\n",";",",");
FSyms := array("=",":","(",")","<",">","[","]"); FSyms := array("=",":","(",")","<",">","[","]");
FNumberChar := inttostr(0 -> 9);
FHexChar := FNumberChar union array("a","b","c","d","e","f",
"A","B","C","D","E","F");
end end
property Script read FScript write SetScript; property Script read FScript write SetScript;
{** {**
@ -511,26 +480,67 @@ type TTmfParser = class(TTmfParserbase)
end end
function gettree2(); //获得继承关系树 function gettree2(); //获得继承关系树
begin begin
tx := mtic;
d := gettreeasobject(); d := gettreeasobject();
if d then if d then
begin begin
d.setinhertedpaths(fssourdirs);//设置路径 d.setinhertedpaths(fssourdirs);//设置路径
d.initinherited(); d.initinherited(); //解析继承的数据文件信息
d.addinode(d.finheritednode); //合并继承的信息
getnodelist(d,lst,dlist); //获取冲突的对象
for i,v in dlist do //删除冲突的成员
begin
try
v["p"].fobjects.deleteindex(v["n"]);
except
end;
end
return object2tree2(d); return object2tree2(d);
end end
end end
function inheritedcoy(n,t,ht); function getnodelist(d,lst,dlist); //获取排除对象列表,以及冲突的对象
begin begin
d := gettreeasobject(); if not ifarray(lst) then lst := array();
if d then if not ifarray(dlist) then dlist := array();
begin fos := d.fobjects;
d.setinhertedpaths(fssourdirs);//设置路径 for i,v in fos.IndexNames() do
d.initinherited(); begin
return d.inheritedstr(n,t,ht,0); vd := fos[v];
end if lst[v] then //父类中的优先级大于最新添加的,因为新加入的不能和原有的重名,如果积累中添加了,子类也应该被删掉
return ""; begin
if lst[v,"i"] and not(vd.ifinherited) then //删除当前这个
begin
dlist[length(dlist)] := array("p":d,"n":v);
end else
if vd.ifinherited and not(lst[v,"i"]) then //删除上一个
begin
dlist[length(dlist)] := lst[v,array("p","n")];
lst[v] := array("p":d,"nd":vd,"n":v,"i":vd.ifinherited,"ct":vd.inheritedcount);
end else
if not(vd.ifinherited) and not(lst[v,"i"]) then //删除当前
begin
dlist[length(dlist)] := array("p":d,"n":v);
end else
if vd.ifinherited<lst[v,"ct"] then //删除当前
begin
dlist[length(dlist)] := array("p":d,"n":v);
end else //删除上一个
begin
dlist[length(dlist)] := lst[v,array("p","n")];
lst[v] := array("p":d,"nd":vd,"n":v,"i":vd.ifinherited,"ct":vd.inheritedcount);
end
end else
begin
lst[v] := array("p":d,"nd":vd,"n":v,"i":vd.ifinherited,"ct":vd.inheritedcount);
end
getnodelist(vd,lst,dlist);
end
end
function inheritedcopy(n,t,ht); //构造继承的tfm文本
begin
return inheritedstr(n,t,ht);
end end
function object2tree2(t); //获得继承关系 function object2tree2(t); //获得继承关系数组
begin begin
r := array(); r := array();
r["inherited"] := t.ifinherited; r["inherited"] := t.ifinherited;
@ -551,23 +561,21 @@ type TTmfParser = class(TTmfParserbase)
objs[v] := object2tree2(fos[v]); objs[v] := object2tree2(fos[v]);
end end
r["property"] := ps; r["property"] := ps;
r["object"] := objs; r["object"] := objs;
return r; return r;
end end
function gettreeasobject(); function gettreeasobject();//当前tfm对象
begin begin
if ftreeobj then return ftreeobj; if ftreeobj then return ftreeobj;
gettree(); gettree();
if FTree then if FTree then
begin begin
//ttfmnode
ftreeobj := createndeobjects(FTree); ftreeobj := createndeobjects(FTree);
return ftreeobj; return ftreeobj;
end end
return nil; return nil;
end end
function createndeobjects(d); function createndeobjects(d);//构造tfm对象树
begin begin
if ifarray(d) then if ifarray(d) then
begin begin
@ -661,7 +669,7 @@ type TTmfParser = class(TTmfParserbase)
end end
end end
end end
function createobj(); function createobj(); //解析对象
begin begin
{** {**
@explan(说明) 获取对象 %% @explan(说明) 获取对象 %%
@ -672,13 +680,12 @@ type TTmfParser = class(TTmfParserbase)
if (tv="object" or tv="inherited") and(tt <> TT_STR) then if (tv="object" or tv="inherited") and(tt <> TT_STR) then
begin begin
r := getobject(); r := getobject();
if tv="inherited" then r["inherited"] := (tv="inherited")?true:false;
r["inherited"] := true;
return r; return r;
end end
end end
end end
function getobject(); function getobject();//解析对象内容
begin begin
{** {**
@explan(说明) 获得对象 %% @explan(说明) 获得对象 %%
@ -710,43 +717,46 @@ type TTmfParser = class(TTmfParserbase)
begin begin
ctoken(tv,tt); ctoken(tv,tt);
lx := tt; lx := tt;
{if tv="item" and(tt <> TT_STR)then if tt<>TT_STR then
begin begin
lx := TT_ITEM; case tv of
val := getabitem(); "[":
end else} begin
if tv="[" and(tt <> TT_STR)then lx := TT_SET;
val := getset();
end
"<":
begin
val := getabitem(tv,fff); // getab();
if fff then lx := TT_COLL;
else lx := TT_ITEM; //TT_COLL;
end
"(":
begin
val := getsb();
lx := TT_LIST;
end
"{":
begin
val := getlb();
lx := TT_BIN;
end
"true":
begin
val := true;
lx := TT_NUM;
end
"false":
begin
val := false;
lx := TT_NUM;
end
else val := tv;
end ;
end else
begin begin
lx := TT_SET; val := tv;
val := getset(); end
end else
if tv="<" and(tt <> TT_STR)then
begin
val := getabitem(tv,fff); // getab();
if fff then lx := TT_COLL;
else lx := TT_ITEM; //TT_COLL;
end else
if tv="(" and(tt <> TT_STR)then
begin
val := getsb();
lx := TT_LIST;
end else
if tv="{" and(tt <> TT_STR)then
begin
val := getlb();
lx := TT_BIN;
end else
if tv="true" and(tt <> TT_STR)then
begin
val := true;
lx := TT_NUM;
end else
if tv="false" and(tt <> TT_STR)then
begin
val := false;
lx := TT_NUM;
end else
val := tv;
end end
function getmembers(); function getmembers();
begin begin
@ -821,7 +831,6 @@ type TTmfParser = class(TTmfParserbase)
begin begin
ctoken(tv,tt); ctoken(tv,tt);
if tv="]" and tt <> TT_STR then return r; if tv="]" and tt <> TT_STR then return r;
//if tv="item" and tt <> TT_STR then r[rl++]:= array("value":getabitem(tv),"type":TT_ITEM);
else if tv="<" and tt <> TT_STR then else if tv="<" and tt <> TT_STR then
begin begin
v := getabitem(tv,fff); v := getabitem(tv,fff);
@ -835,7 +844,6 @@ type TTmfParser = class(TTmfParserbase)
function getabitem(tp,ifitem); function getabitem(tp,ifitem);
begin begin
if not ifstring(tp)then endtp := "end"; if not ifstring(tp)then endtp := "end";
//else if tp="item" then endtp := "end";
else if tp="<" then endtp := ">"; else if tp="<" then endtp := ">";
else PError("dict错误",1); else PError("dict错误",1);
r := array(); r := array();
@ -844,7 +852,7 @@ type TTmfParser = class(TTmfParserbase)
while whileok() do while whileok() do
begin begin
ctoken(tv,tt); ctoken(tv,tt);
if tv=endtp {"end"}and tt <> TT_STR then return r; if tv=endtp and tt <> TT_STR then return r;
p := tv; p := tv;
ptt := tt; ptt := tt;
ctoken(tv,tt); ctoken(tv,tt);
@ -854,13 +862,7 @@ type TTmfParser = class(TTmfParserbase)
if ifnil(val)or ifnil(lx)then PError("item无值",1); if ifnil(val)or ifnil(lx)then PError("item无值",1);
r[rl++]:= array("name":p,"value":val,"type":lx); r[rl++]:= array("name":p,"value":val,"type":lx);
end else end else
{if p="item" and ptt <> TT_STR and(length(r)<1)then PError("item没有=",1);
begin
ifitem := true;
btoken(2);
return getab();
end else}
PError("item没有=",1);
end end
end end
function getab(); function getab();
@ -877,10 +879,6 @@ type TTmfParser = class(TTmfParserbase)
begin begin
return r; return r;
end else end else
{if tv="item" and tt <> TT_STR then
begin
r[rl++]:= getabitem();
end else}
begin begin
return PError("<>内容错误",1); return PError("<>内容错误",1);
end end
@ -905,8 +903,7 @@ type TTmfParser = class(TTmfParserbase)
begin begin
return r; return r;
end else end else
{if tv="item" and tt <> TT_STR then r[rl++]:= array("value":getabitem(tv),"type":TT_ITEM); if tv="<" and tt <> TT_STR then
else }if tv="<" and tt <> TT_STR then
begin begin
v := getabitem(tv,fff); v := getabitem(tv,fff);
lx := fff?TT_COLL:TT_ITEM; lx := fff?TT_COLL:TT_ITEM;
@ -2275,11 +2272,67 @@ type ttfmnode = class()
end end
function create(t,n); function create(t,n);
begin begin
inheritedcount := 0;
fnodename := n; fnodename := n;
fnodetype := t; fnodetype := t;
fpropertys := new tstrindexarray(); fpropertys := new tstrindexarray();
fobjects := new tstrindexarray(); fobjects := new tstrindexarray();
finheritedpaths := array(); finheritedpaths := array();
end
function addinode(nd);
begin
//if not nd then return ;
if nd and nd.finheritednode then nd.addinode(nd.finheritednode);
for i,v in fobjects.IndexNames() do
begin
ov := fobjects[v];
if ov.ifinherited then //继承的控件
begin
if ifobj(nd) then
begin
fd := nd.getnodebyname(v); //ov.fnodename
if fd then
begin
ov.inheritedcount++;
ov.finheritednode :=fd;
end else //不在继承源头,删除
begin
fobjects.deleteindex(v);
end
end else //不在继承源头,删除
begin
fobjects.deleteindex(v);
end
end else
begin
end
end
if nd then
begin
for i,v in nd.getnodenames() do //添加父窗口控件
begin
ov := fobjects[v];
nnd := nd.getnodebyname(v);
if not ov then
begin
fobjects[v] := nnd.copyinh(); //复制属性
end else ov.addinode(nnd); //添加属性
end
end
end
function copyinh();//继承拷贝
begin
r := new ttfmnode(fnodetype,fnodename);
for i,v in fobjects.IndexNames() do
begin
vv := fobjects[v];
vi := vv.copyinh();
r.addobject(vi);
end
r.finheritednode := self;
r.ifinherited := true;
return r;
end end
function get_inherited(data); function get_inherited(data);
begin begin
@ -2290,9 +2343,10 @@ type ttfmnode = class()
begin begin
nd.setinhertedpaths(finheritedpaths); nd.setinhertedpaths(finheritedpaths);
nd.initinherited(); nd.initinherited();
finheritednode := nd;
//addinheritednode(nd); 此处屏蔽
end end
finheritednode := nd;
addinheritednode(nd);
end end
function initinherited(); function initinherited();
begin begin
@ -2330,6 +2384,9 @@ type ttfmnode = class()
end end
function addinheritednode(nd); //处理继承的节点 function addinheritednode(nd); //处理继承的节点
begin begin
///////////////查找空白/////////////////////////////////////
///////////////////////////////////////////////////////////////
for i,v in fobjects.IndexNames() do for i,v in fobjects.IndexNames() do
begin begin
ov := fobjects[v]; ov := fobjects[v];
@ -2350,8 +2407,15 @@ type ttfmnode = class()
fobjects.deleteindex(v); fobjects.deleteindex(v);
end end
end end
ov.addinheritednode(nd); if fd then
end ov.addinheritednode(fd);
end
end
function getnodenames();
begin
return fobjects.IndexNames();
end end
function getnodebyname(sb);//获得节点 function getnodebyname(sb);//获得节点
begin begin
@ -2434,29 +2498,8 @@ type ttfmnode = class()
r[i] := fpropertys[v]; r[i] := fpropertys[v];
end end
return r; return r;
end end
function inheritedstr(n,t,ht,h); inheritedcount;
begin
if ifnil(n) then n := fnodename;
if ifnil(t) then t := fnodetype;
ws := "";
if not(h>=0) then h := 0;
for i:= 0 to h-1 do
begin
ws+=" ";
end
r := ws+"inherited "+n+":"+t;
if ht then r+="("+ht+")";
r+="\r\n";
for i,v in fobjects.IndexNames() do
begin
vo := fobjects[v];
r+=vo.inheritedstr(nil,nil,nil,h+1);
end
r+="\r\n";
r+=ws+"end\r\n";
return r;
end
ifinherited; ifinherited;
finheritedname; finheritedname;
finheritednode; finheritednode;
@ -2464,10 +2507,17 @@ type ttfmnode = class()
fnodename; fnodename;
fobjects; fobjects;
private private
fpropertys; fpropertys;
finheritedpaths; finheritedpaths;
end end
function inheritedstr(n,t,ht);
begin
r := "inherited "+n+":"+t;
if ht then r+="("+ht+")";
r+="\r\n";
r+="end\r\n";
return r;
end
function tablelines(str,n); function tablelines(str,n);
begin begin
lines := str2array(str,"\r\n"); lines := str2array(str,"\r\n");

Binary file not shown.

Binary file not shown.