界面库

添加splitter
This commit is contained in:
JianjunLiu 2022-09-08 17:06:18 +08:00
parent 650d79c677
commit 96374a02c0
7 changed files with 422 additions and 26 deletions

View File

@ -2356,6 +2356,40 @@ type TGraphicLabelWindow = class(TDVirutalWindow)
return true;
end
end
type TGraphicsplitterWindow = class(TDVirutalWindow)
{**
@explan(说明) label 控件替代窗口 %%
**}
function paint();override;
begin
//canvas.Font := font;
//al := BindComp.TextAlign;
//BindComp.CanvasDrawAlignText(self.canvas,self.ClientRect,self.caption,al);
end
function SetPublish(n,v);override;
begin
r := inherited;
//if n="color" then color := v;
//if n="bkbitmap" then bkbitmap := v;
//if (n="textalign" or n="caption" or n="font" or n="bkbitmap") then InvalidateRect(nil,true);
return r;
end
function Create(AOwner);override;
begin
inherited;
BindComp := new tsplitter(self);
width := BindComp.width;
height := BindComp.Height;
color := BindComp.color;
WindowFileds := array("left","top","width","height","color","visible","enabled","align");
end
function DesigningSizer();override;
begin
return true;
end
end
type TDLabel = class(TDComponent)
{**
@ -2392,6 +2426,40 @@ type TDLabel = class(TDComponent)
inherited;
end
end
type tdsplitter = class(TDComponent)
{**
@explan(说明) label控件 %%
**}
function HitTip();override;
begin
return inherited;
end
function IsContainer();override;
begin
return false;
end
function ComponentClass();override;
begin
return class(tsplitter);
end
function dclassname();override;
begin
return "tsplitter";
end
function WndClass();override;
begin
return Class(TGraphicsplitterWindow);
end
function bitmapinfo();override;
begin
return getsplitterbitmapinfo();
end
function Create(AOwner);override;
begin
inherited;
end
end
//****************timmer****************************
type TTimerWindow = class(TDVirutalWindow)
{**
@ -9422,6 +9490,7 @@ begin
class(TDmessagebox),
class(TDBtn),
class(TDLabel),
class(tdsplitter),
class(TDEdit),
class(TDpassword),
class(TDmemo),

View File

@ -33,6 +33,7 @@ function getrunbmpinfo();
function getwrapprojectbmpinfo();
function getcreateprojectbmpinfo();
function geteditcodebitmapinfo();
function getsplitterbitmapinfo();
//编辑器图片
function getdbugerrunbmpinfo();
function getopenfilebmpinfo();
@ -1215,6 +1216,19 @@ CF7F527EA1C3DA7875C10207E7AA366E2C20907118F56AE3DA023E0ECE2A78100
4FA02DDADA8831B0B9AD8BCB2A0297CA9A0F59F7E7B0FE20F1D79BA1B7D429BC4
0000000049454E44AE42608200";
end
function getsplitterbitmapinfo();
begin
return "0502000000060400000074797065000203000000696D670006040000006461746
100021301000089504E470D0A1A0A0000000D4948445200000018000000180806
000000E0773DF8000000017352474200AECE1CE90000000467414D410000B18F0
BFC6105000000097048597300000EC300000EC301C76FA864000000A849444154
484B63F84F6330422C3874E020062616106DC1FDFBB7E1B8BC7C12548630185C1
6800C1E3A3E78F6F63B9485DF026475D800560B5EBCFBFE3FB8E13894873F88FC
6B8FFD7FF2FA1B948709302C80196E91B30F2A82DF072075F82C41B100D970523
12E4B502CC89C700EAB666231483F3AA0AF0F4080A6710003344D453040D37C80
0EF0594008906401B620220406970F686A01C850644C2C20CA024A008D2DF8FF1
F0006015AA04B38837B0000000049454E44AE42608200";
end
{ GetSaveFileBitmapInfo
//保存文件
"0502000000060400000074797065000203000000696D670006040000006461746

View File

@ -897,43 +897,51 @@ type tcontrol = class(tcomponent)
begin
exit;
end
if e.width<1 then exit;
if e.height<1 then exit;
if e.width<2 or e.height<2 then //处理一下操出范围的子控件
begin
case Align of
alLeft,alRight,alTop,alBottom,alClient:
begin
SetBounds(e.left,e.top,2,2);
end
end ;
exit;
end
bds := UnAlignBounds;
case Align of
alTop:
begin
ht := min(e.height,bds[3]-bds[1]);
if ht then
begin
SetBounds(e.left,e.top,e.width,ht);
//if ht then
//begin
SetBounds(e.left,e.top,e.width,max(2,ht));
//SetBoundsRect(array(e.left,e.top,e.width+e.left,e.top+ht));
e.top += ht;
e.height -= ht;
end
//end
end
alRight:
begin
wd := min(e.width,bds[2]-bds[0]);
SetBounds(e.left+e.width-wd,e.top,wd,e.height);
SetBounds(e.left+e.width-wd,e.top,max(wd,2),e.height);
e.width := e.width-wd;
end
alLeft:
begin
wd := min(e.width,bds[2]-bds[0]);
SetBounds(e.left,e.top,wd,e.height);
SetBounds(e.left,e.top,max(wd,2),e.height);
e.left := e.left+wd;
e.width := e.width-wd;
end
alBottom:
begin
ht := min(e.height,bds[3]-bds[1]);
SetBounds(e.left,e.top+e.height-ht,e.width,ht);
SetBounds(e.left,e.top+e.height-ht,e.width,max(ht,2));
e.height -= ht;
end
alClient:
begin
SetBounds(e.left,e.top,e.width,e.height);
SetBounds(e.left,e.top,max(2,e.width),max(2,e.height));
e.height := 0;
e.width := 0;
end

View File

@ -1,5 +1,5 @@
type tcustomcontrol=class(TWinControl)
uses utslvclauxiliary;
uses utslvclauxiliary,utslvclgdi;
{**
@explan(说明) 自绘制窗口控件 %%
**}
@ -22,11 +22,26 @@ type tcustomcontrol=class(TWinControl)
inherited;
if datatype(FOnPaint)=7 then call(FOnPaint,self(true));
end
function ControlAppended(AControl);override;
begin
if AControl is class(tcustomsplitter) then
begin
fhasspliter++;
end
end
function ControlDeleted(AControl);override;
begin
if AControl is class(tcustomsplitter) then
begin
fhasspliter--;
end
end
public
function Create(AOwner:TComponent);override;
begin
inherited;
includestate(FControlState,csCustomPaint);
fsplitterwilldrag := true;
//FCanvas := new tcanvas();
end
function CreateParams(p);override;
@ -37,6 +52,8 @@ type tcustomcontrol=class(TWinControl)
function Recycling();override;
begin
FOnPaint := nil;
fsplitercache := array();
fsplitterdragimglist := nil;
inherited;
end
function DoVScroll(o,e);virtual;
@ -54,8 +71,265 @@ type tcustomcontrol=class(TWinControl)
begin
return DoHScroll(o,e);
end
function WMLButtonDown(o,e);override;//拖拽释放
begin
if fhasspliter<1 then return inherited;
if csDesigning in ComponentState then exit;
case fcurspltype of
alLeft,alRight:
begin
drgidx := 1;
end
alTop,alBottom:
begin
drgidx := 0;
end
else
begin
return inherited;
end
end ;
if fsplitterwilldrag then
begin
cimgst();
fsplitterwilldrag := false;
fsplitterdraging := true;
nxy := clienttowindow(e.xpos,e.ypos);
_wapi.ImageList_BeginDrag(fsplitterdragimglist.Handle,drgidx,12,12);
_wapi.ImageList_DragEnter(self.Handle,nxy[0],nxy[1]);
crect := clientrect;
ps := array(clienttoscreen(crect[0],crect[1]),clienttoscreen(crect[2],crect[3]));
_wapi.clipcursor(ps);
splitterenabled(false);
return ;
end
//end
inherited;
end
function WMLBUTTONUP(o,e);override;//拖拽实现
begin
if fhasspliter<1 then return inherited;
if csDesigning in ComponentState then return ;
if fsplitterdraging then
begin
cimgst();
_wapi.ImageList_DragLeave(self.Handle);
_wapi.ImageList_EndDrag();
splitterenabled(true);
fsplitterwilldrag := true;
fsplitterdraging := false;
sizeprive(e.pos);
_wapi.clipcursor(0);
return ;
end
inherited;
end
function WMMouseMove(o,e);override; //移动
begin
if fhasspliter<1 then return inherited;
if fsplitterdraging then
begin
cimgst();
nxy := clienttowindow(e.xpos,e.ypos);
_wapi.ImageList_DragMove(nxy[0],nxy[1]);
return ;
end else
begin
xy := e.pos();
fcurspltype := nil;
fcursplitterid := -1;
fcursplitter := nil;
for i,v in Controls.data do
begin
if (v is class(tcustomsplitter)) and (v.Visible) and (v.enabled) and pointinrect(xy,v.BoundsRect) and (v<>fcursplitter) then //拖拽
begin
va := v.Align;
if va in array(alLeft,alRight) then
begin
cursor := OCR_SIZEWE;
fcurspltype := va;
fcursplitter := v;
fcursplitterid := i;
return ;
end else
if va in array(alTop,alBottom) then
begin
cursor := OCR_SIZENS;
fcurspltype := va;
fcursplitter := v;
fcursplitterid := i;
return ;
end
end
end
cursor := OCR_NORMAL;
end
inherited;
end
property OnPaint:eventhandler read FOnPaint write FOnPaint;
{**
@param(OnPaint)(function[TCustomControl,tuieventbase]) 窗口关闭消息回调 %%
**}
private
function getzybmp();
begin
r :="0502000000060400000074797065000203000000696D670006040000006461746
10002E300000089504E470D0A1A0A0000000D4948445200000018000000180806
000000E0773DF8000000017352474200AECE1CE90000000467414D410000B18F0
BFC6105000000097048597300000EC300000EC301C76FA8640000007849444154
484BED8FED09C0200C443B90C3B89CDB65174BC02B54134FA41F7FF220207AB98
7477D9910504240F94F2022EDC499654D812EE49C97242C3B08B0504A69371CCD
7A929B60A71C78924B80F294923BC07AC3F492EF7E0076245EB932081448AC851
E963505CA4A3998655DC1538480120242AD27B102A52F60A469C4000000004945
4E44AE42608200";
return r;
end
function getsxbmp();
begin
r := "0502000000060400000074797065000203000000696D670006040000006461746
100027801000089504E470D0A1A0A0000000D4948445200000018000000180806
000000E0773DF8000000017352474200AECE1CE90000000467414D410000B18F0
BFC6105000000097048597300000EC300000EC301C76FA8640000010D49444154
484BE5963D0A84400C853D8885BD585AD8D97802B11704AFA19D8D78053BAFE10
5AC0541F006361E204B86380CAC6322EC6EB31F04740CEF61327F0E08699A0682
2000C771A02C4B98E799BEDC2332288A42099B118621ECFB4E19765883BAAEDFC
4CF48D394B2ECB006499228B1388EB5705555FA79DB36CABC4654A2B66D615916
2D3A8E23F47DAF8243DC64C43490F26706BEEF2B83755D6984E79101CE986118E
84D8636388E43FDFA27629A2652350CA228D235FE44E05A417E67F0F5127D8B47
06B81F799EC7EE3F268F0CCEFA6219A4FC8101AE5CDB766DCE161BAC419EE74AF
4EAC0C18673B0067747669665946547D483AB435F228E889B7C5E5B5CD785AEEB
689403E005E8019174FBC7C7A70000000049454E44AE42608200";
return r;
end
function candosplitter(v);
begin
return (not(v is class(tcustomsplitter)) and (v.Visible) and (v.Align = fcurspltype));
end
function sizeprive(xy);
begin
id := fcursplitterid;
ctls := Controls;
rc := clientrect;
x := max(rc[0],xy[0]);
x := min(rc[2],x);
y := max(rc[1],xy[1]);
y:= min(rc[3],y);
case fcurspltype of
alLeft :
begin
for i:= id-1 downto 0 do
begin
v := ctls[i];
if candosplitter(v) then
begin
vL := v.Left;
sw := fcursplitter.Width;
nvl := max(x-vl-sw,sw);
v.Align := alNone;
v.Width := nvl;
v.Align := fcurspltype;
return ;
end
end
end
alTop:
begin
for i:= id-1 downto 0 do
begin
v := ctls[i];
if candosplitter(v) then
begin
vL := v.top;
sw := fcursplitter.Height;
nvl := max(y-vl-sw,sw);
v.Align := alNone;
v.Height := nvl;
v.Align := fcurspltype;
return ;
end
end
end
alRight:
begin
for i:= id-1 downto 0 do
begin
v := ctls[i];
if candosplitter(v) then
begin
vl := (v.BoundsRect)[2];
sw := fcursplitter.Width;
nvl := max(vl-x-sw*1.5,sw);
v.Align := alNone;
v.Width := nvl;
v.Align := fcurspltype;
return ;
end
end
end
alBottom:
begin
for i:= id-1 downto 0 do
begin
v := ctls[i];
if candosplitter(v) then
begin
vL := (v.BoundsRect)[3];
sw := fcursplitter.Height;
nvl := max(vl-y-sw*1.5,sw);
v.Align := alNone;
v.Height := nvl;
v.Align := fcurspltype;
return ;
end
end
end
end
end
function cimgst();
begin
if not fsplitterdragimglist then
begin
fsplitterdragimglist := new TCustomImageList(self);
fsplitterdragimglist.Width := 24;
fsplitterdragimglist.Height := 24;
bmp := new TcustomBitmap();
bmp.readvcon(HexFormatStrToTsl(getsxbmp()));
fsplitterdragimglist.addbmp(bmp);
bmp.readvcon(HexFormatStrToTsl(getzybmp()));
fsplitterdragimglist.addbmp(bmp);
end
end
function splitterenabled(b);
begin
if not b then
begin
fsplitercache := array();
for i,v in controls.data do
begin
fsplitercache[i] := array(v,v.enabled);
v.enabled := false;
end
end else
begin
for i,v in fsplitercache do
begin
v[0].enabled := v[1];
end
fsplitercache := nil;
end
end
fsplitterdragimglist;
fsplitterwilldrag;
fsplitterdraging;
fcurspltype;
fcursplitter;
fcursplitterid;
fsplitercache;
fhasspliter;
end;

View File

@ -0,0 +1,17 @@
type tcustomsplitter = class(tgraphiccontrol)
{**
@explan(说明)调整分割控件
**}
function create(AOwner);
begin
inherited;
Caption := "";
color := 0xEED2BC;
Width := 6;
Height := 100;
end
function SetAlign(a);override;
begin
inherited;
end
end

View File

@ -2509,6 +2509,16 @@ type tcoolbar = class(tcustomcoolbar)
return array("name","enabled","caption","autosize","border","wsdlgmodalframe","font","color","dragbtncolor","visible","arrange");
end
end
type tsplitter = class(tcustomsplitter)
function create(AOwner);
begin
inherited;
end
function publishs();override;
begin
return array("name","enabled","border","left","top","width","height","color","transparent","visible","align");
end
end
//树控件
type TTreeCtlNode = class( TcustomTreeCtlNode)

View File

@ -44,11 +44,11 @@ type tcustomcoolbar=class(tcustomcontrol)
end
return r;
end
function MouseUp(o,e);override;//拖拽实现
function WMLBUTTONUP(o,e);override;//ÍÏקʵÏÖ
begin
if csDesigning in ComponentState then exit;
if e.button=mbLeft then
begin
//if e.button=mbLeft then
//begin
if FIs_Draging then
begin
_wapi.ImageList_DragLeave(self.Handle);
@ -77,22 +77,21 @@ type tcustomcoolbar=class(tcustomcontrol)
InvalidateRect(nil,false);
end
end
end
r := ClientRect;
end
EnabledChild(true);
FWill_Drag := true;
FIs_Draging := false;
_wapi.clipcursor(0);
return ;
end
end
//end
inherited;
end
function MouseDown(o,e);override;//拖拽释放
function WMLButtonDown(o,e);override;//ÍÏ×§ÊÍ·Å
begin
if csDesigning in ComponentState then exit;
if e.button=mbLeft then
begin
//if e.button=mbLeft then
//begin
xy := e.pos;
trk := -1;
for i,v in fcoolbands.data do
@ -113,7 +112,7 @@ type tcustomcoolbar=class(tcustomcontrol)
end
end
if trk<0 then return ;
if trk<0 then return inherited;
nxy := clienttowindow(e.xpos,e.ypos);
if FWill_Drag then
begin
@ -125,16 +124,18 @@ type tcustomcoolbar=class(tcustomcontrol)
ps := array(clienttoscreen(crect[0],crect[1]),clienttoscreen(crect[2],crect[3]));
_wapi.clipcursor(ps);
EnabledChild(false);
return ;
end
end
//end
inherited;
end
function MouseMove(o,e);override; //移动
function WMMouseMove(o,e);override; //ÒÆ¶¯
begin
if FIs_Draging then
begin
nxy := clienttowindow(e.xpos,e.ypos);
_wapi.ImageList_DragMove(nxy[0],nxy[1]);
return ;
end else
begin
xy := e.pos();
@ -153,12 +154,15 @@ type tcustomcoolbar=class(tcustomcontrol)
break;
end
end
if not flg then
if flg then
begin
return ;
end else
begin
cursor := OCR_NORMAL;
end
end
inherited;
inherited;
end
function doControlALign();override;//µ÷ÕûλÖÃ
begin