<?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>RBDevZone &#187; ResExcellence</title>
	<atom:link href="http://www.rbdevzone.com/category/resex/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.rbdevzone.com</link>
	<description>The REALbasic Resource</description>
	<lastBuildDate>Tue, 31 Aug 2010 19:55:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Guessing Game</title>
		<link>http://www.rbdevzone.com/2008/10/guessing-game/</link>
		<comments>http://www.rbdevzone.com/2008/10/guessing-game/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 01:03:52 +0000</pubDate>
		<dc:creator>Paul Lefebvre</dc:creator>
				<category><![CDATA[ResExcellence]]></category>
		<category><![CDATA[Source Code]]></category>

		<guid isPermaLink="false">http://www.rbdevzone.com/2008/10/guessing-game/</guid>
		<description><![CDATA[by Erick Tejkowski
Did you know that your computer can read minds? This week we&#8217;ll witness its extraordinary mind-reading powers by creating a simple REALbasic project. See if you can figure out how it works before looking at the code!

Downloads
Because the code for this demo is drop-dead simple, there isn&#8217;t really any reason to cover the [...]]]></description>
			<content:encoded><![CDATA[<p><cite>by Erick Tejkowski</cite></p>
<p>Did you know that your computer can read minds? This week we&#8217;ll witness its extraordinary mind-reading powers by creating a simple REALbasic project. See if you can figure out how it works before looking at the code!</p>
<div style="text-align:center;"><img src="http://www.rbdevzone.com/wp-content/uploads/2008/10/04-25-03-img1.jpg" alt="04-25-03_img1.jpg" border="0" width="350" height="221" /></div>
<h2>Downloads</h2>
<p>Because the code for this demo is drop-dead simple, there isn&#8217;t really any reason to cover the process of putting an interface together. Check one of the previous tutorials if you are a complete REALbasic newbie. The fact is, this project doesn&#8217;t have any tricky code at all. The trick lies in the mathematical content of the application, not the code itself.</p>
<p>Download the <a href="http://www.rbdevzone.com/wp-content/uploads/2008/10/guessinggame.rbp.zip" title="GuessingGame.rbp.zip">Guessing Game</a> project.</p>
<p><cite>Originally published by ResExcellence Reprinted with permission</cite></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rbdevzone.com/2008/10/guessing-game/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image Spinner</title>
		<link>http://www.rbdevzone.com/2008/10/image-spinner/</link>
		<comments>http://www.rbdevzone.com/2008/10/image-spinner/#comments</comments>
		<pubDate>Fri, 17 Oct 2008 00:37:06 +0000</pubDate>
		<dc:creator>Paul Lefebvre</dc:creator>
				<category><![CDATA[ResExcellence]]></category>
		<category><![CDATA[Source Code]]></category>

		<guid isPermaLink="false">http://www.rbdevzone.com/2008/10/image-spinner/</guid>
		<description><![CDATA[by Erick Tejkowski
One of the most frequently asked questions among REALbasic lists is &#8220;How do I rotate an image?&#8221; This project will show you how to quickly and easily rotate an image in realtime. The REALbasic Group2D class simplifies matters significantly for us. By dragging a few items to your interface and adding a bit [...]]]></description>
			<content:encoded><![CDATA[<p><cite>by Erick Tejkowski</cite></p>
<p>One of the most frequently asked questions among REALbasic lists is &#8220;How do I rotate an image?&#8221; This project will show you how to quickly and easily rotate an image in realtime. The REALbasic Group2D class simplifies matters significantly for us. By dragging a few items to your interface and adding a bit of code, you&#8217;ll be spinning in no time.</p>
<h2>Build the Interface</h2>
<p>Launch REALbasic and add a Canvas, a PushButton, and a Slider control to the Window1 interface. Set the maximum value of the slider to 6283. Since one complete rotation around a circle is approximately 6.283 radians, we&#8217;ll use the larger value of 6283 to insure fine resolution upon rotation. Next, click on the slider to select it and uncheck its Enabled property in the Properties window. Then, add an image file to your project. I snagged a photo of Michael Coyle, ResEx&#8217; own top dog. His image accompanies the source code download at the end of this tutorial. The final interface looks like this: </p>
<div style="text-align:center;"><img src="http://www.rbdevzone.com/wp-content/uploads/2008/10/4-11-03-img1.jpg" alt="4-11-03_img1.jpg" border="0" width="212" height="311" /></div>
<h2>Add the Code</h2>
<p>Double-click PushButton1 and add the following code to its Action event.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">  <span style="color: #000080;">Dim</span> px <span style="color: #000080;">as</span> PixmapShape
  <span style="color: #000080;">Dim</span> p <span style="color: #000080;">as</span> Picture
&nbsp;
  px=<span style="color: #000080;">New</span> PixmapShape(coyle)
  p=<span style="color: #000080;">New</span> Picture(coyle.width,coyle.height,32)
  d=<span style="color: #000080;">New</span> Group2D
  d.<span style="color: #000080;">append</span>(px)
  Canvas1.Backdrop=p
  Canvas1.backdrop.Objects=d
  canvas1.Refresh 
  slider1.enabled = <span style="color: #000080;">True</span></pre></div></div>

<p>Next, add this code to the Paint event of Canvas1.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">  g.clearRect 0,0,me.width,me.height
  g.drawobject d,47,60</pre></div></div>

<p>With the Window1 code editor opened, create a new property of that window, by choosing Edit-New Property. Name the property like this:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">d <span style="color: #000080;">as</span> Group2D</pre></div></div>

<div style="text-align:center;"><img src="http://www.rbdevzone.com/wp-content/uploads/2008/10/4-11-03-img2.jpg" alt="4-11-03_img2.jpg" border="0" width="209" height="306" /></div>
<h2>Conclusion</h2>
<p>Choose Debug-Run to see your work. By drawing an image using a Group2D object, you can a number of important image operations. The speed isn&#8217;t as fast as an RGBSurface, but for many tasks its perfectly suitable.</p>
<p>Download the <a href="http://www.rbdevzone.com/wp-content/uploads/2008/10/imagespinner.zip" title="ImageSpinner.zip">ImageSpinner</a> project.</p>
<p><cite>Originally published by ResExcellence Reprinted with permission</cite></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rbdevzone.com/2008/10/image-spinner/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Resizable Sheets</title>
		<link>http://www.rbdevzone.com/2008/04/resizable-sheets/</link>
		<comments>http://www.rbdevzone.com/2008/04/resizable-sheets/#comments</comments>
		<pubDate>Sat, 05 Apr 2008 00:25:57 +0000</pubDate>
		<dc:creator>Paul Lefebvre</dc:creator>
				<category><![CDATA[Featured Articles]]></category>
		<category><![CDATA[ResExcellence]]></category>
		<category><![CDATA[User Interface]]></category>

		<guid isPermaLink="false">http://www.rbdevzone.com/2008/04/resizable-sheets/</guid>
		<description><![CDATA[I needed this in a project I was working on and it turned out that Seth Willits had written about how to do this in a ResExcellence post from 2006.
Download the code to try it out.  To use it, simply include the ResizableSheet class in your project and set your sheet&#8217;s Super to it. [...]]]></description>
			<content:encoded><![CDATA[<p>I needed this in a project I was working on and it turned out that Seth Willits had written about how to do this in a ResExcellence post from 2006.</p>
<p>Download the code to try it out.  To use it, simply include the ResizableSheet class in your project and set your sheet&#8217;s Super to it.  And of course, be sure to enable the resizable property on the sheet.</p>
<p>It worked pretty well for me in REALbasic 2008 Release 1.</p>
<p><a title="Resizable Sheet Project" href="http://www.rbdevzone.com/wp-content/uploads/2008/04/resizable-sheet.rbp">Download Resizable Sheet Project</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rbdevzone.com/2008/04/resizable-sheets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CGS Private Functions</title>
		<link>http://www.rbdevzone.com/2008/01/cgs-private-functions/</link>
		<comments>http://www.rbdevzone.com/2008/01/cgs-private-functions/#comments</comments>
		<pubDate>Sun, 06 Jan 2008 16:00:46 +0000</pubDate>
		<dc:creator>Paul Lefebvre</dc:creator>
				<category><![CDATA[ResExcellence]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[User Interface]]></category>

		<guid isPermaLink="false">http://www.rbdevzone.com/2008/01/cgs-private-functions/</guid>
		<description><![CDATA[by Seth Willits
Mac OS X is full of private APIs available only to Apple to use in their own software and the operating system. Clever developers, much more knowledgeable than I, have been able to reverse engineer some of these APIs and do some neat things with them. I was fiddling with the CGSPrivate functions [...]]]></description>
			<content:encoded><![CDATA[<p><em>by Seth Willits</em></p>
<p>Mac OS X is full of private APIs available only to Apple to use in their own software and the operating system. Clever developers, much more knowledgeable than I, have been able to reverse engineer some of these APIs and do some neat things with them. I was fiddling with the CGSPrivate functions that were made popuplar by a program called Desktop Manager which makes virtual desktops, and made a REALbasic module of (almost) all of the functions in that header as well as some others.</p>
<p>One of the neat things in this header are functions to transition the entire screen, like fast user switching does. I haven&#8217;t yet done anything useful with these methods, but I did write a tiny sample application that demonstrates these effects.<br />
<a href="http://www.rbdevzone.com/wp-content/uploads/2008/01/fastuserswitching.png" title="FastUserSwitching"><img src="http://www.rbdevzone.com/wp-content/uploads/2008/01/fastuserswitching.png" alt="FastUserSwitching" /></a><a href="http://www.rbdevzone.com/wp-content/uploads/2008/01/window.jpg" title="CGSPrivate Window"><img src="http://www.rbdevzone.com/wp-content/uploads/2008/01/window.jpg" alt="CGSPrivate Window" /></a></p>
<h2>Full Screen Effects</h2>
<p>The code below is pretty simple, and with a fair amount of work using more of the functions, you could do some wickedly cool stuff, like&#8230; a virtual desktop manager program made in REALbasic. <img src='http://www.rbdevzone.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Dim</span> cid <span style="color: #000080;">as</span> <span style="color: #000080;">Integer</span> = _CGSDefaultConnection()<span style="color: #000080;">Dim</span> transNo <span style="color: #000080;">As</span> IntegerdimDim transSpec <span style="color: #000080;">As</span> CGSTransitionSpectransSpec.<span style="color: #000080;">Type</span> = CGSTransitionType(PopupMenu1.ListIndex + 1)
&nbsp;
transSpec.<span style="color: #000080;">Option</span> = CGSTransitionOption(PopupMenu2.ListIndex)
&nbsp;
transSpec.WindowID = 0 // Fullscreen
&nbsp;
transSpec.BackColorPtr = 0
&nbsp;
<span style="color: #000080;">Dim</span> err <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>
&nbsp;
err = CGSNewTransition(cid, transSpec, transNo)
&nbsp;
err = CGSSetWorkspace(cid, 0)
&nbsp;
err = CGSInvokeTransition(cid, transNo, 0.5)
&nbsp;
CGSPrivate.Delay(0.5)
&nbsp;
err = CGSReleaseTransition(cid, transNo)</pre></div></div>

<p>Finished</p>
<p>Download <a href="http://www.rbdevzone.com/wp-content/uploads/2008/01/cgsprivaterbp.zip" title="CGSPrivate Project">CGSPrivate Project</a></p>
<p><em>Originally published by ResExcellence<br />
Reprinted with permission</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rbdevzone.com/2008/01/cgs-private-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Zing with CapacityString</title>
		<link>http://www.rbdevzone.com/2007/10/zing-with-capacitystring/</link>
		<comments>http://www.rbdevzone.com/2007/10/zing-with-capacitystring/#comments</comments>
		<pubDate>Mon, 15 Oct 2007 14:35:38 +0000</pubDate>
		<dc:creator>Paul Lefebvre</dc:creator>
				<category><![CDATA[ResExcellence]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[Strings]]></category>

		<guid isPermaLink="false">http://www.rbdevzone.com/2007/10/zing-with-capacitystring/</guid>
		<description><![CDATA[by Seth Willits
In this tutorial we&#8217;re going to write a CapacityString class which will vastly improve string performance in certain situations. Now, I admit this tutorial isn&#8217;t exactly going to be eye catching, but I think for some of you it will be quite an eye opener.
The Problem
Let&#8217;s say that you&#8217;re going to be importing [...]]]></description>
			<content:encoded><![CDATA[<p><em>by Seth Willits</em></p>
<p>In this tutorial we&#8217;re going to write a CapacityString class which will vastly improve string performance in certain situations. Now, I admit this tutorial isn&#8217;t exactly going to be eye catching, but I think for some of you it will be quite an eye opener.</p>
<h2>The Problem</h2>
<p>Let&#8217;s say that you&#8217;re going to be importing some data from a file, processing it, and outputting the results to a string. Since this process can take quite a while you&#8217;re going to want to display a progress dialog with a progress bar that increments realistically based on the current position in the file. Normally you&#8217;d have something that looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">bin = File.OpenAsBinaryFile
length = bin.Length 
&nbsp;
<span style="color: #000080;">For</span> i = 1 <span style="color: #000080;">To</span> length <span style="color: #000080;">Step</span> 2048
   s = s + ProcessData( bin.Read(2048) )
   // show progress
<span style="color: #000080;">Next</span></pre></div></div>

<p>There&#8217;s nothing extraordinary about this code at all, but what if I told you that it could be sped up by over 50 times? It&#8217;s quite possible, and easy.</p>
<p>Note that every time through the loop we assign a value to the string &#8220;s&#8221;, and during that assignment REALbasic reallocates a block of memory to store the contents of that string. The problem is that allocating memory is actually pretty slow, so doing it over and over and over again is very inefficient. The solution is to simply allocate enough memory up front so that it never has to be reallocated. Sounds easy, and it is, but REALbasic strings can&#8217;t do this so what we need to do is do it ourselves using a MemoryBlock.</p>
<h2>The CapacityString Class</h2>
<p>Create a new class called CapacityString and add three properties to it: mCapacity as Integer, mLength as Integer, and mData as MemoryBlock. mData is the chunk of memory that we&#8217;re going to be using to store the string, mCapacity will cache the size of the MemoryBlock (although it will always contain the value returned by mData.Size, the fewer function calls we make the faster the code will be), and because the string inside the MemoryBlock will almost never be the size of the MemoryBlock itself, we use mLength to store the size of the string.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Sub</span> Constructor(capacity <span style="color: #000080;">as</span> <span style="color: #000080;">Integer</span>)
   mCapacity = capacity
   mData = <span style="color: #000080;">New</span> MemoryBlock(mCapacity)
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span> 
&nbsp;
<span style="color: #000080;">Function</span> Operator_Convert() <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
   Return mData.StringValue(0, mLength)
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

<p>The constructor initializes the mData MemoryBlock to have the capacity we want, and Operator_Convert is a handy method to return the string that is stored in the CapacityString.</p>
<p>The SetString method below sets the string in the CapacityString. The first thing that each of these methods below does is first check to see if the string will actually fit inside of the MemoryBlock. If it doesn&#8217;t, it resizes (within the method, function calls would add overhead ;^) and then assigns the string.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Sub</span> SetString(s <span style="color: #000080;">as</span> <span style="color: #000080;">String</span>)
   <span style="color: #000080;">Dim</span> slen <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span> = LenB(s)
   <span style="color: #000080;">If</span> mCapacity &amp;lt; slen <span style="color: #000080;">Then</span>
      mCapacity = slen
      mData.Size = mCapacity
   <span style="color: #000080;">End</span> <span style="color: #000080;">If</span> 
&nbsp;
   mData.StringValue(0, slen) = s
   mLength = slen
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span> 
&nbsp;
<span style="color: #000080;">Sub</span> AppendString(s <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>)
   <span style="color: #000080;">Dim</span> slen <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span> = LenB(s) 
&nbsp;
   <span style="color: #000080;">If</span> mCapacity &amp;lt; mLength + slen <span style="color: #000080;">Then</span>
      mCapacity = mLength + slen
      mData.Size = mCapacity
   <span style="color: #000080;">End</span> <span style="color: #000080;">If</span> 
&nbsp;
   mData.StringValue(mLength, slen) = s
   mLength = mLength + slen
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></pre></div></div>

<p>AppendString is similar to SetString but just adds the string onto the end. This is equivalent to &#8220;s = s + &#8230;&#8221;. The InsertString method below doesn&#8217;t have a direct equivalent to REALbasic&#8217;s String type because you have to use Mid or Left and Right with Strings to be able to insert text in the middle. So this not only speeds things up, but gives us extra functionality. That&#8217;s nice. :^)</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Sub</span> InsertString(location <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>, s <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>)
   <span style="color: #000080;">Dim</span> slen <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span> = LenB(s)
   <span style="color: #000080;">If</span> mCapacity &amp;lt; mLength + slen <span style="color: #000080;">Then</span>
      mCapacity = mLength + slen
      mData.Size = mCapacity
   <span style="color: #000080;">End</span> <span style="color: #000080;">If</span> 
&nbsp;
   // 0 based
   location = location - 1
   mData.StringValue(location + slen, mLength - location) = mData.StringValue(location, mLength - location)
   mData.StringValue(location, slen) = s
   mLength = mLength + slen
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></pre></div></div>

<p>For a simple test of the class, you can use this code:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Sub</span> Action()
   <span style="color: #000080;">dim</span> s <span style="color: #000080;">as</span> <span style="color: #000080;">String</span>
   <span style="color: #000080;">dim</span> cs <span style="color: #000080;">as</span> CapacityString
   <span style="color: #000080;">dim</span> bin <span style="color: #000080;">as</span> BinaryStream
   <span style="color: #000080;">dim</span> i, length <span style="color: #000080;">as</span> <span style="color: #000080;">Integer</span>
   <span style="color: #000080;">dim</span> time <span style="color: #000080;">as</span> <span style="color: #000080;">Double</span>
   <span style="color: #000080;">dim</span> file <span style="color: #000080;">as</span> FolderItem   file = GetOpenFolderItem(<span style="color: #800000;">&quot;&quot;</span>) 
&nbsp;
   <span style="color: #000080;">if</span> file = nil <span style="color: #000080;">then</span> return 
&nbsp;
   ///////////////////////
   // Using a <span style="color: #000080;">String</span>
   ///////////////////////
   time = Microseconds
   bin = File.OpenAsBinaryFile
   length = bin.Length 
&nbsp;
   <span style="color: #000080;">for</span> i = 1 <span style="color: #000080;">to</span> length <span style="color: #000080;">step</span> 2048
      s = s + bin.Read(2048)
   <span style="color: #000080;">next</span> 
&nbsp;
   time = (Microseconds - time) / 1000000
   MsgBox <span style="color: #800000;">&quot;String: &quot;</span> + Format(time, <span style="color: #800000;">&quot;###.##&quot;</span>) + <span style="color: #800000;">&quot; seconds&quot;</span>
   bin.<span style="color: #000080;">Close</span> 
&nbsp;
   ///////////////////////
   // Using a CapacityString
   ///////////////////////
   time = Microseconds
   bin = File.OpenAsBinaryFile
   length = bin.Length
   cs = <span style="color: #000080;">New</span> CapacityString(length) 
&nbsp;
   <span style="color: #000080;">for</span> i = 1 <span style="color: #000080;">to</span> length <span style="color: #000080;">step</span> 2048
      cs.AppendString bin.Read(2048)
   <span style="color: #000080;">next</span> 
&nbsp;
   time = (Microseconds - time) / 1000000
   MsgBox <span style="color: #800000;">&quot;CapacityString: &quot;</span> + Format(time, <span style="color: #800000;">&quot;###.##&quot;</span>) + <span style="color: #800000;">&quot; seconds&quot;</span>
   bin.<span style="color: #000080;">Close</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></pre></div></div>

<h4>Finished</h4>
<p>This isn&#8217;t a completely &#8220;finished&#8221; class as it doesn&#8217;t take every string posibility into account, but it&#8217;s a solid foundation for anyone wanting to take the idea even further.</p>
<p><a href="http://www.rbdevzone.com/wp-content/uploads/2007/10/capacitystringproject.zip" title="CapacityString project">Download CapacityString REALbasic project</a></p>
<p><em>Originally published by ResExcellence<br />
Reprinted with permission</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rbdevzone.com/2007/10/zing-with-capacitystring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Splitter Control</title>
		<link>http://www.rbdevzone.com/2007/10/splitter-control/</link>
		<comments>http://www.rbdevzone.com/2007/10/splitter-control/#comments</comments>
		<pubDate>Mon, 15 Oct 2007 14:34:26 +0000</pubDate>
		<dc:creator>Paul Lefebvre</dc:creator>
				<category><![CDATA[Controls]]></category>
		<category><![CDATA[ResExcellence]]></category>
		<category><![CDATA[Source Code]]></category>

		<guid isPermaLink="false">http://www.rbdevzone.com/2007/10/splitter-control/</guid>
		<description><![CDATA[by Seth Willits 
After much hard work and perspiration (not really)&#8230;&#8230;.. it&#8217;s done.

As I originally thought, this code will take forever to explain and I don&#8217;t think many of you will want to read it anyway. It works and that&#8217;s all you need to know, right?   If you have any questions about how [...]]]></description>
			<content:encoded><![CDATA[<p><em>by Seth Willits </em></p>
<p>After much hard work and perspiration (not really)&#8230;&#8230;.. it&#8217;s done.</p>
<p><a href="http://www.rbdevzone.com/wp-content/uploads/2007/10/splitviewwindow.jpg" title="Splitter Control"><img src="http://www.rbdevzone.com/wp-content/uploads/2007/10/splitviewwindow.thumbnail.jpg" alt="Splitter Control" /></a></p>
<p>As I originally thought, this code will take forever to explain and I don&#8217;t think many of you will want to read it anyway. It works and that&#8217;s all you need to know, right? <img src='http://www.rbdevzone.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  If you have any questions about how this works, just shoot me an email and I&#8217;ll be happy to answer it. Also, if you have any changes that make it not-as-ugly on Windows&#8230; I may look at those too.</p>
<p><a href="http://www.rbdevzone.com/wp-content/uploads/2007/10/splittercontrolproject.zip" title="Splitter Control project">Download Splitter Control REALbasic project</a></p>
<p><em>Originally published by ResExcellence<br />
Reprinted with permission</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rbdevzone.com/2007/10/splitter-control/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Alternating Color ListBox (like iTunes)</title>
		<link>http://www.rbdevzone.com/2007/10/alternating-color-listbox-like-itunes/</link>
		<comments>http://www.rbdevzone.com/2007/10/alternating-color-listbox-like-itunes/#comments</comments>
		<pubDate>Wed, 10 Oct 2007 14:32:57 +0000</pubDate>
		<dc:creator>Paul Lefebvre</dc:creator>
				<category><![CDATA[Controls]]></category>
		<category><![CDATA[ResExcellence]]></category>
		<category><![CDATA[User Interface]]></category>

		<guid isPermaLink="false">http://www.rbdevzone.com/2007/10/alternating-color-listbox-like-itunes/</guid>
		<description><![CDATA[by Bob Keeney
Many years ago, Erick Tejkowski posted a tutorial on alternating row colors to get the same style as an iTunes type listbox. The solution is simple, but yet many people still ask how to do it. We’ll step through the process on how to do this with REALbasic 2007.
Create the Class
Code reusability is [...]]]></description>
			<content:encoded><![CDATA[<p>by Bob Keeney</p>
<p>Many years ago, Erick Tejkowski posted a tutorial on alternating row colors to get the same style as an iTunes type listbox. The solution is simple, but yet many people still ask how to do it. We’ll step through the process on how to do this with REALbasic 2007.</p>
<h2>Create the Class</h2>
<p>Code reusability is a good thing. We’ll subclass the standard REALbasic listbox. Add a new class to your project and name it “ARListBox”. In the properties list set its super to “ListBox” so it can inherit all of the listbox events and properties.</p>
<p><a href="http://www.rbdevzone.com/?attachment_id=26" rel="attachment wp-att-26" title="Add Class to Project"><img src="http://capeumc.fatcow.com/wp-content/uploads/2007/10/addclass.thumbnail.jpg" alt="Add Class to Project" /></a></p>
<p>Edit the ARListbox code and add a property called “bAlternateRows as Boolean” and set it’s scope to Public. Find the CellBackgroundPaint event and add this code:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Function</span> CellBackgroundPaint(g <span style="color: #000080;">As</span> Graphics, row <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>, column <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Boolean</span>
<span style="color: #000080;">If</span> bAlternateRows <span style="color: #000080;">And</span> row <span style="color: #000080;">Mod</span> 2 = 0 <span style="color: #000080;">Then</span>
   g.ForeColor = RGB(237, 243, 254)
   g.FillRect(0, 0, g.Width, g.Height)
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

<p>The function is pretty straightforward but we’ll go through it line by line. The event is called by by REALbasic when it needs to draw the ListBox (as in a refresh event), you don’t have to do anything to get this to work. RB passes in the graphics object as well as the row and column of the cell in question.</p>
<p>If bAlternateRows is set to TRUE we take the row variable and use the MOD function to determine if the row is even or not. The MOD function is the same as saying, take the row, divide it by 2 and give me the remainder. If the remainder is zero, then do the painting.</p>
<p>When we want to make the row the alternate color we set the foreground of the graphics object to our alternate color. In this case, we’re using a hard coded color and you could easily substitute your own. Then we call the FillRect method of the graphics object and fill the entire graphics object starting at top, left (i.e. 0, 0) and filling the entire width and height of the graphics object.</p>
<h2>An Aside on the Event Handling</h2>
<p>Technically, we should return a True from this function if we’ve handled the DrawCellBackgroundPaint event so RB doesn’t try to do it twice. But since we haven’t created a new DrawCellBackgroundPaint event this isn’t an issue and RB doesn’t really care. If you ever want to override this functionality in the future, you would define a new event named exactly the same as the DrawCellBackgroundPaint (you could name it anything, but it helps using the same function name) with the same parameters and return value. To allow your instantiated class to override the behavior you then add this:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Function</span> CellBackgroundPaint(g <span style="color: #000080;">As</span> Graphics, row <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>, column <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Boolean</span>
//<span style="color: #000080;">Call</span> our <span style="color: #000080;">event</span> <span style="color: #000080;">and</span> see <span style="color: #000080;">if</span> the user has handled it
<span style="color: #000080;">If</span> CellBackgroundPaint(g, row, column) <span style="color: #000080;">Then</span> Return <span style="color: #000080;">True</span> 
&nbsp;
//<span style="color: #000080;">If</span> we haven’t handled it, this <span style="color: #000080;">is</span> the default behavior
<span style="color: #000080;">If</span> bAlternateRows <span style="color: #000080;">And</span> row <span style="color: #000080;">Mod</span> 2 = 0 <span style="color: #000080;">Then</span>
   g.ForeColor = RGB(237, 243, 254)
   g.FillRect(0, 0, g.Width, g.Height)
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span> 
&nbsp;
Return <span style="color: #000080;">True</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

<h2>Edit Property List Behavior</h2>
<p>Now that we’ve defined our class go back to the project tab and right click on the ARListBox class. Select Property List Behavior from the options. Once the dialog opens, scroll down the properties list and check the bAlternateRows checkbox and then click the OK button.</p>
<p>Once we’ve checked this option, our bAlternateRows variable may be set through the IDE instead of having to set it via code. This is simply a shortcut and could easily have been done via code in the open event or done using Computed Properties. One could argue that Computed Properties may be the best way to do this if you decide to change the color or toggle the bAlternateRows value at runtime. In our simple example this isn’t an issue.</p>
<p><a href="http://www.rbdevzone.com/2007/10/alternating-color-listbox-like-itunes/realbasic-group-on-linkedin/" rel="attachment wp-att-27" title="Property List Behavior"><img src="http://capeumc.fatcow.com/wp-content/uploads/2007/10/propertylistbehavior.jpg" alt="Property List Behavior" /></a></p>
<h2>Add the Control To a Window</h2>
<p>Now go to Window1 that was created for you when you created a new project. Choose “Project Controls” from the tools pallet and drag a new instance of ARListbox on to your window. Resize and change properties as necessary. In the Properties List you’ll see the bAlternatveRows property under the ‘behavior’ heading. Make sure it’s checked.</p>
<p>Go into the code editor and find the Open event of ARListbox1 (the default name of our new ARListbox object. In the open event use this code:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Sub</span> <span style="color: #000080;">Open</span>()
<span style="color: #000080;">Dim</span> i <span style="color: #000080;">As</span> <span style="color: #000080;">Integer</span>
<span style="color: #000080;">For</span> i = 1 <span style="color: #000080;">To</span> 15
   Me.AddRow <span style="color: #800000;">&quot;Row &quot;</span> + Str(i)
   Me.Cell(i - 1, 1) = <span style="color: #800000;">&quot;Cell (&quot;</span> + str(i) + <span style="color: #800000;">&quot;, 1)&quot;</span>
   Me.Cell(i - 1, 2) = <span style="color: #800000;">&quot;Cell (&quot;</span> + str(i) + <span style="color: #800000;">&quot;, 2)&quot;</span>
<span style="color: #000080;">Next</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></pre></div></div>

<p>This code simply gives us some sample data for our listbox to use. You can play around with the number of rows and the text in the cells, but the important point is that each even row in the listbox is colored!</p>
<h2>Conclusion</h2>
<p>With this sample project we’ve created a very simple and elegant variation of the standard listbox. It demonstrates how to subclass a control and some of the basics of events. Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.rbdevzone.com/2007/10/alternating-color-listbox-like-itunes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MessageDialog Sheet</title>
		<link>http://www.rbdevzone.com/2007/10/messagedialog-sheet/</link>
		<comments>http://www.rbdevzone.com/2007/10/messagedialog-sheet/#comments</comments>
		<pubDate>Wed, 10 Oct 2007 14:32:20 +0000</pubDate>
		<dc:creator>Paul Lefebvre</dc:creator>
				<category><![CDATA[ResExcellence]]></category>
		<category><![CDATA[User Interface]]></category>

		<guid isPermaLink="false">http://www.rbdevzone.com/2007/10/messagedialog-sheet/</guid>
		<description><![CDATA[by Seth Willits
The MessageDialog class is an important user interface element that if not done correctly, sticks out like a sore thumb on Mac OS X. Users expect a consistent message interface between applications, so it is critical that developers adopt and embrace the MessageDialog class as a part of becoming a good Mac OS [...]]]></description>
			<content:encoded><![CDATA[<p><em>by Seth Willits</em></p>
<p>The MessageDialog class is an important user interface element that if not done correctly, sticks out like a sore thumb on Mac OS X. Users expect a consistent message interface between applications, so it is critical that developers adopt and embrace the MessageDialog class as a part of becoming a good Mac OS X citizen.</p>
<h2>It&#8217;s a Sheet!</h2>
<p>This tutorial isn&#8217;t exactly the most indepth of them all. In the code below, you simply have a chunk which sets up a MessageDialog in the CancelClose event of a Window and displays it using ShowModalWithin.</p>
<p><a rel="attachment wp-att-24" href="http://www.rbdevzone.com/2007/10/messagedialog-sheet/messagedialog-sheet/" title="MessageDialog Sheet"><img src="http://www.rbdevzone.com/wp-content/uploads/2007/10/messagedialogsheet.png" alt="MessageDialog Sheet"></a></p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Function</span> CancelClose(appQuitting <span style="color: #000080;">As</span> <span style="color: #000080;">Boolean</span>) <span style="color: #000080;">As</span> <span style="color: #000080;">Boolean</span>
<span style="color: #000080;">Dim</span> dlog <span style="color: #000080;">As</span> MessageDialog
&nbsp;
// Create Dialog
dlog = <span style="color: #000080;">New</span> MessageDialog
dlog.Message = <span style="color: #800000;">&quot;Do you want to save the changes you made in the document &quot;</span><span style="color: #800000;">&quot;&quot;</span> + self.Title + <span style="color: #800000;">&quot;&quot;</span><span style="color: #800000;">&quot;?&quot;</span>
dlog.Explanation = <span style="color: #800000;">&quot;Your changes will be lost if you don't save them.&quot;</span>
dlog.ActionButton.Caption = <span style="color: #800000;">&quot;&amp;Save...&quot;</span>
dlog.CancelButton.Caption = <span style="color: #800000;">&quot;Cancel&quot;</span>
dlog.AlternateActionButton.Caption = <span style="color: #800000;">&quot;&amp;Don't Save&quot;</span>
dlog.ActionButton.Visible = <span style="color: #000080;">True</span>
dlog.CancelButton.Visible = <span style="color: #000080;">True</span>
dlog.AlternateActionButton.Visible = <span style="color: #000080;">True</span>
&nbsp;
// Show Dialog
<span style="color: #000080;">Select</span> <span style="color: #000080;">Case</span> dlog.ShowModalWithin(self).Caption
<span style="color: #000080;">Case</span> <span style="color: #800000;">&quot;&amp;Save...&quot;</span>
MsgBox <span style="color: #800000;">&quot;Pretend this is a save dialog...&quot;</span>
Return <span style="color: #000080;">False</span>
<span style="color: #000080;">Case</span> <span style="color: #800000;">&quot;&amp;Don't Save&quot;</span>
Return <span style="color: #000080;">False</span>
<span style="color: #000080;">Case</span> <span style="color: #800000;">&quot;Cancel&quot;</span>
Return <span style="color: #000080;">True</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">Select</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></div></div>

<h2>Finished</h2>
<p>What&#8217;s really nice about this class is that any cross-platform issues are already taken care of for you. If the ShowModalWithin method is used to create a sheet window in Mac OS X, the same code compiled for Windows and Linux has the dialos appear as a standalone window. In addition, the placement of the Save, Don&#8217;t Save, and Cancel buttons is different in Mac OS X than it is in Windows and Linux, but the MessageDialog class takes care of button placement as well.</p>
<p><a href="http://www.rbdevzone.com/wp-content/uploads/2007/10/messagedialogsheetsproject.zip" title="MessageDialogSheet project">Download MessageDialogSheet REALbasic project</a></p>
<p><em>Originally published by ResExcellence<br />
Reprinted with permission</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rbdevzone.com/2007/10/messagedialog-sheet/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Quartz Gradients</title>
		<link>http://www.rbdevzone.com/2007/09/quartz-gradients/</link>
		<comments>http://www.rbdevzone.com/2007/09/quartz-gradients/#comments</comments>
		<pubDate>Sat, 15 Sep 2007 14:31:02 +0000</pubDate>
		<dc:creator>Paul Lefebvre</dc:creator>
				<category><![CDATA[Controls]]></category>
		<category><![CDATA[ResExcellence]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[User Interface]]></category>

		<guid isPermaLink="false">http://www.rbdevzone.com/2007/09/quartz-gradients/</guid>
		<description><![CDATA[by Seth Willits
Continuing the article about drawing a simple rectangle with a Quartz shadow, in this article we take a look at axial gradients. The code for this is actually a major pain to explain (I admit I don&#8217;t know everything there is to know about it as well), so, sorry, but I&#8217;m going to [...]]]></description>
			<content:encoded><![CDATA[<p><em>by Seth Willits</em></p>
<p>Continuing the article about drawing a simple rectangle with a Quartz shadow, in this article we take a look at axial gradients. The code for this is actually a major pain to explain (I admit I don&#8217;t know everything there is to know about it as well), so, sorry, but I&#8217;m going to pull a &#8220;just look at the code if you want&#8221; here.</p>
<p>What I&#8217;ve done is add on an extension to the Graphics class which takes a bunch of parameters.</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Sub</span> DrawAxialGradient(Extends g <span style="color: #000080;">as</span> Graphics,
c <span style="color: #000080;">as</span> Canvas,
vertical <span style="color: #000080;">as</span> <span style="color: #000080;">Boolean</span>,
color1 <span style="color: #000080;">as</span> Color,
color2 <span style="color: #000080;">as</span> Color,
Left <span style="color: #000080;">as</span> <span style="color: #000080;">Integer</span>,
Top <span style="color: #000080;">as</span> <span style="color: #000080;">Integer</span>,
Width <span style="color: #000080;">as</span> <span style="color: #000080;">Integer</span>,
Height <span style="color: #000080;">as</span> <span style="color: #000080;">Integer</span>)</pre></div></div>

<p>The canvas parameter is actually optional, but you won&#8217;t be able to see why in the example project. Right now, because of the way Canvases are implemented it&#8217;s a pain in the butt to deal with because the context you&#8217;re drawing into is actually the window&#8217;s. That is, a Canvas isn&#8217;t a &#8220;real&#8221; control, it&#8217;s just an abstract way to look at a certain rectangle in the window. That&#8217;s a problem because if you&#8217;re trying to draw into a canvas, you need to know about the window the canvas is in so you can translate the coordinates and clip appropriately. If you&#8217;re not drawing in canvas, you pass in nil and it should just do the right thing.</p>
<p>The vertical boolean parameter specifies if the axial shading is vertical or horizontal (there&#8217;s no start point and end point definition in this implementation, it&#8217;s a bit hardcoded). Color1 and Color2 are the two (not, not three or more in this implementation), and the next four parameters are the bounds of the gradient.</p>
<p>It&#8217;s relatively limiting (better than what RB has!), but that&#8217;s mostly because to do everything you can in Quartz, you really have to do it all yourself, or I&#8217;d really have to spend more time to abstract it out and provide a few different methods and ways of doing things. Have look around the code and you should see why it&#8217;d actually be a little tricky.</p>
<p><a href="http://www.rbdevzone.com/wp-content/uploads/2007/10/quartz_gradients.zip" title="Quartz Gradients REALbasic project">Download Quartz Gradients REALbasic project</a></p>
<p><em>Originally published by ResExcellence<br />
Reprinted with permission<br />
</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rbdevzone.com/2007/09/quartz-gradients/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wiggle Window</title>
		<link>http://www.rbdevzone.com/2007/09/wiggle-window/</link>
		<comments>http://www.rbdevzone.com/2007/09/wiggle-window/#comments</comments>
		<pubDate>Thu, 13 Sep 2007 14:30:22 +0000</pubDate>
		<dc:creator>Paul Lefebvre</dc:creator>
				<category><![CDATA[ResExcellence]]></category>
		<category><![CDATA[Source Code]]></category>
		<category><![CDATA[User Interface]]></category>

		<guid isPermaLink="false">http://www.rbdevzone.com/2007/09/wiggle-window/</guid>
		<description><![CDATA[by Erick Tejkowski
Should you accidentally enter the wrong password while logging onto an OS X machine, you&#8217;ll notice that the login window wiggles back and forth a few times. In fact, it looks like the login window is shaking its head &#8220;NO!&#8221; at you. This week we&#8217;ll look at how to implement this functionality with [...]]]></description>
			<content:encoded><![CDATA[<p><em>by Erick Tejkowski</em></p>
<p>Should you accidentally enter the wrong password while logging onto an OS X machine, you&#8217;ll notice that the login window wiggles back and forth a few times. In fact, it looks like the login window is shaking its head &#8220;NO!&#8221; at you. This week we&#8217;ll look at how to implement this functionality with REALbasic. It turns out that it&#8217;s very simple to accomplish, so let&#8217;s get started.</p>
<h2>Build the Interface</h2>
<p>Launch REALbasic and open the default Window1. To this window, add a PushButton and a Timer. Set the Mode property of the Timer to 0 (zero). You can arrange the window however you wish.<br />
Add the Code<br />
Open the Code Editor for Window1 and add two properties to the window:</p>
<ul>
<li>OrigX As Integer</li>
<li>Wiggle As Integer</li>
</ul>
<p>Next, enter this code in the Action event of PushButton1:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;">Wiggle = 0
OrigX = Self.Left
Timer1.Period = 30
Timer1.Mode = 2</pre></div></div>

<p>Finally, add this code to the Action event of Timer1:</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">If</span> Wiggle &amp;gt; 5 <span style="color: #000080;">Then</span>
   Me.Mode = 0
   Self.Left = OrigX
<span style="color: #000080;">Else</span>
   <span style="color: #000080;">If</span> (Wiggle <span style="color: #000080;">Mod</span> 2) = 0 <span style="color: #000080;">Then</span>
      Self.Left = OrigX - 20
   <span style="color: #000080;">Else</span>
      Self.Left = OrigX + 20
   <span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
   Wiggle = Wiggle + 1
<span style="color: #000080;">End</span> <span style="color: #000080;">If</span></pre></div></div>

<p>By clicking the PushButton, you reset some variables that keep track of the position of the window as well as the number of wiggles. Then, the timer starts firing. As the timer fires, it increases the wiggle counter and alternates the position of the window between its two positions. Once the counter exceeds 5, the timer stops. Simple, eh?</p>
<h2>Conclusion</h2>
<p>That&#8217;s all there is to it.</p>
<p><a href="http://www.rbdevzone.com/wp-content/uploads/2007/10/wigglewindow.zip" title="Wiggle Window REALbasic project">Download Wiggle Window REALbasic project</a></p>
<p><em>Originally published by ResExcellence<br />
Reprinted with permission</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.rbdevzone.com/2007/09/wiggle-window/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
