?? suiimagepanel.pas
字號:
////////////////////////////////////////////////////////////////////////////////////
//
//
// FileName : SUIImagePanel.pas
// Creater : Shen Min
// Date : 2001-10-15
// Comment :
//
// Copyright (c) 2002-2003 Sunisoft
// http://www.sunisoft.com
// Email: support@sunisoft.com
//
////////////////////////////////////////////////////////////////////////////////////
unit SUIImagePanel;
interface
{$I SUIPack.inc}
uses Windows, Extctrls, Graphics, Classes, Messages, Controls, SysUtils, Forms,
SUIPublic, SUIThemes, SUIMgr;
type
TsuiPanel = class(TCustomPanel)
private
m_BorderColor : TColor;
m_UIStyle : TsuiUIStyle;
m_FileTheme : TsuiFileTheme;
m_TitleBitmap : TBitmap;
m_ShowButton : Boolean;
m_InButton : Boolean;
m_Poped : Boolean;
m_OnPush : TNotifyEvent;
m_OnPop : TNotifyEvent;
m_Height : Integer;
m_Moving : Boolean;
m_FromTheme : Boolean;
m_CaptionFontColor : TColor;
procedure WMERASEBKGND(var Msg : TMessage); message WM_ERASEBKGND;
procedure SetBorderColor(const Value: TColor);
procedure SetFileTheme(const Value: TsuiFileTheme);
procedure SetUIStyle(const Value: TsuiUIStyle);
procedure SetShowButton(const Value: Boolean);
procedure SetHeight2(const Value: Integer);
procedure SetCaptionFontColor(const Value: TColor);
function GetPushed: Boolean;
protected
procedure Paint(); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
procedure AlignControls(AControl: TControl; var Rect: TRect); override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure Resize(); override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy(); override;
procedure Pop();
procedure Push();
property Pushed : Boolean read GetPushed;
published
property FileTheme : TsuiFileTheme read m_FileTheme write SetFileTheme;
property UIStyle : TsuiUIStyle read m_UIStyle write SetUIStyle;
property BorderColor : TColor read m_BorderColor write SetBorderColor;
property Font;
property Caption;
property ShowButton : Boolean read m_ShowButton write SetShowButton;
property Height : Integer read m_Height write SetHeight2;
property CaptionFontColor : TColor read m_CaptionFontColor write SetCaptionFontColor;
property BiDiMode;
property Anchors;
property Align;
property TabStop;
property TabOrder;
property Color;
property Visible;
property PopupMenu;
property OnPush : TNotifyEvent read m_OnPush write m_OnPush;
property OnPop : TNotifyEvent read m_OnPop write m_OnPop;
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;
TsuiDrawStyle = (suiNormal, suiStretch, suiTile);
TsuiCustomPanel = class(TCustomPanel)
private
m_Picture : TPicture;
m_Transparent : Boolean;
m_AutoSize : Boolean;
m_CaptionPosX: Integer;
m_CaptionPosY: Integer;
m_DrawStyle : TsuiDrawStyle;
m_LastDrawCaptionRect : TRect;
procedure ApplyAutoSize();
procedure ApplyTransparent();
procedure SetPicture(const Value: TPicture);
procedure SetAutoSize(const Value: Boolean); reintroduce;
procedure SetCaptionPosX(const Value: Integer);
procedure SetCaptionPosY(const Value: Integer);
procedure SetDrawStyle(const Value: TsuiDrawStyle);
procedure CMTEXTCHANGED(var Msg : TMessage); message CM_TEXTCHANGED;
procedure WMERASEBKGND(var Msg : TMessage); message WM_ERASEBKGND;
protected
procedure Paint(); override;
procedure ClearPanel(); virtual;
procedure RepaintText(Rect : TRect); virtual;
procedure PictureChanged(Sender: TObject); virtual;
procedure SetTransparent(const Value: Boolean); virtual;
procedure Resize(); override;
property Picture : TPicture read m_Picture write SetPicture;
property Transparent : Boolean Read m_Transparent Write SetTransparent default false;
property AutoSize : Boolean Read m_AutoSize Write SetAutoSize;
property CaptionPosX : Integer read m_CaptionPosX write SetCaptionPosX;
property CaptionPosY : Integer read m_CaptionPosY write SetCaptionPosY;
property DrawStyle : TsuiDrawStyle read m_DrawStyle write SetDrawStyle;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy(); override;
end;
TsuiImagePanel = class(TsuiCustomPanel)
published
property BiDiMode;
property BorderWidth;
property Anchors;
property Picture;
property Transparent;
property AutoSize;
property Alignment;
property Align;
property Font;
property TabStop;
property TabOrder;
property Caption;
property Color;
property DrawStyle;
property Visible;
property PopupMenu;
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
{ TsuiCustomPanel }
procedure TsuiCustomPanel.ApplyAutoSize;
begin
if m_AutoSize then
begin
if (
(Align <> alTop) and
(Align <> alBottom) and
(Align <> alClient)
) then
Width := m_Picture.Width;
if (
(Align <> alLeft) and
(Align <> alRight) and
(Align <> alClient)
) then
Height := m_Picture.Height;
end;
end;
procedure TsuiCustomPanel.ApplyTransparent;
begin
if m_Picture.Graphic.Transparent <> m_Transparent then
m_Picture.Graphic.Transparent := m_Transparent;
end;
procedure TsuiCustomPanel.ClearPanel;
begin
Canvas.Brush.Color := Color;
if ParentWindow <> 0 then
Canvas.FillRect(ClientRect);
end;
procedure TsuiCustomPanel.CMTEXTCHANGED(var Msg: TMessage);
begin
RepaintText(m_LastDrawCaptionRect);
Repaint();
end;
constructor TsuiCustomPanel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
m_Picture := TPicture.Create();
ASSERT(m_Picture <> nil);
m_Picture.OnChange := PictureChanged;
m_CaptionPosX := -1;
m_CaptionPosY := -1;
BevelInner := bvNone;
BevelOuter := bvNone;
Repaint();
end;
destructor TsuiCustomPanel.Destroy;
begin
if m_Picture <> nil then
begin
m_Picture.Free();
m_Picture := nil;
end;
inherited;
end;
procedure TsuiCustomPanel.Paint;
var
uDrawTextFlag : Cardinal;
Rect : TRect;
Buf : TBitmap;
begin
Buf := TBitmap.Create();
Buf.Height := Height;
Buf.Width := Width;
if m_Transparent then
DoTrans(Buf.Canvas, self);
if Assigned(m_Picture.Graphic) then
begin
if m_DrawStyle = suiStretch then
Buf.Canvas.StretchDraw(ClientRect, m_Picture.Graphic)
else if m_DrawStyle = suiTile then
TileDraw(Buf.Canvas, m_Picture, ClientRect)
else
Buf.Canvas.Draw(0, 0, m_Picture.Graphic);
end
else if not m_Transparent then
begin
Buf.Canvas.Brush.Color := Color;
Buf.Canvas.FillRect(ClientRect);
end;
Buf.Canvas.Brush.Style := bsClear;
if Trim(Caption) <> '' then
begin
Buf.Canvas.Font := Font;
if (m_CaptionPosX <> -1) and (m_CaptionPosY <> -1) then
begin
Buf.Canvas.TextOut(m_CaptionPosX, m_CaptionPosY, Caption);
m_LastDrawCaptionRect := Classes.Rect(
m_CaptionPosX,
m_CaptionPosY,
m_CaptionPosX + Buf.Canvas.TextWidth(Caption),
m_CaptionPosY + Buf.Canvas.TextWidth(Caption)
);
end
else
begin
Rect := ClientRect;
uDrawTextFlag := DT_CENTER;
if Alignment = taRightJustify then
uDrawTextFlag := DT_RIGHT
else if Alignment = taLeftJustify then
uDrawTextFlag := DT_LEFT;
DrawText(Buf.Canvas.Handle, PChar(Caption), -1, Rect, uDrawTextFlag or DT_SINGLELINE or DT_VCENTER);
m_LastDrawCaptionRect := Rect;
end;
end;
BitBlt(Canvas.Handle, 0, 0, Width, Height, Buf.Canvas.Handle, 0, 0, SRCCOPY);
Buf.Free();
end;
procedure TsuiCustomPanel.PictureChanged(Sender: TObject);
begin
if m_Picture.Graphic <> nil then
begin
if m_AutoSize then
ApplyAutoSize();
ApplyTransparent();
end;
ClearPanel();
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -