Introduction to Delphi xe2 firemonkey (15)-filter: Get filter information

Source: Internet
Author: User
Inheritance of filter classes:
 
Tobject-> tpersistent-> tfilter-> tshaderfilter-> {Specific filter class} // The following example uses FMX first. four common methods of filter unit: Procedure fillcategory (alist: tstrings); Procedure fillfiltersincategory (const category: string; alist: tstrings); function filterbyname (const aname: string): tfilter; function filterclassbyname (const aname: string): tfilterclass;
The fillcategory () method can be used to obtain the filter category list:
 
Fillcategory (listbox1.items );
You can use the fillfiltersincategory () method to obtain the Filter list of a category:
 
Fillfiltersincategory ('category name', listbox2.items );
You can use the filterbyname () method to obtain the filter object:
VaR filter: tfilter; begin filter: = filterbyname ('filter name'); // This is convenient, saving the need to manually create an end;
You can use the filterattr () method of tfilter to obtain the filter information:
 
VaR filter: tfilter; filterrec: tfilterrec; // filter information is encapsulated in a tfilterrec-type struct. Begin filter: = filterbyname ('filter name'); filterrec: = filter. filterattr; {because filterattr is a class method, you can also obtain it as follows} filterrec: = filterclassbyname ('filter name '). filterattr; end;
Tfilterrec structure:

 
Tfilterrec = Record Name: string; // Filter Name Desc: string; // filter description values: tshadervaluerecarray; // filter parameter array, tshadervaluerec type end;
Tshadervaluerec structure:

Tshadervaluerec = Record Name: string; // parameter name Desc: string; // parameter description valuetype: tshadervaluetype; // parameter type: vtfloat, vtpoint, vtcolor, vtbitmap (value, point, color value, image) value: variant; // parameter value min, Max, default: variant; // The minimum, maximum, and default value of the parameter end;
Test: Two tlistbox, one tmemo, and oncreate and tlistbox onclick events are required.

Uses system. typinfo; // used to obtain the enumeration name procedure tform1.formcreate (Sender: tobject); begin fillcategory (listbox1.items); // get the category name list end; Procedure tform1.listbox1click (Sender: tobject ); vaR stritem1: string; begin stritem1: = listbox1.items [listbox1.itemindex]; iterator (stritem1, listbox2.items); // obtain the Filter list listbox2.itemindex: = 0; listbox2.onclick (NiL) of the specified category ); end; Procedure extract (Sender: tobject); var stritem2: string; filter: tfilter; filterrec: tfilterrec; shadervaluerec: iterator; begin stritem2: = listbox2.items [listbox2.itemindex]; filter: = filterbyname (stritem2); // obtain the filter object filterrec: = Filter Using the Filter Name. filterattr; // get the information of the filter object // filterrec: = filterclassbyname (stritem ). filterattr; // memo1.text: = 'filter Class Name: '+ filter. tostring; // classname memo1.lines. add ('filter name: '+ filterrec. name); memo1.lines. add ('filter Description: '+ filterrec. DESC); memo1.lines. add ('----------------------------------------------'); For shadervaluerec in filterrec. values do begin memo1.lines. add ('parameter name: '+ shadervaluerec. name); memo1.lines. add ('parameter Description: '+ shadervaluerec. DESC); memo1.lines. add ('parameter type: '+ getenumname (typeinfo (tshadervaluetype), INTEGER (shadervaluerec. valuetype); If shadervaluerec. valuetype tshadervaluetype. vtbitmap then begin memo1.lines. add ('current value: '+ String (shadervaluerec. value); memo1.lines. add ('minimum: '+ String (shadervaluerec. min); memo1.lines. add ('default value: '+ String (shadervaluerec. default); memo1.lines. add ('maximum: '+ String (shadervaluerec. max); end; memo1.lines. add (emptystr); end;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.