FireMonkey | Andreano Lanusse | Technology and Software Development http://www.andreanolanusse.com/en/development/firemonkey/ Where Andreano Lanusse talk about technology, software development, programming techniques, databases, games and more through articles, tutorials and videos Mon, 12 Aug 2019 04:35:13 +0000 en hourly 1 https://wordpress.org/?v=6.3.4 What’s new in Delphi XE4? http://www.andreanolanusse.com/en/whats-new-in-delphi-xe4/ http://www.andreanolanusse.com/en/whats-new-in-delphi-xe4/#comments Mon, 22 Apr 2013 14:16:40 +0000 http://www.andreanolanusse.com/en/?p=918 This time you didn’t have to way a full year to see a new Delphi release, 8 months after XE3 release Delphi XE4 is out. iOS development is the major topic of course and bring the second version of FireMonkey to iOS, a lot of expectation on this topic specially after XE2. Also there is […]

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
This time you didn’t have to way a full year to see a new Delphi release, 8 months after XE3 release Delphi XE4 is out.

iOS development is the major topic of course and bring the second version of FireMonkey to iOS, a lot of expectation on this topic specially after XE2.

Also there is a bunch of new stuffs to talk about, like:

  • New Delphi compiler for mobile platform, which brings several changes in the language and set a future path to the Delphi language, obvious these changes will affect desktop development in the future and you need to start learning about that now.
  • The SQLite and InterBase support for iOS
  • ClientDataSet available on iOS
  • Several FireMonkey changes for iOS, componentes, new classes
  • Etc..

RAD Studio XE4 now includes only Delphi, C++Builder and HTML5Builder. Delphi Prism is no longer part of RAD Studio, the name is dead and from now you have to refer to Oxygene from RemObjects. You can check the official communication from RemObjects here, where Marc Hoffman provide more details about the future related to .NET development with Oxygene (old Prism) and their support to iOS and Android development.

Trial is already available here or if you prefer download the full Delphi and C++Builder ISO here.

The Delphi XE4 documentation has a extensive list of What’s new in Delphi and C++Builder XE4, below the table of content:

That’s it for now.

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
http://www.andreanolanusse.com/en/whats-new-in-delphi-xe4/feed/ 9
TDBXJsonTools copy/convert data between TDataSet – TJSONObject – DBXReader http://www.andreanolanusse.com/en/tdbxjsontools-copyconvert-data-between-tdataset-tjsonobject-dbxreader/ http://www.andreanolanusse.com/en/tdbxjsontools-copyconvert-data-between-tdataset-tjsonobject-dbxreader/#comments Wed, 01 Aug 2012 09:30:20 +0000 http://www.andreanolanusse.com/en/?p=818 You can copy data from DBXReader to ClientDataSet and vice-versa using dbxExpress framework, you probably already read some of my blog posts where I explain how it works in desktop applications, however in mobile platforms we don’t have ClientDataSet and in case you want something similar you always, what can you do? DataSnap Mobile Connectors […]

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
You can copy data from DBXReader to ClientDataSet and vice-versa using dbxExpress framework, you probably already read some of my blog posts where I explain how it works in desktop applications, however in mobile platforms we don’t have ClientDataSet and in case you want something similar you always, what can you do?

DataSnap Mobile Connectors has a class called TDBXJsonTools, this class allows developers to copy/convert data between DBXReader, TJSONObject, DBXReader and other types, you can do that in any mobile platform supported by the connectors, like: Java/Android, Java/BlackBerry, Objective-C, C#/Windows Phone and FreePascal.

In a native desktop application you would use TDBXDataSetReader.CopyReaderToClientDataSet(Reader, ClientDataSet) to copy the DBXReader to a ClientDataSet, in the mobile apps you will use TDBXJsonTools.CreateTDataSetFromJSON(DBXReader.asJSONObject).

Meanwhile, this is not only about copy/convert data, it gives you several ways to interact and transport data using different types and take advantage of the native types in each platform. For example, when using DataSet in FireMonkey on iOS it will use TDataSet class from FreePascal/Delphi RTL, when using with Java, TDataSet will be extension of TDBXReader and so on.

DBXReader is unidirectional and navigation is limited, when using FireMonkey on iOS developers can copy the DBXReader data to a DataSet, which is bi-directional, it will enable the navigation and use of other DataSet features.

The following code represents the TDBXJsonTools interface for FreePascal.

  TDBXJsonTools = class
  public
    class procedure jsonToDBX(obj: TJSONValue; var value: TDBXValue; dbxTypeName: String);
    class procedure JSONToValueType(json: TJSONArray; var vt: TDBXValueType);
    class function DBXParametersToJSONObject(dbxParameters: TDSParams) : TJSONObject;
    class function DBXReaderToJSONObject(dbxReader: TDBXReader): TJSONObject;
    class function CreateTDataSetFromJSON(value: TJSONObject): TDataset;
    class function TDataSetToJSONObject(value: TDataset): TJSONObject;
    class function GetTFieldTypeByTDBXDataTypes(DBXDataTypes: TDBXDataTypes) : TFieldType;
    class function GetTDBXDataTypesByTFieldType(FieldType: TFieldType) : TDBXDataTypes;
    class function CreateTStreamFromJSONArray(value: TJSONArray): TStream;
    class function StreamToJSONArray(value: TStream): TJSONArray;
    class function JSONToTableType(value: TJSONValue; dbxTypeName: String): TObject;
    class function SerializeTableType(Objetc: TObject): TJSONObject;

  end;

My recommendation is to continue using DBXReader as the primarily source of data, and when necessary take advantage of the TDBXJsonTools class.

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
http://www.andreanolanusse.com/en/tdbxjsontools-copyconvert-data-between-tdataset-tjsonobject-dbxreader/feed/ 1
FireMonkey 3D Text Editor Delphi source code available http://www.andreanolanusse.com/en/firemonkey-3d-text-editor-delphi-source-code-available/ http://www.andreanolanusse.com/en/firemonkey-3d-text-editor-delphi-source-code-available/#comments Mon, 05 Mar 2012 22:17:53 +0000 http://www.andreanolanusse.com/en/?p=815 The source code for the FireMonkey 3D Text Editor is available on RAD Studio SourceForge repository. You can check out the code using the following command line: For Delphi XE2 svn co https://radstudiodemos.svn.sourceforge.net/svnroot/radstudiodemos/branches/RadStudio_XE2/FireMonkey/3DTextEditor/ For Delphi XE3 svn co https://radstudiodemos.svn.sourceforge.net/svnroot/radstudiodemos/branches/RadStudio_XE2/FireMonkey/3DTextEditor/ Through this sample you can learn lots of FireMonkey features, have fun!!!

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
The source code for the FireMonkey 3D Text Editor is available on RAD Studio SourceForge repository.

You can check out the code using the following command line:

For Delphi XE2
svn co https://radstudiodemos.svn.sourceforge.net/svnroot/radstudiodemos/branches/RadStudio_XE2/FireMonkey/3DTextEditor/

For Delphi XE3
svn co https://radstudiodemos.svn.sourceforge.net/svnroot/radstudiodemos/branches/RadStudio_XE2/FireMonkey/3DTextEditor/

Through this sample you can learn lots of FireMonkey features, have fun!!!

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
http://www.andreanolanusse.com/en/firemonkey-3d-text-editor-delphi-source-code-available/feed/ 6
Using Regular Expression on C++Builder FireMonkey Application http://www.andreanolanusse.com/en/using-regular-expression-on-cbuilder-firemonkey-application/ http://www.andreanolanusse.com/en/using-regular-expression-on-cbuilder-firemonkey-application/#respond Fri, 06 Jan 2012 22:11:14 +0000 http://www.andreanolanusse.com/en/?p=768 Here another C++ example showing how to use the RTL regular expression on C++Builder FireMonkey Application. This example  validate a string content based on four different regular expression, which are: Checks if the given text is a validate e-mail address Checks if the given text contains a valid IP address Checks if the given text […]

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
Here another C++ example showing how to use the RTL regular expression on C++Builder FireMonkey Application.

This example  validate a string content based on four different regular expression, which are:

  • Checks if the given text is a validate e-mail address
  • Checks if the given text contains a valid IP address
  • Checks if the given text is a valid date (dd-mm-yyyy)
  • Checks if the given text is a valid date (mm-dd-yyyy)

The follow code shows the four regular expressions used by this application.

void __fastcall TForm1::lbRegExpChange(TObject *Sender) {
	switch (lbRegExp->ItemIndex) {
	case 0:
		lbType->Text = "E-mail for validation";

		MemoRegEx->Text =
			"^((?>[a-zA-Z\d!#$%&''*+\\-/=?^_`{|}~]+\\x20*" "|\"((?=[\\x01-\\x7f])[^\"\\\\]|\\\\[\\x01-\\x7f])*\"\\"
			"x20*)*(?\.?[a-zA-Z\d!" "#$%&''*+\\-/=?^_`{|}~]+)+|\"\"((?=[\\x01-\\x7f])"
			"[^\"\\\\]|\\\\[\\x01-\\x7f])*\")@(((?!-)[a-zA-Z\\d\\" "-]+(?)$";

		break;
	case 1: {
			// Accept IP address between 0..255
			lbType->Text = "IP address for validation (0..255)";
			MemoRegEx->Text =
				"\\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\" ".(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\."
				"(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\." "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\b";
			break;

		}
	case 2: {
			// Data interval format mm-dd-yyyy
			lbType->Text =
				"Date in mm-dd-yyyy format from between 01-01-1900 and 12-31-2099";
			MemoRegEx->Text =
				"^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[" "01])[- /.](19|20)\\d\\d$";
			break;

		}
	case 3: {
			// Data interval format mm-dd-yyyy
			lbType->Text =
				"Date in dd-mm-yyyy format from between 01-01-1900 and 31-12-2099";
			MemoRegEx->Text =
				"^(0[1-9]|[12][0-9]|3[01])[- /.](0[1-9]|1[01" "2])[- /.](19|20)\\d\\d$";
			break;

		}
	}
	EditTextChangeTracking(EditText);

}

To execute the validation you can use the method TRegExp::IsMatch as you can see bellow:

void __fastcall TForm1::EditTextChangeTracking(TObject *Sender) {
       // EditText contain the string value and MemoRegEx the regular expression
	if (TRegEx::IsMatch(EditText->Text, MemoRegEx->Text)) {
		SEResult->ShadowColor = TAlphaColors::Green;
	}
	else
		SEResult->ShadowColor = TAlphaColors::Red;

}

Since this is a FireMonkey Application, I used a Shadow Effect to show if the Edit box value is valid or not (Green=valid / Red=invalid). The following image shows what happen when you input a invalid e-mail address on Windows and Mac.

Now the results when you provide the correct e-mail address.

You can download the source code from here or just update your local RAD Studio XE2 samples folder from our RAD Studio SVN repository.

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
http://www.andreanolanusse.com/en/using-regular-expression-on-cbuilder-firemonkey-application/feed/ 0
Using dbExpress Framework on Windows and Mac with C++Builder http://www.andreanolanusse.com/en/using-dbexpress-framework-on-windows-and-mac-with-cbuilder/ http://www.andreanolanusse.com/en/using-dbexpress-framework-on-windows-and-mac-with-cbuilder/#comments Fri, 06 Jan 2012 10:33:58 +0000 http://www.andreanolanusse.com/en/?p=763 During the following weeks I’m writing a series of C++ examples to demonstrate the use of VCL, FireMonkey, RTL, dbExpress, and others stuff. Each example will have a major focus, but you will be able to learn other stuffs as well. If there is something specific on C++ you would like to see, please let […]

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
During the following weeks I’m writing a series of C++ examples to demonstrate the use of VCL, FireMonkey, RTL, dbExpress, and others stuff. Each example will have a major focus, but you will be able to learn other stuffs as well. If there is something specific on C++ you would like to see, please let me know and I will do my best to bring that in one of my following posts.

In this first post I demonstrate how to use dbExpress Framework to run SQL’s against your database. Since I want to run the application on Windows and Mac, the console application will target FireMonkey.

The Console Application Wizard for C++ has been updated in C++Builder XE2, adding a Target Framework Option as you can see below.

The following code shows how to connect to an InterBase database, execute a SELECT SQL against the COUNTRY table, and display the results, of course you can use dbExpress Framework to run queries against any database supported by dbExpress, just remember that some dbExpress drivers are not available on Mac in XE2, for example SQL Server and ODBC drivers.

If you are C++ developer you will understand pretty quickly the following code, which has some comments to help you to understand the code.

#include <fmx.h>

#pragma hdrstop
#pragma argsused

#include <tchar.h>
#include <stdio.h>
#include <System.SysUtils.hpp>
#include <Data.DBXDynalink.hpp>
#include <Data.DBXCommon.hpp>
#include <Data.DBXInterbase.hpp>
#include <memory>

int _tmain(int argc, _TCHAR* argv[]) {

	// Get database connection instance
	std::auto_ptr<TDBXConnection>conn
		(TDBXConnectionFactory::GetConnectionFactory()->GetConnection
		("EMPLOYEE", "sysdba", "masterkey"));

	if (conn.get() != NULL) {

		printf("================= Connection Properties ============\n");

		AnsiString s = conn->ConnectionProperties->Properties->Text + "\n";
		printf(s.c_str());

		// create command and transaction objects to execute the query
		std::auto_ptr<TDBXCommand>command(conn->CreateCommand());

                // initiate a transaction
		TDBXTransaction *transaction =
			conn->BeginTransaction(TDBXIsolations::ReadCommitted);

		command->Text = "SELECT * FROM Country";
		command->Prepare();

		// execute the query and get the cursor (DBXReader)
		std::auto_ptr<TDBXReader>reader(command->ExecuteQuery());

		// print number of columns and each record
		printf(AnsiString("Number of Columns:" + IntToStr(reader->ColumnCount) +
			"\n").c_str());

		// display the list of records
		while (reader->Next()) {
			printf((reader->Value[reader->GetOrdinal("COUNTRY")]->GetAnsiString
				() + "\n").c_str());
		}

		printf("====================================================\n");

		conn->CommitFreeAndNil(transaction);
	}

	Sleep(5000);
	return 0;
}

Before you run this code, make sure you have the dbExpress alias EMPLOYEE setup to connect into the EMPLOYEE.GDB database and the InterBase client installed, if everything is ok just compile and run the program on Windows and Mac, the following image shows this application running on Mac.

There are few things you need to be aware when deploying and running this kind of application on Mac; on my following post I will explain everything about that.

For now we’ve learned how to use DBX Framework and make the application to compile and run on Windows and Mac.

You can download the source code from here or just update your local RAD Studio XE2 samples folder from our RAD Studio SVN repository.

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
http://www.andreanolanusse.com/en/using-dbexpress-framework-on-windows-and-mac-with-cbuilder/feed/ 2
Connecting to PostgreSQL through dbExpress ODBC driver http://www.andreanolanusse.com/en/connecting-to-postgresql-through-dbexpress-odbc-driver/ http://www.andreanolanusse.com/en/connecting-to-postgresql-through-dbexpress-odbc-driver/#comments Wed, 02 Nov 2011 07:30:27 +0000 http://www.andreanolanusse.com/en/?p=723 Delphi XE2 and C + + Builder XE2  introduce the new dbExpress ODBC driver, which enable FireMonkey and VCL applications to connect to any database that provides a ODBC driver. In order to show how it works, I created a FireMonkey project sample that connect to a PostgreSQL database. As first step, you must install the PostgreSQL ODBC driver […]

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
Delphi XE2 and C + + Builder XE2  introduce the new dbExpress ODBC driver, which enable FireMonkey and VCL applications to connect to any database that provides a ODBC driver.

In order to show how it works, I created a FireMonkey project sample that connect to a PostgreSQL database.

As first step, you must install the PostgreSQL ODBC driver on the machine that will run the application. Second, applications compiled as 32-bit, requires the 32-bit ODBC driver, 64-bit applications will require the 64-bit ODBC driver.

Onde installed the driver, create and configure a User DSN or System DSN on the ODBC Data Source Administrator (odbcad32.exe):

Instructions for windows 64-bit

  • For 32-bit applications use c:\Windows\SysWOW64\odbcad32.exe
  • For 64-bit applications use o c:\Windows\system32\odbcad32.exe

Instructions for windows 32-bit

  • Use  c:\Windows\system32\odbcad32.exe

The next step is to create an dbExpress ODBC alias on Data Explorer, where the Database Name parameter is the name of the Data Source created earlier, in my example the Data Source is called PostgreSQL35W. The database, username and password was already defined in the Data Source, but you can override the username and password parameters through the SQLConnection.

Assuming you already know how to use the SQLConnection, DataSetProvider and ClientDataSet or SimpleDataSet ,and DataSource components, just connect all  the components as you usually do. The SQLConnection will look like this:

  object SQLConnection1: TSQLConnection
    ConnectionName = 'PostgreSQLOdbc'
    DriverName = 'ODBC'
    LoginPrompt = False
    Params.Strings = (
      'drivername=ODBC'
      'Database=PostgreSQL35W')
  end

You can use the dbExpress framework when connected to a database through dbExpress ODBC driver. In XE2 the ODBC driver is compatible with Windows, we are evaluating the possibility to support this driver on Mac.

The figure below shows the FireMonkey application connected to PostgreSQL via dbExpress ODBC driver. Now you can connect to any other other database not supported natively by dbExpress.

Download the source code here.

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
http://www.andreanolanusse.com/en/connecting-to-postgresql-through-dbexpress-odbc-driver/feed/ 9
Creating XML files with Delphi and FireMonkey on Mac http://www.andreanolanusse.com/en/creating-xml-files-with-delphi-and-firemonkey-on-mac/ http://www.andreanolanusse.com/en/creating-xml-files-with-delphi-and-firemonkey-on-mac/#comments Thu, 27 Oct 2011 10:19:40 +0000 http://www.andreanolanusse.com/en/?p=717 I got some questions about how to manipulate XML files in FireMonkey applications when running on Mac. One of the solution for that is to use the Mac API (Cocoa), there are several class and different ways to work with XML on Mac, in this post I’m going to show one way to create an […]

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
I got some questions about how to manipulate XML files in FireMonkey applications when running on Mac.

One of the solution for that is to use the Mac API (Cocoa), there are several class and different ways to work with XML on Mac, in this post I’m going to show one way to create an XML file, if you are interested to learn more about the XML class available for Mac, visit the Apple documentation website.

Cocoa provide several classes/interfaces to work with XML, the sample project used on this post use NSXMLDocument, NSXMLElement, NSXMLNode and NSData interfaces and related classes, all of them can be found in the Macapi.Foundation unit.

The NSXMLDocument interface and TNSXMLDocument class are the starting point to create the XML Document, where we define the version and encoding for the XML file.

procedure TFrmXml.CreateXMLButtonClick(Sender: TObject);
var
  XmlDoc: NSXMLDocument;
  Root, Book, Author, Publisher: NSXMLElement;
  Data: NSData;
begin

  // Create Xml Document
  XmlDoc := TNSXMLDocument.Create;
  XmlDoc.setVersion(NSSTR('1.0'));
  XmlDoc.setCharacterEncoding(NSSTR('UTF-8'));

After that we need to define what XML elements (nodes) will be added to the XML, since I’m going to create several elements I created three helper methods (CreateElement and Attribute) to help me with that.

The CreateElement method has two implementations, the first one is very simple, just create a new TNSXMLElement based on the name and value parameters.

function TFrmXml.CreateElement(Name, Value: String): NSXMLElement;
begin
  Result := TNSXMLElement.Create;
  Result.setName(NSSTR(Name));
  Result.setStringValue(NSSTR(Value));
end;

The second CreateElement implementation creates a new element which can contain attributes, in order to pass a NSXMLNode that represent a attribute, we will use the Attribute helper method.

function TFrmXml.CreateElement(Name: String; Attr: NSXMLNode): NSXMLElement;
begin
  Result := TNSXMLElement.Create;
  Result.initWithName(NSSTR(Name));

  if Assigned(Attr) then
    Result.addAttribute(Attr);
end;

Below a short overview about the NSXMLNode class extracted from Apple documentation:

Objects of the NSXMLNode class are nodes in the abstract, logical tree structure that represents an XML document. Node objects can be of different kinds, corresponding to the following markup constructs in an XML document: element, attribute, text, processing instruction, namespace, and comment. In addition, a document-node object (specifically, an instance of NSXMLDocument) represents an XML document in its entirety. NSXMLNode objects can also represent document type declarations as well as declarations in Document Type Definitions (DTDs). Class factory methods of NSXMLNode enable you to create nodes of each kind. Only document, element, and DTD nodes may have child nodes.

Among the NSXML family of classes—that is, the Foundation classes with the prefix “NSXML” (excluding NSXMLParser)—the NSXMLNode class is the base class. Inheriting from it are the classes NSXMLElement, NSXMLDocument, NSXMLDTD, and NSXMLDTDNode. NSXMLNode specifies the interface common to all XML node objects and defines common node behavior and attributes, for example hierarchy level, node name and value, tree traversal, and the ability to emit representative XML markup text.

NSXMLNode could be a comment, text, element and other types in Cocoa, the Attribute helper method ensure we will receive a NSXMLNode of type attribute.

function TFrmXml.Attribute(Name, Value: String): NSXMLNode;
var
  Node: Pointer;
begin
  Node := TNSXMLNode.OCClass.attributeWithName(NSSTR(Name), NSSTR(Value));
  Result := TNSXMLNode.Wrap(Node);
end;

 

Now is time to use the helper methods to create the XML document and at the end use the NSData object to format and save the XML file. This is what the following code does:

  // Create the root doc element including one attribute
  Root := CreateElement('BookStore', Attribute('url', 'http://www.amazon.com'));
  XmlDoc.initWithRootElement(Root);

  // Create the first Book node
  Book := CreateElement('Book', Attribute('Name', 'Steve Jobs'));

  // Create the Author and Publisher elements
  Author := CreateElement('Author', 'Walter Isaacson');
  Publisher := CreateElement('Publisher', 'Simon Schuster (October 24, 2011)');

  // Add the elements to the XML
  Root.addChild(Book);
  Book.addChild(Author);
  Book.addChild(Publisher);

  // Create the second Book node
  Book := CreateElement('Book', Attribute('Name',
    'Clean Code: A Handbook of Agile Software Craftsmanship'));
  Author := CreateElement('Author', 'Robert C. Martin');
  Publisher := CreateElement('Publisher',
    'Prentice Hall; 1 edition (August 11, 2008)');

  // Add the elements from the second Book node to the XML
  Root.addChild(Book);
  Book.addChild(Author);
  Book.addChild(Publisher);

  // Makes the Xml output more human-readable inserting
  // carriage returns and indenting nested elements
  Data := XmlDoc.XMLDataWithOptions(NSXMLNodePrettyPrint);
  Data.writeToFile(NSSTR(XMLLocation.Text), true);

  XmlContent.Lines.LoadFromFile(XMLLocation.Text);

end;

end.

Here the resulting app on Mac OS X:

You can download the source code directly from the RAD Studio demos repository here and it was tested with Delphi XE2 and XE3.

I originally mention that TXMLDocument was not available for Mac, and this is incorrect, thanks Chris Rolliston for the heads up and to migrate my sample to TXMLDocument.

When you drop a TXMLDocument component on your design the default DOMVendor MSXML, you have to change to ADOM XML v4 to support cross-platform. In case you have the unit Xml.Win.msxmldom added on your form you won’t be able to compile for Mac, after you set the DOMVendor to ADOM XML v4 remove that unit from your code and everything will be fine.

Here the version using TXMLDocument:

unit MainForm;

interface

uses
  System.SysUtils, System.Types, System.UITypes, System.Classes,
  System.Variants, XML.XMLDoc, FMX.Dialogs,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Layouts,
  FMX.Memo, FMX.Edit, FMX.Effects, FMX.Objects, Xml.xmldom, Xml.XMLIntf;

type
  TFrmXml = class(TForm)
    CreateXMLButton: TButton;
    XmlContent: TMemo;
    XMLLocation: TEdit;
    Label1: TLabel;
    Image1: TImage;
    procedure CreateXMLButtonClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  end;

var
  FrmXml: TFrmXml;

implementation

{$R *.fmx}

procedure TFrmXml.CreateXMLButtonClick(Sender: TObject);
var
  XmlDoc: IXMLDocument;
  Root, Book, Author, Publisher: IXMLNode;
begin
  // Create Xml Document
  XmlDoc := TXMLDocument.Create(nil);
  XmlDoc.Active := True;
  XmlDoc.Options := XmlDoc.Options + [doNodeAutoIndent];
  XmlDoc.Version := '1.0';

  // Create the root doc element with one attributes
  Root := XmlDoc.CreateNode('BookStore');
  Root.Attributes['url'] := 'http://www.amazon.com';
  XmlDoc.DocumentElement := Root;

  // Create the first Book node
  Book := XmlDoc.CreateNode('Book');
  Book.Attributes['Name'] := 'Steve Jobs';

  // Create the Author and Publisher elements
  Author := XmlDoc.CreateNode('Author');
  Author.Text := 'Walter Isaacson';
  Publisher := XmlDoc.CreateNode('Publisher');
  Publisher.Text := 'Simon Schuster (October 24, 2011)';

  // Add the elements to the XML
  Root.ChildNodes.Add(Book);
  Book.ChildNodes.Add(Author);
  Book.ChildNodes.Add(Publisher);

  // Create the second Book node
  Book := XmlDoc.CreateNode('Book');
  Book.Attributes['Name'] := 'Clean Code: A Handbook of Agile Software Craftsmanship';
  Author := XmlDoc.CreateNode('Author');
  Author.Text := 'Robert C. Martin';
  Publisher := XmlDoc.CreateNode('Publisher');
  Publisher.Text := 'Prentice Hall; 1 edition (August 11, 2008)';

  // Add the elements from the second Book node to the XML
  Root.ChildNodes.Add(Book);
  Book.ChildNodes.Add(Author);
  Book.ChildNodes.Add(Publisher);

  XmlDoc.SaveToFile(XMLLocation.Text);

  XmlContent.Lines.LoadFromFile(XMLLocation.Text);

end;

procedure TFrmXml.FormCreate(Sender: TObject);
begin
  XMLLocation.Text := IncludeTrailingPathDelimiter(GetHomePath) + 'create.xml';
end;

end.

With this you have everything you need to manipulate XML file on Windows and Mac.

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
http://www.andreanolanusse.com/en/creating-xml-files-with-delphi-and-firemonkey-on-mac/feed/ 3
Video: Delphi XE2 and FireMonkey app on Windows, Mac and iOS http://www.andreanolanusse.com/en/video-delphi-xe2-and-firemonkey-app-on-windows-mac-and-ios/ http://www.andreanolanusse.com/en/video-delphi-xe2-and-firemonkey-app-on-windows-mac-and-ios/#comments Fri, 05 Aug 2011 07:53:31 +0000 http://www.andreanolanusse.com/en/?p=681 After the RAD Studio XE2 World Tour first stop in New Zealand, you see all over internet great comments about Delphi XE2 and FireMonkey support for iOS, beyond Windows 64-bit and Mac. I know you are curious to see all of the great stuffs coming on RAD Studio XE2 and to give you an idea; […]

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
After the RAD Studio XE2 World Tour first stop in New Zealand, you see all over internet great comments about Delphi XE2 and FireMonkey support for iOS, beyond Windows 64-bit and Mac.

I know you are curious to see all of the great stuffs coming on RAD Studio XE2 and to give you an idea; I prepared a 5 minutes preview video. It shows a Delphi XE2 HD FireMonkey application running on Windows (64-bit), Mac and iOS, the use of 3D components and animations.

There are lot of possibilities with FireMonkey and all of the other new features in Rad Studio XE2, we are presenting all of them during the World Tour, reserve some time and register for the World Tour near you.

[button link=”http://www.embarcadero.com/world-tour” size=”large” style=”note” color=”red” border=”white” text=”light” window=”yes”]Register today for the RAD Studio XE2 World Tour[/button]

 

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
http://www.andreanolanusse.com/en/video-delphi-xe2-and-firemonkey-app-on-windows-mac-and-ios/feed/ 44
A little bit about FireMonkey and Delphi XE2 http://www.andreanolanusse.com/en/a-little-bit-about-firemonkey-and-delphi-xe2/ http://www.andreanolanusse.com/en/a-little-bit-about-firemonkey-and-delphi-xe2/#comments Wed, 03 Aug 2011 09:04:35 +0000 http://www.andreanolanusse.com/en/?p=671 FireMonkey is going to be a whole new world of possibilities for Delphi and C++Builder developers. The platform itself is flexible, customizable and multi-platform, all components behave the same on Windows and Mac. In this post I will give you a general idea of some very powerful concepts related with components in FireMonkey, during the RAD Studio […]

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
FireMonkey is going to be a whole new world of possibilities for Delphi and C++Builder developers. The platform itself is flexible, customizable and multi-platform, all components behave the same on Windows and Mac. In this post I will give you a general idea of some very powerful concepts related with components in FireMonkey, during the RAD Studio XE2 World Tour you will see much more.

Components in FireMonkey are containers; it means you can embed any component inside any other component. Just to give you an idea, the Button component is composed of 9 components. When together, they look and behave like a Button, let’s see how it works.

[ilink style=”tick”]Starts with a TLayout component, which helps to organize all of the controls[/ilink]
[ilink style=”tick”]Three TRectangle are responsible for the button look and feel, like: border, background and foreground color[/ilink]
[ilink style=”tick”]A Label represents the Button text[/ilink]
[ilink style=”tick”]And ends with four components, two for animation and other two for effects. Why effects and animations? Animations will happen when you move the mouse over/out the button, effects will happen when button is pressed or has a focus, the glow effect is responsible for that.[/ilink]

As you can see, a number of different features has been used to create a button, this is what happen with all of FireMonkey components.

And one more think, components’ look and feel can be changed and reused using Styles. Imagine a web page that use CSS, you change the web page look and feel just updating the CSS, right? In FireMonkey is the same, instead CSS you will use Styles to change the application look and feel.

Apps and components look and work properly on the respective native platform, but you can also style them to look or behave differently. below an example.

More to come, stay tuned to this blog, other Embarcadero blogs and Embarcadero web site.

[button link=”http://www.embarcadero.com/world-tour” size=”large” style=”note” color=”red” border=”white” text=”light” window=”yes”]Register today for the RAD Studio XE2 World Tour[/button]

Andreano Lanusse | Technology and Software Development Follow me on Twitter: @andreanolanusse

]]>
http://www.andreanolanusse.com/en/a-little-bit-about-firemonkey-and-delphi-xe2/feed/ 62