界面库

popupmenu 以及coolbar
This commit is contained in:
JianjunLiu 2022-08-30 01:34:14 +08:00
parent fad69fa5e4
commit 8f64b3363f
7 changed files with 63 additions and 29 deletions

View File

@ -1685,11 +1685,12 @@ type TVclDesigner = class(tvcform)
v[0].SetComponentProperties(v[1],va.GetTrueComponent()); v[0].SetComponentProperties(v[1],va.GetTrueComponent());
end end
end end
except except
end ; end ;
FTree.Loading := nil; FTree.Loading := nil;
end end
function loadtfmtotree(p,d,node,owner,prs,obarray); function loadtfmtotree(p,d,node,wr,prs,obarray);
begin begin
{** {**
@explan(说明) 导入tfm文件 %% @explan(说明) 导入tfm文件 %%
@ -1712,7 +1713,7 @@ type TVclDesigner = class(tvcform)
it.Imgs := FImageList.GetImageId("tdcreateform"); it.Imgs := FImageList.GetImageId("tdcreateform");
FLoadInheritedName := array(); FLoadInheritedName := array();
end end
comp := it.ComponentCreater(node,owner); comp := it.ComponentCreater(node,wr);
comp.name := d["name"]; comp.name := d["name"];
obarray[d["name"]] := comp; obarray[d["name"]] := comp;
FVariableSelecter.additem(comp); FVariableSelecter.additem(comp);

View File

@ -695,7 +695,7 @@ type tcontrol = class(tcomponent)
@param(e)(tuieventbase) ÏûÏ¢ %% @param(e)(tuieventbase) ÏûÏ¢ %%
**} **}
if e.Result then exit; if e.Result then exit;
if FPopupMenu is class(TcustomPopupmenu) then if FPopupMenu is class({TcustomPopupmenu}TcustomMenu) then
begin begin
uf := TPM_LEFTALIGN .| TPM_TOPALIGN .| TPM_RIGHTBUTTON; uf := TPM_LEFTALIGN .| TPM_TOPALIGN .| TPM_RIGHTBUTTON;
_wapi.TrackPopupMenu(FPopupMenu.Handle,uf,e.lolparamsigned,e.hilparamsigned,0,e.wparam,nil); _wapi.TrackPopupMenu(FPopupMenu.Handle,uf,e.lolparamsigned,e.hilparamsigned,0,e.wparam,nil);

View File

@ -1010,7 +1010,7 @@ type TTray=class(TComponent)
function ShowPopUpMenu(); function ShowPopUpMenu();
begin begin
if not FHaveadd then exit; if not FHaveadd then exit;
if FPopupMenu is class(TcustomPopupmenu)then if FPopupMenu is class({TcustomPopupmenu}TcustomMenu)then
begin begin
ps := array(x,y); ps := array(x,y);
_wapi.GetCursorPos(ps); _wapi.GetCursorPos(ps);
@ -1112,7 +1112,7 @@ type TVCForm = class(TScrollingWinControl)
if(FTray is class(TTray))then if(FTray is class(TTray))then
begin begin
tp := FTray.PopupMenu; tp := FTray.PopupMenu;
if tp is class(TcustomPopupmenu)then if tp is class({TcustomPopupmenu}TcustomMenu)then
begin begin
return tp; return tp;
end end
@ -2490,7 +2490,7 @@ type tcoolbar = class(tcustomcoolbar)
end end
function publishs();override; function publishs();override;
begin begin
return array("name","enabled","caption","autosize","border","font","color","dragbtncolor","visible","arrange"); return array("name","enabled","caption","autosize","border","wsdlgmodalframe","font","color","dragbtncolor","visible","arrange");
end end
end end

View File

@ -937,15 +937,15 @@ type TWinControl = class(tcontrol)
end end
function WMMENURBUTTONUP(o,e):WM_MENURBUTTONUP;virtual; function WMMENURBUTTONUP(o,e):WM_MENURBUTTONUP;virtual;
begin begin
if PopupMenu is class(TcustomPopupmenu)then PopupMenu.dispatch(e); if PopupMenu is class({TcustomPopupmenu}TcustomMenu)then PopupMenu.dispatch(e);
end end
function WMMENUSELECT(o,e):WM_MENUSELECT;virtual; function WMMENUSELECT(o,e):WM_MENUSELECT;virtual;
begin begin
if PopupMenu is class(TcustomPopupmenu)then PopupMenu.dispatch(e); if PopupMenu is class({TcustomPopupmenu}TcustomMenu)then PopupMenu.dispatch(e);
end end
function WMINITMENUPOPUP(o,e):WM_INITMENUPOPUP;virtual; function WMINITMENUPOPUP(o,e):WM_INITMENUPOPUP;virtual;
begin begin
if PopupMenu is class(TcustomPopupmenu)then PopupMenu.dispatch(e); if PopupMenu is class({TcustomPopupmenu}TcustomMenu)then PopupMenu.dispatch(e);
end end
function WMERASEBKGND(o,e):WM_ERASEBKGND;override; function WMERASEBKGND(o,e):WM_ERASEBKGND;override;
begin begin
@ -998,7 +998,7 @@ type TWinControl = class(tcontrol)
//dc := _wapi.GetDC(SELF.hANDLE); //dc := _wapi.GetDC(SELF.hANDLE);
//dcid := _wapi.SaveDC(dc); //dcid := _wapi.SaveDC(dc);
canvas.handle := dc; canvas.handle := dc;
if(e.wparam=0)and(PopupMenu is class(TcustomPopupmenu))then if(e.wparam=0)and(PopupMenu is class({TcustomPopupmenu}TcustomMenu))then
begin begin
r := PopupMenu.dispatch(e); r := PopupMenu.dispatch(e);
if r then if r then
@ -1032,7 +1032,7 @@ type TWinControl = class(tcontrol)
@param(o)()¿Ø¼þ±¾Éí %% @param(o)()¿Ø¼þ±¾Éí %%
@param(e)(TMMEASUREITEM)²âÁ¿ÏûÏ¢ %% @param(e)(TMMEASUREITEM)²âÁ¿ÏûÏ¢ %%
**} **}
if(e.wparam=0 and e.ctltype=ODT_MENU)and(PopupMenu is class(TcustomPopupmenu))and PopupMenu.Dispatch(e)then exit; if(e.wparam=0 and e.ctltype=ODT_MENU)and(PopupMenu is class({TcustomPopupmenu}TcustomMenu))and PopupMenu.Dispatch(e)then exit;
for i := 0 to FControls.count-1 do for i := 0 to FControls.count-1 do
begin begin
it := FControls[i]; it := FControls[i];
@ -1090,7 +1090,7 @@ type TWinControl = class(tcontrol)
end end
function WMCOMMAND(o,e):WM_COMMAND;virtual; function WMCOMMAND(o,e):WM_COMMAND;virtual;
begin begin
if(popupmenu is class(TcustomPopupmenu))and popupmenu.dispatch(e)then exit; if(popupmenu is class({TcustomPopupmenu}TcustomMenu))and popupmenu.dispatch(e)then exit;
hd := e.lparam; hd := e.lparam;
if hd then if hd then
begin begin

View File

@ -163,6 +163,7 @@ type tcustomcoolbar=class(tcustomcontrol)
end end
function doControlALign();override;//µ÷ÕûλÖà function doControlALign();override;//µ÷ÕûλÖÃ
begin begin
if not HandleAllocated() then return ;
mwid := 10; mwid := 10;
swid := 10; swid := 10;
y := 0; y := 0;
@ -176,7 +177,16 @@ type tcustomcoolbar=class(tcustomcontrol)
if abs(dh)>4 then if abs(dh)>4 then
begin begin
Align := alNone; Align := alNone;
Height := (border*2)+nh; {if WSSizebox then
begin
bw := 16;
end else
if WsDlgModalFrame then
begin
bw := 6;
end else}
if Border then bw := 2;
Height := bw+nh;
Align := alTop; Align := alTop;
return ; return ;
end end

View File

@ -4116,7 +4116,7 @@ type TcustomToolButton=class(tcomponent)
if FStylesep then return ; if FStylesep then return ;
if Parent then if Parent then
begin begin
if FPopupMenu is class(TcustomPopupmenu) then if FPopupMenu is class({TcustomPopupmenu}TcustomMenu) then
begin begin
Parent.PopupMenu := FPopupMenu; Parent.PopupMenu := FPopupMenu;
rec := GetRect(); rec := GetRect();
@ -4188,7 +4188,10 @@ type TcustomToolButton=class(tcomponent)
if nv<>FStylesep then if nv<>FStylesep then
begin begin
FStylesep := nv; FStylesep := nv;
if FToolbar then FToolbar.BtnChanged(); if FToolbar then
begin
FToolbar.ExecuteCommand("btnchanged",0);
end
end end
end end
function getShortCut(); function getShortCut();
@ -4247,7 +4250,10 @@ type TcustomToolButton=class(tcomponent)
if nv <> FEnabled then if nv <> FEnabled then
begin begin
FEnabled := nv; FEnabled := nv;
if FToolbar then FToolbar.BtnChanged(); if FToolbar then
begin
FToolbar.ExecuteCommand("btnchanged",0);
end
end end
end end
function SetVisible(v); function SetVisible(v);
@ -4256,7 +4262,10 @@ type TcustomToolButton=class(tcomponent)
if nv <> FVisible then if nv <> FVisible then
begin begin
FVisible := nv; FVisible := nv;
if FToolbar then FToolbar.BtnChanged(); if FToolbar then
begin
FToolbar.ExecuteCommand("btnchanged",0);
end
end end
end end
protected //action protected //action
@ -4316,7 +4325,10 @@ type TcustomToolButton=class(tcomponent)
if ifnumber(id)and id <> FImageId then if ifnumber(id)and id <> FImageId then
begin begin
FImageId := id; //Ë¢ÐÂһϠFImageId := id; //Ë¢ÐÂÒ»ÏÂ
if FToolbar then FToolbar.BtnChanged(); //FToolbar.InvalidateRect(nil,false); if FToolbar then
begin
FToolbar.ExecuteCommand("btnchanged",0);
end
end end
end end
private private
@ -4369,10 +4381,14 @@ type TcustomToolBar=class(TCustomControl)
end end
end end
end end
{function ContextMenu(o,e);override; function ContextMenu(o,e);override;
begin begin
if csDesigning in ComponentState then
begin
return inherited;
end
e.skip := true; e.skip := true;
end } end
function MouseUp(o,e);override; function MouseUp(o,e);override;
begin begin
if csDesigning in ComponentState then return; if csDesigning in ComponentState then return;
@ -4447,7 +4463,7 @@ type TcustomToolBar=class(TCustomControl)
begin begin
bt := FButtons[idx]; bt := FButtons[idx];
st := bt.ShortCut; st := bt.ShortCut;
if bt.PopupMenu is class(TcustomPopupmenu) then s1 := bt.PopupMenu.Caption; if bt.PopupMenu is class({TcustomPopupmenu}TcustomMenu) then s1 := bt.PopupMenu.Caption;
else s1 := bt.Caption; else s1 := bt.Caption;
FTipWnd.Tip := s1+(st?(" ("+st+")"):""); FTipWnd.Tip := s1+(st?(" ("+st+")"):"");
FTipWnd.ShowTIp(); FTipWnd.ShowTIp();
@ -4743,10 +4759,17 @@ type TcustomToolBar=class(TCustomControl)
FCurrentPos := nil; FCurrentPos := nil;
FMouseDownIdx :=-1; FMouseDownIdx :=-1;
end end
function BtnChanged(); function ExecuteCommand(cmd,pm);override;
begin
case cmd of
"btnchanged":
begin begin
CalcButtonsRect(); CalcButtonsRect();
InvalidateRect(nil,false); InvalidateRect(nil,false);
return 0;
end
end ;
return inherited;
end end
protected protected
procedure SetAlign(Value:TAlign);override; procedure SetAlign(Value:TAlign);override;
@ -4784,8 +4807,8 @@ type TcustomToolBar=class(TCustomControl)
return; return;
end end
imglst := ImageList; //ͼ±ê imglst := ImageList; //ͼ±ê
imgw := 36; imgw := 28;
imgh := 36; imgh := 28;
if imglst is class(TCustomImageList)then if imglst is class(TCustomImageList)then
begin begin
imgw := imglst.Width+4; imgw := imglst.Width+4;