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 Athens | Samples and navigate to:
Object Pascal\Multi-Device Samples\User Interface\SearchContext
CPP\Multi-Device Samples\User Interface\SearchContext
- Subversion Repository:
- You can find Delphi and C++ code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
Description
By modifying a TClearingEdit, a field with its associated icons will be highlighted through its opacity and glow effects. It also uses a menu with options for loading data, managing data, and uploading new images using Live Bindings.
Select Options > Manage Data to configure the search options. You may also double click the 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 it highlighted.
- Note: If you want to deploy this sample application, first you must:
- Add to the Deployment Manager the
iconData.cds
file for any target platform. - Add the MIDAS library to the Deployment Manager as well for any target platform.
- Add to the Deployment Manager the
Files
File | Class |
---|---|
unitSearchMenuHelperCpp | The TSearchItem class, the TSearchBand class, the TSearchBandManager class |
formMain |
|
dataData | The TdtmdlData Class |
formMain | the TfrmMain Class |
SearchContext (Delphi) |
The project itself |
Classes
- TSearchItem is a form of TLayout, which represents an item with its specifics and it contains:
- a TSearchState enum 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 form of TLayout and it contains:
- TGridLayout called FItemGrid
- TObjectList called FSearchItems
- TLabel called FBandTitle
- TSearchBandManager is a form of TLayout and it contains:
- TObjectList called FSearchBands
- TdtmdlData is a form of TDataModule and it contains:
- TClientDataSet called cdsIconData and it contains:
- TIntegerField called cdsIconDataID
- Two TStringField called cdsIconDataCategory and cdsIconDataDescription
- TMemoField called cdsIconDataSearchTerms
- TBlobField called cdsIconDataIcon
- TDataSource called dsIconData
- TClientDataSet called cdsIconData and it contains:
- TfrmData is a secondary form, accesible through the Options > Manage Data command. It is a version of TForm and it contains:
- TImageControl called ImageControl1
- Four TLabel called Label1, Label2, Label3, and Label4
- Two TEdit called Edit1 and Edit2
- TMemo called ReflectionEffect1
- TOpenDialog called Memo1
- TBindSourceDB called BindSourceDB1
- TBindingsList called BindingsList1
- Four TLinkControlToField called LinkControlToField1, LinkControlToField2, LinkControlToField3, and LinkControlToField4
- TBindNavigator called NavigatorBindSourceDB1
- TfrmMain is the main form that constitutes the user interface. It is a version of TForm and it contains:
- Two TLayout called Layout1 and Layout2
- TReflectionEffect called ReflectionEffect1
- TClearingEdit called edtSearch
- TOpenDialog called OpenDialog1
- TVertScrollBox called VertScrollBox1
- TMainMenu called MainMenu1 contains :
- Four TMenuItem called MenuItem4, miLoadData, miLoadImages, and miManageData
- TSearchBandManager called SearchBandManager
Implementation
When you run the application, the main window of the sample is displayed:
- Select the Options > Load Data command to load the data. This also happens by default at the form creation.
- Select the Options > Load Images command to open a browse dialog, where you can select and open a new cdsIconData, after closing the former one.
- Select the Options > Manage Data command to open a TForm, where using TBindNavigator you can add, delete, and navigate through items.
- Search for a word and observe the TGlowEffect and Opacity change around the icons where the text matches either the label or one of its associated search terms. There can be no glow, partial glow (when a part of the word coresponds), and full glow.
- Double-click on 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.Dialogs.TOpenDialog
- 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