Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Thu Sep 21, 2017 9:01 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Accessing Mac OS X Linen Texture Programmically
PostPosted: Thu Mar 21, 2013 10:20 am 
Offline

Joined: Fri Dec 23, 2005 7:59 pm
Posts: 35
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!

_________________
Searchware Solutions
Simply Great Software
http://www.searchwaresolutions.com


Top
 Profile  
Reply with quote  
 Post subject: Re: Accessing Mac OS X Linen Texture Programmically
PostPosted: Thu Mar 21, 2013 10:16 pm 
Offline
User avatar

Joined: Fri Sep 30, 2005 11:00 am
Posts: 583
Location: Beautiful Taiwan
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.

_________________
Sam Rowlands
rMBP 15" @ 10.8 & '08 MBA 13" @ 10.6 + 10.7, RB2012
http://www.ohanaware.com/
AppWrapper - Prepare Apps for Mac App Store & OS X 10.8 - http://www.ohanaware.com/appwrapper/


Top
 Profile  
Reply with quote  
 Post subject: Re: Accessing Mac OS X Linen Texture Programmically
PostPosted: Sat Mar 30, 2013 5:01 pm 
Offline

Joined: Fri Dec 23, 2005 7:59 pm
Posts: 35
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...

_________________
Searchware Solutions
Simply Great Software
http://www.searchwaresolutions.com


Top
 Profile  
Reply with quote  
 Post subject: Re: Accessing Mac OS X Linen Texture Programmically
PostPosted: Sat Mar 30, 2013 11:54 pm 
Offline

Joined: Mon Aug 15, 2011 10:25 pm
Posts: 293
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..

_________________
Real Studio 2012r1.1 | MacBook Pro i5, 10.6.8 | Windows 7


Top
 Profile  
Reply with quote  
 Post subject: Re: Accessing Mac OS X Linen Texture Programmically
PostPosted: Sun Mar 31, 2013 12:21 am 
Offline
User avatar

Joined: Fri Sep 30, 2005 11:00 am
Posts: 583
Location: Beautiful Taiwan
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.

_________________
Sam Rowlands
rMBP 15" @ 10.8 & '08 MBA 13" @ 10.6 + 10.7, RB2012
http://www.ohanaware.com/
AppWrapper - Prepare Apps for Mac App Store & OS X 10.8 - http://www.ohanaware.com/appwrapper/


Top
 Profile  
Reply with quote  
 Post subject: Re: Accessing Mac OS X Linen Texture Programmically
PostPosted: Sun Mar 31, 2013 12:58 am 
Offline

Joined: Mon Aug 15, 2011 10:25 pm
Posts: 293
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..

_________________
Real Studio 2012r1.1 | MacBook Pro i5, 10.6.8 | Windows 7


Top
 Profile  
Reply with quote  
 Post subject: Re: Accessing Mac OS X Linen Texture Programmically
PostPosted: Sun Mar 31, 2013 8:49 am 
Offline

Joined: Fri Dec 23, 2005 7:59 pm
Posts: 35
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.

_________________
Searchware Solutions
Simply Great Software
http://www.searchwaresolutions.com


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group