Glyph from Character
Glyph from Character
- Subject: Glyph from Character
- From: Gordon Apple <email@hidden>
- Date: Wed, 21 Mar 2007 13:27:11 -0500
> Send Cocoa-dev mailing list submissions to
> email@hidden
>
> To subscribe or unsubscribe via the World Wide Web, visit
> http://lists.apple.com/mailman/listinfo/cocoa-dev
> or, via email, send a message with subject or body 'help' to
> email@hidden
>
> You can reach the person managing the list at
> email@hidden
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of Cocoa-dev digest..."
>
>
> Today's Topics:
>
> 1. Re: NSBezierPath Arc bug, intel. (Michael Watson)
> 2. Re: NSBezierPath Arc bug, intel. (Half Activist)
> 3. making a custom view not grab the keyboard (Artemiy Pavlov)
> 4. How can I combine 2 data buffers? (Yevgeniy Goldberg)
> 5. RE: Embedding a WebView in a Table (Christopher Hickman)
> 6. Re: Embedding a WebView in a Table (I. Savant)
> 7. Re: How to detect main menu being opened (Doug F)
> 8. Re: Embedding a WebView in a Table (Adam R. Maxwell)
> 9. Displaying Cocoa NIBs from Carbon? (Patrick M)
> 10. Application Caches (Ryan Homer)
> 11. Re: Displaying Cocoa NIBs from Carbon? (Eric Schlegel)
> 12. Problem with NSImageCell and -setImageScaling (Glenn Zelniker)
> 13. Re: Problem with NSImageCell and -setImageScaling (Stephen Deken)
> 14. Re: How to add my cocoa app at system preferences others
> categary (Nick Zitzmann)
> 15. Re: How can I combine 2 data buffers? (Nick Zitzmann)
> 16. Re: Application Caches (Nick Zitzmann)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Wed, 21 Mar 2007 09:53:02 -0400
> From: Michael Watson <email@hidden>
> Subject: Re: NSBezierPath Arc bug, intel.
> To: Half Activist <email@hidden>
> Cc: email@hidden
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> Can you post the code *you* use specifically to draw the path?
>
>
> --
> m-s
>
> On 21 Mar, 2007, at 09:26, Half Activist wrote:
>
>> Hi All,
>>
>> I'm currently drawing a round rectangle with arcs.
>> When drawing direclty to the screen, I get round rectangles.
>> When I lock the focus on an nsimage, the rectanlges aren't
>> rounded, but this only happens on intel macs,
>> powerpc macs have no problem.
>>
>> I use the code that comes from this page:
>> http://www.cocoadev.com/index.pl?RoundedRectangles
>>
>> Regards
>> _______________________________________________
>>
>> Cocoa-dev mailing list (email@hidden)
>>
>> 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:
>> 40bungie.org
>>
>> This email sent to email@hidden
>
>
>
> ------------------------------
>
> Message: 2
> Date: Wed, 21 Mar 2007 15:03:43 +0100
> From: Half Activist <email@hidden>
> Subject: Re: NSBezierPath Arc bug, intel.
> To: Michael Watson <email@hidden>, email@hidden
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> Yeah, there it goes:
> PS: It works on PowerPCs, not on intel, the rectangles a normal, not
> rounded.
>
> Somewhere I created a category to extend NSBezierPath
>
> @implementation NSBezierPath (RoundedRectCategory)
> + (NSBezierPath *) bezierPathWithRoundRectInRect:(NSRect)rect radius:
> (float) radius
> {
> NSBezierPath *path;
> NSRect inner_rect;
>
> inner_rect = NSInsetRect(rect, radius, radius);
>
> path = [NSBezierPath bezierPath];
>
> [path moveToPoint:NSMakePoint(rect.origin.x+rect.size.width/2.0,
> rect.origin.y+rect.size.height)];
>
> [path appendBezierPathWithArcWithCenter:NSMakePoint
> (inner_rect.origin.x, inner_rect.origin.y + inner_rect.size.height)
> radius: radius startAngle: 90.0 endAngle: 180.0];
>
> [path appendBezierPathWithArcWithCenter:inner_rect.origin radius:
> radius startAngle: 180.0 endAngle:270.0];
>
> [path appendBezierPathWithArcWithCenter:NSMakePoint
> (inner_rect.origin.x + inner_rect.size.width, inner_rect.origin.y)
> radius: radius startAngle: 270.0 endAngle:360.0];
>
> [path appendBezierPathWithArcWithCenter:NSMakePoint
> (inner_rect.origin.x + inner_rect.size.width, inner_rect.origin.y +
> inner_rect.size.height) radius: radius startAngle: 0.0 endAngle:90.0];
>
> [path closePath];
>
> return path;
> }
>
>
> @end
>
> Somewhere else, i draw a rectangle onto an nsimage
>
> NSImage *imageRoundRect( NSColor *backgroundColor, NSColor
> *strokeColor, NSSize size, float roundCornerRadius )
> {
> if( backgroundColor == nil || strokeColor == nil || NSEqualSizes
> ( size, NSZeroSize ) )
> return nil;
>
> NSRect frame;
> frame.origin = NSZeroPoint;
> frame.size = size;
>
> frame = NSInsetRect( frame, 1.0, 1.0 );
> if( (roundCornerRadius * 2.0) > frame.size.height )
> roundCornerRadius = frame.size.height / 2.0;
> if( (roundCornerRadius * 2.0) > frame.size.width )
> roundCornerRadius = frame.size.width / 2.0;
>
> NSImage *newImage = [ [ NSImage alloc ] initWithSize: size ];
> [ newImage setBackgroundColor: [ NSColor clearColor ] ];
>
> [ newImage lockFocus ];
>
> // Drawing the image
> NSBezierPath *p = [ NSBezierPath bezierPathWithRoundRectInRect:
> frame radius: roundCornerRadius ];
> [ backgroundColor setFill ];
> [ p fill ];
> [ strokeColor setStroke ];
> [ p stroke ];
>
> [ newImage unlockFocus ];
>
> return [ newImage autorelease ];
> }
>
>
>
>
> On Mar 21, 2007, at 2:53 PM, Michael Watson wrote:
>
>> Can you post the code *you* use specifically to draw the path?
>>
>>
>> --
>> m-s
>>
>> On 21 Mar, 2007, at 09:26, Half Activist wrote:
>>
>>> Hi All,
>>>
>>> I'm currently drawing a round rectangle with arcs.
>>> When drawing direclty to the screen, I get round rectangles.
>>> When I lock the focus on an nsimage, the rectanlges aren't
>>> rounded, but this only happens on intel macs,
>>> powerpc macs have no problem.
>>>
>>> I use the code that comes from this page:
>>> http://www.cocoadev.com/index.pl?RoundedRectangles
>>>
>>> Regards
>>> _______________________________________________
>>>
>>> Cocoa-dev mailing list (email@hidden)
>>>
>>> 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:
>>> 40bungie.org
>>>
>>> This email sent to email@hidden
>>
>
>
>
> ------------------------------
>
> Message: 3
> Date: Wed, 21 Mar 2007 16:23:20 +0200
> From: Artemiy Pavlov <email@hidden>
> Subject: making a custom view not grab the keyboard
> To: ML Cocoa Cocoa <email@hidden>
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> Hello all!
>
> I have an Audio Unit plugin with a Cocoa view. Whichever application
> hosts it, the view grabs the keyboard, so that for example the space
> bar doesn't launch playback until you click on the host's main window
> to make it active. Can I somehow make my Cocoa view not grab the
> keyboard?
>
> Thanks for any tips!
>
>
> Best wishes,
>
> Artemiy.
>
>
> ------------------------------
>
> Message: 4
> Date: Wed, 21 Mar 2007 09:26:37 -0500
> From: Yevgeniy Goldberg <email@hidden>
> Subject: How can I combine 2 data buffers?
> To: email@hidden
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> Greetings!
> I need to be able to combine 2 data buffers into 1.
> What is the technique for doing that?
> Let's say, I have buf1 with 5K of data in it and I need to prepend it
> with another 2K worth of 0.00.
>
> Thanks for any help :)
>
> -Eugene
>
>
> ------------------------------
>
> Message: 5
> Date: Wed, 21 Mar 2007 10:51:04 -0400
> From: "Christopher Hickman" <email@hidden>
> Subject: RE: Embedding a WebView in a Table
> To: "'Steve Israelson'" <email@hidden>, "'Adam R. Maxwell'"
> <email@hidden>
> Cc: 'Cocoa mailing list' <email@hidden>
> Message-ID: <001f01c76bc8$5bbd43b0$email@hidden>
> Content-Type: text/plain; charset="us-ascii"
>
> http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Clas
> ses/NSAttributedString_AppKitAdditions/Reference/Reference.html
>
> -----Original Message-----
> From: cocoa-dev-bounces+tophu=email@hidden
> [mailto:cocoa-dev-bounces+tophu=email@hidden] On Behalf Of Steve
> Israelson
> Sent: Wednesday, March 21, 2007 3:44 AM
> To: Adam R. Maxwell
> Cc: Cocoa mailing list
> Subject: Re: Embedding a WebView in a Table
>
> No, I have not tried that, but I will.
> If only there was some docs on what it can do.
> One liners like it inits with html is not enough to tell me much.
>
> On 20-Mar-07, at 10:24 PM, Adam R. Maxwell wrote:
>
>>
>> On Mar 20, 2007, at 22:06, I. Savant wrote:
>>
>>> On Mar 21, 2007, at 12:41 AM, Steve Israelson wrote:
>>>
>>>> Well, the drawing is simplistic.
>>>> Item things like Name : Joe Number of items: 25
>>>> In an html table.
>>>> Maybe an image or 2.
>>>> Themeable using custom CSS supplied by the user.
>>>> ...
>>>
>>> Okay, so your goal is to create some kind of a themeable list
>>> view. Now we're getting somewhere; WebKit is definitely the path
>>> of least resistance, but is kind of heavyweight and you're looking
>>> for optimization.
>>
>> Have you tried NSAttributedString's initWithHTML... methods?
>> Drawing attributed strings in table cells should be much easier
>> than drawing with a WebView.
>>
>> -- Adam
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> 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:
>
> This email sent to email@hidden
>
>
>
> ------------------------------
>
> Message: 6
> Date: Wed, 21 Mar 2007 10:51:56 -0400
> From: "I. Savant" <email@hidden>
> Subject: Re: Embedding a WebView in a Table
> To: "Adam R. Maxwell" <email@hidden>
> Cc: Cocoa mailing list <email@hidden>, Steve Israelson
> <email@hidden>
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> On Mar 21, 2007, at 1:24 AM, Adam R. Maxwell wrote:
>> Have you tried NSAttributedString's initWithHTML... methods?
>> Drawing attributed strings in table cells should be much easier
>> than drawing with a WebView.
>
> I thought I read somewhere that it doesn't handle CSS (either well
> or at all). I haven't tried it myself, so I can't verify.
>
>
> --
> I.S.
>
>
>
>
>
> ------------------------------
>
> Message: 7
> Date: Wed, 21 Mar 2007 11:15:00 -0400
> From: Doug F <email@hidden>
> Subject: Re: How to detect main menu being opened
> To: Cocoa List <email@hidden>
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> Hello all,
>
> I handled this in a less-than-perfect way that uses some undocumented
> functionality. It now works as expected, except it does not work if
> focus is merely put onto the menu bar (e.g., with Control-F2).
>
> The relevant code snippets from my application's main controller
> object are below. (This is archived and restored in the MainMenu.nib,
> initial NIB.)
>
> Clearly, one should have a const NSString
> *menuTrackingNotificationName defined up top and used for good style
> and practice.
>
> Cheers,
>
> Doug
>
> /** Set up some notification watchers **/
> - (void)applicationDidFinishLaunching:(NSNotification *)aNotification
> {
> NSLog(@"applicationDidFinishLaunching");
>
> // Watch for the main menu being opened
> // Determined this using Notification Watcher
> [[NSDistributedNotificationCenter defaultCenter]
> addObserver:self
> selector:@selector(menuOpened:)
>
> name:@"com.apple.HIToolbox.beginMenuTrackingNotification"
> object:nil];
> }
>
> /** Removes some notifications **/
> - (void)applicationWillTerminate:(NSNotification *)aNotification
> {
> // Undo the registration from above
> [[NSDistributedNotificationCenter defaultCenter]
> removeObserver:self
>
> name:@"com.apple.HIToolbox.beginMenuTrackingNotification"
> object:nil];
> }
>
> /** We get this from a distributed notification set up at app launch **/
> // This works, but seems to be undocumented
> - (void)menuOpened:(id)dontKnowWhatThisParameterIs
> {
> NSLog(@"Menu opened");
> [gameModel pause];
> }
>
> On Mar 20, 2007, at 1:17 PM, Doug F wrote:
>
>> Hello all,
>>
>> Is there any API that will tell me when the user has opened any of
>> the main menu bar's menus (including the Apple menu)? I want to
>> "pause" my application's timers and update some state when this
>> occurs, but I haven't figured out a reliable way.
>>
>> My first idea almost worked for all menus except the system-Apple
>> menu. I set up a delegate for each menu and implemented
>> - (void)menuNeedsUpdate:(NSMenu *)menu
>> which then called my "pause" routine. (Incidentally, setting the
>> delegate of the whole main menu did NOT ever call the above
>> routine; I had to set the delegate of each menu individually in
>> Interface Builder.)
>>
>> This failed because one of my menu items was a "Pause" menu with a
>> hotkey. As it turns out, hitting this hotkey causes
>> "menuNeedsUpdate" to be invoked prior to the target/action being
>> called, which pauses things and updates the menu to modify the menu
>> item to be a "resume" (with the same hotkey (modifies the title
>> only)), so when the hotkey target/action was called, that turned
>> right around and unpaused things! That was a fun thing to figure out.
>>
>> Bigger picture, though: It also fails because there is no way to
>> determine if the system-Apple menu has been opened.
>>
>> So, I need a way to generate some sort of event or target/action
>> when ANY menu is opened (via click or, even, Control-F2 to focus on
>> the menu bar) so I can pause my application.
>>
>> Would anyone have any ideas, please? I've looked at the PDFs of
>> Apple docs, Googled and Cocoadev'd and Cocoabuildered and either my
>> search abilities suck or I'm just oblivious.
>
>
>
> ------------------------------
>
> Message: 8
> Date: Wed, 21 Mar 2007 08:18:14 -0700
> From: "Adam R. Maxwell" <email@hidden>
> Subject: Re: Embedding a WebView in a Table
> To: "I. Savant" <email@hidden>
> Cc: Cocoa mailing list <email@hidden>, Steve Israelson
> <email@hidden>
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes
>
>
> On Mar 21, 2007, at 07:51, I. Savant wrote:
>
>> On Mar 21, 2007, at 1:24 AM, Adam R. Maxwell wrote:
>>> Have you tried NSAttributedString's initWithHTML... methods?
>>> Drawing attributed strings in table cells should be much easier
>>> than drawing with a WebView.
>>
>> I thought I read somewhere that it doesn't handle CSS (either well
>> or at all). I haven't tried it myself, so I can't verify.
>
> If the CSS in the same file/data, it works AFAIR, but haven't looked
> at it for a while. NSAttributedString uses WebKit underneath on
> 10.4+, so it at least has potential for pretty complete support (you
> can specify a WebResourceLoadDelegate as well).
>
> -- adam
>
>
> ------------------------------
>
> Message: 9
> Date: Wed, 21 Mar 2007 11:38:55 -0400
> From: "Patrick M" <email@hidden>
> Subject: Displaying Cocoa NIBs from Carbon?
> To: email@hidden, email@hidden
> Message-ID:
> <email@hidden>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> I have a carbon application that displays several windows.
>
> I am adding a feature to display another window and I would like to use the
> nice Cocoa NIB stuff to make my life easier, but I cannot seem to get the
> Cocoa NIB to load properly from my carbon code.
>
> I have investigated this and found the Apple "
> http://developer.apple.com/samplecode/CocoaInCarbon" sample that was no
> help.
>
> I get an error on the CreateWindowFromNib call, it returns -10, and I have
> only seen ONE reference to this error for this function in all my searches,
> what does this error mean and can I even get a full featured Cocoa NIB to be
> displayed using Carbon APIs in manner attempted below?
>
> Failing that, is there any better documentation about the differences
> between Carbon and Cocoa NIBs (other than the obvious: Carbon requires an
> explicit handler and Cocoa does not).
>
> I do not want to call the NIB functions from Carbon (as is done in the
> sample), I want the Cocoa NIB to handle all messages and have control return
> to the function below after the user is finished interacting with the Cocoa
> window/dialog. The window/dialog will update things (data etc...) as
> needed, and the calling function below does not need to know what was done
> at all.
>
> The Nib "MyNib" and the window "MyWindow" in the nib do exist.
>
> void showWindow() {
>
> IBNibRef nibRef;
> WindowRef windowRef;
> OSStatus retError = noErr;
>
> if (noErr == CreateNibReference(CFSTR("MyNib"), &nibRef)) {
> if (noErr == (retError = CreateWindowFromNib(nibRef,
> CFSTR("MyWindow"), &windowRef))) {
> ShowWindow(windowRef);
> BringToFront(windowRef);
> RunAppModalLoopForWindow(windowRef);
> HideWindow(windowRef);
> DisposeWindow(windowRef);
> }
> DisposeNibReference(nibRef);
> }
> }
>
>
> ------------------------------
>
> Message: 10
> Date: Wed, 21 Mar 2007 11:40:59 -0400
> From: Ryan Homer <email@hidden>
> Subject: Application Caches
> To: Apple Cocoa-Dev Mailing List <email@hidden>
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> Many applications make use of a cache stored in ~/Library/Cache/...
>
> Is there a Cocoa framework to go with this that helps to store/
> retrieve information in there or is this just a convention and you're
> responsible for creating your own files, etc.?
>
> Thanks!
>
>
>
> ------------------------------
>
> Message: 11
> Date: Wed, 21 Mar 2007 08:44:51 -0700
> From: Eric Schlegel <email@hidden>
> Subject: Re: Displaying Cocoa NIBs from Carbon?
> To: Patrick M <email@hidden>
> Cc: email@hidden, email@hidden
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
>
> On Mar 21, 2007, at 8:38 AM, Patrick M wrote:
>
>> I get an error on the CreateWindowFromNib call, it returns -10, and
>> I have only seen ONE reference to this error for this function in
>> all my searches, what does this error mean and can I even get a
>> full featured Cocoa NIB to be displayed using Carbon APIs in manner
>> attempted below?
>
> You'll need to use the Cocoa functions for creating your window from
> a nib. The Carbon nib functions do not work with Cocoa nibs.
>
> -eric
>
>
>
> ------------------------------
>
> Message: 12
> Date: Wed, 21 Mar 2007 12:05:06 -0400
> From: Glenn Zelniker <email@hidden>
> Subject: Problem with NSImageCell and -setImageScaling
> To: Apple Mailing List <email@hidden>
> Message-ID: <email@hidden>
> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed
>
> I'm having a strange problem with an NSImageCell. Here's code snippet:
>
>
> NSImageCell *imCell = [[NSCell alloc] initImageCell:myImage]];
>
> [imCell setImageScaling:NSScaleToFit];
>
>
> This compiles fine without any warnings, but when it runs I get an
> exception that looks like this:
>
> ****** -[NSCell setImageScaling:]: selector not recognized.
>
> I don't understand why the image cell looks like an NSCell (although
> I guess it's because NSImageCell is part of a class cluster). How can
> I get this to work?
>
>
> Glenn Z
Simple question, to which I've found a multitude of ridiculously complex
answers in the archives. I just want the Bezier path of a character, e.g.,
"A", "?", "&".
[path appendBezierPathWithGlyph:(NSGlyph)something(@"A")
infont:[NSFont systemFontOfSize:400];
There must be a simple function "something" that will map the glyph
index of a given character. What is it?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden