界面库

处理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;
//////////////////Ŀ¼/////////////////////
{$ifdef linux}
basepath := ".vcl/tsl/";
home := sysgetenv("HOME");
if home then basepath := home+"/.vcl/";
else
basepath := ".vcl/";
{$else}
basepath := TS_GetUserProfileHome();
{$endif}

View File

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

View File

@ -6,7 +6,7 @@ type TWinControl = class(tcontrol)
{$else}
{$define gdipaint}
{$endif}
uses utslvclauxiliary,utslvclmemstruct,utslvclbase,utslvclevent,utslvclgdi,uvclthreadworker,utslvclaction,utslvclmenu,utslvclstdctl;
uses utslvclauxiliary,utslvclmemstruct,utslvclbase,utslvclevent,utslvclgdi,uvclthreadworker,utslvclaction,utslvclmenu;//,utslvclstdctl;
{**
@explan(˵Ã÷) ´°¿Ú¿Ø¼þ %%
**}
@ -2506,7 +2506,8 @@ type TWinControl = class(tcontrol)
if not st then return 0;
if c then
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
if c.ExecuteCommand("doshortcut",st)="havedoshortcut" then return "havedoshortcut";
end
@ -2525,7 +2526,12 @@ type TWinControl = class(tcontrol)
if dispatchmenushortcut(o.Action,st) then return "havedoshortcut";
if dispatchmenushortcut(o.PopupMenu,st) then return "havedoshortcut";
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
begin
if dispatchmenushortcut(o.MainMenu,st) then return "havedoshortcut";

View File

@ -2511,12 +2511,33 @@ type tsgtkapi = class(tgtkapis)
//caret 插入符号 处理
function drawcaret(h,xy,f);
begin
ct := g_object_get_data(h,"gtk_window_caret");
if f=1 then //Çå³ý
ct := g_object_get_data(h,"gtk_window_caret");
if f=1 then //清除
begin
if g_object_get_data(ct,"isshow") then return ;
end
/////会到以前的处理/////////////////////////////
if f=-1 then
begin
if g_object_get_data(ct,"isshow") then
begin
g_object_set_data(ct,"isshow",0);
gtk_widget_hide(ct);
end else
begin
g_object_set_data(ct,"isshow",true);
gtk_widget_show(ct);
end
end else
if f = 1 then
begin
g_object_set_data(ct,"isshow",true);
gtk_widget_show(ct);
end
return ;
////////////////////////////
//获得窗口
hwcr := g_object_get_data(h,"gtk_clientwideget");
hcr := gdk_cairo_create(gtk_widget_get_window(hwcr));
@ -2559,28 +2580,35 @@ type tsgtkapi = class(tgtkapis)
if not ctm then return 0;
g_gtk_caret_cache_timer := createobject(ctm,nil);
g_gtk_caret_cache_timer.Interval := 500;//680;
g_gtk_caret_cache_timer.Ontimer := function(o,e)begin
global g_current_get_focus_widget;
h := g_current_get_focus_widget;
if not h then return ;
if not g_object_get_data(h,"caretshow") then return ;
GetCaretPos(xy);
drawcaret(h,xy,-1);
end
g_gtk_caret_cache_timer.start();
g_gtk_caret_cache_timer.Ontimer := function(o,e)
begin
global g_current_get_focus_widget;
h := g_current_get_focus_widget;
if not h then return ;
if not g_object_get_data(h,"caretshow") then return ;
GetCaretPos(xy);
drawcaret(h,xy,-1);
end
g_gtk_caret_cache_timer.start();
end
h := g_object_get_data(hwnd,"gtk_window_caret"); //»ñµÃcaret
if not h then
begin
h := gtk_event_box_new();
gtk_widget_hide(h);
g_object_set_data(hwnd,"gtk_window_caret",h);
h := g_object_get_data(hwnd,"gtk_window_caret"); //获得caret
if not h then
begin
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);
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);
end
if nWidth>=0 and nHeight>=0 then
begin
g_object_set_data(h,"width_c",nWidth);
g_object_set_data(h,"heigt_c",nHeight);
gtk_widget_set_size_request(h,nWidth,nHeight);
end
return h;
end
@ -2592,6 +2620,7 @@ type tsgtkapi = class(tgtkapis)
if not IsGtkWidget(hwnd) then return ;
g_object_set_data(hwnd,"caretshow",0);
ct := g_object_get_data(hwnd,"gtk_window_caret");
gtk_widget_hide(ct);
return ;
// 获得focus
end
@ -2602,15 +2631,16 @@ type tsgtkapi = class(tgtkapis)
if IsGtkWidget(hwnd) then
begin
crt := g_object_get_data( hwnd,"gtk_window_caret");
GetCaretPos(xy);
if xy[0]<>x then
drawcaret(hwnd,xy,1);
GetCaretPos(xy);
if crt then //处理此处
begin
gtk_object_set_data(hwnd,"caret_x_pos",x);
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
if xy[0]<>x then
drawcaret(hwnd,xy,1);
end
return ;
end
@ -2635,6 +2665,7 @@ type tsgtkapi = class(tgtkapis)
if not IsGtkWidget(hwnd) then return ;
ct := g_object_get_data(hwnd,"gtk_window_caret");
g_object_set_data(hwnd,"caretshow",0);
if ct then gtk_widget_hide(ct);
return ;
end
function ShowCaret(hwnd :pointer):integer;

View File

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

View File

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