界面库

优化代码
This commit is contained in:
JianjunLiu 2022-04-22 15:27:57 +08:00
parent f6c6342cef
commit 517a052205
4 changed files with 387 additions and 418 deletions

View File

@ -314,7 +314,11 @@ type TGdiplusflat=class
class function GlobalSize(menm:pointer):integer;stdcall;external "Kernel32.dll" name "GlobalSize";
class function memcpy(dst:pointer;src:string;size_t:integer):pointer;cdecl;external "msvcrt.dll" name "memcpy";
class function memcpy2(var dst:string;src:pointer;size_t:integer):pointer;cdecl;external "msvcrt.dll" name "memcpy";
class function tuicloseistream(sm:pointer):integer;cdecl;external "TSLUIL.dll" name "tuicloseistream";
class function tuicloseistream(sm:pointer);
begin
r := tslvclcloseistream(sm);
return r;
end
class function GlobalAlloc(uFlags :integer;dwBytes:integer):pointer;stdcall;external "Kernel32.dll" name "GlobalAlloc";
class Function GdipCreatePath(brushMode:integer;var path:pointer):integer;stdcall;external "gdiplus.dll" name "GdipCreatePath";

View File

@ -954,7 +954,6 @@ end
end
end
class function MultiByteToWideChar_a(CodePage:integer;dwFlags:integer;lpMultiByteStr:string;cbMultiByte:integer;var lpWideCharStr:string;cchWideChar:integer):integer;
class function tuicloseistream(sm:pointer):integer;
class function GetEncoderClsid(n:String;ed:pointer):integer;
begin
WriteStringToPtr(ed,n); //保存
@ -2770,7 +2769,7 @@ end
gtk_widget_destroy(cdlg);
return r=-5;
end
function tsl_gtk_color_selection_property(w:pointer):pointer;cdecl;external "./plugin/libTSLUIL.so";
type TBrowseinfoA_ = class(tslcstructureobj)
{**
@explan(说明)文件夹选择结构 %%
@ -3066,8 +3065,11 @@ end
MultiByteToWideChar_a(0, 0, c , -1, pwszUnicode , iSize-1);
return pwszUnicode;
end
class function GetEncoderClsid(n:String;ed:pointer):integer;cdecl;external "TSLUIL.dll" name "GetEncoderClsid";
class function tuicloseistream(sm:pointer):integer;cdecl;external "TSLUIL.dll" name "tuicloseistream";
class function GetEncoderClsid(n:String;ed:pointer);
begin
r := tslvclgetencoderclsid(n,ed);
return r;
end;
//***********
function GetDpiForMonitor(hmonitor:pointer; dpiType:integer;var dpiX:integer;var dpiY:integer):pointer;stdcall;external "Shcore.dll" name "GetDpiForMonitor";
//Kernel32.dll
@ -25745,16 +25747,6 @@ type TImage=class(TSLUIBASE)
vp := GetFileType(t);
s := gdi.imagetostring(FHandle,vp);
return s;
/////////////////
st := ImageToStream(t);
_wapi.GetHGlobalFromStream(st,memo);
len := _wapi.GlobalSize(memo);
s := "";
lm := _wapi.GlobalLock(memo);
setlength(s,len);
_wapi.memcpy2(s,lm,len);
_wapi.tuicloseistream(st);
return s;
end
function StringToImage(b);
begin
@ -25771,24 +25763,6 @@ type TImage=class(TSLUIBASE)
FHandle := hd;
end
return r;
////////////////////////////////////
len := length(b);
hm := _wapi.GlobalAlloc(2,len+1); //分配内容
lm := _wapi.GlobalLock(hm); //枷锁
if lm <> 0 then
begin
_wapi.memcpy(lm,b,len); //内存拷贝
_wapi.GlobalUnlock(hm); //解锁
end
_wapi.CreateStreamOnHGlobal(hm,true,st);
r := gdi.GdipLoadImageFromStream(st,hd);
if hd then
begin
DestroyHandle();
FHandle := hd;
end
_wapi.tuicloseistream(st);
return r;
end
function ToHbitmap();
begin
@ -28221,7 +28195,8 @@ type TBasicAction=class(TComponent)
begin
if FOnExecute then
begin
calldatafunction(FOnExecute,self);
e := new tuieventbase(0,0,0,0);
calldatafunction(FOnExecute,self(true),e);
return true;
end
return false;
@ -31809,7 +31784,6 @@ type TArrayTreeClass = class
FSubName := sub;
end
end
function create(v);
begin
{**
@ -31865,7 +31839,6 @@ type TArrayTreeClass = class
end
return ret;
end
class function SetColumnName(info);
begin
if not ifarray(info)then info := array("id":"id","pid":"pid","sub":"sub");
@ -31909,7 +31882,6 @@ type TArrayTreeClass = class
pdo := oarray[-inf];
ifcycle := false;
end
pdo.addcomponent(ido);
end
if ifcycle and oarray then
@ -32029,7 +32001,6 @@ type TArrayTreeClass = class
FTStringa.Clear();
return r;
end
function STNV();
begin
{**
@ -32077,8 +32048,7 @@ type TArrayTreeClass = class
{**
@explan(说明) 读取section 下面key %%
**}
if ifstring(sn) and sn then
Fini.readSection(sn,FTStringa);
if ifstring(sn)and sn then Fini.readSection(sn,FTStringa);
return STA();
end
function ReadSections();virtual;
@ -32094,8 +32064,7 @@ type TArrayTreeClass = class
{**
@explan(说明) 读取section下面的所有key:value %%
**}
if ifstring(sn) and sn then
FIni.ReadSectionValues(sn,FTStringa);
if ifstring(sn)and sn then FIni.ReadSectionValues(sn,FTStringa);
return STNV();
end
function RenameSection(sn1,sn2);virtual;
@ -32131,8 +32100,7 @@ type TArrayTreeClass = class
{**
@explan(说明) 获得section 数据,二维表,name,value 列
**}
if ifstring(sn) and sn then
FIni.ReadSectionValues(sn,FTStringa);
if ifstring(sn)and sn then FIni.ReadSectionValues(sn,FTStringa);
return STNVA();
end
function ReadSectionValues3(sn);
@ -32153,8 +32121,7 @@ type TArrayTreeClass = class
{**
@explan(说明) 读取key %%
**}
if CheckSK(sn,key) then
return FIni.ReadString(sn,key,ifstring(def)?def:"");
if CheckSK(sn,key)then return FIni.ReadString(sn,key,ifstring(def)?def:"");
return nil;
end
function WriteKey(sn,key,v);virtual;
@ -32162,24 +32129,20 @@ type TArrayTreeClass = class
{**
@explan(说明) 写入key %%
**}
if ifnil(v)then v := "";
if CheckSK(sn,key) then
return FIni.WriteString(sn,key,ifstring(v)?v:tostn(v));
if CheckSK(sn,key)then return FIni.WriteString(sn,key,ifstring(v)?v:tostn(v));
return 0;
end
function DeleteKey(sn,key);virtual;
begin
if CheckSK(sn,key) then
return FIni.DeleteKey(sn,key);
if CheckSK(sn,key)then return FIni.DeleteKey(sn,key);
end
function EraseSection(sn);virtual;
begin
{**
@explan(说明)删除section %%
**}
if ifstring(sn) and sn then
return FIni.EraseSection(sn);
if ifstring(sn)and sn then return FIni.EraseSection(sn);
end
function Destroy();virtual;
begin
@ -32191,6 +32154,7 @@ type TArrayTreeClass = class
property LowerValue read FLowerValue write FLowerValue;
_tag;
end
type TCreateProcessA = class()
{**
@explan(说明) 进程构造对象 %%

View File

@ -453,6 +453,7 @@ type tgtkapis = class() //gtk
function gtk_main_iteration():integer ;cdecl;external 'libgtk-3.so';
///////////////////////////////////////////////////////
function tsl_gtk_idle_interface(p:pointer):integer;cdecl;external "./plugin/libTSLUIL.so";
function tsl_gtk_color_selection_property(w:pointer):pointer;cdecl;external "./plugin/libTSLUIL.so";
function g_idle_remove_by_data(p:pointer):integer;cdecl;external 'libgtk-3.so';
////////////////
@ -2867,7 +2868,7 @@ type tgtk_ctl_object = class(_gtkeventtype)
FConnectNameIds := array();
FConnectHandlers := array();
end
function getsingalmap();virtual;
function getsignalmap();virtual;
begin
return array(
"wm-user":'tsl_gtk_wmuser_event', //Óû§
@ -2898,7 +2899,7 @@ type tgtk_ctl_object = class(_gtkeventtype)
end
//echo "\r\nconnect ===========================",FHandle,"=====",n;
eid := GetGtkEventNameOrId(ln);
fn := (getsingalmap())[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;
@ -3143,7 +3144,7 @@ type tgtk_im_object = class(tgtk_ctl_object)
Connect(v,f);
end
end
function getsingalmap();override;
function getsignalmap();override;
begin
return array(
"preedit-start":"dodeleteevents" ,

Binary file not shown.