Delphi GUI Programming
with FireMonkey
Unleash the full potential of the FMX framework to build exciting cross-platform apps with Embarcadero Delphi
Andrea Magni
BIRMINGHAM - MUMBAI
Delphi GUI Programming with FireMonkey
Copyright 2020 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author(s), nor Packt Publishing or its dealers and distributors, will be held liable for any damages caused or alleged to have been caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
Commissioning Editor: Kunal Chaudhari
Acquisition Editor: Alok Dhuri
Content Development Editor: Rosal Colaco
Senior Editor: Rohit Singh
Technical Editor: Gaurav Gala
Copy Editor: Safis Editing
Project Coordinator: Francy Puthiry
Proofreader: Safis Editing
Indexer: Rekha Nair
Production Designer: Aparna Bhagat
First published: October 2020
Production reference: 1281020
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham
B3 2PB, UK.
ISBN 978-1-78862-417-6
www.packt.com
I've always loved technology and computer programming. Thanks to my father, I had access to computers when it was neither easy nor popular to have. This, together with my personal inclination to problem-solving, made me a software developer way before I graduated from university as a computer engineer. For me and Delphi, it was love at first sight, even when I was still a kid. The Italian Delphi community (strongly backed by Marco Cant, the Delphi guru since forever and the current RAD studio product manager at Embarcadero Technologies) is the cradle where I started my growth into the professional that I am today.
Besides Marco, I really have to thank many people who helped me a lot. Among all of them, I'd especially like to mention two: Uberto Barbini, who was the first one to believe in me and offer me a job, and Nando Dessena, who has been (and still is) my mentor and an irreplaceable source of knowledge. I also owe a lot to my customers over the years, who trusted a very young guy (in the past, at least) when there were not many evident reasons for doing so.
During the last 5 years or so, I've opened up a great deal to the worldwide Delphi community, starting in Europe. There are so many Delphi gurus and talented developers out there that it is simply impossible to mention them all. All of them have brought some light to my path to becoming a better software developer, and to them I pay much respect. I also want to thank Jim McKeeth (chief developer advocate and engineer at Embarcadero Technologies) for all the effort he puts into promoting Delphi worldwide and coordinating MVP activities.
Now that I am an experienced Delphi developer, it is my turn to give back to the community some of the knowledge I've tried to collect over the years. This is the main reason I've written this book, adding this to my regular activity as Embarcadero MVP (technical blog, conferences) and an author of Delphi-related Open-Source Software projects.
Writing a technical book proved to be quite an effort for me, and this makes my admiration for all those prolific authors of Delphi-related books out there greater and greater.
This book is especially dedicated to these people:
My wife, Marta, for the love, support, and inspiration through all these years; and my lovely daughter, Federica: I hope that you always keep your happiness and curiosity.
Andrea Magni
Packt.com
Subscribe to our online digital library for full access to over 7,000 books and videos, as well as industry leading tools to help you plan your personal development and advance your career. For more information, please visit our website.
Why subscribe?
Spend less time learning and more time coding with practical eBooks and Videos from over 4,000 industry professionals
Improve your learning with Skill Plans built especially for you
Get a free eBook or video every month
Fully searchable for easy access to vital information
Copy and paste, print, and bookmark content
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.packt.com and as a print book customer, you are entitled to a discount on the eBook copy. Get in touch with us at customercare@packtpub.com for more details.
At www.packt.com , you can also read a collection of free technical articles, sign up for a range of free newsletters, and receive exclusive discounts and offers on Packt books and eBooks.
Foreword
For many years since its release, Delphi development was tied to the Microsoft Windows platform and based on the VCL library, which is deeply rooted in the Windows API. As Embarcadero started attempting a foray into mobile development, it became clear that the challenge of building single-source, multi-device applications required a rethink of the user interface controls library, while keeping the core foundations of Delphi and its runtime library made sense.
The original solution was to create a library that represents components in terms of their primitive graphical elements, so that the same component could draw itself with different graphical elements depending on the platform, making it almost identical to the platform controls. In this way, you create a button, which looks like a classic button on Windows, an Android one on the Google mobile OS, and an iOS element on the Apple OS. As operating systems evolve their UI style, the library can keep up and be updated. This is the essence of FireMonkey and its styling architecture.
The second core element of the architecture is that its Graphical User Interface (GUI) rendering is mapped to the Graphical Processing Unit (GPU) with drivers that use the optimal GPU solution for each platform (at times offering more than one). This is the direction all the cross-platform frameworks are embracing today, so we can say that FireMonkey was ahead of time in its design. Finally, the library uses its styling architecture to allow mapping controls to native platform user interface components (such as the web and maps, but also input controls).
Next page