Автор: tanaseduard
Дата сообщения: 05.12.2010 18:35
makz
Ниже копия моего класса для смены скинов.
Код: Unit lib_Dev_Skins;
Interface
Uses Forms,Variants,
dxBar,cxLookAndFeels,cxLookAndFeelPainters,dxSkinsForm,
dxSkinsCore,dxSkinBlack,dxSkinBlue,dxSkinCaramel,dxSkinCoffee,dxSkinDarkRoom,
dxSkinDarkSide,dxSkinFoggy,dxSkinGlassOceans,dxSkiniMaginary,dxSkinLilian,
dxSkinLiquidSky,dxSkinLondonLiquidSky,dxSkinMcSkin,dxSkinMoneyTwins,dxSkinOffice2007Black,
dxSkinOffice2007Blue,dxSkinOffice2007Green,dxSkinOffice2007Pink,dxSkinOffice2007Silver,
dxSkinPumpkin,dxSkinSeven,dxSkinSharp,dxSkinSilver,dxSkinSpringTime,dxSkinStardust,
dxSkinSummer2008,dxSkinsDefaultPainters,dxSkinValentine,dxSkinXmas2008Blue,
dxSkinsdxStatusBarPainter,dxSkinsdxBarPainter,cxGraphics,cxControls,dxSkinscxPCPainter,
cxPC;
Type
TSkinChangeNotify=Procedure(AUseSkin:Boolean;ASkinName:String) Of Object;
Type
TDevExpressSkins=Class
Constructor Create;
Destructor Destroy; Override;
Procedure CreateAllSkinButtons(ASubItem:TdxBarSubItem;AImIndexWithout,AImIndexWith:Integer);
Private
FUpdateNotify:TSkinChangeNotify;
FSkinController:TdxSkinController;
Procedure SkinButtonClick(Sender:TObject);
Public
Procedure SetSkin(ASkinName:String);
Property SkinChangeEvent:TSkinChangeNotify Write FUpdateNotify;
End;
Implementation
Constructor TDevExpressSkins.Create;
Begin
FSkinController:=TdxSkinController.Create(Application.MainForm);
End;
Destructor TDevExpressSkins.Destroy;
Begin
FSkinController.Destroy;
End;
Procedure TDevExpressSkins.CreateAllSkinButtons(ASubItem:TdxBarSubItem;AImIndexWithout,AImIndexWith:Integer);
Var
barBtn:TdxBarItemLink;
i:Integer;
Begin
Try
barBtn:=ASubItem.ItemLinks.Add;
barBtn.Item:=TdxBarButton.Create(ASubItem.BarManager);
barBtn.UserPaintStyle:=psCaptionGlyph;
TdxBarButton(barBtn.Item).OnClick:=SkinButtonClick;
TdxBarButton(barBtn.Item).ImageIndex:=AImIndexWithout;
TdxBarButton(barBtn.Item).Caption:='Без скина';
//Create Skin Button
For I:=0 To GetExtendedStylePainters.Count-1 Do
Begin
barBtn:=ASubItem.ItemLinks.Add;
barBtn.Item:=TdxBarButton.Create(ASubItem.BarManager);
barBtn.UserPaintStyle:=psCaptionGlyph;
TdxBarButton(barBtn.Item).OnClick:=SkinButtonClick;
TdxBarButton(barBtn.Item).ImageIndex:=AImIndexWith;
TdxBarButton(barBtn.Item).Caption:=GetExtendedStylePainters.Names[I];
If i=0 Then barBtn.BeginGroup:=True;
End;
Finally
End;
End;
Procedure TDevExpressSkins.SkinButtonClick(Sender:TObject);
Begin
Try
If TdxBarButton(Sender).Tag=-100 Then
Begin
FSkinController.SkinName:='';
FSkinController.UseSkins:=False;
If (Assigned(FUpdateNotify))And(@FUpdateNotify<>Nil) Then
FUpdateNotify(False,'');
End
Else
Begin
FSkinController.SkinName:=TdxBarButton(Sender).Caption;
FSkinController.UseSkins:=True;
If Assigned(FUpdateNotify)And(@FUpdateNotify<>Nil) Then
FUpdateNotify(True,FSkinController.SkinName);
End;
Finally
End;
End;
Procedure TDevExpressSkins.SetSkin(ASkinName:String);
Begin
FSkinController.SkinName:=ASkinName;
FSkinController.UseSkins:=True;
End;
End.