Real Software Forums
http://forums.realsoftware.com/

Accessing Mac OS X Linen Texture Programmically
http://forums.realsoftware.com/viewtopic.php?f=7&t=47361
Page 1 of 1

Author:  Searchware Solutions [ Thu Mar 21, 2013 10:20 am ]
Post subject:  Accessing Mac OS X Linen Texture Programmically

I am wanting to use the Mac OS X Linen Texture (such as that found in the back of the Notifcations Pane in Mac OS X Mountain Lion) as the backdrop of a window in an application.

This texture can be found at

/System/Library/Frameworks/AppKit.framework/Versions/C/Resources/NSTexturedFullScreenBackgroundColor.png


There are a few options, as I see it, available to me:

    1. Add that graphic to my app itself at just reference it internally. I'm not really sure of the legalities of this, plus if Apple ever updates this graphic in a future update to Mac OS X, my app would have to be updated to show the new version as well.

    2. Access the graphic directly by hard-coding the folderitem path into the application. The problem with this is that, again, if Apple ever changes the location of the graphic, this breaks my app. In addition, If I use
    dim f as FolderItem = Volume( 0 ).Child( "System" ).Child( "Library" ).Child( "Frameworks" ).Child( "AppKit.framework" ).Child( "Versions" ).Child( "C" ).Child( "Resources" ).Child( "NSTexturedFullScreenBackgroundColor.png" )

    that doesn't take into account localized versions of the OS. Do these folder names change with the language of the OS, or are they static no matter what?

    3. Use some sort of system call to retrieve the graphic from the system. But, I have no idea if such a critter exists let alone how to use it with Real.Studio.

Does anyone have any thoughts or suggestions here?

Thank you!

Author:  rowlands [ Thu Mar 21, 2013 10:16 pm ]
Post subject:  Re: Accessing Mac OS X Linen Texture Programmically

If you have the MBS plugin, you can use the following code.

Dim nsi as NSImageMbS = NSImageMBS.imageNamed( "NSTexturedFullScreenBackgroundColor" )


Otherwise I'm sure it can be done with the MacOSLib or even your own declares.

However this image isn't present in OS X 10.6, so you may want to include a backup image for that OS, or just in case Apple do change this functionality.

Author:  Searchware Solutions [ Sat Mar 30, 2013 5:01 pm ]
Post subject:  Re: Accessing Mac OS X Linen Texture Programmically

I meant to get back to you earlier about this, but I wanted to say thanks for this tip! This works really well!

Quote:
However this image isn't present in OS X 10.6, so you may want to include a backup image for that OS, or just in case Apple do change this functionality.


I was rather surprised as I thought this texture wasn't available either, but it DOES seem to be available, at least as of 10.6.8 (which is as far back as I'm supporting with this project anyway). Interesting...

Author:  shaosean [ Sat Mar 30, 2013 11:54 pm ]
Post subject:  Re: Accessing Mac OS X Linen Texture Programmically

Not seeing the file, in the location posted above, on Mac OS X 10.6.8.. Have not tried to get it through code, as it may be in a slightly different location..

Author:  rowlands [ Sun Mar 31, 2013 12:21 am ]
Post subject:  Re: Accessing Mac OS X Linen Texture Programmically

shaosean wrote:
Not seeing the file, in the location posted above, on Mac OS X 10.6.8.. Have not tried to get it through code, as it may be in a slightly different location..

If there is one thing I've learned the hard way, is that if Apple supply an API for accessing elements, and the code has been posted to do so, use it.

I know that the MBS costs money, the MacOSLib is free, although for some things it can be harder to wrap your head around.

The reason being, in 10.8.4, Apple can move the image file update the image file or a bunch of other things. if you use the API, your app will still get the correct image. If you directly link to it, and it moves, you'll no longer get it or if Sandboxing then prevents your app from accessing that location, you won't get it.

Another advantage for using the correct mechanism is that you'll also get the Retina version if your app is being used on a Retina display.

Author:  shaosean [ Sun Mar 31, 2013 12:58 am ]
Post subject:  Re: Accessing Mac OS X Linen Texture Programmically

I respect Christian's hard work (anyone remember using REALbasic before MBS will appreciate his work too ;-) ), but I was just remarking about the lack of the file at the location provided..

Author:  Searchware Solutions [ Sun Mar 31, 2013 8:49 am ]
Post subject:  Re: Accessing Mac OS X Linen Texture Programmically

rowlands wrote:
shaosean wrote:
Not seeing the file, in the location posted above, on Mac OS X 10.6.8.. Have not tried to get it through code, as it may be in a slightly different location..

If there is one thing I've learned the hard way, is that if Apple supply an API for accessing elements, and the code has been posted to do so, use it.

I know that the MBS costs money, the MacOSLib is free, although for some things it can be harder to wrap your head around.

The reason being, in 10.8.4, Apple can move the image file update the image file or a bunch of other things. if you use the API, your app will still get the correct image. If you directly link to it, and it moves, you'll no longer get it or if Sandboxing then prevents your app from accessing that location, you won't get it.


And this is precisely the reason I figured there had to be some sort of API call to get this rather than hard-coding it. I just had no idea what that call was. :D

I haven't done any further research as to where the linen texture is stored in 10.6.8 (because it's definitely there, apparently), but probably won't put too much effort into it.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/