Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts

Thursday, May 28, 2020

Delphi 10.4 Sydney is here!

Hi folks,

Delphi 10.4 Sydney has just released and this version comes with a lot of interesting features:

    • New Delphi CodeInsight based on LSP server
    • Custom Managed Records in the Delphi Language
    • New VCL Components, including TEdgeBrowser, and expanded High DPI support for VCL styled applications
    • Enhanced Delphi multi-device platform support integrating newer Apple APIs and supporting the latest Android
    • New LLDB-based debugger for Windows 64-bit for C++
    • Unified installer for online & offline installations
    • GetIt Package Manager Enhancements


            I would like to spend few words around the features that impressed me:


            Code Insight Technology in Delphi 10.4

            From David Millington blog post:

            In 10.4, Code insight features are implemented using a ‘LSP Server’. LSP refers to the Language Server Protocol, which is a standardized way to implement code insight-like features for many languages. An IDE talks to a ‘language server’, which is a small helper app that calculates and generates the information the IDE displays. It does so using a defined protocol, and that’s the language server protocol.

            In other words, the IDE now talks to a helper app when you do something like open a project, or type a keystroke in your file.

            What does it means?
            • Communication with another process is asynchronous
            • The work is done in another process
              • This means all the memory usage for calculating results is no longer in the IDE itself. The IDE has more memory, and the helper app can use its entire memory space dedicated solely to providing results
            • What you see onscreen is what the compiler sees. 
              • If your code compiles, you won’t see any Error Insight errors; conversely, if you do see red squiggly underlines in your code or in the Structure view, your code will not compile.
            • You can get code completion while debugging.

            If you want to know more about it have a look to David Millington post 


            Custom Managed Records 

            This is absolutely the top new language feature of Delphi 10.4!

            Now in 10.4 the Delphi record type supports custom initialization and finalization:

            From Marco Cantù blog post:

            You can declare a record with custom initialization and finalization code regardless of the data type of its fields, and you can write such custom initialization and finalization code.
            This is achieved by adding specific, new operators to the record type (you can have one without the other if you want).
            Below is a simple code snippet:

            type
              TMyRecord = record
                Value: Integer;
                class operator Initialize (out Dest: TMyRecord);
                class operator Finalize(var Dest: TMyRecord);
              end;


            The huge difference between this construction mechanism and what was previously available for records is the automatic invocation. If you write something like the code below, you can invoke both the initializer and the finalizer, and end up with a try-finally block generated by the compiler for your managed record instance.

            Marco Cantù post to know more.


            GetIt Package Manager Enhancements

            GetIt Package Manager Enhancements in Delphi 10.4:
            • the ability of sorting the list of entries by date, seeing the most recent ones on top
            • for each entry you have already installed, the indication that an updated version is available
            • the ability to list all installed entries that have an update available

            Rad studio patches

            A killer feature of the new GeIt is absolutely the ability to use GetIt to distribute patches, with a specific way to alert customers that a patch is available. There is a new section to the Welcome page to indicate when a patch is available and you have not installed it:


            Here a screenshot of Rad Studio patches in action:

            As you can see there is already a patch available through GetIt, this will completely revolutionize the patches distribution!

            Webinar Delphi 10.4

            Here the link for the launch webinar - https://www.youtube.com/watch?v=-rTLEXLVueQ&feature=youtu.be - Enjoy it!


            Other useful resources 


            As you can see from the info above this is a fantastic release! Enjoy it!


            Friday, March 24, 2017

            One codebase to rule them all - RAD Studio 10.2 Tokyo is here!

            Finally, it's arrived!! The penguin invasion has started! RAD Studio 10.2 Tokyo is here bringing with it support for Linux!
            Delphi for Linux is now available delivering support for Linux 64bit server-side and standalone applications for Ubuntu and RedHat Enterprise. Guys, I'm very enthusiastic about this new support! This is a very greats news for Delphi developers and not, everywhere!


            By now Delphi can support and generate native code for several platforms (7 to be exact!!!): Linux (64bit), Windows (x86 and x64), OS X (32-bit ), iOS (32 and 64-bit) and Android.
            I think that no citation may be more appropriate of this:
            one codebase to rule them all
            Below a list of the most interesting features available in this release (IMHO):

            Delphi Linux Compiler


            • 64-bit Linux platform support
            • Delphi language support
            • ARC-enabled
            • 1-based strings
            • LLVM engine based

            Supported Linux Distributions


            • Ubuntu Server (Ubuntu 16.04 LTS)
            • RedHat Enterprise Linux (version 7)

            RTL features supported


            • Linux file system access
            • Threading and Parallel Programming Libraries support
            • Memory management
            • HTTP and REST libraries support for HTTP calls

            64-bit Linux for Server Applications


            • FireDAC provides Linux support for all Linux-capable DBMS, with the only exception of Informix. See Database Connectivity.
            • WebBroker, RAD Server (EMS), and DataSnap support for Multi-tier servers (standalone and Apache modules).
            • DUnitX support.
            • PAServer support.
            • Indy-based client and server support.

            FireMonkey


            • New System Status Bar Options on iOS
              • Two new properties have been added to TForm for changing the behavior of the system status bar on iOS: SystemStatusBar.BackgroundColor and SystemStatusBar.Visibility.


            • Multi-Threading Support for TBitmap, TCanvas and TContext3D
            • Unification of Delphi and Java threads on Android: CallInUIThread has been deprecated. All code is now running in the Java UI Thread, removing the need for thread synchronization

            Improvements for Firebird


            • New Direct property to add support for the Direct I/O backup feature.

            Improvements for MySQL

            • Support for MySQL v 5.7.
            • Support for MariaDB v 5.5 or later. Use FireDAC's MySQL node to connect to MariaDB.
            • Compatibilty with the recent MySQL versions 5.6.x and 5.7.x.

            Database improvements


            • VCL TDBImage direct support for JPEG and PNG graphic formats.
            • Support for display options for BlobFields.
            • Direct GUID access for TField classes.

            RTL


            • HTTP Client
            • HTTP Client Library provides support for 64-bit Linux.
            • Improved async support in HTTP client
            • RTL support for 64-bit Linux
            • RAD Studio 10.2 Tokyo provides Linux file system support using standard system functions, streams, and the IOUtils unit. It also provides Standard RTL Path Functions support for 64-bit Linux.

            Improved C++ packages for mobile

            RAD Studio 10.2 Tokyo links C++ packages for iOS and Android statically. Previous versions of RAD Studio generated a file with the .so extension for C++ packages, but were not actually dynamic libraries. RAD Studio 10.2 Tokyo generates C++ packages with the correct file extension (.a). If you statically link against a .so package, you may need to change to link against the new filename.

            RAD Server Multi-Tenancy Support

            With Multi-Tenancy support, a single RAD Server instance with a single RAD Server database connection can support multiple isolated tenants. Each tenant has a unique set of RAD Server resources including Users, Groups, Installations, Edge Modules, and other data. All tenants have custom resources that are installed in the EMS Server. Also, as an administrator you can create new tenants, edit existing ones, add, edit, or delete details of your tenants, specify if the tenant is active, and delete the tenants that you do not need.

            iOS 10 Simulator, device, and macOS

            Full support for iOS 10, including iOS 10 32-bit and 64-bit debugging on device, Simulator support (Delphi only) and macOS Sierra support.

            The news are not only these, for the complete list of all news of this release go here.

            Sunday, February 19, 2017

            How-To implement 2 finger pan gesture in Delphi Firemonkey

            In Firemonkey, as you know, there is a great support for gestures: standard and interactive. The most important interactive gestures as Zoom, Pan, Rotate, DoubleTap (with an amazing description in dockwiki ), etc... are provided by the framework. See here for a full documentation. In a recent project I had the need to implement 2 finger pan gesture, that is not present in the provided gestures. But Firemonkey is a very great framework, and you can implement an event handler to manage custom actions when OnTouch occurs to specify what happens when a user touches the form using a finger or a similar device (not a mouse). So I wrote a little snippet of code that simulate the 2 finger pan gesture, I created a new demo and moved it into my Delphi Demos repository on Github.
            I tried it on Android and works fine and very smoothly. It should works fine on all Firemonkey supported platforms: Windows, Android, iOS and OSX.

            Tuesday, June 3, 2014

            Access Marvel Developer API with Delphi XE6



            Marvel has recent made available The Marvel Comics API, that allows developers everywhere to access information about Marvel Universe. "The Marvel Comics API is a RESTful service which provides methods for accessing specific resources at canonical URLs and for searching and filtering sets of resources by various criteria. All representations are encoded as JSON objects".



            So my idea is to access these API with the Delphi REST Client Library and create an awesome app.
            Let's start!
            At First we need to register to the developers program, once registered we will be given 2 keys one public and the other private that will be used to call the Marvel API. For more information about the service, resources, authentication and so on I refer you to the official Pages: General Info - Getting Started - Interactive API tester.
            You can access six resource types using the API:

            • Comics
            • Comic Series
            • Comic Stories
            • Comic events and crossovers
            • Creators
            • Characters

            In this first demo app I get information only about characters of Marvel Universe.




            I created an HeaderFooter Mobile Application by the wizard, modified the text of prebuilt label for the Title ("Marvel Character"), added a TLabel for the name of the Character, a TImage that is the representative image for the character and finally I insert the mainly 3 components of the REST Client Library: RESTClient, RESTRequest and RESTResponse.
            The Marvel Comics API’s base endpoint is http://gateway.marvel.com/v1/public so I put this URL in the BaseURL property of the RESTClient.



            The RESTRequest represent the resource in the REST pattern and in this case represent the character. I defined the Resource property in this way: characters?limit=1&offset={OFFSET}&ts={TS}&apikey={APIKEY}&hash={HASH}.
            There are 3 parameters:
            • limit - that represent the number of the result, in this case 1 result for time because we can see 1 character at time on the form
            • offset - that indicate the distance from the first character
            • ts - a timestamp (or other long string which can change on a request-by-request basis)
            •  apikey - your public key
            • hash - a md5 digest of the ts parameter, your private key and your public key (e.g. md5(ts+privateKey+publicKey)
            This is the snippet code of request:

            procedure THeaderFooterForm.ExecuteRequest;
            var
              TS: string;
              imd5: TIdHashMessageDigest;
              HASHStr: string;
            begin
              // StartWait show a progress dialog until the request is finished
              StartWait;
              TS := IntToStr(DateTimeToUnix(Now));
              RESTRequest1.Params.ParameterByName('OFFSET').Value := FOffSet.ToString;
              RESTRequest1.Params.ParameterByName('TS').Value := TS;
              RESTRequest1.Params.ParameterByName('APIKEY').Value := PUBLIC_KEY;
              imd5 := TIdHashMessageDigest5.Create;
              try
                HASHStr := TS + PRIVATE_KEY + PUBLIC_KEY;
                RESTRequest1.Params.ParameterByName('HASH').Value :=
                  imd5.HashStringAsHex(HASHStr).ToLower;
                RESTRequest1.ExecuteAsync(OnAfterRequest);
              finally
                imd5.Free;
              end;
            end;
            

            Once the call give a result will need to parse the JSON response to take the name of the character and its image, obviously respecting the JSON structure described in the official documentation:

            procedure THeaderFooterForm.OnAfterRequest;
            var
              RetObject: TJSONObject;
              RetData: TJSONObject;
              MResult: TJSONObject;
              Loader: TImageLoaderThread;
              Thumbnail: TJSONObject;
            begin
              try
                RetObject := TJSONObject.ParseJSONValue(RESTResponse1.Content)
                  as TJSONObject;
                RetData := RetObject.GetValue('data') as TJSONObject;
                MResult := (RetData.GetValue('results') as TJSONArray).Get(0)
                  as TJSONObject;
                Thumbnail := MResult.GetValue('thumbnail') as TJSONObject;
                Text1.Text := MResult.GetValue('name').Value;
                // TImageLoaderThread is a custom class to retrieve the image in a background thread
                // and 2 anonymous methods to notify when thread finish download image and when bitmap is ready  
                Loader := TImageLoaderThread.Create(true, nil, OnBitmapLoaded);
                Loader.ImgURL := Thumbnail.GetValue('path').Value + '.' +
                  Thumbnail.GetValue('extension').Value;
                Loader.Start;
              finally
                StopWait;
              end;
            end;
            

            The image is provided by another URL so I have to make another request for the image.
            Both the request (info character + image) are completed by background threads so it doesn't block the GUI.
            Here some screeenshot about final app





            The app run on Android device but the code work on Android, iOS, Windows and Mac.
            In the next post I will improve the app creating a master-detail structure that allowing to search character by other criteria!
            The code was loaded on my github repository.