Re: text orientation/positioning with layout manager

2011-01-31 Thread Todd Heberlein
On Jan 31, 2011, at 3:23 PM, Aki Inoue wrote:

> The precise definition of the point specified by the argument is the top left 
> corner of the text container containing the glyph range in the focused view 
> coordinate system.

This flipped view for fonts confuses me a bit because the fonts are oriented 
correctly. For example, an 'A' appears upright, not upside down. I'm going to 
have to ponder/research this a little more.

For now, if I want my string drawn on a base line beginning at the point 
basePoint, I currently define a glyphPoint which subtracts the font's pointSize 
from the basePoint's Y value. So far it seems to work on a variety of font 
sizes. Are there any obvious "gotchas" that I am missing with this approach?


Todd

glyphPoint.x = basePoint.x;
glyphPoint.y = basePoint.y - [myFont pointSize];

[layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:glyphPoint];

___

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: worker thread iterating over array - SLOW

2011-01-31 Thread Peter Lübke

Thanks Ken,
I was afraid to get an answer like this:-)


Am 01.02.2011 um 02:07 schrieb Ken Thomases:


On Jan 31, 2011, at 5:13 PM, Peter Lübke wrote:

I use a worker thread in my app that invokes the same method(s) on  
all objects in an array sent from the main thread. The array may  
contain thousands of objects.
The main thread communicates with the worker thread via  
distributed objects.


Everything works fine except performance is too slow.
Seems to me that my NSConnection asks for the method signature  
each time the method is invoked on an object in the array, thus  
adding massive overhead.


Well, that's part of it, but probably not the biggest part.

The way you're using D.O. defeats the purpose of having a worker  
thread.


Sending the array from the main thread to the worker thread causes  
the worker thread to receive a proxy for the array.  Then, as you  
request each element of the array, that's a message to the main  
thread and back, and what you get is... a proxy for the element  
(not the element itself).  Then, every operation you perform on the  
element is a message to the main thread _and the main thread  
performs the work on behalf of its "client"_.


So, you have effectively failed to shift the work from the main  
thread to the worker thread.  The main thread is a "server" doing  
all of the work on the behalf of its client, the worker thread.


Not quite... In this case, the worker thread is the server.
I guess that's why the main thread is all the way responsive. The  
worker thread also sends messages to the main thread updating a  
progress indicator which all works nice.




If you're going to use D.O., ideally you want the messages to  
either carry no data or to carry data values (bycopy), not  
references to objects.


Thanks for clarifying this. This explains a point I totally overlooked.


Also, you want to design a fairly coarse-grained protocol of  
requests that a client can make of the server -- few requests to do  
some big chunks of work, not many requests for small chunks of work.




This is what I thought I was doing, the "bad" thing - if I get it  
right - is that I pass the array to the server?





The shared objects approach - call NSThread's - 
detachNewThreadSelector:toTarget:withObject: with the array as  
argument 3, have the secondary thread do the job and exit - is way  
faster!


Is there a reason that's not sufficient?  Why are you trying to use  
D.O.?




There's a bunch of these arrays around, all containing objects of one  
class. There's another bunch of objects of various classes that  
access these objects.
I didn't like the idea of implementing the creation of threads  that  
always kind of do the same sort of work in each of these different  
classes.
So I thought it might be a good idea to have a singleton "thread  
manager" create worker threads as needed and coordinate those  
different object's requests.


Reading your statements, I will have to spent some thoughts on the  
basic concept...


Thanks,
Peter



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


Bizarre behaviour of NSFontDescriptor and/or NSCharacterSet

2011-01-31 Thread Brian Schack
I have a small application that exhibits behaviour so strange that I
can't even begin to explain what bug might possibly be responsible for
it.  I'm thinking of submitting a bug report to Apple, but first I'd
like someone else to take a look at it to see if I haven't made some
silly mistake or assumption.

The application in question finds the set of fonts that can represent
the characters in a string (ie, 'give me all the fonts that can display
these characters: "0123456789"').  The core function is:

NSArray *fontsWith(NSString *str)
{
NSCharacterSet *cset = 
[NSCharacterSet characterSetWithCharactersInString:str];
NSDictionary *attributes = 
[NSDictionary dictionaryWithObjectsAndKeys:cset, 
 NSFontCharacterSetAttribute, nil];
NSFontDescriptor *descriptor = 
[NSFontDescriptor fontDescriptorWithFontAttributes:attributes];

return [descriptor matchingFontDescriptorsWithMandatoryKeys:nil];
}

The function usually behaves as I'd expect.  If I give it a short
string, it returns a large number of fonts.  As I add characters, it
finds fewer fonts that have glyphs for those characters.

The following is a list of strings passed in and number of fonts
returned from fontsWith() (where x and y vary depending on the number of
fonts on your system, and y < x):

@"." => x fonts
@".z" => y fonts

As you would expect, including two dots instead of one makes no
difference:

@".." => x fonts
@"..z" => y fonts

Now, for the strangeness.  Consider the following two strings:

@""
@"...z"

Each is 64 characters long.  You would expect to get exactly the same
answers with them as you would with @"." and @".z".  And you do, but
*only* if you run the program separately for each string.  If the
program has two consecutive calls to fontsWith(), here's what you get:

@"" => x
@"...z" => x

Both return the same answer!  And if I reverse the calling sequence:

@"...z" => y
@"" => y

I get y and y, instead of y and x!

Note that if I remove one dot from each of the strings, making them 63
characters long, then I get the proper results.  There seems to be
something magical about that 64th character, but I have no idea what it
is.  Remember that the string is converted to a character set.  I've
checked the sets, and they report that they contain exactly one
character (".") for the first string, and two ("." and "z") for the
second.  The original length of the string should have absolutely no
effect on the result returned by fontDescriptorWithFontAttributes, but
it seems to.

I've run the program on two different systems, and had the same results.
I've searched the net but found no other reports of this problem.  Can
anyone explain what is going on?
___

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 puzzle about rotation

2011-01-31 Thread WT
On Jan 31, 2011, at 11:16 PM, David Rowland wrote:

> Is there something that defeats the delivery of rotate events to a view 
> controller?

This may or may not be the case with your app, but a UITabBarController vetoes 
device orientation change events to its managed view controllers unless every 
one of them supports the orientation change in question. However, it still 
calls the view controllers' -shouldAutorotateToInterfaceOrientation: method (as 
it must, in order to find out if they all support the orientation change being 
requested). It may not invoke them every time, though. Rather, it may invoke 
them once per view controller and cache the result. I don't know which is the 
case, but it's easy to check.___

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: text orientation/positioning with layout manager

2011-01-31 Thread David F.
Douglas -- Something somewhere must be trying to compensate for the unflipped 
context, because the text isn't drawn upside-down.  Yes, the positioning is 
calculated with the assumption that the context is flipped, and effects like 
strikethrough and underline are drawn with the assumption that the context is 
flipped.

But the text glyphs themselves are always drawn right-side up.

Isn't this a bug?  (And doesn't pretty much every developer who touches the 
text system trip over this?)  If the glyphs were actually drawn upside-down 
then the problem would be pretty obvious.  Instead, forgetting to flip the 
context produces weird effects (but not upside-down text).  And when some one 
posts to the list and asks for help, and they are told that the context isn't 
flipped, then their first reaction is to believe that that can't be the 
problem--after all, the text isn't upside-down.

That was certainly my reaction the last time I tripped over this and it appears 
that the original poster has had that reaction as well.

So why aren't glyphs drawn upside-down when the context hasn't been flipped?!

David


On Jan 31, 2011, at 3:15 PM, Douglas Davidson wrote:

> The layout manager expects to be drawing within a flipped context.
> 
> Douglas Davidson
> 
> On Jan 31, 2011, at 2:09 PM, Todd Heberlein wrote:
> 
>> I'm doing a simple experiment using NSTextStorage, NSLayoutManager, 
>> NSTextContainer to draw some text (I am basing this on the CircleView 
>> example because I want some of that orientation power later).
>> 
>> I have found that when rendering the text using 
>> drawGlyphsForGlyphRange:atPoint:, I don't get the text where I expected. It 
>> is higher than I expect. Furthermore, when I draw a rectangle around the 
>> text (or try to) using the rectangle from usedRectForTextContainer:, the 
>> text is outside the rectangle (in short, the rectangle is where I expect it 
>> to be, but the text glyphs are not).
>> 
>> Is there a secret incantation that I am missing?
>> 
>> Thanks,
>> 
>> Todd
>> 
>> Basic code snippet:
>> 
>> point = NSMakePoint(1.0, 1.0);
>> glyphRange = [layoutManager glyphRangeForTextContainer:textContainer];
>> usedRect = [layoutManager usedRectForTextContainer:textContainer];
>> usedRect.origin = point;
>> 
>> [layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:point];
>> [[NSBezierPath bezierPathWithRect: rect] stroke];
>> ___
>> 
>> 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/ddavidso%40apple.com
>> 
>> This email sent to ddavi...@apple.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/davidf%40gmx.us
> 
> This email sent to dav...@gmx.us

___

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


-[CALayer setContents:] slower in iOS 4.2?

2011-01-31 Thread Julian Wood
We have a game engine of sorts, developed under 3.2. It did use NSTimer to fire 
off the game loop, but now uses CADisplayLink, at 15fps. The game loop 
basically sends messages to as many as 15 sprites, telling them to update their 
position and their frame. A sprite is in essence a CALayer, and we use 
-[CALayer setContents:] and -[CALayer setPosition:] to update those properties. 
All sprites are updated in a CATransaction, and everything is performed on the 
main thread. The image used for contents is obtained from a UIImage 
spriteAtlas. The atlas can be quite large: 1000x1600. It contains all the 
animation frames for a sprite. We grab the appropriate image portion from the 
spriteAtlas using CGImageCreateWithImageInRect(CGImageRef image, CGRect rect). 
In general, we haven't been hitting the memory limit on the device with this 
approach, and when it does, it recovers nicely.

Now this all worked perfectly in 3.2, but in iOS > 4, we have performance 
problems, on the device only. Basically the sprites are very laggy and the 
animation is choppy, until resources have fully loaded (it can take from 1s to 
30s to fully settle down). The culprit would appear to be -[CALayer 
setContents:], which can take on the order of 0.3s-0.8s, the first time the 
image is used. The problem is then exacerbated as we re-enter the gameloop, 
with resources not in place.

So to solve this, we have tried several approaches (apart from waiting for a 
possibly never-coming performance fix to -[CALayer setContents:]):

1. Preload image assets. One would think this would be easy, but nothing seems 
to preload a CGImageRef until it is actually painted on the screen. Or at the 
very least, there is no time penalty until you try to paint an image on the 
screen. Nothing we have tried has improved this situation. The docs for 
-[UIImage CGImage] state: "If the image data has been purged because of memory 
constraints, invoking this method forces that data to be loaded back into 
memory. Reloading the image data may incur a performance penalty." I had 
assumed this to mean that the image will be fully loaded into memory, but our 
results would suggest that it doesn't actually get loaded until it is used (eg 
in setContents:). We're using +[UIImage imageNamed:] to load the image, and so 
far the cache inherent to that method has been good to us.

2. Invoke -[CALayer setContents:] on a background thread. This does not change 
the situation at all. I suspect that -[CALayer setContents:] simply grabs the 
main thread and does its work there, regardless of the thread it is invoked 
from, though I can't find any docs that say this explicitly.

[spriteLayer performSelectorInBackground:@selector(setContents:) 
withObject:(id)frameImage];
vs
[spriteLayer setContents:(id)frameImage];

3. Block until the image has been loaded. Basically, we skip any updates on the 
sprite until a flag appears, indicating the image has been loaded. Since the 
image loading is asynchronous, AFAICT, we just set the flag before and after 
-[CALayer setContents:].

Again, this does not improve performance, which says to me that setContents on 
other instances of CALayer on the screen are being affected, even though their 
imageContents are loaded and cached. I can only imagine this is because 
everything is being invoked on the same thread, on the same runloop.


One final note - my CADisplayLink timer does not seem very reliable - ie, I get 
between 2 and 200 fps, when I should only ever get 15fps, assuming it is tied 
directly to hardware. Perhaps because it is also on the main runloop, it is 
suffering as well? While these anomalies are rare, they occur exactly when 
trying to load a new sprite atlas image. It seems like this alone could be 
causing the problem. I'm looking now at running it on another runloop or 
thread. NSTimer doesn't change anything appreciably, either.

timer_ = [CADisplayLink displayLinkWithTarget:self 
selector:@selector(gameloop)];
[timer_ setFrameInterval:4]; // 15fps
[timer_ addToRunLoop:[NSRunLoop currentRunLoop] 
forMode:NSDefaultRunLoopMode];

I measure fps like this in the gameloop:

double startTime = CACurrentMediaTime(); 
double fps = 1/(startTime - lastTime_);
lastTime_ = startTime;
ILog (@"fps: %f", fps);

So I feel like I'm flailing around a bit here now. I know what the problem is, 
but have been unable to find an approach that will improve the situation. It 
may be that we have to split up our sprite atlases, but I wanted to ask for 
advice from the list first. 

Any thoughts or suggestions would be greatly appreciated! Thanks,

Julian




___

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

Re: worker thread iterating over array - SLOW

2011-01-31 Thread Ken Thomases
On Jan 31, 2011, at 8:48 PM, Peter Lübke wrote:

> Thanks Ken,

You're welcome.

> Am 01.02.2011 um 02:07 schrieb Ken Thomases:
> 
>> So, you have effectively failed to shift the work from the main thread to 
>> the worker thread.  The main thread is a "server" doing all of the work on 
>> the behalf of its client, the worker thread.
> 
> Not quite... In this case, the worker thread is the server.

If the main thread owns the real array and the worker thread receives a proxy 
of the array (and thus its elements), then the main thread is the server, 
serving the services of the array and its elements to the worker thread.  It 
doesn't matter how you intended/designed things to work.

> I guess that's why the main thread is all the way responsive.

This probably has to do with the granularity of the messages that the worker 
thread is sending to the array and its elements.  If it's invoking many quick 
methods, then the main thread will remain responsive, even if it's doing all 
the work.  That's because there are frequent opportunities for it to respond to 
GUI events between messages from the worker thread.


>> Also, you want to design a fairly coarse-grained protocol of requests that a 
>> client can make of the server -- few requests to do some big chunks of work, 
>> not many requests for small chunks of work.
> 
> This is what I thought I was doing, the "bad" thing - if I get it right - is 
> that I pass the array to the server?

Basically, yes.  It's not a hard and fast rule that doing so is always wrong or 
bad.  Just remember that every method invoked on the proxy is delivered to the 
original object over the D.O. connection, the provider of that original object 
does the work, and then results are passed back -- and if the results are 
non-value objects, they are passed by reference, meaning as proxies.  So, the 
proxiness can cascade.


> There's a bunch of these arrays around, all containing objects of one class. 
> There's another bunch of objects of various classes that access these objects.
> I didn't like the idea of implementing the creation of threads  that always 
> kind of do the same sort of work in each of these different classes.
> So I thought it might be a good idea to have a singleton "thread manager" 
> create worker threads as needed and coordinate those different object's 
> requests.

That's a thread pool.  You can use any number of synchronization techniques to 
give work to the threads in a pool.  NSConditionLock is nice and 
straightforward.  See 
.

There are also message queue implementations to do something a bit like D.O., 
except without the proxying.  I've used YAMessageQueue in the past.  It's also 
not too hard to roll your own.

Cheers,
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: text orientation/positioning with layout manager

2011-01-31 Thread Graham Cox

On 01/02/2011, at 1:04 PM, Todd Heberlein wrote:

> For now, if I want my string drawn on a base line beginning at the point 
> basePoint, I currently define a glyphPoint which subtracts the font's 
> pointSize from the basePoint's Y value. So far it seems to work on a variety 
> of font sizes. Are there any obvious "gotchas" that I am missing with this 
> approach?


Well, the font height is not the same as the xHeight, which is the distance 
between the top of the character and the baseline. If you use the font's 
xHeight value you'll be a lot closer.

But NSLayoutManager will give you the layout bounding rectangles which are 
correct for the range of text you ask it to lay out - if you draw the glyphs 
into those rects they are definitely correct. For doing fancy text layouts like 
curves, you can still use the layout manager and then transform the resulting 
glyph positions as you want. That's what I do for the text-on-path stuff in 
DrawKit.

--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: text orientation/positioning with layout manager

2011-01-31 Thread Ross Carter
On Jan 31, 2011, at 10:53 PM, David F. wrote:

> So why aren't glyphs drawn upside-down when the context hasn't been flipped?!

Why do you think they should be upside down? Flippedness is implicated in 
determining the origin point of the text container. Text containers themselves 
are always right-side-up (or flipped, if you prefer).

Perhaps you are confounding text drawing behavior with image drawing 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: text orientation/positioning with layout manager

2011-01-31 Thread Ross Carter
On Jan 31, 2011, at 9:04 PM, Todd Heberlein wrote:

> For now, if I want my string drawn on a base line beginning at the point 
> basePoint, I currently define a glyphPoint which subtracts the font's 
> pointSize from the basePoint's Y value. So far it seems to work on a variety 
> of font sizes. Are there any obvious "gotchas" that I am missing with this 
> approach?

The first gotcha that comes to mind is an NSTextAttachment.
___

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: NSTableView selecting text within a cell [SOLUTION]

2011-01-31 Thread Ben Golding

On 31/01/2011, at 16:30, Ben Golding wrote:

> I have an app with a NSTableView where the data is presented to the user.  
> When the user hits "Find", I'd like to be able to scroll the table view to 
> the visible cell (easy enough) and then select the range that matched within 
> that field (not so easy).
> 
> At present, my code looks like:
> 
> NSCell *cell = [csvTableView preparedCellAtColumn:col row:row];
> NSText *textEditor = [csvWindow fieldEditor:YES forObject:cell];
> 
> NSLog(@"Match: row %@, field %@, range(%d, %d)", [match row], [match field], 
> [match range].location, [match range].length);
> [csvTableView scrollRowToVisible:row];
> [csvTableView scrollColumnToVisible:col];
> [textEditor setSelectedRange:[match range]];
> 
> I feel like I need to between getting the textEditor for the window and 
> calling -setSelectedRange:, I just don't know what.

I got a really great answer from Corbin Dunn who explained that what I was 
doing was not giving me what I wanted: asking for a field editor for the cell 
wasn't sensible; what I really wanted was the field editor for the control, ie 
the tableView.

In essence he suggested I should change my code to:

NSText *textEditor;

[csvTableView editColumn:col row:row withEvent:nil select:NO];
textEditor = [csvWindow fieldEditor:YES forObject:csvTableView];
[textEditor setSelectedRange:[match range]];

which is not just shorter, it works!

Ben.

smime.p7s
Description: S/MIME cryptographic signature
___

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

array controllers and key paths

2011-01-31 Thread Amy Heavey

Hi,

I've got 3 entities, Event, CustomerOrders and CustomerORderITems.

Events has a to many relationship (eventOrders) to CustomerOrders
CustomerOrders has a to many relationship (customerOrderItems) to  
CustomerOrderItems


I'd like to be able to list all of the CustomerOrderItems for a  
selected event in a table.


I think I need to create a new array controller (eventOrderItems) but  
how do I bind the content? I've tried various array/set key paths but  
none have worked so far. Is this possible?


I've got an array controller called eventOrders which is bound to the  
Events.selection so I thought I could bind eventOrderItems to  
eventOrders.arrangedObjects keypath customerOrderItems


If I try to bind the content set I get an error saying something like  
cannot create content set, try using content array,

Cannot create NSSet from object (
) of class NSCFArray - consider using contentArray binding instead of  
contentSet binding


 but if I try that I get another error
[<_NSFaultingMutableSet 0x1a0a90>  
addObserver:forKeyPath:options:context:] is not supported. Key path:  
orderItemProduct.productTitle




Many Thanks

Amy



___

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: Initializing NSWindow with Carbon window

2011-01-31 Thread Kyle Sluder
On Sun, Jan 30, 2011 at 11:45 PM, Andrew James  wrote:
> I've done some investigating and still getting the behavior that the window 
> does
> not display from the code below
>
> Interestingly,  if you look at the two ShowWindow/SelectWindow pairs. I will 
> see
> the window when the first one is uncommented only.  I will not see the window
> when the second set is uncommented only.  ODD.  Don't know if this provides 
> any
> insight.
>
> WindowRef carbonWindow = carbonBuilder.GetProduct();
>
> //      If these are only Show/Select uncommented, window will display
> //ShowWindow( carbonWindow );
> //SelectWindow( carbonWindow );
>
> NSWindow *wrapper = [ [ NSWindow alloc ] initWithWindowRef: carbonWindow ];
>
> //      If these are only Show/Select uncommented, window will NOT display
> //ShowWindow( carbonWindow );
> //SelectWindow( carbonWindow );

I have two observations:

1. Why not move entirely to Cocoa for your UI, rather than continuing
to build a Carbon UI and then wrapping it in a Cocoa window?

2. Is does not surprise me that the system doesn't like you making
Carbon window calls on a window once it's been wrapped by a Cocoa
window.

--Kyle Sluder
___

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: Add a view (xib) to a project

2011-01-31 Thread Uli Kusterer
On 30.01.2011, at 22:59, Max Stottrop wrote:
> But now to my question. Can anyone of you explain me (slowly;)) how to add 
> another view (.xib) file to my iPhone project?  I tried several things, but 
> none worked for me. Thanks in advance.

 There are two steps to this:

1) Create a UIViewController subclass to load the XIB
2) Create the actual XIB file, and make sure you set the "custom class" of its 
"File's Owner" to the class of object that loads your XIB (i.e. the subclass 
from step 1)

Both of these can be achieved using the File -> New menu item in Xcode these 
days, and then opening and editing the resulting files.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de



___

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: Initializing NSWindow with Carbon window

2011-01-31 Thread Uli Kusterer
On 30.01.2011, at 11:17, Andrew James wrote:
> I have a legacy builder class that creates a Carbon window and I want to 
> initialize an NSWindow with this WindowRef.

 What for? What are you trying to achieve? Nonestly, I wouldn't recommend 
mixing Carbon and Cocoa windows in the same application. There are many subtle 
and not-so-subtle bugs (from window ordering issues, e.g. on app 
activation/deactivation, to weird behaviour when showing sheets, to the 
impossibility of correctly activating and deactivating menu items in both Cocoa 
and Carbon...).

 The only case I've found works is having modal Cocoa windows in a Carbon 
application. All other things had this or that annoying issue, leak, or 
whatever.

 If you want my recommendation: Save yourself the trouble and just start 
porting the whole window to Cocoa. I generally create a new window controller 
class, and then recreate everything from the original class in the new one in 
Cocoa, step by step, starting with one method (e.g. the constructor and setup 
methods) and then porting all the methods called by this one. The model behind 
everything stays the same. That ensures the behaviour even of complex windows 
isn't unintentionally modified. Of course, you will have to change some things, 
but at least this way you don't accidentally miss something.

 That way, you can at least partially run the old code next to the new one and 
compare their behaviours, to make sure they're exactly the same.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."



___

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


Tab bar controller inside a navigation controller, how to adjust the view height

2011-01-31 Thread ico
I am trying to implement an app similar as "tweetie" applicatin, use
UIViewController to implement a custom TabBarController that can be pushed
in a navigation stack. This has been discussed before as shown here:

http://stackoverflow.com/questions/576764/tab-bar-controller-inside-a-navigation-controller-or-sharing-a-navigation-root-v


My app running well except for 1 problem. That is if the app receive the
memory warning message, and one of the view in the tabbar, say this tabbar
has 3 tabs, the first one's view(a table view) is released as it is not
active when the app receive the memory warning message, then when user tap
the first tab to come back with the first view, viewLoad and viewDidLoad
method is called, but the view's height is not correct. I figure out the
reason, that is when the tabbar get pushed into the navigation stack, the
view will automatically subtract the navigationbar height from the view
height, so that the tableview's height is correct. However, if the view is
released and come back to it, the tableview's height is not correct anymore
because it does not adjust the height by minus the navigationbar's height.
Even though I know the reason, but I can't find a solution to fix it. Any
help will be appreciated.

Hopefully I stated the problem clearly. Thank you.

-- 
==
Life isn't about finding yourself.
Life is about creating yourself.
___

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: Initializing NSWindow with Carbon window

2011-01-31 Thread Andrew James
The application I'm writing hosts Audio Units.  Many latest rev quite relevant 
Audio Units still only support a Carbon based AU view.  So at this point, 
without thumbing my nose at the plug-in industry, I have to support Carbon 
based 
Audio Unit views as well as Cocoa based Audio Unit views.

Cheers,
--aj


- Original Message 
From: Uli Kusterer 
To: Andrew James 
Cc: list-cocoa-dev 
Sent: Mon, January 31, 2011 1:39:21 AM
Subject: Re: Initializing NSWindow with Carbon window

On 30.01.2011, at 11:17, Andrew James wrote:
> I have a legacy builder class that creates a Carbon window and I want to 
> initialize an NSWindow with this WindowRef.

What for? What are you trying to achieve? Nonestly, I wouldn't recommend mixing 
Carbon and Cocoa windows in the same application. There are many subtle and 
not-so-subtle bugs (from window ordering issues, e.g. on app 
activation/deactivation, to weird behaviour when showing sheets, to the 
impossibility of correctly activating and deactivating menu items in both Cocoa 
and Carbon...).

The only case I've found works is having modal Cocoa windows in a Carbon 
application. All other things had this or that annoying issue, leak, or 
whatever.

If you want my recommendation: Save yourself the trouble and just start porting 
the whole window to Cocoa. I generally create a new window controller class, 
and 
then recreate everything from the original class in the new one in Cocoa, step 
by step, starting with one method (e.g. the constructor and setup methods) and 
then porting all the methods called by this one. The model behind everything 
stays the same. That ensures the behaviour even of complex windows isn't 
unintentionally modified. Of course, you will have to change some things, but 
at 
least this way you don't accidentally miss something.

That way, you can at least partially run the old code next to the new one and 
compare their behaviours, to make sure they're exactly the same.

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
___

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: Initializing NSWindow with Carbon window

2011-01-31 Thread Uli Kusterer
On Jan 31, 2011, at 4:57 PM, Andrew James wrote:
> The application I'm writing hosts Audio Units.  Many latest rev quite 
> relevant 
> Audio Units still only support a Carbon based AU view.  So at this point, 
> without thumbing my nose at the plug-in industry, I have to support Carbon 
> based 
> Audio Unit views as well as Cocoa based Audio Unit views.

 Ouch. That sucks. Good luck with that!

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."



___

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: Help Book authoring tool?

2011-01-31 Thread Ross Carter
On Jan 30, 2011, at 2:03 PM, Luc Van Bogaert wrote:

> Hello,
> 
> I would like to solicite some recommendations for an authoring tool to create 
> help books. I'm looking for a preferably freeware application, with a decent 
> html editor.

Well, there is Helpify, which uses Omni Outliner. Personally, I found it easier 
to write the HTML by hand.
___

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: NSTableView selecting text within a cell

2011-01-31 Thread Ross Carter
On Jan 31, 2011, at 12:30 AM, Ben Golding wrote:

> I have an app with a NSTableView where the data is presented to the user.  
> When the user hits "Find", I'd like to be able to scroll the table view to 
> the visible cell (easy enough) and then select the range that matched within 
> that field (not so easy).
> 
> At present, my code looks like:
> 
> NSCell *cell = [csvTableView preparedCellAtColumn:col row:row];
> NSText *textEditor = [csvWindow fieldEditor:YES forObject:cell];
> 
> NSLog(@"Match: row %@, field %@, range(%d, %d)", [match row], [match field], 
> [match range].location, [match range].length);
> [csvTableView scrollRowToVisible:row];
> [csvTableView scrollColumnToVisible:col];
> [textEditor setSelectedRange:[match range]];
> 
> I feel like I need to between getting the textEditor for the window and 
> calling -setSelectedRange:, I just don't know what.

Sounds like a case for selectWithFrame:inView:editor:delegate:start:length:
___

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: NSTableView selecting text within a cell

2011-01-31 Thread Corbin Dunn

On Jan 30, 2011, at 9:30 PM, Ben Golding wrote:

> 
> I have an app with a NSTableView where the data is presented to the user.  
> When the user hits "Find", I'd like to be able to scroll the table view to 
> the visible cell (easy enough) and then select the range that matched within 
> that field (not so easy).
> 
> At present, my code looks like:
> 
> NSCell *cell = [csvTableView preparedCellAtColumn:col row:row];

hi ben,
This simply returns a prepared cell; not a copied cell.

> NSText *textEditor = [csvWindow fieldEditor:YES forObject:cell];

This won't give you what you want; the field editor is used by the control, not 
the cell. In this case, it is the tableView. The prepared cell doesn't have a 
particular knowledge of where it is in the table; it is just setup to be used 
for drawing. So, asking for the fieldEditor of a cell doesn't make sense.

> 
> NSLog(@"Match: row %@, field %@, range(%d, %d)", [match row], [match field], 
> [match range].location, [match range].length);
> [csvTableView scrollRowToVisible:row];
> [csvTableView scrollColumnToVisible:col];
> [textEditor setSelectedRange:[match range]];
> 
> I feel like I need to between getting the textEditor for the window and 
> calling -setSelectedRange:, I just don't know what.

You need to begin an editing session first; call this:

- (void)editColumn:(NSInteger)column row:(NSInteger)row withEvent:(NSEvent 
*)theEvent select:(BOOL)select;

then ask for the field editor:

NSTextView *textEditor = [csvWindow fieldEditor:YES forObject:table];

Then do whatever selection you want on it.


corbin

> 
>   Ben.___
> 
> 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/corbind%40apple.com
> 
> This email sent to corb...@apple.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: Help Book authoring tool?

2011-01-31 Thread John Velman
On Sun, Jan 30, 2011 at 08:03:23PM +0100, Luc Van Bogaert wrote:
> Hello,
> 
> I would like to solicite some recommendations for an authoring tool to create 
> help books. I'm looking for a preferably freeware application, with a decent 
> html editor.
> 
> Thanks,
> 
> -- 
> Luc Van Bogaert


Once I found such an application somewhere at a Caltech website if I recall
correctly.  I didn't find it all that easy to use, and I can't find it
again.

Writing help books is intimidating at first, especially if you're not into
writing HTML, but once you understand a bit about the recommended structure
of help files, it isn't hard to put them together without a special app.  I
like to write plain text, so I use VIM with markdown, and a Haskell
application Pandoc to convert to html.   There are undoubtedly numerous
other combinations to do the same thing.

There are free HTML editors out there, if that's more to your taste than
plain text with markup.  I tried Amaya, as I recall, but went back to
Vim/Pandoc.

There is an Apple help-authoring mailing list.  Perhaps you should
subscibe.  Fairly low traffic.

Best,

John Velman

___

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: Initializing NSWindow with Carbon window

2011-01-31 Thread Kyle Sluder
On Mon, Jan 31, 2011 at 7:57 AM, Andrew James  wrote:
> The application I'm writing hosts Audio Units.  Many latest rev quite relevant
> Audio Units still only support a Carbon based AU view.  So at this point,
> without thumbing my nose at the plug-in industry, I have to support Carbon 
> based
> Audio Unit views as well as Cocoa based Audio Unit views.

In that case, you might consider asking your question on
coreaudio-api. The readers there might have better insight into the
nuances of implementing an AU host.

--Kyle Sluder
___

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: Help Book authoring tool?

2011-01-31 Thread Matt Neuburg
On Sun, 30 Jan 2011 20:03:23 +0100, Luc Van Bogaert  
said:
>Hello,
>
>I would like to solicite some recommendations for an authoring tool to create 
>help books. I'm looking for a preferably freeware application, with a decent 
>html editor.

I rolled my own:

http://www.apeth.com/RubyFrontierDocs/

m.

--
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.apeth.net/matt/default.html#applescriptthings___

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: Tab bar controller inside a navigation controller, how to adjust the view height

2011-01-31 Thread Matt Neuburg
On Mon, 31 Jan 2011 20:29:47 +0800, ico  said:
>I am trying to implement an app similar as "tweetie" applicatin, use
>UIViewController to implement a custom TabBarController that can be pushed
>in a navigation stack. This has been discussed before as shown here:
>
>http://stackoverflow.com/questions/576764/tab-bar-controller-inside-a-navigation-controller-or-sharing-a-navigation-root-v
>
>
>My app running well except for 1 problem. That is if the app receive the
>memory warning message, and one of the view in the tabbar, say this tabbar
>has 3 tabs, the first one's view(a table view) is released as it is not
>active when the app receive the memory warning message, then when user tap
>the first tab to come back with the first view, viewLoad and viewDidLoad
>method is called, but the view's height is not correct. I figure out the
>reason, that is when the tabbar get pushed into the navigation stack, the
>view will automatically subtract the navigationbar height from the view
>height, so that the tableview's height is correct. However, if the view is
>released and come back to it, the tableview's height is not correct anymore
>because it does not adjust the height by minus the navigationbar's height.
>Even though I know the reason, but I can't find a solution to fix it. Any
>help will be appreciated.

You're not supposed to put a tab bar interface inside a navigation interface. A 
solution that works, and that will avoid the problem you're having, is to 
present the tab bar interface modally.

If you're not willing to do that, then you might try to implement 
didReceiveMemoryWarning and just return - thus preventing the view from being 
unloaded. 

m.

--
matt neuburg, phd = m...@tidbits.com, 
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.apeth.net/matt/default.html#applescriptthings___

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: Help Book authoring tool?

2011-01-31 Thread Warren Dodge
On Jan 30, 2011, at 11:03 AM, Luc Van Bogaert wrote:
> Hello,
> 
> I would like to solicite some recommendations for an authoring tool to create 
> help books. I'm looking for a preferably freeware application, with a decent 
> html editor.
> 
> Thanks,


An article on using VoodooPad
http://www.manton.org/2009/09/voodoopad_help_update.html

An article on using RapidWeaver
http://www.bernard-web.com/pierre/blog/index.php?id=1026707120109018779

Warren

___

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: what are the disadvantages in keeping libraries and input files inside app bundle

2011-01-31 Thread Paul M


On 29/01/2011, at 2:08 AM, Dave Carrigan wrote:

This is the preferred method of deployment. Experienced Mac users hate 
it when an installation scatters crud all over the filesystem. You 
should especially not be polluting /usr/local/lib.


The sole reason for the existance of /usr/local/lib is to hold 
libraries used by user installed apps.




Dave Carrigan
Seattle, WA

On Jan 28, 2011, at 2:56 AM, "Abhijeet Singh"  wrote:

Hi,I have number of static and dynamic libraries in my application. 
At present i have kept all the libraries in "\usr\local\lib" folder. 
I was wondering whether it would be a good idea to keep all these 
libraries inside the application bundle itself? Similarly there are 
number of input files that my application uses. At present these 
files are kept in "Library/Application Support/MyApp" folder. These 
files also be kept inside the bundle.The advantage with this approach 
is I dont need to create different directories on target machine at 
the time of deployment since all the user data is inside the app 
bundle itself.What could be the major disadvantages of this 
approach?Thanks & Regards AbhijeetDear cocoadev ! Get Yourself a 
cool, short @in.com Email ID now!

___



paulm

___

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: Help Book authoring tool?

2011-01-31 Thread Jerry Krinock
You should look at some of the solutions which have been suggested, and try 
*really hard* to accept them as they are, or with minor modifications if they 
are open-sourced.  Unfortunately, I was unable to do so, and succumbed to the 
temptation to roll my own, as others have done.  It works great, I enjoy 
writing Perl, and I love it, but it used up two weeks of my life that could 
better have been spent writing Cocoa code.

___

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


text orientation/positioning with layout manager

2011-01-31 Thread Todd Heberlein
I'm doing a simple experiment using NSTextStorage, NSLayoutManager, 
NSTextContainer to draw some text (I am basing this on the CircleView example 
because I want some of that orientation power later).

I have found that when rendering the text using 
drawGlyphsForGlyphRange:atPoint:, I don't get the text where I expected. It is 
higher than I expect. Furthermore, when I draw a rectangle around the text (or 
try to) using the rectangle from usedRectForTextContainer:, the text is outside 
the rectangle (in short, the rectangle is where I expect it to be, but the text 
glyphs are not).

Is there a secret incantation that I am missing?

Thanks,

Todd

Basic code snippet:

point = NSMakePoint(1.0, 1.0);
glyphRange = [layoutManager glyphRangeForTextContainer:textContainer];
usedRect = [layoutManager usedRectForTextContainer:textContainer];
usedRect.origin = point;

[layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:point];
[[NSBezierPath bezierPathWithRect: rect] stroke];
___

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: text orientation/positioning with layout manager

2011-01-31 Thread Douglas Davidson
The layout manager expects to be drawing within a flipped context.

Douglas Davidson

On Jan 31, 2011, at 2:09 PM, Todd Heberlein wrote:

> I'm doing a simple experiment using NSTextStorage, NSLayoutManager, 
> NSTextContainer to draw some text (I am basing this on the CircleView example 
> because I want some of that orientation power later).
> 
> I have found that when rendering the text using 
> drawGlyphsForGlyphRange:atPoint:, I don't get the text where I expected. It 
> is higher than I expect. Furthermore, when I draw a rectangle around the text 
> (or try to) using the rectangle from usedRectForTextContainer:, the text is 
> outside the rectangle (in short, the rectangle is where I expect it to be, 
> but the text glyphs are not).
> 
> Is there a secret incantation that I am missing?
> 
> Thanks,
> 
> Todd
> 
> Basic code snippet:
> 
> point = NSMakePoint(1.0, 1.0);
> glyphRange = [layoutManager glyphRangeForTextContainer:textContainer];
> usedRect = [layoutManager usedRectForTextContainer:textContainer];
> usedRect.origin = point;
> 
> [layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:point];
> [[NSBezierPath bezierPathWithRect: rect] stroke];
> ___
> 
> 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/ddavidso%40apple.com
> 
> This email sent to ddavi...@apple.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


Main menu in NSDocument based application

2011-01-31 Thread Bruce Cresanta
Hello,

I've been scouring through the docs trying to figure out how to get a 
reference to the main menu in an NSDocument based app.I need to make 
programmatic changes to the menu depending on which NSDocument is key.   Would 
you please help me find a pointer to the main menu?

Thank you,

Bruce
___

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: Main menu in NSDocument based application

2011-01-31 Thread Lee Ann Rucker

On Jan 31, 2011, at 2:25 PM, Bruce Cresanta wrote:

> Hello,
> 
>   I've been scouring through the docs trying to figure out how to get a 
> reference to the main menu in an NSDocument based app.I need to make 
> programmatic changes to the menu depending on which NSDocument is key.   
> Would you please help me find a pointer to the main menu?

NSDocument validateUserInterfaceItem: will probably give you everything you 
need. There's seldom a need to update a menu before it asks to be updated. 

If you find you must use the main menu, the method you need is conveniently 
named mainMenu. One of my favorite tricks for finding new things is to set 
XCode's documentation search mode to "prefix" and type something 
likely.___

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: Main menu in NSDocument based application

2011-01-31 Thread Sherm Pendley
On Mon, Jan 31, 2011 at 5:25 PM, Bruce Cresanta  wrote:
>
>        I've been scouring through the docs trying to figure out how to get a 
> reference to the main menu in an NSDocument based app.    I need to make 
> programmatic changes to the menu depending on which NSDocument is key.   
> Would you please help me find a pointer to the main menu?

What kind of changes? In general, adding and removing menu items is
discouraged in Mac apps. Disabling menu items that don't apply to the
current document and/or selection is the preferred approach, and for
that you don't need a pointer to the menu. The current document is in
the responder chain, so if it doesn't respond to a menu item's action
message, that menu item will be disabled automatically. For more
detailed control, for example to disable a menu item based on the
current selection in a document, one can write a -validateMenuItem:
method to decide whether the given menu item should be enabled or not.

I'm not trying to give you the "HIG lecture," I'm just saying -
depending on what you want to do, there might be an easier way to do
it that doesn't actually need a pointer to the main menu. On the other
hand, there are certainly reasons to alter the main menu in other ways
that *do* require such a pointer. So, if you do need it, there's
NSApplications's mainMenu method, which you can call using the NSApp
global, as in:

  NSMenu *menu = [NSApp mainMenu];

sherm--

-- 
Cocoa programming in Perl:
http://camelbones.sourceforge.net
___

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: Main menu in NSDocument based application

2011-01-31 Thread Bruce Cresanta
Thank you,

I needed to know about the responder chain...  The thing is well thought out. 

Bruce


On Jan 31, 2011, at 3:43 PM, Sherm Pendley wrote:

> On Mon, Jan 31, 2011 at 5:25 PM, Bruce Cresanta  wrote:
>> 
>>I've been scouring through the docs trying to figure out how to get a 
>> reference to the main menu in an NSDocument based app.I need to make 
>> programmatic changes to the menu depending on which NSDocument is key.   
>> Would you please help me find a pointer to the main menu?
> 
> What kind of changes? In general, adding and removing menu items is
> discouraged in Mac apps. Disabling menu items that don't apply to the
> current document and/or selection is the preferred approach, and for
> that you don't need a pointer to the menu. The current document is in
> the responder chain, so if it doesn't respond to a menu item's action
> message, that menu item will be disabled automatically. For more
> detailed control, for example to disable a menu item based on the
> current selection in a document, one can write a -validateMenuItem:
> method to decide whether the given menu item should be enabled or not.
> 
> I'm not trying to give you the "HIG lecture," I'm just saying -
> depending on what you want to do, there might be an easier way to do
> it that doesn't actually need a pointer to the main menu. On the other
> hand, there are certainly reasons to alter the main menu in other ways
> that *do* require such a pointer. So, if you do need it, there's
> NSApplications's mainMenu method, which you can call using the NSApp
> global, as in:
> 
>  NSMenu *menu = [NSApp mainMenu];
> 
> sherm--
> 
> -- 
> Cocoa programming in Perl:
> http://camelbones.sourceforge.net

___

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


worker thread iterating over array - SLOW

2011-01-31 Thread Peter Lübke

Hi list,

I use a worker thread in my app that invokes the same method(s) on  
all objects in an array sent from the main thread. The array may  
contain thousands of objects.
The main thread communicates with the worker thread via distributed  
objects.


Everything works fine except performance is too slow.
Seems to me that my NSConnection asks for the method signature each  
time the method is invoked on an object in the array, thus adding  
massive overhead.


The shared objects approach - call NSThread's - 
detachNewThreadSelector:toTarget:withObject: with the array as  
argument 3, have the secondary thread do the job and exit - is way  
faster!


I just started using DO and probably missed more than one thing, so  
any help is very much appreciated.


- Peter
___

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: text orientation/positioning with layout manager

2011-01-31 Thread Graham Cox

On 01/02/2011, at 9:09 AM, Todd Heberlein wrote:

> I'm doing a simple experiment using NSTextStorage, NSLayoutManager, 
> NSTextContainer to draw some text (I am basing this on the CircleView example 
> because I want some of that orientation power later).
> 
> I have found that when rendering the text using 
> drawGlyphsForGlyphRange:atPoint:, I don't get the text where I expected. It 
> is higher than I expect. Furthermore, when I draw a rectangle around the text 
> (or try to) using the rectangle from usedRectForTextContainer:, the text is 
> outside the rectangle (in short, the rectangle is where I expect it to be, 
> but the text glyphs are not).
> 
> Is there a secret incantation that I am missing?


One thing that caught me out at first was that text is laid out based on the 
top, left of the glyph's bounding box, not on some notional baseline. The 
glyphs are positioned so that the baselines line up, but this is done by 
offsetting the top edge of the bbox. So if you assume that it's the baseline 
you're setting, text will be placed generally higher than expected. Is that 
what's happening?

--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: text orientation/positioning with layout manager

2011-01-31 Thread Aki Inoue
The precise definition of the point specified by the argument is the top left 
corner of the text container containing the glyph range in the focused view 
coordinate system.

Aki

On Jan 31, 2011, at 3:18 PM, Graham Cox wrote:

> 
> On 01/02/2011, at 9:09 AM, Todd Heberlein wrote:
> 
>> I'm doing a simple experiment using NSTextStorage, NSLayoutManager, 
>> NSTextContainer to draw some text (I am basing this on the CircleView 
>> example because I want some of that orientation power later).
>> 
>> I have found that when rendering the text using 
>> drawGlyphsForGlyphRange:atPoint:, I don't get the text where I expected. It 
>> is higher than I expect. Furthermore, when I draw a rectangle around the 
>> text (or try to) using the rectangle from usedRectForTextContainer:, the 
>> text is outside the rectangle (in short, the rectangle is where I expect it 
>> to be, but the text glyphs are not).
>> 
>> Is there a secret incantation that I am missing?
> 
> 
> One thing that caught me out at first was that text is laid out based on the 
> top, left of the glyph's bounding box, not on some notional baseline. The 
> glyphs are positioned so that the baselines line up, but this is done by 
> offsetting the top edge of the bbox. So if you assume that it's the baseline 
> you're setting, text will be placed generally higher than expected. Is that 
> what's happening?
> 
> --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/aki%40apple.com
> 
> This email sent to a...@apple.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: worker thread iterating over array - SLOW

2011-01-31 Thread Peter Lübke


Am 01.02.2011 um 00:20 schrieb A.M.:



On Jan 31, 2011, at 6:13 PM, Peter Lübke wrote:


Hi list,

I use a worker thread in my app that invokes the same method(s) on  
all objects in an array sent from the main thread. The array may  
contain thousands of objects.
The main thread communicates with the worker thread via  
distributed objects.


Everything works fine except performance is too slow.
Seems to me that my NSConnection asks for the method signature  
each time the method is invoked on an object in the array, thus  
adding massive overhead.


The shared objects approach - call NSThread's - 
detachNewThreadSelector:toTarget:withObject: with the array as  
argument 3, have the secondary thread do the job and exit - is way  
faster!


I just started using DO and probably missed more than one thing,  
so any help is very much appreciated.


Did you set the root proxy protocol?
-[NSDistantObject setProtocolForProxy:]



I can -setProtocolForProxy: for the proxy for the array, but I can't  
do it for the objects in the array, right?



Perhaps you could also look at -[NSRunLoop  
performSelector:onThread:withObject:waitUntilDone:].



You probably meant -[NSObject  
performSelector:onThread:withObject:waitUntilDone:].


The -performSelector:... methods don't offer the flexibility I need  
here, so I'll rather have to go for NSInvocation.
Besides from this, I'd like my app to continue running in Tiger, and  
unfortunately, in Tiger there's only - 
performSelectorOnMainThread:... . methods.


Cheers,
Peter




___

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


New to internationalization

2011-01-31 Thread Bruce Cresanta
Hello,

I would like to internationalize my app.   Does anyone know of a good 
tutorial.   The docs are pretty good, but a tutorial would be helpful.   I plan 
to target 2 languages to begin with.

Thanks,

Bruce
___

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: worker thread iterating over array - SLOW

2011-01-31 Thread Ken Thomases
On Jan 31, 2011, at 5:13 PM, Peter Lübke wrote:

> I use a worker thread in my app that invokes the same method(s) on all 
> objects in an array sent from the main thread. The array may contain 
> thousands of objects.
> The main thread communicates with the worker thread via distributed objects.
> 
> Everything works fine except performance is too slow.
> Seems to me that my NSConnection asks for the method signature each time the 
> method is invoked on an object in the array, thus adding massive overhead.

Well, that's part of it, but probably not the biggest part.

The way you're using D.O. defeats the purpose of having a worker thread.

Sending the array from the main thread to the worker thread causes the worker 
thread to receive a proxy for the array.  Then, as you request each element of 
the array, that's a message to the main thread and back, and what you get is... 
a proxy for the element (not the element itself).  Then, every operation you 
perform on the element is a message to the main thread _and the main thread 
performs the work on behalf of its "client"_.

So, you have effectively failed to shift the work from the main thread to the 
worker thread.  The main thread is a "server" doing all of the work on the 
behalf of its client, the worker thread.

If you're going to use D.O., ideally you want the messages to either carry no 
data or to carry data values (bycopy), not references to objects.  Also, you 
want to design a fairly coarse-grained protocol of requests that a client can 
make of the server -- few requests to do some big chunks of work, not many 
requests for small chunks of work.


> The shared objects approach - call NSThread's 
> -detachNewThreadSelector:toTarget:withObject: with the array as argument 3, 
> have the secondary thread do the job and exit - is way faster!

Is there a reason that's not sufficient?  Why are you trying to use D.O.?

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


iPhone puzzle about rotation

2011-01-31 Thread David Rowland
I create a minimal view-based app from an Xcode template, and I implement these 
UIViewController methods,

- 
(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
 {
   return YES;
}

- 
(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
 duration:(NSTimeInterval)duration
{
}


I put breakpoints on them, and they behave more of less as I expect:

1) shouldAutorotateToInterfaceOrientation  is called on launch.
2) When I rotate the device (Simulator) it is called again and then 
willRotateToInterfaceOrientation is called.

The same thing works in one of my applications.

My problem is with another application that works like this,

1) shouldAutorotateToInterfaceOrientation  is called on launch.
2) When I rotate the device, nothing happens.


Is there something that defeats the delivery of rotate events to a view 
controller?


thanks for any help,

David

___

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