界面库

优化
This commit is contained in:
JianjunLiu 2022-08-12 16:52:49 +08:00
parent 8ea9849190
commit e77ddf4e7a
3 changed files with 113 additions and 71 deletions

View File

@ -1018,9 +1018,10 @@ type TVclDesigner = class(tvcform)
begin begin
f := FProjectFileOpener.FileName; f := FProjectFileOpener.FileName;
FProjectsManager.OpenFileFromTpjFile(f); FProjectsManager.OpenFileFromTpjFile(f);
for i := length(f) downto 3 do fio := ioFileseparator();
for i := length(f) downto 2 do
begin begin
if f[i]="\\" then if f[i]=fio then
begin begin
FProjectFileOpener.initialDir := f[1:(i-1)]; FProjectFileOpener.initialDir := f[1:(i-1)];
break; break;
@ -1035,7 +1036,7 @@ type TVclDesigner = class(tvcform)
fio := ioFileseparator(); fio := ioFileseparator();
if f then if f then
begin begin
for i := length(f) downto 3 do for i := length(f) downto 2 do
begin begin
if f[i]=fio then if f[i]=fio then
begin begin

View File

@ -93,7 +93,9 @@ type tsgtkapi = class(tgtkapis)
y := g_object_get_data(hwd,"gtk_layout_y"); y := g_object_get_data(hwd,"gtk_layout_y");
w := g_object_get_data(hwd,"gtk_layout_width"); w := g_object_get_data(hwd,"gtk_layout_width");
h := g_object_get_data(hwd,"gtk_layout_height"); 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 if w>=0 and h>=0 then
gtk_widget_set_size_request(hwd,w,h); gtk_widget_set_size_request(hwd,w,h);
end end
@ -213,7 +215,7 @@ type tsgtkapi = class(tgtkapis)
if (uiAction = 0x30) and (pvParam>0 or pvParam<0) then if (uiAction = 0x30) and (pvParam>0 or pvParam<0) then
begin begin
w := static gdk_screen_width(); w := static gdk_screen_width();
h := static gdk_screen_height(); h := static gdk_screen_height()-70;
rc := new tcrect(pvParam); rc := new tcrect(pvParam);
rc._setvalue_(0,0); rc._setvalue_(0,0);
rc._setvalue_(1,0); rc._setvalue_(1,0);
@ -245,7 +247,9 @@ type tsgtkapi = class(tgtkapis)
//info := new TWINDOWINFO(f); //info := new TWINDOWINFO(f);
end end
function SetWindowPos(h:pointer;hWndInsertAfter:pointer; X:integer; Y:integer; cx:integer;cy:integer; uFlags:integer); 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 if 0x400 .& uFlags then
begin begin
//echo "border set \r\n"; //echo "border set \r\n";
@ -257,11 +261,12 @@ type tsgtkapi = class(tgtkapis)
wt := static gtk_window_get_type(); wt := static gtk_window_get_type();
if g_type_check_instance_is_a(h,wt) then //主窗口 if g_type_check_instance_is_a(h,wt) then //主窗口
begin begin
pcd := gtk_object_get_data(h,"gtk_decorated")?g_w_c_width:0;
x0 := g_object_get_data(h,"gtk_layout_x"); x0 := g_object_get_data(h,"gtk_layout_x");
y0 := g_object_get_data(h,"gtk_layout_y"); y0 := g_object_get_data(h,"gtk_layout_y");
if (x>=0 and y>=0) and (x<>x0 or y<>y0) then //窗口位置 if (x>=0 and y>=0) and (x<>x0 or y<>y0) then //窗口位置
begin begin
gtk_window_move(h,x,y); gtk_window_move(h,x,y-pcd);
g_object_set_data(h,"gtk_layout_x",x); g_object_set_data(h,"gtk_layout_x",x);
g_object_set_data(h,"gtk_layout_y",y); g_object_set_data(h,"gtk_layout_y",y);
flg .|=2; flg .|=2;
@ -455,55 +460,56 @@ type tsgtkapi = class(tgtkapis)
// class(tUIglobalData).uigetdata("TGlobalComponentcache").getwndbyhwnd(hwnd); // class(tUIglobalData).uigetdata("TGlobalComponentcache").getwndbyhwnd(hwnd);
function Gtk_TrigMoveSizeEvent(h,aleft,atop,AWidth,AHeight,flg); function Gtk_TrigMoveSizeEvent(h,aleft,atop,AWidth,AHeight,flg);
begin begin
gfw := class(tUIglobalData).uigetdata("G_F_TWIN_PROC_"); gfw := class(tUIglobalData).uigetdata("G_F_TWIN_PROC_");
SWP_NOMOVE := 2; SWP_NOMOVE := 2;
SWP_NOSIZE := 1; SWP_NOSIZE := 1;
WM_WINDOWPOSCHANGED := 0x47; WM_WINDOWPOSCHANGED := 0x47;
d := new tvclwindowpos_class(0); d := new tvclwindowpos_class(0);
SizeChanged := flg .& 1; SizeChanged := flg .& 1;
PosChanged := flg .& 2; PosChanged := flg .& 2;
if SizeChanged then
if SizeChanged then
begin
vb := g_object_get_data(h,"gtk_window_vscroll_bar");
hb := g_object_get_data(h,"gtk_window_hscroll_bar");
if vb and gtk_widget_is_visible(vb) then
begin begin
d.cx := max(AWidth-10,0); vb := g_object_get_data(h,"gtk_window_vscroll_bar");
end hb := g_object_get_data(h,"gtk_window_hscroll_bar");
else d.cx := AWidth; {if vb and gtk_widget_is_visible(vb) then
if hb and gtk_widget_is_visible(hb) then begin
begin d.cx := max(AWidth-10,0);
d.cy := max(AHeight-10,0); end
end else d.cx := AWidth;
else 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.cy := AHeight;
D.flags := SWP_NOMOVE; D.flags := SWP_NOMOVE;
if gfw then call(gfw,h,WM_WINDOWPOSCHANGED,0,d._getptr_); if gfw then call(gfw,h,WM_WINDOWPOSCHANGED,0,d._getptr_);
end end
if PosChanged then 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 //Õâ¸öÊDz»ÊÇÓ¦¸Ã·ÅÇ°Ãæ
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 begin
call(gfw,h,0x3,0,makeposition(ALeft,ATop)); d.x := ALeft;
end d.y := ATop;
d.flags := SWP_NOSIZE;
end if gfw then call(gfw,h,WM_WINDOWPOSCHANGED,0,d._getptr_);
end
if SizeChanged then //Õâ¸öÊDz»ÊÇÓ¦¸Ã·ÅÇ°Ãæ
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 end
function GetCursorPos(var p:array of integer); function GetCursorPos(var p:array of integer);
@ -1331,12 +1337,11 @@ type tsgtkapi = class(tgtkapis)
if mb and gtk_widget_is_visible(mb) then if mb and gtk_widget_is_visible(mb) then
begin begin
rec := zeros(4); rec := zeros(4);
gtk_widget_get_allocation(mb,rec); gtk_widget_get_allocation(mb,rec);
if rec[3]>1 then if rec[3]>1 then
begin begin
p[1]+= rec[3] ;//max(rec[3],25); p[1]+= rec[3] ;//max(rec[3],25);
end end
end end
end end
return true; return true;
@ -3056,8 +3061,11 @@ type tgtkapis = class() //gtk
end end
if cls then if cls then
begin 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 end
return r; return r;
end end
@ -6032,7 +6040,7 @@ type tgtk_ctl_scroll_window = class(tgtk_ctl_object)
_wapi.gtk_widget_set_size_request(FClientWideget,w,h); _wapi.gtk_widget_set_size_request(FClientWideget,w,h);
//inherited widgetsizechanged(h,w); //inherited widgetsizechanged(h,w);
end //else inherited widgetsizechanged(h,w); end //else inherited widgetsizechanged(h,w);
inherited widgetsizechanged(h,w); inherited widgetsizechanged(h,w); //clientrect
end end
function GetScrollInfo(nBar,si);override;//获得滚动条信息 function GetScrollInfo(nBar,si);override;//获得滚动条信息
begin begin
@ -6386,7 +6394,12 @@ type tgtk_ctl_window_PoPup = class(tgtk_ctl_scroll_window)
Exit; Exit;
end end
if (cx <> AWidth) then _wapi.g_object_set_data(h,"gtk_layout_width",AWidth); 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 if x <> ALeft then
begin begin
_wapi.g_object_set_data(h,"gtk_layout_x",aleft); _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 end else
begin begin
//nheight := max(10,nheight_-30);
_wapi.gtk_window_set_title(h,_wapi.TslStringToGtk(lpWindowName)); _wapi.gtk_window_set_title(h,_wapi.TslStringToGtk(lpWindowName));
//有标题 有菜单的顶层窗口 //有标题 有菜单的顶层窗口
end end
@ -6468,13 +6482,13 @@ type tgtk_ctl_window_PoPup = class(tgtk_ctl_scroll_window)
//_wapi.gtk_widget_set_can_focus(eb,true); //_wapi.gtk_widget_set_can_focus(eb,true);
_wapi.g_object_set_data(h,"gtk_layout",clientLayout); _wapi.g_object_set_data(h,"gtk_layout",clientLayout);
_wapi.g_object_set_data(clientLayout,"gtk_layout_owner",h); _wapi.g_object_set_data(clientLayout,"gtk_layout_owner",h);
global g_w_c_width;
InitWidgetSize(h,x,y,nwidth,nheight); 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 if nwidth>0 and nheight>0 then
begin begin
_wapi.gtk_window_resize(h,nwidth,nheight); _wapi.gtk_window_resize(h,nwidth,nheight);
end end
_wapi.gtk_widget_show_all(vbox); _wapi.gtk_widget_show_all(vbox);
InitContainerList(h); //容器list InitContainerList(h); //容器list
@ -6491,6 +6505,29 @@ type tgtk_ctl_window_PoPup = class(tgtk_ctl_scroll_window)
end end
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) type tgtk_ctl_window = class(tgtk_ctl_scroll_window)
function Create(h);override; function Create(h);override;
begin begin
@ -7042,5 +7079,8 @@ CAIRO_OPERATOR_HSL_LUMINOSITY:=28;
} }
function gtk_init_check(argc:string;argcv:string):integer;cdecl;external 'libgtk-3.so'; function gtk_init_check(argc:string;argcv:string):integer;cdecl;external 'libgtk-3.so';
initialization 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. end.

View File

@ -851,7 +851,7 @@ type TcustomTreeCtlNode = class(TVirtualListItem)
begin begin
if not Owner.NodeInList(p) then return 0;// 不在列表中 if not Owner.NodeInList(p) then return 0;// 不在列表中
if not p.Expanded then return 0; //非展开 if not p.Expanded then return 0; //非展开
pidx := Owner.GetItemIndex(p); //»ñµÃλÖà pidx := Owner.GetItemIndex(p); //»ñµÃλÖÃ
end else //根节点 end else //根节点
begin begin
pidx := -1; pidx := -1;
@ -1361,7 +1361,7 @@ type TVirtualList = class(TVirtualListFixed)
begin begin
idx := b; idx := b;
ei := e; ei := e;
if not(idx >= 0 and idx)then return false; if not(idx >= 0{ and idx})then return false;
Try Try
IncPaintLock(); IncPaintLock();
while idx <= ei do while idx <= ei do
@ -1699,6 +1699,7 @@ type TcustomTreeCtl = class(TVirtualList)
begin begin
r := CallSelChange(it); r := CallSelChange(it);
if r then return; if r then return;
if it=RootNode then return ;
IF HandleAllocated()then IF HandleAllocated()then
begin begin
GoToNode(it); GoToNode(it);