Solipsism Gradient

Rainer Brockerhoff’s blog

Browsing Posts published in March, 2004

This will take some explaining, and may not make much sense unless you’re a Cocoa developer. So feel free to skip this.

In early February – about a month and a half ago – someone asked an obscure question on the developer lists and, by chance, I had a code sample that did almost exactly what that guy wanted. So I sent it to him. So far so good… warm fuzzy feelings all around…

…it turned out that this gave me an idea for a new contextual menu for the Finder. So I thought, the new CM will be just that code sample with some padding, so let me start first on the application to configure stuff for the CM. Shouldn’t take more than a week or two.

As usual, I started out by designing the application icon first, which sidetracked me into a long investigation about the habits and aspect of a certain mammal. That done, I decided the user interface should consist only of a list of items. Fixed-size items each consisting of a few icons and a name. Of course, the first choice was using a NSTableView.

It turns out that the icons were too dissimilarly sized, so a table with one row per item showed too few items, and the UI looked ugly. So my next idea was to use a NSMatrix of cells, each cell with the subitems artfully arranged. This looked better, but…

I soon noticed that a NSMatrix operates with rows and columns of cells (duh!). I wanted a view that adapted itself to the window size the user wanted, but having to scroll both horizontally and vertically was ugly as soon as there were more than a dozen items. So I messed around for a couple of days with adapting the number of columns to the window width, and couldn’t get it to work reliably.

So I decided that I wanted something like iPhoto’s browser window, where there’s only a vertical scrollbar, and the view adapts instantly to width variations. So I started to write a custom view that would be inserted into a NSScrollView and do automatic layout of as many items fit into the current width.

After a week of this it was almost working… however, I was getting some strange behavior in certain conditions; when the window was resized very rapidly, or when the scroller had to appear during insertions, or, and so forth. It appeared that I wasn’t managing the communications between the NSScrollView and my own view correctly under all circumstances.

So I was trying to trace when NSTextViews communicate with their NSScrollViews, when it hit me that I could simply use a NSTextView and insert the item as specialized NSTextAttachmentCells. Bliss! This would give me all the required scrolling and resizing behavior automatically, and I would just have to write the specialized cell code and disable some of the NSTextView’s functions… it wouldn’t do to allow the user to insert actual text there, for instance.

There I went off into another two-week-long detour of writing and debugging the cell code. My cells consist of several subentities which are actually NSViews themselves – images and text – and they in turn have to be editable, selectable, and so forth. I’ll leave the saga of how I finally solved this for another post – it involves adding a subview to the NSTextView, something not normally done.

So after that I had to decide which text behaviors I wanted to leave in the NSTextView. No editing, OK. Selecting multiple items with the text cursor? Hmm… it looked interesting. The user could select several items and drag them somewhere! Perhaps for backing up the items into a Finder window – or to make a list of his items into a text windows. I happily set to work implementing routines for copying and dragging the current selection in various formats, which in turned allowed me to exercise my code under unforeseen conditions and decide how the items would be stored and saved.

Then when it was nearly finished I started to run into snags again. Suddenly I wanted to select two non-adjacent items, which NSTextView doesn’t allow. I changed my system-wide selection color (for a non-related reason) and suddenly selections in my NSTextView began to look ugly – worse, the way selections were made called the user’s attention to the fact that this was a NSTextView with much reduced functionality. This is never a good idea; it leads the user to expect certain things to work, and when they won’t work, it’s a negative experience.

So today I disabled all text selections wholesale, as well as all related functionality. This enabled me to throw out several chunks of code and someday might allow me to implement discontinuous item selections, too. So the NSTextView really just handles reflowing of my item list, and all the remaining functionality is shuffled off into my specialized NSTextAttachmentCell class.

So far so good; I expected to finally freeze my UI and get to work on the shareware related aspects – registration, trial expiration, and so forth. However, I still have to extirpate the final clue that I’m using a text view, namely the I-beam (text insertion) cursor. So far I’ve hammered away at this for the whole day without finding a solution that works all of the time.

As usual. 😥

Stay tuned…

Good example

No comments

Scoble linked to this great story about how JetBlue‘s CEO now and then works as a flight attendant on his own airline:

…Beginning in the first row, he slowly made his way through the plane, stopping to chat with anyone who cared to talk to him, answering every question people asked. I was sitting in the 11th row, and it took him more than an hour to reach me. “Nice airline you have here,” I said. “Where do you come up with all these great ideas – like the televisions?”

“I get most of my ideas on flights like this one,” Neeleman said. “The customers tell me what they want.”

“Oh, listening to your customers,” I said. “What a novel idea!”

Well worth a read. If all CEOs did something similar to keep in touch with their own customers, the world would be a better place…


No comments

The J-Walk Blog spreads the word regarding the dangers of Dihydrogen monoxide, an odorless, tasteless chemical that can be fatal when inhaled.

…Although the U.S. Government and the Centers for Disease Control (CDC) do not classify Dihydrogen Monoxide as a toxic or carcinogenic substance (as it does with better known chemicals such as hydrochloric acid and saccharine), DHMO is a constituent of many known toxic substances, diseases and disease-causing agents, environmental hazards and can even be lethal to humans in quantities as small as a thimbleful…

This lethal chemical should be banned forthwith! City officials in Aliso Viejo (CA) nearly banned foam cups after learning that DMHO was involved in their manufacture.

The Presurfer (hey, no permalinks!) steered me to Robert Delaney’s Cross-cultural comparisons, by way of Mark Rosenfelder‘s American Culture page. There are links to dozens of other culture descriptions. Here’s a sample from the description for Brazil:

  • You drive on the right side of the road. You stop at red lights if someone is around; otherwise you slow down. If you’re a pedestrian and cars are anywhere around, you better watch out carefully before crossing the street.
  • You think of Argentina as a pleasant country with two cities: charming, cosmopolitan Buenos Aires, and beautiful Bariloche (where the Brazilian ski championship takes place). You think Argentinians as a people are arrogant and conceited, but you often like individual Argentinians.
  • When you were younger, you considered the Volkswagen Beetle a dream car.
  • The police are armed, sometimes with submachine guns. You are afraid all police are violent and crooked, but at the same time you would rather have them around.

If you’re interested in cultural differences, this is fascinating reading. If I find the time, I may write some comments for the Brazil page.

While I’m being nibbled to death (or at least to distraction) by lots of little incidental unrelated-to-each-other problems and racing to finish my new application, the nice folks at Boing Boing side-tracked me to what may be the best lab report ever: Electron Band Structure In Germanium, My Ass:

…The upshot is that if you heat up a sample of germanium, electrons will jump from a non-conductive energy band to a conductive one, thereby creating a measurable change in resistivity. This relation between temperature and resistivity can be shown to be exponential in certain temperature regimes by waving your hands and chanting “to first order”.

…Now, let’s look a bit more closely at this data, remembering that it is absolutely first-rate. Do you see the exponential dependence? I sure don’t. I see a bunch of crap.

Christ, this was such a waste of my time.

Banking on my hopes that whoever grades this will just look at the pictures, I drew an exponential through my noise. I believe the apparent legitimacy is enhanced by the fact that I used a complicated computer program to make the fit. I understand this is the same process by which the top quark was discovered…

The report is by Lucas Kovar, who also says:

I have recently removed my old stuff in the interest of not looking like a twit.


Zen Tech Support

No comments

Hold everything, you must read this: Make me one with everything:

…Margret then tried Steve’s problem. “Computer crashes every day sometime between noon and 1PM, but never the exact same time.”

“Lunching colleagues use coffeepot in adjacent room. When heating element turns off, a minor electrical surge induces a magnetic field in the extension cord Steve has wrapped around the steel leg of his desk next to the computer. The solution is to unwind the cord.”

The omniscient Indian friend on the other end of the phone line placidly answered all of Margret’s questions, until she came to the last. This one had been given to her by Adam, who taught computer science at the local university. His problem wasn’t a technical support issue, really, but during the flow of the dinnertime conversation it seemed a funny thing to add to a list of ponderables; what if you gave them a problem you knew was impossible to solve? Adam had reassured Margret that this one was the worst of the bunch, unsolved since 1936 when it was invented by one of the earliest of all computer scientists, and mathematically proven to be unsolvable…

Thanks to Derek Woolverton for the link…

Re: Orkutlery

No comments

In a recent post, I said:
Rainer Brockerhoff wrote:

…I recommend the Spherical Object Collectors community, created by my friend (in several senses) Mario AV, which already pointed me at this fascinating page about Hikaru Dorodango, or Japanese shiny mud balls.

Now I read at Jonathan Peterson’s that there’s a more up-to-date article available; it even has videos of each step of the process of making a dorodango!


No comments

Rio Grande do Sul is the southernmost state in Brazil. It was settled in the 1800s by Italian and German immigrants, and the effects of that are still very much in evidence today. Gramado, where we’ve stayed over the Carnaval weekend, is a small town with 28,000 people that now lives mostly from tourism and hosts a famous South American film festival.

In most other parts of Brazil you can expect a town this size to barely have paved streets. In contrast, Gramado has dozens of first-class hotels, broadband Internet everywhere, upscale boutiques and many well-kept tourist attractions. It feels much like a prosperous tourist town in, say, Southern Germany.

Except for the sun and the tropical plants, this photo of an apartment building looks very European. Here’s a shot of the downtown shopping district:

The tree on the left is a “Paraná Pine” (Araucaria Angustifolia), the local variety of pine. I’ve seen much larger ones in the nearby parks. The fellow walking towards me is clad in the common clothes of the rural gaúcho (pronounced gah-OOsho or, by the locals, gah-OOtsho).

A well-known gaúcho specialty is the chimarrão, the local variety of mate tea. It’s traditionally drunk in a special cup made from a gourd and with a metal straw that has a disk-shaped strainer at the end. Here’s the chimarrão set our bus driver carried around with him:

Once the gourd is properly set up and packed, it’s replenished periodically with hot water from the thermos bottle. It’s very tasty and invigorating. Since it has high caffeine content it ought to be useful for programming…

Photos licensed by Creative Commons license. Unless otherwise noted, content © 2002-2021 by Rainer Brockerhoff. Iravan child theme by Rainer Brockerhoff, based on Arjuna-X, a WordPress Theme by SRS Solutions. jQuery UI based on Aristo.