unit ugtkinterface; interface { 20220128-0900 稳定接口 20210902-0308 稍微整理 } uses cstructurelib,utslvclmemstruct; function _gtkeventcall_();//gtk消息分发 function _gtkidledo_(); //gtk idle消息分发 function _gtk_add_time_msg_(h,m,w,l); function GetGtkEventNameOrId(n); //gtk 事件名称 function AddMessageToGtkMessageQueue(FHandle,msg,wparam,lparam,d);//添加事件 function FeachMessageFromGtkMessageQueue();//获取最后的事件 function clearMessageFromGtkMessageQueue(h,m);//清除消息 function hasMessageFromGtkMessageQueue(h,m);//是否存在消息 type TGtkList = class( _gslist) //gtk链表类 function create(ptr); begin inherited; end end type tgtkeventobject =class(tgtk_ctl_object) //gtk对象消息类(测试用) function create(h); begin inherited; 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() //gtk对象api接口 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 class 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 class 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 := 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 := 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 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_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 gtk_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 TslStringToGtk(s); //ascii转utf8 begin return ansitoutf8(s); end function TslStringToGtk2(s); //ascii转utf8 begin global g_ansi_unit_cache ; if not ifarray(g_ansi_unit_cache) then g_ansi_unit_cache := array(); r := g_ansi_unit_cache[s]; if ifnil(r) then begin r := ansitoutf8(s); g_ansi_unit_cache[s] := r;; end 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_(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_(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_(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_(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_(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_(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_(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 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 r := cls.CreateWnd(dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nwidth,nheight,hwndparent,hmenu,hinstance,d._getptr_()); end return r; end function gtk_GetClassInfoExtA(h,cl,lpwcx); //获得信息 begin lcl := lowercase(cl); cs := GetGtkwindowclass(lcl); d := new taggtkWNDCLASSA(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 taggtkWNDCLASSA(lpwcx); reggtkwindowclass(d._getdata_()); return true; end function gtk_color_selection_dialog_new(t:string):pointer;cdecl;external 'libgtk-3.so'; 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 return tsl_gtk_execsystem(format('nautilus "%s" &',p)); 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"; /////////////////////////////////timer/////////////////////////////// class function g_timeout_add(interval:integer; _function:pointer; d:pointer):integer; cdecl; external 'libgtk-3.so'; //添加 //libglib-2.0.so gtk_timeout_remove libgtk-x11-2.0.so class procedure g_source_remove(timeout_handler_id:integer); cdecl; external 'libgtk-3.so';//"libgtk-x11-2.0.so"; //移除 //////////////////////////clipboard///////////////////// procedure gtk_clipboard_set_text(c:pointer;s:string;len:integer);cdecl;external 'libgtk-3.so'; function gtk_clipboard_get(atm:pointer):pointer;cdecl;external 'libgtk-3.so'; function gtk_clipboard_wait_for_text(clipboard:pointer):string;cdecl;external 'libgtk-3.so'; //////////////////////// function gtk_events_pending():integer;cdecl;external 'libgtk-3.so'; function gtk_main_iteration_do(f:integer):integer;cdecl;external 'libgtk-3.so'; function gtk_main_iteration():integer ;cdecl;external 'libgtk-3.so'; /////////////////////////////////////////////////////// function g_idle_remove_by_data(p:pointer):integer;cdecl;external 'libgtk-3.so'; //////////////// function g_slist_alloc():pointer;cdecl;external 'libgtk-3.so'; function g_slist_append(list:pointer;d:pointer):pointer;cdecl;external 'libgtk-3.so'; procedure g_slist_free(list:pointer);cdecl;external 'libgtk-3.so'; function g_slist_find(gl:pointer;d:pointer):pointer;cdecl;external 'libgtk-3.so'; function g_slist_length(gl:pointer):integer;cdecl;external 'libgtk-3.so'; function g_slist_delete_link(gl:pointer;gl2:pointer):pointer;cdecl;external 'libgtk-3.so'; function g_slist_remove(gl:pointer;gl2:pointer):pointer;cdecl;external 'libgtk-3.so'; ////////////////not classfiy////////////////////////////////// function gtk_widget_is_visible(w:pointer):integer;cdecl;external 'libgtk-3.so'; function gtk_widget_has_focus(w:pointer):integer;cdecl;external 'libgtk-3.so'; procedure gtk_widget_set_can_focus(w:pointer;cf:integer);cdecl;external 'libgtk-3.so'; function gtk_window_get_focus(w:pointer):pointer;cdecl;external 'libgtk-3.so'; procedure gtk_widget_grab_focus(w:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_window_set_focus(window:pointer; focus:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_window_set_type_hint(window:pointer; tp:integer);cdecl;external 'libgtk-3.so'; procedure gtk_widget_set_has_window(widget:pointer;has_window:integer);cdecl;external 'libgtk-3.so'; function gtk_widget_get_parent(w:pointer):pointer;cdecl;external 'libgtk-3.so'; function gtk_widget_get_allocated_width(w:pointer):integer;cdecl;external 'libgtk-3.so'; function gtk_widget_get_allocated_height(w:pointer):integer;cdecl;external 'libgtk-3.so'; procedure gtk_widget_set_sensitive(w:pointer;s:integer);cdecl;external 'libgtk-3.so'; function gtk_widget_get_sensitive(w:pointer):integer;cdecl;external 'libgtk-3.so'; function gtk_widget_is_toplevel(w:pointer):integer;cdecl;external 'libgtk-3.so'; function gtk_window_get_title(w:pointer):string;cdecl;external 'libgtk-3.so'; ////////////////////////////////im///////////////////////// function gtk_im_multicontext_new():pointer;cdecl;external 'libgtk-3.so'; function gtk_im_multicontext_get_context_id(im:pointer):string;cdecl;external 'libgtk-3.so'; function gtk_im_multicontext_get_type():pointer;cdecl;external 'libgtk-3.so'; procedure gtk_im_context_set_client_window(im:pointer;w:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_im_context_set_use_preedit (im:pointer;s:integer);cdecl;external 'libgtk-3.so'; procedure gtk_im_context_focus_in(im:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_im_context_focus_out (im:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_im_context_reset(im:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_im_context_get_preedit_string(im:pointer;var str:string;var attrs:pointer;cp:array of integer);cdecl;external 'libgtk-3.so'; function gtk_im_context_filter_keypress(im:pointer;e:pointer):integer;cdecl;external 'libgtk-3.so'; function gtk_im_context_delete_surrounding(im:pointer;offset:integer;nchars:integer):integer;cdecl;external 'libgtk-3.so'; function gtk_im_context_get_surrounding(im:pointer;var txt:string;var cursor_index:integer):integer;cdecl;external 'libgtk-3.so'; procedure gtk_im_context_set_cursor_location(im:pointer;var area:array of integer);cdecl;external 'libgtk-3.so'; //////////////////////////////////gobject////// function g_type_check_instance_is_a(instance:pointer;iface_type:pointer):integer;cdecl;external 'libgtk-3.so'; {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;cdecl;external 'libgtk-3.so'; procedure g_object_unref(g:pointer);cdecl;external 'libgtk-3.so'; ////////////////////////scroll////////////////////////// function gtk_scrolled_window_new(hadjustment:pointer; vadjustment:pointer):pointer;cdecl;external 'libgtk-3.so'; procedure gtk_scrolled_window_add_with_viewport(s:pointer;c:pointer);cdecl;external 'libgtk-3.so'; function gtk_scrolled_window_get_hscrollbar(s:pointer):pointer;cdecl;external 'libgtk-3.so'; function gtk_scrolled_window_get_vscrollbar(s:pointer):pointer;cdecl;external 'libgtk-3.so'; function gtk_scrolled_window_get_hadjustment(s:pointer):pointer;cdecl;external 'libgtk-3.so'; function gtk_scrolled_window_get_vadjustment(s:pointer):pointer;cdecl;external 'libgtk-3.so'; procedure gtk_scrolled_window_set_max_content_height(s:pointer;h:integer);cdecl;external 'libgtk-3.so'; procedure gtk_scrolled_window_set_min_content_height(s:pointer;h:integer);cdecl;external 'libgtk-3.so'; procedure gtk_scrolled_window_set_max_content_width(s:pointer;h:integer);cdecl;external 'libgtk-3.so'; procedure gtk_scrolled_window_set_policy(s:pointer;p:integer);cdecl;external 'libgtk-3.so'; /////////////////////scrollable//////////////////////////// procedure gtk_scrollable_set_vscroll_policy(s:pointer;p:integer);cdecl;external 'libgtk-3.so'; procedure gtk_scrollable_set_hscroll_policy(s:pointer;p:integer);cdecl;external 'libgtk-3.so'; function gtk_scrollable_get_hadjustment(s:pointer):pointer;cdecl;external 'libgtk-3.so'; function gtk_scrollable_get_vadjustment(s:pointer):pointer;cdecl;external 'libgtk-3.so'; //////////////gdk window /////// procedure gdk_window_show_unraised(w:pointer);cdecl;external 'libgtk-3.so'; ///////////////////////////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); cdecl;external 'libgtk-3.so'; function gdk_display_get_default():pointer;cdecl;external 'libgtk-3.so'; function gdk_screen_get_default():pointer;cdecl;external 'libgtk-3.so'; function gdk_display_get_default_seat(d:pointer):pointer;cdecl;external 'libgtk-3.so'; function gdk_seat_get_pointer(dm:pointer):pointer;cdecl;external 'libgtk-3.so'; procedure gdk_device_get_position(d:pointer;t:pointer;var x :integer;var y:integer);cdecl;external 'libgtk-3.so'; function gdk_event_get_scroll_deltas(d:pointer;var x :double;var y:double):integer;cdecl;external 'libgtk-3.so'; procedure gdk_window_get_position(w:pointer;var x:integer;var y:integer);cdecl;external 'libgtk-3.so'; function gdk_screen_height():integer;cdecl;external 'libgtk-3.so'; function gdk_screen_width():integer;cdecl;external 'libgtk-3.so'; function gdk_event_get_event_type(e:pointer):integer;cdecl;external 'libgtk-3.so'; ////////////////////////// start //////////////////////////////////////// procedure gtk_init(argc:string;argcv:string);cdecl;external 'libgtk-3.so'; procedure gtk_main ();cdecl;external 'libgtk-3.so'; procedure gtk_main_quit();cdecl;external 'libgtk-3.so'; //////////////////////context/////////////////////////////// function gtk_widget_get_style_context(w:pointer):pointer;cdecl;external 'libgtk-3.so'; /////////////////////////////////////////////////////////////// /////////////////////////////////widget//////////////////////////////////// function gtk_widget_get_realized(w:pointer):integer;cdecl;external 'libgtk-3.so'; procedure gtk_widget_set_events(w:pointer;f:integer);cdecl;external 'libgtk-3.so'; procedure gtk_widget_get_allocation(w:pointer;var rec:array of integer);cdecl;external 'libgtk-3.so'; procedure gtk_widget_set_allocation(w:pointer; rec: array of integer);cdecl;external 'libgtk-3.so'; procedure gtk_widget_size_allocate(w:pointer; rec: array of integer);cdecl;external 'libgtk-3.so'; procedure gtk_widget_modify_text(w:pointer;t:integer;c:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_widget_set_tooltip_text(w:pointer;tip:string);cdecl;external 'libgtk-3.so'; procedure gtk_widget_set_size_request(wd:pointer;h:integer;w:integer);cdecl;external 'libgtk-3.so'; procedure gtk_widget_get_size_request(wd:pointer;var h:integer;var w:integer);cdecl;external 'libgtk-3.so'; procedure gtk_widget_set_app_paintable(w:pointer;f:integer);cdecl;external 'libgtk-3.so'; procedure gtk_widget_realize(w:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_widget_queue_draw(w:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_widget_queue_draw_area(w:pointer;x:integer;y:integer;wd:integer;ht:integer);cdecl;external 'libgtk-3.so'; function gtk_widget_get_margin_top(w:pointer):integer;cdecl;external 'libgtk-3.so'; /////////////////////edit entry////////////////////////////////////////////////////// function gtk_entry_new():pointer;cdecl;external 'libgtk-3.so'; function gtk_entry_get_text(w:pointer):string;cdecl;external 'libgtk-3.so'; procedure gtk_entry_set_text(e:pointer;c:string);cdecl;external 'libgtk-3.so'; function gtk_entry_get_text_length(e:pointer):short;cdecl;external 'libgtk-3.so'; procedure gtk_entry_set_visibility(e:pointer;v:integer);cdecl;external 'libgtk-3.so'; procedure gtk_entry_set_width_chars(e:pointer;v:integer);cdecl;external 'libgtk-3.so'; procedure gtk_entry_set_invisible_char(e:pointer;c:integer);cdecl;external 'libgtk-3.so'; //procedure gtk_entry_set_editable(e:pointer;ed:integer);cdecl;external 'libgtk-3.so'; procedure gtk_editable_set_editable(e:pointer;ed:integer);cdecl;external 'libgtk-3.so'; procedure gtk_entry_set_has_frame(e:pointer;s:integer);cdecl;external 'libgtk-3.so'; procedure gtk_entry_set_max_length(e:pointer;len:integer);cdecl;external 'libgtk-3.so'; /////////////////////text view memo ////////////////////////////////////////////////////// function gtk_text_view_new():pointer;cdecl;external 'libgtk-3.so'; procedure gtk_text_view_set_wrap_mode(t:pointer;md:integer);cdecl;external 'libgtk-3.so'; procedure gtk_text_view_set_buffer(t:pointer;bf:pointer);cdecl;external 'libgtk-3.so'; function gtk_text_buffer_new(tagtable:pointer):pointer;cdecl;external 'libgtk-3.so'; procedure gtk_text_buffer_get_iter_at_offset(bf:pointer;iter:pointer;offset:integer);cdecl;external 'libgtk-3.so'; procedure gtk_text_buffer_insert(bf:pointer;iter:pointer;txt:string;len:integer);cdecl;external 'libgtk-3.so'; procedure gtk_text_view_set_editable(t:pointer;e:integer);cdecl;external 'libgtk-3.so'; procedure gtk_text_set_word_wrap(t:pointer;e:integer);cdecl;external 'libgtk-3.so'; procedure gtk_text_buffer_get_end_iter(b:pointer;iter:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_text_buffer_get_start_iter(b:pointer;iter:pointer);cdecl;external 'libgtk-3.so'; function gtk_text_buffer_get_char_count(b:pointer):integer;cdecl;external 'libgtk-3.so'; function gtk_text_buffer_get_line_count(b:pointer):integer;cdecl;external 'libgtk-3.so'; procedure gtk_text_buffer_delete(b:pointer;start:pointer;ed:pointer);cdecl;external 'libgtk-3.so'; function gtk_text_buffer_get_text(b:pointer;start:pointer;ed:pointer;ic:integer):string;cdecl;external 'libgtk-3.so'; function gtk_text_buffer_get_selection_bounds(b:pointer;st:pointer;ed:pointer):integer;cdecl;external 'libgtk-3.so'; //////////////////////////////pango//////////////////////////////////////////// function pango_font_description_from_string(ns:string):pointer; cdecl;external 'libgtk-3.so'; procedure pango_font_description_free(pg:pointer);cdecl;external 'libgtk-3.so'; procedure pango_font_description_set_size(pg:pointer;sz:integer);cdecl;external 'libgtk-3.so'; function pango_cairo_create_layout(c:pointer):pointer;cdecl;external 'libgtk-3.so'; function pango_cairo_create_context(c:pointer):pointer;cdecl;external 'libgtk-3.so'; procedure pango_layout_set_width(p:pointer;w:integer);cdecl;external 'libgtk-3.so'; function pango_layout_get_width(p:pointer):integer;cdecl;external 'libgtk-3.so'; procedure pango_layout_set_wrap(p:pointer;wp:integer);cdecl;external 'libgtk-3.so'; procedure pango_layout_set_font_description(p:pointer;f:pointer);cdecl;external 'libgtk-3.so'; procedure pango_layout_set_text(pl:pointer;s:string;len:integer);cdecl;external 'libgtk-3.so'; procedure pango_cairo_show_layout(cr:pointer;pl:pointer);cdecl;external 'libgtk-3.so'; function pango_cairo_font_map_get_default():pointer;cdecl;external 'libgtk-3.so'; procedure pango_font_map_list_families(fm:pointer;var fls:pointer;var n:integer);cdecl;external 'libgtk-3.so'; function pango_font_family_get_name(n:pointer):string;cdecl;external 'libgtk-3.so'; function pango_font_family_get_names(); //获得文字 begin fm := pango_cairo_font_map_get_default(); pango_font_map_list_families(fm,ls,lsn); mt := new aefclassobj_(); r := array(); psize := static getctypesize()["intptr"]; 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//////////////////////////////// function cairo_create(s:pointer):pointer;cdecl;external 'libgtk-3.so'; procedure cairo_save(c:pointer);cdecl;external 'libgtk-3.so'; procedure cairo_restore(c:pointer);cdecl;external 'libgtk-3.so'; function gdk_cairo_create(w:pointer):pointer;cdecl;external 'libgtk-3.so'; function cairo_move_to(cr:pointer;x:double;y:double);cdecl;external 'libgtk-3.so'; function cairo_line_to(cr:pointer;x:double;y:double);cdecl;external 'libgtk-3.so'; procedure cairo_set_source(cr:pointer;s:pointer);cdecl;external 'libgtk-3.so'; function cairo_get_source(cr:pointer):pointer;cdecl;external 'libgtk-3.so'; procedure cairo_curve_to(cr:pointer;x1:double;y1:double;x2:double;y2:double;x3:double;y3:double);cdecl;external 'libgtk-3.so'; procedure cairo_rectangle(c:pointer;x:double;y:double;w:double;h:double);cdecl;external 'libgtk-3.so'; procedure cairo_set_source_rgba(c:pointer;red:double;green:double;blue:double;alpha:double);cdecl;external 'libgtk-3.so'; procedure cairo_set_source_rgb(c:pointer;r:double;g:double;b:double);cdecl;external 'libgtk-3.so'; procedure cairo_set_line_width(c:pointer;w:double);cdecl;external 'libgtk-3.so'; function cairo_get_line_width(c:pointer):double;cdecl;external 'libgtk-3.so'; procedure cairo_set_line_cap(c:pointer;cp:integer);cdecl;external 'libgtk-3.so'; function cairo_get_line_cap(c:pointer):integer;cdecl;external 'libgtk-3.so'; procedure cairo_set_line_join(c:pointer;t:integer);cdecl;external 'libgtk-3.so'; function cairo_get_line_join(c:pointer):integer;cdecl;external 'libgtk-3.so'; //procedure draw_round_rectangle(c:pointer;x:double;y:double;w:double;h:double;r:double);cdecl;external 'libgtk-3.so'; procedure cairo_arc (cr:pointer; xc:double;yc:double;radius:double;angle1:double;angle2:double);cdecl;external 'libgtk-3.so'; procedure cairo_translate(cr:pointer;tx:double;ty:double);cdecl;external 'libgtk-3.so'; procedure cairo_rotate(cr:pointer;angle:double);cdecl;external 'libgtk-3.so'; procedure cairo_scale(cr:pointer;sx:double;sy:double);cdecl;external 'libgtk-3.so'; procedure cairo_set_operator(c:pointer;op:integer);cdecl;external 'libgtk-3.so'; function cairo_get_operator(c:pointer):integer;cdecl;external 'libgtk-3.so'; procedure cairo_set_tolerance(c:pointer;tol:double);cdecl;external 'libgtk-3.so'; function cairo_get_tolerance(c:pointer):double;cdecl;external 'libgtk-3.so'; procedure cairo_destroy(c:pointer);cdecl;external 'libgtk-3.so'; procedure cairo_close_path(c:pointer);cdecl;external 'libgtk-3.so'; procedure cairo_set_fill_rule(c:pointer;rul:integer);cdecl;external 'libgtk-3.so'; procedure cairo_clip(c:pointer);cdecl;external 'libgtk-3.so'; procedure cairo_clip_preserve(c:pointer);cdecl;external 'libgtk-3.so'; procedure cairo_clip_extents(c:pointer;x1:double;y1:double;x2:double;y2:double);cdecl;external 'libgtk-3.so'; function cairo_in_clip(c:pointer;x:double;y:double);cdecl;external 'libgtk-3.so'; procedure cairo_reset_clip(c:pointer);cdecl;external 'libgtk-3.so'; procedure cairo_stroke(c:pointer);cdecl;external 'libgtk-3.so'; procedure cairo_stroke_preserve(c:pointer);cdecl;external 'libgtk-3.so'; procedure cairo_set_dash(c:pointer;dash:array of double;num_dash:integer;offset:double);cdecl;external 'libgtk-3.so'; procedure cairo_fill(c:pointer);cdecl;external 'libgtk-3.so'; procedure cairo_fill_preserve(c:pointer);cdecl;external 'libgtk-3.so'; procedure cairo_fill_extents(c:pointer;x1:double;y1:double;x2:double;y2:double);cdecl;external 'libgtk-3.so'; procedure cairo_paint_with_alpha(c:pointer;alpah:double);cdecl;external 'libgtk-3.so'; procedure cairo_paint(c:pointer);cdecl;external 'libgtk-3.so'; function cairo_applay_pen_style(dc); begin pt := gtk_object_get_data(dc,"pen.style"); if pt=0x2 then begin cairo_set_dash(dc,array(4.0,1.0),2,0); end else cairo_set_dash(dc,array(4.0,0.0),2,0); 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 //////////////////////text//////// https://developer.gnome.org/cairo/stable/cairo-cairo-font-options-t.html#cairo-font-options-get-hint-metrics procedure cairo_show_text(c:pointer;t:string);cdecl;external 'libgtk-3.so'; procedure cairo_select_font_face(cr:pointer;n:string;slat:integer;weight:integer);cdecl;external 'libgtk-3.so'; procedure cairo_set_font_size(cr:pointer;sz:double);cdecl;external 'libgtk-3.so'; procedure cairo_text_extents(cr:pointer;s:string;ext:pointer);cdecl;external 'libgtk-3.so'; procedure cairo_font_extents(cr:pointer;ext:pointer);cdecl;external 'libgtk-3.so'; procedure cairo_get_font_options(cr:pointer;ft:pointer);cdecl;external 'libgtk-3.so'; procedure cairo_set_font_options(cr:pointer;ft:pointer);cdecl;external 'libgtk-3.so'; function cairo_font_options_create():pointer;cdecl;external 'libgtk-3.so'; procedure cairo_font_options_destroy(op:pointer);cdecl;external 'libgtk-3.so'; ////////cairo surface//////2 { CAIRO_FORMAT_INVALID = -1, CAIRO_FORMAT_ARGB32 = 0, CAIRO_FORMAT_RGB24 = 1, CAIRO_FORMAT_A8 = 2, CAIRO_FORMAT_A1 = 3, CAIRO_FORMAT_RGB16_565 = 4, CAIRO_FORMAT_RGB30 = 5 } function cairo_image_surface_create(t:integer;w:integer;h:integer):pointer;cdecl;external 'libgtk-3.so'; function cairo_image_surface_create_from_png(f:string):pointer;cdecl;external 'libgtk-3.so'; function cairo_image_surface_get_width(sf:pointer):integer;cdecl;external 'libgtk-3.so'; function cairo_image_surface_get_height(sf:pointer):integer;cdecl;external 'libgtk-3.so'; procedure cairo_surface_destroy(sf:pointer);cdecl;external 'libgtk-3.so'; procedure cairo_set_source_surface(cr:pointer;sf:pointer;x:double;y:double);cdecl;external 'libgtk-3.so'; procedure cairo_pattern_set_extend(c:pointer;pe:integer);cdecl;external 'libgtk-3.so'; function cairo_pattern_create_linear(x0:double;y0:double;x1:double;y1:double):pointer;cdecl;external 'libgtk-3.so'; procedure cairo_pattern_add_color_stop_rgb(c:pointer;offset:double;r:double;g:double;b:double;a:double);cdecl;external 'libgetk-3.so'; /////////////////////////window////////// procedure gdk_window_move_resize(w:pointer;x:integer;y:integer;wd:integer;h:integer);cdecl;external 'libgtk-3.so'; procedure gdk_window_resize(w:pointer;wd:integer;h:integer);cdecl;external 'libgtk-3.so'; procedure gtk_window_begin_move_drag(w:pointer;btn:integer;x:integer;y:integer;t:integer);cdecl;external 'libgtk-3.so'; procedure gtk_window_begin_resize_drag(w:pointer;e:integer;btn:integer;x:integer;y:integer;t:integer);cdecl;external 'libgtk-3.so'; function gtk_widget_get_toplevel(w:pointer):pointer;cdecl;external 'libgtk-3.so'; /////////// modal //////////////////////////////// procedure gtk_window_set_modal(w:pointer;f:integer);cdecl;external 'libgtk-3.so'; procedure gtk_window_set_transient_for(w:pointer;p:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_window_get_size(wd:pointer;var h:integer;var w:integer);cdecl;external 'libgtk-3.so'; procedure gtk_window_set_icon(w:pointer;ico:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_window_set_resizable(p:pointer;f:integer);cdecl;external 'libgtk-3.so'; function gtk_window_get_resizable(p:pointer):integer;cdecl;external 'libgtk-3.so'; procedure gtk_window_set_decorated(w:pointer;f:integer);cdecl;external 'libgtk-3.so'; function gtk_window_get_decorated(w:pointer):integer;cdecl;external 'libgtk-3.so'; procedure gtk_window_set_title(w:pointer;t:string);cdecl;external 'libgtk-3.so'; procedure gtk_window_set_geometry_hints (window:pointer; eometry_widget:pointer; geometry:pointer; geom_mask:integer);cdecl;external 'libgtk-3.so'; procedure gtk_window_resize(w:pointer;wd:integer;ht:integer);cdecl;external 'libgtk-3.so'; procedure gtk_window_resize_to_geometry(w:pointer;wd:integer;ht:integer);cdecl;external 'libgtk-3.so'; procedure gtk_window_move(w:pointer;x:integer;y:integer);cdecl;external 'libgtk-3.so'; ////////////////////// container layout fixed ////////////////////// procedure gtk_container_add(c1:pointer;c2:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_container_remove(c:pointer;w:pointer); cdecl;external 'libgtk-3.so'; procedure gtk_container_set_border_width (container:pointer;border_width:integer);cdecl;external 'libgtk-3.so'; function gtk_fixed_new():pointer;cdecl;external 'libgtk-3.so'; function gtk_layout_new(h:pointer;v:pointer):pointer;cdecl;external 'libgtk-3.so'; procedure gtk_layout_get_size(layout:pointer;var width:integer;var height:integer);cdecl;external 'libgtk-3.so'; procedure gtk_layout_set_size(layout:pointer; width:integer; height:integer);cdecl;external 'libgtk-3.so'; procedure gtk_fixed_put(fixed:pointer;widget:pointer;x:integer;y:integer);cdecl;external 'libgtk-3.so'; procedure gtk_layout_put(fixed:pointer;widget:pointer;x:integer;y:integer);cdecl;external 'libgtk-3.so'; function gtk_layout_get_bin_window(l:pointer):pointer;cdecl;external 'libgtk-3.so'; //////////////////////////// box ///////////////////////// function gtk_vbox_new(homogeneous:integer;spacing:integer):pointer;cdecl;external 'libgtk-3.so'; function gtk_hbox_new(homogeneous:integer;spacing:integer):pointer;cdecl;external 'libgtk-3.so'; procedure gtk_box_pack_end(box:pointer;w:pointer;expand:integer;f:integer;pad:integer);cdecl;external 'libgtk-3.so'; procedure gtk_box_pack_start(box:pointer;w:pointer;expand:integer;f:integer;pad:integer);cdecl;external 'libgtk-3.so'; //////////////////////////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;cdecl;external 'libgtk-3.so'; function gtk_menu_bar_new():pointer;cdecl;external 'libgtk-3.so'; procedure gtk_menu_shell_append(mb:pointer;mi:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_menu_shell_prepend(mb:pointer;mi:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_menu_shell_insert(mb:pointer;mi:pointer;idx:integer);cdecl;external 'libgtk-3.so'; function gtk_menu_item_new_with_label(s:string):pointer;cdecl;external 'libgtk-3.so'; function gtk_menu_item_new():pointer;cdecl;external 'libgtk-3.so'; procedure gtk_menu_item_set_submenu(mb:pointer;mi:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_menu_item_set_use_underline(mi:pointer;l:integer);cdecl;external 'libgtk-3.so'; function gtk_separator_menu_item_new():pointer;cdecl;external 'libgtk-3.so'; function gtk_menu_new():pointer;cdecl;external 'libgtk-3.so'; procedure gtk_menu_item_select(mi:pointer);cdecl;external 'libgtk-3.so'; function gtk_check_menu_item_new():pointer;cdecl;external 'libgtk-3.so'; function gtk_check_menu_item_new_with_label(s:string):pointer;cdecl;external 'libgtk-3.so'; procedure gtk_check_menu_item_set_active(cmi:pointer;ck:integer);cdecl;external 'libgtk-3.so'; function gtk_check_menu_item_get_active(cmi:pointer):integer;cdecl;external 'libgtk-3.so'; procedure gtk_check_menu_item_toggled(cmi:pointer);cdecl;external 'libgtk-3.so'; function gtk_menu_item_get_label(mi:pointer):string;cdecl;external 'libgtk-3.so'; procedure gtk_menu_item_set_label(mi:pointer;l:string);cdecl;external 'libgtk-3.so'; procedure gtk_menu_set_title(mi:pointer;l:string);cdecl;external 'libgtk-3.so'; procedure gtk_menu_reorder_child(mb:pointer;mi:pointer;id:integer);cdecl;external 'libgtk-3.so'; procedure gtk_menu_popup (menu:pointer; parent_menu_shell:pointer; parent_menu_item:pointer; func:pointer; data:pointer; button:integer; activate_time:integer);cdecl;external 'libgtk-3.so'; procedure gtk_menu_item_activate(mi:pointer);cdecl;external 'libgtk-3.so'; /////////////////////////// adjust scroll ///////////////////////////////// function gtk_adjustment_get_type():pointer; cdecl;external 'libgtk-3.so'; 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; cdecl;external 'libgtk-3.so'; function gtk_adjustment_get_value(adj:pointer):double; cdecl;external 'libgtk-3.so'; procedure gtk_adjustment_set_value(adj:pointer;v:double); cdecl;external 'libgtk-3.so'; procedure gtk_adjustment_set_page_size(adj:pointer;v:double); cdecl;external 'libgtk-3.so'; procedure gtk_adjustment_changed(adj:pointer); cdecl;external 'libgtk-3.so'; procedure gtk_adjustment_value_changed(adj:pointer); cdecl;external 'libgtk-3.so'; procedure gtk_adjustment_set_lower(adj:pointer;v:double);cdecl;external 'libgtk-3.so'; procedure gtk_adjustment_set_upper(adj:pointer;v:double);cdecl;external 'libgtk-3.so'; function gtk_adjustment_get_upper(adj:pointer):double;cdecl;external 'libgtk-3.so'; function gtk_adjustment_get_lower(adj:pointer):double;cdecl;external 'libgtk-3.so'; function gtk_hscrollbar_new(adj:pointer):pointer; cdecl;external 'libgtk-3.so'; function gtk_vscrollbar_new(adj:pointer):pointer; cdecl;external 'libgtk-3.so'; procedure gtk_adjustment_configure(adj:pointer; v:double; lower:double; upper:double; step_increment:double; page_increment:double; page_size:double);cdecl;external 'libgtk-3.so'; //////////////////////////////////////////////////// function gtk_frame_new(lbl:string):pointer;cdecl;external 'libgtk-3.so'; ///////////////////////////////////// function gtk_calendar_new():pointer;cdecl;external 'libgtk-3.so'; ///////////////////////////////// function gtk_spinner_new():pointer;cdecl;external 'libgtk-3.so'; procedure gtk_spinner_start(spn:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_spinner_stop(spn:pointer);cdecl;external 'libgtk-3.so'; /////////////////////////////// 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;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):pointer;cdecl;external 'libgtk-3.so'; 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; cdecl;external 'libgtk-3.so'; procedure gtk_dialog_response(w:pointer;id:integer); cdecl;external 'libgtk-3.so'; function gtk_file_chooser_dialog_new(t:string;p:pointer;act:integer;bstring1:string;bvalue1:integer;bstring2:string;bvalue2:integer;pend:pointer):pointer ; cdecl;external 'libgtk-3.so'; function gtk_file_chooser_get_filename(p:pointer):string;cdecl;external 'libgtk-3.so'; function gtk_file_chooser_set_filename(p:pointer;n:string):integer;cdecl;external 'libgtk-3.so'; procedure gtk_file_chooser_set_select_multiple(p:pointer;m:integer);cdecl;external 'libgtk-3.so'; function gtk_file_chooser_get_filenames(p:pointer):pointer ;cdecl;external 'libgtk-3.so'; function gtk_font_chooser_dialog_new(t:string;p:pointer):pointer;cdecl;external 'libgtk-3.so'; function gtk_font_selection_dialog_new(t:string):pointer;cdecl;external 'libgtk-3.so'; function gtk_font_selection_dialog_get_font_name(d:pointer):string;cdecl;external 'libgtk-3.so'; function gtk_font_selection_dialog_get_preview_text(p:pointer):string;cdecl;external 'libgtk-3.so'; procedure gtk_font_selection_dialog_set_preview_text(p:pointer;t:string); cdecl;external 'libgtk-3.so'; function gtk_font_selection_dialog_set_font_name(p:pointer;f:string):integer; cdecl;external 'libgtk-3.so'; procedure gtk_widget_modify_font(w:pointer;p:pointer); cdecl;external 'libgtk-3.so'; function gtk_color_selection_dialog_get_type():pointer;cdecl;external 'libgtk-3.so'; procedure gtk_color_selection_set_current_color(w:pointer;c:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_color_selection_get_current_color(w:pointer;c:pointer);cdecl;external 'libgtk-3.so'; function gdk_color_parse(cs:string;c:pointer):integer;cdecl;external 'libgtk-3.so'; ////////////////// evntbox //////////////////////////// function gtk_event_box_new():pointer;cdecl;external 'libgtk-3.so'; //获得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 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);cdecl;external 'libgtk-3.so'; procedure gtk_widget_get_parent_window(w:pointer;p:pointer);cdecl;external 'libgtk-3.so'; function gtk_widget_get_type():pointer;cdecl;external 'libgtk-3.so'; procedure gtk_widget_modify_bg(w:pointer;tyle:integer;c:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_layout_move(l:pointer;w:pointer;x:integer;y:integer);cdecl;external 'libgtk-3.so'; procedure gtk_grab_add(w:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_widget_destroy(w:pointer);cdecl;external 'libgtk-3.so'; function g_thread_self():pointer;cdecl;external 'libgtk-3.so'; function gtk_get_major_version ():integer;cdecl;external 'libgtk-3.so'; function gtk_get_micro_version ():integer;cdecl;external 'libgtk-3.so'; function gtk_get_binary_age ():integer;cdecl;external 'libgtk-3.so'; function g_main_context_default():pointer;cdecl;external 'libgtk-3.so'; function g_main_context_get_poll_func(d:pointer):pointer;cdecl;external 'libgtk-3.so'; function gtk_main_level():integer;external 'libgtk-3.so'; function g_signal_connect_data(instance:pointer; detailed_signal:string; c_handler:pointer;data:pointer;dd:pointer;f:integer):integer;cdecl;external 'libgtk-3.so'; 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;cdecl;external 'libgtk-3.so'; procedure g_signal_emit_by_name(w:pointer;n:string;p1:pointer;p2:pointer);cdecl;external 'libgtk-3.so'; function gtk_container_get_type():pointer;cdecl;external 'libgtk-3.so'; function gtk_window_get_type():pointer;cdecl;external 'libgtk-3.so'; function gdk_window_get_type():pointer;cdecl;external 'libgtk-3.so'; function g_type_check_instance_cast(instance:pointer;ty:pointer):pointer;cdecl;external 'libgtk-3.so'; function gtk_window_new(lev:integer):pointer; cdecl;external 'libgtk-3.so'; procedure gdk_window_set_back_pixmap(window:pointer;pixmap:pointer;parent_relative:integer);cdecl;external 'libgtk-x11-2.0.so'; procedure gdk_pixbuf_ref(pixbuf:pointer);cdecl;external 'libgtk-3.so'; procedure gdk_pixbuf_unref(pixbuf:pointer);cdecl;external 'libgtk-3.so'; function gdk_cursor_new(c:integer):pointer;cdecl;external 'libgtk-3.so'; procedure gdk_window_set_cursor(w:pointer;c:pointer);cdecl;external 'libgtk-3.so'; function gtk_widget_get_window(g:pointer):pointer;cdecl;external 'libgtk-3.so'; procedure gtk_window_get_position(g:pointer;var x:integer;var y:integer);cdecl;external 'libgtk-3.so'; function gtk_image_new_from_file(f:string):pointer;cdecl;external 'libgtk-3.so'; procedure gtk_widget_show_all (window:pointer);cdecl;external 'libgtk-3.so';//'libgtk-x11-2.0.so'; procedure gtk_widget_show(window:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_widget_show_now(window:pointer);cdecl;external 'libgtk-3.so'; procedure gtk_widget_hide(window:pointer);cdecl;external 'libgtk-3.so'; //-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);cdecl;external 'libgtk-3.so'; function gtk_image_new_from_pixbuf(image:pointer):pointer; cdecl;external 'libgtk-3.so'; function gtk_image_new():pointer; cdecl;external 'libgtk-3.so'; function gdk_pixbuf_get_width(src_pixbuf:pointer):integer;cdecl;external 'libgtk-3.so'; function gdk_pixbuf_get_height(src_pixbuf:pointer):integer;cdecl;external 'libgtk-3.so'; 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 _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); {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 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); {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 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 _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 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 := unit(tslvcl).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 /////////////////gdi/////////////////////////////////////////// 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 := unit(tslvcl).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 := unit(tslvcl).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 implementation /////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////额外定义的结构体 为了适应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 MouseIsMoved(); begin if FLock then return ; id := FList[FIndex]; if not id then return ; ps := array(0,0); _wapi.GetCursorPos(ps); if FCpos = ps then return ; FCpos := ps; if Mousehittest then call(Mousehittest,self,id); if Mousemovecall then call(Mousemovecall,self,id); 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 create(api); begin _wapi := api; FCpos := array(0,0); _wapi.GetCursorPos(FCpos); FList := array(); FIndex := -1; FTimer := new unit(tslvcl).TTimer(); FTimer.interval := 30; //30毫秒 FTimer.Ontimer := thisfunction(MouseIsMoved); FTimer.start(); end function destroy(); begin FIndex := -1; FList := array(); FTimer.stop(); FTimer := nil; end Mousemovecall; Mousehittest; _wapi; FCpos; private FLock; FIndex ; FList; end type tgtk_ctl_object = class(_gtkeventtype) private FHitwidgetposition; static FsysCursors; Fsyscommand0x12; Fsyscommand0x12info; protected //////////////////////样式//////// Fdwstyle; FExdwstyle; /////////////////////////////////// function CanignoreBtnpress();virtual; begin return true; end public function Create(h); //构造 begin sinit(); if not _wapi then begin _const := getwin32const(); _wapi := unit(tslvcl).gettswin32api(); FMousemoveernotify := new tenterouterlist(_wapi); FMousemoveernotify.Mousemovecall := thisfunction(widgetmousemovecall); FMousemoveernotify.Mousehittest := thisfunction(widgetmousehit); FsysCursors := array(); FsysCursors[0] := _wapi.gdk_cursor_new(2); FsysCursors[1] := _wapi.gdk_cursor_new(70); FsysCursors[2] := _wapi.gdk_cursor_new(16); end SetHandle(h); FHitwidgetposition := 0; end static FLastPosition; 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])); AddMessageToGtkMessageQueue(id,_const.WM_MOUSEMOVE,0,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; FMousemoveernotify.lock(); 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 r := unit(tslvcl)._twinproc_(FHandle,msg,w,l); if msg = CM_CURSORCHANGED then begin 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 := wd; FHitwidgetposition := r; clearMessageFromGtkMessageQueue(FHandle,CM_CURSORCHANGED); case r of 10,11:begin //_wapi.gdk_window_set_cursor(wd,FsysCursors[1]) ; g_show_cursor_window := 0; AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,FsysCursors[1]); end 12,15:begin //_wapi.gdk_window_set_cursor(wd,FsysCursors[2]) ; g_show_cursor_window := 0; AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,FsysCursors[2]); end 1:begin //_wapi.gdk_window_set_cursor(wd,FsysCursors[0]) ; AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,0,0); end else begin if _wapi.gtk_object_get_data(FHandle,"gtk_decorated") then return ; rsz := _wapi.gtk_object_get_data(FHandle,"gtk_widget_resizeable"); if rsz then begin unit(tslvcl).lowuperdword(l,lo,hi); ht := _wapi.hittestwidget(FHandle,lo,hi); FHitwidgetposition := ht; if ht=10 or ht=11 then begin //return _wapi.gdk_window_set_cursor(wd,FsysCursors[1]) ; g_show_cursor_window := 0; AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,FsysCursors[1]); end else if ht=12 or ht=15 then begin g_show_cursor_window := 0; //return _wapi.gdk_window_set_cursor(wd,FsysCursors[2]) ; AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,wd,FsysCursors[2]); end end //_wapi.gdk_window_set_cursor(wd,FsysCursors[0]) ; return AddMessageToGtkMessageQueue(FHandle,CM_CURSORCHANGED,0,0); 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 fimhandle; function gdk_window_get_state(w:pointer):integegr;cdecl;external 'libgtk-3.so'; function GtkEventDispatchA(a,b,c,d);//gtk消息分发 begin global g_gtk_scroll_lock; if g_gtk_scroll_lock then begin return true; end if FHitwidgetposition in array(110,111,112,115) then begin mn := GetGtkEventNameOrId(b); if mn="event" then begin e := new _GdkEventAny(c); if 3=e.ttype then begin ogps := Fsyscommand0x12info[0]; xy := Fsyscommand0x12info[1]; cxy := array(0,0); _wapi.GetCursorPos(cxy); dx := cxy[0]-ogps[0]; dy := cxy[1]-ogps[1]; case FHitwidgetposition of 110: begin if dx<>0 then _wapi.SetWindowPos(a.handle,0,xy[0]+dx,xy[1],xy[2]-dx,xy[3],0); end 111: begin if dx<>0 then _wapi.SetWindowPos(a.handle,0,xy[0],xy[1],xy[2]+dx,xy[3],0); end 112: begin if dy<>0 then _wapi.SetWindowPos(a.handle,0,xy[0],xy[1]+dy,xy[2],xy[3]-dy,0); end 115: begin if dy<>0 then _wapi.SetWindowPos(a.handle,0,xy[0],xy[1],xy[2],xy[3]+dy,0); end end; return 1; end else if 7 = e.ttype then begin FHitwidgetposition := 0; Fsyscommand0x12info := nil; FMousemoveernotify.unlock(); //return ; end end end else if Fsyscommand0x12 and ifarray(Fsyscommand0x12info) then begin mn := GetGtkEventNameOrId(b); if mn="event" then begin e := new _GdkEventAny(c); if 3=e.ttype then begin ogps := Fsyscommand0x12info[0]; xy := Fsyscommand0x12info[1]; cxy := array(0,0); _wapi.GetCursorPos(cxy); dx := cxy[0]-ogps[0]; dy := cxy[1]-ogps[1]; if dx>3 or dx<-3 or dy<-3 or dy>3 then begin _wapi.SetWindowPos(a.handle,0,xy[0]+dx,xy[1]+dy,-1,-1,0); end return 1; end else if 7 = e.ttype then begin Fsyscommand0x12 := false; Fsyscommand0x12info := nil; FMousemoveernotify.unlock(); //return ; end end end return GtkEventDispatchb(a,b,c,d); end function GtkEventDispatchb(a,b,c,d); //gtk消息分发 begin mn := GetGtkEventNameOrId(b); // _send_ global g_current_get_focus_widget,g_current_loss_focus_widget,g_gtk_buttontable,G_GTK_WINDOW_ACTIVATE, g_gtk_keytable; if not ifarray(g_gtk_buttontable) then g_gtk_buttontable := array(0,0); if not ifarray(g_gtk_keytable) then g_gtk_keytable := array(0x10:0,0x11:0,0x12:0); if mn = "event" then begin e := new _GdkEventAny(c); case e.ttype of GDK_WINDOW_STATE: begin {st := gdk_window_get_state(e.window);//.& 0xffff; if (st .& 32) = 32 then begin echo "\r\n above"; end else if (st .& 64) = 64 then begin echo "\r\n blowe"; end } end GDK_BUTTON_PRESS: begin e := new _GdkEventButton(c); psi := makelong(integer(e.x),integer(e.y)); //r := array(); //_wapi.GetTopWidgetList(a.handle,e.x_root,e.y_root,r); //rl := length(r)-1; //if r[rl,0]<>a.handle then return false;; wp := 0; 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 g_gtk_buttontable[0] := _const.MK_LButton; if FHitwidgetposition in array(10,11,12,15) then begin FHitwidgetposition += 100; FMousemoveernotify.lock(); 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 g_gtk_buttontable[1] := _const.MK_RButton; CallTslVclProc(_const.WM_RBUTTONDOWN ,wp,psi); end end ; 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 AddMessageToGtkMessageQueue(G_GTK_WINDOW_ACTIVATE,0x6,0,0,0); G_GTK_WINDOW_ACTIVATE := hwd; AddMessageToGtkMessageQueue(hwd,0x6,1,0,0); end return CanignoreBtnpress(); end GDK_BUTTON_RELEASE: begin //t := 1+"1234"; e := new _GdkEventButton(c); 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 g_gtk_buttontable[0] := 0; CallTslVclProc(_const.WM_LBUTTONUP ,wp,psi); end 3:begin 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 GDK_2BUTTON_PRESS: begin ne := new _GdkEventButton(c); psi := makelong(integer(ne.x),integer(ne.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 ne.button of 1: begin CallTslVclProc(_const.WM_LBUTTONDBLCLK ,wp,psi); end 3:begin CallTslVclProc(_const.WM_RBUTTONDBLCLK ,wp,psi); end end ; return CanignoreBtnpress(); end 32: begin //echo tostn(new _GdkEventWindowState(c)._getdata_()); end 8,9: //key begin kud := e.ttype; ///////////////////////////////////控制键 e := new _GdkEventKey(c); kv := e.keyval; acskey := array( 65505: 0x10, //shift 65506: 0x10, 65507: 0x11, //control 65508: 0x11, 65513: 0x12, //alt 65514: 0x12 ); if acskey[kv] then begin if 8=kud then begin g_gtk_keytable[acskey[kv]] := _shl( 1,15); end else begin g_gtk_keytable[acskey[kv]] := 0; end end ///////////////菜单按键 if kv = 65513 or kv = 65514 then 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; if not _wapi.gtk_widget_is_toplevel(ah) then return true ; fcsctl := _wapi.gtk_window_get_focus(ah); if not fcsctl then begin fcsctl := unit(tslvcl).initializeapplication().handle; //用主窗口的 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 := 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 10: //mouse in begin //e := new _GdkEventCrossing(c); //echo tostn(e._getdata_()); //echo "===enter\r\n"; FMousemoveernotify.push(a.handle); //_wapi.GetCursorPos(ps); //e := new _GdkEventMotion(c); //echo "\r\n enter:",a.handle,tostn(ps),tostn(e._getdata_()); end 11: //mouse out begin FMousemoveernotify.pop(a.handle); //echo "\r\nleave:",a.handle; end 3: begin // echo "\r\n move",datetimetostr(now()),"====",a.handle,"****",FMousemoveernotify.feach(); // if not(FMousemoveernotify.inner(a.handle)) then // begin // echo "====move====="; // e := new _GdkEventMotion(c); // CallTslVclProc(_const.WM_MOUSEMOVE ,0,makelong(integer(e.x),integer(e.y))); // end end 12: //focus begin h := a.handle; //getfimobj().setclientwindow(e.window); getfimobj().setclientwindow(e.window); getfimobj().setfocusctl(self); if (new _GdkEventFocus(c).iin)=1 then begin g_current_get_focus_widget := h; //echo "\r\nsetfocus==>",h; ch := _wapi.g_object_get_data(h,"gtk_client_parent"); if ch then begin //AddMessageToGtkMessageQueue(ch,_const.WM_SETFOCUS,0,0,0); CallGtkWinProc(ch,_const.WM_SETFOCUS,0,0); end else begin CallTslVclProc(_const.WM_SETFOCUS,0,0,0); end //WM_SETFOCUS getfimobj().focusin(); end else begin g_current_loss_focus_widget := h; g_current_get_focus_widget := 0; ch := _wapi.g_object_get_data(a.handle,"gtk_client_parent"); //将killfocus 修改为立即执行 if ch then begin //AddMessageToGtkMessageQueue(ch,_const.WM_KILLFOCUS,0,0,0); CallGtkWinProc(ch,_const.WM_KILLFOCUS,0,0); end else begin //echo "\r\nkill focus:",h; CallTslVclProc(_const.WM_KILLFOCUS,0,0,0); end getfimobj().focusout(); end end end ; end if mn="activate" then begin //echo "\r\nacive","==",b,"==",c,"d"; end // r := GtkEventDispatch(a,mn,c,d); return r; end function GtkEventDispatch(a,mn,c,d);virtual; //根据名称处理gtk消息 begin //消息分发 global g_current_get_focus_widget; case mn of "destroy" : begin FMousemoveernotify.unlock(); Fsyscommand0x12 := 0; Fsyscommand0x12info := nil; FHitwidgetposition := 0; r := CallTslVclProc(_const.WM_NCDESTROY ,0,0); //echo "\r\ncall destroy===",r,">>>",a.handle; end { "map": begin end "wm-user": begin r := CallTslVclProc(_const.WM_USER ,c,d); end "button-press-event": begin //return true; end "button-release-event": begin end "motion-notify-event": begin //e := new _GdkEventMotion(c); //CallTslVclProc(_const.WM_MOUSEMOVE ,0,makelong(integer(e.x),integer(e.y))); //return true; end "set-focus-child": begin //echo "\r\nsignal name id:",GetGtkEventNameOrId("set-focus-child"); //echo "\r\nset focus child:",a.handle,"*****",c,"============",d; end "key-press-event": begin //echo "\r\n==key :=",1,"***" , a.handle,"====",_wapi.gtk_widget_is_toplevel(a.handle),"==========",datetimetostr(now()); end } end ; return r; 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" 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 g_signal_handler_disconnect(FHandle,lnid); end FConnectNameIds := array(); FConnectHandlers := array(); end function getsignalmap();virtual; begin return array( "wm-user":'tsl_gtk_wmuser_event', //用户 "destroy":"tsl_gtk_destroy_event", //销毁 "activate":"tsl_gtk_activate_event", //活动 "clicked":"tsl_gtk_clicked_event", //点击 "value-changed":"tsl_gtk_adj_value_changed_event", //值改变 "delete-event":"tsl_gtk_delete_event", //删除 //"day-selected":"tsl_gtk_day_select_event", //日历选择 "changed" :"tsl_gtk_changed_event", //改变 "preedit-changed":"tsl_gtk_preedit_changed_event" , ); end function Connect(n,f); //连接消息 begin //删除connect //添加connect //connect id if FHandle=0 then return 0; if not ifstring(n) then return 0; ln := FormularSingalName(lowercase(n)); lnid := FConnectNameIds[ln]; if lnid then begin //echo "\r\n========================remove connect:",n; reindex(FConnectNameIds,array(ln:nil)); g_signal_handler_disconnect(FHandle,lnid); end //echo "\r\nconnect ===========================",FHandle,"=====",n; eid := GetGtkEventNameOrId(ln); fn := (getsignalmap())[ln]; if not(fn and ifstring(fn)) then fn := "tsl_gtk_normal_event_cb"; lnid := g_signal_connect_data(FHandle, ln, gettslvcleventhandler(fn), eid,nil,0); FConnectNameIds[ln] := lnid; FConnectHandlers[inttostr(eid)] := f; 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 datatype(c)=7 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; class function gtk_widget_get_type():pointer;cdecl;external 'libgtk-3.so'; class procedure g_signal_handler_disconnect(instance:pointer;id:integer);cdecl;external 'libgtk-3.so'; class function g_signal_connect_data(instance:pointer; detailed_signal:string; c_handler:pointer;data:pointer;dd:pointer;f:integer):pointer;cdecl;external 'libgtk-3.so'; class 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;cdecl;external 'libgtk-3.so'; FConnectNameIds; FConnectHandlers; FValues; FDestroysignalId; static TGtkObjects; Static FinitNewSignaled; function SetHandle(h); begin if FHandle then return 0; initNewSingal(); 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 class function initNewSingal(); begin return ; //wm-user if FinitNewSignaled then return ; FinitNewSignaled := true; for i,v in array(gtk_widget_get_type()) do begin g_signal_new("wm-user", v, 2, 0, nil, nil, 0, 4, 2, 17*4,68); end end function FormularSingalName(n); begin r := ""; for i := 1 to length(n) do begin vi := n[i]; if vi="_" then r+="-"; else r+=vi; end return r; end function needdestroy();virtual; begin return true; end static FMousemoveernotify; 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 getsignalmap();override; begin return array( "preedit-start":"dodeleteevents" , "preedit-changed":"dodeleteevents" , "preedit-surrounding":"dodeleteevents" , "preedit-end":"dodeleteevents" , "commit":"tsl_gtk_normal_event_cb" ); end function GtkEventDispatch(a,mn,c,d);override; //根据名称处理gtk消息 begin case mn of "commit": begin FCommit := ReadStringFromPtr(c); //echo FCommit,FCtl,"**\r\n"; if FCtl then begin s := utf8toansi(FCommit); for i:= 1 to length(s) do begin //echo "***\r\n",ord(s[i]),">>",FCtl._const.WM_CHAR,"<<<"; FCtl.CallTslVclProc(_const.WM_CHAR,ord(s[i]),0); end end //echo "cmt=====",tostn(FCommit); end end; end function GtkBaseEventName();override; //绑定的消息 begin //"commit","delete-surrounding", return array("commit");//,"preedit-changed","preedit-end","preedit-start","retrieve-surrounding"); 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; //Connect("event",thisfunction(scrollevent)); 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)); hwd := handle; _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]); //mtic; CallTslVclProc(_const.WM_PAINT,0,0); //绘制 _wapi.cairo_set_dash(cr,array(4.0,0.0),2,0); if not(self(true) is class(tgtk_ctl_window_PoPup)) then begin 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, 2); _wapi.cairo_rectangle(cr,0,0,r[2]-1,r[3]-1); _wapi.cairo_stroke(cr); end if (Fdwstyle .& _const.WS_BORDER)= _const.WS_BORDER then begin _wapi.cairo_set_source_rgb(cr, 100/255, 100/255, 100/255); _wapi.cairo_set_line_width(cr, 0.5); _wapi.cairo_rectangle(cr,1,1,r[2]-1,r[3]-1); _wapi.cairo_stroke(cr); end CallTslVclProc(_const.WM_NCPAINT,0,cr); //绘制 end _wapi.cairo_destroy(cr); _wapi.gtk_object_set_data(cr); //echo "\r\ntime:",datetimetostr(now()),"===timeuses:",mtoc,"===",hd; end; function CreateWnd(dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nwidth,nheight,hwndparent,hmenu,hinstance,lpParam);override; begin //echo "\r\nctl:",tostn(params),tostn(__stack_frame),datetimetostr(now()); d := new tslcstructureobj(MemoryAlignmentCalculate( array(("lpcreateparams","intptr",0))),lpParam); isp := unit(tslvcl).controlisCustomPaint(d._getvalue_("lpcreateparams")); 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(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; return inherited; 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,w-scrlsize,scrlsize); end else _wapi.gtk_widget_set_size_request(FHscrollbar,w,scrlsize); if (fbarshow .& 2)=2 then //h begin _wapi.gtk_widget_set_size_request(Fvscrollbar,scrlsize,h-scrlsize); end else _wapi.gtk_widget_set_size_request(Fvscrollbar,scrlsize,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,w,h); //inherited widgetsizechanged(h,w); end //else inherited widgetsizechanged(h,w); inherited widgetsizechanged(h,w); 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 static fstaticchanged; function GtkEventDispatch(a,mn,c,d);override; begin //消息分发 if mn="scroll-event" then begin h := a.handle; nt := now(); if (nt-(1/24/3600/20))0 and dr<>1 then return ; x := ed.x_root; y := ed.y_root; 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 hasMessageFromGtkMessageQueue(-1,_const.LM_MOUSEWHEEL) then return true; if hasMessageFromGtkMessageQueue(-1,_const.WM_SIZE) then return true; if hasMessageFromGtkMessageQueue(-1,_const.WM_MOUSEMOVE) then return true; FScrollT := now(); dr := (dr=1)?-1:1; xy := makelong(rxy[0],rxy[1]); 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 dr := makelong(ctl,dr); //clearMessageFromGtkMessageQueue(ri,_const.LM_MOUSEWHEEL); AddMessageToGtkMessageQueue(ri,_const.LM_MOUSEWHEEL,dr,xy,1); return true; end end return inherited; end function Destroy();override; begin inherited; FHadjustment := nil; Fvadjustment := nil; FHscrollbar := nil; Fvscrollbar := nil; FLayouter := nil; Fvscrollbarobj := nil; Fhscrollbarobj := nil; FClientWideget := nil; end protected function initadjustSingal(); 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; 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 GtkEventDispatch(a,mn,c,d);override; begin //消息分发 //echo "eventtype:",_wapi.gdk_event_get_event_type(c),"\r\n"; case mn of "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); //echo "\r\n>>>",ALeft,"===",ATop; AWidth := integer(cf.width); AHeight := integer(cf.height); 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); if cy <> AHeight then _wapi.g_object_set_data(h,"gtk_layout_height",AHeight); 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,(SizeChanged?1:0).|(PosChanged?2:0)); return r; end "delete-event": begin r := CallTslVclProc(_const.WM_CLOSE,0,0); return r; end "activate-default": begin echo "activate-defalut\r\n"; end end; return inherited; end function GtkBaseEventName();override; begin return inherited union2 array("configure-event","delete-event","scroll-event","activate-default"); end function CreateWnd(dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nwidth,nheight,hwndparent,hmenu,hinstance,lpParam);override; begin //echo "\r\nctl===popup:",tostn(params),tostn(__stack_frame),datetimetostr(now()),">>>>"; h := _wapi.gtk_window_new(0); //控件层 srszie := (_const.WS_SIZEBOX .& dwStyle)=_const.WS_SIZEBOX; _wapi.gtk_object_set_data(h,"gtk_decorated",1); if not((_const.WS_CAPTION .& dwStyle)= _const.WS_CAPTION or (_const.WS_SYSMENU .& dwStyle)=_const.WS_SYSMENU) then begin _wapi.gtk_window_set_decorated(h,false); _wapi.gtk_object_set_data(h,"gtk_decorated",0); //无菜单顶层窗口 end else begin _wapi.gtk_window_set_title(h,_wapi.TslStringToGtk(lpWindowName)); //有标题 有菜单的顶层窗口 end if (_const.WS_BORDER .& dwStyle)=_const.WS_BORDER then //Border begin _wapi.gtk_container_set_border_width(h,1); 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.gtk_window_set_resizable(h,srszie); _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; /////////////////////////水平滚动条//////////////////////////////////// initadjustSingal(); evtdrawbox := _wapi.gtk_event_box_new(); //lot 放一个event box 便于绘制 _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,nwidth,nheight); //_wapi.gtk_widget_set_size_request(evtdrawbox,2000,2000); //_wapi.gtk_widget_set_events(eb,16777214); _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,y); if nwidth>0 and nheight>0 then begin _wapi.gtk_window_resize(h,nwidth,nheight); end _wapi.gtk_widget_show_all(vbox); InitContainerList(h); //容器list if (_const.WS_VISIBLE .& dwStyle)=_const.WS_VISIBLE then begin _wapi.ShowWindow(h); end else begin _wapi.gtk_widget_hide(h); end _wapi.SetParent(h,hwndparent); handle := h; return inherited; end 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(); //布局绘制层 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.gtk_widget_set_size_request(evtdrawbox,10000,10000); _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 /////////////////////////滚动条//////////////////////////////////// initadjustSingal(); ///////////////////////////颜色处理///////////////////////////////////////// {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;cdecl;external "libgtk-3.so"; function g_main_context_ref(m:pointer):pointer;cdecl;external "libgtk-3.so"; function g_main_context_acquire(m:pointer):integer;cdecl;external "libgtk-3.so"; procedure g_main_context_release(m:pointer);cdecl;external "libgtk-3.so"; type tGtkMessageQueue = class //消息队列 {** @ignore(忽略) gtk消息队列 **} private 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(); FLen++; FData[FLen] := array(h,m,l,w,obj); unlock(); end function Feach(); begin lock(); if FCurrent100 then begin FData := FData[FCurrent+1:];//min(FLen-1,FCurrent+100)]; FCurrent := -1; FLen := length(FData); end end else begin Clean(); end unlock(); return r; end function cleaneasyLostMessage(h,m); begin 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 hasMessageFromGtkMessageQueue(h,m); begin GLobal G_GTK_MESSAGE_QUEUE_A; if G_GTK_MESSAGE_QUEUE_A then G_GTK_MESSAGE_QUEUE_A.haseasyLostMessage(h,m); end function clearMessageFromGtkMessageQueue(h,m); begin GLobal G_GTK_MESSAGE_QUEUE_A; if G_GTK_MESSAGE_QUEUE_A then G_GTK_MESSAGE_QUEUE_A.cleaneasyLostMessage(h,m); end function AddMessageToGtkMessageQueue(FHandle,msg,wparam,lparam,d); //推送消息 begin GLobal G_GTK_MESSAGE_QUEUE_A; if not G_GTK_MESSAGE_QUEUE_A then begin G_GTK_MESSAGE_QUEUE_A := new tGtkMessageQueue(); end G_GTK_MESSAGE_QUEUE_A.add(FHandle,msg,wparam,lparam,d); end function FeachMessageFromGtkMessageQueue(); //获取消息 begin GLobal G_GTK_MESSAGE_QUEUE_A; if G_GTK_MESSAGE_QUEUE_A then begin d := G_GTK_MESSAGE_QUEUE_A.Feach(); return d; end //return class(tgtk_ctl_object).Feach(params); end function GetGtkEventNameOrId(n); //获得event begin global G_E_ID_Name_1; global G_E_ID_Name_2; if not ifarray(G_E_ID_Name_1) then begin 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 ); for i,v in G_E_ID_Name_1 do begin G_E_ID_Name_2[v] := i; end end if ifstring(n) then begin ln := lowercase(n); r := G_E_ID_Name_1[ln]; if not r then begin r := new tcstring(64); r.setv(n); r := r._getptr_(); G_E_ID_Name_1[ln] := r; G_E_ID_Name_2[r] := ln; end return r; end else if n>0 or n<0 then return G_E_ID_Name_2[n]; end function callpaintmessage(d); begin _wapi := unit(tslvcl).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 unit(tslvcl)._timeproc_(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 := unit(tslvcl).gettswin32api(); h := _wapi.GetParent(d[0]); if h then begin AddMessageToGtkMessageQueue(h,d[1],h,d[3],true); end return 1; end return r; end else begin tslprocessmessages(false); sleep(10); end end else begin tslprocessmessages(false); sleep(10);//休息一下 end unit(uvclthreadworker).RunThreadWorkerHost(); 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 := 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 type taggtkWNDCLASSA = class(tslcstructureobj)// 窗口类对象 %% static classstruct; class function getstruct(); begin if not classstruct then begin classstruct := MemoryAlignmentCalculate( array( ("cbsize","int",0), ("style","int",0), ("lpfnwndproc","intptr",0), ("cbclsextra","int",0), ("cbwndextra","int",0), ("hinstance","intptr",0), ("hicon","intptr",0), ("hcursor","intptr",0), ("hbrbackground","intptr",0), ("lpszmenuname","intptr",0),//("lpszmenuname","char*",100), ("lpszclassname","char*",100), ("hiconsm","intptr",0))); end return classstruct; end function create(ptr); begin class(tslcstructureobj).create(getstruct(),ptr); _setvalue_("cbsize",_size_()); end 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 unit(tslvcl).TSLUIBASE(); end function makelong(l,h,p); begin return unit(tslvcl).makelong(l,h,p); end function tsl_gtk_get_thread(); begin return static systhreadid(); end type _gtkeventtype=class static GTK_EVENT_ISNIT; static GDK_DELETE; static GDK_DESTROY; static GDK_EXPOSE; static GDK_MOTION_NOTIFY; static GDK_BUTTON_PRESS; static GDK_2BUTTON_PRESS; static GDK_3BUTTON_PRESS; static GDK_BUTTON_RELEASE; static GDK_KEY_PRESS; static GDK_KEY_RELEASE; static GDK_ENTER_NOTIFY; static GDK_LEAVE_NOTIFY; static GDK_FOCUS_CHANGE; static GDK_CONFIGURE; static GDK_MAP; static GDK_UNMAP; static GDK_PROPERTY_NOTIFY; static GDK_SELECTION_CLEAR; static GDK_SELECTION_REQUEST; static GDK_SELECTION_NOTIFY; static GDK_PROXIMITY_IN; static GDK_PROXIMITY_OUT; static GDK_DRAG_ENTER; static GDK_DRAG_LEAVE; static GDK_DRAG_MOTION; static GDK_DRAG_STATUS; static GDK_DROP_START; static GDK_DROP_FINISHED; static GDK_CLIENT_EVENT; static GDK_VISIBILITY_NOTIFY; static GDK_NO_EXPOSE; static GDK_SCROLL; static GDK_WINDOW_STATE; static GDK_SETTING; static GDK_OWNER_CHANGE; static GDK_GRAB_BROKEN; static GDK_DAMAGE; static GDK_NOTHING; static GTK_RESPONSE_HELP; static GTK_RESPONSE_APPLY; static GTK_RESPONSE_NO; static GTK_RESPONSE_YES; static GTK_RESPONSE_CLOSE; static GTK_RESPONSE_CANCEL; static GTK_RESPONSE_OK; static GTK_RESPONSE_DELETE_EVENT; static GTK_RESPONSE_ACCEPT; static GTK_RESPONSE_REJECT; static GTK_RESPONSE_NONE; class function sinit(); begin if GTK_EVENT_ISNIT then return ; GTK_EVENT_ISNIT := true; GDK_DELETE := 0; GDK_DESTROY := 1; GDK_EXPOSE := 2; GDK_MOTION_NOTIFY := 3; GDK_BUTTON_PRESS := 4; GDK_2BUTTON_PRESS := 5; GDK_3BUTTON_PRESS := 6; GDK_BUTTON_RELEASE := 7; GDK_KEY_PRESS := 8; GDK_KEY_RELEASE := 9; GDK_ENTER_NOTIFY := 10; GDK_LEAVE_NOTIFY := 11; GDK_FOCUS_CHANGE := 12; GDK_CONFIGURE := 13; GDK_MAP := 14; GDK_UNMAP := 15; GDK_PROPERTY_NOTIFY := 16; GDK_SELECTION_CLEAR := 17; GDK_SELECTION_REQUEST := 18; GDK_SELECTION_NOTIFY := 19; GDK_PROXIMITY_IN := 20; GDK_PROXIMITY_OUT := 21; GDK_DRAG_ENTER := 22; GDK_DRAG_LEAVE := 23; GDK_DRAG_MOTION := 24; GDK_DRAG_STATUS := 25; GDK_DROP_START := 26; GDK_DROP_FINISHED := 27; GDK_CLIENT_EVENT := 28; GDK_VISIBILITY_NOTIFY := 29; GDK_NO_EXPOSE := 30; GDK_SCROLL := 31; GDK_WINDOW_STATE := 32; GDK_SETTING := 33; GDK_OWNER_CHANGE := 34; GDK_GRAB_BROKEN := 35; GDK_DAMAGE := 36; GDK_NOTHING := -1; GTK_RESPONSE_HELP := -11; GTK_RESPONSE_APPLY := -10; GTK_RESPONSE_NO := -9; GTK_RESPONSE_YES := -8; GTK_RESPONSE_CLOSE := -7; GTK_RESPONSE_CANCEL := -6; GTK_RESPONSE_OK := -5; GTK_RESPONSE_DELETE_EVENT := -4; GTK_RESPONSE_ACCEPT := -3; GTK_RESPONSE_REJECT := -2; GTK_RESPONSE_NONE := -1; end end initialization end.