界面库

代码整理
This commit is contained in:
JianjunLiu 2022-11-01 14:40:24 +08:00
parent fe6e2c7eae
commit e855fce170
4 changed files with 49 additions and 62 deletions

View File

@ -85,9 +85,6 @@ type tcontrol = class(tcomponent)
//FMouseEntered;//: boolean;
FVisible;//: Boolean; //可见
FID; //id
FOnMeasureItem;
FOnDrawItem;
#!end
//位置信息
FLeft:integer; //左边
@ -342,6 +339,15 @@ type tcontrol = class(tcomponent)
bindmessage(i,findfunction(v,o));
end
end
function preparesetparent(np);
begin
if (np is getparenttype()) then
begin
if not CheckNewParent(np) then return ;
if not np.checknewchild(self(true)) then return ;
end
SetParent(np);
end
protected //部分属性设置
function GetControlFont();virtual;
begin
@ -496,7 +502,7 @@ type tcontrol = class(tcomponent)
@explan(说明) 子控件删除 %%
**}
end
function operatectrl(actrl,op);virtual; //控件操作通知
function operatectrl(actrl,op); //控件操作通知
begin
idx := FControls.indexof(actrl);
if op=opRemove then
@ -689,36 +695,6 @@ type tcontrol = class(tcomponent)
begin
DoCNCOMMAND(o,e);
end
function CNMEASUREITEM(o,e):CN_MEASUREITEM;virtual;
begin
CallMessgeFunction(FOnMeasureItem,o,e);
DoMeasureItem(o,e);
end
function DoMeasureItem(o,e);virtual;
begin
{**
@explan(说明) 控件测量通知消息 %%
@param(o)(TWinControl) 控件自身 %%
@param(e)(TMMEASUREITEM) 消息 %%
**}
end
function CNDRAWITEM(o,e):CN_DRAWITEM;virtual;
begin
//tb := new tbrush();
//tbh := tb.handle;
//odh := _wapi.SelectObject(canvas.Handle,tbh);
DoDrawItem(o,e);
//_wapi.SelectObject(canvas.Handle,odh);
end
function DoDrawItem(o,e);virtual;
begin
{
@explan(说明) 控件绘制通知消息 %%
@param(o)(TWinControl) 控件自身 %%
@param(e)(TMDRAWITEM) 消息 %%
}
CallMessgeFunction(FOnDrawItem,o,e);
end
function DoMouseEnter(o,e);virtual;
begin
{
@ -993,8 +969,6 @@ type tcontrol = class(tcomponent)
CallMessgeFunction(OnSize,o,e);
DoWMSIZE(o,e);
end
function CMCursorChanged(o,e):CM_CURSORCHANGED;virtual;
begin
//if SetTempCursor(o.Cursor) then e.skip := true;
@ -1166,15 +1140,22 @@ type tcontrol = class(tcomponent)
FCursor := new tcustomcursor();
FCursor.id := IDC_ARROW;
end
procedure CheckNewParent(AParent:TWinControl);virtual; //检查parent
function checknewparent(AParent:TWinControl);virtual; //检查parent
begin
{
@ignore(忽略)
@explan(说明) 判断是否可以作为父节点
@explan(说明) 判断是否可以作为当前类型的父节点 %%
@return(bool)
}
return(AParent is getparenttype()) ;//and AParent.IsContainer(self(true));
return false;
return true;
end
function checknewchild(achild);virtual;//检查child
begin
{
@explan(说明) 判断是否可以作为当前类型的子节点 %%
@return(bool)
}
return true;
end
function Recycling();override; //销毁处理
begin
{**
@ -1281,10 +1262,6 @@ type tcontrol = class(tcomponent)
begin
//if Dragging() then DragManager.DragStop(Drop);
end
function getmessagehandle(id);virtual;
begin
if ifnumber(id)and FMessagehandle then return FMessagehandle[id];
end
function dispatch(o,e);virtual; //分发消息
begin
{**
@ -1292,8 +1269,12 @@ type tcontrol = class(tcomponent)
@param(o)()控件自身 %%
@param(e)(tuieventbase) 消息类及其子类 %%
**}
func := getmessagehandle(e.Msg);
if func then call(func,o,e);
id := e.Msg;
if ifnumber(id) and FMessagehandle then
begin
func := FMessagehandle[id];
if func then call(func,o,e);
end
end
procedure DoControlAlign();virtual;//调整子控件位置
begin
@ -1491,7 +1472,7 @@ type tcontrol = class(tcomponent)
property OnDblClick:eventhandler read FOnDblClick write FOnDblClick;
//property OnResize read FOnResize write FOnResize;
property OnShowHint read FOnShowHint write FOnShowHint;
property Parent read FParent write SetParent;
property Parent read FParent write preparesetparent;
property PopupMenu:tpopupmenu read FPopupMenu write FPopupMenu{read GetPopupmenu write SetPopupMenu};
//property ShowHint read FShowHint write SetShowHint ;
property Visible:bool read FVisible write SetVisible ;
@ -1507,16 +1488,14 @@ type tcontrol = class(tcomponent)
@param(Height)(integer) 高度 %%
@param(Width)(integer) 宽度 %%
@param(Zorder)(integer) 设置控件在父窗口的次序,最底层为 0 %%
@param(Top)() 上方位置 %%
@param(Left)() 左边 %%
@param(Top)(integer) 上方位置 %%
@param(Left)(integer) 左边 %%
**}
property BoundsRect read GetBoundsRect write SetBoundsRect;
property Zorder read GetZorder write SetZorder;
property ControlState: TControlState read FControlState write FControlState;
property Color:color read getcolor write SetColor;//FColor;
property BKBitmap:tbitmap read FBKBitmap write SetBitmap;
property OnMeasureItem read FOnMeasureItem write FOnMeasureItem;
property OnDrawItem read FOnDrawItem write FOnDrawItem;
//property OnMouseEnter:eventhandler read FOnMouseEnter write FOnMouseEnter;
//property OnMouseLeave:eventhandler read FOnMouseLeave write FOnMouseLeave;
property Controls read FControls;
@ -1526,8 +1505,6 @@ type tcontrol = class(tcomponent)
@param(Controls)(TFpList of tcontrol) 子组件 %%
@param(OnMouseLeave)(function[TControl,tuieventbase]) 鼠标离开回调 %%
@param(OnMouseEnter)(function[TControl,tuieventbase]) 鼠标进入回调 %%
@param(OnMeasureItem)(function[TControl,TMMEASUREITEM]) 控件测量回调 %%
@param(OnDrawItem)(function[TControl,TMDRAWITEM]) 控件绘制回调 %%
@param(Color)(integer) 背景色 %%
**}
function isCustomPaint(); //提供给gtk使用

View File

@ -3021,7 +3021,7 @@ type TPairSplitterSide=class(TCustomControl)
oldparent.RemoveSide(self);
end
inherited;
parent.AddSide(self);
parent.AddSide(self(true));
end else
if not(p is class(TWincontrol))then
begin

View File

@ -1961,9 +1961,10 @@ type TWinControl = class(tcontrol)
end
function SetParent(NewParent);override; //type_twinctrol
begin
ih := HandleAllocated();
if(NewParent=parent)and(NewParent is class(TWinControl))then //避免wrapcontrol句柄发生改变的问题
begin
if HandleAllocated()and NewParent.HandleAllocated()then
if ih and NewParent.HandleAllocated()then
begin
if _wapi.GetParent(self.Handle)=NewParent.Handle then return;
end
@ -1974,7 +1975,8 @@ type TWinControl = class(tcontrol)
//都有句柄
callparent := false;
callalocate := false;
if HandleAllocated()and NewParent.HandleAllocated()then
ph := NewParent.HandleAllocated();
if ih and ph then
begin
if WsPopUp then
begin
@ -1983,12 +1985,12 @@ type TWinControl = class(tcontrol)
end else
if _wapi.SetParent(FHandle,NewParent.handle)then callparent := true;
end else
if HandleAllocated()and not(NewParent.HandleAllocated())then
if ih and not(ph)then
begin
DestroyHandle();
callparent := true;
end else
if not(HandleAllocated())and NewParent.HandleAllocated()then
if not(ih)and ph then
begin
callparent := true;
callalocate := true;
@ -1997,8 +1999,8 @@ type TWinControl = class(tcontrol)
callparent := true;
end
if callparent then
begin
class(tcontrol).SetParent(NewParent);
begin
inherited SetParent(NewParent);//class(tcontrol).SetParent(NewParent);
if Align <> alNone then
begin
NewParent.DoControlAlign();
@ -2007,7 +2009,7 @@ type TWinControl = class(tcontrol)
if callalocate then HandleNeeded();
end else
begin
if HandleAllocated()then DestroyHandle();
if ih then DestroyHandle();
inherited SetParent(NewParent);
end
end

View File

@ -572,6 +572,14 @@ type tcustompagecontrol = class(TCustomControl)
(AIndexnew<FTabItems.length()) then
begin
FTabItems.swap(AIndex,AIndexnew);
if FCurrentid = AIndex then
begin
FCurrentid := AIndexnew;
end else
if FCurrentid = AIndexnew then
begin
FCurrentid := AIndex;
end
CalcTabs();
InvalidateRect(nil,false);
end