界面库

优化gtkactivate
This commit is contained in:
JianjunLiu 2023-01-05 17:36:51 +08:00
parent 5c87f678d6
commit 8ed3ce6baa
5 changed files with 126 additions and 24 deletions

View File

@ -308,6 +308,7 @@ type TVclDesigner = class(tvcform)
return r; return r;
end end
public //设计器工程 public //设计器工程
ffilemenu;
function OpenFileFromTpjFile(); //从文件打开工程 function OpenFileFromTpjFile(); //从文件打开工程
begin begin
FProjectFileOpener.caption := "打开"; FProjectFileOpener.caption := "打开";
@ -461,7 +462,7 @@ type TVclDesigner = class(tvcform)
@explan(说明) 菜单 @explan(说明) 菜单
**} **}
return array( return array(
("type":"menu","caption":"文件","onclick",nil,"items":( ("type":"menu","caption":"Îļþ","filed":"ffilemenu","onclick",nil,"items":(
("type":"menu","caption":"保存","onclick":thisfunction(saveCurrentForm), ("type":"menu","caption":"保存","onclick":thisfunction(saveCurrentForm),
"bitmap":getsaveallbitmapinfo()), "bitmap":getsaveallbitmapinfo()),
("type":"menu","caption":"代码编辑","onclick":thisfunction(openclassfile), ("type":"menu","caption":"代码编辑","onclick":thisfunction(openclassfile),
@ -1315,6 +1316,8 @@ type TVclDesigner = class(tvcform)
FProjectFileOpener.filter := array("tvcl工程":"*.tpj"); FProjectFileOpener.filter := array("tvcl工程":"*.tpj");
FProjectFileOpener.parent := self; FProjectFileOpener.parent := self;
FProjectManager.FTslEditer.setdbugruncall(thisfunction(debugproject)); //设置调试回调 FProjectManager.FTslEditer.setdbugruncall(thisfunction(debugproject)); //设置调试回调
FProjectManager.newmenu.parent := ffilemenu;//
//fnewmenu
end end
property VariableSelecter read FVariableSelecter; //当前控件树的变量对象 property VariableSelecter read FVariableSelecter; //当前控件树的变量对象

View File

@ -476,6 +476,17 @@ type TProjectView = class(TVCForm) //
end end
FWrapFolder := new TFolderChooseADlg(self); FWrapFolder := new TFolderChooseADlg(self);
FWrapFolder.Caption := "打包工程到目录"; FWrapFolder.Caption := "打包工程到目录";
fnewmenu := new TMenu(self);
fnewmenu.Enabled := false;
fnewmenu.caption := "新建";
for i,v in array("form","panel","script","tsf") do
begin
it := new TMenu(self);
it.caption := v;
it.parent := fnewmenu;
it.OnClick := thisfunction(newadd);
end
return; return;
end end
function setnodesel(nd); function setnodesel(nd);
@ -574,6 +585,30 @@ type TProjectView = class(TVCForm) //
end end
//OpenTreeNode(); //OpenTreeNode();
end end
function newadd(o,e);
begin
cnd := getdefaultdir();
if not cnd then return ;
case o.caption of
"tsf":
begin
AddTsfToCurrentDir(createnamea("func"),"tsf",cnd);
end
"script":
begin
AddTsfToCurrentDir(createnamea("tsl"),"tsl",cnd);
end
"panel":
begin
AddPanelToCurrentDir(createnamea("pal"),cnd);
end
"form":
begin
AddFormToCurrentDir(createnamea("form"),cnd);
end
end
end
function Add_dir(); //添加目录 function Add_dir(); //添加目录
begin begin
if not FCProjectPath then return Messageboxa("工程没打开","提示",0,self); if not FCProjectPath then return Messageboxa("工程没打开","提示",0,self);
@ -918,11 +953,13 @@ type TProjectView = class(TVCForm) //
FDesigner.caption := "TVCL界面设计器 "+FprojName; FDesigner.caption := "TVCL界面设计器 "+FprojName;
FTree.ProjectNode.Expand(); FTree.ProjectNode.Expand();
FTree.PopUpMenu := FTreePopUpMenu; FTree.PopUpMenu := FTreePopUpMenu;
fnewmenu.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;
return; return;
end end
FTslEditer.TslSearchDir := array(p,Getfuncextdir()); FTslEditer.TslSearchDir := array(p,Getfuncextdir());
@ -1033,7 +1070,7 @@ type TProjectView = class(TVCForm) //
if cn then FTree.InvalidateItem(cn); if cn then FTree.InvalidateItem(cn);
SaveProjInfo(); SaveProjInfo();
end end
function AddinheritdToCurrentDir(info); function AddinheritdToCurrentDir(info,cnd);
begin begin
n := info[1]; n := info[1];
if not(LegalVariableName(n))then return MessageboxA("名字不合法,请重试","提示",0,self); if not(LegalVariableName(n))then return MessageboxA("名字不合法,请重试","提示",0,self);
@ -1055,7 +1092,13 @@ type TProjectView = class(TVCForm) //
us := ""; us := "";
end end
/////////// ///////////
ph := FTree.CurrentNode.FPath; if cnd then
begin
ph := cnd.FPath;
end else
begin
ph := FTree.CurrentNode.FPath;
end
fio := ioFileseparator(); fio := ioFileseparator();
fn := array("name":n,"type":nd.FType,"dir":ph); fn := array("name":n,"type":nd.FType,"dir":ph);
cprojpath := FCProjectPath; cprojpath := FCProjectPath;
@ -1102,11 +1145,17 @@ end
SaveProjInfo(); SaveProjInfo();
nd.parent.expand(); nd.parent.expand();
end end
function AddFormToCurrentDir(n); //添加窗口 function AddFormToCurrentDir(n,cnd); //添加窗口
begin begin
if not(LegalVariableName(n))then return MessageboxA("名字不合法,请重试","提示",0,self); if not(LegalVariableName(n))then return MessageboxA("名字不合法,请重试","提示",0,self);
if FTree.NameInTree(lowercase(n),nil,true)then return MessageboxA("重复的文件名","提示",0,self); if FTree.NameInTree(lowercase(n),nil,true)then return MessageboxA("重复的文件名","提示",0,self);
ph := FTree.CurrentNode.FPath; if cnd then
begin
ph := cnd.FPath;
end else
begin
ph := FTree.CurrentNode.FPath;
end
fio := ioFileseparator(); fio := ioFileseparator();
fn := array("name":n,"type":"form","dir":ph); fn := array("name":n,"type":"form","dir":ph);
cprojpath := FCProjectPath; cprojpath := FCProjectPath;
@ -1138,14 +1187,21 @@ end
end end
end else fn["type"]:= "tsf"; end else fn["type"]:= "tsf";
end end
FTree.SetFileToNode(fn); nd := FTree.SetFileToNode(fn);
SaveProjInfo(); SaveProjInfo();
FTree.SetSel(nd);
end end
function AddPanelToCurrentDir(n); //添加面板 function AddPanelToCurrentDir(n,cnd); //添加面板
begin begin
if not LegalVariableName(n)then return MessageboxA("名字不合法,请重试","提示",0,self); if not LegalVariableName(n)then return MessageboxA("名字不合法,请重试","提示",0,self);
if FTree.NameInTree(lowercase(n),nil,true)then return MessageboxA("重复的文件名","提示",0,self); if FTree.NameInTree(lowercase(n),nil,true)then return MessageboxA("重复的文件名","提示",0,self);
ph := FTree.CurrentNode.FPath; if cnd then
begin
ph := cnd.FPath;
end else
begin
ph := FTree.CurrentNode.FPath;
end
fio := ioFileseparator(); fio := ioFileseparator();
fn := array("name":n,"type":"panel","dir":ph); fn := array("name":n,"type":"panel","dir":ph);
cprojpath := FCProjectPath; cprojpath := FCProjectPath;
@ -1178,8 +1234,9 @@ end
end else fn["type"]:= "tsf"; end else fn["type"]:= "tsf";
end end
FTree.SetFileToNode(fn); nd := FTree.SetFileToNode(fn);
SaveProjInfo(); SaveProjInfo();
FTree.SetSel(nd);
end end
function RenameCurrentDir(n); //修改目录名 function RenameCurrentDir(n); //修改目录名
begin begin
@ -1248,11 +1305,18 @@ end
end else end else
return MessageboxA("更名错误","提示",0,self); return MessageboxA("更名错误","提示",0,self);
end end
function AddTsfToCurrentDir(n,t); //添加文件 function AddTsfToCurrentDir(n,t,cnd); //添加文件
begin begin
if not LegalVariableName(n)then return MessageboxA("名字不合法,请重试","提示",0,self); if not LegalVariableName(n)then return MessageboxA("名字不合法,请重试","提示",0,self);
if FTree.NameInTree(lowercase(n),nil,true)then return MessageboxA("重复的文件名","提示",0,self); if FTree.NameInTree(lowercase(n),nil,true)then return MessageboxA("重复的文件名","提示",0,self);
fn := array("name":n,"type":t,"dir":FTree.CurrentNode.FPath); if cnd then
begin
p := cnd.FPath;
end else
begin
p := FTree.CurrentNode.FPath;
end
fn := array("name":n,"type":t,"dir":p);
nnd := FTree.SetFileToNode(fn); nnd := FTree.SetFileToNode(fn);
ph := nnd.geteditfilename(); ph := nnd.geteditfilename();
if not FileExists("",ph)then if not FileExists("",ph)then
@ -1262,6 +1326,7 @@ end
ReWriteString(ph,r); ReWriteString(ph,r);
end end
SaveProjInfo(); SaveProjInfo();
FTree.SetSel(nnd);
end end
function ShowExeEditer(); //显示调试窗口 function ShowExeEditer(); //显示调试窗口
begin begin
@ -1452,12 +1517,35 @@ end
private private
FMoveMnus; FMoveMnus;
FMoveMenu; FMoveMenu;
function getdefaultdir();
begin
cnd := FTree.CurrentNode;
while cnd and cnd<>ftree.RootNode and cnd.FType<>"dir" do
begin
cnd := cnd.parent;
end
return cnd;
end
function createnamea(pre);
begin
idx := 1;
n := pre;
while idx>0 do
begin
n := pre+inttostr(idx);
idx++;
if not LegalVariableName(n) then continue;
if FTree.NameInTree(n,nil,true) then continue;
break;
end
return n;
end
function MoveCurrentFileto(o,e); function MoveCurrentFileto(o,e);
begin begin
nd := FTree.CurrentNode; nd := FTree.CurrentNode;
if nd then if nd then
d := nd.FFileInfo; d := nd.FFileInfo;
cp := nd.caption; cp := nd.caption;
fio := ioFileseparator(); fio := ioFileseparator();
if not ifarray(d) then return ; if not ifarray(d) then return ;
@ -1686,7 +1774,9 @@ end
FAddMenuTsf; FAddMenuTsf;
FAddMenuTsl; FAddMenuTsl;
FOpenMenu; FOpenMenu;
fnewmenu;
public public
property newmenu read fnewmenu;
FTslEditer; FTslEditer;
property tree read ftree; property tree read ftree;
private private

View File

@ -1662,7 +1662,7 @@ type TWinControl = class(tcontrol)
end end
function setactive(); virtual; function setactive(); virtual;
begin begin
if WsPopUp and HandleAllocated() then if not(factivated) and WsPopUp and HandleAllocated() then
begin begin
_wapi.SetActiveWindow(self.Handle); _wapi.SetActiveWindow(self.Handle);
end end
@ -1879,7 +1879,12 @@ type TWinControl = class(tcontrol)
tcn := P.WinClassName; tcn := P.WinClassName;
f := _wapi.CreateWindowExA(p.ExStyle,tcn,tcc,stl,x,y,sx,sy,p.WndParent,id,p.happ,selfid); f := _wapi.CreateWindowExA(p.ExStyle,tcn,tcc,stl,x,y,sx,sy,p.WndParent,id,p.happ,selfid);
InitializeWnd(); InitializeWnd();
if HandleAllocated()then ControlCreateWnd(); if HandleAllocated()then
begin
ControlCreateWnd();
//处理初始化active的问题
if factivated and factivecontrol and ContainsControl(factivecontrol) then factivecontrol.SetFocus();
end
end end
function Notification(ac,op);override; function Notification(ac,op);override;
begin begin
@ -2523,10 +2528,9 @@ type TWinControl = class(tcontrol)
property onSetFocus:eventhandler read FonSetFocus write fonSetFocus; property onSetFocus:eventhandler read FonSetFocus write fonSetFocus;
property oncreated:eventhandler read foncreated write foncreated; property oncreated:eventhandler read foncreated write foncreated;
property ActiveControl read getactivecontrol write setactivecontrol; property ActiveControl read getactivecontrol write setactivecontrol;
property Active read factivated;//是否获活动窗口
private //模态相关 private //模态相关
property Modaling read FModaling; property Modaling read FModaling;
{** {**
@param(BorderStyle)(bsNone|bsSingle) 边框样式 %% @param(BorderStyle)(bsNone|bsSingle) 边框样式 %%
@param(Handle)(pointer) 窗口句柄 %% @param(Handle)(pointer) 窗口句柄 %%

View File

@ -4963,14 +4963,17 @@ type tgtk_ctl_object = class(_gtkeventtype)
if st .& (2^7) then if st .& (2^7) then
begin begin
//CallTslVclProc(_const.WM_SETFOCUS ,0,0); //CallTslVclProc(_const.WM_SETFOCUS ,0,0);
hwd := handle; hwd := handle;
hwd := _wapi.gtk_widget_is_toplevel(hwd)?hwd:_wapi.gtk_widget_get_toplevel(hwd); hwd := _wapi.gtk_widget_is_toplevel(hwd)?hwd:_wapi.gtk_widget_get_toplevel(hwd);
if G_GTK_WINDOW_ACTIVATE<>hwd then if G_GTK_WINDOW_ACTIVATE<>hwd then
begin begin
if G_GTK_WINDOW_ACTIVATE then if G_GTK_WINDOW_ACTIVATE then
AddMessageToGtkMessageQueue(G_GTK_WINDOW_ACTIVATE,0x6,0,0,0); begin
end AddMessageToGtkMessageQueue(G_GTK_WINDOW_ACTIVATE,0x6,0,0,0);
end
end
AddMessageToGtkMessageQueue(hwd,0x6,1,0,0); AddMessageToGtkMessageQueue(hwd,0x6,1,0,0);
G_GTK_WINDOW_ACTIVATE := hwd;
//CallTslVclProc(_const.WM_ACTIVATE ,2,0,0); //CallTslVclProc(_const.WM_ACTIVATE ,2,0,0);
end end
{GDK_WINDOW_STATE_WITHDRAWN = 1 << 0, {GDK_WINDOW_STATE_WITHDRAWN = 1 << 0,

View File

@ -4012,6 +4012,8 @@ type TCustomComboBoxbase=class(TCustomControl)
if csDesigning in ComponentState then return; if csDesigning in ComponentState then return;
x := e.xpos; x := e.xpos;
y := e.ypos; y := e.ypos;
if x>1 and y>1 then return ShowDropDown(true);
return ;
if x>FBtnRect[0]and x<FBtnRect[2]and y>FBtnRect[1]and y<FBtnRect[3]then if x>FBtnRect[0]and x<FBtnRect[2]and y>FBtnRect[1]and y<FBtnRect[3]then
begin begin
ShowDropDown(true); ShowDropDown(true);