Feeds

New vistas with windows frames

Open your mind

Remote control for virtualized desktops

Mac Secrets Time to look at the mysterious 'borderView' object, used by the Cocoa libraries to render a window to the screen. Although you'll not often need the specialised facilities provided by the border view, they can be very useful when creating certain kinds of application.

Here's a little experiment you can try. In xCode, create a new, windowed Cocoa application and then add a subclass of NSWindow. You can call this subclass anything you like, but I called mine MyAppWindow. Now go into Interface Builder and change the class of the application window to match. Finally, go into MyAppWindow.m, add an awakeFromNib method, and put the following code inside it:

 

NSLog ([[self _borderView] className]);

When you build the application, the compiler will whinge that the window might not respond to the _borderView selector. If you want to shut the compiler up, check out how I do it by downloading the sample application, at the end. When you run the app, you should see the string NSThemeFrame displayed on the Console. So, what is the border view, and why should you care?

Cocoa programmers are generally only concerned with the content area of a window, and ordinarily, this is the only part of the window they have direct control over. However, the minimize, maximize and close buttons, together with the whole title-bar area are also part of the window, as are the bottom left- and right-hand corners.

All this stuff is handled by a specialised hierarchy of NSView descendents, of which NSThemeFrame is the most commonly encountered. The undocumented _borderView selector returns an instance of this class, which is referred to as a border view or frame view.

Work with handlers

So what can we do with it? If you look at the methods associated with NSThemeFrame, you'll see a couple called setIsClosable: and setIsResizable:. As the name suggests, you can use these methods to control whether or not the window shows a close button, or can be resized. To show this functionality, I added a couple of checkboxes to this month's demo program at the end, and hooked them up to these action handlers:

 

- (IBAction) toggleClosable: (id) sender
{
        [[self _borderView] setIsClosable: [sender state]];
}

- (IBAction) toggleSizable: (id) sender
{
        [[self _borderView] setIsResizable: [sender state]];
}

Ordinarily, you control whether a window can be closed or resized when creating the window, but in exceptional circumstances, you might want to programmatically change these attributes on the fly. (Hint: think of the Karelia Media Browser, and how the window "flips" over. You might want one side of your window to be resizable, and the other not).

Accessing these frame view methods makes this dead easy.

Beginner's guide to SSL certificates

More from The Register

next story
Be real, Apple: In-app goodie grab games AREN'T FREE – EU
Cupertino stands down after Euro legal threats
Download alert: Nearly ALL top 100 Android, iOS paid apps hacked
Attack of the Clones? Yeah, but much, much scarier – report
You stupid BRICK! PCs running Avast AV can't handle Windows fixes
Fix issued, fingers pointed, forums in flames
Microsoft: Your Linux Docker containers are now OURS to command
New tool lets admins wrangle Linux apps from Windows
Bada-Bing! Mozilla flips Firefox to YAHOO! for search
Microsoft system will be the default for browser in US until 2020
Facebook, working on Facebook at Work, works on Facebook. At Work
You don't want your cat or drunk pics at the office
Soz, web devs: Google snatches its Wallet off the table
Killing off web service in 3 months... but app-happy bonkers are fine
prev story

Whitepapers

Choosing cloud Backup services
Demystify how you can address your data protection needs in your small- to medium-sized business and select the best online backup service to meet your needs.
Getting started with customer-focused identity management
Learn why identity is a fundamental requirement to digital growth, and how without it there is no way to identify and engage customers in a meaningful way.
10 threats to successful enterprise endpoint backup
10 threats to a successful backup including issues with BYOD, slow backups and ineffective security.
Reg Reader Research: SaaS based Email and Office Productivity Tools
Read this Reg reader report which provides advice and guidance for SMBs towards the use of SaaS based email and Office productivity tools.
The hidden costs of self-signed SSL certificates
Exploring the true TCO for self-signed SSL certificates, including a side-by-side comparison of a self-signed architecture versus working with a third-party SSL vendor.