Simple cocoa calculator - cocoa

I'm in the process of teaching myself basic cocoa application development and so I'm stepping up to the classic "calculator" project.
What I was wondering is this: to create the actual calculator interface would it be best to just add 4 rows of 4 NSButton controls and edit them to have the label/functionality I want or is there a more efficient way to create the layout?
I know this is a basic application but following OS X rules I want my code to be as efficient as possible so I want to make sure I'm doing it right.
Thanks for any help guys.

There's really nothing wrong with creating 4x4 buttons and you'll have the most flexibility with this approach. The most efficient way though would be to use an NSMatrix. To create a matrix of buttons in Interface Builder, create one button (your prototype), then select Layout->Embed Objects in->Matrix from the menu. When you now select the matrix, you can specify 4 rows and 4 columns in the Attributes tab of the inspector window.

Related

File browser-like element in Mac OS programming of Xcode

Sorry that my title is not clear enough. What I wanted to ask is based on a screen capture:
I want to make an app like this. But there are two elements I do not know what the classes are: A and B (C and D are NSSplitView. I just knew).
Could any one just tell me what ducuments to follow to create UIs like the appearance of A and B? Thank you!
Create A UI in NSOutlineView is the way to display hierarchical data that can be expanded and collapsed, such as directories and files in a file system.
B is made by Gradient buttons set images to gradient buttons to get B UI
or
Use NSToolBar to use formal ui design.

Are hierarchies possible inside a Cocoa popup menu?

I was just wondering if it is possible to create a drop down or popup menu with a hierarchy? The application I am currently working on tracks Assignments, Courses, and Subjects. When the user creates an Assignment they will need to be able to select a Course that it belongs to from a drop down but I also wan't the drop down to be organized a little bit by having headers so the user can easily see what Subject that Course belongs to.
Example:
Select Course: [drop down below]
- Life
--Chores
--Eating
--Vacations
- Math
--Algebra
--Calculus
Etc...
Not the best example but the entries "Life" and "Math" would be bold and unselectable and all of the others would be regular menu items. Does anyone have any suggestions? Let me know if you need more information on what I am trying to do.
Yes, if you build them manually in code or in Interface Builder. No, if you're using Bindings.
NSPopUpButton takes an NSMenu full of NSMenuItems.

looking for (N) steps GUI kind of thing

i dont sure if this question is for this group but i don't know where to ask
im looking for GUI examples that gives the user for example make X in 4 steps
kind of GUI especial for none teachi folks
Do you mean like a Dialog Wizard type interface?
The idea of a wizard is you have a single window where you can step through a number of frames containing different selections using a next button and a back button to go back and change selections? Sometimes you have a finish button to use the default selections on the remaining frames.
What language and GUI toolkit are you using???

Is there a simple way to combine a text and icon in an NSCell in Cocoa?

I'm trying to create a very simple selection list widget based on NSOutlineView. However, I'm having a hard time figuring out how to display an icon and a label right next to it, which is really the expected behavior in all the mainstream implementations of that kind of widget out there (iTunes, mail, Finder,...).
So far I am just binding two separate cells, but then when I'm expanding the tree, the icon cell grows larger and a gap appears between the icon and its accompanying label. I know I can probably overcome this problem by extending NSCell and provide a custom class, but as what I'm trying to achieve is really the standard thing, I can't be resigned to accept that there isn't a simpler solution.
Candide
Sadly, there isn't a 'text and icon' cell that you can just use, fresh out of the box as you would like. However, when I was working on a project, I found that Apple released some sample code that implements this, since it is such a common idiom.
This can be found here, specifically ImageAndTextCell.h/m
It can help teach you about UI customization by reading through this example, but scratching that, just dropping the ImageAndTextCell straight into your project should do just fine.
You need to create ImageAndTextcell to combine text and icon..
you can create ImageAndTextcell like this Sample Project

Implementing "scrubby sliders" in Cocoa?

How would I go about implementing something along the lines of "scrubby sliders", like in Photoshop and quite a few other image-processing applications?
They are slightly hard to describe.. basically you have a regular numeric input-box, but you can click-and-hold the mouse button, and it functions like a slider (until you release). If you click in the box, you can select text, edit/paste/etc as usual.
The Photoshop docs describe it, and I put together a quick example video (an example of the sliders in Shake)
Another similar implementation would be the jog-wheel in Final Cut Pro, which functions similarly, without the numeric readout being underneath.
I can't seem to find any mention of implementing these, although there is probably alternative names for this. It is for a OS X 10.5 Cocoa application.
It is for a colour-grading application, where a user might need to make tiny adjustments (0.001, for example), to huge adjustments (say, -100 +100) on the same control. A regular slider isn't accurate enough over that range of value.
Copy-and-pasting values into the box would be a secondary concern to scrubbing the values, and the Photoshop/Shake setup really well. The unobviousness of the control is also of a low concern, as it's not a "regular desktop application"
I've encountered those. They suck, because they prevent the user from dragging to select the text of the number.
A better idea would be a miniature slider beneath the field that expands to a full-size slider when the user holds down the mouse button on it and collapses back to its miniature size when the user releases the mouse button. This way, the selection behavior is still available, but you also provide the slider—and in a more obvious way.
There's no built-in class in Cocoa for either one. You'll have to implement your own.
I doubt that this exists in Cocoa framework. As far as I remember it is not mentioned in the Apple Human Interface Guidelines.
You can develop one yourself by using a custom view and tracking mouse events (-mouseDown:, mouseUp:, -mouseDragged:).

Resources