unit ugtkinterface; interface { 20230810-1616 修改常量 20220128-0900 稳定接口 20210902-0308 稍微整理 } uses utslvclconstant,cstructurelib,utslvclauxiliary,utslvclmemstruct; function _gtkeventcall_();//gtk消息分发 function _gtkidledo_(); //gtk idle消息分发 function _gtk_add_time_msg_(h,m,w,l); function GetGtkEventNameOrId(n); //gtk 事件名称 function getfuncptrbyname(lib,n); type tgtkeventobject =class(tgtk_ctl_object) //gtk对象消息类(测试用) function create(h); begin inherited; end end type GSourceFuncs=class(tslcstructureobj) //gsourcefuncs private static SSTRUCT; function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array( ("prepare","intptr",0), ("check","intptr",0), ("dispatch","intptr",0), ("finalize","intptr",0))); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); end function prepare(source:pointer;tout:integer):integer;cdecl; begin return 1; end function check(source:pointer):integer;cdecl; begin return true; end function dispatch(source:pointer;callback:pointer;user_data:integer):integer;cdecl; begin return true; end procedure finalize(source);cdecl; begin end end type tsgtkapi = class(tgtkapis) function AnsiToWidChar(c); begin if not ifstring(c) then return ""; //return widestring(c); return c; //此处不转换widchar,linux end function GetModuleFileNameExA(); begin end function Comctl32DllGetVersion(); begin end function shell32DllGetVersion(); begin end function GetSystemMetrics(idx); begin global g_w_c_width; case idx of 0x4 : return g_w_c_width; end ; return 24; end function GetCursorInfo_(); begin end function GetMonitorInfoA(); begin end function open_chm(fn,pg); begin if ifstring(pg) and pg then pm := format('kchmviewer %s -showPage %s.htm &',fn,pg); else pm := format('kchmviewer %s &',fn); tsl_gtk_exec_system(pm); end function CreateToolhelp32Snapshot()begin return -1; end; function EnumProcesses_();begin end function ShowWindow(hwd :pointer;f:integer); begin {SW_HIDE := 0x0;SW_SHOWNORMAL := 0x1;SW_NORMAL := 0x1; SW_SHOWMINIMIZED := 0x2;SW_SHOWMAXIMIZED := 0x3;SW_MAXIMIZE := 0x3; 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;} 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"); pcd := gtk_object_get_data_title_height(hwd); gtk_window_move(hwd,x,max(0,y-pcd)); if w>=0 and h>=0 then begin //gtk_window_set_default_size(hwd,w,max(0,h-pcd)); //gtk_widget_set_size_request(hwd,w,max(0,h-pcd)); gtk_window_resize(hwd,w,max(0,h-pcd)); end 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 gtk_widget_grab_focus(cf); //tplev := gtk_widget_get_toplevel(cf); //if tplev then gtk_window_set_focus(tplev,cf); end end end gtk_widget_show(hwd); end return true; end function MessageBoxA(hwnd :pointer;txt:string;cap:string;flag:integer); begin return gtk_MessageBoxA(hwnd,txt,cap,flag); end function IsWindow(h); begin if h>0 or h<0 then begin return IsGtkWidget(h); end end function IsZoomed(hd:pointer) begin return 0; end function GetWindowTextA(h,s,l); begin if not(h>0 or h<0) then return ; if not ifstring(s) then return ; wt := static gtk_window_get_type(); if g_type_check_instance_is_a(h,wt) then begin rs := GtkStringToTsl(gtk_window_get_title(h)); end else begin lbl := g_object_get_data(h,"gtk_layout_label"); if lbl then begin rs := GtkStringToTsl(gtk_label_get_text(lbl)); end else begin et := g_object_get_Data(h,"gtk_layout_editer"); if et then begin rs := GtkStringToTsl( gtk_entry_get_text(h)); end else begin et := g_object_get_Data(h,"gtk_layout_memo"); if et then begin rs := gtk_executeMessageA(h,0xd,0,0); end end end end if rs then begin for i:= 1 to min(length(s),min(length(rs),l)) do begin s[i] := rs[i]; end return i; end end function SetWindowTextA(h,s); begin if not(h>0 or h<0) then return ; if not ifstring(s) then return ; wt := static gtk_window_get_type(); us := TslStringToGtk(s); if g_type_check_instance_is_a(h,wt) then begin gtk_window_set_title(h,us); end else begin return ; lbl := g_object_get_data(h,"gtk_layout_label"); if lbl then begin return gtk_label_set_text(lbl,us); end et := g_object_get_Data(h,"gtk_layout_editer"); if et then begin return gtk_entry_set_text(h,us); end et := g_object_get_Data(h,"gtk_layout_memo"); if et then begin gtk_executeMessageA(h,0xc,0,us); end //et := g_object_get_Data(h,"gtk_layout_memo"); //if et then return gtk_entry_set_text(et,us); end end function GetScrollInfo(hWnd:pointer;x:integer;info:pointer) begin return gtk_GetScrollInfo(hwnd,x,info); end function SetScrollInfo(hwnd:pointer; nBar:integer; lpsi:pointer;redraw:integer) begin return gtk_SetScrollInfo(hwnd,nBar,lpsi,redraw); end function SystemParametersInfoA(uiAction:integer;uiParam:integer; pvParam:pointer; fWinIni:integer); begin if (uiAction = 0x30) and (pvParam>0 or pvParam<0) then begin w := static gdk_screen_width(); h := static gdk_screen_height()-70; rc := new tcrect(pvParam); rc._setvalue_(0,0); rc._setvalue_(1,0); rc._setvalue_(2,w); rc._setvalue_(3,h); end end function GetClientRect(h :pointer;var rec:array of integer); begin if h then begin x0 := g_object_get_data(h,"gtk_layout_width"); pcd := gtk_object_get_data_title_height(h); y0 := g_object_get_data(h,"gtk_layout_height")-pcd; end rec := array(0,0,x0, max(0,y0)); return true; end function GetWindowRect(hwnd :pointer;var rec:array of integer):integer; begin xy := array(0,0); ClientToScreen(hwnd,xy); h := g_object_get_data(hwnd,"gtk_layout_height"); w := g_object_get_data(hwnd,"gtk_layout_width"); pcd := gtk_object_get_data_title_height(hwnd); rec := array(xy[0],xy[1],xy[0]+w,max(0,xy[1]+h-pcd)); end function GetWindowInfo(hwnd :pointer;f:pointer):integer; begin if not(f>0 or f<0 ) then return 0; //info := new TWINDOWINFO(f); end function SetWindowPos(h:pointer;hWndInsertAfter:pointer; X:integer; Y:integer; cx:integer;cy:integer; uFlags:integer); begin //echo "\r\nset window pos:" ,x,"===",y,"=<>=",cx,"===",cy; if 0x400 .& uFlags then begin //echo "border set \r\n"; InvalidateRect(h,nil,false); return ; end if not(h>0 or h<0) then return ; flg := 0; wt := static gtk_window_get_type(); pcd := gtk_object_get_data_title_height(h); if g_type_check_instance_is_a(h,wt) then //主窗口 begin x0 := g_object_get_data(h,"gtk_layout_x"); y0 := g_object_get_data(h,"gtk_layout_y"); if (x>=0 and y>=0) and (x<>x0 or y<>y0) then //窗口位置 begin gtk_window_move(h,x,max(0,y-pcd)); g_object_set_data(h,"gtk_layout_x",x); g_object_set_data(h,"gtk_layout_y",y); flg .|=2; end w0 := g_object_get_data(h,"gtk_layout_width"); h0 := g_object_get_data(h,"gtk_layout_height"); if (cx>=0 and cy>=0) and ( cx<>w0 or cy<>h0) then begin if gtk_window_get_resizable(h) then begin gtk_widget_set_size_request(h,1,1); end else begin gtk_widget_set_size_request(h,cx,max(0,cy-pcd)); end gtk_window_resize(h,cx,max(0,cy-pcd)); g_object_set_data(h,"gtk_layout_width",cx); g_object_set_data(h,"gtk_layout_height",cy); flg .|=1; end if flg then //多发送一次消息 begin Gtk_TrigMoveSizeEvent(h,x,y,cx,cy,flg); end end else if isGtkWidget(h) then begin lot := gtk_widget_get_parent(h); //flg := 0; if lot then begin x0 := g_object_get_data(h,"gtk_layout_x"); y0 := g_object_get_data(h,"gtk_layout_y"); if x<>x0 or y<>y0 then begin gtk_layout_move(lot,h,x,y); g_object_set_data(h,"gtk_layout_x",x); g_object_set_data(h,"gtk_layout_y",y); flg .|=2; end end w0 := g_object_get_data(h,"gtk_layout_width"); h0 := g_object_get_data(h,"gtk_layout_height"); if (cx>=0 and cy>=0) and ( cx<>w0 or cy<>h0) then begin gtk_widget_set_size_request(h,cx,max(0,cy-pcd)); g_object_set_data(h,"gtk_layout_width",cx); g_object_set_data(h,"gtk_layout_height",cy); flg .|=1; end if flg then begin Gtk_TrigMoveSizeEvent(h,x,y,cx,cy,flg); end end end function IsGtkWidget(h); begin if h>0 or h<0 then begin wt := static gtk_widget_get_type(); return g_type_check_instance_is_a(h,wt); end end function gtk_window_showmodal(w); //shomodal begin dialog := w.handle; pt := GetParent(dialog); if (pt) and GTK_WIDGET(pt) then begin if (not gtk_widget_is_toplevel(pt)) then begin pt := gtk_widget_get_toplevel(pt); end //gtk_window_set_type_hint((dialog),0); //gtk_window_set_modal(GTK_WINDOW( dialog),TRUE); //屏蔽掉showmodal gtk_window_set_transient_for( GTK_WINDOW(dialog),GTK_WINDOW(pt)); //gtk_widget_set_sensitive(pt,false); //w.Visible := true; gtk_widget_show(dialog); g_object_set_data(dialog,"is_show_modaling",true); pts := array(); while pt do //获取有效的有效的父窗口 begin if gtk_widget_get_sensitive(pt) then begin gtk_widget_set_sensitive(pt,false); pts[length(pts)] := pt; pt := gtk_window_get_transient_for(pt); end end g_object_set_data(dialog,"modaling_top_parent",pts); return true; end end function gtk_window_endmodal(w); //shomodal begin 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); gtk_window_set_transient_for( GTK_WINDOW(dialog),0); //gtk_window_set_modal(GTK_WINDOW( dialog),false); //屏蔽掉showmodal //w.Visible := false; gtk_widget_hide(dialog); pts := g_object_get_data(dialog,"modaling_top_parent"); if (pts) then begin g_object_set_data(dialog,"modaling_top_parent",0); for i,pt in pts do begin gtk_widget_set_sensitive(pt,true); end end end function GetWindow(wd,t); //获得窗口,需要实现 begin return 0; end function GetParent(h); //获得父窗口 begin if not IsGtkWidget(h) then return 0; if gtk_widget_is_toplevel(h) then return g_object_get_data(h,"gtk_layout_parent"); p := gtk_widget_get_parent(h); if p then return g_object_get_data(p,"gtk_layout_owner"); return 0; end function SetParent(h :pointer;phwnd:pointer); //设置gtk父窗口 begin if h=phwnd then return 0; if not IsGtkWidget(h) then return 0; if gtk_widget_is_toplevel(h) then begin r := g_object_get_data(h,"gtk_layout_parent"); if r<>phwnd then ;//return ; //此处不返回了,继续往下 g_object_set_data(h,"gtk_layout_parent",IsGtkWidget(phwnd)?phwnd:0); if gtk_widget_is_visible(h) then //显示的子窗口处理 begin if GTK_WIDGET(phwnd) then begin if gtk_widget_is_toplevel(phwnd) then pp := phwnd; else pp := gtk_widget_get_toplevel(phwnd); gtk_widget_hide(h); gtk_window_set_transient_for(h,pp); gtk_widget_show(h); end end else begin gtk_window_set_transient_for(h,0); //处理20211020 end return r; end lot :=gtk_widget_get_parent(h); ;//g_object_get_data(h,"gtk_layout_parent");// //原有layout if lot then begin r := g_object_get_data(lot,"gtk_layout_owner"); if r=phwnd then return 0; gtk_container_remove(lot,h); end if not phwnd then return r; lot := g_object_get_data(phwnd,"gtk_layout"); if lot then begin x := g_object_get_data(h,"gtk_layout_x"); y := g_object_get_data(h,"gtk_layout_y"); gtk_layout_put(lot,h,x,y); end return r; end function hittestwidget(h,x,y); begin wd := class(tUIglobalData).uigetdata("TGlobalComponentcache").getwndbyhwnd(h); if wd then return wd.gethitstyle(x,y); return 0; end function GetTopWidgetList(h,x,y,r); begin wd := class(tUIglobalData).uigetdata("TGlobalComponentcache").getwndbyhwnd(h); if wd and wd.Visible and wd.Enabled then //可见移入子窗口判断 begin xy :=array(x,y) ;//wd.ScreenToClient(x,y); if xy[0]>0 and xy[1]>0 and wd.width>xy[0] and wd.height>xy[1] then begin r[length(r)] := array(h,xy); ctls := wd.Controls; for i:= 0 to ctls.count-1 do begin ci := ctls[i]; if (ci is class(TWinControl)) and ci.HandleAllocated() and (not ci.WsPopUp) then begin GetTopWidgetList(ci.Handle,x-ci.left,y-ci.top,r); end end end end end // class(tUIglobalData).uigetdata("TGlobalComponentcache").getwndbyhwnd(hwnd); function Gtk_TrigMoveSizeEvent(h,aleft,atop,AWidth,AHeight,flg); begin gfw := class(tUIglobalData).uigetdata("G_F_TWIN_PROC_"); SWP_NOMOVE := 2; SWP_NOSIZE := 1; WM_WINDOWPOSCHANGED := 0x47; d := new tvclwindowpos_class(0); SizeChanged := flg .& 1; PosChanged := flg .& 2; if SizeChanged then begin {vb := g_object_get_data(h,"gtk_window_vscroll_bar"); hb := g_object_get_data(h,"gtk_window_hscroll_bar"); if vb and gtk_widget_is_visible(vb) then begin d.cx := max(AWidth-10,0); end else d.cx := AWidth; if hb and gtk_widget_is_visible(hb) then begin d.cy := max(AHeight-10,0); end else d.cy := AHeight; } d.cx := AWidth; d.cy := AHeight; D.flags := SWP_NOMOVE; if gfw then call(gfw,h,WM_WINDOWPOSCHANGED,0,d._getptr_); end if PosChanged then begin d.x := ALeft; d.y := ATop; d.flags := SWP_NOSIZE; if gfw then call(gfw,h,WM_WINDOWPOSCHANGED,0,d._getptr_); end if SizeChanged then //这个是不是应该放前面 begin pcd := gtk_object_get_data_title_height(h); gtk_widgetsizechanged(h,max(0,AHeight-pcd),AWidth); end {if SizeChanged then begin _twinproc_(h,0x5,0,makeposition(AWidth,AHeight)); end} if PosChanged then begin if gfw then begin call(gfw,h,0x3,0,makeposition(ALeft,ATop)); end end end function GetCursorPos(var p:array of integer); begin gdk_display_get_pointer(gdk_display_get_default(), nil, x, y, nil) ; p := array(x,y); return true; end function PostQuitMessage(c); begin gtk_main_quit(); return c; end ///////////////////////////////////////// ///////////////////////////////////////// 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]; } 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 return gtk_RegisterClassExA(wc); end function GetClassInfoExA(HH:pointer;lpszClass:string;lpwcx:pointer); begin return gtk_GetClassInfoExtA(hh,lpszClass,lpwcx); end function CreateWindowExA(dwExStyle:integer; lpClassName:string; lpWindowName:string; dwStyle:integer;x:integer;y:integer;nWidth:integer;nHeight:integer; hWndParent:pointer;hMenu:pointer; hInstance:pointer;lpParam:pointer); begin return gtk_createwindowexa(dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nwidth,nheight,hwndparent,hmenu,hinstance,lpParam); end ///////////////////////空接口 function GetModuleHandleA(name:pointer)begin return 1; end; function SetClassLongPtrA(HH:pointer;idx:integer;dwNewLong:pointer)begin end; function GetClassLongPtrA(HH:pointer;idx:integer)begin end; //////////////////////////////////////// function CallWindowProcA(lpPrevWndFunc:pointer;hWnd:pointer;Msg:integer;wParam:pointer;lParam:pointer) begin //默认处理程序 //echo "call defalt handler\r\n"; end function GetSysColor(idx:integer):integer; begin cl := array(13158600,0,13743257,14405055,15790320,16777215,6579300,0,0,0, 11842740,16578548,11250603,14120960,16777215,15790320, 10526880,7171437,0,0,16777215,6908265,14935011,0,14811135,0, 13395456,15389113,15918295,16750899,15790320); r := cl[idx]; if ifnil(r) then return 0xffffff; return r; if idx = 0x5 then begin return 0xffffff; end return 0xf0f0f0; end function SendMessageA(h,msg,w,l); begin return gtk_sendmessagea(h,msg,w,l); end function PostMessageA(h,msg,w,l,d); begin return gtk_postmessagea(h,msg,w,l,d); end function SetWindowLongPtrA(h,n,v); begin if not(h>0 or h<0) then return 0; return gtk_SetWindowLongPtrA(h,n,v); end function GetWindowLongPtrA(h,idx); begin if not(h>0 or h<0) then return 0; return gtk_GetWindowLongPtrA(h,idx); end function DestroyWindow(h:pointer); begin if h>0 or h<0 then begin SetParent(h,0); if IsGtkWidget(h) then begin gtk_widget_destroy(h); end end end function MultiByteToWideChar_a(CodePage:integer;dwFlags:integer;lpMultiByteStr:string;cbMultiByte:integer;var lpWideCharStr:string;cchWideChar:integer):integer; begin end function EnableWindow(w,c); begin //可能还有其他处理 if not(w>0 or w<0) then return false; r := gtk_widget_get_sensitive(w); nc := c?true:false; issetfc := false; if r<>nc then begin if not nc then //似乎还是有点问题 begin cf := GetFocus(); pcf := cf; while pcf do //查找上层窗口 begin if pcf = w then begin g_object_set_data(w,"gtk_focus_widget_handle",cf); issetfc := true; break; end pcf := gtk_widget_get_parent(pcf); end if not issetfc then //保存当前消失的窗口 begin g_object_set_data(w,"gtk_focus_widget_handle",0); end end gtk_widget_set_sensitive(w,nc); global g_current_get_focus_widget; if nc and 0=g_current_get_focus_widget then begin fh := g_object_get_data(w,"gtk_focus_widget_handle") ; if fh and GTK_WIDGET(fh) then begin SetFocus(fh); end end end return r; end function CreateStreamOnHGlobal(hGlobal:pointer;fDeleteOnRelease:integer; var ppstm:pointer):pointer; begin ppstm := ""; return true; end function GetHGlobalFromStream(pstm:string; var phglobal:string):pointer; begin // phglobal := pstm; end function memcpy2(var dst:string;src:string;size_t:integer):pointer; begin //字符串 dst := src; return ;// end function GlobalUnlock(mem :string):integer; begin return mem; end function GlobalSize(menm:pointer):integer; begin return 0;// end function InvalidateRect(hwnd :pointer;rec:array of integer;f:integer):integer; begin h := g_object_get_data(hwnd,"gtk_clientwideget"); if h then begin if ifarray(rec) and ifnumber(rec[0]) and ifnumber(rec[1]) and ifnumber(rec[2]) and ifnumber(rec[3]) then begin gtk_widget_queue_draw_area(h,rec[0],rec[1],rec[2]-rec[0],rec[3]-rec[1]); end else begin gtk_widget_queue_draw(h); end end end function InvalidateRect2(hwnd :pointer;rec:pointer;f:integer):integer; begin InvalidateRect(hwnd,0,f); end //////////////////////////////gdi/////////////////////////////////////////// function cairo_clear_clip(hdc,rc); begin cairo_reset_clip(hdc); cairo_rectangle(hdc,rc[0],rc[1],rc[2]-rc[0],rc[3]-rc[1]); cairo_clip(hdc); end function cairo_clip_rec(hdc,rc); begin cairo_set_line_width(hdc,0); cairo_rectangle(hdc,rc[0],rc[1],rc[2]-rc[0],rc[3]-rc[1]); cairo_clip_preserve(hdc); cairo_stroke(hdc); end function cairo_clear_clip_ploy(hdc,ps); begin cairo_reset_clip(hdc); for i,v in ps do begin if i=0 then cairo_move_to(hdc,v[0],v[1]); else cairo_line_to(hdc,v[0],v[1]); end cairo_line_to(hdc,ps[0,0],ps[0,1]); cairo_clip(hdc); end function SelectObject(hdc :pointer;gdiobj:pointer); begin // if not hdc then return 0; if not(gdiobj>0 or gdiobj<0) then return 0; global gtk_gdi_object_globals; gdiindex := inttostr(gdiobj); obj := gtk_gdi_object_globals[gdiindex]; if not obj then return 0; t := obj[1]; o := obj[0]; //gtk_gdi_object_globals[gdiindex,"hdc"] := hdc; case obj[1] of "pen": begin r := gtk_object_get_data(hdc,"pen"); gtk_object_set_data(hdc,"pen",gdiobj); gtk_object_set_data(hdc,"pen.color",o.color); gtk_object_set_data(hdc,"pen.width",o.width); gtk_object_set_data(hdc,"pen.style",o.style); end "brush": begin r := gtk_object_get_data(hdc,"brush"); gtk_object_set_data(hdc,"brush",gdiobj); gtk_object_set_data(hdc,"brush.color",o.color); gtk_object_set_data(hdc,"brush.style",o.style); end "font": begin r := gtk_object_get_data(hdc,"font"); gtk_object_set_data(hdc,"font",gdiobj); end "rgn": begin x := 0;//gtk_object_get_data(dc,"viewport.x"); y := 0;//gtk_object_get_data(dc,"viewport.y"); r := gtk_object_get_data(hdc,"rgn"); gtk_object_set_data(hdc,"rgn",gdiobj); if obj[2]="poly" then begin ps1 := (new t_points(gdiobj)).get_points(); ps := array(); for i,v in ps1 do begin ps[i] := array(v[0]+x,v[1]+y); end cairo_clear_clip_ploy(hdc,ps); end else begin rc := (new TCRect(gdiobj))._getdata_(); rc[0]+=x; rc[2]+=x; rc[1]+=y; rc[3]+=y; cairo_clear_clip(hdc,rc); end end end ; if r then begin //if ifarray(gtk_gdi_object_globals[inttostr(r)]) then gtk_gdi_object_globals[inttostr(r),"hdc"] := nil; end return r; end function textoutexa(hdc :pointer;X:integer;y:integer;txt:string;len:integer):integer; begin cl := gtk_object_get_data(hdc,"text.color"); // gtk_rgb_color_rgb(cl,r,g,b); // cairo_set_source_rgb(hdc, r, g, b); xb := 0;//gtk_object_get_data(hdc,"viewport.x"); yb := 0;//gtk_object_get_data(hdc,"viewport.y"); ft := gtk_object_get_data(hdc,"font"); global gtk_gdi_object_globals; if ft and ifarray(gtk_gdi_object_globals) then begin fto := gtk_gdi_object_globals[inttostr(ft)]; if fto then fto := fto[0]; if fto then //文字处理 begin ftod := fto._getdata_(); fc := ftod["facename"]; ht := ftod["height"]; wd := ftod["width"]; it := 0;//ftod["italic"]; wt := ftod["weight"]=700; udl := ftod["underline"]; fnotset := false; {fns := static pango_font_family_get_names(); for i,v in fns do begin if v=fc then begin fnotset := true; break; end end } cft := (fnotset?fc:"AR PL UKai CN"); global g_gtk_font_get_size ; cfinfo := g_gtk_font_get_size[cft{,ht},wd,it,wt]; if cfinfo then begin wd := cfinfo["width"]; dkzt := cfinfo["zczw"]; iwd2 := cfinfo["iwd2"]; cairo_select_font_face(hdc,cft,it,wt); cairo_set_font_size(hdc,cfinfo["iwd2"]); end else begin cairo_select_font_face(hdc,cft,it,wt); brk := 0; wd2 := wd*2{-2-wt}; //稍微缩小一点 iwd2 := wd2; brk_Ct := 0; dkzt := false; {ext := new _cairo_text_extents_t(nil); while not brk do begin brk_Ct++; cairo_set_font_size(hdc,iwd2); cairo_text_extents(hdc, U"国", ext._getptr_()); nwd := ext.width; if brk_Ct = 1 then begin cairo_text_extents(hdc, U"i", ext._getptr_()); nwd2 := ext.width; dkzt := (nwd2/nwd)>0.6; //echo "\r\n*********************",(nwd2/nwd); if dkzt then //不支持中文,稍微放大一点 begin wd2 := wd+1+it-wt; iwd2 := wd+1+it-wt; end end if nwd>(wd2+0.04) then begin iwd2-=0.001; end else if nwd<(wd2+0.04) then begin iwd2+=0.001; end else begin brk := true; end echo "\r\n",iwd2,"++++",wd; if brk_Ct>50 then break; end echo "\r\ncalc count:",brk_Ct;} g_gtk_font_get_size[cft,{ht,}wd,it,wt] := array("width":wd,"zczw":dkzt,"iwd2":iwd2); cairo_set_font_size(hdc,iwd2); end end end ht := wd*2; wid := wd; idx := 1 ; tlen := (len<0)?length(txt):(min(len,length(txt))); xp := x+xb; yp := y+yb+ht; ///////////////////背景///////////////////////////////////////// if gtk_object_get_data(hdc,"font.bkmode") = 2 then begin fillbk := true; gtk_rgb_color_rgb(gtk_object_get_data(hdc,"font.bkcolor"),bkr,bkg,bkb); //cairo_fill end //////////////////////////////////////////////////////// if udl then begin cairo_set_line_width(hdc,0.4); end if bytetype(txt,tlen)=1 then //字符类型判断 begin tlen-=1; end txts := array(); txtidx := 0; txti := ""; while idx<=tlen do begin ci := GetChar(txt,idx); idx++; if ci=10 then begin txts[txtidx++] := array(txti,yp,xp); txti := ""; yp+=ht; continue; end if ci=13 then continue; if ci=9 then txti+=" "; else txti+=txt[idx-1]; end if txti then txts[txtidx++] := array(txti,yp,xp); gtk_rgb_color_rgb(cl,pr,pg,pb); for i ,v in txts do begin v0 := v[0]; if not v0 then continue; vl := length(v0); xx := v[2]; yy := v[1]-2; if fillbk then begin cairo_move_to(hdc,xx,yy); cairo_line_to(hdc,xx+wid*vl,yy); cairo_line_to(hdc,xx+wid*vl,yy-ht); cairo_line_to(hdc,xx,yy-ht); cairo_line_to(hdc,xx,yy); cairo_set_source_rgb(hdc, bkr, bkg, bkb); cairo_fill(hdc); end cairo_set_source_rgb(hdc, pr, pg, pb); if udl then begin cairo_move_to(hdc,xx,yy-1); cairo_line_to(hdc,(xx+wid*vl),yy-1); cairo_stroke(hdc); end cairo_move_to(hdc,xx,yy); cairo_show_text(hdc,TslStringToGtk(v0)); end return 1; end Function TextOutA(hdc :pointer;X:integer;y:integer;txt:string;len:integer):integer; begin s := txt; for i,v in array("\r","\n") do begin if pos(v,s) then begin s := replacetext(s,v,""); end end return textoutexa(hdc,x,y,s,min(len,length(s))); end Function DrawTextA(hdc :pointer;txt:string;len:integer;rec:array of integer;fmt:integer):integer; begin //输出字符数 //方位 return DrawTextExA(hdc,txt,len,rec,fmt,0); end Function DrawTextExA(hdc :pointer;txt:string;len:integer;rec:array of integer;fmt:integer;lpdtp:pointer):integer; begin slen := length( txt); if slen<1 then return ; ft := gtk_object_get_data(hdc,"font"); global gtk_gdi_object_globals; if ft and ifarray(gtk_gdi_object_globals) then begin fto := gtk_gdi_object_globals[inttostr(ft)]; if fto then fto := fto[0]; wd := fto._getvalue_("width"); ht := fto._getvalue_("height"); end rl:=0; mxl := 0; rs := 1; for i := 1 to length(txt) do begin vi:=txt[i]; if vi="\r" then continue; if vi="\n" then begin rs++; mxl := max(mxl,rl); rl := 0; continue; end rl++; end ht := ht*rs; mxl := max(mxl,rl); //DT_LEFT := 0; DT_RIGHT := 0x2; //DT_TOP := 0; DT_BOTTOM:= 0x8; DT_CENTER := 0x1; DT_VCENTER:= 0x4; //DT_SINGLELINE:= 0x20; //DT_TABSTOP:= 0x80; rw := rec[2]-rec[0]; nlen := min(len, min(integer(rw/wd),mxl)); sx := rec[0]; rh := rec[3]-rec[1]; sy := rec[1]; if fmt=0 or not(fmt>0 or fmt<0 ) then begin end if (fmt .& DT_CENTER)=DT_CENTER then //处理 begin if nlen = mxl then begin sx +=(rw-(nlen*wd))/2; end end if (fmt .& DT_VCENTER)=DT_VCENTER then //处理 begin if rh>ht then begin sy+=(rh-ht)/2; end end if (fmt .& DT_RIGHT)=DT_RIGHT then //不处理 begin if rw>(nlen*wd) then begin sx := rec[2]-((nlen*wd)); end end if (fmt .& DT_BOTTOM)=DT_BOTTOM then //不处理 begin sy := rec[3]-3-ht; end dht := max(ht-20,0)*0.08;//处理字体过大可能被覆盖的问题 20241012 cairo_save(hdc); x := 0;//gtk_object_get_data(hdc,"viewport.x"); y := 0;//gtk_object_get_data(hdc,"viewport.y"); reci := array(rec[0]+x,rec[1]+y,rec[2]+x,rec[3]+y); cairo_clip_rec(hdc,reci); r := TextOutexA(hdc,sx,sy-dht,txt,slen); cairo_restore(hdc); return r; end Function SetTextColor(hdc :pointer;col:integer):integer; begin gtk_object_set_data(hdc,"text.color",col); return true; end Function SetPixel(dc,x,y,colr); begin if not dc then return ; if ifnumber(x) and ifnumber(y) then begin pc := colr; MoveToEx(dc,x,y); pc := gtk_object_get_data(dc,"pen.color"); pw := gtk_object_get_data(dc,"pen.width"); gtk_object_set_data(dc,"pen.color",colr); gtk_object_set_data(dc,"pen.width",2); LineTo(dc,x+1,y+1); gtk_object_set_data(dc,"pen.color",pc); gtk_object_set_data(dc,"pen.width",pw); return 1; end end function cairo_set_pen_color(dc); begin pc := gtk_object_get_data(dc,"pen.color"); pt := gtk_object_get_data(dc,"pen.style"); if pw>0 then cairo_set_line_width(dc,pw); else cairo_set_line_width(dc,1); if pc=0 then begin if pt=5 then begin cairo_set_source_rgba(dc,1,1,1,0); end else begin cairo_set_source_rgb(dc,0,0,0); end end else begin if pt=5 then begin cairo_set_source_rgba(dc,1,1,1,0); end else begin gtk_rgb_color_rgb(pc,rc,gc,bc); cairo_set_source_rgb(dc,rc,gc,bc); end end end function cairo_set_brush_color(dc); begin brc := gtk_object_get_data(dc,"brush.color"); bst := gtk_object_get_data(dc,"brush.style"); if brc=0 then begin if bst=1 then begin cairo_set_source_rgba(dc,1,1,1,0); end else begin cairo_set_source_rgb(dc,0,0,0); end end else begin if bst=1 then begin cairo_set_source_rgba(dc,1,1,1,0); end else begin gtk_rgb_color_rgb(brc,rc,gc,bc); cairo_set_source_rgb(dc,rc,gc,bc); end end end Function FillRect(dc:pointer;rec:array of integer;br:pointer):integer; begin if not dc then return ; if ifarray(rec) then begin global gtk_gdi_object_globals; if not ifarray(gtk_gdi_object_globals) then gtk_gdi_object_globals := array(); brs := gtk_gdi_object_globals[inttostr(br)]; if not brs then return 0; cl := brs[0].Color; x := 0;//gtk_object_get_data(dc,"viewport.x"); y := 0;//gtk_object_get_data(dc,"viewport.y"); cairo_rectangle(dc, x+rec[0], y+rec[1], rec[2]-rec[0], rec[3]-rec[1]); gtk_rgb_color_rgb(cl,r,g,b); cairo_set_source_rgb(dc,r,g,b); cairo_fill(dc); end end Function InvertRect(dc:pointer;rec:array of integer;br:pointer):integer; begin if not dc then return ; if ifarray(rec) then begin global gtk_gdi_object_globals; if not ifarray(gtk_gdi_object_globals) then gtk_gdi_object_globals := array(); brs := gtk_gdi_object_globals[inttostr(br)]; if not brs then return 0; cl := brs[0].Color; x := 0;//gtk_object_get_data(dc,"viewport.x"); y := 0;//gtk_object_get_data(dc,"viewport.y"); cairo_rectangle(dc, x+rec[0], y+rec[1], rec[2]-rec[0], rec[3]-rec[1]); gtk_rgb_color_rgb(cl,r,g,b); cairo_set_source_rgb(dc,1-r,1-g,1-b); cairo_fill(dc); end end function ReleaseDC(hwd :pointer;hdc:pointer):integer; begin DeleteDC(hdc); end function SelectClipRgn(hdc :pointer;gdiobj:pointer); begin r := SelectObject(hdc,gdiobj); if not(gdiobj) then begin gtk_object_set_data(hdc,"rgn",nil); cairo_reset_clip(hdc); end return r; end function CreatePolygonRgn(ps:array of integer;len:integer;md:integer):pointer; begin global gtk_gdi_object_globals; if ifarray(ps) and mrows(ps)>2 and mcols(ps)=2 then begin p := new t_points(); p.set_points(ps); ptr := p._getptr_(); gtk_gdi_object_globals[inttostr(ptr)] := array(p,"rgn","poly"); return ptr; end end function CreateRectRgn(nLeftRect:integer;nTopRect:integer;nRightRect:integer;nBottomRect:integer):pointer; begin global gtk_gdi_object_globals; p := new TCRect(); p.left := nLeftRect; p.top := nTopRect; p.right := nRightRect; p.bottom := nBottomRect; ptr := p._getptr_(); gtk_gdi_object_globals[inttostr(ptr)] := array(p,"rgn","rect"); return ptr; end function CombineRgn(hrgnDest:pointer;hrgnSrc1:pointer;hrgnSrc2:pointer; fnCombineMode:integer):integer; begin //RGN_ERROR := 0x0;RGN_AND := 0x1;RGN_OR := 0x2;RGN_XOR := 0x3;RGN_DIFF := 0x4;RGN_COPY := 0x5; rd := new TCRect(hrgnDest); rs1 := new TCRect(hrgnSrc1); if fnCombineMode=0x1 then begin rs2 := new TCRect(hrgnSrc2); rd.left := max(rs1.left,rs2.left); rd.top := max(rs1.top,rs2.top); rd.right := min(rs1.right,rs2.right); rd.bottom := min(rs1.bottom,rs2.bottom); end else if fnCombineMode=0x5 then begin rd.left := rs1.left ; rd.top := rs1.top ; rd.right := rs1.right ; rd.bottom := rs1.bottom ; end return ret; end function SetViewportOrgEx(dc:pointer;x:integer;y:integer;var pt:array of integer):integer; begin if not getViewportOrgEx(dc,pt) then return 0; if pt[0]<>0 or pt[1]<>0 then begin cairo_translate(dc,0-pt[0],0-pt[1]); end cairo_translate(dc,x,y); gtk_object_set_data(dc,"viewport.x1",x); gtk_object_set_data(dc,"viewport.y1",y); return 1; end function getViewportOrgEx(dc:pointer;var pt:array of integer):integer; begin if not dc then return 0; pt := array(); pt[0] := gtk_object_get_data(dc,"viewport.x1"); pt[1] := gtk_object_get_data(dc,"viewport.y1"); return 1; end function DeleteObject(gdiobj :pointer);//删除gdi对象 begin global gtk_gdi_object_globals,g_cairo_api; gdiindex := inttostr( gdiobj); r := gtk_gdi_object_globals[gdiindex]; if r then begin //if ifarray(gtk_gdi_object_globals[inttostr(r)]) then gtk_gdi_object_globals[inttostr(r),"hdc"] := nil; reindex(gtk_gdi_object_globals,array(inttostr(gdiobj):nil)); return true; end g_cairo_api.GdipDisposeImage(gdiobj); return 0; end function DestroyIcon(icon:pointer):integer; begin return DeleteObject(icon); end function DestroyCursor(cursor:pointer):integer; begin return DeleteObject(cursor); end function SetActiveWindow(h); begin if not IsGtkWidget(h) then return 0; if gtk_widget_is_toplevel(h) then hh := h; else hh := gtk_widget_get_toplevel(h); if hh then gtk_window_present(hh); end function CreatePen(FS,w,FC); //gtk 模拟 pen begin global gtk_gdi_object_globals; p := new ttgtk_pen(); p.width := w; p.color := FC; p.style := fs; ptr := p._getptr_(); gtk_gdi_object_globals[inttostr(ptr)] := array(p,"pen"); return ptr; //构造画笔 end function CreateSolidBrush(crColor:integer); begin global gtk_gdi_object_globals; p := new ttgtk_brush(); p.color := crColor; ptr := p._getptr_(); gtk_gdi_object_globals[inttostr(ptr)] := array(p,"brush"); return ptr; end function CreateBrushIndirect(lblf:pointer); begin global gtk_gdi_object_globals; p := new ttgtk_brush(); p2 := new ttgtk_brush(lblf); p.color := p2.color; p.style := p2.style; //p.color := crColor; ptr := p._getptr_(); gtk_gdi_object_globals[inttostr(ptr)] := array(p,"brush"); return ptr; end function CreateFontIndirectA(lplf:pointer); begin global gtk_gdi_object_globals; p := new ttgtk_font(); p2 := new ttgtk_font(lplf); for i,v in array("height","width","escapement","orientation","weight","italic","underline","strikeout","charset","outprecision","clipprecision","quality","pitchandfamily","facename") do p._setvalue_(v,p2._getvalue_(v)); ptr := p._getptr_(); gtk_gdi_object_globals[inttostr(ptr)] := array(p,"font"); return ptr; end Function GetTextMetricsA(hdc :pointer;TM:pointer):integer; begin end Function MoveToEx(hdc :pointer;x:integer;y:integer;var point:array of integer):integer; begin xb := 0;//gtk_object_get_data(hdc,"viewport.x"); yb := 0;//gtk_object_get_data(hdc,"viewport.y"); //cairo_move_to(hdc,x+xb,y+yb); xy := gtk_object_get_data(hdc,"movepointto"); if xy then begin point := xy; end else point := array(0,0); gtk_object_set_data(hdc,"movepointto",array(x,y)); end Function LineTo(dc :pointer;x:integer;y:integer):integer; begin xb := 0;//gtk_object_get_data(dc,"viewport.x"); yb := 0;//gtk_object_get_data(dc,"viewport.y"); pw := gtk_object_get_data(dc,"pen.width"); if pw>0 then cairo_set_line_width(dc,pw); else cairo_set_line_width(dc,1); cairo_set_pen_color(dc); cairo_applay_pen_style(dc); //LineTo xy := gtk_object_get_data(dc,"movepointto"); if xy then begin cairo_move_to(dc,xy[0]+xb,xy[1]+yb); end gtk_object_set_data(dc,"movepointto",array(x,y)); cairo_line_to(dc,x+xb,y+yb); cairo_stroke(dc); end //////////////////////////gtk 菜单////////////////// Function CreateMenu():pointer; begin r := gtk_menu_bar_new(); gtk_widget_show(r); return r; end Function CreatePopupMenu():pointer; begin //弹出菜单 r := gtk_menu_new(); gtk_widget_show(r); g_object_set_data(r,"popmenubar",true); return r; end Function DestroyMenu(hMenu:pointer):integer; begin if hMenu and GTK_WIDGET(hMenu) then return gtk_widget_destroy(hMenu); end Function DrawMenuBar(hwd:pointer):integer; //处理菜单栏 begin h :=g_object_get_data(hwd,"gtk_layout_height"); w :=g_object_get_data(hwd,"gtk_layout_width"); pcd := gtk_object_get_data_title_height(hwnd); gtk_widgetsizechanged(hwd,max(0,h-pcd),w); end Function SetMenu(hwd:pointer;hmenu:pointer):integer; //设置菜单栏 begin vb := g_object_get_data(hwd,"gtk_vbox"); if not vb then return ; mb := g_object_get_data(hwd,"menubar"); if mb = hmenu then return ; {if mb and GTK_WIDGET(mb) then begin gist := gtk_container_get_children(mb); ridx := 0; while gist do begin og := new _gslist(gist); dt := og.data; if dt then gtk_container_remove(mb,dt); ridx++; gist := og.next; end gtk_widget_destroy(mb); end} if hmenu then begin g_object_set_data(hwd,"menubar",hmenu); g_object_set_data(hmenu,"menubarwindow",hwd); gtk_box_pack_start(vb,hmenu,0,0,0); gtk_widget_realize(hmenu); //gtk_widget_show_all(hmenu); end else begin g_object_set_data(hwd,"menubar",0); end h :=g_object_get_data(hwd,"gtk_layout_height"); w :=g_object_get_data(hwd,"gtk_layout_width"); pcd := gtk_object_get_data_title_height(hwnd); gtk_widgetsizechanged(hwd,max(0,h-pcd),w); //移除原有窗口 //menubar 添加到窗口 end Function RemoveMenu( hMenu:pointer; uPosition:integer;uFlags:integer):integer; begin mi := gtk_menu_shell_get_by_positon(hmenu,uPosition); if mi then begin g_object_ref(mi); gtk_container_remove(hMenu,mi); return true; end //移除菜单项目 end Function SetMenuItemInfoA( hMenu:pointer; uItem:integer;fByPosition:integer;lpmii:pointer):integer; begin return gtk_SetMenuItemInfoA(hMenu,uitem,fbyposition,lpmii); //添加菜单 end Function InsertMenuItemA( hMenu:pointer;uItem:integer;fByPosition:integer;lpmii:pointer):integer; begin return gtk_insertmenuitema(hMenu,uitem,fbyposition,lpmii); //添加菜单 end Function TrackPopupMenu( hMenu:pointer;uFlags:integer; x:integer; y:integer; nReserved:integer;hWnd:pointer; prcRect: array of integer):integer; begin global g_c_btn_release_event; //echo "\r\n===trackmenu:",hmenu,"===",x,"===",y,"===",nReserved,"===hwnd:",hwnd,"===rect:",tostn(prcRect); if g_object_get_data(hMenu,"popmenubar") then begin g_object_set_data(hMenu,"popmenubarwindow",hWnd); //gtk_menu_popup(hmenu,0,0,0,0,3,0);//弹出 gtk_get_current_event_time() if g_c_btn_release_event then ev := g_c_btn_release_event._getptr_; gtk_menu_popup_at_pointer(hMenu,ev); //gtk_menu_popup_at_rect(hmenu,hWnd,array(x,y,-1,-1),0,0,0); return 1; end else begin end //弹出菜单 end function ClientToScreen(hwnd :pointer;var p:array of integer):integer; // 继续努力 begin if not hwnd then return ; if not IsGtkWidget(hwnd) then return ; p1 := g_object_get_data(hwnd,"motion_xy"); if not ifarray(p1) then p1 := g_object_get_data(1000,"motion_xy"); if ifarray(p1) then begin dx := p1["x_r"]-p1["x"]; dy := p1["y_r"]-p1["y"]; p[0]+=dx; p[1]+=dy; end return true; end function ScreenToClient(hwnd :pointer;var p:array of integer):integer;// 继续努力 begin p1 := g_object_get_data(hwnd,"motion_xy"); if ifarray(p1) then begin dx := p1["x_r"]-p1["x"]; dy := p1["y_r"]-p1["y"]; p[0]-=dx; p[1]-=dy; end return true; end function BeginPaint(hwd :pointer;strc:pointer):pointer; begin psc := new TPAINTSTRUCT(strc); dc := g_object_get_data(hwd,"paint_dc"); rec := g_object_get_data(hwd,"paint_rect"); psc._setvalue_("hdc",dc); psc._setvalue_("rcpaint",array(rec[0],rec[1],rec[0]+rec[2],rec[1]+rec[3])); //{array(0,0,w,h)} return dc; end function EndPaint(hwd :pointer;strc:pointer):integer; begin return 0; end function GetDC(hwd); begin if hwd<0 or hwd>0 then begin hwcr := g_object_get_data(h,"gtk_clientwideget"); if hwcr>0 or hwcr<0 then return gdk_cairo_create(gtk_widget_get_window(hwcr)); end else if hwd=0 then begin return 1; end end function SaveDC(hdc :pointer):integer; begin if not(hdc>0 or hdc<0) then return ; cairo_save(hdc); //需要处理 end function RestoreDC(hdc :pointer;nSavedDC:integer):integer; begin if not(hdc>0 or hdc<0) then return ; cairo_restore(hdc); //需要处理 end function DeleteDC(hdc :pointer):integer; begin if not(hdc>0 or hdc<0) then return ; gtk_object_set_data(hdc); //清空 cairo_destroy(hdc); //需要处理 end function GetTextExtentPoint32A(hdc:pointer;lpString:string;c:integer; psizl:pointer):integer; begin end function GetTextExtentPoint32A2(hdc:pointer;lpString:string;c:integer; var psizl:array of integer):integer; begin psizl := array(0,0); if not(hdc>0 or hdc<0) then return 0; if not( ifstring(lpString) and c>0 and c>=length(lpString)) then return 0; ft := gtk_object_get_data(hdc,"font"); global gtk_gdi_object_globals; wd := 8; ht := 16; if ft then begin fto := gtk_gdi_object_globals[inttostr(ft)]; if fto then fto := fto[0]; if fto then //文字处理 begin fc := fto._getvalue_("facename"); ht := fto._getvalue_("height"); wd := fto._getvalue_("width"); end end psizl[0] := wd*length(lpString); psizl[1] := ht; return 1; end function GetCharWidthA(hdc:pointer;iFirst:integer;iLast:integer;var lpBuffer:array of integer):integer; begin end Function Rectangle(dc :pointer;l:integer;t:integer;r:integer;b:integer):integer; begin x := 0;//gtk_object_get_data(dc,"viewport.x"); y := 0;//gtk_object_get_data(dc,"viewport.y"); pw := gtk_object_get_data(dc,"pen.width"); if pw>0 then cairo_set_line_width(dc,pw); else cairo_set_line_width(dc,1); if pc=0 then begin cairo_set_source_rgb(dc,0,0,0); end else begin gtk_rgb_color_rgb(pc,rc,gc,bc); cairo_set_source_rgb(dc,rc,gc,bc); end cairo_applay_pen_style(dc); cairo_move_to(dc,l+x,t+y); cairo_line_to(dc,r+x,t+y); cairo_line_to(dc,r+x,b+y); cairo_line_to(dc,l+x,b+y); cairo_line_to(dc,l+x,t+y); cairo_set_brush_color(dc); cairo_fill_preserve(dc); cairo_set_pen_color(dc); cairo_stroke(dc); return 1; end Function Ellipse(dc :pointer;l:integer;t:integer;r:integer;b:integer):integer; begin //圆心 //长度 x := 0;//gtk_object_get_data(dc,"viewport.x"); y := 0;//gtk_object_get_data(dc,"viewport.y"); pw := gtk_object_get_data(dc,"pen.width"); if pw>0 then cairo_set_line_width(dc,pw); else cairo_set_line_width(dc,1); mx := (l+r)/2+x; my := (b+t)/2+y; cairo_save(dc); cairo_translate(dc,mx,my); rx := (r-l)/2; ry := (b-t)/2; cairo_scale(dc,1,ry/rx); cairo_applay_pen_style(dc); cairo_move_to(dc,rx,0); cairo_arc(dc, 0, 0, rx, 0, 2 * pi()); cairo_set_brush_color(dc); cairo_fill_preserve(dc); cairo_set_pen_color(dc); cairo_stroke(dc); cairo_restore(dc); //cairo_scale(dc,1,rx/ry); //cairo_translate(dc,0-mx,0-my); return 1; end Function RoundRect(dc :pointer;l:integer;t:integer;r:integer;b:integer;wid:integer;ht:integer):integer; begin xb := 0;//gtk_object_get_data(dc,"viewport.x"); yb := 0;//gtk_object_get_data(dc,"viewport.y"); pw := gtk_object_get_data(dc,"pen.width"); if pw>0 then cairo_set_line_width(dc,pw); else cairo_set_line_width(dc,1); cairo_applay_pen_style(dc); cairo_draw_round_rectangle(dc,l,t,r-l,b-t,wid); cairo_set_brush_color(dc); cairo_fill_preserve(dc); //绘制底色 cairo_set_pen_color(dc); cairo_stroke(dc);//绘制边框 return 1; end Function Chord(hdc :pointer;l:integer;t:integer;r:integer;b:integer;wid:integer;ht:integer):integer; begin x := 0;//gtk_object_get_data(dc,"viewport.x"); y := 0;//gtk_object_get_data(dc,"viewport.y"); pw := gtk_object_get_data(dc,"pen.width"); direct := gtk_object_get_data(dc,"arcdirection"); if pw>0 then cairo_set_line_width(dc,pw); else cairo_set_line_width(dc,1); mx := (l+r)/2+x; my := (b+t)/2+y; cairo_save(dc); cairo_translate(dc,mx,my); rx := (r-l)/2; ry := (b-t)/2; cairo_scale(dc,1,ry/rx); cairo_applay_pen_style(dc); xx1 := nXRadial1-mx; yy1 := (nYRadial1-my); xx2 := nXRadial2-mx; yy2 := (nYRadial2-my); arg1 := getargbyxy(xx1,yy1); arg2 := getargbyxy(xx2,yy2); cairo_move_to(dc,0,0); if direct=2 then begin cairo_arc(dc, 0, 0, rx, arg1, arg2); end else begin cairo_arc(dc, 0, 0, rx, arg2, arg1); end cairo_set_brush_color(dc); cairo_move_to(dc,cos(arg1)*rx,sin(arg1)*rx); cairo_line_to(dc,cos(arg2)*rx,sin(arg2)*rx); cairo_fill_preserve(dc); cairo_set_pen_color(dc); cairo_stroke(dc); cairo_restore(dc); //cairo_scale(dc,1,rx/ry); //cairo_translate(dc,0-mx,0-my); end Function Pie(dc :pointer;l:integer;t:integer;r:integer;b:integer;nXRadial1:integer;nYRadial1:integer;nXRadial2:integer;nYRadial2:integer):integer; begin x := 0;//gtk_object_get_data(dc,"viewport.x"); y := 0;//gtk_object_get_data(dc,"viewport.y"); pw := gtk_object_get_data(dc,"pen.width"); direct := gtk_object_get_data(dc,"arcdirection"); if pw>0 then cairo_set_line_width(dc,pw); else cairo_set_line_width(dc,1); mx := (l+r)/2+x; my := (b+t)/2+y; cairo_save(dc); cairo_translate(dc,mx,my); rx := (r-l)/2; ry := (b-t)/2; cairo_scale(dc,1,ry/rx); cairo_applay_pen_style(dc); xx1 := nXRadial1-mx; yy1 := (nYRadial1-my); xx2 := nXRadial2-mx; yy2 := (nYRadial2-my); arg1 := getargbyxy(xx1,yy1); arg2 := getargbyxy(xx2,yy2); cairo_move_to(dc,0,0); if direct=2 then begin cairo_arc(dc, 0, 0, rx, arg1, arg2); end else begin cairo_arc(dc, 0, 0, rx, arg2, arg1); end cairo_set_brush_color(dc); cairo_move_to(dc,cos(arg1)*rx,sin(arg1)*rx); cairo_line_to(dc,0,0); cairo_line_to(dc,cos(arg2)*rx,sin(arg2)*rx); cairo_fill_preserve(dc); cairo_set_pen_color(dc); cairo_stroke(dc); cairo_restore(dc); //cairo_scale(dc,1,rx/ry); //cairo_translate(dc,0-mx,0-my); end Function SetArcDirection(dc :pointer;direct:integer):integer; begin if direct = 1 or direct = 2 then begin gtk_object_set_data(dc,"arcdirection",direct); end //AD_CLOCKWISE:=2; //AD_COUNTERCLOCKWISE := 1; end private function getargbyxy(x,y_); begin y := y_; pi := pi(); if x=0 and y>=0 then begin return pi/2; end if x=0 and y<=0 then begin return pi*3/2; end if x>=0 and y>=0 then begin ph := 1; end else if x<=0 and y>=0 then begin ph := 2; end else if x<=0 and y<=0 then begin ph := 3; end else if x>=0 and y<=0 then begin ph := 4; end arg := arctan(y/x); if ph=2 or ph = 3 then arg +=pi; return arg; end public //Function Arc(hdc :pointer;nLeftRect:integer;nTopRect:integer;nRightRect:integer;nBottomRect:integer;nXRadial1:integer;nYRadial1:integer;nXRadial2:integer;nYRadial2:integer):integer; Function Arc(dc :pointer;l:integer;t:integer;r:integer;b:integer;nXRadial1:integer;nYRadial1:integer;nXRadial2:integer;nYRadial2:integer):integer; begin x := 0;//gtk_object_get_data(dc,"viewport.x"); y := 0;//gtk_object_get_data(dc,"viewport.y"); pw := gtk_object_get_data(dc,"pen.width"); //brc := gtk_object_get_data(dc,"brush.color"); direct := gtk_object_get_data(dc,"arcdirection"); if pw>0 then cairo_set_line_width(dc,pw); else cairo_set_line_width(dc,1); mx := (l+r)/2+x; my := (b+t)/2+y; cairo_save(dc); cairo_translate(dc,mx,my); rx := (r-l)/2; ry := (b-t)/2; cairo_scale(dc,1,ry/rx); cairo_applay_pen_style(dc); xx1 := nXRadial1-mx; yy1 := (nYRadial1-my); xx2 := nXRadial2-mx; yy2 := (nYRadial2-my); arg1 := getargbyxy(xx1,yy1); arg2 := getargbyxy(xx2,yy2); if direct=2 then begin cairo_arc(dc, 0, 0, rx, arg1, arg2); end else begin cairo_arc(dc, 0, 0, rx, arg2, arg1); end {if brc=0 then begin cairo_set_source_rgb(dc,0,0,0); end else begin gtk_rgb_color_rgb(brc,rc,gc,bc); cairo_set_source_rgb(dc,rc,gc,bc); end cairo_fill_preserve(dc); } cairo_set_pen_color(dc); cairo_stroke(dc); cairo_restore(dc); //cairo_scale(dc,1,rx/ry); //cairo_translate(dc,0-mx,0-my); end Function Polygon(dc :pointer;points:array of integer;n:integer):integer; begin if n<3 then return ; x := 0;//gtk_object_get_data(dc,"viewport.x"); y := 0;//gtk_object_get_data(dc,"viewport.y"); pw := gtk_object_get_data(dc,"pen.width"); if pw>0 then cairo_set_line_width(dc,pw); else cairo_set_line_width(dc,1); //cairo_move_to(dc,points[0]+x,Points[1]+y); cairo_applay_pen_style(dc); for i := 0 to n-1 do begin if i = 0 then cairo_move_to(dc,Points[i,0]+x,Points[i,1]+y); else cairo_line_to(dc,Points[i,0]+x,Points[i,1]+y); end cairo_line_to(dc,Points[0,0]+x,Points[0,1]+y); cairo_set_brush_color(dc); cairo_fill_preserve(dc); cairo_set_pen_color(dc); cairo_stroke(dc); end Function PolyBezier(dc :pointer;points:array of integer;n:integer):integer; begin if length(points)<4 then return 0; x := 0;//gtk_object_get_data(dc,"viewport.x"); y := 0;//gtk_object_get_data(dc,"viewport.y"); pw := gtk_object_get_data(dc,"pen.width"); if pw>0 then cairo_set_line_width(dc,pw); else cairo_set_line_width(dc,1); cairo_set_pen_color(dc); cairo_applay_pen_style(dc); cairo_move_to(dc,points[0,0]+x,Points[0,1]+y); for i := 1 to length(points)-2 step 3 do begin cairo_curve_to(dc,points[i,0]+x,points[i,1]+y,points[i+1,0]+x,points[i+1,1]+y,points[i+2,0]+x,points[i+2,1]+y); end cairo_stroke(dc); return 1; end Function SetPolyFillMode(hdc :pointer;md:integer):integer; begin end Function Polyline(dc :pointer;points:array of integer;n:integer):integer; begin if n<2 then return ; x := 0;//gtk_object_get_data(dc,"viewport.x"); y := 0;//gtk_object_get_data(dc,"viewport.y"); pw := gtk_object_get_data(dc,"pen.width"); if pw>0 then cairo_set_line_width(dc,pw); else cairo_set_line_width(dc,1); cairo_set_pen_color(dc); cairo_applay_pen_style(dc); for i := 0 to n-1 do begin if i = 0 then cairo_move_to(dc,Points[i,0]+x,Points[i,1]+y); else cairo_line_to(dc,Points[i,0]+x,Points[i,1]+y); end cairo_stroke(dc); end Function PolyPolyline(hdc :pointer;points:array of integer;pc:array of integer;n:integer):integer; begin end Function DrawFrameControl(DC:pointer; var LPRECT: array of integer ; dr1 :integer;dr2:integer):integer; begin { DFC_SCROLL := 0x3;DFC_BUTTON := 0x4;DFC_POPUPMENU := 0x5; DFCS_CAPTIONCLOSE := 0x0;DFCS_CAPTIONMIN := 0x1;DFCS_CAPTIONMAX := 0x2; DFCS_CAPTIONRESTORE := 0x3;DFCS_CAPTIONHELP := 0x4;DFCS_MENUARROW := 0x0; DFCS_MENUCHECK := 0x1;DFCS_MENUBULLET := 0x2;DFCS_MENUARROWRIGHT := 0x4; DFCS_SCROLLUP := 0x0;DFCS_SCROLLDOWN := 0x1;DFCS_SCROLLLEFT := 0x2; DFCS_SCROLLRIGHT := 0x3;DFCS_SCROLLCOMBOBOX := 0x5;DFCS_SCROLLSIZEGRIP := 0x8; DFCS_SCROLLSIZEGRIPRIGHT := 0x10;DFCS_BUTTONCHECK := 0x0;DFCS_BUTTONRADIOIMAGE := 0x1; DFCS_BUTTONRADIOMASK := 0x2;DFCS_BUTTONRADIO := 0x4;DFCS_BUTTON3STATE := 0x8; DFCS_BUTTONPUSH := 0x10;DFCS_INACTIVE := 0x100;DFCS_PUSHED := 0x200; DFCS_CHECKED := 0x400;DFCS_TRANSPARENT := 0x800;DFCS_HOT := 0x1000; DFCS_ADJUSTRECT := 0x2000;DFCS_FLAT := 0x4000;DFCS_MONO := 0x8000; } x := 0;//gtk_object_get_data(dc,"viewport.x"); y := 0;//gtk_object_get_data(dc,"viewport.y"); case dr1 of 0x4 : //DFC_BUTTON begin //if dr2 = 0x10 then // DFCS_BUTTONPUSH //begin //end else //cairo_applay_pen_style(dc); cairo_set_dash(dc,array(0),0,0); if dr2 = 0 then // DFCS_BUTTONCHECK begin cairo_set_source_rgb(dc,135/255,135/255,135/255); cairo_set_line_width(dc,5); cairo_rectangle(dc, LPRECT[0]+x, LPRECT[1]+y, LPRECT[2]-LPRECT[0], LPRECT[3]-LPRECT[1]); cairo_stroke_preserve(dc); cairo_set_source_rgb(dc,1,1,1); cairo_fill(dc); end else if dr2 = 0x400 then // DFCS_CHECKED begin cairo_set_source_rgb(dc,135/255,135/255,135/255); cairo_set_line_width(dc,5); cairo_rectangle(dc, LPRECT[0]+x, LPRECT[1]+y, LPRECT[2]-LPRECT[0], LPRECT[3]-LPRECT[1]); cairo_stroke_preserve(dc); cairo_set_source_rgb(dc,1,1,1); cairo_fill(dc); cairo_move_to(dc,LPRECT[0]+x+2,LPRECT[1]+y+(LPRECT[3]-LPRECT[1])/3); cairo_line_to(dc,LPRECT[0]+x+(LPRECT[2]-LPRECT[0])/3,y+LPRECT[3]-2); cairo_line_to(dc,LPRECT[2]+x-2,LPRECT[1]+y+(LPRECT[3]-LPRECT[1])/4); cairo_set_source_rgb(dc,100/255,100/255,100/255); cairo_set_line_width(dc,4); cairo_stroke(dc); end else if dr2 = 0x1 then // DFCS_BUTTONRADIOIMAGE begin cairo_set_source_rgb(dc,135/255,135/255,135/255); cairo_set_line_width(dc,5); l := LPRECT[0]; r := LPRECT[2]; t := LPRECT[1]; b := LPRECT[3]; mx := (l+r)/2+x; my := (b+t)/2+y; cairo_save(dc); cairo_translate(dc,mx,my); rx := (r-l)/2; ry := (b-t)/2; cairo_scale(dc,1,ry/rx); cairo_move_to(dc,rx,0); cairo_arc(dc, 0, 0, rx, 0, 2 * 3.1415926); cairo_stroke_preserve(dc); cairo_set_source_rgb(dc,1,1,1); cairo_fill(dc); cairo_set_line_width(dc,1); cairo_arc(dc, 0, 0, max(rx-5,3), 0, 2 * 3.1415926); cairo_set_source_rgb(dc,100/255,100/255,100/255); cairo_fill(dc); cairo_restore(dc); //cairo_scale(dc,1,rx/ry); //cairo_translate(dc,0-mx,0-my); end else if dr2 = 0x4 then // DFCS_BUTTONRADIO begin cairo_set_source_rgb(dc,135/255,135/255,135/255); cairo_set_line_width(dc,5); l := LPRECT[0]; r := LPRECT[2]; t := LPRECT[1]; b := LPRECT[3]; mx := (l+r)/2+x; my := (b+t)/2+y; cairo_save(dc); cairo_translate(dc,mx,my); rx := (r-l)/2; ry := (b-t)/2; cairo_scale(dc,1,ry/rx); cairo_move_to(dc,rx,0); cairo_arc(dc, 0, 0, rx, 0, 2 * 3.1415926); cairo_stroke_preserve(dc); cairo_set_source_rgb(dc,1,1,1); cairo_fill(dc); cairo_restore(dc); //cairo_scale(dc,1,rx/ry); //cairo_translate(dc,0-mx,0-my); end else begin cairo_set_line_width(dc,4); cairo_rectangle(dc, LPRECT[0]+x, LPRECT[1]+y, LPRECT[2]-LPRECT[0], LPRECT[3]-LPRECT[1]); {cairo_move_to(dc,LPRECT[0]+x,LPRECT[1]+y); cairo_line_to(dc,LPRECT[2]+x,LPRECT[1]+y); cairo_line_to(dc,LPRECT[2]+x,LPRECT[3]+y); cairo_line_to(dc,LPRECT[0]+x,LPRECT[3]+y); cairo_line_to(dc,LPRECT[0]+x,LPRECT[1]+y); cairo_set_source_rgb(dc,200/255,200/255,200/255); cairo_stroke_preserve(dc); cairo_set_source_rgb(dc,221/255,221/255,221/255); cairo_fill(dc);} cairo_set_source_rgb(dc,221/255,221/255,221/255); cairo_fill_preserve(dc); cairo_set_source_rgb(dc,210/255,207/255,205/255); cairo_stroke(dc); end end 0x3 : // DFC_SCROLL begin cairo_set_source_rgb(dc,221/255,221/255,221/255); cairo_set_line_width(dc,0.1); cairo_set_dash(dc,array(0),0,0);//cairo_applay_pen_style(dc); cairo_rectangle(dc, LPRECT[0]+x, LPRECT[1]+y, LPRECT[2]-LPRECT[0], LPRECT[3]-LPRECT[1]); cairo_fill(dc); if dr2 = 0 then // DFCS_SCROLLUP begin cairo_move_to(dc,LPRECT[0]+x+2,LPRECT[1]+y+(LPRECT[3]-LPRECT[1])/1.5); cairo_line_to(dc,LPRECT[0]+x+(LPRECT[2]-LPRECT[0])/2,LPRECT[1]+3); cairo_line_to(dc,LPRECT[2]-2,LPRECT[1]+y+(LPRECT[3]-LPRECT[1])/1.5); cairo_line_to(dc,LPRECT[0]+x+2,LPRECT[1]+y+(LPRECT[3]-LPRECT[1])/1.5); cairo_set_source_rgb(dc,10/255,10/255,10/255); cairo_fill(dc); end else if dr2 = 1 then // DFCS_SCROLLDOWN begin cairo_move_to(dc,LPRECT[0]+x+2,LPRECT[1]+y+(LPRECT[3]-LPRECT[1])/3); cairo_line_to(dc,LPRECT[0]+x+(LPRECT[2]-LPRECT[0])/2,LPRECT[3]-3); cairo_line_to(dc,LPRECT[2]-2,LPRECT[1]+y+(LPRECT[3]-LPRECT[1])/3); cairo_line_to(dc,LPRECT[0]+x+2,LPRECT[1]+y+(LPRECT[3]-LPRECT[1])/3); cairo_set_source_rgb(dc,10/255,10/255,10/255); cairo_fill(dc); end if dr2 = 2 then //DFCS_SCROLLLEFT; begin cairo_move_to(dc,LPRECT[0]+x+(LPRECT[2]-LPRECT[0])*2/3,LPRECT[1]+y+2); cairo_line_to(dc,LPRECT[0]+x+(LPRECT[2]-LPRECT[0])*2/3,LPRECT[3]+y-2); cairo_line_to(dc,LPRECT[0]+x+2,LPRECT[1]+y+(LPRECT[3]-LPRECT[1])/2); cairo_line_to(dc,LPRECT[0]+x+(LPRECT[2]-LPRECT[0])*2/3,LPRECT[1]+y+2); cairo_set_source_rgb(dc,10/255,10/255,10/255); cairo_fill(dc); end else if dr2 = 3 then //DFCS_SCROLLRIGHT; begin cairo_move_to(dc,LPRECT[0]+x+(LPRECT[2]-LPRECT[0])/3,LPRECT[1]+y+2); cairo_line_to(dc,LPRECT[0]+x+(LPRECT[2]-LPRECT[0])/3,LPRECT[3]+y-2); cairo_line_to(dc,LPRECT[2]+x-2,LPRECT[1]+y+(LPRECT[3]-LPRECT[1])/2); cairo_line_to(dc,LPRECT[0]+x+(LPRECT[2]-LPRECT[0])/3,LPRECT[1]+y+2); cairo_set_source_rgb(dc,10/255,10/255,10/255); cairo_fill(dc); end end end end Function SetBkColor(dc:pointer;clrref:integer):integer; begin //font背景色 gtk_object_set_data(dc,"font.bkcolor",clrref); end Function GetBkColor(dc:pointer):integer; begin return gtk_object_get_data(dc,"font.bkcolor"); end Function SetBkMode(dc:pointer;clrref:integer):integer; begin gtk_object_set_data(dc,"font.bkmode",clrref); end Function GetBkMode(dc:pointer):integer; begin return gtk_object_get_data(dc,"font.bkmode"); end Function FillRgn(dc:pointer;rgn:pointer;br:pointer):integer; begin end Function SetTextAlign(dc:pointer;fMode:integer):integer; begin end Function SetWorldTransform(dc:pointer;lpXform:pointer):integer; begin end function UpdateWindow(hwnd :pointer):integer; begin w :=g_object_get_data(hwnd,"gtk_layout_width"); h := g_object_get_data(hwnd,"gtk_layout_height"); pcd :=gtk_object_get_data_title_height(hwnd); gtk_widgetsizechanged(hwnd,max(0,h-pcd),w); return true; end function ClipCursor(rec:array of integer):integer; begin end function SetFocus(hwnd :pointer):pointer; begin cfcs := GetFocus(); if cfcs = hwnd then return 0; return gtk_widget_grab_focus(hwnd); if not(hwnd>0 or hwnd<0) then return 0; ph := hwnd; if not GTK_WIDGET(hwnd) then return 0; if not gtk_widget_is_toplevel(hwnd) then begin ph := gtk_widget_get_toplevel(hwnd); echo "++set not top:",ph,">>>",hwnd; gtk_window_set_focus(ph,hwnd); end else begin echo "\r\n+++set top>>>",ph,">>>",hwnd; gtk_window_set_focus(hwnd,0); end //if not lot then //lot := hwnd; //gtk_widget_grab_focus(lot); return 0; end function GetFocus():pointer; begin global g_current_get_focus_widget; if g_current_get_focus_widget then return g_current_get_focus_widget; return 0; end Function LoadImageA(hinst:pointer;lpszName:string; uType:integer; cxDesired:integer;cyDesired:integer;fuLoad:integer):pointer; begin end function LoadIconA2(t,id); begin end function LoadBitmapA(hin:pointer;lpsz:string):pointer; begin end function LoadBitmapA2(hin:pointer;lpsz:pointer):pointer; begin end Function GetObjectA(hgdiobj:pointer;cbBuffer:integer;lpvObject:pointer):integer; begin bmpobj := new TSHBMP(lpvObject); bmpobj.bmwidth := gdk_pixbuf_get_width(hgdiobj); bmpobj.bmheight := gdk_pixbuf_get_height(hgdiobj); return ; end function GetIconInfo(hIcon:pointer; piconinfo:pointer):integer; begin //icoobj := new TSHICON(lpvObject); //icoobj.bmwidth := gdk_pixbuf_get_width(hgdiobj); //icoobj.bmheight := gdk_pixbuf_get_height(hgdiobj); return ; end function CreateCompatibleDC(hdc :pointer):pointer; begin sf := cairo_image_surface_create(0,100,100); r := cairo_create(sf); return r; return 0; end Function SetCursor(hd:pointer):pointer; begin global g_show_cursor_window; gcw := g_show_cursor_window; if gcw and (hd>0 or hd<0) then begin 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 global g_cairo_api; if not hdc then return ; xb := 0;//gtk_object_get_data(hdc,"viewport.x"); yb := 0;//gtk_object_get_data(hdc,"viewport.y"); img := g_cairo_api.GdipGetbmpSurface(bm); //cairo_set_source(hdc, img); //cairo_pattern_set_extend(cairo_get_source(hdc),1); cairo_set_source_surface(hdc, img, x-rc[0], y-rc[1]); cairo_rectangle(hdc,xb+x,yb+y,rc[2]-rc[0],rc[3]-rc[1]); if flag = 0x8800c6 or flag = 0x4 then begin //echo "\r\nset alopha***********"; //cairo_paint_with_alpha(hdc,0.2); //cairo_set_source_rgba(hdc, 0.6, 0.6, 0.6, 0.5); //cairo_set_operator(hdc, 12); end else begin //cairo_paint_with_alpha(hdc,0); //cairo_paint_with_alpha(hdc,1); //cairo_set_source_rgba(hdc, 1.0, 1.0, 1.0, 0); //cairo_fill(hdc); end cairo_fill(hdc); //cairo_set_operator(hdc, 1); //cairo_set_source_surface(hdc, img, x-rc[0], y-rc[1]); end function drawbitmapstretchtodc(bm,hdc,drect,rc,flag,thdc); begin global g_cairo_api; if not hdc then return ; xb := 0;//gtk_object_get_data(hdc,"viewport.x"); yb := 0;//gtk_object_get_data(hdc,"viewport.y"); img := g_cairo_api.GdipGetbmpSurface(bm); if not img then return ; x := drect[0]; y := drect[1]; p1 := (drect[2]-drect[0])/(rc[2]-rc[0]); p2 := (drect[3]-drect[1])/(rc[3]-rc[1]); if p1<0 or p2<0 then return 0; cairo_save(hdc); cairo_translate(hdc,xb+x,yb+y); cairo_scale(hdc,p1,p2); cairo_set_source_surface(hdc, img, 0, 0); cairo_rectangle(hdc,0,0,rc[2]-rc[0],rc[3]-rc[1]); if flag = 0x8800c6 or flag = 0x4 then //添加alpha处理 begin //echo "\r\nset alopha*******+++****************"; alf := 0.5; cairo_paint_with_alpha(hdc,alf); cairo_set_source_rgba(hdc, 0.6, 0.6, 0.6, alf); end else begin alf := gtk_object_get_data(hdc,"alpha"); if alf>0 then begin cairo_paint_with_alpha(hdc,(alf/255)); end else cairo_paint_with_alpha(hdc,1); cairo_set_source_rgba(hdc, 1.0, 1.0, 1.0, 0); end cairo_fill(hdc); cairo_restore(hdc); //cairo_scale(hdc,1/p1,1/p2); //cairo_translate(hdc,0-xb-x,0-yb-y); end function DrawIcon(hDC:pointer;X:integer;Y:integer;hIcon:pointer):integer; begin global g_cairo_api; if not hdc then return ; xb := 0;//gtk_object_get_data(hdc,"viewport.x"); yb := 0;//gtk_object_get_data(hdc,"viewport.y"); img := g_cairo_api.GdipGetbmpSurface(hIcon); if not img then return 0; cairo_save(hdc); cairo_set_source_surface(hdc, img, x+xb, y+yb); alf := gtk_object_get_data(hdc,"alpha"); if alf>0 then begin cairo_paint_with_alpha(hdc,(alf/255)); end else cairo_paint_with_alpha(hdc,1); cairo_paint(hdc); cairo_restore(hdc); return true; end //////////////////////imagelist///////////////////////////////////////////////////////////////////////// function ImageList_Add(himl:pointer;hbmImage:pointer; hbmMask:pointer):integer; begin global g_cairo_api; if not(himl>0 or himl<0) then return 0; if not(hbmImage>0 or hbmImage<0) then return 0; global g_image_list_caches ; if not ifarray(g_image_list_caches) then g_image_list_caches := array(); sptr := inttostr(himl); obj := g_image_list_caches[sptr,"imglist"] ; if not obj then return ; g_cairo_api.GdipCreateBitmapFromHBITMAP(hbmImage,r1,0); cbmp := class(tUIglobalData).uigetdata("G_T_BITMAP_"); if cbmp then begin bmp := createobject(cbmp); bmp.Handle := r1; obj.Push(bmp); end end function ImageList_AddMasked(himl:pointer;hbmImage:pointer; crMask:integer):integer; begin return ImageList_Add(himl,hbmImage,crMask); end function ImageList_BeginDrag(himlTrack:pointer; iTrack:integer;x:integer;y:integer):integer; begin global g_gtk_drag_window,g_image_list_caches,g_gtk_dragxy ; if not ifarray(g_image_list_caches) then return ; if not(himlTrack>0 or himlTrack<0) then return ; sptr := inttostr(himlTrack); if not g_gtk_drag_window then begin g_gtk_drag_window := new tcustomcontrol(class(tUIglobalData).uigetdata("tuiapplication"));//createobject(G_T_TCUSTOMCONTROL_,class(tUIglobalData).uigetdata("tuiapplication")); g_gtk_drag_window.color := rgb(180,180,180); g_gtk_drag_window.Border := false; g_gtk_drag_window.WsPopUp := true; g_gtk_drag_window.Enabled := false; g_gtk_drag_window.Visible := false; h := g_gtk_drag_window.handle; end cx := g_image_list_caches[sptr,"width"] ; cy := g_image_list_caches[sptr,"height"] ; obj := g_image_list_caches[sptr,"imglist"] ; if not(cx>0 and cy>0) then return ; if obj then begin g_gtk_drag_window.BKBitmap := obj[iTrack]; cx+=2; cy+=2; end g_gtk_drag_window.SetBounds(0,0,cx,cy); g_gtk_dragxy := array(x,y); end function ImageList_DragMove(x:integer;y:integer):integer; begin global g_gtk_drag_window,g_gtk_drag_lock_window,g_gtk_dragxy; if not g_gtk_drag_window then return ; xy := g_gtk_drag_lock_window.ClientToScreen(x,y); SetWindowPos(g_gtk_drag_window.Handle,0,xy[0]-g_gtk_dragxy[0],xy[1]-g_gtk_dragxy[1],-1,-1,0); //SetWindowPos(g_gtk_drag_window.Handle,0,integer(g_gtk_dragxy[0]-g_gtk_drag_window.width/2),integer(g_gtk_dragxy[1]-g_gtk_drag_window.height/2),-1,-1,0); end function ImageList_DragEnter(hwndLock:pointer;x:integer;y:integer):integer; begin global g_gtk_drag_window,g_gtk_drag_lock_window; if not g_gtk_drag_window then return ; g_gtk_drag_lock_window := class(tUIglobalData).uigetdata("TGlobalComponentcache").getwndbyhwnd(hwndLock); if not g_gtk_drag_lock_window then return ; h := g_gtk_drag_window.handle; g_object_set_data(h,"gtk_layout_parent",gtk_widget_get_toplevel(g_gtk_drag_lock_window.handle)); //g_gtk_drag_window.Enabled := false; ImageList_DragMove(x,y); g_gtk_drag_window.show( 0x4); end function ImageList_DragLeave(hwndLock:pointer):integer; begin global g_gtk_drag_window,g_gtk_drag_lock_window; g_gtk_drag_lock_window := nil; if not g_gtk_drag_window then return ; g_gtk_drag_window.show(0); end procedure ImageList_EndDrag(); begin //global g_gtk_drag_window; //g_gtk_drag_window.show(0); end function ImageList_Create(cx:integer; cy:integer; flags:integer; cInitial:integer;cGrow:integer):pointer; begin global g_image_list_caches ; if not ifarray(g_image_list_caches) then g_image_list_caches := array(); obj := new tcstring(8); ptr := obj._getptr_(); sptr := inttostr(ptr); g_image_list_caches[sptr,"obj"] := obj; g_image_list_caches[sptr,"width"] := cx; g_image_list_caches[sptr,"height"] := cy; g_image_list_caches[sptr,"flags"] := flags; g_image_list_caches[sptr,"initial"] := cInitial; g_image_list_caches[sptr,"grow"] := cGrow; g_image_list_caches[sptr,"imglist"] := new tnumindexarray(); return ptr; end function ImageList_Draw(himl:pointer;i:integer;hdcDst:pointer;x:integer;y:integer;fStyle:integer):integer; begin if not(himl>0 or himl<0) then return 0; global g_image_list_caches ; if not ifarray(g_image_list_caches) then return 0; sptr := inttostr(himl); obj := g_image_list_caches[sptr,"imglist"]; if not obj then return ; bmp := obj[i]; if not bmp then return ; cx := g_image_list_caches[sptr,"width"]; cy := g_image_list_caches[sptr,"height"]; drawbitmapstretchtodc(bmp.Handle,hdcDst,array(x,y,x+cx,y+cy),array(0,0,bmp.bmwidth,bmp.bmheight),fStyle,0); end function ImageList_Destroy(himl:pointer):integer; begin if not(himl>0 or himl<0) then return 0; global g_image_list_caches ; if not ifarray(g_image_list_caches) then return 0; reindex(g_image_list_caches,array(inttostr(himl):nil)); end function ImageList_Replace(himl:pointer;id:integer;hbmImage:pointer; hbmMask:pointer):integer; begin global g_cairo_api; if not(himl>0 or himl<0) then return 0; if not(hbmImage>0 or hbmImage<0) then return 0; global g_image_list_caches ; if not ifarray(g_image_list_caches) then return 0; obj := g_image_list_caches[inttostr(himl),"imglist"]; if not obj then return ; cbmp := class(tUIglobalData).uigetdata("G_T_BITMAP_"); if not cbmp then return 0; g_cairo_api.GdipCreateBitmapFromHBITMAP(hbmImage,0,r1); bmp := createobject(cbmp); bmp.Handle := r1; if id=-1 then obj.Push(bmp); else obj.splice(id,1,bmp); end function ImageList_Remove(himl:pointer;id:integer):integer; begin if not(himl>0 or himl<0) then return 0; global g_image_list_caches ; if not ifarray(g_image_list_caches) then return 0; obj := g_image_list_caches[inttostr(himl),"imglist"]; if not obj then return ; if id=-1 then obj.pop(); else obj.splice(id,1); end function ImageList_SetBkColor(himl:pointer;clrBk:integer):integer; begin end function ImageList_LoadImageA2(hi:pointer;lpbmp:pointer;cx:integer;cGrow:integer; crMask:integer;uType:integer;uFlags:integer):pointer; begin end function ImageList_GetBkColor(himl:pointer):integer; begin end function ImageList_GetDragImage(ppt:pointer;pptHotspot:pointer):pointer; function ImageList_GetImageCount(himl:pointer):integer; begin if not(himl>0 or himl<0) then return 0; global g_image_list_caches ; if not ifarray(g_image_list_caches) then return 0; obj := g_image_list_caches[inttostr(himl),"imglist"]; if not obj then return 0; return obj.length(); end function ImageList_SetImageCount(himl:pointer;clrBk:integer):integer; function ImageList_Copy(himlDst:pointer;iDst:integer; himlSrc:pointer;iSrc:integer;uFlags:integer):integer; function ImageList_Duplicate(himl:pointer):pointer; function ImageList_Merge(himl1:pointer;i1:integer;himl2:pointer;i2:integer;dx:integer;dy:integer):pointer; function ImageList_SetDragCursorImage(himlDrag:pointer;iDrag:integer;dxHotspot:integer;dyHotspot:integer):integer; function ImageList_GetImageInfo(himl:pointer; i:integer;pImageInfo:pointer):integer; begin end function ImageList_ReplaceIcon(himl:pointer;i:integer;hicon:pointer):integer; begin return ImageList_Replace(himl,i,hicon,0); end function ImageList_SetIconSize(himl:pointer;cx:integer;cy:integer):integer; function ImageList_GetIconSize(himl:pointer;var cx:integer;var cy:integer):integer; begin global g_image_list_caches ; if not ifarray(g_image_list_caches) then return 0; sptr := inttostr(himl); cx := g_image_list_caches[sptr,"width"]; cy := g_image_list_caches[sptr,"height"]; return 1; end function ImageList_GetIcon(himl:pointer;i:integer;flags:integer):pointer; begin if not(himl>0 or himl<0) then return 0; global g_image_list_caches ; if not ifarray(g_image_list_caches) then return 0; obj := g_image_list_caches[inttostr(himl),"imglist"]; if not obj then return ; r := obj[i]; if r then return r.Handle; return 1; end function ImageList_DrawIndirect(pimldp:pointer):pointer; function ImageList_DragShowNolock(fShow:integer):integer; ////////////////////////////////////////////////////// ////////////////////////clipboard//////////////////////////////////////// function OpenClipboard(h); begin global g_clipbaord_ptr; g_clipbaord_ptr := gtk_clipboard_get(69); return (g_clipbaord_ptr>0 or g_clipbaord_ptr<0); end function EmptyClipboard(); begin c := gtk_clipboard_get(69); gtk_clipboard_clear(c); return 0; end function CloseClipboard(); begin global g_clipbaord_ptr; g_clipbaord_ptr := nil; return true; end function IsClipboardFormatAvailable(fmt); begin global g_clipbaord_ptr; const CF_TEXT=0x1; const CF_BITMAP=0x2; c := g_clipbaord_ptr; bf := gtk_text_buffer_new(0); if not( c>0 or c<0) then return 0; case fmt of CF_TEXT: begin return gtk_clipboard_wait_is_text_available(c); end CF_BITMAP: begin gtk_clipboard_wait_is_image_available(c); end end return false; end function getclipboardtext(clpd); begin global g_clipbaord_ptr; c := g_clipbaord_ptr; r := gtk_clipboard_wait_for_text(c); return GtkStringToTsl(r); end function setclipboardtext(clbd,s); begin global g_clipbaord_ptr; c := g_clipbaord_ptr; if ifstring(s) and s then begin if (IsTextUTF8(s)<>1) then begin gs := TslStringToGtk(s); end else gs := s; return gtk_clipboard_set_text(c,gs,length(gs)); end else if ifnil(s) then begin gtk_clipboard_clear(c); end return 1; end function getclipboardbmp(); begin global g_clipbaord_ptr; c := g_clipbaord_ptr; return gtk_clipboard_wait_for_image(c); end function setclipboardbmp(h); begin global g_clipbaord_ptr; c := g_clipbaord_ptr; gtk_clipboard_set_image(c,h); return 1; //return false; end //////////////////////////////////////end clip board ////////////////////////////////// //////////////////////////////timmer////////////////// function SetTimer(hWnd:pointer; nIDEvent:pointer; uElapse:integer;lpTimerFunc:pointer):integer; begin global g_gtk_ttimer_cache; if not ifarray(g_gtk_ttimer_cache) then g_gtk_ttimer_cache := array(); obj := new ttmstruct(nil);//tslcstructure(sc); sc := array((0,"int",0),(1,"int",0)); rt := g_timeout_add(uElapse,lpTimerFunc,obj._getptr_() ); g_gtk_ttimer_cache[rt] := obj; obj._setvalue_(0,rt); return rt; end function KillTimer(hWnd:pointer; nIDEvent:pointer):integer; begin global g_gtk_ttimer_cache; if not ifarray(g_gtk_ttimer_cache) then return 0; obj := g_gtk_ttimer_cache[nIDEvent] ; if not obj then return 0; g_source_remove(obj._getvalue_(0)); reindex(g_gtk_ttimer_cache,array(nIDEvent:nil)); return true; end //////////////////////////////////////////////////////////////////// function GetOpenFileNameA(LPOPENFILENAMEA:pointer):integer; begin global g_open_file_flag; g_open_file_flag := 1; r := GetSaveFileNameA(LPOPENFILENAMEA); g_open_file_flag := 0; return r; end function GetSaveFileNameA(LPOPENFILENAMEA:pointer):integer; begin global g_open_file_flag; /////////////////////////////////////////////// GTK_RESPONSE_CANCEL := -6; GTK_RESPONSE_ACCEPT := -3; ///////////////////////////////////////// r := false; obj := new TtagOFNA_(LPOPENFILENAMEA); wd := obj._getvalue_("hwndowner"); wd := wd?:nil; if wd then wd := gtk_widget_get_toplevel(wd); mulsel := false; if obj._getvalue_("flags") .& 0x200 then mulsel := true; //echo "\r\n>>>", obj._getvalue_("nmaxfiletitle"); opaction := g_open_file_flag?false:true; //打开或者save cdlg := gtk_file_chooser_dialog_new("file selector",wd,opaction,"open",GTK_RESPONSE_ACCEPT,"cancel",GTK_RESPONSE_CANCEL,nil); if mulsel then begin gtk_file_chooser_set_select_multiple(cdlg,true); end dfdir := obj._getvalue_("lpstrinitialdir"); if dfdir then //默认位置 begin df := my_trim( ReadStringFromPtr(dfdir)); if df then begin //gtk_file_chooser_set_filename(cdlg,TslStringToGtk( df)); gtk_file_chooser_set_filename(cdlg, df); end end if GTK_RESPONSE_ACCEPT=gtk_dialog_run(cdlg)then begin mf := obj._getvalue_("nmaxfile"); if mulsel then begin gfs := gtk_file_chooser_get_filenames(cdlg); gf := ""; ff1 := true; fodpos := 0; ffd := "/"; while gfs do begin if mf1 then ffd := dts[1:fodpos-1]; else ffd := "/"; gf :=ffd; gf+="\0"; end if fodpos 1 then begin bts := ReadBytesFromPtr(obj._getvalue_("lpstrfilter"),obj._getvalue_("nmaxfiletitle")); fndx := ""; for i ,v in bts do begin if bts[i]=0 and bts[i+1]=0 then break; fndx+=chr(bts[i]); end stp := str2array(fndx,"\0")[fidx*2-1]; for i := length(stp) downto 1 do begin if stp[i] = "." then begin stype := stp[i:]; end end for i := length(gf) downto 1 do begin gfi := gf[i]; if gfi="/" then begin gf+=stype; break; end else if gfi = "." then begin break; end end end end if gf then begin fptr := obj._getvalue_("lpstrfile"); gf+="\0"; WriteStringToPtr(fptr,gf,length(gf)); {//gf := GtkStringToTsl( gf); bts := zeros(length(gf)+1); for i := 1 to length(gf) do begin bts[i-1] := ord(gf[i]); end WriteBytesToPtr(fptr,bts);} r := true; end end gtk_widget_destroy(cdlg); return r; end function ChooseFontA(LOGFONTA:pointer):integer; begin obj := new ttagCHOOSEFONTA(LOGFONTA); lgobj := obj._getvalue_("lplogfont"); ht := lgobj._getvalue_("height"); hts := ""; if ht>5 then hts := inttostr(ht); ss := my_trim(lgobj._getvalue_("facename"))+" "+(lgobj._getvalue_("italic")?"Italic":"")+" "+((lgobj._getvalue_("weight")=700)?"Bold":"") + " "+ hts;; cdlg := gtk_font_selection_dialog_new("font select"); gtk_font_selection_dialog_set_preview_text(cdlg,"test fonttext"); gtk_font_selection_dialog_set_font_name(cdlg,TslStringToGtk(ss)); if gtk_dialog_run(cdlg)=-5 then //确定 begin s := GtkStringToTsl( gtk_font_selection_dialog_get_font_name(cdlg)); fns := static pango_font_family_get_names(); for i,v in fns do begin if pos(v,s)=1 then begin lgobj._setvalue_("facename",GtkStringToTsl(v)); if pos("Italic",s) then begin lgobj._setvalue_("italic",1); end else begin lgobj._setvalue_("italic",0); end if pos("Bold",s) then begin lgobj._setvalue_("weight",700); end else begin lgobj._setvalue_("weight",400); end nms := inttostr(0->9); for j := 1 to length(s) do begin if s[j] in nms then begin nm := s[j]; for jj:= j+1 to length(s) do begin if s[jj] in nms then begin nm+=s[jj]; end else break; end break; end end if nm then begin ht := strtoint(nm); lgobj._setvalue_("height",ht); lgobj._setvalue_("width",integer(ht/2)); end break; end end r := true; end gtk_widget_destroy(cdlg); return r; end function ChooseColorA(LOGFONTA:pointer):integer;//颜色选择 begin obj := new ttagCHOOSECOLORA(LOGFONTA); cdlg := gtk_color_selection_dialog_new("color select dialog"); /////////////////////////////////////////////////////////////////////// //btnptr := tsl_gtk_color_selection_property(cdlg); //获得位置 //cpbtns := new Tintptr(btnptr); //cbtnobj := cpbtns._getvalue_(0); cbtnobj := gtk_color_selection_dialog_get_color_selection(cdlg); ///////////////////////////////////////////////////////////////// color := static new _Gdkrgba(); rc := obj.rgbresult ; color.set_c(rc); //gtk_color_selection_set_has_opacity_control(cbtnobj,true); gtk_color_selection_set_has_palette(cbtnobj,true); gtk_color_selection_set_current_rgba(cbtnobj,color._getptr_()); r := gtk_dialog_run(cdlg); //rt := Gtk_dlg_get_response_name_by_id(r); gtk_color_selection_get_current_rgba(cbtnobj,color._getptr_()); obj.rgbresult := color.get_c(); gtk_widget_destroy(cdlg); return r=-5; end function SHBrowseForFolderA(LPITEMIDLIST:pointer):pointer; begin /////////////////////////////////////////////// GTK_RESPONSE_CANCEL := -6; GTK_RESPONSE_ACCEPT := -3; ///////////////////////////////////////// obj := new TBrowseinfoA_(LPITEMIDLIST); wd := obj._getvalue_("hwndowner"); wd := wd?:nil; if wd and not(gtk_widget_is_toplevel(wd)) then wd := gtk_widget_get_toplevel(wd); //top level r := 0; cdlg := gtk_file_chooser_dialog_new("folder selector",wd,2,"open",GTK_RESPONSE_ACCEPT,"cancel",GTK_RESPONSE_CANCEL,0); dir := obj._getvalue_("pidlroot"); if dir then //默认位置 begin df := (ReadStringFromPtr(dir)); if df then begin //gtk_file_chooser_set_filename(cdlg,TslStringToGtk( df)); gtk_file_chooser_set_filename(cdlg,( df)); end end if GTK_RESPONSE_ACCEPT=gtk_dialog_run(cdlg) then begin //r := GtkStringToTsl( gtk_file_chooser_get_filename(cdlg)); r := ( gtk_file_chooser_get_filename(cdlg)); end gtk_widget_destroy(cdlg); return r; end function SHGetPathFromIDListA(LPBROWSEINFOA:pointer;var buf:string ):integer; begin for i := 1 to length(LPBROWSEINFOA) do begin buf[i] := LPBROWSEINFOA[i]; end buf[i+1] := 0; return true; end function ILCreateFromPathA(pszPath:string):pointer; begin mt := unit(cstructurelib).get_mem_mgr(); len := length(pszPath)+1; bts := zeros(n); for i:= 1 to len-1 do bts[i-1] :=ord(pszPath[i]); r := mt.tmalloc(len); WriteBytesToPtr(r,bts); return r; end procedure ILFree(pidl:pointer); begin if pidl>0 or pidl<0 then begin mt := unit(cstructurelib).get_mem_mgr(); mt.tfree(pidl); end end //caret 插入符号 处理 function drawcaret(h,xy,f); begin global g_caret_object; ct := g_caret_object;//g_object_get_data(h,"gtk_window_caret"); if f=1 then //清除 begin if g_object_get_data(ct,"isshow") then return ; end /////会到以前的处理///////////////////////////// if f=-1 then begin if g_object_get_data(ct,"isshow") then begin g_object_set_data(ct,"isshow",0); gtk_widget_hide(ct); end else begin g_object_set_data(ct,"isshow",true); gtk_widget_show(ct); end end else if f = 1 then begin g_object_set_data(ct,"isshow",true); gtk_widget_show(ct); end end private g_gtk_caret_cache_timer; function docarettime(p:pointer):integer;cdecl; begin global g_current_get_focus_widget; h := g_current_get_focus_widget; if not h then return 1; if not g_object_get_data(h,"caretshow") then return 1; GetCaretPos(xy); drawcaret(h,xy,-1); return 1; end public function CreateCaret(hWnd :pointer;hBitmap:pointer;nWidth:integer;nHeight:integer):integer; begin global g_Caret_Blink_Time,g_caret_object; if not(hwnd>0 or hwnd<0) then return 0; //if gtk_widget_is_toplevel(hwnd) then pw := hwnd; //else pw := gtk_widget_get_toplevel(hwnd); if not g_gtk_caret_cache_timer then begin Fscrolltimedo := makeinstance(thisfunction(docarettime)); g_gtk_caret_cache_timer:= new ttmstruct(nil); rt := g_timeout_add(g_Caret_Blink_Time,Fscrolltimedo,g_gtk_caret_cache_timer._getptr_() ); g_gtk_caret_cache_timer._setvalue_(0,rt); end h := g_caret_object; if not h then begin h := gtk_window_new(1); c := new _GdkColor(nil); c.SetRgb(0,0,0); gtk_widget_modify_bg(h,0,c._getptr_()); gtk_window_move(h,0,0); g_caret_object := h; end if nWidth>=0 and nHeight>=0 then begin g_object_set_data(h,"width_c",nWidth); g_object_set_data(h,"heigt_c",nHeight); gtk_widget_set_size_request(h,nWidth,nHeight); gtk_window_resize(h,nWidth,nHeight); end //gtk_window_set_transient_for(h,pw); return h; end function DestroyCaret():integer; begin global g_current_get_focus_widget,g_caret_object; hwnd := g_current_get_focus_widget; if not(hwnd>0 or hwnd<0) then return ; if not IsGtkWidget(hwnd) then return ; g_object_set_data(hwnd,"caretshow",0); //ct := g_object_get_data(hwnd,"gtk_window_caret"); gtk_widget_hide(g_caret_object); return ; // 获得focus end function SetCaretPos(x:integer;y:integer):integer; begin global g_current_get_focus_widget,g_caret_object; hwnd := g_current_get_focus_widget; if IsGtkWidget(hwnd) then begin crt := g_caret_object; GetCaretPos(xy); if crt then //处理此处 begin gtk_object_set_data(hwnd,"caret_x_pos",x); gtk_object_set_data(hwnd,"caret_y_pos",y); p := array(x,y); ClientToScreen(hwnd,p); if gtk_widget_is_toplevel(hwnd) then pw := hwnd; else pw := gtk_widget_get_toplevel(hwnd); if GTK_IS_WINDOW(pw) then begin gtk_window_set_transient_for(crt,pw); end gtk_window_move(crt,p[0],p[1]); end if xy[0]<>x then drawcaret(hwnd,xy,1); end return ; end function GetCaretPos(lp:array of integer):integer; begin global g_current_get_focus_widget; hwnd := g_current_get_focus_widget; if IsGtkWidget(hwnd) then begin x := gtk_object_get_data(hwnd,"caret_x_pos"); y := gtk_object_get_data(hwnd,"caret_y_pos"); lp := array(x,y); return ; end lp := array(0,0); return ; end function HideCaret(hwnd :pointer):integer; begin // 获得focus widget if not(hwnd>0 or hwnd<0) then return ; if not IsGtkWidget(hwnd) then return ; global g_caret_object; ct := g_caret_object;//g_object_get_data(hwnd,"gtk_window_caret"); g_object_set_data(hwnd,"caretshow",0); if ct then gtk_widget_hide(ct); return ; end function ShowCaret(hwnd :pointer):integer; begin if not(hwnd>0 or hwnd<0) then return ; if not IsGtkWidget(hwnd) then return ; g_object_set_data(hwnd,"caretshow",1); return 1; end function GetCaretBlinkTime():integer; begin global g_Caret_Blink_Time; return g_Caret_Blink_Time; end function SetCaretBlinkTime(uMSeconds :integer):integer; begin global g_Caret_Blink_Time; if uMSeconds>100 and uMSeconds<> g_Caret_Blink_Time then begin g_Caret_Blink_Time := integer(uMSeconds); end end Function WinExec(lpCmdLine:string;nCmdShow:integer):integer; begin end; function Shell_NotifyIconA(dwMessage:integer; lpData:pointer):integer; begin end function SetForegroundWindow(hwd :pointer):integer; begin end function BringWindowToTop(hwd :pointer); begin SetActiveWindow(hwd); end function GetWindowHandleByPID(); begin end function AllowSetForegroundWindow(hwd :pointer); begin end function ForegroundWindow(hwnd); begin SetActiveWindow(hwd); end //socket { function socket(af:integer;tp:integer;protocol:integer):pointer;begin end function WSAStartup(af:SHORT;DA:pointer):integer;begin end function WSACleanup():integer;begin end function htonl(hostlong:integer):integer;begin end function htons(hostshort:short):short;begin end function ntohs(hostshort:short):short;begin end function bind(s:pointer;name:pointer;len:integer):integer;begin end function accept(s:pointer;name:pointer;var len:integer):pointer;begin end function send(s:pointer;bufer:string;len:integer;flag:integer):integer;begin end function recv(s:pointer;var bufer:string;len:integer;flag:integer):integer;begin end function listen(s:pointer;port:integer):integer;begin end function closesocket(s:pointer):integer;begin end function connect(s:pointer;name:pointer;len:integer):integer;begin end function inet_addr(s:string):integer;begin end function WSAGetLastError():integer;begin end function inet_ntoa(ad:integer):string;begin end function shutdown(s:pointer;how:integer):integer;begin end function WSAAsyncSelect(s:pointer;hWnd:pointer;wMsg:integer;lEvent:integer):integer;begin end function ioctlsocket(s:pointer;cmd:integer;var argp:integer):integer;begin end function setsockopt(s:pointer;level:integer;optname:integer;optval:string;optlen:integer):integer;begin end function getsockopt(s:pointer;level:integer;optname:integer;var optval:string;var optlen:integer):integer;begin end } end implementation function gettswin32api(); begin global G_O_TSWIN32API_; return G_O_TSWIN32API_; end function my_trim(s); begin if not ifstring(s) then return ""; for i:= 1 to length(s) do begin if s[i]="\0" then begin if i=1 then return ""; return s[1:(i-1)]; end end return s; end /////////////////////////////////////////////////////////////////////////// type TGtkList = class( _gslist) //gtk链表类 function create(ptr); begin inherited; end end type t_points=class(tslcstructureobj) private static fpoints; static SSTRUCT; function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array( (0,"int",0))); return SSTRUCT; end public function create(ptr) begin if not ifarray(fpoints) then fpoints := array(); inherited create(getstruct(),ptr); end function set_points(d); begin p := _getptr_(); if p then begin //_setvalue_(0,length(d)); fpoints[inttostr(p)] := d; end end function get_points(); begin p := _getptr_(); if p then begin return fpoints[inttostr(p)]; end end end type ttmstruct=class(tslcstructureobj) {** @explan(说明)矩形区域内存分配 %% **} private static SSTRUCT; function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array( (0,"int",0), (1,"int",0))); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); end end type Tintptr=class(tslcstructureobj) {** @explan(说明)矩形区域内存分配 %% **} private static SSTRUCT; function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array( (0,"intptr",0))); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); end end type tmenuitemobject = class(tgtk_ctl_object) //gtk菜单对象类 function create(h); begin inherited; Connect("activate",thisfunction(mactivate)); Connect("destroy",thisfunction(mdestroy)); end lpmii; function mactivate(); begin h := handle; mid := _wapi.g_object_get_data(h,"menuid"); if mid then begin while h do begin hwd := _Wapi.g_object_get_data(h,"popmenubarwindow"); if hwd then begin r := _wapi.gtk_postmessagea(hwd,_const.WM_COMMAND,makelong(mid,0),0,0); _wapi.g_object_set_data(h,"popmenubarwindow",0); return r; end hwd := _wapi.g_object_get_data(h,"menubarwindow"); if hwd then //主菜单 begin //echo "\r\n============hwd is find\r\n"; r := _wapi.gtk_postmessagea(hwd,_const.WM_COMMAND,makelong(mid,0),0,0); //echo "send main menu command:"; return r; end h := _wapi.g_object_get_data(h,"pmenu"); end end end function mdestroy(); begin //echo "\r\nmenu destroyed"; end end type tgtkapis = class(t_cairo_api) //gtk对象api接口 procedure cairo_set_source_rgb(c:pointer;r:double;g:double;b:double); begin v := gtk_object_get_data(c,"alpha") ; if v>0 and v<255 then begin return cairo_set_source_rgba(c,r,g,b,(v/255)); end return class(t_cairo_api).cairo_set_source_rgb(c,r,g,b); end function gtk_object_set_data(h,n,v); //保存数据 begin if not(h>0 or h<0) then return 0; global gtk_object_data_values_global; if not ifarray(gtk_object_data_values_global) then gtk_object_data_values_global := array(); if ifnil(n) then reindex(gtk_object_data_values_global,array(inttostr(h):nil)); else if ifarray(n) then begin gtk_object_data_values_global[inttostr(h)] := n; end else gtk_object_data_values_global[inttostr(h),n] := v; //echo tostn(gtk_object_data_values_global); end function gtk_object_get_data_title_height(h); //获取标题栏高度 begin global g_w_c_width; return gtk_object_get_data(h,"gtk_wnd_hs_caption")?g_w_c_width:0; end function gtk_object_get_data(h,n); //获得数据 begin if not(h>0 or h<0) then return 0; global gtk_object_data_values_global; if not ifarray(gtk_object_data_values_global) then return 0; if ifnil(n) then begin r := gtk_object_data_values_global[inttostr(h)]; if not ifarray(r) then r := array(); return r; end r := gtk_object_data_values_global[inttostr(h),n]; if ifnil(r) then return 0; return r; end function gtk_SetMenuItemInfoA(hMenu,uitem,fbyposition,lpmii); //菜单操作 begin //return ; _const := GetWin32Const(); it := gtk_menu_shell_get_by_positon(hMenu,uitem); if not it then return 0; lpm := new tmenuStruct(lpmii); msk := lpm.fmask; st := lpm.fstate; ss := " "; needset := false; if (msk .& _const.MIIM_STRING)=_const.MIIM_STRING then begin c := lpm.getdwtypedata(); gtk_object_set_data(it,"caption",c); needset := true; end if _const.MIIM_STATE =(msk .& _const.MIIM_STATE) then begin if (_const.MF_DISABLED = (st .& _const.MF_DISABLED)) then begin gtk_widget_set_sensitive(it,false); end else if (_const.MF_ENABLED = (st .& _const.MF_ENABLED)) then //是否有效 begin gtk_widget_set_sensitive(it,true); end if ((st .& _const.MF_CHECKED)= _const.MF_CHECKED) then //是否check begin gtk_object_set_data(it,"checked",1); needset := true; end else if ((st .& _const.MF_UNCHECKED)= _const.MF_UNCHECKED) then //是否check begin gtk_object_set_data(it,"checked",0); needset := true; end end if needset then begin c := my_trim(gtk_object_get_data(it,"caption")); if gtk_object_get_data(it,"checked") then begin gtk_menu_item_set_label(it,TslStringToGtk("[√]"+c)); end else gtk_menu_item_set_label(it,TslStringToGtk(ss+c)); end if (msk .& _const.MIIM_SUBMENU)=_const.MIIM_SUBMENU then //下一级菜单 begin gtk_menu_item_set_submenu(it,lpm.hsubmenu); g_object_set_data(it,"menuid",0); end {else begin echo "\r\n seet sub menuid: ",lpm.wid; echo " odid:",g_object_get_data(it,"menuid"),"***"; //g_object_set_data(it,"menuid",lpm.wid); end} return 1; end function gtk_insertmenuitema(hMenu,uitem,fbyposition,lpmii);//菜单操作 begin _const := GetWin32Const(); lpm := new tmenuStruct(lpmii); msk := lpm.fmask; ft := lpm.ftype; st := lpm.fstate; ss := " "; c := my_trim(lpm.getdwtypedata())?:""; if ft = _const.MFT_SEPARATOR then //分割 begin it := gtk_separator_menu_item_new(); end else begin //文本 //it := gtk_check_menu_item_new_with_label(c);//2 if ((st .& _const.MFS_CHECKED)= _const.MFS_CHECKED) then begin it := gtk_menu_item_new_with_label(TslStringToGtk("[√]"+c)); gtk_object_set_data(it,"checked",1); end else begin gtk_object_set_data(it,"checked",0); it := gtk_menu_item_new_with_label(TslStringToGtk(ss+c)); end end gtk_object_set_data(it,"caption",c); gtk_widget_show(it); new tmenuitemobject(it); g_object_set_data(it,"pmenu",hMenu); gtk_menu_shell_insert(hMenu,it,uitem); if st .& _const.MFS_DISABLED then //是否有效 begin gtk_widget_set_sensitive(it,false); end else gtk_widget_set_sensitive(it,true); cid := lpm.wid; if msk .& _const.MIIM_SUBMENU then //下一级菜单 begin gtk_menu_item_set_submenu(it,lpm.hsubmenu); g_object_set_data(lpm.hsubmenu,"pmenu",hMenu); g_object_set_data(it,"menuid",0); end else begin g_object_set_data(it,"menuid",cid); end end function gtk_widgetsizechanged(hwnd,h,w); //大小改变 begin return class(tgtk_ctl_object).widgetsizechangeda(hwnd,h,w) ; end function getDefWindowProcA(); begin return 0; end function getvclwindowprocA(); begin return 0; end function gtk_GetScrollInfo(hwnd,nBar,lpsi); //滚动条信息 begin //获得scroll return class(tgtk_ctl_object).getscrollinfoa(hwnd,nBar,lpsi) ; end function gtk_SetScrollInfo(hwnd, nBar, lpsi,redraw);//设置滚动条 begin //设置scroll return class(tgtk_ctl_object).SetScrollInfoa(hwnd, nBar, lpsi,redraw) ; end function gtk_postmessagea(h,msg,w,l,d); //post模拟 begin AddMessageToGtkMessageQueue(h,msg,w,l,d); end function gtk_sendmessagea(h,msg,w,l); //send 模拟 begin return class(tgtk_ctl_object).CallGtkWinProc(h,msg,w,l); end function gtk_SetWindowLongPtrA(h,n,v); //setlong begin return class(tgtk_ctl_object).SetWindowLongPtrA(h,n,v); end function gtk_GetWindowLongPtrA(h,idx); //getlong begin return class(tgtk_ctl_object).GetWindowLongPtrA(h,idx); end function gtk_executeMessageA(h,msg,w,l); //执行消息 begin return class(tgtk_ctl_object).executeMessageA(h,msg,w,l); end function gtk_addMessageQueue(FHandle,msg,wparam,lparam,d); begin return AddMessageToGtkMessageQueue(FHandle,msg,wparam,lparam,d); end function GetKeyState(key); //按键状态 begin global g_gtk_keytable; if g_gtk_keytable then begin if key in array(0x10,0x11,0x12) then begin r := g_gtk_keytable[key]; if r>=0 then return r; end end ; end function GetAsyncKeyState(key);//鼠标按键状态 begin global g_gtk_buttontable; if g_gtk_buttontable then begin // case key of 1: begin if g_gtk_buttontable[0] then return _shl(1,15); end 2: begin if g_gtk_buttontable[1] then return _shl(1,15); end end ; end end function TslStringToGtk2(s); //ascii转utf8 begin return ansitoutf8(s); end function TslStringToGtk(s); //ascii转utf8 begin return ansitoutf8(s); global g_ansi_unit_cache ; r := g_ansi_unit_cache[s]; if ifnil(r) then begin r := ansitoutf8(s); g_ansi_unit_cache[s] := 1; //echo "\r\ntrans:",length(trim(s))," ",r;//" >>",s; end return ansitoutf8(s); return r; end function GtkStringToTsl(s); //ascii转utf8 begin return utf8toansi(s); end function gtk_MessageBoxA(hd,txt,title,flag); //messagebox模拟 begin flag := flag .& 7; if flag = 0 then begin r := tsl_gtk_messagebox_b(TslStringToGtk(txt),TslStringToGtk(title),hd,U"确定",1,"b",0,"c",0); if r=1 then return 1; return 0; end else if flag = 1 then begin r := tsl_gtk_messagebox_b(TslStringToGtk(txt),TslStringToGtk(title),hd,U"确定",1,U"取消",1,"c",0); if r=1 then return 1; else return 2; end else if flag = 2 then begin r := tsl_gtk_messagebox_b(TslStringToGtk(txt),TslStringToGtk(title),hd,U"终止",1,U"重试",1,U"忽略",1); case r of 1: return 3; 2: return 4; 0,3:return 5; end end else if flag = 3 then begin r := tsl_gtk_messagebox_b(TslStringToGtk(txt),TslStringToGtk(title),hd,U"是",1,U"否",1,U"取消",1); case r of 1: return 6; 2: return 7; 0,3:return 2; end end else if flag =4 then begin r := tsl_gtk_messagebox_b(TslStringToGtk(txt),TslStringToGtk(title),hd,U"是",1,U"否",1,"c",0); case r of 1: return 6; 2: return 7; else return 0; end end else if flag = 5 then begin r := tsl_gtk_messagebox_b(TslStringToGtk(txt),TslStringToGtk(title),hd,U"重试",1,U"取消",1,U"取消",0); case r of 1: return 4; else return 2; end end else if flag = 6 then begin r := tsl_gtk_messagebox_b(TslStringToGtk(txt),TslStringToGtk(title),hd,U"取消",1,U"重试",1,U"继续",1); case r of 1: return 2; 2: return 4; 3: return 11; else return 2; end end end function tsl_gtk_messagebox_b(); begin global g_gtk_call_handler_manager; mgnr := g_gtk_call_handler_manager; pms := params; dialog := gtk_window_new(0); //gtk_dialog_new(); gtk_window_set_resizable(GTK_WINDOW(dialog),FALSE); gtk_window_set_position(GTK_WINDOW(dialog),3); //GTK_WIN_POS_CENTER_ALWAYS btns := new tslcstructureobj(MemoryAlignmentCalculate(array((0,"intptr",0),(1,"intptr",0),(2,"intptr",0),(3,"intptr",0)))); btns._setvalue_(0,dialog); g_signal_connect_data(GTK_WIDGET(dialog),"destroy",mgnr.get(thisfunction( MessageBoxQuit)),btns._getptr_,0); id := pms[0]; idt := pms[1]; pt := pms[2]; if(GTK_WIDGET(pt))then //GTK_IS_WINDOW begin if(not gtk_widget_is_toplevel(pt))then begin pt := gtk_widget_get_toplevel(pt); end gtk_window_set_modal(GTK_WINDOW(dialog),TRUE); gtk_window_set_transient_for(GTK_WINDOW(dialog),GTK_WINDOW(pt)); end gtk_window_set_title(GTK_WINDOW(dialog),(idt)); gtk_container_set_border_width(GTK_CONTAINER(dialog),5); gtk_widget_realize(dialog); lbl := gtk_label_new((id)); gtk_misc_set_padding((lbl),10,10); //GTK_MISC vbox := gtk_vbox_new(FALSE,5); hbox := gtk_hbox_new(FALSE,10); gtk_box_pack_start((vbox),lbl,TRUE,TRUE,0); //GTK_BOX gtk_widget_show(lbl); gtk_container_add(GTK_CONTAINER(dialog),GTK_WIDGET(vbox)); gtk_widget_show(vbox); gtk_widget_show(hbox); gtk_widget_show(dialog); temp := 0; for idx := 0 to 2 do begin temp := pms[3+idx * 2]; btn := gtk_button_new_with_label(temp); btns._setvalue_(idx+1,btn); temp := pms[3+idx * 2+1]; g_signal_connect_data(GTK_WIDGET(btn),"clicked",mgnr.get(thisfunction( MessageBoxQuit)),btns._getptr_,nil); if temp then gtk_widget_show(btn); gtk_box_pack_start((hbox),btn,TRUE,TRUE,0); end gtk_box_pack_start((vbox),hbox,TRUE,TRUE,0); class(tUIglobalData).uigetdata("tuiapplication").run(); for idx := 3 downto 1 do begin if(0=(btns._getvalue_(idx)))then begin return idx; end end return 0; end function MessageBoxQuit(w:pointer;dd: pointer); begin da := new tslcstructureobj(MemoryAlignmentCalculate(array((0,"intptr",0),(1,"intptr",0),(2,"intptr",0),(3,"intptr",0))),dd); d := da._getdata_(); gtk_window_set_modal(GTK_WINDOW(d[0]),false); gtk_window_set_transient_for( GTK_WINDOW(d[0]),0); for i := 0 to 3 do begin if(w=d[i])then begin if i=0 then begin gtk_main_quit(); end else begin da._setvalue_(i,0); g_signal_emit_by_name(d[0], "destroy"); end break; end end return 0; end function gtk_createwindowexa(dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nwidth,nheight,hwndparent,hmenu,hinstance,lpParam); //窗口构造类 begin //array("tsui_application","tsui_window","tsluidesigner_a_a_1","tsui_form","tui_button","tui_edit","tui_tablecontrol32","tui_PageSheet","tui_monthcalendar","tui_datetimepicker") d := new tslcstructureobj(MemoryAlignmentCalculate( array( ("lpcreateparams","intptr",lpParam))),nil); _const := GetWin32Const(); if (dwStyle .& _const.WS_POPUP)=_const.WS_POPUP then begin cls := new tgtk_ctl_window_PoPup(); end else begin cls := new tgtk_ctl_window(); end if cls then begin global g_w_i_datas ; dptr := d._getptr_(); //g_w_i_datas[inttostr(dptr)] := new tgtk_wnd_info(); r := cls.CreateWnd(dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nwidth,nheight,hwndparent,hmenu,hinstance,dptr); //reindex(g_w_i_datas,array(inttostr(dptr):nil)); end return r; end function gtk_GetClassInfoExtA(h,cl,lpwcx); //获得信息 begin lcl := lowercase(cl); cs := GetGtkwindowclass(lcl); d := new tagWNDCLASSA(lpwcx); if cs then begin for i,v in cs do begin d._setvalue_(i,v); end return true; end return false; end function gtk_RegisterClassExA(lpwcx);//注册信息 begin d := new tagWNDCLASSA(lpwcx); reggtkwindowclass(d._getdata_()); return true; end function gtk_color_selection_dialog_new(t:string):pointer; begin _f_ := static function(t:string):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(t); end function gtk_color_selection_dialog_get_color_selection(d:pointer):pointer; begin _f_ := static function(d:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(d); end function Gtk_event_get_name_by_id(id); //gdk消息名称--id对应 begin d := array(0:"GDK_DELETE",1:"GDK_DESTROY",2:"GDK_EXPOSE",3:"GDK_MOTION_NOTIFY",4:"GDK_BUTTON_PRESS", 5:"GDK_2BUTTON_PRESS",6:"GDK_3BUTTON_PRESS",7:"GDK_BUTTON_RELEASE",8:"GDK_KEY_PRESS",9:"GDK_KEY_RELEASE", 10:"GDK_ENTER_NOTIFY",11:"GDK_LEAVE_NOTIFY",12:"GDK_FOCUS_CHANGE",13:"GDK_CONFIGURE",14:"GDK_MAP",15:"GDK_UNMAP", 16:"GDK_PROPERTY_NOTIFY",17:"GDK_SELECTION_CLEAR",18:"GDK_SELECTION_REQUEST",19:"GDK_SELECTION_NOTIFY",20:"GDK_PROXIMITY_IN", 21:"GDK_PROXIMITY_OUT",22:"GDK_DRAG_ENTER",23:"GDK_DRAG_LEAVE",24:"GDK_DRAG_MOTION",25:"GDK_DRAG_STATUS", 26:"GDK_DROP_START",27:"GDK_DROP_FINISHED",28:"GDK_CLIENT_EVENT",29:"GDK_VISIBILITY_NOTIFY",30:"GDK_NO_EXPOSE", 31:"GDK_SCROLL",32:"GDK_WINDOW_STATE",33:"GDK_SETTING",34:"GDK_OWNER_CHANGE",35:"GDK_GRAB_BROKEN",36:"GDK_DAMAGE",-1:"GDK_NOTHING") ; return d[id]; end function Gtk_dlg_get_response_name_by_id(id); //对话框id--名称对应 begin d := array(-11:"GTK_RESPONSE_HELP",-10:"GTK_RESPONSE_APPLY",-9:"GTK_RESPONSE_NO",-8:"GTK_RESPONSE_YES", -7:"GTK_RESPONSE_CLOSE",-6:"GTK_RESPONSE_CANCEL",-5:"GTK_RESPONSE_OK",-4:"GTK_RESPONSE_DELETE_EVENT", -3:"GTK_RESPONSE_ACCEPT",-2:"GTK_RESPONSE_REJECT",-1:"GTK_RESPONSE_NONE"); return d[id]; end function openresourcemanager(p); //打开资源管理器 begin if ifstring(p) then begin if fileexists("","/usr/bin/zenity") then begin tsl_gtk_exec_system(format('zenity --file-selection --filename="%s" --file-selection --multiple &',p)); return 1;// end if fileexists("","/usr/bin/caja") then begin tsl_gtk_exec_system(format('caja "%s" &',p)); return 1; end tsl_gtk_exec_system(format('nautilus "%s" &',p)); return 1; end end function tsl_gtk_exec_system(cmd) ; begin _f_ := static function(cmd:string):integer;external getfuncptrbyname("libc","system"); return ##_f_(cmd); end /////////////////////////////pipe process///////////执行程序相关///////////////////////////// //function tsl_gtk_closehandle(p:pointer):integer;cdecl;external "plugin/libTSLUIL.so"; //function tsl_gtk_pipread(p:pointer;var msg:string;ct:integer):integer;cdecl;external "plugin/libTSLUIL.so"; //function tsl_gtk_kill(p:pointer;sig:integer):integer;cdecl;external "plugin/libTSLUIL.so"; //function tsl_gtk_createprocessa(exe:string; cmd : array of string; ev : array of string;var pw:pointer):pointer;cdecl;external "plugin/libTSLUIL.so"; // procedure g_object_get_property(g:pointer;n:string;v:pointer); begin _f_ := static procedure(g:pointer;n:string;v:pointer); cdecl; external getfuncptrbyname(0,functionname()); ////libglib-2.0.so return ##_f_(g,n,v); end function g_value_get_pointer(v:pointer):pointer; begin _f_ := static function(v:pointer):pointer; cdecl; external getfuncptrbyname(0,functionname()); ////libglib-2.0.so return ##_f_(v); end procedure g_free(mem:pointer); begin _f_ := static procedure(mem:pointer); cdecl; external getfuncptrbyname(0,functionname()); ////libglib-2.0.so return ##_f_(g_free); end /////////////////////////////////timer/////////////////////////////// function g_timeout_add(interval:integer; _function:pointer; d:pointer):integer; begin _f_ := static function(interval:integer; _function:pointer; d:pointer):integer; cdecl; external getfuncptrbyname(0,functionname()); ////libglib-2.0.so return ##_f_(interval,_function,d); end procedure g_source_remove(timeout_handler_id:integer); begin _f_ := static procedure(timeout_handler_id:integer); cdecl; external getfuncptrbyname(0,functionname()); ////libglib-2.0.so return ##_f_(timeout_handler_id); end function p_to_str(p); //读取字符串并销毁原来的ptr begin r := ""; if p then begin r := ReadStringFromPtr(p); g_free(p); end return r; end /////////////////////cairo gtk////////////////////////////// function gdk_cairo_create(w:pointer):pointer; begin _f_ := static function(w:pointer):pointer;cdecl;external get_cairo_func(functionname()); return ##_f_(w); end //////////////////////////clipboard///////////////////// procedure gtk_clipboard_set_text(c:pointer;s:string;len:integer); begin _f_ := static procedure(c:pointer;s:string;len:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(c,s,len); end procedure gtk_clipboard_set_image(c:pointer;pixbuf:pointer); begin _f_ := static procedure(c:pointer;pixbuf:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(c,pixbuf); end function gtk_clipboard_clear(clip:pointer); begin _f_ := static procedure(clip:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(clip); end function gtk_clipboard_wait_is_text_available(clip:pointer):integer; begin _f_ := static function(clip:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(clip); end function gtk_clipboard_wait_is_rich_text_available(clip:pointer;tgs:pointer):integer; begin _f_ := static function(clip:pointer;tgs:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(clip,tgs); end function gtk_clipboard_wait_is_image_available(clip:pointer):integer; begin _f_ := static function(clip:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(clip); end function gtk_clipboard_get(atm:pointer):pointer; begin _f_ := static function(atm:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(atm); end function gtk_clipboard_wait_for_image(clipboard:pointer):pointer; begin _f_ := static function(clipboard:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(clipboard); end function gtk_clipboard_wait_for_text(clipboard:pointer):string; begin _f_ := static function(clipboard:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); p := ##_f_(clipboard); return p_to_str(p); end //////////////////////// function gtk_events_pending():integer; begin _f_ := static function():integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function gtk_main_iteration_do(f:integer):integer; begin _f_ := static function(f:integer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(f); end function gtk_main_iteration():integer ; begin _f_ := static function():integer ;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function g_idle_remove_by_data(p:pointer):integer; begin _f_ := static function(p:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(p); end /////////////////////////////////////////////////////// //////////////// function g_slist_alloc():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function g_slist_append(list:pointer;d:pointer):pointer; begin _f_ := static function(list:pointer;d:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(list,d); end procedure g_slist_free(list:pointer); begin _f_ := static procedure(list:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(list); end function g_slist_find(gl:pointer;d:pointer):pointer; begin _f_ := static function(gl:pointer;d:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(gl,d); end function g_slist_length(gl:pointer):integer; begin _f_ := static function(gl:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(gl); end function g_slist_delete_link(gl:pointer;gl2:pointer):pointer; begin _f_ := static function(gl:pointer;gl2:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(gl,gl2); end function g_slist_remove(gl:pointer;gl2:pointer):pointer; begin _f_ := static function(gl:pointer;gl2:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(gl,gl2); end ////////////////not classfiy////////////////////////////////// function gtk_widget_is_visible(w:pointer):integer; begin _f_ := static function(w:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end function gtk_widget_has_focus(w:pointer):integer; begin _f_ := static function(w:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end procedure gtk_widget_set_can_focus(w:pointer;cf:integer); begin _f_ := static procedure(w:pointer;cf:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,cf); end function gtk_window_get_focus(w:pointer):pointer; //GdkX11 – 3.0 begin _f_ := static function(w:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end function gdk_x11_window_get_xid(wd:pointer); // begin _f_ := static function(wd:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(wd); end procedure gtk_widget_grab_focus(w:pointer); begin _f_ := static procedure(w:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end function gtk_widget_activate(w:pointer):integer; begin _f_ := static function(w:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end procedure gtk_window_set_focus(window:pointer; focus:pointer); begin _f_ := static procedure(window:pointer; focus:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(window,focus); end procedure gtk_window_set_accept_focus(window:pointer; setting:integer); begin _f_ := static procedure(window:pointer; setting:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(window,setting?true:false); end procedure gtk_window_set_type_hint(window:pointer; tp:integer); begin _f_ := static procedure(window:pointer; tp:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(window,tp); 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); begin _f_ := static procedure(widget:pointer;has_window:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(widget,has_window); end function gtk_widget_get_parent(w:pointer):pointer; begin _f_ := static function(w:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end function gtk_widget_get_allocated_width(w:pointer):integer; begin _f_ := static function(w:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end function gtk_widget_get_allocated_height(w:pointer):integer; begin _f_ := static function(w:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end procedure gtk_widget_set_sensitive(w:pointer;s:integer); begin _f_ := static procedure(w:pointer;s:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,s); end function gtk_widget_get_sensitive(w:pointer):integer; begin _f_ := static function(w:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end function gtk_widget_is_toplevel(w:pointer):integer; begin _f_ := static function(w:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end function gtk_window_get_title(w:pointer):string; begin _f_ := static function(w:pointer):string;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end ////////////////////////////////im///////////////////////// function gtk_im_multicontext_new():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function gtk_im_multicontext_get_context_id(im:pointer):string; begin _f_ := static function(im:pointer):string;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(im); end function gtk_im_multicontext_get_type():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end procedure gtk_im_context_set_client_window(im:pointer;w:pointer); begin _f_ := static procedure(im:pointer;w:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(im,w); end procedure gtk_im_context_set_use_preedit (im:pointer;s:integer); begin _f_ := static procedure(im:pointer;s:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(im,s); end procedure gtk_im_context_focus_in(im:pointer); begin _f_ := static procedure(im:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(im); end procedure gtk_im_context_focus_out (im:pointer); begin _f_ := static procedure(im:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(im); end procedure gtk_im_context_reset(im:pointer); begin _f_ := static procedure(im:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(im); end procedure gtk_im_context_get_preedit_string(im:pointer;var str:string;var attrs:pointer;cp:array of integer); begin _f_ := static procedure(im:pointer;var str:string;var attrs:pointer;cp:array of integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(im,str,attrs,cp); end function gtk_im_context_filter_keypress(im:pointer;e:pointer):integer; begin _f_ := static function(im:pointer;e:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(im,e); end function gtk_im_context_delete_surrounding(im:pointer;offset:integer;nchars:integer):integer; begin _f_ := static function(im:pointer;offset:integer;nchars:integer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(im,offset,nchars); end function gtk_im_context_get_surrounding(im:pointer;var txt:string;var cursor_index:integer):integer; begin _f_ := static function(im:pointer;var txt:string;var cursor_index:integer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(im,txt,cursor_index); end procedure gtk_im_context_set_cursor_location(im:pointer;var area:array of integer); begin _f_ := static procedure(im:pointer;var area:array of integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(im,area); end //////////////////////////////////gobject////// function g_type_check_instance_is_a(instance:pointer;iface_type:pointer):integer; begin _f_ := static function(instance:pointer;iface_type:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(instance,iface_type); end {procedure g_object_set_data(object:pointer;key:string;data:pointer);cdecl;external 'libgtk-3.so'; function g_object_get_data(object:pointer;key:string):pointer;cdecl;external 'libgtk-3.so'; procedure g_object_set_data_base(object:pointer;key:string;data:pointer);cdecl;external 'libgtk-3.so' name "g_object_set_data"; function g_object_get_data_base(object:pointer;key:string):pointer;cdecl;external 'libgtk-3.so' name 'g_object_get_data'; } function g_object_get_data(object:pointer;key:string); begin return gtk_object_get_data(object,key); //r := g_object_get_data_base(object,key); return r; end function g_object_set_data(object:pointer;key:string;data:pointer); begin return gtk_object_set_data(object,key,data); end function g_object_ref(g:pointer):pointer; begin _f_ := static function(g:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(g); end procedure g_object_unref(g:pointer); begin _f_ := static procedure(g:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(g); end ////////////////////////scroll////////////////////////// function gtk_scrolled_window_new(hadjustment:pointer; vadjustment:pointer):pointer; begin _f_ := static function(hadjustment:pointer; vadjustment:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(hadjustment,vadjustment); end procedure gtk_scrolled_window_add_with_viewport(s:pointer;c:pointer); begin _f_ := static procedure(s:pointer;c:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(s,c); end function gtk_scrolled_window_get_hscrollbar(s:pointer):pointer; begin _f_ := static function(s:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(s); end function gtk_scrolled_window_get_vscrollbar(s:pointer):pointer; begin _f_ := static function(s:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(s); end function gtk_scrolled_window_get_hadjustment(s:pointer):pointer; begin _f_ := static function(s:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(s); end function gtk_scrolled_window_get_vadjustment(s:pointer):pointer; begin _f_ := static function(s:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(s); end procedure gtk_scrolled_window_set_max_content_height(s:pointer;h:integer); begin _f_ := static procedure(s:pointer;h:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(s,h); end procedure gtk_scrolled_window_set_min_content_height(s:pointer;h:integer); begin _f_ := static procedure(s:pointer;h:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(s,h); end procedure gtk_scrolled_window_set_max_content_width(s:pointer;h:integer); begin _f_ := static procedure(s:pointer;h:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(s,h); end procedure gtk_scrolled_window_set_policy(s:pointer;p:integer); begin _f_ := static procedure(s:pointer;p:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(s,p); end /////////////////////scrollable//////////////////////////// procedure gtk_scrollable_set_vscroll_policy(s:pointer;p:integer); begin _f_ := static procedure(s:pointer;p:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(s,p); end procedure gtk_scrollable_set_hscroll_policy(s:pointer;p:integer); begin _f_ := static procedure(s:pointer;p:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(s,p); end function gtk_scrollable_get_hadjustment(s:pointer):pointer; begin _f_ := static function(s:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(s); end function gtk_scrollable_get_vadjustment(s:pointer):pointer; begin _f_ := static function(s:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(s); end //////////////gdk window /////// procedure gdk_window_get_geometry(w,x,y,sz1,sz2); begin _f_ := static procedure(w:pointer;var x :integer;var y:integer;var sz1:integer;var sz2:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,x,y,sz1,sz2); end procedure gdk_window_show_unraised(w:pointer); begin _f_ := static procedure(w:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end ///////////////////////////device////////////////////////// //gdk_display_get_pointer(gdk_display_get_default(), nil, x, y, nil); //鼠标位置 procedure gdk_display_get_pointer(d:pointer; screen:string;var x :integer;var Y:integer;msk:string); begin _f_ := static procedure(d:pointer; screen:string;var x :integer;var Y:integer;msk:string); cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(d,screen,x,Y,msk); end procedure gdk_set_allowed_backends(backends:string); begin _f_ := static procedure(backends:string); cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(backends); end function gdk_display_get_default():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function gdk_keymap_get_for_display(disp:pointer):pointer; begin _f_ := static function(disp:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(disp); end function gdk_keymap_get_modifier_state(kmp:pointer):integer; begin _f_ := static function(kmp:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(kmp); end function gdk_keymap_get_caps_lock_state(kmp:pointer):integer; begin _f_ := static function(kmp:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(kmp); end function gdk_screen_get_default():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function gdk_display_get_default_seat(d:pointer):pointer; begin _f_ := static function(d:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(d); end function gdk_seat_get_pointer(dm:pointer):pointer; begin _f_ := static function(dm:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(dm); end procedure gdk_device_get_position(d:pointer;t:pointer;var x :integer;var y:integer); begin _f_ := static procedure(d:pointer;t:pointer;var x :integer;var y:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(d,t,x,y); end function gdk_event_get_scroll_deltas(d:pointer;var x :double;var y:double):integer; begin _f_ := static function(d:pointer;var x :double;var y:double):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(d,x,y); end procedure gdk_window_get_position(w:pointer;var x:integer;var y:integer); begin _f_ := static procedure(w:pointer;var x:integer;var y:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,x,y); end function gdk_screen_height():integer; begin _f_ := static function():integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function gdk_screen_width():integer; begin _f_ := static function():integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function gdk_event_get_event_type(e:pointer):integer; begin _f_ := static function(e:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(e); end function gdk_cairo_get_clip_rectangle(cr:pointer;var rec:array of integer):integer; begin _f_ := static function(cr:pointer;var rec:array of integer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(cr,rec); end ////////////////////////// start //////////////////////////////////////// procedure gtk_init(argc:string;argcv:string); begin _f_ := static procedure(argc:string;argcv:string);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(argc,argcv); end function gtk_get_current_event_time():integer; begin _f_ := static function():integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function gtk_get_binary_age():integer; begin _f_ := static function():integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end procedure gtk_main(); begin _f_ := static procedure();cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end procedure gtk_main_quit(); begin _f_ := static procedure();cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function gtk_mainidle(idledata); begin //idledata :=(new tcbytearray(4))._getptr_(); id := g_idle_add(gettslvcleventhandler_("tsl_gtk_idle"),idledata); gtk_main(); g_idle_remove_by_data(idledata); //删除idle return 1; end function g_main_depth(); //Returns the depth of the stack of calls begin _f_ := static function():integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function g_main_loop_new(ctx:pointer;is_running:integer):pointer; begin _f_ := static function(ctx:pointer;is_running:integer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(ctx,is_running); end function g_main_loop_quit(loop:pointer); begin _f_ := static procedure(loop:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(loop); end function g_main_loop_get_context(lp:pointer):pointer; begin _f_ := static function(lp:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(lp); end function g_idle_add(f:pointer;d:pointer):integer; begin _f_ := static function(f:pointer;d:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(f,d); end function g_idle_source_new(); begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function g_timeout_source_new(interval); begin _f_ := static function(interval:integer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(interval); end function g_source_destroy(source); begin _f_ := static procedure(source:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(source); end function g_source_unref(source); begin _f_ := static procedure(source:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(source); end function g_source_ref(source); begin _f_ := static function(source:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(source); end function g_source_set_can_recurse(source:pointer;cr:integer); begin _f_ := static procedure(source:pointer;cr:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(source,cr); end function g_source_attach(source:pointer;ctx:pointer):integer; begin _f_ := static function(source:pointer;ctx:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(source,ctx); end function g_source_set_callback(source:pointer;func:pointer;data:pointer;notify:poiner):integer; begin _f_ := static procedure(source:pointer;func:pointer;data:pointer;notify:poiner);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(source,func,data,notify); end function g_main_context_default():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function g_main_context_pending(gctx:pointer):integer; begin _f_ := static function(gctx:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(gctx); end function g_main_context_iteration(gctx:pointer;bk:integer):integer; begin _f_ := static function(gctx:pointer;bk:integer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(gctx,bk); end function g_main_context_get_poll_func(ctx:pointer):pointer; begin _f_ := static function(ctx:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(ctx); end function g_source_is_destroyed(source:pointer):integer; begin _f_ := static function(source:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(source); end function g_source_add_child_source(source:pointer;child_source:pointer); begin _f_ := static procedure(source:pointer;child_source:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(source,child_source); end function g_source_add_poll(source:pointer;fd:pointer); begin _f_ := static procedure(source:pointer;fd:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(source,fd); end //////////////////////context/////////////////////////////// function gtk_widget_get_style_context(w:pointer):pointer; begin _f_ := static function(w:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end ////////////////////拖拽文件相关/////////////////////////////////////////// function gtk_drag_get_data(w:pointer;c:pointer;ls:pointer;tm:integer); begin _f_ := static procedure(w:pointer;c:pointer;var ls:pointer;tm:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,c,ls,tm); end function gdk_drag_status(c:pointer;ac:integer;tm:integer); begin _f_ := static procedure(c:pointer;ac:integer;tm:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(c,ac,tm); end function gtk_drag_dest_set(w:pointer;flgs:integer;targets:pointer;ntg:integer;actions:integer):integer; begin _f_ := static procedure(w:pointer;flgs:integer;targets:pointer;ntg:integer;actions:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,flgs,targets,ntg,actions); end function gdk_drag_context_list_targets(c:pointerr); begin _f_ := static procedure(c:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(c); end function gtk_selection_data_get_text(d:pointer); begin _f_ := static function(d:pointer):string;cdecl;external getfuncptrbyname(0,functionname()); p := ##_f_(d); return p_to_str(p); end function gtk_selection_data_get_data_type(d:pointer); begin _f_ := static function(d:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(d); end function gdk_atom_name(a:pointer):string; begin _f_ := static function(d:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); p := ##_f_(d); return p_to_str(p); end function gtk_drag_dest_find_target(w:pointer;ctx:pointer;tglist:pointer); begin _f_ := static function(w:pointer;ctx:pointer;tglist:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,ctx,tglist); end function gtk_target_list_new(ntg):pointer; begin _f_ := static function(tg:pointer;ntg:integer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(0,0); end function gdk_window_get_pointer(w:pointer;var x:integer;var y:integer;var mask:pointer); begin _f_ := static function(d:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(d); end function gtk_selection_data_get_length(ntg):integer; begin _f_ := static function(ntg:pointer;):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(ntg); end function get_drage_file_names(w); begin global g_drage_file_file_names; r := g_drage_file_file_names; g_drage_file_file_names := array(); if not ifarray(r) then r := array(); return r; end function gtk_selection_data_get_uris(d); begin if not d then return array(); _f_ := static function(d:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); r := ##_f_(d); rr := r; if not r then return array(); ret := array(); _tool := unit(cstructurelib).get_mem_mgr(); while true do begin p1 := _tool.readptr(r); if not p1 then break; fi := _tool.readstr(p1); if not fi then continue; if pos("file://",fi) then begin ret[idx++] := fi[8:]; end r+=8; end g_strfreev(rr); return ret; end function gtk_target_entry_new(target,flags,info); begin _f_ := static function(target:string;flags:integer;info:integer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(target,flags,info); end function gtk_target_entry_free(tg:pointer); begin _f_ := static procedure(tg:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(tg); end function gtk_drag_finish(ctx,suc,del,tm); begin _f_ := static procedure(ctx:pointer;suc:integer;del:integer;tm:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(ctx,suc,del,tm); end function g_strfreev(uris); begin _f_ := static procedure(uris:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(uris); end /////////////////////////////////widget//////////////////////////////////// function gtk_widget_get_realized(w:pointer):integer; begin _f_ := static function(w:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end procedure gtk_widget_set_events(w:pointer;f:integer); begin _f_ := static procedure(w:pointer;f:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,f); end procedure gtk_widget_get_allocation(w:pointer;var rec:array of integer); begin _f_ := static procedure(w:pointer;var rec:array of integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,rec); end procedure gtk_widget_set_allocation(w:pointer; rec: array of integer); begin _f_ := static procedure(w:pointer; rec: array of integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,rec); end procedure gtk_widget_size_allocate(w:pointer; rec: array of integer); begin _f_ := static procedure(w:pointer; rec: array of integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,rec); end procedure gtk_widget_modify_text(w:pointer;t:integer;c:pointer); begin _f_ := static procedure(w:pointer;t:integer;c:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,t,c); end procedure gtk_widget_set_tooltip_text(w:pointer;tip:string); begin _f_ := static procedure(w:pointer;tip:string);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,tip); end procedure gtk_widget_set_size_request(wd:pointer;w:integer;h:integer); begin _f_ := static procedure(wd:pointer;w:integer;h:integer);cdecl;external getfuncptrbyname(0,functionname()); window_get_true_size(wd,w,h,wdo,hto); return ##_f_(wd,wdo,hto); end procedure gtk_widget_get_size_request(wd:pointer;var h:integer;var w:integer); begin _f_ := static procedure(wd:pointer;var h:integer;var w:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(wd,h,w); end procedure gtk_widget_set_app_paintable(w:pointer;f:integer); begin _f_ := static procedure(w:pointer;f:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,f); end procedure gtk_widget_realize(w:pointer); begin _f_ := static procedure(w:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end procedure gtk_widget_queue_draw(w:pointer); begin _f_ := static procedure(w:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end procedure gtk_widget_queue_resize_no_redraw(w:pointer); begin _f_ := static procedure(w:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end procedure gtk_widget_queue_draw_area(w:pointer;x:integer;y:integer;wd:integer;ht:integer); begin _f_ := static procedure(w:pointer;x:integer;y:integer;wd:integer;ht:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,x,y,wd,ht); end function gtk_widget_get_margin_top(w:pointer):integer; begin _f_ := static function(w:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end /////////////////////edit entry////////////////////////////////////////////////////// function gtk_entry_new():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function gtk_entry_get_text(w:pointer):string; begin _f_ := static function(w:pointer):string;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end procedure gtk_entry_set_text(e:pointer;c:string); begin _f_ := static procedure(e:pointer;c:string);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(e,c); end function gtk_entry_get_text_length(e:pointer):short; begin _f_ := static function(e:pointer):short;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(e); end procedure gtk_entry_set_visibility(e:pointer;v:integer); begin _f_ := static procedure(e:pointer;v:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(e,v); end procedure gtk_entry_set_width_chars(e:pointer;v:integer); begin _f_ := static procedure(e:pointer;v:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(e,v); end procedure gtk_entry_set_invisible_char(e:pointer;c:integer); begin _f_ := static procedure(e:pointer;c:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(e,c); end //procedure gtk_entry_set_editable(e:pointer;ed:integer);cdecl;external 'libgtk-3.so'; procedure gtk_editable_set_editable(e:pointer;ed:integer); begin _f_ := static procedure(e:pointer;ed:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(e,ed); end procedure gtk_entry_set_has_frame(e:pointer;s:integer); begin _f_ := static procedure(e:pointer;s:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(e,s); end procedure gtk_entry_set_max_length(e:pointer;len:integer); begin _f_ := static procedure(e:pointer;len:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(e,len); end /////////////////////text view memo ////////////////////////////////////////////////////// function gtk_text_view_new():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end procedure gtk_text_view_set_wrap_mode(t:pointer;md:integer); begin _f_ := static procedure(t:pointer;md:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(t,md); end procedure gtk_text_view_set_buffer(t:pointer;bf:pointer); begin _f_ := static procedure(t:pointer;bf:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(t,bf); end function gtk_text_buffer_new(tagtable:pointer):pointer; begin _f_ := static function(tagtable:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(tagtable); end procedure gtk_text_buffer_get_iter_at_offset(bf:pointer;iter:pointer;offset:integer); begin _f_ := static procedure(bf:pointer;iter:pointer;offset:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(bf,iter,offset); end procedure gtk_text_buffer_insert(bf:pointer;iter:pointer;txt:string;len:integer); begin _f_ := static procedure(bf:pointer;iter:pointer;txt:string;len:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(bf,iter,txt,len); end procedure gtk_text_view_set_editable(t:pointer;e:integer); begin _f_ := static procedure(t:pointer;e:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(t,e); end procedure gtk_text_set_word_wrap(t:pointer;e:integer); begin _f_ := static procedure(t:pointer;e:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(t,e); end procedure gtk_text_buffer_get_end_iter(b:pointer;iter:pointer); begin _f_ := static procedure(b:pointer;iter:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(b,iter); end procedure gtk_text_buffer_get_start_iter(b:pointer;iter:pointer); begin _f_ := static procedure(b:pointer;iter:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(b,iter); end function gtk_text_buffer_get_char_count(b:pointer):integer; begin _f_ := static function(b:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(b); end function gtk_text_buffer_get_line_count(b:pointer):integer; begin _f_ := static function(b:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(b); end procedure gtk_text_buffer_delete(b:pointer;start:pointer;ed:pointer); begin _f_ := static procedure(b:pointer;start:pointer;ed:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(b,start,ed); end function gtk_text_buffer_get_text(b:pointer;start:pointer;ed:pointer;ic:integer):string; begin _f_ := static function(b:pointer;start:pointer;ed:pointer;ic:integer):pointer;cdecl;external getfuncptrbyname(0,functionname()); p := ##_f_(b,start,ed,ic); return p_to_str(p); end function gtk_text_buffer_get_selection_bounds(b:pointer;st:pointer;ed:pointer):integer; begin _f_ := static function(b:pointer;st:pointer;ed:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(b,st,ed); end //////////////////////////////pango//////////////////////////////////////////// function pango_font_description_from_string(ns:string):pointer; begin _f_ := static function(ns:string):pointer; cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(ns); end procedure pango_font_description_free(pg:pointer); begin _f_ := static procedure(pg:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(pg); end procedure pango_font_description_set_size(pg:pointer;sz:integer); begin _f_ := static procedure(pg:pointer;sz:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(pg,sz); end function pango_cairo_create_layout(c:pointer):pointer; begin _f_ := static function(c:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(c); end function pango_cairo_create_context(c:pointer):pointer; begin _f_ := static function(c:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(c); end procedure pango_layout_set_width(p:pointer;w:integer); begin _f_ := static procedure(p:pointer;w:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(p,w); end function pango_layout_get_width(p:pointer):integer; begin _f_ := static function(p:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(p); end procedure pango_layout_set_wrap(p:pointer;wp:integer); begin _f_ := static procedure(p:pointer;wp:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(p,wp); end procedure pango_layout_set_font_description(p:pointer;f:pointer); begin _f_ := static procedure(p:pointer;f:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(p,f); end procedure pango_layout_set_text(pl:pointer;s:string;len:integer); begin _f_ := static procedure(pl:pointer;s:string;len:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(pl,s,len); end procedure pango_cairo_show_layout(cr:pointer;pl:pointer); begin _f_ := static procedure(cr:pointer;pl:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(cr,pl); end function pango_cairo_font_map_get_default():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end procedure pango_font_map_list_families(fm:pointer;var fls:pointer;var n:integer); begin _f_ := static procedure(fm:pointer;var fls:pointer;var n:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(fm,fls,n); end function pango_font_family_get_name(n:pointer):string; begin _f_ := static function(n:pointer):string;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(n); end function pango_font_family_get_names(); //获得文字 begin fm := pango_cairo_font_map_get_default(); pango_font_map_list_families(fm,ls,lsn); mt := unit(cstructurelib).get_mem_mgr(); r := array(); {$ifdef win32} psize := 4; {$else} psize := 8; {$endif } for i:= 0 to lsn -1 do begin pi := mt.readptr(ls+psize*i); r[i] := GtkStringToTsl( pango_font_family_get_name(pi)); end return r; end ////////////////////cairo ext//////////////////////////// function cairo_applay_pen_style(dc); begin pt := gtk_object_get_data(dc,"pen.style"); case pt of 1: begin ds := array(14,6); cairo_set_dash(dc,ds,length(ds),0); end 2: begin ds := array(3,3); cairo_set_dash(dc,ds,length(ds),0); end 3: begin ds := array(10,4,3,4); cairo_set_dash(dc,ds,length(ds),0); end 4: begin ds := array(10,3,3,3,3,3); cairo_set_dash(dc,ds,length(ds),0); end else begin cairo_set_dash(dc,array(0),0,0); end end return pt=5; end function cairo_draw_round_rectangle(cr,x,y,w,h,r); begin cairo_move_to(cr, x + r, y); cairo_line_to(cr, x + w - r, y); cairo_move_to(cr, x + w, y + r); cairo_line_to(cr, x + w, y + h - r); cairo_move_to(cr, x + w - r, y + h); cairo_line_to(cr, x + r, y + h); cairo_move_to(cr, x, y + h - r); cairo_line_to(cr, x, y + r); cairo_arc(cr, x + r, y + r, r, 3.14, 3 * 3.14 / 2.0); cairo_arc(cr, x + w - r, y + r, r, 3 * 3.14 / 2, 2 * 3.14); cairo_arc(cr, x + w - r, y + h - r, r, 0, 3.14 / 2); cairo_arc(cr, x + r, y + h - r, r, 3.14 / 2, 3.14); end /////////////////////////window////////// procedure gtk_window_set_keep_above(w:pointer;f:integer); begin _f_ := static procedure(w:pointer;f:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,f); end procedure gtk_window_set_keep_below(w:pointer;f:integer); begin _f_ := static procedure(w:pointer;f:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,f); end function gtk_window_list_toplevels():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function gdk_window_get_window_type(w:pointer); begin _f_ := static function(w:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end procedure gdk_window_move_resize(w:pointer;x:integer;y:integer;wd:integer;h:integer); begin _f_ := static procedure(w:pointer;x:integer;y:integer;wd:integer;h:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,x,y,wd,h); end procedure gdk_window_resize(w:pointer;wd:integer;h:integer); begin _f_ := static procedure(w:pointer;wd:integer;h:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,wd,h); end procedure gtk_window_begin_move_drag(w:pointer;btn:integer;x:integer;y:integer;t:integer); begin _f_ := static procedure(w:pointer;btn:integer;x:integer;y:integer;t:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,btn,x,y,t); end procedure gtk_window_begin_resize_drag(w:pointer;e:integer;btn:integer;x:integer;y:integer;t:integer); begin _f_ := static procedure(w:pointer;e:integer;btn:integer;x:integer;y:integer;t:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,e,btn,x,y,t); end function gtk_widget_get_toplevel(w:pointer):pointer; begin _f_ := static function(w:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end /////////// modal //////////////////////////////// function gtk_window_is_active(w:pointer):integer; begin _f_ := static function(w:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end procedure gtk_window_present(w:pointer); begin _f_ := static procedure(w:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end function gtk_window_activate_default(w:pointer):integer; begin _f_ := static function(w:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end function gtk_window_activate_focus(w:pointer):integer; begin _f_ := static function(w:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end function gtk_window_has_toplevel_focus(w:pointer):integer; begin _f_ := static function(w:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end procedure gtk_window_set_modal(w:pointer;f:integer); begin _f_ := static procedure(w:pointer;f:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,f); end procedure gtk_widget_set_opacity(w:pointer;f:double); begin _f_ := static procedure(w:pointer;f:double);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,f); end procedure gtk_window_set_transient_for(w:pointer;p:pointer); begin global g_applicaton_wnd_handle; _f_ := static procedure(w:pointer;p:pointer);cdecl;external getfuncptrbyname(0,functionname()); if (p = g_applicaton_wnd_handle) and gdk_backend_is_wayland() then //处理底层窗口问题 begin return ##_f_(w,0); end return ##_f_(w,p); end function gtk_window_get_transient_for(w:pointer):pointer; begin _f_ := static function(w:pointer;p:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,p); end procedure gtk_window_get_size(wg:pointer;var w:integer;var h:integer); begin _f_ := static procedure(wg:pointer;var w:integer;var h:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(wg,w,h); end procedure gtk_window_set_icon(w:pointer;ico:pointer); begin _f_ := static procedure(w:pointer;ico:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,ico); end procedure gtk_window_set_position(wd:pointer;ps:integer); begin _f_ := static procedure(w:pointer;p:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(wd,ps); end procedure gtk_window_set_default_size(p:pointer;w:integer;h:integer); begin _f_ := static procedure(p:pointer;w:integer;h:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(p,w,h); end procedure gtk_window_set_resizable(p:pointer;f:integer); begin _f_ := static procedure(p:pointer;f:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(p,f); end function gtk_window_get_resizable(p:pointer):integer; begin _f_ := static function(p:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(p); end procedure gtk_window_set_decorated(w:pointer;f:integer); begin _f_ := static procedure(w:pointer;f:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,f); end function gtk_window_get_decorated(w:pointer):integer; begin _f_ := static function(w:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end procedure gtk_window_set_title(w:pointer;t:string); begin _f_ := static procedure(w:pointer;t:string);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,t); end procedure gtk_window_set_titlebar(w:pointer;t:pointer); begin _f_ := static procedure(w:pointer;t:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,t); end function gtk_window_get_titlebar(w:pointer):pointer; begin _f_ := static function(w:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end procedure gtk_window_set_geometry_hints(window:pointer;eometry_widget:pointer;geometry:pointer;geom_mask:integer); begin _f_ := static procedure(window:pointer;eometry_widget:pointer;geometry:pointer;geom_mask:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(window,eometry_widget,geometry,geom_mask); end function gtk_widget_get_margin_end(w:pointer):integer; begin _f_ := static function(w:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end function gtk_widget_get_margin_right(w:pointer):integer; begin _f_ := static function(w:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end function gtk_widget_get_margin_bottom(w:pointer):integer; begin _f_ := static function(w:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end procedure gtk_window_resize(w:pointer;wd:integer;ht:integer); begin _f_ := static procedure(w:pointer;wd:integer;ht:integer);cdecl;external getfuncptrbyname(0,functionname()); save_wnd_size(w,wd,ht); window_get_true_size(wnd,wd,ht,wdo,hto); return ##_f_(w,wdo,hto); end function window_get_true_size(wnd,wd,ht,wdo,hto); begin global g_gtk_shadow_width,g_gtk_shadow_heigt; wdo := wd;hto := ht; if gdk_backend_is_wayland() and g_object_get_data(wnd,"size_has_shadow") then begin wdo+=g_gtk_shadow_width;hto+=g_gtk_shadow_heigt; end end function save_wnd_size(w,wd,ht); begin if g_object_get_data(w,"size_last_set") then begin g_object_set_data(w,"size_last_set_value",array(wd,ht)); end end procedure gtk_window_resize_to_geometry(w:pointer;wd:integer;ht:integer); begin _f_ := static procedure(w:pointer;wd:integer;ht:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,wd,ht); end procedure gtk_window_move(w:pointer;x:integer;y:integer); begin _f_ := static procedure(w:pointer;x:integer;y:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,x,y); end ////////////////////// container layout fixed ////////////////////// procedure gtk_container_add(c1:pointer;c2:pointer); begin _f_ := static procedure(c1:pointer;c2:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(c1,c2); end procedure gtk_container_remove(c:pointer;w:pointer); begin _f_ := static procedure(c:pointer;w:pointer); cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(c,w); end procedure gtk_container_set_border_width (container:pointer;border_width:integer); begin _f_ := static procedure(container:pointer;border_width:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(container,border_width); end function gtk_fixed_new():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function gtk_layout_new(h:pointer;v:pointer):pointer; begin _f_ := static function(h:pointer;v:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(h,v); end procedure gtk_layout_get_size(layout:pointer;var width:integer;var height:integer); begin _f_ := static procedure(layout:pointer;var width:integer;var height:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(layout,width,height); end procedure gtk_layout_set_size(layout:pointer; width:integer; height:integer); begin _f_ := static procedure(layout:pointer; width:integer; height:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(layout,width,height); end procedure gtk_fixed_put(fixed:pointer;widget:pointer;x:integer;y:integer); begin _f_ := static procedure(fixed:pointer;widget:pointer;x:integer;y:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(fixed,widget,x,y); end procedure gtk_layout_put(fixed:pointer;widget:pointer;x:integer;y:integer); begin _f_ := static procedure(fixed:pointer;widget:pointer;x:integer;y:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(fixed,widget,x,y); end function gtk_layout_get_bin_window(l:pointer):pointer; begin _f_ := static function(l:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(l); end //////////////////////////// box ///////////////////////// function gtk_vbox_new(homogeneous:integer;spacing:integer):pointer; begin _f_ := static function(homogeneous:integer;spacing:integer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(homogeneous,spacing); end function gtk_hbox_new(homogeneous:integer;spacing:integer):pointer; begin _f_ := static function(homogeneous:integer;spacing:integer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(homogeneous,spacing); end procedure gtk_box_pack_end(box:pointer;w:pointer;expand:integer;f:integer;pad:integer); begin _f_ := static procedure(box:pointer;w:pointer;expand:integer;f:integer;pad:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(box,w,expand,f,pad); end procedure gtk_box_pack_start(box:pointer;w:pointer;expand:integer;f:integer;pad:integer); begin _f_ := static procedure(box:pointer;w:pointer;expand:integer;f:integer;pad:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(box,w,expand,f,pad); end //////////////////////////menu////////////////////////////////////////////////// function gtk_menu_shell_get_by_positon(h:pointer;pi:integer); begin gist := gtk_container_get_children(h); ridx := 0; while gist do begin og := new _gslist(gist); if ridx=pi then begin return og.data; end ridx++; gist := og.next; //echo "\r\n+++",gist,"+++\r\n"; end return 0; end function gtk_container_get_children(m:pointer):pointer; begin _f_ := static function(m:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(m); end function gtk_menu_bar_new():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end procedure gtk_menu_shell_append(mb:pointer;mi:pointer); begin _f_ := static procedure(mb:pointer;mi:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(mb,mi); end procedure gtk_menu_shell_prepend(mb:pointer;mi:pointer); begin _f_ := static procedure(mb:pointer;mi:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(mb,mi); end procedure gtk_menu_shell_insert(mb:pointer;mi:pointer;idx:integer); begin _f_ := static procedure(mb:pointer;mi:pointer;idx:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(mb,mi,idx); end function gtk_menu_item_new_with_label(s:string):pointer; begin _f_ := static function(s:string):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(s); end function gtk_menu_item_new():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end procedure gtk_menu_item_set_submenu(mb:pointer;mi:pointer); begin _f_ := static procedure(mb:pointer;mi:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(mb,mi); end procedure gtk_menu_item_set_use_underline(mi:pointer;l:integer); begin _f_ := static procedure(mi:pointer;l:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(mi,l); end function gtk_separator_menu_item_new():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function gtk_menu_new():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end procedure gtk_menu_item_select(mi:pointer); begin _f_ := static procedure(mi:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(mi); end function gtk_check_menu_item_new():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function gtk_check_menu_item_new_with_label(s:string):pointer; begin _f_ := static function(s:string):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(s); end procedure gtk_check_menu_item_set_active(cmi:pointer;ck:integer); begin _f_ := static procedure(cmi:pointer;ck:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(cmi,ck); end function gtk_check_menu_item_get_active(cmi:pointer):integer; begin _f_ := static function(cmi:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(cmi); end procedure gtk_check_menu_item_toggled(cmi:pointer); begin _f_ := static procedure(cmi:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(cmi); end function gtk_menu_item_get_label(mi:pointer):string; begin _f_ := static function(mi:pointer):string;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(mi); end procedure gtk_menu_item_set_label(mi:pointer;l:string); begin _f_ := static procedure(mi:pointer;l:string);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(mi,l); end procedure gtk_menu_set_title(mi:pointer;l:string); begin _f_ := static procedure(mi:pointer;l:string);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(mi,l); end procedure gtk_menu_reorder_child(mb:pointer;mi:pointer;id:integer); begin _f_ := static procedure(mb:pointer;mi:pointer;id:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(mb,mi,id); end procedure gtk_menu_popup(menu:pointer;parent_menu_shell:pointer;parent_menu_item:pointer;func:pointer;data:pointer;button:integer;activate_time:integer); begin _f_ := static procedure(menu:pointer;parent_menu_shell:pointer;parent_menu_item:pointer;func:pointer;data:pointer;button:integer;activate_time:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(menu,parent_menu_shell,parent_menu_item,func,data,button,activate_time); end procedure gtk_menu_popup_at_rect(menu:pointer;rect_window:pointer;var rect : array of integer;rect_anchor:pointer;menu_anchor:pointer;trigger_event:pointer); begin _f_ := static procedure(menu:pointer;rect_window:pointer;var rect : array of integer;rect_anchor:pointer;menu_anchor:pointer;trigger_event:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(menu,rect_window,rect,rect_anchor,menu_anchor,trigger_event); end procedure gtk_menu_popup_at_pointer(mi:pointer;evt:pointer); begin _f_ := static procedure(mi:pointer;evt:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(mi,evt); end procedure gtk_menu_item_activate(mi:pointer); begin _f_ := static procedure(mi:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(mi); end /////////////////////////// adjust scroll ///////////////////////////////// function gtk_adjustment_get_type():pointer; begin _f_ := static function():pointer; cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function GTK_ADJUSTMENT(w); begin return g_type_check_instance_cast(w,gtk_adjustment_get_type()); end function gtk_adjustment_new(v:double;lower:double;upper:double;step_increment:double;page_increment:double;page_size:double):pointer; begin _f_ := static function(v:double;lower:double;upper:double;step_increment:double;page_increment:double;page_size:double):pointer; cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(v,lower,upper,step_increment,page_increment,page_size); end function gtk_adjustment_get_value(adj:pointer):double; begin _f_ := static function(adj:pointer):double; cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(adj); end procedure gtk_adjustment_set_value(adj:pointer;v:double); begin _f_ := static procedure(adj:pointer;v:double); cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(adj,v); end procedure gtk_adjustment_set_page_size(adj:pointer;v:double); begin _f_ := static procedure(adj:pointer;v:double); cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(adj,v); end procedure gtk_adjustment_changed(adj:pointer); begin _f_ := static procedure(adj:pointer); cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(adj); end procedure gtk_adjustment_value_changed(adj:pointer); begin _f_ := static procedure(adj:pointer); cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(adj); end procedure gtk_adjustment_set_lower(adj:pointer;v:double); begin _f_ := static procedure(adj:pointer;v:double);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(adj,v); end procedure gtk_adjustment_set_upper(adj:pointer;v:double); begin _f_ := static procedure(adj:pointer;v:double);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(adj,v); end function gtk_adjustment_get_upper(adj:pointer):double; begin _f_ := static function(adj:pointer):double;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(adj); end function gtk_adjustment_get_lower(adj:pointer):double; begin _f_ := static function(adj:pointer):double;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(adj); end function gtk_hscrollbar_new(adj:pointer):pointer; begin _f_ := static function(adj:pointer):pointer; cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(adj); end function gtk_vscrollbar_new(adj:pointer):pointer; begin _f_ := static function(adj:pointer):pointer; cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(adj); end procedure gtk_adjustment_configure(adj:pointer;v:double;lower:double;upper:double;step_increment:double;page_increment:double;page_size:double); begin _f_ := static procedure(adj:pointer;v:double;lower:double;upper:double;step_increment:double;page_increment:double;page_size:double);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(adj,v,lower,upper,step_increment,page_increment,page_size); end //////////////////////////////////////////////////// function gtk_frame_new(lbl:string):pointer; begin _f_ := static function(lbl:string):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(lbl); end function gtk_calendar_new():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end ///////////////////////////////// function gtk_spinner_new():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end procedure gtk_spinner_start(spn:pointer); begin _f_ := static procedure(spn:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(spn); end procedure gtk_spinner_stop(spn:pointer); begin _f_ := static procedure(spn:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(spn); end /////////////////////////////// // function gtk_progress_bar_new():pointer;cdecl;external 'libgtk-3.so'; // procedure gtk_progress_bar_set_text(pb:pointer;t:string);cdecl;external 'libgtk-3.so'; // procedure gtk_progress_bar_set_show_text(pb:pointer;s:integer);cdecl;external 'libgtk-3.so'; // procedure gtk_progress_bar_set_fraction(pb:pointer;p:double);cdecl;external 'libgtk-3.so'; // procedure gtk_progress_bar_set_pulse_step(pb:pointer;p:double);cdecl;external 'libgtk-3.so'; // function gtk_progress_bar_get_fraction(pb:pointer):double;cdecl;external 'libgtk-3.so'; // function gtk_progress_bar_set_inverted(pb:pointer;v:integer);cdecl;external 'libgtk-3.so'; // procedure gtk_progress_bar_pulse(pb:pointer);cdecl;external 'libgtk-3.so'; //procedure gtk_progress_configure(pb:pointer;v:double;min:double;max:double);cdecl;external 'libgtk-3.so'; //////////////////////////////label///////////////////////////////////// function gtk_label_new(t:string):pointer; begin _f_ := static function(t:string):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(t); end procedure gtk_misc_set_padding (misc:pointer;x:integer;y:integer); begin _f_ := static procedure (misc:pointer;x:integer;y:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(misc,x,y); end // function gtk_label_new(t:string):pointer;cdecl;external 'libgtk-3.so'; // function gtk_label_get_text(w:pointer):string;cdecl;external 'libgtk-3.so'; // procedure gtk_label_set_text(l:pointer;t:string);cdecl;external 'libgtk-3.so'; // procedure gtk_label_set_selectable(l:pointer;s:integer);cdecl;external 'libgtk-3.so'; // procedure gtk_label_set_markup(l:pointer;t:string);cdecl;external 'libgtk-3.so'; //////////////// button btn ///////////////// // function gtk_button_get_label(b:pointer):string;cdecl;external 'libgtk-3.so'; // function gtk_button_get_event_window(b:pointer):pointer;cdecl;external 'libgtk-3.so'; function gtk_button_new_with_label(c:string); begin _f_ := static function(c:string):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(c); end // function gtk_button_new():pointer;cdecl;external 'libgtk-3.so'; // function gtk_check_button_new():pointer;cdecl;external 'libgtk-3.so'; // function gtk_check_button_new_with_label(l:string):pointer;cdecl;external 'libgtk-3.so'; // function gtk_radio_button_new(g:pointer):pointer;cdecl;external 'libgtk-3.so'; // function gtk_radio_button_new_from_widget(g:pointer):pointer;cdecl;external 'libgtk-3.so'; // procedure gtk_toggle_button_set_active(tg:pointer;ac:integer);cdecl;external 'libgtk-3.so'; // function gtk_toggle_button_get_active(tg:pointer):integer;cdecl;external 'libgtk-3.so'; // procedure gtk_button_clicked(b:pointer);cdecl;external 'libgtk-3.so'; // procedure gtk_radio_button_set_group(rbtn:pointer;lst:pointer);cdecl;external 'libgtk-3.so'; ////////////////////////// dialog /////////////////////////////////////////////////////////// function gtk_dialog_run(d:pointer):integer; begin _f_ := static function(d:pointer):integer; cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(d); end procedure gtk_dialog_response(w:pointer;id:integer); begin _f_ := static procedure(w:pointer;id:integer); cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,id); end function gtk_file_chooser_dialog_new(t:string;p:pointer;act:integer;bstring1:string;bvalue1:integer;bstring2:string;bvalue2:integer;pend:pointer):pointer ; begin _f_ := static function(t:string;p:pointer;act:integer;bstring1:string;bvalue1:integer;bstring2:string;bvalue2:integer;pend:pointer):pointer ; cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(t,p,act,bstring1,bvalue1,bstring2,bvalue2,pend); end function gtk_file_chooser_get_filename(p:pointer):string; begin _f_ := static function(p:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); pp := ##_f_(p); return p_to_str(pp); end function gtk_file_chooser_set_filename(p:pointer;n:string):integer; begin _f_ := static function(p:pointer;n:string):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(p,n); end procedure gtk_file_chooser_set_select_multiple(p:pointer;m:integer); begin _f_ := static procedure(p:pointer;m:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(p,m); end function gtk_file_chooser_get_filenames(p:pointer):pointer ; begin _f_ := static function(p:pointer):pointer ;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(p); end function gtk_font_chooser_dialog_new(t:string;p:pointer):pointer; begin _f_ := static function(t:string;p:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(t,p); end function gtk_font_selection_dialog_new(t:string):pointer; begin _f_ := static function(t:string):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(t); end function gtk_font_selection_dialog_get_font_name(d:pointer):string; begin _f_ := static function(d:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); p := ##_f_(d); return p_to_str(p); end {function gtk_font_selection_dialog_get_preview_text(p:pointer):string; begin _f_ := static function(p:pointer):string;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(p); end} procedure gtk_font_selection_dialog_set_preview_text(p:pointer;t:string); begin _f_ := static procedure(p:pointer;t:string); cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(p,t); end function gtk_font_selection_dialog_set_font_name(p:pointer;f:string):integer; begin _f_ := static function(p:pointer;f:string):integer; cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(p,f); end procedure gtk_widget_modify_font(w:pointer;p:pointer); begin _f_ := static procedure(w:pointer;p:pointer); cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,p); end function gtk_color_selection_dialog_get_type():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end procedure gtk_color_selection_set_current_color(w:pointer;c:pointer); begin _f_ := static procedure(w:pointer;c:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,c); end procedure gtk_color_selection_set_current_rgba(w:pointer;c:pointer); begin _f_ := static procedure(w:pointer;c:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,c); end procedure gtk_color_selection_get_current_rgba(w:pointer;c:pointer); begin _f_ := static procedure(w:pointer;c:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,c); end procedure gtk_color_selection_get_current_color(w:pointer;c:pointer); begin _f_ := static procedure(w:pointer;c:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,c); end procedure gtk_color_selection_set_has_opacity_control(w:pointer;c:integer); begin _f_ := static procedure(w:pointer;c:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,c); end procedure gtk_color_selection_set_has_palette(w:pointer;c:integer); begin _f_ := static procedure(w:pointer;c:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,c); end function gdk_color_parse(cs:string;c:pointer):integer; begin _f_ := static function(cs:string;c:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(cs,c); end /////////////////////////////////////////////////// function gdk_event_new(t:integer):pointer; begin _f_ := static function(t:integer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(t); end ////////////////// evntbox //////////////////////////// function gtk_event_box_new():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end //获得image function GTK_WIDGET(w); //gtkwidget begin wt := static gtk_widget_get_type(); return g_type_check_instance_cast(w,wt); return w; end function GTK_CONTAINER(w);//gtk容器 begin wt := static gtk_container_get_type(); return g_type_check_instance_cast(w,wt); end function GTK_WINDOW(w);//gtkwindow begin wt := static gtk_window_get_type(); return g_type_check_instance_cast(w,wt); return w; end function GTK_IS_WINDOW(w);//gtkwindow begin wt := static gtk_window_get_type(); return g_type_check_instance_is_a(w,wt); return w; end function GDK_WINDOW(w); //gdkwindow begin wt := static gdk_window_get_type(); return g_type_check_instance_cast(w,wt); return w; end function GTK_COLOR_SELECTION_DIALOG(W); begin return g_type_check_instance_cast(w,gtk_color_selection_dialog_get_type()); end procedure gtk_widget_set_parent_window(w:pointer;p:pointer); begin _f_ := static procedure(w:pointer;p:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,p); end procedure gtk_widget_get_parent_window(w:pointer;p:pointer); begin _f_ := static procedure(w:pointer;p:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,p); end function gtk_widget_get_type():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end procedure gtk_widget_modify_bg(w:pointer;tyle:integer;c:pointer); begin _f_ := static procedure(w:pointer;tyle:integer;c:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,tyle,c); end procedure gtk_layout_move(l:pointer;w:pointer;x:integer;y:integer); begin _f_ := static procedure(l:pointer;w:pointer;x:integer;y:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(l,w,x,y); end procedure gtk_grab_add(w:pointer); begin _f_ := static procedure(w:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end procedure gtk_widget_destroy(w:pointer); begin _f_ := static procedure(w:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end function g_thread_self():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function gtk_get_major_version ():integer; begin _f_ := static function():integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function gtk_get_micro_version ():integer; begin _f_ := static function():integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function gtk_main_level():integer; begin _f_ := static function():integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function g_signal_connect_data(instance:pointer; detailed_signal:string; c_handler:pointer;data:pointer;dd:pointer;f:integer):pointer; //gulong begin _f_ := static function(instance:pointer; detailed_signal:string; c_handler:pointer;data:pointer;dd:pointer;f:integer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(instance,detailed_signal,c_handler,data,dd,f); end procedure g_signal_handler_disconnect(instance:pointer;id:pointer); //gulong begin _f_ := static procedure(instance:pointer;id:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(instance,id); end function g_signal_new(signal_name:string;itype:pointer;signal_flags:integer;class_offset:integer;accumulator:pointer;accu_data:pointer;c_marshaller:pointer;return_type:pointer;n_params:integer;p1:pointer;p2:pointer):integer; begin _f_ := static function(signal_name:string;itype:pointer;signal_flags:integer;class_offset:integer;accumulator:pointer;accu_data:pointer;c_marshaller:pointer;return_type:pointer;n_params:integer;p1:pointer;p2:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(signal_name,itype,signal_flags,class_offset,accumulator,accu_data,c_marshaller,return_type,n_params,p1,p2); end procedure g_signal_emit_by_name(w:pointer;n:string;p1:pointer;p2:pointer); begin _f_ := static procedure(w:pointer;n:string;p1:pointer;p2:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w,n,p1,p2); end function gtk_container_get_type():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function gtk_window_get_type():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function gdk_window_get_type():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function g_type_check_instance_cast(instance:pointer;ty:pointer):pointer; begin _f_ := static function(instance:pointer;ty:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(instance,ty); end function gtk_window_new(lev:integer):pointer; begin _f_ := static function(lev:integer):pointer; cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(lev); end function gdk_backend_is_wayland(); //wayland 判断 begin return static is_wayland(); end procedure gdk_window_set_back_pixmap(window:pointer;pixmap:pointer;parent_relative:integer); begin _f_ := static procedure(window:pointer;pixmap:pointer;parent_relative:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(window,pixmap,parent_relative); end procedure gdk_pixbuf_ref(pixbuf:pointer); begin _f_ := static procedure(pixbuf:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(pixbuf); end procedure gdk_pixbuf_unref(pixbuf:pointer); begin _f_ := static procedure(pixbuf:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(pixbuf); end function gdk_cursor_new(c:integer):pointer; begin _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()); return ##_f_(w,c); end function gtk_widget_get_root_window(g:pointer):pointer; begin _f_ := static function(g:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(g); end function gtk_widget_get_window(g:pointer):pointer; begin _f_ := static function(g:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(g); end procedure gtk_window_get_position(g:pointer;var x:integer;var y:integer); begin _f_ := static procedure(g:pointer;var x:integer;var y:integer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(g,x,y); end function gtk_image_new_from_file(f:string):pointer; begin _f_ := static function(f:string):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(f); end procedure gtk_widget_show_all(window:pointer); begin _f_ := static procedure(window:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(window); end procedure gtk_window_maximize(window:pointer); begin _f_ := static procedure(window:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(window); end procedure gtk_widget_show(window:pointer); begin _f_ := static procedure(window:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(window); end procedure gtk_widget_show_now(window:pointer); begin _f_ := static procedure(window:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(window); end procedure gtk_widget_hide(window:pointer); begin _f_ := static procedure(window:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(window); end //-lgtk-x11-2.0 -lgdk-x11-2.0 -lpangocairo-1.0 -latk-1.0 -lcairo -lgdk_pixbuf-2.0 -lgio-2.0 //-lpangoft2-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lharfbuzz -lfontconfig -lfreetype //procedure gdk_pixbuf_render_pixmap_and_mask(pixbuf:pointer;var pixmap_return:int64;var mask_return:int64;alpha_threshold:integer); cdecl;external 'libgtk-x11-2.0.so'; //function gtk_image_get_pixbuf (image:pointer):pointer; cdecl;external 'libgtk-x11-2.0.so'; //function gdk_pixbuf_copy(image:pointer):pointer; cdecl;external 'libgtk-x11-2.0.so'; procedure gtk_image_set_from_file (img:pointer;filename:string); begin _f_ := static procedure(img:pointer;filename:string);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(img,filename); end function gtk_image_new_from_pixbuf(image:pointer):pointer; begin _f_ := static function(image:pointer):pointer; cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(image); end function gtk_image_new():pointer; begin _f_ := static function():pointer; cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function gdk_pixbuf_get_from_window(wd:pointer;x:integer;y:integer;w:integer;h:integer):pointer; begin _f_ := static function(wd:pointer;x:integer;y:integer;w:integer;h:integer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(wd,x,y,w,h); end function gdk_window_create_similar_surface(wd:pointer;ctx:integer;w:integer;h:integer):pointer; begin _f_ := static function(wd:pointer;ctx:integer;w:integer;h:integer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(wd,ctx,w,h); end function gdk_pixbuf_get_width(src_pixbuf:pointer):integer; begin _f_ := static function(src_pixbuf:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(src_pixbuf); end function gdk_pixbuf_get_height(src_pixbuf:pointer):integer; begin _f_ := static function(src_pixbuf:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(src_pixbuf); end ////////////////////libc//////////////////////////////// function popen(e:string;f:string):pointer; begin _f_ := static function(e:string;f:string):pointer;cdecl;external getfuncptrbyname("libc",functionname()); return ##_f_(e,f); end function pclose(p:pointer):integer; begin _f_ := static function(p:pointer):integer;cdecl;external getfuncptrbyname("libc",functionname()); return ##_f_(p); end function fgets(var e:string;f:integer;ptr:pointer):pointer; begin _f_ := static function(var e:string;f:integer;ptr:pointer):pointer;cdecl;external getfuncptrbyname("libc",functionname()); return ##_f_(e,f,ptr); end function getcwd(); begin s := ""; n := 260; setlength(s,n); _f_ := static function(s : string ;len:integer):string;cdecl;external getdlsymaddress("libc.so.6",functionname()); if ##_f_(s,n)=0 then return ""; for i:= 1 to n do begin if s[i]="\0" then begin return s[1:(i-1)]; end end return ""; end function exec_command_line(cmd) //执行linux命令 begin len := 1024; buf_ps := ""; setlength(buf_ps,len); result := ""; ptr:=popen(cmd, "r"); if((ptr)<>0) then begin while(fgets(buf_ps, len-1, ptr)<>0) do begin for i:= 1 to len-1 do begin vi := buf_ps[i]; if vi="\0" then begin break; end end if i>1 then result += buf_ps[1:(i-1)]; end pclose(ptr); end return result; end function get_proc_comand(); //获得进程命令行 begin tempdir := sysgetenv("HOME")+"/.tslvcl/proc/"+inttostr(datetoint(date()))+"-"+inttostr(integer(time()*24*60*60)); f := tempdir+"/1.txt"; CreateDirWithFileName(f); dir := %% /proc/%%; d := filelist("",dir+"*"); f2b := tempdir+"/"; r := array(); for i,v in d do begin n := v["FileName"]; if n="." or n=".." then continue; f := dir+n+"/cmdline"; if not fileexists("",f) then continue; //sz := filesize("",f); f2 := f2b+n; filecopy("",f,"",f2); ri := readfile(rwraw(),"",f2,0,filesize("",f2),fd); if ri=1 and fd then begin r[n] := replacetext(fd,"\0"," "); end end return r; end end type _cairo_matrix_t = class(tslcstructureobj) private static SSTRUCT; class function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate( array( ("xx","double",0), ("yx","double",0), ("xy","double",0), ("yy","double",0), ("x0","double",0), ("y0","double",0) ));//,nil,nil,4); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); end property xx index "xx" read _getvalue_ write _setvalue_; property yx index "yx" read _getvalue_ write _setvalue_; property xy index "xy" read _getvalue_ write _setvalue_; property yy index "yy" read _getvalue_ write _setvalue_; property x0 index "x0" read _getvalue_ write _setvalue_; property y0 index "y0" read _getvalue_ write _setvalue_; end type _cairo_text_extents_t = class(tslcstructureobj) private static SSTRUCT; class function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate( array( ("x_bearing","double",0), ("y_bearing","double",0), ("width","double",0), ("height","double",0), ("x_advance","double",0), ("y_advance","double",0) ));//,nil,nil,4); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); end property x_bearing index "x_bearing" read _getvalue_ write _setvalue_; property y_bearing index "y_bearing" read _getvalue_ write _setvalue_; property width index "width" read _getvalue_ write _setvalue_; property height index "height" read _getvalue_ write _setvalue_; property x_advance index "x_advance" read _getvalue_ write _setvalue_; property y_advance index "y_advance" read _getvalue_ write _setvalue_; end type _cairo_font_extents_t = class(tslcstructureobj) private static SSTRUCT; class function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate( array( ("ascent","double",0), ("descent","double",0), ("height","double",0), ("max_x_advance","double",0), ("max_y_advance","double",0) ));//,nil,nil,4); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); end property ascent index "ascent" read _getvalue_ write _setvalue_; property descent index "descent" read _getvalue_ write _setvalue_; property height index "height" read _getvalue_ write _setvalue_; property max_x_advance index "max_x_advance" read _getvalue_ write _setvalue_; property max_y_advance index "max_y_advance" read _getvalue_ write _setvalue_; end type _dlgwidgets = class(tslcstructureobj) private static SSTRUCT; class function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate( array( (0,"intptr",0), (1,"intptr",0), (2,"intptr",0), (3,"intptr",0) ));//,nil,nil,4); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); end end type _GdkGeometry = class(tslcstructureobj) private static SSTRUCT; class function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate( array( ("min_width","int",-1), ("min_height","int",-1), ("max_width","int",-1), ("max_height","int",-1), ("base_width","int",-1), ("base_height","int",-1), ("width_inc","int",-1), ("height_inc","int",-1), ("min_aspect","int",-1), ("max_aspect","int",-1), ("win_gravity","int",-1) ));//,nil,nil,4); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); end property min_width index "min_width" read _getvalue_ write _setvalue_; property min_height index "min_height" read _getvalue_ write _setvalue_; property max_width index "max_width" read _getvalue_ write _setvalue_; property max_height index "max_height" read _getvalue_ write _setvalue_; property base_width index "base_width" read _getvalue_ write _setvalue_; property base_height index "base_height" read _getvalue_ write _setvalue_; property width_inc index "width_inc" read _getvalue_ write _setvalue_; property height_inc index "height_inc" read _getvalue_ write _setvalue_; property min_aspect index "min_aspect" read _getvalue_ write _setvalue_; property max_aspect index "max_aspect" read _getvalue_ write _setvalue_; property GdkGravity index "GdkGravity" read _getvalue_ write _setvalue_; end type _GdkEventButton=class(tslcstructureobj) private static SSTRUCT; class function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array( ("ttype","intptr",0), ("window","intptr",0), ("send_event","byte",0), ("time","int",0), ("x","double",0), ("y","double",0), ("axes","intptr",0), ("state","int",0), ("button","int",0), ("device","intptr",0), ("x_root","double",0), ("y_root","double",0) ));//,nil,nil,4); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); end property ttype index "ttype" read _getvalue_ write _setvalue_; property window index "window" read _getvalue_ write _setvalue_; property send_event index "send_event" read _getvalue_ write _setvalue_; property time index "time" read _getvalue_ write _setvalue_; property x index "x" read _getvalue_ write _setvalue_; property y index "y" read _getvalue_ write _setvalue_; property axes index "axes" read _getvalue_ write _setvalue_; property state index "state" read _getvalue_ write _setvalue_; property button index "button" read _getvalue_ write _setvalue_; property device index "device" read _getvalue_ write _setvalue_; property x_root index "x_root" read _getvalue_ write _setvalue_; property y_root index "y_root" read _getvalue_ write _setvalue_; end type _GdkEventKey=class(tslcstructureobj) private static SSTRUCT; class function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array( ("ttype","intptr",0), ("window","intptr",0), ("send_event","byte",0), ("time","int",0), ("state","int",0), ("keyval","int",0), ("length","int",0), ("str","intptr",0), ("hardware_keycode","short",0), ("group","byte",0), ("is_modifier","int",1) ));//,nil,nil,4); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); end property ttype index "ttype" read _getvalue_ write _setvalue_; property window index "window" read _getvalue_ write _setvalue_; property send_event index "send_event" read _getvalue_ write _setvalue_; property time index "time" read _getvalue_ write _setvalue_; property state index "state" read _getvalue_ write _setvalue_; property keyval index "keyval" read _getvalue_ write _setvalue_; property length index "length" read _getvalue_ write _setvalue_; property hardware_keycode index "hardware_keycode" read _getvalue_ write _setvalue_; property group index "group" read _getvalue_ write _setvalue_; property is_modifier index "is_modifier" read _getvalue_ write _setvalue_; end type _GdkEventConfigure=class(tslcstructureobj) private static SSTRUCT; class function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array( ("ttype","intptr",0), ("window","intptr",0), ("send_event","byte",0), ("x","int",0), ("y","int",0), ("width","int",0), ("height","int",0) ));//,nil,nil,4); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); end property ttype index "ttype" read _getvalue_ write _setvalue_; property window index "window" read _getvalue_ write _setvalue_; property send_event index "send_event" read _getvalue_ write _setvalue_; property x index "x" read _getvalue_ write _setvalue_; property y index "y" read _getvalue_ write _setvalue_; property width index "width" read _getvalue_ write _setvalue_; property height index "height" read _getvalue_ write _setvalue_; end type _GdkEventMotion=class(tslcstructureobj) private static SSTRUCT; class function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array( ("ttype","intptr",0), ("window","intptr",0), ("send_event","byte",0), ("time","int",0), ("x","double",0), ("y","double",0), ("axes","intptr",0), ("state","int",0), ("is_hint","short",0), ("device","intptr",0), ("x_root","double",0), ("y_root","double",0)));//,nil,nil,4); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); end property ttype index "ttype" read _getvalue_ write _setvalue_; property window index "window" read _getvalue_ write _setvalue_; property send_event index "send_event" read _getvalue_ write _setvalue_; property time index "time" read _getvalue_ write _setvalue_; property x index "x" read _getvalue_ write _setvalue_; property y index "y" read _getvalue_ write _setvalue_; property axes index "axes" read _getvalue_ write _setvalue_; property state index "state" read _getvalue_ write _setvalue_; property is_hint index "is_hint" read _getvalue_ write _setvalue_; property device index "device" read _getvalue_ write _setvalue_; property x_root index "x_root" read _getvalue_ write _setvalue_; property y_root index "y_root" read _getvalue_ write _setvalue_; end type _GdkEventScroll=class(tslcstructureobj) private static SSTRUCT; class function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array( ("ttype","intptr",0), ("window","intptr",0), ("send_event","byte",0), ("time","int",0), ("x","double",0), ("y","double",0), ("state","int",0), ("direction","int",0), ("device","intptr",0), ("x_root","double",0), ("y_root","double",0)));//,nil,nil,4); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); end property ttype index "ttype" read _getvalue_ write _setvalue_; property window index "window" read _getvalue_ write _setvalue_; property send_event index "send_event" read _getvalue_ write _setvalue_; property time index "time" read _getvalue_ write _setvalue_; property x index "x" read _getvalue_ write _setvalue_; property y index "y" read _getvalue_ write _setvalue_; property axes index "axes" read _getvalue_ write _setvalue_; property state index "state" read _getvalue_ write _setvalue_; property is_hint index "is_hint" read _getvalue_ write _setvalue_; property device index "device" read _getvalue_ write _setvalue_; property x_root index "x_root" read _getvalue_ write _setvalue_; property y_root index "y_root" read _getvalue_ write _setvalue_; property direction index "direction" read _getvalue_ write _setvalue_; end type _GdkEventAny=class(tslcstructureobj) private static SSTRUCT; class function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array( ("ttype","intptr",0), ("window","intptr",0), ("send_event","byte",0) ));//,nil,nil,4); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); end property ttype index "ttype" read _getvalue_ write _setvalue_; property window index "window" read _getvalue_ write _setvalue_; property send_event index "send_event" read _getvalue_ write _setvalue_; end type _GdkEventFocus=class(tslcstructureobj) private static SSTRUCT; class function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array( ("ttype","intptr",0), ("window","intptr",0), ("send_event","byte",0), ("iin","short",0) ));//,nil,nil,4); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); end property ttype index "ttype" read _getvalue_ write _setvalue_; property window index "window" read _getvalue_ write _setvalue_; property send_event index "send_event" read _getvalue_ write _setvalue_; property iin index "iin" read _getvalue_ write _setvalue_; end type _GdkEventExpose=class(tslcstructureobj) private static SSTRUCT; class function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array( ("ttype","intptr",0), ("window","intptr",0), ("send_event","byte",0), ("area","int[4]",0), ("region","intptr",0), ("count","int",0) ));//,nil,nil,4); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); end property ttype index "ttype" read _getvalue_ write _setvalue_; property window index "window" read _getvalue_ write _setvalue_; property send_event index "send_event" read _getvalue_ write _setvalue_; property area index "area" read _getvalue_ write _setvalue_; end type _GdkEventNoExpose=class(_GdkEventAny) function Create(ptr); begin inherited; end end type _GdkEventVisibility=class(tslcstructureobj) private static SSTRUCT; class function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array( ("ttype","intptr",0), ("window","intptr",0), ("send_event","byte",0), ("state","int",0) ));//,nil,nil,4); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); end property ttype index "ttype" read _getvalue_ write _setvalue_; property window index "window" read _getvalue_ write _setvalue_; property send_event index "send_event" read _getvalue_ write _setvalue_; property state index "state" read _getvalue_ write _setvalue_; end type _GdkEventCrossing=class(tslcstructureobj) private static SSTRUCT; class function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array( ("ttype","intptr",0), ("window","intptr",0), ("send_event","byte",0), ("subwindow","intptr",0), ("time","int",0), ("x","double",0), ("y","double",0), ("x_root","double",0), ("y_root","double",0), ("mode","intptr",0), ("detail","intptr",0), ("focus","int",0), ("state","int",0) ));//,nil,nil,4); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); end property ttype index "ttype" read _getvalue_ write _setvalue_; property window index "window" read _getvalue_ write _setvalue_; end type _GdkEventWindowState=class(tslcstructureobj) private static SSTRUCT; class function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array( ("ttype","intptr",0), ("window","intptr",0), ("send_event","byte",0), ("changed_mask","int",0), ("new_window_state","int",0) ));//,nil,nil,4); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); end property ttype index "ttype" read _getvalue_ write _setvalue_; property window index "window" read _getvalue_ write _setvalue_; property send_event index "send_event" read _getvalue_ write _setvalue_; property changed_mask index "changed_mask" read _getvalue_ write _setvalue_; property new_window_state index "new_window_state" read _getvalue_ write _setvalue_; end type _GtkTextIter=class(tslcstructureobj) static classstruct; class function getstruct(); begin if not classstruct then begin classstruct := MemoryAlignmentCalculate(array( ("dummy1","intptr",0), ("dummy2","intptr",0), ("dummy3","int",0), ("dummy4","int",0), ("dummy5","int",0), ("dummy6","int",0), ("dummy7","int",0), ("dummy8","int",0), ("dummy9","intptr",0), ("dummy10","intptr",0), ("dummy11","int",0), ("dummy12","int",0), ("dummy13","int",0), ("dummy14","intptr",0), ("dummy15","intptr",0) ));//,nil,nil,4); end return classstruct; end function create(ptr); begin class(tslcstructureobj).create(getstruct(),ptr); end end type _Gdkrgba=class(tslcstructureobj) static classstruct; class function getstruct(); begin if not classstruct then begin classstruct := MemoryAlignmentCalculate(array( ("r","double",0), ("g","double",0), ("b","double",0), ("a","double",0))); end return classstruct; end function create(ptr); begin class(tslcstructureobj).create(getstruct(),ptr); end function set_c(c); begin if gtk_rgb_color_rgb(c,r1,g1,b1) then begin r := r1; g := g1; b := b1; end end function get_c(); begin if gtk_rgb_color_rgb2(_getvalue_("r"),_getvalue_("g"),_getvalue_("b"),c) then return c; end function SetRgb(red,green,blue); begin r := red; g := green; b := blue; end property a index "a" read _getvalue_ write _setvalue_; property r index "r" read _getvalue_ write _setvalue_; property g index "g" read _getvalue_ write _setvalue_; property b index "b" read _getvalue_ write _setvalue_; end type _GdkColor=class(tslcstructureobj) static classstruct; class function getstruct(); begin if not classstruct then begin classstruct := MemoryAlignmentCalculate(array( ("p","int",0), ("r","short",0), ("g","short",0), ("b","short",0))); end return classstruct; end function create(ptr); begin class(tslcstructureobj).create(getstruct(),ptr); end function SetRgb(red,green,blue); begin r := red; g := green; b := blue; end property p index "p" read _getvalue_ write _setvalue_; property r index "r" read _getvalue_ write _setvalue_; property g index "g" read _getvalue_ write _setvalue_; property b index "b" read _getvalue_ write _setvalue_; end type _GdkColor=class(tslcstructureobj) static classstruct; class function getstruct(); begin if not classstruct then begin classstruct := MemoryAlignmentCalculate(array( ("p","int",0), ("r","short",0), ("g","short",0), ("b","short",0))); end return classstruct; end function create(ptr); begin class(tslcstructureobj).create(getstruct(),ptr); end function SetRgb(red,green,blue); begin r := red; g := green; b := blue; end property p index "p" read _getvalue_ write _setvalue_; property r index "r" read _getvalue_ write _setvalue_; property g index "g" read _getvalue_ write _setvalue_; property b index "b" read _getvalue_ write _setvalue_; end type _gvaluev = class(tmemoryclass) function create(); begin inherited; end function v_int(); begin return mtool().readint(fptr); end function v_int64(); begin return mtool().readint64(fptr); end function v_double(); begin return mtool().readdouble(fptr); end function v_pointer(); begin return mtool().readptr(fptr); end fptr; end type _Gvalue=class(tslcstructureobj) private static SSTRUCT; class function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array(("g_type","int64",0), ("v1","int64",1), ("v2","int64",0))); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); fdatas := array(new _gvaluev(),new _gvaluev()); end function data(idx); begin r := fdatas[idx>0?1:0]; r.fptr := _getvalueaddr_((idx>0?"v2":"v1")); return r; end function destroy();override; begin inherited; end private fdatas; end /////////////////gdi/////////////////////////////////////////// type ttgtk_pen=class(tslcstructureobj) private static SSTRUCT; class function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array(("lopenstyle","int",0), ("lopnwidth","int",1), ("lopnwidth2","int",0), ("lopncolor","int",0))); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); _wapi := gettswin32api(); end function destroy();override; begin ht := _getptr_(); inherited; _wapi.gtk_object_set_data(ht); end property style index "lopenstyle" read _getvalue_ write _setvalue_; property width index "lopnwidth" read _getvalue_ write _setvalue_; property color index "lopncolor" read _getvalue_ write _setvalue_; private _wapi; end type ttgtk_brush=class(tslcstructureobj) private static SSTRUCT; class function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array(("lbstyle","int",0), ("lbcolor","int",crColor), ("lbhatch","intptr",0))); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); _wapi := gettswin32api(); end function destroy();override; begin ht := _getptr_(); inherited; _wapi.gtk_object_set_data(ht); end property style index "lbstyle" read _getvalue_ write _setvalue_; property hatch index "lbhatch" read _getvalue_ write _setvalue_; property color index "lbcolor" read _getvalue_ write _setvalue_; private _wapi; end type ttgtk_font=class(tslcstructureobj) private static SSTRUCT; class function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate(array( ("height","int",15), ("width","int",0), ("escapement","int",0), ("orientation","int",0), ("weight","int",400), ("italic","byte",0), ("underline","byte",0), ("strikeout","byte",0), ("charset","byte",134), ("outprecision","byte",3), ("clipprecision","byte",2), ("quality","byte",1), ("pitchandfamily","byte",0), ("facename","char[32]","新宋体"))); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); _wapi := gettswin32api(); end function destroy();override; begin ht := _getptr_(); inherited; _wapi.gtk_object_set_data(ht); end property height index "height" read _getvalue_ write _setvalue_; property width index "width" read _getvalue_ write _setvalue_; property escapement index "escapement" read _getvalue_ write _setvalue_; property orientation index "orientation" read _getvalue_ write _setvalue_; property weight index "weight" read _getvalue_ write _setvalue_; property italic index "italic" read _getvalue_ write _setvalue_; property underline index "underline" read _getvalue_ write _setvalue_; property strikeout index "strikeout" read _getvalue_ write _setvalue_; property charset index "charset" read _getvalue_ write _setvalue_; property outprecision index "outprecision" read _getvalue_ write _setvalue_; property clipprecision index "clipprecision" read _getvalue_ write _setvalue_; property quality index "quality" read _getvalue_ write _setvalue_; property pitchandfamily index "pitchandfamily" read _getvalue_ write _setvalue_; property facename index "facename" read _getvalue_ write _setvalue_; private _wapi; end //////////////////////////////////////////额外定义的结构体 为了适应windows api/////////////////////////////////////////// type TSystemTime = class(tslcstructureobj) private static SSTRUCT; function getstruct() begin if not SSTRUCT then SSTRUCT := MemoryAlignmentCalculate( array( ("wYear","short",0), ("wMonth","short",0), ("wDayOfWeek","short",0), ("wDay","short",0), ("wHour","short",0), ("wMinute","short",0), ("wSecond","short",0), ("wMilliseconds","short",0) )); return SSTRUCT; end public function create(ptr) begin inherited create(getstruct(),ptr); end property wYear index "wYear" read _getvalue_ write _setvalue_ ; property wMonth index "wMonth" read _getvalue_ write _setvalue_ ; property wDay index "wDay" read _getvalue_ write _setvalue_ ; end type tagNMSELCHANGE=class(tslcstructureobj) private static SSTRUCT; structdata; pstruct; function getstruct(); begin if not SSTRUCT then begin ar1:=array( ("wYear","short",0), ("wMonth","short",0), ("wDayOfWeek","short",0), ("wDay","short",0), ("wHour","short",0), ("wMinute","short",0), ("wSecond","short",0), ("wMilliseconds","short",0) ); ar3:=array( ("nmhdr","user",(("hwndfrom","intptr",0),("idfrom","intptr",0),("code","int",0))), ("stselstart","user",ar1), ("stselend","user",ar1)); SSTRUCT:=MemoryAlignmentCalculate(ar3); end return SSTRUCT; end public function create(p); begin inherited create(getstruct(),p); end function SetDataa(y,m,d); begin v := _getvalue_("stselstart"); if ifobj(v) then begin v._setvalue_("wYear",y); v._setvalue_("wMonth",m+1); v._setvalue_("wDay",d); end end end /////////////////////////////////额外定义的结构体 为了适应windows api/////////////////////////////////////////// type _gslist =class(tslcstructureobj) static classstruct; class function getstruct(); begin if not classstruct then begin classstruct := MemoryAlignmentCalculate( array( ("data","intptr",0), ("next","intptr",0)));//,nil,nil,4); end return classstruct; end function create(ptr); begin class(tslcstructureobj).create(getstruct(),ptr); end property data index "data" read _getvalue_ write _setvalue_ ; property next index "next" read _getvalue_ write _setvalue_ ; end { type tenterouterlist = class function push(d); begin FIndex++; FList[FIndex] := d; end function lock(); begin FLock := true; end function unlock(); begin FLock := false; end function feach(); begin return FList[FIndex]; end function inner(h); begin for i,v in FList do begin if v=h then return true; end return false; end function pop(d); begin for i := 0 to length(FList)-1 do begin if d=FList[i] then begin deleteindex(FList,i,true); FIndex--; end end end function MouseIsMoved(ptr:pointer):integer;cdecl; begin if FTimer._getvalue_(0)=0 then return 0; if FLock then return 1; id := FList[FIndex]; if not id then return 1; ps := array(0,0); _wapi.GetCursorPos(ps); if FCpos = ps then return 1; FCpos := ps; if Mousehittest then call(Mousehittest,self,id); if Mousemovecall then call(Mousemovecall,self,id); return 1; end function create(api); begin _wapi := api; FCpos := array(0,0); _wapi.GetCursorPos(FCpos); FList := array(); FIndex := -1; Fscrolltimedo := makeinstance(thisfunction(MouseIsMoved)); FTimer:= new ttmstruct(nil); rt := _wapi.g_timeout_add(30,Fscrolltimedo,FTimer._getptr_() ); //30毫秒 FTimer._setvalue_(0,rt); end function destroy(); begin FIndex := -1; FList := array(); if FTimer then begin FTimer._setvalue_(0,0); //FTimer.stop(); //FTimer := nil; end end Mousemovecall; Mousehittest; _wapi; FCpos; private FLock; FIndex ; FList; FTimer; //20230314 修正此处问题 end } type tgtk_ctl_object = class(_gtkeventtype) private fwindow_cursor; //当前的cursor FHitwidgetposition; static FsysCursors; Fsyscommand0x12; Fsyscommand0x12info; protected //////////////////////样式//////// Fdwstyle; FExdwstyle; /////////////////////////////////// function CanignoreBtnpress();virtual; //忽略 begin // return false; return true; end public function Create(h); //构造 begin if not _wapi then begin _const := getwin32const(); _wapi := gettswin32api(); FsysCursors := array(); 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; end static FLastPosition; class function mywidgetmousehit(id,p); begin return executeMessageA(id,_const.WM_NCHITTEST,0,makelong(p[0],p[1])); end class function mywidgetmousemovecall(id,p); begin if hasMessageFromGtkMessageQueue(id,_const.WM_MOUSEMOVE) then return ; mp := makelong(p[0],p[1]); global g_gtk_keytable,g_gtk_buttontable; wp := 0; if g_gtk_keytable[0x10] then wp .|= 0x0004; if g_gtk_keytable[0x11] then wp .|= 0x0008; wp .|= g_gtk_buttontable[0]; wp .|= g_gtk_buttontable[1]; AddMessageToGtkMessageQueue(id,_const.WM_MOUSEMOVE,wp,mp,0); end class function widgetmousehit(nfer,id); begin _wapi.GetCursorPos(p); return executeMessageA(id,_const.WM_NCHITTEST,0,makelong(p[0],p[1])); end class function widgetmousemovecall(nfer,id); begin if hasMessageFromGtkMessageQueue(id,_const.WM_MOUSEMOVE) then return ; _wapi.GetCursorPos(p); if FLastPosition=p then return ; FLastPosition := p; //点击测试 //r := CallGtkWinProc(id,_const.WM_NCHITTEST,0,makelong(p[0],p[1])); _wapi.ScreenToClient(id,p); mp := makelong(p[0],p[1]); //CallTslVclProc(id,_const.WM_NCHITTEST,0,makelong(p[0],p[1])); //echo "\r\n",nfer; global g_gtk_keytable,g_gtk_buttontable; wp := 0; if g_gtk_keytable[0x10] then wp .|= 0x0004; if g_gtk_keytable[0x11] then wp .|= 0x0008; wp .|= g_gtk_buttontable[0]; wp .|= g_gtk_buttontable[1]; AddMessageToGtkMessageQueue(id,_const.WM_MOUSEMOVE,wp,mp,0); end function DefaultMessageDo(msg,w,l);virtual; begin //if (FHitwidgetposition <> 0) or (FHitwidgetposition <> 1) then return 0; if (msg = _const.WM_SYSCOMMAND and w = 0xF012) or (msg = _const.WM_NCLBUTTONDOWN and w= _const.HTCAPTION) then //WM_NCLBUTTONDOWN begin Fsyscommand0x12 := true; h := handle; x := _wapi.g_object_get_data(h,"gtk_layout_x"); y := _wapi.g_object_get_data(h,"gtk_layout_y"); cx := _wapi.g_object_get_data(h,"gtk_layout_width"); cy := _wapi.g_object_get_data(h,"gtk_layout_height"); xy := array(0,0); _wapi.GetCursorPos(xy); Fsyscommand0x12info:= array( xy,(x,y,cx,cy) ); end return 0; end function CallTslVclProc(msg,w,l,P);virtual; //调用到win消息处理 begin CM_CURSORCHANGED := _const.CM_CURSORCHANGED; if p then begin return AddMessageToGtkMessageQueue(FHandle,msg,w,l,p); end else begin gfw := class(tUIglobalData).uigetdata("G_F_TWIN_PROC_"); 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); end end else if (msg = _const.WM_NCHITTEST) then begin global g_show_cursor_window; wd := _Wapi.gtk_widget_get_window(FHandle); 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; if fwindow_cursor <> FsysCursors[1] then begin fwindow_cursor := FsysCursors[1]; AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,fwindow_cursor); end end 12,15:begin //g_show_cursor_window := 0; if fwindow_cursor <> FsysCursors[2] then begin fwindow_cursor := 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,fwindow_cursor); end end else begin if _wapi.gtk_object_get_data(FHandle,"gtk_wnd_hs_caption") then return ; rsz := _wapi.gtk_object_get_data(FHandle,"gtk_widget_resizeable"); if rsz then begin lowuperdword(l,lo,hi); ht := _wapi.hittestwidget(FHandle,lo,hi); FHitwidgetposition := ht; if ht=10 or ht=11 then begin //g_show_cursor_window := 0; if fwindow_cursor <> FsysCursors[1] then begin fwindow_cursor := 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; if fwindow_cursor <> FsysCursors[2] then begin fwindow_cursor := 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]; //下面的次序可能交换 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 if not r then begin DefaultMessageDo(msg,w,l); end return r; end end function executeMessage(msg,w,l);virtual; //执行消息 begin return CallTslVclProc(msg,w,l); return 0; end function GetScrollInfo(nBar,si);virtual; begin end function setScrollInfo(nBar,si,redraw);virtual; begin end function GetWidnowLong(idx);virtual; //样式 begin case idx of _const.GWL_EXSTYLE : begin return FExdwstyle; end _const.GWL_STYLE : begin return Fdwstyle; end end ; end function SetWidnowLong(idx,v);virtual; //样式 begin stl := new TSTYLESTRUCT(nil); stl.styleold := 0; case idx of _const.GWL_EXSTYLE : begin if FExdwstyle<>v then begin FExdwstyle := V; stl.stylenew := dwExStyle; CallTslVclProc(_const.WM_STYLECHANGED,_const.GWL_EXSTYLE,stl._getptr_()); end end _const.GWL_STYLE : begin if Fdwstyle <> V then begin Fdwstyle := V; stl.stylenew := v; CallTslVclProc(_const.WM_STYLECHANGED,_const.GWL_STYLE,stl._getptr_()); end end end ; end function widgetsizechanged(h,w);virtual; //大小改变 begin CallTslVclProc(_const.WM_SIZE,0,makelong(w,h)); end function gdk_window_get_state(w:pointer):integegr; begin _f_ := static function(w:pointer):integegr;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(w); end function imitate_event_size();virtual; //模拟移动 begin if _wapi.gtk_object_get_data(Handle,"gtk_wnd_hs_caption") then return false; return true; end function GSWINDOWSTATEEVENT(a,b,c,d);virtual; //状态改变 begin global G_GTK_WINDOW_ACTIVATE; obj := new _GdkEventWindowState(c); st := obj.new_window_state; { cm := obj.changed_mask; if (cm .& 128)=128 then begin hwd := handle; hwd := _wapi.gtk_widget_is_toplevel(hwd)?hwd:_wapi.gtk_widget_get_toplevel(hwd); wp := (128=(st .& 128)); echo "\r\nactivate:",hwd," ",wp; if wp then AddMessageToGtkMessageQueue(hwd,0x6,1,0,0); else AddMessageToGtkMessageQueue(hwd,0x6,0,0,0); //echo "\r\n focus:", handle," ",(128=(st .& 128)); end } if st .& GDK_WINDOW_STATE_MAXIMIZED then begin return CallTslVclProc(_const.WM_SYSCOMMAND ,_const.SC_MAXIMIZE,0); end {if st .& 2 then begin return CallTslVclProc(_const.WM_SYSCOMMAND ,_const.SC_MINIMIZE,0); end if st .& (GDK_WINDOW_STATE_FULLSCREEN) then begin //echo "\r\n full screen"; end if st .& (GDK_WINDOW_STATE_ABOVE) then begin //echo "\r\n above"; end if st .& (GDK_WINDOW_STATE_BELOW) then begin //echo "\r\n below"; end } if st .& (GDK_WINDOW_STATE_FOCUSED) then begin //CallTslVclProc(_const.WM_SETFOCUS ,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 begin AddMessageToGtkMessageQueue(G_GTK_WINDOW_ACTIVATE,0x6,0,0,0); end end AddMessageToGtkMessageQueue(hwd,0x6,1,0,0); G_GTK_WINDOW_ACTIVATE := hwd; //CallTslVclProc(_const.WM_ACTIVATE ,2,0,0); end {GDK_WINDOW_STATE_WITHDRAWN = 1 << 0, GDK_WINDOW_STATE_ICONIFIED = 1 << 1, GDK_WINDOW_STATE_MAXIMIZED = 1 << 2, GDK_WINDOW_STATE_STICKY = 1 << 3, GDK_WINDOW_STATE_FULLSCREEN = 1 << 4, GDK_WINDOW_STATE_ABOVE = 1 << 5, GDK_WINDOW_STATE_BELOW = 1 << 6} return false; end function GSBUTTONPRESSEVENT(a,b,c,d);virtual; begin global g_gtk_buttontable, g_gtk_keytable; e := new _GdkEventButton(c); wp := 0; if ifarray(g_gtk_keytable) then begin if g_gtk_keytable[0x10] then wp .|= 0x0004; if g_gtk_keytable[0x11] then wp .|= 0x0008; 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)); case e.button of 1: begin wp .|=0x1; g_gtk_buttontable[0] := _const.MK_LButton; if FHitwidgetposition in array(10,11,12,15) then begin FHitwidgetposition += 100; h := handle; xy := array(0,0); _wapi.GetCursorPos(xy); Fsyscommand0x12info:= array( xy, (_wapi.g_object_get_data(h,"gtk_layout_x"), _wapi.g_object_get_data(h,"gtk_layout_y"), _wapi.g_object_get_data(h,"gtk_layout_width"), _wapi.g_object_get_data(h,"gtk_layout_height")) ); CallTslVclProc(_const.WM_NCLBUTTONDOWN ,wp,psi); end else begin CallTslVclProc(_const.WM_LBUTTONDOWN ,wp,psi); end end 3: begin wp .|=0x2; g_gtk_buttontable[1] := _const.MK_RButton; CallTslVclProc(_const.WM_RBUTTONDOWN ,wp,psi); end end ; return CanignoreBtnpress(); end function GSMOTIONNOTIFYEVENT(a,b,c,d);virtual; begin global g_gtk_dragxy; e := new _GdkEventMotion(c); //CallTslVclProc(_const.WM_MOUSEMOVE ,0,makelong(integer(e.x),integer(e.y)),true); id := a.handle; mxy := array(); mxy["x"] := e.x; mxy["y"] := e.y; mxy["x_r"] := e.x_root; mxy["y_r"] := e.y_root; _wapi.g_object_set_data(id,"motion_xy",mxy); //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 global g_gtk_buttontable, g_gtk_keytable,g_c_btn_release_event; FHitwidgetposition := 0; Fsyscommand0x12info := nil; e := new _GdkEventButton(c); ev := new _GdkEventButton(nil); ev.CopyFromString(e.CopyToString()); g_c_btn_release_event := ev; psi := makelong(integer(e.x),integer(e.y)); wp := 0; if ifarray(g_gtk_keytable) then begin if g_gtk_keytable[0x10] then wp .|= 0x0004; if g_gtk_keytable[0x11] then wp .|= 0x0008; end case e.button of 1: begin wp .|=0x1; g_gtk_buttontable[0] := 0; CallTslVclProc(_const.WM_LBUTTONUP ,wp,psi); end 3:begin wp .|=0x2; g_gtk_buttontable[1] := 0; CallTslVclProc(_const.WM_RBUTTONUP ,wp,psi); //if not hasMessageFromGtkMessageQueue(a.handle,_const.LM_CONTEXTMENU ) then CallTslVclProc(_const.LM_CONTEXTMENU ,a.handle,makelong(integer(e.x_root),integer(e.y_root)),true); end end ; return CanignoreBtnpress(); end function GSFOCUSINEVENT(a,b,c,d);virtual; begin global g_current_get_focus_widget; h := a.handle; e := new _GdkEventAny(c); getfimobj().setclientwindow(e.window); getfimobj().setfocusctl(self); g_current_get_focus_widget := h; //echo "\r\nfocous in >",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 begin CallTslVclProc(_const.WM_SETFOCUS,0,0,0); end //WM_SETFOCUS getfimobj().focusin(); end function GSFOCUSOUTEVENT(a,b,c,d);virtual; begin 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; //echo "\r\n focus out>",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 function gs_key_vent(a,b,c,d); begin global g_gtk_keytable,g_current_get_focus_widget; e := new _GdkEventKey(c); kud := e.ttype; ///////////////////////////////////控制键 kv := e.keyval; {acskey := array( 65505: 0x10, //shift 65506: 0x10, 65507: 0x11, //control 65508: 0x11, 65513: 0x12, //alt 65514: 0x12 );} ///////////////菜单按键 if kv = 65513 or kv = 65514 then begin if kud=8 then begin CallTslVclProc(_const.WM_SYSKEYDOWN ,0x12,0); end else begin CallTslVclProc(_const.WM_SYSKEYUP ,0x12,0); end return true; end notctrlpress := not(kud=8 and (g_gtk_keytable[0x11] or g_gtk_keytable[0x12]) ); // kn := array( // 65288 : _const.VK_BACK, // 65289 : _const.VK_TAB, // 65293 : 13 , //enter // 65307 : _const.VK_ESCAPE, // 65505 : _const.VK_SHIFT, // 65506 : _const.VK_SHIFT, // 65507 : _const.VK_CONTROL, // 65508 : _const.VK_CONTROL, // 65509 : _const.VK_CAPITAL, // 65513 : _const.VK_MENU, // 65514 : _const.VK_MENU, // 65535 : _const.VK_DELETE, // 65379 : _const.VK_INSERT, // 65360 : _const.VK_HOME, // 65361 : _const.VK_LEFT, // 65362 : _const.VK_UP, // 65363 : _const.VK_RIGHT, // 65364 : _const.VK_DOWN, // 65365 : 33, //pageup // 65366 : 34, //pagedown // 65367 : _const.VK_END // //VK_SPACE // ); //r := CallTslVclProc(_const.WM_KEYDOWN ,kv,0); //r := CallTslVclProc(_const.WM_CHAR ,kv,0); //echo "\r\n===handle:",a.handle; ah := a.handle; fcsctl := g_current_get_focus_widget; { if not _wapi.gtk_widget_is_toplevel(ah) then return true ; fcsctl := _wapi.gtk_window_get_focus(ah); echo "\r\nfocus:",fcsctl;} if not fcsctl then begin obj := class(tUIglobalData).uigetdata("tuiapplication"); if obj then fcsctl := obj.handle; else fcsctl := 0; if not fcsctl then return true; end fcsctl := TGtkObjects[inttostr(fcsctl)] ; if not fcsctl then return true; if (kud = 8) and (kv<>65505 or kv<>65506) then begin if getfimobj().presskey(c) then begin //echo "\r\n inputx:" , getfimobj().FCommit; //return true; end else begin //echo "\r\n not char input"; notachar := true; //echo "\r\nkkkkvvv:",kv; end end //echo "\r\nkey fillter ed:",kud,"====",kv; //return 1; case kv of //65513,65514,65506 65288: begin if kud=8 then begin r := fcsctl.CallTslVclProc(_const.WM_KEYDOWN ,_const.VK_BACK,0); if notctrlpress then r := fcsctl.CallTslVclProc(_const.WM_CHAR ,_const.VK_BACK,0); end else begin r := fcsctl.CallTslVclProc(_const.WM_KEYUP ,_const.VK_BACK,0); end end 65289,{---} 65056: //VK_TAB char begin if kud=8 then begin r := fcsctl.CallTslVclProc(_const.WM_KEYDOWN ,_const.VK_TAB,0); if not(g_gtk_keytable[0x11]) then r := fcsctl.CallTslVclProc(_const.WM_CHAR ,_const.VK_TAB,0); end else begin r := fcsctl.CallTslVclProc(_const.WM_KEYUP ,_const.VK_TAB,0); end end 65293: begin if kud=8 then begin r := fcsctl.CallTslVclProc(_const.WM_KEYDOWN ,13,0); if notctrlpress then r := fcsctl.CallTslVclProc(_const.WM_CHAR ,13,0); end else begin r := fcsctl.CallTslVclProc(_const.WM_KEYUP ,13,0); end end 65307: // _const.VK_ESCAPE, begin if kud=8 then begin r := fcsctl.CallTslVclProc(_const.WM_KEYDOWN ,_const.VK_ESCAPE,0); if notctrlpress then r := fcsctl.CallTslVclProc(_const.WM_CHAR ,_const.VK_ESCAPE,0); end else begin r := fcsctl.CallTslVclProc(_const.WM_KEYUP ,_const.VK_ESCAPE,0); end end 65360: //65360 : _const.VK_HOME, begin if kud=8 then begin r := fcsctl.CallTslVclProc(_const.WM_KEYDOWN ,_const.VK_HOME,0); end else begin r := fcsctl.CallTslVclProc(_const.WM_KEYUP ,_const.VK_HOME,0); end end 65361: begin if kud=8 then begin r := fcsctl.CallTslVclProc(_const.WM_KEYDOWN ,_const.VK_LEFT,0); end else begin r := fcsctl.CallTslVclProc(_const.WM_KEYUP ,_const.VK_LEFT,0); end end 65362: begin if kud=8 then begin r := fcsctl.CallTslVclProc(_const.WM_KEYDOWN ,_const.VK_UP,0); end else begin r := fcsctl.CallTslVclProc(_const.WM_KEYUP ,_const.VK_UP,0); end end 65363: begin if kud=8 then begin r := fcsctl.CallTslVclProc(_const.WM_KEYDOWN ,_const.VK_RIGHT,0); end else begin r := fcsctl.CallTslVclProc(_const.WM_KEYUP ,_const.VK_RIGHT,0); end end 65364: begin if kud=8 then begin r := fcsctl.CallTslVclProc(_const.WM_KEYDOWN ,_const.VK_DOWN,0); end else begin r := fcsctl.CallTslVclProc(_const.WM_KEYUP ,_const.VK_DOWN,0); end end 65365: begin if kud=8 then begin r := fcsctl.CallTslVclProc(_const.WM_KEYDOWN ,33,0); end else begin r := fcsctl.CallTslVclProc(_const.WM_KEYUP ,33,0); end end 65366: begin if kud=8 then begin r := fcsctl.CallTslVclProc(_const.WM_KEYDOWN ,34,0); end else begin r := fcsctl.CallTslVclProc(_const.WM_KEYUP ,34,0); end end 65367: begin if kud=8 then begin r := fcsctl.CallTslVclProc(_const.WM_KEYDOWN ,_const.VK_END,0); end else begin r := fcsctl.CallTslVclProc(_const.WM_KEYUP ,_const.VK_END,0); end end 65379: // _const.VK_INSERT, begin if kud=8 then begin r := fcsctl.CallTslVclProc(_const.WM_KEYDOWN ,_const.VK_INSERT,0); end else begin r := fcsctl.CallTslVclProc(_const.WM_KEYUP ,_const.VK_INSERT,0); end end 65505,65506: //_const.VK_SHIFT, begin if kud=8 then begin r := fcsctl.CallTslVclProc(_const.WM_KEYDOWN ,_const.VK_SHIFT,0); end else begin r := fcsctl.CallTslVclProc(_const.WM_KEYUP ,_const.VK_SHIFT,0); end end 65507,65508: //, //_const.VK_CONTROL begin if kud=8 then begin r := fcsctl.CallTslVclProc(_const.WM_KEYDOWN ,_const.VK_CONTROL,0); end else begin r := fcsctl.CallTslVclProc(_const.WM_KEYUP ,_const.VK_CONTROL,0); end end 65509: // _const.VK_CAPITAL, begin if kud=8 then begin r := fcsctl.CallTslVclProc(_const.WM_KEYDOWN ,_const.VK_CAPITAL,0); end else begin r := fcsctl.CallTslVclProc(_const.WM_KEYUP ,_const.VK_CAPITAL,0); end end 65513,65514: //WM_SYSKEYUP ,WM_SYSKEYDOWN begin //_const.VK_MENU, end 65535: //_const.VK_DELETE, begin if kud=8 then begin r := fcsctl.CallTslVclProc(_const.WM_KEYDOWN ,_const.VK_DELETE,0); end else begin r := fcsctl.CallTslVclProc(_const.WM_KEYUP ,_const.VK_DELETE,0); end end 65470 to ( 65470+24): begin if kud=8 then begin r := fcsctl.CallTslVclProc(_const.WM_KEYDOWN ,kv-65470+0x70,0); end else begin r := fcsctl.CallTslVclProc(_const.WM_KEYUP ,kv-65470+0x70,0); end end else begin keymapb := static array( 96:192, 45:189, 61:187, 91:219, 93:221, 92:220, 59:186, 39:222, 44:188, 46:190, 47:191, 40:57, 33:49, 64:50, 35:51, 36:52, 37:53, 94:54, 38:55, 42:56, 41:48, 126:192 ); if {notachar and} kud=8 then //去掉notkey begin if kv>=97 and kv<=122 then kv := kv-32; else begin kv2 := keymapb[kv]; if kv2 then kv := kv2; end r := fcsctl.CallTslVclProc(_const.WM_KEYDOWN ,{_xor(32,kv)}kv,0); //if notctrlpress then r := CallTslVclProc(_const.WM_CHAR , kv,0); end else if kud=9 then begin if kv>=97 and kv<=122 then kv := kv-32; else begin kv2 := keymapb[kv]; if kv2 then kv := kv2; end r := fcsctl.CallTslVclProc(_const.WM_KEYUP ,{_xor(32,kv)}kv,0); end end end ; return true; end function GtkEventDispatchA(a,b,c,d);//gtk消息分发 begin mn := GetGtkEventNameOrId(b); e := new _GdkEventAny(c); if imitate_event_size() then begin 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; return 1; end else if GDK_BUTTON_RELEASE = e.ttype then begin FHitwidgetposition := 0; Fsyscommand0x12info := nil; //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 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 if GDK_BUTTON_RELEASE = e.ttype then begin Fsyscommand0x12 := false; Fsyscommand0x12info := nil; //return ; end end end end case mn of GS_ENTER_NOTIFY_EVENT: begin fwindow_cursor := 0; end GS_DESTROY: begin Fsyscommand0x12 := 0; Fsyscommand0x12info := nil; FHitwidgetposition := 0; r := CallTslVclProc(_const.WM_NCDESTROY ,0,0); end GS_BUTTON_PRESS_EVENT: begin id := a.handle; if not _wapi.g_object_get_data(id,"motion_xy") then begin e := new _GdkEventButton(c); _wapi.g_object_set_data(id,"motion_xy",array("x":e.x,"y":e.y,"x_r":e.x_root,"y_r":e.y_root)); end return GSBUTTONPRESSEVENT(a,b,c,d); end GS_MOTION_NOTIFY_EVENT: begin return GSMOTIONNOTIFYEVENT(a,b,c,d); end GS_BUTTON_RELEASE_EVENT: begin return GSBUTTONRELEASEEVENT(a,b,c,d); end GS_KEY_PRESS_EVENT: 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 r := GtkEventDispatch(a,mn,c,d); return r; end function GtkEventDispatch(a,mn,c,d);virtual; //根据名称处理gtk消息 begin //消息分发 return false; end 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,GS_ENTER_NOTIFY_EVENT); //,"set-focus-child" end function CreateWnd(dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nwidth,nheight,hwndparent,hmenu,hinstance,lpParam);virtual; //构造窗口 begin CallTslVclProc(_const.WM_NCCREATE,0,lpParam); ///////////////////// stl := new TSTYLESTRUCT(nil); stl.styleold := 0; stl.stylenew := dwStyle; CallTslVclProc(_const.WM_STYLECHANGED,_const.GWL_STYLE,stl._getptr_()); stl.styleold := 0; stl.stylenew := dwExStyle; CallTslVclProc(_const.WM_STYLECHANGED,_const.GWL_EXSTYLE,stl._getptr_()); /////////////////////////////////////////////////////////////////////////////////// f := thisfunction(GtkEventDispatchA); for i,v in GtkBaseEventName() do begin Connect(v,f); end ////////////////////////////////////////////////////////////// Fdwstyle := dwStyle; FExdwstyle := dwExStyle; if (_const.WS_DISABLED .& dwStyle)=_const.WS_DISABLED then //enabled处理 begin _wapi.EnableWindow(FHandle,false); end widgetsizechanged(nheight,nwidth); _wapi.g_object_set_data(FHandle,"gtk_widget_resizeable",(_const.WS_SIZEBOX .& dwStyle)=_const.WS_SIZEBOX); return FHandle; end function InitWidgetSize(h,x,y,nwidth,nheight); //设置窗口位置信息 begin _wapi.g_object_set_data(h,"gtk_layout_x",x); _wapi.g_object_set_data(h,"gtk_layout_y",y); _wapi.g_object_set_data(h,"gtk_layout_width",nwidth); _wapi.g_object_set_data(h,"gtk_layout_height",nheight); end function InitContainerList(h); //处理radiobtn 容器问题 begin return ; rlist := _wapi.g_slist_alloc(); gl := new _gslist(rlist); rbtn := _wapi.gtk_radio_button_new(0); gl.data := rbtn; //_wapi.g_object_set_data(h,"gtk_layout_radiolist",rlist); end function DisconnectAll(); //断开所有消息 begin if FHandle=0 then return 0; for i,lnid in FConnectNameIds do begin _wapi.g_signal_handler_disconnect(FHandle,lnid); end FConnectNameIds := array(); FConnectHandlers := array(); 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 Connect(n,f); //连接消息 begin //删除connect //添加connect //connect id if FHandle=0 then return 0; if not ifstring(n) then return 0; ln := FormularSignalName(lowercase(n)); lnid := FConnectNameIds[ln]; if lnid then begin //echo "\r\n========================remove connect:",n; reindex(FConnectNameIds,array(ln:nil)); _wapi.g_signal_handler_disconnect(FHandle,lnid); end //echo "\r\nconnect ===========================",FHandle,"=====",n; eid := GetGtkEventNameOrId(ln); ptr := get_fptr_by_sigal_name(n); if ptr then begin lnid := _wapi.g_signal_connect_data(FHandle, ln, ptr, eid,nil,0); FConnectNameIds[ln] := lnid; FConnectHandlers[inttostr(eid)] := f; end else begin echo "\r\n not find signal callback:",n; end return lnid; end function DefaultDestroyHandler(); begin destroy(); return true; end class function SetWindowLongPtrA(h,idx,v); begin if TGtkObjects then begin o := TGtkObjects[inttostr(h)]; if o then return o.SetWidnowLong(idx,v) ; end end class function widgetsizechangeda(h,aheight,awidth) ; begin if TGtkObjects then begin o := TGtkObjects[inttostr(h)]; if o then return o.widgetsizechanged(aheight,awidth) ; end end class function SetScrollInfoa(h, nBar,lpsi,redraw); begin if TGtkObjects then begin o := TGtkObjects[inttostr(h)]; if o then return o.SetScrollInfo(nBar,lpsi,redraw) ; end end class function GetScrollInfoa(h, nBar,lpsi); begin if TGtkObjects then begin o := TGtkObjects[inttostr(h)]; if o then return o.GetScrollInfo(nBar,lpsi) ; end end class function executeMessageA(h,msg,w,l); begin if TGtkObjects then begin o := TGtkObjects[inttostr(h)]; if o then return o.executeMessage(msg,w,l) ; end end class function GetWindowLongPtrA(H,idx); begin if TGtkObjects then begin o := TGtkObjects[inttostr(h)]; if o then return o.GetWidnowLong(idx,v) ; end end class function CallGtkWinProc(h,msg,w,l); begin if TGtkObjects then begin o := TGtkObjects[inttostr(h)]; if o then return o.CallTslVclProc(msg,w,l) ; end end class function DispatchGtkEventCall(pms); //回调入口 begin if not pms then return 0; o := TGtkObjects[inttostr(pms[0])]; if o then return o.CallGtkEvent(pms); return 0; end function CallGtkEvent(pms); //处理对象函数 begin xxid := pms[1]; c := FConnectHandlers[inttostr(xxid)]; if iffuncptr(c) then begin pms2 := pms; pms2[0] := self; r := callinarray(c,pms2); if needdestroy() then begin if r = 0 and FDestroysignalId=xxid then begin DefaultDestroyHandler(pms); //callinarray(thisfunction(DefaultDestroyHandler),pms); end end return r; end else begin if FDestroysignalId=xxid and needdestroy() then begin DefaultDestroyHandler(pms); //callinarray(thisfunction(DefaultDestroyHandler),pms); end end return true; end function destroy();virtual; //销毁 begin if FHandle<>0 then begin reindex(TGtkObjects,array(inttostr(FHandle):nil)); //_wapi.g_object_unref(FHandle); end FRegisterWMUSER := 0; //tsl_gtk_remove_widget_thread(FHandle); FHandle := 0; FConnectHandlers := array(); FConnectNameIds := array(); FValues := array(); end function SetValue(n,v); begin FValues[n] := v; end function GetValue(n); begin return FValues[n]; end property handle read FHandle write SetHandle; static _wapi; static _const; private FHandle; FConnectNameIds; FConnectHandlers; FValues; FDestroysignalId; static TGtkObjects; Static FinitNewSignaled; function SetHandle(h); begin if FHandle then return 0; initNewSignal(); FConnectNameIds := array(); FConnectHandlers := array(); FValues := array(); FHandle := 0; if h then begin FHandle := h; _wapi.g_object_ref(h); if not ifarray(TGtkObjects) then TGtkObjects := array(); TGtkObjects[inttostr(h)] := self(true); FDestroysignalId := GetGtkEventNameOrId("destroy"); if needdestroy() then Connect("destroy",thisfunction(DefaultDestroyHandler)); return true; end end function initNewSignal(); begin return ; //wm-user if FinitNewSignaled then return ; FinitNewSignaled := true; for i,v in array(_wapi.gtk_widget_get_type()) do begin _wapi.g_signal_new("wm-user", v, 2, 0, nil, nil, 0, 4, 2, 17*4,68); end end f_format_names; function FormularSignalName(n); begin if not ifarray(f_format_names) then f_format_names := array(); r := f_format_names[n]; if r then return r; r := ""; for i := 1 to length(n) do begin vi := n[i]; if vi="_" then r+="-"; else r+=vi; end f_format_names[n] := r; return r; end function needdestroy();virtual; begin return true; end class function getfimobj(); begin if not FImobj then FImobj := new tgtk_im_object(nil); return FImobj; end static FImobj; end type tscrollobject = class() fbar; fadj; fpgcount; fsi; function create(bar,adj,si); begin fbar :=bar; fadj := adj; fsi := si; end end type tgtk_im_object = class(tgtk_ctl_object) function Create(h);override; begin h := _wapi.gtk_im_multicontext_new(); inherited; f := thisfunction(GtkEventDispatchA); //_Wapi.gtk_widget_set_events(h,16777214); for i,v in GtkBaseEventName() do begin //echo "\r\n connect",v,"***", Connect(v,f); end end function GtkEventDispatch(a,mn,c,d);override; //根据名称处理gtk消息 begin case mn of "commit": begin FCommit := ReadStringFromPtr(c); if FCtl then begin s := utf8toansi(FCommit); for i:= 1 to length(s) do begin FCtl.CallTslVclProc(_const.WM_CHAR,ord(s[i]),0); end end end end; end function GtkBaseEventName();override; //绑定的消息 begin return array("commit");//,"preedit-changed","preedit-end","preedit-start","retrieve-surrounding");//"commit","delete-surrounding", //"preedit-start":"do_two_param_event" , // "preedit-changed":"do_two_param_event" , // "preedit-surrounding":"do_two_param_event" , // "preedit-end":"do_two_param_event" , // "commit":"tsl_gtk_normal_event_cb" end function focusin();//focus in begin h := handle; _wapi.gtk_im_context_focus_in(h); end function set_location(); begin h := handle; _wapi.gtk_im_context_set_cursor_location(h,array(50,100,300,300)); end function presskey(c); //focus out begin h := handle; //ps := array(0,0,100,100); //_Wapi.GetCursorPos(ps); //_wapi.gtk_im_context_set_cursor_location(h,ps); return _wapi.gtk_im_context_filter_keypress(h,c); end function focusout(); begin h := handle; _wapi.gtk_im_context_focus_out(h); end function get_preedit_string(); begin return; h := handle; pc := array(0,0,0,0,0); str := ""; setlength(str,100); attr := 0; _wapi.gtk_im_context_get_preedit_string(h,str,attr,pc); end function setfocusctl(ctl); begin if ctl <>FCtl then begin h := handle; _wapi.gtk_im_context_reset(h); FCtl := ctl; end end function setclientwindow(w); begin if w and (w<>FWindow) then begin h := handle; _wapi.gtk_im_context_set_client_window(h,w); end end FCtlHandle; FCommit; function needdestroy();override; begin return false; end private FWindow; FCtl; end type tgtk_ctl_object_scroll = class(tgtk_ctl_object) function Create(h);override; begin inherited; end function GtkBaseEventName();override; begin return array("value-changed"); end function needdestroy();override; begin return false; end end type tgtk_ctl_object_scroll_Bar = class(tgtk_ctl_object) function Create(h);override; begin inherited; Connect("event",thisfunction(scrollevent)); end function scrollevent(a,b,c,d); begin global g_gtk_scroll_lock; if "event"=GetGtkEventNameOrId(b) then begin e := new _GdkEventAny(c); case e.ttype of GDK_ENTER_NOTIFY: begin // g_gtk_scroll_lock := true; end GDK_LEAVE_NOTIFY: begin //g_gtk_scroll_lock := false; end end end end end type tgtk_ctl_scroll_window = class(tgtk_ctl_object) function Create(h);override; begin inherited; fbarshow := 0; end function scrollwindowdraw(a,b,c,d); begin //hd := a.handle; //r := zeros(4); //_wapi.gtk_widget_get_allocation(hd,r); //cr := _wapi.gdk_cairo_create(_wapi.gtk_widget_get_window(hd)); //_wapi.cairo_destroy(cr); cr :=c;//rec := r; rec := zeros(4); _wapi.gdk_cairo_get_clip_rectangle(cr,rec); _Wapi.g_object_set_data(cr,nil); //_wapi.cairo_clip_extents(cr,x,y,w,h); hwd := handle; _wapi.g_object_set_data(hwd,"paint_dc",cr); _wapi.g_object_set_data(hwd,"paint_rect",rec); CallTslVclProc(_const.WM_PAINT,0,0); //绘制 if not(self(true) is class(tgtk_ctl_window_PoPup)) then begin hd := a.handle; r := zeros(4); _wapi.gtk_widget_get_allocation(hd,r); if (r[2]<=(rec[0]+rec[2])) or (r[3]<=(rec[1]+rec[3])) then begin _wapi.gtk_object_set_data(cr,"alpha",nil); _wapi.cairo_set_dash(cr,array(4.0,0.0),2,0); if ((FExdwstyle .& _const.WS_EX_DLGMODALFRAME)= _const.WS_EX_DLGMODALFRAME) or ((FExdwstyle .& _const.WS_SIZEBOX)= _const.WS_SIZEBOX) then begin _wapi.cairo_set_source_rgb(cr, 0.8, 0.8, 0.8); _wapi.cairo_set_line_width (cr, 2); _wapi.cairo_rectangle(cr,0.5,0.5,r[2]-0.5,r[3]-0.5); _wapi.cairo_stroke(cr); end if (Fdwstyle .& _const.WS_BORDER)= _const.WS_BORDER then begin _wapi.cairo_set_source_rgb(cr, 0.1, 0.1, 0.1); _wapi.cairo_set_line_width(cr, 0.5); _wapi.cairo_rectangle(cr,0,0,r[2]-0.25,r[3]-0.25); _wapi.cairo_stroke(cr); end CallTslVclProc(_const.WM_NCPAINT,0,cr); //绘制 end end _wapi.gtk_object_set_data(cr);//清除标记 global g_save_wind; if not ifarray(g_save_wind) then return ; if g_save_wind["handle"] <> hwd then return ; gsi := g_save_wind; g_save_wind := nil; fn := gsi["file"]; if not(fn and ifstring(fn)) then return ; fn := ansitoutf8(fn); r := zeros(4); hd := a.handle; _wapi.gtk_widget_get_allocation(hd,r); gwd := _wapi.gtk_widget_get_window(hd); pix := _wapi.gdk_pixbuf_get_from_window(gwd,r[0],r[1],r[2],r[3]); tp := gsi["type"]; if not(tp in array("png","bmp")) then tp := "png"; if parseregexpr("\\."$tp$"$",fn,"",m,mp,ml)<>1 then fn+="."$tp; gdk_pixbuf_save(pix,fn,tp,nil,nil,nil,nil,nil,nil); end; function CreateWnd(dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nwidth,nheight,hwndparent,hmenu,hinstance,lpParam);override; begin fispaint := class(tUIglobalData).uigetdata("G_F_CONTROL_IS_CUSTOMPAINT"); //echo "\r\nctl:",tostn(params),tostn(__stack_frame),datetimetostr(now()); d := new tslcstructureobj(MemoryAlignmentCalculate( array(("lpcreateparams","intptr",0))),lpParam); if fispaint then begin isp := call(fispaint,d._getvalue_("lpcreateparams")); end h := self.handle; {if (_const.WS_BORDER .& dwStyle)=_const.WS_BORDER then begin _wapi.gtk_container_set_border_width(h,1); end } _wapi.gtk_widget_set_can_focus(h,true); if isp and FClientWideget then //自绘制 begin FClientObject := new tgtk_ctl_object_client(FClientWideget); _wapi.g_object_set_data(h,"gtk_clientwideget",FClientWideget); FClientObject.Connect("draw",thisfunction(scrollwindowdraw)); _wapi.gtk_widget_set_app_paintable(FClientWideget, TRUE); //绘制 end //隐藏滚动条 _wapi.gtk_widget_hide(FHscrollbar); _wapi.gtk_widget_hide(Fvscrollbar); _wapi.g_object_set_data(h,"gtk_window_vscroll_bar",Fvscrollbar); _wapi.g_object_set_data(h,"gtk_window_hscroll_bar",Fhscrollbar); FScroller := array(); fvsi := new TScrollinfo(); fhsi := new TScrollinfo(); v1 := new tscrollobject(Fvscrollbar,Fvadjustment,fvsi); v2 := new tscrollobject(FHscrollbar,Fhadjustment,fhsi); FScroller[_const.SB_HORZ] := v2; FScroller[_const.SB_VERT] := v1; if (dwExStyle .& _const.WS_EX_ACCEPTFILES)>0 then begin ftarget := _wapi.gtk_target_entry_new("text/uri-list",4,1); ftargetsids := array(); //wg := _wapi.GTK_WIDGET(h); wg := h; _wapi.gtk_drag_dest_set(wg,GTK_DEST_DEFAULT_DROP,ftarget,1,GDK_ACTION_PRIVATE); ftargetsids[0] := _wapi.g_signal_connect_data(wg,"drag-motion",get_instance_i(thisfunction(do_motion)),0,0,0); ftargetsids[1] := _wapi.g_signal_connect_data(wg,"drag-data-received",get_instance_i(thisfunction(do_received)),0,0,0); ftargetsids[2] := _wapi.g_signal_connect_data(wg,"drag-drop",get_instance_i(thisfunction(do_drop)),0,0,0); end return inherited; end function do_drop(w:pointer;ctx:pointer;x:integer;y:integer;tm:integer;ud:pointer):integer;cdecl; begin return true; end procedure do_received(w:pointer;ctx:pointer;x:integer;y:integer;d:pointer;info:integer;tm:integer;ud:pointer);cdecl; begin global g_drage_file_file_names; g_drage_file_file_names := _wapi.gtk_selection_data_get_uris(d); _wapi.gtk_drag_finish(ctx,true,true,tm); AddMessageToGtkMessageQueue(w,_const.WM_DROPFILES,d,tm); end function do_motion(w:pointer;c:pointer;x:integer;y:integer;tm:integer;d:pointer):integer;cdecl; begin _wapi.gdk_drag_status(c,GDK_ACTION_PRIVATE,tm); return true; end function widgetsizechanged(h_,w_);override; //大小改变 begin h := h_; w := w_; hwd := self.handle; mb := _wapi.g_object_get_data(hwd,"menubar"); if mb and _wapi.gtk_widget_is_visible(mb) then begin rec := zeros(4); _wapi.gtk_widget_get_allocation(mb,rec); if rec[3]>1 then begin h-= rec[3];//max(rec[3],25); end else begin gist := _wapi.gtk_container_get_children(mb); //处理 if gist then begin h-=25; end end end scrlsize := 12; if (fbarshow .& 1)=1 then //v begin _wapi.gtk_widget_set_size_request(FHscrollbar,max(0,w-scrlsize),scrlsize); end else _wapi.gtk_widget_set_size_request(FHscrollbar,max(0,w),scrlsize); if (fbarshow .& 2)=2 then //h begin _wapi.gtk_widget_set_size_request(Fvscrollbar,scrlsize,max(0,h-scrlsize)); end else _wapi.gtk_widget_set_size_request(Fvscrollbar,scrlsize,max(0,h)); _wapi.gtk_layout_move( FLayouter,FHscrollbar,0,h-scrlsize); _wapi.gtk_layout_move( FLayouter,Fvscrollbar,w-scrlsize,0); if FClientWideget then begin if (fbarshow .& 2)=2 {_wapi.gtk_widget_is_visible(FHscrollbar)} then begin h-=11; end if (fbarshow .& 1)=1 {_wapi.gtk_widget_is_visible(Fvscrollbar)} then begin w-=11; end _wapi.gtk_widget_set_size_request(FClientWideget,max(0,w),max(0,h)); //inherited widgetsizechanged(h,w); end //else inherited widgetsizechanged(h,w); inherited widgetsizechanged(h,w); //clientrect end function GetScrollInfo(nBar,si);override;//获得滚动条信息 begin osi := fvsi; gsi := new TScrollinfo(si); adj := Fvadjustment; if nbar = _const.SB_HORZ then begin osi := fhsi; adj := Fhadjustment; end msk := gsi.fmask; if msk .& _const.SIF_RANGE then begin gsi.nmin := osi.nmin; gsi.nmax := osi.nmax; end if msk .& _const.SIF_POS then begin gsi.npos := osi.npos; end if msk .& _const.SIF_PAGE then begin gsi.npage := osi.npage; end if msk .& _const.SIF_TRACKPOS then begin gsi.ntrackpos := osi.ntrackpos; end end function SetScrollInfo(nBar,si,redraw);override; //设置滚动条信息 begin //echo "\r\n",datetimetostr(now()),"====showbar===",fbarshow; bkshowbar := fbarshow; osi := fvsi; gsi := new TScrollinfo(si); adj := Fvadjustment; bar := Fvscrollbar; cbs := 1; if nbar = _const.SB_HORZ then begin osi := fhsi; adj := Fhadjustment; bar := FHscrollbar; cbs := 2; end else begin //echo "\r\n",datetimetostr(now()),tostn(gsi._getdata_()); end msk := gsi.fmask; if msk .& _const.SIF_RANGE then begin if gsi.nmin <> osi.nmin then begin //osi.nmin := gsi.nmin; _wapi.gtk_adjustment_set_lower(adj,gsi.nmin); osi.nmin := _wapi.gtk_adjustment_get_lower(adj); //添加 end if gsi.nmax <> osi.nmax then begin //osi.nmax := gsi.nmax; _wapi.gtk_adjustment_set_upper(adj,gsi.nmax); osi.nmax := _wapi.gtk_adjustment_get_upper(adj); //添加 rgchanged := true; end end if msk .& _const.SIF_POS then begin gp := gsi.npos; if gp <> osi.npos then begin //if gp>gsi.nmax then return ; //if gp>(gsi.nmax-gsi.npage+1) then return ; //此处做处理 gmx := osi.nmax; gnx := osi.nmin; if (gmx-osi.npage)<0 or gp<(gmx-osi.npage+3) then begin gp := min(gmx,max(gp,gnx)); //osi.npos := gp; _wapi.gtk_adjustment_set_value(adj,gp); osi.npos := _wapi.gtk_adjustment_get_value(adj); end else if gp>=(gmx-osi.npage+3) then //超过最大值的处理 begin gp := min(gmx,max(gp,gnx)); _wapi.gtk_adjustment_set_value(adj,gp); osi.npos := _wapi.gtk_adjustment_get_value(adj); end end end if msk .& _const.SIF_PAGE then begin if gsi.npage <> osi.npage then begin osi.npage := gsi.npage; _wapi.gtk_adjustment_set_page_size(adj, gsi.npage-1); //abs(gsi.npage-gsi.nmax) pgchanged := true; end end dosetchange := false; ////移动到公用 之前在 page change //////////////暂时屏蔽/////////////////// (* if (rgchanged or pgchanged) and ((gsi.nmax-gsi.npage)<=0) {and osi.npos>0} then //还原 begin w := makelong(_const.SB_TOP,0); //osi.ntrackpos := 0; if nbar = _const.SB_HORZ then begin //clearMessageFromGtkMessageQueue(self.handle,_const.WM_HSCROLL); CallTslVclProc(_const.WM_HSCROLL,w,0,1); end else begin //clearMessageFromGtkMessageQueue(self.handle,_const.WM_vSCROLL); CallTslVclProc(_const.WM_VSCROLL,w,0,1); end //dosetchange := true; end *) ////////////////////////////////////// if msk .& _const.SIF_TRACKPOS then begin if gsi.ntrackpos <> osi.ntrackpos then begin osi.ntrackpos := gsi.ntrackpos; end end if gsi.npage>=(gsi.nmax-gsi.nmin) then begin _wapi.gtk_widget_hide(bar); fbarshow .&=(3 .& _not(cbs)); end else begin _wapi.gtk_widget_show(bar); fbarshow .|=cbs; end //echo "\r\n",datetimetostr(now()),"====showbar end===",fbarshow; if bkshowbar<>fbarshow then begin h := handle; w0 := _wapi.g_object_get_data(h,"gtk_layout_width"); h0 := _wapi.g_object_get_data(h,"gtk_layout_height"); //eturn ; //echo "\r\n===in put client size:",h0,"===",w0; widgetsizechanged(h0,w0); end end function hadjustmentmousedown(a,b,c,d);virtual; begin FHBardown := true; end function vadjustmentmousedown(a,b,c,d);virtual; begin FVBardown := true; end function hadjustmentmouseup(a,b,c,d);virtual; begin FHBardown := false; end function vadjustmentmouseup(a,b,c,d);virtual; begin FVBardown := false; end function hadjustmentchanged(a,b,c,d);virtual; //滚动条改变 begin if not FHBardown then begin return ; end v := _wapi.gtk_adjustment_get_value(a.handle); fhsi.ntrackpos := v; w := makelong(_const.SB_THUMBTRACK,0); CallTslVclProc(_const.WM_HSCROLL,w,0,1); end function vadjustmentchanged(a,b,c,d);virtual;//垂直滚动条改变 begin if not FVBardown then begin return 0; end v := _wapi.gtk_adjustment_get_value(a.handle); fvsi.ntrackpos := v; w := makelong(_const.SB_THUMBTRACK,0); CallTslVclProc(_const.WM_VSCROLL,w,0,1); end private ftarget ; ftargetsids; fscrollinfos; ftimerobj;ftimerfptr; Fscrolltimedo; FStatscrollTime; public function scrolltimedo(ptr:pointer):integer; begin if ifnil(FStatscrollTime) then return 1; //没有滚动消息 t := now(); if (t-FStatscrollTime)<(1/24/3600/100) then return 1; //时间间隔不够10毫秒 FStatscrollTime := nil; //执行了 if fscrollinfos then begin WHEEL_DELTA := 120; ctl := 0; global g_gtk_buttontable,g_gtk_keytable; if ifarray(g_gtk_buttontable) then begin ctl .|= g_gtk_buttontable[0]; ctl .|= g_gtk_buttontable[1]; end if ifarray(g_gtk_keytable) then begin if g_gtk_keytable[0x10] then ctl .|= _const.MK_Shift; if g_gtk_keytable[0x11] then ctl .|= _const.MK_Control; end len := length(fscrollinfos)-1; xy := fscrollinfos[len,2]; h := fscrollinfos[len,0]; dr := sum(fscrollinfos[:,1]); if dr=0 then return 1; fscrollinfos := array(); dr := makelong(ctl,dr); AddMessageToGtkMessageQueue(h,_const.LM_MOUSEWHEEL,dr,xy,1); end return 1; end function GtkEventDispatch(a,mn,c,d);override; begin //消息分发 if mn=GS_SCROLL_EVENT then begin h := a.handle; ed := new _GdkEventScroll(c); dr := ed.direction; if dr<>0 and dr<>1 then return ; x := ed.x;//ed.x_root; y := ed.y;//ed.y_root;-_wapi.gtk_object_get_data_title_height(h); //////////////位置处理//////////////////////////////////////////////////////// mb := _wapi.g_object_get_data(h,"menubar"); if mb and _wapi.gtk_widget_is_visible(mb) then begin rec := zeros(4); _wapi.gtk_widget_get_allocation(mb,rec); y-=rec[3]; end if _wapi.gdk_backend_is_wayland() then begin global g_gtk_shadow_width,g_gtk_shadow_heigt; y-=integer(g_gtk_shadow_heigt/2);//_wapi.gtk_object_get_data_title_height(h); end //////////////////////////////////////////////////////// r := array(); _wapi.GetTopWidgetList(h,x,y,r); lenr := length(r)-1; for i := lenr downto 0 do begin ri := r[i][0]; rxy := r[i][1]; fv := _wapi.g_object_get_data(ri,"gtk_window_vscroll_bar"); if fv and _wapi.gtk_widget_is_visible(fv) then begin ifdowheel := true; break; end end if not ifdowheel then begin ri := r[lenr][0]; rxy := r[lenr][1]; end if ri and rxy then begin if not ftimerobj then begin fscrollinfos := array(); ftimerfptr := makeinstance(weakref_get(thisfunction(scrolltimedo))); Fscrolltimedo := ftimerfptr; ftimerobj := new ttmstruct(nil); rt := _wapi.g_timeout_add(8,Fscrolltimedo,ftimerobj._getptr_() ); ftimerobj._setvalue_(0,rt); end FStatscrollTime := now(); //当前时间 xy := makelong(rxy[0],rxy[1]); WHEEL_DELTA := 120; dr := (dr=1)?(-WHEEL_DELTA):(WHEEL_DELTA); fscrollinfos[length(fscrollinfos)] := array(ri,dr,xy); return true; end end return inherited; end function Destroy();override; begin if ftarget then //处理拖拽问题 begin h := handle; _wapi.gtk_target_entry_free(ftarget); ftarget := nil; if h then begin for i,v in ftargetsids do begin _wapi.g_signal_handler_disconnect(h,v); end end end inherited; if ftimerobj then begin _wapi.g_source_remove(ftimerobj._getvalue_(0)); deleteinstance(ftimerfptr); ftimerfptr := 0; ftimerobj := nil; end //get_instance_u(thisfunction(do_motion)); //get_instance_u(thisfunction(do_received)); //get_instance_u(thisfunction(do_drop)); FHadjustment := nil; Fvadjustment := nil; FHscrollbar := nil; Fvscrollbar := nil; FLayouter := nil; Fvscrollbarobj := nil; Fhscrollbarobj := nil; FClientWideget := nil; end protected function initadjustSignal(); begin FHadjustment := _wapi.gtk_adjustment_new(0.0,0.0,0.0,1.0,1.0,1.0); FHscrollbar := _wapi.gtk_hscrollbar_new(FHadjustment); //////////////////////////垂直滚动条//////////////////////////////////// FVadjustment := _wapi.gtk_adjustment_new(0.0,0.0,0.0,1.0,1.0,1.0); Fvscrollbar := _wapi.gtk_vscrollbar_new(FVadjustment); _wapi.gtk_layout_put(FLayouter,Fvscrollbar,0,0); _wapi.gtk_layout_put(FLayouter,FHscrollbar,0,0); fhadjustobject := new tgtk_ctl_object_scroll(FHadjustment); fvadjustobject := new tgtk_ctl_object_scroll(Fvadjustment); fhadjustobject.Connect("value-changed",thisfunction(hadjustmentchanged)); fvadjustobject.Connect("value-changed",thisfunction(vadjustmentchanged)); Fvscrollbarobj := new tgtk_ctl_object_scroll_Bar(Fvscrollbar); Fvscrollbarobj.Connect("button-press-event",thisfunction(vadjustmentmousedown)); Fvscrollbarobj.Connect("button-release-event",thisfunction(vadjustmentmouseup)); Fhscrollbarobj := new tgtk_ctl_object_scroll_Bar(Fhscrollbar); Fhscrollbarobj.Connect("button-press-event",thisfunction(hadjustmentmousedown)); Fhscrollbarobj.Connect("button-release-event",thisfunction(hadjustmentmouseup)); end FLayouter; //layout FHscrollbar; //滚动条控件 Fvscrollbar; Fvscrollbarobj; //滚动条对象 Fhscrollbarobj; FHadjustment; //滚动条adjustment Fvadjustment; fhadjustobject; fvadjustobject; FClientWideget; //客户区 FClientObject; private FScrollT; fvsi; //滚动条信息 fhsi; fbarshow; FVBardown; //滚动条按下 FHBardown; FScroller; function gdk_pixbuf_save(pixbuf:pointer;p:string;tp:string;gerr:string;p1:string; p2:string;p3:string;p4:string;p5:string):integer; begin _f_ := static function(pixbuf:pointer;p:string;tp:string;gerr:string;p1:string; p2:string;p3:string;p4:string;p5:string):integer;cdecl;external getdlsymaddress("libgtk-3.so.0",functionname()); return ##_f_(pixbuf,p,tp,gerr,p1,p2,p3,p4,p5); end end type tgtk_ctl_object_client = class(tgtk_ctl_object) function create(h); begin inherited; end end type tgtk_ctl_window_PoPup = class(tgtk_ctl_scroll_window) function Create(h);override; begin inherited; end function DefaultMessageDo(msg,w,l);override; begin if msg = _const.WM_SETICON then begin if l then begin h := handle; _wapi.gtk_window_set_icon(h,l); end end inherited; end function later_set_size(id:pointer):integer;cdecl; begin _wapi.g_object_set_data(id,"size_last_set",0); if _wapi.IsGtkWidget(id) then begin _wapi.gtk_window_get_size(id,wd,ht); sv := _wapi.g_object_get_data(id,"size_last_set_value") ; if ifarray(sv) and (sv[0]<>wd or sv[1]<>ht) then begin _wapi.gtk_widget_set_size_request(id,integer(sv[0]),integer(sv[1])); _wapi.gtk_window_resize(id,integer(sv[0]),integer(sv[1])); end end return false; end function GtkEventDispatch(a,mn,c,d);override; begin //消息分发 //echo "eventtype:",_wapi.gdk_event_get_event_type(c),"\r\n"; global g_gtk_shadow_size_nset,g_gtk_shadow_width,g_gtk_shadow_heigt; case mn of GS_HIDE: begin AddMessageToGtkMessageQueue(a.handle,_const.WM_SHOWWINDOW,0,0,nil); end GS_SHOW: begin AddMessageToGtkMessageQueue(a.handle,_const.WM_SHOWWINDOW,1,0,nil); if _wapi.g_object_get_data(a.handle,"size_last_set") then //延时处理 begin _wapi.g_timeout_add(20,makeinstance(thisfunction(later_set_size)),a.handle); end end GS_CONFIGURE_EVENT: begin //return false; h := a.handle; x := _wapi.g_object_get_data(h,"gtk_layout_x"); y := _wapi.g_object_get_data(h,"gtk_layout_y"); cx := _wapi.g_object_get_data(h,"gtk_layout_width"); cy := _wapi.g_object_get_data(h,"gtk_layout_height"); cf := new _GdkEventConfigure(c); ALeft := integer(cf.x); ATop := integer(cf.y); //_wapi.gtk_window_get_position(h,aleft,atop); _wapi.gtk_window_get_size(h,AWidth,AHeight); if g_gtk_shadow_size_nset then begin ewidth := cf.width; eheight := cf.height; dw := abs(AWidth-ewidth); dh := abs(AHeight-eheight); if dw>10 and dh>10 and dw<200 and dh<200 then begin g_gtk_shadow_width := dw; g_gtk_shadow_heigt := dh; g_gtk_shadow_size_nset := false; end end //echo "\r\nconfigure:",AWidth," ",AHeight; SizeChanged :=(cx <> AWidth)or(cy <> AHeight); PosChanged :=(x <> ALeft)or(y <> ATop); if(not SizeChanged)and(not PosChanged)then begin Exit; end if (cx <> AWidth) then _wapi.g_object_set_data(h,"gtk_layout_width",AWidth); pcd := _wapi.gtk_object_get_data_title_height(h); if cy <> AHeight then begin _wapi.g_object_set_data(h,"gtk_layout_height",AHeight+pcd); end if x <> ALeft then begin _wapi.g_object_set_data(h,"gtk_layout_x",aleft); end if y <> ATop then begin _wapi.g_object_set_data(h,"gtk_layout_y",atop); end r := _wapi.Gtk_TrigMoveSizeEvent(h,const aleft,const atop,const AWidth,const AHeight+pcd,(SizeChanged?1:0).|(PosChanged?2:0)); return r; end "delete-event": begin r := CallTslVclProc(_const.WM_CLOSE,0,0); return r; end end; return inherited; end function GtkBaseEventName();override; begin //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,GS_SHOW,GS_HIDE); end function CreateWnd(dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nwidth,nheight,hwndparent,hmenu,hinstance,lpParam);override; begin global g_w_c_width; hascap := (_const.WS_CAPTION .& dwStyle)= _const.WS_CAPTION or (_const.WS_SYSMENU .& dwStyle)=_const.WS_SYSMENU; srszie :=((_const.WS_MAXIMIZEBOX .& dwStyle)=_const.WS_MAXIMIZEBOX) or ((_const.WS_SIZEBOX .& dwStyle)=_const.WS_SIZEBOX); if hascap or srszie then //有标题 begin h := _wapi.gtk_window_new(0); //控件层 end else begin h := _wapi.gtk_window_new(1); //popup //_wapi.gtk_window_set_type_hint(h,GDK_WINDOW_TYPE_HINT_MENU); //此处忽略类型 end _wapi.gtk_object_set_data(h,"gtk_wnd_hs_caption",1); if not(hascap or srszie) then begin _wapi.gtk_window_set_decorated(h,false); _wapi.gtk_object_set_data(h,"gtk_wnd_hs_caption",0); pcd := 0; //无菜单顶层窗口 end else begin _wapi.gtk_window_set_decorated(h,true); _wapi.gtk_window_set_title(h,_wapi.TslStringToGtk(lpWindowName)); pcd := g_w_c_width; //有标题 有菜单的顶层窗口 end if (_const.WS_BORDER .& dwStyle)=_const.WS_BORDER then //Border begin _wapi.gtk_container_set_border_width(h,1); end _wapi.gtk_window_set_default_size(h,max(1,nWidth),max(1,nheight-pcd)); //顶层窗口采用设default if not srszie then begin if _wapi.gdk_backend_is_wayland() and hascap then _wapi.g_object_set_data(h,"size_has_shadow",true); _wapi.g_object_set_data(h,"size_last_set",true); _wapi.g_object_set_data(h,"size_last_set_value",array(max(1,nWidth),max(1,nheight-pcd))); end _wapi.gtk_window_set_resizable(h,srszie); {if false then ////////////最大最小处理/////////////////////// begin gd := new _GdkGeometry(); gd.min_width := nWidth; gd.min_height:= max(1,nheight-pcd); gd.max_width := nWidth+1; gd.max_height := max(1,nheight-pcd)+1; _wapi.gtk_window_set_geometry_hints(h,0,gd._getptr_(),1+2+4+8+16+32+46+128); end } vbox := _wapi.gtk_vbox_new(0,0); //菜单布局层 _wapi.gtk_container_add(h,vbox); _wapi.g_object_set_data(h,"gtk_vbox",vbox); //vbox _wapi.g_object_set_data(h,"gtk_popwp",2+srszie); { vbox //menubar layout hscroll vscroll clientwidget } ctllayout := _Wapi.gtk_layout_new(0,0); _wapi.gtk_box_pack_end(vbox,ctllayout,1,1,0); FLayouter := ctllayout; /////////////////////////水平滚动条//////////////////////////////////// initadjustSignal(); evtdrawbox := _wapi.gtk_event_box_new(); //lot 放一个event box 便于绘制 _wapi.gtk_widget_set_events(evtdrawbox, 0x3FFFFFE); _wapi.gtk_layout_put(ctllayout,evtdrawbox,0,0); clientLayout := _Wapi.gtk_layout_new(0,0); _wapi.gtk_container_add(evtdrawbox,clientLayout); _wapi.gtk_widget_set_size_request(evtdrawbox,max(1,nwidth),max(1,nheight-pcd)); _wapi.g_object_set_data(evtdrawbox,"gtk_client_parent",h); FClientWideget := evtdrawbox; //_wapi.gtk_widget_set_can_focus(eb,true); _wapi.g_object_set_data(h,"gtk_layout",clientLayout); _wapi.g_object_set_data(clientLayout,"gtk_layout_owner",h); InitWidgetSize(h,x,y,nwidth,nheight); _wapi.gtk_window_move(h,x,max(0,y-pcd)); _wapi.gtk_widget_show_all(vbox); InitContainerList(h); //容器list if hwndparent then //设置parent _wapi.SetParent(h,hwndparent); begin _wapi.g_object_set_data(h,"gtk_layout_parent",hwndparent); if _wapi.gtk_widget_is_toplevel(hwndparent) then trf := hWndParent; else trf := _wapi.gtk_widget_get_toplevel(hwndparent); if _wapi.GTK_IS_WINDOW(trf) then _wapi.gtk_window_set_transient_for(h,trf); end //设置default 后不使用 resize 函数 ///////////需要绑定show信号,所以此处提前widget_show 前 handle := h; r := inherited; //////////////////////////////////////////////////// if (_const.WS_VISIBLE .& dwStyle)=_const.WS_VISIBLE then begin //_wapi.ShowWindow(h); _wapi.gtk_widget_show(h); end else begin _wapi.gtk_widget_hide(h); end /////////////处理边框消息/////////////////// 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)); connect(GS_EVENT,thisfunction(nonevent)); FClientObject.connect(GS_EVENT,thisfunction(mygsevent)); end return r; end function nonevent(); begin end function GSBUTTONRELEASEEVENT(a,b,c,d);override; begin if not _wapi.gtk_widget_get_sensitive(a.handle) then return true; return false; end function GSMOTIONNOTIFYEVENT(a,b,c,d);override; begin if not _wapi.gtk_widget_get_sensitive(a.handle) then return true; return false; end function GSBUTTONPRESSEVENT(a,b,c,d);override; begin if not _wapi.gtk_widget_get_sensitive(a.handle) then return true; 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); inherited GSMOTIONNOTIFYEVENT(self,b,c,d); return false; end function mygsevent(a,b,c,d); begin return GtkEventDispatchA(self,b,c,d); end end type tgtk_wnd_info = class() function create(h); begin x := 0; y := 0; h := 0; w := 0; c := 0; m := 0; lt := 0; end function destroy(); begin end x; y; h; w; c; m; lt; fh; end type tgtk_ctl_window = class(tgtk_ctl_scroll_window) function Create(h);override; begin inherited; end function CreateWnd(dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nwidth,nheight,hwndparent,hmenu,hinstance,lpParam);override; begin h := _wapi.gtk_event_box_new();//控件层 ctllayout := _Wapi.gtk_layout_new(0,0);//控件布局层 _wapi.gtk_container_add(h,ctllayout); evtdrawbox := _wapi.gtk_event_box_new(); //布局绘制层 _wapi.gtk_widget_set_events(evtdrawbox, 0x3FFFFFE); clientlayout := _wapi.gtk_layout_new(0,0); //客户区布局层 _wapi.gtk_container_add(evtdrawbox,clientlayout); _wapi.gtk_layout_put(ctllayout,evtdrawbox,0,0); _wapi.gtk_widget_set_size_request(evtdrawbox,nwidth,nheight); _wapi.g_object_set_data(h,"gtk_layout",clientlayout); _wapi.g_object_set_data(clientlayout,"gtk_layout_owner",h); _wapi.g_object_set_data(evtdrawbox,"gtk_client_parent",h); _wapi.gtk_widget_show_all(evtdrawbox); FClientWideget := evtdrawbox; InitWidgetSize(h,x,y,nwidth,nheight); FLayouter := ctllayout; _wapi.gtk_widget_set_size_request(h,nwidth,nheight); _wapi.gtk_widget_show(ctllayout); if (dwStyle .& _const.WS_VISIBLE)=_const.WS_VISIBLE then begin _wapi.gtk_widget_show(h); end /////////////////////////滚动条//////////////////////////////////// initadjustSignal(); ///////////////////////////颜色处理///////////////////////////////////////// {c := new _GdkColor(nil); c.SetRgb(0,0xffff,0); _wapi.gtk_widget_modify_bg(h,0,c._getptr_());} ///////////////////////////////////////////////////////////////////// InitContainerList(h); _wapi.SetParent(h,hwndparent); handle := h; return inherited; end end function g_main_context_new():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function g_main_context_ref(m:pointer):pointer; begin _f_ := static function(m:pointer):pointer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(m); end function g_main_context_acquire(m:pointer):integer; begin _f_ := static function(m:pointer):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(m); end procedure g_main_context_release(m:pointer); begin _f_ := static procedure(m:pointer);cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(m); end type tGtkMessageQueue=class //消息队列 {** @ignore(忽略) gtk消息队列 **} public function Create(); begin Clean(); FMainContext := g_main_context_new(); g_main_context_ref(FMainContext); fLock := 0; end function Add(h,m,l,w,obj); begin lock(); FData[FLen]:= array(h,m,l,w,obj); FLen++; //createidle(); unlock(); end function Feach(); begin lock(); if FCurrent100 then begin FData := FData[FCurrent:]; //min(FLen-1,FCurrent+100)]; FCurrent :=0; FLen := length(FData); end end else begin Clean(); end unlock(); return r; end function feacheasylostmessage(h,m); begin r := array(); ri := 0; idx := FCurrent; lock(); while idx0)then begin fLock--; if(fLock=0)then begin g_main_context_release(FMainContext); end end end end function _gtkeventcall_();//消息回调 begin r := class(tgtk_ctl_object).DispatchGtkEventCall(params); return r; end function _gtk_add_time_msg_(h,m,w,l); begin //定时处理 AddMessageToGtkMessageQueue(h,m,w,l,0x113); end function get_m_m_q(); //获取消息队列 begin return static new tGtkMessageQueue(); end function hasMessageFromGtkMessageQueue(h,m); //是否存在消息 begin get_m_m_q().haseasyLostMessage(h,m); end function feacheasylostMessageFromGtkMessageQueue(h,m); //获取容丢失的消息 begin return get_m_m_q().feacheasylostmessage(h,m); end function clearMessageFromGtkMessageQueue(h,m); //清除消息 begin return get_m_m_q().cleaneasyLostMessage(h,m); end function AddMessageToGtkMessageQueue(FHandle,msg,wparam,lparam,d); //推送消息 begin return get_m_m_q().add(FHandle,msg,wparam,lparam,d); end function FeachMessageFromGtkMessageQueue(); //获取最后的事件 begin return get_m_m_q().Feach(); end function GetGtkEventNameOrId(n); //获得event begin global G_E_ID_Name_1,G_E_ID_Name_2; if ifstring(n) then begin ln := lowercase(n); r := G_E_ID_Name_1[ln]; if ifnil(r) then begin mx := 18; for i ,v in G_E_ID_Name_1 do begin mx := max(mx,v); end r := mx+1; G_E_ID_Name_1[ln] := r; G_E_ID_Name_2[r] := ln; return r; end else begin return r; end end else if n>0 or n<0 then return G_E_ID_Name_2[n]; end function callpaintmessage(d); begin _wapi := gettswin32api(); _const := GetWin32Const(); r := zeros(4); hd := d[0]; _wapi.gtk_widget_get_allocation(hd,r); cr := _wapi.gdk_cairo_create(_wapi.gtk_widget_get_window(hd)); hwd := hd; _wapi.g_object_set_data(hwd,"paint_dc",cr); _wapi.g_object_set_data(hwd,"paint_height",r[3]); _wapi.g_object_set_data(hwd,"paint_width",r[2]); r := class(tgtk_ctl_object).CallGtkWinProc(d[0],d[1],d[2],d[3]); _wapi.cairo_set_dash(cr,array(4.0,0.0),2,0); if (FExdwstyle .& _const.WS_EX_DLGMODALFRAME)= _const.WS_EX_DLGMODALFRAME then begin _wapi.cairo_set_source_rgb(cr, 225/255, 225/255, 225/255); _wapi.cairo_set_line_width (cr, 3); _wapi.cairo_rectangle(cr,0,0,r[2],r[3]); _wapi.cairo_stroke(cr); end if (Fdwstyle .& _const.WS_BORDER)= _const.WS_BORDER then begin _wapi.cairo_set_source_rgb(cr, 0, 0, 0); _wapi.cairo_set_line_width (cr, 1); _wapi.cairo_rectangle(cr,0,0,r[2],r[3]); _wapi.cairo_stroke(cr); end _wapi.cairo_destroy(cr); _wapi.gtk_object_set_data(cr); end function _gtkidledo_(); //回调 begin d := FeachMessageFromGtkMessageQueue(); if ifarray(d) then begin //echo "\r\n>>",d[0],"==",d[1],"===",d[4],">>>",datetimetostr(now()); {if d[1] = 0x007B then begin r := class(tgtk_ctl_object).CallGtkWinProc(d[0],d[1],d[2],d[3]); if not r then //右键菜单上传 begin end return r; end } if d[4]=0x113 and d[0]=0 then //定时 begin fgt := class(tUIglobalData).uigetdata("G_F_TIME_PROC_"); if fgt then call(fgt,d[0],d[1],d[2],d[3]); end else if d[0] then begin r := class(tgtk_ctl_object).CallGtkWinProc(d[0],d[1],d[2],d[3]); if r=0 and d[1]= 0x007B then //处理 contextmenu消息 begin _wapi := gettswin32api(); h := _wapi.GetParent(d[0]); if h then begin AddMessageToGtkMessageQueue(h,d[1],h,d[3],true); end return 1; end return 1; //r end else begin tslprocessmessages(false); //sleep(10); end r := 1; end else begin r := 0; tslprocessmessages(false); //sleep(10);//休息一下 end if unit(uvclthreadworker).RunThreadWorkerHost() then r := 1; if r=0 then sleep(25); //get_m_m_q().idleworked := r; return true; end procedure tslprocessmessages()begin end; function InitGtkWindowClass(); //初始化窗口类 begin global G_GTK_WINDOW_CLASSINFO; if not ifarray(G_GTK_WINDOW_CLASSINFO) then begin G_GTK_WINDOW_CLASSINFO := array(); fp := 0;//getwinprocptr(); cls := array(array("cbsize":80,"style":43,"lpfnwndproc":fp,"cbclsextra":0,"cbwndextra":0,"hinstance":0,"hicon":0L,"hcursor":0L,"hbrbackground":0L,"lpszmenuname":0L,"lpszclassname":"tsui_application","hiconsm":0L) ,array("cbsize":80,"style":43,"lpfnwndproc":fp,"cbclsextra":0,"cbwndextra":0,"hinstance":0,"hicon":0L,"hcursor":0L,"hbrbackground":0L,"lpszmenuname":0L,"lpszclassname":"tsui_window","hiconsm":0L) ,array("cbsize":80,"style":43,"lpfnwndproc":fp,"cbclsextra":0,"cbwndextra":0,"hinstance":0,"hicon":0L,"hcursor":0L,"hbrbackground":0L,"lpszmenuname":0L,"lpszclassname":"tui_panel","hiconsm":0L) ,array("cbsize":80,"style":43,"lpfnwndproc":fp,"cbclsextra":0,"cbwndextra":0,"hinstance":0,"hicon":0L,"hcursor":0L,"hbrbackground":0L,"lpszmenuname":0L,"lpszclassname":"tsluidesigner_a_a_1","hiconsm":0L) ,array("cbsize":80,"style":43,"lpfnwndproc":fp,"cbclsextra":0,"cbwndextra":0,"hinstance":0,"hicon":0L,"hcursor":0L,"hbrbackground":0L,"lpszmenuname":0L,"lpszclassname":"tsui_form","hiconsm":0L) ,array("cbsize":80,"style":139,"lpfnwndproc":fp,"cbclsextra":0,"cbwndextra":8,"hinstance":0,"hicon":0L,"hcursor":65541L,"hbrbackground":0L,"lpszmenuname":0L,"lpszclassname":"tui_button","hiconsm":0L) ,array("cbsize":80,"style":136,"lpfnwndproc":fp,"cbclsextra":0,"cbwndextra":8,"hinstance":0,"hicon":0L,"hcursor":65543L,"hbrbackground":0L,"lpszmenuname":0L,"lpszclassname":"tui_edit","hiconsm":0L) ,array("cbsize":80,"style":16395,"lpfnwndproc":fp,"cbclsextra":0,"cbwndextra":8,"hinstance":0,"hicon":0L,"hcursor":65541L,"hbrbackground":16L,"lpszmenuname":0L,"lpszclassname":"tui_tablecontrol32","hiconsm":0L) ,array("cbsize":80,"style":43,"lpfnwndproc":fp,"cbclsextra":0,"cbwndextra":0,"hinstance":0,"hicon":0L,"hcursor":0L,"hbrbackground":0L,"lpszmenuname":0L,"lpszclassname":"tui_PageSheet","hiconsm":0L) ,array("cbsize":80,"style":16384,"lpfnwndproc":fp,"cbclsextra":0,"cbwndextra":8,"hinstance":0,"hicon":0L,"hcursor":65541L,"hbrbackground":6L,"lpszmenuname":0L,"lpszclassname":"tui_monthcalendar","hiconsm":0L) ,array("cbsize":80,"style":16384,"lpfnwndproc":fp,"cbclsextra":0,"cbwndextra":8,"hinstance":0,"hicon":0L,"hcursor":65541L,"hbrbackground":6L,"lpszmenuname":0L,"lpszclassname":"tui_prograssbar","hiconsm":0L) ,array("cbsize":80,"style":16384,"lpfnwndproc":fp,"cbclsextra":0,"cbwndextra":8,"hinstance":0,"hicon":0L,"hcursor":65541L,"hbrbackground":6L,"lpszmenuname":0L,"lpszclassname":"tui_datetimepicker","hiconsm":0L) ); for i ,v in cls do begin G_GTK_WINDOW_CLASSINFO[v["lpszclassname"]] := v; end end end type tmenuStruct = class(tslcstructureobj)// 菜单类对象 %% static classstruct; class function getstruct(); begin if not classstruct then begin classstruct := MemoryAlignmentCalculate( array( ("cbsize","int",0), ("fmask","int",0), ("ftype","int",0), ("fstate","int",0), ("wid","int",0), ("hsubmenu","intptr",0), ("hbmpchecked","intptr",0), ("hbmpunchecked","intptr",0), ("dwitemdata","intptr",0), ("dwtypedata","intptr",0), ("cch","int",90), ("hbmpitem","intptr",0))); end return classstruct; end function create(ptr); begin class(tslcstructureobj).create(getstruct(),ptr); _setvalue_("cbsize",_size_()); end function getdwtypedata(); //获得数据 begin len := _getvalue_("cch"); p := _getvalue_("dwtypedata"); d := ReadBytesFromPtr(p,len); r := ""; setlength(r,len); for i := 1 to len do begin r[i] := d[i-1]; end return r; //ReadStringFromPtr(p); end property wid:integer index "wid" read _getvalue_ write _setvalue_; property hsubmenu:integer index "hsubmenu" read _getvalue_ write _setvalue_; property hbmpitem:integer index "hbmpitem" read _getvalue_ write _setvalue_; property dwtypedata:integer index "dwtypedata" read _getvalue_ write _setvalue_; property fmask:integer index "fmask" read _getvalue_ write _setvalue_; property ftype:integer index "ftype" read _getvalue_ write _setvalue_; property fstate:integer index "fstate" read _getvalue_ write _setvalue_; end function GetGtkwindowclass(n);//获得窗口类 begin global G_GTK_WINDOW_CLASSINFO; InitGtkWindowClass(); return G_GTK_WINDOW_CLASSINFO[n]; end function reggtkwindowclass(cs);//注册窗口类 begin global G_GTK_WINDOW_CLASSINFO; InitGtkWindowClass(); G_GTK_WINDOW_CLASSINFO[cs["lpszclassname"]] := cs; end function GetWin32Const(); //获得win32常量 begin return static new TSLUICONST(); end function tsl_gtk_get_thread(); begin return static systhreadid(); 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; static const GDK_WINDOW_STATE_STICKY=8; static const GDK_WINDOW_STATE_FULLSCREEN=16; static const GDK_WINDOW_STATE_ABOVE=32; static const GDK_WINDOW_STATE_BELOW=64; static const GDK_WINDOW_STATE_FOCUSED=128; static const GDK_WINDOW_STATE_TILED=256; static const GDK_WINDOW_STATE_TOP_TILED=512; static const GDK_WINDOW_STATE_TOP_RESIZABLE=1024; static const GDK_WINDOW_STATE_RIGHT_TILED=2048; static const GDK_WINDOW_STATE_RIGHT_RESIZABLE=4069; static const GDK_WINDOW_STATE_BOTTOM_TILED=8192; static const GDK_WINDOW_STATE_BOTTOM_RESIZABLE=16384; static const GDK_WINDOW_STATE_LEFT_TILED=32768; static const GDK_WINDOW_STATE_LEFT_RESIZABLE=65536; static const GDK_GRAVITY_NORTH_WEST=1; static const GDK_GRAVITY_NORTH=2; static const GDK_GRAVITY_NORTH_EAST=3; static const GDK_GRAVITY_WEST=4; static const GDK_GRAVITY_CENTER=5; static const GDK_GRAVITY_EAST=6; static const GDK_GRAVITY_SOUTH_WEST=7; static const GDK_GRAVITY_SOUTH=8; static const GDK_GRAVITY_SOUTH_EAST=9; static const GDK_GRAVITY_STATIC=10; static const GDK_WINDOW_TYPE_HINT_NORMAL=0; static const GDK_WINDOW_TYPE_HINT_DIALOG=1; static const GDK_WINDOW_TYPE_HINT_MENU=2; static const GDK_WINDOW_TYPE_HINT_TOOLBAR=3; static const GDK_WINDOW_TYPE_HINT_SPLASHSCREEN=4; static const GDK_WINDOW_TYPE_HINT_UTILITY=5; static const GDK_WINDOW_TYPE_HINT_DOCK=6; static const GDK_WINDOW_TYPE_HINT_DESKTOP=7; static const GDK_WINDOW_TYPE_HINT_DROPDOWN_MENU=8; static const GDK_WINDOW_TYPE_HINT_POPUP_MENU=9; static const GDK_WINDOW_TYPE_HINT_TOOLTIP=10; static const GDK_WINDOW_TYPE_HINT_NOTIFICATION=11; static const GDK_WINDOW_TYPE_HINT_COMBO=12; static const GDK_WINDOW_TYPE_HINT_DND=13; static const GDK_DELETE=0; static const GDK_DESTROY=1; static const GDK_EXPOSE=2; static const GDK_MOTION_NOTIFY=3; static const GDK_BUTTON_PRESS=4; static const GDK_2BUTTON_PRESS=5; static const GDK_3BUTTON_PRESS=6; static const GDK_BUTTON_RELEASE=7; static const GDK_KEY_PRESS=8; static const GDK_KEY_RELEASE=9; static const GDK_ENTER_NOTIFY=10; static const GDK_LEAVE_NOTIFY=11; static const GDK_FOCUS_CHANGE=12; static const GDK_CONFIGURE=13; static const GDK_MAP=14; static const GDK_UNMAP=15; static const GDK_PROPERTY_NOTIFY=16; static const GDK_SELECTION_CLEAR=17; static const GDK_SELECTION_REQUEST=18; static const GDK_SELECTION_NOTIFY=19; static const GDK_PROXIMITY_IN=20; static const GDK_PROXIMITY_OUT=21; static const GDK_DRAG_ENTER=22; static const GDK_DRAG_LEAVE=23; static const GDK_DRAG_MOTION=24; static const GDK_DRAG_STATUS=25; static const GDK_DROP_START=26; static const GDK_DROP_FINISHED=27; static const GDK_CLIENT_EVENT=28; static const GDK_VISIBILITY_NOTIFY=29; static const GDK_NO_EXPOSE=30; static const GDK_SCROLL=31; static const GDK_WINDOW_STATE=32; static const GDK_SETTING=33; static const GDK_OWNER_CHANGE=34; static const GDK_GRAB_BROKEN=35; static const GDK_DAMAGE=36; static const GDK_NOTHING=-1; static const GTK_RESPONSE_HELP=-11; static const GTK_RESPONSE_APPLY=-10; static const GTK_RESPONSE_NO=-9; static const GTK_RESPONSE_YES=-8; static const GTK_RESPONSE_CLOSE=-7; static const GTK_RESPONSE_CANCEL=-6; static const GTK_RESPONSE_OK=-5; static const GTK_RESPONSE_DELETE_EVENT=-4; static const GTK_RESPONSE_ACCEPT=-3; static const GTK_RESPONSE_REJECT=-2; static const GTK_RESPONSE_NONE=-1; static const GTK_TARGET_SAME_APP =1; static const GTK_TARGET_SAME_WIDGET =2; static const GTK_TARGET_OTHER_APP =4; static const GTK_TARGET_OTHER_WIDGET =8; static const GDK_ACTION_DEFAULT =1; static const GDK_ACTION_COPY =2; static const GDK_ACTION_MOVE =4; static const GDK_ACTION_LINK =8; static const GDK_ACTION_PRIVATE =16; static const GDK_ACTION_ASK =32; static const GTK_DEST_DEFAULT_MOTION =1; static const GTK_DEST_DEFAULT_HIGHLIGHT =2; static const GTK_DEST_DEFAULT_DROP =4; 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"; static const GTK_WIN_POS_NONE= 0; static const GTK_WIN_POS_CENTER= 1; static const GTK_WIN_POS_MOUSE= 2; static const GTK_WIN_POS_CENTER_ALWAYS= 3; static const GTK_WIN_POS_CENTER_ON_PARENT= 4; end { //cairo 常量 CAIRO_OPERATOR_CLEAR:=0; CAIRO_OPERATOR_SOURCE:=1; CAIRO_OPERATOR_OVER:=2; CAIRO_OPERATOR_IN:=3; CAIRO_OPERATOR_OUT:=4; CAIRO_OPERATOR_ATOP:=5; CAIRO_OPERATOR_DEST:=6; CAIRO_OPERATOR_DEST_OVER:=7; CAIRO_OPERATOR_DEST_IN:=8; CAIRO_OPERATOR_DEST_OUT:=9; CAIRO_OPERATOR_DEST_ATOP:=10; CAIRO_OPERATOR_XOR:=11; CAIRO_OPERATOR_ADD:=12; CAIRO_OPERATOR_SATURATE:=13; CAIRO_OPERATOR_MULTIPLY:=14; CAIRO_OPERATOR_SCREEN:=15; CAIRO_OPERATOR_OVERLAY:=16; CAIRO_OPERATOR_DARKEN:=17; CAIRO_OPERATOR_LIGHTEN:=18; CAIRO_OPERATOR_COLOR_DODGE:=19; CAIRO_OPERATOR_COLOR_BURN:=20; CAIRO_OPERATOR_HARD_LIGHT:=21; CAIRO_OPERATOR_SOFT_LIGHT:=22; CAIRO_OPERATOR_DIFFERENCE:=23; CAIRO_OPERATOR_EXCLUSION:=24; CAIRO_OPERATOR_HSL_HUE:=25; CAIRO_OPERATOR_HSL_SATURATION:=26; CAIRO_OPERATOR_HSL_COLOR:=27; CAIRO_OPERATOR_HSL_LUMINOSITY:=28; } {//selection 常量 static const GDK_SELECTION_PRIMARY =1; //A GdkAtom representing the PRIMARY selection. static const GDK_SELECTION_SECONDARY =2; //A GdkAtom representing the SECONDARY selection. static const GDK_SELECTION_CLIPBOARD =69; //A GdkAtom representing the CLIPBOARD selection. static const GDK_TARGET_BITMAP =5; //A GdkAtom representing the BITMAP selection target. static const GDK_TARGET_COLORMAP =7; //A GdkAtom representing the COLORMAP selection target. static const GDK_TARGET_DRAWABLE =17; //A GdkAtom representing the DRAWABLE selection target. static const GDK_TARGET_PIXMAP =20; //A GdkAtom representing the PIXMAP selection target. static const GDK_TARGET_STRING =31; //A GdkAtom representing the STRING selection target. static const GDK_SELECTION_TYPE_ATOM =4; //A GdkAtom representing the ATOM selection type. static const GDK_SELECTION_TYPE_BITMAP =5; //A GdkAtom representing the BITMAP selection type. static const GDK_SELECTION_TYPE_COLORMAP =7; //A GdkAtom representing the COLORMAP selection type. static const GDK_SELECTION_TYPE_DRAWABLE =17; //A GdkAtom representing the DRAWABLE selection type. static const GDK_SELECTION_TYPE_INTEGER =19; //A GdkAtom representing the INTEGER selection type. static const GDK_SELECTION_TYPE_PIXMAP =20; //A GdkAtom representing the PIXMAP selection type. static const GDK_SELECTION_TYPE_WINDOW =33; //A GdkAtom representing the WINDOW selection type. static const GDK_SELECTION_TYPE_STRING =31; } /////////////////////////////非api上面的external 函数/////////////////////////////////////////////////// function gtk_init_check(argc:string;argcv:string):integer; begin _f_ := static function(argc:string;argcv:string):integer;cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(argc,argcv); end function gtk_disable_setlocale(); begin _f_ := static procedure();cdecl;external getfuncptrbyname(0,functionname()); return ##_f_(); end function signal_connect_data(instance:pointer; detailed_signal:string; c_handler:pointer;data:pointer;dd:pointer;f:integer):pointer; begin _f_ := static function(instance:pointer; detailed_signal:string; c_handler:pointer;data:pointer;dd:pointer;f:integer):pointer;cdecl;external getfuncptrbyname(0,"g_signal_connect_data"); return ##_f_(instance,detailed_signal,c_handler,data,dd,f); end function keymap_get_modifier_state(kmp:pointer):integer; begin _f_ := static function(kmp:pointer):integer;cdecl;external getfuncptrbyname(0,"gdk_keymap_get_modifier_state"); return ##_f_(kmp); end function keymap_get_default():pointer; begin _f_ := static function():pointer;cdecl;external getfuncptrbyname(0,"gdk_keymap_get_default"); return ##_f_(); end /////////////////////////////////////////////////////////////////////////// function igtk(); begin global g_w_i_datas,g_w_c_width, g_gtk_buttontable,g_gtk_keytable, g_gtk_call_handler_manager,g_gtk_font_get_size,g_gtk_dragxy, g_gtk_shadow_width,g_gtk_shadow_heigt,g_gtk_shadow_size_nset, G_E_ID_Name_1,G_E_ID_Name_2,g_Caret_Blink_Time,g_ansi_unit_cache,gtk_gdi_object_globals,g_cairo_api; g_cairo_api := new t_img_op_api(); g_ansi_unit_cache := array(); gtk_gdi_object_globals := array(); G_E_ID_Name_2 := array(); G_E_ID_Name_1 := array( "wm-user":10, "destroy":11, "activate":12, "clicked":13, "value-changed":14, "delete-event":15, "event":16 , "window-sate-event":17); for i,v in G_E_ID_Name_1 do begin G_E_ID_Name_2[v] := i; end g_Caret_Blink_Time := 600; g_gtk_dragxy := array(0,0); g_gtk_font_get_size := array(); gtk_init_check(nil,nil); g_w_i_datas := array(); g_w_c_width := 35; g_gtk_shadow_size_nset := true; g_gtk_shadow_width := 52; g_gtk_shadow_heigt := 89; g_gtk_buttontable := array(0,0); g_gtk_keytable := array(0x10:0,0x11:0,0x12:0); g_gtk_call_handler_manager := new tinstancemanager(); //////////////////初始化kyemap///////////////////////////////////////////// if getglobalcache("~gtk~init",gc) then return ;//echo gc ; setglobalcache("~gtk~init","\r\ngtk init ok"); kmp := keymap_get_default(); if not kmp then return 0; signal_connect_data(kmp,"state-changed",g_gtk_call_handler_manager.get(thisfunction(tsl_gtk_keymp_state)),0,0); end function ugtk(); begin global g_gtk_call_handler_manager; g_gtk_call_handler_manager := nil; end function gettslvcleventhandler_(fname:string):pointer; begin global g_gtk_call_handler_manager; if not g_gtk_call_handler_manager then return 0; mgnr := g_gtk_call_handler_manager; fptr := findfunction(fname); if fptr then return mgnr.get(fptr); case fname of "do_two_param_event": return mgnr.get(thisfunction(do_two_param_event)); "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_idle": return mgnr.get(thisfunction(tsl_gtk_idle)); end ; end function get_instance_i(fn); begin global g_gtk_call_handler_manager; if not g_gtk_call_handler_manager then return 0; mgnr := g_gtk_call_handler_manager; return mgnr.get(fn); end function get_instance_u(fn); begin global g_gtk_call_handler_manager; if not g_gtk_call_handler_manager then return 0; mgnr := g_gtk_call_handler_manager; return mgnr.del(fn); end procedure tsl_gtk_keymp_state(kmp:pointer;d:pointer); begin global g_gtk_keytable; g_gtk_keytable := array(0x10:0,0x11:0,0x12:0); if not kmp then return ; state := keymap_get_modifier_state(kmp); if state>0 then begin if (state .& 1) = 1 then begin g_gtk_keytable[0x10] := _shl( 1,15); end else if (state .& 4) = 4 then begin g_gtk_keytable[0x11] := _shl( 1,15); end else if (state .& 8) = 8 then begin g_gtk_keytable[0x12] := _shl( 1,15); end end end ////////////////////////new function////////////////////////////////////////////// function c_g_e_enter_notify_event(w:pointer;dt:pointer;u_d:pointer):integer; begin return _gtkeventcall_(w,u_d,dt); end function c_g_e_leave_notify_event(w:pointer;dt:pointer;u_d:pointer):integer; //leave-notify-event begin return _gtkeventcall_(w,u_d,dt); end function c_g_e_drag_begin(w:pointer;dt:pointer;u_d:pointer):integer; // begin return _gtkeventcall_(w,u_d,dt); //return do_two_param_event(a, "value-changed"); end function c_g_e_hide(w:pointer;u_d:pointer):integer; // begin return do_two_param_event(w, GetGtkEventNameOrId(u_d)); //return do_two_param_event(a, "value-changed"); end function c_g_e_show(w:pointer;u_d:pointer):integer; // begin return do_two_param_event(w, GetGtkEventNameOrId(u_d)); //return do_two_param_event(a, "value-changed"); end function c_g_e_visibility_notify_event(w:pointer;e:pointer;u_d:pointer):integer; // begin return false; //return do_two_param_event(a, "value-changed"); end 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_idle(dlg:pointer):integer; begin return _gtkidledo_(dlg); end function tsl_gtk_normal_event_bc(a:pointer;b:pointer;c:pointer):integer; begin return _gtkeventcall_(a,b,c); end function tsl_gtk_normal_event_cb(a:pointer;b:pointer;c:pointer):integer; begin return _gtkeventcall_(a,c,b); //获得消息处理函数的指针 end function do_two_param_event( a:pointer;b:string):integer; begin return _gtkeventcall_(a,GetGtkEventNameOrId(b),0); end ///////////////////////////////////////////////////////////// function gtk_rgb_color_rgb(c,r,g,b); begin if not ifnumber(c) then return 0; r := getrvalue(c)/0xff; g := getgvalue(c)/0xff; b := getbvalue(c)/0xff ; return true; end function gtk_rgb_color_rgb2(r,g,b,c); begin if ifnumber(r) and ifnumber(g) and ifnumber(b) then begin c := rgb(integer(r*0xff),integer(g*0xff),integer(b*0xff)); return true; end end function is_wayland(); begin st := static sysgetenv("XDG_SESSION_TYPE"); if st="wayland" then begin bkend := static sysgetenv("GDK_BACKEND"); if bkend="x11" then return false; return true; end return false; end function getfuncptrbyname(lib,n); begin case lib of "libc": begin return getdlsymaddress("libc.so.6",n); end else return getdlsymaddress("libgtk-3.so.0",n); end end initialization igtk(); finalization ugtk(); end.