设计器

优化细节
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
public //设计器工程
ffilemenu;
fviewmenu;
function OpenFileFromTpjFile(); //从文件打开工程
begin
FProjectFileOpener.caption := "打开";
@ -468,7 +469,7 @@ type TVclDesigner = class(tvcform)
("type":"menu","caption":"代码编辑","onclick":thisfunction(openclassfile),
"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":true,"onclick":thisfunction(Mobjinspect),
"bitmap":getdefaultbmpinfo())
@ -587,17 +588,21 @@ type TVclDesigner = class(tvcform)
@explan(说明) 移动 控件 %%
**}
//setcomponentfocus(o,false);
FPropGrid.SetGridValue("left",O.left,O) ;
FPropGrid.SetGridValue("top",o.top,O);
l := O.left;
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
function ComponentSize(o,e);//大小改变
begin
{**
@explan(说明) 调整控件大小 %%
**}
FPropGrid.SetGridValue("width",o.width,O);
FPropGrid.SetGridValue("height",o.height,O);
w := o.width;
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);
end
function DesignerClose(o,e) //控件窗口关闭
@ -984,6 +989,27 @@ type TVclDesigner = class(tvcform)
FPropGrid.Component := nd.fcomp ;
FEventGrid.Component := nd.fcomp ;
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); //切换控件树
begin
FCurrentNode := nil;
@ -1037,6 +1063,10 @@ type TVclDesigner = class(tvcform)
end
return r;
end
"shownode":
begin
showcurrent();
end
"hiddrennode":
begin
hidenatree(fcwindowinfo);
@ -1316,7 +1346,8 @@ type TVclDesigner = class(tvcform)
FProjectFileOpener.filter := array("tvcl工程":"*.tpj");
FProjectFileOpener.parent := self;
FProjectManager.FTslEditer.setdbugruncall(thisfunction(debugproject)); //设置调试回调
FProjectManager.newmenu.parent := ffilemenu;//
FProjectManager.newmenu.parent := ffilemenu;//
FProjectManager.goformmenu.parent := fviewmenu;//
//fnewmenu
end

View File

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

View File

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

View File

@ -1799,8 +1799,11 @@ type TColorbox=class(TcustomListBox)
public
function create(aOwner);override;
begin
inherited;
inherited;
fcustomcolor := nil;
arr := array(
("value":"Custom","color":nil),
("value":"None","color":nil),
("value":"Black","color":0),
("value":"Maroon","color":128),
("value":"Green","color":32768),
@ -1825,6 +1828,25 @@ type TColorbox=class(TcustomListBox)
("value":"MedGray","color":10789024));
setData(arr);
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);
begin
{**
@ -1869,15 +1891,20 @@ type TColorbox=class(TcustomListBox)
end
function CheckListItem(v);override;
begin
return ifarray(v)and ifstring(v["value"])and ifnumber(v["color"]);
return ifarray(v) and ifstring(v["value"]) ;//and ifnumber(v["color"]);
end
function PaintIdexText(idx,rc,cvs);override;
begin
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);
cvs.brush.color := getColor(idx);
cvs.fillrect(rrect);
rrect := array(rc[0]+rl,rc[1]+rl,rc[0]-rl+rc[3]-rc[1],rc[3]-rl);
cl := getColor(idx);
if cl>=0 or cl<0 then
begin
cvs.brush.color := cl;
cvs.fillrect(rrect);
end
rc[0]+= rc[3]-rc[1];
rc[1]+= 2;
cvs.drawtext(getColorName(idx),rc,DT_NOPREFIX);
end
function publishs();override;
@ -1890,7 +1917,21 @@ type TColorbox=class(TcustomListBox)
"onselchanged","onnotification"
);
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;
end
@ -1998,6 +2039,18 @@ type TColorCombobox=class(TCustomComboBoxbase)
**}
return FListBox.getColor(id);
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;
begin
return array("name","anchors","font","color",
@ -2006,7 +2059,16 @@ type TColorCombobox=class(TCustomComboBoxbase)
"readonly","itemindex",
"onselchanged","ondropdown","oncloseup","onnotification");
end
property customcolor read getcustomcolor write setcustomcolor;
private
function getcustomcolor();
begin
return FListBox.customcolor;
end
function setcustomcolor(cl);
begin
FListBox.customcolor := cl;
end
function SetItemIndex(idx);override;
begin
FListBox.SetCurrentSelection(idx);

View File

@ -2549,7 +2549,7 @@ type TWinControl = class(tcontrol)
begin
ctb := class(tUIglobalData).uigetdata("G_T_TOOLBAR_");
if (c is class(TcustomMenu)) or (c is ctb) or (c is class(TCustomAction)) then
begin
begin
if c.ExecuteCommand("doshortcut",st)="havedoshortcut" then return "havedoshortcut";
end
cc := c.Components ;

View File

@ -2938,7 +2938,17 @@ type TSynCompletion = class(TSynCompletionList)
end
end
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; //值
FPos; //位置
FLen; //长度
@ -3098,6 +3108,7 @@ type tcustomsynhighlighter = class(TSynHighLighter)
begin
inherited;
fsymcolor := 0xa000a0;
fnumbercolor := 0x666666;
fkeywordcolor := 0x0000ff;
fstringcolor := 0xff00ff;
fannotationcolor := 0xff0000;
@ -3244,6 +3255,7 @@ type tcustomsynhighlighter = class(TSynHighLighter)
property stringcolor:color read fstringcolor write fstringcolor;
property annotationcolor:color read fannotationcolor write fannotationcolor;
property symcolor:color read fsymcolor write fsymcolor;
property numbercolor:color read fnumbercolor write fnumbercolor;
property ignorecase:bool read fignorecase write setignorecase;
private
function setignorecase(i);
@ -3580,7 +3592,7 @@ type tcustomsynhighlighter = class(TSynHighLighter)
fstringcolor;
fannotationcolor;
fsymcolor;
fnumbercolor;
//
fswordpairs;
fswordpairshash;

View File

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

View File

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