From e6dd894873886f5ceb6c7768459c591edb2c9a54 Mon Sep 17 00:00:00 2001 From: tslediter Date: Wed, 3 Jan 2024 17:53:48 +0800 Subject: [PATCH] gtk MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化鼠标图标 --- funcext/tvclib/ugtkinterface.tsf | 142 +++++++++++++++++++------ funcext/tvclib/utslvclcefinterface.tsf | 49 +++++---- 2 files changed, 139 insertions(+), 52 deletions(-) diff --git a/funcext/tvclib/ugtkinterface.tsf b/funcext/tvclib/ugtkinterface.tsf index 474c60f..9cb575c 100644 --- a/funcext/tvclib/ugtkinterface.tsf +++ b/funcext/tvclib/ugtkinterface.tsf @@ -555,11 +555,35 @@ type tsgtkapi = class(tgtkapis) ///////////////////////////////////////// Function LoadCursorA2(hd:pointer;n:pointer) begin + + { + static OCR_WAIT; //150 + static OCR_CROSS; //30; + static OCR_UP; //6 + static OCR_SIZE; //0 + static OCR_SIZENWSE; //14 + static OCR_SIZENESW; //12 + static OCR_SIZEWE; //70 + static OCR_SIZENS; //138 + static OCR_SIZEALL; //58 + static OCR_ICOCUR; // 0 + static OCR_NO; //0 + static OCR_HAND; //24 + static OCR_APPSTARTING; //126 + static OCR_IBEAM; //152 rn := array(0x7F01:152,0x7F8A:126,0x7F89:24,0x7F88:0,0x7F87:0, 0x7F86:58,0x7F85:138,0x7F84:70,0x7F83:12,0x7F82:14,0x7F80:58,0x7F04:6, 0x7F03:30,0x7F02:150)[n]; - if ifnil(rn) then rn := 2; - return gdk_cursor_new(rn); + } + rn := array(0x7F01:"text",0x7F8A:"context-menu",0x7F89:"pointer",0x7F88:"default",0x7F87:"default", + 0x7F86:"move",0x7F85:"row-resize",0x7F84:"col-resize",0x7F83:"nesw-resize",0x7F82:"nwse-resize",0x7F80:"move",0x7F04:"n-resize", + 0x7F03:"crosshair",0x7F02:"wait")[n]; + if not ifstring(rn) then rn := "default"; + //r := gdk_cursor_new(rn); + ds := static gdk_display_get_default(); + r := gdk_cursor_new_from_name(ds,rn); + //echo "\r\n getcursor:",n," ",rn," ",r; + return r; end function RegisterClassExA(wc:pointer); begin @@ -2111,12 +2135,18 @@ type tsgtkapi = class(tgtkapis) return 0; end Function SetCursor(hd:pointer):pointer; - begin - global g_show_cursor_window; - if g_show_cursor_window and (hd>0 or hd<0) then + begin + global g_show_cursor_window; + gcw := g_show_cursor_window; + if gcw and (hd>0 or hd<0) then begin - gdk_window_set_cursor(g_show_cursor_window,hd); + clearMessageFromGtkMessageQueue(gcw[0],gcw[2]); + AddMessageToGtkMessageQueue(gcw[0],gcw[2],gcw[1],hd); + //wd := g_show_cursor_window; + //echo "\r\nsetcousor:",datetimetostr(now())," ",wd," ",hd; + //gdk_window_set_cursor(wd,hd); end + return true; end function drawbitmaptodc(bm,hdc,x,y,rc,flag,thdc); begin @@ -5605,6 +5635,21 @@ type tgtkapis = class() //gtk _f_ := static function(c:integer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(c); end + function gdk_cursor_new_from_name(disp:pointer;n:string):pointer; + begin + //global g_c_r_hash;if not ifarray(g_c_r_hash) then g_c_r_hash := array(); + _f_ := static function(disp:pointer;n:string):pointer;cdecl;external getfuncptrbyname(0,functionname()); + if ifnil(disp) then disp := static gdk_display_get_default(); + r := static ##_f_(disp,n) name disp $" "$n; + //g_c_r_hash[r] := n; + return r; + end + + function gdk_window_get_cursor(g:pointer):pointer; + begin + _f_ := static function(g:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); + return ##_f_(g); + end procedure gdk_window_set_cursor(w:pointer;c:pointer); begin _f_ := static procedure(w:pointer;c:pointer);cdecl;external getfuncptrbyname(0,functionname()); @@ -6591,7 +6636,7 @@ end } type tgtk_ctl_object = class(_gtkeventtype) private - + fwindow_cursor; //µ±Ç°µÄcursor FHitwidgetposition; static FsysCursors; Fsyscommand0x12; @@ -6614,9 +6659,9 @@ type tgtk_ctl_object = class(_gtkeventtype) _const := getwin32const(); _wapi := gettswin32api(); FsysCursors := array(); - FsysCursors[0] := _wapi.gdk_cursor_new(2); - FsysCursors[1] := _wapi.gdk_cursor_new(70); - FsysCursors[2] := _wapi.gdk_cursor_new(16); + FsysCursors[0] := _wapi.gdk_cursor_new_from_name(nil,"default") ;//_wapi.gdk_cursor_new(2); + FsysCursors[1] := _wapi.gdk_cursor_new_from_name(nil,"col-resize");//_wapi.gdk_cursor_new(70); + FsysCursors[2] := _wapi.gdk_cursor_new_from_name(nil,"row-resize");//_wapi.gdk_cursor_new(16); end SetHandle(h); FHitwidgetposition := 0; @@ -6682,7 +6727,6 @@ type tgtk_ctl_object = class(_gtkeventtype) end return 0; end - fwindow_cursor; function CallTslVclProc(msg,w,l,P);virtual; //µ÷Óõ½winÏûÏ¢´¦Àí begin CM_CURSORCHANGED := _const.CM_CURSORCHANGED; @@ -6692,12 +6736,13 @@ type tgtk_ctl_object = class(_gtkeventtype) end else begin gfw := class(tUIglobalData).uigetdata("G_F_TWIN_PROC_"); - if gfw then + if gfw then begin r := call(gfw,FHandle,msg,w,l); end if msg = CM_CURSORCHANGED then begin + clearMessageFromGtkMessageQueue(FHandle,CM_CURSORCHANGED); if l<>0 and w<>0 then begin return _wapi.gdk_window_set_cursor(w,l); @@ -6707,32 +6752,31 @@ type tgtk_ctl_object = class(_gtkeventtype) begin global g_show_cursor_window; wd := _Wapi.gtk_widget_get_window(FHandle); - g_show_cursor_window := wd; + g_show_cursor_window := array(FHandle,wd,CM_CURSORCHANGED); FHitwidgetposition := r; clearMessageFromGtkMessageQueue(FHandle,CM_CURSORCHANGED); case r of 10,11:begin - g_show_cursor_window := 0; + //g_show_cursor_window := 0; if fwindow_cursor <> FsysCursors[1] then begin fwindow_cursor := FsysCursors[1]; - AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,FsysCursors[1]); + AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,fwindow_cursor); end end 12,15:begin - g_show_cursor_window := 0; + //g_show_cursor_window := 0; if fwindow_cursor <> FsysCursors[2] then begin fwindow_cursor := FsysCursors[2]; - AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,FsysCursors[2]); + AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,fwindow_cursor); end end 1:begin if fwindow_cursor <> FsysCursors[0] then begin fwindow_cursor := FsysCursors[0]; - //AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,FsysCursors[0]); - AddMessageToGtkMessageQueue(FHandle,_const.WM_SETCURSOR,wd,FsysCursors[0]); + AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,fwindow_cursor); end end else @@ -6746,28 +6790,32 @@ type tgtk_ctl_object = class(_gtkeventtype) FHitwidgetposition := ht; if ht=10 or ht=11 then begin - g_show_cursor_window := 0; + //g_show_cursor_window := 0; if fwindow_cursor <> FsysCursors[1] then begin fwindow_cursor := FsysCursors[1]; - return AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,FsysCursors[1]); + return AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,fwindow_cursor); end return r; end else if ht=12 or ht=15 then begin - g_show_cursor_window := 0; + //g_show_cursor_window := 0; if fwindow_cursor <> FsysCursors[2] then begin fwindow_cursor := FsysCursors[2]; - return AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,FsysCursors[2]); + return AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,fwindow_cursor); end return r; end end if fwindow_cursor<>FsysCursors[0] then begin - fwindow_cursor := FsysCursors[0]; - return AddMessageToGtkMessageQueue(FHandle,_const.WM_SETCURSOR,wd,FsysCursors[0]); - end return r; + fwindow_cursor := FsysCursors[0]; //ÏÂÃæµÄ´ÎÐò¿ÉÄܽ»»» + AddMessageToGtkMessageQueue(FHandle,_const.WM_SETCURSOR,wd,1); + AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,fwindow_cursor); + //el := makelong(1,0); + end + + return r; end end ; end else @@ -6985,6 +7033,7 @@ type tgtk_ctl_object = class(_gtkeventtype) //g_gtk_dragxy := array(integer(e.x_root),integer(e.y_root)); mywidgetmousehit(id,array(integer(e.x_root),integer(e.y_root))); mywidgetmousemovecall(id,array(integer(e.x),integer(e.y))); + return true; end function GSBUTTONRELEASEEVENT(a,b,c,d);virtual; begin @@ -7485,6 +7534,7 @@ type tgtk_ctl_object = class(_gtkeventtype) case mn of GS_ENTER_NOTIFY_EVENT: begin + fwindow_cursor := 0; end GS_DESTROY: begin @@ -7499,7 +7549,7 @@ type tgtk_ctl_object = class(_gtkeventtype) end GS_MOTION_NOTIFY_EVENT: begin - GSMOTIONNOTIFYEVENT(a,b,c,d); + return GSMOTIONNOTIFYEVENT(a,b,c,d); end GS_BUTTON_RELEASE_EVENT: begin @@ -7538,7 +7588,7 @@ type tgtk_ctl_object = class(_gtkeventtype) function GtkBaseEventName();virtual; //°ó¶¨µÄÏûÏ¢ 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(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" + 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,GS_ENTER_NOTIFY_EVENT); //,"set-focus-child" end function CreateWnd(dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nwidth,nheight,hwndparent,hmenu,hinstance,lpParam);virtual; //¹¹Ôì´°¿Ú begin @@ -8752,7 +8802,9 @@ type tgtk_ctl_window_PoPup = class(tgtk_ctl_scroll_window) end function cleinteventmove(a,b,c,d); begin - return inherited GSMOTIONNOTIFYEVENT(self,b,c,d); + //return inherited GSMOTIONNOTIFYEVENT(self,b,c,d); + inherited GSMOTIONNOTIFYEVENT(self,b,c,d); + return false; end function mygsevent(a,b,c,d); begin @@ -9220,7 +9272,37 @@ begin end type _gtkeventtype=class - + static const GDK_C_DEFAULT = "default"; + static const GDK_C_help = "help"; + static const GDK_C_pointer = "pointer"; + static const GDK_C_context_menu = "context-menu"; + static const GDK_C_progress = "progress"; + static const GDK_C_wait = "wait"; + static const GDK_C_cell = "cell"; + static const GDK_C_crosshair = "crosshair"; + static const GDK_C_vertical_text = "vertical-text"; + static const GDK_C_alias = "alias"; + static const GDK_C_copy = "copy"; + static const GDK_C_no_drop = "no-drop"; + static const GDK_C_move = "move"; + static const GDK_C_not_allowed= "not-allowed"; + static const GDK_C_grab = "grab"; + static const GDK_C_grabbing = "grabbing"; + static const GDK_C_all_scroll = "all-scroll"; + static const GDK_C_col_esize = "col-resize"; + static const GDK_C_row_resize = "row_resize"; + static const GDK_C_n_resize = "n-resize"; + static const GDK_C_e_resize = "e-resize"; + static const GDK_C_s_resize = "s-resize"; + static const GDK_C_w_resize = "w_resize"; + static const GDK_C_ne_resize = "ne-resize"; + static const GDK_C_sw_resize = "sw-resize"; + static const GDK_C_se_resize = "se-resize"; + static const GDK_C_nesw_resize = "nesw-resize"; + static const GDK_C_nwse_resize = "nwse-resize"; + static const GDK_C_zoom_in = "zoom-in"; + static const GDK_C_zoom_out = "zoom-out"; + static const GDK_WINDOW_STATE_WITHDRAWN=1; static const GDK_WINDOW_STATE_ICONIFIED=2; static const GDK_WINDOW_STATE_MAXIMIZED=4; diff --git a/funcext/tvclib/utslvclcefinterface.tsf b/funcext/tvclib/utslvclcefinterface.tsf index e7e964e..ac94e69 100644 --- a/funcext/tvclib/utslvclcefinterface.tsf +++ b/funcext/tvclib/utslvclcefinterface.tsf @@ -588,49 +588,54 @@ type cef_string_map_t = class() return ##_f_(map); end end - +{$ifdef linux} type cef_main_args_t=class(tslcstructureobj) private static SSTRUCT; class function getstruct() begin - if not SSTRUCT then - begin -{$ifdef linux} - SSTRUCT := MemoryAlignmentCalculate(array(("argc","int",0),("argv","intptr",0))); -{$else} - SSTRUCT := MemoryAlignmentCalculate(array(("instance","intptr",0))); -{$endif} - end + if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array(("argc","int",0),("argv","intptr",0))); return SSTRUCT; end public -{$ifdef linux} - function create(c,v); + function create(ptr);override; begin - inherited create(getstruct(),0); - argc := c; - argv := v; + inherited create(getstruct(),ptr); end property argc index "argc" read _getvalue_ write _setvalue_; - property argv index "argv" read _getvalue_ write _setvalue_; + property argv index "argv" read _getvalue_ write _setvalue_; +end {$else} +type cef_main_args_t=class(tslcstructureobj) + private + static SSTRUCT; + class function getstruct() + begin + if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array(("instance","intptr",0))); + return SSTRUCT; + end + public function create(ptr) begin inherited create(getstruct(),ptr); end property instance index "instance" read _getvalue_ write _setvalue_; -{$endif} -end -type cef_basetime_t = class(cef_main_args_t) //32bit ¿ÉÄÜÓÐÎÊÌâÐèÒªÐÞÕý +end +{$endif} +type cef_basetime_t = class(tslcstructureobj) //32bit ¿ÉÄÜÓÐÎÊÌâÐèÒªÐÞÕý function create(ptr); begin - inherited; + inherited create(getstruct(),ptr); end - property val index "instance" read _getvalue_ write _setvalue_; - private - instance; + property val index "val" read _getvalue_ write _setvalue_; + private + static SSTRUCT; + class function getstruct() + begin + if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array(("val","intptr",0))); + return SSTRUCT; + end end type cef_base_ref_counted_t=class(tslcstructureobj) private