Friday, April 23, 2010

Snow Leopard, external displays, and fonts


UPDATE 05/03/2010: The correct answer seems to be this one: 10.6: Re-enable LCD font smoothing for some monitors. "The problem with the Automatic option is that OS X incorrectly detects many third party LCD monitors as CRTs, and consequently, disables LCD font smoothing."

A couple months ago I purchased a new 13" Macbook Pro. This was before the April updates, so it's the mid-2009 model. As an external display I'm still using the BenQ FP202W that I've had since 2006. The MBP connects to the BenQ with an official Apple-branded MiniDisplay-to-DVI adapter.

I've boiled the weirdness down to a reproducible case:

(1) Open XCode. The editor screen looks like this:


i.e. it looks normal. Legible.

(2) Connect the adapter to the BenQ monitor and connect the adapter to the MiniDisplay port on the laptop. My desktop appears on the BenQ and XCode still looks normal.

(3) Quit XCode and restart it. Now the editor looks like this:


It's the same font (Monaco Regular 12) but the rendering is somehow different. Weak and spidery. The difference is noticeable in the screengrabs, in person the difference is even more jarring.

TextMate does the same thing. I have TextMate also using Monaco Regular 12, so maybe it's related to the font? I have no idea what's causing this or how to fix it.

Saturday, April 17, 2010

Interactive Debugger for PHP


If you're looking for a free (zero-dollar) debugger for PHP, I've stumbled onto the combination of Xdebug installed onto the server and MacGDBp on my workstation. My favorite part is that I don't need to have a copy of the source tree on my workstation to do source-level debugging. It's transferred to me on demand by the magic of DBGP.

UPDATE: If you don't mind dropping a little money, I've been happy with the debugger in PHPStorm. You still need Xdebug installed on the PHP server for PHPStorm to interact with it.

Wednesday, January 20, 2010

The Nerd in the High Castle


I like to read history books, and that includes the history of the computer industry. Steven Levy's stuff is pretty good, even if sometimes he gets a little breathless in the telling. Dealers of Lightning, West of Eden, Soul of a New Machine, stuff like that.

From reading enough of these, and from the tech press as well, I know there's this notion floating around that during the early 80s Apple was fighting the wrong enemy. (Pirates of Silicon Valley also plays this note.) During that era, Apple focused on IBM instead of on Microsoft. But Microsoft and MS-DOS really won their independence from IBM during the Clone Wars. Everyone wanted to clone the IBM PC, and run MS-DOS on it, because IBM had been so successful. If Apple had somehow won market dominance over IBM in the early 80s, they would have also defeated Microsoft by proxy.

That got me thinking though, that Microsoft probably would not have stayed out of the OS market. They were still a successful applications company at the time and, if PC-DOS had failed, they surely would have made another attempt at an OS product. Now it starts to sound like the plot of a alternate history novel, doesn't it? On the back cover: "What if Apple had defeated IBM in 1984? What if Microsoft had partnered with Commodore to sell MS-Windows in 1986?"

Wow I just realized... if someone wrote that book, I would totally read it.

Wednesday, October 14, 2009

Can I make a UIView transition to itself?


Sure, why not?

Let's say you have a UIViewController and you want the base view to do a CATransition from itself to itself:

- (void)doTransToSelf {
    CATransition *anime = [CATransition animation];
    anime.type = kCATransitionPush;
    anime.subtype = kCATransitionFromRight;
    anime.duration = 0.5;

    UIView *mySuper = self.view.superview;
    [self.view removeFromSuperview];
    [mySuper addSubview:self.view];
    [mySuper.layer addAnimation:anime forKey:nil];
}


Or, changing this to work on a subview of self.view is trivial.

So, why would you want to do this? In my case, I have a collection of data objects and a UIView that is the user interface for editing one object. When the user is ready to move on and edit the next object in the collection, the user interface doesn't substantially change, I'm really just changing the data object that is the target of the user's edits. So I want to re-use the same view with the same set of IBOutlets, and just do the transition as a visual cue to the user - "okay, you're working on a different object now."

Sunday, June 28, 2009

Why won't my backBarButtonItem use its action?


Or, How to make a backBarButtonItem send its action to its target.

Answer: you don't.

Because a backBarButtonItem is a UIBarButtonItem, it has "target" and "action" properties, leading you to believe that if you assign values to those properties, shit will happen. Alas, shit will not happen. Or rather, the usual shit will happen, but not the extra shit you hoped would happen. The backBarButtonItem is special - no matter what you do with those properties, «target» will never receive a message for «action».

What you can do instead is assign a delegate to either your UINavigationController or UINavigationBar. Both of these classes have delegate protocols that give you opportunities to act when the stack of view controllers changes. I've been using my root view controller as the delegate object, since that one never gets popped off the stack.