界面库

加入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(说明) 设计器属性编辑库,继承该库,定义属性编辑类 %% @explan(说明) 设计器属性编辑库,继承该库,定义属性编辑类 %%
**} **}
uses utslvclauxiliary,utslvclbase,utslvclgdi,uvcpropertytypespersistence,tslvcl,utslvcldcomponents; uses utslvclauxiliary,utslvclbase,utslvclgdi,uvcpropertytypespersistence,tslvcl,utslvcldcomponents,UTslSynMemo;
function registereditpropertytodesigner(cls); function registereditpropertytodesigner(cls);
type TGCellRender = class(TSLUIBASE) //属性编辑器单元格对象基类 type TGCellRender = class(TSLUIBASE) //属性编辑器单元格对象基类
{** {**
@ -1464,15 +1464,8 @@ type TGridList = class(TListView)
end end
end end
//**********属性编辑类*************** //**********属性编辑类***************
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
type TGridCellNaturalEdit = class(TGridPropertyRender,TPropertyNatural) type TGridCellNaturalEdit = class(TGridPropertyRender,TPropertyNatural)
@ -3478,6 +3471,7 @@ type TtextEditor = class(tpanel)
property ItemStr read GetItemStr write SetItemStr; property ItemStr read GetItemStr write SetItemStr;
end end
type TGridCellTextEdit = class(TGridCellEditWithButton,TPropertyText) type TGridCellTextEdit = class(TGridCellEditWithButton,TPropertyText)
{** {**
@explan(说明)编辑字符串文本属性%% @explan(说明)编辑字符串文本属性%%
@ -3590,6 +3584,188 @@ type TGridCellStringsEdit = class(TGridCellTextEdit)
inherited; inherited;
end end
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) type TstringsEditor = class(TtextEditor)
{** {**
@explan(说明)memo编辑器%% @explan(说明)memo编辑器%%
@ -4309,7 +4485,11 @@ begin
class(TGridCellPairIntEdit), class(TGridCellPairIntEdit),
class(TGridCellPairSpliterTypeEdit), class(TGridCellPairSpliterTypeEdit),
class(tGridCellAlignPosBoxEdit), class(tGridCellAlignPosBoxEdit),
class(TGridCellTreeViewDataEdit) class(TGridCellTreeViewDataEdit),
class(TGridCelltslEdit),
class(TGridCelllazytslEdit)
)); ));
registerproperties(psi); registerproperties(psi);
end end

View File

@ -218,6 +218,7 @@ public //֪ͨ
@param(AComponent)(tcomponent) 改变的对象 %% @param(AComponent)(tcomponent) 改变的对象 %%
@param(Operation)(member of TOperation) 通知码 %% @param(Operation)(member of TOperation) 通知码 %%
**} **}
if dosendrenote(AComponent,Operation) then return ;
If(Operation=opRemove)then If(Operation=opRemove)then
begin begin
RemoveFreeNotification(AComponent); RemoveFreeNotification(AComponent);
@ -231,6 +232,17 @@ public //֪ͨ
end; end;
end; end;
private 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); //设置设计状态 Procedure SetDesignInstance(Value); //设置设计状态
begin begin
If Value then If Value then

View File

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

View File

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

View File

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

View File

@ -40,8 +40,22 @@ function DeleteAllFiles(path);
function CreateDirWithFileName(fname); function CreateDirWithFileName(fname);
function TS_GetUserProfileHome(); function TS_GetUserProfileHome();
function gettslexefullpath(); function gettslexefullpath();
type tpossizenote = class()
type tuiglobaldata=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; static UIData;
class Function uisetdata(n,d); class Function uisetdata(n,d);
begin begin
@ -60,7 +74,7 @@ type tuiglobaldata=class
if not ifarray(UIData)then UIData := array(); if not ifarray(UIData)then UIData := array();
end end
end end
type TCharDiscrimi=class type TCharDiscrimi=class()
static CD_SMA; static CD_SMA;
static CD_BGA; static CD_BGA;
static CD_SMZ; static CD_SMZ;

View File

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

View File

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

View File

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

View File

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

View File

@ -1035,7 +1035,7 @@ type TPropertyType=class
@explan(说明) 是否为延迟设置属性%% @explan(说明) 是否为延迟设置属性%%
@return(bool) @return(bool)
**} **}
return false; return Fislazy;
end end
function IfComponent();virtual; function IfComponent();virtual;
begin begin
@ -1045,6 +1045,9 @@ type TPropertyType=class
return false; return false;
end end
property TmfParser:TTmfParser read Gettfmparser; property TmfParser:TTmfParser read Gettfmparser;
property islazy read Fislazy write Fislazy; //ÊÇ·ñºóÌì¾ÍÊý¾Ý
private
Fislazy;
end end
type TPropertyNatural=class(TPropertyType) //自然数 type TPropertyNatural=class(TPropertyType) //自然数
function EditType();override; function EditType();override;
@ -1907,6 +1910,59 @@ type TPropertyText=class(TPropertyString)
return tostn(d); return tostn(d);
end end
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) type TPropertyStrings=class(TPropertyType)
function EditType();override; function EditType();override;
begin begin
@ -2345,6 +2401,8 @@ begin
"tpropertytabalign", "tpropertytabalign",
"tpropertytext", "tpropertytext",
"tpropertystrings", "tpropertystrings",
"tpropertytsl",
"tpropertylazytsl",
"tpropertyesalign", "tpropertyesalign",
"tpropertymbbtnstyle", "tpropertymbbtnstyle",
"tpropertymbicostyle", "tpropertymbicostyle",