⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 decortorunit1.pas

📁 设计模式delphi版给想学delphi的朋友一个很有价值的参考
💻 PAS
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -