diff --git a/designer/utslcodeeditor.tsf b/designer/utslcodeeditor.tsf index 026ab30..18c3eff 100644 --- a/designer/utslcodeeditor.tsf +++ b/designer/utslcodeeditor.tsf @@ -1073,7 +1073,7 @@ type TFTSLScriptMemo = class(TFTSLScriptcustomMemo) begin inherited; end - function SetFocus(); + function SetFocus();override; begin global g_script_can_set_not_focus; if g_script_can_set_not_focus then return ; diff --git a/funcext/tvclib/tslvcl.tsf b/funcext/tvclib/tslvcl.tsf index b793470..ba29043 100644 --- a/funcext/tvclib/tslvcl.tsf +++ b/funcext/tvclib/tslvcl.tsf @@ -4502,6 +4502,11 @@ type tapplicationwindow=class(TWinControl) function DoCnNotify(o,e);override; begin end + private + function setactivecontrol(ctl);virtual; + begin + + end end type TImageListDrawStyle = class() diff --git a/funcext/tvclib/twincontrol.tsf b/funcext/tvclib/twincontrol.tsf index 9c4fc5e..83bcc27 100644 --- a/funcext/tvclib/twincontrol.tsf +++ b/funcext/tvclib/twincontrol.tsf @@ -16,6 +16,7 @@ type TWinControl = class(tcontrol) //__wstylestruct; //样式消息结构体 __clientsize; //客户区大小 //__oldclientsize; //旧客户区大小 + factivated; FClientleft; FClientTop; FClientWdith; @@ -221,6 +222,7 @@ type TWinControl = class(tcontrol) nv := v?true:false; if nv <> FWsPopUp then begin + factivated := false; FWsPopUp := nv; if HandleAllocated()then RecreateWnd(); end @@ -846,7 +848,14 @@ type TWinControl = class(tcontrol) end function WMACTIVATE(o,e):WM_ACTIVATE;virtual; begin + factivated := e.wparam; CallMessgeFunction(OnActivate,o,e); + if e.skip then return ; + defaulthandler(e); + if factivated and ContainsControl(factivecontrol) then + begin + factivecontrol.SetFocus(); + end end function GetClientRect();override; begin @@ -910,6 +919,7 @@ type TWinControl = class(tcontrol) function WMNCDESTROY(o,e):WM_NCDESTROY;virtual; begin FHandle := nil; + factivated := false; for i := 0 to FControls.count-1 do begin item := FControls[i]; @@ -1642,13 +1652,21 @@ type TWinControl = class(tcontrol) **} if HandleAllocated()then return _wapi.UpdateWindow(self.Handle); end - function SetFocus(); + function SetFocus();virtual; begin if HandleAllocated()then begin - _wapi.SetFocus(self.Handle); + r := _wapi.SetFocus(self.Handle); + return r; end end + function setactive(); virtual; + begin + if WsPopUp and HandleAllocated() then + begin + _wapi.SetActiveWindow(self.Handle); + end + end function DescendantHwnd(hwnd); begin { @@ -1769,9 +1787,10 @@ type TWinControl = class(tcontrol) return r; end end - function ContainsControl(Control:TControl):bool; + function ContainsControl(Control_:TControl):bool;//包含控件 begin - while(Control <> nil)and(Control <> Self) do Control := Control.Parent; + Control := Control_; + while(Control is class(TWinControl)) and(Control <> Self) do Control := Control.Parent; return Control=Self; end function create(owner);override; //type_twinctrol @@ -1824,6 +1843,7 @@ type TWinControl = class(tcontrol) ImageList := nil; FonSetFocus := nil; FonKillFocus := nil; + factivecontrol := nil; inherited; end function RecreateWnd();virtual; @@ -1861,6 +1881,14 @@ type TWinControl = class(tcontrol) InitializeWnd(); if HandleAllocated()then ControlCreateWnd(); end + function Notification(ac,op);override; + begin + if op=opRecycling and ac=factivecontrol then + begin + factivecontrol := nil; + end + inherited; + end protected function drawdesigninggrid(); begin @@ -1913,6 +1941,7 @@ type TWinControl = class(tcontrol) @explan(说明)析构窗口句柄 %% **} EndModal(); + factivated := false; if HandleAllocated()then begin {FTRACKMOUSEEVENT.hwndtrack := handle; @@ -2465,7 +2494,7 @@ type TWinControl = class(tcontrol) MainWndProc(h,WM_NCCREATE,0,0); end end - public //对外property + published //对外property property MinWidth:natural read FMinWidth write SetMinWidth; property MinHeight:natural read FMinHeigt write SetMinHeight; //property MaxWidth:integer read FMaxWidth write SetMaxWidth; @@ -2493,6 +2522,7 @@ type TWinControl = class(tcontrol) property onKillFocus:eventhandler read FonKillFocus write FonKillFocus; property onSetFocus:eventhandler read FonSetFocus write fonSetFocus; property oncreated:eventhandler read foncreated write foncreated; + property ActiveControl read getactivecontrol write setactivecontrol; private //模态相关 property Modaling read FModaling; @@ -2565,4 +2595,33 @@ type TWinControl = class(tcontrol) if mu.ExecuteCommand("doshortcut",st)="havedoshortcut" then return "havedoshortcut"; end end + function setactivecontrol(ctl);virtual; + begin + if WsPopUp then + begin + if factivecontrol = ctl then return ; + if ctl is class(TWinControl) then + begin + factivecontrol := ctl; + if factivated then + begin + ctl.SetFocus(); + end + end else + begin + factivecontrol := nil; + end + end else + begin + p := parent ; + if p then return p.ActiveControl := ctl; + end + end + function getactivecontrol(); + begin + if WsPopUp then return factivecontrol; + factivecontrol := nil; + end + factivecontrol; + end \ No newline at end of file diff --git a/funcext/tvclib/ugtkinterface.tsf b/funcext/tvclib/ugtkinterface.tsf index d2f9ae8..5b611f5 100644 --- a/funcext/tvclib/ugtkinterface.tsf +++ b/funcext/tvclib/ugtkinterface.tsf @@ -54,80 +54,87 @@ type tsgtkapi = class(tgtkapis) SW_SHOWNOACTIVATE := 0x4;SW_SHOW := 0x5;SW_MINIMIZE := 0x6; SW_SHOWMINNOACTIVE := 0x7;SW_SHOWNA := 0x8;SW_RESTORE := 0x9; SW_SHOWDEFAULT := 0xA;SW_FORCEMINIMIZE := 0xB;SW_MAX := 0xB;} - global G_GTK_WINDOW_ACTIVATE; - if not hwd then return ; - if not GTK_WIDGET(hwd) then return ; - if f =0 then - begin - - if gtk_widget_is_toplevel(hwd) then - begin - p := GetParent(hwd); - if p then gtk_window_set_transient_for(hwd,0); - end - gtk_widget_hide(hwd); - end else - if f=0xc then - begin - if gtk_widget_is_toplevel(hwd) then - begin - p := GetParent(hwd); - if p and GTK_WIDGET(p) then - begin - if gtk_widget_is_toplevel(p) then pp := p; - else - pp := gtk_widget_get_toplevel(p); - if pp then gtk_window_set_transient_for(hwd,pp); - end - end - gtk_widget_show_all(hwd); - end else - begin - if gtk_widget_is_toplevel(hwd) then - begin - global g_current_get_focus_widget; - cf := g_current_get_focus_widget; - p := GetParent(hwd); - if p and GTK_WIDGET(p) then - begin - if gtk_widget_is_toplevel(p) then pp := p; - else - pp := gtk_widget_get_toplevel(p); - if pp then gtk_window_set_transient_for(hwd,pp); - end - if 2 =g_object_get_data(hwd,"gtk_popwp") then - begin - x := g_object_get_data(hwd,"gtk_layout_x"); - y := g_object_get_data(hwd,"gtk_layout_y"); - w := g_object_get_data(hwd,"gtk_layout_width"); - h := g_object_get_data(hwd,"gtk_layout_height"); - global g_w_c_width; - pcd := gtk_object_get_data(hwd,"gtk_wnd_hs_caption")?g_w_c_width:0; - gtk_window_move(hwd,x,max(0,y-pcd)); - if w>=0 and h>=0 then - gtk_widget_set_size_request(hwd,w,max(0,h-pcd)); - end - if f=0x4 then - begin - if not gtk_window_get_decorated(hwd) then - gtk_window_set_type_hint(hwd,3); - if cf and cf<>g_current_get_focus_widget then //设置一下focus - begin - tplev := gtk_widget_get_toplevel(cf); - if tplev then gtk_window_set_focus(tplev,cf); - end - end - end - gtk_widget_show(hwd); - {if f<>0x4 and G_GTK_WINDOW_ACTIVATE<>hwd then - begin - if G_GTK_WINDOW_ACTIVATE then - gtk_addMessageQueue(G_GTK_WINDOW_ACTIVATE,0x6,0,0,0); - G_GTK_WINDOW_ACTIVATE := hwd; - gtk_addMessageQueue(hwd,0x6,1,0,0); - end } - end - return true; + global G_GTK_WINDOW_ACTIVATE; + if not hwd then return ; + if not GTK_WIDGET(hwd) then return ; + if f =0 then //隐藏 + begin + if gtk_widget_is_toplevel(hwd) then + begin + p := GetParent(hwd); + if p then gtk_window_set_transient_for(hwd,0); + end + gtk_widget_hide(hwd); + end else + if f=0x3 then //最大化 + begin + if gtk_widget_is_toplevel(hwd) then + begin + gtk_window_maximize(hwd); + end + end else + if f=0xc then //show + begin + if gtk_widget_is_toplevel(hwd) then + begin + p := GetParent(hwd); + if p and GTK_WIDGET(p) then + begin + if gtk_widget_is_toplevel(p) then pp := p; + else + pp := gtk_widget_get_toplevel(p); + if pp then gtk_window_set_transient_for(hwd,pp); + end + end + //gtk_widget_show_all(hwd); + gtk_widget_show(hwd); + end else //其他 + begin + if gtk_widget_is_toplevel(hwd) then + begin + global g_current_get_focus_widget; + cf := g_current_get_focus_widget; + p := GetParent(hwd); + if p and GTK_WIDGET(p) then + begin + if gtk_widget_is_toplevel(p) then pp := p; + else + pp := gtk_widget_get_toplevel(p); + if pp then gtk_window_set_transient_for(hwd,pp); + end + if 2 =g_object_get_data(hwd,"gtk_popwp") then + begin + x := g_object_get_data(hwd,"gtk_layout_x"); + y := g_object_get_data(hwd,"gtk_layout_y"); + w := g_object_get_data(hwd,"gtk_layout_width"); + h := g_object_get_data(hwd,"gtk_layout_height"); + global g_w_c_width; + pcd := gtk_object_get_data(hwd,"gtk_wnd_hs_caption")?g_w_c_width:0; + gtk_window_move(hwd,x,max(0,y-pcd)); + if w>=0 and h>=0 then + gtk_widget_set_size_request(hwd,w,max(0,h-pcd)); + end + if f=0x4 then + begin + if not gtk_window_get_decorated(hwd) then + gtk_window_set_type_hint(hwd,3); + if cf and cf<>g_current_get_focus_widget then //设置一下focus + begin + tplev := gtk_widget_get_toplevel(cf); + if tplev then gtk_window_set_focus(tplev,cf); + end + end + end + gtk_widget_show(hwd); + {if f<>0x4 and G_GTK_WINDOW_ACTIVATE<>hwd then + begin + if G_GTK_WINDOW_ACTIVATE then + gtk_addMessageQueue(G_GTK_WINDOW_ACTIVATE,0x6,0,0,0); + G_GTK_WINDOW_ACTIVATE := hwd; + gtk_addMessageQueue(hwd,0x6,1,0,0); + end } + end + return true; end function MessageBoxA(hwnd :pointer;txt:string;cap:string;flag:integer); begin @@ -3791,7 +3798,8 @@ type tgtkapis = class() //gtk function gtk_widget_get_window(g:pointer):pointer;cdecl;external 'libgtk-3.so'; procedure gtk_window_get_position(g:pointer;var x:integer;var y:integer);cdecl;external 'libgtk-3.so'; function gtk_image_new_from_file(f:string):pointer;cdecl;external 'libgtk-3.so'; - procedure gtk_widget_show_all (window:pointer);cdecl;external 'libgtk-3.so';//'libgtk-x11-2.0.so'; + procedure gtk_widget_show_all(window:pointer);cdecl;external 'libgtk-3.so';//'libgtk-x11-2.0.so'; + procedure gtk_window_maximize(window:pointer);cdecl;external 'libgtk-3.so';//'libgtk-x11-2.0.so'; procedure gtk_widget_show(window:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_widget_show_now(window:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_widget_hide(window:pointer);cdecl;external 'libgtk-3.so';