优化gtk消息处理
This commit is contained in:
tslediter 2023-12-15 15:33:14 +08:00
parent afdfe2e2f7
commit ff29e86b3b
2 changed files with 873 additions and 680 deletions

View File

@ -1271,7 +1271,13 @@ type TBlockManager=class(TVCForm)
FEditer.EndModal(); FEditer.EndModal();
end end
FList.OnDblClick :=function(o,e)begin FList.OnDblClick :=function(o,e)begin
if FList.SelectedId>=0 then
begin
FEditer.caption := "Ð޸ĴúÂë¿é..."; FEditer.caption := "Ð޸ĴúÂë¿é...";
end else
begin
FEditer.caption := "Ìí¼Ó´úÂë¿é..."
end
FEditer.SetData(FList.SelectedValue); FEditer.SetData(FList.SelectedValue);
FEditer.showmodal(); FEditer.showmodal();
end end
@ -1327,7 +1333,6 @@ type TBlockManager=class(TVCForm)
if v[1] and v[2] and v[3] then r[ri++] := array("prefix":v[0],"caption":v[1],"value":v[2],"valueext":v[3]); if v[1] and v[2] and v[3] then r[ri++] := array("prefix":v[0],"caption":v[1],"value":v[2],"valueext":v[3]);
end end
r union2= array(); r union2= array();
return r; return r;
end end
function SetData(d); function SetData(d);

View File

@ -400,17 +400,20 @@ type tsgtkapi = class(tgtkapis)
begin begin
pt := gtk_widget_get_toplevel(pt); pt := gtk_widget_get_toplevel(pt);
end end
w.Visible := true;
gtk_window_set_type_hint((dialog),0); gtk_window_set_type_hint((dialog),0);
//gtk_window_set_modal(GTK_WINDOW( dialog),TRUE); //屏蔽掉showmodal gtk_window_set_modal(GTK_WINDOW( dialog),TRUE); //屏蔽掉showmodal
gtk_window_set_transient_for( GTK_WINDOW(dialog),GTK_WINDOW(pt)); gtk_window_set_transient_for( GTK_WINDOW(dialog),GTK_WINDOW(pt));
//w.Visible := true;
gtk_widget_show(dialog);
g_object_set_data(dialog,"is_show_modaling",true);
return true; return true;
end end
end end
function gtk_window_endmodal(w); //shomodal function gtk_window_endmodal(w); //shomodal
begin begin
dialog := w.handle; dialog := w.handle;
if not g_object_get_data(dialog,"is_show_modaling") then return ;
g_object_set_data(dialog,"is_show_modaling",false);
pt := GetParent(dialog); pt := GetParent(dialog);
if (pt) then if (pt) then
begin begin
@ -418,9 +421,10 @@ type tsgtkapi = class(tgtkapis)
begin begin
pt := gtk_widget_get_toplevel(pt); pt := gtk_widget_get_toplevel(pt);
end end
//gtk_window_set_modal(GTK_WINDOW( dialog),false); //屏蔽掉showmodal gtk_window_set_modal(GTK_WINDOW( dialog),false); //屏蔽掉showmodal
gtk_window_set_transient_for( GTK_WINDOW(dialog),0); gtk_window_set_transient_for( GTK_WINDOW(dialog),0);
w.Visible := false; //w.Visible := false;
gtk_widget_hide(dialog);
end end
end end
function GetParent(h); //获得父窗口 function GetParent(h); //获得父窗口
@ -3782,6 +3786,11 @@ type tgtkapis = class() //gtk
_f_ := static procedure(window:pointer; tp:integer);cdecl;external getfuncptrbyname(0,functionname()); _f_ := static procedure(window:pointer; tp:integer);cdecl;external getfuncptrbyname(0,functionname());
return ##_f_(window,tp); return ##_f_(window,tp);
end end
function gtk_window_get_type_hint(window:pointer):integer;
begin
_f_ := static function(window:pointer):integer;cdecl;external getfuncptrbyname(0,functionname());
return ##_f_(window);
end
procedure gtk_widget_set_has_window(widget:pointer;has_window:integer); procedure gtk_widget_set_has_window(widget:pointer;has_window:integer);
begin begin
_f_ := static procedure(widget:pointer;has_window:integer);cdecl;external getfuncptrbyname(0,functionname()); _f_ := static procedure(widget:pointer;has_window:integer);cdecl;external getfuncptrbyname(0,functionname());
@ -6597,6 +6606,7 @@ type tenterouterlist = class
FList; FList;
FTimer; //20230314 修正此处问题 FTimer; //20230314 修正此处问题
end end
type tgtk_ctl_object = class(_gtkeventtype) type tgtk_ctl_object = class(_gtkeventtype)
private private
@ -6837,108 +6847,9 @@ type tgtk_ctl_object = class(_gtkeventtype)
begin begin
return true; return true;
end end
function get_ignore_event_type(tp);virtual; function GSWINDOWSTATEEVENT(a,b,c,d);virtual; //状态改变
begin
return false;
end
function GtkEventDispatchA(a,b,c,d);//gtk消息分发
begin
if imitate_event_size() then
begin
global g_gtk_scroll_lock;
if g_gtk_scroll_lock then
begin
return true;
end
if FHitwidgetposition in array(110,111,112,115) then
begin
mn := GetGtkEventNameOrId(b);
if mn="event" then
begin
e := new _GdkEventAny(c);
if 3=e.ttype then
begin
ogps := Fsyscommand0x12info[0];
xy := Fsyscommand0x12info[1];
cxy := array(0,0);
_wapi.GetCursorPos(cxy);
dx := cxy[0]-ogps[0];
dy := cxy[1]-ogps[1];
case FHitwidgetposition of //0 修改为 -1
110:
begin
if dx<>0 then _wapi.SetWindowPos(a.handle,-1,xy[0]+dx,xy[1],xy[2]-dx,xy[3],0);
end
111:
begin
if dx<>0 then _wapi.SetWindowPos(a.handle,-1,xy[0],xy[1],xy[2]+dx,xy[3],0);
end
112:
begin
if dy<>0 then _wapi.SetWindowPos(a.handle,-1,xy[0],xy[1]+dy,xy[2],xy[3]-dy,0);
end
115:
begin
if dy<>0 then _wapi.SetWindowPos(a.handle,-1,xy[0],xy[1],xy[2],xy[3]+dy,0);
end
end;
return 1;
end else
if 7 = e.ttype then
begin
FHitwidgetposition := 0;
Fsyscommand0x12info := nil;
FMousemoveernotify.unlock();
//return ;
end
end
end else
if Fsyscommand0x12 and ifarray(Fsyscommand0x12info) then
begin
mn := GetGtkEventNameOrId(b);
if mn="event" then
begin
e := new _GdkEventAny(c);
if 3=e.ttype then
begin
ogps := Fsyscommand0x12info[0];
xy := Fsyscommand0x12info[1];
cxy := array(0,0);
_wapi.GetCursorPos(cxy);
dx := cxy[0]-ogps[0];
dy := cxy[1]-ogps[1];
if dx>3 or dx<-3 or dy<-3 or dy>3 then
begin
_wapi.SetWindowPos(a.handle,0,xy[0]+dx,xy[1]+dy,-1,-1,0);
end
return 1;
end else
if 7 = e.ttype then
begin
Fsyscommand0x12 := false;
Fsyscommand0x12info := nil;
FMousemoveernotify.unlock();
//return ;
end
end
end
end
return GtkEventDispatchb(a,b,c,d);
end
function GtkEventDispatchb(a,b,c,d); //gtk消息分发
begin
mn := GetGtkEventNameOrId(b); // _send_
global g_current_get_focus_widget,g_current_loss_focus_widget,g_gtk_buttontable,G_GTK_WINDOW_ACTIVATE, g_gtk_keytable;
if mn = "event" then
begin
e := new _GdkEventAny(c);
//echo "\r\nwindow:",_wapi.gtk_widget_get_window(a.handle)," ",e.window;
if get_ignore_event_type(e) then return false;
case e.ttype of
GDK_WINDOW_STATE:
begin begin
global G_GTK_WINDOW_ACTIVATE;
obj := new _GdkEventWindowState(c); obj := new _GdkEventWindowState(c);
st := obj.new_window_state; st := obj.new_window_state;
if st .& 4 then if st .& 4 then
@ -6984,23 +6895,40 @@ type tgtk_ctl_object = class(_gtkeventtype)
GDK_WINDOW_STATE_FULLSCREEN = 1 << 4, GDK_WINDOW_STATE_FULLSCREEN = 1 << 4,
GDK_WINDOW_STATE_ABOVE = 1 << 5, GDK_WINDOW_STATE_ABOVE = 1 << 5,
GDK_WINDOW_STATE_BELOW = 1 << 6} GDK_WINDOW_STATE_BELOW = 1 << 6}
return false;
end end
GDK_BUTTON_PRESS: function GSBUTTONPRESSEVENT(a,b,c,d);virtual;
begin begin
//echo "\r\n bt press",datetimetostr(now())," ",handle," ",e.window," >>",_Wapi.gtk_widget_get_window(handle),"+++",_wapi.gdk_window_get_window_type(e.window),"***", global g_gtk_buttontable, g_gtk_keytable;
// _wapi.gtk_widget_get_toplevel(handle);
e := new _GdkEventButton(c); e := new _GdkEventButton(c);
psi := makelong(integer(e.x),integer(e.y));
//r := array();
//_wapi.GetTopWidgetList(a.handle,e.x_root,e.y_root,r);
//rl := length(r)-1;
//if r[rl,0]<>a.handle then return false;;
wp := 0; wp := 0;
if ifarray(g_gtk_keytable) then if ifarray(g_gtk_keytable) then
begin begin
if g_gtk_keytable[0x10] then wp .|= 0x0004; if g_gtk_keytable[0x10] then wp .|= 0x0004;
if g_gtk_keytable[0x11] then wp .|= 0x0008; if g_gtk_keytable[0x11] then wp .|= 0x0008;
end end
if e.ttype=GDK_2BUTTON_PRESS then
begin
psi := makelong(integer(e.x),integer(e.y));
case e.button of
1:
begin
CallTslVclProc(_const.WM_LBUTTONDBLCLK ,wp,psi);
end
3:
begin
CallTslVclProc(_const.WM_RBUTTONDBLCLK ,wp,psi);
end
end ;
return CanignoreBtnpress();
end
psi := makelong(integer(e.x),integer(e.y));
//r := array();
//_wapi.GetTopWidgetList(a.handle,e.x_root,e.y_root,r);
//rl := length(r)-1;
//if r[rl,0]<>a.handle then return false;
case e.button of case e.button of
1: 1:
begin begin
@ -7047,9 +6975,17 @@ type tgtk_ctl_object = class(_gtkeventtype)
end } end }
return CanignoreBtnpress(); return CanignoreBtnpress();
end end
GDK_BUTTON_RELEASE: function GSMOTIONNOTIFYEVENT(a,b,c,d);virtual;
begin begin
//t := 1+"1234"; e := new _GdkEventMotion(c);
//CallTslVclProc(_const.WM_MOUSEMOVE ,0,makelong(integer(e.x),integer(e.y)),true);
id := a.handle;
mywidgetmousehit(id,array(integer(e.x_root),integer(e.y_root)));
mywidgetmousemovecall(id,array(integer(e.x),integer(e.y)));
end
function GSBUTTONRELEASEEVENT(a,b,c,d);virtual;
begin
global g_gtk_buttontable, g_gtk_keytable;
e := new _GdkEventButton(c); e := new _GdkEventButton(c);
psi := makelong(integer(e.x),integer(e.y)); psi := makelong(integer(e.x),integer(e.y));
wp := 0; wp := 0;
@ -7075,36 +7011,56 @@ type tgtk_ctl_object = class(_gtkeventtype)
end ; end ;
return CanignoreBtnpress(); return CanignoreBtnpress();
end end
GDK_2BUTTON_PRESS: function GSFOCUSINEVENT(a,b,c,d);virtual;
begin begin
ne := new _GdkEventButton(c); global g_current_get_focus_widget,g_current_loss_focus_widget;
psi := makelong(integer(ne.x),integer(ne.y)); h := a.handle;
wp := 0; e := new _GdkEventAny(c);
if ifarray(g_gtk_keytable) then getfimobj().setclientwindow(e.window);
getfimobj().setfocusctl(self);
g_current_get_focus_widget := h;
//echo "\r\nsetfocus==>",h;
ch := _wapi.g_object_get_data(h,"gtk_client_parent");
if ch then
begin begin
if g_gtk_keytable[0x10] then wp .|= 0x0004; //AddMessageToGtkMessageQueue(ch,_const.WM_SETFOCUS,0,0,0);
if g_gtk_keytable[0x11] then wp .|= 0x0008; CallGtkWinProc(ch,_const.WM_SETFOCUS,0,0);
end else
begin
CallTslVclProc(_const.WM_SETFOCUS,0,0,0);
end end
case ne.button of //WM_SETFOCUS
1: getfimobj().focusin();
end
function GSFOCUSOUTEVENT(a,b,c,d);virtual;
begin begin
CallTslVclProc(_const.WM_LBUTTONDBLCLK ,wp,psi); global g_current_get_focus_widget,g_current_loss_focus_widget;
h := a.handle;
e := new _GdkEventAny(c);
getfimobj().setclientwindow(e.window);
getfimobj().setfocusctl(self);
g_current_loss_focus_widget := h;
g_current_get_focus_widget := 0;
ch := _wapi.g_object_get_data(a.handle,"gtk_client_parent");
//将killfocus 修改为立即执行
if ch then
begin
//AddMessageToGtkMessageQueue(ch,_const.WM_KILLFOCUS,0,0,0);
CallGtkWinProc(ch,_const.WM_KILLFOCUS,0,0);
end else
begin
//echo "\r\nkill focus:",h;
CallTslVclProc(_const.WM_KILLFOCUS,0,0,0);
end
getfimobj().focusout();
end end
3:begin function gs_key_vent(a,b,c,d);
CallTslVclProc(_const.WM_RBUTTONDBLCLK ,wp,psi);
end
end ;
//return true; //此处处理
return CanignoreBtnpress();
end
8,9: //key
begin begin
global g_gtk_keytable;
e := new _GdkEventKey(c);
kud := e.ttype; kud := e.ttype;
///////////////////////////////////控制键 ///////////////////////////////////控制键
e := new _GdkEventKey(c);
kv := e.keyval; kv := e.keyval;
{acskey := array( {acskey := array(
65505: 0x10, //shift 65505: 0x10, //shift
@ -7113,17 +7069,7 @@ type tgtk_ctl_object = class(_gtkeventtype)
65508: 0x11, 65508: 0x11,
65513: 0x12, //alt 65513: 0x12, //alt
65514: 0x12 65514: 0x12
); );}
if acskey[kv] then
begin
if 8=kud then
begin
g_gtk_keytable[acskey[kv]] := _shl( 1,15);
end else
begin
g_gtk_keytable[acskey[kv]] := 0;
end
end }
///////////////菜单按键 ///////////////菜单按键
if kv = 65513 or kv = 65514 then if kv = 65513 or kv = 65514 then
begin begin
@ -7398,7 +7344,7 @@ type tgtk_ctl_object = class(_gtkeventtype)
end end
else else
begin begin
keymapb := array( keymapb := static array(
96:192, 96:192,
45:189, 45:189,
61:187, 61:187,
@ -7446,136 +7392,146 @@ type tgtk_ctl_object = class(_gtkeventtype)
end end
end ; end ;
return true; return true;
end end
10: //mouse in function GtkEventDispatchA(a,b,c,d);//gtk消息分发
begin begin
//e := new _GdkEventCrossing(c); mn := GetGtkEventNameOrId(b);
//echo tostn(e._getdata_()); e := new _GdkEventAny(c);
//echo "===enter\r\n"; if imitate_event_size() then
//FMousemoveernotify.push(a.handle); begin
//_wapi.GetCursorPos(ps); global g_gtk_scroll_lock;
//e := new _GdkEventMotion(c); if g_gtk_scroll_lock then
//echo "\r\n enter:",a.handle,tostn(ps),tostn(e._getdata_()); begin
return true;
end
if FHitwidgetposition in array(110,111,112,115) then
begin
if mn="event" then
begin
if GDK_MOTION_NOTIFY=e.ttype then
begin
ogps := Fsyscommand0x12info[0];
xy := Fsyscommand0x12info[1];
cxy := array(0,0);
_wapi.GetCursorPos(cxy);
dx := cxy[0]-ogps[0];
dy := cxy[1]-ogps[1];
case FHitwidgetposition of //0 修改为 -1
110:
begin
if dx<>0 then _wapi.SetWindowPos(a.handle,-1,xy[0]+dx,xy[1],xy[2]-dx,xy[3],0);
end
111:
begin
if dx<>0 then _wapi.SetWindowPos(a.handle,-1,xy[0],xy[1],xy[2]+dx,xy[3],0);
end
112:
begin
if dy<>0 then _wapi.SetWindowPos(a.handle,-1,xy[0],xy[1]+dy,xy[2],xy[3]-dy,0);
end
115:
begin
if dy<>0 then _wapi.SetWindowPos(a.handle,-1,xy[0],xy[1],xy[2],xy[3]+dy,0);
end end
11: //mouse out
begin
//FMousemoveernotify.pop(a.handle);
//echo "\r\nleave:",a.handle;
end
3:
begin
e := new _GdkEventMotion(c);
//CallTslVclProc(_const.WM_MOUSEMOVE ,0,makelong(integer(e.x),integer(e.y)),true);
id := a.handle;
mywidgetmousehit(id,array(integer(e.x_root),integer(e.y_root)));
mywidgetmousemovecall(id,array(integer(e.x),integer(e.y)));
end end;
12: //focus return 1;
begin
h := a.handle;
//getfimobj().setclientwindow(e.window);
getfimobj().setclientwindow(e.window);
getfimobj().setfocusctl(self);
if (new _GdkEventFocus(c).iin)=1 then
begin
g_current_get_focus_widget := h;
//echo "\r\nsetfocus==>",h;
ch := _wapi.g_object_get_data(h,"gtk_client_parent");
if ch then
begin
//AddMessageToGtkMessageQueue(ch,_const.WM_SETFOCUS,0,0,0);
CallGtkWinProc(ch,_const.WM_SETFOCUS,0,0);
end else end else
if GDK_BUTTON_RELEASE = e.ttype then
begin begin
CallTslVclProc(_const.WM_SETFOCUS,0,0,0); FHitwidgetposition := 0;
Fsyscommand0x12info := nil;
FMousemoveernotify.unlock();
//return ;
end
end end
//WM_SETFOCUS
getfimobj().focusin();
end else end else
if Fsyscommand0x12 and ifarray(Fsyscommand0x12info) then
begin begin
g_current_loss_focus_widget := h; mn := GetGtkEventNameOrId(b);
g_current_get_focus_widget := 0; if mn="event" then
ch := _wapi.g_object_get_data(a.handle,"gtk_client_parent");
//将killfocus 修改为立即执行
if ch then
begin begin
//AddMessageToGtkMessageQueue(ch,_const.WM_KILLFOCUS,0,0,0); e := new _GdkEventAny(c);
CallGtkWinProc(ch,_const.WM_KILLFOCUS,0,0); if GDK_MOTION_NOTIFY=e.ttype then
begin
ogps := Fsyscommand0x12info[0];
xy := Fsyscommand0x12info[1];
cxy := array(0,0);
_wapi.GetCursorPos(cxy);
dx := cxy[0]-ogps[0];
dy := cxy[1]-ogps[1];
if dx>3 or dx<-3 or dy<-3 or dy>3 then
begin
_wapi.SetWindowPos(a.handle,0,xy[0]+dx,xy[1]+dy,-1,-1,0);
end
return 1;
end else end else
if GDK_BUTTON_RELEASE = e.ttype then
begin begin
//echo "\r\nkill focus:",h; Fsyscommand0x12 := false;
CallTslVclProc(_const.WM_KILLFOCUS,0,0,0); Fsyscommand0x12info := nil;
end FMousemoveernotify.unlock();
getfimobj().focusout(); //return ;
end end
end end
end ;
end end
//if mn="activate" then
//begin
//echo "\r\nacive","==",b,"==",c,"d";
//end
//
r := GtkEventDispatch(a,mn,c,d);
return r;
end end
function GtkEventDispatch(a,mn,c,d);virtual; //根据名称处理gtk消息
begin
//消息分发
global g_current_get_focus_widget;
case mn of case mn of
"destroy" : GS_DESTROY:
begin begin
FMousemoveernotify.unlock(); FMousemoveernotify.unlock();
Fsyscommand0x12 := 0; Fsyscommand0x12 := 0;
Fsyscommand0x12info := nil; Fsyscommand0x12info := nil;
FHitwidgetposition := 0; FHitwidgetposition := 0;
r := CallTslVclProc(_const.WM_NCDESTROY ,0,0); r := CallTslVclProc(_const.WM_NCDESTROY ,0,0);
//echo "\r\ncall destroy===",r,">>>",a.handle;
end end
{ GS_BUTTON_PRESS_EVENT:
"map":
begin begin
return GSBUTTONPRESSEVENT(a,b,c,d);
end end
"wm-user": GS_MOTION_NOTIFY_EVENT:
begin begin
r := CallTslVclProc(_const.WM_USER ,c,d); GSMOTIONNOTIFYEVENT(a,b,c,d);
end end
"button-press-event": GS_BUTTON_RELEASE_EVENT:
begin begin
//return true; return GSBUTTONRELEASEEVENT(a,b,c,d);
end end
"button-release-event": GS_KEY_PRESS_EVENT:
begin begin
if gs_key_vent(a,b,c,8) then return true;
end
GS_KEY_RELEASE_EVENT:
begin
if gs_key_vent(a,b,c,9) then return true;
end
GS_FOCUS_IN_EVENT:
begin
GSFOCUSINEVENT(a,b,c,d);
end
GS_FOCUS_OUT_EVENT:
begin
GSFOCUSOUTEVENT(a,b,c,d);
end
GS_WINDOW_STATE_EVENT:
begin
return GSWINDOWSTATEEVENT(a,b,c,d);
end
end end
"motion-notify-event": r := GtkEventDispatch(a,mn,c,d);
begin
//e := new _GdkEventMotion(c);
//CallTslVclProc(_const.WM_MOUSEMOVE ,0,makelong(integer(e.x),integer(e.y)));
//return true;
end
"set-focus-child":
begin
//echo "\r\nsignal name id:",GetGtkEventNameOrId("set-focus-child");
//echo "\r\nset focus child:",a.handle,"*****",c,"============",d;
end
"key-press-event":
begin
//echo "\r\n==key :=",1,"***" , a.handle,"====",_wapi.gtk_widget_is_toplevel(a.handle),"==========",datetimetostr(now());
end
}
end ;
return r; return r;
end end
function GtkEventDispatch(a,mn,c,d);virtual; //根据名称处理gtk消息
begin
//消息分发
return false;
end
function GtkBaseEventName();virtual; //绑定的消息 function GtkBaseEventName();virtual; //绑定的消息
begin begin
return array("destroy","map","button-press-event","motion-notify-event","button-release-event","key-press-event","key-release-event","event"); //,"set-focus-child" //return array("destroy","map","button-press-event","motion-notify-event","button-release-event","key-press-event","key-release-event","event"); //,"set-focus-child"
return array(GS_DESTROY,GS_BUTTON_PRESS_EVENT,GS_MOTION_NOTIFY_EVENT,GS_BUTTON_RELEASE_EVENT,GS_KEY_PRESS_EVENT,GS_KEY_RELEASE_EVENT,GS_FOCUS_IN_EVENT,GS_FOCUS_OUT_EVENT,GS_WINDOW_STATE_EVENT,GS_EVENT); //,"set-focus-child"
end end
function CreateWnd(dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nwidth,nheight,hwndparent,hmenu,hinstance,lpParam);virtual; //构造窗口 function CreateWnd(dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nwidth,nheight,hwndparent,hmenu,hinstance,lpParam);virtual; //构造窗口
begin begin
@ -7632,10 +7588,32 @@ type tgtk_ctl_object = class(_gtkeventtype)
FConnectNameIds := array(); FConnectNameIds := array();
FConnectHandlers := array(); FConnectHandlers := array();
end end
f_signal_f_map;
function unformatsignalname(n);
begin
return replacetext(n,"-","_");
end
function get_fptr_by_sigal_name(n);virtual;
begin
global g_gtk_call_handler_manager;
if not g_gtk_call_handler_manager then return 0;
mgnr := g_gtk_call_handler_manager;
if not ifarray(f_signal_f_map) then f_signal_f_map := array();
fn := "c_g_e_"+unformatsignalname(n);
r := f_signal_f_map[fn];
if ifnil(r) then
begin
ffn := findfunction(fn);
if ffn then
r := mgnr.get(ffn);
else r := 0;
f_signal_f_map[fn] := r;
end
return r;
end
function getsignalmap();virtual; function getsignalmap();virtual;
begin begin
return array( return array(
"wm-user":'tsl_gtk_wmuser_event', //用户
"destroy":"tsl_gtk_destroy_event", //销毁 "destroy":"tsl_gtk_destroy_event", //销毁
"activate":"tsl_gtk_activate_event", //活动 "activate":"tsl_gtk_activate_event", //活动
"clicked":"tsl_gtk_clicked_event", //点击 "clicked":"tsl_gtk_clicked_event", //点击
@ -7644,7 +7622,11 @@ type tgtk_ctl_object = class(_gtkeventtype)
//"day-selected":"tsl_gtk_day_select_event", //日历选择 //"day-selected":"tsl_gtk_day_select_event", //日历选择
"changed" :"tsl_gtk_changed_event", //改变 "changed" :"tsl_gtk_changed_event", //改变
"preedit-changed":"tsl_gtk_preedit_changed_event" , "preedit-changed":"tsl_gtk_preedit_changed_event" ,
"activate-default":"tsl_gtk_activate_default_event_cb" "activate-default":"tsl_gtk_activate_default_event_cb" ,
GS_WINDOW_STATE_EVENT:"tsl_gtk_window_state_event" ,
GS_FOCUS:"tsl_gtk_focus_event",
GS_FOCUS_IN_EVENT:"tsl_gtk_focus_in_event" ,
GS_FOCUS_OUT_EVENT:"tsl_gtk_focus_out_event"
); );
end end
function connect_test(n,f); //测试使用 function connect_test(n,f); //测试使用
@ -7671,12 +7653,21 @@ type tgtk_ctl_object = class(_gtkeventtype)
g_signal_handler_disconnect(FHandle,lnid); g_signal_handler_disconnect(FHandle,lnid);
end end
//echo "\r\nconnect ===========================",FHandle,"=====",n; //echo "\r\nconnect ===========================",FHandle,"=====",n;
eid := GetGtkEventNameOrId(ln); eid := GetGtkEventNameOrId(ln);
fn := (getsignalmap())[ln]; //fn := (getsignalmap())[ln];
if not(fn and ifstring(fn)) then fn := "tsl_gtk_normal_event_cb"; //if not(fn and ifstring(fn)) then fn := "tsl_gtk_normal_event_cb";
lnid := g_signal_connect_data(FHandle, ln, gettslvcleventhandler_(fn), eid,nil,0); //lnid := g_signal_connect_data(FHandle, ln, gettslvcleventhandler_(fn), eid,nil,0);
ptr := get_fptr_by_sigal_name(n);
if ptr then
begin
lnid := g_signal_connect_data(FHandle, ln, ptr, eid,nil,0);
FConnectNameIds[ln] := lnid; FConnectNameIds[ln] := lnid;
FConnectHandlers[inttostr(eid)] := f; FConnectHandlers[inttostr(eid)] := f;
end else
begin
echo "\r\n not find:",n;
end
return lnid; return lnid;
end end
function DefaultDestroyHandler(); function DefaultDestroyHandler();
@ -7873,8 +7864,12 @@ type tgtk_ctl_object = class(_gtkeventtype)
end end
end end
f_format_names;
function FormularSignalName(n); function FormularSignalName(n);
begin begin
if not ifarray(f_format_names) then f_format_names := array();
r := f_format_names[n];
if r then return r;
r := ""; r := "";
for i := 1 to length(n) do for i := 1 to length(n) do
begin begin
@ -7882,6 +7877,7 @@ type tgtk_ctl_object = class(_gtkeventtype)
if vi="_" then r+="-"; if vi="_" then r+="-";
else r+=vi; else r+=vi;
end end
f_format_names[n] := r;
return r; return r;
end end
function needdestroy();virtual; function needdestroy();virtual;
@ -8123,7 +8119,7 @@ type tgtk_ctl_scroll_window = class(tgtk_ctl_object)
_wapi.gtk_widget_set_can_focus(h,true); _wapi.gtk_widget_set_can_focus(h,true);
if isp and FClientWideget then //自绘制 if isp and FClientWideget then //自绘制
begin begin
FClientObject := new tgtk_ctl_object(FClientWideget); FClientObject := new tgtk_ctl_object_client(FClientWideget);
_wapi.g_object_set_data(h,"gtk_clientwideget",FClientWideget); _wapi.g_object_set_data(h,"gtk_clientwideget",FClientWideget);
FClientObject.Connect("draw",thisfunction(scrollwindowdraw)); FClientObject.Connect("draw",thisfunction(scrollwindowdraw));
_wapi.gtk_widget_set_app_paintable(FClientWideget, TRUE); //绘制 _wapi.gtk_widget_set_app_paintable(FClientWideget, TRUE); //绘制
@ -8487,8 +8483,6 @@ type tgtk_ctl_scroll_window = class(tgtk_ctl_object)
function scrolltimedo(ptr:pointer):integer; function scrolltimedo(ptr:pointer):integer;
begin begin
if ifnil(FStatscrollTime) then return 1; //没有滚动消息 if ifnil(FStatscrollTime) then return 1; //没有滚动消息
//obj := new ttmstruct(ptr);
//obj._setvalue_(0,0);
t := now(); t := now();
if (t-FStatscrollTime)<(1/24/3600/100) then return 1; //时间间隔不够10毫秒 if (t-FStatscrollTime)<(1/24/3600/100) then return 1; //时间间隔不够10毫秒
FStatscrollTime := nil; //执行了 FStatscrollTime := nil; //执行了
@ -8507,7 +8501,6 @@ type tgtk_ctl_scroll_window = class(tgtk_ctl_object)
if g_gtk_keytable[0x10] then ctl .|= _const.MK_Shift; if g_gtk_keytable[0x10] then ctl .|= _const.MK_Shift;
if g_gtk_keytable[0x11] then ctl .|= _const.MK_Control; if g_gtk_keytable[0x11] then ctl .|= _const.MK_Control;
end end
len := length(fscrollinfos)-1; len := length(fscrollinfos)-1;
xy := fscrollinfos[len,2]; xy := fscrollinfos[len,2];
h := fscrollinfos[len,0]; h := fscrollinfos[len,0];
@ -8632,6 +8625,13 @@ type tgtk_ctl_scroll_window = class(tgtk_ctl_object)
FHBardown; FHBardown;
FScroller; FScroller;
end
type tgtk_ctl_object_client = class(tgtk_ctl_object)
function create(h);
begin
inherited;
end
end end
type tgtk_ctl_window_PoPup = class(tgtk_ctl_scroll_window) type tgtk_ctl_window_PoPup = class(tgtk_ctl_scroll_window)
function Create(h);override; function Create(h);override;
@ -8655,16 +8655,6 @@ type tgtk_ctl_window_PoPup = class(tgtk_ctl_scroll_window)
if _wapi.gtk_object_get_data(Handle,"gtk_wnd_hs_caption") then return false; if _wapi.gtk_object_get_data(Handle,"gtk_wnd_hs_caption") then return false;
return true; return true;
end end
function get_ignore_event_type(e);override;
begin
tp := e.ttype;
h := handle;
if (tp in array(GDK_MOTION_NOTIFY,GDK_BUTTON_PRESS,GDK_BUTTON_RELEASE)) and _wapi.gtk_object_get_data(h,"gtk_wnd_hs_caption") and (e.window = _Wapi.gtk_widget_get_window(h)) then
begin
return true;
end
return false;
end
function GtkEventDispatch(a,mn,c,d);override; function GtkEventDispatch(a,mn,c,d);override;
begin begin
//消息分发 //消息分发
@ -8716,17 +8706,14 @@ type tgtk_ctl_window_PoPup = class(tgtk_ctl_scroll_window)
r := CallTslVclProc(_const.WM_CLOSE,0,0); r := CallTslVclProc(_const.WM_CLOSE,0,0);
return r; return r;
end end
"activate-default":
begin
echo "\r\n activate-defalut",datetimetostr(now());
end
end; end;
return inherited; return inherited;
end end
function GtkBaseEventName();override; function GtkBaseEventName();override;
begin begin
return inherited union2 array("configure-event","delete-event","scroll-event","activate-default"); //return inherited union2 array("configure-event","delete-event","scroll-event","activate-default");
return inherited union2 array(GS_CONFIGURE_EVENT,GS_DELETE_EVENT,GS_SCROLL_EVENT);
end end
function CreateWnd(dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nwidth,nheight,hwndparent,hmenu,hinstance,lpParam);override; function CreateWnd(dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nwidth,nheight,hwndparent,hmenu,hinstance,lpParam);override;
begin begin
@ -8741,7 +8728,7 @@ type tgtk_ctl_window_PoPup = class(tgtk_ctl_scroll_window)
end end
else else
begin begin
h := _wapi.gtk_window_new(0); //popup h := _wapi.gtk_window_new(1); //popup
end end
//_wapi.gtk_widget_set_events(h,0x3FFFFFE); //_wapi.gtk_widget_set_events(h,0x3FFFFFE);
@ -8814,8 +8801,38 @@ type tgtk_ctl_window_PoPup = class(tgtk_ctl_scroll_window)
begin begin
_wapi.gtk_widget_hide(h); _wapi.gtk_widget_hide(h);
end end
r := inherited;
return inherited; if FClientObject then
begin
FClientObject.connect(GS_BUTTON_PRESS_EVENT,thisfunction(cleinteventpress));
FClientObject.connect(GS_BUTTON_RELEASE_EVENT,thisfunction(cleinteventrelease));
FClientObject.connect(GS_MOTION_NOTIFY_EVENT,thisfunction(cleinteventmove));
end
return r;
end
function GSBUTTONRELEASEEVENT(a,b,c,d);override;
begin
return false;
end
function GSMOTIONNOTIFYEVENT(a,b,c,d);override;
begin
return false;
end
function GSBUTTONPRESSEVENT(a,b,c,d);override;
begin
return false;
end
function cleinteventpress(a,b,c,d);
begin
return inherited GSBUTTONPRESSEVENT(self,b,c,d);
end
function cleinteventrelease(a,b,c,d);
begin
return inherited GSBUTTONRELEASEEVENT(self,b,c,d);
end
function cleinteventmove(a,b,c,d);
begin
return inherited GSMOTIONNOTIFYEVENT(self,b,c,d);
end end
end end
@ -9374,6 +9391,75 @@ type _gtkeventtype=class
static const GTK_DEST_DEFAULT_HIGHLIGHT =2; static const GTK_DEST_DEFAULT_HIGHLIGHT =2;
static const GTK_DEST_DEFAULT_DROP =4; static const GTK_DEST_DEFAULT_DROP =4;
static const GTK_DEST_DEFAULT_ALL =7; static const GTK_DEST_DEFAULT_ALL =7;
static const GS_ACCEL_CLOSURES_CHANGED= "accel-closures-changed";
static const GS_BUTTON_PRESS_EVENT= "button-press-event";
static const GS_BUTTON_RELEASE_EVENT= "button-release-event";
static const GS_CAN_ACTIVATE_ACCEL= "can-activate-accel";
static const GS_CHILD_NOTIFY= "child-notify";
static const GS_COMPOSITED_CHANGED= "composited-changed";
static const GS_CONFIGURE_EVENT= "configure-event";
static const GS_DAMAGE_EVENT= "damage-event";
static const GS_DELETE_EVENT= "delete-event";
static const GS_DESTROY= "destroy";
static const GS_DESTROY_EVENT= "destroy-event";
static const GS_DIRECTION_CHANGED= "direction-changed";
static const GS_DRAG_BEGIN= "drag-begin";
static const GS_DRAG_DATA_DELETE= "drag-data-delete";
static const GS_DRAG_DATA_GET= "drag-data-get";
static const GS_DRAG_DATA_RECEIVED= "drag-data-received";
static const GS_DRAG_DROP= "drag-drop";
static const GS_DRAG_END= "drag-end";
static const GS_DRAG_FAILED= "drag-failed";
static const GS_DRAG_LEAVE= "drag-leave";
static const GS_DRAG_MOTION= "drag-motion";
static const GS_DRAW= "draw";
static const GS_ENTER_NOTIFY_EVENT= "enter-notify-event";
static const GS_EVENT= "event";
static const GS_EVENT_AFTER= "event-after";
static const GS_FOCUS= "focus";
static const GS_FOCUS_IN_EVENT= "focus-in-event";
static const GS_FOCUS_OUT_EVENT= "focus-out-event";
static const GS_GRAB_BROKEN_EVENT= "grab-broken-event";
static const GS_GRAB_FOCUS= "grab-focus";
static const GS_GRAB_NOTIFY= "grab-notify";
static const GS_HIDE= "hide";
static const GS_HIERARCHY_CHANGED= "hierarchy-changed";
static const GS_KEY_PRESS_EVENT= "key-press-event";
static const GS_KEY_RELEASE_EVENT= "key-release-event";
static const GS_KEYNAV_FAILED= "keynav-failed";
static const GS_LEAVE_NOTIFY_EVENT= "leave-notify-event";
static const GS_MAP= "map";
static const GS_MAP_EVENT= "map-event";
static const GS_MNEMONIC_ACTIVATE= "mnemonic-activate";
static const GS_MOTION_NOTIFY_EVENT= "motion-notify-event";
static const GS_MOVE_FOCUS= "move-focus";
static const GS_PARENT_SET= "parent-set";
static const GS_POPUP_MENU= "popup-menu";
static const GS_PROPERTY_NOTIFY_EVENT= "property-notify-event";
static const GS_PROXIMITY_IN_EVENT= "proximity-in-event";
static const GS_PROXIMITY_OUT_EVENT= "proximity-out-event";
static const GS_QUERY_TOOLTIP= "query-tooltip";
static const GS_REALIZE= "realize";
static const GS_SCREEN_CHANGED= "screen-changed";
static const GS_SCROLL_EVENT= "scroll-event";
static const GS_SELECTION_CLEAR_EVENT= "selection-clear-event";
static const GS_SELECTION_GET= "selection-get";
static const GS_SELECTION_NOTIFY_EVENT= "selection-notify-event";
static const GS_SELECTION_RECEIVED= "selection-received";
static const GS_SELECTION_REQUEST_EVENT= "selection-request-event";
static const GS_SHOW= "show";
static const GS_SHOW_HELP= "show-help";
static const GS_SIZE_ALLOCATE= "size-allocate";
static const GS_STATE_CHANGED= "state-changed";
static const GS_STATE_FLAGS_CHANGED= "state-flags-changed";
static const GS_STYLE_SET= "style-set";
static const GS_STYLE_UPDATED= "style-updated";
static const GS_TOUCH_EVENT= "touch-event";
static const GS_UNMAP= "unmap";
static const GS_UNMAP_EVENT= "unmap-event";
static const GS_UNREALIZE= "unrealize";
static const GS_VISIBILITY_NOTIFY_EVENT= "visibility-notify-event";
static const GS_WINDOW_STATE_EVENT= "window-state-event";
end end
{ //cairo 常量 { //cairo 常量
CAIRO_OPERATOR_CLEAR:=0; CAIRO_OPERATOR_CLEAR:=0;
@ -9464,6 +9550,10 @@ begin
"tsl_gtk_normal_event_cb": return mgnr.get(thisfunction(tsl_gtk_normal_event_cb)); "tsl_gtk_normal_event_cb": return mgnr.get(thisfunction(tsl_gtk_normal_event_cb));
"tsl_gtk_normal_event_bc": return mgnr.get(thisfunction(tsl_gtk_normal_event_bc)); "tsl_gtk_normal_event_bc": return mgnr.get(thisfunction(tsl_gtk_normal_event_bc));
"tsl_gtk_idle": return mgnr.get(thisfunction(tsl_gtk_idle)); "tsl_gtk_idle": return mgnr.get(thisfunction(tsl_gtk_idle));
"tsl_gtk_window_state_event": return mgnr.get(thisfunction(tsl_gtk_window_state_event));
"tsl_gtk_focus_event": return mgnr.get(thisfunction(tsl_gtk_focus_event));
"tsl_gtk_focus_in_event": return mgnr.get(thisfunction(tsl_gtk_focus_in_event));
"tsl_gtk_focus_out_event": return mgnr.get(thisfunction(tsl_gtk_focus_out_event));
end ; end ;
end end
function get_instance_i(fn); function get_instance_i(fn);
@ -9501,6 +9591,104 @@ begin
end end
end end
end end
////////////////////////new function//////////////////////////////////////////////
function c_g_e_value_changed(a:pointer;b:pointer):integer; //tsl_gtk_adj_value_changed_event
begin
return do_two_param_event(a, "value-changed");
end
function c_g_e_destroy(a:pointer; b:pointer;c:pointer):integer; //tsl_gtk_destroy_event
begin
return _gtkeventcall_(a,b,c);
end
function c_g_e_event(a:pointer;b:pointer;c:pointer):integer; //tsl_gtk_normal_event_cb
begin
return _gtkeventcall_(a,c,b);
end
function c_g_e_button_press_event(a:pointer;b:pointer;c:pointer):integer;
begin
return _gtkeventcall_(a,c,b);
end
function c_g_e_button_release_event(a:pointer;b:pointer;c:pointer):integer;
begin
return _gtkeventcall_(a,c,b);
end
function c_g_e_motion_notify_event(a:pointer;b:pointer;c:pointer):integer;
begin
return _gtkeventcall_(a,c,b);
end
function c_g_e_key_press_event(a:pointer;b:pointer;c:pointer):integer;
begin
//return _gtkeventcall_(a,c,b);
return _gtkeventcall_(a,c,b);
end
function c_g_e_key_release_event(a:pointer;b:pointer;c:pointer):integer;
begin
return _gtkeventcall_(a,c,b);
end
function c_g_e_scroll_event(a:pointer;b:pointer;c:pointer):integer;
begin
return _gtkeventcall_(a,c,b);
end
function c_g_e_draw(a:pointer;b:pointer;c:pointer):integer;
begin
return _gtkeventcall_(a,c,b);
end
function c_g_e_commit(a:pointer;b:pointer;c:pointer):integer;
begin
return _gtkeventcall_(a,c,b);
end
function c_g_e_configure_event(a:pointer;b:pointer;c:pointer):integer;
begin
return _gtkeventcall_(a,c,b);
end
function c_g_e_delete_event(a:pointer;b:pointer):integer; //tsl_gtk_delete_event
begin
return do_two_param_event(a, "delete-event");
end
function c_g_e_activate_default(a:pointer;b:pointer):integer; //tsl_gtk_activate_default_event_cb
begin
return do_two_param_event(a, "activate-default");
end
function c_g_e_window_state_event(w:pointer;state:pointer;user_data:pointer):integer; //tsl_gtk_window_state_event
begin
return _gtkeventcall_(w,GetGtkEventNameOrId("window-state-event"),state);
end
function c_g_e_focus_in_event(w:pointer;state:pointer;user_data:pointer):integer;
begin
return _gtkeventcall_(w,GetGtkEventNameOrId("focus-in-event"),state);
end
function c_g_e_focus_out_event(w:pointer;state:pointer;user_data:pointer):integer;
begin
return _gtkeventcall_(w,GetGtkEventNameOrId("focus-out-event"),state);
end
function c_g_e_focus(w:pointer;state:pointer;user_data:pointer):integer;
begin
return _gtkeventcall_(w,GetGtkEventNameOrId("focus"),state);
end
function c_g_e_activate(a:pointer;b:pointer):integer; //tsl_gtk_activate_event
begin
return do_two_param_event(a, "activate");
end
/////////////////////////////////////////////////////////////
function tsl_gtk_window_state_event(w:pointer;state:pointer;user_data:pointer):integer;
begin
return _gtkeventcall_(w,GetGtkEventNameOrId("window-state-event"),state);
end
function tsl_gtk_focus_event(w:pointer;state:pointer;user_data:pointer):integer;
begin
return _gtkeventcall_(w,GetGtkEventNameOrId("focus"),state);
end
function tsl_gtk_focus_in_event(w:pointer;state:pointer;user_data:pointer):integer;
begin
return _gtkeventcall_(w,GetGtkEventNameOrId("focus-in-event"),state);
end
function tsl_gtk_focus_out_event(w:pointer;state:pointer;user_data:pointer):integer;
begin
return _gtkeventcall_(w,GetGtkEventNameOrId("focus-out-event"),state);
end
function tsl_gtk_idle(dlg:pointer):integer; function tsl_gtk_idle(dlg:pointer):integer;
begin begin
return _gtkidledo_(dlg); return _gtkidledo_(dlg);