You are on page 1of 13

CnPack

http://www.cnpack.org

CnSkin

(master@cnpack.org ), savetime, e-
CnPack

V0.8.2.0
2008.01.07
2008.01.12

CnPack Skin CnPack


Skin CnPack Skin
Skin

e- CnPack Skin
savetime SkinMagic
WindowProc

Skin
SkinStyle SkinStyle
SkinStyle
SkinThemes
SkinMagic

1

2

(C)Copyright 2001-2008 CnPack 1 13


CnPack
http://www.cnpack.org

CnPack CnPack

CnSkin CnPack

savetime
e-
master@cnpack.org http://www.cnpack.org

CnPack

CnPack Skin
SkinStyleSkinTheme
SkinMagic
SkinStyle SkinStyle
Skin SkinThemes
SkinThemes
SkinStyle SkinThemes
SkinThemes Active
VCL

VCL ButtonLabelComboBox
SkinMagicMagic
SkinThemes

(C)Copyright 2001-2008 CnPack 2 13


CnPack
http://www.cnpack.org

CnPack Skin
TCnSkinStyle ICnSkinParams

CnPack TCnSkinStyle
CnSkinXPBlueStyleCnSkinXPGreenStyleCnSkinXPSilverStyle
Windows XP

CnSkinStyle Loaded

CnSkinStyle

CnPack CnSkinThemes

Active
Skins TCnSkinStyle

CnPack SkinIndex
SkinIndex SkinIndex

function CnSkinThemes: TCnSkinThemes;

CnSkinThemes CurrentSkin SkinIndex SkinStyle

(C)Copyright 2001-2008 CnPack 3 13


CnPack
http://www.cnpack.org

CurrentSkin CnSkinThemes
SkinStyle CnSkinThemes
CnSkinThemes
TCnSkinThemeController CnSkinThemes

CnSkinThemes SkinIndex CnSkinThemes SkinIndex


CurrentSkin

CnPack CnSkinMagic TControl


WindowProc

AfterConstuction BeforeDestruction
CnSkinMagic
WindowProc WindowProc
WindowProc
WindowProc
SkinActive CnSkinThemes Active
True WindowProc
WindowProc
class

CnSkinMagic FClassList Item TClassData


ClassType VMT AfterConstuction
BeforeDestruction WindowProc
TClassData
TControlSubClass TControlSubClass

SkinWindowProc
RegisterClass TControl
Skin WindowProc

CnSkinMagic RegisterClass WindowProc


CnSkinMagic AfterConstuction BeforeDestruction

(C)Copyright 2001-2008 CnPack 4 13


CnPack
http://www.cnpack.org

TClassData
CnSkinMagic AfterConstuction BeforeDestruction
CnSkinMagic
TControlSubClass WindowProc

TControlSubClass WindowProc CnSkinThemes
Active SkinWindowProc WindowProc
WindowProc SkinWindowProc SkinWindowProc

7CnSkinStyle

1CnSkinStyle

TCnSkinXPGreenStyle
TCnSkinXPBlueStyle - TCnSkinXPStyle TCnSkinStyle TComponent
TCnSkinXPSilverStyle

II

TCnSkinStyle ICnSkinParams

ICnSkinParams = interface(IUnknown)
['{C4FDB92B-AE10-49F9-918E-F4F7DC9CD1E4}']
function GetFaceColor: TColor;
function GetLightColor: TColor;
function GetMenuHotColor: TColor;
function GetShadowColor: TColor;
function GetActiveCaptionColor: TColor;
function GetInActiveCaptionColor: TColor;
function GetCaptionHeight: Integer;
function GetBorderSize: Integer;
function GetButtonSize: Integer;
function GetButtonRight: Integer;
function GetButtonTop: Integer;
function GetCaptionFontSize: Integer;
function GetRgnSize: Integer;
function GetWindowBmp: TBitmap;
function GetWindowBtnBmp: TBitmap;
function GetScrollBarBmp: TBitmap;

(C)Copyright 2001-2008 CnPack 5 13


CnPack
http://www.cnpack.org

function GetButtonBmp: TBitmap;


function GetCheckBmp: TBitmap;
function GetComboBmp: TBitmap;
function GetRadioBmp: TBitmap;

property FaceColor: TColor read GetFaceColor;


{* }
property LightColor: TColor read GetLightColor;
{* }
property ShadowColor: TColor read GetShadowColor;
{* }
property MenuHotColor: TColor read GetMenuHotColor;
{* }
property ActiveCaptionColor: TColor read GetActiveCaptionColor;
{* }
property InActiveCaptionColor: TColor read GetInActiveCaptionColor;
{* }
property CaptionHeight: Integer read GetCaptionHeight;
{* }
property BorderSize: Integer read GetBorderSize;
{* }
property ButtonSize: Integer read GetButtonSize;
{* }
property ButtonTop: Integer read GetButtonTop;
{* }
property ButtonRight: Integer read GetButtonRight;
{* }
property CaptionFontSize: Integer read GetCaptionFontSize;
{* }
property RgnSize: Integer read GetRgnSize;
{* }
property WindowBmp: TBitmap read GetWindowBmp;
{* }
property WindowBtnBmp: TBitmap read GetWindowBtnBmp;
{* }
property ScrollBarBmp: TBitmap read GetScrollBarBmp;
{* }
property ButtonBmp: TBitmap read GetButtonBmp;
{* }
property CheckBmp: TBitmap read GetCheckBmp;
{* }
property RadioBmp: TBitmap read GetRadioBmp;
{* }
property ComboBmp: TBitmap read GetComboBmp;

(C)Copyright 2001-2008 CnPack 6 13


CnPack
http://www.cnpack.org

{* }
end;

TCnSkinStyle = class(TComponent, ICnSkinParams)


......

TCnSkinStyle InitConsts InitResources

TCnSkinStyle TCnSkinXPStyle InitConsts


XP TCnSkinXPStyle
InitRecources CnReadBmpFromResource
TBitmap

procedure CnReadBmpFromResource(Bmp: TBitmap; const ResName: string);


{* }

2CnSkinThemes

1CnSkinThemes

TCnSkinThemes TObject

CnSkin CnSkinFormCnSkinMenu
CnSkinThemes CnSkinThemes SkinStyle
CnSkinThemes Controls
CnSkinStyle CnSkinThemes
CnSkinThemes SkinStyles

TCnSkinThemes = class(TObject)
private
FSkins: TList;
FControls: TList;
FOldSkinIndex: Integer;
FSkinIndex: Integer;
FCurrentSkin: TCnSkinStyle;
FActive: Boolean;
function GetSkinCount: Integer;
procedure SetSkinIndex(const Value: Integer);

(C)Copyright 2001-2008 CnPack 7 13


CnPack
http://www.cnpack.org

function GetSkins(Index: Integer): TCnSkinStyle;


procedure SetActive(const Value: Boolean);
protected
procedure LoadStyle(Skin: TCnSkinStyle);
public
constructor Create; virtual;
{* }
destructor Destroy; override;
{* }
procedure AddSkin(Skin: TCnSkinStyle);
{* SkinStyle }
procedure RemoveSkin(Skin: TCnSkinStyle);
{* SkinStyle}
property Active: Boolean read FActive write SetActive;
{* }
property Controls: TList read FControls;
{* CnSkin }
property SkinCount: Integer read GetSkinCount;
{* SkinStyle }
property SkinIndex: Integer read FSkinIndex write SetSkinIndex;
{* SkinStyle 0 SkinCount - 1}
property Skins[Index: Integer]: TCnSkinStyle read GetSkins;
{* SkinStyle }
property CurrentSkin: TCnSkinStyle read FCurrentSkin;
{* SkinStyle Skins }
end;

Active False SkinIndex -1


SkinIndex Active True SkinIndex 0
SkinStyle

4CnSkinThemeController

TCnSkinThemeController - TComponent

CnSkinThemeController CnSkinThemes
CnSkinThemes TCnSkinThemes
CnSkinThemes
CriticalSection
CnSkinThemes

(C)Copyright 2001-2008 CnPack 8 13


CnPack
http://www.cnpack.org

function CnSkinThemes: TCnSkinThemes;


{* CnSkinThemes }

3CnSkinMagic

1CnSkinMagic

TCnSkinMagic TComponent

CnSkinMagic

TCnSkinMagic = class(TCnComponent)
{* }
private
function GetSkinActive: Boolean;
protected
class procedure RefreshControls;
{* }
public
class procedure EnableSkin;
{* CnSkinMagic }
class procedure DisableSkin;
{* CnSkinMagic }
class procedure RegisterClass(AClass: TControlClass; AWindowProc: Point
er);
{* CnSkinMagic Class, ,
: AClass SubClass , TControlClass
AWndProc SubClass WindowProc,
AWindowProc
procedure AWindowProc(Self: TControlSubClass; var Message: TMessage)
;
}
published
property SkinActive: Boolean read GetSkinActive;
{* Skin , EnableSkin DisableSkin }
end;

(C)Copyright 2001-2008 CnPack 9 13


CnPack
http://www.cnpack.org

RegisterClass AWindowProc

procedure AWindowProc(Self: TControlSubClass; var Message: TMessage);

4TControlSubClass

TControlSubClass SubClass Skin


public

TControlSubClass = class(TObject)
{* SubClass Skin public }
private
FControl: TControl;
FSkinWindowProc: TWndMethod;
FOldWindowProc: TWndMethod;
FIsWinControl: Boolean;
FMouseInControl: Boolean;
constructor Create(AControl: TControl);
{* Skin , private }
procedure WindowProc(var Message: TMessage);
public
property Control: TControl read FControl;
{* SubClass () }
property OldWindowProc: TWndMethod read FOldWindowProc;
{* WindowProc }
property IsWinControl: Boolean read FIsWinControl;
{* TWinControl }
property MouseInControl: Boolean read FMouseInControl;
{* }
end;

SkinWindowProc

5TClassData

FClassList TClassData FClassList


TCnClassList

TCnClassList = class(TList)
{* ClassData }
protected
procedure Notify(Ptr: Pointer; Action: TListNotification); override;
end;

(C)Copyright 2001-2008 CnPack 10 13


CnPack
http://www.cnpack.org

Notify ItemTClassData
TClassData

TClassData = record
{* TCnClassList }
ClassType: TClass;
WindowProc: Pointer;
OldAfterConstruction: Pointer;
OldBeforeDestruction: Pointer;
end;

procedure CnAfterConstruction(Self: TControl);

CnAfterConstruction AfterConstruction
TControlSubClass
AfterConstruction

procedure CnBeforeDestruction(Self: TControl);

CnBeforeDestruction BeforeDestruction
TControlSubClass ,
BeforeDestruction

function FindClassData(AClass: TClass): PClassData;


FindClassData FClassList TClassData

4CnSkinForm

1CnSkinForm

TCnSkinForm TComponent

CnSkinForm Form SkinStyle


CnSkinThemes

CnSkinForm Skin
CnSkinStyle CnSkinThemes CnSkinForm

(C)Copyright 2001-2008 CnPack 11 13


CnPack
http://www.cnpack.org

Owner WindowProc NC

FormStyle fsNone

4 2

1 2 N

5CnSkinMenu

1CnSkinMenu

TCnSkinMenu TComponent

CnSkinMenu MainMenu PopupMenu


SkinStyle OwnerDraw True
MeasureItem DrawItem
CnSkinThemes

4 2

1 2 N


CnSkinForm

(C)Copyright 2001-2008 CnPack 12 13


CnPack
http://www.cnpack.org

CnSkinMenu

Delphi5/6/7Windows98/NT/2000/XP
Delphi 5

CnSkinForm MDI
CnRadioButton

(C)Copyright 2001-2008 CnPack 13 13

You might also like