FMX.SearchContext Sample
This sample demonstrates how to create and use a search context and how to use FireMonkey image effects.
Location
You can find the SearchContext sample project at:
- Start | Programs | Embarcadero RAD Studio Florence | Samples and navigate to:
Object Pascal\Multi-Device Samples\User Interface\SearchContextCPP\Multi-Device Samples\User Interface\SearchContext
- Subversion Repository:
- You can find Delphi and C++ code samples in GitHub Repositories. Search for the sample by name in the repository corresponding to your RAD Studio version.
Description
By modifying a TClearingEdit, the sample highlights a field and its associated icons using opacity and glow effects. It also provides a menu with options for loading and managing data, and uploading new images using LiveBindings.
Select Options > Manage Data to configure the search options. You can also double-click an icon image to add more icons.
How to Use the Sample
- To run the example, open its project file:
- Delphi:
SearchContext.dproj - C++:
SearchContext_Cpp.cbproj
- Delphi:
- Press F9 or choose Run > Run.
- Start typing a search term that matches the beginning of one of the "INTERNET" or "SYSTEM" items to see the matching item highlighted.
- Note: To deploy this sample application, you must first:
- Add the
iconData.cdsfile to the Deployment Manager for each target platform. - Add the MIDAS library to the Deployment Manager for each target platform.
- Add the
Files
| File | Class |
|---|---|
| unitSearchMenuHelperCpp | The TSearchItem, TSearchBand, and TSearchBandManager classes. |
| formMain |
|
| dataData | The TdtmdlData class. |
| formMain | The TfrmMain class. |
|
SearchContext (Delphi) |
The sample project files. |
Classes
- TSearchItem is a TLayout descendant that represents an item and its associated information. It contains:
- A TSearchState enumeration variable called FSearchState
- TRectangle called BackGroundRec
- TImage called Image
- TGlowEffect called GlowPartial
- TStringList called FSearchText
- TLabel called FooterLabel
- TCircle called BackGroundGlow
- TNotifyEvent called FOnDblClick
- TSearchBand is a TLayout descendant that contains:
- TGridLayout called FItemGrid
- TObjectList called FSearchItems
- TLabel called FBandTitle
- TSearchBandManager is a TLayout descendant that contains:
- TObjectList called FSearchBands
- TdtmdlData is a TDataModule descendant that contains:
- TClientDataSet called cdsIconData, which contains:
- TIntegerField called cdsIconDataID
- Two TStringField components called cdsIconDataCategory and cdsIconDataDescription
- TMemoField called cdsIconDataSearchTerms
- TBlobField called cdsIconDataIcon
- TDataSource called dsIconData
- TClientDataSet called cdsIconData, which contains:
- TfrmData is a secondary form accessible through the Options > Manage Data command. It descends from TForm and contains:
- TImageControl called ImageControl1
- Four TLabel components called Label1, Label2, Label3, and Label4
- Two TEdit components called Edit1 and Edit2
- TMemo called Memo1
- TOpenDialog called OpenDialog1
- TBindSourceDB called BindSourceDB1
- TBindingsList called BindingsList1
- Four TLinkControlToField components called LinkControlToField1, LinkControlToField2, LinkControlToField3, and LinkControlToField4
- TBindNavigator called NavigatorBindSourceDB1
- TfrmMain is the main form that provides the user interface. It descends from TForm and contains:
- Two TLayout components called Layout1 and Layout2
- TReflectionEffect called ReflectionEffect1
- TClearingEdit called edtSearch
- TOpenDialog called OpenDialog1
- TVertScrollBox called VertScrollBox1
- TMainMenu called MainMenu1, which contains:
- Four TMenuItem components called MenuItem4, miLoadData, miLoadImages, and miManageData
- TSearchBandManager called SearchBandManager
Implementation
When you run the application, the main window of the sample is displayed. You can perform the following actions:
- Select Options > Load Data to load the data. The sample also loads the data automatically when the main form is created.
- Select Options > Load Images to open a file dialog where you can select and load a new cdsIconData dataset after closing the previously loaded dataset.
- Select Options > Manage Data to open a TForm where you can use TBindNavigator to add, delete, and navigate through items.
- Search for a word and observe how the TGlowEffect and opacity change around the icons whose labels or associated search terms match the search text. The icons can display no glow, a partial glow (when only part of the word matches), or a full glow.
- Double-click an icon to display its corresponding list of search terms.
Uses
- FMX.Menus.TMainMenu
- FMX.Dialogs.TOpenDialog
- FMX.Layouts.TVertScrollBox
- FMX.StdCtrls.TPanel
- FMX.Edit.TClearingEdit
- FMX.Layouts.TLayout
- FMX.Effects.TReflectionEffect
- Data.Bind.DBScope.TBindSourceDB
- Data.Bind.Components.TBindingsList
- Data.Bind.Components.TLinkControlToField
- Fmx.Bind.Navigator.TBindNavigator
- FMX.Memo.TMemo
- FMX.Edit.TEdit
- FMX.StdCtrls.TImageControl
- Datasnap.DBClient.TClientDataSet
- Data.DB.TIntegerField
- Data.DB.TStringField
- Data.DB.TMemoField
- Data.DB.TBlobField
- Data.DB.TDataSource
- FMX.Objects.TRectangle
- FMX.Objects.TImage
- FMX.Effects.TGlowEffect
- FMX.Objects.TCircle
- System.Classes.TStringList
- System.Classes.TNotifyEvent
- FMX.Layouts.TGridLayout
- System.Generics.Collections.TObjectList