ksskinobjects.pas
来自「小区水费管理系统源代码水费收费管理系统 水费收费管理系统」· PAS 代码 · 共 2,327 行 · 第 1/5 页
PAS
2,327 行
{==============================================================================
SkinEngine's Objects
Copyright (C) 2000-2002 by Evgeny Kryukov
All rights reserved
All conTeThements of this file and all other files included in this archive
are Copyright (C) 2002 Evgeny Kryukov. Use and/or distribution of
them requires acceptance of the License Agreement.
See License.txt for licence information
$Id: KsSkinObjects.pas,v 1.4 2002/10/28 21:04:21 Evgeny Exp $
===============================================================================}
unit KsSkinObjects;
{$I se_define.inc}
{$T-,W-,X+,P+}
interface
uses Windows, Classes, Sysutils, Messages, Controls, Graphics, Forms,
se_controls;
const
WM_INVALIDATESKINOBJECT = WM_USER + 1097;
WM_GETSKINFORM = WM_USER + 1098;
DesignMode: boolean = false;
type
{ Sets the object's alignment. The following table lists the possible values:
<TABLE>
Value Meaning
----- -------
saNone No aligment use
saLeft, saMostLeft Aligment to left side
saTop, saMostTop Aligment to top side
saRight, saMostRight Aligment to right side
saBottom, saMostBottom Aligment to bottom side
saClient Aligment by owner client rect
saTopLeft Aligment by topleft
saTopRight Aligment by topright
saBottomLeft, Aligment by bottomleft
saBottomRight Aligment by bottomright
saCenter Aligment in owner center
saText Aligment by text width
</TABLE>
}
TSeAlign = (saNone, saLeft, saMostLeft, saTop, saMostTop, saRight, saMostRight,
saBottom, saMostBottom, saClient, saTopLeft, saTopRight, saBottomLeft,
saBottomRight, saCenter, saText);
{ Sets then SkinObject kind}
TSeKind = (
skNone,
{ Forms }
skForm, skCaption, skTitle, skTop, skLeft, skRight, skBottom, skTopLeft,
skTopRight, skBottomLeft, skBottomRight, skSysButton, skClient,
{ Menus }
skMenuBar, skMenuBarItem, skMenuBarItemText,
skPopupMenu, skPopupMenuItem, skPopupMenuItemText,
skItemText,
skTranparent
);
{ Sets SkinObject state. The following table lists the possible values:
<TABLE>
Value Meaning
----- -------
ssNormal Normal state
ssDesign Design mode (in SkinBuilder)
ssMaximized Parent form is maximized
ssMinimized Parent form is minimized
ssRollup Parent form is rollup
ssHot Object is rollover
ssPressed Object is pressed
ssFocused Object is focused
ssDisabled Object is disabled
</TABLE>
}
TSeState = (
ssNormal,
{ Builder}
ssDesign,
{ Forms }
ssMaximized, ssMinimized, ssRollup,
{ Menus and Controls }
ssHot, ssPressed, ssFocused, ssDisabled
);
{ Sets the text aligment. }
TSeTextAlign = (taTopLeft, taTopCenter, taTopRight, taLeft, taCenter,
taRight, taBottomLeft, taBottomCenter, taBottomRight);
{ Sets the text showing effect. The following table lists the possible values:
<TABLE>
Value Meaning
----- -------
teNone No effect
teShadow Draw with black shadow
</TABLE>
}
TSeTextEffect = (teNone, teShadow);
{ The following table lists the possible values:
<TABLE>
Value Meaning
----- -------
tsTile Bitmap tile on the object
tsStretch Bitmap stretch by object size
tsCenter Bitmap centered
</TABLE>
}
TscTileStyle = (tsTile, tsStretch, tsCenter);
{ The following table lists the possible values:
<TABLE>
Value Meaning
----- -------
sbaNone No actions
sbaClose Close parent form
sbaHelp Help
sbaMinimize Minimize parent form
sbaMaximize Maximize parent form
sbaRestore Restore parent form
sbaRollUp Rollup parent form
sbaRollDown Rolldown parent form
sbaTray Minimize to tray
sbaSysMenu Popup system menu
sbaRollPanel Roolup (or Rolldown) RollPanel
</TABLE>
}
TSeAction = (sbaNone, sbaClose, sbaHelp, sbaMinimize, sbaMaximize,
sbaRestore, sbaRollUp, sbaRollDown, sbaTray, sbaSysMenu, sbaRollPanel,
sbaCustom);
TSeButtonState = (bsNormal, bsHover, bsDown);
{ The following table lists the possible values:
<TABLE>
Value Meaning
----- -------
rkLeft Roll to left
rkTop Roll to top
rkRight Roll to right
rkBottom Roll to bottom
</TABLE>
}
TSeRollKind = (rkLeft, rkTop, rkRight, rkBottom);
{ TSeSkinObject class }
TSeSkinObject = class(TComponent)
private
FAlign: TSeAlign;
FKind: TSeKind;
FLeft: integer;
FTop: integer;
FWidth: integer;
FHeight: integer;
FVisible: boolean;
FBitmaps: TSeBitmapList;
FActive: boolean;
FState: TSeState;
FParentControl: TWinControl;
FOldWidth, FOldHeight: integer;
FText: WideString;
FTextAlign: TSeTextAlign;
FTextMarginRight: integer;
FTextMarginLeft: integer;
FTextMarginTop: integer;
FTextEffect: TSeTextEffect;
FDrawIfOwner: boolean;
FRightText: WideString;
FEnabled: boolean;
FMarginLeft: integer;
FMarginTop: integer;
FMarginBottom: integer;
FMarginRight: integer;
FBiDiMode: TBiDiMode;
FMasked: boolean;
procedure ReadData(Stream: TStream);
procedure WriteData(Stream: TStream);
function GetCount: integer;
function GetObject(index: integer): TSeSkinObject;
function GetBoundsRect: TRect;
procedure SetHeight(const Value: integer);
procedure SetWidth(const Value: integer);
procedure SetLeft(const Value: integer);
procedure SetTop(const Value: integer);
procedure SetBoundsRect(const Value: TRect);
procedure SetBitmaps(const Value: TSeBitmapList);
procedure SetFont(const Value: TFont);
procedure SetActive(const Value: boolean);
procedure SetParentControl(const Value: TWinControl);
procedure SetMarginBottom(const Value: integer);
procedure SetMarginLeft(const Value: integer);
procedure SetMarginRight(const Value: integer);
procedure SetMarginTop(const Value: integer);
procedure SetBiDiMode(const Value: TBiDiMode);
protected
FColor: TColor;
FFont: TFont;
procedure DefineProperties(Filer: TFiler); override;
function GetSkinForm: TComponent;
procedure DrawObjectText(Canvas: TCanvas);
function UseRightToLeftAlignment: Boolean;
function UseRightToLeftReading: Boolean;
function DrawTextBiDiModeFlags(Flags: Integer): Longint;
function DrawTextBiDiModeFlagsReadingOnly: Longint;
function GetFont: TFont; virtual;
procedure SetState(const Value: TSeState); virtual;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure AfterLoad; virtual;
{ Assign, Copy }
procedure Assign(Source: TPersistent); override;
function CreateCopy(AOwner: TSeSkinObject): TSeSkinObject;
{ Aligning }
procedure Aligning;
procedure Invalidate;
{ Drawing }
procedure Draw(Canvas: TCanvas); virtual;
procedure DrawChild(Canvas: TCanvas);
{ Region }
function GetRegion: HRgn;
function CreateRegion: HRgn; virtual;
{ Colors }
procedure ChangeHue(DeltaHue: integer); virtual;
{ Events }
procedure MouseHover; virtual;
procedure MouseLeave; virtual;
procedure MouseDown(Button: TMouseButton; X, Y: integer); virtual;
procedure MouseMove(Shift: TShiftState; X, Y: integer); virtual;
procedure MouseUp(Button: TMouseButton; X, Y: integer); virtual;
procedure MouseDouble(Button: TMouseButton; X, Y: integer); virtual;
{ Children }
procedure Add(SkinObject: TSeSkinObject);
procedure Remove(SkinObject: TSeSkinObject);
function FindObjectByKind(AKind: TSeKind): TSeSkinObject;
function FindObjectByName(AName: string): TSeSkinObject;
function FindObjectByPoint(Point: TPoint): TSeSkinObject;
procedure SetCharset(CharSet: TFontCharset); virtual;
{ properties }
property Active: boolean read FActive write SetActive;
property BiDiMode: TBiDiMode read FBiDiMode write SetBiDiMode;
property Bitmaps: TSeBitmapList read FBitmaps write SetBitmaps;
property BoundsRect: TRect read GetBoundsRect write SetBoundsRect;
property Count: integer read GetCount;
property Enabled: boolean read FEnabled write FEnabled;
property ParentControl: TWinControl read FParentControl write SetParentControl;
property Objects[index: integer]: TSeSkinObject read GetObject; default;
property State: TSeState read FState write SetState;
property Text: WideString read FText write FText;
property RightText: WideString read FRightText write FRightText;
property Visible: boolean read FVisible write FVisible;
published
property Align: TSeAlign read FAlign write FAlign;
property Color: TColor read FColor write FColor;
property DrawIfOwner: boolean read FDrawIfOwner write FDrawIfOwner;
property Font: TFont read GetFont write SetFont;
property Kind: TSeKind read FKind write FKind;
property Masked: boolean read FMasked write FMasked;
property Left: integer read FLeft write SetLeft;
property Top: integer read FTop write SetTop;
{ Specifies the object height }
property Height: integer read FHeight write SetHeight;
{ Specifies the object width }
property Width: integer read FWidth write SetWidth;
{ Specifies the left margin }
property MarginLeft: integer read FMarginLeft write SetMarginLeft;
{ Specifies the right margin }
property MarginRight: integer read FMarginRight write SetMarginRight;
{ Specifies the top margin }
property MarginTop: integer read FMarginTop write SetMarginTop;
{ Specifies the bottom margin }
property MarginBottom: integer read FMarginBottom write SetMarginBottom;
{ Specifies the text aligment }
property TextAlign: TSeTextAlign read FTextAlign write FTextAlign;
{ Specifies the text effect }
property TextEffect: TSeTextEffect read FTextEffect write FTextEffect;
{ Specifies the left text margin }
property TextMarginLeft: integer read FTextMarginLeft write FTextMarginLeft;
{ Specifies the right text margin }
property TextMarginRight: integer read FTextMarginRight write FTextMarginRight;
{ Specifies the top text margin }
property TextMarginTop: integer read FTextMarginTop write FTextMarginTop;
end;
TSeSkinObjectClass = class of TSeSkinObject;
{ TSeActiveObject class }
TSeActiveObject = class(TSeSkinObject)
private
FActiveColor: TColor;
FActiveFont: TFont;
procedure SetActiveFont(const Value: TFont);
protected
function GetFont: TFont; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
{ Assign, Copy }
procedure Assign(Source: TPersistent); override;
{ Drawing }
procedure Draw(Canvas: TCanvas); override;
{ Colors }
procedure ChangeHue(DeltaHue: integer); override;
{ Charset }
procedure SetCharset(CharSet: TFontCharset); override;
published
{ Specifies the color if Active = true }
property ActiveColor: TColor read FActiveColor write FActiveColor;
{ Specifies the font if Active = true }
property ActiveFont: TFont read FActiveFont write SetActiveFont;
end;
{ TSeBitmapObject class }
TSeBitmapObject = class(TSeSkinObject)
private
FBitmap: TSeBitmapLink;
FTileStyle: TscTileStyle;
FBorderTileStyle: TscTileStyle;
FMaskedBorder: boolean;
FMaskedAngles: boolean;
procedure SetBitmap(const Value: TSeBitmapLink);
procedure SetBorderTileStyle(const Value: TscTileStyle);
protected
procedure DrawNormal(Canvas: TCanvas);
procedure DrawRect(Canvas: TCanvas; MarginRect, MarginDstRect: TRect;
ATileStyle: TscTileStyle; AMasked: boolean);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure AfterLoad; override;
{ Assign, Copy }
procedure Assign(Source: TPersistent); override;
{ Drawing }
procedure Draw(Canvas: TCanvas); override;
{ Region }
function CreateRegion: HRgn; override;
published
{ Specifies the object's bitmap }
property Bitmap: TSeBitmapLink read FBitmap write SetBitmap;
property BorderTileStyle: TscTileStyle read FBorderTileStyle write SetBorderTileStyle;
property MaskedBorder: boolean read FMaskedBorder write FMaskedBorder;
property MaskedAngles: boolean read FMaskedAngles write FMaskedAngles;
property TileStyle: TscTileStyle read FTileStyle write FTileStyle;
end;
{ TSeActiveBitmap class }
TSeActiveBitmap = class(TSeBitmapObject)
private
FActiveBitmap: TSeBitmapLink;
FActiveFont: TFont;
procedure SetActiveFont(const Value: TFont);
procedure SetActiveBitmap(const Value: TSeBitmapLink);
protected
function GetFont: TFont; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure AfterLoad; override;
{ Assign, Copy }
procedure Assign(Source: TPersistent); override;
{ Drawing }
procedure Draw(Canvas: TCanvas); override;
{ Charset }
procedure SetCharset(CharSet: TFontCharset); override;
published
{ Specifies the bitmap if Active = true }
property ActiveBitmap: TSeBitmapLink read FActiveBitmap write SetActiveBitmap;
{ Specifies the font if Active = true }
property ActiveFont: TFont read FActiveFont write SetActiveFont;
end;
{ TSeSystemButton class }
TSeSystemButton = class(TSeActiveBitmap)
private
FAction: TSeAction;
FBitmapPressed: TSeBitmapLink;
FBitmapHot: TSeBitmapLink;
{ Internal }
FButtonState: TSeButtonState;
FShift: TShiftState;
procedure DoAction;
procedure SetAction(const Value: TSeAction);
procedure SetBitmapPressed(const Value: TSeBitmapLink);
procedure SetBitmapHot(const Value: TSeBitmapLink);
protected
procedure SetState(const Value: TSeState); override;
procedure SetChildState(const Value: TSeState);
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure AfterLoad; override;
{ Assign, Copy }
procedure Assign(Source: TPersistent); override;
{ Drawing }
procedure Draw(Canvas: TCanvas); override;
{ Events }
procedure MouseHover; override;
procedure MouseLeave; override;
procedure MouseDown(Button: TMouseButton; X, Y: integer); override;
procedure MouseMove(Shift: TShiftState; X, Y: integer); override;
procedure MouseUp(Button: TMouseButton; X, Y: integer); override;
procedure MouseDouble(Button: TMouseButton; X, Y: integer); override;
published
{ Specifies the click action }
property Action: TSeAction read FAction write SetAction;
{ Specifies bitmap in ssHot state }
property BitmapHot: TSeBitmapLink read FBitmapHot write SetBitmapHot;
{ Specifies bitmap in ssPressed state }
property BitmapPressed: TSeBitmapLink read FBitmapPressed write SetBitmapPressed;
end;
{ TSeButtonObject class }
TSeButtonObject = class(TSeBitmapObject)
private
FBitmapFocused: TSeBitmapLink;
FBitmapHot: TSeBitmapLink;
FBitmapPressed: TSeBitmapLink;
FBitmapDisabled: TSeBitmapLink;
procedure SetBitmapFocused(const Value: TSeBitmapLink);
procedure SetBitmapDisabled(const Value: TSeBitmapLink);
procedure SetBitmapHot(const Value: TSeBitmapLink);
procedure SetBitmapPressed(const Value: TSeBitmapLink);
protected
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure AfterLoad; override;
{ Assign, Copy }
procedure Assign(Source: TPersistent); override;
{ Drawing }
procedure Draw(Canvas: TCanvas); override;
published
{ Specifies the bitmap in ssHot state }
property BitmapHot: TSeBitmapLink read FBitmapHot write SetBitmapHot;
{ Specifies the bitmap in ssFocused state }
property BitmapFocused: TSeBitmapLink read FBitmapFocused write SetBitmapFocused;
{ Specifies the bitmap in ssPressed state }
property BitmapPressed: TSeBitmapLink read FBitmapPressed write SetBitmapPressed;
{ Specifies the bitmap in ssDisabled state }
property BitmapDisabled: TSeBitmapLink read FBitmapDisabled write SetBitmapDisabled;
end;
{ TSeTextObject class }
TSeTextObject = class(TSeSkinObject)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?