界面库

处理gtk的缓存和caret
This commit is contained in:
JianjunLiu 2022-12-08 16:43:58 +08:00
parent bf7bc4c1aa
commit 32bd460b1d
6 changed files with 84 additions and 42 deletions

View File

@ -32,7 +32,11 @@ type TEditerForm = class(TVCform) //
GLobal G_OpenHostory; GLobal G_OpenHostory;
//////////////////Ŀ¼///////////////////// //////////////////Ŀ¼/////////////////////
{$ifdef linux} {$ifdef linux}
basepath := ".vcl/tsl/"; home := sysgetenv("HOME");
if home then basepath := home+"/.vcl/";
else
basepath := ".vcl/";
{$else} {$else}
basepath := TS_GetUserProfileHome(); basepath := TS_GetUserProfileHome();
{$endif} {$endif}

View File

@ -328,7 +328,10 @@ type TProjectView = class(TVCForm) //
FTslEditer.ReadOnlyDirs := array(GetVCLdir()); FTslEditer.ReadOnlyDirs := array(GetVCLdir());
fio := ioFileseparator(); fio := ioFileseparator();
{$ifdef linux} {$ifdef linux}
bpath := ".vcl/tsl/"; home := sysgetenv("HOME");
if home then bpath := home+"/.vcl/";
else
bpath := ".vcl/";
{$else} {$else}
bpath := TS_GetUserProfileHome(); bpath := TS_GetUserProfileHome();
{$endif} {$endif}

View File

@ -6,7 +6,7 @@ type TWinControl = class(tcontrol)
{$else} {$else}
{$define gdipaint} {$define gdipaint}
{$endif} {$endif}
uses utslvclauxiliary,utslvclmemstruct,utslvclbase,utslvclevent,utslvclgdi,uvclthreadworker,utslvclaction,utslvclmenu,utslvclstdctl; uses utslvclauxiliary,utslvclmemstruct,utslvclbase,utslvclevent,utslvclgdi,uvclthreadworker,utslvclaction,utslvclmenu;//,utslvclstdctl;
{** {**
@explan(˵Ã÷) ´°¿Ú¿Ø¼þ %% @explan(˵Ã÷) ´°¿Ú¿Ø¼þ %%
**} **}
@ -2506,7 +2506,8 @@ type TWinControl = class(tcontrol)
if not st then return 0; if not st then return 0;
if c then if c then
begin begin
if (c is class(TcustomMenu)) or (c is class(tcustomtoolbar)) or (c is class(TCustomAction)) then ctb := class(tUIglobalData).uigetdata("G_T_TOOLBAR_");
if (c is class(TcustomMenu)) or (c is ctb) or (c is class(TCustomAction)) then
begin begin
if c.ExecuteCommand("doshortcut",st)="havedoshortcut" then return "havedoshortcut"; if c.ExecuteCommand("doshortcut",st)="havedoshortcut" then return "havedoshortcut";
end end
@ -2525,7 +2526,12 @@ type TWinControl = class(tcontrol)
if dispatchmenushortcut(o.Action,st) then return "havedoshortcut"; if dispatchmenushortcut(o.Action,st) then return "havedoshortcut";
if dispatchmenushortcut(o.PopupMenu,st) then return "havedoshortcut"; if dispatchmenushortcut(o.PopupMenu,st) then return "havedoshortcut";
end end
w := class(tUIglobalData).uigetdata("G_T_TVCFORM_"); w := class(tUIglobalData).uigetdata("G_T_TVCFORM_");//Ö÷´°¿Ú
if w and (o is w ) then
begin
if dispatchmenushortcut(o.MainMenu,st) then return "havedoshortcut";
end
w := class(tUIglobalData).uigetdata("G_T_TOOLBAR_");//¹¤¾ßÌõ
if w and (o is w ) then if w and (o is w ) then
begin begin
if dispatchmenushortcut(o.MainMenu,st) then return "havedoshortcut"; if dispatchmenushortcut(o.MainMenu,st) then return "havedoshortcut";

View File

@ -2511,12 +2511,33 @@ type tsgtkapi = class(tgtkapis)
//caret 插入符号 处理 //caret 插入符号 处理
function drawcaret(h,xy,f); function drawcaret(h,xy,f);
begin begin
ct := g_object_get_data(h,"gtk_window_caret"); ct := g_object_get_data(h,"gtk_window_caret");
if f=1 then //清除 if f=1 then //清除
begin begin
if g_object_get_data(ct,"isshow") then return ; if g_object_get_data(ct,"isshow") then return ;
end end
/////»áµ½ÒÔǰµÄ´¦Àí/////////////////////////////
if f=-1 then
begin
if g_object_get_data(ct,"isshow") then
begin
g_object_set_data(ct,"isshow",0);
gtk_widget_hide(ct);
end else
begin
g_object_set_data(ct,"isshow",true);
gtk_widget_show(ct);
end
end else
if f = 1 then
begin
g_object_set_data(ct,"isshow",true);
gtk_widget_show(ct);
end
return ;
////////////////////////////
//获得窗口 //获得窗口
hwcr := g_object_get_data(h,"gtk_clientwideget"); hwcr := g_object_get_data(h,"gtk_clientwideget");
hcr := gdk_cairo_create(gtk_widget_get_window(hwcr)); hcr := gdk_cairo_create(gtk_widget_get_window(hwcr));
@ -2559,7 +2580,8 @@ type tsgtkapi = class(tgtkapis)
if not ctm then return 0; if not ctm then return 0;
g_gtk_caret_cache_timer := createobject(ctm,nil); g_gtk_caret_cache_timer := createobject(ctm,nil);
g_gtk_caret_cache_timer.Interval := 500;//680; g_gtk_caret_cache_timer.Interval := 500;//680;
g_gtk_caret_cache_timer.Ontimer := function(o,e)begin g_gtk_caret_cache_timer.Ontimer := function(o,e)
begin
global g_current_get_focus_widget; global g_current_get_focus_widget;
h := g_current_get_focus_widget; h := g_current_get_focus_widget;
if not h then return ; if not h then return ;
@ -2573,14 +2595,20 @@ type tsgtkapi = class(tgtkapis)
if not h then if not h then
begin begin
h := gtk_event_box_new(); h := gtk_event_box_new();
c := new _GdkColor(nil);
c.SetRgb(0,0,0);
gtk_widget_modify_bg(h,0,c._getptr_());
gtk_widget_hide(h); gtk_widget_hide(h);
lot := g_object_get_data(hWnd,"gtk_layout");
//gtk_layout_move(lot,h,x,y);
gtk_layout_put(lot,h,0,0);
g_object_set_data(hwnd,"gtk_window_caret",h); g_object_set_data(hwnd,"gtk_window_caret",h);
end end
if nWidth>=0 and nHeight>=0 then if nWidth>=0 and nHeight>=0 then
begin begin
g_object_set_data(h,"width_c",nWidth); g_object_set_data(h,"width_c",nWidth);
g_object_set_data(h,"heigt_c",nHeight); g_object_set_data(h,"heigt_c",nHeight);
gtk_widget_set_size_request(h,nWidth,nHeight);
end end
return h; return h;
end end
@ -2592,6 +2620,7 @@ type tsgtkapi = class(tgtkapis)
if not IsGtkWidget(hwnd) then return ; if not IsGtkWidget(hwnd) then return ;
g_object_set_data(hwnd,"caretshow",0); g_object_set_data(hwnd,"caretshow",0);
ct := g_object_get_data(hwnd,"gtk_window_caret"); ct := g_object_get_data(hwnd,"gtk_window_caret");
gtk_widget_hide(ct);
return ; return ;
// 获得focus // 获得focus
end end
@ -2603,14 +2632,15 @@ type tsgtkapi = class(tgtkapis)
begin begin
crt := g_object_get_data( hwnd,"gtk_window_caret"); crt := g_object_get_data( hwnd,"gtk_window_caret");
GetCaretPos(xy); GetCaretPos(xy);
if xy[0]<>x then
drawcaret(hwnd,xy,1);
if crt then //处理此处 if crt then //处理此处
begin begin
gtk_object_set_data(hwnd,"caret_x_pos",x); gtk_object_set_data(hwnd,"caret_x_pos",x);
gtk_object_set_data(hwnd,"caret_y_pos",y); gtk_object_set_data(hwnd,"caret_y_pos",y);
lot := g_object_get_data(hwnd,"gtk_layout");
gtk_layout_move(lot,crt,x,y);
end end
if xy[0]<>x then
drawcaret(hwnd,xy,1);
end end
return ; return ;
end end
@ -2635,6 +2665,7 @@ type tsgtkapi = class(tgtkapis)
if not IsGtkWidget(hwnd) then return ; if not IsGtkWidget(hwnd) then return ;
ct := g_object_get_data(hwnd,"gtk_window_caret"); ct := g_object_get_data(hwnd,"gtk_window_caret");
g_object_set_data(hwnd,"caretshow",0); g_object_set_data(hwnd,"caretshow",0);
if ct then gtk_widget_hide(ct);
return ; return ;
end end
function ShowCaret(hwnd :pointer):integer; function ShowCaret(hwnd :pointer):integer;

View File

@ -6752,24 +6752,21 @@ type tcustomprocess = class(tcomponent) //
envp := array(); envp := array();
if ph then if ph then
begin begin
envp[length(envp)] := "LD_LIBRARY_PATH=LD_LIBRARY_PATH:"+ph; //envp[length(envp)] := "LD_LIBRARY_PATH=LD_LIBRARY_PATH:"+ph;
envp[length(envp)] := "LD_LIBRARY_PATH="+ph;
end end
envp[length(envp)] := getgtkdisplay(); //envp[length(envp)] := getgtkdisplay();
Sysexecsetenvs(envp,0); Sysexecsetenvs(envp,1);
{$endif} {$endif}
return 1; return 1;
end end
function getgtkdisplay(); {function getgtkdisplay();
begin begin
try
dsp := sysgetenv("DISPLAY"); dsp := sysgetenv("DISPLAY");
if dsp="" then dsp := ":0"; if dsp="" then dsp := ":0";
if not ifstring(dsp) then dsp := ":0"; if not ifstring(dsp) then dsp := ":0";
except
dsp := ":0";
end;
return "DISPLAY="+dsp; return "DISPLAY="+dsp;
end end }
private //静态处理函数 private //静态处理函数
class function dispatchproc(); //循环处理打印 class function dispatchproc(); //循环处理打印
begin begin
@ -7048,6 +7045,7 @@ begin
{$ifdef linux} {$ifdef linux}
class(tUIglobalData).uisetdata("G_T_TTIMER_",class(TCustomTimer)); class(tUIglobalData).uisetdata("G_T_TTIMER_",class(TCustomTimer));
{$endif} {$endif}
class(tUIglobalData).uisetdata("G_T_TOOLBAR_",class(tcustomtoolbar));
end end
function unuinit(); function unuinit();
begin begin

View File

@ -5,7 +5,7 @@ interface
@date(20220509) %% @date(20220509) %%
**} **}
uses cstructurelib,utslvclauxiliary; uses cstructurelib,utslvclauxiliary;
type twindowsapi = class type twindowsapi = class()
private private
static fdefaultwinprochandle; static fdefaultwinprochandle;
public public