设计器

优化细节
This commit is contained in:
JianjunLiu 2023-01-10 11:27:05 +08:00
parent 8ed3ce6baa
commit 12f73f17d6
8 changed files with 185 additions and 26 deletions

View File

@ -309,6 +309,7 @@ type TVclDesigner = class(tvcform)
end end
public //设计器工程 public //设计器工程
ffilemenu; ffilemenu;
fviewmenu;
function OpenFileFromTpjFile(); //从文件打开工程 function OpenFileFromTpjFile(); //从文件打开工程
begin begin
FProjectFileOpener.caption := "打开"; FProjectFileOpener.caption := "打开";
@ -468,7 +469,7 @@ type TVclDesigner = class(tvcform)
("type":"menu","caption":"代码编辑","onclick":thisfunction(openclassfile), ("type":"menu","caption":"代码编辑","onclick":thisfunction(openclassfile),
"bitmap":geteditcodebitmapinfo()) "bitmap":geteditcodebitmapinfo())
)), )),
("type":"menu","caption":"ĘÓÍź","items":( ("type":"menu","caption":"ÊÓͼ","filed":"fviewmenu","items":(
("type":"menu","caption":"工程文件管理","checked":1,"bitmap":GetWindowMgrBmp(),"onclick":thisfunction(ShowProjectView)), ("type":"menu","caption":"工程文件管理","checked":1,"bitmap":GetWindowMgrBmp(),"onclick":thisfunction(ShowProjectView)),
("type":"menu","caption":"对象浏览","checked":true,"onclick":thisfunction(Mobjinspect), ("type":"menu","caption":"对象浏览","checked":true,"onclick":thisfunction(Mobjinspect),
"bitmap":getdefaultbmpinfo()) "bitmap":getdefaultbmpinfo())
@ -587,17 +588,21 @@ type TVclDesigner = class(tvcform)
@explan(说明) 移动 控件 %% @explan(说明) 移动 控件 %%
**} **}
//setcomponentfocus(o,false); //setcomponentfocus(o,false);
FPropGrid.SetGridValue("left",O.left,O) ; l := O.left;
FPropGrid.SetGridValue("top",o.top,O); r := o.top;
if not FPropGrid.SetGridValue("left",l,O) then o.setpublish("left",l);
if not FPropGrid.SetGridValue("top",r,O) then o.setpublish("top",r);
end end
function ComponentSize(o,e);//大小改变 function ComponentSize(o,e);//大小改变
begin begin
{** {**
@explan(说明) 调整控件大小 %% @explan(说明) 调整控件大小 %%
**} **}
FPropGrid.SetGridValue("width",o.width,O); w := o.width;
FPropGrid.SetGridValue("height",o.height,O); h := o.height;
if not FPropGrid.SetGridValue("width",w,O) then o.setpublish("width",w);
if not FPropGrid.SetGridValue("height",h,O) then o.setpublish("height",h);
//setcomponentfocus(o,false); //setcomponentfocus(o,false);
end end
function DesignerClose(o,e) //控件窗口关闭 function DesignerClose(o,e) //控件窗口关闭
@ -984,6 +989,27 @@ type TVclDesigner = class(tvcform)
FPropGrid.Component := nd.fcomp ; FPropGrid.Component := nd.fcomp ;
FEventGrid.Component := nd.fcomp ; FEventGrid.Component := nd.fcomp ;
end end
function showcurrent();
begin
nd := fcwindowinfo;
if nd then
begin
FTree := fcwindowinfo.ftree;
nnd := FTree.RootItem.GetNodeByIndex(0);
if nnd then
begin
cp := nnd.Component;
if cp then
begin
wd := cp.Cwnd;
if wd.visible then
begin
_wapi.SetActiveWindow(wd.Handle);
end
end
end
end
end
function switchtree(nd); //切换控件树 function switchtree(nd); //切换控件树
begin begin
FCurrentNode := nil; FCurrentNode := nil;
@ -1037,6 +1063,10 @@ type TVclDesigner = class(tvcform)
end end
return r; return r;
end end
"shownode":
begin
showcurrent();
end
"hiddrennode": "hiddrennode":
begin begin
hidenatree(fcwindowinfo); hidenatree(fcwindowinfo);
@ -1317,6 +1347,7 @@ type TVclDesigner = class(tvcform)
FProjectFileOpener.parent := self; FProjectFileOpener.parent := self;
FProjectManager.FTslEditer.setdbugruncall(thisfunction(debugproject)); //设置调试回调 FProjectManager.FTslEditer.setdbugruncall(thisfunction(debugproject)); //设置调试回调
FProjectManager.newmenu.parent := ffilemenu;// FProjectManager.newmenu.parent := ffilemenu;//
FProjectManager.goformmenu.parent := fviewmenu;//
//fnewmenu //fnewmenu
end end

View File

@ -14,7 +14,6 @@ type TProjectManagerForm = class(TVCForm) //
Border := false; Border := false;
FProjectCoder := new TDesignerProjectsRecoder(); FProjectCoder := new TDesignerProjectsRecoder();
FDesigner := AOwner; FDesigner := AOwner;
//FileOpen.filter := array("tvcl¹¤³Ì":"*.tpj");
visible := false; visible := false;
WsSizeBox := true; WsSizeBox := true;
caption := "历史工程"; caption := "历史工程";
@ -478,7 +477,12 @@ type TProjectView = class(TVCForm) //
FWrapFolder.Caption := "打包工程到目录"; FWrapFolder.Caption := "打包工程到目录";
fnewmenu := new TMenu(self); fnewmenu := new TMenu(self);
fgoformmenu := new TMenu(self);
fgoformmenu.caption := "回到设计器";
fgoformmenu.ShortCut := "f12";
fgoformmenu.OnClick := thisfunction(filetoform);
fnewmenu.Enabled := false; fnewmenu.Enabled := false;
fgoformmenu.Enabled := false;
fnewmenu.caption := "新建"; fnewmenu.caption := "新建";
for i,v in array("form","panel","script","tsf") do for i,v in array("form","panel","script","tsf") do
begin begin
@ -638,6 +642,7 @@ type TProjectView = class(TVCForm) //
function Add_form(); function Add_form();
begin begin
if not FCProjectPath then return Messageboxa("工程没打开","提示",0,self); if not FCProjectPath then return Messageboxa("工程没打开","提示",0,self);
return AddFormToCurrentDir(createnamea("form"));
if FInput.ShowModal()then if FInput.ShowModal()then
begin begin
AddFormToCurrentDir(FInput.GetEditV(1)); AddFormToCurrentDir(FInput.GetEditV(1));
@ -646,6 +651,7 @@ type TProjectView = class(TVCForm) //
function Add_panel(); function Add_panel();
begin begin
if not FCProjectPath then return Messageboxa("工程没打开","提示",0,self); if not FCProjectPath then return Messageboxa("工程没打开","提示",0,self);
return AddPanelToCurrentDir(createnamea("pal"));
if FInput.ShowModal()then if FInput.ShowModal()then
begin begin
AddPanelToCurrentDir(FInput.GetEditV(1)); AddPanelToCurrentDir(FInput.GetEditV(1));
@ -654,6 +660,7 @@ type TProjectView = class(TVCForm) //
function Add_tsf(); function Add_tsf();
begin begin
if not FCProjectPath then return Messageboxa("工程没打开","提示",0,self); if not FCProjectPath then return Messageboxa("工程没打开","提示",0,self);
return AddTsfToCurrentDir(createnamea("func"),"tsf");
if FInput.ShowModal()then if FInput.ShowModal()then
begin begin
AddTsfToCurrentDir(FInput.GetEditV(1),"tsf"); AddTsfToCurrentDir(FInput.GetEditV(1),"tsf");
@ -662,6 +669,7 @@ type TProjectView = class(TVCForm) //
function add_tsl(); function add_tsl();
begin begin
if not FCProjectPath then return Messageboxa("工程没打开","提示",0,self); if not FCProjectPath then return Messageboxa("工程没打开","提示",0,self);
return AddTsfToCurrentDir(createnamea("tsl"),"tsl");
if FInput.ShowModal()then if FInput.ShowModal()then
begin begin
AddTsfToCurrentDir(FInput.GetEditV(1),"tsl"); AddTsfToCurrentDir(FInput.GetEditV(1),"tsl");
@ -729,6 +737,21 @@ type TProjectView = class(TVCForm) //
end end
return FTslEditer.GetClassInfo(); return FTslEditer.GetClassInfo();
end end
function filetoform();
begin
it := FTslEditer.GetCurrentItem();
if not it then return ;
f := it.ScriptPath;
r := getnodebyfilename(f,FTree.RootNode) ;
if not r then return ;
if r=FTree.CurrentNode then
begin
OpenFileByName(r.Fname);
FDesigner.ExecuteCommand("shownode",nil);
end else
setnodesel(r);
end
function ShowEditor(); //显示函数编辑 function ShowEditor(); //显示函数编辑
begin begin
FTslEditer.Show(SW_SHOWNOACTIVATE); // FTslEditer.Show(SW_SHOWNOACTIVATE); //
@ -954,12 +977,14 @@ type TProjectView = class(TVCForm) //
FTree.ProjectNode.Expand(); FTree.ProjectNode.Expand();
FTree.PopUpMenu := FTreePopUpMenu; FTree.PopUpMenu := FTreePopUpMenu;
fnewmenu.Enabled := true; fnewmenu.Enabled := true;
fgoformmenu.Enabled := true;
end else end else
begin begin
FTree.PopUpMenu := nil; FTree.PopUpMenu := nil;
FOpenProjectFile := ""; FOpenProjectFile := "";
messageboxa("打开工程文件错误:"+f,"提示",0,self); messageboxa("打开工程文件错误:"+f,"提示",0,self);
fnewmenu.Enabled := false; fnewmenu.Enabled := false;
fgoformmenu.Enabled := false;
return; return;
end end
FTslEditer.TslSearchDir := array(p,Getfuncextdir()); FTslEditer.TslSearchDir := array(p,Getfuncextdir());
@ -1514,9 +1539,28 @@ end
end end
end end
end end
function Recycling();override;
begin
inherited;
FMoveMnus := nil;
FMoveMenu := nil;
FOpenMenu := nil;
fnewmenu := nil;
fgoformmenu := nil;
end
private private
FMoveMnus; FMoveMnus;
FMoveMenu; FMoveMenu;
function getnodebyfilename(f,nd);//获得编辑器对应节点
begin
if not nd then return 0;
if (nd.gettsfname()=f) or (nd.gettmfname()=f) then return nd;
for i:=0 to nd.ItemCount-1 do
begin
r := getnodebyfilename(f,nd.GetNodeByIndex(i));
if r then return r;
end
end
function getdefaultdir(); function getdefaultdir();
begin begin
cnd := FTree.CurrentNode; cnd := FTree.CurrentNode;
@ -1775,8 +1819,10 @@ end
FAddMenuTsl; FAddMenuTsl;
FOpenMenu; FOpenMenu;
fnewmenu; fnewmenu;
fgoformmenu;
public public
property newmenu read fnewmenu; property newmenu read fnewmenu;
property goformmenu read fgoformmenu;
FTslEditer; FTslEditer;
property tree read ftree; property tree read ftree;
private private
@ -1856,7 +1902,7 @@ BD141CA912494F502D48D224F45050274A21E03806FF2C7CA7516022D7D000000
caption := "代码编辑器"; caption := "代码编辑器";
WsDlgModalFrame := true; WsDlgModalFrame := true;
visible := false; visible := false;
Left := 50; Left := 300;
Top := 120; Top := 120;
Width := 1000; Width := 1000;
height := 900; height := 900;

View File

@ -1832,7 +1832,6 @@ type TEditer=class(TCustomcontrol) //
FSynClasses["bat"]:= array(class(TBatSynHigLighter),class(TSynCompletion),";bat;cmd;"); FSynClasses["bat"]:= array(class(TBatSynHigLighter),class(TSynCompletion),";bat;cmd;");
FSynClasses["tfm"]:= array(class(ttfmhighlighter),class(TSynCompletion),";tfm;"); FSynClasses["tfm"]:= array(class(ttfmhighlighter),class(TSynCompletion),";tfm;");
FSynClasses["None"]:= array(nil,nil,""); FSynClasses["None"]:= array(nil,nil,"");
//FSynClasses["tsf"] := FSynClasses["tsl"];
FTslChmHelp := new TTslChmHelp(); FTslChmHelp := new TTslChmHelp();
FCodeFormatInfo := array("wordct":80,"charct":200,"syn":true,"sel":false,"arraytype":0); FCodeFormatInfo := array("wordct":80,"charct":200,"syn":true,"sel":false,"arraytype":0);
FPageEditer.OnDblClick := function(o,e) FPageEditer.OnDblClick := function(o,e)

View File

@ -1800,7 +1800,10 @@ type TColorbox=class(TcustomListBox)
function create(aOwner);override; function create(aOwner);override;
begin begin
inherited; inherited;
fcustomcolor := nil;
arr := array( arr := array(
("value":"Custom","color":nil),
("value":"None","color":nil),
("value":"Black","color":0), ("value":"Black","color":0),
("value":"Maroon","color":128), ("value":"Maroon","color":128),
("value":"Green","color":32768), ("value":"Green","color":32768),
@ -1825,6 +1828,25 @@ type TColorbox=class(TcustomListBox)
("value":"MedGray","color":10789024)); ("value":"MedGray","color":10789024));
setData(arr); setData(arr);
end end
function MouseUp(o,e);override;
begin
inherited;
idx := GetIdxByYpos(e.ypos);
if idx =0 then
begin
if not FCdlg then
begin
FCdlg := new TColorChooseADlg(self);
FCdlg.parent := self;
end
if FCdlg.OpenDlg() then
begin
cl := FCdlg.result;
setcustomcolor(cl);
end
end
end
function getColor(n); function getColor(n);
begin begin
{** {**
@ -1869,15 +1891,20 @@ type TColorbox=class(TcustomListBox)
end end
function CheckListItem(v);override; function CheckListItem(v);override;
begin begin
return ifarray(v)and ifstring(v["value"])and ifnumber(v["color"]); return ifarray(v) and ifstring(v["value"]) ;//and ifnumber(v["color"]);
end end
function PaintIdexText(idx,rc,cvs);override; function PaintIdexText(idx,rc,cvs);override;
begin begin
rl := integer((rc[3]-rc[1])* 0.15); rl := integer((rc[3]-rc[1])* 0.15);
rrect := array(rc[0]+rl,rc[1]+rl,rc[0]-rl+rc[3]-rc[1],rc[3]-rl); rrect := array(rc[0]+rl,rc[1]+rl,rc[0]-rl+rc[3]-rc[1],rc[3]-rl);
cvs.brush.color := getColor(idx); cl := getColor(idx);
cvs.fillrect(rrect); if cl>=0 or cl<0 then
begin
cvs.brush.color := cl;
cvs.fillrect(rrect);
end
rc[0]+= rc[3]-rc[1]; rc[0]+= rc[3]-rc[1];
rc[1]+= 2;
cvs.drawtext(getColorName(idx),rc,DT_NOPREFIX); cvs.drawtext(getColorName(idx),rc,DT_NOPREFIX);
end end
function publishs();override; function publishs();override;
@ -1890,7 +1917,21 @@ type TColorbox=class(TcustomListBox)
"onselchanged","onnotification" "onselchanged","onnotification"
); );
end end
private property customcolor read fcustomcolor write setcustomcolor;
function setcustomcolor(cl);
begin
if fcustomcolor<>cl and (cl>=0 or cl<0) then
begin
fcustomcolor := cl;
r := FitemData[0];
r["color"] := cl;
FitemData.splice(0,1,r);
p := parent ;
if p then p.Notification(self,"customcolorchanged");
end
end
fcustomcolor;
FCdlg;
multiSel; multiSel;
end end
@ -1998,6 +2039,18 @@ type TColorCombobox=class(TCustomComboBoxbase)
**} **}
return FListBox.getColor(id); return FListBox.getColor(id);
end end
function Notification(o,op);override;
begin
if o=FListBox and op="customcolorchanged" then
begin
if onSelchanged and (FListBox.ItemIndex=0) then
begin
CallMessgeFunction(OnSelChanged,self(true),new tuieventbase(0,0,0,0));
end
return InvalidateRect(nil,false) ;
end
return inherited;
end
function publishs();override; function publishs();override;
begin begin
return array("name","anchors","font","color", return array("name","anchors","font","color",
@ -2006,7 +2059,16 @@ type TColorCombobox=class(TCustomComboBoxbase)
"readonly","itemindex", "readonly","itemindex",
"onselchanged","ondropdown","oncloseup","onnotification"); "onselchanged","ondropdown","oncloseup","onnotification");
end end
property customcolor read getcustomcolor write setcustomcolor;
private private
function getcustomcolor();
begin
return FListBox.customcolor;
end
function setcustomcolor(cl);
begin
FListBox.customcolor := cl;
end
function SetItemIndex(idx);override; function SetItemIndex(idx);override;
begin begin
FListBox.SetCurrentSelection(idx); FListBox.SetCurrentSelection(idx);

View File

@ -2938,7 +2938,17 @@ type TSynCompletion = class(TSynCompletionList)
end end
end end
type TSynHighLighter = class(TComponent) //语法高亮类型 type TSynHighLighter = class(TComponent) //语法高亮类型
Type TToken = class type thtcolor = class()
function create(cl);
begin
if cl>0 or cl<=0 then FColor := cl;
else FColor := 0;
end
property color read fcolor write fcolor;
private
fcolor;
end
Type TToken = class()
FValue; //值 FValue; //值
FPos; //位置 FPos; //位置
FLen; //长度 FLen; //长度
@ -3098,6 +3108,7 @@ type tcustomsynhighlighter = class(TSynHighLighter)
begin begin
inherited; inherited;
fsymcolor := 0xa000a0; fsymcolor := 0xa000a0;
fnumbercolor := 0x666666;
fkeywordcolor := 0x0000ff; fkeywordcolor := 0x0000ff;
fstringcolor := 0xff00ff; fstringcolor := 0xff00ff;
fannotationcolor := 0xff0000; fannotationcolor := 0xff0000;
@ -3244,6 +3255,7 @@ type tcustomsynhighlighter = class(TSynHighLighter)
property stringcolor:color read fstringcolor write fstringcolor; property stringcolor:color read fstringcolor write fstringcolor;
property annotationcolor:color read fannotationcolor write fannotationcolor; property annotationcolor:color read fannotationcolor write fannotationcolor;
property symcolor:color read fsymcolor write fsymcolor; property symcolor:color read fsymcolor write fsymcolor;
property numbercolor:color read fnumbercolor write fnumbercolor;
property ignorecase:bool read fignorecase write setignorecase; property ignorecase:bool read fignorecase write setignorecase;
private private
function setignorecase(i); function setignorecase(i);
@ -3580,7 +3592,7 @@ type tcustomsynhighlighter = class(TSynHighLighter)
fstringcolor; fstringcolor;
fannotationcolor; fannotationcolor;
fsymcolor; fsymcolor;
fnumbercolor;
// //
fswordpairs; fswordpairs;
fswordpairshash; fswordpairshash;

View File

@ -296,7 +296,7 @@ private
begin begin
end else end else
CallMessgeFunction(Onclick,o,e); CallMessgeFunction(Onclick,o,e);
end end
function DoMeasureItem(o,e);virtual; function DoMeasureItem(o,e);virtual;
begin begin
@ -459,7 +459,7 @@ private
if cmd = 'doshortcut' then if cmd = 'doshortcut' then
begin begin
if csDesigning in ComponentState then return ; if csDesigning in ComponentState then return ;
if Visible and Enabled and Parent and GetMenuType(0) then if FVisible and Enabled and Parent and GetMenuType(0) then
begin begin
if d = ShortCut then if d = ShortCut then
begin begin

View File

@ -1308,7 +1308,7 @@ type teditable=class(TSLUIBASE) //
end end
"ecselbkcolor": "ecselbkcolor":
begin begin
if pm>0 or pm<0 then fselbkcolor := pm; if pm>=0 or pm<0 then fselbkcolor := pm;
return fselbkcolor; return fselbkcolor;
end end
"ecplaceholdercolor": "ecplaceholdercolor":
@ -3799,7 +3799,7 @@ type TcustomListBox=class(TCustomListBoxbase)
end end
function setselbkcolor(v); function setselbkcolor(v);
begin begin
if (v>0 or v<0) and v<>fselbkcolor then if (v>=0 or v<0) and v<>fselbkcolor then
begin begin
fselbkcolor := v; fselbkcolor := v;
end end
@ -3829,8 +3829,11 @@ type TcustomListBox=class(TCustomListBoxbase)
if(idx >= min(FSelBegin,FSelEnd)and idx <= max(FSelBegin,FSelEnd))or(FMultisel=2 and FMultisel3Data[idx])then if(idx >= min(FSelBegin,FSelEnd)and idx <= max(FSelBegin,FSelEnd))or(FMultisel=2 and FMultisel3Data[idx])then
begin begin
r := true; r := true;
cvs.brush.Color := fselbkcolor;//0xFFE7CB;//rgb(204,231,255); if fselbkcolor<>Color then
cvs.FillRect(rc); begin
cvs.brush.Color := fselbkcolor;//0xFFE7CB;//rgb(204,231,255);
cvs.FillRect(rc);
end
end end
return r; return r;
end end
@ -4058,6 +4061,7 @@ type TCustomComboBoxbase=class(TCustomControl)
inherited; inherited;
end end
published published
property itemcount read GetItemCount ;
property ItemIndex:tsl read GetItemIndex write SetItemIndex; property ItemIndex:tsl read GetItemIndex write SetItemIndex;
property OnSelchanged:eventhandler read FOnSelchanged write FOnSelchanged; property OnSelchanged:eventhandler read FOnSelchanged write FOnSelchanged;
property ondropdown:eventhandler read Fondropdown write Fondropdown; property ondropdown:eventhandler read Fondropdown write Fondropdown;
@ -4110,6 +4114,11 @@ type TCustomComboBoxbase=class(TCustomControl)
Fondropdown; //ÏÂÀ­ Fondropdown; //ÏÂÀ­
Foncloseup; //ÊÕÆð Foncloseup; //ÊÕÆð
FBtnWidth; FBtnWidth;
function GetItemCount();
begin
if not FListBox then return 0;
return FListBox.ItemCount;
end
function SetmaxListItemShow(v);//ÏÔʾÏîÄ¿ÊýÁ¿ function SetmaxListItemShow(v);//ÏÔʾÏîÄ¿ÊýÁ¿
begin begin
if v>0 then if v>0 then