探索FireMonkey的StyleBook皮肤控件的使用

StyleBook 介绍及VICEN对皮肤控件的一些看法

可以说StyleBook的出现,简直是皮肤控件厂商的噩梦,因为用户可以通过StyleBook快速切换控件样式,而不需要在去购买第三方换肤控件,对于免费并且是官方集成的StyleBook来说,优势不言而喻。因此,以后的皮肤控件除非有自己的特色,例如Raize,提供了很多系统没有的控件,并且有自己的独特的外形风格,否则很难在发展下去。我们很期待有一套类似QQ样的界面控件套件,可以换肤、切换窗口样式颜色、跟换窗口背景图片等。

先来看看StyleBook为我们提供了哪些默认的界面风格,这些界面风格都被安装在:

..\Program Files\Embarcadero\RAD Studio\9.0\Redist\styles\Fmx\

目录下,如果你要发布你的程序,将这里的你需要用到的.style文件一并复制到你发布软件目录即可。

StyleBook提供的界面风格如下:

Windows7.Style

RubyGraphite.style

MacGraphite.Style

MacBlue.Style

IOS.Style

GoldenGraphite.Style

FMX.Platform.Win.style

FMX.Platform.Mac.style

FMX.Platform.iOS.style

dark.style

Blend.Style

AquaGraphite.style

Amakrits.Style

Air.Style

虽然并不多,但可以自行设计扩展,而且支持动态切换,使用也相当的简单。

下面我们看看如何来使用 StyleBook

1) 首先我们来新建一个FireMonkey HD Application工程

2) 在窗口上放一个StyleBook控件,它位于Standard控件页下。

3) 将窗口的StyleBook属性与StyleBookl控件链接。

procedure TFrmStyleTest.FormCreate(Sender: TObject);
begin
Self.StyleBook := StyleBook;
end;

4) 现在就可以使用StyleBook.FileName := ‘样式名称’ 来切换样式了,需要特别注意的是,样式文件必须与EXE在同一个目录,因为测试程序样式文件没加路径,如果不在同一目录就没显示效果。
这里写图片描述
代码如下:

 unit FireStyle;

 interface

 uses
     System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
     FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Menus, FMX.Edit,
     FMX.ListBox, FMX.Layouts, FMX.Memo;

type
TFrmStyleTest = class(TForm)
    StyleBook: TStyleBook;
    MainMenu: TMainMenu;
    Menu_File: TMenuItem;
    Menu_File_Open: TMenuItem;
    Menu_Help: TMenuItem;
    Menu_File_New: TMenuItem;
    Menu_File_Line0: TMenuItem;
    Menu_File_Quit: TMenuItem;
    Menu_Help_About: TMenuItem;
    Chk_Test: TCheckBox;
    Rb_Style_0: TRadioButton;
    Rb_Style_1: TRadioButton;
    Rb_Style_2: TRadioButton;
    Rb_Style_3: TRadioButton;
    Rb_Style_4: TRadioButton;
    Rb_Style_5: TRadioButton;
    Rb_Style_6: TRadioButton;
    Rb_Style_7: TRadioButton;
    Rb_Style_8: TRadioButton;
    Rb_Style_9: TRadioButton;
    Rb_Style_10: TRadioButton;
    Rb_Style_11: TRadioButton;
    Rb_Style_12: TRadioButton;
    Rb_Style_13: TRadioButton;
    Lab_StyleName: TLabel;
    But_Close: TButton;
    Ed_StyleName: TEdit;
    tb_Test: TTrackBar;
    pb_Bar: TProgressBar;
    sb_Test: TScrollBar;
    cmb_Test: TComboBox;
    ListBoxItem1: TListBoxItem;
    ListBoxItem2: TListBoxItem;
    ListBoxItem3: TListBoxItem;
    Memo_Test: TMemo;
    tmr_Process: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure But_CloseClick(Sender: TObject);
    procedure Menu_File_QuitClick(Sender: TObject);
    procedure Rb_Style_0Click(Sender: TObject);
    procedure tmr_ProcessTimer(Sender: TObject);
private
    procedure ApplyStyle(swStyle: WideString);
    { Private declarations }
public
    { Public declarations }
end;

var
FrmStyleTest: TFrmStyleTest;

implementation

{$R *.fmx}

procedure TFrmStyleTest.But_CloseClick(Sender: TObject);
begin
    Close;
end;

procedure TFrmStyleTest.FormCreate(Sender: TObject);
begin
    Self.StyleBook := StyleBook;
    ApplyStyle('iOS.style');
end;

procedure TFrmStyleTest.Menu_File_QuitClick(Sender: TObject);
begin
    Close;
end;

procedure TFrmStyleTest.Rb_Style_0Click(Sender: TObject);
begin
    try
        ApplyStyle((Sender as TRadioButton).Text);
    except end;
end;

procedure TFrmStyleTest.tmr_ProcessTimer(Sender: TObject);
begin
    if (pb_Bar.Value + 1) > 100 then pb_Bar.Value := 0
    else pb_Bar.Value := pb_Bar.Value + 1;
end;

procedure TFrmStyleTest.ApplyStyle(swStyle:WideString);
begin
    if swStyle<>'' then StyleBook.FileName := swStyle;
    Ed_StyleName.Text := swStyle;
 end;

 end.

转载于:https://www.cnblogs.com/xieyunc/p/9126498.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值