Re: Reading word at mouse pointer w/o Universal Access

2008-02-28 Thread Steve Christensen
I don't have specific knowledge but, yes, I would expect that the  
dictionary support is a trusted part of the OS, thus can be hooked  
into every application.


As far as I know, if you want to touch another application's UI, you  
have to go through accessibility. From the OS's point of view yours  
is just another application, so it seems reasonable that the user  
should decide whether or not to allow your application to see what's  
going on in another.


steve


On Feb 28, 2008, at 5:33 PM, Ryan Homer wrote:

Let me clarify that it doesn't seem to be the Dictionary  
application that's reading the word at the mouse pointer but rather  
the OS itself or some daemon, perhaps, when  Ctrl-Option-D is  
pressed. It might be the process called DictionaryPanel that seems  
to always be running.


Anyway, if anyone can point me to the appropriate functions/methods/ 
classes that might be involved in doing such a thing w/o the  
aforementioned techniques, please let me know.


On 28-Feb-08, at 8:27 PM, Ryan Homer wrote:

I've read this post (http://lists.apple.com/archives/accessibility- 
dev/2006/Aug/msg7.html) about using the accessibility options  
to read the text under the cursor. However, this requires that the  
user enable access for assistive devices in System Preferences.  
The application must therefore check for that. It also seems quite  
complicated; I don't want to have to deal with glyphs and the like  
- I only want the text under the cursor, full stop.


The Dictionary application is able to read a word under the cursor  
without enabling access for assistive devices.


Does anyone therefore know of an alternative way to do this?

Thanks in advance.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Read jpeg comments from file?

2008-04-03 Thread Steve Christensen

On Apr 3, 2008, at 2:13 AM, Trygve Inda wrote:

If you just need to display the image, use an NSImage
(initWithContentsOfFile).
If you need a greater control over metadata, use the ImageIO API
(search CGImageSource in doc and sample codes).


This works and retrieves the user text that was embedded in the  
image). Is
there a more Cocoa-way to do this ather than having to use  
QuickTime and

FSSpecs?


I don't know about detaching from QuickTime, but you can at least get  
rid of the FSSpec parts:



GraphicsImportComponent  tGIC;
ComponentResult  result;
UserData myUD;
Handle   dataHandle;
CFStringRef  cfString = nil;
FSReftheFSRef;
OSErrerr;


Handle   dataRef;
OSType   dataRefType;


CFURLGetFSRef ((CFURLRef) [NSURL fileURLWithPath:path], theFSRef);


result = QTNewDataReferenceFromFSRef(theFSRef, 0, dataRef,  
dataRefType);

if (result == noErr)
{
result = GetGraphicsImporterForDataRef(dataRef, dataRefType,  
tGIC);

if (result == noErr)
{


 err = NewUserData(myUD);
 if (!err)
 {
  result = GraphicsImportGetMetaData (tGIC, myUD);
  if (result == noErr)
  {
dataHandle = NewHandle (0);
if (dataHandle)
{
 err = GetUserDataText (myUD, dataHandle, kUserDataTextComment,  
1, 0);

 if (!err)
 {
   HLock (dataHandle);
   cfString = CFStringCreateWithBytes (kCFAllocatorDefault,  
(UInt8 *)
(*dataHandle), GetHandleSize(dataHandle),  
kCFStringEncodingMacRoman, false);

}
}
}
}



}

DisposeHandle(dataRef);
}

And a couple of other things I noticed:

- You could just use ComponentResult as your error/result variable  
type since it handles a superset of OSErr values.

- You're not calling DisposeHandle(dataHandle).


steve

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: fileHFSCreatorCode fileAttributesAtPath:traverseLink on app bundles

2008-04-08 Thread Steve Christensen

On Apr 7, 2008, at 10:03 PM, Jens Alfke wrote:

On 7 Apr '08, at 8:11 PM, Mike wrote:

I need to get the creator code of my app's bundle without diving  
into the bundle and reading the plist directly.


You're mixing up HFS creator codes with bundle identifiers, I think.

HFS creator codes are attributes of document files that identify  
what app created them. They're 4-character codes like 'ttxt'.  
They're not used much anymore in OS X, partly because most  
filesystems don't support them. (Even if your app defines one, you  
won't find any files inside the bundle with that creator code. It's  
stored as a key in the Info.plist.)


Bundle identifiers look like com.mycompany.MyApp and are used to  
identify applications in OS X. To get your app's bundle identifier,  
use the NSBundle snippet someone already posted.


Although if, for some reason, the OP is looking for the classic  
type and creator values (4-character OSType), you can also get them  
directly using CF:


void GetBundleTypeCreator(CFURLRef bundleURL, OSType bundleType,  
OSType bundleCreator)

{
bundleType = 0;
bundleCreator = 0;

CFBundleRef bundle = CFBundleCreate(kCFAllocatorDefault,  
bundleURL);


if (bundle != NULL)
{
CFBundleGetPackageInfo(bundle, bundleType, bundleCreator);
CFRelease(bundle);
}
}

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Finding running process on disk

2008-04-09 Thread Steve Christensen

On Apr 9, 2008, at 9:03 PM, Mike wrote:
Is there a way to locate the bundle of a running process on disk  
from within the running process?


You mean something like +[NSBundle mainBundle]?

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Tips to deploy applications to multiple Mac OS X versions

2008-04-10 Thread Steve Christensen

On Apr 9, 2008, at 11:08 PM, Ben Lachman wrote:

On Apr 9, 2008, at 3:27 PM, David Duncan wrote:

On Apr 9, 2008, at 7:43 AM, Lorenzo Bevilacqua wrote:

I'm trying to build a Cocoa application so that it can run on Mac  
OS X from version 10.3.9 to 10.5.
I have 10.5 installed so the application runs fine on my system  
and on other Leopard systems.
I haven't build a project for multiple platforms yet, so I tried  
to duplicate the main Xcode target and set different deployment  
target settings like


Typically you would only use 1 target. Use the SDK to the OS whose  
API your are targeting (such as the 10.5 SDK). Then set the  
deployment target to the minimum version you wish to run on  
(example, 10.3). Finally, you would do runtime checks for API  
availability.


This is totally true.  Multiple binaries make unhappy users. Of  
course buggy cross-version binaries make unhappy users too.


- Is there a way to differentiate part of code by platform? I  
remember I saw in some files lines like this


#if MACOSX_DEPLOYMENT_TARGET == MAC_OS_X_VERSION_10_4
#endif

is this correct?


This is a compile time check. Generally it is appropriate if you  
plan to ship a binary with a specific compile-time dependency. It  
sounds like you really want a run time check, which requires you  
to check for the availability of the features you are trying to  
use. How you check for this will depend on what you are doing to  
some degree.



To elaborate:

Your code will have checks like this in it:

if( [someObject respondsToSelector:@selector 
(niftyLeopardFeatureMethod:)] )

[someObject niftyLeopardFeatureMethod:anotherObject];
else
// handle the 10.4 and/or 10.3.9 case


Actually, what I find to be a better arrangement is something like this:

#if MACOSX_DEPLOYMENT_TARGET  MAC_OS_X_VERSION_10_5
if (![someObject respondsToSelector:@selector 
(niftyLeopardFeatureMethod:)])

{
// handle the pre-10.5 case here
}
else
#endif
{
// handle the 10.5+ case here
}

Picky, perhaps, but the benefit is that the check for existence of a  
10.5 feature, plus the code that handles the older OS versions, is  
inside a compile-time conditional. If you later change your  
deployment target to 10.5, all the older OS pieces are compiled out.  
You can also easily search your sources for  
MACOSX_DEPLOYMENT_TARGET to find your legacy code.


One caveat, though, is that you should probably have a runtime check  
for the minimum OS version you expect so that you don't end up with a  
crash if someone tries to use your nifty Leopard features on Tiger.  
Adding something to main() would probably be easiest, either checking  
against NSAppKitVersionNumber or calling Gestalt() to get the OS  
version.


steve

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


how to manage multiple non-document windows

2008-04-24 Thread Steve Christensen
I'm rewriting an old legacy app in Cocoa and have run into a  
stumbling block. The app is supposed to support having multiple  
windows open, but the window content is unrelated to the concept of a  
document - which is the normal multiple window model. Instead the  
windows provide a UI to perform specific calculations, among other  
things. An example of what I'm looking for would be if you had a  
version of the Calculator application where you could create multiple  
calculator windows so you could leave several calculations open  
simultaneously, if that makes sense.


When I start up the app, an instance of the window is created, but I  
can't figure out how to get it to repeat the process in response to  
selecting New from the File menu. I've found a bunch of info on  
multiple document windows, or a single non-doc window plus a  
preferences window, but nothing on instantiating multiple non- 
document windows. Did I just miss something basic, or is all of the  
magic really focused on NSDocumentController, etc.?


steve

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: how to manage multiple non-document windows

2008-04-25 Thread Steve Christensen

On Apr 24, 2008, at 5:01 PM, Ken Thomases wrote:


On Apr 24, 2008, at 6:39 PM, Steve Christensen wrote:
I'm rewriting an old legacy app in Cocoa and have run into a  
stumbling block. The app is supposed to support having multiple  
windows open, but the window content is unrelated to the concept  
of a document - which is the normal multiple window model.  
Instead the windows provide a UI to perform specific calculations,  
among other things. An example of what I'm looking for would be if  
you had a version of the Calculator application where you could  
create multiple calculator windows so you could leave several  
calculations open simultaneously, if that makes sense.


When I start up the app, an instance of the window is created, but  
I can't figure out how to get it to repeat the process in response  
to selecting New from the File menu. I've found a bunch of info on  
multiple document windows, or a single non-doc window plus a  
preferences window, but nothing on instantiating multiple non- 
document windows. Did I just miss something basic, or is all of  
the magic really focused on NSDocumentController, etc.?


If you're going to instantiating a window from a nib multiple  
times, it should generally be in the nib by itself.  Well, the nib  
can have other objects which accompany the window, like  
NSController subclasses.


Then, you load the nib once for each window that you need to  
instantiate.


It's quite helpful to use NSWindowController (or custom subclass)  
objects to manage each nib, its loading, and the resulting window.   
Typically, the NSWindowController is not contained in the nib.   
Rather it is instantiated to manage the loading of the nib from the  
outside.  It is often the File's Owner of the nib.


I put both the window and NSWindowController subclass in MainMenu.nib  
since some of the menu items control behavior in the window (and some  
of the window's current state is reflected in the menus. So I  
wouldn't think that you'd want to reload the nib for that case, right?


I've tried using -[NSWindowController initWithWindowNibName:owner:]  
to create a new controller instance (in response to FileNew),  
figuring that it'd drag the associated window along, but the  
controller's _window ivar is nil, so obviously that's not working. Is  
it just going to be easier for me to go the NSDocument, etc., route  
and say that I have a document that I'm going to load (wink,  
wink) in order to better fit within what appears to be the expected  
multiple window model?


I also just noticed that when I close one of these windows  
(configured with release on close), the controller still hangs  
around, but that's another issue...



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: how to manage multiple non-document windows

2008-04-25 Thread Steve Christensen

On Apr 25, 2008, at 12:45 PM, Erik Verbruggen wrote:


On 25 Apr 2008, at 20:06, Steve Christensen wrote:

I put both the window and NSWindowController subclass in  
MainMenu.nib since some of the menu items control behavior in the  
window (and some of the window's current state is reflected in the  
menus. So I wouldn't think that you'd want to reload the nib for  
that case, right?


Yes, you will want to reload the nib to get a new window. However,  
no, you don't want that for the menu bar. So you should move the  
window to a different nib file. Unfortunately, that will give you  
the excitement of having to update the menu status according to  
the selected window:


And if I move the window and window controller out of the main nib,  
I'm no longer given an option for targets associated with my window  
controller (the first responder doesn't list my controller IBActions)  
when trying to wire up all the menu items. This was likely why I just  
put them into the main nib in the first place.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: how to manage multiple non-document windows

2008-04-25 Thread Steve Christensen


On Apr 25, 2008, at 5:51 PM, Jean-Daniel Dupas wrote:


Le 26 avr. 08 à 01:44, Steve Christensen a écrit :

On Apr 25, 2008, at 12:45 PM, Erik Verbruggen wrote:


On 25 Apr 2008, at 20:06, Steve Christensen wrote:

I put both the window and NSWindowController subclass in  
MainMenu.nib since some of the menu items control behavior in  
the window (and some of the window's current state is reflected  
in the menus. So I wouldn't think that you'd want to reload the  
nib for that case, right?


Yes, you will want to reload the nib to get a new window.  
However, no, you don't want that for the menu bar. So you should  
move the window to a different nib file. Unfortunately, that will  
give you the excitement of having to update the menu status  
according to the selected window:


And if I move the window and window controller out of the main  
nib, I'm no longer given an option for targets associated with my  
window controller (the first responder doesn't list my controller  
IBActions) when trying to wire up all the menu items. This was  
likely why I just put them into the main nib in the first place.


You can add methods and Outlet manualy to a class in IB. In the  
Identity tab of the inspector, there is the class name, and the  
list of methods and outlets, both with a +button.


Add your methods to the first responder and then you will ba able  
to bind them.


That did it! Thank you so much for the pointer.

steve

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: FSCopyObjectASync Not Calling Callback In Cocoa

2008-04-30 Thread Steve Christensen
I noticed in some sample code (http://developer.apple.com/samplecode/ 
FSFileOperation/listing1.html), that after creating the  
FSFileOperationRef, it calls FSFileOperationScheduleWithRunLoop,  
specifying the current run loop. Just a guess that you're probably  
not making that association so the callback is never being called.



On Apr 30, 2008, at 5:42 PM, Matt Long wrote:

I execute this code and it successfully copies my file from source  
to destination:


- (IBAction)startCopy:(id)sender;
{
FSFileOperationRef fileOp = FSFileOperationCreate(NULL);

FSRef source;
FSRef destination;

FSPathMakeRef( (const UInt8 *)[[sourceFilePath stringValue]  
cStringUsingEncoding:NSUTF8StringEncoding], source, NULL );

Boolean isDir = true;
FSPathMakeRef( (const UInt8 *)[[destinationFilePath  
stringValue] cStringUsingEncoding:NSUTF8StringEncoding],  
destination, isDir );


OSStatus status = FSCopyObjectAsync (fileOp,
source,
destination,
NULL,
kFSFileOperationDefaultOptions,
statusCallback,
1.0,
NULL);

CFRelease(fileOp);

if( status )
NSLog(@Status: %@, status);
}


status returns with no error. However my callback never gets  
called. Here's the callback.


static void statusCallback (FSFileOperationRef fileOp,
  const FSRef *currentItem,
  FSFileOperationStage stage,
  OSStatus error,
  CFDictionaryRef statusDictionary,
  void *info
)
{

[snip]

}


Any idea why?

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: List Running apps and windows

2008-05-03 Thread Steve Christensen

On May 3, 2008, at 3:52 PM, Jere Gmail wrote:


I want to list all the running apps and their windows.
Running apps is easy with [ws launchedApplications] but I cant find a
way for listing their windows.
I have tried NSWindowList(win_count,arr_win)  but then
[[NSApplication sharedApplication] windowWithWindowNumber:arr_win[i]]
in a bucle will give me no info on windows from other apps.
Can anyone help? Thanks


Each application has its own private address space, so including  
another app's windows in your app's window list doesn't make sense.  
The only way to find out about other app's windows is to have the  
user enable accessibility in System Preferences. This has already  
been discussed in detail here and on other lists. You might try doing  
a search to see what's already been said.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: regarding fxPlug plugins

2008-05-08 Thread Steve Christensen

On May 8, 2008, at 7:10 AM, Shashi Kumar wrote:


I am new to fxplug. And I wanted to create an fxplug plugin from a
cocoa application. What should be the right way to do this ? I have
fxPlug SDK installed. The specification is: I have an cocoa  
application
with UI having effects and image. And I want to create fxplug as  
output

on any button event.

OR

How can I create a fxplug as output with cocoa application. And I  
don't

wanna use Xocde template for fxplug. That fxplug should get created by
cocoa or carbon application.

Can anyone explain it in simple and step wise manner giving some links
and hints.


Your description above didn't make it clear to me exactly what you want
to do, but here's I understood it:

I want to create a Cocoa application that will allow a user to
define an effect. When the user pushes a button in the UI, the
application will then create a FxPlug plugin that will implement
the effect.

Is that correct?

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: regarding fxPlug plugins

2008-05-09 Thread Steve Christensen
I don't know what FxFactory does to create custom effects, and I  
don't know that there is a preferred solution to your problem. That  
method is not the typical way that plugins are created. You can  
certainly write code that will assemble the expected FxPlug bundle  
pieces, which should be very straightforward. There are a few items  
that you will need to deal with on a per-plugin basis, though:


1. You will need to create a uniquely-named effect class (based upon  
FxFilter, FxGenerator or FxTransition) to execute the effect in the  
plugin. This is because Objective-C registers each class name at  
runtime, so if you create two plugins that use the same class name,  
the first-loaded plugin's class will be used by the second plugin.


2. For each plugin you will need to generate a pair of UUIDs, one to  
associate with the plugin and one with its group in the plugin's  
Info.plist file. You'll also need to store the plugin's class name in  
the Info.plist file.


As far as the code to actually do this, I leave that as an exercise  
for the reader. You should definitely read up on the FxPlug API and  
rendering documentation so you know how plugins work.



On May 8, 2008, at 8:39 PM, Shashi Kumar wrote:

Yes this exactly what I want. And I think this is the thing which  
FxFactory application do, as far I understood. So, could you give  
me the solution for this with explanation.



--- On Thu, 5/8/08, Steve Christensen [EMAIL PROTECTED] wrote:


From: Steve Christensen [EMAIL PROTECTED]
Subject: Re: regarding fxPlug plugins
To: cocoa-dev@lists.apple.com
Cc: [EMAIL PROTECTED]
Date: Thursday, May 8, 2008, 4:41 PM
On May 8, 2008, at 7:10 AM, Shashi Kumar wrote:


I am new to fxplug. And I wanted to create an fxplug plugin from a
cocoa application. What should be the right way to do this ? I have
fxPlug SDK installed. The specification is: I have an cocoa
application with UI having effects and image. And I want to create
fxplug as output on any button event.

OR

How can I create a fxplug as output with cocoa application. And I  
don't
wanna use Xocde template for fxplug. That fxplug should get  
created by

cocoa or carbon application.

Can anyone explain it in simple and step wise manner giving some  
links

and hints.


Your description above didn't make it clear to me exactly what you  
want

to do, but here's I understood it:

 I want to create a Cocoa application that will allow a user to
 define an effect. When the user pushes a button in the UI, the
 application will then create a FxPlug plugin that will implement
 the effect.

Is that correct?


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: how to create .qtz file from custom cocoa app

2008-05-12 Thread Steve Christensen

On May 12, 2008, at 6:30 AM, Shashi Kumar wrote:

I am looking for an cocoa app through which I can create .qtz file.  
The cocoa app will be having UI in which i 'll implement some  
effects on image. Now, lets say I 've a button export. When I 'll  
click export button, it should get saved as .qtz file. And I should  
be able to open it using quartz composer or 'll be able to render  
it in openGL.


That Cocoa app would be Quartz Composer. I don't believe there is any  
API that will allow you to create a .qtz file programmatically.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: list open application windows

2008-05-12 Thread Steve Christensen

On May 12, 2008, at 8:15 PM, Ben Lowndes wrote:


I'm a cocoa newbie, so I may be missing something obvious here: I'd
like to get a list of open windows for all currently running
applications.

I've been able to get the list of running applications from
NSworkspace, but can't see a method of getting the open windows.

Using appleScript I seem to be able to reference them all but I'm
wondering if there's a cocoa method?


This is a popular topic that has been discussed a lot here on this  
(and other) lists, so it would be a good idea to do some searching.  
In general, you can only directly reference windows in your own  
process. There are methods of getting some access to windows in other  
processes via the accessibility APIs, and someone here mentioned  
recently about a new Leopard-only method but I can't remember what it  
is off the top of my head.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: how to create .qtz file from custom cocoa app

2008-05-12 Thread Steve Christensen

On May 12, 2008, at 9:03 PM, Shashi Kumar wrote:

Is it not possible that from UI, I will generate XML file which  
will be kind of PList file of .qtz file containing tree list of its  
properties. And from that XML file we will create .qtz file ??


And, no, there isn't a Cocoa API that will effectively compile an  
XML file into a .qtz file. So as I said before, my understanding is  
that the only way you can create a .qtz file is by using the Quartz  
Composer application.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: How to tell if iTunes is running.

2008-05-24 Thread Steve Christensen
My version wasn't about using the path for something else; it was  
only about providing a method that doesn't care what the iTunes  
application is called. For example, if someone were to rename it  
iTunes 7.6.2, then your version would stop working.


However, as Thomas Engelmeier pointed out in a separate message,  
Apple doesn't currently localize the names of its iApps so you're  
probably safe.



On May 24, 2008, at 12:17 PM, Mr. Gecko wrote:


because I do not need the path for what I am doing.





On May 24, 2008, at 2:05 PM, Steve Christensen wrote:

Would something like this work better? It should deal with  
localization or if the user renames iTunes for some reason.


iTunesIsOpen = NO;
NSWorkspace* workspace = [NSWorkspace sharedWorkspace];
NSString* iTunesPath = [workspace  
absolutePathForAppBundleWithIdentifier:@com.apple.iTunes];

NSArray* lApplications = [workspace launchedApplications];
int lAppsCount = [lApplications count];
int a;
for (a = 0; a  lAppsCount; a++)
{
  NSDictionary* applicationD = [lApplications objectAtIndex:a];
  if ([[applicationD objectForKey:@NSApplicationPath]  
isEqualToString:iTunesPath])

  {
 iTunesIsOpen = YES;
 break;
  }
}

[iTunesLMenu setTitle: NSLocalizedString(iTunesIsOpen ? @Quit  
iTunes : @Launch iTunes,@)];



On May 24, 2008, at 8:29 AM, Mr. Gecko wrote:


Thanks I am using this
iTunesIsOpen = NO;
[iTunesLMenu setTitle: NSLocalizedString(@Launch iTunes,@)];
NSArray *lApplications = [[NSWorkspace sharedWorkspace]  
launchedApplications];

int a;
for (a=0; a[lApplications count]; a++) {
  NSDictionary *applicationD = [lApplications objectAtIndex:a];
  if ([[applicationD objectForKey:@NSApplicationName]  
isEqualToString:@iTunes]) {

 iTunesIsOpen = YES;
 [iTunesLMenu setTitle: NSLocalizedString(@Quit iTunes,@)];
  }
}
On May 23, 2008, at 5:07 PM, Nick Zitzmann wrote:


On May 23, 2008, at 4:01 PM, Mr. Gecko wrote:


How can I tell if iTunes is running with cocoa.


In this particular case, you should be able to get that  
information using -[NSWorkspace launchedApplications]...


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: How to tell if iTunes is running.

2008-05-24 Thread Steve Christensen

On May 24, 2008, at 2:11 PM, Jens Alfke wrote:


On 24 May '08, at 12:05 PM, Steve Christensen wrote:

Would something like this work better? It should deal with  
localization or if the user renames iTunes for some reason.

...
  if ([[applicationD objectForKey:@NSApplicationPath]  
isEqualToString:iTunesPath])


It would be simpler just to use the NSApplicationBundleIdentifier  
key, comparing it with com.apple.iTunes.


I didn't see that in the headers but it is in the docs. Yes, that'd  
work better.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: drawer attached to modal window is unresponsive

2008-05-30 Thread Steve Christensen
I dumped the items in the drawer so they wouldn't take up real estate  
unless needed since they can be on the bulky side. I ended up  
scrapping the drawer and just putting the items in the window itself.  
Bigger window but fewer issues.


Thanks...
steve


On May 30, 2008, at 1:16 PM, Andrew Merenbach wrote:


* PGP Signed by an unverified key: 05/30/08 at 13:16:53

Hi, Steve!

My experience is that drawers have always been buggy -- and drawers  
have had issues with Garbage Collection, too, under Leopard  
(although I haven't tested any drawers in a GC app since I upgraded  
from 10.5.2 to to 10.5.3 the other day).


Also, I've read on this list that drawers confuse people, and  
*some* might even call them poor UI.  There are alternatives for  
some situations, in my opinion, such as child/parent window  
pairings, inspector utility windows, and controls in toolbars.


That said, I don't have an exact answer for your main issue -- I  
think that someone else will likely have one that will solve it --  
but in response to your last question, I would personally give up  
on the drawer.  They've been nothing but trouble -- which is  
perhaps why Apple has all but dumped them in their own programs --  
Mail.app's sidebar, for instance, is now a source list in the main  
window, instead of being in a drawer.


Cheers,
Andrew

On May 30, 2008, at 12:55 PM, Steve Christensen wrote:

I'm working on a plugin that needs to do some involved setup, and  
I'm handling this in a modal window since the setup has to be done  
in an atomic fashion. The window also has an attached drawer. What  
I'm finding is that I can open and close the drawer, and a table  
view in the drawer will scroll if I move a scroll wheel while the  
mouse is over the table, but if I click on any of the controls in  
the drawer, I just hear a beep instead of having something useful  
happen.


Is this expected behavior? Is there any way to allow the drawer to  
process user events or should I give up on the drawer?


steve


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Why does this https post request always return 404 Not Found

2008-06-22 Thread Steve Christensen

Hmmm... Google not working?

- http://del.icio.us/help/thirdpartytools lists the APIs for a  
variety of programming languages at the bottom of the page.


- http://www.scifihifi.com/cocoalicious/ is an open source Cocoa  
del.icio.us client, so you should be able to see what they did.



On Jun 21, 2008, at 10:14 PM, an0 wrote:


Cool, it works. Thanks a lot.
But as to APIs, I really can't find the login API, or I would of
course use that instead of posting forms.
Can you tell me where the login API is?

On Sun, Jun 22, 2008 at 6:32 AM, Jens Alfke [EMAIL PROTECTED]  
wrote:
This is pretty weird. After some experimenting, I narrowed it down  
to the
value of the User-Agent header. I think the del.icio.us server is  
checking
that header and returning a 404 if it doesn't like it. And it  
doesn't seem
to like CFNetwork's default user-agent header, though it likes  
Safari and

curl.

You can programmatically set the User-Agent header value to  
Mozilla/5.0
(Macintosh; U; Intel Mac OS X 10_5_3; en-us) AppleWebKit/525.18  
(KHTML, like

Gecko) Version/3.1.1 Safari/525.20 and the result should work.

On the other hand, why are you trying to log into del.icio.us  
using forms
and cookies as though you were a web browser? That site already  
has a pretty

comprehensive API for applications to access it; you should use that
instead. (That may in fact be what they're trying to tell you by  
blocking

your request.)


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: [Moderator] List Guidelines - Must Read

2008-06-27 Thread Steve Christensen

On Jun 27, 2008, at 8:25 AM, Devon Ferns wrote:

I agree.  It's not like what's in the SDK is super secret.  Anyone  
can download it.


Yeah, anyone can download it, but in order to download it, you have  
to go through the process of accepting a license agreement that  
includes a NDA restriction. And if people honor the NDA then the  
contents of the SDK are, in fact, super secret because only the  
people bound by the NDA know what's in the SDK.


This is how it works in business. If you want to use somebody else's  
stuff, you often have to agree that what they tell you stops with you  
(or your company). If you violate the agreement, at the very least  
they won't be doing business with you again because you'll have a  
reputation of not being trustworthy.


Ultimately it comes down to how good your word is...

steve

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Trying to display a static image on my window. Any tips would be great

2008-07-01 Thread Steve Christensen

On Jul 1, 2008, at 6:41 AM, Papa-Raboon wrote:


I have been trying to get a static image to display in a corner of my
window and it has to literally just sit there and do nothing however I
have searched and searched Apple's dodumentation but no success yet.

I have dropped an Image View onto the window in IB and set the
following in my .h file in Xcode:

   IBOutlet NSImageView *theImage;

Then in my .m file I have this so far:

NSString *imageName;
NSImage *tempImage;

	imageName = [[NSBundle mainBundle] pathForResource:@logo  
ofType:@PNG];

tempImage = [[NSImage alloc] initWithContentsOfFile:imageName];

My image is set in my project in the resources folder and is called
logo.png and I hooked up the object to the NSImageView using IB.

Can't seem to get it to display. I believe I have a line of code
missing that will tie my MSImage to my NSImageView but not sure how.

Any Ideas please?

I'm pretty new to cocoa and don't understand all the lingo yet so be
gentle please.


This is just a static image from your application's bundle, so you  
should be able to do everything in IB without writing any code. After  
dragging a NSImageView into your window, open the Inspector window if  
it's not already open. Then set attributes Image=logo (Cocoa will  
figure out the file's extension), Border=none, Scale: to fit. Select  
Size from the inspector's popup menu and set the size to the image's  
size. Depending on where the image will be in your window, you may  
need to set the autosizing struts and springs right below the size  
info. You can find out if it stays in the correct place when your  
window resizes by selecting Test Interface from the File menu  
(command-R).


steve



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Trying to display a static image on my window. Any tips would be great

2008-07-01 Thread Steve Christensen
If you add an IBAction method to your window controller's class, it  
can respond to a click on the image by calling


[[NSWorkspace sharedWorkspace] openURL:@http://www.apple.com;];


On Jul 1, 2008, at 9:09 AM, Papa-Raboon wrote:


Thanks loads for that Steve. It seems to be doing as I wanted now.
Someone kindly pointed out that if I created my image with an Alpha
chanel that it could also have transparencies too which worked
beautifully. I just need to figure out how to hyperlink it so it can
open a URL in a browser now.

Cheers
Paul

2008/7/1 Steve Christensen [EMAIL PROTECTED]:

On Jul 1, 2008, at 6:41 AM, Papa-Raboon wrote:

I have been trying to get a static image to display in a corner  
of my
window and it has to literally just sit there and do nothing  
however I

have searched and searched Apple's dodumentation but no success yet.

I have dropped an Image View onto the window in IB and set the
following in my .h file in Xcode:

  IBOutlet NSImageView *theImage;

Then in my .m file I have this so far:

   NSString *imageName;
   NSImage *tempImage;

   imageName = [[NSBundle mainBundle] pathForResource:@logo
ofType:@PNG];
   tempImage = [[NSImage alloc]  
initWithContentsOfFile:imageName];


My image is set in my project in the resources folder and is called
logo.png and I hooked up the object to the NSImageView using IB.

Can't seem to get it to display. I believe I have a line of code
missing that will tie my MSImage to my NSImageView but not sure how.

Any Ideas please?

I'm pretty new to cocoa and don't understand all the lingo yet so be
gentle please.


This is just a static image from your application's bundle, so you  
should be
able to do everything in IB without writing any code. After  
dragging a
NSImageView into your window, open the Inspector window if it's  
not already
open. Then set attributes Image=logo (Cocoa will figure out the  
file's
extension), Border=none, Scale: to fit. Select Size from the  
inspector's
popup menu and set the size to the image's size. Depending on  
where the
image will be in your window, you may need to set the autosizing  
struts and
springs right below the size info. You can find out if it stays in  
the
correct place when your window resizes by selecting Test Interface  
from the

File menu (command-R).

steve


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: How to converting a Carbon nib to Cocoa?

2008-07-02 Thread Steve Christensen
This question was asked recently on the carbon-dev list and the  
answer was that there is no way to automate the process, nor even a  
method to get you part-way. Unfortunately this is likely to be one of  
those painful transitions for you...



On Jul 2, 2008, at 8:31 PM, Fosse wrote:

It would be a nightmare to recreate them by hand... , especially  
for the big

project which needs to move to Cocoa..

No better method?


On Mon, Jun 30, 2008 at 3:37 AM, Christopher Pavicich  
[EMAIL PROTECTED] wrote:



Hi:

  There is no way to automatically convert a Carbon Interface Builder
Document into a Cocoa Interface Builder Document.
  You are going to need to recreate all of your Carbon dialogues  
in Cocoa.

By hand.

--Chris


On Jun 29, 2008, at 1:59 AM, Fosse wrote:

My Carbon nib contains a lot of dialogs.  I want to make it be  
used by
another cocoa application and don't want to create all those  
dialogs and
econstruct the entire control hierarchy manually in the Interface  
Builder.
I don't care about connections, I'll wire them up myself. I'm  
just hoping

to avoid repeating the layout work.

The Cocoa nib uses binary file objects.nib which is different  
with the xml
file used byCarbon nib . I can't find any way to convert it with  
either

Interface Builder or nibtool.

Does anyone know of an automated method for doing the  
conversion?  Or

method to create Cocoa NIB without using Interface Builder?

I found two related questions here but no more answers..
http://lists.apple.com/archives/cocoa-dev/2001/Jul/msg00243.html
http://lists.apple.com/archives/carbon-development/2003/Aug/ 
msg00161.html


Thanks a lot!


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Does this caution need fixed? (newb)

2008-07-03 Thread Steve Christensen

On Jul 3, 2008, at 9:40 AM, Chris Paveglio wrote:

Also, should my code be caution free as a sign of clean coding or  
can some cautions that don't affect functionality be dismissed?


I'm one of those people who turns on just about every warning and  
then fixes the code that generates the warnings. Yeah, I might need  
to do more work up front, but I'd rather know what the compiler is  
thinking than have to later suffer a hard-to-track bug due to a case  
of late-night coding... :)


steve

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: iPhone: Implementing search and index combo, like Contacts?

2008-07-15 Thread Steve Christensen

On Jul 15, 2008, at 7:48 AM, Michael Dupuis wrote:


I'm assuming the NDA has been lifted now...


Nope, still under NDA, as mentioned a few days ago:


From: Cocoa Dev Admins [EMAIL PROTECTED]
Date: July 10, 2008 7:01:39 PM PDT
To: Cocoa-Dev List cocoa-dev@lists.apple.com
Subject: [Moderator] iPhone SDK is still under NDA - Do not discuss  
openly.


Until an announcement is made otherwise, developers should be aware  
that the iPhone SDK is still under non-disclosure. It can't be  
discussed here, or anywhere publicly. This includes other mailing  
lists, forums, and definitely blogs.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Detecting platform architecture within Cocoa app?

2008-07-29 Thread Steve Christensen

On Jul 29, 2008, at 12:56 PM, Jack Skellington wrote:


Is there a way to determine if an App is running on Intel or PPC
from within the App?


Depending on what you're trying to do, you can go at least a couple  
routes at build time.


If you only care about endianness:

#ifdef __BIG_ENDIAN__
#ifdef __LITTLE_ENDIAN__


If you care about the actual architecture:

#ifdef __ppc__  // 32-bit PPC
#ifdef __ppc64__// 64-bit PPC
#ifdef __i386__ // 32-bit Intel
#ifdef __x86_64__   // 64-bit Intel


There are also parallel ones defined in /usr/include/ 
TargetConditionals.h:


#if TARGET_RT_LITTLE_ENDIAN
#if TARGET_RT_BIG_ENDIAN

#if TARGET_CPU_PPC
#if TARGET_CPU_PPC64
#if TARGET_CPU_X86
#if TARGET_CPU_X86_64

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Checking for hackintosh

2008-07-30 Thread Steve Christensen

On Jul 30, 2008, at 8:55 AM, Tim McGaughy wrote:


On Jul 29, 2008, at 9:22 PM, John Joyce wrote:


Does anybody have a means or a tool for checking for hackintoshes?
I really don't approve of such things and would like to leave  
clever messages on my own software if it is run on a hackintosh.


What's a hackintosh?


A Windows PC that has been hacked to some extent so as to be able to  
install OS X. I didn't actually know myself, but Google is your  
friend. It looks like you first muck with the BIOS to make the PC  
friendlier to the OS installer and the OS itself, then away you go.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: My own listbox

2008-08-02 Thread Steve Christensen

On Aug 2, 2008, at 3:52 AM, Vitaly Ovchinnikov wrote:


Is it possible to get rid of blue focus border for NSTableView when
I select it?


In IB's inspector window, one of NSTableView's attributes is Focus  
Ring. Just set it to none.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Accessing member variables from another thread crashes

2008-08-10 Thread Steve Christensen

On Aug 9, 2008, at 5:24 PM, Dennis Harms wrote:

I've created a class with some member variables of type NSString*.  
In the
init function of the class, I write something into those strings.  
Now I call
a function of the initialized class instance as a new thread and  
try to read
from those member variables. This leads to a crash... Can someone  
give me a

hint as to why this won't work?

Here's my code, shrunk down to just the problematic part:

-- MyClass.h -
@interface MyClass: NSObject
{
@private
NSString* baseURL;
}

- (id) initWithHost: (NSString*) _url;
- (void) doSomething: (id) object;

@end
--

-- MyClass.m -
@implementation MyClass

- (id) initWithHost: (NSString*) _url
{
self = [super init];
baseURL = [NSString stringWithString: _url];


One thing I notice right off is that you're initializing an instance  
variable using a method that creates an autoreleased string, which  
will go away next time through the application's event loop. How  
about baseURL = [_url retain]; instead? If the string pointed to by  
_url is really immutable, you just need to increment the retain count  
so it'll continue to exist for the lifetime of your object (and then  
be sure to call [_url release] in your object's dealloc method so you  
don't leak memory).



return self;
}

- (void) doSomething: (id) object
{
NSString *url = [NSString stringWithString: baseURL];  // --  
the crash

occurs even when just reading the member


You might check that baseURL is still valid just before executing  
this statement when you have your app set up to execute this in other  
than the main thread. Making the change, above, will likely fix the  
crash.


Also, why are you calling -stringWithString: here? You already have a  
perfectly good string in baseURL. Use it directly.



}

@end
--

I've tried calling the function in the same thread, as well as three
different ways of calling it in a seperate thread. Every time there's
another thread involved, it crashes when accessing the member  
variable. If

the function doesn't access any members, the code works just fine...

instance = [[MyClass alloc] initWithHost: txtHost.text];
[instance doSomething: nil];   // Works
[instance performSelectorInBackground: @selector(doSomething:)  
withObject:

nil];   // Doesn't work
[[[NSThread alloc] initWithTarget: instance selector:
@selector(doSomething:) object: nil] start];   // Doesn't work
[NSThread detachNewThreadSelector: @selector(doSomething:) toTarget:
instance withObject: nil];   // Doesn't work


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Monospaced Simulated Braille

2008-08-12 Thread Steve Christensen
For the time being I suppose you could query the Braille font for its  
maximum character width, then draw each character in a string  
individually, centering it horizontally within a rectangle that has  
the maximum width. That would mean manually advancing each  
character's position on a line and handling wrapping, but it might  
get you there. This solution would also have the benefit of just  
working if the Braille font is later fixed to be monospace.



On Aug 11, 2008, at 6:31 PM, Deborah Goldsmith wrote:

The Braille characters should probably be monospace. Please write a  
bug.



On Aug 8, 2008, at 2:11 PM, James Jennings wrote:


I want to display and edit simulated Braille.


OS X has had Braille fonts since Tiger, so all I need to do is  
pass the

correct Unicode codes to NSTextView, except the Braille fonts are
proportional spaced, and I need monospaced.


There is a Unicode entity called BRAILLE PATTERN BLANK which could  
double as
a space, except that NSTextView doesn't treat it as white space.  
It's not

used for finding word breaks.


I've been looking for solutions along the lines of:

Override the character spacing of a font, or

Override the definition of white space, or

Override the word break algorithm.

but I haven't found documentation for any of that.

Any suggestions?

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Preventing windows from being dragged

2008-08-21 Thread Steve Christensen
Kinda hair-trigger on the defensiveness, dontcha think, especially  
since Andrew didn't actually say you were wrong?


The great majority of Mac applications do not run in kiosk mode so  
for most cases preventing window movement *is* wrong because you take  
control away from the user. Had you first mentioned that you were  
building a kiosk app - a vital piece of info - you might've received  
what you considered to be useful replies right off the bat. Or to  
quote the Xcode list's monthly reminder, For a great introduction to  
asking technical questions on a mailing list, see “How To Ask  
Questions The Smart Way” by Eric Steven Raymond at http://catb.org/ 
~esr/faqs/smart-questions.html.



On Aug 21, 2008, at 7:43 PM, Mike wrote:


What I am doing is definitely not wrong.

My application is a kiosk application, I put up shielding windows  
on all

attached monitors, and I enter kiosk mode. I then have a totally black
display with a single window - mine - which is the size of the main
display but which I want to be immovable.

I suggest you familiarize yourself with OS X's kiosk mode and Core
Graphics' shielding windows before you go telling people they are  
wrong.


What I am doing is no more wrong than a game developer taking  
over the

display.

In fact, you're a time-waster because instead of helping people,  
all you
can do is tell them you're wrong without providing any kind of  
solution (and without even knowing what you are talking about).


If you don't have the ability to help people, then please refrain  
from polluting the mailing lists with time-wasting nonsense.


Mike

Andrew Merenbach wrote:

Hi, Mike,
Unfortunately, I'm not sure as to the exact answer to your  
question.  Do bear in mind, however, that -- even if there is a  
way -- you'll have to take into account that the user might very  
well switch Spaces, rendering your window no longer visible.   
While I won't tell you right-off-the-bat that what you're doing is  
wrong, as you probably have a good reason for doing what you ask,  
may I enquire: what exactly are you attempting to do?  Helping  
everyone to understand your situation might help everyone in  
helping you.  :)

Best,
Andrew
On Aug 21, 2008, at 6:10 PM, Mike wrote:
Is there any way to prevent a Cocoa window from being dragged  
while it is onscreen?


Thanks,

Mike


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Preventing windows from being dragged

2008-08-22 Thread Steve Christensen

On Aug 21, 2008, at 8:31 PM, Kyle Sluder wrote:

On Thu, Aug 21, 2008 at 11:18 PM, Steve Christensen  
[EMAIL PROTECTED] wrote:
The great majority of Mac applications do not run in kiosk mode so  
for most
cases preventing window movement *is* wrong because you take  
control away

from the user.


Hold on, I don't agree with that.  Taking control away from the user
is wrong except in situation where it's right, in which case you
typically want something like a kiosk.  The way you've phrased it
seems like you're claiming that kiosk mode is wrong on its face.


Sorry, I thought I had been clear. The OP had written that he wanted  
to prevent a window from moving without providing the critical detail  
that he was writing a kiosk application, and some of the replies  
reflected that. If you have a good reason for taking over the screen  
(kiosk app, full-screen game, animated desktop background, slideshow/ 
presentation mode in a regular app, etc.), I think it's perfectly  
fine to use a window that doesn't move. If you're writing a regular  
app, the user should be able to arrange windows as s/he sees fit.


My two cents...

steve

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Window widgets

2008-10-17 Thread Steve Christensen
One thing to point out is that there is no guarantee that those  
window widgets will continue to be red, yellow and green dots in a  
future OS release. Or that someone won't patch - 
standardWindowButton:forStyleMask: as part of a haxie for skinning  
the UI, in which case you could end up with some bizarre-looking  
status images. I would suggest either tracking down a set of images  
you like and then include them in your app's bundle, or rolling your  
own. Fewer chances for surprises that way.


steve


On Oct 17, 2008, at 10:23 AM, Andre Masse wrote:


Oh yeah! Looks like its exactly what I need!

Thanks a lot,

Andre Masse


On Oct 17, 2008, at 13:07, Andy Lee wrote:


Does this help?

standardWindowButton:forStyleMask:

--Andy

On Oct 17, 2008, at 12:46 PM, Andre Masse wrote:


Hi all,

I want to use the same widgets as the OS uses for its windows  
(red, yellow and green dots) for a status bar in my application,  
like IB does to indicate sync status with XCode. This is to  
reflect the connection status (red == not connected, green  
connected etc.) in mine. Is there a direct access to these  
widgets? They're not in NSImage constants.


I've poke in IB's nib to steal them but no luck ;-)  I could  
roll out my own but would prefer using those provide by the OS.


Thanks and have a good day,

Andre Masse

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Window widgets

2008-10-17 Thread Steve Christensen

On Oct 17, 2008, at 10:52 AM, Kyle Sluder wrote:

On Fri, Oct 17, 2008 at 1:41 PM, Steve Christensen  
[EMAIL PROTECTED] wrote:

I would suggest either tracking down a
set of images you like and then include them in your app's bundle, or
rolling your own. Fewer chances for surprises that way.


If you want the widgets that are in the upper-left corner of the
screen, then this is precisely what you should not do.
+standardWindowButton:forStyleMask: is THE way to get the standard
window controls.  Mimicking them yourself is wrong.


The OP's request was for a way to get ahold of the red, yellow and  
green dots used (currently) as window widgets so that he could use  
them as status images:


I want to use the same widgets as the OS uses for its windows (red,  
yellow and green dots) for a status bar in my application, like IB  
does to indicate sync status with XCode. This is to reflect the  
connection status (red == not connected, green connected etc.) in mine.


Thus I feel that my comment was correct: He shouldn't rely on the  
current look of those widgets when he's using them in a context other  
than for which they were intended.


steve

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: what do you use to make icons and similar?

2008-10-19 Thread Steve Christensen

On Oct 19, 2008, at 5:50 AM, Benjamin Dobson wrote:

I believe png are really what I'm trying to make here, they seem  
to be recommended.


PNGs are not resolution independent, although they are perfectly  
acceptable. Saving as a TIFF then converting it to PDF with Preview  
works well for me.


Please excuse me if I missed something earlier in the thread, but my  
understanding of TIFFs (and PNGs and JPEGs) is that they're all  
purely raster formats. Thus, how does saving a TIFF as a PDF get you  
resolution independence? (At least that's what I read you to be saying.)


steve

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Bind button title to Boolean

2008-10-27 Thread Steve Christensen

On Oct 27, 2008, at 3:32 AM, Trygve Inda wrote:

How can I bind a button title to a Boolean but have a custom title  
for each
state? For example, I have a BOOL  isRunning, if YES, my button  
should read

Stop Running else Start Running.

I can't really do this with an alternate title since when the  
button is
pushed and temporarily held down, the title should not change as it  
is a

normal push pill button.


How about something like this? Whenever isRunning changes, it  
triggers an update of the button's title.



+ (void) initialize
{
...

[self setKeys:[NSArray arrayWithObject:@isRunning]
triggerChangeNotificationsForDependentKey:@buttonTitle];

...
}


- (NSString*) buttonTitle
{
return [self isRunning] ? @Stop Running : @Start Running;
}


- (BOOL) isRunning
{
return _isRunning;
}

- (void) setIsRunning:(BOOL)isRunning
{
[self willChangeValueForKey:@isRunning];
_isRunning = isRunning;
[self didChangeValueForKey:@isRunning];
}

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]


Re: Transparent image

2009-02-09 Thread Steve Christensen
Something similar to what you're asking was discussed on this list  
last week. To get you started:


[window setOpaque:NO];
[window setBackgroundColor:[NSColor colorWithCalibratedWhite:1.0  
alpha:0.5]];




On Feb 9, 2009, at 1:55 PM, Christian Graus wrote:

I have a window with an image showing on it.  Above this I have a  
window,
which contains an IKImageView derived class.  The IKImageView has a  
PNG in
it, which has a transparency layer.  What I need to do, is to make  
that
image appear above the image I have in my main window, that is, the  
control
needs to be transparent, so that one picture appears above  
another.  I've
found a sample that sets the window alpha, but that fades the whole  
window,

I just want to make the background transparent.  I'd appreciate any
suggestions.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Transparent image

2009-02-09 Thread Steve Christensen
Sorry, I misread your original posting. You're trying to make the  
view transparent, not the window. Based on what you're seeing when  
you set the view's backgroundColor, it looks like the alpha component  
is being ignored. I would guess that either the IKImageView only  
supports an opaque background or you need to play with it some more  
to get transparency to work. One way to find out would be to subclass  
IKImageView and override NSView's isOpaque method, returning NO.


Also, depending on what you're trying to do, you could always use  
NSImageView since that does respect transparency, at least when I've  
tried it with the non-bordered version.



On Feb 9, 2009, at 3:10 PM, Christian Graus wrote:


I'm sorry, I'm not sure that I'm following this.

Looking at it more closely, on the side I want this behaviour, it's  
just an IKImageView derived class on top of a window.  So, I just  
need to make the IKImageView show the image, transparently.  I've  
tried setting the Opaque setting, but it doesn't appear to have  
one.  I've also tried setting the background color to what you've  
shown here ( it gives me a white background ) or clearColor ( which  
gives me a black background ).  Is there something I am missing ?


Thanks for your help

Christian

On Tue, Feb 10, 2009 at 9:18 AM, Steve Christensen  
puns...@mac.com wrote:
Something similar to what you're asking was discussed on this list  
last week. To get you started:


[window setOpaque:NO];
[window setBackgroundColor:[NSColor colorWithCalibratedWhite:1.0  
alpha:0.5]];





On Feb 9, 2009, at 1:55 PM, Christian Graus wrote:

I have a window with an image showing on it.  Above this I have a  
window,
which contains an IKImageView derived class.  The IKImageView has a  
PNG in
it, which has a transparency layer.  What I need to do, is to make  
that
image appear above the image I have in my main window, that is, the  
control
needs to be transparent, so that one picture appears above  
another.  I've
found a sample that sets the window alpha, but that fades the whole  
window,

I just want to make the background transparent.  I'd appreciate any
suggestions.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How to get the white shadow effect when drawing NSStrings?

2009-02-22 Thread Steve Christensen
It seems like the best solution would be to handle both the Leopard+  
and pre-Leopard cases at runtime so any changes to HID over time are  
non-issues since you've limited the custom code to the pre-Leopard  
case. You might be able to get away with as little as adding a  
category to NSCell (typed in Mail so this hasn't been tested):


@implementation NSCell (MyRaisedBackgroundStyle)
- (void)useRaisedBackgroundStyle
{
#if MAC_OS_X_VERSION_MIN_REQUIRED  MAC_OS_X_VERSION_10_5
if (floor(NSAppKitVersionNumber) = NSAppKitVersionNumber10_4)
{
NSMutableAttributedString* text =  
[[[NSMutableAttributedString alloc] initWithAttributedString:

[self attributedStringValue]] autorelease];
NSShadow* shadow = [[[NSShadow alloc] init] autorelease];

[shadow setShadowColor:[NSColor colorWithCalibratedWhite:1.0  
alpha:0.5]];

[shadow setShadowOffset:NSMakeSize(0.0, -1.5)];
[shadow setShadowBlurRadius:0.0];

[text addAttribute:NSShadowAttributeName value:shadow  
range:NSMakeRange(0, [text length])];

[self setAttributedStringValue:text];
}
else
#endif

{
[self setBackgroundStyle:NSBackgroundStyleRaised];
}
}
@end

You'd need to call this method after the cell's text has been  
initialized/modified, which could just be done in -awakeFromNib for  
static text. If you wanted to get fancy, you could write a custom  
cell class that does all of the above whenever any of the text  
attributes are changed.


steve


On Feb 22, 2009, at 2:38 PM, Ken Ferry wrote:


Yes, I'm sure. :-) You won't get the subpixel font smoothing right, if
nothing else.
Also, the other method tracks whatever the current human interface  
design is

for text on a raised surface.

-Ken

On Sun, Feb 22, 2009 at 2:16 PM, Graham Cox  
graham@bigpond.com wrote:




On 23/02/2009, at 4:43 AM, Ken Ferry wrote:


 This effect cannot be implemented with text attributes.



Are you sure? This gets awfully close, unless I'm missing the  
point here

(the font to use your choice):

+ (NSDictionary*)   defaultTitleAttributes
{
   // return the dictionary used to specify the attributes for  
drawing

the title string in the palette windows. Override to
   // customize the title string

   static NSDictionary*sTitleAttrs = nil;

   if ( sTitleAttrs == nil )
   {
   NSFont* font = [NSFont boldSystemFontOfSize:11.0];
   NSMutableParagraphStyle* style = [[NSParagraphStyle
defaultParagraphStyle] mutableCopy];

   [style setAlignment:NSCenterTextAlignment];

   NSShadow* shadw = [[NSShadow alloc] init];

   [shadw setShadowColor:[NSColor whiteColor]];
   [shadw setShadowOffset:NSMakeSize( 0, -1.5 )];
   [shadw setShadowBlurRadius:1.0];

   sTitleAttrs = [NSDictionary
dictionaryWithObjectsAndKeys:font,NSFontAttributeName,

 style,NSParagraphStyleAttributeName,

 shadw, NSShadowAttributeName,

 nil];
   [sTitleAttrs retain];
   [style release];
   [shadw release];
   }

   return sTitleAttrs;
}

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


custom control's value change isn't being noticed by controller

2009-02-26 Thread Steve Christensen
I've written a custom control containing multiple NSTextFieldCells.  
The combined cell values result in a single integer value accessed  
via the control's intValue/setIntValue: and objectValue/ 
setObjectValue: (as a NSNumber).


The control is correctly displaying the current value when it's bound  
to a controller's someValue method, but if I edit one of the cells in  
the control, the controller's setSomeValue: isn't firing to pick up  
the change. When editing finishes, my control's textDidEndEditing:  
method is called. I calculate the updated control value and call  
[self setObjectValue:[NSNumber numberWithInteger:value]] to get  
observers to notice the change but nothing happens.


I figure I'm missing some little thing in my setup but I don't know  
what. Any clues?


steve

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


enabling Edit menu items in a modal window?

2009-02-27 Thread Steve Christensen
I'm working on a plugin that needs to do its configuration in a modal  
window. As soon as it calls [NSApp runModalForWindow:window], the  
items in the Edit menu are disabled. Is there some way to selectively  
enable some of the items? For instance, it'd be nice if I could do a  
Select All...


steve

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: enabling Edit menu items in a modal window?

2009-02-28 Thread Steve Christensen

On Feb 27, 2009, at 3:44 PM, Graham Cox wrote:


On 28/02/2009, at 4:26 AM, Steve Christensen wrote:

I'm working on a plugin that needs to do its configuration in a  
modal window. As soon as it calls [NSApp  
runModalForWindow:window], the items in the Edit menu are  
disabled. Is there some way to selectively enable some of the  
items? For instance, it'd be nice if I could do a Select All...


Well, does your modal window or its first responder or anything in- 
between implement selectAll:?


Commands in a menu will be enabled if anything in the responder  
chain can a) respond to them or b) explicitly enables them in a - 
validateMenuItem: call. When a modal window is displayed, the  
responder chain goes as far as the window and stops - it doesn't  
continue on up to the app as a modeless window's responder chain does.


As far as I know it should. My window is laid out in its nib like this:

- NSWindow
  - NSView (Content View)
...
- NSScrollView
  - MyCustomTableView
- NSTableColumn
- NSTableColumn
...

At the time I check the Edit menu, the focus ring is around my custom  
table view and a row is selected. NSTableView says that it implements  
selectAll: and deselectAll:, and just to be extra sure, I created my  
own that just call super, but that doesn't change any behavior.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Rotate NSImage to get a new NSImage, without drawing

2009-03-01 Thread Steve Christensen


On Feb 28, 2009, at 10:20 PM, Jerry Krinock wrote:


On 2009 Feb 28, at 20:10, Graham Cox wrote:

Create the new image, swapping width and height, lock focus onto  
it, apply a transform that rotates 90 degrees, and draw the first  
into the second.


You can't do it without drawing, but the drawing doesn't need to  
be onscreen.


Thanks, Graham.  Fun stuff

@implementation NSImage (Transform)

[snip]

@end


That version only works for a ±90° rotation since you're just  
swapping the width and height for the rotated image size. A more  
generalized solution would be:


- (NSImage*)imageRotatedByDegrees:(CGFloat)degrees
{
// calculate the bounds for the rotated image
NSRect imageBounds = {NSZeroPoint, [self size]};
NSBezierPath* boundsPath = [NSBezierPath  
bezierPathWithRect:imageBounds];

NSAffineTransform* transform = [NSAffineTransform transform];

[transform rotateByDegrees:degrees];
[boundsPath transformUsingAffineTransform:transform];

NSRect rotatedBounds = {NSZeroPoint, [boundsPath bounds].size};
NSImage* rotatedImage = [[[NSImage alloc]  
initWithSize:rotatedBounds.size] autorelease];


// center the image within the rotated bounds
imageBounds.origin.x = NSMidX(rotatedBounds) - (NSWidth 
(imageBounds) / 2);
imageBounds.origin.y = NSMidY(rotatedBounds) - (NSHeight 
(imageBounds) / 2);


// set up the rotation transform
transform = [NSAffineTransform transform];
[transform translateXBy:+(NSWidth(rotatedBounds) / 2) yBy:+ 
(NSHeight(rotatedBounds) / 2)];

[transform rotateByDegrees:degrees];
[transform translateXBy:-(NSWidth(rotatedBounds) / 2) yBy:- 
(NSHeight(rotatedBounds) / 2)];


// draw the original image, rotated, into the new image
[rotatedImage lockFocus];
[transform set];
[self drawInRect:imageBounds fromRect:NSZeroRect  
operation:NSCompositeCopy fraction:1.0] ;

[rotatedImage unlockFocus];

return rotatedImage;
}

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: enabling Edit menu items in a modal window?

2009-03-01 Thread Steve Christensen

On Mar 1, 2009, at 1:59 AM, Paul Sanders wrote:


At the time I check the Edit menu, the focus ring is around my custom
table view and a row is selected. NSTableView says that it implements
selectAll: and deselectAll:, and just to be extra sure, I created my
own that just call super, but that doesn't change any behavior.


Try it in a non-modal window.  My guess is that you will get the same
behaviour (which would eliminate one unknown).  FWIW I have a text  
edit

field in a modal window and all the menu items (which are connected to
firstResponder, as set up by IB) work as they should.


I added a text field to my modal window, and when it is the first  
responder the cut, copy, paste and select all menu items are enabled.  
Just for grins I added a second NSTableView to the window and  
rebuilt. When that table has focus, the edit menu items are all  
disabled, just like for the original table.


I admit the possibility that I'm doing something weird, but it must  
be a NSTableView-only kind of weird...


steve

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: enabling Edit menu items in a modal window?

2009-03-02 Thread Steve Christensen

On Mar 1, 2009, at 11:38 PM, Paul Sanders wrote:


I added a text field to my modal window, and when it is the first
responder the cut, copy, paste and select all menu items are enabled.
Just for grins I added a second NSTableView to the window and
rebuilt. When that table has focus, the edit menu items are all
disabled, just like for the original table.



I admit the possibility that I'm doing something weird, but it must
be a NSTableView-only kind of weird...


You could write a little class that derives from NSTableView and  
override
validateMenuItem.  Putting a debugger breakpoint on that might tell  
you

more.  The ins-and-outs of it are covered here:

http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/ 
ApplicationKit/Protocols/NSMenuValidation_Protocol/Reference/ 
Reference.html


I tried doing that, both in my NSTableView subclass and, just to see  
if it would make a difference, in my window controller. No  
difference. This continues to be strange since NSTextFields work just  
great in that regard.


I also tried another test case and created a new Cocoa app project  
with a table in a window. When I ran it as-is, Select All was  
disabled. When I subclassed the table and added validateMenuItem:,  
Select All was enabled. So at this point I'm stuck because nobody  
even calls validateMenuItem: for my modal window...


steve

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: enabling Edit menu items in a modal window?

2009-03-02 Thread Steve Christensen

On Mar 2, 2009, at 8:47 AM, Paul Sanders wrote:


nobody even calls validateMenuItem: for my modal window...


Well, you're one step closer to getting to the bottom of it  
perhaps, knowing

that.

Is the target of the menu item in question set to the first  
responder in IB?
Forgive me if you know all this, but at the code level, this  
corresponds to
setting a nil target for the menu item in question. This then  
searches the
responder chain, starting with the first responder, for the first  
object
than can respond to the selector defined for the menu item's 'sent  
action'
in IB, and then sends that object a validateMenuItem message (if  
the object
can respond to such a message that is, otherwise it just enables  
the menu

item regardless).  This is all in the docs.

So it is (probably!) one of:
  - the target of the menu item is incorrectly set in IB
  - the action of the menu item is incorrectly set in IB
  - the control in question does not respond to the action set in IB
  - the responder chain is screwed up somehow (unlikely)

Having said all of which, I haven't tried any of this with a table  
view,

only an edit field.

A bit of digging around in the debugger should reveal which it is.   
IB sets
up items 1 and 2 when you first create your application but maybe  
something
has trampled on them.  Item 3 can be tested, I would think, by  
sending the

table view the appropriate action message yourself in GDB.


I think I mentioned in my original message that I'm writing an  
application plugin (for FCP, actually), so I wasn't involved in  
setting up the application's nib.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: enabling Edit menu items in a modal window?

2009-03-02 Thread Steve Christensen

On Mar 2, 2009, at 9:10 AM, mmalc Crawford wrote:


On Mar 2, 2009, at 8:28 AM, Steve Christensen wrote:

http://developer.apple.com/DOCUMENTATION/Cocoa/Reference/ 
ApplicationKit/Protocols/NSMenuValidation_Protocol/Reference/ 
Reference.html
I tried doing that, both in my NSTableView subclass and, just to  
see if it would make a difference, in my window controller. No  
difference. This continues to be strange since NSTextFields work  
just great in that regard.
I also tried another test case and created a new Cocoa app project  
with a table in a window. When I ran it as-is, Select All was  
disabled. When I subclassed the table and added validateMenuItem:,  
Select All was enabled. So at this point I'm stuck because nobody  
even calls validateMenuItem: for my modal window...



Is this on 10.4?
Are you possibly hitting the bug described in http:// 
developer.apple.com/documentation/Cocoa/Conceptual/ 
NSPersistentDocumentTutorial104/08_CreationSheet/ 
chapter_9_section_6.html?


Yes, this is on 10.4. I suppose it could be that bug, except that  
NSTextFields work just fine...


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: enabling Edit menu items in a modal window?

2009-03-02 Thread Steve Christensen

On Mar 2, 2009, at 10:47 AM, Paul Sanders wrote:


I think I mentioned in my original message that I'm writing an
application plugin (for FCP, actually), so I wasn't involved in
setting up the application's nib.


Oh yes, so you did.  So, I have now done what I should have done  
before and
stuck a table view in my modal dialog to test it.  And ... the  
items in the
edit menu all work perfectly.  Specifically, when editting a table  
cell, I

can cut, copy, paste and select all.


What happens if you're not actually editing a cell but the table has  
focus? I would expect that Select All would be enable so that you  
could select all rows, right? That's the behavior I'm interested in...


steve

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


NSImage/NSBitmapImageRep color shifts when creating scaled copy

2009-03-06 Thread Steve Christensen
I'm trying to create a scaled-down copy of a large NSBitmapImageRep  
(i.e., 3200x2400 - 320x240). The smaller image eventually gets  
passed to OpenGL for drawing. What I'm finding is that the copy has  
color shifted. When I draw the copy, it appears to be darker and more  
saturated than the original.


I have tried several ways to get a copy that has the same color  
characteristics as the original but no success so far. My simplest  
version looks like this:


NSRect resizedBounds = {NSZeroPoint, desiredBitmapSize};
NSImage* resizedImage = [[[NSImage alloc]  
initWithSize:resizedBounds.size] autorelease];


[resizedImage lockFocus];
[[NSGraphicsContext currentContext]  
setImageInterpolation:NSImageInterpolationHigh];
[image drawInRect:resizedBounds fromRect:NSZeroRect  
operation:NSCompositeCopy fraction:1.0];

[resizedImage unlockFocus];

bitmapImage = [NSBitmapImageRep imageRepWithData:[resizedImage  
TIFFRepresentation]];



Am I missing something or is this just how Quartz works? Is there  
another way to get there? I'm not wedded to NSImage and friends if a  
better solution exists elsewhere. This needs to run on 10.4 or later.


Thanks,
steve

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSImage/NSBitmapImageRep color shifts when creating scaled copy

2009-03-06 Thread Steve Christensen

On Mar 6, 2009, at 1:15 PM, Kyle Sluder wrote:

On Fri, Mar 6, 2009 at 2:21 PM, Steve Christensen puns...@mac.com  
wrote:
I'm trying to create a scaled-down copy of a large  
NSBitmapImageRep (i.e.,
3200x2400 - 320x240). The smaller image eventually gets passed to  
OpenGL
for drawing. What I'm finding is that the copy has color shifted.  
When I
draw the copy, it appears to be darker and more saturated than the  
original.


Sounds like you're falling victim to this problem:
http://www.4p8.com/eric.brasseur/gamma.html


In this case what I found out was running into a difference of  
opinion between the ColorSync profile attached to the  
NSBitmapImageRep in the source image and the default one (or lack of  
one) for a newly-created NSBitmapImageRep in the resized image.


I ended up rewriting my code to create a new NSBitmapImageRep with  
the destination size, then copy what I thought were relevant  
properties (NSImageRGBColorTable, NSImageColorSyncProfileData,  
NSImageGamma) from the source NSBitmapImageRep if they exist. Then  
create a context using +[NSGraphicsContext  
graphicsContextWithBitmapImageRep:] using the destination  
NSBitmapImageRep and draw into that.


steve

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Need to use Quartz... I think?

2009-03-07 Thread Steve Christensen
I'm coming in on the middle of this so I don't know if what's already  
been discussed. How many -unique- images are there? If you're working  
with a relatively small number of images, you could just cache a  
single copy of each and then supply the correct image for a  
particular cell.


If you have image versions that are otherwise identical except for,  
say, a different background, you could reduce your image requirements  
to a smaller number of images with a common graphical piece and then  
one image for each background. Then when you draw, draw a background  
image then draw the common image on top.


If you really do have a larger number of images, you might be able to  
get away with either replacing them with a single larger image that  
has all of the smaller images laid out in a grid, then just draw a  
portion of that image; or creating a NSBitmapImageRep big enough to  
hold all the images, making it the current graphics context, drawing  
the smaller images into it, then draw a portion of the image.


If other solutions won't work to reduce your memory footprint, you  
may need to reduce the number of images you're working with. Just one  
of the hazards of working with a small-memory (relatively) device...


steve


On Mar 7, 2009, at 10:35 AM, James Cicenia wrote:


Unfortunately they are not sequential.

They are a graphical calendar with two images per month. They can  
exist, they can be yellow or they can be green.

So, unfortunately, I can't do that.
:-(


On Mar 7, 2009, at 12:28 PM, David Duncan wrote:


On Mar 7, 2009, at 10:22 AM, James Cicenia wrote:


I am creating a visual indicator.
There can be approximately up to 400 rows.
Each row can have up to 24 little images.



I imagine those images are pretty small if you can fit 24 of them  
across the screen...


If the images are always displayed in the same order, then the  
simplest method might be something like this:
Create a single image with all of your little images side by side  
in the correct order

Create a UITableView
For each UITableViewCell, embed a single opaque UIImageView.
Assign the indicator UIImage as the content of that UIImageView
Size the UIImageView to expose the number of indicators you desire  
and set its contentMode to UIViewContentModeLeft.


If the indicators can appear in any order, you probably would  
still want to do this in a UITableView, but you probably have more  
work.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Design question: View with hell lot of drawing

2009-03-10 Thread Steve Christensen

On Mar 10, 2009, at 1:39 AM, rajesh wrote:


I need to display huge number of elements  in NSView (1000-2000).
These elements are generally made of high resolution image files  
with some fancy drawing around them. These elements may vary from  
size 300 X 270 to 4280 X 3500.


First I made use of NSView's for elements, I abandoned the idea  
because I was supposed to connect some elements with lines,  
obviously line drawing was going behind the elements .
Secondly I tried with CALayer's and I have a problem of GPU  
constraint for the resolutions I mentioned.(I tried optimizing, by  
only displaying required layer in the View's visible part ,that too  
didn't help much)


Is there any other way of approach, or should I be making use of  
one of the ways I mentioned ?


In addition to Graham's comments in a previous reply, I'd also  
suggest that, depending on what your view does, to generate a smaller  
thumbnail to represent the full-sized image. This both reduces your  
memory footprint as well as improving drawing speed. If the thumbnail  
size is dependent upon the view size, you could either invalidate  
your thumbnail cache when the view size changes or choose a maximum  
thumbnail size that you just scale appropriately.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSSlider changed notification

2009-03-11 Thread Steve Christensen
As previous replies have mentioned, if you're looking for continuous  
change, you need to make sure that continuous is set to YES, either  
by checking continuously send action while sliding in IB or by  
calling [mySlider setContinuous:YES].


You could keep track of changes to the slider value by either binding  
the slider's value to a property in your controller (which also means  
that the slider will stay in synch if the value is changed  
elsewhere), or adding a method to the controller of the form


- (void)mySliderChanged:(id)sender;

and then connecting the slider's target/action to that method in your  
controller by dragging a connection between the slider and controller  
in IB.



On Mar 10, 2009, at 11:03 AM, David Alter wrote:

I'm sure this is something basic that I'm just missing. For some  
reason I
can not find how to get a notification when my slider changes  
value. I want

to be able to subscribe to receive a notification if the slider value
changes. Is there a delegate method for this? What is the best way  
to get

this?

I guess one option would be to use KVO, but I suspect there is
a simpler solution.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: ack no class

2009-03-30 Thread Steve Christensen
Maybe start up that generated app in gdb with a breakpoint set on  
NSLog? When it breaks you could look at the backtrace. That may at  
least tell you where the message is being generated, which may then  
tell you why.



On Mar 29, 2009, at 3:26 PM, Mark Sibly wrote:


I'm the author of BlitzMax, a multi-platform 'basic like' compiler.

I've recently had a few reports that apps generated by the Mac version
are producing a mysterious ack no class error when they start up -
similar to this:

 2009-03-24 22:26:14.460 test[10329:717] ack no class

This appears to be written to 'stderr' and is occuring somewhere
between [NSApp run] and the [applicationDidFinishLaunching] method in
the app delegate - ie: it appears to be somewhere inside OsX/Cocoa.

I have been unable to reproduce this myself, but it's occurring on at
least one other machine with an identical config to mine - an Intel
Mac with OS X 10.5.6.

Has anyone else encountered this?

From the few similar cases I've found via google, Safari beta4 has
been suggested as a cause but I have that installed and am not getting
this error.

It's not really a biggy, as it doesn't seem to affect the app in any
way, it's just pretty ugly for users of an apparently 'basic like'
language.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Handling List of Hardware Devices in NSTableView w/ Asynchronous Updates

2009-04-01 Thread Steve Christensen

On Apr 1, 2009, at 7:51 AM, Grant Erickson wrote:

I've a list of hardware devices in an NSTableView. The contents of  
the table

view are updated accordingly using the device model (C++) getters in
objectValueForTableColumn and using the device model setters in
setObjectValue.

However, the device model can also asynchronously create (sometimes
rapidly-order of tens to hundreds of milliseconds) updates for one  
of the
model values independently of the getter. To handle this, I  
currently have
the controller implement a delegate method for these asynchronous  
updates

and then do:

[mDeviceTable reloadData];

Unfortunately, this then causes the table to hit all the device  
getters for
all the devices and update all the columns even though only a  
single column
(and possibly row) has changed thereby creating needless bus  
traffic and

activity.


One approach would be to use a NSMutableIndex to keep track of which  
device/table row is in need of an update. As each device finishes an  
update it would set its index in the set. The benefit is that if your  
hardware updates more often than your chosen UI update rate, only the  
most recent values will be used. If device updates are happening in  
another thread, you'll need to protect read/write accesses to the  
index set with a lock so you don't access it when it's in an  
inconsistent state.


Then have a timer run periodically to check if any devices have  
updated information. For each index, just mark the corresponding  
table row as needing an update, then remove that index from the index  
set. When the table view is asked to update stale rows, it will just  
call tableView:objectValueForTableColumn:row: as for any other update.


My first inclination is to create an array of dictionaries that act  
as a
cache for the device attributes, have the asynchronous delegate  
update the

appropriate key/value and then have reloadData update from there.


Caching information would be a good idea, whether it happens in your C 
++ device class(es) or by copying information into a NSArray. It  
allows you to repeatedly access current device information without  
further touching the hardware, particularly if device access times  
are on the slow side. Getting that information synchronously would  
lock up the UI while the data is being fetched.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: finder file size

2009-04-07 Thread Steve Christensen
Well, directories -are- a single file so it makes sense that the file  
size refers to exactly the directory and not its contents. Besides,  
for the general case of looking at files/folders in a particular  
directory, you could get all the attributes quickly without paying a  
time penalty to recursively calculate the total file size until you  
decide that you actually need that information.


As for choosing to use Carbon, making that decision based on what the  
Finder is or isn't doing is not very relevant. Not everything has  
been made native Cocoa, or a Carbon solution might be better for a  
particular task. If you don't want to see procedural calls in your  
general code, just wrap the Carbon bits in a Cocoa method wrapper and  
claim blissful ignorance of the implementation. :)



On Apr 7, 2009, at 9:04 PM, Jo Phils wrote:


Thank you I.S. and all who replied! :-)

It's my understanding that [NSFileManager  
fileAttributesAtPath:traverseLink:] will do fine for a single file  
but for directories it won't include the sizes of the  
subdirectories as Finder does.  That's what I got in my testing as  
well but maybe I'm missing something?


As for not using Carbon I suppose there's no reason I can't use  
it.  I was just thinking with Finder going away from Carbon and  
since I'm just learning Cocoa I was trying to avoid it if I could.   
But if it's the best way I can use it...


Thank you very much,

Rick


From: I. Savant idiotsavant2...@gmail.com
To: Jo Phils jo_p...@yahoo.com
Cc: cocoa dev cocoa-dev@lists.apple.com
Sent: Tuesday, April 7, 2009 11:13:19 PM
Subject: Re: finder file size

On Tue, Apr 7, 2009 at 11:09 AM, Jo Phils jo_p...@yahoo.com wrote:

My apologies if this has been answered before but isn't there a  
simple way to get the file size as it shows under Size in Finder  
without using Carbon and without enumerating the directory?  My  
understanding is NSFileSize will not do it?


  Have you tried searching the archives? How about Google?

  See -[NSFileManager fileAttributesAtPath:traverseLink:] ... it
includes a fileSize attribute.

--
I.S.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Storing bundle loaded main class instances in NSArray

2009-04-08 Thread Steve Christensen
If your _instances variable is initialized using either  
[NSMutableArray array] or [NSMutableArray arrayWithCapacity:...], it  
will be autoreleased and become invalid. You can fix that by doing  
something like [NSMutableArray array] retain] or using  
[NSMutableArray alloc] initWithCapacity:...].


When an object is released, the underlying memory is reclaimed but  
any variables that were referencing the object are unmodified so they  
now point to garbage.


And as for zombies, Google is your friend. The first hit for  
NSZombieEnabled gives a good description.



On Apr 8, 2009, at 6:15 AM, Daniel Luis dos Santos wrote:

The _instances mutable array is instantiated in the default init  
method that is called on all other init methods. It is never  
released. I am using an Auto release pool. The log writes ;


2009-04-08 13:56:53.189 TestRunner[2568:813] *** -[NSFileManager  
fileExistsAtPath:]: unrecognized selector sent to instance 0x1126f0


When releasing a pointer does its value change ? or it just  
releases the memory ?

What is that zombie thing you're talking about ?


On Apr 8, 2009, at 1:53 PM, Graham Cox wrote:



On 08/04/2009, at 10:33 PM, Daniel Luis dos Santos wrote:

	if ((nil != saID)  ([[saID class] isSubclassOfClass: [NSData  
class]])) {

//[_instances addObject: aDriverInstance];

When I uncomment the addObject line above, later in the code  
NSFileManager throws a doesNotRespondToSelector exception, which  
is very odd.





Still not enough to go on.

Where is _instances initialised? Is it released anywhere? What  
does the exception log? Is it possible _instances could be being  
released leaving a stale pointer that points to NSFileManager?  
Have you run it with NSZombieEnabled turned on? Any difference?


Please post the *relevant* code.

--Graham


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: finder file size

2009-04-08 Thread Steve Christensen

On Apr 8, 2009, at 5:51 PM, Gerriet M. Denkmann wrote:

On 9 Apr 2009, at 02:03, Sean McBride s...@rogue-research.com  
wrote:



On 4/7/09 9:04 PM, Jo Phils said:

As for not using Carbon I suppose there's no reason I can't use  
it.  I
was just thinking with Finder going away from Carbon and since  
I'm just

learning Cocoa I was trying to avoid it if I could.  But if it's the
best way I can use it...


Carbon is an overloaded term, it means many things all at once.


Yes. This has confused me a lot.

I would propose to use only the term Carbon application as  
defined in:


 Carbon application ::= app whose main.c file is very big (more  
than 5000 characters) and contains InstallApplicationEventHandler().


as opposed to:
Cocoa application ::= app with a very small main.m (less than 100  
characters) which contains NSApplicationMain().


And NOT to use the term Carbon (other than in Carbon  
application), but to use the term C-function instead.


Like:
To get the file size one can use some methods in NSFileManager,  
or, if one needs more detailed information (e.g. physical size,  
sizes of resource fork), one can use the C-functions documented in  
the File Manager Reference (defined in Files.h), which are part of  
the CoreServices.framework.


I don't know about an official definition, but my definition of a  
Carbon application is one that uses either a Carbon nib or resource  
fork-based user interface components, i.e., legacy menu manager,  
control manager (or HIViews), window manager, etc., even if it uses  
Cocoa to perform some tasks.


My definition of a Cocoa application is one that uses a Cocoa nib  
and/or user interface components based off of NSView, NSWindow, etc.,  
even if it calls the C-based File Manager, Core Foundation, Quartz,  
etc., to perform some particular task.


To give an example of my confusion about the term Carbon: The  
aforementioned File Manager Reference contains this sentence: In  
Carbon, this name must be a leaf name; the name cannot contain a  
semicolon.


That is unrelated to any Carbon/Cocoa definition. File Manager path  
names separate path components with colons (:) instead of slashes (/).


Or: the Carbon File Manager does not return the number of files in  
this field


I guess this would depend on which API call and which parameter this  
refers to.



A somehow unrelated question:
What would be a rational reason to create a new Carbon  
application today?


You're more comfortable working in C or C++ and your intention is  
that the application you create will only be used in a 32-bit  
environment.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: C: treated as a path component

2009-04-15 Thread Steve Christensen

On Apr 15, 2009, at 1:34 PM, Jean-Daniel Dupas wrote:


Le 15 avr. 09 à 01:57, Dragan Milić a écrit :


Hell all,

Let's suppose I've got NSString @C:omponent , which represents  
the name of a file. Is there a way to instruct NSString class not  
to treat a leading single letter followed by a column as a path  
separator? Namely, I need this one treated as only one path  
component @C:omponent, but NSString sees two, @C: and  
omponent. So, if I ask for the last path component, I get  
@omponent instead of the whole string @C:omponent.


I've searched documentation, took a look into NSPathUtilities.h,  
but no help.



You can use the CFURL API which provide a set of function to  
manipulate path, but due to memory management, it's not as clean  
than the Cocoa string API (objects are not autoreleased).


• CFURLCreateCopyAppendingPathComponent
• CFURLCreateCopyAppendingPathExtension
• CFURLCreateCopyDeletingLastPathComponent
• CFURLCreateCopyDeletingPathExtension

CFURLCopyPathExtension
CFURLCopyLastPathComponent

etc…


Or to stay entirely in Cocoa-land, you could always use

NSArray* components = [filePath componentsSeparatedByString:@/];
NSString* lastPathComponent = [components objectAtIndex:([components  
count] - 1)];


Not quite as straightforward as the methods in NSPathUtilities but it  
would certainly work around the colon issue...


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Problem in displaying image in NSTableView

2009-04-20 Thread Steve Christensen

On Apr 18, 2009, at 7:54 PM, cocoa learner wrote:


Hello All,
In my NSTableView I am using NSImageCell as one column to display  
images.

And I have implemented my datastore method like this -

- (id) tableView: (NSTableView *)aTableView
objectValueForTableColumn: (NSTableColumn *)aTableColumn
row: (NSInteger)rowIndex
{
/* code to display other column data
.
*/

//Code to display image
if (coloumnIndex == 2)
{
NSImage *tmpImage = [[tableData objectAtIndex: rowIndex] personPhoto];

NSLog(@TableController::dataSourceSecondAPI : [ Debug ] Coloumn  
Index = 2,

so returning the image);

return tmpImage;
}
}

And my persons init method looks like this -

- (id) init
{
[super init];


Probably safer to use self = [super init]; here. For most classes  
self won't change, but it has been brought up on-list before that  
there are some exceptions where [super init] can give you a  
completely different instance.



personName = @New name;
personAddr = @New addrress;
personPhoto = [[NSImage alloc] initWithContentsOfFile:
@/Volumes/Working/cocoa/Play-NSTableView/Linea.jpg];
if (personPhoto == nil)
{


You need a call to [self dealloc] here, otherwise you leak an  
instance of the class if you can't load the image.



return nil;
}

 return self;
}

After running my application the image looks very small like an icon.
Can any one tell me how to display a bigger image in NSTableView?


The image is scaled to fit the table's row height, rather than having  
the row height adjusted to fit a particular image. If the row height  
isn't currently large enough, you can either change it in IB or in  
code. And for 10.4 and later, you can have your table's delegate  
implement -tableView:heightOfRow: to change the height on a row-by- 
row basis.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: OpenGL

2009-04-20 Thread Steve Christensen

On Apr 20, 2009, at 4:23 PM, Andrew Farmer wrote:


On 20 Apr 09, at 06:59, fawad shafi wrote:
i am new on OpenGL Framework, i dnt know to that how to display  
the simple 3D image using OpenGL.


This doesn't appear to be relevant to Cocoa development, at least  
until the Cocoa OpenGL views get involved. If you're just getting  
started with OpenGL, you may want to begin by getting yourelf a  
copy of the OpenGL Red Book.


http://www.opengl.org/documentation/red_book/


...and subscribe to the mac-opengl mailing list, which is also a  
better place to ask these sorts of questions.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Why is NSString-FSRef so hard?

2009-04-25 Thread Steve Christensen
You'd said in an earlier thread that the file path characters are coming from a 
text file and that you're then storing those in a STL string. The STL string 
doesn't care what the encoding is since it's just a storage construct. When you 
try to create a CFString or NSString from those characters, you need to know 
what the character encoding is, particularly for the case where a path contains 
special (non-ASCII) characters, otherwise the CFStringCreate*() or [NSString 
stringWith*:] calls will fail. If those fail then you won't be able to 
successfully create a CFURL/NSURL, so CFURLGetFSRef will naturally fail.

Since you haven't been able (so far) to determine what the character encoding 
is, have you thought about reading in the characters from the file, displaying 
each character in hex, and finding the value(s) that represent one of the 
non-ASCII characters? With those values in hand you should be able to do some 
online research to determine what the character encoding actually is. Once you 
get past that part, everything else should just work.

 
On Saturday, April 25, 2009, at 05:28PM, Erg Consultant 
erg_consult...@yahoo.com wrote:
I was using CFURLGetFSRef passing in the NSString which works fine as long as 
the path contains no special chars. If it does, CFURLGetFSRef returns nil.

Erg


From: Nick Zitzmann n...@chronosnet.com
To: Erg Consultant erg_consult...@yahoo.com
Cc: cocoa-dev@lists.apple.com
Sent: Saturday, April 25, 2009 4:41:20 PM
Subject: Re: Why is NSString-FSRef so hard?


On Apr 25, 2009, at 5:33 PM, Erg Consultant wrote:

 Isn't there some easy way to get an FSRef from an NSString that is a path 
 containing special characters?


What, specifically, have you tried? I don't think I've ever had 
+fileURLWithPath: fail on me with a path string, even if the string contained 
non-ASCII characters.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How remove a clip path? SOLVED

2009-05-05 Thread Steve Christensen

On May 5, 2009, at 11:57 AM, McLaughlin, Michael P. wrote:

Naturally, I came up with a solution two minutes after posting my  
query to

this list :-(

My solution is

[[NSBezierPath bezierPathWithRect:rect] setClip];

where rect is the viewRect.  This works for me.  It might not be  
the best

solution in all cases.

*** Original post ***

In a custom NSBezierView, I fill the view with a background color  
then set a
clip path that will eventually be drawn as a map.  I do this so  
that I can
color-code the map (in a complicated way) without going outside  
the lines.


If I then draw the map, external boundaries are drawn as half-width  
lines

because the clip path divides them in half lengthwise.

I cannot just double the line width because there are internal map
boundaries as well so I would like to *remove* the clip path totally.

If I write

[[NSBezierPath new] setClip];

this works perfectly except that I get an error in the Console  
window which

I would rather avoid.

Is there a recommended way to remove a clip path?

Note: Setting the clip path to a dummy path outside the view does  
not work

because then the map will not be drawn at all.


Does something like this not work?

[NSGraphicsContext saveGraphicsState];
[[NSBezierPath bezierPathWithRect:rect] setClip];
[NSGraphicsContext restoreGraphicsState];

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: drawing my image in snow leopard

2009-09-02 Thread Steve Christensen

Does this not do what you want?

[myImage drawInRect:NSIntegralRect(myCenteredRect) fromRect:...];

steve


On Sep 2, 2009, at 9:22 AM, Rick C. wrote:

thank you markus i do see that now.  since my icon centers the  
numbers will always change.  this should be obvious but what would  
be the least memory intensive way to constantly round this number...


center.x = bounds.width *.5

if center.x is a round number it works as you say.  i'm probably  
missing the obvious as usual but i'm having a bit of trouble to  
round/truncate the cgfloat...


thanks again,

rick


From: Markus Spoettl msappleli...@toolsfactory.com
To: cocoa dev cocoa-dev@lists.apple.com
Sent: Wednesday, September 2, 2009 8:17:56 PM
Subject: Re: drawing my image in snow leopard

On Sep 2, 2009, at 12:33 PM, Rick C. wrote:
i've been using NSImage drawInRect:fromRect:operation:fraction: to  
draw and center my .icns image in a resizable custom view for some  
time without issues.  now in snow leopard the same code works,  
however when the custom view is at its minimum size the image is  
slightly blurry.  when i resize the custom view to full size the  
image is fine.  seems to be maybe scaling but i'm not rescaling  
the image the size is constant.  of course the view is being  
resized.  i just checked again in leopard and this is not an  
issue.  i'm thinking i need to add something in my code to keep up  
with changes in snow leopard but i haven't yet figured out what  
that might be.  if anyone needs some code i can post it.  thank you,


The AppKit release notes state that with 10.6 the image destination  
coordinates are no longer rounded to integral values. Just round x  
and y of your destination rect and the image should appear sharp  
like before.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Macros

2009-09-02 Thread Steve Christensen
Wouldn't this be better asked on the xcode-users mailing list  
(assuming you're talking about Xcode debug/release builds)? It  
doesn't have anything to do with Cocoa.



On Sep 2, 2009, at 8:54 AM, Development wrote:

Ok I cannot find an example of how to do this online so I'nm asking  
here.
I was never any good at writing macros but I have a bool that needs  
to be yes if the current build is debug and no if it is release and  
I'm not sure how to write the macro for that. Could some one point  
me at a macro example that might show that?

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Image Thresholding

2009-09-03 Thread Steve Christensen

On Sep 2, 2009, at 10:29 PM, fawad shafi wrote:


I want to convert grayscale or RGB image to Binary Image.
Please provide sample code.


Requests to please provide sample code sounds like you want other  
people to do your work for you. There is plenty of information on how  
to do that if you just spend some time doing your own research.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: sprintf and 64-bit integers

2009-09-13 Thread Steve Christensen

On Sep 13, 2009, at 11:10 AM, slasktrattena...@gmail.com wrote:


On Sun, Sep 13, 2009 at 8:01 PM, Bill Bumgarner b...@mac.com wrote:

On Sep 13, 2009, at 10:59 AM, slasktrattena...@gmail.com wrote:
I'm updating my code for Snow Leopard and ran into this problem. The


app crashes at this line:

sprintf(str, %d, val);

where val is a CFIndex. According to the string programming guide  
here...



http://developer.apple.com/mac/library/documentation/Cocoa/ 
Conceptual/Strings/Articles/formatSpecifiers.html


...I need to cast my CFIndex to long and replace the %d format
specifier to %ld. I tried that but still got the crash. So I kept
trying with all the format specifiers in the book, declaring my
variable a NSInteger, unsigned int, etc, but no matter what the app
kept crashing. The only that that actually worked was %lx, but  
then I

get the numbers all wrong. It seems that sprintf only accepts 32-bit
integers. Is this correct? If so, what's the workaround? I'm  
compiling

for both 10.5 and 10.6. Advice appreciated, thanks.


You are off in the weeds.

There is nothing about a value conversion that could cause a  
crash.  Wrong
value? Sure.  But not a crash.  Thus, the formatting string is  
*not* causing

a crash.

The problem is almost assuredly that 'str' is pointing to garbage,
uninitialized or otherwise wrong.

Post the code for how str is created.

b.bum


Sorry, str is simply created like this:

char str[10];
sprintf(str, %d, val);


For a 64-bit unsigned integer, the maximum decimal value is  
18446744073709551615. A quick count shows that to be 20 characters  
long, not including the null-terminator. Stuffing 20 characters into  
a local buffer is likely to trash the stack frame.


steve

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Finding user's Music folder (and others)?

2009-09-17 Thread Steve Christensen

On Sep 17, 2009, at 8:18 PM, Rick Mann wrote:


On Sep 17, 2009, at 20:15:43, Michael Babin wrote:


On Sep 17, 2009, at 10:03 PM, Rick Mann wrote:

Hmm. I take it back. I can't get code calling  
NSSearchPathForDirectoriesInDomains() to compile.


  NSArray* paths = NSSearchPathForDirectoriesInDomains 
(NSMusicDirectory, NSUserDomainMask, false);


error: 'NSMusicDirectory' was not declared in this scope

What do I need to do to get NSMusicDirectory?


Are you building with the 10.6 SDK? NSMusicDirectory is available  
in 10.6 and later, according to the docs and the header file  
(NSPathUtilities.h).


Well, I thought I had, but I tried again just to be sure. That's  
the trick. I just overlooked the line that said 10.6. Thanks!


And if you want to get that path for earlier OS versions, you could  
use FSFindFolder:



NSString* musicFolderPath = nil;
FSRef musicFolderRef;

if (FSFindFolder(kUserDomain, kMusicDocumentsFolderType,  
kCreateFolder, musicFolderRef) == noErr)

{
NSURL* musicFolderURL = [(NSURL*)CFURLCreateFromFSRef(NULL,  
musicFolderRef) autorelease];


musicFolderPath = [musicFolderURL path];
}

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Problem with fontDescriptorWithFontAttributes:

2009-09-21 Thread Steve Christensen

On Sep 21, 2009, at 2:29 PM, Laurent Daudelin wrote:


On Sep 21, 2009, at 14:23, Kyle Sluder wrote:

Fonts really don't have colors.  I don't know why  
NSFontColorAttribute

is defined in NSFontDescriptor.h, but none of the other attributed
string attributes are in there.

Why are you trying to attach a color to a font?

--Kyle Sluder


Simple: I want to set the font as a gray to show that the text  
field cell is disabled, e.g. cannot be selected.


Yes, but a font describes essentially the shape of all the glyphs.  
When it comes time to draw it, -then- you apply characteristics like  
color, but to the string you're trying to draw, not to the font.


steve

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How to create a control just as RGB Sphere and Alpha bar

2009-09-25 Thread Steve Christensen
Is there some reason why you can't use the color picker to specify a  
color+alpha value? It would save you a bunch of work in duplicating  
existing system functionality.



On Sep 24, 2009, at 11:20 PM, Symadept wrote:


Hi Graham,
Yes. But do you have any other ways to handle this.

I want something like this


I could be able to pick the color from the spectrum band and could  
change
the Alpha (This I can manage to some extent, Immediately I need to  
handle

the picking colour from the spectrum.)

Regards
Mustafa

On Fri, Sep 25, 2009 at 1:41 PM, Graham Cox  
graham@bigpond.com wrote:




On 25/09/2009, at 1:14 PM, Symadept wrote:

 Can any help me how to create a view which contains Spectrum Bar  
(Just as

RGB Sphere in NSColorPanel) and an Alpha bar?



NSImageView?

--Graham


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] Application running for the very first time...

2009-10-07 Thread Steve Christensen

On Oct 1, 2009, at 10:57 PM, James Lin wrote:


Thank you for the code snipet, but I am confused at the logic here...

the following code will be executed EVERY time the program runs,  
right?


	NSMutableDictionary *dictionary = [[NSMutableDictionary alloc]  
initWithCapacity:10];
	[dictionary setObject: [NSNumber numberWithBool:YES]  
forKey:@PIFirstRun];

[[NSUserDefaults standardUserDefaults] registerDefaults:dictionary];
[dictionary release];

so [dictionary setObject: [NSNumber numberWithBool:YES]  
forKey:@PIFirstRun] will run EVERYTIME the program runs?
Wouldn't that set my PIFirstRun to YES every time the user launch  
my application?


The user defaults are just that: default values. They provide the  
values that are returned for a key by NSUserDefaults until the value  
for that key is modified by your application. So, yes, the code above  
will be run every time but it doesn't affect any modified keys. As  
soon as a key's value is modified, that new value is added to the  
application's preference file and will be used from that point  
forward. If the preferences file is ever deleted, your application  
will go back to using the default values until they are modified.


So you could think of the behavior of [[NSUserDefaults  
standardUserDefaults] boolForKey:@PIFirstRun] as:


if (PIFirstRun key exists in my app's preferences)
return value of key from app's preferences;
else
return value of key from defaults dictionary;


In that case

if ([[NSUserDefaults standardUserDefaults]  
boolForKey:@PIFirstRun] == YES){
		[[NSUserDefaults standardUserDefaults] setBool:NO  
forKey:@PIFirstRun];

//first run

[userDefaults setInteger:5 forKey:@myIngeter];
}

will reset my myInteger to 5 EVERY single time?


Yes, because you're modifying the value of that key every time.

What if all i want is to set myInteger to 5 the very first time  
my application lunches and ONCE ONLY?


Add it to the defaults dictionary:

NSDictionary* defaults = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], @PIFirstRun,
[NSNumber numberWithInt:5],@myInteger,
nil];

[[NSUserDefaults standardUserDefaults] defaults];

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: [iPhone] Application running for the very first time...

2009-10-07 Thread Steve Christensen


On Oct 7, 2009, at 10:47 AM, Marco S Hyman wrote:


On Oct 7, 2009, at 10:33 AM, Steve Christensen wrote:


In that case

if ([[NSUserDefaults standardUserDefaults]  
boolForKey:@PIFirstRun] == YES){
		[[NSUserDefaults standardUserDefaults] setBool:NO  
forKey:@PIFirstRun];

//first run

[userDefaults setInteger:5 forKey:@myIngeter];
}

will reset my myInteger to 5 EVERY single time?


Yes, because you're modifying the value of that key every time.


No.  Read the code snip again.  setInteger will only be set
when PIFirstRun is YES.  When YES PIFirstRun is set to NO so
future runs will skip setting myInteger.  Unless, as you noted
in comments I snipped, the preferences file is deleted or other
code sets PIFirstRun back to YES.


My mistake.

What if all i want is to set myInteger to 5 the very first  
time my application lunches and ONCE ONLY?


Add it to the defaults dictionary:

NSDictionary* defaults = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], @PIFirstRun,
[NSNumber numberWithInt:5],@myInteger,
nil];

[[NSUserDefaults standardUserDefaults] defaults];


That may also do the trick.   I say MAY because it is possible that
the act of setting the code might cause some side effect that won't
occur if the defaults are initialized to the value.


I suppose if something was bound to that key then some other behavior  
could be triggered. If the idea was that the value really should be  
initialized once then putting it in the defaults would be best,  
unless you wanted to know if the value had been set to some value vs.  
being undefined.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Are these Apple or 3rd party classes?

2009-10-09 Thread Steve Christensen
A quick Google search came up with a reference to EPIJDataManager  
that somehow relates to Epson printers. I couldn't find any other  
info than that.



On Oct 9, 2009, at 6:48 AM, Philip White wrote:

A customer of one of my shareware programs has reported that my  
program frequently crashes when he tries to print. No one else has  
reported this kind of error. The stack trace he sends me includes  
the following lines: (this is just some of them)


20  EPIJDataManager_Core_L  0x0d201bca  
_Z28SendMessageToDataManagerCoremPvS_ + 254
21  EPIJDataManager_Core_L  0x0d20272c  
SendMessageToCoreDataManager + 710
22  EPIJDataManager 0x0cf75b12  
SendMessageToDataManager + 142
23  PDECPlugin010x0c8fe6c0 - 
[CERPEPIJDataManager(EPIJDataManagerMessageMethod) pDEInitialize] +  
566
24  PDECPlugin010x0c8fe3b7 - 
[CERPEPIJDataManager(EventHandlerMethod) onInitialize:] + 577


I don't really know a lot about the inner workings of the print  
system, but would anyone be able to tell me if this looks like it  
is third party stuff (printer drivers?) or Apple stuff?


He is running 10.6.1


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Opening a NSSavePanel as a Sheet, and blocking like in [panel runModal]

2009-10-15 Thread Steve Christensen
I had written this NSOpenPanel category to work in a plugin  
environment, and I think it should do the right thing. Just set up  
the NSOpenPanel as you like then call - 
runModalForDirectory:file:types:relativeToWindow: and it will return  
when the user has selected (or not) a file.


steve


// category on NSOpenPanel that runs the open sheet modally and  
returns when done

@interface NSOpenPanel(ModalSheets)

- (NSInteger)runModalForDirectory:(NSString*)path file:(NSString*) 
name types:(NSArray*)fileTypes

relativeToWindow:(NSWindow*)window;

@end

@implementation NSOpenPanel(ModalSheets)

- (void)__modalOpenPanelDidEnd:(NSOpenPanel*)panel returnCode:(int) 
returnCode contextInfo:(void*)contextInfo

{
#pragma unused(panel, contextInfo)

[NSApp stopModalWithCode:returnCode];
}

- (NSInteger)runModalForDirectory:(NSString*)path file:(NSString*) 
name types:(NSArray*)fileTypes


relativeToWindow:(NSWindow*)window
{
NSInteger   result;

if (window != nil)
{
		[self beginSheetForDirectory:path file:name modalForWindow:window  
modalDelegate:self
didEndSelector:@selector 
(__modalOpenPanelDidEnd:returnCode:contextInfo:) contextInfo:nil];


result = [NSApp runModalForWindow:self];

[NSApp endSheet:self];
}
else
{
result = [self runModalForDirectory:path file:name 
types:fileTypes];
}

return result;
}

@end




On Oct 14, 2009, at 6:02 AM, Motti Shneor wrote:

I'm in a strange situation, where I am implementing a plugin  
component that runs within a host application which I don't have  
access to.


Within this context, The host sometimes calls my plug-in to open an  
NSSavePanel (or NSOpenPanel). The host expects that I'm synchronous  
--- i.e. I only return when the NSSavePanel is dismissed, and  
there's a result.


However, The host also provides me with its own Window, and I need  
to open my NSSavePanel as a Sheet-window over the host's window.


Now NSSavePanel (and NSOpenPanel) provide 2 different ways to run them

1. runModal (or a vaiant) that is synchronous --- but it does not  
create a sheet window
2 beginSheetFor... (or variants) that are asynchronous (I must  
supply with a callback selector to be called as the NSSavePanel is  
dismissed) --- these DO create a sheet over the parent window.


Is there a decent way to combine these two requirements?


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Opening a NSSavePanel as a Sheet, and blocking like in [panel runModal]

2009-10-21 Thread Steve Christensen
 NavTester[4398]  
Error: kCGErrorIllegalArgument: CGSOrderWindowList: NULL list  
pointer or empty list


Any ideas? something I forgot to do? What in general is the state  
of opening cocoa-sheets over Carbon-windows? When do I need to  
release this NSWindow? I don't wish to close the Carbon window, as  
it is coming from my host application!


You may not want to call FrontWindow() since its docs say, Most  
applications should use call ActiveNonFloatingWindow or  
FrontNonFloatingWindow instead of FrontWindow because  
ActiveNonFloatingWindow and FrontNonFloatingWindow return the active  
and frontmost document window, respectively, skipping over other  
types of windows that may be in front of the active document, such as  
the menubar window, floating windows, help tags and toolbars.




On 15/10/2009, at 21:40, Steve Christensen wrote:

I had written this NSOpenPanel category to work in a plugin
environment, and I think it should do the right thing. Just set up
the NSOpenPanel as you like then call -
runModalForDirectory:file:types:relativeToWindow: and it will return
when the user has selected (or not) a file.

steve


// category on NSOpenPanel that runs the open sheet modally and  
returns when done

@interface NSOpenPanel(ModalSheets)

- (NSInteger)runModalForDirectory:(NSString*)path file:(NSString*)
name types:(NSArray*)fileTypes 
relativeToWindow:(NSWindow*)window;

@end

@implementation NSOpenPanel(ModalSheets)

- (void)__modalOpenPanelDidEnd:(NSOpenPanel*)panel returnCode:(int)
returnCode contextInfo:(void*)contextInfo
{
#pragma unused(panel, contextInfo)

[NSApp stopModalWithCode:returnCode];
}

- (NSInteger)runModalForDirectory:(NSString*)path file:(NSString*)
name types:(NSArray*)fileTypes relativeToWindow:(NSWindow*)window
{
NSInteger result;

if (window != nil)
{
[self beginSheetForDirectory:path file:name 
modalForWindow:window
modalDelegate:self didEndSelector:@selector
(__modalOpenPanelDidEnd:returnCode:contextInfo:) 
contextInfo:nil];

result = [NSApp runModalForWindow:self];

[NSApp endSheet:self];
}
else
{
result = [self runModalForDirectory:path file:name 
types:fileTypes];
}

return result;
}

@end


On Oct 14, 2009, at 6:02 AM, Motti Shneor wrote:

I'm in a strange situation, where I am implementing a plugin
component that runs within a host application which I don't have
access to.

Within this context, The host sometimes calls my plug-in to open an
NSSavePanel (or NSOpenPanel). The host expects that I'm synchronous
--- i.e. I only return when the NSSavePanel is dismissed, and
there's a result.

However, The host also provides me with its own Window, and I need
to open my NSSavePanel as a Sheet-window over the host's window.

Now NSSavePanel (and NSOpenPanel) provide 2 different ways to run them

1. runModal (or a vaiant) that is synchronous --- but it does not
create a sheet window
2 beginSheetFor... (or variants) that are asynchronous (I must
supply with a callback selector to be called as the NSSavePanel is
dismissed) --- these DO create a sheet over the parent window.

Is there a decent way to combine these two requirements?


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Opening a NSSavePanel as a Sheet, and blocking like in [panel runModal]

2009-10-22 Thread Steve Christensen
I don't know what the difference would be in trying to attach to a  
native NSWindow vs one that wraps a Carbon window. When I've done  
this in the past, I always knew that I was attaching to a native  
NSWindow. Sorry I can't be more helpful.


steve


On Oct 22, 2009, at 6:44 AM, Motti Shneor wrote:


Thanks again.

Regarding the Carbon Window problem, the FrontWindow() call was  
just an illustration. The WindowRef I'm supplying is of a visible  
(usually active and front) Document window. The problems are not  
even consistent, and will randomly occur. The desired behavior,  
though, will very rarely occur. (I'd say one in a hundred times).


In short --- Are there any specific implications to opening a cocoa  
sheet over a carbon (document) window? Is there any specific setup  
I need to know about? What are the limitations of Cocoa NSWindow  
wrappers around Carbon windows?


The problem is, my Plugin is written using cocoa, but runs within a  
Carbon application. I need to attach my NSOpen/NSSave panels onto a  
given application window, which is, of course, a Carbon window. I  
get this bogus behavior and even worse, both running with my Host  
application, and with simplistic test programs like the one below.


Any hints?
Last (and most important) - Supposedly I use your nice category  
like this:


WindowRef frontWin = ::FrontWindow();  // get Carbon application
front window. Actually, any carbon window.
NSWindow *cocoaFromCarbonWin = [[NSWindow alloc]  
initWithWindowRef:frontWin];

NSSavePanel *navPanel = [NSSavePanel savePanel];
[navPanel runModalForDirectory:nil file:nil types:nil  
relativeToWindow: cocoaFromCarbonWin];


Then I'm seeing a host of strange and bogus behaviors.

1. The most severe is that the sheet opens BEHIND the application
window, BUT is still the key window. So, the application is dead
--- I can't click on the sheet (it's not front, and not active,
does not respond to clicks). However, the main application window
is blocked for events too! (I have blocked it via
runModalForWindow!). so, I'm dead. User must force-quit the
application.

2. The sheet opens in the wrong place -- just somewhere on the
screen - not always the same place, but favorably when a centered
dialog would appear. If then I try to drag the parent carbon window
by its title, the sheet would jump into place and be dragged
right. Events seem to be OK.

3. The sheet is invisible --- Although I get no errors from the
application. However, the debugger console would (sometimes!)
contain lines like this:

[Session started at 2009-10-21 11:01:52 +0200.]
GNU gdb 6.3.50-20050815 (Apple version gdb-1346) (Fri Sep 18   
20:40:51 UTC 2009)
Wed Oct 21 12:11:53 Moti-Schneors-Mac-Pro.local NavTester[4398]   
Error: kCGErrorIllegalArgument: _CGSFindSharedWindow: WID 1835
Wed Oct 21 12:11:53 Moti-Schneors-Mac-Pro.local NavTester[4398]   
Error: kCGErrorFailure: Set a breakpoint @ CGErrorBreakpoint()  
to catch errors as they are logged.
Wed Oct 21 12:11:53 Moti-Schneors-Mac-Pro.local NavTester[4398]   
Error: kCGErrorIllegalArgument: CGSOrderWindowListWithGroups:  
invalid window ID (1835)
Wed Oct 21 12:11:53 Moti-Schneors-Mac-Pro.local NavTester[4398]   
Error: kCGErrorIllegalArgument: CGSOrderWindowList: NULL list  
pointer or empty list
Wed Oct 21 12:11:53 Moti-Schneors-Mac-Pro.local NavTester[4398]   
Error: kCGErrorIllegalArgument: _CGSFindSharedWindow: WID 1836
Wed Oct 21 12:11:53 Moti-Schneors-Mac-Pro.local NavTester[4398]   
Error: kCGErrorIllegalArgument: CGSOrderWindowListWithGroups:  
invalid window ID (1836)
Wed Oct 21 12:11:53 Moti-Schneors-Mac-Pro.local NavTester[4398]   
Error: kCGErrorIllegalArgument: CGSOrderWindowList: NULL list  
pointer or empty list


Any ideas? something I forgot to do? What in general is the state
of opening cocoa-sheets over Carbon-windows? When do I need to
release this NSWindow? I don't wish to close the Carbon window, as
it is coming from my host application!


You may not want to call FrontWindow() since its docs say, Most
applications should use call ActiveNonFloatingWindow or
FrontNonFloatingWindow instead of FrontWindow because
ActiveNonFloatingWindow and FrontNonFloatingWindow return the active
and frontmost document window, respectively, skipping over other
types of windows that may be in front of the active document, such as
the menubar window, floating windows, help tags and toolbars.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How to imitiate mouse move programmatically? [NSApp postEvent:atStart:] does not work...

2009-11-03 Thread Steve Christensen
Oleg, had you thought of doing something like adding -isSelectionValid  
and -setSelectionValid: methods to your controller class? The view  
would always keep track of the mouse state, tell the controller what  
the current selection is when the mouse moves, but won't update itself  
or respond to mouse clicks while the lengthy operation is in progress.  
No fake events since the view has been tracking the real mouse all  
along. Just call -setNeedsDisplay: inside -setSelectionValid: to  
automagically get the view to redraw itself to reflect the current  
mouse state.


steve


On Nov 3, 2009, at 5:46 AM, Oleg Krupnov wrote:


Graham, I really appreciate you taking your time to write such
detailed posts for me, but what I am trying to say is that I am doing
everything exactly as you suggest, following the best design patterns
(I think). There is a controller and it maintains the selection. The
view only draws the selection in its drawRect, and during drawRect it
queries the selection from the controller. The view can also cause the
selection to change in response to mouse input. That's when the view
performs hit testing of its items, in its mouseMoved handler. Then the
view asks the controller to change the current selection. Then the
controller calls back the view telling that selection has changed, and
the view calls setNeedsDisplay on itself.

The way the items are displayed, and therefore also how they are
hit-tested, is encapsulated inside the view. In other words, the
controller and the model don't have to know how the items appear and
how to hit test them in each kind of view. The view is responsible to
process the mouse events.

This all is pretty standard MVC pattern, I believe. No problem with  
that.


The need to refresh the view after animation is rather a tiny
exception from the otherwise solid implementation. And I am
considering the fake mouse event because it seems the most natural and
straightforward way of changing the state of the system in this case.
Think of it this way: while the animation is in progress, the user may
be moving the mouse around, but all those events were ignored, and
what matters is only the last position of the mouse at the moment when
the animation ends. So in a sense, the fake mouse move event is not so
much fake, but a single consolidated mouse event of all those events.
The way my system should respond to this event is exactly the same as
to an ordinary, non-fake mouse event.

If I don't generate that fake event and use some explicit methods, I
would have to do the following:

1. in controller, determine which view the mouse currently is over
(hit test the window)
2. localize the coordinate to that view and ask the view to hit test
its items for the coordinate
3. set the controller's selection to that item

This all, and exactly this, would happen all by itself, by the already
existing code, in case if I sent the fake mouse moved event.



On Tue, Nov 3, 2009 at 3:09 PM, Graham Cox graham@bigpond.com  
wrote:


On 03/11/2009, at 11:15 PM, Oleg Krupnov wrote:

Maybe I'm not speaking clearly, but that's exactly what I'm trying  
to
do -- use a mouse event to cause a state change, but in this case  
the

mouse event would be fake. Mouse position is in no way part of the
view's state. I just want that at particular moment the view's state
becomes synchronized with the current mouse position, as if the  
mouse

did move.


But why? State is an independent variable. It is coupled to the mouse
location in your case, but it's independent nevertheless. If you  
like, state
is the part of the view's output (because it causes the visual  
appearance to
change) whereas events are always input. Don't conflate them -  
views are
designed to keep the input (events) and outputs (drawing) handled  
in two

completely independent phases.

There are multiple items in the view, and the hovered one of the  
items
should be highlighted. When the mouse event arrives, the view  
performs
hit testing of its items and determines which of the items is  
hovered.

If I make a setState method as you suggest, I would have to specify
which item to highlight. This would break the view's encapsulation,
because I would have to perform item hit testing externally.


I don't really follow this. At some point any hit testing does have  
to be
done externally, if you have multiple objects, either by you or by  
AppKit.

Doing it yourself is easy, and I strongly recommend that approach as
follows:

1. main view gets the localised mouse location.
2. it iterates over all of its sub-objects representing the items  
and asks
each one to test itself against the mouse position which is passed  
to it.
3. The first item that returns yes is sent the appropriate - 
setState: to

highlight it (and the main view also keeps track of this one as the
selected item).
4. the -setState: method invalidates the drawing area covered by  
the object.

5. drawing deals with the appearance change.

This is the 

Re: Bulletproof way to create a new CGBitmapContext from an existing image?

2009-11-03 Thread Steve Christensen
Why not alway create a CGBitmapContext of the desired size and in a  
supported pixel format (see http://developer.apple.com/mac/library/qa/qa2001/qa1037.html 
), then call CGContextDrawImage to draw the CGImage into the  
context? Then you're always controlling the parameters.


CGRect bounds = CGRectMake(0, 0, scaleFactorX * image.size.width,  
scaleFactorY * image.size.height);

context = CGBitmapContextCreate(NULL,
bounds.size.width,
bounds.size.height,
8,
4 * bounds.size.width,
CGColorSpaceCreateDeviceRGB(),  
kCGImageAlphaPremultipliedFirst);
CGContextDrawImage(context, bounds, image.CGImage);


On Nov 1, 2009, at 8:45 AM, thatsanicehatyouh...@mac.com wrote:

I have some code where I'm downloading images from the internet.  
They're probably all going to be jpegs, but I'm not making that  
assumption in my code. I have no control over the images. I'm  
creating a CGBitmapContext to manipulate them. Further, I'm scaling  
the image (could be up or down depending on the original size) by  
creating the context with the size I want and drawing the original  
image into that.


I'm trying to write code to avoid messages such as this:

Error: CGBitmapContextCreate: unsupported parameter combination: 8  
integer bits/component; 16 bits/pixel; 1-component colorspace;  
kCGImageAlphaPremultipliedFirst; 352 bytes/row.


I only rarely get these now, but I want to make that never. I'm  
pasting my code below that I have so far - can anyone suggest  
something better? (I'm working on an iPhone if it makes any  
difference.)


Cheers,
Demitri

size_t bitsPerComponent = CGImageGetBitsPerComponent(image.CGImage);
CGColorSpaceRef colorSpace = CGImageGetColorSpace(image.CGImage);

// The value returned by CGImageGetBytesPerRow might be smaller than  
the final

// image if we are scaling to a larger size.
float contextWidth = (float)ceil((double)scaleX*image.size.width) *  
4.0;
int bytesPerRow = (CGImageGetBytesPerRow(image.CGImage)   
contextWidth) ? CGImageGetBytesPerRow(image.CGImage)


: contextWidth;

context = CGBitmapContextCreate(NULL, // let the OS manage the  
memory for me

// image 
dimensions (desired width, desired height)

scaleFactorX*image.size.width, scaleFactorY*image.size.height,

bitsPerComponent,
bytesPerRow,
colorSpace,

kCGImageAlphaPremultipliedFirst);


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How can a plug-in bundle get access to its own resources?

2009-11-15 Thread Steve Christensen
As has been pointed out several times, it's a really bad idea to have  
the same-named class in multiple plugins. The Objective-C runtime will  
load the first class instance it finds (in your case, in the first- 
loaded plugin). For all other plugins, when the class is referenced,  
that first class instance is used, so calling [NSBundle bundleForClass: 
[self class]] will cause it to return the bundle for that first  
plugin, no matter which plugin is asking. This answers your question  
about code knowing its containing bundle. You made an assumption about  
where the plug-in's code was loaded that turned out to be incorrect.


If you want to use the same class code for each plug-in, I would  
suggest that you use a #define to rename the plug-in class at build  
time, and add a per-target definition containing a unique class name.  
Then your common class would be renamed automatically for each target.  
If you have to specify the plugin class in, say, your Info.plist, you  
could use the same build definition.


@interface PLUGIN_CLASS_NAME
...
@end


@implementation PLUGIN_CLASS_NAME
...
@end

The benefit of going with this model is that you still maintain a  
single code base for all of your plugins, even though the class is  
renamed on a per-plugin basis; you eliminate the which plugin am I  
problem you're running into now; and you don't have to worry about  
having an older plugin version that happens to load before a newer  
version, thus forcing all the newer plug-ins to use the older plug-in  
code.



On Nov 15, 2009, at 3:36 AM, Motti Shneor wrote:


Thanks, but the bundleWithIdentifier has its own problems.

1. The identifier is (as far as i know) accessible only from the  
bundle itself, which I don't have! I'm circling around here, without  
access to my own resources!  Must I hard-code the bundle identifier  
as a string constant within each of my plug-ins?


2. Even if I DO follow this rule, how can I manage to distinguish  
between two bundles that include the same plug-in but from different  
versions?


They have the same class, and the same identifier


Really, Isn't there a way for a library (dll, dylib framework etc)  
to know what is its containing bundle?



On 10/11/2009, at 19:42, Douglas Davidson wrote:


On Nov 10, 2009, at 4:59 AM, Motti Shneor wrote:


Thanks guys, but you may have not read all my message ---

The [NSBundle bundleForClass:[self class]];

is unusable for me, because I have many plugins that build from the
same code, and export the same class (of course --- the same class
name).

Obj-C has no name-spaces, and so, If you load 2 such plugins, and
use the [NSBundle bundleForClass:[self class]] in each of them
independently --- you'll get erroneous answers! both of them will
return the same bundle although they come from different bundles.

This is hardly a system bug because there are no namespaces, and
for the same class name there is only one bundle.


As others have said, don't do this.  However, to answer your  
question,

the other way to locate your bundle is via bundleWithIdentifier:.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How can a plug-in bundle get access to its own resources?

2009-11-16 Thread Steve Christensen
/2009, at 00:51, Steve Christensen wrote:


As has been pointed out several times, it's a really bad idea to have
the same-named class in multiple plugins. The Objective-C runtime  
will

load the first class instance it finds (in your case, in the first-
loaded plugin). For all other plugins, when the class is referenced,
that first class instance is used, so calling [NSBundle  
bundleForClass:

[self class]] will cause it to return the bundle for that first
plugin, no matter which plugin is asking. This answers your question
about code knowing its containing bundle. You made an assumption  
about

where the plug-in's code was loaded that turned out to be incorrect.

If you want to use the same class code for each plug-in, I would
suggest that you use a #define to rename the plug-in class at build
time, and add a per-target definition containing a unique class name.
Then your common class would be renamed automatically for each  
target.

If you have to specify the plugin class in, say, your Info.plist, you
could use the same build definition.

@interface PLUGIN_CLASS_NAME
...
@end


@implementation PLUGIN_CLASS_NAME
...
@end

The benefit of going with this model is that you still maintain a
single code base for all of your plugins, even though the class is
renamed on a per-plugin basis; you eliminate the which plugin am I
problem you're running into now; and you don't have to worry about
having an older plugin version that happens to load before a newer
version, thus forcing all the newer plug-ins to use the older plug-in
code.


On Nov 15, 2009, at 3:36 AM, Motti Shneor wrote:


Thanks, but the bundleWithIdentifier has its own problems.

1. The identifier is (as far as i know) accessible only from the
bundle itself, which I don't have! I'm circling around here, without
access to my own resources!  Must I hard-code the bundle identifier
as a string constant within each of my plug-ins?

2. Even if I DO follow this rule, how can I manage to distinguish
between two bundles that include the same plug-in but from different
versions?

They have the same class, and the same identifier

Really, Isn't there a way for a library (dll, dylib framework etc)
to know what is its containing bundle?


On 10/11/2009, at 19:42, Douglas Davidson wrote:


On Nov 10, 2009, at 4:59 AM, Motti Shneor wrote:


Thanks guys, but you may have not read all my message ---

The [NSBundle bundleForClass:[self class]];

is unusable for me, because I have many plugins that build from  
the

same code, and export the same class (of course --- the same class
name).

Obj-C has no name-spaces, and so, If you load 2 such plugins, and
use the [NSBundle bundleForClass:[self class]] in each of them
independently --- you'll get erroneous answers! both of them will
return the same bundle although they come from different bundles.

This is hardly a system bug because there are no namespaces, and
for the same class name there is only one bundle.


As others have said, don't do this.  However, to answer your
question,
the other way to locate your bundle is via bundleWithIdentifier:.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Drawing an arc fill inside an image

2011-05-26 Thread Steve Christensen
Custom view that sits on top of a UIImageView? Implement -drawRect: and a 
progress property and you're done.


On May 26, 2011, at 11:21 AM, Alex Kac wrote:

 I'm not sure what the best way to tackle this is... so I thought I'd ask 
 here. I have an image with a circular button inside of it. I'd like to 
 dynamically fill this button in an arc to show progress much like how when 
 you are on iTunes Store on an iOS and its playing the preview its animating 
 filling the circle in a sweep of an arc. Mine doesn't need to animate however.
 
 So I have the image, and I suppose I can draw that image to a context and 
 then draw an arc on that image, and then make another image out of it. That 
 seems like it would get slow if I needed to do that a lot. Any suggestions? I 
 also wouldn't mind any links that might show similar code. This is for iOS. I 
 tried searching Google, but my GoogleFu is not showing anything, probably due 
 to me not using the right terms.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Application Design

2011-05-27 Thread Steve Christensen
A view controller controls a specific view hierarchy so it shouldn't be 
reaching explicitly out to other view controllers to tell them to do something.

Depending on your specific situation, interested objects could register for 
notifications when certain things change in the world, then one object could 
just broadcast that something changed and not worry about what other objects 
care. Or you could synch a controller's state (and possibly its view(s)) in its 
-viewWillAppear: method since in many cases only a single controller's view 
hierarchy is visible at any one time.


On May 27, 2011, at 11:13 AM, Dan Hopwood wrote:

 I have been writing iPhone applications for a while now, with not too many
 problems but I feel like I haven't fully grasped how an application should
 be structured in terms of storing application objects. e.g. up to now, I've
 created a header file, declared all the main objects e.g. app delegate, view
 controllers, utilities and initialised them in the app delegate. For each
 class, I then just include the header file, which gives me access to all the
 objects, should I need to send them messages on certain UI events.
 
 Another option I have considered is storing them all in the app delegate
 instead and creating utility methods in the app delegate that delegate out
 to the objects from one place. E.g. a VC would then call the app delegate
 each time it needs to interact with another VC.
 
 If neither of these options is valid, which I suspect is the case (certainly
 global pointers is considered to be bad practise), then how do you store
 these pointers to that they are accessible in some way by all the VCs.
 Sending in the required pointers on initialisation of each VC (and storing a
 copy in each class) is the only other option I can think of but this seems
 annoyingly unelegant.
 
 Thoughts and suggestions much appreciated.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Application Design

2011-05-31 Thread Steve Christensen
How about providing a singleton class method? Then you just include 
WebServiceInterface.h where needed. No need to have a global variable.

@implementation WebServiceInterface

...

+ (WebServiceInterface*) sharedInterface
{
static WebServiceInterface* sharedInstance = nil;

if (sharedInstance == nil)
sharedInstance = [[WebServiceInterface alloc] init];

return sharedInstance;
}

...

@end


foo = [[WebServiceInterface sharedInterface] someMethod];


On May 31, 2011, at 3:25 AM, Dan Hopwood wrote:

 Thanks for all your answers, they make complete sense.
 
 I have one more related question. I have developed a custom, stateful 
 WebServiceInterface object, which manages all connection requests made to an 
 XML-RPC server. Being stateful, I initialise this object when the app 
 launches and at the moment I store a pointer to it in a header file, which I 
 include in all view controllers. This allows me to make a request for data 
 from anywhere. In a similar way, I feel that storing a global pointer is not 
 best practise and can't help but think there is a more elegant way of doing 
 this. One option I have considered if storing/initialising the object in the 
 app delegate and then creating a utility method in the delegate that wraps 
 the object call. Is this the best solution or is there a design pattern I am 
 unaware of?
 
 Many thanks!
 
 
 On 28 May 2011 19:15, Conrad Shultz con...@synthetiqsolutions.com wrote:
 On May 28, 2011, at 6:11, Dan Hopwood d...@biasdevelopment.com wrote:
 
  Thanks for your response Steve. I have considered using the
  nsnotification service but what if you need to not only let another
  object know when an event has occurred but you also need to send that
  object some data? For example a user selects an option in a table -
  the selection must be conveyed in some way to the vc I'm pushing on
  the nav controller stack so that it's view is dynamic depending on the
  selection. As far as I'm aware that is not possible using
  notifications.
 
 That's very doable with notifications.  See the object and userInfo 
 methods in NSNotification and corresponding methods in NSNotificationCenter.
 
  In general I create a new vc/nib for *every* screen I have in the app.
  Let's take a navigation app as an example. Are you saying that the
  hierarchy should be:
 
  - 'root view controller' (has overall control, contains navigation
  logic and sends data between the containing view controllers)
  -- 'nav controller'
  -- 'all view controllers to be pushed/popped'
 
  ...where the nav controller and its view controllers are stored and
  initialised inside the 'root view controller'?
 
 Well, I'd say the view controllers aren't stored inside the root view 
 controller; they are pushed onto the navigation stack as and when needed. 
 Unless you are doing some caching, I wouldn't store the view controllers 
 outside the navigation stack. (If you do implement caching, make sure you 
 respond to memory warnings by flushing the cache!)
 
 In a navigation based application I feel that your architecture is simplified 
 by design.  Since only one view controller (notwithstanding modal view 
 controllers) is on screen at any time, and they are all arranged 
 hierarchically, parents should configure their children before pushing them 
 onto the stack. When children need to communicate back to their parents (for 
 example, if you push an editor view controller from a summary view 
 controller, which needs to be updated when the editor view controller makes 
 changes), you can use KVO or notifications, but if the communication is by 
 design of interest only to the parent and child view controllers, just make 
 the parent the delegate of the child. So if the child, say, had a list of 
 favorite URLs for the user to select, it could call something like [delegate 
 didSelectFavorite:url] which would cause the parent to be updated (and change 
 appearance when the child is popped off the stack).

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Application Design

2011-06-01 Thread Steve Christensen
Why do you need to do any explicit cleanup on app termination? App memory 
disappears (poof!) so it's not like you're leaking anything. Is your class 
holding onto some state that must be written out to disk, for example?


On Jun 1, 2011, at 3:54 AM, Dan Hopwood wrote:

 Thanks Steve. For completeness - what's the proper way to perform the 
 cleanup? Should another static method be created that releases the singleton 
 instance when the app is closed? i.e.
 
 + (void)releaseSharedInterface
 {
 [sharedInstance release];
 sharedInsance = nil;
 }
 
 D
 
 
 On 1 June 2011 09:54, Dan Hopwood d...@biasdevelopment.com wrote:
 Great, thanks a lot Steve - very helpful.
 
 D
 
 
 
 On 31 May 2011 18:44, Steve Christensen puns...@mac.com wrote:
 How about providing a singleton class method? Then you just include 
 WebServiceInterface.h where needed. No need to have a global variable.
 
 @implementation WebServiceInterface
 
 ...
 
 + (WebServiceInterface*) sharedInterface
 {
   static WebServiceInterface* sharedInstance = nil;
 
   if (sharedInstance == nil)
   sharedInstance = [[WebServiceInterface alloc] init];
 
   return sharedInstance;
 }
 
 ...
 
 @end
 
 
 foo = [[WebServiceInterface sharedInterface] someMethod];
 
 
 On May 31, 2011, at 3:25 AM, Dan Hopwood wrote:
 
 Thanks for all your answers, they make complete sense.
 
 I have one more related question. I have developed a custom, stateful 
 WebServiceInterface object, which manages all connection requests made to an 
 XML-RPC server. Being stateful, I initialise this object when the app 
 launches and at the moment I store a pointer to it in a header file, which I 
 include in all view controllers. This allows me to make a request for data 
 from anywhere. In a similar way, I feel that storing a global pointer is not 
 best practise and can't help but think there is a more elegant way of doing 
 this. One option I have considered if storing/initialising the object in the 
 app delegate and then creating a utility method in the delegate that wraps 
 the object call. Is this the best solution or is there a design pattern I am 
 unaware of?
 
 Many thanks!
 
 
 On 28 May 2011 19:15, Conrad Shultz con...@synthetiqsolutions.com wrote:
 On May 28, 2011, at 6:11, Dan Hopwood d...@biasdevelopment.com wrote:
 
  Thanks for your response Steve. I have considered using the
  nsnotification service but what if you need to not only let another
  object know when an event has occurred but you also need to send that
  object some data? For example a user selects an option in a table -
  the selection must be conveyed in some way to the vc I'm pushing on
  the nav controller stack so that it's view is dynamic depending on the
  selection. As far as I'm aware that is not possible using
  notifications.
 
 That's very doable with notifications.  See the object and userInfo 
 methods in NSNotification and corresponding methods in NSNotificationCenter.
 
  In general I create a new vc/nib for *every* screen I have in the app.
  Let's take a navigation app as an example. Are you saying that the
  hierarchy should be:
 
  - 'root view controller' (has overall control, contains navigation
  logic and sends data between the containing view controllers)
  -- 'nav controller'
  -- 'all view controllers to be pushed/popped'
 
  ...where the nav controller and its view controllers are stored and
  initialised inside the 'root view controller'?
 
 Well, I'd say the view controllers aren't stored inside the root view 
 controller; they are pushed onto the navigation stack as and when needed. 
 Unless you are doing some caching, I wouldn't store the view controllers 
 outside the navigation stack. (If you do implement caching, make sure you 
 respond to memory warnings by flushing the cache!)
 
 In a navigation based application I feel that your architecture is 
 simplified by design.  Since only one view controller (notwithstanding modal 
 view controllers) is on screen at any time, and they are all arranged 
 hierarchically, parents should configure their children before pushing them 
 onto the stack. When children need to communicate back to their parents (for 
 example, if you push an editor view controller from a summary view 
 controller, which needs to be updated when the editor view controller makes 
 changes), you can use KVO or notifications, but if the communication is by 
 design of interest only to the parent and child view controllers, just make 
 the parent the delegate of the child. So if the child, say, had a list of 
 favorite URLs for the user to select, it could call something like [delegate 
 didSelectFavorite:url] which would cause the parent to be updated (and 
 change appearance when the child is popped off the stack).

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa

Re: Application Design

2011-06-01 Thread Steve Christensen
Yep, that's true. I was going for the simple case since, unless you 
specifically plan to reference the singleton from multiple threads, you don't 
need to do anything more fancy.


On Jun 1, 2011, at 5:05 PM, Andrew Thompson wrote:

 I'll caution you as written that singleton is not be thread safe. Often you 
 don't care, because you only have one thread or because creating 2 webservice 
 clients may not be a problem for you. 
 
 
 On Jun 1, 2011, at 3:54 AM, Dan Hopwood d...@biasdevelopment.com wrote:
 
 Thanks Steve. For completeness - what's the proper way to perform the
 cleanup? Should another static method be created that releases the singleton
 instance when the app is closed? i.e.
 
 + (void)releaseSharedInterface
 {
   [sharedInstance release];
   sharedInsance = nil;
 }
 
 D
 
 
 On 1 June 2011 09:54, Dan Hopwood d...@biasdevelopment.com wrote:
 
 Great, thanks a lot Steve - very helpful.
 
 D
 
 
 
 On 31 May 2011 18:44, Steve Christensen puns...@mac.com wrote:
 
 How about providing a singleton class method? Then you just
 include WebServiceInterface.h where needed. No need to have a global
 variable.
 
 @implementation WebServiceInterface
 
 ...
 
 + (WebServiceInterface*) sharedInterface
 {
 static WebServiceInterface* sharedInstance = nil;
 
 if (sharedInstance == nil)
 sharedInstance = [[WebServiceInterface alloc] init];
 
 return sharedInstance;
 }
 
 ...
 
 @end
 
 
 foo = [[WebServiceInterface sharedInterface] someMethod];
 
 
 On May 31, 2011, at 3:25 AM, Dan Hopwood wrote:
 
 Thanks for all your answers, they make complete sense.
 
 I have one more related question. I have developed a custom, stateful
 WebServiceInterface object, which manages all connection requests made to 
 an
 XML-RPC server. Being stateful, I initialise this object when the app
 launches and at the moment I store a pointer to it in a header file, which 
 I
 include in all view controllers. This allows me to make a request for data
 from anywhere. In a similar way, I feel that storing a global pointer is 
 not
 best practise and can't help but think there is a more elegant way of doing
 this. One option I have considered if storing/initialising the object in 
 the
 app delegate and then creating a utility method in the delegate that wraps
 the object call. Is this the best solution or is there a design pattern I 
 am
 unaware of?
 
 Many thanks!
 
 
 On 28 May 2011 19:15, Conrad Shultz con...@synthetiqsolutions.comwrote:
 
 On May 28, 2011, at 6:11, Dan Hopwood d...@biasdevelopment.com wrote:
 
 Thanks for your response Steve. I have considered using the
 nsnotification service but what if you need to not only let another
 object know when an event has occurred but you also need to send that
 object some data? For example a user selects an option in a table -
 the selection must be conveyed in some way to the vc I'm pushing on
 the nav controller stack so that it's view is dynamic depending on the
 selection. As far as I'm aware that is not possible using
 notifications.
 
 That's very doable with notifications.  See the object and userInfo
 methods in NSNotification and corresponding methods in 
 NSNotificationCenter.
 
 In general I create a new vc/nib for *every* screen I have in the app.
 Let's take a navigation app as an example. Are you saying that the
 hierarchy should be:
 
 - 'root view controller' (has overall control, contains navigation
 logic and sends data between the containing view controllers)
 -- 'nav controller'
 -- 'all view controllers to be pushed/popped'
 
 ...where the nav controller and its view controllers are stored and
 initialised inside the 'root view controller'?
 
 Well, I'd say the view controllers aren't stored inside the root view
 controller; they are pushed onto the navigation stack as and when needed.
 Unless you are doing some caching, I wouldn't store the view controllers
 outside the navigation stack. (If you do implement caching, make sure you
 respond to memory warnings by flushing the cache!)
 
 In a navigation based application I feel that your architecture is
 simplified by design.  Since only one view controller (notwithstanding 
 modal
 view controllers) is on screen at any time, and they are all arranged
 hierarchically, parents should configure their children before pushing 
 them
 onto the stack. When children need to communicate back to their parents 
 (for
 example, if you push an editor view controller from a summary view
 controller, which needs to be updated when the editor view controller 
 makes
 changes), you can use KVO or notifications, but if the communication is by
 design of interest only to the parent and child view controllers, just 
 make
 the parent the delegate of the child. So if the child, say, had a list of
 favorite URLs for the user to select, it could call something like 
 [delegate
 didSelectFavorite:url] which would cause the parent to be updated (and
 change appearance when the child is popped off the stack

Re: Scaling a NSImage not working

2011-06-01 Thread Steve Christensen
-drawInRect draws the image into the destination rectangle, stretching or 
shrinking as necessary to get it to fit. If you want to preserve the aspect 
ratio, you'll have to generate a scaled rectangle with the image's aspect 
ratio. That's just simple math.


On Jun 1, 2011, at 9:29 PM, Development wrote:

 Ok am I barking up the wrong tree here?
 
 I know there has to be a way of taking an image of size say 128X128
 and drawing it in to a rectangle of say size 256X512
 without loosing the aspect ratio of the original image.
 
 However The following code DOES NOT DO THIS
 
 NSImage * screenImage = [[NSImage alloc]initWithCGImage:cgImage 
 size:NSMakeSize(CGImageGetWidth(cgImage), CGImageGetHeight(cgImage))];
 
NSImage * destination = [[NSImage alloc]initWithSize:movieFrame.size];
[destination lockFocus];
[[NSColor blackColor]set];
NSRectFill([destination alignmentRect]); //I want a black poster frame 
 around the image
[screenImage drawInRect:[destination alignmentRect] fromRect:[screenImage 
 alignmentRect] operation:NSCompositeSourceAtop fraction:1.0];
 
[destination unlockFocus];
 
 
 Was I completely mistaken in thinking that the way I'm doing this was suppose 
 to preserve the aspect ratio?
 Is it even possible to do what I'm trying to do? (I know the answer is yes 
 since I've seen it done.)
 
 Am I going to have to do this at the CGImage level?
 
 Some kind of information would be nice google is a bust, cannot find the 
 information on the developer site.
 All the examples I have seen assume the source and destination images are the 
 same size
 However as I explained before, the user is able to select specific areas in 
 the capture view to focus on.  And since the selections never have the same 
 aspect ratio as the destination, when I try to draw the image it's distorted. 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Malformed URL string in openURL

2011-06-07 Thread Steve Christensen
On Jun 7, 2011, at 6:32 PM, James Merkel wrote:

 On Jun 7, 2011, at 6:20 PM, Jens Alfke wrote:
 
 On Jun 7, 2011, at 6:17 PM, James Merkel wrote:
 
 The following works ok:
 
 NSString * mapquestURLString;
 
 mapquestURLString = [NSString 
 stringWithString:@http://mapq.st/?maptype=hybridq=39.7452,-104.98916;];
 
 (Just FYI, the -stringWithString call is redundant. You can just assign the 
 constant directly to the variable.)
 
 mapquestURLString = [NSString 
 stringWithString:@http://mapq.st/?maptype=hybridq=39.7452,-104.98916(Test 
 point label)”];
 
 It’s not the parens that are illegal, it’s the spaces. Change them to %20 
 and you should be OK.
 
 —Jens
 
 Right you are -- thanks.
 
 I was using stringWithString because I actually  was building  up a URL 
 string by appending strings.
 I simplified the code to show the problem.

Is there some reason you're not using built-in support to properly escape 
strings that are part of URLs?

NSString* mapType = @hybrid;
NSString* location = @39.7452,-104.98916(Test point label);

mapquestURLString = [NSString 
stringWithFormat:@http://mapq.st/?maptype=%@q=%@;,
[mapType 
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
[location 
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: iOS: encoding a custom view with a shape in it

2011-06-11 Thread Steve Christensen
How do the results differ between what you saw before and after saving the 
document? Is everything wrong? or just the scaling, the rotation, what?

And to draw an object, are you using an affine transform just to rotate it or 
for scaling and/or translation as well?


On Jun 9, 2011, at 4:25 PM, Development wrote:

 This app allows users to do a number of graphical things. On of those things 
 is to draw rectangles and ellipses.
 
 No it would not be complete if they could not resize and rotate these shapes. 
 Thus the features exist.
 
 The problem comes when I freeze dry the object.
 I encode it exactly as it exists at the moment the saveDocument: option is 
 invoked. 
 colors, frame,rotation etc
 logging these values confirms them
 
 When I unfreeze it, well the values remain identical. hence I know the save 
 worked.
 
 I initialize the object with the decoded rectangle for the frame
 I then apply the transition to rotate it to the correct angle.
 
 hmm the result looks nothing like the initial item did at save time
 
 So I've been looking at this very closely... Is this happening because simply 
 applying the last known frame and angle does not mean it will match?
 If this is the case, does it mean then that in order to preserve the exact 
 state, I must not only save all the data about the object but an array of 
 every change made to the object such as resizes and rotations in order to get 
 the correct result?
 
 My bandaid is to convert the view in to a UIImage and save the image. This 
 fixes the problem however the downside is that special effects that can be 
 applied to rectangles and ellipses are not available on reload.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: iOS: encoding a custom view with a shape in it

2011-06-11 Thread Steve Christensen
And also to clarify, are you freeze drying a view or the objects it draws? 
You should be doing the latter since that's part of your model.


On Jun 11, 2011, at 6:47 PM, Steve Christensen wrote:

 How do the results differ between what you saw before and after saving the 
 document? Is everything wrong? or just the scaling, the rotation, what?
 
 And to draw an object, are you using an affine transform just to rotate it or 
 for scaling and/or translation as well?
 
 
 On Jun 9, 2011, at 4:25 PM, Development wrote:
 
 This app allows users to do a number of graphical things. On of those things 
 is to draw rectangles and ellipses.
 
 No it would not be complete if they could not resize and rotate these 
 shapes. Thus the features exist.
 
 The problem comes when I freeze dry the object.
 I encode it exactly as it exists at the moment the saveDocument: option is 
 invoked. 
 colors, frame,rotation etc
 logging these values confirms them
 
 When I unfreeze it, well the values remain identical. hence I know the save 
 worked.
 
 I initialize the object with the decoded rectangle for the frame
 I then apply the transition to rotate it to the correct angle.
 
 hmm the result looks nothing like the initial item did at save time
 
 So I've been looking at this very closely... Is this happening because 
 simply applying the last known frame and angle does not mean it will match?
 If this is the case, does it mean then that in order to preserve the exact 
 state, I must not only save all the data about the object but an array of 
 every change made to the object such as resizes and rotations in order to 
 get the correct result?
 
 My bandaid is to convert the view in to a UIImage and save the image. This 
 fixes the problem however the downside is that special effects that can be 
 applied to rectangles and ellipses are not available on reload.
 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: iOS: encoding a custom view with a shape in it

2011-06-15 Thread Steve Christensen
On Jun 15, 2011, at 8:29 AM, Development wrote:

 Using the keyed archiver I save all of the values related to the drawing 
 inside of the view. Then of course I save the view's parameters.

OK, I can see archiving the properties of the shape(s) so that you can restore 
them. It sounds like you're trying to archive the view as well, but I'm unsure 
why. A view just provides a place to draw things, but it has nothing to do with 
the data model, so it doesn't really make sense to save it as well. The 
properties needed to draw the shapes should be able to stand independent of the 
view.

 I'm not sure what you mean by the objects it draws?  I'm using CGContext 
 methods to draw rectangles and elipses so other than saving all the values 
 such as transforms and colors and all I'm not sure what you mean.

The objects are the rectangles and ellipses. I had assumed that you created 
shape classes to hold the properties (frame, rotation, color, etc.) and to draw 
those shapes.


 On Jun 11, 2011, at 6:49 PM, Steve Christensen wrote:
 
 And also to clarify, are you freeze drying a view or the objects it draws? 
 You should be doing the latter since that's part of your model.
 
 
 On Jun 11, 2011, at 6:47 PM, Steve Christensen wrote:
 
 How do the results differ between what you saw before and after saving the 
 document? Is everything wrong? or just the scaling, the rotation, what?
 
 And to draw an object, are you using an affine transform just to rotate it 
 or for scaling and/or translation as well?
 
 
 On Jun 9, 2011, at 4:25 PM, Development wrote:
 
 This app allows users to do a number of graphical things. On of those 
 things is to draw rectangles and ellipses.
 
 No it would not be complete if they could not resize and rotate these 
 shapes. Thus the features exist.
 
 The problem comes when I freeze dry the object.
 I encode it exactly as it exists at the moment the saveDocument: option is 
 invoked. 
 colors, frame,rotation etc
 logging these values confirms them
 
 When I unfreeze it, well the values remain identical. hence I know the 
 save worked.
 
 I initialize the object with the decoded rectangle for the frame
 I then apply the transition to rotate it to the correct angle.
 
 hmm the result looks nothing like the initial item did at save time
 
 So I've been looking at this very closely... Is this happening because 
 simply applying the last known frame and angle does not mean it will match?
 If this is the case, does it mean then that in order to preserve the exact 
 state, I must not only save all the data about the object but an array of 
 every change made to the object such as resizes and rotations in order to 
 get the correct result?
 
 My bandaid is to convert the view in to a UIImage and save the image. This 
 fixes the problem however the downside is that special effects that can 
 be applied to rectangles and ellipses are not available on reload.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Animating handwriting

2011-06-23 Thread Steve Christensen
Is this a correct interpretation of what you're trying to do? You have a title 
string that will be drawn in a handwriting font. You wish to reveal each of the 
letter strokes over time as if someone were actually writing the title on a 
piece of paper.


On Jun 23, 2011, at 9:45 AM, Gustavo Pizano wrote:

 Hello.
 
 Yes kinda.
 
 G.
 On Jun 23, 2011, at 6:34 PM, Conrad Shultz wrote:
 
 -BEGIN PGP SIGNED MESSAGE-
 Hash: SHA1
 
 On 6/23/11 6:50 AM, Gustavo Adolfo Pizano wrote:
 Helo Ken.
 
 Thanks for answer,
 I meant, I have some title string already, and I wish to be able to
 animate as if its being written at the moment, also I forgot to
 mention that this is for iOS.
 
 Sorry, do you mean that you have an NSString and a handwriting font,
 and you wish to animate the rendering of the string in that font?
 
 - -- 
 Conrad Shultz
 
 Synthetiq Solutions
 www.synthetiqsolutions.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How to resolve bulk warning Creating selector for nonexistent method ...?

2011-07-05 Thread Steve Christensen
For the nonexistent method warnings, your project- or target-level settings 
likely have Undeclared Selector checked in the GCC warnings section of the 
build settings.

For the multiple selectors warnings, look at the Strict Selector Matching item 
in the same section. It says this will pop up if you're trying to send the 
message to a variable of type id, vs to an explicit class type.


On Jul 3, 2011, at 6:16 PM, arri wrote:

 Hi Motti,
 
 I would be very interested to know how you resolved this issue, if at all.
 
 I'm suddenly facing the same issue, out of no-where. Instead of trying
 to find the source of the problem, I just reverted to the last known
 working version (svn), but the warnings persist.
 This surprises me a bit, because earlier today i had cleaned the
 project and made a release-build for distribution to the client, and
 this went fine.
 
 I'm sure i'm overlooking something very obvious and stupid. Does
 anyone have an idea what that could be?
 
 thanks,
 arri
 
 
 On Mon, Jan 25, 2010 at 12:04 PM, Motti Shneor mot...@waves.com wrote:
 Hi everyone.
 
 I'm building static library, whose outward API is plain C, and whose 
 implementation is Cocoa-based.
 
 It was building and working alright, until (yesterday) something changed, 
 and any attempt to clean/build/rebuild it produces huge amount of 
 compilation warnings, on EVERY Obj-C message.
 
 First, there's a bulk of warnings like this:
 
 /Volumes/Data/.../FileManager_GUI_Mac.mm:224: warning: creating selector for 
 nonexistent method 'openPanel'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:196: warning: creating selector for 
 nonexistent method 'release'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:193: warning: creating selector for 
 nonexistent method 'code'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:190: warning: creating selector for 
 nonexistent method 'savePanel'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:190: warning: creating selector for 
 nonexistent method 'alloc'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:171: warning: creating selector for 
 nonexistent method 'stringWithFormat:'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:160: warning: creating selector for 
 nonexistent method 'getCString:maxLength:encoding:'
 
 Then another bulk of warnings, complaining about DOUBLE definitions for 
 Cocoa methods
 
 /Volumes/Data/.../FileManager_GUI_Mac.mm:244:0
 /Volumes/Data/.../FileManager_GUI_Mac.mm:244: warning: multiple selectors 
 named '+isVertical' found
 /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSplitView.h:30:0
  
 /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSplitView.h:30:
  warning: found '-(BOOL)isVertical'
 /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSliderCell.h:59:0
  
 /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSliderCell.h:59:
  warning: also found '-(NSInteger)isVertical'
 
 
 
 Notes:
 The project is building Intel-only Universal (32/64bit, architectures i386 
 and x86_64
 I only #import Cocoa/Cocoa.h once, in a single source file (an interface 
 header file).
 I added (linked) the Cocoa Framework once in the project, referencing the 
 Current SDK.
 The project DOES compile, and even works.
 If i turn on the  Build Active Architecture Only build option for the 
 project (ONLY_ACTIVE_ARCH = YES) then I only get the warnings when I compile 
 32bit. 64bit compilation is free of warnings.
 
 
 These warnings worry me, as I might be using a wrong framework, and the code 
 may break on a user machine.
 
 Any idea will be greatly appreciated.
 
 
 Motti Shneor
 --
 Senior Software Engineer
 Waves Audio ltd.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: How to resolve bulk warning Creating selector for nonexistent method ...?

2011-07-06 Thread Steve Christensen
You mentioned switching between debug and release configurations, so that would 
be a good first place to look since individual build settings can be set on a 
per-configuration basis.


On Jul 5, 2011, at 3:59 PM, arri wrote:

 Hi Steve,
 
 Thanks for your reply! Usually i would be tempted to get to the bottom
 of this and understand where/what mistakes were made (and by who;).
 But other than switching between Debug/Release i hadn't touched the
 build-settings at all, so i figured the problem couldn't be there..
 
 But meanwhile i did managed to 'fix' the issue by clearing Xcode's
 caches ( XCode-app-menu  Empry Caches ).
 Appearanly some things got corrupted and/or confused on that level. As
 a nice bonus, i also got about 10Gb of diskspace back.
 
 So i have no clue what the real problem was, but it's fixed.
 
 thanks,
 arri
 
 
 On Tue, Jul 5, 2011 at 9:17 PM, Steve Christensen puns...@mac.com wrote:
 For the nonexistent method warnings, your project- or target-level settings 
 likely have Undeclared Selector checked in the GCC warnings section of the 
 build settings.
 
 For the multiple selectors warnings, look at the Strict Selector Matching 
 item in the same section. It says this will pop up if you're trying to send 
 the message to a variable of type id, vs to an explicit class type.
 
 
 On Jul 3, 2011, at 6:16 PM, arri wrote:
 
 Hi Motti,
 
 I would be very interested to know how you resolved this issue, if at all.
 
 I'm suddenly facing the same issue, out of no-where. Instead of trying
 to find the source of the problem, I just reverted to the last known
 working version (svn), but the warnings persist.
 This surprises me a bit, because earlier today i had cleaned the
 project and made a release-build for distribution to the client, and
 this went fine.
 
 I'm sure i'm overlooking something very obvious and stupid. Does
 anyone have an idea what that could be?
 
 thanks,
 arri
 
 
 On Mon, Jan 25, 2010 at 12:04 PM, Motti Shneor mot...@waves.com wrote:
 Hi everyone.
 
 I'm building static library, whose outward API is plain C, and whose 
 implementation is Cocoa-based.
 
 It was building and working alright, until (yesterday) something changed, 
 and any attempt to clean/build/rebuild it produces huge amount of 
 compilation warnings, on EVERY Obj-C message.
 
 First, there's a bulk of warnings like this:
 
 /Volumes/Data/.../FileManager_GUI_Mac.mm:224: warning: creating selector 
 for nonexistent method 'openPanel'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:196: warning: creating selector 
 for nonexistent method 'release'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:193: warning: creating selector 
 for nonexistent method 'code'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:190: warning: creating selector 
 for nonexistent method 'savePanel'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:190: warning: creating selector 
 for nonexistent method 'alloc'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:171: warning: creating selector 
 for nonexistent method 'stringWithFormat:'
 /Volumes/Data/.../FileManager_GUI_Mac.mm:160: warning: creating selector 
 for nonexistent method 'getCString:maxLength:encoding:'
 
 Then another bulk of warnings, complaining about DOUBLE definitions for 
 Cocoa methods
 
 /Volumes/Data/.../FileManager_GUI_Mac.mm:244:0
 /Volumes/Data/.../FileManager_GUI_Mac.mm:244: warning: multiple selectors 
 named '+isVertical' found
 /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSplitView.h:30:0
  
 /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSplitView.h:30:
  warning: found '-(BOOL)isVertical'
 /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSliderCell.h:59:0
  
 /Developer/SDKs/MacOSX10.5.sdk/System/Library/Frameworks/AppKit.framework/Headers/NSSliderCell.h:59:
  warning: also found '-(NSInteger)isVertical'
 
 
 
 Notes:
 The project is building Intel-only Universal (32/64bit, architectures i386 
 and x86_64
 I only #import Cocoa/Cocoa.h once, in a single source file (an interface 
 header file).
 I added (linked) the Cocoa Framework once in the project, referencing the 
 Current SDK.
 The project DOES compile, and even works.
 If i turn on the  Build Active Architecture Only build option for the 
 project (ONLY_ACTIVE_ARCH = YES) then I only get the warnings when I 
 compile 32bit. 64bit compilation is free of warnings.
 
 
 These warnings worry me, as I might be using a wrong framework, and the 
 code may break on a user machine.
 
 Any idea will be greatly appreciated.
 
 
 Motti Shneor
 --
 Senior Software Engineer
 Waves Audio ltd.
 
 

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com

Re: iOS: AVFoundation, AVAssetWriter and caching

2011-07-06 Thread Steve Christensen
With the caveat that I haven't actually tried it, would it make more sense to 
be streaming the movie data to a local file, then specifying the URL/path to 
the file in the initializer method of one of the movie player classes? If the 
player can handle the case where not all the movie data is present then it 
should just do the right thing. The benefit is that you can use the same code 
to play the movie, no matter how much of it is local.


On Jul 5, 2011, at 8:03 PM, John Michael Zorko wrote:

 I'm interested in caching a movie as I play it from the internet, so that the 
 next time the user asks for the movie, it can play it from the device 
 filesystem. I'm thinking capturing frames and audio and using an 
 AVAssetWriter like I would when recording from the camera, but i'm not sure 
 if this will work when recording from a playing asset. Would anyone 
 illuminate me as to whether this is possible, or if I need to explore other 
 ways of doing this (which would probably be a lot less cool and efficient 
 than doing it this way, alas)?

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: IOS graphics

2011-07-11 Thread Steve Christensen
The first thing I notice is that none of the CGContext* calls after 
UIGraphicsBeginImageContext is referring to that image context so they are 
having no effect on it. You should move the UIGraphicsGetCurrentContext down 
after the [drawImage...] call.

If you are still not able to get the desired result with any of the Quartz 
blend modes, you'll need to create a bitmap context and tweak the pixels in the 
pixel buffer directly.


On Jul 11, 2011, at 8:48 AM, Development wrote:

 Sorry I figured since it was only a sudo change anyway it wouldn't matter.
 
 UIImage * drawImage = rotatingView.image;
CGContextRef context = UIGraphicsGetCurrentContext();
CGRect newRect = CGRectMake(0.0, 0.0, rotatingView.frame.size.width, 
 rotatingView.frame.size.height);
 
UIGraphicsBeginImageContext(newRect.size);
[drawImage drawInRect:newRect];
CGContextTranslateCTM(context, 0.0, rotatingView.frame.size.height);
CGContextScaleCTM(context, 1.0, -1.0);
CGContextClipToMask(context, newRect, drawImage.CGImage);
CGContextSetBlendMode(context, kCGBlendModeHue);
CGContextSetRGBFillColor(context, self.color.r ,self.color.g , 
 self.color.b, 1.0);
CGContextFillRect(context, newRect);
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
 
   This applies a colored rectangle applied over the image and clipped to 
 it as a mask. Which is not what I want. But even it if was the problem is 
 that when I get the png rep so I can save it with transparency to the 
 document, the applied color is lost. An easy way around this is to sable the 
 color values and reapply because when the document is flattened and save as 
 a png the color appears correctly. 
 But again that's effort in the wrong direction anyway.
 A side note the alpha is 1.0 right now, but in the finished product I thought 
 I'd use a slider to adjust that as intensity or something. Anyway it doesn't 
 matter it's just a colored rectangle over top of the image.
 
 
 On Jul 11, 2011, at 5:16 AM, Mike Abdullah wrote:
 
 Giving us a link to the example code would be a big help in understanding 
 what you're trying.
 
 On 11 Jul 2011, at 02:06, Development wrote:
 
 Im having a problem with adjusting the color values of a UIImage.
 
 How does one adjust levels and color values of a UIImage.
 The example code I found only overlays a rectangle clipped to an image 
 mask. It looks like color value adjustment until you realize 2 things.
 a) I absolutely cannot render the image view with the color adjustment into 
 a graphic context with the adjustment in tact, because what I always get 
 back is the original, unadjusted image.
 a b) it's not really adjusting the levels. And since it isn't it also means 
 I cannot actually adjust the brightness, contrast or anything else either.
 
 
 Is adjusting UIImage color levels even possible?

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Strange NSFileManager file replacement issue

2011-08-19 Thread Steve Christensen
On Aug 19, 2011, at 7:17 AM, Sixten Otto wrote:

 On Thu, Aug 18, 2011 at 10:38 PM, Ken Thomases k...@codeweavers.com wrote:
 
 Those functions, and the general operation that they perform, require that
 the files to be exchanged be on the same file system.
 
 If true, that certainly makes that method far less useful in the general
 case than I expected, and really seems restricted to the saving a new copy
 of an in-memory document and swapping it case. I really don't want to put
 the in-process download into the Documents tree. (Both because it's
 potentially visible to the user through iTunes, and because
 NSTemporaryDirectory() will be swept up occasionally.)

Is there any reason why you can't put the downloaded file in your app's private 
cache directory (.../appdir/Library/Caches), i.e., what gets returned by 
NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES)? 
That should certainly be within the bigger app directory hierarchy, and thus a 
peer of the app's Documents directory.


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Account validation in CocoaTouch for the purchased app

2011-12-21 Thread Steve Christensen
On Dec 20, 2011, at 2:26 PM, Alexander Reichstadt wrote:

 given an app is sold on iTunes, is there a way for that app to find out which 
 email address was used for the iTunes account when it was purchased?

I don't believe so. As far as I know, the only way to find that out is to ask 
the user.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: NSString looses Umlaute

2011-12-22 Thread Steve Christensen
And just to add in one more bit about why it's important to separate the text 
from the binary header, -initWithData:encoding: [r]eturns nil if the 
initialization fails for some reason (for example if data does not represent 
valid data for encoding). (That is from the NSString docs.)


On Dec 22, 2011, at 9:30 AM, Alexander Reichstadt wrote:

 I should add, you are right in that it also says:
 
 n+1, 1 byte, 0x0D stored as the Field Descriptor terminator.
 
 Everything from byte 68 on is then a multiple of 48 bytes, so I can simply 
 check on each 67+(n*48)+1 to see if that byte is 0x0D, which is the marker 
 position of which to follow Mike's advise on getting the subdata.
 
 Alex
 
 
 Am 22.12.2011 um 17:29 schrieb Ken Thomases:
 
 On Dec 22, 2011, at 9:54 AM, Alexander Reichstadt wrote:
 
 The DBF file format documentation says the header is in binary, then there 
 is a linefeed (\r), then there is the body. Each field has a fixed length, 
 wether used or not doesn't matter, the unused rest is filled with spaces.
 
 So, I read the file as data, stringily it as DOSLatin1, split it at the 
 linefeed and read the body according to the field definitions I am given. 
 They are guaranteed, so maybe some day I get around to writing a nice DBF 
 parser, but until then I go by the guaranteed field lengths.
 
 I tested it now on a couple of files and it works without a hitch.
 
 If the header is binary, then any of its bytes might be 0x0D, which is the 
 same as \r (or did you actually mean it when you said linefeed which is 
 0x0A or \n?), so your approach will fail.  In all probability, the header is 
 a fixed length and you can just skip that part of the data.  Either way, if 
 this is meant for more than a casual, one-off, in-house app, you'll have to 
 find a more reliable technique.
 
 Regards,
 Ken

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Storyboard SplitViewController example

2011-12-25 Thread Steve Christensen
On Dec 24, 2011, at 7:13 PM, Jamie Daniel wrote:

 I am very new to Xcode and iPad development. I am trying to do the following:
 
 I have an initial NavigationController and ViewController. I am trying to go 
 from a button on the ViewController to a SplitViewController using 
 Storyboards but I can't seem to get it to work. Does anyone have an example 
 of how to do it? Or an example of how to hand code it?

The iPad-Specific Controllers section of the View Controller Programming Guide 
for iOS specifically says:

A split view controller must always be the root of any interface you create. 
In other words, you must always install the view from a UISplitViewController 
object as the root view of your application’s window. The panes of your 
split-view interface may then contain navigation controllers, tab bar 
controllers, or any other type of view controller you need to implement your 
interface.

This topic has come up here in the past, so you may want to search the archives.

Also, you cross-posted to the Xcode mailing list. This would be off-topic there 
so I removed it in this reply.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


  1   2   3   >