优化鼠标图标
This commit is contained in:
tslediter 2024-01-03 17:53:48 +08:00
parent 0833d3a150
commit e6dd894873
2 changed files with 139 additions and 52 deletions

View File

@ -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;

View File

@ -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