How to mimic Finder left tree in cocoa app? - user-interface

I really like a look of left tree in Finder (Mac OS X >= 10.5). That with a blue background color and "DEVICES" and "PLACES" dropdowns. I'd like category view in my app to look the same. But since I'm new to Mac OS X app development, I can't figure out if it's just a OutlineView? If so is there a predefined color scheme like in finder?

It's a source list. See the source list section of the Human Interface Guidelines
To make one in IB, you add a vertical split view with a thin divider. Into the left pane you put an outline view and set the highlight style to "source list". That will automatically give you the correct background colour.

Related

Add NSTitlebarAccessoryViewController to the left of the titlebar/toolbar

I have implemented a unified titlebar/toolbar and now would like to add two buttons to the bar. They need to be located at the far left, just right of the stoplight buttons. I'm creating a toolbar that's very similar to System Preferences.
I have looked at the API for adding NSTitlebarAccessoryViewController and the only valid properties for layoutAttribute are NSLayoutAttributeRight (adds the view to the far right of the toolbar) and NSLayoutAttributeBottom which essentially places the view underneath the unified toolbar in its own toolbar.
I want neither of those options, so how would one add a bunch of buttons to the very left of the unified toolbar?
It is actually a lot easier to archive this:
Just add a toolbar to your window using the Interface Builder and set the title visibility to hidden:
[window setTitleVisibility:NSWindowTitleHidden];
This is now possible in OS X 10.11. Quoting from the header file:
For applications linked on Mac OS 10.11 or later, NSLayoutAttributeLeft is also supported; placing the item on the left side of the window (adjacent and to the right of the close/minimize/maximize buttons).
You can use WAYAppStoreWindow on GitHub to do this. I created a fork of the WAYWindow subproject to vertically centre the document title since this wasn't supported.

How to create this element on OS X?

I find that I can't find this element on the XIB. How can I create this thing on OS X? Thanks.
That's a bottom bar with a label (text field) control in it. In IB, select the window, then select the Size inspector (⌘-⌥-5). There, you will find a Content Border pop-up menu. Select either Small or Large Bottom Border. Then, drag a label control into the border area. Then use the normal techniques to set the content of the label. For static content, you can just edit it in IB. Otherwise, you can use bindings to do it or set up an outlet and set it programmatically.
Are you talking about NSPathControl, which does exist in Interface Builder:
And here's an Apple sample project that might help you out.

How do I get Mac Toolbar Items that look like the standard toolbar buttons?

I'm working on some updates to my first Mac app and I'm trying to get my window's toolbar buttons to look like the toolbar buttons on EVERY standard Mac app. However, for the life of me, I can't find a button type or a barbutton type that gets me what I'm looking for. Am I missing something?
Here is an image showing several Mac apps (Preview, Finder, and Safari) with toolbars at the top which have very-slighty rounded corner buttons which also have a slight gradient on them, etc.
However, in my .xib I've got a toolbar and I've dropped every kind of button I can find on the thing and nothing looks like the standard Mac button.
The first button looks pretty close, but it's clearly not the same color. Am I missing something?
#Matt Ball is right - you can use NSSegmentedControls, even for single one-time click buttons. Just set the number of segments to 1, and set the mode to "Select None".
One of my shipping apps uses this technique, see below:
All of the controls there are NSSegmentedControl, including the single one.
Update: there are a few standard button icons which are meant for toolbars. The NSImage Class Reference has a list.
In the above screenshot, only two of the buttons are using built-in images: NSLeftFacingTriangleTemplate, and NSRightFacingTriangleTemplate. The others I drew myself.

Adding a search bar in main menu

I am using mac os with objective C and XCode.My recent task is to add a search bar in main menu of mac desktop programatically.Could u please suggest me how to proceed with.Thanks
To do this most easily, you require Mac OS X 10.5 or later.
The idea of a single menu bar is an illusion; it is a combination of two things: one that switches with the current application (a list of menus implemented by NSMenu, NSMenuItem, etc.), and one that doesn't change: the system's status bar (NSStatusBar).
If I understand correctly you want to call [NSStatusBar systemStatusBar] to obtain the main status bar (little icons in the corner of the screen) and add something to it, such as an icon that pops a menu.
You can use NSStatusItem to define something for this bar (e.g. to display a menu when clicked) and in your NSMenu definition you can add a view using setView: (this is the part that requires Mac OS X 10.5). The view can be anything, including a search bar.

Is there any thing like a NSBottomBar?

Okay of course i checked the API and there is nothing - at least under this class name.
What i mean is the widget referred to as a bottom bar in the Apple Human Interface Guidline.
Do i have to draw this myself from a NSView, if so how do i get the texture drawn?
alt text http://developer.apple.com/mac/library/documentation/UserExperience/Conceptual/AppleHIGuidelines/art/wn_newwindowparts.jpg
P.S.: I added Toolbar to the tags because it is the closest generic keyword i can find and the bottom bar ist just the opposite as a toolbar.
You're looking for the "content border." This is something you need to set in code with Leopard, but you can set it in Interface Builder in Snow Leopard (note you must be targeting 10.6 or above in order for this to be a valid setting in Interface Builder).
You can conveniently set a large or small border (using the standard Apple-approved sizes). To set this, select your window in Interface Builder, then show the Size inspector. At the bottom of the panel, you'll find the Content Border settings.
Brandin Walkin's excellent BWToolkit (BSD license) provides support for UI in the content border (among many other nice UI elements) and makes using a "bottom bar" much more enjoyable.

Resources