My News: TOP - Autos Intimate goods Chairs Underwear Ladies handbag Bracelets Sportswear Top auto-moto furniture Dating Boots FDA Approved Pharmacy Boats Necklace Yachts Medical tests Suits Medicine news Building materials Top casino Rington ya.by Tunings Sale Auto Chronometer Blog Search the Web Cases Mobiles Cigarettes Cars auto-moto Ear rings Cigarette Green Card Information
uncommonplace
 

    Follow me

     Round trip integrity
    Filed under: — David @ 6:46 pm

    Today I wrote an “Open Recent” feature to mimic what’s available in Cocoa apps - including file icons, and even showing the parent directory for items that have the same name. It’s working pretty well, except at the moment the parent directory icon is upside down. This involves a custom-drawn menu item, and there’s a bit of silliness in how that’s done. You are provided a CGContextRef, with its origin in the bottom left corner, and an item bounds rectangle in QuickDraw space, where the origin is in the top left corner. For some drawing operations you can get around this by simply flipping everything around, but if you’re drawing icons or text then they’ll get flipped too.

    In the process of testing this I realized this was an opportunity to take advantage of the scripting support I recently completed. I haven’t finished the preferences-writing part of the recent items menu, so I have to open two same-named files every time I run the app to test it. So I recorded a script for opening those two files… and it didn’t run.

    This kind of defeats the purpose of being able to record a script. I don’t know where it gets tripped up, but somehow Script Editor doesn’t like the way the commands are worded even though it wrote them in the first place. If I target another application, like TextEdit, then it works fine, so it must be a script dictionary problem, but I’m using stuff straight from Apple’s sample dictionaries. I suspect I’ll have to abandon the new-fangled .sdef dictionary format and go back to the previous .scriptsuite format. I’m awaiting a reply on the AppleScript-Implementors mailing list before I proceed…

     Forum guest posting disabled for now
    Filed under: — David @ 8:32 am

    For the time being, posting in the forums will require registering for an account. I hope this doesn’t discourage anyone who has something meaningful to contribute.
    (more…)

     Cocoa scripting works… too well
    Filed under: — David @ 7:10 pm

    It turns out I was just missing one little thing - I had to initialize the Cocoa script registry, by calling [NSScriptSuiteRegistry sharedScriptSuiteRegistry].

    With that in place, things started working quite well… in fact, in some cases Cocoa scripting was doing a little too much. I included the Open Documents and Quit events in the script terminology file so they would show up properly in the Script Editor application, but that meant the Cocoa scripting system saw them too, and it installed handlers for them, overriding my own. As a result, the app won’t quit because Cocoa is stealing the message. I could exclude the Cocoa method name from the terminology file, which seems to make things work right, but it also causes Cocoa to complain in the console, and I prefer to keep that clean. So I explicitly remove those open/quit Cocoa-installed handlers after initializing the script registry.

    Next up: a bunch more unit tests. But that will wait until after the weekend.

     Forging on to scripting
    Filed under: — David @ 8:25 pm

    I’ve been making more progress on the ACCELA framework classes. The ultimate goal has been to be able to fully replace PowerPlant, specifically in the four main areas of command handling, view management, document management, and scriptability. The Carbon toolbox provides the first two, and the ACCELA wrappers for those APIs are in place.

    I’m basically ignoring PowerPlant X since it doesn’t have documents or scripting. I asked Greg Dow about that once, and he said he just didn’t have time to finish that part before he left Metrowerks.

    A few months ago I started on the document classes, and the basic stuff for that is in place now as well, including some unit tests. One of the main flaws of PowerPlant, when compared to the modern Mac OS X interface guidelines, is that the document classes were designed with the assumption that all dialogs relating to saving documents are application-modal. This is no longer the case since we have sheet dialogs, so that’s part of the reason why my ADocument and ADocumentManager classes aren’t very similar to PowerPlant’s LDocument and LDocApplication. Fortunately I was already off to a good start, having written CSheetDocument a while back to shoehorn sheet dialogs into PowerPlant for Icon Machine.

    Now I’m tackling scripting. I’ve put it off until last because it’s the most complex. PowerPlant does this very well, so I’ve got quite a bit to live up to. The current recommended approach is to use the Cocoa scripting API for Carbon apps that haven’t added scripting support yet. This makes sense, since Cocoa’s scripting is very full-featured - even better than PowerPlant in some ways, mainly because it leverages features of Objective-C like key-value coding. The problem is that there are no examples of how to use this in a Carbon application.

    It took me a little while to figure out how it would even work, since Cocoa’s scripting all funnels through the NSApplication object, and I was wondering if I’d have to subclass that, which is an odd thing to have to do in a Carbon application. But fortunately that’s not necessary - just set up an application delegate that handles the “application:delegateHandlesKey:” message, and that will set up your delegate for handling all the application’s properties and elements. The other part is telling the script system what classes to use when creating new objects, such as documents; this apparently is handled by putting your class name in the script definition (sdef) file. So then you set up an Objective-C class with that name which will then pass things on to whatever C++/Carbon stuff you have going on, and it should all work.

    Of course, right now it doesn’t actually work at all, and I can’t get any error messages out of it more specific than “it didn’t work”, but in theory it all makes sense.

    I think I posted this mainly to help solidify the concepts in my head. I’ll post more when I find more answers. When this is all reaches a 1.0-ish stage I’ll finally post an ACCELA release package, and see how much attention it gets :)

    As I was collecting links for this post, I found that, as promised, PowerPlant has indeed been released as open source - on SourceForge, under the BSD license. That will be interesting to check out.

     The Creationists
    Filed under: — David @ 9:33 am

    I was just listening to a Science Friday episode talking about a recent intelligent-design-versus-evolution trial. What bothered me was that the guest (guess which side she was on!) kept saying negative things about “the creationists”. That’s my complaint about the whole debate - “the creationists” are all lumped together as a bunch of religious wackos that want to push their beliefs on everyone else and don’t understand the concept of science.

    Hi, I’m a creationist. I believe God created the earth. I just don’t know how, and I expect it will be a long time before any of us do.

    Evolution is just a theory - even the scientists will tell you this. We won’t know for sure that that’s how life as we know it came to be until we invent time travel so we can go back and make sure… or until we get God to tell us how he did it, which I think is more likely.

    But the theory of evolution is science, and that’s what belongs in our school science classrooms. Our science has not advanced to the point where we can begin to explain things like how God created the world. I hope we get there some day; I believe that’s what God wants us to do. But we shouldn’t act like we’re there until we actually are. That’s why I don’t pay any attention to intelligent design.

    Side note- best headline of the day: Bush urges end to cartoon violence


    This is my personal blog. The views expressed on these pages are mine alone and not those of my employer.

    Powered by WordPress

    Shareware Icons Games
    Topic - News Blogs: Bracelets auto-moto Chairs Blog Search the Web Top auto-moto Boats Autos Cases Intimate goods Necklace Trousers Underwear Top casino Sale Auto Building materials Evening dress Yachts Tunings Medicine news furniture Rington Replica Rolex Mobiles Rolex Replica Boots Ear rings Fashions Green Card Information ya.by Balans Cigarettes Medical tests Sport Betting Cars