Build a Custom Sheet in Cocoa

blog — Tags: , , , , , — anon @ 10/03 7:51 pm

What is a sheet? Well, Cocoa introduced several new GUI elements like drawers that aren’t used by too many applications right now. They are used nicely, however, in Mail to house your mailboxes and in OmniWeb to store your bookmarks.

One of the elements that are available to Mac developers are called “sheets”. In particular, sheets are those things that slide out of the title bar of a window. In fact, a sheet is just a NSPanel that is being attached to the application window at runtime. You can see a sheet in action when actually opening or saving a file.

What is the difference between a sheet that slides out and a modal window that pops up? Well, there are some serious considerations. You may also want to check out this tutorial by Erik. J. Barzeski on CocoaDevCentral which I used as a informational and textual base for this post. There you can find a little bit more about modal windows which I don’t want to explain right here in depth.

In short, sheets are a very stylish way to let the user know that a certain action needs to be done or that there is something wrong and that need to be fixed.

(more…)

Hacking Cocoa: Method Swizzling

blog — Tags: , , , , , , , — anon @ 10/03 5:47 pm

From cocoadev.com:

The Objective-C runtime lets you modify the mappings from a selector (method name) to an implementation (the method code itself). This allows you to “patch” methods in code you don’t have the source to (AppKit, FoundationKit, etc).

Unlike creating a category method with the same name as the original method (effectively replacing the original method), MethodSwizzling lets your replacement method make use of the original method, almost like subclassing.

This is best used in cases where a single method needs substitution or extension but if you need to modify many behaviors of a class, you may be better off using ClassPosing.

But I found this article way more informative and that, in turn, led my way to the SIMBL Framework which I can greatly recommend.

After thinking about this a couple of minutes you’ll also find a huge amount of possibilities and hack-arounds. But seriously, there are some things to consider like this.

To make it short, Kevin Ballards code did fail in the 10.5 Mac OS X release and had to be rewritten. In fact, many code had to be rewritten which somehow led to JRSwizzle, a very good implementation that runs under Leopard and Snow Leopard.

So either using SIMBL or MethodSwizzling (JRSwizzle in particular) does the trick. It’s absolutely obvious to be very careful when swizzling methods or creating plugins via SIMBL – but the possibilities appear very clear and vast to me.

Another great possibility to hack around with Cocoa is F-Script by Philippe Mougin and F-ScriptAnywhere by Ken Ferry. Two very essential tools when hacking just for fun or seriously developing Cocoa applications.

Using identity tranform on XML nodes

blog — Tags: , , — anon @ 09/12 12:11 pm

Recently I needed to expose all the child nodes of a root node in a XML file. Not as trivial as I first thought. I was looking for a smart way to do this for some identically structured XML files. I ended up with some XSLT code that uses identity transformation to do what I need.

The following is a simplified sample of what I have.

<rootnode>
    <childnode>
        ...
    </childnode>
</rootnode>

And this is how I would like it to be.

<childnode>
    ...
</childnode>

The resulting code is very simple and easy to understand if you know the very basics of XSLT. There are different approaches that lead to slightly different code but the result is the same.

(more…)

SVN: Scheduled repository dumps

blog — Tags: , , , , — anon @ 09/11 3:53 am

yuki requested a post on how to backup my SVN repositories. Well, here you are :)

Dumping repositories with the help of Scheduled Tasks under Windows or the Cron Daemon under Linux isn’t as complicated as you might think. Of course there are caveats, and regular things that you have to take an eye on, but in the end you’ll have an reliable solution that fit your needs.

(more…)

WPF: Double-click event handlers

blog — Tags: , , — anon @ 09/02 1:51 pm

How do I add a double-click event to a ListView/GridView control? In fact, adding such a double-click event handler to a certain control is a simple task.

An event handler is simply a method (function) that receives the input from a device such as a mouse or keyboard and does something with it. Like its name implies, it handles events – more specifically, input events.

(more…)

WPF: Using value converters

blog — Tags: , , — anon @ 09/02 8:33 pm

The data binding infrastructure of the WPF is extremely flexible. One of the major contributors to that flexibility is the fact that a custom value converter can be injected between two bound objects (i.e. the data source and target). A value converter can be thought of as a black box into which a value is passed, and another value is emitted.

(more…)

How to Customize the Wordpress Tag Cloud

blog — Tags: , , , — anon @ 09/01 4:02 pm

If you’re like me you might also want to change the default settings that the Wordpress Tag Cloud use. Normally this would be done in the sidebar.php that lives inside your theme folder, but in my case – I use the Widget Editor – I don’t have any control over the Tag Cloud. So I decided to hack the Wordpress core no matter what others are saying about that. Of course, I have to mention that changes getting reverted after you update.

For this you need to modify the wp_tag_cloud function in the category-template.php file. It’s remarkably easy to do. Here’s how.

  1. Open the file /wp-includes/category-template.php
  2. Search for the line that begins with function wp_tag_cloud
  3. Make changes in the array as follows:
    • To specify the smallest font size, set the value after ’smallest’. The default is 8 points
    • To specify the largest font size, set the value after ‘largest’. The default size is 22 points
    • To specify the maximum number of tags included in the cloud, set the value after ‘number’. The default number of tags is 45
  4. Overwrite the existing file with the changed file

Easy, huh? This is considered as a hack. So don’t blame me if something happens to your Wordpress install or if suddenly everything blows up completely.

SVN: How to create and apply patches

blog — Tags: , , , , — anon @ 08/12 10:25 pm

In my opinion Subversion is a great tool and by now essential in a development process. In the company where I am working at, Subversion is used only by a small number of developers who are committing their work regularly. Everybody knows who is working on which part of the project. But having an increasing number of contributors (OpenSource projects for example) traditional repository usage can be a pain in the ass. This is where patches come in to hand.

What is a patch? A patch is a text file that contains the alteration that were made to a specific file. It includes the lines that have been removed, added or modified. In short, if you have a script and edited it, you could create a patch file containing the changes you’ve made.

What’s the point of this? For example, if you want to contribute code changes to a project where you don’t have write access to it you would post your patch file to a ticket system or such. Someone will then review your changes before actually committing them.

(more…)

Windows Vista UAC

blog — Tags: , , — anon @ 08/12 3:53 pm

Well, while working with Windows Vista on my company laptop I always get the UAC dialog. When first “touching” Vista I never thought that I’ll ever getting used to it. But in fact if you’re working up to 10 hours a day with it you’re definitely get somehow used to it.

But just using it is not the same than developing applications that make use of it! Anyway I was not suprised that I quickly found lots of articles that let you disable the UAC feature in Vista.

This may be suitable for users but NOT for developers. We’re still have to mess around with UAC and the whole technology behind that.

A real good source of information is The Moth. Daniel Moth is a former MVP that now works at Microsoft. He collected a lot of useful information in his blog that can help you understand UAC.

When developing an application that uses a certain kind of functionality that requires administrative privileges you’ll have to decide if you want to elevate the whole application or if you want to refactor that functionality by cutting it off from the main application and to externalize it in a seperate process. In this case you’ll need some extra coding in your software.

(more…)

C#: Creating a Windows Service

blog — Tags: , , — anon @ 1:00 am

Some time ago I wondered if it is possible to build a Windows service from scratch using Visual Studio 2008. I started with a Console Application and added basic service functionality by hand. I found a lot of search results when trying to find something useful on the net but I came up with my own implementation.

The following article will cover what you need to do to convert a Console Application into a Windows Service and install it. I used Visual Studio 2008, but it should also work with older Editions like VS 2003 & VS 2005.

(more…)

Next Page »
copyright © 2008-2010 datenkompost.de/blog - barecity derivative | imprint
* a title remix inspired by a popular german book