Delphi GUI Programming with FireMonkey
eBook - ePub

Delphi GUI Programming with FireMonkey

Unleash the full potential of the FMX framework to build exciting cross-platform apps with Embarcadero Delphi

Andrea Magni

Share book
  1. 546 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Delphi GUI Programming with FireMonkey

Unleash the full potential of the FMX framework to build exciting cross-platform apps with Embarcadero Delphi

Andrea Magni

Book details
Book preview
Table of contents
Citations

About This Book

Create modern yet effective multi-platform applications by building interactive UIs following a single codebase approach to boost productivity

Key Features

  • Delve into the FireMonkey framework and explore its powerful capabilities
  • Enhance the user experience by using various technologies included in Delphi and FMX
  • Boost developer productivity through the cross-platform capabilities enabled by the framework

Book Description

FireMonkey (FMX) is a cross-platform application framework that allows developers to create exciting user interfaces and deliver applications on multiple operating systems (OS). This book will help you learn visual programming with Delphi and FMX.

Starting with an overview of the FMX framework, including a general discussion of the underlying philosophy and approach, you'll then move on to the fundamentals and architectural details of FMX. You'll also cover a significant comparison between Delphi and the Visual Component Library (VCL). Next, you'll focus on the main FMX components, data access/data binding, and style concepts, in addition to understanding how to deliver visually responsive UIs. To address modern application development, the book takes you through topics such as animations and effects, and provides you with a general introduction to parallel programming, specifically targeting UI-related aspects, including application responsiveness. Later, you'll explore the most important cross-platform services in the FMX framework, which are essential for delivering your application on multiple platforms while retaining the single codebase approach. Finally, you'll learn about FMX's built-in 3D functionalities.

By the end of this book, you'll be familiar with the FMX framework and be able to build effective cross-platform apps.

What you will learn

  • Explore FMX's fundamental components with a brief comparison to VCL
  • Achieve visual responsiveness through alignment capabilities and layout components
  • Enrich the user experience with the help of transitions and visual animations
  • Get to grips with data access and visual data binding
  • Build exciting and responsive UIs for desktop and mobile platforms
  • Understand the importance of responsive applications using parallel programming
  • Create visual continuity through your applications with TFrameStand and TFormStand
  • Explore the 3D functionalities offered by FMX

Who this book is for

This book is for Delphi developers who are looking to discover the full potential of the FireMonkey framework in order to build interactive cross-platform GUI applications and achieve an optimal UI/UX. Basic familiarity with Delphi programming and the VCL will be beneficial but not mandatory.

Frequently asked questions

How do I cancel my subscription?
Simply head over to the account section in settings and click on “Cancel Subscription” - it’s as simple as that. After you cancel, your membership will stay active for the remainder of the time you’ve paid for. Learn more here.
Can/how do I download books?
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
What is the difference between the pricing plans?
Both plans give you full access to the library and all of Perlego’s features. The only differences are the price and subscription period: With the annual plan you’ll save around 30% compared to 12 months on the monthly plan.
What is Perlego?
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Do you support text-to-speech?
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Is Delphi GUI Programming with FireMonkey an online PDF/ePUB?
Yes, you can access Delphi GUI Programming with FireMonkey by Andrea Magni in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming Languages. We have over one million books available in our catalogue for you to explore.

Information

Year
2020
ISBN
9781788621236
Edition
1
Section 1: Delphi GUI Programming Frameworks
This section will introduce you to the FMX application framework and explain some of its capabilities in relation to another Delphi product: the Visual Component Library (VCL). We are going to explore the context in which FMX has been designed and implemented in order to understand how its peculiarities suit a product such as Delphi (or RAD Studio).
The comparison with VCL will be extremely useful if you are already familiar with Delphi and VCL, but also, if you are using Delphi for the first time, many fundamental concepts are summarized in this section and you will see how these concepts fit together.
This section contains the following chapters:
  • Chapter 1, Introducing the FireMonkey Framework
  • Chapter 2, Exploring Similarities and Differences with VCL
Introducing the FireMonkey Framework
Welcome to the first chapter of this book! We are at the beginning of a journey to gain knowledge about a great application framework, that is, the FireMonkey (FMX) framework. These days, developers face a hard-to-solve problem—building effective cross-platform applications. From a project management point of view, one of the most wanted features is to achieve this goal through a single source code base, not, for example, having a different code base for each supported platform.
The introduction of the FireMonkey framework represented a crucial point, putting Embarcadero Delphi in a magic spot in the global software development scenario. Developers are enabled to design and build native applications for the most popular platforms, including both desktop (Microsoft Windows, Linux, and Apple OS X, now also known as macOS) and mobile (Google Android and Apple iOS), using a single toolset and language (thus reducing the effort needed).
This chapter will go through the following topics, to provide some background about what FMX is, why it was created, and its most evident strengths:
  • Approaching FireMonkey
  • Abstracting the visual part of your apps
  • Looking beyond the UI
  • Back to the metal
  • Understanding the strengths and weaknesses of the FMX approach
After reading this chapter, you will be familiar with the general context in which this framework has been developed, including a general understanding of the underlying philosophy of the chosen approach.

Technical requirements

Here is the source code used in this chapter: https://github.com/PacktPublishing/Delphi-GUI-Programming-with-FireMonkey/tree/master/Chapter%2001/HelloWorld.
Generally speaking, for the whole book, you need a computer with Delphi set up and a few additional libraries installed (such as Radiant Shapes (https://getitnow.embarcadero.com/?q=radiant+shapes) and CodeSite Logging (https://getitnow.embarcadero.com/?q=codesite)). Having other physical devices and setting up multiple platforms (iOS, Android, OS X/macOS, and Linux) other than Windows is a plus but not strictly needed to follow the flow of the book.

Approaching FireMonkey

In this section, we will explore the general background we need to properly introduce the FMX framework. Delphi is a longevous environment and it existed way before the FMX framework. We need to delve a bit into the roots of the Delphi tool to understand FMX in a better way.
When I was still a teenager, Delphi was the best development environment to build Microsoft Windows applications. I had some Turbo Pascal background knowledge and someone told me to give Borland Delphi a try in order to easily get into visual application development. That was during the time of Windows 95 and the world, from an IT point of view, was much simpler than today. DOS and Windows had a very large share of personal computer coverage. The remaining part of the world was running Linux or Macintosh but with a limited share and only in very specific contexts. Even though the mainframe (such as IBM AS400) was still a thing, business companies were mostly running Windows.
Given that I had limited DOS programming knowledge, I spent a lot of time learning how to build a Windows GUI application and also experimented with other languages (such as Visual Basic, Java, and Visual C++) but Delphi has been my favorite right from the start.
The ability to easily build beautiful Windows applications through a designer is still a great plus and I really think this has been one of the key factors of Delphi's success. The following screenshot shows the Delphi 10.4.1 Sydney splash-screen:
Figure 1.1
Apart from the convenient GUI Rapid Application Development (RAD) approach, built into an effective IDE, Object Pascal was a great language showcasing full Object-Oriented Programming (OOP) support, great C compatibility (perfect for Windows API calls), and featuring a very fast compiler. Generated applications also had outstanding runtime performances.
Looking at Delphi as a whole product, what surfaces is a fantastic tool, capable of letting developers focus on their application code while building fast, good-looking, modern applications – a shiny gem to easily deliver proper and curated GUI applications for the Microsoft Windows platform. In other words, the product performed very well by being more abstracted than raw C/C++ programming and proving to be way more powerful than Visual Basic (just to cite two of the biggest Delphi competitors over time).
This has been possible thanks to a framework shipped with the product: the Visual Component Library (VCL). It acted as a sort of abstraction over the standard Windows controls, wrapping them in a more suitable and easy-to-use programming interface. A big difference with respect to other products has been that all this provided the ability to go back to being low-level and interact with the primitive control whenever needed.
Using the VCL was convenient and the library naturally evolved over two decades (at least!) of development by covering more and more Windows features and capabilities. Every Delphi developer felt at home while dealing with VCL components and most applications never needed to breach into low-level code. This meant higher productivity for the developer and I myself have seen several projects started with other technologies then being abandoned due to running over time for the project execution. Developer teams struggled to deliver functionalities in years while the same project revamped with Delphi came to a successful conclusion within months.
Today, the general scenario is much more complex than what it looked like in the late 1990s. We have seen the rise of mobile platforms and at the time I am writing this, a mobile Operating System (OS) (that is, Android) is now the most used OS worldwide. Also, the desktop platforms scene has seen some changes and now Apple’s Mac OS X (aka macOS) has much more widespread adoption than before (even if this is not equally true in every part of the world). Linux somewhat lost the race for desktop user adoption (I am not considering Android as a Linux family member, even though it is Linux kernel-based) but got a relevant position as a server-side platform (driving the web, one could say).
In the following graph, you can see OS distribution over time (period starting January 2009 to January 2020 – data source: https://gs.statcounter.com):
Figure 1.2
From the preceding graph, it is easy to spot the decline of Windows (the dominant platform from 2009 up to 2017) and the corresponding rise of Android (with it overtaking around 2018).
Generally speaking, today, multi-tier architectures have become the de facto standard for real projects that have to deal with a (possibly high) number of heterogeneous clients and need to provide users with proper interfaces in very different scenarios (desktop, mobile, web platforms across different device families). Due to this fact, it's more and more challenging to see applications as single projects, built for a specific platform (as it was for decades). The availability of an application across multiple platforms has become a very demanding feature (it has almost become an intrinsic standard requirement).
To build and maintain multiple (one per supported platform) development projects, just to deliver the same functionalities to all involved final users, is costly from several points of view. It is hard because developers will have to learn platform-specific behaviors, technologies, APIs, programming languages and deployment toolchains. This requires several different, demanding skills. It will likely mean more than a single development team will be required to accomplish the mission. This also quickly leads to maintainability issues over time, with a huge impact on the total cost and time-to-market of the product you are building. Even if building a specific application for each platform sounds too expensive, the other option (to build a single cross-platform application) has to address some not so evident issues.
First of all, nobody really wants to have a cross-platform application framework that only enables the developer to rely on the common shared part of all platforms. Obviously, this approach (the greatest common divisor) would fall short as platforms are diverging in terms of functionalities and even those capabilities available on all platforms usually have some interface/implementation details that make them hard (or expensive/inefficient) to abstract.
At the same time, nobody needs a framework that is a composition of specific functionalities gathered from all supported platforms as this would result in something actually enabling developers to build applications relying on all functionalities of all platforms but forcing them to write different code (in the same language, though) for each platform (that is, the general problem the framework has been built to solve).
The solution (as often happens) is something in between these two opposites. FireMonkey is in a nice spot, thanks to its mixed strategy. Being a sort of compromise, it goes without saying that this also translates into a list of related strengths and weaknesses.
In the following screenshot, you can see the Delphi IDE while designing a multi-platform application. The Android style is selected for use in the form designer, an iOS style preview is available through the Multi-Device Preview window (docked into the IDE on the right side) and an instance of the application is running on the Windows platform, just in front of the IDE itself—three styles visible at the same time, one per platform; three different binaries using the same (single) source code:
Figure 1.3
As you can see, the cross-platform capabilities of Delphi are highlighted in the preceding screenshot. You are building your application (using a single programming language: Delphi), addressing multiple platforms easily. You can design your app in the IDE, select one of the supported styles (each style being associated with a specific platform—Android, as shown in the previous screenshot) to preview the result in the form designer, seamlessly. At the same time, you can also have a look at Multi-Device Preview (part of the IDE set of functionalities named Fire UI). There, you'll get a realistic preview of how your application will look on other (multiple, eventually) platforms (iOS, which is also shown in the preceding screenshot).
Note that neither of the two mentioned platforms (Android and iOS) is the one that your IDE is running (Windows) and that your app will also be able to be executed, no code changes needed, on Windows (and Linux and OS X/macOS). Doesn't sound great enough? Then you can go even further and have your forms previewed, live, on a mobile device through another technology named Live Preview (still part of the Fire UI set, http://docwiki.embarcadero.com/RADStudio/en/FireUI_Live_Preview). This time, you'll be able to preview (without having to wait until the compilation time) your UI on actual physical devices, without effort, with the screen of the device acting as an extension of your IDE.
In this section, we discussed the current scenario of software development, describing how and why we are facing the need to deliver multi-platform applications. We also introduced the FMX framework approach, with respect to the difficulties of the implementation of the same application using different tools to address different platforms.
In the next section, we are going to focus on the strategy FMX takes in order to provide ...

Table of contents