{"id":4713,"date":"2017-09-27T17:21:20","date_gmt":"2017-09-27T09:21:20","guid":{"rendered":"http:\/\/blog.qdac.cc\/?p=4713"},"modified":"2017-09-27T17:23:37","modified_gmt":"2017-09-27T09:23:37","slug":"fmx%e5%9c%a8%e7%a8%8b%e5%ba%8f%e4%b8%ad%e4%bd%bf%e7%94%a8%e5%b7%b2%e6%9c%89%e7%9a%84%e6%a0%b7%e5%bc%8f%e6%9d%a5%e6%b8%b2%e6%9f%93","status":"publish","type":"post","link":"https:\/\/blog.qdac.cc\/?p=4713","title":{"rendered":"[FMX]\u5728\u7a0b\u5e8f\u4e2d\u4f7f\u7528\u5df2\u6709\u7684\u6837\u5f0f\u505a\u81ea\u5df1\u9700\u8981\u7684\u6e32\u67d3"},"content":{"rendered":"<p>\u4eca\u5929\u6211\u4eec\u6765\u505a\u4e00\u4ef6\u574f\u4e8b\uff0c\u6211\u4eec\u90fd\u662f\u574f\u5b69\u5b50\u2026\u2026<\/p>\n<p>\u6211\u4eec\u77e5\u9053\uff0cFMX \u662f\u6709 StyleBook\uff0c\u6bcf\u4e2a\u63a7\u4ef6\u6709\u81ea\u5df1\u7684\u6837\u5f0f,\u4f46\u6709\u65f6\u5019\uff0c\u6211\u4eec\u8981\u7ed8\u5236\u81ea\u7ed8\u4e00\u4e9b\u72b6\u6001\uff0c\u96be\u9053\u975e\u8981\u7528\u6237\u91cd\u65b0\u5b9a\u4e49\u4e00\u5806\u6837\u5f0f\u5417\uff1f\u4e3a\u5565\u4e0d\u80fd\u5229\u7528\u73b0\u6210\u7684\u6837\u5f0f\u5462\uff0c\u6bd4\u5982\uff0c\u6211\u5c31\u53ea\u662f\u8981\u81ea\u7ed8\u4e00\u4e2aCheckBox\uff0c\u4f46\u6211\u8fd8\u4e0d\u60f3\u653e\u7f6e\u4e00\u4e2aTCheckBox\u7ec4\u4ef6\uff0c\u90a3\u4e48\u600e\u4e48\u6765\u505a\u5462\uff1f<\/p>\n<p>\u7b2c\u4e00\uff1a\u6211\u4eec\u9700\u8981\u77e5\u9053 TCheckBox \u4f7f\u7528\u7684\u6837\u5f0f\u540d\u79f0\uff0c \u6309\u7167\u5b98\u65b9\u7684\u547d\u540d\u89c4\u5219\uff0c\u5b83\u662f\u53bb\u6389 T\uff0c\u53d8\u5c0f\u5199\uff0c\u7136\u540e\u518d\u52a0 style\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u6837\u5f0f\u7684\u540d\u79f0\u4e3a checkboxstyle\u3002<\/p>\n<p>\u7b2c\u4e8c\uff1a\u6211\u4eec\u9700\u8981\u77e5\u9053\u6211\u4eec\u8981\u627e\u7684\u6837\u5f0f\u7684\u540d\u79f0\uff0c\u5bf9\u4e8e CheckBox\uff0c\u5b83\u662f background\uff0c\u5f53\u7136\u4f60\u4e5f\u53ef\u4ee5\u4e0d\u8981\u53bb\u7ba1\u5b83\uff0c\u4f60\u6309\u7c7b\u578b\u6765\u627e\uff0c\u6bd4\u5982\u8fd9\u91cc\u662f\u5b83\u5b50\u5bf9\u8c61\u4e2d\u7c7b\u578b\u4e3a TCheckStyleObject \u7c7b\u578b\u7684\u5bf9\u8c61\u3002<\/p>\n<p>\u7b2c\u4e09\uff1a\u5982\u679c\u6211\u4eec\u662f\u901a\u8fc7\u540d\u79f0\u6765\u627e\u7684\u8bdd\uff0c\u5c31\u9700\u8981\u5224\u65ad\u4e0b\u662f\u4e0d\u662f\u5bf9\u5e94\u7684\u6837\u5f0f\u5bf9\u8c61\uff0c\u5982\u679c\u4e0d\u662f\uff0c\u5c31\u4e0d\u80fd\u7ee7\u7eed\u4e86\uff0c\u5982\u679c\u662f\u624d\u80fd\u7ee7\u7eed\u3002\u5982\u679c\u662f\u7684\u8bdd\uff0c\u6211\u4eec\u5c31\u53ef\u4ee5\u8c03\u7528\u6837\u5f0f\u5bf9\u8c61\u7684 DrawToCanvas \u65b9\u6cd5\uff0c\u5c06\u5176\u7ed8\u5236\u5230\u76ee\u6807\u753b\u5e03\u4e0a\u4e86\u3002<\/p>\n<p>\u5230\u4e86\u8fd9\u4e00\u6b65\uff0c\u6211\u4eec\u5c31\u753b\u51fa\u4e86\u4e00\u4e2a\u7b80\u5355\u7684\u590d\u9009\u6846\uff0c\u4f46\u662f\u5982\u679c\u6211\u4eec\u8981\u7ed8\u5236\u4e00\u4e2a\u9009\u4e2d\u7684\u590d\u9009\u6846\u600e\u4e48\u529e\uff1f\u7ee7\u7eed<\/p>\n<p>\u7b2c\u56db\uff1a\u6211\u4eec\u8981\u6dfb\u52a0\u4e00\u4e2aIsChecked \u5c5e\u6027\uff0c\u5f53\u7136\u5982\u679c\u662f\u522b\u7684\u5c5e\u6027\uff08\u5e03\u5c14\u503c\uff09\uff0c\u4f60\u5c31\u9700\u8981\u8bbe\u7f6e TCheckStyleObject \u5bf9\u8c61\u7684 ActiveTrigger\uff0c\u8bbe\u7f6e\u540e\u8c03\u7528 StartTriggerAnimation \u6765\u542f\u7528\u8fd9\u4e2a\u89e6\u53d1\u5668\uff0c\u6bd4\u5982 IsChecked\u3002<\/p>\n<p>\u7b2c\u4e94\uff1a\u56de\u5230\u7b2c\u4e09\u6b65\uff0c\u7ed8\u5236\u5230\u753b\u5e03\u4e0a\u5c31\u597d\u4e86\u3002<\/p>\n<p>\u7b80\u5355\u7684\u53c2\u8003\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre class=\"lang:delphi decode:true\">uses fmx.styles.objects;\r\n{$R *.fmx}\r\n\r\nprocedure TForm1.FormPaint(Sender: TObject; Canvas: TCanvas;\r\n  const ARect: TRectF);\r\nvar\r\n  ARes: TFMXObject;\r\n  AStyle: TCheckStyleObject;\r\nbegin\r\n  ARes := TStyledControl.LookupStyleObject(nil, nil, Self, 'checkboxstyle', '',\r\n    '', false);\r\n  ARes := ARes.FindStyleResource('background', true);\r\n  if Assigned(ARes) and (ARes is TCheckStyleObject) then\r\n  begin\r\n    AStyle := TCheckStyleObject(ARes as TCheckStyleObject);\r\n    AStyle.StartTriggerAnimation(Self, 'IsChecked');\/\/\u53ea\u7ed8\u5236\u666e\u901a\u7684\u9009\u62e9\u6846\u4e0d\u9700\u8981\u5b83\uff0c\u66f4\u5177\u4f53\u8bf7\u770b Delphi \u81ea\u5df1\u7684\u6e90\u7801\u5b9e\u73b0\r\n    AStyle.DrawToCanvas(Canvas, RectF(10, 10, 10 + AStyle.Width,\r\n      10 + AStyle.Height));\r\n  end;\r\nend;\r\n\r\nfunction TForm1.GetIsChecked: Boolean;\r\nbegin\r\n  Result := true;\r\nend;\r\n<\/pre>\n<p>\u5f53\u7136\u4e86\uff0c\u5982\u679c\u5acc\u8fd9\u91cc\u8c03\u7528 StartTrigger \u9ebb\u70e6\uff0c\u76f4\u63a5\u4fee\u6539\u5176\u79c1\u6709\u7684 FState \u6210\u5458\u5c31\u5f97\u4e86\uff0c\u5177\u4f53\u65b9\u6cd5\uff0c\u53c2\u8003\u4ee5\u524d\u7684\u6587\u7ae0\u3002<\/p>\n<p>\u597d\u5427\uff0c\u9644\u4e2a\u56fe\uff0c\u6709\u56fe\u6709\u771f\u76f8\uff1a<\/p>\n<p><a href=\"https:\/\/blog.qdac.cc\/wp-content\/uploads\/2017\/09\/customstyledrawer.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-4717\" src=\"https:\/\/blog.qdac.cc\/wp-content\/uploads\/2017\/09\/customstyledrawer.png\" alt=\"\" width=\"213\" height=\"141\" \/><\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4eca\u5929\u6211\u4eec\u6765\u505a\u4e00\u4ef6\u574f\u4e8b\uff0c\u6211\u4eec\u90fd\u662f\u574f\u5b69\u5b50\u2026\u2026 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[69,8,603],"tags":[321,735],"class_list":["post-4713","post","type-post","status-publish","format-standard","hentry","category-c-builder","category-delphi","category-603","tag-321","tag-735"],"views":4013,"_links":{"self":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4713","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4713"}],"version-history":[{"count":4,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4713\/revisions"}],"predecessor-version":[{"id":4718,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=\/wp\/v2\/posts\/4713\/revisions\/4718"}],"wp:attachment":[{"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4713"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4713"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.qdac.cc\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4713"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}