The custom class NSToolbarBadgedItem provides the ability to display small amount of text in the bottom right corner surrounded by a colored oval. This small badge could used to indicate that user has X messages or flag that there is a user action required.
The current implementation is not perfect, I had trouble getting the text into the correct position within the oval. I tried to center the text horazontally and vertical using a combination of the bounding NSRect of the Glyph and the overall bounding NSRect of the full text. This calculation could probably be improved by using the NSFont's capHeight, descender, ascender.
Setup In Inteface Builder
You can do this using Interface Builder's 'User Defined Runtime Attributes', this lets you store custom data within the nib file and have it loaded / applied to your constucted class. This is possable because the class is Key-value coding complient which provides a mechanism for indirectly accessing / setting an objects attributes. If you would like to know more check out Apple's article about Key-value coding.
It is possable to observe these changes within xcode if you place a break point in your init function where the values have yet to be applied and then within the awakeFromNib function which is called after the nib changes have been applied the class.
The current class inteface lets you set the following values via Interface Builder:
|badgeValue||The Value displied in the badge, if null or empty the entire badge will not be displayed.|
|badgeFontName||Font to use to render the text.|
|badgeTextColor||Color to render the text.|
|badgeTextShadowColor||Shadow Color of the text, if null or the alpha is zero the shadow is not rendered.|
|badgeLineColor||Color of the line round the oval, it is also used to blend into the gradiant fill.|
|badgeFillColor||Color of the main oval.|
|badgeShadowColor||Shadow Color of the oval, if null or the alpha is zero the shadow is not rendered.|
This is a custom alert panel that permits the use of NSAttribuedString to display html or rich text content within an alerts message or information display block.
I have tried to keep a similar interface to the origional NSAlert class to make it easy to intigrate the class into a project, it is still missing a chunk of functionality that comes out of the box with the standard Alert.
The custom alert panel came about due to my frustration with trying to alter the existing panel post layout to include an NSTextView that would contain the rich text content, I did ended up with a working solution. But altering the postion of the Accessory View after the content was layed out felt kind of a brittle solution and could break if the NSAlert layout changed, also the code looked like the a massive hack. So the only solution I came to was to roll my own Alter Panel.
#import <Cocoa/Cocoa.h> @interface NSAttributedAlert : NSPanel - (id) init; - (NSImage*) icon; - (void) setIcon:(NSImage*)image; - (NSArray*) buttons; - (void) addButtonWithTitle:(NSString*)title; - (void) setMessageText:(NSString*)text; - (void) setMessageText:(NSString*)text containsHtml:(BOOL)state; - (void) setMessageAttributedText:(NSAttributedString*)text; - (void) setInformativeText:(NSString*)text; - (void) setInformativeText:(NSString*)text containsHtml:(BOOL)state; - (void) setInformativeAttributedText:(NSAttributedString*)text; - (void)setAccessoryView:(NSView *)view; - (NSView *)accessoryView; - (void) layout; - (NSInteger) runModal; - (void)beginSheetModalForWindow:(NSWindow *)window modalDelegate:(id)modalDelegate didEndSelector:(SEL)alertDidEndSelector contextInfo:(void *)contextInfo; @end
Several years ago when I started working with the iOS platform there were no good 2d render engines avaliable and like most developers each project was built with just the bare minimum of what was need to get the project done. After a couple project each using there own set of tech (open GL, UIKit) I decided to create a small and light weight 2d render engine that I could use in multiple projects. Electric2D is the result of that effort.
As the project has sat idle and there are a number of years and I always had the intention of open sourcing the project at some point. I have decide to release the project, please feel to use it for reference but I would suggest that there are some much nicer and well maintained projects out there that would be better suited for your own projects. I have been using cocos2d / cocos2d-x for the last while for work and my personal projects as well as Unity3D.
The render was built using Open GL 1.1 as I had no need to support shaders at the time, the project does include a nice bash script for creating a SDK. This was to make it very easy to integrate into a project by just including it in the project settings, it also removed the need to compile the lib all the time and let me keep the project separate from my game projects. This script is run using a target and does a command line build of the project. It will also package up the result into dmg if my memory serves me.
Where's the old content?
Unfortunately the server I was hosting the original blog on was hacked, this resulted in the entire machine being formatted and a fresh OS installed. Luckily enough I still have a lot of the content in a sql file and I will try to resurrect some of the post that are still relevant.
Though this may take some time.
I finally got round to writing a small Python script to parse the old content. It’s now up but the links and images are broken, the content may not be as relevant as it once was.
I started a blog several years ago, it was mostly about my life as a programmer and it gave me a place to post code and my own thoughts. This is the second attempt at getting back into it so please do wish me luck :)
The question that I ask my self is why has it taken so long to get start posting content again?
The truth of the matter my heart and head were not ready. A lot has happened over the past couple years and I felt lost for a long time. I just needed time to get back my head back and so I choice to hide away for a while. I am not one to talk about my personal life and I'm not going to start now sorry.
Suffice to say I'm still alive and kicking :)