Entries in crossplatform (1)

Monday
May282012

Apesuite Spotlight: The X Object

I just wanted to take a quick moment to point out a bit of the behind the scenes and non-visual utiltiy that Apesuite can bring to Firemonkey.

When we startied working on Apesuite we quickly realized how narrow the Firemonkey framework is in regards to cross platform APIs and system level access.  It was sometimes a case that the APIs were wrapped differently than we expected or not at all.  

To simplify acessing some of this information in a standard way regardless of the operating system, we wrote what we call the X object.  

To use the X object in your applications, all you have to do is include Ape.Utility.CrossPlatform to your uses clause.  Once you do you have access to the following functions:

System

  1. X.System.FontFamilies - Returns a list of system installed font family names for use with the Firemonkey TFont.
  2. X.System.DPI - Intended to be a cross platform inspection of the current DPI setting, though currently returns a hard coded value of 96. 
  3. X.System.DebugWrite - Writes to the Windows debugger api on Windows and to the terminal on OS X.
  4. X.System.DebugEnabled - Turns on and off the output written with X.System.DebugWrite

Files

  1. X.Files.OpenWithDefault - The provided filename will be open with the default application on the system. For example, if you supply an HTML file, the file may be opened with IE on Windows and Safari on OS X.. or whatever the registered default application is for HTML files.
  2. X.Files.PathFrom - Creates a path using supplied directory and file names to return a path built with the correct delimiter.

Environment

  1. X.Env.SearchPath - Returns the currently registered search path on the system.
  2. X.Env.AppFilename - Returns the "app" name of the application.  On OS X this is the application package in which the exe resides.  On Windows, this is the name of the folder in which the exe resides.
  3. X.Env.ExeFilename - Returns the actual filename of the running executable.
  4. X.Env.AppFolder - Returns the folder path to the executable, stopping at the level of the application package on OSX.
  5. X.Env.ExeFolder - Returns the full folder path to the executable.
  6. X.Env.TempFolder - Returns a writable temp folder path that can be used by your application.
  7. X.Env.HomeFolder - Returns the user's writable home folder.  On OS X this equates to /Users/username and on Windows,  C:\Users\username\AppData\Roaming or the appropriate path as set on the system.

This is just the start of what this object will eventually become.  As we find that we need access to something in a simple cross-platform way, we'll be extending this object appropriately.  In the meantime, feel free to use what is there when you are developing your firemonkey applications.