Of Colour Wells and Alpha

June 20th, 2006

Many applications require a mix of colour pickers: some that support transparency (alpha) values, and some that don’t. For some reason Apple decided not to make this totally straight forward to implement, even if it is fairly simple to do when you know how.

To support this you need to create two subclasses of NSColorWell, teach Interface Builder about those subclasses and set colour wells in the interface to use the right class.

I created these classes for use in ControlTower, but I would guess they’ll be of use to other Mac OS X developers, so here they are. Feel free to use or abuse them as you see fit.

NSColorWellWithAlpha.h

//
//  NSColorWellWithAlpha.h
//  ControlTower
//
//  Created by Andrew Wellington on 30/04/06.
//  Copyright 2006 Andrew Wellington. All rights reserved.
//

#import 


@interface NSColorWellWithAlpha : NSColorWell {

}

@end

NSColorWellWithAlpha.m

//
//  NSColorWellWithAlpha.m
//  ControlTower
//
//  Created by Andrew Wellington on 30/04/06.
//  Copyright 2006 Andrew Wellington. All rights reserved.
//

#import "NSColorWellWithAlpha.h"


@implementation NSColorWellWithAlpha
- (void)activate:(BOOL)exclusive
{
    [[NSColorPanel sharedColorPanel] setShowsAlpha:YES];
    [super activate: exclusive];
}
@end

NSColorWellWithoutAlpha.h

//
//  NSColorWellWithoutAlpha.h
//  ControlTower
//
//  Created by Andrew Wellington on 30/04/06.
//  Copyright 2006 Andrew Wellington. All rights reserved.
//

#import 


@interface NSColorWellWithoutAlpha : NSColorWell {

}

@end

NSColorWellWithoutAlpha.m

//
//  NSColorWellWithoutAlpha.m
//  ControlTower
//
//  Created by Andrew Wellington on 30/04/06.
//  Copyright 2006 Andrew Wellington. All rights reserved.
//

#import "NSColorWellWithoutAlpha.h"

@implementation NSColorWellWithoutAlpha
- (void)activate:(BOOL)exclusive
{
    [super activate: exclusive];
    [[NSColorPanel sharedColorPanel] setShowsAlpha:NO];
}
@end

Importing into Interface Builder

Simply drag the header files to the main window for the nib (the window that contains the objects in the nib). Set the Custom Class in the Inspector for a NSColorWell to use the correct class based on whether it needs alpha support or not.

That’s it. Easy isn’t it?

New Site and New Software

May 22nd, 2006

After a bunch of procrastinating and a bunch of playing, I’ve rewritten the entire site. It should look pretty much the same to you, but it’s all powered by my own code now. There’s no comment support on the blog as yet, but if there’s demand I guess I could get around to writing that too.

The main reason for the new site is now it hosts software a bit more obviously, and of course the new site comes with not one, but two brand new applications:

  • DotMac Enabler an application for use in configuring .Mac for use on restricted workstations where System Preferences may not be usable for this
  • ControlTower an application to manage Terminals for you allowing you to easily launch new Terminals

So, any problems with the site or the new applications, give me a shout and I’ll see what I can do.

SubEthaEdit for Free

April 26th, 2006

One of my favourite text editors for Mac OS X SubEthaEdit from CodingMonkeys is part of a very special deal at BLOGZOT 2.0 on MacZOT.com.

For every blog post about this deal, the price will reduce by 5c, if they hit 3,000 copies given away, MacZOT and TheCodingMonkeys will award $105,000 in Mac software. This is one of the nicest text editors on any platform with awesomely cool collaborative editing features.

So everyone, get the word out about SubEthaEdit in case there are people out there who don’t realise how cool it is yet πŸ™‚

Xsan 1.3

April 25th, 2006

Xsan 1.3 is finally (almost) out, supposedly addressing a number of issues that I know of with it. Time for some testing and we’ll see if they really are fixed.

(Yes this is a relatively uninteresting post, but well I haven’t posted anything in quite a while, so nyer!)

And they say Xcode isn’t stable

March 6th, 2006

andrew 6535 0.1 -6.5 537188 136228 ?? S 28Jan06 109:23.91 /Developer/Applications/Xcode.app/Contents/MacOS/Xcode -psn_0_8519681

That’s right folks, it is currently 22:29, 6th March 2006, and that copy of Xcode has really been running since January 28th. Unfortunately it’s really getting to the stage where I should restart for these updates that keep showing up so it may be cut off in its prime of life…

The State of the Union Address Drinking Game 2006

February 1st, 2006

The President of the United States gives a state of the union address each year to the US Congress. Clearly, the most appropriate thing to do with an occasion such as this is to turn it into a drinking game.

To see just how smashed you really should be, this table shows the number of drinks you should have had based on the state of the union transcript from C-Span.

Event Number of Occurrences Total Drinks
The state of our union is strong 1 1
troops 2 2 small
Iraq 16 16
Iran 6 6
terror 20 20 small
Mahmoud Ahmadinejad 0 0
Saddam Hussein 0 0
democracy 3 6
elections 3 0*
freedom 17 17
Ariel Sharon 0 0
Homeland 1 1
Jack Abramoff 0 0
Hard Work 0 0
Bring it on 0 0
Nukular 3 3
Scooter Libby 0 0
New Orleans 2 2
bipartisan 2 4
foreign oil 0 0
Medicare 2 2
education 2 2**
environment 1 1
border security 0 0
illegal immigration 0 0
God 2 4
sacrafice 0 0
fiscal discipline 0 0
tax burden 0 0
evil 2 4
Don’t mess with Texas! 0 0
defends the necessity or legality of the NSA surveillance program 1 1
if he praises either Chief Justice Roberts or Justice (?) Alito 1 1
if the speech is under an hour 1 2***
Total 73, 22 small

* Elections was mentioned 3 times, but from the transcript I can’t be sure they’re within one minute.
** Education can’t be sure from a transcript if it was mispronounced for the bonus +1
*** Finish your drink and have another beer

How not to boot Windows XP on an Intel Mac

January 30th, 2006

Neosmart seems to be getting a whole heap of links for their theory on how to boot Windows XP on an Intel Mac. Sounds great, right? Just one problem, leaving aside the whole part about the MacBook not shipping yet so there being no way to verify this, their method just ain’t going to work as written.

1. Using the Bootable Acronis Disk Director CD on the MacBook, shrink the Mac partition. Create a new partition of type NTFS/HPFS in the remaining space.

Uhm, and just how did we boot Acronis again? If it can boot on an Intel Mac they certainly forgot to mention anything about it on their website. Not a mention of EFI that I can see. Note only that, but Acronis doesn’t know anything about HFS+ so you won’t be resizing an HFS+ partition with it, you’d corrupt the filesystem beyond recognition. So it looks like even at step 1 we’re out of luck.

Steps 2-15 are done on a generic PC that can already boot Windows XP so we can ignore them.

16. In Mac now, hack the Darwin Bootloader to add another entry that chainloads Drive(0) Partition(2). With GRUB it would look something like this… I’m not sure if Darwin is the same, but this step is very simple, and has nothing to do with EFI.
title Windows XP
rootnoverify (hd0,1)
chainloader +1

Well the Darwin bootloader bears no resemblence to GRUB. The Darwin bootloader on PowerPC Macs and on the old x86 Darwin version basically just boots Darwin. No options, you’re getting Darwin. There’s no magic chainloader option in every previous version of the Darwin bootloader, so don’t go expecting that it suddenly exists for Intel Macs.

Nobody has yet to even get Vista to boot on an Intel Mac (the best anyone has gotten is the “Press Any Key to boot from CD” message), so how the Vista files are magically helping I’m not sure either.

There’s very little relating to an Intel Mac in the article, just wild theories that to be honest just don’t make any sense. This is an article to take with a large dose of sodium chloride.

WordPress 2.0

January 27th, 2006

So I updated WordPress tonight to 2.0. I doubt you’ll notice any difference, but the admin interface is a pretty blue now πŸ˜›

Let me know if anything seems to be broken since the update.

The Apple Store is Indecisive

January 21st, 2006

On Friday I received the following estimated ship dates for a new iPod I ordered:

  • Wednesday 18th January, 2006
  • Monday 30th January, 2006
  • Shipment Notification for 20th January, 2006

Oh well, it’ll be here on Monday πŸ™‚

Comment Spam

December 26th, 2005

So there’s been a whole bunch of comment spam attempts (all rather useless because I’ve got comment moderation turned on for just such an event). None of them seem to actually be much use for spamming, they’re all the standard “your site is so great” garbage, then with a few links to popular websites (think major news sites, etc). I can only assume they’re trying to see if it’s possible to post comment spam or not before they then go nuts and try lots of different sites, although I’ve had a fair number of them just for this. Who knows, after all one of the key rules of spammers is that spammers are stupid isn’t it?

To avoid them I’m going to make a small modification to the comment posting page so it doesn’t fit the standard template they’re no doubt trying. In the garbage field you need to enter at least 4 characters — any 4 characters will work, this should just stop any bots that are trying the standard WordPress template for entering a comment.