界面库

加入onnotify消息
This commit is contained in:
JianjunLiu 2022-10-28 15:38:51 +08:00
parent e9d9e0d2e9
commit 0262217ded
11 changed files with 325 additions and 49 deletions

View File

@ -3,7 +3,7 @@ interface
{**
@explan(说明) 设计器属性编辑库,继承该库,定义属性编辑类 %%
**}
uses utslvclauxiliary,utslvclbase,utslvclgdi,uvcpropertytypespersistence,tslvcl,utslvcldcomponents;
uses utslvclauxiliary,utslvclbase,utslvclgdi,uvcpropertytypespersistence,tslvcl,utslvcldcomponents,UTslSynMemo;
function registereditpropertytodesigner(cls);
type TGCellRender = class(TSLUIBASE) //属性编辑器单元格对象基类
{**
@ -1464,15 +1464,8 @@ type TGridList = class(TListView)
end
end
//**********属性编辑类***************
/////////////////////////////////////////////////////////////////////////
type TGridCellNaturalEdit = class(TGridPropertyRender,TPropertyNatural)
@ -3478,6 +3471,7 @@ type TtextEditor = class(tpanel)
property ItemStr read GetItemStr write SetItemStr;
end
type TGridCellTextEdit = class(TGridCellEditWithButton,TPropertyText)
{**
@explan(说明)编辑字符串文本属性%%
@ -3590,6 +3584,188 @@ type TGridCellStringsEdit = class(TGridCellTextEdit)
inherited;
end
end
type TGridCelltslEdit = class(TGridCellEditWithButton,tpropertytsl)
{**
@explan(说明)编辑字符串文本属性%%
**}
private
isShow;
FRbuttonWidth;
screenbottom;
protected
Fowner;
Fpanel;
rowNum;
colNum;
Fgrid;
public
function create(AOwner);override;
begin
inherited;
Fowner := AOwner;
Fpanel := nil;
FRbuttonWidth := 20;
screenArr := _wapi.getscreenrect();
screenbottom := screenArr[3];
isShow := true;
end
function createEditObj();virtual;
begin
Fpanel := new ttslediter(Fowner);
end
function ButtonClick(grid,e,d);override;
begin
{**
@explan(说明) 格子点击 %%
**}
inherited;
rowNum := e.iitem;
colNum := e.isubitem;
Fgrid := grid;
pt := e.ptaction;
rec := grid.getSubItemRect(rowNum,colNum);
if pt[0]>=(rec[2]-FRbuttonWidth) then
begin
if ifnil(Fpanel) then begin
createEditObj();
Fpanel.parent := Fowner;
Fpanel.OnActivate := function(o,e)
begin
if e.lowparam = WA_INACTIVE then
begin
CellLeave(Fgrid);
end
end;
end
clickToText(d);
if Fpanel.showmodal()=1 then
begin
textChange1(Fpanel.itemData);
end
end
end
function clickToText(d);virtual;
begin
Fpanel.ItemStr := tostn(d["value"]);
end
function CellName();virtual;
begin
return "tsl";
end
function textChange1(data);virtual;
begin
Fgrid.CellChanged(rowNum,colNum,"value",data);
end
function CellDrawLabel(dc,rect,d);override;
begin
{**
@explan(说明) 绘制格子 %%
**}
dc.drawtext(cellName(),rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE);
end
end
type TGridCelllazytslEdit = class(TGridCellEditWithButton,tpropertylazytsl)
{**
@explan(说明)编辑字符串文本属性%%
**}
private
isShow;
FRbuttonWidth;
screenbottom;
protected
Fowner;
Fpanel;
rowNum;
colNum;
Fgrid;
public
function create(AOwner);override;
begin
inherited;
Fowner := AOwner;
Fpanel := nil;
FRbuttonWidth := 20;
screenArr := _wapi.getscreenrect();
screenbottom := screenArr[3];
isShow := true;
end
function createEditObj();virtual;
begin
Fpanel := new ttslediter(Fowner);
end
function ButtonClick(grid,e,d);override;
begin
{**
@explan(说明) 格子点击 %%
**}
inherited;
rowNum := e.iitem;
colNum := e.isubitem;
Fgrid := grid;
pt := e.ptaction;
rec := grid.getSubItemRect(rowNum,colNum);
if pt[0]>=(rec[2]-FRbuttonWidth) then
begin
if ifnil(Fpanel) then begin
createEditObj();
Fpanel.parent := Fowner;
Fpanel.OnActivate := function(o,e)
begin
if e.lowparam = WA_INACTIVE then
begin
CellLeave(Fgrid);
end
end;
end
clickToText(d);
if Fpanel.showmodal()=1 then
begin
textChange1(Fpanel.itemData);
end
end
end
function clickToText(d);virtual;
begin
Fpanel.ItemStr := tostn(d["value"]);
end
function CellName();virtual;
begin
return "lazytsl";
end
function textChange1(data);virtual;
begin
Fgrid.CellChanged(rowNum,colNum,"value",data);
end
function CellDrawLabel(dc,rect,d);override;
begin
{**
@explan(说明) 绘制格子 %%
**}
dc.drawtext(cellName(),rect,DT_VCENTER.|DT_LEFT .|DT_SINGLELINE);
end
end
type ttslediter = class(TtextEditor)
function create(AOwner);
begin
inherited;
caption := "tsl";
hg := new TTslSynHighLighter(self);
memo.Highlighter := hg;
end
protected
function comfirmEdit(o,e);override;
begin
itemData := nil;
s := memo.text;
try
itemData := eval(&s);
except
end
EndModalCode := 1;
return EndModal();
end
end
type TstringsEditor = class(TtextEditor)
{**
@explan(说明)memo编辑器%%
@ -4309,7 +4485,11 @@ begin
class(TGridCellPairIntEdit),
class(TGridCellPairSpliterTypeEdit),
class(tGridCellAlignPosBoxEdit),
class(TGridCellTreeViewDataEdit)
class(TGridCellTreeViewDataEdit),
class(TGridCelltslEdit),
class(TGridCelllazytslEdit)
));
registerproperties(psi);
end

View File

@ -218,6 +218,7 @@ public //֪ͨ
@param(AComponent)(tcomponent) 改变的对象 %%
@param(Operation)(member of TOperation) 通知码 %%
**}
if dosendrenote(AComponent,Operation) then return ;
If(Operation=opRemove)then
begin
RemoveFreeNotification(AComponent);
@ -231,6 +232,17 @@ public //֪ͨ
end;
end;
private
function dosendrenote(a,op);
begin
if op=opRemove or op=opInsert then return 0;
if fonnotification then
begin
e := new tuieventbase(op,0,0,0);
e.sender := a;
CallMessgeFunction(fonnotification,self(true),e);
return e.skip;
end
end
Procedure SetDesignInstance(Value); //设置设计状态
begin
If Value then

View File

@ -1355,12 +1355,11 @@ type tcontrol = class(tcomponent)
end
if rchange then
begin
//mtic;
//relnotification(self(true),array("type":"possize","flag":rchange,"data":array(fleft,ftop,FWidth,FHeight)));
obj := class(tUIglobalData).uigetdata("tuiapplication");
if obj then
begin
obj.Notification(self(true),array("type":"possize","flag":rchange,"data":array(fleft,ftop,FWidth,FHeight)));
//obj.Notification(self(true),new tpossizenote(rchange,fleft,ftop,FWidth,FHeight));
end
//echo "\r\n note change mtoc:",caption,"===",mtoc;
end

View File

@ -517,7 +517,6 @@ type tapplication=class(tcomponent)
end
function Notification(a,op);override;
begin
inherited;
if op=opRecycling then
begin
if a=Fmainform then
@ -529,6 +528,7 @@ type tapplication=class(tcomponent)
FApplicationWindow := nil;
end
end
inherited;
end
function createform(classname,varable);
begin
@ -3279,11 +3279,11 @@ type TPairSplitter=class(tcustomcontrol) //
end
function Notification(AComponent,Operation);override;
begin
inherited;
if Operation=opRemove then
begin
RemoveSide(AComponent);
end
inherited;
end
function DoControlAlign();override;
begin

View File

@ -105,7 +105,6 @@ type TBasicAction=class(TComponent)
end
function Notification(AComponent,Operation);override;
begin
inherited;
if Operation=opRecycling and AComponent=FActionComponent then //opRemove
begin
FActionComponent := nil;
@ -114,6 +113,7 @@ type TBasicAction=class(TComponent)
FParent.DeleteAction(self);
end
end
inherited;
end
function SetActionComponent(Value);
begin
@ -331,11 +331,11 @@ type TCustomactionlist=class(TComponent)
end
function Notification(AComponent,Operation);override;
begin
inherited;
if Operation=opRecycling and AComponent=FActionComponent then //opRemove
begin
DeleteAllActions();
end
inherited;
end
function Recycling();override;
begin

View File

@ -40,8 +40,22 @@ function DeleteAllFiles(path);
function CreateDirWithFileName(fname);
function TS_GetUserProfileHome();
function gettslexefullpath();
type tuiglobaldata=class
type tpossizenote = class()
function create(c,l,t,w,h);
begin
ch := c;
left := l;
top := t;
width := w;
height := h;
end
ch;
left;
top;
width;
height;
end
type tuiglobaldata=class()
static UIData;
class Function uisetdata(n,d);
begin
@ -60,7 +74,7 @@ type tuiglobaldata=class
if not ifarray(UIData)then UIData := array();
end
end
type TCharDiscrimi=class
type TCharDiscrimi=class()
static CD_SMA;
static CD_BGA;
static CD_SMZ;

View File

@ -486,10 +486,13 @@ end
type tmacroconst=class(_commctrldef_,_tvclmsageid_,_shellapi_)
class function sinit();virtual;
begin
if tmacroconstinit then return ;
class(_commctrldef_).sinit();
class(_tvclmsageid_).sinit();
class(_shellapi_).sinit();
tmacroconstinit := true;
end
static tmacroconstinit;
end
type tconstant = class(talign,TAnchorKind,TFormStyle,TComponentState,
TComponentStyle,TOperation,TWinControlFlag,
@ -511,6 +514,7 @@ type TSLUICONST=class(tmacroconst,tconstant)
static WM_TRAY;
class function sinit();override;
begin
if WM_TRAY>0 then return ;
class(tmacroconst).sinit();
opRemove := "opRemove-";//ÒÆ³ý²Ù×÷
opInsert := "opInsert+";//²åÈë
@ -5946,6 +5950,6 @@ end
}
initialization
class(TSLUICONST).sinit();
class(tenumeration).initenumeration(new tconstant());
class(TSLUICONST).sinit();
end.

View File

@ -35,9 +35,8 @@ type tcustomcoolbar=class(tcustomcontrol)
end
function Notification(o,op);override;
begin
r := inherited;
if class(tcoolbarlocker).haslocker then return r;
if (o is class(TWinControl)) and o.WsPopUp then return r;
if class(tcoolbarlocker).haslocker then return ;
if (o is class(TWinControl)) and o.WsPopUp then return ;
if HandleAllocated() and ifarray(op) and (op["type"]="possize") then //位置大小发送变化
begin
ctls := controls;
@ -45,10 +44,10 @@ type tcustomcoolbar=class(tcustomcontrol)
begin
doControlALign();
InvalidateRect(nil,false);
return r;
return ;
end
end
return r;
inherited;
end
function WMLBUTTONUP(o,e);override;//拖拽实现
begin

View File

@ -471,11 +471,11 @@ private
end
function Notification(AComponent:TComponent;Operation:TOperation);override;
begin
inherited;
if Operation=opRecycling then //opRemove
begin
if AComponent=Action then Action := nil;
end
inherited;
end
class function sinit();override;
begin

View File

@ -3843,7 +3843,6 @@ type TCustomComboBoxbase=class(TCustomControl)
function Create(AOwner);override;
begin
inherited;
end
function AfterConstruction();override;
begin
@ -3918,7 +3917,7 @@ type TCustomComboBoxbase=class(TCustomControl)
inherited;
end
published
property ItemIndex:lazyinteger read GetItemIndex write SetItemIndex;
property ItemIndex:lazytsl read GetItemIndex write SetItemIndex;
property OnSelchanged:eventhandler read FOnSelchanged write FOnSelchanged;
property ondropdown:eventhandler read Fondropdown write Fondropdown;
property oncloseup:eventhandler read Foncloseup write Foncloseup;
@ -3947,7 +3946,7 @@ type TCustomComboBoxbase=class(TCustomControl)
**}
if not(FListBox is class(TWinControl))then return;
rc := ClientRect;
FListbox.height := FListBox.ItemHeight * (min(max(0,FListBox.ItemCount),FmaxListItemShow))+10;
FListbox.height := getlistitemheight()* (min(max(0,getlistitemcount()),FmaxListItemShow))+10;
nrc := ClientToScreen(rc[0],rc[3]);
if FScreenRect[3]-nrc[1]<250 then
begin
@ -3970,7 +3969,7 @@ type TCustomComboBoxbase=class(TCustomControl)
Fondropdown; //下拉
Foncloseup; //收起
FBtnWidth;
function SetmaxListItemShow(v);
function SetmaxListItemShow(v);//显示项目数量
begin
if v>0 then
begin
@ -3981,7 +3980,7 @@ type TCustomComboBoxbase=class(TCustomControl)
end
end
end
function SetBtnWidth(n);
function SetBtnWidth(n);//按钮宽度
begin
if not(n>10 and n<100)then return;
nn := int(n);
@ -3992,10 +3991,18 @@ type TCustomComboBoxbase=class(TCustomControl)
DoControlAlign();
end
end
function GetItemIndex();virtual;
function getlistitemcount();virtual; //获得项目
begin
return FListBox.ItemCount;
end
function getlistitemheight();virtual; //获得项目高
begin
return FListBox.ItemHeight;
end
function GetItemIndex();virtual;//获得选中的序号
begin
end
function SetItemIndex();virtual;
function SetItemIndex();virtual;//设置选中的序号
begin
end
end
@ -4240,12 +4247,12 @@ type TcustomComboBox=class(TCustomComboBoxbase)
end
function GetItemIndex();override;
begin
if FMultisel and (csDesigning in ComponentState) then return -1;
//if FMultisel and (csDesigning in ComponentState) then return -1;
return FListBox.GetCurrentSelection();
end
function SetItemIndex(idx);override;
begin
if FMultisel and (csDesigning in ComponentState) then return -1;
//if FMultisel and (csDesigning in ComponentState) then return -1;
return FListBox.SetCurrentSelection(idx);
end
feditischanging;//改变正在回调
@ -5467,7 +5474,6 @@ type TCustomSpinEdit = class(TCustomControl)
begin
FValue := r;
end
return FValue;
end
procedure SetValue(const AValue:Double);virtual;
@ -5590,7 +5596,6 @@ type TCustomSpinEdit = class(TCustomControl)
fedit := nil;
inherited;
end
function DoControlAlign(rect);override;
begin
rect := ClientRect;
@ -5812,7 +5817,8 @@ type tcustomprogressbar=class(TCustomControl)
dc.brush.color := FbarColor;
dc.FillRect(br);
end
function increaseByStep();begin
function increaseByStep();
begin
{**
@explan(说明)按照步增量移动进度条当前的位置,当其超过限度则设置位置至下限以便于从头重新开始%%
@return(integer)先前的位置,出错返回-1%%
@ -5826,7 +5832,8 @@ type tcustomprogressbar=class(TCustomControl)
InvalidateRect(nil,false);
return r;
end
function increaseBySpecifiedIncrement(n);begin
function increaseBySpecifiedIncrement(n);
begin
{**
@explan(说明)进度条移动指定长度,当其超过限度则设置位置至该限度%%
@param(n)(integer)增长的数量%%
@ -5887,7 +5894,8 @@ type tcustomprogressbar=class(TCustomControl)
return not (n.&0xFFFFFFFFFF000000);
else return 0;
end
function setRange(l,h);begin
function setRange(l,h);
begin
{**
@explan(说明)设置进度栏的上下限,要求上限高于下限且皆非负%%
@param(l)(integer)下限%%
@ -5905,7 +5913,8 @@ type tcustomprogressbar=class(TCustomControl)
end
end
function setRangeA(arr);begin
function setRangeA(arr);
begin
return setRange(arr[0],arr[1]);
end
function setPosition(n);
@ -5923,7 +5932,8 @@ type tcustomprogressbar=class(TCustomControl)
end
return r;
end
function setStep(n);begin
function setStep(n);
begin
{**
@explan(说明)设置进度栏步增量%%
@param(n)(integer)要设置的值%%

View File

@ -1035,7 +1035,7 @@ type TPropertyType=class
@explan(说明) 是否为延迟设置属性%%
@return(bool)
**}
return false;
return Fislazy;
end
function IfComponent();virtual;
begin
@ -1045,6 +1045,9 @@ type TPropertyType=class
return false;
end
property TmfParser:TTmfParser read Gettfmparser;
property islazy read Fislazy write Fislazy; //ÊÇ·ñºóÌì¾ÍÊý¾Ý
private
Fislazy;
end
type TPropertyNatural=class(TPropertyType) //自然数
function EditType();override;
@ -1907,6 +1910,59 @@ type TPropertyText=class(TPropertyString)
return tostn(d);
end
end
type tpropertytsl=class(TPropertyType)
Function EditType();override;
begin
return "tsl";
end
function TmfToNode(d);override;
begin
if ifstring(d)then
begin
r := HexFormatStrToTsl(d);
return r;
end
end
function FormatTMF(d);override;
begin
if datanotok(d) then return "";
reti := TSlToHexFormatStr(d);
ret := "{ ";
ret += reti;
ret += " }";
return ret;
end
function ReadTMF(d,o);override;
begin
if d and ifstring(d) then
begin
return HexFormatStrToTsl(d);
end
end
private
function datanotok(d);//
begin
if ifobj(d) then return true;
if ifarray(d) then
begin
for i ,v in d do
begin
if (datanotok(v)) then return true;
end
end
return false;
end
end
type tpropertylazytsl = class(tpropertytsl)
Function EditType();override;
begin
return "lazytsl";
end
function LazyProperty();override;
begin
return true;
end
end
type TPropertyStrings=class(TPropertyType)
function EditType();override;
begin
@ -2345,6 +2401,8 @@ begin
"tpropertytabalign",
"tpropertytext",
"tpropertystrings",
"tpropertytsl",
"tpropertylazytsl",
"tpropertyesalign",
"tpropertymbbtnstyle",
"tpropertymbicostyle",