From e77ddf4e7ae43f48ba2a6436e8c3b08813cd32b6 Mon Sep 17 00:00:00 2001 From: JianjunLiu Date: Fri, 12 Aug 2022 16:52:49 +0800 Subject: [PATCH] =?UTF-8?q?=E7=95=8C=E9=9D=A2=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 浼樺寲 --- designer/tslvcldesigner.tsf | 7 +- funcext/tvclib/ugtkinterface.tsf | 172 +++++++++++++++++++------------ funcext/tvclib/utslvcltree.tsf | 5 +- 3 files changed, 113 insertions(+), 71 deletions(-) diff --git a/designer/tslvcldesigner.tsf b/designer/tslvcldesigner.tsf index 0475019..041c343 100644 --- a/designer/tslvcldesigner.tsf +++ b/designer/tslvcldesigner.tsf @@ -1018,9 +1018,10 @@ type TVclDesigner = class(tvcform) begin f := FProjectFileOpener.FileName; FProjectsManager.OpenFileFromTpjFile(f); - for i := length(f) downto 3 do + fio := ioFileseparator(); + for i := length(f) downto 2 do begin - if f[i]="\\" then + if f[i]=fio then begin FProjectFileOpener.initialDir := f[1:(i-1)]; break; @@ -1035,7 +1036,7 @@ type TVclDesigner = class(tvcform) fio := ioFileseparator(); if f then begin - for i := length(f) downto 3 do + for i := length(f) downto 2 do begin if f[i]=fio then begin diff --git a/funcext/tvclib/ugtkinterface.tsf b/funcext/tvclib/ugtkinterface.tsf index 16942a4..543be74 100644 --- a/funcext/tvclib/ugtkinterface.tsf +++ b/funcext/tvclib/ugtkinterface.tsf @@ -93,7 +93,9 @@ type tsgtkapi = class(tgtkapis) y := g_object_get_data(hwd,"gtk_layout_y"); w := g_object_get_data(hwd,"gtk_layout_width"); h := g_object_get_data(hwd,"gtk_layout_height"); - gtk_window_move(hwd,x,y); + //global g_w_c_width; + //pcd := gtk_object_get_data(h,"gtk_decorated")?g_w_c_width:0; + gtk_window_move(hwd,x,y-pcd); if w>=0 and h>=0 then gtk_widget_set_size_request(hwd,w,h); end @@ -213,7 +215,7 @@ type tsgtkapi = class(tgtkapis) if (uiAction = 0x30) and (pvParam>0 or pvParam<0) then begin w := static gdk_screen_width(); - h := static gdk_screen_height(); + h := static gdk_screen_height()-70; rc := new tcrect(pvParam); rc._setvalue_(0,0); rc._setvalue_(1,0); @@ -245,7 +247,9 @@ type tsgtkapi = class(tgtkapis) //info := new TWINDOWINFO(f); end function SetWindowPos(h:pointer;hWndInsertAfter:pointer; X:integer; Y:integer; cx:integer;cy:integer; uFlags:integer); - begin + begin + //echo "\r\nset window pos:" ,x,"===",y,"=<>=",cx,"===",cy; + global g_w_c_width; if 0x400 .& uFlags then begin //echo "border set \r\n"; @@ -257,11 +261,12 @@ type tsgtkapi = class(tgtkapis) wt := static gtk_window_get_type(); if g_type_check_instance_is_a(h,wt) then //主窗口 begin + pcd := gtk_object_get_data(h,"gtk_decorated")?g_w_c_width:0; x0 := g_object_get_data(h,"gtk_layout_x"); y0 := g_object_get_data(h,"gtk_layout_y"); if (x>=0 and y>=0) and (x<>x0 or y<>y0) then //窗口位置 - begin - gtk_window_move(h,x,y); + begin + gtk_window_move(h,x,y-pcd); g_object_set_data(h,"gtk_layout_x",x); g_object_set_data(h,"gtk_layout_y",y); flg .|=2; @@ -455,55 +460,56 @@ type tsgtkapi = class(tgtkapis) // class(tUIglobalData).uigetdata("TGlobalComponentcache").getwndbyhwnd(hwnd); function Gtk_TrigMoveSizeEvent(h,aleft,atop,AWidth,AHeight,flg); begin - gfw := class(tUIglobalData).uigetdata("G_F_TWIN_PROC_"); - SWP_NOMOVE := 2; - SWP_NOSIZE := 1; - WM_WINDOWPOSCHANGED := 0x47; - d := new tvclwindowpos_class(0); - SizeChanged := flg .& 1; - PosChanged := flg .& 2; - - if SizeChanged then - begin - vb := g_object_get_data(h,"gtk_window_vscroll_bar"); - hb := g_object_get_data(h,"gtk_window_hscroll_bar"); - if vb and gtk_widget_is_visible(vb) then + gfw := class(tUIglobalData).uigetdata("G_F_TWIN_PROC_"); + SWP_NOMOVE := 2; + SWP_NOSIZE := 1; + WM_WINDOWPOSCHANGED := 0x47; + d := new tvclwindowpos_class(0); + SizeChanged := flg .& 1; + PosChanged := flg .& 2; + if SizeChanged then begin - d.cx := max(AWidth-10,0); - end - else d.cx := AWidth; - if hb and gtk_widget_is_visible(hb) then - begin - d.cy := max(AHeight-10,0); - end - else + vb := g_object_get_data(h,"gtk_window_vscroll_bar"); + hb := g_object_get_data(h,"gtk_window_hscroll_bar"); + {if vb and gtk_widget_is_visible(vb) then + begin + d.cx := max(AWidth-10,0); + end + else d.cx := AWidth; + if hb and gtk_widget_is_visible(hb) then + begin + d.cy := max(AHeight-10,0); + end + else + d.cy := AHeight; + } + d.cx := AWidth; d.cy := AHeight; - D.flags := SWP_NOMOVE; - if gfw then call(gfw,h,WM_WINDOWPOSCHANGED,0,d._getptr_); - end - if PosChanged then - begin - d.x := ALeft; - d.y := ATop; - d.flags := SWP_NOSIZE; - if gfw then call(gfw,h,WM_WINDOWPOSCHANGED,0,d._getptr_); - end - if SizeChanged then //这个是不是应该放前面 - begin - gtk_widgetsizechanged(h,AHeight,AWidth); - end - {if SizeChanged then - begin - _twinproc_(h,0x5,0,makeposition(AWidth,AHeight)); - end} - if PosChanged then - begin - if gfw then + D.flags := SWP_NOMOVE; + if gfw then call(gfw,h,WM_WINDOWPOSCHANGED,0,d._getptr_); + end + if PosChanged then begin - call(gfw,h,0x3,0,makeposition(ALeft,ATop)); - end - - end + d.x := ALeft; + d.y := ATop; + d.flags := SWP_NOSIZE; + if gfw then call(gfw,h,WM_WINDOWPOSCHANGED,0,d._getptr_); + end + if SizeChanged then //这个是不是应该放前面 + begin + gtk_widgetsizechanged(h,AHeight,AWidth); + end + {if SizeChanged then + begin + _twinproc_(h,0x5,0,makeposition(AWidth,AHeight)); + end} + if PosChanged then + begin + if gfw then + begin + call(gfw,h,0x3,0,makeposition(ALeft,ATop)); + end + end end function GetCursorPos(var p:array of integer); @@ -1331,12 +1337,11 @@ type tsgtkapi = class(tgtkapis) if mb and gtk_widget_is_visible(mb) then begin rec := zeros(4); - gtk_widget_get_allocation(mb,rec); - if rec[3]>1 then - begin - p[1]+= rec[3] ;//max(rec[3],25); - end - + gtk_widget_get_allocation(mb,rec); + if rec[3]>1 then + begin + p[1]+= rec[3] ;//max(rec[3],25); + end end end return true; @@ -3056,8 +3061,11 @@ type tgtkapis = class() //gtk end if cls then begin - r := cls.CreateWnd(dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nwidth,nheight,hwndparent,hmenu,hinstance,d._getptr_()); - + global g_w_i_datas ; + dptr := d._getptr_(); + //g_w_i_datas[inttostr(dptr)] := new tgtk_wnd_info(); + r := cls.CreateWnd(dwExStyle,lpClassName,lpWindowName,dwStyle,x,y,nwidth,nheight,hwndparent,hmenu,hinstance,dptr); + //reindex(g_w_i_datas,array(inttostr(dptr):nil)); end return r; end @@ -6032,7 +6040,7 @@ type tgtk_ctl_scroll_window = class(tgtk_ctl_object) _wapi.gtk_widget_set_size_request(FClientWideget,w,h); //inherited widgetsizechanged(h,w); end //else inherited widgetsizechanged(h,w); - inherited widgetsizechanged(h,w); + inherited widgetsizechanged(h,w); //clientrect end function GetScrollInfo(nBar,si);override;//获得滚动条信息 begin @@ -6386,7 +6394,12 @@ type tgtk_ctl_window_PoPup = class(tgtk_ctl_scroll_window) 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 cy <> AHeight then + begin + //global g_w_c_width; + //pcd := _wapi.gtk_object_get_data(h,"gtk_decorated")?g_w_c_width:0; + _wapi.g_object_set_data(h,"gtk_layout_height",AHeight); + end if x <> ALeft then begin _wapi.g_object_set_data(h,"gtk_layout_x",aleft); @@ -6429,6 +6442,7 @@ type tgtk_ctl_window_PoPup = class(tgtk_ctl_scroll_window) //无菜单顶层窗口 end else begin + //nheight := max(10,nheight_-30); _wapi.gtk_window_set_title(h,_wapi.TslStringToGtk(lpWindowName)); //有标题 有菜单的顶层窗口 end @@ -6468,13 +6482,13 @@ type tgtk_ctl_window_PoPup = class(tgtk_ctl_scroll_window) //_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); - + global g_w_c_width; InitWidgetSize(h,x,y,nwidth,nheight); - _wapi.gtk_window_move(h,x,y); + pcd := _wapi.gtk_object_get_data(h,"gtk_decorated")?g_w_c_width:0; + _wapi.gtk_window_move(h,x,y-pcd); if nwidth>0 and nheight>0 then begin - _wapi.gtk_window_resize(h,nwidth,nheight); - + _wapi.gtk_window_resize(h,nwidth,nheight); end _wapi.gtk_widget_show_all(vbox); InitContainerList(h); //容器list @@ -6491,6 +6505,29 @@ type tgtk_ctl_window_PoPup = class(tgtk_ctl_scroll_window) end end +type tgtk_wnd_info = class() + function create(h); + begin + x := 0; + y := 0; + h := 0; + w := 0; + c := 0; + m := 0; + lt := 0; + end + function destroy(); + begin + end + x; + y; + h; + w; + c; + m; + lt; + fh; +end type tgtk_ctl_window = class(tgtk_ctl_scroll_window) function Create(h);override; begin @@ -7042,5 +7079,8 @@ CAIRO_OPERATOR_HSL_LUMINOSITY:=28; } function gtk_init_check(argc:string;argcv:string):integer;cdecl;external 'libgtk-3.so'; initialization - gtk_init_check(nil,nil); + global g_w_i_datas,g_w_c_width; + gtk_init_check(nil,nil); + g_w_i_datas := array(); + g_w_c_width := 35; end. \ No newline at end of file diff --git a/funcext/tvclib/utslvcltree.tsf b/funcext/tvclib/utslvcltree.tsf index 7adf135..a294043 100644 --- a/funcext/tvclib/utslvcltree.tsf +++ b/funcext/tvclib/utslvcltree.tsf @@ -851,7 +851,7 @@ type TcustomTreeCtlNode = class(TVirtualListItem) begin if not Owner.NodeInList(p) then return 0;// 不在列表中 if not p.Expanded then return 0; //非展开 - pidx := Owner.GetItemIndex(p); //获得位置 + pidx := Owner.GetItemIndex(p); //获得位置 end else //根节点 begin pidx := -1; @@ -1361,7 +1361,7 @@ type TVirtualList = class(TVirtualListFixed) begin idx := b; ei := e; - if not(idx >= 0 and idx)then return false; + if not(idx >= 0{ and idx})then return false; Try IncPaintLock(); while idx <= ei do @@ -1699,6 +1699,7 @@ type TcustomTreeCtl = class(TVirtualList) begin r := CallSelChange(it); if r then return; + if it=RootNode then return ; IF HandleAllocated()then begin GoToNode(it);