decortorunit1.pas
来自「设计模式delphi版给想学delphi的朋友一个很有价值的参考」· PAS 代码 · 共 126 行
PAS
126 行
unit DecortorUnit1;
interface
uses classes;
type
TVisualComponent = class(Tcomponent) //Delphi跌谋てじン惠膥┯Tcomponent
public
constructor Create; virtual;
procedure Draw(); virtual;
procedure Resize(); virtual;
//.........
end;
TDecortor = class(TVisualComponent)
private
f_component: TVisualComponent;
public
constructor Create(aComponent: TVisualComponent); virtual;
procedure Draw(); virtual;
procedure Resize(); virtual;
//.........
end;
TBorderDecortor = class(TDecortor)
private
f_width: Integer;
procedure DrawBorder(width: Integer);
public
constructor Create(aComponent: TVisualComponent; width: Integer); virtual;
procedure Draw(); virtual;
//......
end;
TScrollDecortor = class(TDecortor)
public
constructor Create(aComponent: TVisualComponent); virtual;
procedure Draw(); virtual;
//......
end;
TTextView = class(TVisualComponent)
public
constructor Create; virtual;
end;
implementation
constructor TVisualComponent.Create;
begin
//....
end;
procedure TVisualComponent.Draw();
begin
//....
end;
procedure TVisualComponent.Resize();
begin
//....
end;
constructor TDecortor.Create(aComponent: TVisualComponent);
begin
//....
end;
procedure TDecortor.Draw();
begin
f_component.Draw;
//....
end;
procedure TDecortor.Resize();
begin
f_component.Resize;
//....
end;
procedure TBorderDecortor.DrawBorder(width: Integer);
begin
//....
end;
constructor TBorderDecortor.Create(aComponent: TVisualComponent; width: Integer);
begin
//....
end;
procedure TBorderDecortor.Draw();
begin
inherited;
DrawBorder(f_width);
//....
end;
constructor TTextView.Create;
begin
inherited;
//....
end;
constructor TScrollDecortor.Create(aComponent: TVisualComponent);
begin
//....
end;
procedure TScrollDecortor.Draw();
begin
//....
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?