<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>

<channel>
	<title>Makes No Sense At All</title>
	<atom:link href="http://www.katoemba.net/makesnosenseatall/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.katoemba.net/makesnosenseatall</link>
	<description>Interesting things to share around software development, music and what else comes to mind</description>
	<pubDate>Thu, 15 May 2008 16:43:25 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5.1</generator>
	<language>en</language>
			<item>
		<title>Major downtime</title>
		<link>http://www.katoemba.net/makesnosenseatall/index.php/2008/05/15/major-downtime/</link>
		<comments>http://www.katoemba.net/makesnosenseatall/index.php/2008/05/15/major-downtime/#comments</comments>
		<pubDate>Thu, 15 May 2008 16:42:04 +0000</pubDate>
		<dc:creator>Berrie</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.katoemba.net/makesnosenseatall/index.php/2008/05/15/major-downtime/</guid>
		<description><![CDATA[For 2 days my local ADSL provider (xs4all) has been suffering from a major outage, which 50,000+ people impacted. As a result of this I was unable to use the Internet, and this website was also mostly unavailable, since I&#8217;m hosting this from my home network.&#60;br&#62;
It seems that by now most of the problems are [...]]]></description>
			<content:encoded><![CDATA[<p>For 2 days my local ADSL provider (<a href="http://www.xs4all.nl" target="_blank">xs4all</a>) has been suffering from a major outage, which 50,000+ people impacted. As a result of this I was unable to use the Internet, and this website was also mostly unavailable, since I&#8217;m hosting this from my home network.&lt;br&gt;</p>
<p>It seems that by now most of the problems are gone.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.katoemba.net/makesnosenseatall/index.php/2008/05/15/major-downtime/feed/</wfw:commentRss>
		</item>
		<item>
		<title>RitMeester page added</title>
		<link>http://www.katoemba.net/makesnosenseatall/index.php/2008/04/08/ritmeester-page-added/</link>
		<comments>http://www.katoemba.net/makesnosenseatall/index.php/2008/04/08/ritmeester-page-added/#comments</comments>
		<pubDate>Tue, 08 Apr 2008 20:37:54 +0000</pubDate>
		<dc:creator>Berrie</dc:creator>
		
		<category><![CDATA[Software development]]></category>

		<category><![CDATA[Apple]]></category>

		<category><![CDATA[Belastingdienst]]></category>

		<category><![CDATA[Bijtelling]]></category>

		<category><![CDATA[Kilometer Registratie]]></category>

		<category><![CDATA[Lease-auto]]></category>

		<category><![CDATA[Mac]]></category>

		<category><![CDATA[Mac OS X 10.5]]></category>

		<category><![CDATA[Ritten Administratie]]></category>

		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.katoemba.net/makesnosenseatall/index.php/2008/04/08/ritmeester-page-added/</guid>
		<description><![CDATA[Today I have added a page on RitMeester. With this software you can keep an adminstration of your car usage, required to get certain tax benefits on a lease car in the Netherlands. RitMeester is still under development, in the meantime I want to give people a sneak preview of what it&#8217;s going to look [...]]]></description>
			<content:encoded><![CDATA[<p>Today I have added a page on <a href="http://www.katoemba.net/makesnosenseatall/index.php/ritmeester/">RitMeester</a>. With this software you can keep an adminstration of your car usage, required to get certain tax benefits on a lease car in the Netherlands. RitMeester is still under development, in the meantime I want to give people a sneak preview of what it&#8217;s going to look like.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.katoemba.net/makesnosenseatall/index.php/2008/04/08/ritmeester-page-added/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Calq now includes Hungarian localization</title>
		<link>http://www.katoemba.net/makesnosenseatall/index.php/2008/04/07/calq-now-includes-hungarian-localization/</link>
		<comments>http://www.katoemba.net/makesnosenseatall/index.php/2008/04/07/calq-now-includes-hungarian-localization/#comments</comments>
		<pubDate>Mon, 07 Apr 2008 18:59:33 +0000</pubDate>
		<dc:creator>Berrie</dc:creator>
		
		<category><![CDATA[Software development]]></category>

		<category><![CDATA[Calq]]></category>

		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.katoemba.net/makesnosenseatall/index.php/2008/04/07/calq-now-includes-hungarian-localization/</guid>
		<description><![CDATA[Thanks to the help of Abzu from www.machonosit.hu Calq is now also available in Hungarian. The localization has been added to the existing 1.4.3 version. Download is available here.
]]></description>
			<content:encoded><![CDATA[<p>Thanks to the help of Abzu from <a href="http://www.machonosit.hu" target="_blank">www.machonosit.hu</a> <a href="http://www.katoemba.net/makesnosenseatall/index.php/calq/">Calq</a> is now also available in Hungarian. The localization has been added to the existing 1.4.3 version. Download is available <a href="http://www.katoemba.net/download/Calq-1.4.3.dmg.gz">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.katoemba.net/makesnosenseatall/index.php/2008/04/07/calq-now-includes-hungarian-localization/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Version 1.4.3 of Calq is available</title>
		<link>http://www.katoemba.net/makesnosenseatall/index.php/2008/03/15/version-143-of-calq-is-available/</link>
		<comments>http://www.katoemba.net/makesnosenseatall/index.php/2008/03/15/version-143-of-calq-is-available/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 17:28:41 +0000</pubDate>
		<dc:creator>Berrie</dc:creator>
		
		<category><![CDATA[Software development]]></category>

		<category><![CDATA[Apple]]></category>

		<category><![CDATA[Calq]]></category>

		<category><![CDATA[Mac]]></category>

		<category><![CDATA[Mac OS X 10.5]]></category>

		<category><![CDATA[Software]]></category>

		<guid isPermaLink="false">http://www.katoemba.net/makesnosenseatall/index.php/2008/03/15/version-143-of-calq-is-available/</guid>
		<description><![CDATA[Today I have released v1.4.3 of Calq for Mac OS X. It has improved compatibility with Spaces under Leopard, by making sure that the Calq window always appears on the active space. If you&#8217;re running Tiger (OS X 10.4) there is no need to download this upgrade.
]]></description>
			<content:encoded><![CDATA[<p>Today I have released <a href="http://www.katoemba.net/download/Calq-1.4.3.dmg.gz" title="Download Calq v1.4.3">v1.4.3 of Calq</a> for Mac OS X. It has improved compatibility with Spaces under Leopard, by making sure that the Calq window always appears on the active space. If you&#8217;re running Tiger (OS X 10.4) there is no need to download this upgrade.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.katoemba.net/makesnosenseatall/index.php/2008/03/15/version-143-of-calq-is-available/feed/</wfw:commentRss>
		</item>
		<item>
		<title>The iPhone SDK - why are people left out?</title>
		<link>http://www.katoemba.net/makesnosenseatall/index.php/2008/03/12/the-iphone-sdk-why-are-people-left-out/</link>
		<comments>http://www.katoemba.net/makesnosenseatall/index.php/2008/03/12/the-iphone-sdk-why-are-people-left-out/#comments</comments>
		<pubDate>Wed, 12 Mar 2008 19:43:48 +0000</pubDate>
		<dc:creator>Berrie</dc:creator>
		
		<category><![CDATA[Software development]]></category>

		<category><![CDATA[iPhone]]></category>

		<category><![CDATA[iPhone SDK]]></category>

		<category><![CDATA[MPD]]></category>

		<guid isPermaLink="false">http://www.katoemba.net/makesnosenseatall/index.php/2008/03/12/the-iphone-sdk-why-are-people-left-out/</guid>
		<description><![CDATA[Last week Apple finally made the iPhone SDK available. Great, now I can turn my iPod Touch into a remote for the MPD music server that I&#8217;m running on my central Ubuntu server.
But hold on&#8230; I can&#8217;t install the SDK on my G4 Powerbook. What a bummer. In the meantime there are listings on the [...]]]></description>
			<content:encoded><![CDATA[<p>Last week Apple finally made the <a href="http://developer.apple.com/iphone/" target="_blank">iPhone SDK</a> available. Great, now I can turn my iPod Touch into a remote for the <a href="http://www.musicpd.org/" target="_blank">MPD</a> music server that I&#8217;m running on my central <a href="http://www.ubuntu.com/" target="_blank">Ubuntu</a> server.<br/><br />
But hold on&#8230; I can&#8217;t install the SDK on my G4 Powerbook. What a bummer. In the meantime there are listings on the Internet on how you can use Pacifist to <a href="http://www.iphoneatlas.com/2008/03/10/surprise-iphone-sdk-also-works-on-powerpc-macs/" target="_blank">install the SDK on a PowerPC system</a>. I tried that today, but it dropped everything in my root rather then creating a Developer folder, making it quite a mess. It also dropped stuff in my /usr and /Library folders, ouch. After cleaning up the mess I took a different route: I installed the SDK on my wifes iBook, then copied the entire Development folder over to my PowerPC. This works fine, and after downloading <a href="http://www.musicpd.org/libmpdclient.shtml" target="_blank">lipmpdclient</a>, I had the list of artists on my server showing up in the Aspen emulator in less then 10 minutes.<br/><br />
So I can develop happily from here onwards, as long as I don&#8217;t want to actually install anything on my iPod Touch. To get onto the device you need to apply for the iPhone Developer Program. But initially it&#8217;s only open to developers from the US. What sort of policy is that? Does Apple see 1st class world-citizens and 2nd class world-citizens? I don&#8217;t care so much that I can&#8217;t distribute this software to others right now, but I&#8217;m not even able to put it on my own Touch. Don&#8217;t I have the right to mess with that thing? Weird.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.katoemba.net/makesnosenseatall/index.php/2008/03/12/the-iphone-sdk-why-are-people-left-out/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Pica type cursus en Mac: geen goede combinatie</title>
		<link>http://www.katoemba.net/makesnosenseatall/index.php/2008/02/23/pica-type-cursus-niet-geschikt-voor-mac/</link>
		<comments>http://www.katoemba.net/makesnosenseatall/index.php/2008/02/23/pica-type-cursus-niet-geschikt-voor-mac/#comments</comments>
		<pubDate>Sat, 23 Feb 2008 12:02:20 +0000</pubDate>
		<dc:creator>Berrie</dc:creator>
		
		<category><![CDATA[Uncategorized]]></category>

		<category><![CDATA[Apple]]></category>

		<category><![CDATA[Mac]]></category>

		<category><![CDATA[Pica]]></category>

		<category><![CDATA[Type cursus]]></category>

		<category><![CDATA[Typen]]></category>

		<guid isPermaLink="false">http://www.katoemba.net/makesnosenseatall/index.php/2008/02/23/pica-type-cursus-niet-geschikt-voor-mac/</guid>
		<description><![CDATA[The following article is in Dutch because it&#8217;s only relevant for people in the Netherlands.
Helaas heb ik moeten constateren dat Instituut Pica in het verhaal rond haar cursus computertypen geen eerlijke voorlichting geeft aan klanten. Nadat we onze belangstelling hadden doorgegeven om onze zoon deze cursus te laten volgen kwam er iemand langs om uit [...]]]></description>
			<content:encoded><![CDATA[<p>The following article is in Dutch because it&#8217;s only relevant for people in the Netherlands.</p>
<p>Helaas heb ik moeten constateren dat <a href="http://www.instituutpica.nl" target="_blank">Instituut Pica</a> in het verhaal rond haar cursus computertypen geen eerlijke voorlichting geeft aan klanten. Nadat we onze belangstelling hadden doorgegeven om onze zoon deze cursus te laten volgen kwam er iemand langs om uit te leggen hoe een en ander in zijn werk gaat bij deze cursus. Uiteraard hebben we hierbij aangegeven dat we een Apple Mac gebruiken, en gevraagd of dit een probleem zou zijn. Ons werd verzekerd dat men hier een aantekening van zou maken en dat dit verder geen problemen op zou leveren.<br />
Nu onze zoon een aantal weken bezig is en ik de lessen bekeken heb, vind ik dit geen correcte voorstelling van zaken. De cursus is duidelijk georiënteerd op het gebruik van Windows in combinatie met Microsoft Word. Alle uitleg over computer specifieke zaken richt zich hierop. Enkele voorbeelden: de wekelijkse toets moet aangeleverd worden in .doc formaat, er worden allerlei toets-combinaties uitgelegd die Windows specifiek zijn, net als de uitleg van het gebruik van speciale tekens zoals é of ë. Voor het leren typen op zichzelf is dit niet zo&#8217;n probleem, maar een deel van de overige informatie is dus gewoon onbruikbaar. Het minste dat je dan mag verwachten is dat dat tijdens zo&#8217;n voorafgaand gesprek gemeld wordt, zeker wanneer je daar expliciet naar vraagt!<br />
Daarom zou ik iedereen die met een Mac werkt en overweegt om zijn kind een Pica cursus te laten doen, aanraden om hier nog eens goed over na te denken. In het geval men niet over Word beschikt zou ik er zeker niet aan beginnen.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.katoemba.net/makesnosenseatall/index.php/2008/02/23/pica-type-cursus-niet-geschikt-voor-mac/feed/</wfw:commentRss>
		</item>
		<item>
		<title>District Line</title>
		<link>http://www.katoemba.net/makesnosenseatall/index.php/2008/02/12/district-line/</link>
		<comments>http://www.katoemba.net/makesnosenseatall/index.php/2008/02/12/district-line/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 21:16:10 +0000</pubDate>
		<dc:creator>Berrie</dc:creator>
		
		<category><![CDATA[Music]]></category>

		<guid isPermaLink="false">http://www.katoemba.net/makesnosenseatall/index.php/2008/02/12/district-line/</guid>
		<description><![CDATA[Yesterday the new CD from Bob Mould appeared on emusic (at least for those located in Europe). Some songs similar to his previous solo work, some similar to what he did with Sugar and some tracks that could also have gone on Blowoff. After 3 listens I&#8217;m not yet able to judge the quality.

I&#8217;ve read [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday the new CD from <a href="http://www.bobmould.com/frameset" target="_blank">Bob Mould</a> appeared on <a href="http://www.emusic.com/album/Bob-Mould-District-Line-MP3-Download/11141753.html" target="_blank">emusic</a> (at least for those located in Europe). Some songs similar to his previous solo work, some similar to what he did with Sugar and some tracks that could also have gone on <a href="http://www.emusic.com/album/Blowoff-Blowoff-MP3-Download/10998206.html" target="_blank">Blowoff</a>. After 3 listens I&#8217;m not yet able to judge the quality.<br />
<br />
I&#8217;ve read the <a href="http://www.spin.com/features/magazine/2008/01/0802_bob_mould/index.html" target="_blank">SPIN interview</a> with him, and as has happened before the subject of a Hüsker Dü reunion came up. According to Bob it&#8217;s not going to happen, and I can only agree with him. Sure, if they would get together and play in Holland I would certainly go and see them, but I would know up front it can only be disappointing. Those guys are 20 years older (and like he said he can&#8217;t scream that way or play as fast anymore), but what&#8217;s even more important is that I&#8217;m 20 years older as well. And when you&#8217;re 40 you can try to relive your youth by going to reunion concerts but in the end you&#8217;re still an old guy.<br />
<br />
So it&#8217;s better to keep the memory of what once was. Plus I&#8217;m lucky enough to have seen them perform live in the Warehouse tour.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.katoemba.net/makesnosenseatall/index.php/2008/02/12/district-line/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Multiline cells in NSTableView</title>
		<link>http://www.katoemba.net/makesnosenseatall/index.php/2008/02/05/multiline-cells-in-nstableview/</link>
		<comments>http://www.katoemba.net/makesnosenseatall/index.php/2008/02/05/multiline-cells-in-nstableview/#comments</comments>
		<pubDate>Tue, 05 Feb 2008 20:53:08 +0000</pubDate>
		<dc:creator>Berrie</dc:creator>
		
		<category><![CDATA[Software development]]></category>

		<category><![CDATA[Cocoa]]></category>

		<category><![CDATA[core data]]></category>

		<category><![CDATA[data binding]]></category>

		<category><![CDATA[NSAttributedString]]></category>

		<category><![CDATA[NSTableView]]></category>

		<guid isPermaLink="false">http://www.katoemba.net/makesnosenseatall/index.php/2008/01/20/multiline-cells-in-nstableview/</guid>
		<description><![CDATA[When you&#8217;re building an application that is based on data records, and each record contains a significant amount of data that you want to display in a table row, the space per row may be too small to fit everything. You can add every data element in its own column, but this leads to horizontal [...]]]></description>
			<content:encoded><![CDATA[<p>When you&#8217;re building an application that is based on data records, and each record contains a significant amount of data that you want to display in a table row, the space per row may be too small to fit everything. You can add every data element in its own column, but this leads to horizontal scrolling which can be cumbersome. A better solution to this problem is combining multiple data elements in a single cell. I&#8217;ll demonstrate how this can be done with a core data based application using data binding through a basic example. The end result of the finalized sample will look like this:
</p>
<p><center><br />
<img src="http://www.katoemba.net/makesnosenseatall/wp-content/uploads/2008/02/multilinecell.png" width="463" height="321" alt="MultilineCell Sample App"/><br />
</center></p>
<p>For the sample I have made a core data entity named Order with 2 real attributes, orderNumber and orderLine. To combine these two elements into a single cell I add another transient attribute to the entity, named orderNumberLine. </p>
<p><center><br />
<a href="http://www.katoemba.net/makesnosenseatall/wp-content/uploads/2008/02/datamodel1.png"><img src="http://www.katoemba.net/makesnosenseatall/wp-content/uploads/2008/02/datamodel1.png" width="300" height="156" alt="Datamodel.png"/></a><br />
</center></p>
<p>Because the attribute is transient it will not become part of a file when you save the model. This is fine because whenever we need the value for the orderNumberLine attribute we will compose it from the orderNumber and orderLine values.
</p>
<p>The entity is linked to the class Order, in which we override the standard key-value method orderNumberLine:
</p>
<p>
<pre><code>
// Compose an attributed string that combines the values of the
// orderNumber and orderLine attributes.
- (NSString*)orderNumberLine
{
	NSString *tmpValue;
	NSMutableAttributedString *attrValue;
	NSDictionary *boldFont =
		[NSDictionary dictionaryWithObject:[NSFont boldSystemFontOfSize:10.0]
					forKey:NSFontAttributeName];
	NSDictionary *normalFont =
		[NSDictionary dictionaryWithObject:[NSFont systemFontOfSize:10.0]
					forKey:NSFontAttributeName];

	[self willAccessValueForKey:@"orderNumberLine"];
	// Put the order number in bold
	attrValue = [[NSMutableAttributedString alloc]
				initWithString:(self.orderNumber?self.orderNumber:@&#8221;<Unknown>&#8220;)
				attributes:boldFont];
	// Then add a newline
	[attrValue appendAttributedString:[[NSAttributedString alloc]
				initWithString:@&#8221;\n&#8221;]];
	// And finally add the order line in normal font
	[attrValue appendAttributedString:[[NSAttributedString alloc]
				initWithString:(self.orderLine?[self.orderLine stringValue]:@&#8221;<Unknown>&#8220;)
				attributes:normalFont]];

	tmpValue = [[NSAttributedString alloc] initWithAttributedString:attrValue];
	[self didAccessValueForKey:@"orderNumberLine"];

	return tmpValue;
}
</code></pre>
</p>
<p>The orderNumberLine method will compose a <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSAttributedString_Class/Reference/Reference.html" target="_blank">NSAttributedString</a> that consist of the orderNumber and orderLine, separated by a newline. Because we&#8217;re using an attributed string we can also use different fonts for different elements, here the orderNumber is in 10 point bold, while the orderLine is in 10 point regular.<br />
<br/>We can now bind the orderNumberLine value to a cell in an <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTableView_Class/Reference/Reference.html" target="_blank">NSTableView</a> in Interface Builder, then the cell will show a 2 line value. To properly display you need to increase the row height of the table view (in this case for a 10 point font size it to 26).
</p>
<p>When you build the application adding only the orderNumberLine method to the Order class, you will notice that the cell that is bound to this method will display properly when it is redrawn (for example through scrolling or selecting the row). But when the value of either orderNumber or orderLine is changed elsewhere in the interface, the cell containing the composite string will not automatically redraw. This can easily be solved by doing an update to orderNumberLine attribute whenever one of its components (orderNumber or orderLine) changes. Then the bindings will take care that the UI is updated immediately. It doesn&#8217;t matter what you set the value of orderNumberLine to because it will be calculated upon retrieval anyway. The two following two methods demonstrate this:
</p>
<p>
<pre><code>
// Override to trigger update of transient attribute orderNumberLine
- (void)setOrderNumber:(NSString*)value
{
	[self willChangeValueForKey:@"orderNumber"];
	[self setPrimitiveValue:value forKey: @"orderNumber"];
	[self didChangeValueForKey:@"orderNumber"];

	// Set the orderNumberLine to trigger updates to bound UI elements
	// The value we set it do doesn&#8217;t matter as the actual value
	// is calculated whenever the orderNumberLine is fetched.
	self.orderNumberLine = @&#8221;";
}

// Override to trigger update of transient attribute orderNumberLine
- (void)setOrderLine:(NSNumber*)value
{
	[self willChangeValueForKey:@"orderLine"];
	[self setPrimitiveValue:value forKey: @"orderLine"];
	[self didChangeValueForKey:@"orderLine"];

	// Set the orderNumberLine to trigger updates to bound UI elements
	// The value we set it do doesn&#8217;t matter as the actual value
	// is calculated whenever the orderNumberLine is fetched.
	self.orderNumberLine = @&#8221;";
}
</code></pre>
</p>
<p>To conclude, by adding a transient attribute, and writing three methods we can display a composed string in a cell. As this string can be an attributed string, we can apply different formatting to the elements composing the string. To look at the complete example, download it<br />
<a href="http://www.katoemba.net/makesnosenseatall/wp-content/uploads/2008/02/multilinecell.zip" title="MultilineCell.zip">here</a> and open it in XCode.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.katoemba.net/makesnosenseatall/index.php/2008/02/05/multiline-cells-in-nstableview/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Safari like button bar in Interface Builder</title>
		<link>http://www.katoemba.net/makesnosenseatall/index.php/2008/01/13/safari-like-button-bar-in-interface-builder/</link>
		<comments>http://www.katoemba.net/makesnosenseatall/index.php/2008/01/13/safari-like-button-bar-in-interface-builder/#comments</comments>
		<pubDate>Sun, 13 Jan 2008 15:08:55 +0000</pubDate>
		<dc:creator>Berrie</dc:creator>
		
		<category><![CDATA[Software development]]></category>

		<category><![CDATA[Button Bar]]></category>

		<category><![CDATA[Cocoa]]></category>

		<category><![CDATA[Interface Builder]]></category>

		<category><![CDATA[Mac OS X 10.5]]></category>

		<category><![CDATA[NSMatrix]]></category>

		<guid isPermaLink="false">http://www.katoemba.net/makesnosenseatall/index.php/2008/01/13/safari-like-button-bar-in-interface-builder/</guid>
		<description><![CDATA[In the previous post on the use of NSGradient I showed a screenshot of a button bar similar to the one that is used in Safari to store your favourites. For an application I&#8217;m writing I have an NSTableView with date based rows, and I want to allow easy filtering the table contents on date [...]]]></description>
			<content:encoded><![CDATA[<p>In the previous post on the <a href="/makesnosenseatall/index.php/2008/01/09/nsview-with-gradient-background/">use of NSGradient</a> I showed a screenshot of a button bar similar to the one that is used in Safari to store your favourites. For an application I&#8217;m writing I have an <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSTableView_Class/Reference/Reference.html" target="_blank">NSTableView</a> with date based rows, and I want to allow easy filtering the table contents on date ranges like month, last month, week, last week etcetera. A button bar is nice looking way of doing this, the screenshot below shows what this looks like (in Dutch, but you&#8217;ll get the idea).</p>
<p><center><img src="http://www.katoemba.net/makesnosenseatall/wp-content/uploads/2008/01/filtering-screenshot1.png" width="567" height="210"/><br />
</center></p>
<p>Until recently you had to use for example <a href="http://www.harmless.de/cocoa-code.php" target="_blank">AMButtonBar</a> to get a button bar like this, but with Leopard our developers life has again been made easier: you can now create the button bar in Interface Builder, using only standard components.<br/></p>
<p>Start by dropping an <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSMatrix_Class/Reference/Reference.html" target="_blank">NSMatrix</a> component (you will find this in the objects library under Views &amp; Cells, Inputs &amp; Values) onto your view. Per default it creates a matrix of 1 column, 2 rows with radio buttons on it. Then set the correct prototype on the <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSMatrix_Class/Reference/Reference.html" target="_blank">NSMatrix</a> object so that newly added buttons will have look right. Click on the little circle that is visible on the right bottom of the <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSMatrix_Class/Reference/Reference.html" target="_blank">NSMatrix</a> when it&#8217;s selected,</p>
<p><center><br />
<img src="http://www.katoemba.net/makesnosenseatall/wp-content/uploads/2008/01/prototype-screenshot.png" width="362" height="83"/><br />
</center></p>
<p>then the prototype attributes are shown in the Inspector window. Select <b>Recessed</b> as <b>Style</b>, and use centered <b>Alignment</b>. Select the right value under <b>Position</b>, based on whether you want to add an image to the buttons or not. In this case I choose not to use images.</p>
<p><center><br />
<img src="http://www.katoemba.net/makesnosenseatall/wp-content/uploads/2008/01/prototype-attributes-screenshot.png" width="272" height="345"/><br />
</center></p>
<p>Once the prototype is setup properly, select the <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSMatrix_Class/Reference/Reference.html" target="_blank">NSMatrix</a> object and have a look at the attributes in the Inspector window.
</p>
<p><center><br />
<img src="http://www.katoemba.net/makesnosenseatall/wp-content/uploads/2008/01/matrix-attributes-screenshot.png" width="271" height="171"/><br />
</center></p>
<p>Change the number of rows and columns to meet your needs, in this case I&#8217;m using 1 row and 6 columns. You end up with one traditional radio button (the one that was originally there) and 5 new buttons according to the prototype. Select the first button and manually set its properties so that it matches the prototype as well.<br/><br />
Next, for each button edit the button <b>Title</b> and specify a unique <b>Tag</b> value in the Inspector window, so that you can distinguish which button was clicked in the attached method in your code later on. Optionally you can add a tooltip under the Identity tab on the Inspector window.
</p>
<p>The final step is to write the method in the controller class, and attach it to the <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSMatrix_Class/Reference/Reference.html" target="_blank">NSMatrix</a> object. When you use the tag values to identify which button was clicked you will only need a single method, and don&#8217;t have to attach a method directly to the buttons. A sample implementation method:</p>
<p>
<pre><code>
- (IBAction)filterData:(id)sender
{
    int tag = [sender selectedTag];

    switch (tag) {
        case 1000: // Show all
            // Remove data  filtering so that all rows are shown
            break;
        case 1001: // Show this month
            // Filter data so that only rows with a date between
            // first and last day of current month are shown
            break;
        case 1002: // Show last month
            // Filter data so that only rows with a date between
            // first and last day of previous month are shown
            break;
        default:
            // Should never get here
            break;
    }
}
</code></pre>
</p>
<p>If you&#8217;re using coredata filtering the data is very easy, as you only need to create a <a href="http://developer.apple.com/documentation/Cocoa/Reference/Foundation/Classes/NSPredicate_Class/Reference/NSPredicate.html" target="_blank">NSPredicate</a> object in which you specify the filtering criteria, and set that predicate on the <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSArrayController_Class/Reference/Reference.html" target="_blank">NSArrayController</a> that holds the rows. This is beyond the scope of this post, if you have questions on that let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.katoemba.net/makesnosenseatall/index.php/2008/01/13/safari-like-button-bar-in-interface-builder/feed/</wfw:commentRss>
		</item>
		<item>
		<title>NSView with gradient background</title>
		<link>http://www.katoemba.net/makesnosenseatall/index.php/2008/01/09/nsview-with-gradient-background/</link>
		<comments>http://www.katoemba.net/makesnosenseatall/index.php/2008/01/09/nsview-with-gradient-background/#comments</comments>
		<pubDate>Wed, 09 Jan 2008 21:27:41 +0000</pubDate>
		<dc:creator>Berrie</dc:creator>
		
		<category><![CDATA[Software development]]></category>

		<category><![CDATA[Cocoa]]></category>

		<category><![CDATA[Colored view]]></category>

		<category><![CDATA[Mac OS X 10.5]]></category>

		<category><![CDATA[NSGradient]]></category>

		<category><![CDATA[NSView]]></category>

		<guid isPermaLink="false">http://www.katoemba.net/makesnosenseatall/index.php/2008/01/09/nsview-with-gradient-background/</guid>
		<description><![CDATA[In Mac OS X 10.5 a new class NSGradient is introduced, that makes it really easy to work with gradients (as you might have guessed from the name). The sample code below shows a basic yet functional implementation of an NSView subclass that has either an colored or gradient background.
ColorGradientView.h
@interface ColorGradientView : NSView
{
&#160;&#160;NSColor *startingColor;
&#160;&#160;NSColor *endingColor;
&#160;&#160;int [...]]]></description>
			<content:encoded><![CDATA[<p>In Mac OS X 10.5 a new class <a href="http://developer.apple.com/documentation/Cocoa/Reference/NSGradient_class/Reference/Reference.html" target="_blank">NSGradient</a> is introduced, that makes it really easy to work with gradients (as you might have guessed from the name). The sample code below shows a basic yet functional implementation of an <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html" target="_blank">NSView</a> subclass that has either an colored or gradient background.</p>
<p>ColorGradientView.h</p>
<pre><code>@interface ColorGradientView : NSView
{
&nbsp;&nbsp;NSColor *startingColor;
&nbsp;&nbsp;NSColor *endingColor;
&nbsp;&nbsp;int angle;
}

// Define the variables as properties
@property(copy) NSColor *startingColor;
@property(copy) NSColor *endingColor;
@property(assign) int value;

@end</code></pre>
<p>ColorGradientView.m</p>
<pre><code>#import "GradientView.h"

@implementation ColorGradientView

// Automatically create accessor methods
@synthesize startingColor;
@synthesize endingColor;
@synthesize angle;

- (id)initWithFrame:(NSRect)frame {
&nbsp;&nbsp;self = [super initWithFrame:frame];
&nbsp;&nbsp;if (self) {
&nbsp;&nbsp;&nbsp;&nbsp;// Initialization code here.
&nbsp;&nbsp;&nbsp;&nbsp;startingColor = [NSColor colorWithCalibratedWhite:1.0 alpha:1.0];
&nbsp;&nbsp;&nbsp;&nbsp;endingColor = nil;
&nbsp;&nbsp;&nbsp;&nbsp;angle = 270;
&nbsp;&nbsp;}
&nbsp;&nbsp;return self;
}

- (void)drawRect:(NSRect)rect {
&nbsp;&nbsp;if (endingColor == nil || [startingColor isEqual:endingColor]) {
&nbsp;&nbsp;&nbsp;&nbsp;// Fill view with a standard background color
&nbsp;&nbsp;&nbsp;&nbsp;[startingColor set];
&nbsp;&nbsp;&nbsp;&nbsp;NSRectFill(rect);
&nbsp;&nbsp;}
&nbsp;&nbsp;else {
&nbsp;&nbsp;&nbsp;&nbsp;// Fill view with a top-down gradient
&nbsp;&nbsp;&nbsp;&nbsp;// from startingColor to endingColor
&nbsp;&nbsp;&nbsp;&nbsp;NSGradient* aGradient = [[NSGradient alloc]
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;initWithStartingColor:startingColor
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;endingColor:endingColor];
&nbsp;&nbsp;&nbsp;&nbsp;[aGradient drawInRect:[self bounds] angle:angle];
&nbsp;&nbsp;}
}

@end</code></pre>
<p>Note that the code is based on the new garbage collection mechanism available in Objective-C 2.0, so there are no retain or release calls.</p>
<p>In the following picture you see a gradient effect from top to bottom to give a subtle 3d appearance:</p>
<p>
<img src="http://www.katoemba.net/makesnosenseatall/wp-content/uploads/2008/01/gradient-screenshot.png" width="566" height="26"/>
</p>
<p>To achieve this, add a <a href="http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/Classes/NSView_Class/Reference/NSView.html" target="_blank">NSView</a> in Interface Builder and define its class as ColorGradientView. In your controller, add a ColorGradientView outlet (e.g. myGradientView) and in Interface Builder attach the view to the outlet. Add the following 3 lines to the <code>- (void)awakeFromNib</code> method in the controller:</p>
<pre><code>
[myGradientView setStartingColor:
&nbsp;&nbsp;&nbsp;&nbsp;[NSColor colorWithCalibratedWhite:0.85 alpha:1.0]];
[myGradientView setEndingColor:
&nbsp;&nbsp;&nbsp;&nbsp;[NSColor colorWithCalibratedWhite:0.7 alpha:1.0]];
[myGradientView setAngle:270];
</code></pre>
<p>In upcoming post I will go into details of how to create the Safari like buttons that you see in the screen shot.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.katoemba.net/makesnosenseatall/index.php/2008/01/09/nsview-with-gradient-background/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
