Delphi Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
델파이 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
FreePascal/Lazarus
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
델마당
볼랜드포럼 광고 모집

델파이 Q&A
Delphi Programming Q&A
[12386] Re:[질문]TShapePanel 이라고 혹시 아세요?
civilian [civilian] 1534 읽음    2009-01-23 13:26
구글링해보니 나오네요

unit Span;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls;

type
  TShapePanel = class(TCustomPanel)
  private
    { Private declarations }
    FShape: TShapeType;
    procedure SetShape(v: TShapeType);
  protected
    { Protected declarations }
    procedure Paint;override;
  public
    { Public declarations }
    constructor Create(A: TComponent);override;
  published
    { Published declarations }
    property Shape: TShapeType read FShape write SetShape default stRectangle;
  end;

procedure Register;

implementation

constructor TShapePanel.Create (A: TComponent);
begin
     inherited Create(A);
     FShape:=stRectangle;
     Caption:='';
     Invalidate;
end;

procedure TShapePanel.SetShape(v: TShapeType);
begin
     if V<>FShape then
     begin
          FShape:=v;
          Invalidate;
     end;
end;

procedure TShapePanel.Paint;
var
  Rect: TRect;
  TopColor, BottomColor: TColor;
  FontHeight: Integer;
  a: Integer;
const
  Alignments: array[TAlignment] of Word = (DT_LEFT, DT_RIGHT, DT_CENTER);
begin
  Rect := GetClientRect;
  with Canvas do
  begin
    Brush.Color := Color;
    FillRect(Rect);
    case FShape of
    stRectangle: Rectangle(Rect.Left,Rect.Top,Rect.Right, Rect.Bottom);
    stSquare:    begin
                      If Rect.bottom-Rect.top>=Rect.Right-Rect.Left then
                         A:=Rect.Right-Rect.Left
                      else
                         A:=Rect.bottom-Rect.top;
                      Rectangle(Rect.Left,Rect.Top,Rect.Left+a, Rect.Top+a);
                 end;
    stRoundRect: RoundRect (Rect.Left,Rect.Top,Rect.Right,Rect.Bottom,6,6);
    stRoundSquare:begin
                      If Rect.bottom-Rect.top>=Rect.Right-Rect.Left then
                         A:=Rect.Right-Rect.Left
                      else
                         A:=Rect.bottom-Rect.top;
                      RoundRect(Rect.Left,Rect.Top,Rect.Left+a, Rect.Top+a,6,6);
                 end;
    stEllipse:   Ellipse(Rect.Left,Rect.top,Rect.Right,Rect.Bottom);
    stCircle:    begin
                      If Rect.bottom-Rect.top>=Rect.Right-Rect.Left then
                         A:=Rect.Right-Rect.Left
                      else
                         A:=Rect.bottom-Rect.top;
                      Ellipse(Rect.Left,Rect.Top,Rect.Left+a, Rect.Top+a);
                 end;
    end;//case
    Brush.Style := bsClear;
    Font := Self.Font;
    FontHeight := TextHeight('W');
    with Rect do
    begin
      Top := ((Bottom + Top) - FontHeight) div 2;
      Bottom := Top + FontHeight;
    end;
    DrawText(Handle, PChar(Caption), -1, Rect, (DT_EXPANDTABS or
      DT_VCENTER) or Alignments[Alignment]);
  end;


end;

procedure Register;
begin
  RegisterComponents('SAS', [TShapePanel]);
end;

end.





김현승 님이 쓰신 글 :
: 안녕하세요
: 질문은 제목과 같습니다.
: 벡터로 이미지를 그려야 하는데...찾아보니 TShapePanel  이런게 있어서요...
:
: 혹시 델파이에서 자체적으로 지원하는 건가요? 아님 따로 받아야 하나요??
:
: 아시는 분 답변 바랍니다.

+ -

관련 글 리스트
12385 [질문]TShapePanel 이라고 혹시 아세요? 김현승 1769 2009/01/22
12386     Re:[질문]TShapePanel 이라고 혹시 아세요? civilian 1534 2009/01/23
12387         Re:Re:[질문]TShapePanel 이라고 혹시 아세요? 김현승 1561 2009/01/23
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.