📄 teecomma.pas
字号:
if not( csDestroying in ComponentState) then
for t:=0 to ControlCount-1 do
if Controls[t].Owner=Self then Controls[t].Enabled:=Value;
end;
Procedure TCustomTeeCommander.ReAlignTeeControls;
var t : Integer;
tmpPos : Integer;
begin
tmpPos:=4;
for t:=0 to ControlCount-1 do
if Controls[t].Owner=Self then
begin
With Controls[t] do
begin
if FVertical then
begin
Left:=4;
Top:=tmpPos;
end
else
begin
Left:=tmpPos;
Top:=4;
end;
end;
if Controls[t] is TBevel then
begin
Inc(tmpPos,4+2);
with Controls[t] as TBevel do
if FVertical then
begin
Shape:=bsTopLine;
Width:=Self.Width-2*4;
Height:=2;
end
else
begin
Shape:=bsLeftLine;
Width:=2;
Height:=Self.Height-2*4;
end;
end
else Inc(tmpPos,25+4);
end;
end;
procedure TCustomTeeCommander.SetVertical(Value:Boolean);
begin
if FVertical<>Value then
begin
FVertical:=Value;
if Align<>alNone then
if FVertical then Align:=alLeft
else Align:=alTop;
ReAlignTeeControls;
end;
end;
{$IFNDEF CLR}
type
TTeePanelAccess=class(TCustomTeePanel);
{$ENDIF}
procedure TCustomTeeCommander.SetPanel(const Value: TCustomTeePanel);
begin
if Assigned(FPanel) then
begin
{$IFDEF D5}
FPanel.RemoveFreeNotification(Self);
{$ENDIF}
{$IFNDEF CLR}TTeePanelAccess{$ENDIF}(FPanel).RemoveListener(Self);
end;
FPanel:=Value;
if Assigned(FPanel) then
begin
FPanel.FreeNotification(Self);
if Assigned({$IFNDEF CLR}TTeePanelAccess{$ENDIF}(FPanel).Listeners) then { 5.01 }
{$IFNDEF CLR}TTeePanelAccess{$ENDIF}(FPanel).Listeners.Add(Self);
end;
if not (csDestroying in ComponentState) then
ShowHideControls(Assigned(FPanel));
end;
procedure TCustomTeeCommander.Loaded;
var t : Integer;
begin
inherited;
if not Assigned(FPanel) then
if Assigned(Parent) then
begin
if Parent is TCustomTeePanel then
Panel:=TCustomTeePanel(Parent)
else
With Parent do
for t:=0 to ComponentCount-1 do
if Components[t] is TCustomTeePanel then
begin
Self.Panel:=TCustomTeePanel(Components[t]);
break;
end;
end;
ShowHideControls(Assigned(FPanel));
end;
Function TCustomTeeCommander.CreateButton( APos:Integer;
AProc:TNotifyEvent;
Const AHint:String;
ABitmap: TBitmap;
AGroupIndex:Integer):TSpeedButton;
begin
result:=TSpeedButton.Create(Self);
With result do
begin
OnClick:=AProc;
if FVertical then SetBounds(4,APos,25,25)
else SetBounds(APos,4,25,25);
Down:= True;
Flat:= True;
{$IFDEF TEEOCX}
ShowHint:=True;
{$ELSE}
ParentShowHint:=True;
{$ENDIF}
Hint:=AHint;
Parent:=Self;
GroupIndex:=AGroupIndex;
if Assigned(ABitmap) then
Glyph.Assign(ABitmap);
end;
end;
Function TCustomTeeCommander.CreateButton( APos:Integer;
AProc:TNotifyEvent;
Const AHint:String;
Const AResName:String;
AGroupIndex:Integer):TSpeedButton;
var Glyph : TBitmap;
begin
Glyph:=TBitmap.Create;
try
if AResName<>'' then { 5.02 }
begin
{$IFDEF CLR}
TeeLoadBitmap(Glyph,AResName,'');
{$ELSE}
Glyph.LoadFromResourceName(HInstance,AResName);
{$ENDIF}
end;
result:=CreateButton(APos, AProc, AHint, Glyph, AGroupIndex);
finally
Glyph.Free;
end;
end;
Function TCustomTeeCommander.DoPanelMouse:Boolean;
begin
result:=True;
end;
Procedure TCustomTeeCommander.CreateBevel(APos:Integer);
begin
With TBevel.Create(Self) do
begin
Shape:=bsLeftLine;
Width:=2;
Height:=Self.Height-4;
Top:=2;
Left:=APos;
Parent:=Self;
end;
end;
Function TCustomTeeCommander.CreateLabel(APos:Integer; AColor:TColor):TLabel;
begin
result:=TLabel.Create(Self);
With result do
begin
Left:=APos;
Top:=12;
Font.Name:=GetDefaultFontName;
Font.Color:=AColor;
Font.Size:=GetDefaultFontSize;
Caption:='';
Parent:=Self;
{$IFNDEF LCL}
Transparent:=True; // 7.05
{$ENDIF}
end;
end;
Function TCustomTeeCommander.TeePanelClass:String;
begin
if FPanel is TCustomAxisPanel then result:=TeeCommanMsg_Chart
else result:=TeeCommanMsg_Panel;
end;
Procedure TCustomTeeCommander.FreeOwnedControls;
var Num : Integer;
tmp : Integer;
t : Integer;
begin
Repeat
Num:=0;
tmp:=-1;
for t:=0 to ControlCount-1 do
if Controls[t].Owner=Self then
begin
Inc(Num);
tmp:=t;
end;
if tmp<>-1 then
begin
RemovingControl(Controls[tmp]);
Controls[tmp].Free;
end;
Until Num=0;
end;
procedure TCustomTeeCommander.RemovingControl(AControl: TControl);
begin
end;
procedure TCustomTeeCommander.Paint;
var
tmpRect : TRect;
procedure Adjust(Bevel:TBevelCut);
begin
if Bevel<>bvNone then
InflateRect(tmpRect,-BevelWidth,-BevelWidth);
end;
var
tmpCanvas : TTeeCanvas;
begin
inherited;
// Draw gradient under commander controls
if Assigned(FGradient) and FGradient.Visible then // 7.05
begin
tmpRect:=GetClientRect;
Adjust(BevelInner);
Adjust(BevelOuter);
tmpCanvas:=TTeeCanvas3D.Create;
try
tmpCanvas.ReferenceCanvas:=Canvas;
FGradient.Draw(tmpCanvas,tmpRect);
finally
tmpCanvas.Free;
end;
end;
end;
{ TTeeCommander }
Constructor TTeeCommander.Create(AOwner:TComponent);
begin
inherited;
{$IFNDEF TEEOCXNOEDITOR}
FEditor:=nil;
FPreviewer:=nil;
{$ENDIF}
FDragging:=False;
FLabelValues:=True;
FVertical:=False;
FEnablePieExp:=True;
CreateControls([ tcbNormal,
tcbSeparator,
tcbRotate,
tcbMove,
tcbZoom,
tcbDepth,
tcb3D,
tcbSeparator,
tcbEdit,
tcbPrintPreview,
tcbCopy,
tcbSave,
tcbLabel ]);
{$IFDEF TEEOCXNOEDITOR}
FButtonEdit.Hide;
FButtonPrint.Hide;
RepositionControls;
{$ENDIF}
end;
Procedure TTeeCommander.RemovingControl(AControl:TControl);
begin
inherited;
if AControl=FButtonNormal then FButtonNormal:=nil else
if AControl=FButtonRotate then FButtonRotate:=nil else
if AControl=FButtonMove then FButtonMove:=nil else
if AControl=FButtonZoom then FButtonZoom:=nil else
if AControl=FButtonDepth then FButtonDepth:=nil else
if AControl=FButtonEdit then FButtonEdit:=nil else
if AControl=FButtonPrint then FButtonPrint:=nil else
if AControl=FButtonCopy then FButtonCopy:=nil else
if AControl=FButtonSave then FButtonSave:=nil else
if AControl=FButton3D then FButton3D:=nil else
if AControl=FLabel then FLabel:=nil;
end;
Procedure TTeeCommander.CreateControls(AControls:Array of TCommanderControls);
var t,
tmpPos:Integer;
begin
FreeOwnedControls;
tmpPos:=4;
for t:=Low(AControls) to High(AControls) do
begin
Case AControls[t] of
tcbNormal : FButtonNormal := CreateButton(tmpPos,ButtonNormalClick,TeeCommanMsg_Normal,'TeeNormal',1);
tcbRotate: FButtonRotate := CreateButton(tmpPos,ButtonRotateClick,TeeCommanMsg_Rotate,'TeeRotate',1);
tcbMove: FButtonMove := CreateButton(tmpPos,ButtonMoveClick,TeeCommanMsg_Move,'TeeMove',1);
tcbZoom: FButtonZoom := CreateButton(tmpPos,ButtonZoomClick,TeeCommanMsg_Zoom,'TeeZoom',1);
tcbDepth: FButtonDepth := CreateButton(tmpPos,ButtonDepthClick,TeeCommanMsg_Depth,'TeeDepth',1);
tcbEdit: FButtonEdit := CreateButton(tmpPos,ButtonEditClick,TeeCommanMsg_Edit,'TeeEdit',0);
tcbPrintPreview: FButtonPrint := CreateButton(tmpPos,ButtonPrintClick,TeeCommanMsg_Print,'TeePrint',0);
tcbCopy: FButtonCopy := CreateButton(tmpPos,ButtonCopyClick,TeeCommanMsg_Copy,'TeeCopy',0);
tcbSave: FButtonSave := CreateButton(tmpPos,ButtonSaveClick,TeeCommanMsg_Save,'TeeSave',0);
tcb3D: begin
FButton3D:= CreateButton(tmpPos,Button3DClick,TeeCommanMsg_3D,'TeeView3D',2);
FButton3D.AllowAllUp:=True;
end;
tcbSeparator: CreateBevel(tmpPos);
tcbLabel: FLabel := CreateLabel(tmpPos,clNavy);
end;
if AControls[t]=tcbSeparator then Inc(tmpPos,4+2)
else Inc(tmpPos,25+4);
end;
ShowHideControls(Assigned(Panel));
if Assigned(FButtonNormal) then // 7.02
FButtonNormal.Down:=True;
end;
Procedure TTeeCommander.RepositionControls;
var t : Integer;
tmpPos : Integer;
begin
tmpPos:=0;
for t:=0 to ControlCount-1 do
begin
if (Controls[t].Owner=Self) and Controls[t].Visible then
begin
Controls[t].Left:=tmpPos;
if Controls[t] is TBevel then Inc(tmpPos,4+2)
else Inc(tmpPos,25+4);
end;
end;
end;
Procedure TTeeCommander.DoMouseDown(X,Y:Integer);
Function ButtonNormalUp:Boolean;
begin
result:=(not Assigned(FButtonNormal)) or (not FButtonNormal.Down);
end;
begin
IPieSeries:=GetPieSeries(x,y);
if Assigned(IPieSeries) or ButtonNormalUp then
begin
FDragging:=True;
FOldX:=X;
FOldY:=Y;
if Assigned(IPieSeries) then FDraggingIndex:=IPieSeries.Clicked(X,Y)
else FDraggingIndex:=-1;
if FPanel is TCustomTeePanel then
TCustomTeePanel(FPanel).CancelMouse:=(FDraggingIndex<>-1) or ButtonNormalUp;
end;
end;
Function TTeeCommander.DoPanelMouse:Boolean;
Function IsButtonUp(AButton:TSpeedButton):Boolean;
begin
result:=((not Assigned(AButton)) or (not AButton.Down));
end;
begin
result:=IsButtonUp(FButtonRotate) and
IsButtonUp(FButtonDepth) and
IsButtonUp(FButtonMove) and
IsButtonUp(FButtonZoom);
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -