suigroupbox.pas
来自「新颖按钮控件」· PAS 代码 · 共 204 行
PAS
204 行
////////////////////////////////////////////////////////////////////////////////
//
//
// FileName : SUIGroupBox.pas
// Creator : Shen Min
// Date : 2002-08-20
// Comment :
//
// Copyright (c) 2002-2003 Sunisoft
// http://www.sunisoft.com
// Email: support@sunisoft.com
//
////////////////////////////////////////////////////////////////////////////////
unit SUIGroupBox;
interface
uses Windows, ExtCtrls, Graphics, Controls, Classes, Forms, Messages,
SUIImagePanel, SUIPublic, SUIThemes;
type
TsuiCustomGroupBox = class(TsuiCustomPanel)
private
m_BorderColor : TColor;
m_Caption : TCaption;
procedure SetBorderColor(const Value: TColor);
procedure SetCaption(const Value : TCaption);
procedure CMFONTCHANGED(var Msg : TMessage); message CM_FONTCHANGED;
procedure CMTEXTCHANGED(var Msg : TMessage); message CM_TEXTCHANGED;
procedure WMERASEBKGND(var Msg : TMessage); message WM_ERASEBKGND;
protected
procedure Paint(); override;
procedure SetEnabled(Value: Boolean); override;
function GetClient() : TRect;
property BorderColor : TColor read m_BorderColor write SetBorderColor;
public
constructor Create(AOwner : TComponent); override;
destructor Destroy(); override;
procedure UpdateUIStyle(UIStyle : TsuiUIStyle); virtual;
published
property Anchors;
property BiDiMode;
property Align;
property Caption read m_Caption write SetCaption;
property Color;
property Font;
property Enabled;
property Transparent;
property ParentColor;
property ParentShowHint;
property ParentBiDiMode;
property ParentFont;
property Visible;
end;
TsuiGroupBox = class(TsuiCustomGroupBox)
published
property BorderColor;
property OnCanResize;
property OnClick;
property OnConstrainedResize;
property OnDockDrop;
property OnDockOver;
property OnDblClick;
property OnDragDrop;
property OnDragOver;
property OnEndDock;
property OnEndDrag;
property OnEnter;
property OnExit;
property OnGetSiteInfo;
property OnMouseDown;
property OnMouseMove;
property OnMouseUp;
property OnResize;
property OnStartDock;
property OnStartDrag;
property OnUnDock;
end;
implementation
{ TsuiGroupBox }
procedure TsuiCustomGroupBox.CMFONTCHANGED(var Msg: TMessage);
begin
Repaint();
end;
procedure TsuiCustomGroupBox.CMTEXTCHANGED(var Msg: TMessage);
begin
Repaint();
end;
constructor TsuiCustomGroupBox.Create(AOwner: TComponent);
var
UIStyle : TsuiUIStyle;
begin
inherited;
inherited Caption := ' ';
Width := 185;
Height := 105;
UIStyle := GetSUIFormStyle(TCustomForm(AOwner));
BorderColor := GetThemeColor(UIStyle, SUI_CONTROL_BORDER_COLOR);
Font.Color := GetThemeColor(UIStyle, SUI_CONTROL_FONT_COLOR);
Transparent := true;
end;
destructor TsuiCustomGroupBox.Destroy;
begin
inherited;
end;
function TsuiCustomGroupBox.GetClient: TRect;
begin
Result := Rect(
ClientRect.Left + 3,
ClientRect.Top + Abs(Font.Height),
ClientRect.Right - 2,
ClientRect.Bottom - 2
);
end;
procedure TsuiCustomGroupBox.Paint;
var
R : TRect;
CapHeight : Integer;
begin
CapHeight := Abs(Font.Height);
inherited;
Canvas.Font := Font;
// draw border
R := ClientRect;
R.Top := R.Top + CapHeight div 2 + 1;
Canvas.Pen.Color := m_BorderColor;
Canvas.MoveTo(R.Left + 2, R.Top);
Canvas.LineTo(R.Left, R.Top);
Canvas.LineTo(R.Left, R.Bottom - 1);
Canvas.LineTo(R.Right - 1, R.Bottom - 1);
Canvas.LineTo(R.Right - 1, R.Top);
if m_Caption <> '' then
Canvas.LineTo(R.Left + Canvas.TextWidth(m_Caption) + 6, R.Top)
else
Canvas.LineTo(R.Left, R.Top);
// draw caption
if not Enabled then
Canvas.Font.Color := clGray;
Canvas.Brush.Style := bsClear;
Canvas.TextOut(5, 0, m_Caption);
end;
procedure TsuiCustomGroupBox.SetBorderColor(const Value: TColor);
begin
m_BorderColor := Value;
Repaint();
end;
procedure TsuiCustomGroupBox.SetCaption(const Value: TCaption);
begin
m_Caption := Value;
Repaint();
end;
procedure TsuiCustomGroupBox.SetEnabled(Value: Boolean);
var
i : Integer;
begin
inherited;
for i := 0 to ControlCount - 1 do
Controls[i].Enabled := Value;
Repaint();
end;
procedure TsuiCustomGroupBox.UpdateUIStyle(UIStyle: TsuiUIStyle);
begin
ContainerApplyUIStyle(self, UIStyle);
end;
procedure TsuiCustomGroupBox.WMERASEBKGND(var Msg: TMessage);
begin
// do nothing
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?