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


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

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

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

    ..Program FilesEmbarcaderoRAD Studio9.0RediststylesFmx

    目录下,如果你要发布你的程序,将这里的你需要用到的.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.
  • 相关阅读:
    Spring源码解读 推荐流程
    Spring源码解读 推荐流程
    验证数据归属
    验证数据归属
    maven用途、核心概念、用法、常用参数和命令、扩展
    Reverse Linked List II
    Insertion Sort List
    Palindrome Partitioning
    Construct Binary Tree from Preorder and Inorder Traversal
    Valid Parentheses
  • 原文地址:https://www.cnblogs.com/xieyunc/p/9126498.html
Copyright © 2020-2023  润新知