设计器

active
This commit is contained in:
JianjunLiu 2022-12-19 10:00:57 +08:00
parent 1a1052169d
commit 05ae594b93
8 changed files with 101 additions and 47 deletions

View File

@ -645,12 +645,16 @@ type TVclDesigner = class(tvcform)
par := FCurrentNode.Component.Cwnd; par := FCurrentNode.Component.Cwnd;
r := FComponentCreater.ComponentCreater(FCurrentNode,FCurrentNode.Component.Cwnd); r := FComponentCreater.ComponentCreater(FCurrentNode,FCurrentNode.Component.Cwnd);
if not r then exit; if not r then exit;
npar := par; //////////////////////////////////////////
while not(npar.WsPopUp) do //npar := par;
begin //while not(npar.WsPopUp) do
npar := par.parent; //begin
end // npar := par.parent;
FProjectManager.hiddeneditor(npar.BoundsRect);//此处隐藏编辑器 //end
//FProjectManager.hiddeneditor(npar.BoundsRect);//´Ë´¦Òþ²Ø±à¼­Æ÷
////////////////////////////////////////////////
global g_script_can_set_not_focus;
g_script_can_set_not_focus := true;
r.CreateName(); r.CreateName();
FVariableSelecter.additem(r); FVariableSelecter.additem(r);
BindCwndMessage(r.Cwnd); BindCwndMessage(r.Cwnd);
@ -677,6 +681,7 @@ type TVclDesigner = class(tvcform)
FCurrentNode := nil; FCurrentNode := nil;
FTree.PopupMenu := nil; FTree.PopupMenu := nil;
//echo "\r\n Ìí¼Ó¿Ø¼þ"; //echo "\r\n Ìí¼Ó¿Ø¼þ";
g_script_can_set_not_focus := false;
return r; return r;
end end
function setcomponentfocus(cwnd,fk); //ÉèÖûñµÃÑ¡ÖÐ function setcomponentfocus(cwnd,fk); //ÉèÖûñµÃÑ¡ÖÐ
@ -1003,8 +1008,9 @@ type TVclDesigner = class(tvcform)
wd := cp.Cwnd; wd := cp.Cwnd;
if wd.visible then if wd.visible then
begin begin
wd.visible := false; //wd.visible := false;
wd.visible := true; //wd.visible := true;
_wapi.SetActiveWindow(wd.Handle);
end end
end end
end end

View File

@ -699,7 +699,7 @@ type TProjectView = class(TVCForm) //
FTslEditer.Show(SW_SHOWNOACTIVATE); // FTslEditer.Show(SW_SHOWNOACTIVATE); //
_wapi.bringWindowToTop(FTslEditer.Handle); _wapi.bringWindowToTop(FTslEditer.Handle);
end end
function hiddeneditor(rc); function hiddeneditor(rc);//Òþ²Ø
begin begin
if FTslEditer.visible then if FTslEditer.visible then
begin begin

View File

@ -1073,6 +1073,12 @@ type TFTSLScriptMemo = class(TFTSLScriptcustomMemo)
begin begin
inherited; inherited;
end end
function SetFocus();
begin
global g_script_can_set_not_focus;
if g_script_can_set_not_focus then return ;
if HandleAllocated() then _wapi.SetFocus(self.Handle);
end
end end
type TPageEditerItem=class(TPageItem) type TPageEditerItem=class(TPageItem)
FPageOrderId; //序号有调用者使用 FPageOrderId; //序号有调用者使用

View File

@ -306,7 +306,9 @@ type TDComponent = class()
end end
function cutclick(o,e);virtual; //剪切节点 function cutclick(o,e);virtual; //剪切节点
begin begin
deleteorcut(o,1); global g_script_can_set_not_focus := true;
deleteorcut(o,1);
g_script_can_set_not_focus := false;
end end
function pasteclick(o,e);virtual; //粘贴节点 function pasteclick(o,e);virtual; //粘贴节点
begin begin
@ -319,7 +321,9 @@ type TDComponent = class()
end end
function deleteclick(o,e);virtual; //控件删除操作 function deleteclick(o,e);virtual; //控件删除操作
begin begin
global g_script_can_set_not_focus := true;
deleteorcut(o,0); deleteorcut(o,0);
g_script_can_set_not_focus := false;
end end
function GetDeleteNames(nd,ns,wds); function GetDeleteNames(nd,ns,wds);
begin begin

View File

@ -119,13 +119,13 @@ type tsgtkapi = class(tgtkapis)
end end
end end
gtk_widget_show(hwd); gtk_widget_show(hwd);
if f<>0x4 and G_GTK_WINDOW_ACTIVATE<>hwd then {if f<>0x4 and G_GTK_WINDOW_ACTIVATE<>hwd then
begin begin
if G_GTK_WINDOW_ACTIVATE then if G_GTK_WINDOW_ACTIVATE then
gtk_addMessageQueue(G_GTK_WINDOW_ACTIVATE,0x6,0,0,0); gtk_addMessageQueue(G_GTK_WINDOW_ACTIVATE,0x6,0,0,0);
G_GTK_WINDOW_ACTIVATE := hwd; G_GTK_WINDOW_ACTIVATE := hwd;
gtk_addMessageQueue(hwd,0x6,1,0,0); gtk_addMessageQueue(hwd,0x6,1,0,0);
end end }
end end
return true; return true;
end end
@ -1153,6 +1153,11 @@ type tsgtkapi = class(tgtkapis)
begin begin
return DeleteObject(cursor); return DeleteObject(cursor);
end end
function SetActiveWindow(h);
begin
hh := gtk_widget_get_toplevel(h);
if hh then gtk_window_present(hh);
end
function CreatePen(FS,w,FC); //gtk Ä£Äâ pen function CreatePen(FS,w,FC); //gtk Ä£Äâ pen
begin begin
global gtk_gdi_object_globals; global gtk_gdi_object_globals;
@ -3219,6 +3224,7 @@ type tgtkapis = class() //gtk
procedure gtk_widget_set_can_focus(w:pointer;cf:integer);cdecl;external 'libgtk-3.so'; procedure gtk_widget_set_can_focus(w:pointer;cf:integer);cdecl;external 'libgtk-3.so';
function gtk_window_get_focus(w:pointer):pointer;cdecl;external 'libgtk-3.so'; function gtk_window_get_focus(w:pointer):pointer;cdecl;external 'libgtk-3.so';
procedure gtk_widget_grab_focus(w:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_widget_grab_focus(w:pointer);cdecl;external 'libgtk-3.so';
function gtk_widget_activate(w:pointer):integer;cdecl;external 'libgtk-3.so';
procedure gtk_window_set_focus(window:pointer; focus:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_window_set_focus(window:pointer; focus:pointer);cdecl;external 'libgtk-3.so';
procedure gtk_window_set_type_hint(window:pointer; tp:integer);cdecl;external 'libgtk-3.so'; procedure gtk_window_set_type_hint(window:pointer; tp:integer);cdecl;external 'libgtk-3.so';
procedure gtk_widget_set_has_window(widget:pointer;has_window:integer);cdecl;external 'libgtk-3.so'; procedure gtk_widget_set_has_window(widget:pointer;has_window:integer);cdecl;external 'libgtk-3.so';
@ -3513,6 +3519,11 @@ type tgtkapis = class() //gtk
procedure gtk_window_begin_resize_drag(w:pointer;e:integer;btn:integer;x:integer;y:integer;t:integer);cdecl;external 'libgtk-3.so'; procedure gtk_window_begin_resize_drag(w:pointer;e:integer;btn:integer;x:integer;y:integer;t:integer);cdecl;external 'libgtk-3.so';
function gtk_widget_get_toplevel(w:pointer):pointer;cdecl;external 'libgtk-3.so'; function gtk_widget_get_toplevel(w:pointer):pointer;cdecl;external 'libgtk-3.so';
/////////// modal //////////////////////////////// /////////// modal ////////////////////////////////
function gtk_window_is_active(w:pointer):integer;cdecl;external 'libgtk-3.so';
procedure gtk_window_present(w:pointer);cdecl;external 'libgtk-3.so';
function gtk_window_activate_default(w:pointer):integer;cdecl;external 'libgtk-3.so';
function gtk_window_activate_focus(w:pointer):integer;cdecl;external 'libgtk-3.so';
function gtk_window_has_toplevel_focus(w:pointer):integer;cdecl;external 'libgtk-3.so';
procedure gtk_window_set_modal(w:pointer;f:integer);cdecl;external 'libgtk-3.so'; procedure gtk_window_set_modal(w:pointer;f:integer);cdecl;external 'libgtk-3.so';
procedure gtk_window_set_transient_for(w:pointer;p:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_window_set_transient_for(w:pointer;p:pointer);cdecl;external 'libgtk-3.so';
procedure gtk_window_get_size(wd:pointer;var h:integer;var w:integer);cdecl;external 'libgtk-3.so'; procedure gtk_window_get_size(wd:pointer;var h:integer;var w:integer);cdecl;external 'libgtk-3.so';
@ -4920,33 +4931,39 @@ type tgtk_ctl_object = class(_gtkeventtype)
GDK_WINDOW_STATE: GDK_WINDOW_STATE:
begin begin
obj := new _GdkEventWindowState(c); obj := new _GdkEventWindowState(c);
msk := obj.new_window_state; st := obj.new_window_state;
//st := obj.changed_mask; if st .& 4 then
if msk .& 4 then
begin begin
return CallTslVclProc(_const.WM_SYSCOMMAND ,_const.SC_MAXIMIZE,0); return CallTslVclProc(_const.WM_SYSCOMMAND ,_const.SC_MAXIMIZE,0);
end end
if msk .& 2 then if st .& 2 then
begin begin
return CallTslVclProc(_const.WM_SYSCOMMAND ,_const.SC_MINIMIZE,0); return CallTslVclProc(_const.WM_SYSCOMMAND ,_const.SC_MINIMIZE,0);
end end
if msk .& (2^4) then if st .& (2^4) then
begin begin
//echo "\r\n full screen"; //echo "\r\n full screen";
end end
if msk .& (2^5) then if st .& (2^5) then
begin begin
//echo "\r\n above"; //echo "\r\n above";
end end
if msk .& (2^6) then if st .& (2^6) then
begin begin
//echo "\r\n below"; //echo "\r\n below";
end end
if msk .& (2^7) then if st .& (2^7) then
begin begin
CallTslVclProc(_const.WM_SETFOCUS ,0,0); //CallTslVclProc(_const.WM_SETFOCUS ,0,0);
CallTslVclProc(_const.WM_ACTIVATE ,2,0,0); hwd := handle;
hwd := _wapi.gtk_widget_is_toplevel(hwd)?hwd:_wapi.gtk_widget_get_toplevel(hwd);
if G_GTK_WINDOW_ACTIVATE<>hwd then
begin
if G_GTK_WINDOW_ACTIVATE then
AddMessageToGtkMessageQueue(G_GTK_WINDOW_ACTIVATE,0x6,0,0,0);
end
AddMessageToGtkMessageQueue(hwd,0x6,1,0,0);
//CallTslVclProc(_const.WM_ACTIVATE ,2,0,0);
end end
{GDK_WINDOW_STATE_WITHDRAWN = 1 << 0, {GDK_WINDOW_STATE_WITHDRAWN = 1 << 0,
GDK_WINDOW_STATE_ICONIFIED = 1 << 1, GDK_WINDOW_STATE_ICONIFIED = 1 << 1,
@ -5005,7 +5022,7 @@ type tgtk_ctl_object = class(_gtkeventtype)
end end
end ; end ;
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
@ -5013,7 +5030,7 @@ type tgtk_ctl_object = class(_gtkeventtype)
AddMessageToGtkMessageQueue(G_GTK_WINDOW_ACTIVATE,0x6,0,0,0); AddMessageToGtkMessageQueue(G_GTK_WINDOW_ACTIVATE,0x6,0,0,0);
G_GTK_WINDOW_ACTIVATE := hwd; G_GTK_WINDOW_ACTIVATE := hwd;
AddMessageToGtkMessageQueue(hwd,0x6,1,0,0); AddMessageToGtkMessageQueue(hwd,0x6,1,0,0);
end end }
return CanignoreBtnpress(); return CanignoreBtnpress();
end end
GDK_BUTTON_RELEASE: GDK_BUTTON_RELEASE:

View File

@ -2,6 +2,10 @@ unit UTslMemo;
{** {**
@explan(说明) 文本控件库 %% @explan(说明) 文本控件库 %%
**} **}
{$ifdef linux}
{$define linuxpop}
{$endif}
interface interface
uses utslvclauxiliary,utslvclgdi,utslvclstdctl; uses utslvclauxiliary,utslvclgdi,utslvclstdctl;
type TMemoLineItem=class() //编辑字符串行对象 type TMemoLineItem=class() //编辑字符串行对象
@ -2634,7 +2638,7 @@ type TSynCompletion = class(TSynCompletionList)
function Create(AOwner);override; function Create(AOwner);override;
begin begin
inherited; inherited;
{$ifdef linux} //处理避免闪烁 {$ifdef linuxpop} //处理避免闪烁
{$else} {$else}
WsPopUp := true; WsPopUp := true;
@ -2727,7 +2731,7 @@ type TSynCompletion = class(TSynCompletionList)
dh := GetYscrollDelta(); dh := GetYscrollDelta();
h := 3+dh*min(self.ItemCount,8); h := 3+dh*min(self.ItemCount,8);
Memo.GetCaretPos(x,y); Memo.GetCaretPos(x,y);
{$ifdef linux} {$ifdef linuxpop}
xy := array(x,y);// xy := array(x,y);//
{$else} {$else}
xy := Memo.ClientToscreen(x,y); xy := Memo.ClientToscreen(x,y);

View File

@ -858,6 +858,7 @@ type tnumindexarray = Class() //ջģ
**} **}
private private
FData; FData;
fdlength;
public public
function Create();virtual; function Create();virtual;
begin begin
@ -865,6 +866,7 @@ type tnumindexarray = Class() //ջģ
@explan(说明) 构造函数 %% @explan(说明) 构造函数 %%
**} **}
FData := array(); FData := array();
fdlength := 0;
end end
function Operator[1](idx,v); function Operator[1](idx,v);
begin begin
@ -886,21 +888,22 @@ type tnumindexarray = Class() //ջģ
@explan(说明) 获得数据长度 %% @explan(说明) 获得数据长度 %%
@return(integer) 长度 %% @return(integer) 长度 %%
**} **}
return ::length(FData); return fdlength;
end end
function Push({value1,value2,....}); function Push({value1,value2,....});
begin begin
{** {**
@explan(说明) 在末尾追加元素,参数个数不定 %% @explan(说明) 在末尾追加元素,参数个数不定 %%
**} **}
r := ::length(FData); r := fdlength;
r1 := r; r1 := r;
for i := 0 to ParamCount-1 do for i := 0 to ParamCount-1 do
begin begin
FData[r]:= Params[i+1]; FData[r]:= Params[i+1];
r++; r++;
end end
if r1 <> r then LengthChanged(r1-r); fdlength := r;
if r1 <> r then LengthChanged(r1-r);
return r; return r;
end end
function Pop(); function Pop();
@ -910,10 +913,11 @@ type tnumindexarray = Class() //ջģ
**} **}
if FData then if FData then
begin begin
id := ::length(FData)-1; id := fdlength-1;
r := FData[id]; r := FData[id];
deleteindex(FData,id); deleteindex(FData,id);
LengthChanged(-1); fdlength--;
LengthChanged(-1);
return r; return r;
end end
return nil; return nil;
@ -928,7 +932,8 @@ type tnumindexarray = Class() //ջģ
end end
function LastIndexOf(v); function LastIndexOf(v);
begin begin
for i := ::length(FData)-1 downto 0 do len := fdlength;
for i := len-1 downto 0 do
begin begin
if v=FData[i]then return i; if v=FData[i]then return i;
end end
@ -940,17 +945,18 @@ type tnumindexarray = Class() //ջģ
end end
function SetValueByIndex(idx,v);virtual; function SetValueByIndex(idx,v);virtual;
begin begin
len := ::length(FData); len := fdlength;
if idx<0 then return nil; if not(idx>=0) then return nil;
if idx <= len then if idx <= len then
begin begin
FData[idx]:= v; FData[idx]:= v;
end else end else
begin begin
for i := len to idx do FData[i]:= nil; for i := len to idx do FData[i]:= nil;
FData[idx]:= v; FData[idx]:= v;
return v;
end end
fdlength := ::length(FData);
return v;
end end
function splice({startid,sellength,value1,valfue2,....}); function splice({startid,sellength,value1,valfue2,....});
begin begin
@ -963,7 +969,7 @@ type tnumindexarray = Class() //ջģ
sl := p[1]; sl := p[1];
sl := ifnil(sl)?inf:sl; sl := ifnil(sl)?inf:sl;
sl := (sl>=0)?sl:0; sl := (sl>=0)?sl:0;
len := ::length(FData); len := fdlength;
st := st<0?0:st; st := st<0?0:st;
st := st >= len?(len):st; st := st >= len?(len):st;
et := st+sl; et := st+sl;
@ -978,7 +984,8 @@ type tnumindexarray = Class() //ջģ
r1 := FData[0:st-1]; r1 := FData[0:st-1];
r2 := FData[et:len-1]; r2 := FData[et:len-1];
FData := r1 union p[2:] union r2; FData := r1 union p[2:] union r2;
if len <> ::length(FData)then LengthChanged(::length(FData)-len); fdlength := ::length(FData);
if len <> fdlength then LengthChanged(fdlength-len);
return r; return r;
end end
function shift(); function shift();
@ -987,11 +994,12 @@ type tnumindexarray = Class() //ջģ
@explan(说明) 弹出头部元素 %% @explan(说明) 弹出头部元素 %%
**} **}
r := nil; r := nil;
len := ::length(FData); len := fdlength;
if len>0 then if len>0 then
begin begin
deleteindex(FData,0); deleteindex(FData,0);
LengthChanged(-1); fdlength--;
LengthChanged(-1);
end end
return len<1?(len):(len-1); return len<1?(len):(len-1);
end end
@ -1004,9 +1012,10 @@ type tnumindexarray = Class() //ջģ
if p then if p then
begin begin
FData := p union FData; FData := p union FData;
LengthChanged(1); fdlength := ::length(FData);
LengthChanged(1);
end end
return ::length(FData); return fdlength;
end end
function swap(i,j); function swap(i,j);
begin begin
@ -1014,7 +1023,7 @@ type tnumindexarray = Class() //ջģ
@explan(说明) 交换下标中的值 %% @explan(说明) 交换下标中的值 %%
**} **}
if i=j then return false; if i=j then return false;
len := ::length(FData); len := fdlength;
if i >= 0 and i<len and j >= 0 and j<len then if i >= 0 and i<len and j >= 0 and j<len then
begin begin
t := FData[i]; t := FData[i];

View File

@ -6012,7 +6012,7 @@ type tcustomprogressbar=class(TCustomControl)
public public
function create(AOwner);override; function create(AOwner);override;
begin begin
inherited; inherited;
Caption:="prograssbar"; Caption:="prograssbar";
FLeft := 10; FLeft := 10;
FTop := 10; FTop := 10;
@ -6132,7 +6132,11 @@ type tcustomprogressbar=class(TCustomControl)
private //属性处理函数 private //属性处理函数
function setSmooth(n); function setSmooth(n);
begin begin
Fsmooth := n; nv := n?true:false;
if nv=Fsmooth then return ;
Fsmooth := nv;
InvalidateRect(nil,false);
end end
function setVertical(n); function setVertical(n);
begin begin
@ -6175,7 +6179,11 @@ type tcustomprogressbar=class(TCustomControl)
end end
function setRangeA(arr); function setRangeA(arr);
begin begin
return setRange(arr[0],arr[1]); r := setRange(arr[0],arr[1]);
if r then
begin
InvalidateRect(nil,false);
end
end end
function setPosition(n); function setPosition(n);
begin begin