界面库

添加coolbar
This commit is contained in:
JianjunLiu 2022-08-28 15:01:28 +08:00
parent 5fb0e102d9
commit 6d926c1568
6 changed files with 232 additions and 145 deletions

View File

@ -2887,7 +2887,54 @@ type TDToolBar = class(TDComponent)
//r.Cwnd.align := r.Cwnd.alnone;
return r;
end
end
type TDcoolBar = class(TDComponent)
{**
@explan(说明) toolbar 设计器控件 %%
**}
public
function HitTip();override;
begin
return inherited;
end
function DefaultAlign();override;
begin
return true;
end
function dclassname();override;
begin
return "tcoolbar";
end
function menus();override;
begin
r := inherited;
return r;
end
function CheckChild(CD);override;
begin
return true;
//return cd is class(TDToolButton);
end
function bitmapinfo();override;
begin
return gettoolbarbitmapinfo();
end
function WndClass();override;
begin
return Class(TcoolBar);
end
function Create(AOwner);override;
begin
inherited;
end
function ComponentCreater(tnode,owner);override;
begin
r := inherited;
//r.Cwnd.align := r.Cwnd.alnone;
return r;
end
end
type TDStatusBar = class(TDComponent)
{**
@ -5532,6 +5579,25 @@ type TGridCellLazyIntegerEdit = class(TGridCellIntegerEdit)
inherited;
end
end
type TGridCellLazystrEdit = class(TGridCellStringEdit) //后处理信息
function CreateEditer(AOwner);override;
begin
return new TGridCellLazystrEdit(AOwner);
end
function EditType();override;
begin
return "lazystr";
end
function LazyProperty();override;
begin
return true;
end
function create(AOwner);override;
begin
inherited;
end
end
//*****************Ñ¡Ôñlist*******************************************
type UniCheckList = class(TTreeView) //µ¥Ñ¡
private
@ -9319,7 +9385,7 @@ begin
class(TDMainMenu),class(TDPopUpMenu),class(TDMenu),
class(TDOpenFileADlg),class(TDSaveFileADlg),class(TDInputQuerys),
class(TDColorChoose),class(TDFontChoose),class(TDFolderChoose),
class(TDToolBar),class(TDStatusBar),class(TDToolButton),
class(TDcoolBar),class(TDToolBar),class(TDStatusBar),class(TDToolButton),
class(TDTray),
class(TDActionList),class(TDAction),
class(TDQuotations),class(TDtlogincontrol),
@ -9355,6 +9421,7 @@ begin
class(TGridCellNaturalEdit),
class(TGridCellIntegerEdit),
class(TGridCellLazyIntegerEdit),
class(TGridCellLazystrEdit),
class(TGridCellStringEdit),
class(TGridCellEventHandleEdit),
class(TGridCellVariableEdit),

View File

@ -1391,7 +1391,7 @@ type tcontrol = class(tcomponent)
end
if rchange then
begin
mtic;
//mtic;
obj := class(tUIglobalData).uigetdata("tuiapplication");
if obj then
begin

View File

@ -22,8 +22,8 @@ unit tslvcl;
{$endif}
interface
uses utslvclconstant,utslvclbase,utslvclauxiliary,cstructurelib,utslvclmemstruct,utslvclevent,
UVCPropertyTypesPersistence,utslvclgdi,utslvclaction,utslvclmenu,utslvclstdctl,utslvclpage,utslvcldlg,
utslvclgrid,utslvcltree;
UVCPropertyTypesPersistence,utslvclgdi,utslvclaction,utslvclmenu,utslvclstdctl,utslvclpage,
utslvcldlg,utslvclgrid,utslvcltree,utslvclcoolbar;
function initializeapplication(); //获得app对象
function RegisterComponentType(n,typ); //注册控件,便于通过控件名称构造控件
function GetAndDispatchMessageA(hwnd,minm,maxm); //win32 分发消息
@ -2444,6 +2444,7 @@ type TToolButton = class(TcustomToolButton)
return array("name","action","caption","enabled","stylesep","imageid","visible","onclick","popupmenu");
end
end
type TToolBar = class( TcustomToolBar)
{**
@explan(说明) 工具栏控件 %%
@ -2479,6 +2480,19 @@ type TStatusBar = class(TcustomStatusBar)
"font","visible","items","ondblclick","onmousedown","onmouseup");
end
end
type tcoolbar = class(tcustomcoolbar)
{**
@explan(˵Ã÷) coolbar¿Ø¼þ %%
**}
function create(AOwner);
begin
inherited;
end
function publishs();override;
begin
return array("name","enabled","caption","autosize","font","color","dragbtncolor","sizebtncolor","visible","arrange");
end
end
//树控件
type TTreeCtlNode = class( TcustomTreeCtlNode)

View File

@ -1,55 +1,51 @@
unit utslvclcoolbar;
{**
@explan(说明) coolbar库,提供coolbar 支持
**}
interface
uses utslvclauxiliary,utslvclgdi;
type tcustomcoolbar=class(tcustomcontrol)
{**
@explan(说明) coolbar基类
**}
function Create(AOwner);
begin
fcoolbands := new tcoolbarlines();
frowheight := 30;
fbtnwidth := 20;
fautosize := true;
inherited;
Align := alTop;
FWill_Drag := true;
cimgst();
fsizebtncolor := _wapi.GetSysColor(COLOR_MENUBAR);
fdragbtncolor := fsizebtncolor;
end
function ControlAppended(AControl);override;
begin
{**
@explan(说明) 子控件添加 %%
**}
it := new tcoolband(AControl);
fcoolbands.appendrow(it);
end
function ControlDeleted(AControl);override;
begin
{**
@explan(说明) 子控件删除 %%
**}
fcoolbands.deleteitem(AControl);
end
function Notification(o,op);override;
begin
return inherited;
if ifarray(op) then
r := inherited;
if class(tflag).haslocker then return r;
if HandleAllocated() and ifarray(op) and (op["type"]="possize") then //位置大小发送变化
begin
ctls := controls;
if (ctls.IndexOf(o)>=0) then
if (ctls.IndexOf(o)>=0) then //子控件大小变化
begin
//echo tostn(op);
flg := op["flag"];
if flag>0 and ((flag .& 4 ) or (flg .& 8)) then
begin
echo "\r\n",tostn(op);
doControlALign();
InvalidateRect(nil,false);
return r;
end
end
return r;
end
inherited;
end
function MouseUp(o,e);override;
function MouseUp(o,e);override;//拖拽实现
begin
if csDesigning in ComponentState then exit;
if e.button=mbLeft then
@ -66,7 +62,6 @@ type tcustomcoolbar=class(tcustomcontrol)
doControlALign();
InvalidateRect(nil,false);
r := getarrange();
echo tostn(r);
end
end else
if fsizenode then
@ -95,7 +90,7 @@ type tcustomcoolbar=class(tcustomcontrol)
end
inherited;
end
function MouseDown(o,e);override;
function MouseDown(o,e);override;//拖拽释放
begin
if csDesigning in ComponentState then exit;
if e.button=mbLeft then
@ -104,15 +99,14 @@ type tcustomcoolbar=class(tcustomcontrol)
trk := -1;
for i,v in fcoolbands.data do
begin
if pointinrect(xy,v.fdragrect) then
if pointinrect(xy,v.fdragrect) then //拖拽
begin
trk := 0;
fdragenode := v;
fsizenode := nil;
break;
end
if pointinrect(xy,v.fsizerect) then
if pointinrect(xy,v.fsizerect) then //调整大小
begin
trk := 1;
fdragenode := nil;
@ -127,9 +121,7 @@ type tcustomcoolbar=class(tcustomcontrol)
begin
FWill_Drag := false;
FIs_Draging := true;
_wapi.ImageList_BeginDrag(FDRageimglist.Handle,trk,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]));
@ -139,7 +131,7 @@ type tcustomcoolbar=class(tcustomcontrol)
end
inherited;
end
function MouseMove(o,e);override;
function MouseMove(o,e);override; //移动
begin
if FIs_Draging then
begin
@ -148,7 +140,7 @@ type tcustomcoolbar=class(tcustomcontrol)
end
inherited;
end
function doControlALign();override;
function doControlALign();override;//调整位置
begin
mwid := 10;
swid := 12;
@ -168,6 +160,7 @@ type tcustomcoolbar=class(tcustomcontrol)
return ;
end
end
lk := new tflag();
for i,v in fcoolbands.data2 do
begin
x := 0;
@ -202,7 +195,7 @@ type tcustomcoolbar=class(tcustomcontrol)
y+=rhs[i];
end
end
function paint();override;
function paint();override; //绘制
begin
dc := canvas;
cl := dc.brush.color;
@ -221,33 +214,10 @@ type tcustomcoolbar=class(tcustomcontrol)
//dc.brush.color := 0x87CEEB;
dc.brush.color := fdragbtncolor;
rc1 := v.fdragrect;
rc1[0]+=1;
rc1[1]+=1;
rc1[2]-=1;
rc1[3]-=1;
dc.fillrect(rc1);
ply := array( rc1[array(0,1)],
rc1[array(2,1)],
rc1[array(2,3)],
rc1[array(0,3)],
rc1[array(0,1)]
);
dc.draw("polyline",ply) ;
paintbtn(v.fdragrect);
//dc.brush.color := 0xEEE8AA;
dc.brush.color := fsizebtncolor;
rc1 := v.fsizerect;
rc1[0]+=1;
rc1[1]+=1;
rc1[2]-=1;
rc1[3]-=1;
dc.fillrect(rc1);
ply := array( rc1[array(0,1)],
rc1[array(2,1)],
rc1[array(2,3)],
rc1[array(0,3)],
rc1[array(0,1)]
);
dc.draw("polyline",ply) ;
paintbtn(v.fsizerect);
end
dc.brush.color := cl;
dc.pen.color := bcl;
@ -255,16 +225,33 @@ type tcustomcoolbar=class(tcustomcontrol)
function Recycling();override;
begin
inherited;
//if FDRageimglist then _wapi.ImageList_Destroy(FDRageimglist);
FDRageimglist := nil;
end
property autosize read fautosize write setautosize;
property arrange read getarrange write setarrange;
property autosize:bool read fautosize write setautosize;
property arrange:lazystr read getarrange write setarrange;
property dragbtncolor:color read fdragbtncolor write fdragbtncolor;
property sizebtncolor:color read fsizebtncolor write fsizebtncolor;
private
fautosize ;
fdragbtncolor;
fsizebtncolor;
fsizelocker;
function paintbtn(rc1);
begin
dc := canvas;
rc1[0]+=1;
rc1[1]+=1;
rc1[2]-=1;
rc1[3]-=1;
dc.fillrect(rc1);
ply := array( rc1[array(0,1)],
rc1[array(2,1)],
rc1[array(2,3)],
rc1[array(0,3)],
rc1[array(0,1)]
);
dc.draw("polyline",ply) ;
end
function arange2a(s);
begin
ss := str2array(s,";");
@ -278,11 +265,12 @@ type tcustomcoolbar=class(tcustomcontrol)
end
end
function getarrange();
function getarrange(b);
begin
if not(b) then b := fcoolbands;
ar := "";
ctls := controls;
for i,vi in fcoolbands.data2 do
for i,vi in b.data2 do
begin
for j,v in vi do
begin
@ -300,7 +288,7 @@ type tcustomcoolbar=class(tcustomcontrol)
ct := ctls.count-1;
if ct<0 then return ;
idxs := 0->(ct);
fcoolbands_ := new tnumindexarray();
ncoollines := new tnumindexarray();
for i,v in str2array(ar,";") do
begin
if v then
@ -321,23 +309,26 @@ type tcustomcoolbar=class(tcustomcontrol)
end
if line.length() then
begin
fcoolbands_.Push(line);
ncoollines.Push(line);
end
end
end
for i,v in idxs do
begin
line := new tnumindexarray();
line.Push(new tcoolband(ctls[vidx]));
fcoolbands_.Push(line);
line.Push(new tcoolband(ctls[v]));
ncoollines.Push(line);
end
fcoolbands := fcoolbands_;
nb := new tcoolbarlines();
nb.lines := ncoollines;
if getarrange()=getarrange(nb) then return ; //相同
fcoolbands := nb;
if HandleAllocated() then
begin
doControlALign();
end
end
function setautosize(v);
function setautosize(v);//自动调整
begin
nv := v?true:false;
if nv<>fautosize then
@ -363,22 +354,17 @@ type tcustomcoolbar=class(tcustomcontrol)
FDRageimglist.addbmp(bmp);
bmp.readvcon(HexFormatStrToTsl(getsizebmp()));
FDRageimglist.addbmp(bmp);
end
fdragenode;
fsizenode;
fcoolbands;
frowheight;
fdragenode; //拖拽的节点
fsizenode; //调整大小节点
fcoolbands; //节点管理器
fbtnwidth;
FIs_Draging;//
FWill_Drag;//
FDRageimglist;//
end
implementation
type tcoolband = class
type tcoolband = class() //管理节点
function create(ctl);
begin
fctl := ctl;
@ -414,7 +400,7 @@ type tcoolband = class
private
fenable;
end
type tcoolbarlines = class
type tcoolbarlines = class() //节点管理器
function create();
begin
flines := new tnumindexarray();
@ -442,56 +428,56 @@ type tcoolbarlines = class
if v.length()<1 then
begin
flines.splice(i,1);//删除
return 2;
end
return 1;
end
end
end
end
return 0;
end
function moveitemto(it,nit,f);//移动到坐标
begin
if it=nit then return 0;
{id1 := -1;
id2 := -1;
for i ,v in data do
bkr := 0;
for i,v in data2 do //查找行列位置
begin
if v= it then
for j,vj in v do
begin
id1 := i;
if id2>-1 then break;
if vj=it then
begin
id1 := array(i,j);
end else
if nit = vj then
begin
id2 := array(i,j);
end
if v=nit then
if id1 and id2 then
begin
id2 := i;
if id1>-1 then break;
bkr := 1;
break;
end
end
//it 为移动的
//nid 为锚点
case f of
0,1: //前
if bkr then break;
end
if not(bkr) then return 0;
if id1[0]=id2[0] then //同一行
begin
if (id2-id1)=1 then return 0;
if ((id1[1]-id2[1])=1) and f=3 then //在后面情况
begin
return 0;
end
if ((id1[1]-id2[1])=-1) and (f=0 or f=1) then //在前面情况
begin
return 0;
end
2: //前一行
begin
end
3: //后
begin
if (id1-id2)=1 then return 0;
end
4: //后一行
begin
end
end }
deleteitem(it);//删掉
case f of
0,1: //前
0,1,3: //前
begin
ifg := 0;
ifg := f=3;
end
2: //前一行
begin
@ -500,10 +486,6 @@ type tcoolbarlines = class
flines.unshift(line);
return 1;
end
3: //后
begin
ifg :=2;
end
4: //后一行
begin
line := new tnumindexarray();
@ -522,9 +504,11 @@ type tcoolbarlines = class
if ifg then //后面
begin
v.splice(j+1,0,it);
return 1;
end else
begin
v.splice(j,0,it);
return 1;
end
end
end
@ -533,19 +517,20 @@ type tcoolbarlines = class
end
function getrowheights(); //总高度
begin
r := array(25);
for i,v in flines.data do
r := array(25); //默认高度
for i,v in getdata2() do
begin
h := 0;
for j,vj in v.data do
for j,vj in v do
begin
if vj["visible"] then
h := max(h,vj["height"]);
end
r[i] := h;
r[i] := max(20,h);
end
return r;
end
function EnabledChild(f);
function EnabledChild(f); //enable
begin
for i,v in flines.data do
begin
@ -555,7 +540,7 @@ type tcoolbarlines = class
end
end
end
function getnodebyxy(x,y);
function getnodebyxy(x,y); //通过位置获得节点的信息,拖拽处理使用
begin
rs := getrowheights();
b := 0;
@ -566,46 +551,45 @@ type tcoolbarlines = class
if v<1 then continue;
if y>=b and y<=b+v then //确定行
begin
for j,bsi in flines[i].data do
for j,bsi in flines[i].data do //在行中循环
begin
rc := bsi.fctlrect;
rt := -1;
if (x>=(rc[0])) and ( x<=(rc[0]+rc[2])) and
(y>=(rc[1]+bdr)) and ( y<=(rc[1]+rc[3]-bdr)) then
(y>=(rc[1]+bdr)) and ( y<=(rc[1]+rc[3]-bdr)) then //中间位置
begin
rt := 0;
end
if x<(rc[0]+bdr) then
if x<(rc[0]+bdr) then //左边
begin
rt := 1;
end
if i=0 then
begin
if y<(rc[1]+bdr) then
if y<(rc[1]+bdr) then //上边
begin
rt := 2;
end
end
if i=rl then
begin
if y>(rc[1]+rc[3]-bdr) then
if y>(rc[1]+rc[3]-bdr) then //下边
begin
rt := 4;
end
end
if rt>-1 then return array(bsi,rt,i,j);
if rt>-1 then return array(bsi,rt,i,j); //后边
end
return array(bsi,3,i,j);
end
b+=v;
end
ri := length(rs)-1;
return array((flines[ri])[0],4,ri,0);
return array((flines[ri])[0],4,ri,0); //字后面
end
property data2 read getdata2;
property data read getdata;
property lines read flines;
property lines read flines write flines;
private
function getdata();
begin
@ -635,9 +619,19 @@ type tcoolbarlines = class
return r;
end
flines;
end
function getmovebmp();
type tflag = class() //锁定对象
static haslocker;
function create();
begin
haslocker++;
end
function destroy();
begin
haslocker--;
end
end
function getmovebmp(); //移动图片
begin
return "0502000000060400000074797065000203000000696D670006040000006461746
10002E801000089504E470D0A1A0A0000000D4948445200000018000000180806
@ -658,7 +652,7 @@ E8A93404DEE2BB10AB6CFBB4672112E12AB6061F785932DEEC585C478A2CF8655
454E44AE42608200";
end
function getsizebmp();
function getsizebmp(); //调整大小图片
begin
return "0502000000060400000074797065000203000000696D670006040000006461746
100020E01000089504E470D0A1A0A0000000D4948445200000018000000180806

View File

@ -4369,10 +4369,10 @@ type TcustomToolBar=class(TCustomControl)
end
end
end
function ContextMenu(o,e);override;
{function ContextMenu(o,e);override;
begin
e.skip := true;
end
end }
function MouseUp(o,e);override;
begin
if csDesigning in ComponentState then return;

View File

@ -1427,6 +1427,17 @@ type TPropertyLazyInteger=class(TPropertyInteger)
return true;
end
end
type TPropertyLazystr=class(TPropertyString)
function EditType();override;
begin
return "lazystr";
end
function LazyProperty();override;
begin
return true;
end
end
type UniSelProperty=class(TPropertyType)
function Create();
begin
@ -2038,6 +2049,7 @@ begin
"tpropertystatusitems",
"tpropertyfilefilter",
"tpropertylazyinteger",
"TPropertyLazystr",
"uniselproperty",
"uniobjectmember",
"tpropertyalign9",