Books Writers Publishers Languages

Delphi GUI programming with FireMonkey

Published by : Packt

Writed by : Andrea Magni

Published date : 29/10/2020

ISBN-13 : 9781788624176

Language : English English

Web site : https://www.packtpub.com/product/delphi-gui-programming-with-firemonkey/9781788624176

About Delphi GUI programming with FireMonkey

This book will be your guide to learning GUI Programming with Delphi. It will introduce you to the FireMonkey – a cross platform framework for GUI programming.

The book starts with a brief intro on FireMonkey framework, by exploring its fundamental and architectural details and what sets it apart from VCL. We then move on to look at the FMX in details covering the aspects like, main components, style concept and elastic UIs. We then move on to look at how responsiveness is a key desirable feature and the Do’s and Don’ts while dealing with parallel programming and UIs. We look at cross platform services and platform specific features of the FMX framework before learning about the vector graphics and 3D functionalities.

By the end of the book you will gain insight into FMX framework’s features, style, use of animation and so on to build effective UIs and achieve rich user experience.

More infos in this interview with Andrea Magni.

You can also read Andreas' official release announcement on his blog.

Where to buy ?

This book has the ISBN13 "9781788624176".
If it is still available for sale, you can order it in your favorite bookstore, by its publisher or online at
Amazon CA, Amazon FR, Amazon JP, Amazon UK or Amazon USA depending on your country.

Table of content

Preface 1

Section 1: Delphi GUI Programming Frameworks

Chapter 1: Introducing the FireMonkey Framework 9
Technical requirements 10
Approaching FireMonkey 10
Abstracting the visual part of your apps 15
Looking beyond the UI 16
Back to the metal 17
Understanding the strengths and weaknesses 18
Summary 21

Chapter 2: Exploring Similarities and Differences with VCL 22
Technical requirements 23
Understanding RTL for everyone 23
Learning about component streaming 25
Understanding the Style Designer 31
Learning about components 35
Handling the placement and sizing of components 39
Understanding anchors 39
Learning about alignments 44
Understanding actions 48
Learning about data binding 51
Summary 54

Section 2: The FMX Framework in Depth

Chapter 3: Mastering Basic Components 57
Technical requirements 58
Understanding the TText component 58
Learning about the TLabel component 62
Understanding shapes 64
Learning about the TLine class 68
Understanding the TRectangle class 70
Learning about the TCircle component 72
Managing images effectively 74
Learning about the MultiResBitmaps unit 75
TImage 79
TImageViewer 81
TImageList 81
TGlyph 87
Learning about buttons 89
TSpeedButton 93
Summary 94

Chapter 4: Discovering Lists and Advanced Components 95
Technical requirements 96
Learning about lists 96
TListBox 97
TListView 102
Providing data for the list 103
Item appearances 105
Custom appearance 109
Dynamic appearance 110
TListView's style customization 112
Basic event handling 116
Search capabilities 117
Pull to refresh 118
Exploring treeviews 121
Customizing TTreeview's items 125
Using grids 129
TGrid and TStringGrid 133
Customizing TGrid and TStringGrid 137
Mastering drawers and panels 138
Drawer mode 139
NavigationPane mode 141
Panel mode 143
Popover mode 144
PlatformBehavior mode 145
Custom mode 146
Summary 146

Chapter 5: Using FireDAC in FMX Applications 147
Technical requirements 148
Learning about the FireDAC library 148
Understanding the library's composition 150
Understanding the options system 152
Exploring FetchOptions properties 152
Exploring FormatOptions properties 154
Exploring ResourceOptions properties 155
Exploring UpdateOptions properties 158
Working with macros and parameters 160
Taking advantage of memory tables 164
Connecting to a database 169
Introducing Tables, Query, StoredProc, and Command 174
Understanding dataset persistence 177
Implementing an onboard database 180
Exploring the LocalSQL feature 183
Summary 187

Chapter 6: Implementing Data Binding 188
Technical requirements 188
Introduction to data binding 189
Approaching LiveBindings 189
Introducing managed bindings 190
Understanding what happens under the hood 194
Mastering real-world data bindings 198
Introducing BindSources 198
Binding a field value to a property – TLinkPropertyToField 201
Binding a dataset field value to a control – TLinkControlToField 206
Formatting data 207
Exploring CustomFormat/CustomParse expressions 208
Understanding LiveBindings methods 210
Creating the package (FormatFloatPackage) 213
Implementing the wrapper (FormatFloatInvokable) 214
Building and installing the package 217
Testing at design time and using it at runtime 217
Making custom method calls available 220
Binding a dataset to a list control – TLinkListControlToField 222
Filling items with data 225
Associating images with data 229
LiveBindings events 230
Binding a dataset to a grid control – TLinkGridToDataSource 231
Summary 237

Chapter 7: Understanding FMX Style Concept 238
Technical requirements 239
Learning about multi-platform visual programming 239
Introducing the Style concept 241
Understanding the anatomy of a style 247
Managing style(s) in the IDE 248
Binding a component to its style 249
Exploring the style definition of a component 250
Approaching the TStyleBook component 254
Learning about Vector styles 255
Understanding Bitmap styles 257
Adding animation, triggers, and effects 263
Managing styles – the TStyleManager component 263
Understanding the selection algorithm 264
Loading a style from embedded resources 269
Learning about platform-native controls 271
Summary 274

Chapter 8: Divide and Conquer with TFrameStand 275
Technical requirements 276
Introducing TFrameStand 276
Designing UIs for mobile applications 277
Learning about the DRY principle 280
Understanding visual continuity 285
Exploring TFrameStand – Hello, World! 288
Implementing views 291
Understanding the THomeFrame frame 293
Learning about the TOrdersFrame frame 295
Understanding the TOrderDetailsFrame frame 297
Defining the stand(s) 300
Learning about animations 305
Defining the fader stand 305
Defining the slider stand 306
Learning about TFormStand 309
Summary 310

Chapter 9: Building Responsive UIs 312
Technical requirements 312
Understanding responsiveness—visual meaning 313
Exploring Bootstrap's grid system 313
Understanding the relevant factors of responsiveness 316
Leveraging device and application peculiarities 316
Handling changes in device orientation 317
Considering the field of application 318
Understanding screen resolution and density 319
Building visual layouts 324
Arranging components with TLayout 327
Letting components flow as text with TFlowLayout 332
Building grid layouts with TGridLayout 335
Advanced arrangements with TGridPanelLayout 336
Introducing FireUI technology 338
Creating a new view 339
The Multi-Device Preview window 345
Using the FireUI Live Preview app 346
Considering other FireUI capabilities 351
Exploring TFormStand 353
Summary 355

Chapter 10: Orchestrating Transitions and Animations 356
Technical requirements 357
Introducing animations and transitions 357
Learning about interpolation 358
Understanding non-linear interpolations 360
Working with the FMXAni demo project 364
Learning about the TAnimation class 367
Understanding global animation management 372
Understanding interpolation modifier functions 373
Learning about TAnimator shortcuts 379
Learning about specialized animation components 381
TFloatAnimation 383
TFloatKeyAnimation 384
TColorAnimation 386
TColorKeyAnimation 389
TGradientAnimation 389
TRectAnimation 389
TBitmapAnimation 389
TBitmapListAnimation 390
TPathAnimation 392
Summary 396

Section 3: Pushing to The Top: Advanced Topics

Chapter 11: Building Responsive Applications 398
Technical requirements 398
Understanding multithreading 399
Understanding the thread safety of UI frameworks 401
Synchronous versus asynchronous execution 402
Utilizing the Synchronize method 404
Learning about the Queue approach 408
Exploring threads and tasks 410
Introducing the TThread class 412
Understanding a thread's lifespan 414
Exploring alternative solutions 422
Introducing the Parallel Programming Library 425
Introducing the TTask class 427
Dealing with synchronization 429
Waiting for a task to complete 429
Waiting for tasks to finish 433
Learning about futures 434
Summary 436
Further reading 436

Chapter 12: Exploring Cross-Platform Services 437
Technical requirements 438
Accessing the clipboard service 438
Understanding copying and pasting text 440
Learning about copying and pasting graphic content 442
Managing dialog forms 445
Understanding differences between synchronous versus asynchronous
modes 446
Leveraging touch capabilities 451
Playing with the form's OnTouch event 451
Considering the form's OnTap event 453
Exploring standard gestures 455
Implementing interactive gestures 458
Understanding messaging support 460
Introducing message definitions as data types 461
Sending messages through the message manager 462
Subscribing and responding to messages 466
Using native HTTP client implementations 468
Getting familiar with Bluetooth support 472
Scanning for devices 474
Connecting to a BLE device 475
Subscribing for notifications 476
Summary 477

Chapter 13: Learning about FMX 3D Capabilities 478
Technical requirements 479
Introducing 3D programming with FMX 479
Building a 3D application 481
Building a 3D "Hello, world!" application 482
Understanding TDummy and the design-time camera 487
Setting up a 3D viewport 489
Understanding lights and materials 496
Learning about lights 496
Learning about the materials 498
Merging 3D and 2D visual objects 498
Using the TLayer3D component 499
Merging TFrameStand with 3D visuals 503
Summary 505

Other Books You May Enjoy 506

Index 509

Preface 1

Section 1: Delphi GUI Programming Frameworks

Chapter 1: Introducing the FireMonkey Framework 9
Technical requirements 10
Approaching FireMonkey 10
Abstracting the visual part of your apps 15
Looking beyond the UI 16
Back to the metal 17
Understanding the strengths and weaknesses 18
Summary 21

Chapter 2: Exploring Similarities and Differences with VCL 22
Technical requirements 23
Understanding RTL for everyone 23
Learning about component streaming 25
Understanding the Style Designer 31
Learning about components 35
Handling the placement and sizing of components 39
Understanding anchors 39
Learning about alignments 44
Understanding actions 48
Learning about data binding 51
Summary 54

Section 2: The FMX Framework in Depth

Chapter 3: Mastering Basic Components 57
Technical requirements 58
Understanding the TText component 58
Learning about the TLabel component 62
Understanding shapes 64
Learning about the TLine class 68
Understanding the TRectangle class 70
Learning about the TCircle component 72
Managing images effectively 74
Learning about the MultiResBitmaps unit 75
TImage 79
TImageViewer 81
TImageList 81
TGlyph 87
Learning about buttons 89
TSpeedButton 93
Summary 94

Chapter 4: Discovering Lists and Advanced Components 95
Technical requirements 96
Learning about lists 96
TListBox 97
TListView 102
Providing data for the list 103
Item appearances 105
Custom appearance 109
Dynamic appearance 110
TListView's style customization 112
Basic event handling 116
Search capabilities 117
Pull to refresh 118
Exploring treeviews 121
Customizing TTreeview's items 125
Using grids 129
TGrid and TStringGrid 133
Customizing TGrid and TStringGrid 137
Mastering drawers and panels 138
Drawer mode 139
NavigationPane mode 141
Panel mode 143
Popover mode 144
PlatformBehavior mode 145
Custom mode 146
Summary 146

Chapter 5: Using FireDAC in FMX Applications 147
Technical requirements 148
Learning about the FireDAC library 148
Understanding the library's composition 150
Understanding the options system 152
Exploring FetchOptions properties 152
Exploring FormatOptions properties 154
Exploring ResourceOptions properties 155
Exploring UpdateOptions properties 158
Working with macros and parameters 160
Taking advantage of memory tables 164
Connecting to a database 169
Introducing Tables, Query, StoredProc, and Command 174
Understanding dataset persistence 177
Implementing an onboard database 180
Exploring the LocalSQL feature 183
Summary 187

Chapter 6: Implementing Data Binding 188
Technical requirements 188
Introduction to data binding 189
Approaching LiveBindings 189
Introducing managed bindings 190
Understanding what happens under the hood 194
Mastering real-world data bindings 198
Introducing BindSources 198
Binding a field value to a property – TLinkPropertyToField 201
Binding a dataset field value to a control – TLinkControlToField 206
Formatting data 207
Exploring CustomFormat/CustomParse expressions 208
Understanding LiveBindings methods 210
Creating the package (FormatFloatPackage) 213
Implementing the wrapper (FormatFloatInvokable) 214
Building and installing the package 217
Testing at design time and using it at runtime 217
Making custom method calls available 220
Binding a dataset to a list control – TLinkListControlToField 222
Filling items with data 225
Associating images with data 229
LiveBindings events 230
Binding a dataset to a grid control – TLinkGridToDataSource 231
Summary 237

Chapter 7: Understanding FMX Style Concept 238
Technical requirements 239
Learning about multi-platform visual programming 239
Introducing the Style concept 241
Understanding the anatomy of a style 247
Managing style(s) in the IDE 248
Binding a component to its style 249
Exploring the style definition of a component 250
Approaching the TStyleBook component 254
Learning about Vector styles 255
Understanding Bitmap styles 257
Adding animation, triggers, and effects 263
Managing styles – the TStyleManager component 263
Understanding the selection algorithm 264
Loading a style from embedded resources 269
Learning about platform-native controls 271
Summary 274

Chapter 8: Divide and Conquer with TFrameStand 275
Technical requirements 276
Introducing TFrameStand 276
Designing UIs for mobile applications 277
Learning about the DRY principle 280
Understanding visual continuity 285
Exploring TFrameStand – Hello, World! 288
Implementing views 291
Understanding the THomeFrame frame 293
Learning about the TOrdersFrame frame 295
Understanding the TOrderDetailsFrame frame 297
Defining the stand(s) 300
Learning about animations 305
Defining the fader stand 305
Defining the slider stand 306
Learning about TFormStand 309
Summary 310

Chapter 9: Building Responsive UIs 312
Technical requirements 312
Understanding responsiveness—visual meaning 313
Exploring Bootstrap's grid system 313
Understanding the relevant factors of responsiveness 316
Leveraging device and application peculiarities 316
Handling changes in device orientation 317
Considering the field of application 318
Understanding screen resolution and density 319
Building visual layouts 324
Arranging components with TLayout 327
Letting components flow as text with TFlowLayout 332
Building grid layouts with TGridLayout 335
Advanced arrangements with TGridPanelLayout 336
Introducing FireUI technology 338
Creating a new view 339
The Multi-Device Preview window 345
Using the FireUI Live Preview app 346
Considering other FireUI capabilities 351
Exploring TFormStand 353
Summary 355

Chapter 10: Orchestrating Transitions and Animations 356
Technical requirements 357
Introducing animations and transitions 357
Learning about interpolation 358
Understanding non-linear interpolations 360
Working with the FMXAni demo project 364
Learning about the TAnimation class 367
Understanding global animation management 372
Understanding interpolation modifier functions 373
Learning about TAnimator shortcuts 379
Learning about specialized animation components 381
TFloatAnimation 383
TFloatKeyAnimation 384
TColorAnimation 386
TColorKeyAnimation 389
TGradientAnimation 389
TRectAnimation 389
TBitmapAnimation 389
TBitmapListAnimation 390
TPathAnimation 392
Summary 396

Section 3: Pushing to The Top: Advanced Topics

Chapter 11: Building Responsive Applications 398
Technical requirements 398
Understanding multithreading 399
Understanding the thread safety of UI frameworks 401
Synchronous versus asynchronous execution 402
Utilizing the Synchronize method 404
Learning about the Queue approach 408
Exploring threads and tasks 410
Introducing the TThread class 412
Understanding a thread's lifespan 414
Exploring alternative solutions 422
Introducing the Parallel Programming Library 425
Introducing the TTask class 427
Dealing with synchronization 429
Waiting for a task to complete 429
Waiting for tasks to finish 433
Learning about futures 434
Summary 436
Further reading 436

Chapter 12: Exploring Cross-Platform Services 437
Technical requirements 438
Accessing the clipboard service 438
Understanding copying and pasting text 440
Learning about copying and pasting graphic content 442
Managing dialog forms 445
Understanding differences between synchronous versus asynchronous
modes 446
Leveraging touch capabilities 451
Playing with the form's OnTouch event 451
Considering the form's OnTap event 453
Exploring standard gestures 455
Implementing interactive gestures 458
Understanding messaging support 460
Introducing message definitions as data types 461
Sending messages through the message manager 462
Subscribing and responding to messages 466
Using native HTTP client implementations 468
Getting familiar with Bluetooth support 472
Scanning for devices 474
Connecting to a BLE device 475
Subscribing for notifications 476
Summary 477

Chapter 13: Learning about FMX 3D Capabilities 478
Technical requirements 479
Introducing 3D programming with FMX 479
Building a 3D application 481
Building a 3D "Hello, world!" application 482
Understanding TDummy and the design-time camera 487
Setting up a 3D viewport 489
Understanding lights and materials 496
Learning about lights 496
Learning about the materials 498
Merging 3D and 2D visual objects 498
Using the TLayer3D component 499
Merging TFrameStand with 3D visuals 503
Summary 505

Other Books You May Enjoy 506

Index 509