<?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"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>/dev/zero &#187; source</title>
	<atom:link href="http://www.devzero.it/tag/source/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.devzero.it</link>
	<description>Unix power @ your service</description>
	<lastBuildDate>Sun, 10 Oct 2010 05:52:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Selectable boxes</title>
		<link>http://www.devzero.it/2009/12/selectable-boxes/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=selectable-boxes</link>
		<comments>http://www.devzero.it/2009/12/selectable-boxes/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 13:18:56 +0000</pubDate>
		<dc:creator>unixo</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[BSD]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[cocoa]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[Interface Builder]]></category>
		<category><![CDATA[macos]]></category>
		<category><![CDATA[nsbox]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[radio group]]></category>
		<category><![CDATA[selection]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[subclass]]></category>

		<guid isPermaLink="false">http://www.devzero.it/?p=97</guid>
		<description><![CDATA[If you had ever used iSync, probably you&#8217;ve been asked to resolve a sync conflict at least one time: the panel shown to the user contains two boxes , mutually excluded i.e. you can only choose one of them. DZSelectableBox is a subclass of NSBox view which emulates this behavior. An instance of this class [...]]]></description>
			<content:encoded><![CDATA[<p>If you had ever used iSync, probably you&#8217;ve been asked to resolve a sync conflict at least one time: the panel shown to the user contains two boxes , mutually excluded i.e. you can only choose one of them.</p>
<p>DZSelectableBox is a subclass of NSBox view which emulates this behavior. An instance of this class comes with one more variable member, the box state: when the box is marked as <em>selected</em>, an inner rounded path is drawn inside its bounds; DZSelectableBox honors title position, if it&#8217;s visible. You can use this class in two different manners: standalone or as part of a radio group.<br />
<span id="more-97"></span></p>
<h3>Standalone version</h3>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo;"><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px; "><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px;"><span style="font-size: small;"><a href="http://www.devzero.it/wp-content/uploads/2009/12/box-standalone.png"> <img class="alignright size-thumbnail wp-image-105" title="Example of standalone use" src="http://www.devzero.it/wp-content/uploads/2009/12/box-standalone-150x150.png" alt="Example of standalone use" width="150" height="150" /></a></span></span></span></p>
<p>A standalone box works as described before: the only thing you&#8217;ve to do is open Interface Builder, place a common NSBox in your window, change its class name into DZSelectableBox and start using it.<br />
You can change box state programmatically by using the <strong>toggleState</strong> message, the <strong>setSelected</strong> method to set its state or simply by clicking on it.</p>
<p style="font: normal normal normal 12px/normal Menlo; margin: 0px;"><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px;"><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px;"><span style="font-size: small;"><a href="http://www.devzero.it/wp-content/uploads/2009/12/box-standalone.png"></a></span><a href="http://www.devzero.it/wp-content/uploads/2009/12/box-standalone.png"></a></span><a href="http://www.devzero.it/wp-content/uploads/2009/12/box-standalone.png"></a></span></p>
<p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Menlo;">
<h3>Radio group version</h3>
<p><a href="http://www.devzero.it/wp-content/uploads/2009/12/box-radiogroup.png"><img class="alignright size-thumbnail wp-image-107" title="Radio group boxes" src="http://www.devzero.it/wp-content/uploads/2009/12/box-radiogroup-150x150.png" alt="Radio group boxes" width="150" height="150" /></a></p>
<p>Whenever you need a group of boxes and the opportunity to select only one of them at time, you&#8217;ve to set a radio group; after you followed the steps described before to create your boxes, you&#8217;ve to add the following sample code to your application:</p>
<pre>leftBox<span style="color: #000000;">.</span>radioGroup<span style="color: #000000;"> = [</span><span style="color: #733ba7;">NSNumber</span><span style="color: #000000;"> </span><span style="color: #411b7f;">numberWithInt</span><span style="color: #000000;">:</span><span style="color: #3527d4;">1</span><span style="color: #000000;">];<span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; "> </span></span>
rightBox<span style="color: #000000;">.</span>radioGroup<span style="color: #000000;"> = [</span><span style="color: #733ba7;">NSNumber</span><span style="color: #000000;"> </span><span style="color: #411b7f;">numberWithInt</span><span style="color: #000000;">:</span><span style="color: #3527d4;">1</span><span style="color: #000000;">];<span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; "> </span></span>
<span style="color: #000000;">[</span><span style="color: #4f8187;">leftBox</span><span style="color: #000000;"> </span>setSelected<span style="color: #000000;">:</span><span style="color: #bc24a0;">YES</span><span style="color: #000000;">];<span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; "> </span></span>
<span style="color: #000000;">[</span><span style="color: #4f8187;">rightBox</span><span style="color: #000000;"> </span>setSelected<span style="color: #000000;">:</span><span style="color: #bc24a0;">NO</span><span style="color: #000000;">];</span><span style="color: #000000;">
</span></pre>
<p><span style="color: #000000;">(we suppose you created two boxes and connected them to two outlets called leftBox and rightBox)</span></p>
<p>When a box belongs to a radio group, it listens for group changes notification: for example, if you select the right box (by clicking on it), the left one will be automatically unselected.</p>
<h3><span style="color: #000000;">Where can I download the code?</span></h3>
<p><span style="color: #000000;">Code is available on <a href="http://github.com/">GitHub</a> at the following url:</span></p>
<p><span style="color: #000000;"><a href="http://github.com/unixo/Selectable-Box" target="_blank">http://github.com/unixo/Selectable-Box</a></span></p>
<p><span style="color: #000000;">You can also download a <a rel="attachment wp-att-145" href="http://www.devzero.it/2009/12/selectable-boxes/selectedbox/">Test application</a></span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.devzero.it/2009/12/selectable-boxes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

