编辑器

优化
This commit is contained in:
JianjunLiu 2022-07-15 22:50:46 +08:00
parent 8c69761acc
commit d833e12ca6
11 changed files with 325 additions and 93 deletions

View File

@ -885,9 +885,9 @@ type TVclDesigner = class(tvcform)
end end
mx := 0; mx := 0;
for i,v in clc do mx := max(mx,v); for i,v in clc do mx := max(mx,v);
height := (integer(mx*32/twidth)+1)*32+60+30; height := (integer(mx*32/twidth)+1)*32+60+30+24;
end else end else
height := 90+32; height := 90+32+24;
end end
function TreeNode2tfmsub(lib,node,itemnames);//tmf文件字符串 function TreeNode2tfmsub(lib,node,itemnames);//tmf文件字符串
@ -1147,21 +1147,18 @@ type TVclDesigner = class(tvcform)
("type":"menu","caption":"新建工程","onclick":thisfunction(CreateTpjFomFile), ("type":"menu","caption":"新建工程","onclick":thisfunction(CreateTpjFomFile),
"bitmap":getcreateprojectbmpinfo()), "bitmap":getcreateprojectbmpinfo()),
("type":"menu","caption":"打开历史","onclick":thisfunction(OpenProjectFromtpj), ("type":"menu","caption":"打开历史","onclick":thisfunction(OpenProjectFromtpj),
"bitmap":GetHostroyBimp()) "bitmap":GetHostroyBimp()),
, //("type":"menu","caption":"打包到","onclick":thisfunction(WrapProjectTo),"bitmap":getwrapprojectbmpinfo())
("type":"menu","caption":"打包到","onclick":thisfunction(WrapProjectTo),
"bitmap":getwrapprojectbmpinfo()
)
) )
), ),
("type":"menu","caption":"运行","items":( ("type":"menu","caption":"运行","items":(
("type":"menu","caption":"配置命令行","onclick":thisfunction(editcommandline)), ("type":"menu","caption":"配置命令行","onclick":thisfunction(editcommandline)),
("type":"menu","caption":"运行","onclick":thisfunction(RunProject),"filed":"FRounMenu", {$ifdef linux}
"bitmap":getrunbmpinfo() ("type":"menu","caption":"运行","onclick":thisfunction(RunProject),"filed":"FRounMenu","bitmap":getrunbmpinfo()),
), ("type":"menu","caption":"停止","onclick":thisfunction(StopProject),"enabled":false,"filed":"FStopMenu","bitmap":getstopbmpinfo()),
("type":"menu","caption":"停止","onclick":thisfunction(StopProject),"enabled":false,"filed":"FStopMenu", {$else}
"bitmap":getstopbmpinfo()), ("type":"menu","caption":"运行","bitmap":getrunbmpinfo(),"onclick":thisfunction( debugproject)), //之前的调试运行
("type":"menu","caption":"调试运行","onclick":thisfunction(debugproject)), {$endif}
)), )),
("type":"menu","caption":"工具","items":( ("type":"menu","caption":"工具","items":(
@ -1850,9 +1847,46 @@ type TVclDesigner = class(tvcform)
FImageList := new TDesigImageList(self); FImageList := new TDesigImageList(self);
FTree.Imagelist := FImageList; FTree.Imagelist := FImageList;
//******************toolbar *************** //******************toolbar ***************
{fdebugtoolbar := new TToolBar(self);
btns := FProjectManager.FTslEditer.getdbugtoolbtns();
idx := 0;
for i,v in btns do
begin
if idx = 0 then fdebugtoolbar.ImageList := v.parent.ImageList;
idx++;
if v.caption = "添加/删除断点F5" then continue;
v.parent := fdebugtoolbar;
v._tag := v.onclick;
v.onclick := function(o,e)begin
cp := o.caption;
CallMessgeFunction(o._tag,o,e);
if cp<>"终止" then
begin
FProjectManager.ShowEditor();
end
end;
end }
tlbar := FProjectManager.FTslEditer.gettoolbar();
savebtn := array( tlbar.getbtnbyindex(1),tlbar.getbtnbyindex(2));
for i,v in savebtn do //处理一下保存工程
begin
v._tag := array(thisfunction(saveCurrentForm),v.onclick);
v.onclick := function(o,e)
begin
for i,v in o._tag do
begin
CallDataFunction(v,o,e);
end
end
end
tlbar.parent := self;
FToolBars := new TDesignertoolbars(self); FToolBars := new TDesignertoolbars(self);
FToolBars.parent := self; FToolBars.parent := self;
FToolBars.Imagelist := FImageList; FToolBars.Imagelist := FImageList;
FToolBars.Font.width := 9;
FToolBars.Font.height := 18;
addtoolbuttons(); addtoolbuttons();
//************菜单****************************** //************菜单******************************
createmainmenubyarray(mainmenus(),FMenu0,self); createmainmenubyarray(mainmenus(),FMenu0,self);
@ -1861,6 +1895,10 @@ type TVclDesigner = class(tvcform)
ic := new Ticon(); ic := new Ticon();
ic.Readvcon(HexFormatStrToTsl(GetTsIconBitmapInfo())); ic.Readvcon(HexFormatStrToTsl(GetTsIconBitmapInfo()));
self.FormICon := ic; self.FormICon := ic;
{fdebugtoolbar.Align := alnone;
fdebugtoolbar.left := FToolBars.Flabelcharlen* 10;
fdebugtoolbar.top := 0;
fdebugtoolbar.parent := FToolBars;}
//文件打窗口 //文件打窗口
@ -7307,16 +7345,19 @@ type TDesignertoolbars = class(TPageControl)
FToolbars; FToolbars;
FLabels ; FLabels ;
fimg; fimg;
function SetImageList(im); function SetImageList(im);
begin begin
fimg := im; fimg := im;
end end
public public
Flabelcharlen;
function Create(AOwner);override; function Create(AOwner);override;
begin begin
inherited; inherited;
align := alClient; align := alClient;
FToolbars := array(); FToolbars := array();
Flabelcharlen := 0;
end end
Procedure Notification(AComponent,Operation);virtual; Procedure Notification(AComponent,Operation);virtual;
begin begin
@ -7362,13 +7403,13 @@ type TDesignertoolbars = class(TPageControl)
begin begin
st := new TTabSheet(self); st := new TTabSheet(self);
st.caption := t; st.caption := t;
tb := new ttoolbar(self); tb := new ttoolbar(self);
tb.align := alClient; tb.align := alClient;
if t<>"非点击添加控件" then if t<>"非点击添加控件" then
begin begin
st.parent := self; st.parent := self;
tb.parent := st; tb.parent := st;
Flabelcharlen+= length(t)+2;
end end
tb.imagelist := fimg; tb.imagelist := fimg;
FToolbars[t] := tb; FToolbars[t] := tb;

View File

@ -1469,7 +1469,7 @@ type TProjectView = class(TVCForm) //
FOpenBtn; FOpenBtn;
FInput; FInput;
FScriptHandle; FScriptHandle;
FTslEditer;
FTmfParser; FTmfParser;
FTslParser; FTslParser;
FTreeTool; FTreeTool;
@ -1487,6 +1487,8 @@ type TProjectView = class(TVCForm) //
FAddMenuTsf; FAddMenuTsf;
FAddMenuTsl; FAddMenuTsl;
FOpenMenu; FOpenMenu;
public
FTslEditer;
end end
type TTslEditer = class(TEditer) type TTslEditer = class(TEditer)

View File

@ -1748,21 +1748,29 @@ type TEditer=class(TCustomcontrol) //
dbgbtns := array(); dbgbtns := array();
for i,v in imgs do for i,v in imgs do
begin begin
bmp.Readvcon(HexFormatStrToTsl(v));
FImages.addbmp(bmp);
bt := new TToolButton(self); bt := new TToolButton(self);
FToolbtns[i]:= bt; FToolbtns[i]:= bt;
bt.OnClick := thisfunction(ToolClick); if v=0 then
bt.Caption := i; begin
bt.imageid := id; bt.stylesep := true;
id++; end else
begin
bmp.Readvcon(HexFormatStrToTsl(v));
FImages.addbmp(bmp);
bt.OnClick := thisfunction(ToolClick);
bt.Caption := i;
bt.imageid := id;
id++;
end
BT.parent := FToolbar; BT.parent := FToolbar;
if i in array("添加/删除断点F5","暂停","继续","进入","跳出","单步","下一行(F8)","终止","刷新符号表","刷新当前符号")then if i in array("添加/删除断点F5","暂停","继续","进入","跳出","单步","下一行(F8)","终止","刷新符号表","刷新当前符号")then
begin begin
dbgbtns[i]:= bt; dbgbtns[i]:= bt;
end end
end end
FImages.DrawBimpFirst := true; FImages.DrawBimpFirst := true;
Fdbgbtns := dbgbtns;
FTslDebug.addbtns(dbgbtns); FTslDebug.addbtns(dbgbtns);
FToolbar.ImageList := FImages; FToolbar.ImageList := FImages;
FInfoShowWnd.Visible := false; FInfoShowWnd.Visible := false;
@ -2111,6 +2119,14 @@ type TEditer=class(TCustomcontrol) //
begin begin
return FFindWnd.GetHistory(); return FFindWnd.GetHistory();
end end
function getdbugtoolbtns();
begin
return Fdbgbtns;
end
function gettoolbar();
begin
return FToolbar;
end
function ShowLogWnd(flg); function ShowLogWnd(flg);
begin begin
n :=(ifnil(flg)or flg)?true:false; n :=(ifnil(flg)or flg)?true:false;
@ -2598,13 +2614,14 @@ type TEditer=class(TCustomcontrol) //
begin begin
if filenameIsTheSame(v,vi)then if filenameIsTheSame(v,vi)then
begin begin
fcadd := false; //fcadd := false;
FOpenHistory.Splice(i,1); //删除原来的记录
break; break;
end end
end end
if fcadd then if fcadd then
begin begin
FOpenHistory.Push(v); FOpenHistory.push(v);
if FOpenHistory.Length()>30 then FOpenHistory.shift(); if FOpenHistory.Length()>30 then FOpenHistory.shift();
end end
end end
@ -2651,7 +2668,8 @@ type TEditer=class(TCustomcontrol) //
end end
if FOpenHistory.Length()>0 then if FOpenHistory.Length()>0 then
begin begin
FHistoryWnd.SetData(FOpenHistory.Data); d := FOpenHistory.Data;
FHistoryWnd.SetData(d);
InitShowWndPos(FHistoryWnd,"history",100,100); InitShowWndPos(FHistoryWnd,"history",100,100);
FHistoryWnd.ShowModal(); FHistoryWnd.ShowModal();
end end
@ -2924,15 +2942,24 @@ type TEditer=class(TCustomcontrol) //
if not(FPageEditer and FPageEditer.parent=self)then return; if not(FPageEditer and FPageEditer.parent=self)then return;
rr := ClientRect; rr := ClientRect;
r := rr; r := rr;
if FToolbar.Parent = self then
begin
htoolbar := true;
end
if htoolbar then
begin
th := FToolbar.CalcHeightFixWidth(rr[2]-rr[0]); th := FToolbar.CalcHeightFixWidth(rr[2]-rr[0]);
//FToolbar.Height := th;
r[3]:= r[0]+th; r[3]:= r[0]+th;
FToolBar.SetBoundsRect(r); FToolBar.SetBoundsRect(r);
end
r := rr; r := rr;
r[1]:= r[3]-FStatus.Height; r[1]:= r[3]-FStatus.Height;
FStatus.SetBoundsRect(r); FStatus.SetBoundsRect(r);
rr := rr; rr := rr;
if htoolbar then
begin
rr[1]:= FToolbar.Height+1; rr[1]:= FToolbar.Height+1;
end
rr[3]:= rr[3]-FStatus.Height-1; rr[3]:= rr[3]-FStatus.Height-1;
{if ffolderdlg and ffolderdlg.Visible then {if ffolderdlg and ffolderdlg.Visible then
begin begin
@ -2946,7 +2973,7 @@ type TEditer=class(TCustomcontrol) //
begin begin
r := rr; r := rr;
r[1]:= r[3]-min(FInfoShowWnd.Height,integer(r[3] * 0.6)); r[1]:= r[3]-min(FInfoShowWnd.Height,integer(r[3] * 0.8)); //0.6 靠扩大到 0.8
rr[3]:= r[1]-1; rr[3]:= r[1]-1;
{fwd := min(FInfoShowWnd.Width,integer(r[2] * 0.6)); //右侧 {fwd := min(FInfoShowWnd.Width,integer(r[2] * 0.6)); //右侧
@ -3825,6 +3852,7 @@ type TEditer=class(TCustomcontrol) //
if ifobj(c[0])and ifobj(c[1])then return array(CreateObject(c[0],ow),CreateObject(c[1],ow)); if ifobj(c[0])and ifobj(c[1])then return array(CreateObject(c[0],ow),CreateObject(c[1],ow));
end end
end end
Fdbgbtns;
static FSynClasses; static FSynClasses;
FCodeFormatInfo; FCodeFormatInfo;
FTslChmHelp; FTslChmHelp;
@ -4979,7 +5007,7 @@ type TMouseMoveList=class(TListBox)
function getItemText(i);override; function getItemText(i);override;
begin begin
r := inherited; r := inherited;
return " "+r; return "["$ i $"]" $ r;
end end
function PaintIdx(idx,rc_,cvs);virtual; function PaintIdx(idx,rc_,cvs);virtual;
begin begin
@ -5068,6 +5096,7 @@ B85C4055CF250DD2251015779AC1ABF4E121390D3FE5BFF436D9BA680DFE3B533
AE42608200"; AE42608200";
r["快捷键说明"]:= getquickkeybitmapinfo(); r["快捷键说明"]:= getquickkeybitmapinfo();
r["代码地图(alt+m)"]:= gettslcodemapbitmapinfo(); r["代码地图(alt+m)"]:= gettslcodemapbitmapinfo();
r["分隔符"] := 0;
return r union dbugicos(); return r union dbugicos();
end end
function dbugicos(); function dbugicos();

View File

@ -262,10 +262,12 @@ type tagCOMPOSITIONFORM=class(tslcstructureobj)
end end
type TTslDebuga=class(TCustomControl) type TTslDebuga=class(TCustomControl)
private //成员变量 private //成员变量
//Frundirect;
FRuningfile; //执行脚本文件名 FRuningfile; //执行脚本文件名
FRuningItem; //执行的pageitem FRuningItem; //执行的pageitem
FCurrentgotoitem; //当前运行到的pageitem FCurrentgotoitem; //当前运行到的pageitem
FDebughandle; //调试的句柄 FDebughandle; //调试的句柄
Fdebugedwhandle ;//调试的窗口
FDebugExe; //调试功能的exe FDebugExe; //调试功能的exe
FConnectchannel; //调试的 通道 FConnectchannel; //调试的 通道
FDebugaddr; //地址 FDebugaddr; //地址
@ -577,7 +579,7 @@ type TTslDebuga=class(TCustomControl)
getdebuger(pms); getdebuger(pms);
exestr := format('"%s" "%s" -DEBUGSERVER -DEBUGLOGIN 0 -WAITATTACH -DEBUGPORT %d -libpath "%s" ',FDebugExe,FRuningfile,FDebugport,dirs); exestr := format('"%s" "%s" -DEBUGSERVER -DEBUGLOGIN 0 -WAITATTACH -DEBUGPORT %d -libpath "%s" ',FDebugExe,FRuningfile,FDebugport,dirs);
exestr += pms; exestr += pms;
FDebughandle := sysexec(FDebugExe,exestr,nil,0,rcode,0); FDebughandle := sysexec(FDebugExe,exestr,nil,0,rcode,0);
if FDebughandle then if FDebughandle then
begin begin
ExecuteCommand("dbgcreatechannel"); ExecuteCommand("dbgcreatechannel");
@ -617,6 +619,7 @@ type TTslDebuga=class(TCustomControl)
function Create(AOwner); function Create(AOwner);
begin begin
inherited; inherited;
//Frundirect := false;
FCmdHistory := array(); FCmdHistory := array();
FCmdHistoryid := 0; FCmdHistoryid := 0;
FCmdHistorycount := 10; FCmdHistorycount := 10;
@ -678,6 +681,26 @@ type TTslDebuga=class(TCustomControl)
dbgunsetbreak(FConnectchannel,usr,n,idx+1); dbgunsetbreak(FConnectchannel,usr,n,idx+1);
end end
end end
function GetWindowHandleByPID(dwProcessID,api) //通过进程ID获取窗口句柄
begin
h := api.GetTopWindow(0);
while(h) do
begin
pid := 0;
dwTheardId := api.GetWindowThreadProcessId(h,pid);
if(dwTheardId <> 0)then
begin
if(pid=dwProcessID)then
begin
// here h is the handle to the window
while(api.GetParent(h)<> 0) do h := api.GetParent(h);
return h;
end
end
h := api.GetNextWindow(h,2);
end
return 0;
end
function Dbgtooldo(o,e) function Dbgtooldo(o,e)
begin begin
cp := o.Caption; cp := o.Caption;
@ -699,6 +722,10 @@ type TTslDebuga=class(TCustomControl)
"暂停": "暂停":
begin begin
ExecuteCommand("dbgpause"); ExecuteCommand("dbgpause");
if Fdebugedwhandle then
begin
_Wapi.postmessagea(Fdebugedwhandle,WM_NULL,0,0);
end
end end
"进入": "进入":
begin begin
@ -721,6 +748,15 @@ type TTslDebuga=class(TCustomControl)
toolbtnState("继续"); toolbtnState("继续");
if FCurrentgotoitem and FCurrentgotoitem.FEditer then FCurrentgotoitem.FEditer.ExecuteCommand("ecruningto",nil); if FCurrentgotoitem and FCurrentgotoitem.FEditer then FCurrentgotoitem.FEditer.ExecuteCommand("ecruningto",nil);
ExecuteCommand("dbgrun"); ExecuteCommand("dbgrun");
{$ifdef linux}
{$else}
if not Fdebugedwhandle then
Fdebugedwhandle := GetWindowHandleByPID(_wapi.GetProcessId(FDebughandle),_wapi);
if Fdebugedwhandle then
begin
_wapi.SetForegroundWindow(Fdebugedwhandle);
end
{$endif}
end end
"终止": "终止":
begin begin
@ -757,7 +793,7 @@ type TTslDebuga=class(TCustomControl)
FConnectchannel := 0; FConnectchannel := 0;
g_tsldbgcallback_handle := nil; g_tsldbgcallback_handle := nil;
if FCurrentgotoitem and FCurrentgotoitem.FEditer then FCurrentgotoitem.FEditer.ExecuteCommand("ecruningto",nil); if FCurrentgotoitem and FCurrentgotoitem.FEditer then FCurrentgotoitem.FEditer.ExecuteCommand("ecruningto",nil);
FDebughandle := 0; FDebughandle := 0;Fdebugedwhandle := 0;
toolbtnState("停止"); toolbtnState("停止");
return; return;
end end
@ -841,6 +877,7 @@ type TTslDebuga=class(TCustomControl)
FCurrentgotoitem.FEditer.ExecuteCommand("ecruningto",stk[0,"LINE"]-1); FCurrentgotoitem.FEditer.ExecuteCommand("ecruningto",stk[0,"LINE"]-1);
end end
end end
//_wapi.SetForegroundWindow(self.Handle); //移动到前端 SetForegroundWindow BringWindowToTop
return; return;
end end
"detached": "detached":
@ -1116,6 +1153,7 @@ type TTslDebuga=class(TCustomControl)
g_tsldbgcallback_handle := nil; g_tsldbgcallback_handle := nil;
fdbgselwnd := nil; fdbgselwnd := nil;
end end
//property rundirect read Frundirect write Frundirect;
private private
function getdefaultdbger(); function getdefaultdbger();
begin begin
@ -1403,7 +1441,7 @@ type TTslDebuga=class(TCustomControl)
if FDebughandle then if FDebughandle then
begin begin
SysTerminate(-1,FDebughandle); SysTerminate(-1,FDebughandle);
FDebughandle := 0; FDebughandle := 0; Fdebugedwhandle := 0;
end end
end end
function parseriteminfo(item,idx,n,usr); function parseriteminfo(item,idx,n,usr);

View File

@ -892,6 +892,11 @@ type TPanel=class(TScrollingWinControl) //
p.cstyle := CS_HREDRAW .| CS_VREDRAW .| CS_OWNDC .| CS_DBLCLKS; p.cstyle := CS_HREDRAW .| CS_VREDRAW .| CS_OWNDC .| CS_DBLCLKS;
//p.exstyle := 0x101; //p.exstyle := 0x101;
end end
function paint();override;
begin
inherited;
drawdesigninggrid();
end
function publishs();override; function publishs();override;
begin begin
return array("name","align","anchors","caption","enabled","cursor","font", return array("name","align","anchors","caption","enabled","cursor","font",
@ -1280,10 +1285,11 @@ type TVCForm = class(TScrollingWinControl)
if cd is class(TComponent)then return Controls.indexof(cd)<0; if cd is class(TComponent)then return Controls.indexof(cd)<0;
return true; return true;
end end
function paint();override; function Paint();override;
begin begin
inherited; inherited;
end drawdesigninggrid();
end
function WMSYSCOMMAND(o,e):WM_SYSCOMMAND;override; function WMSYSCOMMAND(o,e):WM_SYSCOMMAND;override;
begin begin
{** {**
@ -1503,6 +1509,11 @@ type TpanelForm=class(tpanel)
FWidth := wd; FWidth := wd;
wspopup := true; wspopup := true;
end end
function Paint();override;
begin
inherited;
drawdesigninggrid();
end
function SetDesigning(f,fc);override; function SetDesigning(f,fc);override;
begin begin
if f then wspopup := true; if f then wspopup := true;
@ -1522,6 +1533,7 @@ type TDCreatePanel=class(TpanelForm)
inherited; inherited;
Loader.LoadFromTfm(self(true)); Loader.LoadFromTfm(self(true));
end end
end end
//°´Å¥ //°´Å¥
@ -2139,8 +2151,8 @@ type tmemo = class(TSynMemoNorm)
function publishs();override; function publishs();override;
begin begin
return array("name","font", return array("name","font",
"popupmenu","visible", "popupmenu","visible","anchors","align",
"height","width","anchors","left","top", "height","width","left","top",
"text","readonly", "text","readonly",
"tabspace","onmousewheel","onmousemove","onpopupmenu", "tabspace","onmousewheel","onmousemove","onpopupmenu",
"onmousedown","onmouseup", "onmousedown","onmouseup",
@ -3526,7 +3538,7 @@ type TTabSheet = class(TCustomControl)
public public
function paint();override; function paint();override;
begin begin
drawdesigninggrid();
end end
function DesigningMove();override; function DesigningMove();override;
begin begin
@ -4163,6 +4175,11 @@ type TPairSplitterSide=class(TCustomControl)
begin begin
return false; return false;
end end
function paint();override;
begin
inherited;
drawdesigninggrid();
end
function DesigningSizer();override; function DesigningSizer();override;
begin begin
return false; return false;

View File

@ -1830,6 +1830,30 @@ end
if HandleAllocated()then ControlCreateWnd(); if HandleAllocated()then ControlCreateWnd();
end end
protected protected
function drawdesigninggrid();
begin
if csDesigning in ComponentState then
begin
cv := canvas;
if not(cv.HandleAllocated()) then return ;
rc := ClientRect;
dx := 20;
dy := 20;
x := 0;
y := 0;
c := 0;
while y<rc[3] do
begin
y+=dx;
x := 0;
while x<rc[2] do
begin
x+=dx;
cv.SetPixel(array(x,y),c);
end
end
end
end
function ControlCreateWnd(); function ControlCreateWnd();
begin begin
for i := 0 to FControls.count-1 do for i := 0 to FControls.count-1 do

View File

@ -974,6 +974,24 @@ type tsgtkapi = class(tgtkapis)
gtk_object_set_data(hdc,"text.color",col); gtk_object_set_data(hdc,"text.color",col);
return true; return true;
end end
Function SetPixel(dc,x,y,colr);
begin
if not dc then return ;
if ifnumber(x) and ifnumber(y) then
begin
pc := colr;
MoveToEx(dc,x,y);
pc := gtk_object_get_data(dc,"pen.color");
pw := gtk_object_get_data(dc,"pen.width");
gtk_object_set_data(dc,"pen.color",colr);
gtk_object_set_data(dc,"pen.width",2);
LineTo(dc,x+1,y+1);
gtk_object_set_data(dc,"pen.color",pc);
gtk_object_set_data(dc,"pen.width",pc);
return 1;
end
end
Function FillRect(dc:pointer;rec:array of integer;br:pointer):integer; Function FillRect(dc:pointer;rec:array of integer;br:pointer):integer;
begin begin
if not dc then return ; if not dc then return ;
@ -2558,11 +2576,11 @@ type tsgtkapi = class(tgtkapis)
begin begin
end; end;
function SetForegroundWindow(hwd :pointer):integer;
begin
end
function Shell_NotifyIconA(dwMessage:integer; lpData:pointer):integer; function Shell_NotifyIconA(dwMessage:integer; lpData:pointer):integer;
begin begin
end
function SetForegroundWindow(hwd :pointer):integer;
begin
end end
function BringWindowToTop(hwd :pointer); function BringWindowToTop(hwd :pointer);
begin begin

View File

@ -7,6 +7,7 @@ interface
uses cstructurelib,utslvclmemstruct,utslvclauxiliary,utslvclbase; uses cstructurelib,utslvclmemstruct,utslvclauxiliary,utslvclbase;
function GetTextWidthAndHeightWidthFont(s,f,mul); function GetTextWidthAndHeightWidthFont(s,f,mul);
function getdrawablebitmap(w,h,bmp);
type TGdi = class(TSLUIBASE) type TGdi = class(TSLUIBASE)
private private
static GDICache; static GDICache;
@ -2660,11 +2661,14 @@ type TcustomCanvas = class(TSLUIBASE)
@return(tcustombitmap|nil) 成功返回位图 %% @return(tcustombitmap|nil) 成功返回位图 %%
**} **}
r := nil; r := nil;
{$ifdef linux}
return r;
{$endif}
if not(ifarray(rect)and rect[2]>rect[0]and rect[3]>rect[1])then return r; if not(ifarray(rect)and rect[2]>rect[0]and rect[3]>rect[1])then return r;
if not HandleAllocated()then return r; if not HandleAllocated()then return r;
if not FHDC then FHDC := _wapi.CreateCompatibleDC(0); if not FHDC then FHDC := _wapi.CreateCompatibleDC(0);
if not FHDC then return r; if not FHDC then return r;
bthandle := _wapi.CreateCompatibleBitmap(FSHDC2,w,h); bthandle := _wapi.CreateCompatibleBitmap(_wapi.GetDC(0),w,h);
if not bthandle then return r; if not bthandle then return r;
oldb := _wapi.SelectObject(FHDC,bthandle); oldb := _wapi.SelectObject(FHDC,bthandle);
_wapi.BitBlt(FHDC,0,0,rect[2]-rect[0],rect[3]-rect[1],FHandle,rect[0],rect[1],SRCCOPY); _wapi.BitBlt(FHDC,0,0,rect[2]-rect[0],rect[3]-rect[1],FHandle,rect[0],rect[1],SRCCOPY);
@ -2679,6 +2683,9 @@ type TcustomCanvas = class(TSLUIBASE)
@explan(说明)文本旋转%% @explan(说明)文本旋转%%
@param(trans)(array) array(cos,-sin,sin,cos,x,y)%% @param(trans)(array) array(cos,-sin,sin,cos,x,y)%%
**} **}
{$ifdef linux}
return r;
{$endif}
_xformobj._setvalue_("em11",trans[0]); _xformobj._setvalue_("em11",trans[0]);
_xformobj._setvalue_("em12",trans[1]); _xformobj._setvalue_("em12",trans[1]);
_xformobj._setvalue_("em21",trans[2]); _xformobj._setvalue_("em21",trans[2]);
@ -2996,6 +3003,22 @@ begin
cv.handle := cv._wapi.CreateCompatibleDC(0); cv.handle := cv._wapi.CreateCompatibleDC(0);
return cv; return cv;
end end
function getdrawablebitmap(w,h,bmp);
begin
{$ifdef linux}
return 0;
{$endif}
if w>1 and h>1 then
begin
cv := static GetOneCanvas();
api := cv._wapi;
bmp := new TcustomBitmap();
bhd :=api.CreateCompatibleBitmap(api.GetDC(0),w,h);
bmp.handle := bhd;
api.SelectObject(cv.handle,bhd);
return cv;
end
end
initialization initialization
sinitgidplus(); sinitgidplus();
class(tcustomimage).sinit(); class(tcustomimage).sinit();

View File

@ -2569,9 +2569,9 @@ type TcustomListBox=class(TCustomListBoxbase)
end end
function MouseUp(o,e);override; function MouseUp(o,e);override;
begin begin
if FIsMouseDown then if FIsMouseDown then //已经按下过
begin begin
_wapi.clipcursor(ps); _wapi.clipcursor(ps); //解锁光标
FIsMouseDown := false; FIsMouseDown := false;
selchange := 0; selchange := 0;
case FMultisel of case FMultisel of
@ -3552,6 +3552,7 @@ type TcustomToolButton=class(tcomponent)
FImageId :=-1; //imageid FImageId :=-1; //imageid
FEnabled := true; //有效 可以点击 FEnabled := true; //有效 可以点击
FVisible := true; //可见 FVisible := true; //可见
FStylesep := false;
end end
function ExecuteCommand(cmd,d);override; function ExecuteCommand(cmd,d);override;
begin begin
@ -3598,7 +3599,7 @@ type TcustomToolButton=class(tcomponent)
end end
function publishs();override; function publishs();override;
begin begin
return array("name","caption","enabled","imageid","visible","onclick","popupmenu"); return array("name","caption","enabled","stylesep","imageid","visible","onclick","popupmenu");
end end
function Recycling();override; function Recycling();override;
begin begin
@ -3631,6 +3632,7 @@ type TcustomToolButton=class(tcomponent)
property Action:taction read GetAction write SetAction; property Action:taction read GetAction write SetAction;
property ShortCut read getShortCut write SetShortCut; property ShortCut read getShortCut write SetShortCut;
property PopupMenu:tpopupmenu read FPopupMenu write FPopupMenu; property PopupMenu:tpopupmenu read FPopupMenu write FPopupMenu;
property stylesep:bool read FStylesep write setstylesep;
{** {**
@param(OnClick)(function[o:TToolButton;e:tuieventbase]) 点击消息 %% @param(OnClick)(function[o:TToolButton;e:tuieventbase]) 点击消息 %%
@param(Caption)(string) 标题 %% @param(Caption)(string) 标题 %%
@ -3639,7 +3641,17 @@ type TcustomToolButton=class(tcomponent)
@param(Visible)(bool) 是否可见 %% @param(Visible)(bool) 是否可见 %%
**} **}
private private
FStylesep;
FShortCut; FShortCut;
function setstylesep(v);
begin
nv := v?true:false;
if nv<>FStylesep then
begin
FStylesep := nv;
if FToolbar then FToolbar.BtnChanged();
end
end
function getShortCut(); function getShortCut();
begin begin
return formatshortcut(FShortCut); return formatshortcut(FShortCut);
@ -3913,6 +3925,10 @@ type TcustomToolBar=class(TCustomControl)
**} **}
InsertButton(btn); InsertButton(btn);
end end
function getbtnbyindex(idx);
begin
return FButtons[idx];
end
function SetBtnIndex(btn,idx); function SetBtnIndex(btn,idx);
begin begin
{** {**
@ -4018,6 +4034,50 @@ type TcustomToolBar=class(TCustomControl)
**} **}
EndUpdate(); EndUpdate();
end end
function Paint();override;
begin
c := canvas;
for i := 0 to FButtons.length()-1 do
begin
bi := FButtons[i];
if not(bi.Visible)then continue;
ci := FBtnRects[i];
if not ifarray(ci)then return;
if FMouseDownIdx=i then
begin
c.draw("framecontrol",array(ci[0:1],ci[2:3]),DFC_BUTTON,DFCS_BUTTONCHECK);
end else
c.draw("framecontrol",array(ci[0:1],ci[2:3]),DFC_BUTTON,DFCS_BUTTONPUSH);
igslist := ImageList;
if igslist is class(TCustomImageList)then
begin
igid := bi.ImageId;
if igid >= 0 and igid<igslist.ImageCount then
begin
if bi.Enabled then igslist.draw(igid,c,ci[0]+2,ci[1]+2,nil);
else igslist.draw(igid,c,ci[0]+2,ci[1]+2,ILC_COLOR4);
end
end
end
end
function DoEndUpDate();override; //锁定刷新释放
begin
if not(IsUpDating())then
begin
if FWillModifyToolbar then
begin
FWillModifyToolbar := false;
DoControlAlign();
if Parent then Parent.DoControlAlign();
end
end
inherited;
end
function DoControlAlign();override;
begin
CalcButtonsRect();
end
function CalcHeightFixWidth(w); function CalcHeightFixWidth(w);
begin begin
{** {**
@ -4105,49 +4165,6 @@ type TcustomToolBar=class(TCustomControl)
return((frac(nt)>0)?(integer(nt)+1):(nt)) * (imgw+1)+bw; return((frac(nt)>0)?(integer(nt)+1):(nt)) * (imgw+1)+bw;
return(integer(bct/rct)+1) * (imgw+1)+bw; return(integer(bct/rct)+1) * (imgw+1)+bw;
end end
function Paint();override;
begin
c := canvas;
for i := 0 to FButtons.length()-1 do
begin
bi := FButtons[i];
if not(bi.Visible)then continue;
ci := FBtnRects[i];
if not ifarray(ci)then return;
if FMouseDownIdx=i then
begin
c.draw("framecontrol",array(ci[0:1],ci[2:3]),DFC_BUTTON,DFCS_BUTTONCHECK);
end else
c.draw("framecontrol",array(ci[0:1],ci[2:3]),DFC_BUTTON,DFCS_BUTTONPUSH);
igslist := ImageList;
if igslist is class(TCustomImageList)then
begin
igid := bi.ImageId;
if igid >= 0 and igid<igslist.ImageCount then
begin
if bi.Enabled then igslist.draw(igid,c,ci[0]+2,ci[1]+2,nil);
else igslist.draw(igid,c,ci[0]+2,ci[1]+2,ILC_COLOR4);
end
end
end
end
function DoEndUpDate();override; //Ëø¶¨Ë¢ÐÂÊÍ·Å
begin
if not(IsUpDating())then
begin
if FWillModifyToolbar then
begin
FWillModifyToolbar := false;
DoControlAlign();
if Parent then Parent.DoControlAlign();
end
end
inherited;
end
function DoControlAlign();override;
begin
CalcButtonsRect();
end
function IndexOfBtn(btn); function IndexOfBtn(btn);
begin begin
{** {**
@ -4221,6 +4238,7 @@ type TcustomToolBar=class(TCustomControl)
FTimer.Stop(); FTimer.Stop();
FTipWnd.Visible := false; FTipWnd.Visible := false;
end end
function CalcButtonsRect(); function CalcButtonsRect();
begin begin
if(IsUpDating())then if(IsUpDating())then
@ -4255,19 +4273,29 @@ type TcustomToolBar=class(TCustomControl)
begin begin
if rct=0 then if rct=0 then
begin begin
FBtnRects[i]:= array(x,y,x+imgw,y+imgh); if bi.stylesep then
begin
FBtnRects[i]:= array(0,0,0,0);
end else
begin
FBtnRects[i]:= array(x,y,x+imgw,y+imgh);
end
y := 0; y := 0;
x += imgw+1; x += imgw+1;
end else end else
begin begin
y := 0; y := 0;
x += imgw+1; x += imgw+1;
FBtnRects[i]:= array(x,y,x+imgw,y+imgh); if bi.stylesep then FBtnRects[i]:= array(0,0,0,0);
else
FBtnRects[i]:= array(x,y,x+imgw,y+imgh);
y += imgh+1; y += imgh+1;
rct := 1; rct := 1;
end end
end else end else
begin begin
if bi.stylesep then FBtnRects[i]:= array(0,0,0,0);
else
FBtnRects[i]:= array(x,y,x+imgw,y+imgh); FBtnRects[i]:= array(x,y,x+imgw,y+imgh);
y += imgh+1; y += imgh+1;
rct++; rct++;
@ -4287,20 +4315,26 @@ type TcustomToolBar=class(TCustomControl)
begin begin
if rct=0 then if rct=0 then
begin begin
FBtnRects[i]:= array(x,y,x+imgw,y+imgh); if bi.stylesep then FBtnRects[i]:= array(0,0,0,0);
else
FBtnRects[i]:= array(x,y,x+imgw,y+imgh);
x := 0; x := 0;
y += imgh+1; y += imgh+1;
end else end else
begin begin
x := 0; x := 0;
y += imgh+1; y += imgh+1;
FBtnRects[i]:= array(x,y,x+imgw,y+imgh); if bi.stylesep then FBtnRects[i]:= array(0,0,0,0);
else
FBtnRects[i]:= array(x,y,x+imgw,y+imgh);
x += imgw+1; x += imgw+1;
rct := 1; rct := 1;
end end
end else end else
begin begin
FBtnRects[i]:= array(x,y,x+imgw,y+imgh); if bi.stylesep then FBtnRects[i]:= array(0,0,0,0);
else
FBtnRects[i]:= array(x,y,x+imgw,y+imgh);
x += imgw+1; x += imgw+1;
rct++; rct++;
end end

View File

@ -98,7 +98,7 @@ type TCustomThreadworker = class()
if not FThreaders then return ; if not FThreaders then return ;
for idx,i in mrows( FThreaders,1) do for idx,i in mrows( FThreaders,1) do
begin begin
o := FThreaders[i]; o := FThreaders[i];
if uifeachthreadworkerdata(o.handle,msg,data) then if uifeachthreadworkerdata(o.handle,msg,data) then
begin begin
case msg of case msg of

View File

@ -222,8 +222,13 @@ type twindowsapi = class
class function IsWindow(hd:pointer):integer;stdcall;external "User32.dll" name "IsWindow"; class function IsWindow(hd:pointer):integer;stdcall;external "User32.dll" name "IsWindow";
class function IsWindowVisible(hd:pointer):integer;stdcall;external "User32.dll" name "IsWindowVisible"; class function IsWindowVisible(hd:pointer):integer;stdcall;external "User32.dll" name "IsWindowVisible";
function GetWindow(hd:pointer;cd:integer):pointer;stdcall;external "User32.dll" name "GetWindow"; function GetWindow(hd:pointer;cd:integer):pointer;stdcall;external "User32.dll" name "GetWindow";
function GetNextWindow(hd:pointer;cd:integer):pointer;stdcall;external "User32.dll" name "GetNextWindow"; //function GetNextWindow(hd:pointer;cd:integer):pointer;stdcall;external "User32.dll" name "GetNextWindow";
function GetNextWindow(h,cd);
begin
return GetWindow(h,cd);
end
function GetTopWindow(hd:pointer):pointer;stdcall;external "User32.dll" name "GetTopWindow"; function GetTopWindow(hd:pointer):pointer;stdcall;external "User32.dll" name "GetTopWindow";
function GetWindowThreadProcessId(hd:pointer;var pid :integer):integer;stdcall;external "User32.dll" name "GetWindowThreadProcessId";
function IsChild(hd:pointer;cd:pointer):integer;stdcall;external "User32.dll" name "IsChild"; function IsChild(hd:pointer;cd:pointer):integer;stdcall;external "User32.dll" name "IsChild";
function RegisterClassExA(wc:pointer):short;stdcall;external "User32.dll" name "RegisterClassExA"; function RegisterClassExA(wc:pointer):short;stdcall;external "User32.dll" name "RegisterClassExA";
function EnableWindow(wc:pointer;b:integer):integer;stdcall;external "User32.dll" name "EnableWindow"; function EnableWindow(wc:pointer;b:integer):integer;stdcall;external "User32.dll" name "EnableWindow";
@ -320,6 +325,7 @@ type twindowsapi = class
function memcpy2(var dst:string;src:pointer;size_t:integer):pointer;cdecl;external "msvcrt.dll" name "memcpy"; function memcpy2(var dst:string;src:pointer;size_t:integer):pointer;cdecl;external "msvcrt.dll" name "memcpy";
function fopen(filename:string; mode:string):pointer;cdecl;external "msvcrt.dll" name "fopen"; function fopen(filename:string; mode:string):pointer;cdecl;external "msvcrt.dll" name "fopen";
function fclose(f:pointer):integer;cdecl;external "msvcrt.dll" name "fclose"; function fclose(f:pointer):integer;cdecl;external "msvcrt.dll" name "fclose";
function GetProcessId(h:pointer):integer;stdcall;external "Kernel32.dll" name "GetProcessId";
function LockFile(hFile:pointer; dwFileOffsetLow:integer; dwFileOffsetHigh:integer;nNumberOfBytesToLockLow:integer;nNumberOfBytesToLockHigh:integer):integer;stdcall;external "Kernel32.dll" name "LockFile"; function LockFile(hFile:pointer; dwFileOffsetLow:integer; dwFileOffsetHigh:integer;nNumberOfBytesToLockLow:integer;nNumberOfBytesToLockHigh:integer):integer;stdcall;external "Kernel32.dll" name "LockFile";
function UnlockFile(hFile:pointer; dwFileOffsetLow:integer; dwFileOffsetHigh:integer;nNumberOfBytesToLockLow:integer;nNumberOfBytesToLockHigh:integer):integer;stdcall;external "Kernel32.dll" name "UnlockFile"; function UnlockFile(hFile:pointer; dwFileOffsetLow:integer; dwFileOffsetHigh:integer;nNumberOfBytesToLockLow:integer;nNumberOfBytesToLockHigh:integer):integer;stdcall;external "Kernel32.dll" name "UnlockFile";
//icon //icon