I had the honor yesterday of attending Embarcadero’s most exciting pre-release RAD Studio event yet – a summary of the new features are in the previous post.

This post I will explore the FireMonkey aspect of Delphi XE2 a bit more deeply.

Vector-based architecture features and implications:

  • Firemonkey architecture is presumably a significantly enhanced non-VCL successor to Kryukov’s KSDev vector-based VCL components including VGScene, DXScene, ImageFX and his iOS compiler, for which Embarcadero acquired the IP (apparently in Jan 2011 when further development of his VCL components was ceased, and would explain why the Delphi community was taken by surprise with the recent announcement of FireMonkey).
  • allows 3D modeling with all computing work performed by the device’s GPU (thus 3D features currently will not display if remote desktop or Citrix environment)
  • allows assigning data points on a 3D model which can then linked via the new LiveBindings functionality to a source data, thereby enabling live 3D charting, etc
  • can import various 3D models such as 3ds or Collada, with potential to add more support later.
  • full zoom in and out capability without image degradation which means controls look good even on small devices when zooming is applied
  • ability to apply 3D effects and filter effects to forms or components, thus one could create a page turning effect potentially.
  • a critical difference to other vector based frameworks such as Abobe Flash and Microsoft’s WPF (an XAML DirectX .NET based technology with data bindings, upon which Silverlight is built), is that Apple allows FireMonkey applications to be added to their iTunes app store and thus made available for use on iPhones and iPads (ie. it is FPC-compatible).
  • when compiled to a Windows platform, it utilises Direct2D and Direct3D, when compiled to Mac OS X or iOS, it utilises OpenGL.
  • it is currently designed for native applications (ie. running independently of any web browser) and not for Rich Internet Applications (RIA) within web browsers (as does Silverlight or Air), and is not specifically targetting gaming development.

FireMonkey components:

  • does not use Windows messaging and thus does not play well with visual VCL components in the same application, thus avoid them, BUT one still uses TDatasource, TClientDataset, etc.
  • source code included – 99% is Object Pascal code with only a small section of non-pascal GPU code
  • components designed to make migration from VCL as simple as possible by keeping similar naming and properties where possible but obviously events that take Windows messaging parameters had to be changed.
  • new LiveBindings functionality (which also is now on VCL) means almost any property of a control can be unidireectionally or bidirectionally linked to a source – be it a form variable or TDatasource.dataset field, or other control parameter, this also means, some properties such as position x are no longer integer but Double.
  • TFmxObject = class(TComponent);
  • any object can contain other components to make it versatile and very easy to create customised objects
  • just drop a component onto another component and it will become a child of that component – need to take care in the IDE when dropping components onto a form!
  • heavily dependent upon interfaces
  • IControl handles focus, mouse and keyboard events, implemented by TControl and TControl3D
  • IRoot is interface to top-level containers and is implemented by TCustomForm
  • IScene is the container for 2D objects and is implemented by TForm and TCustomLayer3D
  • IViewPort is the container for 3D objects (and requires a GPU), and is implemented by TForm3D and TViewPort3D
  • GPU-based shading filters which can be applied to bitmaps, forms and controls to give Photoshop-like effects
  • new Animation functionality which allows one to modify a property value over time and thereby create changing colors, changing position, etc.
  • new Styles is a CSS-like functionality which allows dynamic skinning with ability to save, load and modify at run time to dramatically alter the appearance of the application.
  • new StyleBook is a container for styles and provided styles include Win7, MacOSX, etc, but of course one can create their own styles.

Live Bindings:

  • available in VCL as well as FireMonkey and in effect makes ALL components and their properties data aware if you wish – very versatile and quite different to VCL’s data-aware approach which is not available in FireMonkey.
  • can specifiy unidirectional or bi-directional links which have read/write capability via use of expressions
  • a binding consists of 4 aspects:
    • source object – this may be a TDatasource.dataset.field or a form variable or component
    • source expression – a string which can be edited at runtime. For example, the name of the source property value you wish to bind to such as DisplayName if source is a TField
    • control object – this is the destination object that you are binding to.
    • control expression – a string which allows one to format the bound data for display, etc. and to specify the control property value which will be linked eg. label.text
  • bindings are stored in TBindingsList, and also allow you to register methods available to be called from the expression strings. The expression evaluation engine also accesses the RTTI.
  • one also needs to set a scope for the binding and this may be done automatically and uses TBindScope and TBindScopeDB (if linking to a TDatasource)
  • instead of TDBNavigator, there is a TBindNavigator which links to a TBindScopeDB or a TBindScope.
  • LiveBindings introduces wonderful new versatile opportunities (eg. you can bind to any component property and even to points on a 3D model) but does introduce a significant potential for runtime errors as the expression strings are no longer part of the compiler syntax mechanism, and particularly, if you change the name of a control or variable during refactoring and forget to change it within the expression, or just do a typing error, you will not get a compiler error but a potentially difficult to detect runtime error which may or may not create an exception.
  • to create a LiveBinding on a form control, just click on the LiveBindings property of the control and you will have the option of creating one manually or choosing “Link to DB Field” which will automatically place the LiveBinding comonents on the form, and will display all TDatasources and their fields for you to select a field to bind to.

Cross-platform RTL support:

  • TFormatSettings in SysUtils
  • TOSVersion
  • TZipFile in System.zip for crossplatform zip/unzip of files – now this will make life much easier!
  • TLoginCredentials
  • TPointF

Cross-platform debugging:

  • this has been simplified – one copies the Embarcadero Platform Assistant to the target machine or virtual machine, specify port and optionally password then just run it.
  • within Delphi IDE, define a remote profile specifying IP address, port and optionally password and remote paths.
  • Run with Debug

Cross-platform development limitations:

  • platform specific functionality obviously is not available for cross-platform compilation eg. Windows messaging (and thus the VCL), COM, menus (not available on iOS), OS API’s, MS XML transforms, etc
  • whilst many GUI applications MAY be applicable for use as is across multiple platforms, the reality is that you would probably wish to have a GUI that is optimised for each platform, and this too is obviously not only possible with FireMonkey, but the best approach for many applications.
  • presumably one could use compiler directives to access different API’s or to use COM for Windows compiles, or access iOS camera for iOS compiles.
  • issues with Free Pascal for developing iOS apps – see here.

Current limitation issues which will almost certainly be addressed by XE3 release in late 2012:

  • cannot compile to Linux, Android or Blackberry (but there are java based Datasnap client solutions for these platforms in the interim)
  • no Windows 8 specific support as this has not yet been released by Microsoft.
  • no customisable gesture support as is currently in the VCL, but usual gestures such as those on an iPad will work as they do normally without programming.
  • compilation to iOS is only Object Pascal (not C++ yet) as it relies upon compilation using FreePascal (and thus certain features such as Generics, Anonymous methods are not supported), and then requires one to use Apple’s xCode IDE to do the final compile – but at least one can debug and edit the Object Pascal code within xCode and changes made within Delphi are automatically visible in xCode without having to go through the FreePascal again.
  • iOS compile requirements:
    • Mac Snow Leopard on an Intel Mac
    • iOS SDK with developer subscription (4.2, 4.3)
    • xCode 3.25 or 3.26 to do the final compile
    • installed official FreePascal 2.4.4 binary required to build FPC 2.5.1
    • if using virtual machine on the Mac such as VMWare Fusion, ensure you save your project to a shared folder that can be accessed by xCode
    • once project saved in Delphi, use a command line utility to export to xCode files (in a subdrectory)
    • then run xCode in OS X and open that project in the xCode subdirectory and compile, debug or run on a connected physical device or an emulation of the device
    • your original object pascal code will be accessible, debuggable and editable within xCode!

Development machine:

  • It would seem for cross-platform development, the preferred environment may be Mac OS X running Delphi within a 64bit Windows VMWare Fusion virtual machine.
  • This would then allow running Apple’s xCode on the same machine and allow all debugging to be performed with the one computer.