Delphi XE2: Is it possible to create Mac GUI applications without FireMonkey?
Asked Answered
B

2

20

Using Delphi XE2, is it possible to create a Mac GUI application without using FireMonkey for the GUI? If so, what could be used and how would one go about it?

Beare answered 16/9, 2011 at 8:40 Comment(4)
I think it would be easier to use FreePascal which has been supporting just that for ages.Vertumnus
The logical question to ask is why?Upsilon
@Misha: No reason at the moment. I was just curious if FM was the only option.Beare
Shannon, I am sure that given enough effort you could possibly do it without FireMonkey, but the effort is always going to be an order of magnitude greater. Cross-platform apps are at version 1.0 with Delphi so I would expect ease of development to increase dramatically over the next 12-24 months. I would not be diving in too deeply as yet as the landscape will change very quickly ;-)Upsilon
I
21

In principle, it is possible. But you'd need to translate the Objective-C headers and classes exposed by Apple. That is a huge task, part of which has already been done by the FreePascal people or the Objective-Pascal people.

But nothing prevents you from translating the (missing) headers yourself. You can call methods of a class and perform other functions using the pure C functions in the Objective-C runtime described on this page. It is just a lot of work, as the class library is huge. You could start with the Core Foundation, then the general Foudnation and then Cocoa, Quartz, etc. That is up to you. You'd probably also want to write wrappers for the classes.

Currently, out of the box, there is no easy way to do what you want.

But I plan to write a simple app as proof of concept that it is possible. That might take some time, though.

Update

You can also use the CoreFoundation headers translated by Embarcadero, in the Macapi namespace (i.e. all units that start with Macapi, like Macapi.ObjectiveC.pas, Macapi.ObjcRuntime.pas, Macapi.CocoaTypes.pas, etc), as well as System.Mac.CFUtils. There you'll find (some of) the major CoreFoundation classes and easy ways to use them from Delphi. I am not sure if these are properly documented, though, so you'll have to find out yourself how to use them. The comments in code might be able to help you.

A little more about this can be found in the docwiki. Note that a console app can also have a GUI.

Update 2

Yes, it is definitely possible. See http://rvelthuis.de/zips/sampleniblessapp.7z . Note that the most important Macapi unit turned out to be Macapi.AppKit.

Interfluve answered 16/9, 2011 at 20:27 Comment(2)
Not really a lot of work (although placing controls in code is always a little more work). I'm sure one could also use xibs or nibs. That is the next thing I want to try. One could also write a code generator that took a VCL form and wrote similar code for you.Interfluve
@RudyVelthuis Hi Rudy, any idea on the following question? I managed to create an empty webview frame, but no content wants to load: #9732317Success
B
1

Would you want to create a Windows GUI application without the VCL?
It's about the same idea, using directly the MacAPIs instead of WinAPIs.
Probably a bit more difficult (understatement) as there is not that wealth of documentation on how to do it from a Delphi/Pascal point of view.

Bajaj answered 16/9, 2011 at 22:58 Comment(3)
It is not that different from programming in Xcode and Objective-C, though. I tried it and succeeded. It is actually astonishing how easy it turned out to be (after some getting-used-to). Next project will actually use a .xib file to place the controls.Interfluve
@Rudy, Err, if it is not that different from programming in Xcode and Objective-C, then why not program in Xcode and Objective-C and save yourself the bother! I suppose as an exercise in what is possible you have proved that it is possible, but for all intents and purposes you would have to have a masochistic streak to want to do this.Upsilon
@Misha: the GUI-related code may be like writing in Objective-C, the rest doesn't have to be (i.e. only the V part of MVC would have to be like it). It was a proof of concept, and could actually be used as a case study for a VCL-like framework, by someone inclined to do so. Darren Kosinski (Emabrcadero) wrote he'll blog about the Macapi units and how to use them. For people who want native components instead if mimicked controls like FMX, it might be a start.Interfluve

© 2022 - 2024 — McMap. All rights reserved.